@bilig/headless 0.9.0 → 0.9.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 +107 -0
- package/dist/work-paper-formula-diagnostics.d.ts +18 -0
- package/dist/work-paper-formula-diagnostics.js +301 -0
- package/dist/work-paper-formula-diagnostics.js.map +1 -0
- package/dist/work-paper-public-surface.d.ts +3 -1
- package/dist/work-paper-public-surface.js +17 -0
- package/dist/work-paper-public-surface.js.map +1 -1
- package/dist/work-paper-types.d.ts +16 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@bilig/headless)
|
|
4
4
|
[](https://github.com/proompteng/bilig)
|
|
5
|
+
[](https://github.com/proompteng/bilig/stargazers)
|
|
5
6
|
[](../../LICENSE)
|
|
6
7
|
|
|
7
8
|
`@bilig/headless` is the production-targeted WorkPaper workbook facade for
|
|
@@ -45,6 +46,14 @@ Supported scope:
|
|
|
45
46
|
- The contract is the WorkPaper/headless API exported by this package.
|
|
46
47
|
- Excel-file ingestion belongs to import/export pipelines before data reaches
|
|
47
48
|
`WorkPaper`; this package executes the validated WorkPaper workbook model.
|
|
49
|
+
- XLSX cached-result parity investigations are covered by the repository
|
|
50
|
+
verifier, not by the published package surface. Use
|
|
51
|
+
`pnpm workpaper:xlsx-corpus:check -- <xlsx-file-or-directory>` for external
|
|
52
|
+
corpora, and `pnpm workpaper:xlsx-corpus:fixtures:check` for the checked-in
|
|
53
|
+
issue #8 reduction corpus. The verifier compares deterministic cached formula
|
|
54
|
+
results and skips volatile or environment-dependent formulas such as `NOW()`
|
|
55
|
+
and `CELL("filename")`; unsupported deterministic formulas remain visible as
|
|
56
|
+
mismatches instead of being silently accepted.
|
|
48
57
|
- Custom function plugins and callback hooks are runtime registrations. Persist
|
|
49
58
|
workbook data with the helpers below, then register custom behavior in
|
|
50
59
|
application code before restore.
|
|
@@ -69,6 +78,8 @@ Repository:
|
|
|
69
78
|
- npm: <https://www.npmjs.com/package/@bilig/headless>
|
|
70
79
|
- runnable example:
|
|
71
80
|
[`examples/headless-workpaper`](../../examples/headless-workpaper)
|
|
81
|
+
- public adoption kit:
|
|
82
|
+
[`docs/public-adoption-kit.md`](../../docs/public-adoption-kit.md)
|
|
72
83
|
|
|
73
84
|
Inside this monorepo:
|
|
74
85
|
|
|
@@ -147,6 +158,10 @@ npm start
|
|
|
147
158
|
Repository CI also runs the same example against packed local runtime packages
|
|
148
159
|
through `pnpm workpaper:smoke:external`.
|
|
149
160
|
|
|
161
|
+
For a concise evaluator-facing summary with copy-paste npm commands, proof
|
|
162
|
+
links, shareable copy, and overclaim guardrails, use the root
|
|
163
|
+
[`Public Adoption Kit`](../../docs/public-adoption-kit.md).
|
|
164
|
+
|
|
150
165
|
## Core Concepts
|
|
151
166
|
|
|
152
167
|
- `WorkPaper` is the top-level workbook object. Create it with
|
|
@@ -157,6 +172,11 @@ through `pnpm workpaper:smoke:external`.
|
|
|
157
172
|
- A string beginning with `=` is a formula. Other strings are literal text.
|
|
158
173
|
`null` clears a cell.
|
|
159
174
|
- `getCellValue()` returns a computed `CellValue`.
|
|
175
|
+
- `getCellDisplayValue()` returns the formatted user-facing text for a cell,
|
|
176
|
+
including workbook error text such as `#VALUE!`.
|
|
177
|
+
- `getCellFormulaDiagnostics()` returns structured formula diagnostics for
|
|
178
|
+
supported error families, including financial cash-flow/date validation for
|
|
179
|
+
`XIRR()` and `XNPV()`.
|
|
160
180
|
- `getCellFormula()` returns the formula text when the cell is a formula.
|
|
161
181
|
- `getCellSerialized()` returns the persisted cell input shape.
|
|
162
182
|
- Mutation methods return WorkPaper change arrays. Empty arrays are valid when
|
|
@@ -194,6 +214,27 @@ workbook.getSheetValues(sheet)
|
|
|
194
214
|
workbook.getSheetSerialized(sheet)
|
|
195
215
|
```
|
|
196
216
|
|
|
217
|
+
Inspect a formula error:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
const value = workbook.getCellValue(at(7, 1))
|
|
221
|
+
const display = workbook.getCellDisplayValue(at(7, 1))
|
|
222
|
+
const diagnostics = workbook.getCellFormulaDiagnostics(at(7, 1))
|
|
223
|
+
|
|
224
|
+
console.log(value) // Raw CellValue protocol object
|
|
225
|
+
console.log(display) // "#VALUE!"
|
|
226
|
+
console.log(diagnostics[0]?.code) // e.g. "financial-unsupported-date-coercion"
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Finance date inputs:
|
|
230
|
+
|
|
231
|
+
`XIRR(values, dates, [guess])` and `XNPV(rate, values, dates)` accept numeric
|
|
232
|
+
Excel serial dates in `dates`. Text labels and text date strings are not
|
|
233
|
+
coerced in headless formulas; they evaluate to `#VALUE!`. Use
|
|
234
|
+
`getCellFormulaDiagnostics()` to distinguish invalid date ranges, mismatched
|
|
235
|
+
range dimensions, invalid cash-flow values, missing positive or negative cash
|
|
236
|
+
flows, invalid rates/guesses, and solver non-convergence.
|
|
237
|
+
|
|
197
238
|
Batch related edits:
|
|
198
239
|
|
|
199
240
|
```ts
|
|
@@ -203,6 +244,39 @@ const changes = workbook.batch(() => {
|
|
|
203
244
|
})
|
|
204
245
|
```
|
|
205
246
|
|
|
247
|
+
Create and read named expressions:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
import { WorkPaper, type WorkPaperCellAddress } from '@bilig/headless'
|
|
251
|
+
|
|
252
|
+
const workbook = WorkPaper.buildFromSheets({
|
|
253
|
+
Plan: [
|
|
254
|
+
['Metric', 'Value'],
|
|
255
|
+
['Base revenue', 100],
|
|
256
|
+
['Target revenue', null],
|
|
257
|
+
],
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
const sheet = workbook.getSheetId('Plan')
|
|
261
|
+
if (sheet === undefined) {
|
|
262
|
+
throw new Error('Plan sheet was not created')
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const at = (row: number, col: number): WorkPaperCellAddress => ({
|
|
266
|
+
sheet,
|
|
267
|
+
row,
|
|
268
|
+
col,
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
workbook.addNamedExpression('GrowthRate', 0.15)
|
|
272
|
+
workbook.setCellContents(at(2, 1), '=B2*(1+GrowthRate)')
|
|
273
|
+
|
|
274
|
+
console.log(workbook.getNamedExpressionValue('GrowthRate')) // CellValue for 0.15
|
|
275
|
+
console.log(workbook.getNamedExpressionFormula('GrowthRate')) // undefined for a scalar name
|
|
276
|
+
console.log(workbook.getCellValue(at(2, 1))) // CellValue for 115
|
|
277
|
+
console.log(workbook.getNamedExpressionValue('MissingName')) // undefined
|
|
278
|
+
```
|
|
279
|
+
|
|
206
280
|
Move cells inside configured bounds:
|
|
207
281
|
|
|
208
282
|
```ts
|
|
@@ -236,6 +310,39 @@ const saved = serializeWorkPaperDocument(exportWorkPaperDocument(workbook, { inc
|
|
|
236
310
|
const restored = createWorkPaperFromDocument(parseWorkPaperDocument(saved))
|
|
237
311
|
```
|
|
238
312
|
|
|
313
|
+
Validate a persisted document before restore:
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
import {
|
|
317
|
+
WorkPaper,
|
|
318
|
+
createWorkPaperFromDocument,
|
|
319
|
+
exportWorkPaperDocument,
|
|
320
|
+
isPersistedWorkPaperDocument,
|
|
321
|
+
parseWorkPaperDocument,
|
|
322
|
+
serializeWorkPaperDocument,
|
|
323
|
+
} from '@bilig/headless'
|
|
324
|
+
|
|
325
|
+
const workbook = WorkPaper.buildFromSheets({
|
|
326
|
+
Sheet1: [[10, '=A1*2']],
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
const document = exportWorkPaperDocument(workbook, { includeConfig: true })
|
|
330
|
+
const serialized = serializeWorkPaperDocument(document)
|
|
331
|
+
|
|
332
|
+
const parsed = parseWorkPaperDocument(serialized)
|
|
333
|
+
if (!isPersistedWorkPaperDocument(parsed)) {
|
|
334
|
+
throw new Error('Persisted WorkPaper document failed validation')
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const restored = createWorkPaperFromDocument(parsed)
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
`parseWorkPaperDocument()` validates JSON and throws on invalid payloads.
|
|
341
|
+
`isPersistedWorkPaperDocument()` is useful when a service already has an
|
|
342
|
+
unknown parsed object. Custom function implementations, callback hooks, and
|
|
343
|
+
other process state are not persisted; register those in application code before
|
|
344
|
+
restoring the workbook.
|
|
345
|
+
|
|
239
346
|
## Persistence Contract
|
|
240
347
|
|
|
241
348
|
`@bilig/headless` persists:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type CellValue } from '@bilig/protocol';
|
|
2
|
+
import type { WorkPaperCellAddress, WorkPaperCellRange, WorkPaperFormulaDiagnostic } from './work-paper-types.js';
|
|
3
|
+
interface WorkPaperFormulaDiagnosticHooks {
|
|
4
|
+
readonly getCellValue: (address: WorkPaperCellAddress) => CellValue;
|
|
5
|
+
readonly getCellValueFormat: (address: WorkPaperCellAddress) => string | undefined;
|
|
6
|
+
readonly getCellFormula: (address: WorkPaperCellAddress) => string | undefined;
|
|
7
|
+
readonly getRangeValues: (range: WorkPaperCellRange) => CellValue[][];
|
|
8
|
+
readonly getSheetId: (sheetName: string) => number | undefined;
|
|
9
|
+
readonly getSheetName: (sheetId: number) => string | undefined;
|
|
10
|
+
readonly simpleCellAddressToString: (address: WorkPaperCellAddress, options?: {
|
|
11
|
+
includeSheetName?: boolean;
|
|
12
|
+
}) => string;
|
|
13
|
+
readonly simpleCellRangeToString: (range: WorkPaperCellRange, options?: {
|
|
14
|
+
includeSheetName?: boolean;
|
|
15
|
+
}) => string;
|
|
16
|
+
}
|
|
17
|
+
export declare function collectWorkPaperFormulaDiagnostics(address: WorkPaperCellAddress, hooks: WorkPaperFormulaDiagnosticHooks): WorkPaperFormulaDiagnostic[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { ValueTag, formatCellDisplayValue, formatErrorCode } from '@bilig/protocol';
|
|
2
|
+
import { excelSerialToDateParts, parseCellAddress, parseFormula, parseRangeAddress } from '@bilig/formula';
|
|
3
|
+
function readFinanceFunctionName(callee) {
|
|
4
|
+
const normalized = callee.toUpperCase();
|
|
5
|
+
if (normalized === 'XIRR' || normalized === 'XNPV') {
|
|
6
|
+
return normalized;
|
|
7
|
+
}
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
function isFinanceCall(node) {
|
|
11
|
+
return node.kind === 'CallExpr' && readFinanceFunctionName(node.callee) !== undefined;
|
|
12
|
+
}
|
|
13
|
+
function buildDiagnostic(base, diagnostic) {
|
|
14
|
+
return {
|
|
15
|
+
severity: 'error',
|
|
16
|
+
address: base.address,
|
|
17
|
+
sheetName: base.sheetName,
|
|
18
|
+
a1: base.a1,
|
|
19
|
+
...(base.formula !== undefined ? { formula: base.formula } : {}),
|
|
20
|
+
...(base.functionName !== undefined ? { functionName: base.functionName } : {}),
|
|
21
|
+
...(base.errorCode !== undefined ? { errorCode: base.errorCode } : {}),
|
|
22
|
+
...(base.errorText !== undefined ? { errorText: base.errorText } : {}),
|
|
23
|
+
...diagnostic,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function displayValue(value, format) {
|
|
27
|
+
const rendered = formatCellDisplayValue(value, format);
|
|
28
|
+
return rendered === '' ? '<blank>' : rendered;
|
|
29
|
+
}
|
|
30
|
+
function describeCellValue(value, format) {
|
|
31
|
+
switch (value.tag) {
|
|
32
|
+
case ValueTag.Empty:
|
|
33
|
+
return 'blank';
|
|
34
|
+
case ValueTag.Boolean:
|
|
35
|
+
return `boolean ${value.value ? 'TRUE' : 'FALSE'}`;
|
|
36
|
+
case ValueTag.String:
|
|
37
|
+
return `text "${value.value}"`;
|
|
38
|
+
case ValueTag.Error:
|
|
39
|
+
return `error ${formatErrorCode(value.code)}`;
|
|
40
|
+
case ValueTag.Number:
|
|
41
|
+
return `number ${displayValue(value, format)}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function resolveRangeNode(node, ownerSheetName, hooks) {
|
|
45
|
+
if (node.refKind !== 'cells') {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const parsed = parseRangeAddress(`${node.start}:${node.end}`, node.sheetName ?? ownerSheetName);
|
|
49
|
+
if (parsed.kind !== 'cells') {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
const sheetName = parsed.sheetName ?? ownerSheetName;
|
|
53
|
+
const sheet = hooks.getSheetId(sheetName);
|
|
54
|
+
if (sheet === undefined) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const range = {
|
|
58
|
+
start: { sheet, row: parsed.start.row, col: parsed.start.col },
|
|
59
|
+
end: { sheet, row: parsed.end.row, col: parsed.end.col },
|
|
60
|
+
};
|
|
61
|
+
const matrix = hooks.getRangeValues(range);
|
|
62
|
+
const values = [];
|
|
63
|
+
const addresses = [];
|
|
64
|
+
for (let rowOffset = 0; rowOffset < matrix.length; rowOffset += 1) {
|
|
65
|
+
const row = matrix[rowOffset] ?? [];
|
|
66
|
+
for (let colOffset = 0; colOffset < (row.length || range.end.col - range.start.col + 1); colOffset += 1) {
|
|
67
|
+
values.push(row[colOffset] ?? { tag: ValueTag.Empty });
|
|
68
|
+
addresses.push({ sheet, row: range.start.row + rowOffset, col: range.start.col + colOffset });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
rows: range.end.row - range.start.row + 1,
|
|
73
|
+
cols: range.end.col - range.start.col + 1,
|
|
74
|
+
values,
|
|
75
|
+
addresses,
|
|
76
|
+
reference: hooks.simpleCellRangeToString(range, { includeSheetName: true }),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function resolveCellNode(node, ownerSheetName, hooks) {
|
|
80
|
+
const parsed = parseCellAddress(node.ref, node.sheetName ?? ownerSheetName);
|
|
81
|
+
const sheetName = parsed.sheetName ?? ownerSheetName;
|
|
82
|
+
const sheet = hooks.getSheetId(sheetName);
|
|
83
|
+
if (sheet === undefined) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const address = { sheet, row: parsed.row, col: parsed.col };
|
|
87
|
+
return {
|
|
88
|
+
rows: 1,
|
|
89
|
+
cols: 1,
|
|
90
|
+
values: [hooks.getCellValue(address)],
|
|
91
|
+
addresses: [address],
|
|
92
|
+
reference: hooks.simpleCellAddressToString(address, { includeSheetName: true }),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function resolveCellArgument(node, ownerSheetName, hooks) {
|
|
96
|
+
if (node?.kind === 'RangeRef') {
|
|
97
|
+
return resolveRangeNode(node, ownerSheetName, hooks);
|
|
98
|
+
}
|
|
99
|
+
if (node?.kind === 'CellRef') {
|
|
100
|
+
return resolveCellNode(node, ownerSheetName, hooks);
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
function resolveScalarNumber(node, ownerSheetName, hooks) {
|
|
105
|
+
if (node === undefined) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
if (node.kind === 'NumberLiteral') {
|
|
109
|
+
return Number.isFinite(node.value) ? node.value : undefined;
|
|
110
|
+
}
|
|
111
|
+
if (node.kind !== 'CellRef') {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const resolved = resolveCellNode(node, ownerSheetName, hooks);
|
|
115
|
+
const value = resolved?.values[0];
|
|
116
|
+
return value?.tag === ValueTag.Number && Number.isFinite(value.value) ? value.value : undefined;
|
|
117
|
+
}
|
|
118
|
+
function firstInvalidNumber(cells) {
|
|
119
|
+
for (let index = 0; index < cells.values.length; index += 1) {
|
|
120
|
+
const value = cells.values[index];
|
|
121
|
+
if (value.tag !== ValueTag.Number || !Number.isFinite(value.value)) {
|
|
122
|
+
return { value, address: cells.addresses[index] };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
function firstInvalidDateSerial(cells) {
|
|
128
|
+
for (let index = 0; index < cells.values.length; index += 1) {
|
|
129
|
+
const value = cells.values[index];
|
|
130
|
+
if (value.tag !== ValueTag.Number) {
|
|
131
|
+
return { value, address: cells.addresses[index], unsupportedCoercion: value.tag === ValueTag.String };
|
|
132
|
+
}
|
|
133
|
+
if (!Number.isFinite(value.value) || excelSerialToDateParts(value.value) === undefined) {
|
|
134
|
+
return { value, address: cells.addresses[index], unsupportedCoercion: false };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
function numericValues(cells) {
|
|
140
|
+
return cells.values.map((value) => (value.tag === ValueTag.Number ? value.value : Number.NaN));
|
|
141
|
+
}
|
|
142
|
+
function dateSerialValues(cells) {
|
|
143
|
+
return cells.values.map((value) => (value.tag === ValueTag.Number ? Math.trunc(value.value) : Number.NaN));
|
|
144
|
+
}
|
|
145
|
+
function diagnoseFinanceCall(call, base, ownerSheetName, hooks) {
|
|
146
|
+
const functionName = readFinanceFunctionName(call.callee);
|
|
147
|
+
if (functionName === undefined) {
|
|
148
|
+
return [
|
|
149
|
+
buildDiagnostic(base, {
|
|
150
|
+
code: 'formula-error',
|
|
151
|
+
message: `Formula evaluated to ${base.errorText ?? 'an error'}.`,
|
|
152
|
+
}),
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
const valuesArg = functionName === 'XNPV' ? call.args[1] : call.args[0];
|
|
156
|
+
const datesArg = functionName === 'XNPV' ? call.args[2] : call.args[1];
|
|
157
|
+
const values = resolveCellArgument(valuesArg, ownerSheetName, hooks);
|
|
158
|
+
const dates = resolveCellArgument(datesArg, ownerSheetName, hooks);
|
|
159
|
+
const financeBase = { ...base, functionName };
|
|
160
|
+
if (!values || !dates) {
|
|
161
|
+
return [
|
|
162
|
+
buildDiagnostic(financeBase, {
|
|
163
|
+
code: 'financial-invalid-argument',
|
|
164
|
+
message: `${functionName} diagnostics require direct cell or cell-range cash-flow and date arguments.`,
|
|
165
|
+
}),
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
if (values.rows !== dates.rows || values.cols !== dates.cols) {
|
|
169
|
+
return [
|
|
170
|
+
buildDiagnostic(financeBase, {
|
|
171
|
+
code: 'financial-mismatched-dimensions',
|
|
172
|
+
message: `${functionName} values range ${values.reference} is ${values.rows}x${values.cols}, but dates range ${dates.reference} is ${dates.rows}x${dates.cols}.`,
|
|
173
|
+
references: [values.reference, dates.reference],
|
|
174
|
+
}),
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
const invalidCashFlow = firstInvalidNumber(values);
|
|
178
|
+
if (invalidCashFlow) {
|
|
179
|
+
const cell = hooks.simpleCellAddressToString(invalidCashFlow.address, { includeSheetName: true });
|
|
180
|
+
return [
|
|
181
|
+
buildDiagnostic(financeBase, {
|
|
182
|
+
code: 'financial-invalid-cash-flow',
|
|
183
|
+
message: `${functionName} cash-flow range ${values.reference} contains ${describeCellValue(invalidCashFlow.value, hooks.getCellValueFormat(invalidCashFlow.address))} at ${cell}; every cash-flow cell must be numeric.`,
|
|
184
|
+
references: [values.reference, cell],
|
|
185
|
+
}),
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
const invalidDate = firstInvalidDateSerial(dates);
|
|
189
|
+
if (invalidDate) {
|
|
190
|
+
const cell = hooks.simpleCellAddressToString(invalidDate.address, { includeSheetName: true });
|
|
191
|
+
const code = invalidDate.unsupportedCoercion ? 'financial-unsupported-date-coercion' : 'financial-invalid-date-range';
|
|
192
|
+
const text = invalidDate.unsupportedCoercion
|
|
193
|
+
? `${functionName} date range ${dates.reference} contains ${describeCellValue(invalidDate.value, hooks.getCellValueFormat(invalidDate.address))} at ${cell}. Use numeric Excel serial dates; text date coercion is not supported for headless ${functionName}.`
|
|
194
|
+
: `${functionName} date range ${dates.reference} contains ${describeCellValue(invalidDate.value, hooks.getCellValueFormat(invalidDate.address))} at ${cell}; dates must be valid numeric Excel serial dates.`;
|
|
195
|
+
return [
|
|
196
|
+
buildDiagnostic(financeBase, {
|
|
197
|
+
code,
|
|
198
|
+
message: text,
|
|
199
|
+
references: [dates.reference, cell],
|
|
200
|
+
}),
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
const cashFlows = numericValues(values);
|
|
204
|
+
if (!cashFlows.some((value) => value > 0)) {
|
|
205
|
+
return [
|
|
206
|
+
buildDiagnostic(financeBase, {
|
|
207
|
+
code: 'financial-missing-positive-cash-flow',
|
|
208
|
+
message: `${functionName} cash-flow range ${values.reference} must contain at least one positive value.`,
|
|
209
|
+
references: [values.reference],
|
|
210
|
+
}),
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
if (!cashFlows.some((value) => value < 0)) {
|
|
214
|
+
return [
|
|
215
|
+
buildDiagnostic(financeBase, {
|
|
216
|
+
code: 'financial-missing-negative-cash-flow',
|
|
217
|
+
message: `${functionName} cash-flow range ${values.reference} must contain at least one negative value.`,
|
|
218
|
+
references: [values.reference],
|
|
219
|
+
}),
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
const dateSerials = dateSerialValues(dates);
|
|
223
|
+
const firstDate = dateSerials[0];
|
|
224
|
+
if (firstDate !== undefined && dateSerials.some((date) => date < firstDate)) {
|
|
225
|
+
return [
|
|
226
|
+
buildDiagnostic(financeBase, {
|
|
227
|
+
code: 'financial-invalid-date-range',
|
|
228
|
+
message: `${functionName} date range ${dates.reference} contains a date before the first date; XIRR/XNPV require later cash-flow dates to be on or after the first date.`,
|
|
229
|
+
references: [dates.reference],
|
|
230
|
+
}),
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
if (functionName === 'XNPV') {
|
|
234
|
+
const rate = resolveScalarNumber(call.args[0], ownerSheetName, hooks);
|
|
235
|
+
if (rate === undefined || rate <= -0.999999999) {
|
|
236
|
+
return [
|
|
237
|
+
buildDiagnostic(financeBase, {
|
|
238
|
+
code: 'financial-invalid-rate',
|
|
239
|
+
message: 'XNPV discount rate must be a finite numeric value greater than -100%.',
|
|
240
|
+
}),
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (functionName === 'XIRR' && call.args[2] !== undefined) {
|
|
245
|
+
const guess = resolveScalarNumber(call.args[2], ownerSheetName, hooks);
|
|
246
|
+
if (guess === undefined) {
|
|
247
|
+
return [
|
|
248
|
+
buildDiagnostic(financeBase, {
|
|
249
|
+
code: 'financial-invalid-rate',
|
|
250
|
+
message: 'XIRR optional guess must be a finite numeric value.',
|
|
251
|
+
}),
|
|
252
|
+
];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return [
|
|
256
|
+
buildDiagnostic(financeBase, {
|
|
257
|
+
code: 'financial-nonconvergence',
|
|
258
|
+
message: `${functionName} inputs are structurally valid, but the solver did not find a valid rate for the supplied cash flows and dates.`,
|
|
259
|
+
references: [values.reference, dates.reference],
|
|
260
|
+
}),
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
export function collectWorkPaperFormulaDiagnostics(address, hooks) {
|
|
264
|
+
const value = hooks.getCellValue(address);
|
|
265
|
+
const formula = hooks.getCellFormula(address);
|
|
266
|
+
if (value.tag !== ValueTag.Error || formula === undefined) {
|
|
267
|
+
return [];
|
|
268
|
+
}
|
|
269
|
+
const sheetName = hooks.getSheetName(address.sheet) ?? String(address.sheet);
|
|
270
|
+
const a1 = hooks.simpleCellAddressToString(address, { includeSheetName: false });
|
|
271
|
+
const base = {
|
|
272
|
+
address,
|
|
273
|
+
sheetName,
|
|
274
|
+
a1,
|
|
275
|
+
formula,
|
|
276
|
+
errorCode: value.code,
|
|
277
|
+
errorText: formatErrorCode(value.code),
|
|
278
|
+
};
|
|
279
|
+
let parsed;
|
|
280
|
+
try {
|
|
281
|
+
parsed = parseFormula(formula);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return [
|
|
285
|
+
buildDiagnostic(base, {
|
|
286
|
+
code: 'formula-error',
|
|
287
|
+
message: `Formula evaluated to ${formatErrorCode(value.code)}.`,
|
|
288
|
+
}),
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
if (isFinanceCall(parsed)) {
|
|
292
|
+
return diagnoseFinanceCall(parsed, base, sheetName, hooks);
|
|
293
|
+
}
|
|
294
|
+
return [
|
|
295
|
+
buildDiagnostic(base, {
|
|
296
|
+
code: 'formula-error',
|
|
297
|
+
message: `Formula evaluated to ${formatErrorCode(value.code)}.`,
|
|
298
|
+
}),
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=work-paper-formula-diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work-paper-formula-diagnostics.js","sourceRoot":"","sources":["../src/work-paper-formula-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAkC,MAAM,iBAAiB,CAAA;AACnH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAA;AAmC5H,SAAS,uBAAuB,CAAC,MAAc;IAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IACvC,IAAI,UAAU,KAAK,MAAM,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QACnD,OAAO,UAAU,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,IAAiB;IACtC,OAAO,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,SAAS,CAAA;AACvF,CAAC;AAED,SAAS,eAAe,CACtB,IAAoB,EACpB,UAA4F;IAE5F,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,GAAG,CAAC,IAAI,CAAC,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AAC,IAAI,CAAC,GAAG;SAChE,CAAC;KACH,CAAA;AACH,CAAC"}
|
|
@@ -2,7 +2,7 @@ import type { SpreadsheetEngine } from '@bilig/core';
|
|
|
2
2
|
import type { CellValue } from '@bilig/protocol';
|
|
3
3
|
import type { WorkPaperEmitter } from './work-paper-emitter.js';
|
|
4
4
|
import { type InternalFunctionBinding } from './work-paper-function-registry.js';
|
|
5
|
-
import type { RawCellContent, SerializedWorkPaperNamedExpression, WorkPaperAddressMappingAdapter, WorkPaperArrayMappingAdapter, WorkPaperCellAddress, WorkPaperCellRange, WorkPaperColumnSearchAdapter, WorkPaperConfig, WorkPaperDateTime, WorkPaperDependencyGraphAdapter, WorkPaperEvaluatorAdapter, WorkPaperFunctionPluginDefinition, WorkPaperFunctionTranslationsPackage, WorkPaperGraphAdapter, WorkPaperLanguagePackage, WorkPaperLazilyTransformingAstServiceAdapter, WorkPaperLicenseKeyValidityState, WorkPaperRangeMappingAdapter, WorkPaperSheet, WorkPaperSheetMappingAdapter, WorkPaperEngineCounters, WorkPaperDetailedListener, WorkPaperEventName, WorkPaperInternals, WorkPaperListener } from './work-paper-types.js';
|
|
5
|
+
import type { RawCellContent, SerializedWorkPaperNamedExpression, WorkPaperAddressMappingAdapter, WorkPaperArrayMappingAdapter, WorkPaperCellAddress, WorkPaperCellRange, WorkPaperFormulaDiagnostic, WorkPaperColumnSearchAdapter, WorkPaperConfig, WorkPaperDateTime, WorkPaperDependencyGraphAdapter, WorkPaperEvaluatorAdapter, WorkPaperFunctionPluginDefinition, WorkPaperFunctionTranslationsPackage, WorkPaperGraphAdapter, WorkPaperLanguagePackage, WorkPaperLazilyTransformingAstServiceAdapter, WorkPaperLicenseKeyValidityState, WorkPaperRangeMappingAdapter, WorkPaperSheet, WorkPaperSheetMappingAdapter, WorkPaperEngineCounters, WorkPaperDetailedListener, WorkPaperEventName, WorkPaperInternals, WorkPaperListener } from './work-paper-types.js';
|
|
6
6
|
import { WorkPaperCapabilitySurface } from './work-paper-capability-surface.js';
|
|
7
7
|
export declare abstract class WorkPaperPublicSurface extends WorkPaperCapabilitySurface {
|
|
8
8
|
static version: string;
|
|
@@ -62,6 +62,8 @@ export declare abstract class WorkPaperPublicSurface extends WorkPaperCapability
|
|
|
62
62
|
resetPerformanceCounters(): void;
|
|
63
63
|
normalizeFormula(formula: string): string;
|
|
64
64
|
calculateFormula(formula: string, scope?: number): CellValue | CellValue[][];
|
|
65
|
+
getCellDisplayValue(address: WorkPaperCellAddress): string;
|
|
66
|
+
getCellFormulaDiagnostics(address: WorkPaperCellAddress): WorkPaperFormulaDiagnostic[];
|
|
65
67
|
getNamedExpressionsFromFormula(formula: string): string[];
|
|
66
68
|
validateFormula(formula: string): boolean;
|
|
67
69
|
getRegisteredFunctionNames(languageCode?: string): string[];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { formatCellDisplayValue } from '@bilig/protocol';
|
|
1
2
|
import { checkWorkPaperLicenseKeyValidity, cloneConfig, DEFAULT_CONFIG } from './work-paper-config.js';
|
|
2
3
|
import { numberToWorkPaperDate, numberToWorkPaperDateTime, numberToWorkPaperTime } from './work-paper-date-time.js';
|
|
3
4
|
import { calculateWorkPaperFormula, getWorkPaperNamedExpressionsFromFormula, normalizeWorkPaperFormula, validateWorkPaperFormula, } from './work-paper-formula-analysis.js';
|
|
5
|
+
import { collectWorkPaperFormulaDiagnostics } from './work-paper-formula-diagnostics.js';
|
|
4
6
|
import { getCapturedWorkPaperFunctionPlugin, getCapturedWorkPaperFunctionPlugins, listCapturedWorkPaperFunctionNames, } from './work-paper-function-registry.js';
|
|
5
7
|
import { getRegisteredWorkPaperFunctionPluginById, getRegisteredWorkPaperFunctionPluginsById, readRegisteredWorkPaperLanguage, } from './work-paper-static-registry.js';
|
|
6
8
|
import { DEFAULT_WORKPAPER_CONFIG, getAllWorkPaperStaticFunctionPlugins, getRegisteredWorkPaperStaticFunctionNames, getRegisteredWorkPaperStaticLanguageCodes, getWorkPaperStaticFunctionPlugin, getWorkPaperStaticLanguage, registerWorkPaperStaticFunction, registerWorkPaperStaticFunctionPlugin, registerWorkPaperStaticLanguage, unregisterAllWorkPaperStaticFunctions, unregisterWorkPaperStaticFunction, unregisterWorkPaperStaticFunctionPlugin, unregisterWorkPaperStaticLanguage, workPaperLanguages, WORKPAPER_BUILD_DATE, WORKPAPER_RELEASE_DATE, WORKPAPER_VERSION, } from './work-paper-static-api.js';
|
|
@@ -126,6 +128,21 @@ export class WorkPaperPublicSurface extends WorkPaperCapabilitySurface {
|
|
|
126
128
|
messageOf: (error, fallback) => this.messageOf(error, fallback),
|
|
127
129
|
});
|
|
128
130
|
}
|
|
131
|
+
getCellDisplayValue(address) {
|
|
132
|
+
return formatCellDisplayValue(this.getCellValue(address), this.getCellValueFormat(address));
|
|
133
|
+
}
|
|
134
|
+
getCellFormulaDiagnostics(address) {
|
|
135
|
+
return collectWorkPaperFormulaDiagnostics(address, {
|
|
136
|
+
getCellValue: (target) => this.getCellValue(target),
|
|
137
|
+
getCellValueFormat: (target) => this.getCellValueFormat(target),
|
|
138
|
+
getCellFormula: (target) => this.getCellFormula(target),
|
|
139
|
+
getRangeValues: (range) => this.getRangeValues(range),
|
|
140
|
+
getSheetId: (sheetName) => this.sheetMapping.getSheetId(sheetName),
|
|
141
|
+
getSheetName: (sheetId) => this.sheetMapping.getSheetName(sheetId),
|
|
142
|
+
simpleCellAddressToString: (target, options) => this.simpleCellAddressToString(target, options),
|
|
143
|
+
simpleCellRangeToString: (range, options) => this.simpleCellRangeToString(range, options),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
129
146
|
getNamedExpressionsFromFormula(formula) {
|
|
130
147
|
return getWorkPaperNamedExpressionsFromFormula(formula, { messageOf: (error, fallback) => this.messageOf(error, fallback) });
|
|
131
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-paper-public-surface.js","sourceRoot":"","sources":["../src/work-paper-public-surface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":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|
1
|
-
import type { CellValue, LiteralInput, RecalcMetrics } from '@bilig/protocol';
|
|
1
|
+
import type { CellValue, ErrorCode, LiteralInput, RecalcMetrics } from '@bilig/protocol';
|
|
2
2
|
import type { EvaluationResult } from '@bilig/formula';
|
|
3
3
|
import type { EngineCounters } from '@bilig/core';
|
|
4
4
|
export type RawCellContent = LiteralInput | string;
|
|
@@ -202,6 +202,21 @@ export type WorkPaperDetailedListener<EventName extends WorkPaperEventName> = (p
|
|
|
202
202
|
export type WorkPaperCellType = 'EMPTY' | 'VALUE' | 'FORMULA' | 'ARRAY';
|
|
203
203
|
export type WorkPaperCellValueType = 'EMPTY' | 'NUMBER' | 'STRING' | 'BOOLEAN' | 'ERROR';
|
|
204
204
|
export type WorkPaperCellValueDetailedType = WorkPaperCellValueType | 'DATE' | 'TIME' | 'DATETIME';
|
|
205
|
+
export type WorkPaperFormulaDiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
206
|
+
export type WorkPaperFormulaDiagnosticCode = 'formula-error' | 'financial-invalid-argument' | 'financial-invalid-cash-flow' | 'financial-unsupported-date-coercion' | 'financial-invalid-date-range' | 'financial-mismatched-dimensions' | 'financial-missing-positive-cash-flow' | 'financial-missing-negative-cash-flow' | 'financial-invalid-rate' | 'financial-nonconvergence';
|
|
207
|
+
export interface WorkPaperFormulaDiagnostic {
|
|
208
|
+
severity: WorkPaperFormulaDiagnosticSeverity;
|
|
209
|
+
code: WorkPaperFormulaDiagnosticCode;
|
|
210
|
+
message: string;
|
|
211
|
+
address: WorkPaperCellAddress;
|
|
212
|
+
sheetName: string;
|
|
213
|
+
a1: string;
|
|
214
|
+
formula?: string;
|
|
215
|
+
functionName?: string;
|
|
216
|
+
errorCode?: ErrorCode;
|
|
217
|
+
errorText?: string;
|
|
218
|
+
references?: string[];
|
|
219
|
+
}
|
|
205
220
|
export type WorkPaperDependencyRef = {
|
|
206
221
|
kind: 'cell';
|
|
207
222
|
address: WorkPaperCellAddress;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bilig/headless",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Headless spreadsheet engine and WorkPaper workbook facade for Node services, coding agents, and HyperFormula-style workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@bilig/core": "0.9.
|
|
53
|
-
"@bilig/formula": "0.9.
|
|
54
|
-
"@bilig/protocol": "0.9.
|
|
52
|
+
"@bilig/core": "0.9.2",
|
|
53
|
+
"@bilig/formula": "0.9.2",
|
|
54
|
+
"@bilig/protocol": "0.9.2"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=24.0.0"
|