/** * TransformPipeline — Composable row transformation engine. * * Allows chaining multiple transform functions into a pipeline. * Each transform is applied in order. If any transform returns null, * the row is filtered out and subsequent transforms are skipped. * * @example * ```typescript * const pipeline = new TransformPipeline() * .pipe((row) => row.status === 'inactive' ? null : row) // filter * .pipe((row) => ({ ...row, age: parseInt(row.age, 10) })) // type coerce * .pipe(async (row) => { // async enrich * const geo = await geocode(row.address); * return { ...row, lat: geo.lat, lng: geo.lng }; * }); * * for await (const batch of csvSuperPro('data.csv', { * licenseKey: key, * transform: pipeline.toFn(), * })) { * await db.insert(batch.rows); * } * ``` */ import type { CsvRow, TransformFn, BatchResult } from '../types/index.js'; export declare class TransformPipeline { private readonly steps; /** * Add a transform step to the pipeline. * Returns `this` for method chaining. * * @param fn Transform function: row → modified row | null (filtered) */ pipe(fn: TransformFn): this; /** * Export the pipeline as a single TransformFn. * This is what you pass to `csvSuperPro({ transform: pipeline.toFn() })`. */ toFn(): TransformFn; /** * Apply the pipeline to an entire batch. * Rows transformed to null are removed from the result. * * @returns New BatchResult with transformed rows. */ applyToBatch(batch: BatchResult): Promise; /** * Apply the pipeline to an array of rows (without BatchResult wrapping). */ applyToRows(rows: CsvRow[]): Promise; /** Number of transform steps in the pipeline. */ get size(): number; /** Check if the pipeline has any transforms. */ get isEmpty(): boolean; /** * Add a filter step that removes rows where `predicate` returns false. */ filter(predicate: (row: CsvRow) => boolean | Promise): this; /** * Add a field selection step (keep only specified columns). * * @example `.select(['name', 'email', 'age'])` */ select(columns: string[]): this; /** * Add a field rename step. * * @example `.rename({ 'old_name': 'newName', 'email_addr': 'email' })` */ rename(mapping: Record): this; /** * Add a field transformation step for specific columns. * * @example `.mapField('age', (v) => String(parseInt(v, 10)))` */ mapField(column: string, fn: (value: string) => string | Promise): this; /** * Add a field trimming step (removes leading/trailing whitespace from all values). */ trim(): this; } //# sourceMappingURL=transform-pipeline.d.ts.map