@origints/xlsx 0.1.1 → 0.3.2
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 +235 -105
- package/dist/index.cjs +40 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.es.js +23997 -832
- package/dist/index.es.js.map +1 -1
- package/dist/parse.d.ts +11 -2
- package/dist/xlsx-cell.d.ts +85 -18
- package/dist/xlsx-cursor.d.ts +2 -0
- package/dist/xlsx-predicate-compiler.d.ts +24 -0
- package/dist/xlsx-predicate-spec.d.ts +211 -0
- package/dist/xlsx-range.d.ts +10 -4
- package/dist/xlsx-sheet.d.ts +18 -15
- package/dist/xlsx-spec-builder.d.ts +220 -0
- package/dist/xlsx-spec-executor.d.ts +25 -0
- package/dist/xlsx-spec.d.ts +121 -0
- package/dist/xlsx-workbook.d.ts +8 -11
- package/package.json +23 -3
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { StepBuilder, ArraySpec, ObjectSpec, ExtractSpec, Spec, SpecLike } from '@origints/core';
|
|
2
|
+
import { XlsxStep, Direction } from './xlsx-spec';
|
|
3
|
+
import { CellPred, SheetPred, RowPred } from './xlsx-predicate-spec';
|
|
4
|
+
/**
|
|
5
|
+
* Spec builder at the cell level — terminal extraction and navigation methods.
|
|
6
|
+
*/
|
|
7
|
+
export declare class XlsxCellSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
8
|
+
protected get format(): "xlsx";
|
|
9
|
+
/** @internal */
|
|
10
|
+
constructor(steps: readonly XlsxStep[]);
|
|
11
|
+
/** @internal Expose steps for colWhere/rowWhere headerRef */
|
|
12
|
+
get _steps(): readonly XlsxStep[];
|
|
13
|
+
/** Extract cell value as string */
|
|
14
|
+
string(): ExtractSpec<XlsxStep, 'string'>;
|
|
15
|
+
/** Extract cell value as number */
|
|
16
|
+
number(): ExtractSpec<XlsxStep, 'number'>;
|
|
17
|
+
/** Extract cell value as boolean */
|
|
18
|
+
boolean(): ExtractSpec<XlsxStep, 'boolean'>;
|
|
19
|
+
/** Extract cell value as Date */
|
|
20
|
+
date(): ExtractSpec<XlsxStep, 'date'>;
|
|
21
|
+
/** Extract raw cell value */
|
|
22
|
+
value(): ExtractSpec<XlsxStep, 'value'>;
|
|
23
|
+
/** Extract cell formula */
|
|
24
|
+
formula(): ExtractSpec<XlsxStep, 'formula'>;
|
|
25
|
+
/** Extract cell value as string, returning default on failure */
|
|
26
|
+
optionalString(defaultValue?: unknown): ExtractSpec<XlsxStep, 'string'>;
|
|
27
|
+
/** Extract cell value as number, returning default on failure */
|
|
28
|
+
optionalNumber(defaultValue?: unknown): ExtractSpec<XlsxStep, 'number'>;
|
|
29
|
+
/** Extract cell value as boolean, returning default on failure */
|
|
30
|
+
optionalBoolean(defaultValue?: unknown): ExtractSpec<XlsxStep, 'boolean'>;
|
|
31
|
+
/** Extract cell value as Date, returning default on failure */
|
|
32
|
+
optionalDate(defaultValue?: unknown): ExtractSpec<XlsxStep, 'date'>;
|
|
33
|
+
/** Extract raw cell value, returning default on failure */
|
|
34
|
+
optionalValue(defaultValue?: unknown): ExtractSpec<XlsxStep, 'value'>;
|
|
35
|
+
/** Move right by count cells (default 1) */
|
|
36
|
+
right(count?: number): XlsxCellSB;
|
|
37
|
+
/** Move left by count cells (default 1) */
|
|
38
|
+
left(count?: number): XlsxCellSB;
|
|
39
|
+
/** Move up by count cells (default 1) */
|
|
40
|
+
up(count?: number): XlsxCellSB;
|
|
41
|
+
/** Move down by count cells (default 1) */
|
|
42
|
+
down(count?: number): XlsxCellSB;
|
|
43
|
+
/** Move by row and column deltas */
|
|
44
|
+
offset(rowDelta: number, colDelta: number): XlsxCellSB;
|
|
45
|
+
/** Scan in direction until predicate matches */
|
|
46
|
+
scanTo(direction: Direction, predicate: CellPred): XlsxCellSB;
|
|
47
|
+
/** Skip cells in direction while predicate matches, land on first non-matching */
|
|
48
|
+
skipWhile(direction: Direction, predicate: CellPred): XlsxCellSB;
|
|
49
|
+
/**
|
|
50
|
+
* Iterate over cells from this position in a direction while the predicate matches.
|
|
51
|
+
* Returns an ArraySpec whose items are produced by the itemMapper.
|
|
52
|
+
* The mapper can return a Spec, a FluentSpec, or a plain record (auto-wrapped to ObjectSpec).
|
|
53
|
+
*/
|
|
54
|
+
eachCell<T extends Spec>(direction: Direction, while_: CellPred, itemMapper: (cell: XlsxCellSB) => T): ArraySpec<T>;
|
|
55
|
+
eachCell(direction: Direction, while_: CellPred, itemMapper: (cell: XlsxCellSB) => Record<string, SpecLike>): ArraySpec<ObjectSpec>;
|
|
56
|
+
/**
|
|
57
|
+
* Iterate over slices (rows or columns) from this cell position.
|
|
58
|
+
* Each slice is passed as an XlsxSliceSB to the mapper, providing
|
|
59
|
+
* header-relative column/row access via colWhere/rowWhere.
|
|
60
|
+
* The mapper can return a Spec, a FluentSpec, or a plain record (auto-wrapped to ObjectSpec).
|
|
61
|
+
*/
|
|
62
|
+
eachSlice<T extends Spec>(direction: Direction, while_: RowPred, itemMapper: (slice: XlsxSliceSB) => T): ArraySpec<T>;
|
|
63
|
+
eachSlice(direction: Direction, while_: RowPred, itemMapper: (slice: XlsxSliceSB) => Record<string, SpecLike>): ArraySpec<ObjectSpec>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* XLSX extract type for column definitions.
|
|
67
|
+
*/
|
|
68
|
+
export type XlsxExtractType = 'string' | 'number' | 'boolean' | 'date' | 'value' | 'formula';
|
|
69
|
+
/**
|
|
70
|
+
* Column definition for XLSX `columns()` shorthand.
|
|
71
|
+
*
|
|
72
|
+
* - `CellPred` — `colWhere(header, pred).string()`
|
|
73
|
+
* - `[CellPred, XlsxExtractType]` — `colWhere(header, pred).{type}()`
|
|
74
|
+
* - `[number, XlsxExtractType?]` — `col(offset).{type ?? 'string'}()`
|
|
75
|
+
* - `SpecLike` — passthrough (any Spec or FluentSpec)
|
|
76
|
+
*/
|
|
77
|
+
export type XlsxColumnDef = CellPred | [CellPred, XlsxExtractType] | [number, XlsxExtractType?] | SpecLike;
|
|
78
|
+
/**
|
|
79
|
+
* Spec builder for items within a slice (row or column section).
|
|
80
|
+
* Provides header-relative column/row access.
|
|
81
|
+
*/
|
|
82
|
+
export declare class XlsxSliceSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
83
|
+
protected get format(): "xlsx";
|
|
84
|
+
/** @internal */
|
|
85
|
+
constructor(steps: readonly XlsxStep[]);
|
|
86
|
+
/** Access a column by matching its header cell against a predicate (header-relative) */
|
|
87
|
+
colWhere(headerRef: XlsxCellSB, predicate: CellPred): XlsxCellSB;
|
|
88
|
+
/** Access a row by matching its header cell against a predicate (header-relative, for rotated tables) */
|
|
89
|
+
rowWhere(headerRef: XlsxCellSB, predicate: CellPred): XlsxCellSB;
|
|
90
|
+
/** Access a column by 0-based offset from the anchor */
|
|
91
|
+
col(offset: number): XlsxCellSB;
|
|
92
|
+
/** Access a row by 0-based offset from the anchor (for rotated tables) */
|
|
93
|
+
row(offset: number): XlsxCellSB;
|
|
94
|
+
/**
|
|
95
|
+
* Extract multiple columns at once, producing an ObjectSpec.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* row.columns(header, {
|
|
100
|
+
* name: cell.equals('Investment'), // colWhere(header, pred).string()
|
|
101
|
+
* amount: [cell.contains('Amount'), 'number'], // colWhere(header, pred).number()
|
|
102
|
+
* note: [2, 'string'], // col(2).string()
|
|
103
|
+
* custom: fluent(row.col(0).string()).map(v => v.trim(), 'trim'), // passthrough
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
columns(headerRef: XlsxCellSB, mapping: Record<string, XlsxColumnDef>): ObjectSpec;
|
|
108
|
+
/** @internal Resolve a single column definition to a Spec */
|
|
109
|
+
private _resolveColumnDef;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Spec builder for items within a row (receives an XlsxRange representing one row).
|
|
113
|
+
* Provides column access to navigate within the row.
|
|
114
|
+
*/
|
|
115
|
+
export declare class XlsxRowItemSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
116
|
+
protected get format(): "xlsx";
|
|
117
|
+
/** @internal */
|
|
118
|
+
constructor(steps: readonly XlsxStep[]);
|
|
119
|
+
/** Access a column by 1-based index within the row */
|
|
120
|
+
col(index: number): XlsxCellSB;
|
|
121
|
+
/** Navigate to a cell by address within the row */
|
|
122
|
+
cell(ref: string): XlsxCellSB;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Spec builder at the range level — cell navigation, rows, and cells collection.
|
|
126
|
+
*/
|
|
127
|
+
export declare class XlsxRangeSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
128
|
+
protected get format(): "xlsx";
|
|
129
|
+
/** @internal */
|
|
130
|
+
constructor(steps: readonly XlsxStep[]);
|
|
131
|
+
/** Navigate to a cell by address within the range */
|
|
132
|
+
cell(ref: string): XlsxCellSB;
|
|
133
|
+
/** Navigate to a cell by coordinates within the range */
|
|
134
|
+
cellAt(row: number, col: number): XlsxCellSB;
|
|
135
|
+
/**
|
|
136
|
+
* Iterate over rows in the range.
|
|
137
|
+
* Each row is provided as an XlsxRowItemSB to the mapper.
|
|
138
|
+
* Returns an ArraySpec.
|
|
139
|
+
*/
|
|
140
|
+
rows<T extends Spec>(itemMapper: (row: XlsxRowItemSB) => T): ArraySpec<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Iterate over all cells in the range as a flat list.
|
|
143
|
+
* Each cell is provided as an XlsxCellSB to the mapper.
|
|
144
|
+
* Returns an ArraySpec.
|
|
145
|
+
*/
|
|
146
|
+
cells<T extends Spec>(itemMapper: (cell: XlsxCellSB) => T): ArraySpec<T>;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Spec builder at the row level.
|
|
150
|
+
*/
|
|
151
|
+
export declare class XlsxRowSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
152
|
+
protected get format(): "xlsx";
|
|
153
|
+
/** @internal */
|
|
154
|
+
constructor(steps: readonly XlsxStep[]);
|
|
155
|
+
/** Navigate to a cell by address within this row */
|
|
156
|
+
cell(ref: string): XlsxCellSB;
|
|
157
|
+
/** Navigate to a cell by column within this row */
|
|
158
|
+
cellAt(row: number, col: number): XlsxCellSB;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Spec builder at the column level.
|
|
162
|
+
*/
|
|
163
|
+
export declare class XlsxColSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
164
|
+
protected get format(): "xlsx";
|
|
165
|
+
/** @internal */
|
|
166
|
+
constructor(steps: readonly XlsxStep[]);
|
|
167
|
+
/** Navigate to a cell by address within this column */
|
|
168
|
+
cell(ref: string): XlsxCellSB;
|
|
169
|
+
/** Navigate to a cell by coordinates within this column */
|
|
170
|
+
cellAt(row: number, col: number): XlsxCellSB;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Spec builder at the sheet level — cell, range, row, column, and search navigation.
|
|
174
|
+
*/
|
|
175
|
+
export declare class XlsxSheetSB extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
176
|
+
protected get format(): "xlsx";
|
|
177
|
+
/** @internal */
|
|
178
|
+
constructor(steps: readonly XlsxStep[]);
|
|
179
|
+
/** Navigate to a cell by address (e.g., "A1", "B2") */
|
|
180
|
+
cell(ref: string): XlsxCellSB;
|
|
181
|
+
/** Navigate to a cell by 1-based row and column coordinates */
|
|
182
|
+
cellAt(row: number, col: number): XlsxCellSB;
|
|
183
|
+
/** Find the first cell matching the predicate */
|
|
184
|
+
find(predicate: CellPred): XlsxCellSB;
|
|
185
|
+
/** Find the first cell matching the predicate in the specified row */
|
|
186
|
+
findInRow(rowIndex: number, predicate: CellPred): XlsxCellSB;
|
|
187
|
+
/** Find the first cell matching the predicate in the specified column */
|
|
188
|
+
findInCol(colIndex: number, predicate: CellPred): XlsxCellSB;
|
|
189
|
+
/** Find the first cell matching the predicate in the specified range */
|
|
190
|
+
findInRange(rangeRef: string, predicate: CellPred): XlsxCellSB;
|
|
191
|
+
/** Navigate to a range by address (e.g., "A1:C10") */
|
|
192
|
+
range(ref: string): XlsxRangeSB;
|
|
193
|
+
/** Navigate to a range by two corner addresses */
|
|
194
|
+
range(from: string, to: string): XlsxRangeSB;
|
|
195
|
+
/** Navigate to a range defined by two dynamically resolved cells */
|
|
196
|
+
range(from: XlsxCellSB, to: XlsxCellSB): XlsxRangeSB;
|
|
197
|
+
/** Navigate to a row by 1-based index */
|
|
198
|
+
row(index: number): XlsxRowSB;
|
|
199
|
+
/** Navigate to a column by 1-based index */
|
|
200
|
+
col(index: number): XlsxColSB;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Spec builder for XLSX workbook — the entry point for xlsx navigation specs.
|
|
204
|
+
*
|
|
205
|
+
* Used as `$` in `emit()` after `.mapIn(parseXlsx())`.
|
|
206
|
+
*/
|
|
207
|
+
export declare class XlsxSpecBuilder extends StepBuilder<XlsxStep, 'xlsx'> {
|
|
208
|
+
protected get format(): "xlsx";
|
|
209
|
+
private constructor();
|
|
210
|
+
/** Create a root spec builder */
|
|
211
|
+
static root(): XlsxSpecBuilder;
|
|
212
|
+
/** Navigate to a sheet by name */
|
|
213
|
+
sheet(name: string): XlsxSheetSB;
|
|
214
|
+
/** Navigate to a sheet by 1-based index */
|
|
215
|
+
sheetAt(index: number): XlsxSheetSB;
|
|
216
|
+
/** Navigate to the first sheet */
|
|
217
|
+
firstSheet(): XlsxSheetSB;
|
|
218
|
+
/** Find a sheet matching the predicate */
|
|
219
|
+
findSheet(predicate: SheetPred): XlsxSheetSB;
|
|
220
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TYPE_LABEL, ExtractionResult, SpecScope } from '@origints/core';
|
|
2
|
+
import { XlsxSpec } from './xlsx-spec';
|
|
3
|
+
import { XlsxWorkbook } from './xlsx-workbook';
|
|
4
|
+
import { XlsxSheet } from './xlsx-sheet';
|
|
5
|
+
import { XlsxCell } from './xlsx-cell';
|
|
6
|
+
/**
|
|
7
|
+
* Context wrapper for slice items.
|
|
8
|
+
* Carries workbook+sheet references so colWhere/rowWhere can resolve headers.
|
|
9
|
+
*/
|
|
10
|
+
export declare class XlsxSliceContext {
|
|
11
|
+
readonly workbook: XlsxWorkbook;
|
|
12
|
+
readonly sheet: XlsxSheet;
|
|
13
|
+
readonly anchorCell: XlsxCell;
|
|
14
|
+
get [TYPE_LABEL](): string;
|
|
15
|
+
constructor(workbook: XlsxWorkbook, sheet: XlsxSheet, anchorCell: XlsxCell);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Execute an XlsxSpec against data.
|
|
19
|
+
*
|
|
20
|
+
* The executor is polymorphic — it detects the input type:
|
|
21
|
+
* - XlsxWorkbook → starts at workbook level
|
|
22
|
+
* - XlsxRange → starts at range level (used for row items)
|
|
23
|
+
* - XlsxCell → starts at cell level (used for cell items)
|
|
24
|
+
*/
|
|
25
|
+
export declare function executeXlsxSpec(spec: XlsxSpec, data: unknown, scope?: SpecScope): ExtractionResult<unknown>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ExtractSpec, Spec } from '@origints/core';
|
|
2
|
+
import { CellPredicateSpec, SheetPredicateSpec, RowPredicateSpec } from './xlsx-predicate-spec';
|
|
3
|
+
/**
|
|
4
|
+
* Direction for cell navigation.
|
|
5
|
+
*/
|
|
6
|
+
export type Direction = 'right' | 'left' | 'up' | 'down';
|
|
7
|
+
/**
|
|
8
|
+
* A single navigation step through an XLSX workbook.
|
|
9
|
+
*/
|
|
10
|
+
export type XlsxStep = {
|
|
11
|
+
readonly kind: 'sheet';
|
|
12
|
+
readonly name: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'sheetAt';
|
|
15
|
+
readonly index: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'firstSheet';
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'findSheet';
|
|
20
|
+
readonly predicate: SheetPredicateSpec;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'find';
|
|
23
|
+
readonly predicate: CellPredicateSpec;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'findInRow';
|
|
26
|
+
readonly rowIndex: number;
|
|
27
|
+
readonly predicate: CellPredicateSpec;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'findInCol';
|
|
30
|
+
readonly colIndex: number;
|
|
31
|
+
readonly predicate: CellPredicateSpec;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'findInRange';
|
|
34
|
+
readonly rangeRef: string;
|
|
35
|
+
readonly predicate: CellPredicateSpec;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'cell';
|
|
38
|
+
readonly ref: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'cellAt';
|
|
41
|
+
readonly row: number;
|
|
42
|
+
readonly col: number;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'right';
|
|
45
|
+
readonly count: number;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: 'left';
|
|
48
|
+
readonly count: number;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'up';
|
|
51
|
+
readonly count: number;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'down';
|
|
54
|
+
readonly count: number;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: 'offset';
|
|
57
|
+
readonly rowDelta: number;
|
|
58
|
+
readonly colDelta: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: 'scanTo';
|
|
61
|
+
readonly direction: Direction;
|
|
62
|
+
readonly predicate: CellPredicateSpec;
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: 'skipWhile';
|
|
65
|
+
readonly direction: Direction;
|
|
66
|
+
readonly predicate: CellPredicateSpec;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'colWhere';
|
|
69
|
+
readonly headerRef: Spec;
|
|
70
|
+
readonly predicate: CellPredicateSpec;
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: 'rowWhere';
|
|
73
|
+
readonly headerRef: Spec;
|
|
74
|
+
readonly predicate: CellPredicateSpec;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: 'range';
|
|
77
|
+
readonly ref: string;
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: 'rangeFromCells';
|
|
80
|
+
readonly from: Spec;
|
|
81
|
+
readonly to: Spec;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: 'row';
|
|
84
|
+
readonly index: number;
|
|
85
|
+
} | {
|
|
86
|
+
readonly kind: 'col';
|
|
87
|
+
readonly index: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Specification for iterating over cells in a direction while a predicate matches.
|
|
91
|
+
*/
|
|
92
|
+
export interface EachCellExtract {
|
|
93
|
+
readonly kind: 'eachCell';
|
|
94
|
+
readonly direction: Direction;
|
|
95
|
+
readonly while: CellPredicateSpec;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Specification for iterating over slices (rows or columns) in a direction
|
|
99
|
+
* while a row-level predicate matches. Each slice is an anchor cell
|
|
100
|
+
* wrapped in XlsxSliceContext for header-relative navigation.
|
|
101
|
+
*/
|
|
102
|
+
export interface EachSliceExtract {
|
|
103
|
+
readonly kind: 'eachSlice';
|
|
104
|
+
readonly direction: Direction;
|
|
105
|
+
readonly while: RowPredicateSpec;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The terminal extraction type for an XLSX value.
|
|
109
|
+
*
|
|
110
|
+
* - Cell-level: 'string', 'number', 'boolean', 'date', 'value', 'formula'
|
|
111
|
+
* - Range-level (produce arrays): 'rows', 'cells'
|
|
112
|
+
* - Cell-level (produce arrays): EachCellExtract, EachSliceExtract
|
|
113
|
+
*/
|
|
114
|
+
export type XlsxExtract = 'string' | 'number' | 'boolean' | 'date' | 'value' | 'formula' | 'rows' | 'cells' | EachCellExtract | EachSliceExtract;
|
|
115
|
+
/**
|
|
116
|
+
* A complete XLSX extraction spec.
|
|
117
|
+
*
|
|
118
|
+
* Describes a path through the workbook (steps) and what to extract (extract).
|
|
119
|
+
* JSON-serializable and suitable for AST introspection.
|
|
120
|
+
*/
|
|
121
|
+
export type XlsxSpec = ExtractSpec<XlsxStep, XlsxExtract>;
|
package/dist/xlsx-workbook.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TYPE_LABEL } from '@origints/core';
|
|
2
2
|
import { XlsxSheet } from './xlsx-sheet';
|
|
3
3
|
import { XlsxResult, XlsxPath } from './xlsx-result';
|
|
4
4
|
/**
|
|
@@ -17,21 +17,23 @@ export interface WorkbookProperties {
|
|
|
17
17
|
readonly modified?: Date;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* A wrapper around
|
|
20
|
+
* A wrapper around workbook data with navigation and query capabilities.
|
|
21
21
|
*
|
|
22
22
|
* XlsxWorkbook provides access to sheets, workbook properties, and
|
|
23
23
|
* supports predicate-based queries for finding sheets.
|
|
24
24
|
*/
|
|
25
25
|
export declare class XlsxWorkbook {
|
|
26
|
-
private readonly workbook;
|
|
27
26
|
private readonly _path;
|
|
28
|
-
|
|
27
|
+
get [TYPE_LABEL](): string;
|
|
28
|
+
private readonly _sheets;
|
|
29
|
+
private readonly _sheetsByName;
|
|
30
|
+
private readonly _props;
|
|
29
31
|
private constructor();
|
|
30
32
|
/**
|
|
31
|
-
* Creates an XlsxWorkbook from
|
|
33
|
+
* Creates an XlsxWorkbook from internal data.
|
|
32
34
|
* @internal
|
|
33
35
|
*/
|
|
34
|
-
static
|
|
36
|
+
static create(sheets: XlsxSheet[], props: WorkbookProperties, file?: string): XlsxWorkbook;
|
|
35
37
|
/**
|
|
36
38
|
* Returns the path for lineage tracking.
|
|
37
39
|
*/
|
|
@@ -120,9 +122,4 @@ export declare class XlsxWorkbook {
|
|
|
120
122
|
* Map over all sheets.
|
|
121
123
|
*/
|
|
122
124
|
map<T>(fn: (sheet: XlsxSheet, index: number) => T): T[];
|
|
123
|
-
/**
|
|
124
|
-
* Get the underlying ExcelJS workbook.
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
getWorkbook(): Workbook;
|
|
128
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origints/xlsx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "XLSX parsing for Origins with full traceability to sheets, ranges, and cells.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,14 +27,34 @@
|
|
|
27
27
|
"lint": "eslint \"{src,tests}/**/*.{ts,tsx}\" --max-warnings 0",
|
|
28
28
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
29
29
|
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/fponticelli/origints.git",
|
|
33
|
+
"directory": "packages/xlsx"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://origints.dev",
|
|
36
|
+
"bugs": "https://github.com/fponticelli/origints/issues",
|
|
37
|
+
"keywords": [
|
|
38
|
+
"origints",
|
|
39
|
+
"data-extraction",
|
|
40
|
+
"lineage",
|
|
41
|
+
"provenance",
|
|
42
|
+
"xlsx",
|
|
43
|
+
"excel",
|
|
44
|
+
"spreadsheet"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18"
|
|
48
|
+
},
|
|
30
49
|
"dependencies": {
|
|
31
|
-
"
|
|
50
|
+
"xlsx": "^0.18.5"
|
|
32
51
|
},
|
|
33
52
|
"peerDependencies": {
|
|
34
|
-
"@origints/core": "^0.
|
|
53
|
+
"@origints/core": "^0.3.0"
|
|
35
54
|
},
|
|
36
55
|
"devDependencies": {
|
|
37
56
|
"@origints/core": "workspace:*",
|
|
57
|
+
"exceljs": "^4.4.0",
|
|
38
58
|
"@types/node": "25.0.6",
|
|
39
59
|
"@vitest/coverage-v8": "^4.0.16",
|
|
40
60
|
"eslint": "9.39.2",
|