### Install ghost-datatype-support-lib Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Install the library via npm. It can be consumed as a standard ESM/CJS package. ```bash npm install ghost-datatype-support-lib ``` -------------------------------- ### myPackage Function Example Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/functions/myPackage.html Demonstrates how to use the myPackage function with a string argument. This function returns a greeting string. ```typescript myPackage('Hello'); // 'Hello from my package' ``` -------------------------------- ### myPackage Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/functions/myPackage.html An example helper function exported from the package. It takes an optional string and returns a greeting string. ```APIDOC ## Function: myPackage ### Description An example helper exported from the package. It returns a greeting string that includes the provided `taco` value. ### Parameters #### Parameters - **taco** (string) - Optional - A string to include in the returned message. Defaults to an empty string. ### Returns - **string** - A greeting string including the provided `taco` value. ### Example ```javascript myPackage('Hello'); // 'Hello from my package' myPackage(); // ' from my package' ``` ``` -------------------------------- ### Use Generic String Helper `myPackage` Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Use this function for a basic smoke-test to confirm the package is installed and importable. It accepts an optional string and returns a greeting. ```typescript import { myPackage } from 'ghost-datatype-support-lib'; // Basic usage const result = myPackage('Hello'); console.log(result); // "Hello from my package" // Called with no argument (uses default empty string) const defaultResult = myPackage(); console.log(defaultResult); // " from my package" ``` -------------------------------- ### myPackage(input) Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt A simple utility function that accepts an optional string input and returns a greeting message combining the input with the phrase "from my package". Useful as a minimal smoke-test export confirming the package is correctly installed and importable. ```APIDOC ## `myPackage(input)` — Generic string helper A simple utility function that accepts an optional string input and returns a greeting message combining the input with the phrase "from my package". Useful as a minimal smoke-test export confirming the package is correctly installed and importable. ### Usage ```ts import { myPackage } from 'ghost-datatype-support-lib'; // Basic usage const result = myPackage('Hello'); console.log(result); // "Hello from my package" // Called with no argument (uses default empty string) const defaultResult = myPackage(); console.log(defaultResult); // " from my package" ``` ``` -------------------------------- ### Import named exports from ghost-datatype-support-lib Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Import specific functionalities like ArdriveExport, ArdriveExportRow, or myPackage directly after installation. ```typescript import { ArdriveExport, ArdriveExportRow, myPackage } from "ghost-datatype-support-lib"; ``` -------------------------------- ### Clone Repository Template Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/README.md Use this command to clone the repository template and set up a new Node.js module with TypeScript. Ensure you replace placeholder values with your project's specific details. ```bash curl -fsSL https://github.com/peterclemenko/ghost-datatype-support-lib/archive/main.tar.gz | tar -xz --strip-components=1 ``` ```bash FULL_NAME="John Smith" GITHUB_USER="johnsmith" REPO_NAME="my-cool-package" sed -i.mybak "s/ lyou can use the following commands to manage your package: - **build**: `tsc --project tsconfig.build.json` — Compile TypeScript sources into the `lib/` output directory and generate type declarations. - **clean**: `rm -rf ./lib/` — Remove previous build artifacts. - **cm**: `cz` — Run Commitizen for guided commit messages. - **lint**: `eslint ./src/ --fix` — Run ESLint on `src/` and auto-fix problems where possible. - **lint:ci**: `eslint ./src --max-warnings 0` — CI-safe lint run that fails on warnings. - **docs**: `typedoc --options typedoc.json` — Generate TypeDoc documentation into `docs/typedoc`. - **prepare**: `husky install` — Husky install hook (runs automatically during install). - **semantic-release**: `semantic-release` — Run semantic-release to publish changelogs and releases. - **test:watch**: `jest --watch` — Run Jest in watch mode. - **test**: `jest --coverage` — Run Jest with coverage output. - **test:mocha**: `mocha -r ts-node/register "test/**/*.mocha.spec.ts" --recursive` — Run Mocha tests written with TypeScript (ts-node). - **test:lint**: `npm run lint:ci` — Alias to the CI lint command. - **typecheck**: `tsc --noEmit` — Run TypeScript type checking without emitting files. ``` -------------------------------- ### myPackage Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/README.md A function that processes an input string and returns a modified string. It accepts an optional options object for further customization. ```APIDOC ## myPackage(input, options?) ### Description Processes an input string and returns a modified string. It accepts an optional options object for further customization. ### Parameters #### input Type: `string` Description: Lorem ipsum. #### options Type: `object` Description: Optional configuration object. ``` -------------------------------- ### ArdriveExport Constructor Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/classes/ArdriveExport.html Initializes a new instance of the ArdriveExport class. ```APIDOC ## constructor * `new ArdriveExport()` ### Description Initializes a new instance of the ArdriveExport class. ### Returns * `ArdriveExport` - A new instance of the ArdriveExport class. ``` -------------------------------- ### Read and Parse CSV File from Disk Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Use the asynchronous `fromFile` method to read a CSV file from the filesystem and parse its content into `ArdriveExportRow` objects. It supports custom file encodings and wraps `parseCSV`, inheriting its parsing logic and tolerances. ```typescript import { ArdriveExport, ArdriveExportRow } from 'ghost-datatype-support-lib'; import path from 'path'; async function processExport(filePath: string): Promise { try { const rows: ArdriveExportRow[] = await ArdriveExport.fromFile(filePath); console.log(`Parsed ${rows.length} file(s) from export`); for (const row of rows) { console.log(`[${row.status.toUpperCase()}] ${row.fileName} (${row.fileSize ?? 'unknown'} bytes)`); console.log(` Download: ${row.directDownloadLink}`); } } catch (err) { console.error('Failed to parse export:', err); } } // Usage processExport(path.join(__dirname, 'testfiles', 'ardrive-export.csv')); // Expected output: // Parsed 2 file(s) from export // [PENDING] New Text Document (2).txt (10 bytes) // Download: https://ardrive.net/7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o // [PENDING] New Text Document.txt (9 bytes) // Download: https://ardrive.net/-7GFEnCxfs098bNn5XpKfQpzJ2CCT-vlJ0AbOStchn0 // Custom encoding example const latin1Rows = await ArdriveExport.fromFile('./export-latin1.csv', 'latin1'); ``` -------------------------------- ### ArdriveExport.fromFile Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Asynchronously reads a CSV file from the specified path and parses its content into an array of ArdriveExportRow objects. Supports custom file encodings. ```APIDOC ## ArdriveExport.fromFile(path, encoding?) ### Description An async static method that reads a CSV file from the filesystem and returns its parsed rows as `ArdriveExportRow[]`. Defaults to UTF-8 encoding. Wraps `ArdriveExport.parseCSV` after reading the file, so all the same tolerance rules apply. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **path** (string) - Required - The file path to the CSV file. * **encoding** (string) - Optional - The encoding of the file (e.g., 'utf-8', 'latin1'). Defaults to 'utf-8'. ### Request Example ```ts import { ArdriveExport, ArdriveExportRow } from 'ghost-datatype-support-lib'; import path from 'path'; async function processExport(filePath: string): Promise { try { const rows: ArdriveExportRow[] = await ArdriveExport.fromFile(filePath); console.log(`Parsed ${rows.length} file(s) from export`); for (const row of rows) { console.log(`[${row.status.toUpperCase()}] ${row.fileName} (${row.fileSize ?? 'unknown'} bytes)`); console.log(` Download: ${row.directDownloadLink}`); } } catch (err) { console.error('Failed to parse export:', err); } } // Usage processExport(path.join(__dirname, 'testfiles', 'ardrive-export.csv')); // Custom encoding example const latin1Rows = await ArdriveExport.fromFile('./export-latin1.csv', 'latin1'); ``` ### Response #### Success Response (200) * **ArdriveExportRow[]** - A promise that resolves to an array of ArdriveExportRow objects representing the parsed CSV data from the file. ``` -------------------------------- ### ArdriveExport.fromFile Method Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/classes/ArdriveExport.html Reads CSV data from a specified file path and parses it into rows. ```APIDOC ## fromFile * `fromFile(path: string, encoding?: string)` ### Description Read CSV from disk and parse into rows. ### Parameters #### Path Parameters * **path** (string) - Required - File system path to CSV * **encoding** (string) - Optional - File encoding (defaults to 'utf8') ### Returns * `Promise` - A promise that resolves to an array of ArdriveExportRow objects. ``` -------------------------------- ### ArdriveExport.HEADER Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt A static string array containing the expected column names for the Ardrive export CSV schema. ```APIDOC ## ArdriveExport.HEADER ### Description A static string array listing the 11 expected column names for the Ardrive export CSV schema. Useful for validating or regenerating export headers programmatically without hardcoding magic strings in calling code. ### Parameters None ### Request Example ```ts import { ArdriveExport } from 'ghost-datatype-support-lib'; console.log(ArdriveExport.HEADER); // [ // 'File Id', // 'File Name', // 'Parent Folder ID', // 'Parent Folder Name', // 'Data Transaction ID', // 'Metadata Transaction ID', // 'File Size', // 'Date Created', // 'Last Modified', // 'Direct Download Link', // 'Status' // ] // Validate that an incoming CSV header matches the expected schema function validateHeader(firstLine: string): boolean { const cols = firstLine.split(',').map(c => c.trim()); return ArdriveExport.HEADER.every((expected, i) => cols[i] === expected); } ``` ### Response #### Success Response (200) * **string[]** - An array of strings representing the CSV header. ``` -------------------------------- ### ArdriveExport.HEADER Property Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/classes/ArdriveExport.html The expected header columns for the CSV, used for informational purposes. ```APIDOC ## HEADER * `HEADER: string[]` ### Description Expected header columns for the CSV (informational). ### Type `string[]` ``` -------------------------------- ### Access Ardrive Export CSV Header Definitions Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt The static `HEADER` property provides an array of the expected column names for Ardrive export CSV files. This is useful for validating incoming CSV headers or programmatically generating headers. ```typescript import { ArdriveExport } from 'ghost-datatype-support-lib'; console.log(ArdriveExport.HEADER); // [ // 'File Id', // 'File Name', // 'Parent Folder ID', // 'Parent Folder Name', // 'Data Transaction ID', // 'Metadata Transaction ID', // 'File Size', // 'Date Created', // 'Last Modified', // 'Direct Download Link', // 'Status' // ] // Validate that an incoming CSV header matches the expected schema function validateHeader(firstLine: string): boolean { const cols = firstLine.split(',').map(c => c.trim()); return ArdriveExport.HEADER.every((expected, i) => cols[i] === expected); } ``` -------------------------------- ### ArdriveExport.parseCSV Method Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/classes/ArdriveExport.html Parses raw CSV text into rows that conform to the ArdriveExportRow type. ```APIDOC ## parseCSV * `parseCSV(csvText: string)` ### Description Parse CSV text into rows that conform to `ArdriveExportRow`. * Tolerant of missing columns (pads with empty strings) * Preserves fields with embedded newlines inside quotes ### Parameters #### Path Parameters * **csvText** (string) - Required - Raw CSV text ### Returns * `ArdriveExportRow[]` - An array of ArdriveExportRow objects. ``` -------------------------------- ### ArdriveExportRow Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt A TypeScript type describing a single parsed row from an Ardrive export CSV file. All fields are strongly typed, with nullable fields (`fileSize`, `dateCreated`, `lastModified`) returning `null` when the source value is absent or unparseable. ```APIDOC ## `ArdriveExportRow` — Typed row interface A TypeScript type describing a single parsed row from an Ardrive export CSV file. All fields are strongly typed, with nullable fields (`fileSize`, `dateCreated`, `lastModified`) returning `null` when the source value is absent or unparseable. ### Interface Definition ```ts import { ArdriveExportRow } from 'ghost-datatype-support-lib'; // Shape of every parsed row const exampleRow: ArdriveExportRow = { fileId: '39a551f7-ec03-4b02-afb4-71f32eb22cf8', fileName: 'New Text Document (2).txt', parentFolderId: '2c319f72-2aa7-49d3-a8a3-047d09bc59a2', parentFolderName: 'export-test', dataTransactionId: '7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o', metadataTransactionId: 'qxF0611nmzxgoYmb8ex4wEzlEKIk_N5UVRRc4bRKqKY', fileSize: 10, // null if missing or non-numeric dateCreated: '2026-04-28T08:50:42.000Z', // null if unparseable lastModified: '2026-04-28T08:50:15.000Z', // null if unparseable directDownloadLink: 'https://ardrive.net/7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o', status: 'pending', }; ``` ``` -------------------------------- ### Define `ArdriveExportRow` Interface Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt This TypeScript interface defines the shape of a single parsed row from an Ardrive export CSV file. Nullable fields return null if the source value is absent or unparseable. ```typescript import { ArdriveExportRow } from 'ghost-datatype-support-lib'; // Shape of every parsed row const exampleRow: ArdriveExportRow = { fileId: '39a551f7-ec03-4b02-afb4-71f32eb22cf8', fileName: 'New Text Document (2).txt', parentFolderId: '2c319f72-2aa7-49d3-a8a3-047d09bc59a2', parentFolderName: 'export-test', dataTransactionId: '7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o', metadataTransactionId: 'qxF0611nmzxgoYmb8ex4wEzlEKIk_N5UVRRc4bRKqKY', fileSize: 10, // null if missing or non-numeric dateCreated: '2026-04-28T08:50:42.000Z', // null if unparseable lastModified: '2026-04-28T08:50:15.000Z', // null if unparseable directDownloadLink: 'https://ardrive.net/7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o', status: 'pending', }; ``` -------------------------------- ### Parse CSV String to ArdriveExportRow Objects Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Use `parseCSV` to convert raw CSV text into an array of `ArdriveExportRow` objects. It handles quoted fields, escaped quotes, and missing values, returning null for unparseable numeric or date fields. Skips the header row automatically. ```typescript import { ArdriveExport } from 'ghost-datatype-support-lib'; const csvText = `File Id,File Name,Parent Folder ID,Parent Folder Name,Data Transaction ID,Metadata Transaction ID,File Size,Date Created,Last Modified,Direct Download Link,Status 39a551f7-ec03-4b02-afb4-71f32eb22cf8,New Text Document (2).txt,2c319f72-2aa7-49d3-a8a3-047d09bc59a2,export-test,7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o,qxF0611nmzxgoYmb8ex4wEzlEKIk_N5UVRRc4bRKqKY,10,2026-04-28 08:50:42.000,2026-04-28 08:50:15.000,https://ardrive.net/7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o,pending 4ca1c067-33b1-423b-a0e9-39a35f551f37,New Text Document.txt,2c319f72-2aa7-49d3-a8a3-047d09bc59a2,export-test,-7GFEnCxfs098bNn5XpKfQpzJ2CCT-vlJ0AbOStchn0,ie8Ji4wxHTyaS9H2EIPtpkO77lMQ7XUH8oWMbrM6t3g,9,2026-04-28 08:50:42.000,2026-04-28 08:50:10.000,https://ardrive.net/-7GFEnCxfs098bNn5XpKfQpzJ2CCT-vlJ0AbOStchn0,pending`; const rows = ArdriveExport.parseCSV(csvText); console.log(rows.length); // 2 const first = rows[0]; console.log(first.fileId); // "39a551f7-ec03-4b02-afb4-71f32eb22cf8" console.log(first.fileName); // "New Text Document (2).txt" console.log(first.fileSize); // 10 console.log(first.dateCreated); // "2026-04-28T08:50:42.000Z" console.log(first.directDownloadLink); // "https://ardrive.net/7yb4bnn8keLA7-..." console.log(first.status); // "pending" // Rows with missing optional fields are safely handled const sparseCSV = `File Id,File Name,Parent Folder ID,Parent Folder Name,Data Transaction ID,Metadata Transaction ID,File Size,Date Created,Last Modified,Direct Download Link,Status abc-123,file.txt,,,txid,,NOT_A_NUMBER,NOT_A_DATE,,https://example.com,`; const [sparse] = ArdriveExport.parseCSV(sparseCSV); console.log(sparse.fileSize); // null (non-numeric → null) console.log(sparse.dateCreated); // null (unparseable date → null) ``` -------------------------------- ### ArdriveExport.parseCSV Source: https://context7.com/peterclemenko/ghost-datatype-support-lib/llms.txt Parses raw CSV text into an array of ArdriveExportRow objects. It handles quoted fields, escaped quotes, and automatically skips the header row. Returns an empty array for invalid or empty input. ```APIDOC ## ArdriveExport.parseCSV(csvText) ### Description A static method that accepts raw CSV text and returns an array of `ArdriveExportRow` objects. It tolerates quoted fields with embedded commas or newlines, handles `""` escaped quotes, pads short rows with empty strings, and skips the header row automatically. Returns an empty array for blank or header-only input. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **csvText** (string) - Required - The raw CSV text to parse. ### Request Example ```ts import { ArdriveExport } from 'ghost-datatype-support-lib'; const csvText = `File Id,File Name,Parent Folder ID,Parent Folder Name,Data Transaction ID,Metadata Transaction ID,File Size,Date Created,Last Modified,Direct Download Link,Status 39a551f7-ec03-4b02-afb4-71f32eb22cf8,New Text Document (2).txt,2c319f72-2aa7-49d3-a8a3-047d09bc59a2,export-test,7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o,qxF0611nmzxgoYmb8ex4wEzlEKIk_N5UVRRc4bRKqKY,10,2026-04-28 08:50:42.000,2026-04-28 08:50:15.000,https://ardrive.net/7yb4bnn8keLA7-0LWW02yyoJ61Krkuttx39FEp74E9o,pending 4ca1c067-33b1-423b-a0e9-39a35f551f37,New Text Document.txt,2c319f72-2aa7-49d3-a8a3-047d09bc59a2,export-test,-7GFEnCxfs098bNn5XpKfQpzJ2CCT-vlJ0AbOStchn0,ie8Ji4wxHTyaS9H2EIPtpkO77lMQ7XUH8oWMbrM6t3g,9,2026-04-28 08:50:42.000,2026-04-28 08:50:10.000,https://ardrive.net/-7GFEnCxfs098bNn5XpKfQpzJ2CCT-vlJ0AbOStchn0,pending`; const rows = ArdriveExport.parseCSV(csvText); console.log(rows.length); // 2 const first = rows[0]; console.log(first.fileId); // "39a551f7-ec03-4b02-afb4-71f32eb22cf8" console.log(first.fileName); // "New Text Document (2).txt" console.log(first.fileSize); // 10 console.log(first.dateCreated); // "2026-04-28T08:50:42.000Z" console.log(first.directDownloadLink); // "https://ardrive.net/7yb4bnn8keLA7-..." console.log(first.status); // "pending" // Rows with missing optional fields are safely handled const sparseCSV = `File Id,File Name,Parent Folder ID,Parent Folder Name,Data Transaction ID,Metadata Transaction ID,File Size,Date Created,Last Modified,Direct Download Link,Status abc-123,file.txt,,,txid,,NOT_A_NUMBER,NOT_A_DATE,,https://example.com,`; const [sparse] = ArdriveExport.parseCSV(sparseCSV); console.log(sparse.fileSize); // null (non-numeric → null) console.log(sparse.dateCreated); // null (unparseable date → null) ``` ### Response #### Success Response (200) * **ArdriveExportRow[]** - An array of ArdriveExportRow objects representing the parsed CSV data. ``` -------------------------------- ### ArdriveExportRow Type Definition Source: https://github.com/peterclemenko/ghost-datatype-support-lib/blob/main/docs/typedoc/types/ArdriveExportRow.html This snippet shows the structure of the ArdriveExportRow type, which represents a record from an Ardrive export CSV. It includes fields like dataTransactionId, dateCreated, directDownloadLink, fileId, fileName, fileSize, lastModified, metadataTransactionId, parentFolderId, parentFolderName, and status. ```APIDOC ## Type alias ArdriveExportRow ### Description Row record for an Ardrive export CSV line. ### Type Declaration ```typescript ArdriveExportRow: { dataTransactionId: string; dateCreated: string | null; directDownloadLink: string; fileId: string; fileName: string; fileSize: number | null; lastModified: string | null; metadataTransactionId: string; parentFolderId: string; parentFolderName: string; status: string; } ``` ### Fields * **dataTransactionId** (string) - Data transaction id * **dateCreated** (string | null) - Date created as ISO string when parseable, otherwise null * **directDownloadLink** (string) - Direct download link * **fileId** (string) - File Id (UUID or identifier) * **fileName** (string) - Original file name * **fileSize** (number | null) - File size in bytes when available, otherwise null * **lastModified** (string | null) - Last modified as ISO string when parseable, otherwise null * **metadataTransactionId** (string) - Metadata transaction id * **parentFolderId** (string) - Parent folder id * **parentFolderName** (string) - Parent folder name * **status** (string) - Status string from the CSV ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.