@bilig/headless 0.9.0 → 0.9.1
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 +81 -0
- 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
|
|
@@ -203,6 +218,39 @@ const changes = workbook.batch(() => {
|
|
|
203
218
|
})
|
|
204
219
|
```
|
|
205
220
|
|
|
221
|
+
Create and read named expressions:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { WorkPaper, type WorkPaperCellAddress } from '@bilig/headless'
|
|
225
|
+
|
|
226
|
+
const workbook = WorkPaper.buildFromSheets({
|
|
227
|
+
Plan: [
|
|
228
|
+
['Metric', 'Value'],
|
|
229
|
+
['Base revenue', 100],
|
|
230
|
+
['Target revenue', null],
|
|
231
|
+
],
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
const sheet = workbook.getSheetId('Plan')
|
|
235
|
+
if (sheet === undefined) {
|
|
236
|
+
throw new Error('Plan sheet was not created')
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const at = (row: number, col: number): WorkPaperCellAddress => ({
|
|
240
|
+
sheet,
|
|
241
|
+
row,
|
|
242
|
+
col,
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
workbook.addNamedExpression('GrowthRate', 0.15)
|
|
246
|
+
workbook.setCellContents(at(2, 1), '=B2*(1+GrowthRate)')
|
|
247
|
+
|
|
248
|
+
console.log(workbook.getNamedExpressionValue('GrowthRate')) // CellValue for 0.15
|
|
249
|
+
console.log(workbook.getNamedExpressionFormula('GrowthRate')) // undefined for a scalar name
|
|
250
|
+
console.log(workbook.getCellValue(at(2, 1))) // CellValue for 115
|
|
251
|
+
console.log(workbook.getNamedExpressionValue('MissingName')) // undefined
|
|
252
|
+
```
|
|
253
|
+
|
|
206
254
|
Move cells inside configured bounds:
|
|
207
255
|
|
|
208
256
|
```ts
|
|
@@ -236,6 +284,39 @@ const saved = serializeWorkPaperDocument(exportWorkPaperDocument(workbook, { inc
|
|
|
236
284
|
const restored = createWorkPaperFromDocument(parseWorkPaperDocument(saved))
|
|
237
285
|
```
|
|
238
286
|
|
|
287
|
+
Validate a persisted document before restore:
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import {
|
|
291
|
+
WorkPaper,
|
|
292
|
+
createWorkPaperFromDocument,
|
|
293
|
+
exportWorkPaperDocument,
|
|
294
|
+
isPersistedWorkPaperDocument,
|
|
295
|
+
parseWorkPaperDocument,
|
|
296
|
+
serializeWorkPaperDocument,
|
|
297
|
+
} from '@bilig/headless'
|
|
298
|
+
|
|
299
|
+
const workbook = WorkPaper.buildFromSheets({
|
|
300
|
+
Sheet1: [[10, '=A1*2']],
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
const document = exportWorkPaperDocument(workbook, { includeConfig: true })
|
|
304
|
+
const serialized = serializeWorkPaperDocument(document)
|
|
305
|
+
|
|
306
|
+
const parsed = parseWorkPaperDocument(serialized)
|
|
307
|
+
if (!isPersistedWorkPaperDocument(parsed)) {
|
|
308
|
+
throw new Error('Persisted WorkPaper document failed validation')
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const restored = createWorkPaperFromDocument(parsed)
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
`parseWorkPaperDocument()` validates JSON and throws on invalid payloads.
|
|
315
|
+
`isPersistedWorkPaperDocument()` is useful when a service already has an
|
|
316
|
+
unknown parsed object. Custom function implementations, callback hooks, and
|
|
317
|
+
other process state are not persisted; register those in application code before
|
|
318
|
+
restoring the workbook.
|
|
319
|
+
|
|
239
320
|
## Persistence Contract
|
|
240
321
|
|
|
241
322
|
`@bilig/headless` persists:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bilig/headless",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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.1",
|
|
53
|
+
"@bilig/formula": "0.9.1",
|
|
54
|
+
"@bilig/protocol": "0.9.1"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=24.0.0"
|