@ricsam/formula-engine 0.0.16 → 0.0.18

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.
Files changed (122) hide show
  1. package/dist/cjs/core/api/api-builder.cjs +67 -0
  2. package/dist/cjs/core/api/api-builder.cjs.map +10 -0
  3. package/dist/cjs/core/api/api-helpers.cjs +191 -0
  4. package/dist/cjs/core/api/api-helpers.cjs.map +10 -0
  5. package/dist/cjs/core/api/api.cjs +65 -0
  6. package/dist/cjs/core/api/api.cjs.map +10 -0
  7. package/dist/cjs/core/api/cell-orm.cjs +80 -0
  8. package/dist/cjs/core/api/cell-orm.cjs.map +10 -0
  9. package/dist/cjs/core/api/table-orm.cjs +171 -0
  10. package/dist/cjs/core/api/table-orm.cjs.map +10 -0
  11. package/dist/cjs/core/autofill-utils.cjs +75 -39
  12. package/dist/cjs/core/autofill-utils.cjs.map +3 -3
  13. package/dist/cjs/core/cell-mover.cjs +178 -0
  14. package/dist/cjs/core/cell-mover.cjs.map +10 -0
  15. package/dist/cjs/core/commands/command-executor.cjs +140 -0
  16. package/dist/cjs/core/commands/command-executor.cjs.map +10 -0
  17. package/dist/cjs/core/commands/content-commands.cjs +574 -0
  18. package/dist/cjs/core/commands/content-commands.cjs.map +10 -0
  19. package/dist/cjs/core/commands/index.cjs +95 -0
  20. package/dist/cjs/core/commands/index.cjs.map +10 -0
  21. package/dist/cjs/core/commands/metadata-commands.cjs +150 -0
  22. package/dist/cjs/core/commands/metadata-commands.cjs.map +10 -0
  23. package/dist/cjs/core/commands/named-expression-commands.cjs +238 -0
  24. package/dist/cjs/core/commands/named-expression-commands.cjs.map +10 -0
  25. package/dist/cjs/core/commands/structure-commands.cjs +495 -0
  26. package/dist/cjs/core/commands/structure-commands.cjs.map +10 -0
  27. package/dist/cjs/core/commands/style-commands.cjs +219 -0
  28. package/dist/cjs/core/commands/style-commands.cjs.map +10 -0
  29. package/dist/cjs/core/commands/table-commands.cjs +226 -0
  30. package/dist/cjs/core/commands/table-commands.cjs.map +10 -0
  31. package/dist/cjs/core/commands/types.cjs +72 -0
  32. package/dist/cjs/core/commands/types.cjs.map +10 -0
  33. package/dist/cjs/core/engine.cjs +218 -263
  34. package/dist/cjs/core/engine.cjs.map +3 -3
  35. package/dist/cjs/core/managers/api-schema-manager.cjs +304 -0
  36. package/dist/cjs/core/managers/api-schema-manager.cjs.map +10 -0
  37. package/dist/cjs/core/managers/copy-manager.cjs +336 -82
  38. package/dist/cjs/core/managers/copy-manager.cjs.map +3 -3
  39. package/dist/cjs/core/managers/reference-manager.cjs +124 -0
  40. package/dist/cjs/core/managers/reference-manager.cjs.map +10 -0
  41. package/dist/cjs/core/managers/style-manager.cjs +115 -147
  42. package/dist/cjs/core/managers/style-manager.cjs.map +3 -3
  43. package/dist/cjs/core/managers/workbook-manager.cjs +87 -3
  44. package/dist/cjs/core/managers/workbook-manager.cjs.map +3 -3
  45. package/dist/cjs/core/types.cjs.map +1 -1
  46. package/dist/cjs/lib.cjs +13 -2
  47. package/dist/cjs/lib.cjs.map +3 -3
  48. package/dist/cjs/package.json +1 -1
  49. package/dist/mjs/core/api/api-builder.mjs +37 -0
  50. package/dist/mjs/core/api/api-builder.mjs.map +10 -0
  51. package/dist/mjs/core/api/api-helpers.mjs +161 -0
  52. package/dist/mjs/core/api/api-helpers.mjs.map +10 -0
  53. package/dist/mjs/core/api/api.mjs +35 -0
  54. package/dist/mjs/core/api/api.mjs.map +10 -0
  55. package/dist/mjs/core/api/cell-orm.mjs +49 -0
  56. package/dist/mjs/core/api/cell-orm.mjs.map +10 -0
  57. package/dist/mjs/core/api/table-orm.mjs +148 -0
  58. package/dist/mjs/core/api/table-orm.mjs.map +10 -0
  59. package/dist/mjs/core/autofill-utils.mjs +75 -39
  60. package/dist/mjs/core/autofill-utils.mjs.map +3 -3
  61. package/dist/mjs/core/cell-mover.mjs +148 -0
  62. package/dist/mjs/core/cell-mover.mjs.map +10 -0
  63. package/dist/mjs/core/commands/command-executor.mjs +109 -0
  64. package/dist/mjs/core/commands/command-executor.mjs.map +10 -0
  65. package/dist/mjs/core/commands/content-commands.mjs +544 -0
  66. package/dist/mjs/core/commands/content-commands.mjs.map +10 -0
  67. package/dist/mjs/core/commands/index.mjs +87 -0
  68. package/dist/mjs/core/commands/index.mjs.map +10 -0
  69. package/dist/mjs/core/commands/metadata-commands.mjs +120 -0
  70. package/dist/mjs/core/commands/metadata-commands.mjs.map +10 -0
  71. package/dist/mjs/core/commands/named-expression-commands.mjs +208 -0
  72. package/dist/mjs/core/commands/named-expression-commands.mjs.map +10 -0
  73. package/dist/mjs/core/commands/structure-commands.mjs +465 -0
  74. package/dist/mjs/core/commands/structure-commands.mjs.map +10 -0
  75. package/dist/mjs/core/commands/style-commands.mjs +189 -0
  76. package/dist/mjs/core/commands/style-commands.mjs.map +10 -0
  77. package/dist/mjs/core/commands/table-commands.mjs +196 -0
  78. package/dist/mjs/core/commands/table-commands.mjs.map +10 -0
  79. package/dist/mjs/core/commands/types.mjs +42 -0
  80. package/dist/mjs/core/commands/types.mjs.map +10 -0
  81. package/dist/mjs/core/engine.mjs +253 -263
  82. package/dist/mjs/core/engine.mjs.map +3 -3
  83. package/dist/mjs/core/managers/api-schema-manager.mjs +274 -0
  84. package/dist/mjs/core/managers/api-schema-manager.mjs.map +10 -0
  85. package/dist/mjs/core/managers/copy-manager.mjs +338 -82
  86. package/dist/mjs/core/managers/copy-manager.mjs.map +3 -3
  87. package/dist/mjs/core/managers/reference-manager.mjs +93 -0
  88. package/dist/mjs/core/managers/reference-manager.mjs.map +10 -0
  89. package/dist/mjs/core/managers/style-manager.mjs +115 -147
  90. package/dist/mjs/core/managers/style-manager.mjs.map +3 -3
  91. package/dist/mjs/core/managers/workbook-manager.mjs +87 -3
  92. package/dist/mjs/core/managers/workbook-manager.mjs.map +3 -3
  93. package/dist/mjs/core/types.mjs.map +1 -1
  94. package/dist/mjs/lib.mjs +13 -2
  95. package/dist/mjs/lib.mjs.map +3 -3
  96. package/dist/mjs/package.json +1 -1
  97. package/dist/types/core/api/api-builder.d.ts +16 -0
  98. package/dist/types/core/api/api-helpers.d.ts +37 -0
  99. package/dist/types/core/api/api.d.ts +83 -0
  100. package/dist/types/core/api/api.type-test.d.ts +1 -0
  101. package/dist/types/core/api/cell-orm.d.ts +29 -0
  102. package/dist/types/core/api/table-orm.d.ts +46 -0
  103. package/dist/types/core/autofill-utils.d.ts +6 -9
  104. package/dist/types/core/cell-mover.d.ts +63 -0
  105. package/dist/types/core/commands/command-executor.d.ts +83 -0
  106. package/dist/types/core/commands/content-commands.d.ts +142 -0
  107. package/dist/types/core/commands/index.d.ts +16 -0
  108. package/dist/types/core/commands/metadata-commands.d.ts +55 -0
  109. package/dist/types/core/commands/named-expression-commands.d.ts +115 -0
  110. package/dist/types/core/commands/structure-commands.d.ts +132 -0
  111. package/dist/types/core/commands/style-commands.d.ts +76 -0
  112. package/dist/types/core/commands/table-commands.d.ts +104 -0
  113. package/dist/types/core/commands/types.d.ts +114 -0
  114. package/dist/types/core/engine.d.ts +241 -23
  115. package/dist/types/core/managers/api-schema-manager.d.ts +121 -0
  116. package/dist/types/core/managers/copy-manager.d.ts +47 -2
  117. package/dist/types/core/managers/reference-manager.d.ts +54 -0
  118. package/dist/types/core/managers/style-manager.d.ts +6 -6
  119. package/dist/types/core/managers/workbook-manager.d.ts +39 -1
  120. package/dist/types/core/types.d.ts +52 -11
  121. package/dist/types/lib.d.ts +8 -0
  122. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ /**
2
+ * TableOrm - Object-Relational Mapping for table data
3
+ *
4
+ * Provides CRUD operations for table data with type-safe access.
5
+ * Used as the `this` context for custom table API methods.
6
+ */
7
+ import type { FormulaEngine } from "../engine";
8
+ import { type TableSchemaHeaders } from "./api-helpers";
9
+ export declare class TableOrm<TItem extends Record<string, unknown>> {
10
+ private engine;
11
+ private workbookName;
12
+ private tableName;
13
+ private headers;
14
+ private namespace;
15
+ constructor(engine: FormulaEngine<any, any>, workbookName: string, tableName: string, headers: TableSchemaHeaders, namespace: string);
16
+ /**
17
+ * Get the table definition from the engine
18
+ */
19
+ private getTable;
20
+ /**
21
+ * Find the first row matching the filter
22
+ */
23
+ findWhere(filter: Partial<TItem>): TItem | undefined;
24
+ /**
25
+ * Find all rows matching the filter
26
+ */
27
+ findAllWhere(filter: Partial<TItem>): TItem[];
28
+ /**
29
+ * Append a new row to the table
30
+ */
31
+ append(item: TItem): TItem;
32
+ /**
33
+ * Update all rows matching the filter
34
+ * Returns the number of rows updated
35
+ */
36
+ updateWhere(filter: Partial<TItem>, update: Partial<TItem>): number;
37
+ /**
38
+ * Remove all rows matching the filter
39
+ * Returns the number of rows removed
40
+ */
41
+ removeWhere(filter: Partial<TItem>): number;
42
+ /**
43
+ * Get the count of data rows in the table
44
+ */
45
+ count(): number;
46
+ }
@@ -1,21 +1,14 @@
1
1
  /**
2
2
  * AutoFill class for handling spreadsheet autofill functionality
3
3
  */
4
- import type { CellAddress, SerializedCellValue, SpreadsheetRange } from "./types";
4
+ import type { SpreadsheetRange } from "./types";
5
5
  import type { FillDirection } from "@ricsam/selection-manager";
6
6
  import type { WorkbookManager } from "./managers/workbook-manager";
7
7
  import type { StyleManager } from "./managers/style-manager";
8
8
  export declare class AutoFill {
9
9
  private workbookManager;
10
10
  private styleManager;
11
- private engine;
12
- constructor(workbookManager: WorkbookManager, styleManager: StyleManager, engine: {
13
- setCellContent: (address: CellAddress, content: SerializedCellValue) => void;
14
- setSheetContent: (opts: {
15
- sheetName: string;
16
- workbookName: string;
17
- }, content: Map<string, SerializedCellValue>) => void;
18
- });
11
+ constructor(workbookManager: WorkbookManager, styleManager: StyleManager);
19
12
  /**
20
13
  * Converts a SpreadsheetRange to FiniteSpreadsheetRange, throwing an error if infinite
21
14
  */
@@ -40,4 +33,8 @@ export declare class AutoFill {
40
33
  * Clears existing cell styles in fill range first (Excel behavior)
41
34
  */
42
35
  private fillStyles;
36
+ /**
37
+ * Copy metadata from seed range to fill range with pattern repetition
38
+ */
39
+ private fillMetadata;
43
40
  }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Information about cells being moved
3
+ */
4
+ export interface MovedCellsInfo {
5
+ /**
6
+ * Set of cell keys in format "workbookName:sheetName:colIndex:rowIndex"
7
+ * for fast O(1) lookup
8
+ */
9
+ cellsSet: Set<string>;
10
+ /**
11
+ * Workbook name of the source cells (all moved cells must be in same workbook/sheet)
12
+ */
13
+ workbookName: string;
14
+ /**
15
+ * Sheet name of the source cells
16
+ */
17
+ sheetName: string;
18
+ /**
19
+ * Row offset for the move (targetRow - sourceRow)
20
+ */
21
+ rowOffset: number;
22
+ /**
23
+ * Column offset for the move (targetCol - sourceCol)
24
+ */
25
+ colOffset: number;
26
+ }
27
+ /**
28
+ * Updates cell and range references in a formula when cells are moved
29
+ *
30
+ * @param formula - The formula string (without the leading =)
31
+ * @param movedCells - Information about which cells were moved
32
+ * @returns The updated formula string, or the original if no changes were made
33
+ *
34
+ * @example
35
+ * // Moving A1 to D5 (offset: col+3, row+4)
36
+ * updateReferencesForMovedCells("A1+B1", {...}) // "D5+B1" (only A1 updated)
37
+ * updateReferencesForMovedCells("SUM(A1:D5)", {...}) // "SUM(E4:H9)" (if entire range moved)
38
+ */
39
+ export declare function updateReferencesForMovedCells(formula: string, movedCells: MovedCellsInfo): string;
40
+ /**
41
+ * Checks if a formula contains a reference to a specific cell
42
+ *
43
+ * @param formula - The formula string (without the leading =)
44
+ * @param workbookName - The workbook name
45
+ * @param sheetName - The sheet name
46
+ * @param colIndex - The column index
47
+ * @param rowIndex - The row index
48
+ * @returns True if the formula references the cell
49
+ */
50
+ export declare function formulaReferencesCell(formula: string, workbookName: string, sheetName: string, colIndex: number, rowIndex: number): boolean;
51
+ /**
52
+ * Checks if a formula contains a reference to a specific range
53
+ *
54
+ * @param formula - The formula string (without the leading =)
55
+ * @param workbookName - The workbook name
56
+ * @param sheetName - The sheet name
57
+ * @param startCol - Range start column
58
+ * @param startRow - Range start row
59
+ * @param endCol - Range end column
60
+ * @param endRow - Range end row
61
+ * @returns True if the formula references the range
62
+ */
63
+ export declare function formulaReferencesRange(formula: string, workbookName: string, sheetName: string, startCol: number, startRow: number, endCol: number, endRow: number): boolean;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * CommandExecutor - Executes commands with undo/redo support and schema validation
3
+ *
4
+ * Handles:
5
+ * - Command execution with optional re-evaluation
6
+ * - Schema validation after re-evaluation
7
+ * - Automatic rollback on validation failure
8
+ * - Undo/redo stacks
9
+ * - Action serialization for persistence
10
+ */
11
+ import type { Declaration } from "../api/api";
12
+ import type { EvaluationManager } from "../managers/evaluation-manager";
13
+ import type { EventManager } from "../managers/event-manager";
14
+ import type { EngineCommand, EngineAction, ExecuteOptions, SchemaValidationResult, SchemaValidationErrorInfo } from "./types";
15
+ /**
16
+ * Error thrown when schema integrity validation fails.
17
+ * Contains all validation errors that occurred.
18
+ */
19
+ export declare class SchemaIntegrityError extends Error {
20
+ errors: SchemaValidationErrorInfo[];
21
+ constructor(errors: SchemaValidationErrorInfo[]);
22
+ }
23
+ /**
24
+ * CommandExecutor manages command execution with validation and undo/redo support.
25
+ */
26
+ export declare class CommandExecutor {
27
+ private apiDeclaration;
28
+ private evaluationManager;
29
+ private eventManager;
30
+ private validateAllSchemas;
31
+ private undoStack;
32
+ private redoStack;
33
+ private actionLog;
34
+ constructor(apiDeclaration: Declaration | undefined, evaluationManager: EvaluationManager, eventManager: EventManager, validateAllSchemas: () => SchemaValidationResult);
35
+ /**
36
+ * Execute a command with optional schema validation.
37
+ *
38
+ * @param command - The command to execute
39
+ * @param options - Execution options
40
+ * @throws SchemaIntegrityError if validation fails
41
+ */
42
+ execute(command: EngineCommand, options?: ExecuteOptions): void;
43
+ /**
44
+ * Undo the last command.
45
+ *
46
+ * @returns true if undo was performed, false if nothing to undo
47
+ */
48
+ undo(): boolean;
49
+ /**
50
+ * Redo the last undone command.
51
+ *
52
+ * @returns true if redo was performed, false if nothing to redo
53
+ */
54
+ redo(): boolean;
55
+ /**
56
+ * Check if undo is available.
57
+ */
58
+ canUndo(): boolean;
59
+ /**
60
+ * Check if redo is available.
61
+ */
62
+ canRedo(): boolean;
63
+ /**
64
+ * Get the action log for persistence/collaboration.
65
+ */
66
+ getActionLog(): EngineAction[];
67
+ /**
68
+ * Clear the action log.
69
+ */
70
+ clearActionLog(): void;
71
+ /**
72
+ * Clear undo/redo stacks.
73
+ */
74
+ clearHistory(): void;
75
+ /**
76
+ * Get the number of commands in the undo stack.
77
+ */
78
+ getUndoStackSize(): number;
79
+ /**
80
+ * Get the number of commands in the redo stack.
81
+ */
82
+ getRedoStackSize(): number;
83
+ }
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Content Commands - Commands that modify cell/sheet content
3
+ *
4
+ * These commands all require re-evaluation after execution.
5
+ */
6
+ import type { WorkbookManager } from "../managers/workbook-manager";
7
+ import type { CopyManager } from "../managers/copy-manager";
8
+ import type { CellAddress, CopyCellsOptions, RangeAddress, SerializedCellValue } from "../types";
9
+ import type { EngineCommand, EngineAction } from "./types";
10
+ /**
11
+ * Command to set a single cell's content.
12
+ */
13
+ export declare class SetCellContentCommand implements EngineCommand {
14
+ private workbookManager;
15
+ private address;
16
+ private newContent;
17
+ readonly requiresReevaluation = true;
18
+ private previousValue;
19
+ private hadPreviousValue;
20
+ constructor(workbookManager: WorkbookManager, address: CellAddress, newContent: SerializedCellValue);
21
+ execute(): void;
22
+ undo(): void;
23
+ toAction(): EngineAction;
24
+ }
25
+ /**
26
+ * Command to set an entire sheet's content.
27
+ */
28
+ export declare class SetSheetContentCommand implements EngineCommand {
29
+ private workbookManager;
30
+ private opts;
31
+ private newContent;
32
+ readonly requiresReevaluation = true;
33
+ private previousContent;
34
+ constructor(workbookManager: WorkbookManager, opts: {
35
+ workbookName: string;
36
+ sheetName: string;
37
+ }, newContent: Map<string, SerializedCellValue>);
38
+ execute(): void;
39
+ undo(): void;
40
+ toAction(): EngineAction;
41
+ }
42
+ /**
43
+ * Command to clear a range of cells.
44
+ */
45
+ export declare class ClearRangeCommand implements EngineCommand {
46
+ private workbookManager;
47
+ private address;
48
+ readonly requiresReevaluation = true;
49
+ private clearedCells;
50
+ constructor(workbookManager: WorkbookManager, address: RangeAddress);
51
+ execute(): void;
52
+ undo(): void;
53
+ toAction(): EngineAction;
54
+ }
55
+ /**
56
+ * Command to paste cells.
57
+ */
58
+ export declare class PasteCellsCommand implements EngineCommand {
59
+ private workbookManager;
60
+ private copyManager;
61
+ private source;
62
+ private target;
63
+ private options;
64
+ readonly requiresReevaluation = true;
65
+ private targetSnapshots;
66
+ private sourceSnapshots;
67
+ constructor(workbookManager: WorkbookManager, copyManager: CopyManager, source: CellAddress[], target: CellAddress, options: CopyCellsOptions);
68
+ execute(): void;
69
+ undo(): void;
70
+ toAction(): EngineAction;
71
+ }
72
+ /**
73
+ * Command to fill areas with a seed range.
74
+ */
75
+ export declare class FillAreasCommand implements EngineCommand {
76
+ private workbookManager;
77
+ private copyManager;
78
+ private seedRange;
79
+ private targetRanges;
80
+ private options;
81
+ readonly requiresReevaluation = true;
82
+ private targetSnapshots;
83
+ constructor(workbookManager: WorkbookManager, copyManager: CopyManager, seedRange: RangeAddress, targetRanges: RangeAddress[], options: CopyCellsOptions);
84
+ execute(): void;
85
+ undo(): void;
86
+ toAction(): EngineAction;
87
+ }
88
+ /**
89
+ * Command to move a single cell.
90
+ */
91
+ export declare class MoveCellCommand implements EngineCommand {
92
+ private workbookManager;
93
+ private copyManager;
94
+ private source;
95
+ private target;
96
+ readonly requiresReevaluation = true;
97
+ private sourceSnapshot;
98
+ private targetSnapshot;
99
+ constructor(workbookManager: WorkbookManager, copyManager: CopyManager, source: CellAddress, target: CellAddress);
100
+ execute(): void;
101
+ undo(): void;
102
+ toAction(): EngineAction;
103
+ }
104
+ /**
105
+ * Command to move a range of cells.
106
+ */
107
+ export declare class MoveRangeCommand implements EngineCommand {
108
+ private workbookManager;
109
+ private copyManager;
110
+ private sourceRange;
111
+ private target;
112
+ readonly requiresReevaluation = true;
113
+ private sourceSnapshots;
114
+ private targetSnapshots;
115
+ constructor(workbookManager: WorkbookManager, copyManager: CopyManager, sourceRange: RangeAddress, target: CellAddress);
116
+ execute(): void;
117
+ undo(): void;
118
+ toAction(): EngineAction;
119
+ }
120
+ /**
121
+ * Command to auto-fill ranges based on a seed pattern.
122
+ * Captures the entire affected area for undo.
123
+ */
124
+ export declare class AutoFillCommand implements EngineCommand {
125
+ private workbookManager;
126
+ private styleManager;
127
+ private autoFillManager;
128
+ private opts;
129
+ private seedRange;
130
+ private fillRanges;
131
+ private direction;
132
+ readonly requiresReevaluation = true;
133
+ private previousContent;
134
+ private previousMetadata;
135
+ constructor(workbookManager: WorkbookManager, styleManager: import("../managers/style-manager").StyleManager, autoFillManager: import("../autofill-utils").AutoFill, opts: {
136
+ sheetName: string;
137
+ workbookName: string;
138
+ }, seedRange: import("../types").SpreadsheetRange, fillRanges: import("../types").SpreadsheetRange[], direction: import("@ricsam/selection-manager").FillDirection);
139
+ execute(): void;
140
+ undo(): void;
141
+ toAction(): EngineAction;
142
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Commands Module - Command Pattern implementation for FormulaEngine
3
+ *
4
+ * This module provides:
5
+ * - EngineCommand interface for all commands
6
+ * - CommandExecutor for execution with undo/redo and schema validation
7
+ * - All command implementations organized by category
8
+ */
9
+ export * from "./types";
10
+ export { CommandExecutor, SchemaIntegrityError } from "./command-executor";
11
+ export { SetCellContentCommand, SetSheetContentCommand, ClearRangeCommand, PasteCellsCommand, FillAreasCommand, MoveCellCommand, MoveRangeCommand, AutoFillCommand, } from "./content-commands";
12
+ export { AddWorkbookCommand, RemoveWorkbookCommand, RenameWorkbookCommand, CloneWorkbookCommand, AddSheetCommand, RemoveSheetCommand, RenameSheetCommand, type StructureCommandDeps, } from "./structure-commands";
13
+ export { AddTableCommand, RemoveTableCommand, RenameTableCommand, UpdateTableCommand, ResetTablesCommand, type TableCommandDeps, } from "./table-commands";
14
+ export { AddNamedExpressionCommand, RemoveNamedExpressionCommand, UpdateNamedExpressionCommand, RenameNamedExpressionCommand, SetNamedExpressionsCommand, type NamedExpressionCommandDeps, } from "./named-expression-commands";
15
+ export { SetCellMetadataCommand, SetSheetMetadataCommand, SetWorkbookMetadataCommand, } from "./metadata-commands";
16
+ export { AddConditionalStyleCommand, RemoveConditionalStyleCommand, AddCellStyleCommand, RemoveCellStyleCommand, ClearCellStylesCommand, } from "./style-commands";
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Metadata Commands - Commands that modify cell/sheet/workbook metadata
3
+ *
4
+ * These commands do NOT require re-evaluation after execution.
5
+ * They only affect metadata, not cell values or formulas.
6
+ */
7
+ import type { WorkbookManager } from "../managers/workbook-manager";
8
+ import type { CellAddress } from "../types";
9
+ import type { EngineCommand, EngineAction } from "./types";
10
+ /**
11
+ * Command to set cell metadata.
12
+ */
13
+ export declare class SetCellMetadataCommand<TMetadata = unknown> implements EngineCommand {
14
+ private workbookManager;
15
+ private address;
16
+ private newMetadata;
17
+ readonly requiresReevaluation = false;
18
+ private previousMetadata;
19
+ private hadPreviousMetadata;
20
+ constructor(workbookManager: WorkbookManager, address: CellAddress, newMetadata: TMetadata | undefined);
21
+ execute(): void;
22
+ undo(): void;
23
+ toAction(): EngineAction;
24
+ }
25
+ /**
26
+ * Command to set sheet metadata.
27
+ */
28
+ export declare class SetSheetMetadataCommand<TMetadata = unknown> implements EngineCommand {
29
+ private workbookManager;
30
+ private opts;
31
+ private newMetadata;
32
+ readonly requiresReevaluation = false;
33
+ private previousMetadata;
34
+ constructor(workbookManager: WorkbookManager, opts: {
35
+ workbookName: string;
36
+ sheetName: string;
37
+ }, newMetadata: TMetadata);
38
+ execute(): void;
39
+ undo(): void;
40
+ toAction(): EngineAction;
41
+ }
42
+ /**
43
+ * Command to set workbook metadata.
44
+ */
45
+ export declare class SetWorkbookMetadataCommand<TMetadata = unknown> implements EngineCommand {
46
+ private workbookManager;
47
+ private workbookName;
48
+ private newMetadata;
49
+ readonly requiresReevaluation = false;
50
+ private previousMetadata;
51
+ constructor(workbookManager: WorkbookManager, workbookName: string, newMetadata: TMetadata);
52
+ execute(): void;
53
+ undo(): void;
54
+ toAction(): EngineAction;
55
+ }
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Named Expression Commands - Commands that modify named expressions
3
+ *
4
+ * These commands all require re-evaluation after execution.
5
+ */
6
+ import type { NamedExpressionManager } from "../managers/named-expression-manager";
7
+ import type { WorkbookManager } from "../managers/workbook-manager";
8
+ import type { NamedExpression } from "../types";
9
+ import type { EngineCommand, EngineAction } from "./types";
10
+ /**
11
+ * Dependencies needed for named expression commands.
12
+ */
13
+ export interface NamedExpressionCommandDeps {
14
+ namedExpressionManager: NamedExpressionManager;
15
+ workbookManager: WorkbookManager;
16
+ renameNamedExpressionInFormula: (formula: string, oldName: string, newName: string) => string;
17
+ }
18
+ /**
19
+ * Command to add a named expression.
20
+ */
21
+ export declare class AddNamedExpressionCommand implements EngineCommand {
22
+ private deps;
23
+ private opts;
24
+ readonly requiresReevaluation = true;
25
+ constructor(deps: NamedExpressionCommandDeps, opts: {
26
+ expression: string;
27
+ expressionName: string;
28
+ sheetName?: string;
29
+ workbookName?: string;
30
+ });
31
+ execute(): void;
32
+ undo(): void;
33
+ toAction(): EngineAction;
34
+ }
35
+ /**
36
+ * Command to remove a named expression.
37
+ */
38
+ export declare class RemoveNamedExpressionCommand implements EngineCommand {
39
+ private deps;
40
+ private opts;
41
+ readonly requiresReevaluation = true;
42
+ private removedExpression;
43
+ constructor(deps: NamedExpressionCommandDeps, opts: {
44
+ expressionName: string;
45
+ sheetName?: string;
46
+ workbookName?: string;
47
+ });
48
+ execute(): void;
49
+ undo(): void;
50
+ toAction(): EngineAction;
51
+ }
52
+ /**
53
+ * Command to update a named expression.
54
+ */
55
+ export declare class UpdateNamedExpressionCommand implements EngineCommand {
56
+ private deps;
57
+ private opts;
58
+ readonly requiresReevaluation = true;
59
+ private previousExpression;
60
+ constructor(deps: NamedExpressionCommandDeps, opts: {
61
+ expression: string;
62
+ expressionName: string;
63
+ sheetName?: string;
64
+ workbookName?: string;
65
+ });
66
+ execute(): void;
67
+ undo(): void;
68
+ toAction(): EngineAction;
69
+ }
70
+ /**
71
+ * Command to rename a named expression.
72
+ */
73
+ export declare class RenameNamedExpressionCommand implements EngineCommand {
74
+ private deps;
75
+ private opts;
76
+ readonly requiresReevaluation = true;
77
+ constructor(deps: NamedExpressionCommandDeps, opts: {
78
+ expressionName: string;
79
+ sheetName?: string;
80
+ workbookName?: string;
81
+ newName: string;
82
+ });
83
+ execute(): void;
84
+ undo(): void;
85
+ toAction(): EngineAction;
86
+ }
87
+ /**
88
+ * Options for setNamedExpressions command.
89
+ */
90
+ type SetNamedExpressionsOpts = ({
91
+ type: "global";
92
+ } | {
93
+ type: "sheet";
94
+ sheetName: string;
95
+ workbookName: string;
96
+ } | {
97
+ type: "workbook";
98
+ workbookName: string;
99
+ }) & {
100
+ expressions: Map<string, NamedExpression>;
101
+ };
102
+ /**
103
+ * Command to set named expressions (replace all at a scope).
104
+ */
105
+ export declare class SetNamedExpressionsCommand implements EngineCommand {
106
+ private deps;
107
+ private opts;
108
+ readonly requiresReevaluation = true;
109
+ private previousExpressions;
110
+ constructor(deps: NamedExpressionCommandDeps, opts: SetNamedExpressionsOpts);
111
+ execute(): void;
112
+ undo(): void;
113
+ toAction(): EngineAction;
114
+ }
115
+ export {};
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Structure Commands - Commands that modify workbook/sheet structure
3
+ *
4
+ * These commands all require re-evaluation after execution.
5
+ */
6
+ import type { ApiSchemaManager } from "../managers/api-schema-manager";
7
+ import type { NamedExpressionManager } from "../managers/named-expression-manager";
8
+ import type { ReferenceManager } from "../managers/reference-manager";
9
+ import type { StyleManager } from "../managers/style-manager";
10
+ import type { TableManager } from "../managers/table-manager";
11
+ import type { WorkbookManager } from "../managers/workbook-manager";
12
+ import type { EngineAction, EngineCommand } from "./types";
13
+ /**
14
+ * Dependencies needed for structure commands.
15
+ */
16
+ export interface StructureCommandDeps {
17
+ workbookManager: WorkbookManager;
18
+ namedExpressionManager: NamedExpressionManager;
19
+ tableManager: TableManager;
20
+ styleManager: StyleManager;
21
+ referenceManager: ReferenceManager;
22
+ apiSchemaManager: ApiSchemaManager;
23
+ renameSheetInFormula: (opts: {
24
+ formula: string;
25
+ oldSheetName: string;
26
+ newSheetName: string;
27
+ }) => string;
28
+ renameWorkbookInFormula: (opts: {
29
+ formula: string;
30
+ oldWorkbookName: string;
31
+ newWorkbookName: string;
32
+ }) => string;
33
+ }
34
+ /**
35
+ * Command to add a workbook.
36
+ */
37
+ export declare class AddWorkbookCommand implements EngineCommand {
38
+ private deps;
39
+ private workbookName;
40
+ readonly requiresReevaluation = true;
41
+ constructor(deps: StructureCommandDeps, workbookName: string);
42
+ execute(): void;
43
+ undo(): void;
44
+ toAction(): EngineAction;
45
+ }
46
+ /**
47
+ * Command to remove a workbook.
48
+ */
49
+ export declare class RemoveWorkbookCommand implements EngineCommand {
50
+ private deps;
51
+ private workbookName;
52
+ readonly requiresReevaluation = true;
53
+ private snapshot;
54
+ constructor(deps: StructureCommandDeps, workbookName: string);
55
+ execute(): void;
56
+ undo(): void;
57
+ toAction(): EngineAction;
58
+ }
59
+ /**
60
+ * Command to rename a workbook.
61
+ */
62
+ export declare class RenameWorkbookCommand implements EngineCommand {
63
+ private deps;
64
+ private workbookName;
65
+ private newWorkbookName;
66
+ readonly requiresReevaluation = true;
67
+ constructor(deps: StructureCommandDeps, workbookName: string, newWorkbookName: string);
68
+ execute(): void;
69
+ undo(): void;
70
+ toAction(): EngineAction;
71
+ }
72
+ /**
73
+ * Command to clone a workbook.
74
+ * Undo simply removes the cloned workbook.
75
+ */
76
+ export declare class CloneWorkbookCommand implements EngineCommand {
77
+ private deps;
78
+ private fromWorkbookName;
79
+ private toWorkbookName;
80
+ readonly requiresReevaluation = true;
81
+ constructor(deps: StructureCommandDeps, fromWorkbookName: string, toWorkbookName: string);
82
+ execute(): void;
83
+ undo(): void;
84
+ toAction(): EngineAction;
85
+ }
86
+ /**
87
+ * Command to add a sheet.
88
+ */
89
+ export declare class AddSheetCommand implements EngineCommand {
90
+ private deps;
91
+ private opts;
92
+ readonly requiresReevaluation = true;
93
+ constructor(deps: StructureCommandDeps, opts: {
94
+ workbookName: string;
95
+ sheetName: string;
96
+ });
97
+ execute(): void;
98
+ undo(): void;
99
+ toAction(): EngineAction;
100
+ }
101
+ /**
102
+ * Command to remove a sheet.
103
+ */
104
+ export declare class RemoveSheetCommand implements EngineCommand {
105
+ private deps;
106
+ private opts;
107
+ readonly requiresReevaluation = true;
108
+ private snapshot;
109
+ constructor(deps: StructureCommandDeps, opts: {
110
+ workbookName: string;
111
+ sheetName: string;
112
+ });
113
+ execute(): void;
114
+ undo(): void;
115
+ toAction(): EngineAction;
116
+ }
117
+ /**
118
+ * Command to rename a sheet.
119
+ */
120
+ export declare class RenameSheetCommand implements EngineCommand {
121
+ private deps;
122
+ private opts;
123
+ readonly requiresReevaluation = true;
124
+ constructor(deps: StructureCommandDeps, opts: {
125
+ workbookName: string;
126
+ sheetName: string;
127
+ newSheetName: string;
128
+ });
129
+ execute(): void;
130
+ undo(): void;
131
+ toAction(): EngineAction;
132
+ }