@tita-agent/dsh-data-table 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +172 -2
- package/cordis.patch.yml +7 -0
- package/lib/client.js +16766 -0
- package/lib/contract-envelope.d.ts +91 -0
- package/lib/contract-envelope.js +106 -0
- package/lib/contract-layout.d.ts +130 -0
- package/lib/contract-layout.js +138 -0
- package/lib/contract-refs.d.ts +39 -0
- package/lib/contract-refs.js +9 -0
- package/lib/contract-version.d.ts +311 -0
- package/lib/contract-version.js +270 -0
- package/lib/contract-wire.d.ts +147 -0
- package/lib/contract-wire.js +99 -0
- package/lib/contracts.d.ts +12 -0
- package/lib/contracts.js +12 -0
- package/lib/types/audit.d.ts +42 -0
- package/lib/types/audit.js +39 -0
- package/lib/types/client/ProjectImportMenu.d.ts +30 -0
- package/lib/types/client/ProjectImportMenu.js +70 -0
- package/lib/types/client/SheetPanel.d.ts +33 -0
- package/lib/types/client/SheetPanel.js +1766 -0
- package/lib/types/client/SheetToggle.d.ts +18 -0
- package/lib/types/client/SheetToggle.js +26 -0
- package/lib/types/client/index.d.ts +15 -0
- package/lib/types/client/index.js +110 -0
- package/lib/types/client/persistence/changes.d.ts +15 -0
- package/lib/types/client/persistence/changes.js +51 -0
- package/lib/types/client/persistence/ids.d.ts +34 -0
- package/lib/types/client/persistence/ids.js +48 -0
- package/lib/types/client/persistence/merge.d.ts +35 -0
- package/lib/types/client/persistence/merge.js +362 -0
- package/lib/types/client/store.d.ts +61 -0
- package/lib/types/client/store.js +152 -0
- package/lib/types/client/surface-context.d.ts +27 -0
- package/lib/types/client/surface-context.js +104 -0
- package/lib/types/client/surface-control.d.ts +2 -0
- package/lib/types/client/surface-control.js +12 -0
- package/lib/types/client/transport/workbookApi.d.ts +159 -0
- package/lib/types/client/transport/workbookApi.js +246 -0
- package/lib/types/client/univer/StandaloneWorkbookPage.d.ts +5 -0
- package/lib/types/client/univer/StandaloneWorkbookPage.js +7 -0
- package/lib/types/client/univer/WorkbookCanvas.d.ts +40 -0
- package/lib/types/client/univer/WorkbookCanvas.js +87 -0
- package/lib/types/client/univer/WorkbookView.d.ts +3 -0
- package/lib/types/client/univer/WorkbookView.js +2 -0
- package/lib/types/client/univer/loader.d.ts +18 -0
- package/lib/types/client/univer/loader.js +81 -0
- package/lib/types/client/univer/standalone-entry.d.ts +1 -0
- package/lib/types/client/univer/standalone-entry.js +19 -0
- package/lib/types/client/versions/VersionChrome.d.ts +33 -0
- package/lib/types/client/versions/VersionChrome.js +21 -0
- package/lib/types/client/versions/inspect.d.ts +70 -0
- package/lib/types/client/versions/inspect.js +88 -0
- package/lib/types/client/versions/preview-decoration.d.ts +11 -0
- package/lib/types/client/versions/preview-decoration.js +54 -0
- package/lib/types/client/versions/records.d.ts +19 -0
- package/lib/types/client/versions/records.js +70 -0
- package/lib/types/client/workspace-host.d.ts +61 -0
- package/lib/types/client/workspace-host.js +124 -0
- package/lib/types/collaboration-hub.d.ts +31 -0
- package/lib/types/collaboration-hub.js +69 -0
- package/lib/types/contract/ids.d.ts +24 -0
- package/lib/types/contract/ids.js +46 -0
- package/lib/types/contract/mutations.d.ts +25 -0
- package/lib/types/contract/mutations.js +782 -0
- package/lib/types/contract/operations.d.ts +54 -0
- package/lib/types/contract/operations.js +203 -0
- package/lib/types/contract/snapshots.d.ts +176 -0
- package/lib/types/contract/snapshots.js +351 -0
- package/lib/types/contract/univer-api-catalog.d.ts +29 -0
- package/lib/types/contract/univer-api-catalog.js +264 -0
- package/lib/types/errors.d.ts +8 -0
- package/lib/types/errors.js +12 -0
- package/lib/types/http/assets-routes.d.ts +3 -0
- package/lib/types/http/assets-routes.js +169 -0
- package/lib/types/http/collaboration.d.ts +10 -0
- package/lib/types/http/collaboration.js +154 -0
- package/lib/types/http/history.d.ts +15 -0
- package/lib/types/http/history.js +134 -0
- package/lib/types/http/project-files.d.ts +79 -0
- package/lib/types/http/project-files.js +206 -0
- package/lib/types/http/project-scope.d.ts +50 -0
- package/lib/types/http/project-scope.js +52 -0
- package/lib/types/http/routes.d.ts +98 -0
- package/lib/types/http/routes.js +323 -0
- package/lib/types/http/standalone.d.ts +9 -0
- package/lib/types/http/standalone.js +31 -0
- package/lib/types/http/trunk.d.ts +10 -0
- package/lib/types/http/trunk.js +322 -0
- package/lib/types/http/worktree.d.ts +9 -0
- package/lib/types/http/worktree.js +145 -0
- package/lib/types/index.d.ts +18 -0
- package/lib/types/index.js +156 -0
- package/lib/types/invariant.d.ts +15 -0
- package/lib/types/invariant.js +15 -0
- package/lib/types/request-params.d.ts +21 -0
- package/lib/types/request-params.js +76 -0
- package/lib/types/store/paths.d.ts +68 -0
- package/lib/types/store/paths.js +148 -0
- package/lib/types/store/project.d.ts +88 -0
- package/lib/types/store/project.js +120 -0
- package/lib/types/store/read.d.ts +110 -0
- package/lib/types/store/read.js +404 -0
- package/lib/types/store/retention.d.ts +27 -0
- package/lib/types/store/retention.js +111 -0
- package/lib/types/store/write.d.ts +22 -0
- package/lib/types/store/write.js +210 -0
- package/lib/types/tools/arguments.d.ts +40 -0
- package/lib/types/tools/arguments.js +130 -0
- package/lib/types/tools/cells.d.ts +50 -0
- package/lib/types/tools/cells.js +298 -0
- package/lib/types/tools/index.d.ts +2 -0
- package/lib/types/tools/index.js +250 -0
- package/lib/types/tools/render.d.ts +47 -0
- package/lib/types/tools/render.js +290 -0
- package/lib/types/tools/univer-api.d.ts +18 -0
- package/lib/types/tools/univer-api.js +198 -0
- package/lib/types/tools/workbook-catalog.d.ts +3 -0
- package/lib/types/tools/workbook-catalog.js +83 -0
- package/lib/types/tools/workbook-edit.d.ts +192 -0
- package/lib/types/tools/workbook-edit.js +912 -0
- package/lib/types/tools/workbook-find.d.ts +11 -0
- package/lib/types/tools/workbook-find.js +89 -0
- package/lib/types/tools/workbook-history.d.ts +2 -0
- package/lib/types/tools/workbook-history.js +59 -0
- package/lib/types/tools/workbook-read.d.ts +21 -0
- package/lib/types/tools/workbook-read.js +204 -0
- package/lib/types/types.d.ts +377 -0
- package/lib/types/types.js +34 -0
- package/lib/types/univer/apply-operation.d.ts +14 -0
- package/lib/types/univer/apply-operation.js +398 -0
- package/lib/types/univer/chunk.d.ts +68 -0
- package/lib/types/univer/chunk.js +16 -0
- package/lib/types/univer/decoration.d.ts +34 -0
- package/lib/types/univer/decoration.js +88 -0
- package/lib/types/univer/diagnostics.d.ts +31 -0
- package/lib/types/univer/diagnostics.js +141 -0
- package/lib/types/univer/engine.d.ts +33 -0
- package/lib/types/univer/engine.js +338 -0
- package/lib/types/univer/entry.d.ts +8 -0
- package/lib/types/univer/entry.js +11 -0
- package/lib/types/univer/facade.d.ts +107 -0
- package/lib/types/univer/facade.js +1 -0
- package/lib/types/univer/fonts.d.ts +202 -0
- package/lib/types/univer/fonts.js +140 -0
- package/lib/types/univer/plugins/collaboration.d.ts +23 -0
- package/lib/types/univer/plugins/collaboration.js +47 -0
- package/lib/types/univer/plugins/export.d.ts +39 -0
- package/lib/types/univer/plugins/export.js +246 -0
- package/lib/types/univer/plugins/history.d.ts +24 -0
- package/lib/types/univer/plugins/history.js +50 -0
- package/lib/types/univer/plugins/version.d.ts +13 -0
- package/lib/types/univer/plugins/version.js +13 -0
- package/lib/types/version/diff.d.ts +36 -0
- package/lib/types/version/diff.js +156 -0
- package/lib/types/version/grouping.d.ts +7 -0
- package/lib/types/version/grouping.js +94 -0
- package/lib/types/version/records.d.ts +17 -0
- package/lib/types/version/records.js +102 -0
- package/lib/types/version/session.d.ts +36 -0
- package/lib/types/version/session.js +89 -0
- package/lib/types/version/summary.d.ts +24 -0
- package/lib/types/version/summary.js +111 -0
- package/lib/types/workbook-manager.d.ts +191 -0
- package/lib/types/workbook-manager.js +935 -0
- package/lib/types/xlsx-export-worker.d.ts +5 -0
- package/lib/types/xlsx-export-worker.js +24 -0
- package/lib/types/xlsx-export.d.ts +21 -0
- package/lib/types/xlsx-export.js +371 -0
- package/lib/types/xlsx-import-worker.d.ts +1 -0
- package/lib/types/xlsx-import-worker.js +19 -0
- package/lib/univer-client.js +690 -0
- package/lib/workbook-page.js +23826 -0
- package/lib/xlsx-export-worker.js +104 -0
- package/lib/xlsx-import-worker.js +46 -0
- package/package.json +106 -3
- package/src/audit.ts +58 -0
- package/src/client/ProjectImportMenu.tsx +100 -0
- package/src/client/SheetPanel.module.css +1578 -0
- package/src/client/SheetPanel.tsx +1934 -0
- package/src/client/SheetToggle.module.css +73 -0
- package/src/client/SheetToggle.tsx +65 -0
- package/src/client/contract.d.ts +19 -0
- package/src/client/index.ts +131 -0
- package/src/client/persistence/changes.ts +58 -0
- package/src/client/persistence/ids.ts +60 -0
- package/src/client/persistence/merge.ts +392 -0
- package/src/client/store.ts +188 -0
- package/src/client/surface-context.ts +123 -0
- package/src/client/surface-control.ts +13 -0
- package/src/client/transport/workbookApi.ts +355 -0
- package/src/client/univer/SheetView.module.css +110 -0
- package/src/client/univer/StandaloneWorkbookPage.module.css +8 -0
- package/src/client/univer/StandaloneWorkbookPage.tsx +15 -0
- package/src/client/univer/WorkbookCanvas.tsx +128 -0
- package/src/client/univer/WorkbookView.module.css +30 -0
- package/src/client/univer/WorkbookView.tsx +3 -0
- package/src/client/univer/loader.ts +90 -0
- package/src/client/univer/react-dom-client.d.ts +10 -0
- package/src/client/univer/standalone-entry.tsx +19 -0
- package/src/client/univer/standalone.css +12 -0
- package/src/client/univer/univer-locales.d.ts +89 -0
- package/src/client/univer/univer-modules.d.ts +26 -0
- package/src/client/versions/VersionChrome.tsx +114 -0
- package/src/client/versions/inspect.ts +138 -0
- package/src/client/versions/preview-decoration.ts +54 -0
- package/src/client/versions/records.ts +78 -0
- package/src/client/workspace-host.ts +147 -0
- package/src/collaboration-hub.ts +83 -0
- package/src/contract/ids.ts +50 -0
- package/src/contract/mutations.ts +791 -0
- package/src/contract/operations.ts +221 -0
- package/src/contract/snapshots.ts +383 -0
- package/src/contract/univer-api-catalog.ts +289 -0
- package/src/css-modules.d.ts +6 -0
- package/src/errors.ts +25 -0
- package/src/http/assets-routes.ts +177 -0
- package/src/http/collaboration.ts +144 -0
- package/src/http/history.ts +151 -0
- package/src/http/project-files.ts +227 -0
- package/src/http/project-scope.ts +77 -0
- package/src/http/routes.ts +364 -0
- package/src/http/standalone.ts +32 -0
- package/src/http/trunk.ts +322 -0
- package/src/http/worktree.ts +119 -0
- package/src/index.ts +165 -0
- package/src/invariant.ts +17 -0
- package/src/request-params.ts +92 -0
- package/src/store/paths.ts +165 -0
- package/src/store/project.ts +137 -0
- package/src/store/read.ts +454 -0
- package/src/store/retention.ts +106 -0
- package/src/store/write.ts +230 -0
- package/src/tools/arguments.ts +128 -0
- package/src/tools/cells.ts +298 -0
- package/src/tools/index.ts +274 -0
- package/src/tools/render.ts +301 -0
- package/src/tools/univer-api.ts +243 -0
- package/src/tools/workbook-catalog.ts +94 -0
- package/src/tools/workbook-edit.ts +987 -0
- package/src/tools/workbook-find.ts +80 -0
- package/src/tools/workbook-history.ts +63 -0
- package/src/tools/workbook-read.ts +210 -0
- package/src/types.ts +432 -0
- package/src/univer/apply-operation.ts +369 -0
- package/src/univer/chunk.ts +77 -0
- package/src/univer/decoration.ts +111 -0
- package/src/univer/diagnostics.ts +136 -0
- package/src/univer/engine.ts +370 -0
- package/src/univer/entry.ts +14 -0
- package/src/univer/facade.ts +91 -0
- package/src/univer/fonts.ts +148 -0
- package/src/univer/overrides.css +33 -0
- package/src/univer/plugins/collaboration.ts +47 -0
- package/src/univer/plugins/export.ts +236 -0
- package/src/univer/plugins/history.ts +49 -0
- package/src/univer/plugins/version.ts +13 -0
- package/src/version/diff.ts +169 -0
- package/src/version/grouping.ts +96 -0
- package/src/version/records.ts +113 -0
- package/src/version/session.ts +90 -0
- package/src/version/summary.ts +117 -0
- package/src/workbook-manager.ts +1111 -0
- package/src/xlsx-export-worker.ts +34 -0
- package/src/xlsx-export.ts +373 -0
- package/src/xlsx-import-worker.ts +30 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contracts for dsh-data-table: sheet data (agent ↔ renderer)
|
|
3
|
+
* and the workbook model (agent tools ↔ node half ↔ browser canvas).
|
|
4
|
+
* @module dsh-data-table/types
|
|
5
|
+
*/
|
|
6
|
+
import type { LineageContext } from '#contracts';
|
|
7
|
+
import type { VersionKind } from '#contracts';
|
|
8
|
+
export type SheetColumnType = 'string' | 'number' | 'boolean' | 'date' | 'currency';
|
|
9
|
+
export interface SheetColumn {
|
|
10
|
+
/** Unique key (English identifier, mirrors the row field). */
|
|
11
|
+
key: string;
|
|
12
|
+
/** Header label (Chinese copy is fine). */
|
|
13
|
+
label: string;
|
|
14
|
+
type: SheetColumnType;
|
|
15
|
+
}
|
|
16
|
+
export interface SheetMeta {
|
|
17
|
+
/** Data source description (e.g. SQL / file path). */
|
|
18
|
+
source?: string;
|
|
19
|
+
/** Generating SQL — data lineage. */
|
|
20
|
+
query?: string;
|
|
21
|
+
/** ISO timestamp. */
|
|
22
|
+
generatedAt?: string;
|
|
23
|
+
/** User-facing notes. */
|
|
24
|
+
notes?: string;
|
|
25
|
+
lineage?: LineageContext;
|
|
26
|
+
}
|
|
27
|
+
/** Persisted schema for an Agent-managed sheet. */
|
|
28
|
+
export interface SheetSchema {
|
|
29
|
+
version: number;
|
|
30
|
+
columns: SheetColumn[];
|
|
31
|
+
/** Number of data rows, excluding the header row. */
|
|
32
|
+
rowCount: number;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
}
|
|
35
|
+
export interface SheetData {
|
|
36
|
+
/** Sheet name (panel title). */
|
|
37
|
+
name: string;
|
|
38
|
+
columns: SheetColumn[];
|
|
39
|
+
rows: Array<Record<string, unknown>>;
|
|
40
|
+
meta?: SheetMeta;
|
|
41
|
+
}
|
|
42
|
+
/** Row/column caps enforced by the host tool (documented in the tool schema). */
|
|
43
|
+
/** Univer is a UI projection, not an unlimited database. Keep local imports
|
|
44
|
+
* bounded at 100k rows; larger tables should use a columnar backend. */
|
|
45
|
+
export declare const SHEET_MAX_ROWS = 100000;
|
|
46
|
+
/** Keep one large Agent append from monopolizing one Univer mutation frame. */
|
|
47
|
+
export declare const SHEET_MAX_APPEND_ROWS = 1000;
|
|
48
|
+
/** Physical row indexes include the header row at index 0. */
|
|
49
|
+
export declare const SHEET_MAX_PHYSICAL_ROWS: number;
|
|
50
|
+
export declare const SHEET_MAX_COLUMNS = 50;
|
|
51
|
+
export declare const SHEET_MAX_NAME = 64;
|
|
52
|
+
/** Whether a parsed tool-argument value is a well-formed sheet. */
|
|
53
|
+
export declare function isSheetData(value: unknown): value is SheetData;
|
|
54
|
+
/** Default workbook id (backward compatible with pre-workbook writes). */
|
|
55
|
+
export declare const DEFAULT_WORKBOOK = "main";
|
|
56
|
+
/**
|
|
57
|
+
* One named workbook: an Univer-compatible snapshot on disk (the whole state,
|
|
58
|
+
* sheets included). The agent addresses workbooks across sessions by id; the
|
|
59
|
+
* browser mounts a residency instance from the current snapshot.
|
|
60
|
+
*/
|
|
61
|
+
export interface WorkbookMeta {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
/** Sheet ids in display order (Univer snapshot convention). */
|
|
65
|
+
sheetOrder: string[];
|
|
66
|
+
/** ISO timestamp of the last save. */
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
/** Monotonically increasing revision of the workbook. */
|
|
69
|
+
revision?: number;
|
|
70
|
+
/** Revision represented by the persisted snapshot sidecar. */
|
|
71
|
+
snapshotRevision?: number;
|
|
72
|
+
/** Append-only operations used by replay, browser projection and audit UI. */
|
|
73
|
+
operations?: WorkbookOperation[];
|
|
74
|
+
/** Durable agent proposals awaiting user confirmation. */
|
|
75
|
+
proposals?: WorkbookProposal[];
|
|
76
|
+
/** Last known checkpoints used by rollback. */
|
|
77
|
+
checkpoints?: WorkbookCheckpoint[];
|
|
78
|
+
/** Univer workbook snapshot (sheets → cellData etc.). */
|
|
79
|
+
snapshot: unknown;
|
|
80
|
+
}
|
|
81
|
+
export type WorkbookActor = 'agent' | 'user';
|
|
82
|
+
/**
|
|
83
|
+
* Lifecycle of a user-visible Version. `temporary` is retained only so old
|
|
84
|
+
* persisted operation logs can still be read; new writes use `open`.
|
|
85
|
+
*/
|
|
86
|
+
export type WorkbookVersionStatus = 'open' | 'final' | 'restored' | 'superseded' | 'temporary';
|
|
87
|
+
/** Ephemeral collaboration state. Presence is broadcast live but never bumps
|
|
88
|
+
* the workbook revision or enters the durable operation log. */
|
|
89
|
+
export type WorkbookPresenceKind = 'selection' | 'editing' | 'active-sheet';
|
|
90
|
+
export interface WorkbookPresencePayload {
|
|
91
|
+
kind: WorkbookPresenceKind;
|
|
92
|
+
payload: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/** Current Univer range plus a bounded value preview for composer context. */
|
|
95
|
+
export interface WorkbookSelectionRange {
|
|
96
|
+
sheetId: string;
|
|
97
|
+
sheetName: string;
|
|
98
|
+
startRow: number;
|
|
99
|
+
startColumn: number;
|
|
100
|
+
endRow: number;
|
|
101
|
+
endColumn: number;
|
|
102
|
+
values: readonly (readonly unknown[])[];
|
|
103
|
+
}
|
|
104
|
+
/** Coordinates the resident canvas can focus from a bridge reference. */
|
|
105
|
+
export interface WorkbookFocusRange {
|
|
106
|
+
sheetId: string;
|
|
107
|
+
startRow: number;
|
|
108
|
+
startColumn: number;
|
|
109
|
+
endRow: number;
|
|
110
|
+
endColumn: number;
|
|
111
|
+
}
|
|
112
|
+
export interface WorkbookPresence {
|
|
113
|
+
workbookId: string;
|
|
114
|
+
sessionId: string;
|
|
115
|
+
actor: WorkbookActor;
|
|
116
|
+
kind: WorkbookPresenceKind;
|
|
117
|
+
payload: Record<string, unknown>;
|
|
118
|
+
timestamp: string;
|
|
119
|
+
}
|
|
120
|
+
/** Isolated review workspace lifecycle. The trunk workbook is never mutated
|
|
121
|
+
* until a worktree is explicitly merged. */
|
|
122
|
+
export type WorkbookWorktreeStatus = 'draft' | 'ready' | 'merged' | 'discarded';
|
|
123
|
+
export type WorkbookOperationType = 'update_cells' | 'clear_range' | 'delete_cells' | 'insert_rows' | 'delete_rows' | 'insert_columns' | 'delete_columns' | 'create_sheet' | 'delete_sheet' | 'rename_sheet' | 'append_rows' | 'format_cells' | 'merge_cells' | 'unmerge_cells' | 'freeze_panes' | 'set_column_width' | 'set_row_height' | 'sort_range' | 'set_hyperlink' | 'remove_hyperlink'
|
|
124
|
+
/** Legacy-only operation retained so existing persisted histories can replay. */
|
|
125
|
+
| 'remove_duplicates' | 'batch' | 'snapshot_replace';
|
|
126
|
+
/** How a deleted cell range affects neighboring cells. */
|
|
127
|
+
export type WorkbookCellDeleteShift = 'clear' | 'left' | 'up';
|
|
128
|
+
export type WorkbookCellValue = string | number | boolean | null;
|
|
129
|
+
export interface WorkbookCellUpdate {
|
|
130
|
+
row: number;
|
|
131
|
+
column: number;
|
|
132
|
+
value: WorkbookCellValue;
|
|
133
|
+
/** Optional Univer formula, without the leading display-only metadata. */
|
|
134
|
+
formula?: string;
|
|
135
|
+
}
|
|
136
|
+
/** A browser-side edit that can be persisted without serializing the workbook. */
|
|
137
|
+
export interface WorkbookLocalChange {
|
|
138
|
+
type: 'update_cells';
|
|
139
|
+
payload: {
|
|
140
|
+
sheetId: string;
|
|
141
|
+
cells: WorkbookCellUpdate[];
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export interface WorkbookRange {
|
|
145
|
+
startRow: number;
|
|
146
|
+
startColumn: number;
|
|
147
|
+
endRow: number;
|
|
148
|
+
endColumn: number;
|
|
149
|
+
}
|
|
150
|
+
export interface WorkbookOperationPayload {
|
|
151
|
+
sheetId?: string;
|
|
152
|
+
sheetName?: string;
|
|
153
|
+
cells?: WorkbookCellUpdate[];
|
|
154
|
+
range?: WorkbookRange;
|
|
155
|
+
count?: number;
|
|
156
|
+
shift?: WorkbookCellDeleteShift;
|
|
157
|
+
name?: string;
|
|
158
|
+
columns?: SheetColumn[];
|
|
159
|
+
rows?: Array<Record<string, unknown>>;
|
|
160
|
+
/** Source-backed import is normalized to append_rows before persistence. */
|
|
161
|
+
sourcePath?: string;
|
|
162
|
+
sourceFormat?: string;
|
|
163
|
+
meta?: SheetMeta;
|
|
164
|
+
schema?: SheetSchema;
|
|
165
|
+
style?: WorkbookCellStyle;
|
|
166
|
+
merge?: WorkbookRange;
|
|
167
|
+
freeze?: {
|
|
168
|
+
rows?: number;
|
|
169
|
+
columns?: number;
|
|
170
|
+
};
|
|
171
|
+
size?: number;
|
|
172
|
+
sort?: {
|
|
173
|
+
column: number;
|
|
174
|
+
direction?: 'asc' | 'desc';
|
|
175
|
+
};
|
|
176
|
+
/** Hyperlink applied to the top-left cell of the range. */
|
|
177
|
+
url?: string;
|
|
178
|
+
label?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Row that holds the column headers for `append_rows`; data starts on the row
|
|
181
|
+
* below it. Defaults to 0, which is the only behaviour the tool had before the
|
|
182
|
+
* field existed, so an omitted value keeps every existing caller intact.
|
|
183
|
+
* Report sheets keep their title block above the real header row, and this is
|
|
184
|
+
* what lets them be appended to instead of forcing a rewrite through
|
|
185
|
+
* `update_cells`.
|
|
186
|
+
*/
|
|
187
|
+
headerRowIndex?: number;
|
|
188
|
+
/**
|
|
189
|
+
* When false, `append_rows` skips comparing existing header labels against the
|
|
190
|
+
* incoming column labels. Structure still has to be one column per column —
|
|
191
|
+
* this only relaxes the text match. Defaults to true.
|
|
192
|
+
*/
|
|
193
|
+
verifyHeader?: boolean;
|
|
194
|
+
/** Legacy-only remove-duplicates payload fields; no longer exposed as tools/UI. */
|
|
195
|
+
dedupeColumns?: number[];
|
|
196
|
+
hasHeader?: boolean;
|
|
197
|
+
keep?: 'first' | 'last';
|
|
198
|
+
/** Server-computed original row indexes removed by remove_duplicates. */
|
|
199
|
+
removedRows?: number[];
|
|
200
|
+
operations?: Array<{
|
|
201
|
+
type: WorkbookOperationType;
|
|
202
|
+
payload: WorkbookOperationPayload;
|
|
203
|
+
}>;
|
|
204
|
+
snapshot?: unknown;
|
|
205
|
+
}
|
|
206
|
+
/** A small, JSON-safe subset of Univer cell styles used by Agent tools. */
|
|
207
|
+
export interface WorkbookCellStyle {
|
|
208
|
+
ff?: string;
|
|
209
|
+
fs?: number;
|
|
210
|
+
bl?: boolean;
|
|
211
|
+
it?: boolean;
|
|
212
|
+
ul?: boolean;
|
|
213
|
+
st?: boolean;
|
|
214
|
+
bg?: string;
|
|
215
|
+
cl?: string;
|
|
216
|
+
ht?: number;
|
|
217
|
+
vt?: number;
|
|
218
|
+
tr?: number;
|
|
219
|
+
n?: string;
|
|
220
|
+
}
|
|
221
|
+
/** A durable, replayable mutation shared by Agent and user edits. */
|
|
222
|
+
export interface WorkbookOperation {
|
|
223
|
+
opId: string;
|
|
224
|
+
workbookId: string;
|
|
225
|
+
revision: number;
|
|
226
|
+
/** Logical parent version. Normally revision - 1; rollback versions point
|
|
227
|
+
* back to the selected target while retaining their global revision number. */
|
|
228
|
+
parentRevision?: number;
|
|
229
|
+
/** Revision observed by the author before this operation was submitted. */
|
|
230
|
+
baseRevision?: number;
|
|
231
|
+
/** Stable logical Version id. Multiple physical revisions may fill one
|
|
232
|
+
* open user Version until it reaches the ten-step target. */
|
|
233
|
+
versionId?: string;
|
|
234
|
+
/** Open Versions accept additional user steps; final Versions do not. */
|
|
235
|
+
versionStatus?: WorkbookVersionStatus;
|
|
236
|
+
/** User-facing semantic description of this Version, supplied by the Host. */
|
|
237
|
+
versionSummary?: string;
|
|
238
|
+
/**
|
|
239
|
+
* v3 Version tier (PRD §4). Absent on operations written before v3; the
|
|
240
|
+
* projection then derives it from summary/actor, so old logs still classify.
|
|
241
|
+
*/
|
|
242
|
+
versionKind?: VersionKind;
|
|
243
|
+
/** Optional Agent intent retained for audit without changing Step payloads. */
|
|
244
|
+
versionIntent?: string;
|
|
245
|
+
/** Correlates multiple semantic Versions emitted by one Agent run. */
|
|
246
|
+
agentRunId?: string;
|
|
247
|
+
/** Cross-plugin task/subtask/run lineage for this durable mutation. */
|
|
248
|
+
lineage?: LineageContext;
|
|
249
|
+
/** Source revision selected by a restore Version. */
|
|
250
|
+
restoredFromRevision?: number;
|
|
251
|
+
actor: WorkbookActor;
|
|
252
|
+
type: WorkbookOperationType;
|
|
253
|
+
timestamp: string;
|
|
254
|
+
payload: WorkbookOperationPayload;
|
|
255
|
+
/**
|
|
256
|
+
* Derived, human summary of this Step (v3.1). Set by the server when the
|
|
257
|
+
* caller's operation is generic — a whole-snapshot save describes itself as
|
|
258
|
+
* `替换 workbook 快照`, which said nothing about *what* changed.
|
|
259
|
+
*/
|
|
260
|
+
stepSummary?: string;
|
|
261
|
+
/** Stable request digest used to detect accidental opId reuse with new data. */
|
|
262
|
+
requestHash?: string;
|
|
263
|
+
}
|
|
264
|
+
/** One replayable atomic step inside a version. */
|
|
265
|
+
export interface WorkbookHistoryStep {
|
|
266
|
+
index: number;
|
|
267
|
+
opId: string;
|
|
268
|
+
type: WorkbookOperationType;
|
|
269
|
+
summary: string;
|
|
270
|
+
/**
|
|
271
|
+
* The revision this Step left behind — the state *after* it.
|
|
272
|
+
*
|
|
273
|
+
* Optional because a Step built from a history entry that predates the field
|
|
274
|
+
* has no revision of its own; a comparison then falls back to the Version's.
|
|
275
|
+
* Carrying it is what lets a Step be a comparison baseline and not only a
|
|
276
|
+
* thing to look at.
|
|
277
|
+
*/
|
|
278
|
+
revision?: number;
|
|
279
|
+
}
|
|
280
|
+
/** Version-first history entry. Steps are available to the client but can be
|
|
281
|
+
* collapsed in the default history view. */
|
|
282
|
+
export interface WorkbookHistoryVersion {
|
|
283
|
+
versionId: string;
|
|
284
|
+
/** Display number (`V1`, `V2`) assigned in creation order; never reused. */
|
|
285
|
+
number: number;
|
|
286
|
+
startRevision: number;
|
|
287
|
+
revision: number;
|
|
288
|
+
parentRevision: number;
|
|
289
|
+
actor: WorkbookActor;
|
|
290
|
+
timestamp: string;
|
|
291
|
+
summary: string;
|
|
292
|
+
/** v3 tier: `named` for a manual save / Agent call / restore, else `auto`. */
|
|
293
|
+
kind: VersionKind;
|
|
294
|
+
intent?: string;
|
|
295
|
+
agentRunId?: string;
|
|
296
|
+
lineage?: LineageContext;
|
|
297
|
+
restoredFromRevision?: number;
|
|
298
|
+
/** Display number of the Version a restore reinstated (v3 origin label). */
|
|
299
|
+
restoredFromNumber?: number;
|
|
300
|
+
stepCount: number;
|
|
301
|
+
steps: WorkbookHistoryStep[];
|
|
302
|
+
canPreview: boolean;
|
|
303
|
+
status: WorkbookVersionStatus;
|
|
304
|
+
branch: 'main' | 'superseded';
|
|
305
|
+
}
|
|
306
|
+
/** Durable isolated workbook workspace used for reviewable changes. */
|
|
307
|
+
export interface WorkbookWorktree {
|
|
308
|
+
id: string;
|
|
309
|
+
workbookId: string;
|
|
310
|
+
/** Opaque browser/agent session that owns this worktree. */
|
|
311
|
+
ownerSessionId: string;
|
|
312
|
+
name: string;
|
|
313
|
+
baseRevision: number;
|
|
314
|
+
revision: number;
|
|
315
|
+
status: WorkbookWorktreeStatus;
|
|
316
|
+
createdAt: string;
|
|
317
|
+
updatedAt: string;
|
|
318
|
+
snapshot: unknown;
|
|
319
|
+
operations: WorkbookOperation[];
|
|
320
|
+
}
|
|
321
|
+
/** Payload-light worktree entry for catalog and UI lists. */
|
|
322
|
+
export interface WorkbookWorktreeSummary {
|
|
323
|
+
id: string;
|
|
324
|
+
workbookId: string;
|
|
325
|
+
ownerSessionId: string;
|
|
326
|
+
name: string;
|
|
327
|
+
baseRevision: number;
|
|
328
|
+
revision: number;
|
|
329
|
+
status: WorkbookWorktreeStatus;
|
|
330
|
+
createdAt: string;
|
|
331
|
+
updatedAt: string;
|
|
332
|
+
}
|
|
333
|
+
export type WorkbookProposalStatus = 'pending' | 'committed' | 'rejected' | 'expired';
|
|
334
|
+
export interface WorkbookProposal {
|
|
335
|
+
id: string;
|
|
336
|
+
workbookId: string;
|
|
337
|
+
actor: WorkbookActor;
|
|
338
|
+
baseRevision: number;
|
|
339
|
+
createdAt: string;
|
|
340
|
+
updatedAt: string;
|
|
341
|
+
status: WorkbookProposalStatus;
|
|
342
|
+
summary: string;
|
|
343
|
+
changes: WorkbookChange[];
|
|
344
|
+
snapshot: unknown;
|
|
345
|
+
committedRevision?: number;
|
|
346
|
+
}
|
|
347
|
+
export interface WorkbookChange {
|
|
348
|
+
kind: 'cell' | 'sheet' | 'structure';
|
|
349
|
+
sheetId?: string;
|
|
350
|
+
sheetName?: string;
|
|
351
|
+
row?: number;
|
|
352
|
+
column?: number;
|
|
353
|
+
before?: unknown;
|
|
354
|
+
after?: unknown;
|
|
355
|
+
/** The value is unchanged on both sides; only the cell's formatting moved. */
|
|
356
|
+
styleOnly?: boolean;
|
|
357
|
+
description?: string;
|
|
358
|
+
}
|
|
359
|
+
export interface WorkbookCheckpoint {
|
|
360
|
+
revision: number;
|
|
361
|
+
actor: WorkbookActor;
|
|
362
|
+
timestamp: string;
|
|
363
|
+
snapshot: unknown;
|
|
364
|
+
}
|
|
365
|
+
/** Tool result for workbook listing/open. */
|
|
366
|
+
export interface WorkbookSummary {
|
|
367
|
+
id: string;
|
|
368
|
+
name: string;
|
|
369
|
+
sheets: Array<{
|
|
370
|
+
id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
schema?: SheetSchema;
|
|
373
|
+
}>;
|
|
374
|
+
updatedAt: string;
|
|
375
|
+
/** Current trunk revision; lets `workbook_catalog(action=list)` feed `baseRevision` without a second read. */
|
|
376
|
+
revision?: number;
|
|
377
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contracts for dsh-data-table: sheet data (agent ↔ renderer)
|
|
3
|
+
* and the workbook model (agent tools ↔ node half ↔ browser canvas).
|
|
4
|
+
* @module dsh-data-table/types
|
|
5
|
+
*/
|
|
6
|
+
/** Row/column caps enforced by the host tool (documented in the tool schema). */
|
|
7
|
+
/** Univer is a UI projection, not an unlimited database. Keep local imports
|
|
8
|
+
* bounded at 100k rows; larger tables should use a columnar backend. */
|
|
9
|
+
export const SHEET_MAX_ROWS = 100000;
|
|
10
|
+
/** Keep one large Agent append from monopolizing one Univer mutation frame. */
|
|
11
|
+
export const SHEET_MAX_APPEND_ROWS = 1000;
|
|
12
|
+
/** Physical row indexes include the header row at index 0. */
|
|
13
|
+
export const SHEET_MAX_PHYSICAL_ROWS = SHEET_MAX_ROWS + 1;
|
|
14
|
+
export const SHEET_MAX_COLUMNS = 50;
|
|
15
|
+
export const SHEET_MAX_NAME = 64;
|
|
16
|
+
/** Whether a parsed tool-argument value is a well-formed sheet. */
|
|
17
|
+
export function isSheetData(value) {
|
|
18
|
+
if (typeof value !== 'object' || value === null)
|
|
19
|
+
return false;
|
|
20
|
+
const sheet = value;
|
|
21
|
+
if (typeof sheet.name !== 'string' || sheet.name.length === 0)
|
|
22
|
+
return false;
|
|
23
|
+
if (!Array.isArray(sheet.columns) || !Array.isArray(sheet.rows))
|
|
24
|
+
return false;
|
|
25
|
+
return sheet.columns.every(column => {
|
|
26
|
+
if (typeof column !== 'object' || column === null)
|
|
27
|
+
return false;
|
|
28
|
+
const c = column;
|
|
29
|
+
return typeof c.key === 'string' && typeof c.label === 'string'
|
|
30
|
+
&& (c.type === 'string' || c.type === 'number' || c.type === 'boolean' || c.type === 'date' || c.type === 'currency');
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Default workbook id (backward compatible with pre-workbook writes). */
|
|
34
|
+
export const DEFAULT_WORKBOOK = 'main';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WorkbookOperation } from '../types.ts';
|
|
2
|
+
import type { SheetsApi, SheetResolver } from './facade.ts';
|
|
3
|
+
/** Default sheet extent (Univer's own default), so data lands on a full-size grid. */
|
|
4
|
+
export interface OperationApplier {
|
|
5
|
+
apply(operation: WorkbookOperation): Promise<void>;
|
|
6
|
+
/** True while an operation from elsewhere is being written to the canvas. */
|
|
7
|
+
isApplyingRemote(): boolean;
|
|
8
|
+
/** Sheet metadata that only exists in the live canvas (not in the snapshot). */
|
|
9
|
+
liveSheetMetadata: Map<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createOperationApplier(deps: {
|
|
12
|
+
sheetsApi: SheetsApi;
|
|
13
|
+
getSheet: SheetResolver;
|
|
14
|
+
}): OperationApplier;
|