javascript-excel 2.1.0 → 2.3.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.
@@ -13,15 +13,27 @@ declare function parseNumber(text: string, options?: {
13
13
  group?: NumberGroup;
14
14
  }): number | undefined;
15
15
  type DateOrder = "YMD" | "DMY" | "MDY";
16
- /** ISO 8601 always; numeric dates (d/m/yyyy, …) only with `order`. Two-digit years are not accepted. */
16
+ /**
17
+ * ISO 8601 always; numeric dates (d/m/yyyy, …) only with `order`. Two-digit
18
+ * years only with `twoDigitYearPivot` and a DMY or MDY order.
19
+ */
17
20
  declare function parseDate(text: string, options?: {
18
- order?: DateOrder;
19
- zone?: "local" | "utc";
21
+ order?: DateOrder | undefined;
22
+ zone?: "local" | "utc" | undefined;
23
+ twoDigitYearPivot?: number | undefined;
20
24
  }): Date | undefined;
21
25
  interface ImportLocale {
22
26
  decimal?: "." | "," | undefined;
23
27
  group?: NumberGroup | undefined;
24
28
  dateOrder?: "auto" | "YMD" | "DMY" | "MDY" | undefined;
29
+ /**
30
+ * Accept two-digit years in numeric dates such as 31.10.26 (DMY) or
31
+ * 10/31/26 (MDY): a year yy below the pivot is 20yy, from it on 19yy.
32
+ * An integer from 0 to 100; 30 is Excel's rule (00–29 → 2000s, 30–99 → 1900s).
33
+ * Needs an explicit DMY or MDY `dateOrder`; 'auto' leaves such columns text.
34
+ * Default undefined: two-digit years are not accepted.
35
+ */
36
+ twoDigitYearPivot?: number | undefined;
25
37
  }
26
38
  interface DetectHeaderOptions {
27
39
  range?: string | undefined;
@@ -35,7 +47,12 @@ interface HeaderDetection {
35
47
  confidence: "high" | "low";
36
48
  }
37
49
  declare function detectHeader(sheet: Sheet<CellInput>, options?: DetectHeaderOptions): HeaderDetection;
38
- type ColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "mixed" | "empty";
50
+ /**
51
+ * A column's type. `'day'` is never inferred: forced (by `types` or a schema
52
+ * field), it converts like `'date'` and then drops the time of day, giving
53
+ * 00:00 of the calendar day in `dateZone` (docs/api.md §5.6, "Type rules").
54
+ */
55
+ type ColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "day" | "mixed" | "empty";
39
56
  interface DatasetLike {
40
57
  columns: ReadonlyArray<{
41
58
  key: string;
@@ -152,7 +169,17 @@ interface ImportDatasetOptions {
152
169
  mapping?: ColumnMapping | undefined;
153
170
  maxRows?: number | undefined;
154
171
  preview?: number | undefined;
155
- /** Reader limits for xlsx; `maxWarnings` also caps the warnings of a CSV file. */
172
+ /**
173
+ * Issues kept in `issues` (added in 2.3). Past it, an issue is counted in `meta.droppedIssues`
174
+ * instead, unless it is the first of its code, so every kind of issue that occurred is listed at
175
+ * least once (and so is an `error` severity, if any). An integer of at least 1, or `Infinity` for no
176
+ * cap; default 100,000.
177
+ */
178
+ maxIssues?: number | undefined;
179
+ /**
180
+ * Reader limits for xlsx. For a CSV file, `maxWarnings` caps its warnings and
181
+ * `maxCellTextLength` limits its fields (raising CSV's 1 MiB `maxFieldBytes` to match).
182
+ */
156
183
  limits?: Partial<ReadLimits> | undefined;
157
184
  signal?: AbortSignalLike | undefined;
158
185
  onProgress?: ((p: ImportProgress) => void) | undefined;
@@ -179,6 +206,13 @@ interface ImportMeta {
179
206
  truncated: boolean;
180
207
  mapping?: ColumnMapping | undefined;
181
208
  unmappedColumns?: string[] | undefined;
209
+ /** Set only when `maxIssues` dropped issues: how many, by code (added in 2.3). */
210
+ droppedIssues?: DroppedIssues | undefined;
211
+ }
212
+ /** Issues `maxIssues` kept out of `ImportDatasetResult.issues`. */
213
+ interface DroppedIssues {
214
+ total: number;
215
+ byCode: Partial<Record<ImportIssueCode, number>>;
182
216
  }
183
217
  interface ImportDatasetResult {
184
218
  columns: ImportedColumn[];
@@ -189,4 +223,4 @@ interface ImportDatasetResult {
189
223
  meta: ImportMeta;
190
224
  }
191
225
  declare function importDataset(input: string | BinaryInput, options?: ImportDatasetOptions): Promise<ImportDatasetResult>;
192
- export { parseDate as A, inferColumnTypes as C, detectHeader as D, ImportLocale as E, DateOrder as O, coerceColumns as S, HeaderDetection as T, DatasetLike as _, importDataset as a, InferredColumn as b, ImportSchema as c, MappedDataset as d, MappingResult as f, ColumnType as g, CoerceResult as h, ImportProgress as i, parseNumber as j, NumberGroup as k, ImportedColumn as l, mapColumns as m, ImportDatasetResult as n, ColumnMapping as o, applyMapping as p, ImportMeta as r, FieldSpec as s, ImportDatasetOptions as t, MappableDataset as u, ImportIssue as v, DetectHeaderOptions as w, TypeOptions as x, ImportIssueCode as y };
226
+ export { NumberGroup as A, coerceColumns as C, ImportLocale as D, HeaderDetection as E, parseNumber as M, detectHeader as O, TypeOptions as S, DetectHeaderOptions as T, ColumnType as _, ImportProgress as a, ImportIssueCode as b, FieldSpec as c, MappableDataset as d, MappedDataset as f, CoerceResult as g, mapColumns as h, ImportMeta as i, parseDate as j, DateOrder as k, ImportSchema as l, applyMapping as m, ImportDatasetOptions as n, importDataset as o, MappingResult as p, ImportDatasetResult as r, ColumnMapping as s, DroppedIssues as t, ImportedColumn as u, DatasetLike as v, inferColumnTypes as w, InferredColumn as x, ImportIssue as y };
@@ -13,15 +13,27 @@ declare function parseNumber(text: string, options?: {
13
13
  group?: NumberGroup;
14
14
  }): number | undefined;
15
15
  type DateOrder = "YMD" | "DMY" | "MDY";
16
- /** ISO 8601 always; numeric dates (d/m/yyyy, …) only with `order`. Two-digit years are not accepted. */
16
+ /**
17
+ * ISO 8601 always; numeric dates (d/m/yyyy, …) only with `order`. Two-digit
18
+ * years only with `twoDigitYearPivot` and a DMY or MDY order.
19
+ */
17
20
  declare function parseDate(text: string, options?: {
18
- order?: DateOrder;
19
- zone?: "local" | "utc";
21
+ order?: DateOrder | undefined;
22
+ zone?: "local" | "utc" | undefined;
23
+ twoDigitYearPivot?: number | undefined;
20
24
  }): Date | undefined;
21
25
  interface ImportLocale {
22
26
  decimal?: "." | "," | undefined;
23
27
  group?: NumberGroup | undefined;
24
28
  dateOrder?: "auto" | "YMD" | "DMY" | "MDY" | undefined;
29
+ /**
30
+ * Accept two-digit years in numeric dates such as 31.10.26 (DMY) or
31
+ * 10/31/26 (MDY): a year yy below the pivot is 20yy, from it on 19yy.
32
+ * An integer from 0 to 100; 30 is Excel's rule (00–29 → 2000s, 30–99 → 1900s).
33
+ * Needs an explicit DMY or MDY `dateOrder`; 'auto' leaves such columns text.
34
+ * Default undefined: two-digit years are not accepted.
35
+ */
36
+ twoDigitYearPivot?: number | undefined;
25
37
  }
26
38
  interface DetectHeaderOptions {
27
39
  range?: string | undefined;
@@ -35,7 +47,12 @@ interface HeaderDetection {
35
47
  confidence: "high" | "low";
36
48
  }
37
49
  declare function detectHeader(sheet: Sheet<CellInput>, options?: DetectHeaderOptions): HeaderDetection;
38
- type ColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "mixed" | "empty";
50
+ /**
51
+ * A column's type. `'day'` is never inferred: forced (by `types` or a schema
52
+ * field), it converts like `'date'` and then drops the time of day, giving
53
+ * 00:00 of the calendar day in `dateZone` (docs/api.md §5.6, "Type rules").
54
+ */
55
+ type ColumnType = "string" | "number" | "boolean" | "date" | "datetime" | "day" | "mixed" | "empty";
39
56
  interface DatasetLike {
40
57
  columns: ReadonlyArray<{
41
58
  key: string;
@@ -152,7 +169,17 @@ interface ImportDatasetOptions {
152
169
  mapping?: ColumnMapping | undefined;
153
170
  maxRows?: number | undefined;
154
171
  preview?: number | undefined;
155
- /** Reader limits for xlsx; `maxWarnings` also caps the warnings of a CSV file. */
172
+ /**
173
+ * Issues kept in `issues` (added in 2.3). Past it, an issue is counted in `meta.droppedIssues`
174
+ * instead, unless it is the first of its code, so every kind of issue that occurred is listed at
175
+ * least once (and so is an `error` severity, if any). An integer of at least 1, or `Infinity` for no
176
+ * cap; default 100,000.
177
+ */
178
+ maxIssues?: number | undefined;
179
+ /**
180
+ * Reader limits for xlsx. For a CSV file, `maxWarnings` caps its warnings and
181
+ * `maxCellTextLength` limits its fields (raising CSV's 1 MiB `maxFieldBytes` to match).
182
+ */
156
183
  limits?: Partial<ReadLimits> | undefined;
157
184
  signal?: AbortSignalLike | undefined;
158
185
  onProgress?: ((p: ImportProgress) => void) | undefined;
@@ -179,6 +206,13 @@ interface ImportMeta {
179
206
  truncated: boolean;
180
207
  mapping?: ColumnMapping | undefined;
181
208
  unmappedColumns?: string[] | undefined;
209
+ /** Set only when `maxIssues` dropped issues: how many, by code (added in 2.3). */
210
+ droppedIssues?: DroppedIssues | undefined;
211
+ }
212
+ /** Issues `maxIssues` kept out of `ImportDatasetResult.issues`. */
213
+ interface DroppedIssues {
214
+ total: number;
215
+ byCode: Partial<Record<ImportIssueCode, number>>;
182
216
  }
183
217
  interface ImportDatasetResult {
184
218
  columns: ImportedColumn[];
@@ -189,4 +223,4 @@ interface ImportDatasetResult {
189
223
  meta: ImportMeta;
190
224
  }
191
225
  declare function importDataset(input: string | BinaryInput, options?: ImportDatasetOptions): Promise<ImportDatasetResult>;
192
- export { parseDate as A, inferColumnTypes as C, detectHeader as D, ImportLocale as E, DateOrder as O, coerceColumns as S, HeaderDetection as T, DatasetLike as _, importDataset as a, InferredColumn as b, ImportSchema as c, MappedDataset as d, MappingResult as f, ColumnType as g, CoerceResult as h, ImportProgress as i, parseNumber as j, NumberGroup as k, ImportedColumn as l, mapColumns as m, ImportDatasetResult as n, ColumnMapping as o, applyMapping as p, ImportMeta as r, FieldSpec as s, ImportDatasetOptions as t, MappableDataset as u, ImportIssue as v, DetectHeaderOptions as w, TypeOptions as x, ImportIssueCode as y };
226
+ export { NumberGroup as A, coerceColumns as C, ImportLocale as D, HeaderDetection as E, parseNumber as M, detectHeader as O, TypeOptions as S, DetectHeaderOptions as T, ColumnType as _, ImportProgress as a, ImportIssueCode as b, FieldSpec as c, MappableDataset as d, MappedDataset as f, CoerceResult as g, mapColumns as h, ImportMeta as i, parseDate as j, DateOrder as k, ImportSchema as l, applyMapping as m, ImportDatasetOptions as n, importDataset as o, MappingResult as p, ImportDatasetResult as r, ColumnMapping as s, DroppedIssues as t, ImportedColumn as u, DatasetLike as v, inferColumnTypes as w, InferredColumn as x, ImportIssue as y };