From b6f8c33ee6fa4b930322cdecf8e67304ae413891 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Thu, 10 Jul 2025 21:49:00 -0700 Subject: [PATCH] Re-export all types in `index.js` Currently, the types are accessible internally in the library and within `index.js`, but NOT accessible from consumers importing from the `index.js` file. A re-export is required to make the types accessible to end-users. Additionally, the JSDoc import will only work for types declared at the module scope, so `CSVWriterStatus` was moved to the outer scope. --- src/core.js | 20 ++++++++++---------- src/index.js | 12 ++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/core.js b/src/core.js index 9594899..7d98291 100644 --- a/src/core.js +++ b/src/core.js @@ -474,6 +474,16 @@ export class CSVTransformer extends TransformStream { } } +/** + * @typedef CSVWriterStatus The current status of the CSVWriter. + * @property {string} name The name of the output CSV file that this writer is writing to. + * @property {number} elapsed The number of milliseconds that have elapsed between this writer's creation and the output CSV file + * handle closing, or until now if the writer is still writing. Measured using `performance.now()`. + * @property {number} rows The estimated number of CSV rows that have been written. If the data passed to the writer is + * a string, the string is counted as one CSV row (i.e., raw string data is NOT parsed again). Includes the header row (first row). + * @property {boolean} done If `true`, the writer is finished writing to the output CSV file and the file handle is closed. + */ + /** * Write a streamed CSV file to disk. * @@ -532,16 +542,6 @@ export class CSVWriter extends WritableStream { this.#status = status; } - /** - * @typedef CSVWriterStatus The current status of the CSVWriter. - * @property {string} name The name of the output CSV file that this writer is writing to. - * @property {number} elapsed The number of milliseconds that have elapsed between this writer's creation and the output CSV file - * handle closing, or until now if the writer is still writing. Measured using `performance.now()`. - * @property {number} rows The estimated number of CSV rows that have been written. If the data passed to the writer is - * a string, the string is counted as one CSV row (i.e., raw string data is NOT parsed again). Includes the header row (first row). - * @property {boolean} done If `true`, the writer is finished writing to the output CSV file and the file handle is closed. - */ - /** @type {CSVWriterStatus} */ get status() { if (!this.#status.done) { diff --git a/src/index.js b/src/index.js index 0e82f90..98edabd 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,15 @@ export { CSVReader, CSVTransformer, CSVWriter } from './core.js'; export { CSVNormalizer, CSVDenormalizer } from './normalization.js'; export { ErrorStrategies } from './errorStrategies.js'; + +/** @typedef {import('./core.js').CSVReaderOptions} CSVReaderOptions */ +/** @typedef {import('./core.js').TransformationOutput} TransformationOutput */ +/** @typedef {import('./core.js').CSVTransformerOptions} CSVTransformerOptions */ +/** @typedef {import('./core.js').CSVTransformerOptionsRaw} CSVTransformerOptionsRaw */ +/** @typedef {import('./core.js').CSVTransformerOptionsBatch} CSVTransformerOptionsBatch */ +/** @typedef {import('./core.js').CSVWriterStatus} CSVWriterStatus */ +/** @typedef {import('./normalization.js').CSVNormalizerHeader} CSVNormalizerHeader */ +/** @typedef {import('./normalization.js').CSVNormalizerOptions} CSVNormalizerOptions */ +/** @typedef {import('./normalization.js').CSVNormalizerRow} CSVNormalizerRow */ +/** @typedef {import('./errorStrategies.js').RetryOptions} RetryOptions */ +/** @typedef {import('./errorStrategies.js').BackoffOptions} BackoffOptions */ -- 2.47.3