@skunkwerkx/hypertabular-wasm32-wasip1 0.0.2 → 1.1.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/LICENSE +21 -0
- package/LICENSE-UNICODE +39 -0
- package/README.md +2 -2
- package/hypertabular.wasip1-browser.js +1423 -0
- package/hypertabular.wasip1-deferred.d.ts +83 -0
- package/hypertabular.wasip1-deferred.js +1865 -0
- package/hypertabular.wasip1.cjs +1645 -0
- package/hypertabular.wasip1.d.cts +870 -0
- package/hypertabular.wasm32-wasip1.wasm +0 -0
- package/hypertabular.wasm32-wasip1.wasm.d.ts +5 -0
- package/package.json +53 -5
|
@@ -0,0 +1,870 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/** The WASI flavor this loader instantiates. */
|
|
5
|
+
export declare const __napiBindingTarget: 'wasm32-wasip1'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The rows of one read, column-major, copied out of the reader: a batch stays valid after
|
|
9
|
+
* the reader has moved on, and after it is closed.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Batch {
|
|
12
|
+
/** How many rows the batch holds. */
|
|
13
|
+
get rows(): number
|
|
14
|
+
/** How many columns: the plan's length. */
|
|
15
|
+
get columnCount(): number
|
|
16
|
+
/** The door each column was read through, in plan order. */
|
|
17
|
+
get doors(): Array<Door>
|
|
18
|
+
/**
|
|
19
|
+
* The line (delimited text) or the sheet row (a workbook) the row came from; 0 for a
|
|
20
|
+
* row the batch does not have.
|
|
21
|
+
*/
|
|
22
|
+
line(row: number): number
|
|
23
|
+
/**
|
|
24
|
+
* The cell at `row` of `column` as HyperCast judged it. A column or row the batch does
|
|
25
|
+
* not have is HyperCast's contract violation: `malformed`, offset 0, length 0; so is every
|
|
26
|
+
* cell of a column that declares constraints, which only `getChecked` can say.
|
|
27
|
+
*/
|
|
28
|
+
get<T extends Value = Value>(column: number, row: number): Verdict<T>
|
|
29
|
+
/**
|
|
30
|
+
* The cell at `row` of `column` as HyperCast's checked door judged it: the value, flagged
|
|
31
|
+
* `adjusted` when `multipleOf`'s rounding changed it (at the text door, a matched `enum`
|
|
32
|
+
* entry as declared, `enumIndex` naming it); a violation of a constraint the column
|
|
33
|
+
* declares, carrying the value as cast and the judged text's span; or the cell's fault. A
|
|
34
|
+
* column that declares none reads as `get` does, never adjusted. A column or row the batch
|
|
35
|
+
* does not have is HyperCast's contract violation.
|
|
36
|
+
*/
|
|
37
|
+
getChecked<T extends Value = Value>(column: number, row: number): CheckedVerdict<T>
|
|
38
|
+
/**
|
|
39
|
+
* What failed in the cell, by HyperCast's `Detail` name: `null` for a cell that cast,
|
|
40
|
+
* one no door was asked about (a token, padding, a formula with no cached value), a read
|
|
41
|
+
* with notes off, and a cell the batch does not have.
|
|
42
|
+
*/
|
|
43
|
+
detail(column: number, row: number): Detail | null
|
|
44
|
+
/**
|
|
45
|
+
* Where the cell's verdict came from (`cell` for every cell of a read with notes off), or
|
|
46
|
+
* `null` for a cell the batch does not have.
|
|
47
|
+
*/
|
|
48
|
+
origin(column: number, row: number): Origin | null
|
|
49
|
+
/**
|
|
50
|
+
* What went wrong in the batch, by row and then column, a row's own entry first: worked
|
|
51
|
+
* out when asked for, a new array each call, the caller's own.
|
|
52
|
+
*/
|
|
53
|
+
faults(): Array<Problem>
|
|
54
|
+
/**
|
|
55
|
+
* The text of the cell, whatever its door and verdict: what a fault's span is a span of.
|
|
56
|
+
* Empty for an empty cell, a typed workbook cell that cast, and a cell the batch does
|
|
57
|
+
* not have.
|
|
58
|
+
*/
|
|
59
|
+
raw(column: number, row: number): Uint8Array
|
|
60
|
+
/**
|
|
61
|
+
* `raw` as a string, each invalid UTF-8 sequence replaced by U+FFFD: for display, since
|
|
62
|
+
* a fault's span counts bytes of `raw`, not UTF-16 code units of this.
|
|
63
|
+
*/
|
|
64
|
+
rawString(column: number, row: number): string
|
|
65
|
+
/**
|
|
66
|
+
* The whole column, a verdict a row, as `get` reads each cell; empty for a column the batch
|
|
67
|
+
* does not have. Every cell of a column that declares constraints is HyperCast's contract
|
|
68
|
+
* violation: `columnChecked` reads it.
|
|
69
|
+
*/
|
|
70
|
+
column<T extends Value = Value>(column: number): Array<Verdict<T>>
|
|
71
|
+
/**
|
|
72
|
+
* The whole column, a verdict a row, as `getChecked` reads each cell: a constrained column
|
|
73
|
+
* and one that declares nothing alike. Empty for a column the batch does not have.
|
|
74
|
+
*/
|
|
75
|
+
columnChecked<T extends Value = Value>(column: number): Array<CheckedVerdict<T>>
|
|
76
|
+
/** How many cells of the column did not cast; 0 for a column the batch does not have. */
|
|
77
|
+
faultCount(column: number): number
|
|
78
|
+
/** The row at `row`, read across; `null` for a row the batch does not have. */
|
|
79
|
+
row(row: number): Row | null
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A batch's store under WebAssembly, as `index.js`'s batch holds it: opaque, and of no use to
|
|
84
|
+
* anything but this package's own `batch*` functions. (Under Node, Bun and Deno the store is an
|
|
85
|
+
* `ArrayBuffer` instead.)
|
|
86
|
+
*/
|
|
87
|
+
export declare class BatchStore {}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* One output column: the source column it reads, the door its cells go through, and what it
|
|
91
|
+
* declares beside them. Made by a factory (`Column.i32(0)`), never by `new`. A factory never
|
|
92
|
+
* refuses: a column whose arguments are not of the declared types is refused, with its
|
|
93
|
+
* place in the plan, when the plan is bound, as is one the core cannot honour (an ordinal
|
|
94
|
+
* past the core's limit, a format or date options HyperCast refuses).
|
|
95
|
+
*/
|
|
96
|
+
export declare class Column {
|
|
97
|
+
/** A boolean, read under HyperCast's natural-language lexicon. */
|
|
98
|
+
static bool(ordinal: number): Column
|
|
99
|
+
/** A UUID, as its lowercase hyphenated text. */
|
|
100
|
+
static uuid(ordinal: number): Column
|
|
101
|
+
/** An RFC 3339 instant. */
|
|
102
|
+
static timestamp(ordinal: number): Column
|
|
103
|
+
/** A strict ISO `yyyy-MM-dd` date. */
|
|
104
|
+
static date(ordinal: number): Column
|
|
105
|
+
/** An ISO 24-hour time of day. */
|
|
106
|
+
static time(ordinal: number): Column
|
|
107
|
+
/** An ISO 8601 duration. */
|
|
108
|
+
static duration(ordinal: number): Column
|
|
109
|
+
/** The cell's text itself. */
|
|
110
|
+
static text(ordinal: number): Column
|
|
111
|
+
/** A signed 8-bit integer. */
|
|
112
|
+
static i8(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
113
|
+
/** A signed 16-bit integer. */
|
|
114
|
+
static i16(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
115
|
+
/** A signed 32-bit integer. */
|
|
116
|
+
static i32(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
117
|
+
/** A signed 64-bit integer, as a `bigint`. */
|
|
118
|
+
static i64(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
119
|
+
/** An unsigned 8-bit integer. */
|
|
120
|
+
static u8(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
121
|
+
/** An unsigned 16-bit integer. */
|
|
122
|
+
static u16(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
123
|
+
/** An unsigned 32-bit integer. */
|
|
124
|
+
static u32(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
125
|
+
/** An unsigned 64-bit integer, as a `bigint`. */
|
|
126
|
+
static u64(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
127
|
+
/** An IEEE single, widened exactly to a number. */
|
|
128
|
+
static f32(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
129
|
+
/** An IEEE double. */
|
|
130
|
+
static f64(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
131
|
+
/** An exact decimal, as its canonical text. */
|
|
132
|
+
static decimal(ordinal: number, format?: PackedNumFormat | undefined | null): Column
|
|
133
|
+
/**
|
|
134
|
+
* A count of seconds, milliseconds, microseconds or nanoseconds since the Unix epoch, in
|
|
135
|
+
* the declared `UnixPrecision`.
|
|
136
|
+
*/
|
|
137
|
+
static unix(ordinal: number, precision: number): Column
|
|
138
|
+
/** An Excel date serial in the declared `ExcelEpoch`. */
|
|
139
|
+
static excelSerial(ordinal: number, epoch: number): Column
|
|
140
|
+
/** A separated calendar date whose fields come in the declared `DateOrder`. */
|
|
141
|
+
static dateOrdered(ordinal: number, order: number): Column
|
|
142
|
+
/** A zone-less civil date-time whose date fields come in the declared `DateOrder`. */
|
|
143
|
+
static datetime(ordinal: number, order: number): Column
|
|
144
|
+
/**
|
|
145
|
+
* Source column `ordinal` through the door a HyperCast `Constraints` is bound to (an
|
|
146
|
+
* integer, float or decimal door, or the text door), whose cells must also meet it: read
|
|
147
|
+
* through `getChecked`, a cell that casts and breaks a declared rule is a violation carrying
|
|
148
|
+
* the value as cast, one that casts and meets them all passes, flagged `adjusted` when
|
|
149
|
+
* `multipleOf`'s rounding changed it, and one that doesn't cast is its fault. A numeric
|
|
150
|
+
* door reads its numbers in `format`, as the plain factories do. As with every factory, an
|
|
151
|
+
* argument that is not what it says (no `Constraints`, a failed `Constraints.declare`'s
|
|
152
|
+
* missing `.value` among them) makes a column that is not `valid`, refused when its plan is
|
|
153
|
+
* bound: never a column with no rules. Each distinct declaration is kept for the life of
|
|
154
|
+
* the process.
|
|
155
|
+
*/
|
|
156
|
+
static checked(ordinal: number, constraints: DeclaredConstraints, format?: PackedNumFormat | undefined | null): Column
|
|
157
|
+
/**
|
|
158
|
+
* The same column answering to these tokens rather than its dialect's or sheet's: a
|
|
159
|
+
* cell whose exact unquoted text is one of them is `empty`, its origin `token`. An empty
|
|
160
|
+
* list means none, so a column can opt out of its dialect's. Each distinct list is kept
|
|
161
|
+
* for the life of the process: a program building lists from request data grows without
|
|
162
|
+
* bound.
|
|
163
|
+
*/
|
|
164
|
+
withTokens(tokens: ReadonlyArray<string>): Column
|
|
165
|
+
/**
|
|
166
|
+
* The same column reading dates under a HyperCast `DateOptions`, its month names
|
|
167
|
+
* included: the `timestamp`, `date`, `dateOrdered` and `datetime` doors read them. On a
|
|
168
|
+
* sheet they reach only a text cell. Each distinct month list is kept for the life of the
|
|
169
|
+
* process.
|
|
170
|
+
*/
|
|
171
|
+
withDateOptions(options: DeclaredDateOptions): Column
|
|
172
|
+
/**
|
|
173
|
+
* The door its cells go through: for `Column.checked`, its declaration's, so `null` there
|
|
174
|
+
* for a declaration that is none.
|
|
175
|
+
*/
|
|
176
|
+
get door(): Door | null
|
|
177
|
+
/**
|
|
178
|
+
* Whether it declares HyperCast's constraints: made by `Column.checked`, and read through
|
|
179
|
+
* `getChecked`.
|
|
180
|
+
*/
|
|
181
|
+
get checked(): boolean
|
|
182
|
+
/** The source column it reads, as it was given (`NaN` for an ordinal that is no number). */
|
|
183
|
+
get ordinal(): number
|
|
184
|
+
/**
|
|
185
|
+
* The notation a number door reads in, as its 92 bytes (other doors carry one too, and
|
|
186
|
+
* read nothing of it); `null` for a column that is not valid.
|
|
187
|
+
*/
|
|
188
|
+
get format(): SuggestedFormat | null
|
|
189
|
+
/**
|
|
190
|
+
* Whether its arguments were of the declared types. A plan holding a column that is not
|
|
191
|
+
* valid is refused when it is bound, with the column's place in the plan; so is one the
|
|
192
|
+
* core cannot honour, valid or not.
|
|
193
|
+
*/
|
|
194
|
+
get valid(): boolean
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A forward-only read of delimited text — CSV, TSV, any single-byte ASCII separator —
|
|
199
|
+
* through a plan, a batch at a time. Made by `fromBytes` or `open`, never by `new`.
|
|
200
|
+
*/
|
|
201
|
+
export declare class DelimitedReader {
|
|
202
|
+
/**
|
|
203
|
+
* Reads delimited text held in memory: a `Uint8Array` (a `Buffer` is one) or a string,
|
|
204
|
+
* read as its UTF-8. With a plan it is bound now; without one (`undefined` or `null`)
|
|
205
|
+
* the header is read and the reader waits for `bind`. The dialect defaults to
|
|
206
|
+
* `Dialect.CSV`. Never throws: anything that stops it is the outcome's `error`.
|
|
207
|
+
*/
|
|
208
|
+
static fromBytes(bytes: Uint8Array | string, dialect?: Dialect | null, plan?: ReadonlyArray<Column> | null, options?: DelimitedOptions | null): Outcome<DelimitedReader>
|
|
209
|
+
/**
|
|
210
|
+
* Opens the file at `path` and reads it a buffer at a time, as `fromBytes` reads memory.
|
|
211
|
+
* The core judges the options' sizes before the file is opened.
|
|
212
|
+
*/
|
|
213
|
+
static open(path: string, dialect?: Dialect | null, plan?: ReadonlyArray<Column> | null, options?: DelimitedOptions | null): Outcome<DelimitedReader>
|
|
214
|
+
/**
|
|
215
|
+
* Samples the file at `path` and suggests a plan for it, never applying it: each column
|
|
216
|
+
* tried against the doors, with a report saying how far the sample settles it. A
|
|
217
|
+
* starting point to inspect; declaring the number format and date order settles what a
|
|
218
|
+
* sample cannot.
|
|
219
|
+
*/
|
|
220
|
+
static suggest(path: string, dialect?: Dialect | null, options?: SuggestOptions | null): Outcome<Suggestion>
|
|
221
|
+
/** `suggest`, over delimited text held in memory: a `Uint8Array` or a string. */
|
|
222
|
+
static suggestBytes(bytes: Uint8Array | string, dialect?: Dialect | null, options?: SuggestOptions | null): Outcome<Suggestion>
|
|
223
|
+
/**
|
|
224
|
+
* Declares the plan a reader opened without one reads through: once, before the first
|
|
225
|
+
* read.
|
|
226
|
+
*/
|
|
227
|
+
bind(plan: ReadonlyArray<Column>): Outcome<null>
|
|
228
|
+
/**
|
|
229
|
+
* Reads the next batch: the batch, `null` once the text is exhausted, or the error that
|
|
230
|
+
* stopped it — a structural failure only after every intact row before it was
|
|
231
|
+
* delivered, and again on every read after.
|
|
232
|
+
*/
|
|
233
|
+
read(): Outcome<Batch | null>
|
|
234
|
+
/**
|
|
235
|
+
* Releases the reader's buffers and its file now, rather than when it is collected.
|
|
236
|
+
* Batches already read stay valid; a read or bind after it is a `closed` error. Closing
|
|
237
|
+
* twice is no error.
|
|
238
|
+
*/
|
|
239
|
+
close(): Outcome<null>
|
|
240
|
+
/**
|
|
241
|
+
* Whether a plan has been bound; `false` once closed. Throws the `busy` error from
|
|
242
|
+
* inside one of the reader's own calls.
|
|
243
|
+
*/
|
|
244
|
+
get isBound(): boolean
|
|
245
|
+
/**
|
|
246
|
+
* The header record's names, or `null` if the dialect declares no header, and once
|
|
247
|
+
* closed. Throws the `busy` error from inside one of the reader's own calls.
|
|
248
|
+
*/
|
|
249
|
+
get header(): Header | null
|
|
250
|
+
/**
|
|
251
|
+
* How many cells a record has: the header's count, or the first record's once it has
|
|
252
|
+
* been read; `null` before either, and once closed. Throws the `busy` error from inside
|
|
253
|
+
* one of the reader's own calls.
|
|
254
|
+
*/
|
|
255
|
+
get columnCount(): number | null
|
|
256
|
+
/**
|
|
257
|
+
* How many records have been read, the header among them; `null` once closed. Throws
|
|
258
|
+
* the `busy` error from inside one of the reader's own calls.
|
|
259
|
+
*/
|
|
260
|
+
get records(): number | null
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The names a source's header declared, in column order. */
|
|
264
|
+
export declare class Header {
|
|
265
|
+
/** Every name, in column order (bytes that are not UTF-8 replaced by U+FFFD). */
|
|
266
|
+
get names(): Array<string>
|
|
267
|
+
/** How many columns the header names. */
|
|
268
|
+
get length(): number
|
|
269
|
+
/**
|
|
270
|
+
* The first column with exactly this name (byte for byte, case and spaces included; a
|
|
271
|
+
* `Uint8Array` is matched against the bytes the file holds), or `null` if none has it.
|
|
272
|
+
* Two columns with the name answer the first: `require` refuses that instead.
|
|
273
|
+
*/
|
|
274
|
+
ordinal(name: string | Uint8Array): number | null
|
|
275
|
+
/**
|
|
276
|
+
* The column with exactly this name: the `noColumn` error naming it if none has it, and
|
|
277
|
+
* the `ambiguousColumn` error naming both if two have, since a plan built from names must
|
|
278
|
+
* not choose for its caller.
|
|
279
|
+
*/
|
|
280
|
+
require(name: string | Uint8Array): Outcome<number>
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* A part of a sheet: rows and columns, each 1-based, `0` meaning no limit on that side.
|
|
285
|
+
* Made by `Range.parse` or `Range.of`, never by `new`.
|
|
286
|
+
*/
|
|
287
|
+
export declare class Range {
|
|
288
|
+
/**
|
|
289
|
+
* A range from its text, `A5:F200`: capital column letters, both corners, the last not
|
|
290
|
+
* before the first. Anything else is the `range` error.
|
|
291
|
+
*/
|
|
292
|
+
static parse(text: string): Outcome<Range>
|
|
293
|
+
/**
|
|
294
|
+
* A range from its four numbers, each 1-based, `0` for no limit on that side: what text
|
|
295
|
+
* cannot say, such as every row from the fifth. A last before its first is the `range`
|
|
296
|
+
* error.
|
|
297
|
+
*/
|
|
298
|
+
static of(firstRow: number, firstColumn: number, lastRow: number, lastColumn: number): Outcome<Range>
|
|
299
|
+
get firstRow(): number
|
|
300
|
+
get firstColumn(): number
|
|
301
|
+
get lastRow(): number
|
|
302
|
+
get lastColumn(): number
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** One row of a batch, read across: the batch's store and an index, nothing copied. */
|
|
306
|
+
export declare class Row {
|
|
307
|
+
/** The row's place in its batch. */
|
|
308
|
+
get index(): number
|
|
309
|
+
/** The line or the sheet row it came from. */
|
|
310
|
+
get line(): number
|
|
311
|
+
/**
|
|
312
|
+
* The cell in `column` as HyperCast judged it; a column the row does not have is the
|
|
313
|
+
* contract violation.
|
|
314
|
+
*/
|
|
315
|
+
get<T extends Value = Value>(column: number): Verdict<T>
|
|
316
|
+
/** The cell in `column` as HyperCast's checked door judged it, as `Batch.getChecked`. */
|
|
317
|
+
getChecked<T extends Value = Value>(column: number): CheckedVerdict<T>
|
|
318
|
+
/** What failed in the cell in `column`, as `Batch.detail`. */
|
|
319
|
+
detail(column: number): Detail | null
|
|
320
|
+
/** Where the verdict of the cell in `column` came from, as `Batch.origin`. */
|
|
321
|
+
origin(column: number): Origin | null
|
|
322
|
+
/** The raw text of the cell in `column`, as `Batch.raw`. */
|
|
323
|
+
raw(column: number): Uint8Array
|
|
324
|
+
/** `raw` as a string, as `Batch.rawString`. */
|
|
325
|
+
rawString(column: number): string
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* A forward-only read of one sheet through a plan, a batch at a time. Made by
|
|
330
|
+
* `Workbook.sheet`, never by `new`.
|
|
331
|
+
*/
|
|
332
|
+
export declare class Sheet {
|
|
333
|
+
/**
|
|
334
|
+
* Declares the plan a sheet opened without one reads through: once, before the first
|
|
335
|
+
* read.
|
|
336
|
+
*/
|
|
337
|
+
bind(plan: ReadonlyArray<Column>): Outcome<null>
|
|
338
|
+
/** Reads the next batch, as `DelimitedReader.read` does. */
|
|
339
|
+
read(): Outcome<Batch | null>
|
|
340
|
+
/**
|
|
341
|
+
* Samples the sheet from its first row, under the options it was opened with, and
|
|
342
|
+
* suggests a plan for it, never applying it: as `DelimitedReader.suggest`. A sheet's
|
|
343
|
+
* date column is text, and its typed cells count for every notation. Reads nothing of
|
|
344
|
+
* this sheet's own read.
|
|
345
|
+
*/
|
|
346
|
+
suggest(options?: SuggestOptions | null): Outcome<Suggestion>
|
|
347
|
+
/**
|
|
348
|
+
* Releases the sheet's buffers now, rather than when it is collected (the workbook's
|
|
349
|
+
* bytes stay until the workbook and its sheets are). Batches already read stay valid; a
|
|
350
|
+
* read or bind after it is a `closed` error. Closing twice is no error.
|
|
351
|
+
*/
|
|
352
|
+
close(): Outcome<null>
|
|
353
|
+
/**
|
|
354
|
+
* Whether a plan has been bound; `false` once closed. Throws the `busy` error from
|
|
355
|
+
* inside one of the sheet's own calls.
|
|
356
|
+
*/
|
|
357
|
+
get isBound(): boolean
|
|
358
|
+
/**
|
|
359
|
+
* The header row's names, or `null` if the sheet was opened without a header, and once
|
|
360
|
+
* closed. Throws the `busy` error from inside one of the sheet's own calls.
|
|
361
|
+
*/
|
|
362
|
+
get header(): Header | null
|
|
363
|
+
/** The workbook's date system, as `Workbook.dateSystem`. */
|
|
364
|
+
get dateSystem(): number
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* An open XLSX, ODS or Numbers workbook, read whole into memory it owns (a zip is read from
|
|
369
|
+
* its directory at the end back). Made by `fromBytes` or `open`, never by `new`.
|
|
370
|
+
*/
|
|
371
|
+
export declare class Workbook {
|
|
372
|
+
/** Opens a workbook held in memory, its format told by what is in it. */
|
|
373
|
+
static fromBytes(bytes: Uint8Array): Outcome<Workbook>
|
|
374
|
+
/** Reads the file at `path` into memory and opens it. */
|
|
375
|
+
static open(path: string): Outcome<Workbook>
|
|
376
|
+
/** The kind of workbook it is. */
|
|
377
|
+
get format(): WorkbookFormat
|
|
378
|
+
/**
|
|
379
|
+
* The date system its serials are in, as HyperCast's `ExcelEpoch` numbers it (`1` 1900,
|
|
380
|
+
* `2` 1904).
|
|
381
|
+
*/
|
|
382
|
+
get dateSystem(): number
|
|
383
|
+
/** Its sheets, in its own order. */
|
|
384
|
+
get sheets(): Array<SheetInfo>
|
|
385
|
+
/**
|
|
386
|
+
* Starts a read of one sheet, by index or by name. With a plan it is bound now; without
|
|
387
|
+
* one the header (if the options declare one) is read and the sheet waits for `bind`.
|
|
388
|
+
*/
|
|
389
|
+
sheet(which: number | string, options?: SheetOptions | null, plan?: ReadonlyArray<Column> | null): Outcome<Sheet>
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Makes every batch this environment reads with `make(store, rows, doors)`, `index.js`'s own,
|
|
394
|
+
* rather than as the native `Batch`, which a native finalizer frees only once the event loop
|
|
395
|
+
* turns. Internal to the package: what `make` is given is of no use to anything else.
|
|
396
|
+
*/
|
|
397
|
+
export declare function __makeBatchesWith(make: (store: unknown, rows: number, doors: Array<Door>) => Batch): void
|
|
398
|
+
|
|
399
|
+
/** `Batch.column`, over a store. */
|
|
400
|
+
export declare function batchColumn(store: unknown, column: number): Array<Verdict<Value>>
|
|
401
|
+
|
|
402
|
+
/** `Batch.columnChecked`, over a store. */
|
|
403
|
+
export declare function batchColumnChecked(store: unknown, column: number): Array<CheckedVerdict<Value>>
|
|
404
|
+
|
|
405
|
+
/** `Batch.detail`, over a store. */
|
|
406
|
+
export declare function batchDetail(store: unknown, column: number, row: number): Detail | null
|
|
407
|
+
|
|
408
|
+
/** `Batch.faultCount`, over a store. */
|
|
409
|
+
export declare function batchFaultCount(store: unknown, column: number): number
|
|
410
|
+
|
|
411
|
+
/** `Batch.faults`, over a store. */
|
|
412
|
+
export declare function batchFaults(store: unknown): Array<Problem>
|
|
413
|
+
|
|
414
|
+
/** `Batch.get`, over a store. */
|
|
415
|
+
export declare function batchGet(store: unknown, column: number, row: number): Verdict<Value>
|
|
416
|
+
|
|
417
|
+
/** `Batch.getChecked`, over a store. */
|
|
418
|
+
export declare function batchGetChecked(store: unknown, column: number, row: number): CheckedVerdict<Value>
|
|
419
|
+
|
|
420
|
+
/** `Batch.line`, over a store. */
|
|
421
|
+
export declare function batchLine(store: unknown, row: number): number
|
|
422
|
+
|
|
423
|
+
/** `Batch.origin`, over a store. */
|
|
424
|
+
export declare function batchOrigin(store: unknown, column: number, row: number): Origin | null
|
|
425
|
+
|
|
426
|
+
/** `Batch.raw`, over a store. */
|
|
427
|
+
export declare function batchRaw(store: unknown, column: number, row: number): Uint8Array
|
|
428
|
+
|
|
429
|
+
/** `Batch.rawString`, over a store. */
|
|
430
|
+
export declare function batchRawString(store: unknown, column: number, row: number): string
|
|
431
|
+
|
|
432
|
+
/** The failure case of an outcome: `ok` is `false` and `error` says why. */
|
|
433
|
+
export interface Broken {
|
|
434
|
+
ok: false
|
|
435
|
+
error: TabularError
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** A calendar date with no time and no zone. */
|
|
439
|
+
export interface CalendarDate {
|
|
440
|
+
year: number
|
|
441
|
+
month: number
|
|
442
|
+
day: number
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* A declaration that would settle an ambiguous column: a date order (a HyperCast
|
|
447
|
+
* `DateOrder`, in `order`) or a notation (in `format`).
|
|
448
|
+
*/
|
|
449
|
+
export interface Candidate {
|
|
450
|
+
kind: CandidateKind
|
|
451
|
+
order: number | null
|
|
452
|
+
format: SuggestedFormat | null
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/** What a candidate declares. */
|
|
456
|
+
export type CandidateKind = 'dateOrder' | 'numFormat'
|
|
457
|
+
|
|
458
|
+
/** The closed set of reasons a cell can fail its door: HyperCast's own. */
|
|
459
|
+
export type CastFailure = 'empty' | 'malformed' | 'outOfRange'
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* The success case of a checked cell: `ok` is `true`; `value` is the value (rounded to
|
|
463
|
+
* `multipleOf` when the declaration rounds; at the text door with an `enum`, the declared entry
|
|
464
|
+
* it matched); `adjusted` is true only when rounding changed it; `enumIndex` is the index of the
|
|
465
|
+
* entry a text matched, `null` otherwise. The same type `@skunkwerkx/hypercast` exports.
|
|
466
|
+
*/
|
|
467
|
+
export interface Checked<T> {
|
|
468
|
+
ok: true
|
|
469
|
+
value: T
|
|
470
|
+
adjusted: boolean
|
|
471
|
+
enumIndex: number | null
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* A cell of a column that declares constraints, as HyperCast's checked door judged it: exactly
|
|
476
|
+
* one of `Checked<T>`, `Failure` or `Violated<T>`, told apart by `ok` and then by
|
|
477
|
+
* `'fault' in verdict`. The same type `@skunkwerkx/hypercast` exports.
|
|
478
|
+
*/
|
|
479
|
+
export type CheckedVerdict<T> = Checked<T> | Failure | Violated<T>
|
|
480
|
+
|
|
481
|
+
/** A civil date and time with no zone. */
|
|
482
|
+
export interface CivilDateTime {
|
|
483
|
+
year: number
|
|
484
|
+
month: number
|
|
485
|
+
day: number
|
|
486
|
+
hour: number
|
|
487
|
+
minute: number
|
|
488
|
+
second: number
|
|
489
|
+
nanos: number
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* A HyperCast `Constraints` (`@skunkwerkx/hypercast`'s, made by `Constraints.declare`), as this
|
|
494
|
+
* package reads it: the door it is bound to and the bytes it crosses a C ABI as.
|
|
495
|
+
*/
|
|
496
|
+
export interface DeclaredConstraints {
|
|
497
|
+
/** The door the declaration is bound to, by HyperCast's `Door` code. */
|
|
498
|
+
door: number
|
|
499
|
+
/** Its 104 bytes. */
|
|
500
|
+
packed: Uint8Array
|
|
501
|
+
/** Its `enum` list, empty for none. */
|
|
502
|
+
packedEnum: Uint8Array
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* What a column's date doors read beyond their own shapes: a `DateOptions` of
|
|
507
|
+
* `@skunkwerkx/hypercast`, its month names included.
|
|
508
|
+
*/
|
|
509
|
+
export interface DeclaredDateOptions {
|
|
510
|
+
flags: number
|
|
511
|
+
pivot: number
|
|
512
|
+
months?: { readonly packed: Uint8Array } | null
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/** How a delimited reader sizes what it owns. Each left out is the core's default. */
|
|
516
|
+
export interface DelimitedOptions {
|
|
517
|
+
/**
|
|
518
|
+
* The most rows a batch holds; 4096 when left out. The core refuses `0`, and a batch of
|
|
519
|
+
* the plan that would ask for more memory than a batch may.
|
|
520
|
+
*/
|
|
521
|
+
batchRows?: number
|
|
522
|
+
/**
|
|
523
|
+
* The input buffer a file is read through to begin with (it grows to hold the longest
|
|
524
|
+
* record); 256 KiB when left out. The core refuses `0`.
|
|
525
|
+
*/
|
|
526
|
+
bufferBytes?: number
|
|
527
|
+
/** Whether a batch keeps each cell's `detail` and `origin`; `true` when left out. */
|
|
528
|
+
notes?: boolean
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* What failed in a cell, as HyperCast names it: the names `@skunkwerkx/hypercast`'s
|
|
533
|
+
* `Detail` uses, and `unknown` for one a later core adds that this binding does not know.
|
|
534
|
+
*/
|
|
535
|
+
export type Detail = 'blank' | 'unexpectedCharacter' | 'digitExpected' | 'delimiterExpected' | 'trailingText' | 'noDigits' | 'signMisplaced' | 'parenthesesUnbalanced' | 'markRepeated' | 'groupMisplaced' | 'groupSize' | 'groupInFraction' | 'ambiguousSeparator' | 'fractionNotAllowed' | 'fieldWidth' | 'wrongLength' | 'componentMissing' | 'notRecognized' | 'unknownUnit' | 'invalidUtf8' | 'tooLong' | 'notFinite' | 'notWhole' | 'negativeNotAllowed' | 'tooLarge' | 'tooSmall' | 'tooPrecise' | 'dateFieldOutOfRange' | 'timeFieldOutOfRange' | 'outsideWindow' | 'nonexistentDate' | 'notAScalar' | 'unknown'
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* How delimited text is written. Every field left out is the core's default: comma-
|
|
539
|
+
* separated (`Dialect.CSV`), `"` quoting, a header, blank lines skipped, nothing skipped,
|
|
540
|
+
* short and long rows refused, UTF-8, no tokens.
|
|
541
|
+
*/
|
|
542
|
+
export interface Dialect {
|
|
543
|
+
/** One character: a tab, or printable ASCII other than `"`. */
|
|
544
|
+
separator?: string
|
|
545
|
+
quoting?: boolean
|
|
546
|
+
hasHeader?: boolean
|
|
547
|
+
skipBlankLines?: boolean
|
|
548
|
+
/**
|
|
549
|
+
* Physical lines to pass over first, after a byte-order mark; a quote in one means
|
|
550
|
+
* nothing.
|
|
551
|
+
*/
|
|
552
|
+
skip?: number
|
|
553
|
+
/** Records to discard after those, ahead of the header if there is one. */
|
|
554
|
+
headerRow?: number
|
|
555
|
+
shortRows?: ShortRows
|
|
556
|
+
longRows?: LongRows
|
|
557
|
+
encoding?: Encoding
|
|
558
|
+
/**
|
|
559
|
+
* The exact unquoted cells that stand for no value, in every column without tokens of
|
|
560
|
+
* its own: such a cell is `empty`, its origin `token`. Each distinct list is kept for the
|
|
561
|
+
* life of the process.
|
|
562
|
+
*/
|
|
563
|
+
tokens?: ReadonlyArray<string>
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** A HyperCast door, as a column names the one its cells go through. */
|
|
567
|
+
export type Door = 'bool' | 'i8' | 'i16' | 'i32' | 'i64' | 'u8' | 'u16' | 'u32' | 'u64' | 'f32' | 'f64' | 'decimal' | 'uuid' | 'timestamp' | 'unix' | 'excelSerial' | 'date' | 'dateOrdered' | 'datetime' | 'time' | 'duration' | 'text'
|
|
568
|
+
|
|
569
|
+
/** A signed span: whole seconds, and nanoseconds with the same sign. */
|
|
570
|
+
export interface Duration {
|
|
571
|
+
seconds: number
|
|
572
|
+
nanos: number
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* What the input's bytes are: UTF-8 (the default), or one decoded to it ahead of the read.
|
|
577
|
+
* Never sniffed.
|
|
578
|
+
*/
|
|
579
|
+
export type Encoding = 'utf8' | 'windows1252' | 'latin1' | 'utf16le'
|
|
580
|
+
|
|
581
|
+
/** What went wrong that is not a cell's verdict. */
|
|
582
|
+
export type ErrorKind = 'io' | 'separator' | 'plan' | 'noSheet' | 'noColumn' | 'ambiguousColumn' | 'range' | 'unbound' | 'alreadyBound' | 'structure' | 'argument' | 'closed' | 'busy'
|
|
583
|
+
|
|
584
|
+
/** The failure case of a verdict: `ok` is `false` and `fault` says why. */
|
|
585
|
+
export interface Failure {
|
|
586
|
+
ok: false
|
|
587
|
+
fault: Fault
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/** What a structural failure is, as the core numbers it. */
|
|
591
|
+
export type FailureKind = 'unclosedQuote' | 'columnCount' | 'rowTooLong' | 'notAZip' | 'container' | 'encrypted' | 'method' | 'missingPart' | 'xml' | 'deflate' | 'notAWorkbook' | 'sharedString' | 'tooLarge' | 'iwa' | 'encoding'
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* The failure case of a cell: the reason, and the offending span in bytes of the cell's raw
|
|
595
|
+
* text, so `raw.subarray(offset, offset + length)` is the offending text.
|
|
596
|
+
*/
|
|
597
|
+
export interface Fault {
|
|
598
|
+
/** Why the cell failed its door. */
|
|
599
|
+
reason: CastFailure
|
|
600
|
+
/** Where the offending span starts, in bytes of the cell's raw text. */
|
|
601
|
+
offset: number
|
|
602
|
+
/** How many bytes it runs; 0 for `empty` and for a contract violation. */
|
|
603
|
+
length: number
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* What a record with more cells than the width is: refused (the default); its extra cells
|
|
608
|
+
* dropped and the row listed by `Batch.faults`; or its extra cells dropped silently.
|
|
609
|
+
*/
|
|
610
|
+
export type LongRows = 'reject' | 'report' | 'truncate'
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* The core's version, `major.minor.patch`, decoded from the same packed
|
|
614
|
+
* `hypertabular_version` every other binding probes.
|
|
615
|
+
*/
|
|
616
|
+
export declare function nativeVersion(): string
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Where a cell's verdict came from: a door judged its text (`cell`), its exact unquoted
|
|
620
|
+
* bytes are a declared token (`token`), the row has no such cell (`padded`), or a
|
|
621
|
+
* workbook's formula has no cached value (`uncached`). All but `cell` are `empty`.
|
|
622
|
+
*/
|
|
623
|
+
export type Origin = 'cell' | 'token' | 'padded' | 'uncached'
|
|
624
|
+
|
|
625
|
+
/** The outcome of opening, binding or reading: the value, or the error that stopped it. */
|
|
626
|
+
export type Outcome<T> = Success<T> | Broken
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* What a numeric column's notation is read from: a `NumFormat` of `@skunkwerkx/hypercast`,
|
|
630
|
+
* whose `packed` is the 92-byte layout the core reads.
|
|
631
|
+
*/
|
|
632
|
+
export interface PackedNumFormat {
|
|
633
|
+
packed: Uint8Array
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* One thing that went wrong in a batch (`Batch.faults`): a cell at `malformed` or
|
|
638
|
+
* `outOfRange`, a formula with no cached value, a cell that broke its column's constraints, or
|
|
639
|
+
* a row longer than the width under `longRows: 'report'`. Blanks, tokens and padding are not
|
|
640
|
+
* problems.
|
|
641
|
+
*/
|
|
642
|
+
export interface Problem {
|
|
643
|
+
/** The row in the batch, from zero. */
|
|
644
|
+
row: number
|
|
645
|
+
/** The line (delimited text) or sheet row (a workbook) it came from. */
|
|
646
|
+
line: number
|
|
647
|
+
/** The plan column, or `null` for an entry about the row as a whole. */
|
|
648
|
+
planColumn: number | null
|
|
649
|
+
/** The source column, from zero (a sheet's own, `A` being 0), or `null` for a row. */
|
|
650
|
+
sourceColumn: number | null
|
|
651
|
+
/** The verdict's reason, or `null` for a row and for a violation, which `keyword` names. */
|
|
652
|
+
reason: CastFailure | null
|
|
653
|
+
/** What failed, by HyperCast's `Detail` name, or `null`. */
|
|
654
|
+
detail: Detail | null
|
|
655
|
+
/** Where the verdict came from; `cell` for a row. */
|
|
656
|
+
origin: Origin
|
|
657
|
+
/** The span in the cell's raw text; 0 where there is none. */
|
|
658
|
+
offset: number
|
|
659
|
+
length: number
|
|
660
|
+
/** For a long row, the width the first record fixed and the cells it had; otherwise 0. */
|
|
661
|
+
expected: number
|
|
662
|
+
found: number
|
|
663
|
+
/**
|
|
664
|
+
* For a cell that broke its column's constraints, the keyword it broke, in the OpenAPI
|
|
665
|
+
* spelling (a `Violation`'s); otherwise `null`.
|
|
666
|
+
*/
|
|
667
|
+
keyword: 'minimum' | 'exclusiveMinimum' | 'maximum' | 'exclusiveMaximum' | 'multipleOf' | 'minLength' | 'maxLength' | 'enum' | (string & {}) | null | null
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/** One sheet of a workbook, as its listing names it. */
|
|
671
|
+
export interface SheetInfo {
|
|
672
|
+
/** The sheet's name. */
|
|
673
|
+
name: string
|
|
674
|
+
/** Whether the workbook hides it. A hidden sheet reads like any other. */
|
|
675
|
+
hidden: boolean
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* How a sheet is read. Each left out is the core's default: a header, empty rows skipped,
|
|
680
|
+
* 4096 rows a batch, nothing skipped, the whole sheet, no tokens, notes kept.
|
|
681
|
+
*/
|
|
682
|
+
export interface SheetOptions {
|
|
683
|
+
hasHeader?: boolean
|
|
684
|
+
skipEmptyRows?: boolean
|
|
685
|
+
/** The most rows a batch holds. The core refuses `0`. */
|
|
686
|
+
batchRows?: number
|
|
687
|
+
/** Rows at the range's start to pass over, empty ones included. */
|
|
688
|
+
skip?: number
|
|
689
|
+
/** Rows read and discarded after those, ahead of the header. */
|
|
690
|
+
headerRow?: number
|
|
691
|
+
/** The part of the sheet to read: a `Range`, or its text (`'A5:F200'`). */
|
|
692
|
+
range?: Range | string
|
|
693
|
+
/**
|
|
694
|
+
* The exact text cells that stand for no value, in every column without tokens of its
|
|
695
|
+
* own. Each distinct list is kept for the life of the process.
|
|
696
|
+
*/
|
|
697
|
+
tokens?: ReadonlyArray<string>
|
|
698
|
+
/** Whether a batch keeps each cell's `detail` and `origin`. */
|
|
699
|
+
notes?: boolean
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* What a record with fewer cells than the width is: refused (the default), or padded with
|
|
704
|
+
* `empty` verdicts whose origin is `padded`.
|
|
705
|
+
*/
|
|
706
|
+
export type ShortRows = 'reject' | 'pad'
|
|
707
|
+
|
|
708
|
+
/** A structural failure: what is broken, and where (the core's `Failure`). */
|
|
709
|
+
export interface StructuralFailure {
|
|
710
|
+
/** What is wrong. */
|
|
711
|
+
kind: FailureKind
|
|
712
|
+
/**
|
|
713
|
+
* Delimited text: the zero-based record, the header counted. A workbook: the part of the
|
|
714
|
+
* package being read.
|
|
715
|
+
*/
|
|
716
|
+
record: number
|
|
717
|
+
/** Delimited text: the 1-based line the record starts on. A workbook: the sheet row. */
|
|
718
|
+
line: number
|
|
719
|
+
/**
|
|
720
|
+
* Delimited text: the record's byte offset in the decoded text (an `encoding` failure's
|
|
721
|
+
* counts the original input). A workbook: how far into the part's inflated bytes the
|
|
722
|
+
* read had got.
|
|
723
|
+
*/
|
|
724
|
+
byte: number
|
|
725
|
+
/** What was expected, for the kinds that say. */
|
|
726
|
+
expected: number
|
|
727
|
+
/** What was found, for the kinds that say. */
|
|
728
|
+
found: number
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/** The success case of a verdict or an outcome: `ok` is `true` and `value` is the value. */
|
|
732
|
+
export interface Success<T> {
|
|
733
|
+
ok: true
|
|
734
|
+
value: T
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/** What a sample says of one source column. */
|
|
738
|
+
export interface SuggestedColumn {
|
|
739
|
+
/** The zero-based source column, as a `Column` names it. */
|
|
740
|
+
ordinal: number
|
|
741
|
+
/** The header's name for it, or `null` with no header. */
|
|
742
|
+
name: string | null
|
|
743
|
+
/** The door found: text when unresolved, and under the first candidate when ambiguous. */
|
|
744
|
+
door: Door
|
|
745
|
+
/**
|
|
746
|
+
* What the door declares beside itself (a `UnixPrecision`, `DateOrder` or
|
|
747
|
+
* `ExcelEpoch`), or `null`.
|
|
748
|
+
*/
|
|
749
|
+
declared: number | null
|
|
750
|
+
/** The notation the plan reads a resolved numeric column in, or `null`. */
|
|
751
|
+
format: SuggestedFormat | null
|
|
752
|
+
/** What to choose between: empty unless ambiguous. */
|
|
753
|
+
candidates: Array<Candidate>
|
|
754
|
+
status: SuggestStatus
|
|
755
|
+
/** The cells `door` took. */
|
|
756
|
+
matched: number
|
|
757
|
+
/** The cells that are not blank. */
|
|
758
|
+
sampled: number
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* A notation a suggestion names: the 92 bytes the core reads, which a `Column` factory
|
|
763
|
+
* takes as its `format` and which compare with a HyperCast `NumFormat`'s own `packed`. A
|
|
764
|
+
* copy, the caller's own.
|
|
765
|
+
*/
|
|
766
|
+
export interface SuggestedFormat {
|
|
767
|
+
packed: Uint8Array
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* What a suggestion found: a plan to inspect, change and pass to a read, a report for each
|
|
772
|
+
* source column, and whether the source has rows past the sample. Never applied.
|
|
773
|
+
*/
|
|
774
|
+
export interface Suggestion {
|
|
775
|
+
plan: Array<Column>
|
|
776
|
+
report: Array<SuggestedColumn>
|
|
777
|
+
truncated: boolean
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* What a suggestion is asked with. Each left out is the core's default: a sample of 1,000
|
|
782
|
+
* rows (an explicit `0` is one row), no notation and no date order declared.
|
|
783
|
+
*/
|
|
784
|
+
export interface SuggestOptions {
|
|
785
|
+
/**
|
|
786
|
+
* The most rows the sample holds. It stops at 4096 rows of delimited text and at a
|
|
787
|
+
* sheet's own batch size.
|
|
788
|
+
*/
|
|
789
|
+
sampleRows?: number
|
|
790
|
+
/** Every column's notation: a HyperCast `NumFormat`. */
|
|
791
|
+
format?: PackedNumFormat
|
|
792
|
+
/**
|
|
793
|
+
* A column's own notation, ahead of `format`: `[ordinal, NumFormat]` pairs, the last for
|
|
794
|
+
* an ordinal winning.
|
|
795
|
+
*/
|
|
796
|
+
columnFormats?: ReadonlyArray<readonly [number, PackedNumFormat]>
|
|
797
|
+
/** Every column's date order where the sample leaves it open: a HyperCast `DateOrder`. */
|
|
798
|
+
dateOrder?: number
|
|
799
|
+
/** A column's own date order, ahead of `dateOrder`: `[ordinal, DateOrder]` pairs. */
|
|
800
|
+
columnDateOrders?: ReadonlyArray<readonly [number, number]>
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** How far a sample settles a column. */
|
|
804
|
+
export type SuggestStatus = 'resolved' | 'ambiguous' | 'unresolved'
|
|
805
|
+
|
|
806
|
+
/** Why a reader could not be made, or stopped. */
|
|
807
|
+
export interface TabularError {
|
|
808
|
+
/** What kind of error it is. */
|
|
809
|
+
kind: ErrorKind
|
|
810
|
+
/** What went wrong, in words. */
|
|
811
|
+
message: string
|
|
812
|
+
/** The structural failure, for `structure`. */
|
|
813
|
+
failure?: StructuralFailure
|
|
814
|
+
/** The plan column, for `plan`. */
|
|
815
|
+
column?: number
|
|
816
|
+
/** The first column with the name, for `ambiguousColumn`. */
|
|
817
|
+
first?: number
|
|
818
|
+
/** The next column with the name, for `ambiguousColumn`. */
|
|
819
|
+
second?: number
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** A wall-clock time of day with no date and no zone; `nanos` is `0..=999_999_999`. */
|
|
823
|
+
export interface TimeOfDay {
|
|
824
|
+
hour: number
|
|
825
|
+
minute: number
|
|
826
|
+
second: number
|
|
827
|
+
nanos: number
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** An instant: seconds since 1970-01-01T00:00:00Z and the nanoseconds after them. */
|
|
831
|
+
export interface Timestamp {
|
|
832
|
+
seconds: number
|
|
833
|
+
nanos: number
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/** What a cell holds once it has cast: the value of the door it was read through. */
|
|
837
|
+
export type Value = boolean | number | bigint | string | Timestamp | CalendarDate | TimeOfDay | CivilDateTime | Duration
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* A cell as HyperCast judged it: exactly one of `Success<T>` or `Failure`, told apart by
|
|
841
|
+
* `ok`. The same type `@skunkwerkx/hypercast` exports.
|
|
842
|
+
*/
|
|
843
|
+
export type Verdict<T> = Success<T> | Failure
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* The failure case of a checked cell whose value broke a declared rule: `ok` is `false` and
|
|
847
|
+
* `violation` says which rule, where, and the value. The same type `@skunkwerkx/hypercast`
|
|
848
|
+
* exports.
|
|
849
|
+
*/
|
|
850
|
+
export interface Violated<T> {
|
|
851
|
+
ok: false
|
|
852
|
+
violation: Violation<T>
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* A rule a cell's value broke, in the OpenAPI spelling, with that value exactly as the door
|
|
857
|
+
* cast it (never rounded; at the text door, the judged text, never an `enum` entry) and the
|
|
858
|
+
* span of the judged text, in bytes of the cell's raw text. Keywords are open to additions, so
|
|
859
|
+
* a `switch` over them needs a `default` arm; a code this package does not name yet arrives
|
|
860
|
+
* as `"keyword N"`. The same type `@skunkwerkx/hypercast` exports.
|
|
861
|
+
*/
|
|
862
|
+
export interface Violation<T> {
|
|
863
|
+
keyword: 'minimum' | 'exclusiveMinimum' | 'maximum' | 'exclusiveMaximum' | 'multipleOf' | 'minLength' | 'maxLength' | 'enum' | (string & {})
|
|
864
|
+
value: T
|
|
865
|
+
offset: number
|
|
866
|
+
length: number
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/** The kind of workbook a container holds, told by what is in it. */
|
|
870
|
+
export type WorkbookFormat = 'xlsx' | 'ods' | 'numbers'
|