@konstit/csv 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -26
- package/THIRD_PARTY_NOTICES.md +7 -1
- package/dist/api.d.ts +39 -249
- package/dist/api.js +40 -304
- package/dist/batches.d.ts +5 -53
- package/dist/batches.js +66 -43
- package/dist/cli-command.d.ts +7 -0
- package/dist/cli-command.js +350 -0
- package/dist/cli-schema.d.ts +111 -0
- package/dist/cli-schema.js +219 -0
- package/dist/cli.js +2 -604
- package/dist/file-stream.d.ts +57 -2
- package/dist/file-stream.js +241 -36
- package/dist/files.d.ts +11 -11
- package/dist/files.js +11 -9
- package/dist/filter.d.ts +4 -6
- package/dist/format-bytes.d.ts +1 -0
- package/dist/format-bytes.js +11 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -14
- package/dist/inspect-file.d.ts +12 -0
- package/dist/inspect-file.js +88 -0
- package/dist/latin1-rows.d.ts +3 -1
- package/dist/latin1-rows.js +61 -23
- package/dist/materialize-field.d.ts +2 -0
- package/dist/materialize-field.js +20 -15
- package/dist/native.d.ts +29 -9
- package/dist/native.js +27 -29
- package/dist/normalize.d.ts +15 -2
- package/dist/normalize.js +41 -2
- package/dist/options-snapshot.js +3 -2
- package/dist/options.d.ts +4 -30
- package/dist/options.js +0 -6
- package/dist/parser.d.ts +14 -15
- package/dist/parser.js +38 -54
- package/dist/strict-schema.d.ts +5 -3
- package/dist/types.d.ts +88 -222
- package/dist/zip-reader.d.ts +11 -1
- package/dist/zip-reader.js +12 -3
- package/package.json +34 -32
- package/prebuilds/darwin-arm64/libcsv_native.dylib +0 -0
- package/prebuilds/darwin-x64/libcsv_native.dylib +0 -0
- package/prebuilds/linux-x64/libcsv_native.so +0 -0
- package/prebuilds/manifest.json +9 -8
- package/prebuilds/provenance/darwin-arm64.json +1 -1
- package/prebuilds/provenance/darwin-x64.json +1 -1
- package/prebuilds/provenance/linux-x64.json +1 -1
- package/dist/worker-count.d.ts +0 -34
- package/dist/worker-count.js +0 -101
- package/dist/worker-factory.d.ts +0 -3
- package/dist/worker-factory.js +0 -9
- package/dist/worker-filter.d.ts +0 -29
- package/dist/worker-filter.js +0 -46
- package/dist/worker-module.d.ts +0 -1
- package/dist/worker-module.js +0 -4
- package/dist/worker-pool.d.ts +0 -93
- package/dist/worker-pool.js +0 -298
- package/dist/worker-rows.d.ts +0 -36
- package/dist/worker-rows.js +0 -127
- package/dist/workers/count.worker.d.ts +0 -1
- package/dist/workers/count.worker.js +0 -36
- package/dist/workers/rows.worker.d.ts +0 -1
- package/dist/workers/rows.worker.js +0 -56
package/dist/parser.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { NativeCsvBatch } from './batches.js';
|
|
|
2
2
|
import { type NativePointer } from './native.js';
|
|
3
3
|
import type { CsvNativeFilterProgramEntry } from './normalize.js';
|
|
4
4
|
import type { CsvColumns, CsvEqualsFilter, CsvInFilter, CsvNativeFilter, CsvNativeProjectionOptions, CsvParserOptions, CsvRow, CsvStartsWithFilter } from './types.js';
|
|
5
|
+
export declare const nativeCsvParserFinalizer: FinalizationRegistry<NativePointer>;
|
|
5
6
|
/**
|
|
6
7
|
* The fixed-configuration parser surface used by high-level streaming APIs.
|
|
7
8
|
*
|
|
@@ -19,7 +20,7 @@ export type PreparedCsvParser = Pick<NativeCsvParser, 'writeBatch' | 'endBatch'
|
|
|
19
20
|
*
|
|
20
21
|
* @param options Base parser settings such as encoding, delimiter, strictness,
|
|
21
22
|
* and fixed column count.
|
|
22
|
-
* @param
|
|
23
|
+
* @param columns Optional zero-based columns to emit in each batch.
|
|
23
24
|
* @param program Optional postfix sequence of filter predicates and boolean
|
|
24
25
|
* operators. The parser validates and normalizes it before preparation.
|
|
25
26
|
* @param projected Whether the caller is explicitly requesting a projected
|
|
@@ -29,7 +30,7 @@ export type PreparedCsvParser = Pick<NativeCsvParser, 'writeBatch' | 'endBatch'
|
|
|
29
30
|
* @throws {Error} If strict validation is requested for a projected or
|
|
30
31
|
* filtered operation, or native parser setup fails.
|
|
31
32
|
*/
|
|
32
|
-
export declare function createPreparedParser(options: CsvParserOptions,
|
|
33
|
+
export declare function createPreparedParser(options: CsvParserOptions, columns?: CsvColumns, program?: readonly CsvNativeFilterProgramEntry[], projected?: boolean): PreparedCsvParser;
|
|
33
34
|
interface PreparedNativeWriter {
|
|
34
35
|
writeBatch(input: NodeJS.TypedArray | DataView, final: boolean): NativePointer | null;
|
|
35
36
|
writeCount(input: NodeJS.TypedArray | DataView, final: boolean): bigint | number;
|
|
@@ -37,18 +38,18 @@ interface PreparedNativeWriter {
|
|
|
37
38
|
/**
|
|
38
39
|
* Prepares native projection and filter buffers for an existing parser handle.
|
|
39
40
|
*
|
|
40
|
-
* This low-level helper is intended for the parser implementation. The
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* This low-level helper is intended for the parser implementation. The native
|
|
42
|
+
* parser owns a copy of the normalized configuration, and the caller remains
|
|
43
|
+
* responsible for closing the handle.
|
|
43
44
|
*
|
|
44
45
|
* @param handle Open native parser handle.
|
|
45
|
-
* @param
|
|
46
|
+
* @param columns Optional zero-based output columns.
|
|
46
47
|
* @param program Optional postfix sequence of filter predicates and boolean
|
|
47
48
|
* operators. It is validated and normalized before preparation.
|
|
48
49
|
* @returns Prepared write functions for batches and counts.
|
|
49
50
|
* @throws {Error} If the native library rejects the configuration.
|
|
50
51
|
*/
|
|
51
|
-
export declare function prepareNativeParser(handle: NativePointer,
|
|
52
|
+
export declare function prepareNativeParser(handle: NativePointer, columns: CsvColumns | undefined, program: readonly CsvNativeFilterProgramEntry[] | undefined): PreparedNativeWriter;
|
|
52
53
|
/**
|
|
53
54
|
* Incrementally parses caller-owned CSV chunks through the native parser.
|
|
54
55
|
*
|
|
@@ -79,7 +80,7 @@ export declare class NativeCsvParser {
|
|
|
79
80
|
* @param options Base parser settings. `encoding`, `delimiter`, `strict`, and
|
|
80
81
|
* `fixedColumns` are captured by this parser; the delimiter defaults to `,`.
|
|
81
82
|
* Automatic delimiter detection (`"auto"`) is available through file APIs,
|
|
82
|
-
* not this manual parser. `
|
|
83
|
+
* not this manual parser. `columns` is validated for compatibility
|
|
83
84
|
* but does not configure `writeBatch()`; apply projection with one of the
|
|
84
85
|
* explicit projected methods instead. `expectedHeaders`, `requireHeader`,
|
|
85
86
|
* and `minDataRows` are schema metadata for higher-level APIs and have no
|
|
@@ -121,7 +122,7 @@ export declare class NativeCsvParser {
|
|
|
121
122
|
/**
|
|
122
123
|
* Parses a chunk with explicit projection and optional native filters.
|
|
123
124
|
*
|
|
124
|
-
* Returned fields follow `
|
|
125
|
+
* Returned fields follow `columns` order. `equalsFilter` and
|
|
125
126
|
* `filters` are mutually exclusive. Keep the same projection and filter
|
|
126
127
|
* configuration for chunks that may belong to one logical row.
|
|
127
128
|
*
|
|
@@ -170,7 +171,7 @@ export declare class NativeCsvParser {
|
|
|
170
171
|
* that want to provide predicate and boolean-operator entries directly.
|
|
171
172
|
*
|
|
172
173
|
* @param chunk Input bytes.
|
|
173
|
-
* @param
|
|
174
|
+
* @param columns Optional zero-based output columns.
|
|
174
175
|
* @param program Filter predicates and boolean operators in postfix order.
|
|
175
176
|
* The method validates and normalizes the entries before the native call.
|
|
176
177
|
* @param final Whether this is the final input chunk.
|
|
@@ -178,18 +179,18 @@ export declare class NativeCsvParser {
|
|
|
178
179
|
* @throws {Error} If strict mode is enabled, the parser is closed, or native
|
|
179
180
|
* parsing rejects the program or input.
|
|
180
181
|
*/
|
|
181
|
-
writeProjectedBatchWhere(chunk: NodeJS.TypedArray | DataView,
|
|
182
|
+
writeProjectedBatchWhere(chunk: NodeJS.TypedArray | DataView, columns: readonly number[] | undefined, program: readonly CsvNativeFilterProgramEntry[], final?: boolean): NativeCsvBatch;
|
|
182
183
|
/**
|
|
183
184
|
* Flushes buffered state with a postfix native filter program.
|
|
184
185
|
*
|
|
185
|
-
* @param
|
|
186
|
+
* @param columns Optional zero-based output columns.
|
|
186
187
|
* @param program Filter predicates and boolean operators in postfix order.
|
|
187
188
|
* The method validates and normalizes the entries before the native call.
|
|
188
189
|
* @returns An owned projected batch; close or dispose it after use.
|
|
189
190
|
* @throws {Error} If strict mode is enabled, the parser is closed, or native
|
|
190
191
|
* parsing rejects the program or final row.
|
|
191
192
|
*/
|
|
192
|
-
endProjectedBatchWhere(
|
|
193
|
+
endProjectedBatchWhere(columns: readonly number[] | undefined, program: readonly CsvNativeFilterProgramEntry[]): NativeCsvBatch;
|
|
193
194
|
/**
|
|
194
195
|
* Counts complete rows emitted by a chunk without materializing fields.
|
|
195
196
|
*
|
|
@@ -330,8 +331,6 @@ export declare class NativeCsvParser {
|
|
|
330
331
|
* separately.
|
|
331
332
|
*/
|
|
332
333
|
close(): void;
|
|
333
|
-
/** Alias for {@link close}, suitable for explicit resource management. */
|
|
334
|
-
dispose(): void;
|
|
335
334
|
/** Implements `using` / explicit resource management. */
|
|
336
335
|
[Symbol.dispose](): void;
|
|
337
336
|
}
|
package/dist/parser.js
CHANGED
|
@@ -2,7 +2,6 @@ import { NativeCsvBatch } from "./batches.js";
|
|
|
2
2
|
import {
|
|
3
3
|
EMPTY_BUFFER,
|
|
4
4
|
native,
|
|
5
|
-
optionalPreparedParserNative,
|
|
6
5
|
u64ToSafeNumber
|
|
7
6
|
} from "./native.js";
|
|
8
7
|
import {
|
|
@@ -14,50 +13,38 @@ import {
|
|
|
14
13
|
normalizeInFilter,
|
|
15
14
|
normalizeNativeFilterProgram,
|
|
16
15
|
normalizeNativeFilters,
|
|
17
|
-
normalizeStartsWithFilter
|
|
16
|
+
normalizeStartsWithFilter,
|
|
17
|
+
rejectSelectedColumns
|
|
18
18
|
} from "./normalize.js";
|
|
19
19
|
function destroyNativeCsvParser(handle) {
|
|
20
20
|
native.symbols.csv_parser_destroy(handle);
|
|
21
21
|
}
|
|
22
|
-
const nativeCsvParserFinalizer = new FinalizationRegistry(destroyNativeCsvParser);
|
|
23
|
-
export function createPreparedParser(options,
|
|
24
|
-
if (!projected &&
|
|
22
|
+
export const nativeCsvParserFinalizer = new FinalizationRegistry(destroyNativeCsvParser);
|
|
23
|
+
export function createPreparedParser(options, columns, program, projected = !1) {
|
|
24
|
+
if (!projected && columns === void 0 && program === void 0)
|
|
25
25
|
return new NativeCsvParser(options);
|
|
26
26
|
if (options.strict === !0)
|
|
27
27
|
throw Error("strict CSV validation is not supported for projected batches");
|
|
28
|
-
if (options.
|
|
29
|
-
normalizeColumns(options.
|
|
28
|
+
if (options.columns !== columns)
|
|
29
|
+
normalizeColumns(options.columns);
|
|
30
30
|
normalizeFixedColumnsCount(options.fixedColumns, "fixed column count");
|
|
31
|
-
return new PreparedNativeCsvParser(options,
|
|
31
|
+
return new PreparedNativeCsvParser(options, columns, program);
|
|
32
32
|
}
|
|
33
|
-
export function prepareNativeParser(handle,
|
|
34
|
-
const
|
|
35
|
-
const hasProjection =
|
|
36
|
-
const columnCount = BigInt(
|
|
33
|
+
export function prepareNativeParser(handle, columns, program) {
|
|
34
|
+
const normalizedColumns = normalizeColumns(columns);
|
|
35
|
+
const hasProjection = columns !== void 0;
|
|
36
|
+
const columnCount = BigInt(columns?.length ?? 0);
|
|
37
37
|
const normalized = program === void 0 ? normalizeNativeFilters(void 0) : normalizeNativeFilterProgram(program);
|
|
38
38
|
const filterCount = BigInt(normalized.filterCount);
|
|
39
39
|
const valueCount = BigInt(normalized.valueCount);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!prepared.symbols.csv_parser_prepare(handle, hasProjection, columns, columnCount, normalized.descriptors, filterCount, normalized.valuesData, normalized.valuesData, normalized.valueOffsets, valueCount))
|
|
43
|
-
throw Error(`native CSV parser failed: ${native.symbols.csv_parser_last_error(handle) ?? "native parser error unavailable"}`);
|
|
44
|
-
return {
|
|
45
|
-
writeBatch: (input, final) => prepared.symbols.csv_parser_write_prepared_batch(handle, input, input, final),
|
|
46
|
-
writeCount: (input, final) => {
|
|
47
|
-
const count = prepared.symbols.csv_parser_write_prepared_count(handle, input, input, final);
|
|
48
|
-
if (count === 0xffffffffffffffffn)
|
|
49
|
-
throw Error(`native CSV parser failed: ${native.symbols.csv_parser_last_error(handle) ?? "native parser error unavailable"}`);
|
|
50
|
-
return count;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
40
|
+
if (!native.symbols.csv_parser_prepare(handle, hasProjection, normalizedColumns, columnCount, normalized.descriptors, filterCount, normalized.valuesData, normalized.valuesData, normalized.valueOffsets, valueCount))
|
|
41
|
+
throw Error(`native CSV parser failed: ${native.symbols.csv_parser_last_error(handle) ?? "native parser error unavailable"}`);
|
|
54
42
|
return {
|
|
55
|
-
writeBatch: (input, final) => native.symbols.
|
|
43
|
+
writeBatch: (input, final) => native.symbols.csv_parser_write_prepared_batch(handle, input, input, final),
|
|
56
44
|
writeCount: (input, final) => {
|
|
57
|
-
const count = native.symbols.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
throw Error(`native CSV parser failed: ${error}`);
|
|
45
|
+
const count = native.symbols.csv_parser_write_prepared_count(handle, input, input, final);
|
|
46
|
+
if (count === 0xffffffffffffffffn)
|
|
47
|
+
throw Error(`native CSV parser failed: ${native.symbols.csv_parser_last_error(handle) ?? "native parser error unavailable"}`);
|
|
61
48
|
return count;
|
|
62
49
|
}
|
|
63
50
|
};
|
|
@@ -67,10 +54,10 @@ class PreparedNativeCsvParser {
|
|
|
67
54
|
#handle;
|
|
68
55
|
#writer;
|
|
69
56
|
#fixedValidator;
|
|
70
|
-
constructor(options,
|
|
57
|
+
constructor(options, columns, program) {
|
|
71
58
|
const handle = createNativeCsvParser(options);
|
|
72
59
|
try {
|
|
73
|
-
this.#writer = prepareNativeParser(handle,
|
|
60
|
+
this.#writer = prepareNativeParser(handle, columns, program);
|
|
74
61
|
this.#fixedValidator = options.fixedColumns === void 0 ? void 0 : new NativeCsvParser(options);
|
|
75
62
|
} catch (error) {
|
|
76
63
|
destroyNativeCsvParser(handle);
|
|
@@ -136,8 +123,9 @@ export class NativeCsvParser {
|
|
|
136
123
|
#strict;
|
|
137
124
|
#fixedColumns;
|
|
138
125
|
constructor(options = {}) {
|
|
126
|
+
rejectSelectedColumns(options);
|
|
139
127
|
this.#strict = options.strict === !0;
|
|
140
|
-
normalizeColumns(options.
|
|
128
|
+
normalizeColumns(options.columns);
|
|
141
129
|
this.#fixedColumns = normalizeFixedColumnsCount(options.fixedColumns, "fixed column count");
|
|
142
130
|
const handle = createNativeCsvParser(options);
|
|
143
131
|
this.#handle = handle;
|
|
@@ -166,15 +154,15 @@ export class NativeCsvParser {
|
|
|
166
154
|
}
|
|
167
155
|
writeProjectedBatch(chunk, options = {}, final = !1) {
|
|
168
156
|
this.#rejectStrictUnsupported("projected batches");
|
|
169
|
-
this.#
|
|
157
|
+
this.#validateProjectionOptions(options);
|
|
170
158
|
if (chunk.byteLength === 0 && final)
|
|
171
159
|
return this.endProjectedBatch(options);
|
|
172
160
|
const handle = this.#requireHandle();
|
|
173
161
|
const input = normalizeChunk(chunk);
|
|
174
|
-
const columns = normalizeColumns(options.
|
|
162
|
+
const columns = normalizeColumns(options.columns);
|
|
175
163
|
const filter = normalizeEqualsFilter(options.equalsFilter);
|
|
176
164
|
const filters = normalizeNativeFilters(options.filters);
|
|
177
|
-
const batch = options.filters === void 0 ? native.symbols.csv_parser_write_projected_batch(handle, input, input, final, options.
|
|
165
|
+
const batch = options.filters === void 0 ? native.symbols.csv_parser_write_projected_batch(handle, input, input, final, options.columns !== void 0, columns, BigInt(options.columns?.length ?? 0), filter.enabled, filter.column, filter.value, filter.value) : native.symbols.csv_parser_write_projected_batch_where_all(handle, input, input, final, options.columns !== void 0, columns, BigInt(options.columns?.length ?? 0), filters.descriptors, BigInt(filters.filterCount), filters.valuesData, filters.valuesData, filters.valueOffsets, BigInt(filters.valueCount));
|
|
178
166
|
if (batch === null)
|
|
179
167
|
throw Error(`native CSV parser failed: ${this.#lastError()}`);
|
|
180
168
|
return new NativeCsvBatch(batch);
|
|
@@ -195,33 +183,33 @@ export class NativeCsvParser {
|
|
|
195
183
|
}
|
|
196
184
|
endProjectedBatch(options = {}) {
|
|
197
185
|
this.#rejectStrictUnsupported("projected batches");
|
|
198
|
-
this.#
|
|
199
|
-
const columns = normalizeColumns(options.
|
|
186
|
+
this.#validateProjectionOptions(options);
|
|
187
|
+
const columns = normalizeColumns(options.columns);
|
|
200
188
|
const filter = normalizeEqualsFilter(options.equalsFilter);
|
|
201
189
|
const filters = normalizeNativeFilters(options.filters);
|
|
202
|
-
const batch = options.filters === void 0 ? native.symbols.csv_parser_finish_projected_batch(this.#requireHandle(), options.
|
|
190
|
+
const batch = options.filters === void 0 ? native.symbols.csv_parser_finish_projected_batch(this.#requireHandle(), options.columns !== void 0, columns, BigInt(options.columns?.length ?? 0), filter.enabled, filter.column, filter.value, filter.value) : native.symbols.csv_parser_finish_projected_batch_where_all(this.#requireHandle(), options.columns !== void 0, columns, BigInt(options.columns?.length ?? 0), filters.descriptors, BigInt(filters.filterCount), filters.valuesData, filters.valuesData, filters.valueOffsets, BigInt(filters.valueCount));
|
|
203
191
|
if (batch === null)
|
|
204
192
|
throw Error(`native CSV parser failed: ${this.#lastError()}`);
|
|
205
193
|
return new NativeCsvBatch(batch);
|
|
206
194
|
}
|
|
207
|
-
writeProjectedBatchWhere(chunk,
|
|
195
|
+
writeProjectedBatchWhere(chunk, columns, program, final = !1) {
|
|
208
196
|
this.#rejectStrictUnsupported("projected batches");
|
|
209
197
|
if (chunk.byteLength === 0 && final)
|
|
210
|
-
return this.endProjectedBatchWhere(
|
|
198
|
+
return this.endProjectedBatchWhere(columns, program);
|
|
211
199
|
const handle = this.#requireHandle();
|
|
212
200
|
const input = normalizeChunk(chunk);
|
|
213
|
-
const
|
|
201
|
+
const normalizedColumns = normalizeColumns(columns);
|
|
214
202
|
const normalized = normalizeNativeFilterProgram(program);
|
|
215
|
-
const batch = native.symbols.csv_parser_write_projected_batch_where_all(handle, input, input, final,
|
|
203
|
+
const batch = native.symbols.csv_parser_write_projected_batch_where_all(handle, input, input, final, columns !== void 0, normalizedColumns, BigInt(columns?.length ?? 0), normalized.descriptors, BigInt(normalized.filterCount), normalized.valuesData, normalized.valuesData, normalized.valueOffsets, BigInt(normalized.valueCount));
|
|
216
204
|
if (batch === null)
|
|
217
205
|
throw Error(`native CSV parser failed: ${this.#lastError()}`);
|
|
218
206
|
return new NativeCsvBatch(batch);
|
|
219
207
|
}
|
|
220
|
-
endProjectedBatchWhere(
|
|
208
|
+
endProjectedBatchWhere(columns, program) {
|
|
221
209
|
this.#rejectStrictUnsupported("projected batches");
|
|
222
|
-
const
|
|
210
|
+
const normalizedColumns = normalizeColumns(columns);
|
|
223
211
|
const normalized = normalizeNativeFilterProgram(program);
|
|
224
|
-
const batch = native.symbols.csv_parser_finish_projected_batch_where_all(this.#requireHandle(),
|
|
212
|
+
const batch = native.symbols.csv_parser_finish_projected_batch_where_all(this.#requireHandle(), columns !== void 0, normalizedColumns, BigInt(columns?.length ?? 0), normalized.descriptors, BigInt(normalized.filterCount), normalized.valuesData, normalized.valuesData, normalized.valueOffsets, BigInt(normalized.valueCount));
|
|
225
213
|
if (batch === null)
|
|
226
214
|
throw Error(`native CSV parser failed: ${this.#lastError()}`);
|
|
227
215
|
return new NativeCsvBatch(batch);
|
|
@@ -335,9 +323,6 @@ export class NativeCsvParser {
|
|
|
335
323
|
nativeCsvParserFinalizer.unregister(this);
|
|
336
324
|
destroyNativeCsvParser(handle);
|
|
337
325
|
}
|
|
338
|
-
dispose() {
|
|
339
|
-
this.close();
|
|
340
|
-
}
|
|
341
326
|
[Symbol.dispose]() {
|
|
342
327
|
this.close();
|
|
343
328
|
}
|
|
@@ -347,9 +332,7 @@ export class NativeCsvParser {
|
|
|
347
332
|
return this.#handle;
|
|
348
333
|
}
|
|
349
334
|
#lastError() {
|
|
350
|
-
|
|
351
|
-
return "parser is closed";
|
|
352
|
-
return native.symbols.csv_parser_last_error(this.#handle) ?? "native parser error unavailable";
|
|
335
|
+
return native.symbols.csv_parser_last_error(this.#requireHandle()) ?? "native parser error unavailable";
|
|
353
336
|
}
|
|
354
337
|
#throwIfNativeError() {
|
|
355
338
|
const error = this.#lastError();
|
|
@@ -360,7 +343,8 @@ export class NativeCsvParser {
|
|
|
360
343
|
if (this.#strict)
|
|
361
344
|
throw Error(`strict CSV validation is not supported for ${operation}`);
|
|
362
345
|
}
|
|
363
|
-
#
|
|
346
|
+
#validateProjectionOptions(options) {
|
|
347
|
+
rejectSelectedColumns(options);
|
|
364
348
|
if (options.equalsFilter !== void 0 && options.filters !== void 0)
|
|
365
349
|
throw Error("use equalsFilter or filters, not both");
|
|
366
350
|
}
|
package/dist/strict-schema.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { NativeCsvBatch } from './batches.js';
|
|
2
2
|
import type { CsvParserOptions, CsvRow } from './types.js';
|
|
3
|
+
type StrictSchemaOptions = Pick<CsvParserOptions, 'strict' | 'expectedHeaders' | 'requireHeader' | 'minDataRows'>;
|
|
3
4
|
export declare class CsvStrictSchemaValidator {
|
|
4
5
|
#private;
|
|
5
|
-
constructor(suppliedOptions:
|
|
6
|
+
constructor(suppliedOptions: StrictSchemaOptions);
|
|
6
7
|
get enabled(): boolean;
|
|
7
8
|
validateRows(rows: readonly CsvRow[]): void;
|
|
8
9
|
validateBatch(batch: NativeCsvBatch): void;
|
|
9
10
|
finish(): void;
|
|
10
11
|
}
|
|
11
|
-
export declare function strictSchemaValidator(options:
|
|
12
|
-
export declare function rejectStrictSchemaUnsupported(options:
|
|
12
|
+
export declare function strictSchemaValidator(options: StrictSchemaOptions): CsvStrictSchemaValidator | undefined;
|
|
13
|
+
export declare function rejectStrictSchemaUnsupported(options: StrictSchemaOptions, operation: string): void;
|
|
14
|
+
export {};
|