@bilig/workbook 0.42.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 +1 -0
- package/README.md +346 -0
- package/dist/check.d.ts +26 -0
- package/dist/check.js +158 -0
- package/dist/check.js.map +1 -0
- package/dist/describe.d.ts +153 -0
- package/dist/describe.js +210 -0
- package/dist/describe.js.map +1 -0
- package/dist/find.d.ts +99 -0
- package/dist/find.js +353 -0
- package/dist/find.js.map +1 -0
- package/dist/formula.d.ts +25 -0
- package/dist/formula.js +135 -0
- package/dist/formula.js.map +1 -0
- package/dist/guards.d.ts +5 -0
- package/dist/guards.js +659 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +22 -0
- package/dist/input.js +231 -0
- package/dist/input.js.map +1 -0
- package/dist/model.d.ts +116 -0
- package/dist/model.js +331 -0
- package/dist/model.js.map +1 -0
- package/dist/ops.d.ts +283 -0
- package/dist/ops.js +2 -0
- package/dist/ops.js.map +1 -0
- package/dist/readback.d.ts +35 -0
- package/dist/readback.js +232 -0
- package/dist/readback.js.map +1 -0
- package/dist/requirements.d.ts +34 -0
- package/dist/requirements.js +223 -0
- package/dist/requirements.js.map +1 -0
- package/dist/result.d.ts +63 -0
- package/dist/result.js +39 -0
- package/dist/result.js.map +1 -0
- package/dist/run.d.ts +21 -0
- package/dist/run.js +514 -0
- package/dist/run.js.map +1 -0
- package/dist/verify.d.ts +33 -0
- package/dist/verify.js +439 -0
- package/dist/verify.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { CellRangeRef, CellStylePatch, LiteralInput } from '@bilig/protocol';
|
|
2
|
+
import type { WorkbookRef, WorkbookRefKind, WorkbookRowOperator } from './find.js';
|
|
3
|
+
import { type WorkbookActionInspection, type WorkbookActionMap, type WorkbookActionPlan, type WorkbookActionPlanResult, type WorkbookModel } from './model.js';
|
|
4
|
+
import type { WorkbookActionInput } from './input.js';
|
|
5
|
+
import type { WorkbookOp } from './ops.js';
|
|
6
|
+
import type { WorkbookCheckStatus, WorkbookRunErrorCode, WorkbookRunResult } from './result.js';
|
|
7
|
+
export interface WorkbookModelDescription {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly description?: string;
|
|
10
|
+
readonly actions: readonly string[];
|
|
11
|
+
readonly actionDetails: readonly WorkbookActionInspection[];
|
|
12
|
+
readonly hasChecks: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkbookBaseRefDescription {
|
|
15
|
+
readonly kind: WorkbookRefKind;
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly label: string;
|
|
18
|
+
}
|
|
19
|
+
export interface WorkbookRangeRefDescription extends WorkbookBaseRefDescription {
|
|
20
|
+
readonly kind: 'range';
|
|
21
|
+
readonly range: CellRangeRef;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkbookNameRefDescription extends WorkbookBaseRefDescription {
|
|
24
|
+
readonly kind: 'name';
|
|
25
|
+
readonly name: string;
|
|
26
|
+
}
|
|
27
|
+
export interface WorkbookTableRefDescription extends WorkbookBaseRefDescription {
|
|
28
|
+
readonly kind: 'table';
|
|
29
|
+
readonly name?: string;
|
|
30
|
+
readonly sheetName?: string;
|
|
31
|
+
readonly headers?: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
export interface WorkbookColumnRefDescription extends WorkbookBaseRefDescription {
|
|
34
|
+
readonly kind: 'column';
|
|
35
|
+
readonly table: WorkbookTableRefDescription;
|
|
36
|
+
readonly rows?: WorkbookRowsRefDescription;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
}
|
|
39
|
+
export interface WorkbookRowsRefDescription extends WorkbookBaseRefDescription {
|
|
40
|
+
readonly kind: 'rows';
|
|
41
|
+
readonly sheetName?: string;
|
|
42
|
+
readonly table?: WorkbookTableRefDescription;
|
|
43
|
+
readonly where: {
|
|
44
|
+
readonly column: string;
|
|
45
|
+
readonly op: WorkbookRowOperator;
|
|
46
|
+
readonly value: LiteralInput;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export type WorkbookRefDescription = WorkbookRangeRefDescription | WorkbookNameRefDescription | WorkbookTableRefDescription | WorkbookColumnRefDescription | WorkbookRowsRefDescription;
|
|
50
|
+
export type WorkbookActionCommandDescription = {
|
|
51
|
+
readonly kind: 'writeFormula';
|
|
52
|
+
readonly target: WorkbookRefDescription;
|
|
53
|
+
readonly formula: string;
|
|
54
|
+
readonly inputs: readonly WorkbookRefDescription[];
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: 'writeValue';
|
|
57
|
+
readonly target: WorkbookRefDescription;
|
|
58
|
+
readonly value: LiteralInput;
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: 'format';
|
|
61
|
+
readonly target: WorkbookRefDescription;
|
|
62
|
+
readonly style?: CellStylePatch;
|
|
63
|
+
readonly numberFormat?: string | null;
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: 'clear';
|
|
66
|
+
readonly target: WorkbookRefDescription;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'op';
|
|
69
|
+
readonly op: WorkbookOp;
|
|
70
|
+
readonly target?: WorkbookRefDescription;
|
|
71
|
+
readonly message?: string;
|
|
72
|
+
};
|
|
73
|
+
export interface WorkbookChangeSummaryDescription {
|
|
74
|
+
readonly kind: string;
|
|
75
|
+
readonly target?: WorkbookRefDescription;
|
|
76
|
+
readonly message: string;
|
|
77
|
+
}
|
|
78
|
+
export interface WorkbookCheckResultDescription {
|
|
79
|
+
readonly status: WorkbookCheckStatus;
|
|
80
|
+
readonly kind: string;
|
|
81
|
+
readonly target?: WorkbookRefDescription;
|
|
82
|
+
readonly refs?: readonly WorkbookRefDescription[];
|
|
83
|
+
readonly message: string;
|
|
84
|
+
readonly expectation?: WorkbookCheckExpectationDescription;
|
|
85
|
+
}
|
|
86
|
+
export type WorkbookCheckExpectationDescription = {
|
|
87
|
+
readonly kind: 'valueEquals';
|
|
88
|
+
readonly value: LiteralInput;
|
|
89
|
+
} | {
|
|
90
|
+
readonly kind: 'valuesEqual';
|
|
91
|
+
readonly values: readonly (readonly LiteralInput[])[];
|
|
92
|
+
} | {
|
|
93
|
+
readonly kind: 'formulaEquals';
|
|
94
|
+
readonly formula: string;
|
|
95
|
+
readonly inputs: readonly WorkbookRefDescription[];
|
|
96
|
+
} | {
|
|
97
|
+
readonly kind: 'formulasEqual';
|
|
98
|
+
readonly formulas: readonly (readonly (string | null)[])[];
|
|
99
|
+
};
|
|
100
|
+
export interface WorkbookActionPlanDescription {
|
|
101
|
+
readonly modelName: string;
|
|
102
|
+
readonly actionName: string;
|
|
103
|
+
readonly input?: WorkbookActionInput;
|
|
104
|
+
readonly refsUsed: readonly WorkbookRefDescription[];
|
|
105
|
+
readonly commands: readonly WorkbookActionCommandDescription[];
|
|
106
|
+
readonly ops: readonly WorkbookOp[];
|
|
107
|
+
readonly changed: readonly WorkbookChangeSummaryDescription[];
|
|
108
|
+
readonly checks: readonly WorkbookCheckResultDescription[];
|
|
109
|
+
}
|
|
110
|
+
export type WorkbookActionPlanResultDescription = {
|
|
111
|
+
readonly status: 'planned';
|
|
112
|
+
readonly plan: WorkbookActionPlanDescription;
|
|
113
|
+
} | {
|
|
114
|
+
readonly status: 'failed';
|
|
115
|
+
readonly modelName: string;
|
|
116
|
+
readonly actionName: string;
|
|
117
|
+
readonly input?: WorkbookActionInput;
|
|
118
|
+
readonly errors: readonly WorkbookRunErrorDescription[];
|
|
119
|
+
readonly checks: readonly WorkbookCheckResultDescription[];
|
|
120
|
+
};
|
|
121
|
+
export interface WorkbookUndoRefDescription {
|
|
122
|
+
readonly id: string;
|
|
123
|
+
readonly ops?: readonly WorkbookOp[];
|
|
124
|
+
}
|
|
125
|
+
export type WorkbookRunResultDescription = {
|
|
126
|
+
readonly status: 'done';
|
|
127
|
+
readonly changed: readonly WorkbookChangeSummaryDescription[];
|
|
128
|
+
readonly checks: readonly WorkbookCheckResultDescription[];
|
|
129
|
+
readonly undo?: WorkbookUndoRefDescription;
|
|
130
|
+
readonly applied?: WorkbookAppliedSummaryDescription;
|
|
131
|
+
} | {
|
|
132
|
+
readonly status: 'failed';
|
|
133
|
+
readonly errors: readonly WorkbookRunErrorDescription[];
|
|
134
|
+
readonly checks: readonly WorkbookCheckResultDescription[];
|
|
135
|
+
};
|
|
136
|
+
export interface WorkbookRunErrorDescription {
|
|
137
|
+
readonly code: WorkbookRunErrorCode;
|
|
138
|
+
readonly message: string;
|
|
139
|
+
readonly path?: string;
|
|
140
|
+
readonly target?: WorkbookRefDescription;
|
|
141
|
+
readonly check?: WorkbookCheckResultDescription;
|
|
142
|
+
readonly expected?: WorkbookActionInput;
|
|
143
|
+
readonly actual?: WorkbookActionInput;
|
|
144
|
+
}
|
|
145
|
+
export interface WorkbookAppliedSummaryDescription {
|
|
146
|
+
readonly opCount: number;
|
|
147
|
+
readonly ops?: readonly WorkbookOp[];
|
|
148
|
+
}
|
|
149
|
+
export declare function describeModel<Refs, Actions extends WorkbookActionMap<Refs>>(model: WorkbookModel<Refs, Actions>): WorkbookModelDescription;
|
|
150
|
+
export declare function describeRef(ref: WorkbookRef): WorkbookRefDescription;
|
|
151
|
+
export declare function describePlan<Refs>(plan: WorkbookActionPlan<Refs>): WorkbookActionPlanDescription;
|
|
152
|
+
export declare function describePlanResult<Refs>(result: WorkbookActionPlanResult<Refs>): WorkbookActionPlanResultDescription;
|
|
153
|
+
export declare function describeRunResult(result: WorkbookRunResult): WorkbookRunResultDescription;
|
package/dist/describe.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { inspectModel, } from './model.js';
|
|
2
|
+
export function describeModel(model) {
|
|
3
|
+
return inspectModel(model);
|
|
4
|
+
}
|
|
5
|
+
function describeRangeRef(ref) {
|
|
6
|
+
return {
|
|
7
|
+
kind: 'range',
|
|
8
|
+
id: ref.id,
|
|
9
|
+
label: ref.label,
|
|
10
|
+
range: { ...ref.range },
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function describeNameRef(ref) {
|
|
14
|
+
return {
|
|
15
|
+
kind: 'name',
|
|
16
|
+
id: ref.id,
|
|
17
|
+
label: ref.label,
|
|
18
|
+
name: ref.name,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function describeTableRef(ref) {
|
|
22
|
+
return {
|
|
23
|
+
kind: 'table',
|
|
24
|
+
id: ref.id,
|
|
25
|
+
label: ref.label,
|
|
26
|
+
...(ref.name !== undefined ? { name: ref.name } : {}),
|
|
27
|
+
...(ref.sheetName !== undefined ? { sheetName: ref.sheetName } : {}),
|
|
28
|
+
...(ref.headers !== undefined ? { headers: [...ref.headers] } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function describeColumnRef(ref) {
|
|
32
|
+
return {
|
|
33
|
+
kind: 'column',
|
|
34
|
+
id: ref.id,
|
|
35
|
+
label: ref.label,
|
|
36
|
+
table: describeTableRef(ref.table),
|
|
37
|
+
...(ref.rows !== undefined ? { rows: describeRowsRef(ref.rows) } : {}),
|
|
38
|
+
name: ref.name,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function describeRowsRef(ref) {
|
|
42
|
+
return {
|
|
43
|
+
kind: 'rows',
|
|
44
|
+
id: ref.id,
|
|
45
|
+
label: ref.label,
|
|
46
|
+
...(ref.sheetName !== undefined ? { sheetName: ref.sheetName } : {}),
|
|
47
|
+
...(ref.table !== undefined ? { table: describeTableRef(ref.table) } : {}),
|
|
48
|
+
where: { ...ref.where },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function describeRef(ref) {
|
|
52
|
+
switch (ref.kind) {
|
|
53
|
+
case 'range':
|
|
54
|
+
return describeRangeRef(ref);
|
|
55
|
+
case 'name':
|
|
56
|
+
return describeNameRef(ref);
|
|
57
|
+
case 'table':
|
|
58
|
+
return describeTableRef(ref);
|
|
59
|
+
case 'column':
|
|
60
|
+
return describeColumnRef(ref);
|
|
61
|
+
case 'rows':
|
|
62
|
+
return describeRowsRef(ref);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function describeCommand(command) {
|
|
66
|
+
switch (command.kind) {
|
|
67
|
+
case 'writeFormula':
|
|
68
|
+
return {
|
|
69
|
+
kind: 'writeFormula',
|
|
70
|
+
target: describeRef(command.target),
|
|
71
|
+
formula: command.formula,
|
|
72
|
+
inputs: command.inputs.map(describeRef),
|
|
73
|
+
};
|
|
74
|
+
case 'writeValue':
|
|
75
|
+
return {
|
|
76
|
+
kind: 'writeValue',
|
|
77
|
+
target: describeRef(command.target),
|
|
78
|
+
value: command.value,
|
|
79
|
+
};
|
|
80
|
+
case 'format':
|
|
81
|
+
return {
|
|
82
|
+
kind: 'format',
|
|
83
|
+
target: describeRef(command.target),
|
|
84
|
+
...(command.style !== undefined ? { style: command.style } : {}),
|
|
85
|
+
...(command.numberFormat !== undefined ? { numberFormat: command.numberFormat } : {}),
|
|
86
|
+
};
|
|
87
|
+
case 'clear':
|
|
88
|
+
return {
|
|
89
|
+
kind: 'clear',
|
|
90
|
+
target: describeRef(command.target),
|
|
91
|
+
};
|
|
92
|
+
case 'op':
|
|
93
|
+
return {
|
|
94
|
+
kind: 'op',
|
|
95
|
+
op: command.op,
|
|
96
|
+
...(command.target !== undefined ? { target: describeRef(command.target) } : {}),
|
|
97
|
+
...(command.message !== undefined ? { message: command.message } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function describeChange(change) {
|
|
102
|
+
return {
|
|
103
|
+
kind: change.kind,
|
|
104
|
+
...(change.target !== undefined ? { target: describeRef(change.target) } : {}),
|
|
105
|
+
message: change.message,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function describeCheck(check) {
|
|
109
|
+
return {
|
|
110
|
+
status: check.status,
|
|
111
|
+
kind: check.kind,
|
|
112
|
+
...(check.target !== undefined ? { target: describeRef(check.target) } : {}),
|
|
113
|
+
...(check.refs !== undefined ? { refs: check.refs.map(describeRef) } : {}),
|
|
114
|
+
message: check.message,
|
|
115
|
+
...(check.expectation !== undefined ? { expectation: describeExpectation(check.expectation) } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function describeExpectation(expectation) {
|
|
119
|
+
switch (expectation.kind) {
|
|
120
|
+
case 'valueEquals':
|
|
121
|
+
return {
|
|
122
|
+
kind: 'valueEquals',
|
|
123
|
+
value: expectation.value,
|
|
124
|
+
};
|
|
125
|
+
case 'valuesEqual':
|
|
126
|
+
return {
|
|
127
|
+
kind: 'valuesEqual',
|
|
128
|
+
values: expectation.values.map((row) => [...row]),
|
|
129
|
+
};
|
|
130
|
+
case 'formulaEquals':
|
|
131
|
+
return {
|
|
132
|
+
kind: 'formulaEquals',
|
|
133
|
+
formula: expectation.formula,
|
|
134
|
+
inputs: expectation.inputs.map(describeRef),
|
|
135
|
+
};
|
|
136
|
+
case 'formulasEqual':
|
|
137
|
+
return {
|
|
138
|
+
kind: 'formulasEqual',
|
|
139
|
+
formulas: expectation.formulas.map((row) => [...row]),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export function describePlan(plan) {
|
|
144
|
+
return {
|
|
145
|
+
modelName: plan.modelName,
|
|
146
|
+
actionName: plan.actionName,
|
|
147
|
+
...(plan.input !== undefined ? { input: plan.input } : {}),
|
|
148
|
+
refsUsed: plan.refsUsed.map(describeRef),
|
|
149
|
+
commands: plan.commands.map(describeCommand),
|
|
150
|
+
ops: [...plan.ops],
|
|
151
|
+
changed: plan.changed.map(describeChange),
|
|
152
|
+
checks: plan.checks.map(describeCheck),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function describeError(error) {
|
|
156
|
+
return {
|
|
157
|
+
code: error.code,
|
|
158
|
+
message: error.message,
|
|
159
|
+
...(error.path !== undefined ? { path: error.path } : {}),
|
|
160
|
+
...(error.target !== undefined ? { target: describeRef(error.target) } : {}),
|
|
161
|
+
...(error.check !== undefined ? { check: describeCheck(error.check) } : {}),
|
|
162
|
+
...(error.expected !== undefined ? { expected: error.expected } : {}),
|
|
163
|
+
...(error.actual !== undefined ? { actual: error.actual } : {}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function describeApplied(applied) {
|
|
167
|
+
return {
|
|
168
|
+
opCount: applied.opCount,
|
|
169
|
+
...(applied.ops !== undefined ? { ops: [...applied.ops] } : {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function describeUndo(undo) {
|
|
173
|
+
return {
|
|
174
|
+
id: undo.id,
|
|
175
|
+
...(undo.ops !== undefined ? { ops: [...undo.ops] } : {}),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export function describePlanResult(result) {
|
|
179
|
+
if (result.status === 'planned') {
|
|
180
|
+
return {
|
|
181
|
+
status: 'planned',
|
|
182
|
+
plan: describePlan(result.plan),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
status: 'failed',
|
|
187
|
+
modelName: result.modelName,
|
|
188
|
+
actionName: result.actionName,
|
|
189
|
+
...(result.input !== undefined ? { input: result.input } : {}),
|
|
190
|
+
errors: result.errors.map(describeError),
|
|
191
|
+
checks: result.checks.map(describeCheck),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
export function describeRunResult(result) {
|
|
195
|
+
if (result.status === 'done') {
|
|
196
|
+
return {
|
|
197
|
+
status: 'done',
|
|
198
|
+
changed: result.changed.map(describeChange),
|
|
199
|
+
checks: result.checks.map(describeCheck),
|
|
200
|
+
...(result.undo !== undefined ? { undo: describeUndo(result.undo) } : {}),
|
|
201
|
+
...(result.applied !== undefined ? { applied: describeApplied(result.applied) } : {}),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
status: 'failed',
|
|
206
|
+
errors: result.errors.map(describeError),
|
|
207
|
+
checks: result.checks.map(describeCheck),
|
|
208
|
+
};
|
|
209
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CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzE,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtF,CAAA;IACH,CAAC;IACD,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;KACzC,CAAA;AACH,CAAC"}
|
package/dist/find.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type CellRangeRef, type LiteralInput } from '@bilig/protocol';
|
|
2
|
+
export type WorkbookRefKind = 'range' | 'name' | 'table' | 'column' | 'rows';
|
|
3
|
+
export interface WorkbookBaseRef {
|
|
4
|
+
readonly kind: WorkbookRefKind;
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkbookRangeRef extends WorkbookBaseRef {
|
|
9
|
+
readonly kind: 'range';
|
|
10
|
+
readonly range: CellRangeRef;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkbookNameRef extends WorkbookBaseRef {
|
|
13
|
+
readonly kind: 'name';
|
|
14
|
+
readonly name: string;
|
|
15
|
+
}
|
|
16
|
+
export interface WorkbookTableRef extends WorkbookBaseRef {
|
|
17
|
+
readonly kind: 'table';
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly sheetName?: string;
|
|
20
|
+
readonly headers?: readonly string[];
|
|
21
|
+
readonly column: (name: string) => WorkbookColumnRef;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkbookColumnRef extends WorkbookBaseRef {
|
|
24
|
+
readonly kind: 'column';
|
|
25
|
+
readonly table: WorkbookTableRef;
|
|
26
|
+
readonly rows?: WorkbookRowsRef;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
}
|
|
29
|
+
export type WorkbookRowOperator = 'eq' | 'neq' | 'contains' | 'startsWith' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
30
|
+
export interface WorkbookRowsRef extends WorkbookBaseRef {
|
|
31
|
+
readonly kind: 'rows';
|
|
32
|
+
readonly sheetName?: string;
|
|
33
|
+
readonly table?: WorkbookTableRef;
|
|
34
|
+
readonly where: {
|
|
35
|
+
readonly column: string;
|
|
36
|
+
readonly op: WorkbookRowOperator;
|
|
37
|
+
readonly value: LiteralInput;
|
|
38
|
+
};
|
|
39
|
+
readonly column: (name: string) => WorkbookColumnRef;
|
|
40
|
+
}
|
|
41
|
+
export type WorkbookRef = WorkbookRangeRef | WorkbookNameRef | WorkbookTableRef | WorkbookColumnRef | WorkbookRowsRef;
|
|
42
|
+
export declare function isWorkbookRef(value: unknown): value is WorkbookRef;
|
|
43
|
+
export declare function collectWorkbookRefs(value: unknown): readonly WorkbookRef[];
|
|
44
|
+
export interface FindTableOptions {
|
|
45
|
+
readonly name?: string;
|
|
46
|
+
readonly sheetName?: string;
|
|
47
|
+
readonly headers?: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
export interface FindColumnOptions {
|
|
50
|
+
readonly table: WorkbookTableRef;
|
|
51
|
+
readonly rows?: WorkbookRowsRef;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
}
|
|
54
|
+
export interface FindRowsOptions {
|
|
55
|
+
readonly sheetName?: string;
|
|
56
|
+
readonly table?: WorkbookTableRef;
|
|
57
|
+
readonly where: {
|
|
58
|
+
readonly column: string;
|
|
59
|
+
readonly op: WorkbookRowOperator;
|
|
60
|
+
readonly value: LiteralInput;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface FindRangeCellInput extends CellRangeRef {
|
|
64
|
+
}
|
|
65
|
+
export type FindRangeInput = FindRangeCellInput | {
|
|
66
|
+
readonly sheetName: string;
|
|
67
|
+
readonly address: string;
|
|
68
|
+
} | {
|
|
69
|
+
readonly sheetName: string;
|
|
70
|
+
readonly startAddress: string;
|
|
71
|
+
readonly endAddress?: string;
|
|
72
|
+
};
|
|
73
|
+
export interface WorkbookFindApi {
|
|
74
|
+
readonly findTable: (options: FindTableOptions) => WorkbookTableRef;
|
|
75
|
+
readonly findColumn: (options: FindColumnOptions) => WorkbookColumnRef;
|
|
76
|
+
readonly findRange: (input: FindRangeInput) => WorkbookRangeRef;
|
|
77
|
+
readonly findName: (name: string) => WorkbookNameRef;
|
|
78
|
+
readonly findRows: (options: FindRowsOptions) => WorkbookRowsRef;
|
|
79
|
+
}
|
|
80
|
+
export interface WorkbookFindNamespace extends WorkbookFindApi {
|
|
81
|
+
readonly table: (options: FindTableOptions) => WorkbookTableRef;
|
|
82
|
+
readonly column: (options: FindColumnOptions) => WorkbookColumnRef;
|
|
83
|
+
readonly range: (input: FindRangeInput) => WorkbookRangeRef;
|
|
84
|
+
readonly name: (name: string) => WorkbookNameRef;
|
|
85
|
+
readonly rows: (options: FindRowsOptions) => WorkbookRowsRef;
|
|
86
|
+
}
|
|
87
|
+
export declare function normalizeRangeRef(input: FindRangeInput): CellRangeRef;
|
|
88
|
+
export declare function createWorkbookTableRef(options: FindTableOptions): WorkbookTableRef;
|
|
89
|
+
export declare function createWorkbookColumnRef(options: FindColumnOptions): WorkbookColumnRef;
|
|
90
|
+
export declare function createWorkbookRangeRef(input: FindRangeInput): WorkbookRangeRef;
|
|
91
|
+
export declare function createWorkbookNameRef(name: string): WorkbookNameRef;
|
|
92
|
+
export declare function createWorkbookRowsRef(options: FindRowsOptions): WorkbookRowsRef;
|
|
93
|
+
export declare function findTable(options: FindTableOptions): WorkbookTableRef;
|
|
94
|
+
export declare function findColumn(options: FindColumnOptions): WorkbookColumnRef;
|
|
95
|
+
export declare function findRange(input: FindRangeInput): WorkbookRangeRef;
|
|
96
|
+
export declare function findName(name: string): WorkbookNameRef;
|
|
97
|
+
export declare function findRows(options: FindRowsOptions): WorkbookRowsRef;
|
|
98
|
+
export declare function createWorkbookFindApi(): WorkbookFindApi;
|
|
99
|
+
export declare const find: WorkbookFindNamespace;
|