@memberjunction/core-entities 6.3.0-edge.0 → 6.3.0-edge.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/dist/.tsbuildinfo +1 -1
- package/dist/custom/AnchoredConversationSecurity.d.ts +10 -1
- package/dist/custom/AnchoredConversationSecurity.d.ts.map +1 -1
- package/dist/custom/AnchoredConversationSecurity.js +15 -0
- package/dist/custom/AnchoredConversationSecurity.js.map +1 -1
- package/dist/custom/ArtifactLockValidation.d.ts +28 -0
- package/dist/custom/ArtifactLockValidation.d.ts.map +1 -0
- package/dist/custom/ArtifactLockValidation.js +867 -0
- package/dist/custom/ArtifactLockValidation.js.map +1 -0
- package/dist/custom/ArtifactPermissionDelegate.d.ts +267 -0
- package/dist/custom/ArtifactPermissionDelegate.d.ts.map +1 -0
- package/dist/custom/ArtifactPermissionDelegate.js +1232 -0
- package/dist/custom/ArtifactPermissionDelegate.js.map +1 -0
- package/dist/custom/ArtifactPreviewSnapshot.d.ts +199 -0
- package/dist/custom/ArtifactPreviewSnapshot.d.ts.map +1 -0
- package/dist/custom/ArtifactPreviewSnapshot.js +772 -0
- package/dist/custom/ArtifactPreviewSnapshot.js.map +1 -0
- package/dist/custom/ArtifactSynthesisEngine.d.ts +151 -0
- package/dist/custom/ArtifactSynthesisEngine.d.ts.map +1 -0
- package/dist/custom/ArtifactSynthesisEngine.js +1124 -0
- package/dist/custom/ArtifactSynthesisEngine.js.map +1 -0
- package/dist/custom/ConversationWriteAccess.d.ts +27 -0
- package/dist/custom/ConversationWriteAccess.d.ts.map +1 -1
- package/dist/custom/ConversationWriteAccess.js +53 -0
- package/dist/custom/ConversationWriteAccess.js.map +1 -1
- package/dist/custom/DocumentLiveBlockEngine.d.ts +612 -0
- package/dist/custom/DocumentLiveBlockEngine.d.ts.map +1 -0
- package/dist/custom/DocumentLiveBlockEngine.js +2352 -0
- package/dist/custom/DocumentLiveBlockEngine.js.map +1 -0
- package/dist/custom/MJQueryEntityExtended.d.ts.map +1 -1
- package/dist/custom/MJQueryEntityExtended.js +27 -11
- package/dist/custom/MJQueryEntityExtended.js.map +1 -1
- package/dist/custom/PermissionProviders/ArtifactPermissionProvider.d.ts.map +1 -1
- package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js +31 -7
- package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js.map +1 -1
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts +3 -4
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts.map +1 -1
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.js +334 -47
- package/dist/custom/PermissionProviders/CollectionPermissionProvider.js.map +1 -1
- package/dist/custom/Permissions/BaseShareEntityExtended.d.ts +19 -3
- package/dist/custom/Permissions/BaseShareEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/BaseShareEntityExtended.js +139 -13
- package/dist/custom/Permissions/BaseShareEntityExtended.js.map +1 -1
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts +8 -6
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js +93 -41
- package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js.map +1 -1
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts +12 -5
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts.map +1 -1
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js +240 -37
- package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js.map +1 -1
- package/dist/custom/SlideDeckEngine.d.ts +427 -0
- package/dist/custom/SlideDeckEngine.d.ts.map +1 -0
- package/dist/custom/SlideDeckEngine.js +1669 -0
- package/dist/custom/SlideDeckEngine.js.map +1 -0
- package/dist/custom/SlideDeckPptxEngine.d.ts +25 -0
- package/dist/custom/SlideDeckPptxEngine.d.ts.map +1 -0
- package/dist/custom/SlideDeckPptxEngine.js +1237 -0
- package/dist/custom/SlideDeckPptxEngine.js.map +1 -0
- package/dist/custom/SpreadsheetEngine.d.ts +1370 -0
- package/dist/custom/SpreadsheetEngine.d.ts.map +1 -0
- package/dist/custom/SpreadsheetEngine.js +17580 -0
- package/dist/custom/SpreadsheetEngine.js.map +1 -0
- package/dist/custom/approvals.d.ts +7 -1
- package/dist/custom/approvals.d.ts.map +1 -1
- package/dist/custom/approvals.js +8 -1
- package/dist/custom/approvals.js.map +1 -1
- package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts +7 -0
- package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts.map +1 -0
- package/dist/custom/operations/ArtifactComplianceAuditOperation.js +7 -0
- package/dist/custom/operations/ArtifactComplianceAuditOperation.js.map +1 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts +7 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts.map +1 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js +7 -0
- package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js.map +1 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.d.ts +60 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.d.ts.map +1 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.js +6 -0
- package/dist/custom/operations/ArtifactGuestShareOperations.js.map +1 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts +7 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts.map +1 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js +7 -0
- package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js.map +1 -0
- package/dist/custom/typedQuery.d.ts +162 -0
- package/dist/custom/typedQuery.d.ts.map +1 -0
- package/dist/custom/typedQuery.js +296 -0
- package/dist/custom/typedQuery.js.map +1 -0
- package/dist/engines/CanonGraphEngine.d.ts +1 -1
- package/dist/engines/CanonGraphEngine.d.ts.map +1 -1
- package/dist/engines/CanonGraphEngine.js +19 -14
- package/dist/engines/CanonGraphEngine.js.map +1 -1
- package/dist/engines/EncryptionEngineBase.js +2 -2
- package/dist/engines/EncryptionEngineBase.js.map +1 -1
- package/dist/engines/QueryEngine.js +2 -2
- package/dist/engines/QueryEngine.js.map +1 -1
- package/dist/engines/SearchEngineBase.d.ts +17 -3
- package/dist/engines/SearchEngineBase.d.ts.map +1 -1
- package/dist/engines/SearchEngineBase.js +100 -28
- package/dist/engines/SearchEngineBase.js.map +1 -1
- package/dist/engines/UserInfoEngine.d.ts +8 -0
- package/dist/engines/UserInfoEngine.d.ts.map +1 -1
- package/dist/engines/UserInfoEngine.js +50 -3
- package/dist/engines/UserInfoEngine.js.map +1 -1
- package/dist/engines/conversations.d.ts +54 -2
- package/dist/engines/conversations.d.ts.map +1 -1
- package/dist/engines/conversations.js +144 -12
- package/dist/engines/conversations.js.map +1 -1
- package/dist/generated/entities/__mj.d.ts +1076 -25406
- package/dist/generated/entities/__mj.d.ts.map +1 -1
- package/dist/generated/entities/__mj.js +636 -41542
- package/dist/generated/entities/__mj.js.map +1 -1
- package/dist/generated/queries/__mj.d.ts +12 -12
- package/dist/generated/queries/__mj.d.ts.map +1 -1
- package/dist/generated/queries/__mj.js +1 -1
- package/dist/generated/queries/__mj.js.map +1 -1
- package/dist/generated/remote_operations.d.ts +225 -0
- package/dist/generated/remote_operations.d.ts.map +1 -1
- package/dist/generated/remote_operations.js +95 -0
- package/dist/generated/remote_operations.js.map +1 -1
- package/dist/generated/schemas/__mj.d.ts +25489 -0
- package/dist/generated/schemas/__mj.d.ts.map +1 -0
- package/dist/generated/schemas/__mj.js +41768 -0
- package/dist/generated/schemas/__mj.js.map +1 -0
- package/dist/generated/schemas.d.ts +2 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +2 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/graph/GraphEngine.d.ts +19 -0
- package/dist/graph/GraphEngine.d.ts.map +1 -1
- package/dist/graph/GraphEngine.js +90 -0
- package/dist/graph/GraphEngine.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +6 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +6 -0
- package/dist/schemas.js.map +1 -0
- package/package.json +17 -6
|
@@ -0,0 +1,1370 @@
|
|
|
1
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
2
|
+
import { BaseSingleton } from '@memberjunction/global';
|
|
3
|
+
import { ArtifactAiFormulaCellRequest } from '../generated/remote_operations.js';
|
|
4
|
+
import { DocumentBlockColumn, DocumentBlockExecutionResult, DocumentBlockMode, FrozenBlockSnapshot, FrozenSnapshotIdentityBinding } from './DocumentLiveBlockEngine.js';
|
|
5
|
+
/**
|
|
6
|
+
* Alias for {@link FrozenBlockSnapshot} used across document and spreadsheet freeze flows (`C2`).
|
|
7
|
+
*/
|
|
8
|
+
export type DocumentFrozenSnapshot = FrozenBlockSnapshot;
|
|
9
|
+
/**
|
|
10
|
+
* Validates that a user- or agent-supplied regular expression is safe against:
|
|
11
|
+
* 1. Exponential star-height / nested quantifiers (`(a+)+`, `(a?)+`, `(a+){2,}`),
|
|
12
|
+
* 2. Overlapping or non-deterministic quantified alternations (`(a|a)*`, `(a|aa)+`, `(ab|a)*`, `(\d|[0-9])+`),
|
|
13
|
+
* while permitting deterministic pairwise-disjoint quantified alternations (`(a|b)*c`, `(foo|bar)+`),
|
|
14
|
+
* 3. Backreferences (`\1`..`\9`, `\k<...>`), lookbehinds, and quantified lookarounds,
|
|
15
|
+
* 4. Polynomial `O(N^2)` / `O(N^3)` backtracking from overlapping quantified tokens without a
|
|
16
|
+
* mandatory disjoint separator (`\d+\d+\d+$`, `\w+.*\w+$`, `a+b*a+`, `.*foo.*bar`) (`E8`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function IsSafeUserRegex(pattern: string, flags?: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Compiles a user-supplied regex pattern after validating it with {@link IsSafeUserRegex},
|
|
21
|
+
* returning `null` if invalid or unsafe (`E8`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function CompileSafeUserRegex(pattern: string, flags?: string): RegExp | null;
|
|
24
|
+
/**
|
|
25
|
+
* Detailed outcome returned by {@link SafeRegexSearchDetailed} (`R6-6`, `R7-3`).
|
|
26
|
+
*/
|
|
27
|
+
export interface SafeRegexSearchResult {
|
|
28
|
+
Matched: boolean;
|
|
29
|
+
TimedOut: boolean;
|
|
30
|
+
InputTooLong: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Optional host-provided preemptive regex sandbox executor (e.g. `node:vm` in server packages)
|
|
34
|
+
* evaluated against the **entire unmodified** input string (`R7-3`).
|
|
35
|
+
*/
|
|
36
|
+
export type SafeRegexSandboxExecutor = (regex: RegExp, input: string, maxDurationMs: number) => {
|
|
37
|
+
Matched: boolean;
|
|
38
|
+
TimedOut: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Result returned by a {@link SafeRegexBatchSandboxExecutor} (`R9-4`).
|
|
42
|
+
*/
|
|
43
|
+
export interface SafeRegexBatchSandboxResult {
|
|
44
|
+
Matches: boolean[];
|
|
45
|
+
TimedOut: boolean;
|
|
46
|
+
TimedOutIndex?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Optional host-provided batched preemptive regex sandbox executor (e.g. `node:vm` in server packages)
|
|
50
|
+
* that tests a batch of whole candidate strings in a single sandbox invocation (`R8-6`, `R9-4`).
|
|
51
|
+
*/
|
|
52
|
+
export type SafeRegexBatchSandboxExecutor = (regex: RegExp, inputs: readonly string[], maxDurationMs: number) => SafeRegexBatchSandboxResult;
|
|
53
|
+
/**
|
|
54
|
+
* Registers (or clears when `null`) a process-wide {@link SafeRegexSandboxExecutor} in
|
|
55
|
+
* `MJGlobal.Instance.GetGlobalObjectStore()` so server packages can provide preemptive
|
|
56
|
+
* `node:vm` timeout enforcement without leaking `node:*` imports into browser bundles (`R7-3`).
|
|
57
|
+
*/
|
|
58
|
+
export declare function RegisterSafeRegexSandboxExecutor(executor: SafeRegexSandboxExecutor | null): void;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves the currently registered {@link SafeRegexSandboxExecutor}, or `null` if none is registered.
|
|
61
|
+
*/
|
|
62
|
+
export declare function GetSafeRegexSandboxExecutor(): SafeRegexSandboxExecutor | null;
|
|
63
|
+
/**
|
|
64
|
+
* Registers (or clears when `null`) a process-wide {@link SafeRegexBatchSandboxExecutor} in
|
|
65
|
+
* `MJGlobal.Instance.GetGlobalObjectStore()` so server packages can amortize `node:vm` boundary
|
|
66
|
+
* overhead across hundreds of cells/lines per batch (`R8-6`).
|
|
67
|
+
*/
|
|
68
|
+
export declare function RegisterSafeRegexBatchSandboxExecutor(executor: SafeRegexBatchSandboxExecutor | null): void;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves the currently registered {@link SafeRegexBatchSandboxExecutor}, or `null` if none is registered (`R8-6`).
|
|
71
|
+
*/
|
|
72
|
+
export declare function GetSafeRegexBatchSandboxExecutor(): SafeRegexBatchSandboxExecutor | null;
|
|
73
|
+
/**
|
|
74
|
+
* Pure-ECMAScript WHATWG-compliant UTF-8 encoder fallback for bare VMs without `TextEncoder` or `Buffer`.
|
|
75
|
+
* Replaces any lone high or low UTF-16 surrogate with `0xEF 0xBF 0xBD` (`U+FFFD`).
|
|
76
|
+
*/
|
|
77
|
+
export declare function EncodeUtf8Fallback(str: string): Uint8Array;
|
|
78
|
+
/**
|
|
79
|
+
* Pure-ECMAScript WHATWG §8.1.1 UTF-8 decoder fallback (`fatal: false`) for bare VMs without `TextDecoder` or `Buffer`.
|
|
80
|
+
* Validates continuation bytes, rejects overlongs, UTF-16 surrogates, and `> U+10FFFF`, emitting `\uFFFD` per
|
|
81
|
+
* invalid maximal subpart without consuming valid follow bytes.
|
|
82
|
+
*/
|
|
83
|
+
export declare function DecodeUtf8Fallback(bytes: Uint8Array): string;
|
|
84
|
+
/**
|
|
85
|
+
* Executes a validated user regex against the **entire unmodified** `input` string — never slicing
|
|
86
|
+
* into windows and never rewriting `^`, `$`, or `\b` anchors (`R7-3`).
|
|
87
|
+
*
|
|
88
|
+
* - Enforces `maxInputBytes` (default `65536` bytes).
|
|
89
|
+
* - Uses the registered {@link SafeRegexSandboxExecutor} (e.g. `node:vm` in `@memberjunction/ai-agents`)
|
|
90
|
+
* for preemptive `maxDurationMs` enforcement on arbitrary whole strings up to `maxInputBytes`.
|
|
91
|
+
* - When no sandbox executor is registered (browser / standalone runtime), runs linear-guaranteed
|
|
92
|
+
* patterns on the full string up to `maxInputBytes` and bounds quantified whole-string evaluation
|
|
93
|
+
* to safe whole-input lengths (`4096` chars, or `1536` chars for quantified alternation) while
|
|
94
|
+
* marking longer inputs as `{ InputTooLong: true }` rather than returning false window results.
|
|
95
|
+
*/
|
|
96
|
+
export declare function SafeRegexSearchDetailed(regex: RegExp, input: string, maxDurationMs?: number, maxInputBytes?: number): SafeRegexSearchResult;
|
|
97
|
+
/**
|
|
98
|
+
* Time- and byte-bounded boolean wrapper around {@link SafeRegexSearchDetailed} (`E8`, `R6-6`).
|
|
99
|
+
*/
|
|
100
|
+
export declare function SafeRegexTest(regex: RegExp, candidate: string, maxInputLength?: number, maxDurationMs?: number): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Detailed result of evaluating a batch of candidate strings against a user regex (`R8-6`, `R9-4`).
|
|
103
|
+
*/
|
|
104
|
+
export interface SafeRegexBatchDetailedResult {
|
|
105
|
+
Matches: boolean[];
|
|
106
|
+
TimedOut: boolean;
|
|
107
|
+
TimedOutIndex?: number;
|
|
108
|
+
InputTooLong: boolean[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Evaluates a validated user regex against a batch of unmodified candidate strings (`R8-6`),
|
|
112
|
+
* running short (`<= 256` chars) and linear-guaranteed patterns natively in `O(N)` and sending
|
|
113
|
+
* all remaining `<= maxInputBytes` candidates to {@link SafeRegexBatchSandboxExecutor} in a single
|
|
114
|
+
* sandbox call bounded by `batchTimeoutMs`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function SafeRegexSearchBatchDetailed(regex: RegExp, inputs: readonly string[], batchTimeoutMs?: number, maxInputBytes?: number): SafeRegexBatchDetailedResult;
|
|
117
|
+
/**
|
|
118
|
+
* Supported value display formats for MJ Sheets cells (`§ 6.3`).
|
|
119
|
+
*/
|
|
120
|
+
export type SpreadsheetCellFormatType = 'general' | 'number' | 'currency' | 'percent' | 'integer' | 'date' | 'datetime' | 'text';
|
|
121
|
+
/**
|
|
122
|
+
* Cell formatting and visual style properties.
|
|
123
|
+
*/
|
|
124
|
+
export interface SpreadsheetCellStyleSpec {
|
|
125
|
+
/** Bold font weight. */
|
|
126
|
+
Bold?: boolean;
|
|
127
|
+
/** Italic font style. */
|
|
128
|
+
Italic?: boolean;
|
|
129
|
+
/** Semantic or CSS color token for text. */
|
|
130
|
+
TextColor?: string;
|
|
131
|
+
/** Semantic or CSS color token for background fill. */
|
|
132
|
+
BackgroundColor?: string;
|
|
133
|
+
/** Horizontal text alignment. */
|
|
134
|
+
HorizontalAlign?: 'left' | 'center' | 'right';
|
|
135
|
+
/** High-level format category. */
|
|
136
|
+
FormatType?: SpreadsheetCellFormatType;
|
|
137
|
+
/** Excel-compatible `numFmt` pattern (e.g. `'$#,##0.00'`, `'0.0%'`, `'#,##0'`, `'yyyy-mm-dd'`). */
|
|
138
|
+
NumberFormatPattern?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Primitive scalar value stored or computed in a spreadsheet cell.
|
|
142
|
+
*/
|
|
143
|
+
export type SpreadsheetCellValue = string | number | boolean | null;
|
|
144
|
+
/**
|
|
145
|
+
* Specification for a single populated cell in a worksheet (`§ 6.2`).
|
|
146
|
+
*
|
|
147
|
+
* Formulas are stored both in human-readable A1 notation (`Formula`) and against
|
|
148
|
+
* stable row/column IDs (`FormulaStable`) so concurrent row/column insertions
|
|
149
|
+
* and formula edits over Yjs never corrupt cell references (`Accept #1`).
|
|
150
|
+
*/
|
|
151
|
+
export interface SpreadsheetCellSpec {
|
|
152
|
+
/** Stable row identifier (`SpreadsheetRowSpec.RowID`). */
|
|
153
|
+
RowID: string;
|
|
154
|
+
/** Stable column identifier (`SpreadsheetColumnSpec.ColumnID`). */
|
|
155
|
+
ColumnID: string;
|
|
156
|
+
/** Current A1 coordinate (e.g. `'B2'`). */
|
|
157
|
+
Address: string;
|
|
158
|
+
/** Raw scalar literal when not a formula cell. */
|
|
159
|
+
RawValue: SpreadsheetCellValue;
|
|
160
|
+
/** Display A1 formula starting with `'='` (e.g. `'=SUM(B2:B9)'`). */
|
|
161
|
+
Formula?: string | null;
|
|
162
|
+
/**
|
|
163
|
+
* Stable-ID formula representation (`@CELL(rowId,colId)` / `@RANGE(r1,c1,r2,c2)`)
|
|
164
|
+
* used to reconstruct `Formula` after row or column insertions/deletions (`§ 6.2`, `Accept #1`).
|
|
165
|
+
*/
|
|
166
|
+
FormulaStable?: string | null;
|
|
167
|
+
/** Latest evaluated value (or error code such as `'#DIV/0!'`, `'#REF!'`, `'#MJ_ACCESS_DENIED!'`). */
|
|
168
|
+
ComputedValue?: SpreadsheetCellValue;
|
|
169
|
+
/** Formatted string representation rendered in the grid. */
|
|
170
|
+
DisplayValue?: string;
|
|
171
|
+
/** Optional style & number format metadata. */
|
|
172
|
+
Style?: SpreadsheetCellStyleSpec;
|
|
173
|
+
/** Optional data validation error message when the cell violates a worksheet validation rule. */
|
|
174
|
+
ValidationError?: string | null;
|
|
175
|
+
/** True when an `=MJ.QUERY` or `=MJ.VIEW` formula was refused due to viewer RLS/entity/query permissions. */
|
|
176
|
+
AccessDenied?: boolean;
|
|
177
|
+
/** Detailed error message when evaluation or viewer permission check fails. */
|
|
178
|
+
ErrorMessage?: string | null;
|
|
179
|
+
/** Anchor cell coordinate (`'B2'`) when this cell was populated by a multi-cell `=MJ.*` spill. */
|
|
180
|
+
SpilledFrom?: string | null;
|
|
181
|
+
/** Multi-cell OOXML array/spill range (`'I6:I8'`) owned by this anchor cell (`R8-8`). */
|
|
182
|
+
SpillRange?: string | null;
|
|
183
|
+
/** Anchor cell coordinate (`'I6'`) when this cell was imported as a child of a multi-cell OOXML dynamic-array spill or legacy CSE array (`R8-8`). */
|
|
184
|
+
ArrayMaster?: string | null;
|
|
185
|
+
/** Bound `SpreadsheetLiveTableSpec.TableID` when this cell was populated by a live table (`B4`). */
|
|
186
|
+
LiveTableID?: string | null;
|
|
187
|
+
/** Optional plain-text cell note. */
|
|
188
|
+
Note?: string | null;
|
|
189
|
+
/** Input content hash stored when an opt-in `=MJ.AI(...)` formula was last evaluated (`§5.2b`). */
|
|
190
|
+
AiInputHash?: string | null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Governance lock rule protecting a rectangular range on a worksheet (`§6.2`).
|
|
194
|
+
*/
|
|
195
|
+
export interface SpreadsheetProtectedRangeSpec {
|
|
196
|
+
/** Stable unique ID for this protection rule. */
|
|
197
|
+
RangeID: string;
|
|
198
|
+
/** Canonical A1 cell or rectangular range (e.g. `'A1:D10'`). */
|
|
199
|
+
Range: string;
|
|
200
|
+
/** `UserInfo.ID` of the creator/owner who locked this range. */
|
|
201
|
+
LockedByUserID: string;
|
|
202
|
+
/** Optional human-readable description shown in lock banners/tooltips. */
|
|
203
|
+
Description?: string;
|
|
204
|
+
/** When true, users with `CanEdit` artifact permission may still edit cells inside the range. */
|
|
205
|
+
AllowEditors?: boolean;
|
|
206
|
+
/** ISO 8601 timestamp when the range was locked. */
|
|
207
|
+
LockedAt?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Authorization context supplied when mutating worksheet cells with {@link SpreadsheetProtectedRangeSpec} enforcement.
|
|
211
|
+
*/
|
|
212
|
+
export interface SpreadsheetCellEditContext {
|
|
213
|
+
/** Acting user ID performing the edit. */
|
|
214
|
+
UserID?: string | null;
|
|
215
|
+
/** Artifact owner/creator user ID (always allowed to edit or unlock). */
|
|
216
|
+
OwnerUserID?: string | null;
|
|
217
|
+
/** True when actor holds editor permission on the artifact. */
|
|
218
|
+
IsEditor?: boolean;
|
|
219
|
+
/** Internal import/system bypass flag. */
|
|
220
|
+
BypassProtection?: boolean;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Stable row descriptor (`§ 6.2`).
|
|
224
|
+
*/
|
|
225
|
+
export interface SpreadsheetRowSpec {
|
|
226
|
+
/** Immutable unique ID for this row within the worksheet. */
|
|
227
|
+
RowID: string;
|
|
228
|
+
/** 1-based row number (`1`, `2`, ...). */
|
|
229
|
+
Index: number;
|
|
230
|
+
/** Optional row height in pixels. */
|
|
231
|
+
Height?: number;
|
|
232
|
+
/** True when hidden by user or active filter. */
|
|
233
|
+
Hidden?: boolean;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Stable column descriptor (`§ 6.2`).
|
|
237
|
+
*/
|
|
238
|
+
export interface SpreadsheetColumnSpec {
|
|
239
|
+
/** Immutable unique ID for this column within the worksheet. */
|
|
240
|
+
ColumnID: string;
|
|
241
|
+
/** 1-based column number (`1 = A`, `2 = B`, ...). */
|
|
242
|
+
Index: number;
|
|
243
|
+
/** Column letter code (`'A'`, `'B'`, ..., `'AA'`). */
|
|
244
|
+
Letter: string;
|
|
245
|
+
/** Optional custom column label. */
|
|
246
|
+
Header?: string;
|
|
247
|
+
/** Optional width in characters/pixels (Excel column width units, default 14). */
|
|
248
|
+
Width?: number;
|
|
249
|
+
/** True when hidden. */
|
|
250
|
+
Hidden?: boolean;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Active sort specification on a worksheet.
|
|
254
|
+
*/
|
|
255
|
+
export interface SpreadsheetSortSpec {
|
|
256
|
+
/** Column letter to sort by (e.g. `'B'`). */
|
|
257
|
+
ColumnLetter: string;
|
|
258
|
+
/** Sort direction. */
|
|
259
|
+
Direction: 'asc' | 'desc';
|
|
260
|
+
/** Number of header rows at the top of the sheet excluded from sorting (default 1). */
|
|
261
|
+
HeaderRows?: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Active filter criterion on a worksheet column.
|
|
265
|
+
*/
|
|
266
|
+
export interface SpreadsheetFilterSpec {
|
|
267
|
+
/** Column letter to filter on (e.g. `'A'`). */
|
|
268
|
+
ColumnLetter: string;
|
|
269
|
+
/** Filter operator. */
|
|
270
|
+
Operator: 'equals' | 'contains' | 'gt' | 'lt' | 'notEmpty';
|
|
271
|
+
/** Filter comparison value. */
|
|
272
|
+
Value: string;
|
|
273
|
+
/** Number of header rows at top of sheet always kept visible (default 1). */
|
|
274
|
+
HeaderRows?: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Data validation rule applied to a cell range.
|
|
278
|
+
*/
|
|
279
|
+
export interface SpreadsheetValidationRuleSpec {
|
|
280
|
+
/** Unique rule ID. */
|
|
281
|
+
RuleID: string;
|
|
282
|
+
/** Target A1 range (e.g. `'C2:C50'`). */
|
|
283
|
+
Range: string;
|
|
284
|
+
/** Validation rule type. */
|
|
285
|
+
RuleType: 'list' | 'numberRange' | 'notEmpty';
|
|
286
|
+
/** Allowed values when `RuleType === 'list'`. */
|
|
287
|
+
AllowedValues?: string[];
|
|
288
|
+
/** Minimum numeric value when `RuleType === 'numberRange'`. */
|
|
289
|
+
MinValue?: number;
|
|
290
|
+
/** Maximum numeric value when `RuleType === 'numberRange'`. */
|
|
291
|
+
MaxValue?: number;
|
|
292
|
+
/** Custom error message shown when violated. */
|
|
293
|
+
ErrorMessage?: string;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Conditional formatting rule applied to a cell range.
|
|
297
|
+
*/
|
|
298
|
+
export interface SpreadsheetConditionalFormatRuleSpec {
|
|
299
|
+
/** Unique rule ID. */
|
|
300
|
+
RuleID: string;
|
|
301
|
+
/** Target A1 range (e.g. `'D2:D50'`). */
|
|
302
|
+
Range: string;
|
|
303
|
+
/** Comparison operator. */
|
|
304
|
+
Operator: 'gt' | 'lt' | 'eq' | 'between' | 'contains';
|
|
305
|
+
/** Primary threshold value. */
|
|
306
|
+
Value1: string | number;
|
|
307
|
+
/** Upper bound when `Operator === 'between'`. */
|
|
308
|
+
Value2?: number;
|
|
309
|
+
/** Semantic highlight tone mapped to `--mj-status-*` tokens. */
|
|
310
|
+
HighlightTone: 'success' | 'warning' | 'danger' | 'info';
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Calculated formula column attached to a live data table (`§ 6.3`).
|
|
314
|
+
* When the bound view/query refreshes and expands/contracts rows, each calculated column's
|
|
315
|
+
* `FormulaTemplate` (using `{ROW}` for the 1-based worksheet row number) is automatically
|
|
316
|
+
* filled down for every data row.
|
|
317
|
+
*/
|
|
318
|
+
export interface SpreadsheetCalculatedColumnSpec {
|
|
319
|
+
/** Column heading written in the table's header row. */
|
|
320
|
+
Header: string;
|
|
321
|
+
/** Formula template where `{ROW}` is replaced with each data row's 1-based row number (e.g. `'=B{ROW}*C{ROW}'`). */
|
|
322
|
+
FormulaTemplate: string;
|
|
323
|
+
/** Optional format type applied to the calculated cells. */
|
|
324
|
+
FormatType?: SpreadsheetCellFormatType;
|
|
325
|
+
/** Optional Excel number format pattern (e.g. `'$#,##0.00'`). */
|
|
326
|
+
NumberFormatPattern?: string;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Range source bound to an MJ `EntityView` or `SavedQuery` (`§ 6.3`, `D10`, `Accept #2`).
|
|
330
|
+
*/
|
|
331
|
+
export interface SpreadsheetLiveTableSpec {
|
|
332
|
+
/** Unique identifier for this live table binding. */
|
|
333
|
+
TableID: string;
|
|
334
|
+
/** Display title for the bound table. */
|
|
335
|
+
Title: string;
|
|
336
|
+
/** Source kind (`'EntityView'` or `'SavedQuery'`). */
|
|
337
|
+
SourceType: 'EntityView' | 'SavedQuery';
|
|
338
|
+
/** Target MJ entity name when `SourceType === 'EntityView'`. */
|
|
339
|
+
EntityName?: string;
|
|
340
|
+
/** Optional saved `MJ: User Views` ID. */
|
|
341
|
+
ViewID?: string;
|
|
342
|
+
/** Optional saved `MJ: User Views` name. */
|
|
343
|
+
ViewName?: string;
|
|
344
|
+
/** Optional structured filter when `SourceType === 'EntityView'`. */
|
|
345
|
+
ExtraFilter?: string;
|
|
346
|
+
/** Optional explicit field list. */
|
|
347
|
+
Fields?: string[];
|
|
348
|
+
/** Target `MJ: Queries` ID when `SourceType === 'SavedQuery'`. */
|
|
349
|
+
QueryID?: string;
|
|
350
|
+
/** Target `MJ: Queries` name when `SourceType === 'SavedQuery'`. */
|
|
351
|
+
QueryName?: string;
|
|
352
|
+
/** Caller-settable query parameters (`IsServerSet` parameters are stripped automatically). */
|
|
353
|
+
QueryParameters?: Record<string, string | number | boolean | null>;
|
|
354
|
+
/** Maximum rows to fetch (default 100). */
|
|
355
|
+
MaxRows?: number;
|
|
356
|
+
/** Top-left A1 cell where headers (and rows below) are written (default `'A1'`). */
|
|
357
|
+
AnchorCell: string;
|
|
358
|
+
/** Whether to write a header row at `AnchorCell` (default `true`). */
|
|
359
|
+
IncludeHeaders?: boolean;
|
|
360
|
+
/** `'Live'` (viewer-scoped refresh) or `'Frozen'` (static snapshot per `O5`). */
|
|
361
|
+
Mode: DocumentBlockMode;
|
|
362
|
+
/** Captured snapshot when `Mode === 'Frozen'`. */
|
|
363
|
+
FrozenSnapshot?: FrozenBlockSnapshot | null;
|
|
364
|
+
/** Calculated formula columns appended to the right of the bound source columns. */
|
|
365
|
+
CalculatedColumns?: SpreadsheetCalculatedColumnSpec[];
|
|
366
|
+
/** ISO timestamp of last live execution. */
|
|
367
|
+
LastRefreshedAt?: string | null;
|
|
368
|
+
/** Number of data rows written on the last refresh. */
|
|
369
|
+
LastRowCount?: number;
|
|
370
|
+
/** Number of columns (source fields + calculated columns) written on the last refresh. */
|
|
371
|
+
LastColumnCount?: number;
|
|
372
|
+
/** True when the current viewer was denied access to the underlying entity/view/query. */
|
|
373
|
+
AccessDenied?: boolean;
|
|
374
|
+
/** Error or access-denied message from the last execution. */
|
|
375
|
+
LastError?: string | null;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Supported chart visualization types for MJ Sheets range charts (`§ 6.3`).
|
|
379
|
+
*/
|
|
380
|
+
export type SpreadsheetChartType = 'bar' | 'line' | 'pie' | 'area';
|
|
381
|
+
/**
|
|
382
|
+
* Chart specification bound to a cell range on a worksheet (`§ 6.3`, `Accept #5`).
|
|
383
|
+
*/
|
|
384
|
+
export interface SpreadsheetChartSpec {
|
|
385
|
+
/** Unique chart ID (`'chart-1'`, etc.). */
|
|
386
|
+
ChartID: string;
|
|
387
|
+
/** Chart title. */
|
|
388
|
+
Title: string;
|
|
389
|
+
/** Chart visualization type. */
|
|
390
|
+
ChartType: SpreadsheetChartType;
|
|
391
|
+
/** Worksheet ID owning the source range. */
|
|
392
|
+
SheetID: string;
|
|
393
|
+
/** A1 range or comma-separated range union feeding the chart (e.g. `'A1:C6'` or `'A1:A6,D1:D6'`). */
|
|
394
|
+
SourceRange: string;
|
|
395
|
+
/** Anchor cell where the floating chart card sits on the worksheet (e.g. `'E2'`). */
|
|
396
|
+
PositionCell: string;
|
|
397
|
+
/** Where the chart renders: `'dock'` in the bottom strip (default) or `'sheet'` floating over the grid. */
|
|
398
|
+
Placement?: 'dock' | 'sheet';
|
|
399
|
+
/** Optional horizontal pixel offset within the grid canvas when `Placement === 'sheet'`. */
|
|
400
|
+
OffsetX?: number;
|
|
401
|
+
/** Optional vertical pixel offset within the grid canvas when `Placement === 'sheet'`. */
|
|
402
|
+
OffsetY?: number;
|
|
403
|
+
/** Optional width in pixels. */
|
|
404
|
+
WidthPx?: number;
|
|
405
|
+
/** Optional height in pixels. */
|
|
406
|
+
HeightPx?: number;
|
|
407
|
+
/** Whether to display the series legend (default `true`). */
|
|
408
|
+
ShowLegend?: boolean;
|
|
409
|
+
/** Header row handling (`'auto'` detects automatically, `true` uses first row/col as labels, `false` treats all as data). */
|
|
410
|
+
HasHeaderRow?: boolean | 'auto';
|
|
411
|
+
/** Series orientation (`'columns'` = each column is a series, `'rows'` = each row is a series). Default `'columns'`. */
|
|
412
|
+
SeriesOrientation?: 'columns' | 'rows';
|
|
413
|
+
/** Zero-based index within the extracted grid for the category/X-axis column (or row when `SeriesOrientation === 'rows'`). */
|
|
414
|
+
CategoryColumnIndex?: number;
|
|
415
|
+
/** Zero-based grid column (or transposed row) indices to include as plotted numeric series. Omit or empty for all numeric series. */
|
|
416
|
+
IncludedSeriesIndices?: number[];
|
|
417
|
+
/** Whether to render value data labels directly on chart bars/points/slices. */
|
|
418
|
+
ShowDataLabels?: boolean;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Evaluated chart dataset extracted from a worksheet range (`Accept #5`).
|
|
422
|
+
*/
|
|
423
|
+
export interface SpreadsheetChartDataset {
|
|
424
|
+
ChartID: string;
|
|
425
|
+
Title: string;
|
|
426
|
+
ChartType: SpreadsheetChartType;
|
|
427
|
+
SheetID: string;
|
|
428
|
+
SourceRange: string;
|
|
429
|
+
Categories: string[];
|
|
430
|
+
Series: Array<{
|
|
431
|
+
Name: string;
|
|
432
|
+
Values: number[];
|
|
433
|
+
ColumnIndex?: number;
|
|
434
|
+
}>;
|
|
435
|
+
Columns: DocumentBlockColumn[];
|
|
436
|
+
Rows: Array<Record<string, string | number>>;
|
|
437
|
+
RevisionHash: string;
|
|
438
|
+
/** Detected columns (or transposed rows when `SeriesOrientation === 'rows'`) available in the source range. */
|
|
439
|
+
DetectedColumns?: Array<{
|
|
440
|
+
Index: number;
|
|
441
|
+
Name: string;
|
|
442
|
+
IsNumeric: boolean;
|
|
443
|
+
}>;
|
|
444
|
+
/** Effective header detection result after applying `HasHeaderRow`. */
|
|
445
|
+
EffectiveHasHeaderRow?: boolean;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Embedded OLE `Artifact` (such as an interactive `Whiteboard`) anchored on a worksheet (`§ 3.4.1`).
|
|
449
|
+
*/
|
|
450
|
+
export interface SpreadsheetEmbeddedArtifactSpec {
|
|
451
|
+
/** Unique embed ID within the worksheet. */
|
|
452
|
+
EmbedID: string;
|
|
453
|
+
/** Display title. */
|
|
454
|
+
Title: string;
|
|
455
|
+
/** Target `MJ: Artifacts` ID. */
|
|
456
|
+
ArtifactID: string;
|
|
457
|
+
/** Optional pinned `MJ: Artifact Versions` ID. */
|
|
458
|
+
ArtifactVersionID?: string | null;
|
|
459
|
+
/** Target artifact type name (e.g. `'Whiteboard'`). */
|
|
460
|
+
ArtifactTypeName: string;
|
|
461
|
+
/** Viewer plugin driver class (e.g. `'WhiteboardArtifactViewerPlugin'`). */
|
|
462
|
+
DriverClass?: string;
|
|
463
|
+
/** Anchor cell coordinate on the worksheet (e.g. `'F2'`). */
|
|
464
|
+
AnchorCell: string;
|
|
465
|
+
/** Width in pixels. */
|
|
466
|
+
WidthPx: number;
|
|
467
|
+
/** Height in pixels. */
|
|
468
|
+
HeightPx: number;
|
|
469
|
+
/** Whether inline editing is enabled. */
|
|
470
|
+
AllowInlineEdit: boolean;
|
|
471
|
+
/** Latest inline JSON payload (e.g. serialized Whiteboard state). */
|
|
472
|
+
InlineContentJSON?: string | null;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Workbook-level named range (`§ 6.3`).
|
|
476
|
+
*/
|
|
477
|
+
export interface SpreadsheetNamedRangeSpec {
|
|
478
|
+
/** Identifier usable inside formulas (e.g. `'TaxRate'` or `'Q1Revenue'`). */
|
|
479
|
+
Name: string;
|
|
480
|
+
/** Worksheet ID containing the range. */
|
|
481
|
+
SheetID: string;
|
|
482
|
+
/** A1 cell or range (e.g. `'B2'` or `'B2:B10'`). */
|
|
483
|
+
Range: string;
|
|
484
|
+
/** Optional description. */
|
|
485
|
+
Description?: string;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Single worksheet tab in an MJ Sheets workbook (`§ 6.2`).
|
|
489
|
+
*/
|
|
490
|
+
export interface WorksheetSpec {
|
|
491
|
+
/** Stable unique ID for this worksheet tab. */
|
|
492
|
+
SheetID: string;
|
|
493
|
+
/** Tab display name (up to 31 chars for Excel compatibility). */
|
|
494
|
+
Name: string;
|
|
495
|
+
/** Ordered list of rows with stable `RowID`s. */
|
|
496
|
+
Rows: SpreadsheetRowSpec[];
|
|
497
|
+
/** Ordered list of columns with stable `ColumnID`s. */
|
|
498
|
+
Columns: SpreadsheetColumnSpec[];
|
|
499
|
+
/** Map of A1 coordinate (`'A1'`, `'B2'`) to cell specification. */
|
|
500
|
+
Cells: Record<string, SpreadsheetCellSpec>;
|
|
501
|
+
/** Number of frozen top rows. */
|
|
502
|
+
FrozenRows: number;
|
|
503
|
+
/** Number of frozen left columns. */
|
|
504
|
+
FrozenColumns: number;
|
|
505
|
+
/** Optional active sort configuration. */
|
|
506
|
+
SortSpec?: SpreadsheetSortSpec | null;
|
|
507
|
+
/** Active column filter criteria. */
|
|
508
|
+
FilterSpecs: SpreadsheetFilterSpec[];
|
|
509
|
+
/** Data validation rules. */
|
|
510
|
+
ValidationRules: SpreadsheetValidationRuleSpec[];
|
|
511
|
+
/** Conditional formatting rules. */
|
|
512
|
+
ConditionalFormats: SpreadsheetConditionalFormatRuleSpec[];
|
|
513
|
+
/** Range sources bound to MJ Views or Queries. */
|
|
514
|
+
LiveTables: SpreadsheetLiveTableSpec[];
|
|
515
|
+
/** Embedded range charts. */
|
|
516
|
+
Charts: SpreadsheetChartSpec[];
|
|
517
|
+
/** Embedded OLE Artifact / Whiteboard objects. */
|
|
518
|
+
EmbeddedArtifacts: SpreadsheetEmbeddedArtifactSpec[];
|
|
519
|
+
/** Protected cell/range rules enforced against unauthorized edits (`§6.2`). */
|
|
520
|
+
ProtectedRanges?: SpreadsheetProtectedRangeSpec[];
|
|
521
|
+
/** Merged cell regions in canonical A1 notation (e.g. `['A1:C1', 'B3:D5']`). */
|
|
522
|
+
MergeRanges?: string[];
|
|
523
|
+
/** Former dynamic-array spill / CSE array child coordinates cleared after import (`R8-8`). */
|
|
524
|
+
ClearedSpillChildren?: string[];
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Complete multi-tab MJ Sheets workbook specification (`§ 6.2`).
|
|
528
|
+
*/
|
|
529
|
+
export interface WorkbookSpec {
|
|
530
|
+
/** Stable workbook ID. */
|
|
531
|
+
WorkbookID: string;
|
|
532
|
+
/** Workbook title. */
|
|
533
|
+
Title: string;
|
|
534
|
+
/** Currently active worksheet ID. */
|
|
535
|
+
ActiveSheetID: string;
|
|
536
|
+
/** Ordered worksheets. */
|
|
537
|
+
Worksheets: WorksheetSpec[];
|
|
538
|
+
/** Workbook-level named ranges. */
|
|
539
|
+
NamedRanges: SpreadsheetNamedRangeSpec[];
|
|
540
|
+
/** Persisted preferred height (px) of the docked bottom strip containing charts, live tables, and embedded canvases. */
|
|
541
|
+
PreferredObjectsPaneHeightPx?: number;
|
|
542
|
+
/** ISO creation timestamp. */
|
|
543
|
+
CreatedAt: string;
|
|
544
|
+
/** ISO last-modified timestamp. */
|
|
545
|
+
UpdatedAt: string;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Parsed representation of an `=MJ.QUERY(...)`, `=MJ.VIEW(...)`, or `=MJ.IMPORTRANGE(...)` custom function call (`§ 6.3`, `§ 7.2`, `§ 4.2`).
|
|
549
|
+
*/
|
|
550
|
+
export interface ParsedMjCustomFunctionCall {
|
|
551
|
+
/** Function kind (`'QUERY'`, `'VIEW'`, `'IMPORTRANGE'`, or `'AI'`). */
|
|
552
|
+
Kind: 'QUERY' | 'VIEW' | 'IMPORTRANGE' | 'AI';
|
|
553
|
+
/** Query name/ID (`QUERY`), Entity name (`VIEW`), target Artifact ID/Name (`IMPORTRANGE`), or prompt (`AI`). */
|
|
554
|
+
PrimaryTarget: string;
|
|
555
|
+
/** View name/ID (`VIEW`) or `'Sheet!A1:D20'` range string (`IMPORTRANGE`). */
|
|
556
|
+
SecondaryTarget?: string;
|
|
557
|
+
/** Positional or key=value arguments passed to the function. */
|
|
558
|
+
Arguments: SpreadsheetCellValue[];
|
|
559
|
+
/** Structured key-value parameters extracted from arguments. */
|
|
560
|
+
NamedParameters: Record<string, SpreadsheetCellValue>;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Request envelope passed to a custom `ImportRangeResolver` for `=MJ.IMPORTRANGE(...)` (`§ 4.2`).
|
|
564
|
+
*/
|
|
565
|
+
export interface SpreadsheetImportRangeRequest {
|
|
566
|
+
ArtifactIDOrName: string;
|
|
567
|
+
RangeString: string;
|
|
568
|
+
VersionNumber?: number;
|
|
569
|
+
ContextUser: UserInfo;
|
|
570
|
+
Provider: IMetadataProvider;
|
|
571
|
+
VisitedArtifactKeys: string[];
|
|
572
|
+
Depth: number;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Parsed representation of an opt-in `=MJ.AI(prompt, [cellOrRange...])` formula (`§ 5.2b`).
|
|
576
|
+
*/
|
|
577
|
+
export interface ParsedMjAiFormulaCall {
|
|
578
|
+
/** Natural-language instruction literal. */
|
|
579
|
+
Prompt: string;
|
|
580
|
+
/** Cell or range reference tokens passed as context arguments. */
|
|
581
|
+
References: string[];
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Options for evaluating `=MJ.QUERY`, `=MJ.VIEW`, and `=MJ.IMPORTRANGE` custom functions and live tables.
|
|
585
|
+
*/
|
|
586
|
+
export interface SpreadsheetMjEvaluationOptions {
|
|
587
|
+
/** Override cache TTL in milliseconds (defaults to 60,000 ms). */
|
|
588
|
+
CacheTtlMs?: number;
|
|
589
|
+
/** Maximum concurrent requests in flight (defaults to 5). */
|
|
590
|
+
MaxConcurrency?: number;
|
|
591
|
+
/** Bypass the viewer result cache when `true`. */
|
|
592
|
+
BypassCache?: boolean;
|
|
593
|
+
/** Optional resolver override for `=MJ.IMPORTRANGE(...)` (useful in tests or custom hosts). */
|
|
594
|
+
ImportRangeResolver?: (request: SpreadsheetImportRangeRequest) => Promise<DocumentBlockExecutionResult>;
|
|
595
|
+
/** Recursion cycle-tracking stack for nested `=MJ.IMPORTRANGE` calls (max depth 3). */
|
|
596
|
+
ImportRangeVisitedKeys?: string[];
|
|
597
|
+
/** Current recursion depth for `=MJ.IMPORTRANGE` (starts at `0`). */
|
|
598
|
+
ImportRangeDepth?: number;
|
|
599
|
+
/** Hosting artifact ID for self-reference / cycle attribution. */
|
|
600
|
+
HostArtifactID?: string;
|
|
601
|
+
/** Optional edit context used to enforce `ProtectedRanges` on non-anchor spill destination cells. */
|
|
602
|
+
EditContext?: SpreadsheetCellEditContext;
|
|
603
|
+
/** Optional binary file resolver override for `ContentMode = 'File'` `.xlsx` targets in `=MJ.IMPORTRANGE`. */
|
|
604
|
+
ResolveFileBytes?: (fileId: string, versionId: string) => Promise<Uint8Array | ArrayBuffer | null>;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Options for explicit opt-in batch evaluation of `=MJ.AI(...)` spreadsheet cells (`§ 5.2b`).
|
|
608
|
+
*/
|
|
609
|
+
export interface SpreadsheetAiEvaluationOptions {
|
|
610
|
+
/** Optional hosting `MJ: Artifacts` ID. */
|
|
611
|
+
ArtifactID?: string | null;
|
|
612
|
+
/** Optional actor/permission context checked before mutating protected cells with AI results. */
|
|
613
|
+
EditContext?: SpreadsheetCellEditContext;
|
|
614
|
+
/** Restrict evaluation to these canonical `'SheetID::Addr'` or `'Addr'` keys. */
|
|
615
|
+
TargetAddresses?: string[];
|
|
616
|
+
/** Maximum cells per batch (clamped to `MAX_AI_FORMULA_BATCH_CELLS = 50`). */
|
|
617
|
+
MaxCells?: number;
|
|
618
|
+
/** Re-evaluate even if `AiInputHash` already matches cached output. */
|
|
619
|
+
ForceRefresh?: boolean;
|
|
620
|
+
/** Optional explicit AI model override. */
|
|
621
|
+
ModelOverride?: string | null;
|
|
622
|
+
/** Optional custom batch evaluator (defaults to `ArtifactEvaluateAiFormulaOperation`). */
|
|
623
|
+
AiEvaluator?: (cells: ArtifactAiFormulaCellRequest[]) => Promise<Array<{
|
|
624
|
+
SheetID: string;
|
|
625
|
+
Address: string;
|
|
626
|
+
InputHash: string;
|
|
627
|
+
Value: string;
|
|
628
|
+
ErrorMessage?: string | null;
|
|
629
|
+
AccessDenied?: boolean;
|
|
630
|
+
}>>;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Summary returned by {@link SpreadsheetEngine.EvaluateAiFormulas}.
|
|
634
|
+
*/
|
|
635
|
+
export interface SpreadsheetAiEvaluationResult {
|
|
636
|
+
EvaluatedCount: number;
|
|
637
|
+
CacheHitCount: number;
|
|
638
|
+
SkippedOverCapCount: number;
|
|
639
|
+
AccessDeniedCount: number;
|
|
640
|
+
ErrorCount: number;
|
|
641
|
+
}
|
|
642
|
+
/** Maximum compressed `.xlsx` archive size accepted by `ImportFromXlsxBytes` (15 MiB, `B6`). */
|
|
643
|
+
export declare const MAX_XLSX_COMPRESSED_BYTES: number;
|
|
644
|
+
/** Maximum cumulative uncompressed size across all ZIP entries in `.xlsx` import (64 MiB, `B6`, `R8-3`). */
|
|
645
|
+
export declare const MAX_XLSX_UNCOMPRESSED_TOTAL_BYTES: number;
|
|
646
|
+
/** Maximum uncompressed size of any single ZIP entry in `.xlsx` import (32 MiB, `B6`, `R8-3`). */
|
|
647
|
+
export declare const MAX_XLSX_ENTRY_BYTES: number;
|
|
648
|
+
/** Maximum formula expression character length accepted before returning `#VALUE!` (`P0-11`). */
|
|
649
|
+
export declare const MAX_FORMULA_LENGTH = 8192;
|
|
650
|
+
/** Maximum parser/evaluator AST recursion depth before returning `#VALUE!` / `#CALC!` (`P0-11`). */
|
|
651
|
+
export declare const MAX_AST_DEPTH = 128;
|
|
652
|
+
/** Maximum formula AST/lambda evaluation operations permitted within a single workbook pass (`B5`). */
|
|
653
|
+
export declare const MAX_EVAL_OPS_PER_WORKBOOK = 2000000;
|
|
654
|
+
/** Maximum wall-clock duration (ms) permitted for a single workbook evaluation pass (`B5`). */
|
|
655
|
+
export declare const MAX_EVAL_TIME_MS = 5000;
|
|
656
|
+
/** Maximum character length permitted in any formula string result (matches Excel's 32,767 cell limit, `B5`). */
|
|
657
|
+
export declare const MAX_CELL_STRING_LENGTH = 32767;
|
|
658
|
+
/** Maximum total cell grid entries emitted in a single `ExportToCsv` pass (`B5`). */
|
|
659
|
+
export declare const MAX_EXPORT_CSV_CELLS = 500000;
|
|
660
|
+
/**
|
|
661
|
+
* Builds the canonical {@link FrozenSnapshotIdentityBinding} for a {@link SpreadsheetLiveTableSpec} (`S3`).
|
|
662
|
+
*/
|
|
663
|
+
export declare function BuildLiveTableIdentityBinding(table: Pick<SpreadsheetLiveTableSpec, 'TableID' | 'SourceType' | 'EntityName' | 'ViewID' | 'ViewName' | 'QueryID' | 'QueryName'>, hostArtifactId?: string | null): FrozenSnapshotIdentityBinding;
|
|
664
|
+
/**
|
|
665
|
+
* Sanitizes a worksheet name for Excel/OOXML compatibility: strips forbidden characters
|
|
666
|
+
* (`[`, `]`, `:`, `*`, `?`, `/`, `\`), trims whitespace, limits length to 31 characters,
|
|
667
|
+
* and deduplicates case-insensitively against `existingLowerNames` using `" (2)"`, `" (3)"`, ...
|
|
668
|
+
*/
|
|
669
|
+
export declare function SanitizeWorksheetName(name: string, existingLowerNames?: ReadonlySet<string>): string;
|
|
670
|
+
/**
|
|
671
|
+
* Converts a 1-based column index (`1 = A`, `26 = Z`, `27 = AA`) to its Excel column letter.
|
|
672
|
+
*/
|
|
673
|
+
export declare function ColumnIndexToLetter(index: number): string;
|
|
674
|
+
/**
|
|
675
|
+
* Converts an Excel column letter (`'A'`, `'Z'`, `'AA'`) to a 1-based column index.
|
|
676
|
+
*/
|
|
677
|
+
export declare function ColumnLetterToIndex(letter: string): number;
|
|
678
|
+
/**
|
|
679
|
+
* Parses an A1 cell coordinate (`'B2'`, `'$B$2'`) into 1-based `{ row, col, absRow, absCol }`.
|
|
680
|
+
*/
|
|
681
|
+
export declare function ParseCellAddress(address: string): {
|
|
682
|
+
row: number;
|
|
683
|
+
col: number;
|
|
684
|
+
colLetter: string;
|
|
685
|
+
absRow: boolean;
|
|
686
|
+
absCol: boolean;
|
|
687
|
+
} | null;
|
|
688
|
+
/**
|
|
689
|
+
* Formats a 1-based `(row, col)` coordinate as an A1 cell address (`'B2'`).
|
|
690
|
+
*/
|
|
691
|
+
export declare function FormatCellAddress(row: number, col: number, absRow?: boolean, absCol?: boolean): string;
|
|
692
|
+
/**
|
|
693
|
+
* Expands an A1 range string (`'A1:C3'`, single cell `'B2'`, whole-column `'A:A'` / `'$A:$C'`,
|
|
694
|
+
* or whole-row `'1:1'` / `'$1:$5'`) into `{ startRow, endRow, startCol, endCol }`.
|
|
695
|
+
*/
|
|
696
|
+
export declare function ParseRangeAddress(range: string, maxRows?: number, maxCols?: number): {
|
|
697
|
+
startRow: number;
|
|
698
|
+
endRow: number;
|
|
699
|
+
startCol: number;
|
|
700
|
+
endCol: number;
|
|
701
|
+
} | null;
|
|
702
|
+
export declare const EXCEL_MAX_ROWS = 1048576;
|
|
703
|
+
export declare const EXCEL_MAX_COLS = 16384;
|
|
704
|
+
export declare const MAX_IMPORT_SHEETS = 128;
|
|
705
|
+
export declare const MAX_IMPORT_WORKBOOK_CELLS = 250000;
|
|
706
|
+
export declare const MAX_IMPORT_WORKBOOK_FORMULAS = 100000;
|
|
707
|
+
export declare const MAX_IMPORT_WORKBOOK_ARRAY_ANCHORS = 25000;
|
|
708
|
+
export declare const MAX_IMPORT_WORKBOOK_COL_TAGS = 25000;
|
|
709
|
+
export declare const MAX_VALIDATION_RULES_PER_SHEET = 5000;
|
|
710
|
+
export declare const MAX_PROTECTED_RANGES_PER_WORKBOOK = 2000;
|
|
711
|
+
export declare const MAX_VALIDATION_ALLOWED_VALUES = 1000;
|
|
712
|
+
export declare const MAX_VALIDATION_CHECKS_PER_WORKBOOK = 2000000;
|
|
713
|
+
export declare const MAX_IMPORT_WORKBOOK_MERGE_RANGES = 50000;
|
|
714
|
+
export declare const MAX_IMPORT_WORKBOOK_CHARTS = 2000;
|
|
715
|
+
export declare const MAX_IMPORT_DRAWING_ANCHORS = 10000;
|
|
716
|
+
export declare const MAX_IMPORT_WORKBOOK_CONDITIONAL_FORMATS = 5000;
|
|
717
|
+
export declare const MAX_IMPORT_WORKBOOK_LIVE_TABLES = 1000;
|
|
718
|
+
export declare const MAX_IMPORT_WORKBOOK_EMBEDDED_ARTIFACTS = 1000;
|
|
719
|
+
export declare const MAX_IMPORTED_FORMULA_BYTES: number;
|
|
720
|
+
export declare const MAX_DAG_EDGES_PER_WORKBOOK = 1000000;
|
|
721
|
+
export declare const MAX_DAG_EXPANDED_WIDE_EDGES = 750000;
|
|
722
|
+
export declare const MAX_DAG_RANGE_WATCHERS = 250000;
|
|
723
|
+
export declare const MAX_EVAL_MATRIX_CELLS_PER_FORMULA = 1000000;
|
|
724
|
+
export declare const MAX_EVAL_MATRIX_CELLS_PER_WORKBOOK = 4000000;
|
|
725
|
+
export interface SpreadsheetWorkerIsolationRunner {
|
|
726
|
+
ImportFromXlsxBytes(bytes: Uint8Array, configurationJson?: string | null, options?: {
|
|
727
|
+
SkipEvaluate?: boolean;
|
|
728
|
+
}): Promise<WorkbookSpec>;
|
|
729
|
+
PatchXlsxBytes(originalBytes: Uint8Array, workbook: WorkbookSpec): Promise<Uint8Array>;
|
|
730
|
+
EvaluateWorkbook(workbook: WorkbookSpec, editContext?: SpreadsheetCellEditContext): Promise<{
|
|
731
|
+
Workbook: WorkbookSpec;
|
|
732
|
+
EvaluatedFormulaCount: number;
|
|
733
|
+
}>;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Registers the server-side `worker_threads` isolation runner used by {@link SpreadsheetEngine}
|
|
737
|
+
* async `Isolated` entry points (`R6-1`). Keeps `@memberjunction/core-entities` free of Node imports.
|
|
738
|
+
*/
|
|
739
|
+
export declare function RegisterSpreadsheetWorkerRunner(runner: SpreadsheetWorkerIsolationRunner | null): void;
|
|
740
|
+
/**
|
|
741
|
+
* Configures whether isolated entry points must fail closed in Node/server mode when no
|
|
742
|
+
* {@link SpreadsheetWorkerIsolationRunner} is registered (`R7-1`).
|
|
743
|
+
*/
|
|
744
|
+
export declare function SetSpreadsheetWorkerIsolationRequired(required: boolean): void;
|
|
745
|
+
/**
|
|
746
|
+
* Returns the registered {@link SpreadsheetWorkerIsolationRunner}, or `null` in browser / standalone mode.
|
|
747
|
+
*/
|
|
748
|
+
export declare function GetSpreadsheetWorkerRunner(): SpreadsheetWorkerIsolationRunner | null;
|
|
749
|
+
/**
|
|
750
|
+
* Isomorphic engine for MJ Sheets (`Excel Spreadsheet` artifact type, `§ 6` & `§ 7.2`).
|
|
751
|
+
*
|
|
752
|
+
* Provides:
|
|
753
|
+
* - Multi-tab workbook creation, normalization, and revision hashing
|
|
754
|
+
* - Stable RowID / ColumnID formula storage (`CompileFormulaToStableIds` / `ResolveFormulaFromStableIds`)
|
|
755
|
+
* so concurrent row/column insertions and formula edits over Yjs preserve exact cell targets (`Accept #1`)
|
|
756
|
+
* - Headless Node + browser formula evaluation covering 35+ spreadsheet functions (`Accept #3`)
|
|
757
|
+
* - Viewer-scoped `=MJ.QUERY(name, ...params)` and `=MJ.VIEW(entity, view, filter)` evaluation with
|
|
758
|
+
* RLS + FLS projection, `IsServerSet` stripping, 60s viewer cache, and concurrency cap (`§ 6.3`, `§ 7.2`)
|
|
759
|
+
* - Range sources (`SpreadsheetLiveTableSpec`) bound to MJ Views/Queries with calculated formula columns
|
|
760
|
+
* and explicit recorded `O5` freeze (`Accept #2`)
|
|
761
|
+
* - Lossless `.xlsx` (OpenXML ZIP with `<f>` formulas and `numFmt` styles) and `.csv` import/export (`Accept #4`)
|
|
762
|
+
* - Range chart dataset extraction for live Sheet-to-Slide / Sheet-to-Doc chart blocks (`Accept #5`)
|
|
763
|
+
*/
|
|
764
|
+
export declare class SpreadsheetEngine extends BaseSingleton<SpreadsheetEngine> {
|
|
765
|
+
private viewerCache;
|
|
766
|
+
private sheetToWorkbook;
|
|
767
|
+
private workbookDagCache;
|
|
768
|
+
private workbookCellCountCache;
|
|
769
|
+
private sheetLookupCache;
|
|
770
|
+
private sheetAxisIdSets;
|
|
771
|
+
private workbookVirtualAxisIndex;
|
|
772
|
+
private sheetUnboundVirtualAxisIndex;
|
|
773
|
+
private cellIndexedVirtualTokens;
|
|
774
|
+
private indexedSheets;
|
|
775
|
+
private sheetsWithVirtualAxisIds;
|
|
776
|
+
private workbooksWithVirtualAxisIds;
|
|
777
|
+
private unimplementedResultCells;
|
|
778
|
+
private validationIndexCache;
|
|
779
|
+
private monotonicIdCounter;
|
|
780
|
+
private _lastEvaluatedFormulaCount;
|
|
781
|
+
private activeEvalBudget;
|
|
782
|
+
private runWithEvalBudget;
|
|
783
|
+
private chargeMatrixAllocation;
|
|
784
|
+
private getOrBuildValidationIndex;
|
|
785
|
+
private getOrBuildSheetColIndex;
|
|
786
|
+
private upsertCellInEvalColIndex;
|
|
787
|
+
private removeCellFromEvalColIndex;
|
|
788
|
+
private getPopulatedCellBounds;
|
|
789
|
+
private consumeEvalBudget;
|
|
790
|
+
private joinCappedStrings;
|
|
791
|
+
/**
|
|
792
|
+
* Number of cell formulas evaluated in the most recent `EvaluateWorkbook` or incremental recalculation pass.
|
|
793
|
+
*/
|
|
794
|
+
get LastEvaluatedFormulaCount(): number;
|
|
795
|
+
protected constructor();
|
|
796
|
+
/** Returns the process-wide singleton instance of {@link SpreadsheetEngine}. */
|
|
797
|
+
static get Instance(): SpreadsheetEngine;
|
|
798
|
+
/** Clears the viewer-scoped `=MJ.QUERY` / `=MJ.VIEW` result cache. */
|
|
799
|
+
ClearViewerFunctionCache(userId?: string): void;
|
|
800
|
+
/**
|
|
801
|
+
* Creates a new multi-tab {@link WorkbookSpec} with stable `RowID`s and `ColumnID`s.
|
|
802
|
+
*/
|
|
803
|
+
CreateEmptyWorkbook(title?: string, sheetNames?: string[], rowCount?: number, colCount?: number): WorkbookSpec;
|
|
804
|
+
/**
|
|
805
|
+
* Creates a single empty {@link WorksheetSpec} with initialized stable `Rows` and `Columns`.
|
|
806
|
+
*/
|
|
807
|
+
CreateEmptyWorksheet(sheetId: string, name: string, rowCount?: number, colCount?: number): WorksheetSpec;
|
|
808
|
+
private assertSynchronousEvaluationAllowed;
|
|
809
|
+
/**
|
|
810
|
+
* Parses a workbook from JSON string, `Configuration` metadata string, CSV text, or returns a default workbook.
|
|
811
|
+
*/
|
|
812
|
+
ParseWorkbook(content?: string | null, configuration?: string | null, options?: {
|
|
813
|
+
SkipEvaluate?: boolean;
|
|
814
|
+
}): WorkbookSpec;
|
|
815
|
+
/**
|
|
816
|
+
* Isolated async counterpart to {@link ParseWorkbook}: enforces workbook limits in
|
|
817
|
+
* {@link NormalizeWorkbook} and delegates `.xlsx` binary imports as well as formula
|
|
818
|
+
* evaluation to the registered server `worker_threads` runner when active (`R7-1`).
|
|
819
|
+
*/
|
|
820
|
+
ParseWorkbookIsolated(content?: string | null, configuration?: string | null, options?: {
|
|
821
|
+
SkipEvaluate?: boolean;
|
|
822
|
+
}): Promise<WorkbookSpec>;
|
|
823
|
+
/**
|
|
824
|
+
* Serializes a {@link WorkbookSpec} to canonical formatted JSON, stripping viewer-scoped
|
|
825
|
+
* `=MJ.*` spill cells, `Mode === 'Live'` table cells, and `=MJ.QUERY`/`=MJ.VIEW` computed values
|
|
826
|
+
* so viewer-scoped data is never persisted (`B4`).
|
|
827
|
+
*/
|
|
828
|
+
SerializeWorkbook(workbook: WorkbookSpec, options?: {
|
|
829
|
+
preserveTimestamps?: boolean;
|
|
830
|
+
}): string;
|
|
831
|
+
/**
|
|
832
|
+
* Returns a deep-cloned workbook with all viewer-scoped data (`=MJ.*` cells/spills,
|
|
833
|
+
* `Mode === 'Live'` tables, and transitively dependent formula cells) stripped (`B7b`).
|
|
834
|
+
*/
|
|
835
|
+
CloneWorkbookWithoutViewerScopedData(workbook: WorkbookSpec): WorkbookSpec;
|
|
836
|
+
private isCellInLiveTableFootprint;
|
|
837
|
+
private cloneWorkbookWithoutViewerScopedData;
|
|
838
|
+
private getOrCreateWorkbookVirtualAxisIndex;
|
|
839
|
+
private extractVirtualAxisTokensFromCell;
|
|
840
|
+
private removeCellFromVirtualAxisIndex;
|
|
841
|
+
private syncCellVirtualAxisIndex;
|
|
842
|
+
private bindSheetsToWorkbook;
|
|
843
|
+
private markSheetHasVirtualAxisIds;
|
|
844
|
+
private getSheetLookup;
|
|
845
|
+
private getStableRowIdForIndex;
|
|
846
|
+
private getStableColIdForIndex;
|
|
847
|
+
private resolveRowIndexFromId;
|
|
848
|
+
private resolveColIndexFromId;
|
|
849
|
+
private mintUniqueRowId;
|
|
850
|
+
private mintUniqueColumnId;
|
|
851
|
+
/**
|
|
852
|
+
* Computes a deterministic FNV-1a revision hash over the workbook for optimistic concurrency checks.
|
|
853
|
+
*/
|
|
854
|
+
ComputeRevisionHash(workbook: WorkbookSpec): string;
|
|
855
|
+
/**
|
|
856
|
+
* Validates workbook-wide structural limits across JSON, room hydration, and `.xlsx` payloads (`R7-1`, `S7-2`, `S7-3`).
|
|
857
|
+
*/
|
|
858
|
+
AssertWorkbookWithinLimits(raw: Partial<WorkbookSpec>): void;
|
|
859
|
+
/**
|
|
860
|
+
* Ensures a partial or deserialized workbook has valid `Rows`, `Columns`, `Cells`, and stable IDs.
|
|
861
|
+
*/
|
|
862
|
+
NormalizeWorkbook(raw: Partial<WorkbookSpec>): WorkbookSpec;
|
|
863
|
+
/**
|
|
864
|
+
* Normalizes a single worksheet, ensuring `Rows` and `Columns` cover all populated cell coordinates,
|
|
865
|
+
* guaranteeing monotonic unique `RowID`s and `ColumnID`s, and ensuring every formula has both
|
|
866
|
+
* `Formula` and `FormulaStable`.
|
|
867
|
+
*/
|
|
868
|
+
NormalizeWorksheet(raw: Partial<WorksheetSpec>, fallbackId?: string, fallbackName?: string): WorksheetSpec;
|
|
869
|
+
/**
|
|
870
|
+
* Shifts relative A1 cell and range references inside `formula` by `(rowDelta, colDelta)`
|
|
871
|
+
* using the formula tokenizer so string literals, sheet prefixes, and function names (e.g. `LOG10`)
|
|
872
|
+
* are never corrupted, and `$`-anchored coordinates stay fixed.
|
|
873
|
+
*/
|
|
874
|
+
ShiftFormulaReferences(formula: string, rowDelta: number, colDelta: number): string;
|
|
875
|
+
/**
|
|
876
|
+
* Translates an A1 formula (e.g. `'=SUM(B2:B9) + $C$2'`) into a stable-ID formula
|
|
877
|
+
* (`'=SUM(@RANGE(sheet-1-row-2,sheet-1-col-B,sheet-1-row-9,sheet-1-col-B)) + @CELL($sheet-1-row-2,$sheet-1-col-C)'`
|
|
878
|
+
* and cross-sheet `'@SHEET_CELL(sheetId,r,c)'` / `'@SHEET_RANGE(sheetId,r1,c1,r2,c2)'`)
|
|
879
|
+
* so concurrent row/column insertions and deletions preserve exact logical references (`§ 6.2`, `Accept #1`, `D3`).
|
|
880
|
+
*/
|
|
881
|
+
CompileFormulaToStableIds(sheet: WorksheetSpec, formula: string, workbook?: WorkbookSpec): string;
|
|
882
|
+
/**
|
|
883
|
+
* Resolves a `FormulaStable` string back to human-readable A1 notation using the current
|
|
884
|
+
* positions of each `RowID` and `ColumnID` in `sheet.Rows` / `sheet.Columns` (and cross-sheet
|
|
885
|
+
* `@SHEET_CELL` / `@SHEET_RANGE` / `@SHEET_COLS` / `@SHEET_ROWS` targets when `workbook` is available) (`§ 6.2`, `Accept #1`, `D3`, `E6`).
|
|
886
|
+
*/
|
|
887
|
+
ResolveFormulaFromStableIds(sheet: WorksheetSpec, formulaStable: string, workbook?: WorkbookSpec): string;
|
|
888
|
+
private assertProtectedRangesAllowStructuralEdit;
|
|
889
|
+
/**
|
|
890
|
+
* Inserts `count` new rows at 1-based `atRowNumber` in `sheetId`, assigning fresh monotonic `RowID`s,
|
|
891
|
+
* shifting affected cells and non-cell range metadata down, and resolving all `FormulaStable` references (`§ 6.2`, `Accept #1`, `D3`).
|
|
892
|
+
*/
|
|
893
|
+
InsertRows(workbook: WorkbookSpec, sheetId: string, atRowNumber: number, count?: number, editContext?: SpreadsheetCellEditContext, recalculate?: boolean): SpreadsheetRowSpec[];
|
|
894
|
+
/**
|
|
895
|
+
* Deletes `count` rows starting at 1-based `atRowNumber` in `sheetId`, shrinking `@RANGE` endpoints
|
|
896
|
+
* to surviving rows (or `#REF!` if the entire range was deleted) and updating non-cell range metadata (`D3`, `R6-10`).
|
|
897
|
+
*/
|
|
898
|
+
DeleteRows(workbook: WorkbookSpec, sheetId: string, atRowNumber: number, count?: number, editContext?: SpreadsheetCellEditContext, recalculate?: boolean): void;
|
|
899
|
+
/**
|
|
900
|
+
* Inserts `count` new columns at 1-based `atColumnNumber` in `sheetId`, assigning fresh UUID `ColumnID`s,
|
|
901
|
+
* shifting affected cells and non-cell range metadata right, and resolving all `FormulaStable` references (`§ 6.2`, `Accept #1`, `D3`).
|
|
902
|
+
*/
|
|
903
|
+
InsertColumns(workbook: WorkbookSpec, sheetId: string, atColumnNumber: number, count?: number, editContext?: SpreadsheetCellEditContext, recalculate?: boolean): SpreadsheetColumnSpec[];
|
|
904
|
+
/**
|
|
905
|
+
* Deletes `count` columns starting at 1-based `atColumnNumber` in `sheetId`, shrinking `@RANGE` endpoints
|
|
906
|
+
* to surviving columns (or `#REF!` if the entire range was deleted) and updating non-cell range metadata (`D3`, `R6-10`).
|
|
907
|
+
*/
|
|
908
|
+
DeleteColumns(workbook: WorkbookSpec, sheetId: string, atColumnNumber: number, count?: number, editContext?: SpreadsheetCellEditContext, recalculate?: boolean): void;
|
|
909
|
+
private shiftVirtualAxisIds;
|
|
910
|
+
/**
|
|
911
|
+
* Rebuilds 1-based row/column indices, moves cells to their current `(RowID, ColumnID)` A1 coordinates,
|
|
912
|
+
* and updates every cell's `Formula` from its `FormulaStable` (`§ 6.2`, `Accept #1`).
|
|
913
|
+
*/
|
|
914
|
+
ReindexWorksheetAndResolveFormulas(sheet: WorksheetSpec): void;
|
|
915
|
+
private reindexWorkbookAfterStructuralEdit;
|
|
916
|
+
private reindexSheetStructureAndFormulas;
|
|
917
|
+
private ensureAllWorkbookFormulasHaveStableIds;
|
|
918
|
+
private shrinkFormulaStableRowEndpointsBeforeDelete;
|
|
919
|
+
private shrinkFormulaStableColEndpointsBeforeDelete;
|
|
920
|
+
private shiftNonCellMetadataForRowEdit;
|
|
921
|
+
private shiftNonCellMetadataForColEdit;
|
|
922
|
+
/**
|
|
923
|
+
* Finds a worksheet by `SheetID` or case-insensitive `Name`.
|
|
924
|
+
*/
|
|
925
|
+
GetWorksheet(workbook: WorkbookSpec, sheetIdOrName: string): WorksheetSpec | undefined;
|
|
926
|
+
private isCseOrArrayFormula;
|
|
927
|
+
/**
|
|
928
|
+
* Writes a value or formula into a single cell (addressed by A1 coordinate or `{ rowId, columnId }`)
|
|
929
|
+
* and recalculates affected dependents (`Accept #3`, `D2`).
|
|
930
|
+
*/
|
|
931
|
+
SetCell(workbook: WorkbookSpec, sheetIdOrName: string, address: string, input: {
|
|
932
|
+
Value?: SpreadsheetCellValue;
|
|
933
|
+
Formula?: string | null;
|
|
934
|
+
FormulaStable?: string | null;
|
|
935
|
+
Literal?: boolean;
|
|
936
|
+
Style?: Partial<SpreadsheetCellStyleSpec>;
|
|
937
|
+
Note?: string | null;
|
|
938
|
+
SpilledFrom?: string | null;
|
|
939
|
+
LiveTableID?: string | null;
|
|
940
|
+
AccessDenied?: boolean;
|
|
941
|
+
ErrorMessage?: string | null;
|
|
942
|
+
AiInputHash?: string | null;
|
|
943
|
+
}, recalculate?: boolean, editContext?: SpreadsheetCellEditContext): SpreadsheetCellSpec;
|
|
944
|
+
/**
|
|
945
|
+
* Clears all populated cells in `rangeA1` (including any owned dynamic-array or legacy CSE spill children
|
|
946
|
+
* whose anchor cell falls inside `rangeA1`) and incrementally recalculates dependents (`R8-8`).
|
|
947
|
+
*/
|
|
948
|
+
ClearRange(workbook: WorkbookSpec, sheetIdOrName: string, rangeA1: string, recalculate?: boolean, editContext?: SpreadsheetCellEditContext): string[];
|
|
949
|
+
/**
|
|
950
|
+
* Clears owned spill / legacy CSE array child cells when anchor cell `canonicalAnchorAddr` is edited,
|
|
951
|
+
* cleared, or overwritten, recording cleared child coordinates on `WORKSHEET_CLEARED_SPILL_CHILDREN` (`R8-8`, `R9-6`).
|
|
952
|
+
*/
|
|
953
|
+
private clearOwnedArrayChildren;
|
|
954
|
+
/**
|
|
955
|
+
* Reads a rectangular A1 range from `sheetIdOrName` as a 2D array of cell specs.
|
|
956
|
+
*/
|
|
957
|
+
ReadRange(workbook: WorkbookSpec, sheetIdOrName: string, rangeA1: string): SpreadsheetCellSpec[][];
|
|
958
|
+
/**
|
|
959
|
+
* Adds a new worksheet tab to `workbook`.
|
|
960
|
+
*/
|
|
961
|
+
AddWorksheet(workbook: WorkbookSpec, name: string, rowCount?: number, colCount?: number): WorksheetSpec;
|
|
962
|
+
/**
|
|
963
|
+
* Renames an existing worksheet in `workbook`, updating all cross-sheet formulas
|
|
964
|
+
* referencing that worksheet across the entire workbook and recalculating (`Blocker 7`).
|
|
965
|
+
*/
|
|
966
|
+
RenameWorksheet(workbook: WorkbookSpec, sheetIdOrName: string, newName: string, evaluate?: boolean): boolean;
|
|
967
|
+
private makeUniqueWorksheetName;
|
|
968
|
+
private getOrSyncSheetAxisIdSets;
|
|
969
|
+
private ensureSheetCapacity;
|
|
970
|
+
private promoteMaterializedVirtualAxisIds;
|
|
971
|
+
/**
|
|
972
|
+
* Synchronously evaluates all standard formulas across all worksheets in `workbook`
|
|
973
|
+
* using an iterative topological DAG traversal (zero JS call-stack recursion across cells).
|
|
974
|
+
*
|
|
975
|
+
* Note: Cells containing `=MJ.QUERY(...)` or `=MJ.VIEW(...)` retain their last viewer-evaluated
|
|
976
|
+
* `ComputedValue` (or `'#MJ_PENDING!'` until `EvaluateMjCustomFunctions` runs with a `UserInfo`).
|
|
977
|
+
*/
|
|
978
|
+
EvaluateWorkbook(workbook: WorkbookSpec, editContext?: SpreadsheetCellEditContext): void;
|
|
979
|
+
/**
|
|
980
|
+
* Evaluates `workbook` inside the registered server `worker_threads` isolation runner when available (`R6-1`),
|
|
981
|
+
* applying its mutated worksheets/named ranges back onto `workbook` in place.
|
|
982
|
+
*/
|
|
983
|
+
EvaluateWorkbookIsolated(workbook: WorkbookSpec, editContext?: SpreadsheetCellEditContext): Promise<void>;
|
|
984
|
+
/**
|
|
985
|
+
* Imports `.xlsx` bytes inside the registered server `worker_threads` isolation runner when available (`R6-1`).
|
|
986
|
+
*/
|
|
987
|
+
ImportFromXlsxBytesIsolated(bytes: Uint8Array | ArrayBuffer, configurationJson?: string | null, options?: {
|
|
988
|
+
SkipEvaluate?: boolean;
|
|
989
|
+
}): Promise<WorkbookSpec>;
|
|
990
|
+
/**
|
|
991
|
+
* Patches `.xlsx` bytes inside the registered server `worker_threads` isolation runner when available (`R6-1`).
|
|
992
|
+
*/
|
|
993
|
+
PatchXlsxBytesIsolated(originalBytes: Uint8Array | ArrayBuffer, workbook: WorkbookSpec): Promise<Uint8Array>;
|
|
994
|
+
/**
|
|
995
|
+
* Incrementally recalculates `canonicalAddr` (plus any `extraDirtyAddrs`) on `sheet` and ONLY their
|
|
996
|
+
* transitive dependent formula cells in iterative topological order (`D2`, `R8-3`, `R8-8`).
|
|
997
|
+
*/
|
|
998
|
+
private recalculateAfterCellEdit;
|
|
999
|
+
/**
|
|
1000
|
+
* Evaluates an arbitrary formula expression against `sheet` in `workbook` without mutating cells.
|
|
1001
|
+
*/
|
|
1002
|
+
EvaluateFormulaExpression(workbook: WorkbookSpec, sheetIdOrName: string, formula: string): SpreadsheetCellValue;
|
|
1003
|
+
private buildWorkbookDependencyGraph;
|
|
1004
|
+
private updateSingleCellInDag;
|
|
1005
|
+
private extractAstCellDependencies;
|
|
1006
|
+
/**
|
|
1007
|
+
* Evaluates `targetKeys` in iterative post-order topological order with explicit cycle detection
|
|
1008
|
+
* (`#CYCLE!`), zero JS call-stack recursion across cells, and $O(1)$ lookup for clean cells when
|
|
1009
|
+
* `dirtyScope` is non-null.
|
|
1010
|
+
*/
|
|
1011
|
+
private evaluateCellKeysIteratively;
|
|
1012
|
+
private finiteOrNumError;
|
|
1013
|
+
private evalBinaryOpScalars;
|
|
1014
|
+
private isTopLevelSpillCandidate;
|
|
1015
|
+
private applyDynamicArraySpillToSheet;
|
|
1016
|
+
private nodeContainsArray;
|
|
1017
|
+
private evalAstNode;
|
|
1018
|
+
private resolveAstRangeDescriptor;
|
|
1019
|
+
private resolveAstRangeMatrix;
|
|
1020
|
+
private evalAstMatrix;
|
|
1021
|
+
private evalAstNodeToLexicalBinding;
|
|
1022
|
+
private createLambdaBinding;
|
|
1023
|
+
private invokeLambdaBinding;
|
|
1024
|
+
private dynamicArrayCellKey;
|
|
1025
|
+
private compareDynamicArraySortValues;
|
|
1026
|
+
private evalDynamicArrayMatrix;
|
|
1027
|
+
private evalAstFunctionCall;
|
|
1028
|
+
private splitTopLevelArgs;
|
|
1029
|
+
private isErrorValue;
|
|
1030
|
+
private toNumberOrError;
|
|
1031
|
+
private toBooleanOrError;
|
|
1032
|
+
private toExcelDateSerialOrError;
|
|
1033
|
+
private compareValues;
|
|
1034
|
+
private strictLookupEqual;
|
|
1035
|
+
private compareSameTypeForLookup;
|
|
1036
|
+
private valuesEqualCaseInsensitive;
|
|
1037
|
+
private matchesCriteria;
|
|
1038
|
+
private formatCellForDisplay;
|
|
1039
|
+
/**
|
|
1040
|
+
* Formats a raw or computed scalar value according to its {@link SpreadsheetCellStyleSpec}.
|
|
1041
|
+
*/
|
|
1042
|
+
FormatCellValue(value: SpreadsheetCellValue, style?: SpreadsheetCellStyleSpec): string;
|
|
1043
|
+
private formatValueWithCustomPattern;
|
|
1044
|
+
/**
|
|
1045
|
+
* Infers a high-level {@link SpreadsheetCellFormatType} from an Excel `numFmt` pattern string.
|
|
1046
|
+
*/
|
|
1047
|
+
InferFormatTypeFromPattern(pattern?: string | null): SpreadsheetCellFormatType;
|
|
1048
|
+
/**
|
|
1049
|
+
* Returns the default Excel `numFmt` pattern for a {@link SpreadsheetCellFormatType}.
|
|
1050
|
+
*/
|
|
1051
|
+
DefaultPatternForFormatType(formatType?: SpreadsheetCellFormatType): string | undefined;
|
|
1052
|
+
private validateCellAgainstSheetRules;
|
|
1053
|
+
/**
|
|
1054
|
+
* Evaluates conditional formatting rules for `cell` on `sheet`, returning the matching highlight tone if any.
|
|
1055
|
+
*/
|
|
1056
|
+
GetCellConditionalHighlight(sheet: WorksheetSpec, cell: SpreadsheetCellSpec): 'success' | 'warning' | 'danger' | 'info' | null;
|
|
1057
|
+
/**
|
|
1058
|
+
* Adds or updates a protected range rule on `sheetIdOrName` (`§ 6.2`).
|
|
1059
|
+
*/
|
|
1060
|
+
AddProtectedRange(workbook: WorkbookSpec, sheetIdOrName: string, spec: Omit<SpreadsheetProtectedRangeSpec, 'LockedAt'> & {
|
|
1061
|
+
LockedAt?: string;
|
|
1062
|
+
}, editContext?: SpreadsheetCellEditContext): SpreadsheetProtectedRangeSpec;
|
|
1063
|
+
/**
|
|
1064
|
+
* Removes a protected range rule by `rangeId` if the actor is authorized (`§ 6.2`).
|
|
1065
|
+
*/
|
|
1066
|
+
RemoveProtectedRange(workbook: WorkbookSpec, sheetIdOrName: string, rangeId: string, editContext?: SpreadsheetCellEditContext): boolean;
|
|
1067
|
+
/**
|
|
1068
|
+
* Merges a rectangular A1 range (`>= 2` cells) on `sheetIdOrName` and stores its canonical A1 range in `sheet.MergeRanges`.
|
|
1069
|
+
*/
|
|
1070
|
+
MergeCells(workbook: WorkbookSpec, sheetIdOrName: string, range: string, editContext?: SpreadsheetCellEditContext): string;
|
|
1071
|
+
/**
|
|
1072
|
+
* Unmerges any merged ranges matching or overlapping `range` on `sheetIdOrName`.
|
|
1073
|
+
*/
|
|
1074
|
+
UnmergeCells(workbook: WorkbookSpec, sheetIdOrName: string, range: string, editContext?: SpreadsheetCellEditContext): number;
|
|
1075
|
+
/**
|
|
1076
|
+
* Adds or updates a data validation rule on `sheetIdOrName` and re-validates affected cells.
|
|
1077
|
+
*/
|
|
1078
|
+
AddValidationRule(workbook: WorkbookSpec, sheetIdOrName: string, rule: SpreadsheetValidationRuleSpec, editContext?: SpreadsheetCellEditContext): SpreadsheetValidationRuleSpec;
|
|
1079
|
+
/**
|
|
1080
|
+
* Removes a data validation rule by `ruleId` from `sheetIdOrName` and clears stale rule errors.
|
|
1081
|
+
*/
|
|
1082
|
+
RemoveValidationRule(workbook: WorkbookSpec, sheetIdOrName: string, ruleId: string, editContext?: SpreadsheetCellEditContext): boolean;
|
|
1083
|
+
/**
|
|
1084
|
+
* Adds or updates a conditional formatting rule on `sheetIdOrName`.
|
|
1085
|
+
*/
|
|
1086
|
+
AddConditionalFormat(workbook: WorkbookSpec, sheetIdOrName: string, rule: SpreadsheetConditionalFormatRuleSpec, editContext?: SpreadsheetCellEditContext): SpreadsheetConditionalFormatRuleSpec;
|
|
1087
|
+
/**
|
|
1088
|
+
* Removes a conditional formatting rule by `ruleId` from `sheetIdOrName`.
|
|
1089
|
+
*/
|
|
1090
|
+
RemoveConditionalFormat(workbook: WorkbookSpec, sheetIdOrName: string, ruleId: string, editContext?: SpreadsheetCellEditContext): boolean;
|
|
1091
|
+
/**
|
|
1092
|
+
* Creates or updates a workbook-level named range and recalculates dependent formulas.
|
|
1093
|
+
*/
|
|
1094
|
+
SetNamedRange(workbook: WorkbookSpec, spec: SpreadsheetNamedRangeSpec, recalculate?: boolean): SpreadsheetNamedRangeSpec;
|
|
1095
|
+
/**
|
|
1096
|
+
* Removes a workbook-level named range by `name`.
|
|
1097
|
+
*/
|
|
1098
|
+
RemoveNamedRange(workbook: WorkbookSpec, name: string, recalculate?: boolean): boolean;
|
|
1099
|
+
/**
|
|
1100
|
+
* Returns all {@link SpreadsheetProtectedRangeSpec} rules covering `address`.
|
|
1101
|
+
*/
|
|
1102
|
+
private getProtectedRangesForCell;
|
|
1103
|
+
/**
|
|
1104
|
+
* Returns the most-restrictive {@link SpreadsheetProtectedRangeSpec} covering `address`, or `null`.
|
|
1105
|
+
* Evaluates all overlapping ranges and prefers `AllowEditors !== true` (`AllowEditors === false`)
|
|
1106
|
+
* over `AllowEditors === true`.
|
|
1107
|
+
*/
|
|
1108
|
+
GetProtectedRangeForCell(sheet: WorksheetSpec, address: string): SpreadsheetProtectedRangeSpec | null;
|
|
1109
|
+
/**
|
|
1110
|
+
* Checks whether an actor may write or clear `address` on `sheet` given `ProtectedRanges` (`§ 6.2`).
|
|
1111
|
+
* Evaluates all overlapping protected ranges using most-restrictive precedence.
|
|
1112
|
+
*/
|
|
1113
|
+
CheckCellWritePermission(sheet: WorksheetSpec, address: string, editContext?: SpreadsheetCellEditContext): {
|
|
1114
|
+
Allowed: boolean;
|
|
1115
|
+
ProtectedRange?: SpreadsheetProtectedRangeSpec;
|
|
1116
|
+
Reason?: string;
|
|
1117
|
+
};
|
|
1118
|
+
private isActorAllowedForProtectedRule;
|
|
1119
|
+
/**
|
|
1120
|
+
* Parses an `=MJ.QUERY(name, ...params)`, `=MJ.VIEW(entity, view, ...params)`, or
|
|
1121
|
+
* `=MJ.IMPORTRANGE(artifact, range, [versionNumber])` formula string.
|
|
1122
|
+
* Returns `null` if `formula` is not one of those calls.
|
|
1123
|
+
*/
|
|
1124
|
+
ParseMjCustomFunctionFormula(formula?: string | null, workbook?: WorkbookSpec, sheet?: WorksheetSpec, currentCellAddress?: string): ParsedMjCustomFunctionCall | null;
|
|
1125
|
+
/**
|
|
1126
|
+
* Evaluates all `=MJ.QUERY(...)` and `=MJ.VIEW(...)` custom function cells across `workbook`
|
|
1127
|
+
* under the active viewer's `contextUser` permissions (`§ 6.3`, `§ 7.2`, `§ 8`).
|
|
1128
|
+
*
|
|
1129
|
+
* Enforces:
|
|
1130
|
+
* - Viewer-scoped RLS + FLS projection (`ProjectEntityValueRowsForUser`)
|
|
1131
|
+
* - Server-set parameter stripping (`StripServerOnlyRunQueryParams`)
|
|
1132
|
+
* - No raw SQL `WhereClause` injection in `=MJ.VIEW`
|
|
1133
|
+
* - Per-viewer 60s result caching (`contextUser.ID + canonicalKey`)
|
|
1134
|
+
* - Concurrency cap (default 5 simultaneous queries)
|
|
1135
|
+
* - Multi-cell spill or scalar return, followed by full workbook formula recalculation
|
|
1136
|
+
*/
|
|
1137
|
+
EvaluateMjCustomFunctions(workbook: WorkbookSpec, contextUser: UserInfo, provider?: IMetadataProvider, options?: SpreadsheetMjEvaluationOptions): Promise<{
|
|
1138
|
+
EvaluatedCount: number;
|
|
1139
|
+
AccessDeniedCount: number;
|
|
1140
|
+
}>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Validates a structured `=MJ.VIEW` filter expression, permitting column names like
|
|
1143
|
+
* `APP_NAME = 'Portal'` and `USER_NAME = 'alice'` while blocking SQL function calls
|
|
1144
|
+
* (`USER_NAME()`, `APP_NAME()`), niladic SQL session tokens (`SYSTEM_USER`, `CURRENT_USER`,
|
|
1145
|
+
* `SESSION_USER`), `@@` global variables (`@@VERSION`), and raw DDL/DML syntax.
|
|
1146
|
+
*/
|
|
1147
|
+
ValidateExtraFilter(extraFilter: string): {
|
|
1148
|
+
Valid: boolean;
|
|
1149
|
+
NormalizedFilter?: string;
|
|
1150
|
+
AccessDenied?: boolean;
|
|
1151
|
+
ErrorMessage?: string;
|
|
1152
|
+
};
|
|
1153
|
+
private executeSingleMjCustomFunction;
|
|
1154
|
+
private executeImportRangeFunction;
|
|
1155
|
+
/**
|
|
1156
|
+
* Parses `'Sheet Name'!A1:D20`, `Sheet2!A1:D20`, or bare `A1:D20` range specifiers for `=MJ.IMPORTRANGE`.
|
|
1157
|
+
*/
|
|
1158
|
+
ParseSheetAndRangeSpecifier(rangeSpec: string): {
|
|
1159
|
+
SheetName?: string;
|
|
1160
|
+
RangeA1: string;
|
|
1161
|
+
} | null;
|
|
1162
|
+
private extractWorkbookRangeResult;
|
|
1163
|
+
/**
|
|
1164
|
+
* Parses an opt-in `=MJ.AI("prompt", [cellOrRange...])` formula string (`§ 5.2b`).
|
|
1165
|
+
* Returns `null` if `formula` is not an `=MJ.AI` call.
|
|
1166
|
+
*/
|
|
1167
|
+
ParseMjAiFormula(formula?: string | null): ParsedMjAiFormulaCall | null;
|
|
1168
|
+
/**
|
|
1169
|
+
* Builds the serialized context payload and deterministic content hash for a single `=MJ.AI(...)` cell.
|
|
1170
|
+
*/
|
|
1171
|
+
ComputeAiFormulaContextAndHash(workbook: WorkbookSpec, sheet: WorksheetSpec, parsed: ParsedMjAiFormulaCall): {
|
|
1172
|
+
ContextValuesJSON: string;
|
|
1173
|
+
InputHash: string;
|
|
1174
|
+
AccessDenied: boolean;
|
|
1175
|
+
};
|
|
1176
|
+
/**
|
|
1177
|
+
* Summarizes all `=MJ.AI(...)` cells in `workbook` and how many are pending or have stale inputs.
|
|
1178
|
+
*/
|
|
1179
|
+
CountPendingAiFormulaCells(workbook: WorkbookSpec): {
|
|
1180
|
+
TotalCount: number;
|
|
1181
|
+
PendingOrStaleCount: number;
|
|
1182
|
+
CellKeys: string[];
|
|
1183
|
+
};
|
|
1184
|
+
/**
|
|
1185
|
+
* Explicitly evaluates opt-in `=MJ.AI(...)` cells across `workbook` (`§ 5.2b`).
|
|
1186
|
+
* Enforces a hard batch cap of 50 cells per invocation and skips cells whose `AiInputHash`
|
|
1187
|
+
* already matches (unless `ForceRefresh: true`). Never invoked automatically on open/recalc.
|
|
1188
|
+
*/
|
|
1189
|
+
EvaluateAiFormulas(workbook: WorkbookSpec, contextUser: UserInfo, provider?: IMetadataProvider, options?: SpreadsheetAiEvaluationOptions): Promise<SpreadsheetAiEvaluationResult>;
|
|
1190
|
+
private applyMjFunctionResultToSheet;
|
|
1191
|
+
private toCellScalar;
|
|
1192
|
+
/**
|
|
1193
|
+
* Refreshes all `LiveTables` across `workbook` under `contextUser`'s permissions (`§ 6.3`, `Accept #2`),
|
|
1194
|
+
* expanding rows, filling down `CalculatedColumns` formulas, and recalculating the workbook.
|
|
1195
|
+
*/
|
|
1196
|
+
RefreshLiveTables(workbook: WorkbookSpec, contextUser: UserInfo, provider?: IMetadataProvider, options?: {
|
|
1197
|
+
TableID?: string;
|
|
1198
|
+
ForceRefreshFrozen?: boolean;
|
|
1199
|
+
}): Promise<Record<string, DocumentBlockExecutionResult>>;
|
|
1200
|
+
private clearPreviousLiveTableCells;
|
|
1201
|
+
private clearLiveTableCellsOnAccessDenied;
|
|
1202
|
+
private populateSheetCellsFromLiveTable;
|
|
1203
|
+
/**
|
|
1204
|
+
* Explicitly freezes a live table into a static snapshot (`O5`, `B7`, `C2`), requiring
|
|
1205
|
+
* `acknowledgeSecurityWarning === true` because frozen rows become visible to all readers.
|
|
1206
|
+
* Supports an optional `preSignedSnapshot` from browser callers that sign via `DocumentCollaborationService.FreezeLiveBlock`.
|
|
1207
|
+
*/
|
|
1208
|
+
FreezeLiveTable(workbook: WorkbookSpec, sheetIdOrName: string, tableId: string, executionResult: DocumentBlockExecutionResult, freezingUser: Pick<UserInfo, 'ID' | 'Name'>, acknowledgeSecurityWarning: boolean, preSignedSnapshot?: DocumentFrozenSnapshot, hostArtifactId?: string | null, recalculate?: boolean): SpreadsheetLiveTableSpec;
|
|
1209
|
+
/**
|
|
1210
|
+
* Unfreezes a frozen table back to `'Live'` viewer-scoped mode.
|
|
1211
|
+
*/
|
|
1212
|
+
UnfreezeLiveTable(workbook: WorkbookSpec, sheetIdOrName: string, tableId: string, recalculate?: boolean): SpreadsheetLiveTableSpec;
|
|
1213
|
+
/**
|
|
1214
|
+
* Extracts a live {@link SpreadsheetChartDataset} from a chart spec (or ad-hoc range) on `workbook`.
|
|
1215
|
+
* Always evaluates the workbook first so formula cells in the chart range reflect latest values (`Accept #5`).
|
|
1216
|
+
*/
|
|
1217
|
+
/**
|
|
1218
|
+
* Reads one or more comma-separated A1 ranges (supporting optional `'SheetName'!` prefixes)
|
|
1219
|
+
* into a single aligned 2D cell grid for chart dataset extraction.
|
|
1220
|
+
*/
|
|
1221
|
+
private readChartSourceGrid;
|
|
1222
|
+
/**
|
|
1223
|
+
* Transposes a 2D cell grid for row-oriented chart extraction (`SeriesOrientation === 'rows'`).
|
|
1224
|
+
*/
|
|
1225
|
+
private transposeChartGrid;
|
|
1226
|
+
ExtractChartDataset(workbook: WorkbookSpec, sheetIdOrName: string, chartIdOrRange: string, overrideSpec?: Partial<SpreadsheetChartSpec>, options?: {
|
|
1227
|
+
SkipEvaluate?: boolean;
|
|
1228
|
+
}): SpreadsheetChartDataset | null;
|
|
1229
|
+
/**
|
|
1230
|
+
* Sorts the data rows of `sheetIdOrName` in-place by `sortSpec.ColumnLetter` while preserving
|
|
1231
|
+
* each row's stable `RowID` so formulas referencing those rows update cleanly (`§ 6.2`, `§ 6.3`).
|
|
1232
|
+
*/
|
|
1233
|
+
SortWorksheet(workbook: WorkbookSpec, sheetIdOrName: string, sortSpec: SpreadsheetSortSpec, editContext?: SpreadsheetCellEditContext, recalculate?: boolean): void;
|
|
1234
|
+
/**
|
|
1235
|
+
* Applies `sheet.FilterSpecs` to mark non-matching data rows as `Hidden = true` (`§ 6.3`).
|
|
1236
|
+
*/
|
|
1237
|
+
ApplyWorksheetFilters(workbook: WorkbookSpec, sheetIdOrName: string): void;
|
|
1238
|
+
/**
|
|
1239
|
+
* Imports a CSV string into a single-tab {@link WorkbookSpec}, inferring numeric/boolean values.
|
|
1240
|
+
* By default (`AllowFormulas: false`), leading `=...` strings are imported safely as literal text
|
|
1241
|
+
* to prevent CSV formula injection (`P1-6`); pass `{ AllowFormulas: true }` when formula promotion is desired.
|
|
1242
|
+
*/
|
|
1243
|
+
ImportFromCsv(csvText: string, sheetName?: string, workbookTitle?: string, options?: {
|
|
1244
|
+
AllowFormulas?: boolean;
|
|
1245
|
+
SkipEvaluate?: boolean;
|
|
1246
|
+
}): WorkbookSpec;
|
|
1247
|
+
/**
|
|
1248
|
+
* Exports a worksheet of `workbook` to RFC 4180 CSV format (using computed values).
|
|
1249
|
+
* By default, strips viewer-scoped live table/spill/`=MJ.*` values (`IncludeViewerScopedValues: false`)
|
|
1250
|
+
* and neutralizes formula-injection prefixes (`=`, `+`, `-`, `@`, `\t`, `\r`) on string cells (`NeutralizeFormulas: true`).
|
|
1251
|
+
*/
|
|
1252
|
+
ExportToCsv(workbook: WorkbookSpec, sheetIdOrName?: string, options?: {
|
|
1253
|
+
IncludeViewerScopedValues?: boolean;
|
|
1254
|
+
NeutralizeFormulas?: boolean;
|
|
1255
|
+
}): string;
|
|
1256
|
+
private parseCsvRows;
|
|
1257
|
+
private coerceCsvScalar;
|
|
1258
|
+
/**
|
|
1259
|
+
* Exports `workbook` to a standards-compliant OpenXML `.xlsx` binary (`Uint8Array`)
|
|
1260
|
+
* that opens cleanly in Microsoft Excel, Apple Numbers, LibreOffice, and `exceljs` (`Accept #4`).
|
|
1261
|
+
*
|
|
1262
|
+
* Preserves:
|
|
1263
|
+
* - Multiple worksheet tabs
|
|
1264
|
+
* - Cell values (`n`, `b`, `inlineStr`, `str`)
|
|
1265
|
+
* - Standard Excel formulas (`<f>SUM(B2:B9)</f>`) with pre-evaluated `<v>` results
|
|
1266
|
+
* (while freezing `=MJ.QUERY`/`=MJ.VIEW` cells to their computed scalar values so Excel never shows `#NAME?`)
|
|
1267
|
+
* - Number formats (`numFmt`: currency `$#,##0.00`, percent `0.0%`, integer `#,##0`, date `yyyy-mm-dd`)
|
|
1268
|
+
* - Bold styles and custom column widths (`<col min="..." max="..." width="..." customWidth="1"/>`)
|
|
1269
|
+
* - Frozen panes (`<pane ySplit="..." xSplit="..." state="frozen"/>`)
|
|
1270
|
+
* - Hidden `_mj_sheets_meta` worksheet holding the chunked `WorkbookSpec` JSON for lossless round-tripping
|
|
1271
|
+
*/
|
|
1272
|
+
ExportToXlsxBytes(workbook: WorkbookSpec, includeMjMetadataSheet?: boolean, options?: {
|
|
1273
|
+
SkipEvaluate?: boolean;
|
|
1274
|
+
}): Uint8Array;
|
|
1275
|
+
/**
|
|
1276
|
+
* Patches an existing `.xlsx` archive (`originalBytes`) in-place with updated cell values and formulas
|
|
1277
|
+
* from `workbook`, preserving all non-cell ZIP entries (drawings, charts, styles, comments, relationships)
|
|
1278
|
+
* and all non-`<sheetData>` worksheet XML elements (`<mergeCells>`, `<hyperlinks>`, `<dataValidations>`,
|
|
1279
|
+
* `<conditionalFormatting>`, `<drawing>`, `<legacyDrawing>`, etc.).
|
|
1280
|
+
*/
|
|
1281
|
+
PatchXlsxBytes(originalBytes: Uint8Array | ArrayBuffer, workbook: WorkbookSpec): Uint8Array;
|
|
1282
|
+
private resolveOrEnsureXldaprMetadataXml;
|
|
1283
|
+
private patchSingleWorksheetXml;
|
|
1284
|
+
/**
|
|
1285
|
+
* Imports an OpenXML `.xlsx` binary (`Uint8Array` or `ArrayBuffer`) into a {@link WorkbookSpec},
|
|
1286
|
+
* preserving worksheets, cell values, formulas (`<f>`), number/currency/percent/date formats (`numFmt`),
|
|
1287
|
+
* column widths, frozen panes, and any MJ metadata (`_mj_sheets_meta` or `configuration`) (`Accept #4`).
|
|
1288
|
+
*/
|
|
1289
|
+
ImportFromXlsxBytes(bytes: Uint8Array | ArrayBuffer, configurationJson?: string | null, options?: {
|
|
1290
|
+
SkipEvaluate?: boolean;
|
|
1291
|
+
}): WorkbookSpec;
|
|
1292
|
+
private buildWorksheetXml;
|
|
1293
|
+
private buildHiddenMetadataSheetXml;
|
|
1294
|
+
/**
|
|
1295
|
+
* Linear O(N) XML element body scanner (`<tag ...>body</tag>`) that avoids polynomial regex backtracking on untrusted OOXML.
|
|
1296
|
+
*/
|
|
1297
|
+
private extractXmlElementBodies;
|
|
1298
|
+
private extractFirstXmlElementBody;
|
|
1299
|
+
private extractMetadataFromHiddenSheetXml;
|
|
1300
|
+
private parseWorksheetXml;
|
|
1301
|
+
private parseStylesXml;
|
|
1302
|
+
private buildContentTypesXml;
|
|
1303
|
+
private buildSpreadsheetDrawingMlChartXml;
|
|
1304
|
+
private buildCellMetadataXml;
|
|
1305
|
+
private buildRootRelsXml;
|
|
1306
|
+
private buildWorkbookXml;
|
|
1307
|
+
private buildWorkbookRelsXml;
|
|
1308
|
+
private buildStylesXml;
|
|
1309
|
+
private escapeXml;
|
|
1310
|
+
private unescapeXml;
|
|
1311
|
+
private extractXmlAttr;
|
|
1312
|
+
private encodeUtf8;
|
|
1313
|
+
private decodeUtf8;
|
|
1314
|
+
private decodeBase64OrDataUrl;
|
|
1315
|
+
BuildZipArchive(entries: Array<{
|
|
1316
|
+
Name: string;
|
|
1317
|
+
Data: Uint8Array;
|
|
1318
|
+
}>): Uint8Array;
|
|
1319
|
+
ExtractZipArchive(zipBytes: Uint8Array): Map<string, Uint8Array>;
|
|
1320
|
+
private buildZipArchive;
|
|
1321
|
+
/**
|
|
1322
|
+
* Pure-TypeScript RFC 1951 raw DEFLATE compressor using LZ77 + fixed Huffman codes (`BTYPE=01`).
|
|
1323
|
+
* Isomorphic (runs in both Node and browser without external dependencies) and produces compact
|
|
1324
|
+
* ZIP entries that round-trip losslessly with `inflateRawDeflate`, `zlib.inflateRawSync`, and Excel.
|
|
1325
|
+
*/
|
|
1326
|
+
private deflateRawFixedHuffman;
|
|
1327
|
+
private extractZipArchive;
|
|
1328
|
+
/**
|
|
1329
|
+
* Bounded, browser-clean pure-TypeScript RFC 1951 raw DEFLATE decompressor (`B6`).
|
|
1330
|
+
* Throws immediately on truncated bitstreams, oversubscribed/invalid Huffman codes,
|
|
1331
|
+
* invalid lookback distances, or decompression bombs exceeding `maxEntryBytes`.
|
|
1332
|
+
*/
|
|
1333
|
+
private inflateRawDeflate;
|
|
1334
|
+
private crc32;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* OpenXML `.xlsx` import/export and in-place patching adapter backed by {@link SpreadsheetEngine}.
|
|
1338
|
+
*/
|
|
1339
|
+
export declare class XlsxOpenXmlAdapter extends BaseSingleton<XlsxOpenXmlAdapter> {
|
|
1340
|
+
protected constructor();
|
|
1341
|
+
static get Instance(): XlsxOpenXmlAdapter;
|
|
1342
|
+
ExportXlsx(workbook: WorkbookSpec, includeMjMetadataSheet?: boolean): Uint8Array;
|
|
1343
|
+
ImportXlsx(bytes: Uint8Array | ArrayBuffer, configurationJson?: string | null, options?: {
|
|
1344
|
+
SkipEvaluate?: boolean;
|
|
1345
|
+
}): WorkbookSpec;
|
|
1346
|
+
ImportXlsxIsolated(bytes: Uint8Array | ArrayBuffer, configurationJson?: string | null, options?: {
|
|
1347
|
+
SkipEvaluate?: boolean;
|
|
1348
|
+
}): Promise<WorkbookSpec>;
|
|
1349
|
+
PatchXlsxBytes(originalBytes: Uint8Array | ArrayBuffer, workbook: WorkbookSpec): Uint8Array;
|
|
1350
|
+
PatchXlsxBytesIsolated(originalBytes: Uint8Array | ArrayBuffer, workbook: WorkbookSpec): Promise<Uint8Array>;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Validates a structured `=MJ.VIEW` filter expression, allowing column names like `[User] = 'bob'`,
|
|
1354
|
+
* `APP_NAME = 'Portal'`, `DB_NAME = 'Prod'`, bracketed column identifiers `[First Name] = 'Ada'`,
|
|
1355
|
+
* and Unicode string literals `Name = N'Renée'` while blocking SQL function-call syntax
|
|
1356
|
+
* (`USER_NAME()`, `APP_NAME()`), unbracketed niladic session tokens (`USER`, `SYSTEM_USER`, `CURRENT_USER`, `SESSION_USER`),
|
|
1357
|
+
* `@@` global variables, comments, semicolons, and DDL/DML keywords (`R7-9`, `R8-5`).
|
|
1358
|
+
*/
|
|
1359
|
+
export declare function ValidateExtraFilter(extraFilter: string): {
|
|
1360
|
+
Valid: boolean;
|
|
1361
|
+
NormalizedFilter?: string;
|
|
1362
|
+
AccessDenied?: boolean;
|
|
1363
|
+
ErrorMessage?: string;
|
|
1364
|
+
};
|
|
1365
|
+
/**
|
|
1366
|
+
* Registers the {@link SpreadsheetEngine} chart/range dataset extractor with
|
|
1367
|
+
* {@link DocumentLiveBlockEngine} (`D5`, breaking circular module imports).
|
|
1368
|
+
*/
|
|
1369
|
+
export declare function LoadSpreadsheetEngine(): void;
|
|
1370
|
+
//# sourceMappingURL=SpreadsheetEngine.d.ts.map
|