@mog-sdk/node 0.1.10 → 0.1.12

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.d.cts CHANGED
@@ -16,11 +16,13 @@ export type IKernelContext = any;
16
16
  export type IEventBus = any;
17
17
 
18
18
 
19
-
19
+ import { Workbook, WorkbookInternal, Worksheet } from '@mog-sdk/spreadsheet-contracts/api';
20
+ export { Workbook, Worksheet } from '@mog-sdk/spreadsheet-contracts/api';
20
21
  import * as _mog_kernel_bridges from '@mog/kernel/bridges';
21
22
 
22
23
 
23
24
 
25
+ import { CodeExecutionOptions, CodeExecutionResult } from '@mog-sdk/spreadsheet-contracts/core';
24
26
 
25
27
  /**
26
28
  * Save a workbook to a file path. Node.js only.
@@ -112,6 +114,7 @@ var subApis = {
112
114
  },
113
115
  ws: {
114
116
  smartArt: "WorksheetSmartArt",
117
+ changes: "WorksheetChanges",
115
118
  formats: "WorksheetFormats",
116
119
  layout: "WorksheetLayout",
117
120
  view: "WorksheetView",
@@ -234,6 +237,30 @@ var interfaces = {
234
237
  usedTypes: [
235
238
  ]
236
239
  },
240
+ getIterativeCalculation: {
241
+ signature: "getIterativeCalculation(): Promise<boolean>;",
242
+ docstring: "Get whether iterative calculation is enabled for circular references.\nConvenience accessor — equivalent to `(await getSettings()).calculationSettings.enableIterativeCalculation`.",
243
+ usedTypes: [
244
+ ]
245
+ },
246
+ setIterativeCalculation: {
247
+ signature: "setIterativeCalculation(enabled: boolean): Promise<void>;",
248
+ docstring: "Set whether iterative calculation is enabled for circular references.\nConvenience mutator — patches `calculationSettings.enableIterativeCalculation`.",
249
+ usedTypes: [
250
+ ]
251
+ },
252
+ setMaxIterations: {
253
+ signature: "setMaxIterations(n: number): Promise<void>;",
254
+ docstring: "Set the maximum number of iterations for iterative calculation.\nConvenience mutator — patches `calculationSettings.maxIterations`.",
255
+ usedTypes: [
256
+ ]
257
+ },
258
+ setConvergenceThreshold: {
259
+ signature: "setConvergenceThreshold(threshold: number): Promise<void>;",
260
+ docstring: "Set the convergence threshold (maximum change) for iterative calculation.\nConvenience mutator — patches `calculationSettings.maxChange`.",
261
+ usedTypes: [
262
+ ]
263
+ },
237
264
  getUsePrecisionAsDisplayed: {
238
265
  signature: "getUsePrecisionAsDisplayed(): Promise<boolean>;",
239
266
  docstring: "Whether to use displayed precision instead of full (15-digit) precision.\nConvenience accessor — inverted from `calculationSettings.fullPrecision`.",
@@ -462,16 +489,18 @@ var interfaces = {
462
489
  ]
463
490
  },
464
491
  clearData: {
465
- signature: "clearData(range: string): Promise<void>;",
492
+ signature: "clearData(range: string): Promise<ClearResult>;",
466
493
  docstring: "Clear all cell data (values and formulas) in a range (A1 notation, e.g. \"A1:C3\").",
467
494
  usedTypes: [
495
+ "ClearResult"
468
496
  ]
469
497
  },
470
498
  clear: {
471
- signature: "clear(range: string, applyTo?: ClearApplyTo): Promise<void>;",
499
+ signature: "clear(range: string, applyTo?: ClearApplyTo): Promise<ClearResult>;",
472
500
  docstring: "Unified clear with mode selection (OfficeJS Range.clear equivalent).\n\n@param range - A1 range string (e.g. \"A1:C3\")\n@param applyTo - What to clear: 'all' (default), 'contents', 'formats', 'hyperlinks'",
473
501
  usedTypes: [
474
- "ClearApplyTo"
502
+ "ClearApplyTo",
503
+ "ClearResult"
475
504
  ]
476
505
  },
477
506
  getValue: {
@@ -1398,21 +1427,36 @@ var interfaces = {
1398
1427
  }
1399
1428
  }
1400
1429
  },
1430
+ WorksheetChanges: {
1431
+ docstring: "Sub-API for opt-in change tracking on a worksheet.",
1432
+ functions: {
1433
+ track: {
1434
+ signature: "track(options?: ChangeTrackOptions): ChangeTracker;",
1435
+ docstring: "Create a change tracker that accumulates cell-level change records\nfrom this point forward.\n\n@param options - Optional scope and origin filters\n@returns A ChangeTracker handle — call collect() to drain, close() when done",
1436
+ usedTypes: [
1437
+ "ChangeTrackOptions",
1438
+ "ChangeTracker"
1439
+ ]
1440
+ }
1441
+ }
1442
+ },
1401
1443
  WorksheetFormats: {
1402
1444
  docstring: "Sub-API for cell formatting operations on a worksheet.",
1403
1445
  functions: {
1404
1446
  set: {
1405
- signature: "set(address: string, format: CellFormat): Promise<void>;",
1447
+ signature: "set(address: string, format: CellFormat): Promise<FormatChangeResult>;",
1406
1448
  docstring: "Set format for a single cell.\n\n@param address - A1-style cell address (e.g. \"A1\", \"B3\")\n@param format - Format properties to apply",
1407
1449
  usedTypes: [
1408
- "CellFormat"
1450
+ "CellFormat",
1451
+ "FormatChangeResult"
1409
1452
  ]
1410
1453
  },
1411
1454
  setRange: {
1412
- signature: "setRange(range: string, format: CellFormat): Promise<void>;",
1455
+ signature: "setRange(range: string, format: CellFormat): Promise<FormatChangeResult>;",
1413
1456
  docstring: "Set format for a contiguous range.\n\n@param range - A1-style range string (e.g. \"A1:B2\")\n@param format - Format properties to apply",
1414
1457
  usedTypes: [
1415
- "CellFormat"
1458
+ "CellFormat",
1459
+ "FormatChangeResult"
1416
1460
  ]
1417
1461
  },
1418
1462
  setRanges: {
@@ -1430,10 +1474,10 @@ var interfaces = {
1430
1474
  ]
1431
1475
  },
1432
1476
  get: {
1433
- signature: "get(address: string): Promise<CellFormat | null>;",
1434
- docstring: "Get the format of a single cell.\n\n@param address - A1-style cell address\n@returns The cell format, or null if no format is set",
1477
+ signature: "get(address: string): Promise<ResolvedCellFormat>;",
1478
+ docstring: "Get the fully-resolved format of a single cell.\n\nReturns a dense CellFormat with all fields present (null for unset properties,\nnever undefined). Includes the full cascade (default → col → row → table → cell → CF)\nwith theme colors resolved to hex.\n\n@param address - A1-style cell address\n@returns The resolved cell format (always an object, never null)",
1435
1479
  usedTypes: [
1436
- "CellFormat"
1480
+ "ResolvedCellFormat"
1437
1481
  ]
1438
1482
  },
1439
1483
  adjustIndent: {
@@ -2317,7 +2361,7 @@ var interfaces = {
2317
2361
  ]
2318
2362
  },
2319
2363
  setCriteria: {
2320
- signature: "setCriteria(\n filterId: string,\n col: number,\n criteria: ColumnFilterCriteria,\n ): Promise<void>;",
2364
+ signature: "setCriteria(filterId: string, col: number, criteria: ColumnFilterCriteria): Promise<void>;",
2321
2365
  docstring: "Set filter criteria for a column using filter ID.\n\n@param filterId - Filter ID\n@param col - Column index (0-based)\n@param criteria - Filter criteria to apply",
2322
2366
  usedTypes: [
2323
2367
  "ColumnFilterCriteria"
@@ -3745,6 +3789,11 @@ var types = {
3745
3789
  definition: "'standard' | 'stacked' | 'percentStacked'",
3746
3790
  docstring: ""
3747
3791
  },
3792
+ AutoFillChange: {
3793
+ name: "AutoFillChange",
3794
+ definition: "{\n row: number;\n col: number;\n type: 'value' | 'formula' | 'format' | 'clear';\n}",
3795
+ docstring: "A single cell change produced by the fill engine."
3796
+ },
3748
3797
  AutoFillMode: {
3749
3798
  name: "AutoFillMode",
3750
3799
  definition: "| 'auto' // Detect pattern automatically (default)\n | 'copy' // Always copy (no series)\n | 'series' // Force series interpretation\n | 'days' // Force date unit: days\n | 'weekdays' // Force date unit: weekdays\n | 'months' // Force date unit: months\n | 'years' // Force date unit: years\n | 'formats' // Copy formats only\n | 'values' // Copy values only (no formats)\n | 'withoutFormats' // Copy values + formulas, skip formats\n | 'linearTrend' // Force linear regression trend\n | 'growthTrend'",
@@ -3752,7 +3801,7 @@ var types = {
3752
3801
  },
3753
3802
  AutoFillResult: {
3754
3803
  name: "AutoFillResult",
3755
- definition: "{\n /** The pattern that was detected (or forced by mode) */\n patternType: FillPatternType;\n /** Number of cells that were filled */\n filledCellCount: number;\n /** Any warnings generated during fill */\n warnings: AutoFillWarning[];\n}",
3804
+ definition: "{\n /** The pattern that was detected (or forced by mode) */\n patternType: FillPatternType;\n /** Number of cells that were filled */\n filledCellCount: number;\n /** Any warnings generated during fill */\n warnings: AutoFillWarning[];\n /** Per-cell changes listing each cell written */\n changes: AutoFillChange[];\n}",
3756
3805
  docstring: "Result from autoFill() — summary of what the fill engine did."
3757
3806
  },
3758
3807
  AutoFillWarning: {
@@ -3945,6 +3994,26 @@ var types = {
3945
3994
  definition: "{\n /** If true, value is treated as a formula (prefixed with =) */\n asFormula?: boolean;\n}",
3946
3995
  docstring: "Options controlling how a cell value is interpreted when written."
3947
3996
  },
3997
+ ChangeOrigin: {
3998
+ name: "ChangeOrigin",
3999
+ definition: "'direct' | 'cascade' | 'remote'",
4000
+ docstring: "Origin of a change: direct write, formula recalculation, or remote collaborator."
4001
+ },
4002
+ ChangeRecord: {
4003
+ name: "ChangeRecord",
4004
+ definition: "{\n /** Cell address in A1 notation (e.g. \"B1\"). */\n address: string;\n /** 0-based row index. */\n row: number;\n /** 0-based column index. */\n col: number;\n /** What caused this change. */\n origin: ChangeOrigin;\n /** Type of change. */\n type: 'modified';\n}",
4005
+ docstring: "WorksheetChanges — Sub-API for opt-in change tracking.\n\nCreates lightweight trackers that accumulate cell-level change records\nacross mutations. Trackers are opt-in to avoid bloating return values;\nthey return addresses + metadata only (no cell values) so callers can\nhydrate via getRange() when needed.\n\nInspired by:\n- Excel OfficeJS onChanged (lightweight payload + lazy hydration)\n- Firestore onSnapshot (query-scoped subscriptions)\n- Yjs transaction.origin (source/origin tagging for collab)"
4006
+ },
4007
+ ChangeTrackOptions: {
4008
+ name: "ChangeTrackOptions",
4009
+ definition: "{\n /** Only track changes within this range (A1 notation, e.g. \"A1:Z100\"). Omit for whole-sheet. */\n scope?: string;\n /** Exclude changes from these origin types. */\n excludeOrigins?: ChangeOrigin[];\n}",
4010
+ docstring: "Options for creating a change tracker."
4011
+ },
4012
+ ChangeTracker: {
4013
+ name: "ChangeTracker",
4014
+ definition: "{\n /** Drain all accumulated changes since creation or last collect() call.\nReturns addresses + metadata only (no cell values) — call ws.getRange()\nto hydrate if needed. */\n collect(): ChangeRecord[];;\n /** Stop tracking and release internal resources. */\n close(): void;;\n /** Whether this tracker is still active (not closed). */\n active: boolean;\n}",
4015
+ docstring: "A handle that accumulates change records across mutations."
4016
+ },
3948
4017
  Chart: {
3949
4018
  name: "Chart",
3950
4019
  definition: "{\n id: string;\n sheetId?: string;\n createdAt?: number;\n updatedAt?: number;\n}",
@@ -4005,6 +4074,11 @@ var types = {
4005
4074
  definition: "'all' | 'contents' | 'formats' | 'hyperlinks'",
4006
4075
  docstring: "Determines which aspects of a range to clear.\nMatches OfficeJS Excel.ClearApplyTo enum."
4007
4076
  },
4077
+ ClearResult: {
4078
+ name: "ClearResult",
4079
+ definition: "{\n /** Number of cells in the cleared range. */\n cellCount: number;\n}",
4080
+ docstring: "Confirmation returned by clearData() and clear()."
4081
+ },
4008
4082
  CodeResult: {
4009
4083
  name: "CodeResult",
4010
4084
  definition: "{\n /** Whether execution completed successfully */\n success: boolean;\n /** Captured console output */\n output?: string;\n /** Error message (if success is false) */\n error?: string;\n /** Execution duration in milliseconds */\n duration?: number;\n}",
@@ -4215,6 +4289,11 @@ var types = {
4215
4289
  definition: "| 'shape'\n | 'connector'\n | 'picture'\n | 'textbox'\n | 'chart'\n | 'camera'\n | 'equation'\n | 'smartart'\n | 'drawing'\n | 'oleObject'\n | 'formControl'\n | 'slicer'\n | 'wordart'",
4216
4290
  docstring: "Type discriminator for floating objects. Superset of Rust FloatingObjectKind (12 variants) + legacy TS-only 'wordart'."
4217
4291
  },
4292
+ FormatChangeResult: {
4293
+ name: "FormatChangeResult",
4294
+ definition: "{\n /** Number of cells whose formatting was changed */\n cellCount: number;\n}",
4295
+ docstring: "Result of a format set/setRange operation."
4296
+ },
4218
4297
  FormatEntry: {
4219
4298
  name: "FormatEntry",
4220
4299
  definition: "{\n /** Cell value descriptor */\n value: { type: string; value?: unknown };\n /** Number format code (e.g., \"#,##0.00\") */\n formatCode: string;\n}",
@@ -4556,6 +4635,11 @@ var types = {
4556
4635
  definition: "{\n /** Number of duplicate rows removed */\n removedCount: number;\n /** Number of unique rows remaining */\n remainingCount: number;\n}",
4557
4636
  docstring: "Result of a remove-duplicates operation."
4558
4637
  },
4638
+ ResolvedCellFormat: {
4639
+ name: "ResolvedCellFormat",
4640
+ definition: "{\n [K in keyof CellFormat]-?: CellFormat[K] | null;\n}",
4641
+ docstring: "Dense cell format where every property is explicitly present (null when unset). Returned by formats.get()."
4642
+ },
4559
4643
  RichTextSegment: {
4560
4644
  name: "RichTextSegment",
4561
4645
  definition: "{\n text: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n color?: string;\n fontName?: string;\n fontSize?: number;\n}",
@@ -4598,7 +4682,7 @@ var types = {
4598
4682
  },
4599
4683
  SetCellsResult: {
4600
4684
  name: "SetCellsResult",
4601
- definition: "{\n /** Number of cells successfully written */\n cellsWritten: number;\n /** Per-cell errors, if any (omitted when all succeed) */\n errors?: Array<{ addr: string; error: string }>;\n /** Non-fatal warnings (e.g., deduplication, coercion) */\n warnings?: OperationWarning[];\n}",
4685
+ definition: "{\n /** Number of cells successfully written */\n cellsWritten: number;\n /** Per-cell errors, if any (omitted when all succeed) */\n errors?: Array<{ addr: string; error: string }> | null;\n /** Non-fatal warnings (e.g., deduplication, coercion) */\n warnings?: OperationWarning[];\n}",
4602
4686
  docstring: "Result of a bulk setCells() operation."
4603
4687
  },
4604
4688
  ShadowAlignment: {
@@ -4952,180 +5036,12 @@ var types = {
4952
5036
  docstring: "A summary snapshot of the entire workbook state."
4953
5037
  }
4954
5038
  };
4955
- var generated = "2026-04-02T22:03:24.772Z";
4956
5039
  var apiSpec = {
4957
5040
  subApis: subApis,
4958
5041
  interfaces: interfaces,
4959
- types: types,
4960
- generated: generated
5042
+ types: types
4961
5043
  };
4962
5044
 
4963
-
4964
- /**
4965
- * A spreadsheet workbook — the primary API for all spreadsheet operations.
4966
- *
4967
- * Create with `createWorkbook()`. Access sheets via `getActiveSheet()`,
4968
- * `getSheet(index)`, or `getSheetByName(name)`.
4969
- *
4970
- * Sub-APIs: history, sheets, names, scenarios, styles, notifications,
4971
- * theme, viewport, protection, floatingObjects.
4972
- */
4973
- export interface Workbook {
4974
- /** Get the currently active worksheet */
4975
- getActiveSheet(): Worksheet;
4976
- /** Get the active sheet ID */
4977
- getActiveSheetId(): string;
4978
- /** Set the active sheet by ID */
4979
- setActiveSheetId(sheetId: string): void;
4980
- /** Get sheet by 0-based index */
4981
- getSheet(index: number): Worksheet;
4982
- /** Get sheet by name */
4983
- getSheetByName(name: string): Worksheet | undefined;
4984
-
4985
- /** Undo/redo, batch operations, checkpoints */
4986
- readonly history: WorkbookHistory;
4987
- /** Sheet CRUD: add, remove, rename, move, duplicate */
4988
- readonly sheets: WorkbookSheets;
4989
-
4990
- /** Execute code in a sandboxed VM */
4991
- executeCode(code: string, options?: { timeout?: number }): Promise<unknown>;
4992
- /** Export workbook to XLSX buffer */
4993
- toBuffer(): Promise<Uint8Array>;
4994
- /** Dispose all resources — MUST call when done */
4995
- dispose(): void;
4996
-
4997
- [key: string]: any;
4998
- }
4999
-
5000
- export interface WorkbookHistory {
5001
- undo(): Promise<void>;
5002
- redo(): Promise<void>;
5003
- batch(fn: () => Promise<void>): Promise<void>;
5004
- [key: string]: any;
5005
- }
5006
-
5007
- export interface WorkbookSheets {
5008
- add(name?: string): Promise<string>;
5009
- remove(sheetId: string): Promise<void>;
5010
- rename(sheetId: string, name: string): Promise<void>;
5011
- getAll(): Array<{ id: string; name: string; index: number }>;
5012
- [key: string]: any;
5013
- }
5014
-
5015
- /**
5016
- * A single worksheet — read/write cells, formatting, charts, and more.
5017
- *
5018
- * Supports both A1 notation (`"A1"`) and numeric addressing (`(row, col)`).
5019
- *
5020
- * Sub-APIs: formats, layout, view, structure, charts, shapes, pictures,
5021
- * filters, validation, tables, pivots, slicers, comments, hyperlinks,
5022
- * outline, protection, print, settings, bindings.
5023
- */
5024
- export interface Worksheet {
5025
- /** Sheet name */
5026
- readonly name: string;
5027
- /** Sheet ID */
5028
- readonly id: string;
5029
- /** 0-based sheet index */
5030
- getIndex(): number;
5031
-
5032
- /** Set a cell value (A1 notation) */
5033
- setCell(address: string, value: unknown): Promise<void>;
5034
- /** Set a cell value (numeric) */
5035
- setCell(row: number, col: number, value: unknown): Promise<void>;
5036
-
5037
- /** Get a cell's computed value */
5038
- getValue(address: string): Promise<unknown>;
5039
- getValue(row: number, col: number): Promise<unknown>;
5040
-
5041
- /** Get a cell's formula (or undefined if none) */
5042
- getFormula(address: string): Promise<string | undefined>;
5043
- getFormula(row: number, col: number): Promise<string | undefined>;
5044
-
5045
- /** Get full cell data */
5046
- getCell(address: string): Promise<CellData | undefined>;
5047
- getCell(row: number, col: number): Promise<CellData | undefined>;
5048
-
5049
- /** Formatting sub-API */
5050
- readonly formats: WorksheetFormats;
5051
- /** Layout sub-API (row heights, column widths, merges) */
5052
- readonly layout: WorksheetLayout;
5053
- /** Chart operations */
5054
- readonly charts: WorksheetCharts;
5055
- /** Table operations */
5056
- readonly tables: WorksheetTables;
5057
-
5058
- /** Describe the sheet for LLM consumption */
5059
- describe(): Promise<string>;
5060
- /** Describe a range for LLM consumption */
5061
- describeRange(range: string): Promise<string>;
5062
-
5063
- [key: string]: any;
5064
- }
5065
-
5066
- export interface CellData {
5067
- value: unknown;
5068
- formula?: string;
5069
- formattedValue?: string;
5070
- [key: string]: any;
5071
- }
5072
-
5073
- export interface WorksheetFormats {
5074
- set(address: string, format: Record<string, unknown>): Promise<void>;
5075
- get(address: string): Promise<Record<string, unknown>>;
5076
- [key: string]: any;
5077
- }
5078
-
5079
- export interface WorksheetLayout {
5080
- setRowHeight(row: number, height: number): Promise<void>;
5081
- setColumnWidth(col: number, width: number): Promise<void>;
5082
- merge(range: string): Promise<void>;
5083
- unmerge(range: string): Promise<void>;
5084
- [key: string]: any;
5085
- }
5086
-
5087
- export interface WorksheetCharts {
5088
- add(type: string, dataRange: string, options?: Record<string, unknown>): Promise<string>;
5089
- remove(chartId: string): Promise<void>;
5090
- [key: string]: any;
5091
- }
5092
-
5093
- export interface WorksheetTables {
5094
- add(range: string, options?: Record<string, unknown>): Promise<string>;
5095
- remove(tableId: string): Promise<void>;
5096
- [key: string]: any;
5097
- }
5098
-
5099
- export interface CreateWorkbookOptions {
5100
- /** Document ID (auto-generated if omitted) */
5101
- documentId?: string;
5102
- /** XLSX source to import */
5103
- source?: { type: 'bytes'; data: Uint8Array } | { type: 'path'; path: string };
5104
- /** Import options */
5105
- importOptions?: Record<string, unknown>;
5106
- }
5107
-
5108
- export interface WorkbookConfig {
5109
- ctx: any;
5110
- getActiveSheetId?: () => string;
5111
- setActiveSheetId?: (sheetId: string) => void;
5112
- eventBus: any;
5113
- [key: string]: any;
5114
- }
5115
-
5116
- /**
5117
- * Create a new headless workbook.
5118
- *
5119
- * @example
5120
- * ```typescript
5121
- * import { createWorkbook } from '@mog/sdk';
5122
- * const wb = await createWorkbook();
5123
- * const ws = wb.getActiveSheet();
5124
- * await ws.setCell('A1', 42);
5125
- * ```
5126
- */
5127
- export declare function createWorkbook(options?: CreateWorkbookOptions): Promise<Workbook>;
5128
-
5129
5045
  /**
5130
5046
  * HeadlessLifecycleSystem - Headless Boot Wrapper for the Spreadsheet Engine
5131
5047
  *