@d0paminedriven/xlsxdown-wasm32-wasi 0.1.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d0paminedriven/xlsxdown-wasm32-wasi",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -1441,6 +1441,11 @@ try {
1441
1441
  }
1442
1442
  export default __napiModule.exports
1443
1443
  export const XlsxDown = __napiModule.exports.XlsxDown
1444
+ export const CurrencySource = __napiModule.exports.CurrencySource
1445
+ export const DateOrder = __napiModule.exports.DateOrder
1446
+ export const EInvoiceStandard = __napiModule.exports.EInvoiceStandard
1447
+ export const InvoiceDocumentType = __napiModule.exports.InvoiceDocumentType
1448
+ export const InvoiceSource = __napiModule.exports.InvoiceSource
1444
1449
  export const NumberSubtype = __napiModule.exports.NumberSubtype
1445
1450
  export const spreadsheetCells = __napiModule.exports.spreadsheetCells
1446
1451
  export const spreadsheetCellsAsync = __napiModule.exports.spreadsheetCellsAsync
@@ -1,4 +1,4 @@
1
- // napi-rs-artifact-metadata:{"version":2,"rootEntry":"index.js","exports":["XlsxDown","NumberSubtype","spreadsheetCells","spreadsheetCellsAsync"],"managedRootEntries":["browser.js","index.js","xlsxdown-node.wasm","xlsxdown-node.debug.wasm"]}
1
+ // napi-rs-artifact-metadata:{"version":2,"rootEntry":"index.js","exports":["XlsxDown","CurrencySource","DateOrder","EInvoiceStandard","InvoiceDocumentType","InvoiceSource","NumberSubtype","spreadsheetCells","spreadsheetCellsAsync"],"managedRootEntries":["browser.js","index.js","xlsxdown-node.wasm","xlsxdown-node.debug.wasm"]}
2
2
  /* eslint-disable */
3
3
  /* auto-generated by NAPI-RS */
4
4
 
@@ -2298,6 +2298,11 @@ try {
2298
2298
  } catch {}
2299
2299
  module.exports = __napiModule.exports
2300
2300
  module.exports.XlsxDown = __napiModule.exports.XlsxDown
2301
+ module.exports.CurrencySource = __napiModule.exports.CurrencySource
2302
+ module.exports.DateOrder = __napiModule.exports.DateOrder
2303
+ module.exports.EInvoiceStandard = __napiModule.exports.EInvoiceStandard
2304
+ module.exports.InvoiceDocumentType = __napiModule.exports.InvoiceDocumentType
2305
+ module.exports.InvoiceSource = __napiModule.exports.InvoiceSource
2301
2306
  module.exports.NumberSubtype = __napiModule.exports.NumberSubtype
2302
2307
  module.exports.spreadsheetCells = __napiModule.exports.spreadsheetCells
2303
2308
  module.exports.spreadsheetCellsAsync = __napiModule.exports.spreadsheetCellsAsync
@@ -22,6 +22,63 @@ export declare class XlsxDown {
22
22
  spreadsheetCells(opts?: SpreadsheetOptions | undefined | null): Array<SheetCells>
23
23
  /** `spreadsheetCells` on a worker thread. */
24
24
  spreadsheetCellsAsync(opts?: SpreadsheetOptions | undefined | null): Promise<Array<SheetCells>>
25
+ /**
26
+ * The cells of the selected sheets keyed by row and then column, so a cell, or a whole row,
27
+ * is one lookup: `rows["12"]["C"]`.
28
+ */
29
+ spreadsheetGrid(opts?: SpreadsheetOptions | undefined | null): Array<SheetGrid>
30
+ /** `spreadsheetGrid` on a worker thread. */
31
+ spreadsheetGridAsync(opts?: SpreadsheetOptions | undefined | null): Promise<Array<SheetGrid>>
32
+ /**
33
+ * The selected sheets laid out as pages: each cell's text placed in its rectangle, broken
34
+ * into words and grouped into lines, every word naming its cell. Cells in hidden rows and
35
+ * columns are left off the page unless `hiddenCells` is set.
36
+ */
37
+ layout(opts?: SpreadsheetOptions | undefined | null): Array<SheetPage>
38
+ /** `layout` on a worker thread. */
39
+ layoutAsync(opts?: SpreadsheetOptions | undefined | null): Promise<Array<SheetPage>>
40
+ /** Invoice fields read from the workbook's visible sheets, each laid out as a page. */
41
+ invoice(opts?: InvoiceOptions | undefined | null): InvoiceResult
42
+ /** `invoice` on a worker thread. */
43
+ invoiceAsync(opts?: InvoiceOptions | undefined | null): Promise<InvoiceResult>
44
+ /**
45
+ * What the workbook says about itself (title, author, dates) and counts of what it holds,
46
+ * sheet by sheet and in total: cells, formulas, merged ranges, tables, pictures, charts,
47
+ * pivot tables, links and comments. Hidden sheets are counted like any other.
48
+ */
49
+ metadata(): XlsxMeta
50
+ /** `metadata` on a worker thread. */
51
+ metadataAsync(): Promise<XlsxMeta>
52
+ }
53
+
54
+ /** `value` is `lines` joined with `
55
+ `. */
56
+ export interface AddressField {
57
+ value: string
58
+ text: string
59
+ confidence: number
60
+ span?: FieldSpan
61
+ lines: Array<string>
62
+ }
63
+
64
+ /**
65
+ * An aircraft or engine the invoice relates to. Maintenance, parts and
66
+ * program invoices identify the asset by airframe (model, manufacturer serial
67
+ * number, registration) and/or by engine (model, engine serial number); one
68
+ * invoice can cover several assets, so `InvoiceFields.aircraft` is a list.
69
+ */
70
+ export interface AircraftReference {
71
+ /** Airframe model, e.g. "Challenger 350", "Global 6000", "Phenom 300". */
72
+ model?: StringField
73
+ /** Manufacturer serial number (MSN). */
74
+ serialNumber?: StringField
75
+ /** Registration / tail number, e.g. "N123AB", "C-GXYZ". */
76
+ registration?: StringField
77
+ /** Engine model, e.g. "BR710", "AE 3007", "PW308C". */
78
+ engineModel?: StringField
79
+ /** Engine serial number (ESN). */
80
+ engineSerialNumber?: StringField
81
+ span?: FieldSpan
25
82
  }
26
83
 
27
84
  /** A rectangle in the sheet frame: points, y up, with A1's top-left corner at `(0, height)`. */
@@ -32,12 +89,184 @@ export interface CellBox {
32
89
  y1: number
33
90
  }
34
91
 
92
+ /**
93
+ * Which tier named the currency: evidence on the page (an ISO code or an unambiguous glyph),
94
+ * content priors such as the vendor's country, the caller's option, or nothing.
95
+ */
96
+ export type CurrencySource = 'Page' | 'Content' | 'Option' | 'Unknown'
97
+
98
+ /** `value` is an ISO 8601 calendar date, `YYYY-MM-DD`. */
99
+ export interface DateField {
100
+ value: string
101
+ text: string
102
+ confidence: number
103
+ span?: FieldSpan
104
+ }
105
+
106
+ export type DateOrder = 'Auto' | 'MDY' | 'DMY' | 'YMD'
107
+
108
+ export type EInvoiceStandard = 'FacturX' | 'ZUGFeRD' | 'XRechnung' | 'UBL' | 'Unknown'
109
+
110
+ export interface EmbeddedInvoiceXml {
111
+ filename: string
112
+ standard: EInvoiceStandard
113
+ /**
114
+ * The guideline / customization identifier, e.g.
115
+ * `urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic`.
116
+ */
117
+ profile?: string
118
+ xml: string
119
+ }
120
+
121
+ /** Where a field was read from, in PDF user space on a 1-based page. */
122
+ export interface FieldSpan {
123
+ page: number
124
+ x0: number
125
+ y0: number
126
+ x1: number
127
+ y1: number
128
+ }
129
+
130
+ export type InvoiceDocumentType = 'Invoice' | 'CreditNote' | 'Unknown'
131
+
132
+ /**
133
+ * Field names mirror the de-facto vocabulary of common invoice extractors so
134
+ * consumers can swap sources with a thin mapper. Naming only: nothing here
135
+ * talks to any service.
136
+ */
137
+ export interface InvoiceFields {
138
+ vendorName?: StringField
139
+ vendorAddress?: AddressField
140
+ vendorTaxId?: StringField
141
+ vendorEmail?: StringField
142
+ vendorPhone?: StringField
143
+ vendorWebsite?: StringField
144
+ customerName?: StringField
145
+ customerId?: StringField
146
+ customerAddress?: AddressField
147
+ customerTaxId?: StringField
148
+ billingAddress?: AddressField
149
+ shippingAddress?: AddressField
150
+ remittanceAddress?: AddressField
151
+ invoiceId?: StringField
152
+ invoiceDate?: DateField
153
+ dueDate?: DateField
154
+ purchaseOrder?: StringField
155
+ paymentTerm?: StringField
156
+ serviceStartDate?: DateField
157
+ serviceEndDate?: DateField
158
+ currencyCode?: string
159
+ subTotal?: MoneyField
160
+ totalDiscount?: MoneyField
161
+ totalTax?: MoneyField
162
+ shippingCost?: MoneyField
163
+ invoiceTotal?: MoneyField
164
+ amountDue?: MoneyField
165
+ previousUnpaidBalance?: MoneyField
166
+ /** MRO work order / shop order the invoice bills against. */
167
+ workOrder?: StringField
168
+ /** Aircraft and engines the invoice relates to; empty when none is identified. */
169
+ aircraft: Array<AircraftReference>
170
+ taxDetails: Array<TaxDetail>
171
+ paymentDetails: Array<PaymentDetail>
172
+ items: Array<InvoiceItem>
173
+ }
174
+
175
+ export interface InvoiceItem {
176
+ description?: StringField
177
+ productCode?: StringField
178
+ quantity?: NumberField
179
+ unit?: StringField
180
+ unitPrice?: MoneyField
181
+ taxRate?: NumberField
182
+ tax?: MoneyField
183
+ discount?: MoneyField
184
+ date?: DateField
185
+ amount?: MoneyField
186
+ /** Absent when the item came from embedded XML (no page geometry). */
187
+ span?: FieldSpan
188
+ }
189
+
190
+ /**
191
+ * Options accepted by every invoice entry point. `preferEmbeddedXml` picks the embedded
192
+ * XML over the pages when both exist; `languages`, `currency`, `dateOrder` and
193
+ * `decimalSeparator` steer the page reader where the page leaves a choice;
194
+ * `includeCandidates` lists, in `warnings`, the candidates each field was chosen from;
195
+ * `includeLayout` is reserved.
196
+ */
197
+ export interface InvoiceOptions {
198
+ /** Label lexicons to enable; default `["en"]`. */
199
+ languages?: Array<string>
200
+ /** ISO 4217 hint when the page shows only symbols. */
201
+ currency?: string
202
+ dateOrder?: DateOrder
203
+ decimalSeparator?: "Auto" | "." | ","
204
+ /** Default `true`. Embedded Factur-X / ZUGFeRD / XRechnung / UBL XML is used when present. */
205
+ preferEmbeddedXml?: boolean
206
+ /** Reserved; accepted and ignored. */
207
+ includeLayout?: boolean
208
+ /**
209
+ * Default `false`. Lists, in `warnings`, the candidates each field was chosen from, with
210
+ * their scores.
211
+ */
212
+ includeCandidates?: boolean
213
+ }
214
+
215
+ export interface InvoiceResult {
216
+ source: InvoiceSource
217
+ documentType: InvoiceDocumentType
218
+ /** Document-level confidence, 0..1. */
219
+ confidence: number
220
+ fields: InvoiceFields
221
+ warnings: Array<string>
222
+ embeddedXml?: EmbeddedInvoiceXml
223
+ /** Which tier named `fields.currencyCode`; absent when no layout pass ran. */
224
+ currencySource?: CurrencySource
225
+ /** The evidence behind `documentType: CreditNote`; empty otherwise. */
226
+ creditSignals: Array<string>
227
+ }
228
+
229
+ /**
230
+ * Which extraction path produced the result: embedded XML, the page text (native, OCR,
231
+ * rendered or mixed), or `None` when the document had no readable
232
+ * pages and no embedded XML.
233
+ */
234
+ export type InvoiceSource = 'EmbeddedXml' | 'Native' | 'Ocr' | 'Rendered' | 'Mixed' | 'None'
235
+
236
+ /**
237
+ * Money as a JS number plus the exact printed text; `text` is authoritative
238
+ * when cents matter.
239
+ */
240
+ export interface MoneyField {
241
+ value: number
242
+ text: string
243
+ confidence: number
244
+ span?: FieldSpan
245
+ currencyCode?: string
246
+ currencySymbol?: string
247
+ }
248
+
249
+ export interface NumberField {
250
+ value: number
251
+ text: string
252
+ confidence: number
253
+ span?: FieldSpan
254
+ }
255
+
35
256
  /**
36
257
  * Whether a Number cell's value is a whole number JavaScript can hold exactly, or a fraction.
37
258
  * A percentage is a fraction (50% is 0.5); the subtype is about the value, not the format.
38
259
  */
39
260
  export type NumberSubtype = 'Integer' | 'Float'
40
261
 
262
+ export interface PaymentDetail {
263
+ iban?: StringField
264
+ swift?: StringField
265
+ bankName?: StringField
266
+ accountNumber?: StringField
267
+ routingNumber?: StringField
268
+ }
269
+
41
270
  /**
42
271
  * One cell of a worksheet: a discriminated union on `type` whose typed value is `value`
43
272
  * (none for `Blank`). A Number carries the full double plus its `subtype` and the
@@ -100,6 +329,104 @@ export interface SheetColumn {
100
329
  hidden: boolean
101
330
  }
102
331
 
332
+ /**
333
+ * One selected worksheet's cells keyed for lookup: `rows["12"]["C"]` is cell C12, and
334
+ * `rows["12"]` is the whole of row 12. Only non-empty cells are present, so a row or a column
335
+ * with nothing in it has no key.
336
+ */
337
+ export interface SheetGrid {
338
+ sheet: string
339
+ /** Position in the workbook, 0-based. */
340
+ index: number
341
+ hidden: boolean
342
+ /** The declared `<dimension>`, which a producer may overstate. */
343
+ dimension?: string
344
+ /** Merged ranges in A1 form. */
345
+ merges: Array<string>
346
+ warnings: Array<string>
347
+ /**
348
+ * Keyed by row number as a reference writes it (`"12"`), then by column letters (`"C"`), each
349
+ * in sheet order.
350
+ */
351
+ rows: Record<string, Record<string, SheetCell>>
352
+ }
353
+
354
+ /**
355
+ * Words sharing a baseline band, left to right. `firstWord` / `wordCount` address a contiguous
356
+ * slice of `SheetPage.words`.
357
+ */
358
+ export interface SheetLine {
359
+ text: string
360
+ x0: number
361
+ y0: number
362
+ x1: number
363
+ y1: number
364
+ firstWord: number
365
+ wordCount: number
366
+ }
367
+
368
+ /** One sheet's counts. */
369
+ export interface SheetMeta {
370
+ name: string
371
+ /** Position in the workbook, 0-based. */
372
+ index: number
373
+ hidden: boolean
374
+ /** The declared `<dimension>`, which a producer may overstate. */
375
+ dimension?: string
376
+ /**
377
+ * From the first to the last row and column that hold a cell, in A1 form: `A1:F20`. Absent
378
+ * for a sheet with no cells. A merged range counts by its first cell only.
379
+ */
380
+ usedRange?: string
381
+ /** The rows and the columns the used range spans. */
382
+ rowCount: number
383
+ columnCount: number
384
+ /**
385
+ * Cells that hold a value or a formula: what `spreadsheetCells` returns for the sheet with
386
+ * `hiddenCells` on.
387
+ */
388
+ cellCount: number
389
+ /** Cells with a formula, the ones that follow a shared formula included. */
390
+ formulaCount: number
391
+ mergedRangeCount: number
392
+ tableCount: number
393
+ /** Pictures on the sheet. */
394
+ imageCount: number
395
+ chartCount: number
396
+ pivotTableCount: number
397
+ /** Links the sheet lists. One link may cover a range of cells. */
398
+ linkCount: number
399
+ /** Cells with a note or a comment thread. */
400
+ commentCount: number
401
+ }
402
+
403
+ /**
404
+ * One selected sheet laid out as a page: every cell's text placed inside the cell's rectangle,
405
+ * broken into words and grouped into lines, with the sheet facts a reader needs beside them.
406
+ */
407
+ export interface SheetPage {
408
+ /** 1-based, in selection order. */
409
+ page: number
410
+ sheet: string
411
+ /** Position in the workbook, 0-based. */
412
+ index: number
413
+ hidden: boolean
414
+ /** The declared `<dimension>`, which a producer may overstate. */
415
+ dimension?: string
416
+ printArea?: string
417
+ /** Merged ranges in A1 form. */
418
+ merges: Array<string>
419
+ /**
420
+ * The page's size in points: the print area when the sheet has one, else A1 to the last
421
+ * non-empty cell, with rows grown to fit their text.
422
+ */
423
+ width: number
424
+ height: number
425
+ words: Array<SheetWord>
426
+ lines: Array<SheetLine>
427
+ warnings: Array<string>
428
+ }
429
+
103
430
  /**
104
431
  * A row whose height differs from the sheet default (auto-fit growth included), or that is
105
432
  * hidden. 0-based.
@@ -111,6 +438,30 @@ export interface SheetRow {
111
438
  hidden: boolean
112
439
  }
113
440
 
441
+ /**
442
+ * One word of a sheet's logical page, with its box in the page frame: points, y up, the page's
443
+ * bottom-left corner at the origin.
444
+ */
445
+ export interface SheetWord {
446
+ text: string
447
+ x0: number
448
+ y0: number
449
+ x1: number
450
+ y1: number
451
+ /** Index into `SheetPage.lines`. */
452
+ line: number
453
+ /** The cell's font: its size in points, its name, and whether it is bold or italic. */
454
+ fontSize?: number
455
+ fontName?: string
456
+ bold?: boolean
457
+ italic?: boolean
458
+ /**
459
+ * The reference of the cell this word was laid out from (`"C3"`); the anchor for a merged
460
+ * range.
461
+ */
462
+ cell: string
463
+ }
464
+
114
465
  /**
115
466
  * The cells of a workbook buffer's selected sheets. Parses the buffer for this call; hold an
116
467
  * `XlsxDown` to read the same workbook more than once.
@@ -135,3 +486,66 @@ export interface SpreadsheetOptions {
135
486
  */
136
487
  hiddenCells?: boolean
137
488
  }
489
+
490
+ export interface StringField {
491
+ value: string
492
+ /** The exact source text the value was derived from. */
493
+ text: string
494
+ confidence: number
495
+ span?: FieldSpan
496
+ }
497
+
498
+ export interface TaxDetail {
499
+ rate?: NumberField
500
+ amount?: MoneyField
501
+ base?: MoneyField
502
+ category?: StringField
503
+ }
504
+
505
+ /**
506
+ * What a workbook says about itself, and counts of what it holds. Hidden sheets, rows and
507
+ * columns are counted like any other: this describes the file, not a selection from it.
508
+ */
509
+ export interface XlsxMeta {
510
+ title?: string
511
+ author?: string
512
+ subject?: string
513
+ /** As written: one string, usually separated by commas or semicolons. */
514
+ keywords?: string
515
+ description?: string
516
+ category?: string
517
+ language?: string
518
+ lastModifiedBy?: string
519
+ revision?: string
520
+ /** When the workbook was created and last saved, as the file writes them. */
521
+ created?: string
522
+ modified?: string
523
+ /** The application that last saved the file, and its version. */
524
+ application?: string
525
+ appVersion?: string
526
+ company?: string
527
+ /** Every sheet, the hidden ones included. */
528
+ sheetCount: number
529
+ hiddenSheetCount: number
530
+ /** Cells that hold a value or a formula, over every sheet. */
531
+ cellCount: number
532
+ formulaCount: number
533
+ mergedRangeCount: number
534
+ /** Words of the cells that hold text, counted from what those cells show. */
535
+ wordCount: number
536
+ /** Characters of those cells that are not white space. */
537
+ characterCount: number
538
+ tableCount: number
539
+ imageCount: number
540
+ chartCount: number
541
+ pivotTableCount: number
542
+ /** Names the workbook defines, the built-in ones (a print area, a filter) left out. */
543
+ definedNameCount: number
544
+ /** Links and comments. */
545
+ annotationCount: number
546
+ linkCount: number
547
+ commentCount: number
548
+ /** Whether dates count from 1904, as workbooks from old versions of Excel for Mac do. */
549
+ date1904: boolean
550
+ sheets: Array<SheetMeta>
551
+ }
Binary file