@mog-sdk/node 0.1.2 → 0.1.7
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/dist/index.cjs +10835 -2096
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +190 -1
- package/dist/index.d.ts +190 -1
- package/dist/index.js +10829 -2093
- package/dist/index.js.map +1 -1
- package/llms.txt +96 -0
- package/package.json +7 -8
package/llms.txt
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @mog-sdk/node
|
|
2
|
+
|
|
3
|
+
Headless spreadsheet engine for Node.js. Full Excel-compatible compute (582 formula functions), XLSX import/export, charts, tables, pivots, conditional formatting — all powered by a native Rust engine.
|
|
4
|
+
|
|
5
|
+
## API Discovery
|
|
6
|
+
|
|
7
|
+
This SDK includes a built-in introspection API. Use it to explore the full API surface programmatically — no need to read type definitions:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { api } from '@mog-sdk/node';
|
|
11
|
+
|
|
12
|
+
// Overview: list all methods and sub-APIs
|
|
13
|
+
api.describe()
|
|
14
|
+
// → { workbook: { methods: [...], subApis: ['sheets','history','names',...] },
|
|
15
|
+
// worksheet: { methods: [...], subApis: ['charts','formats','tables',...] } }
|
|
16
|
+
|
|
17
|
+
// Drill into a sub-API
|
|
18
|
+
api.describe('ws.charts')
|
|
19
|
+
// → { name: 'WorksheetCharts', methods: [{ name: 'add', signature: '...', tags: ['action'] }, ...] }
|
|
20
|
+
|
|
21
|
+
// Get a specific method with full type info
|
|
22
|
+
api.describe('ws.charts.add')
|
|
23
|
+
// → { name: 'add', signature: '...', tags: ['action'], types: { ChartConfig: { definition: '...' } } }
|
|
24
|
+
|
|
25
|
+
// Direct methods on root interfaces
|
|
26
|
+
api.describe('ws.setCell')
|
|
27
|
+
api.describe('wb.batch')
|
|
28
|
+
|
|
29
|
+
// Look up a type definition
|
|
30
|
+
api.describe('type:ChartType')
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Paths use `wb.*` for workbook and `ws.*` for worksheet. Sub-APIs are accessed as `ws.{subApi}.{method}`.
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { createWorkbook } from '@mog-sdk/node';
|
|
39
|
+
|
|
40
|
+
const wb = await createWorkbook();
|
|
41
|
+
const ws = wb.activeSheet;
|
|
42
|
+
|
|
43
|
+
// Write cells (formulas auto-recalc)
|
|
44
|
+
await ws.setCell('A1', 100);
|
|
45
|
+
await ws.setCell('A2', 200);
|
|
46
|
+
await ws.setCell('A3', '=SUM(A1:A2)');
|
|
47
|
+
console.log(await ws.getValue('A3')); // 300
|
|
48
|
+
|
|
49
|
+
// Bulk write
|
|
50
|
+
await ws.setRange('B1', [['Name', 'Score'], ['Alice', 92], ['Bob', 85]]);
|
|
51
|
+
|
|
52
|
+
// Read
|
|
53
|
+
const data = await ws.getData(); // CellValue[][]
|
|
54
|
+
const csv = await ws.toCSV(); // RFC 4180 CSV string
|
|
55
|
+
const json = await ws.toJSON(); // [{ Name: 'Alice', Score: 92 }, ...]
|
|
56
|
+
await ws.describeRange('A1:B3'); // LLM-friendly text summary
|
|
57
|
+
|
|
58
|
+
// Always dispose when done
|
|
59
|
+
await wb.dispose();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Import XLSX
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { createWorkbook } from '@mog-sdk/node';
|
|
66
|
+
import { readFileSync } from 'fs';
|
|
67
|
+
|
|
68
|
+
const wb = await createWorkbook({
|
|
69
|
+
source: { type: 'bytes', data: readFileSync('data.xlsx') }
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Sub-API Examples
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// Sheets
|
|
77
|
+
await wb.sheets.add('Sheet2');
|
|
78
|
+
await wb.sheets.rename(sheetId, 'Sales');
|
|
79
|
+
|
|
80
|
+
// Tables
|
|
81
|
+
await ws.tables.add('Sales', 'A1:C10', { hasHeaders: true });
|
|
82
|
+
|
|
83
|
+
// Charts
|
|
84
|
+
await ws.charts.add({ type: 'bar', dataRange: 'A1:B5' });
|
|
85
|
+
|
|
86
|
+
// Formatting
|
|
87
|
+
await ws.formats.setCellFormat('A1', { bold: true, fontColor: '#FF0000' });
|
|
88
|
+
|
|
89
|
+
// Structure
|
|
90
|
+
await ws.structure.insertRows(5, 3);
|
|
91
|
+
await ws.structure.mergeCells('A1:B1');
|
|
92
|
+
|
|
93
|
+
// History
|
|
94
|
+
await wb.history.undo();
|
|
95
|
+
await wb.history.redo();
|
|
96
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mog-sdk/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Headless spreadsheet engine for Node.js — full Excel-compatible compute, formulas, and file I/O",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
22
|
+
"dist",
|
|
23
|
+
"llms.txt"
|
|
23
24
|
],
|
|
24
25
|
"engines": {
|
|
25
26
|
"node": ">= 18"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
|
-
"
|
|
29
|
+
"generate:api-spec": "tsx scripts/generate-api-spec.ts",
|
|
30
|
+
"build": "tsx scripts/generate-api-spec.ts && tsup && node scripts/build-types.mjs",
|
|
29
31
|
"build:dev": "tsup --no-dts",
|
|
30
32
|
"test": "jest --config jest.config.cjs",
|
|
31
33
|
"typecheck": "tsc --noEmit",
|
|
@@ -51,11 +53,8 @@
|
|
|
51
53
|
"access": "public"
|
|
52
54
|
},
|
|
53
55
|
"optionalDependencies": {
|
|
54
|
-
"@mog-sdk/darwin-arm64": "
|
|
55
|
-
"@mog-sdk/darwin-x64": "
|
|
56
|
-
"@mog-sdk/linux-x64-gnu": "0.1.0",
|
|
57
|
-
"@mog-sdk/linux-arm64-gnu": "0.1.0",
|
|
58
|
-
"@mog-sdk/win32-x64-msvc": "0.1.0"
|
|
56
|
+
"@mog-sdk/darwin-arm64": "workspace:*",
|
|
57
|
+
"@mog-sdk/darwin-x64": "workspace:*"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
61
60
|
"@rust-bridge/client": "workspace:*",
|