@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
package/package.json
CHANGED
|
@@ -1,6 +1,109 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tita-agent/dsh-data-table",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Univer spreadsheet terminal (Table): Agent and user edits share revisioned workbook operations through the official right Sidebar + CSV export",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"main": "lib/types/index.js",
|
|
10
|
+
"types": "lib/types/index.d.ts",
|
|
11
|
+
"imports": {
|
|
12
|
+
"#contracts": {
|
|
13
|
+
"types": "./lib/contracts.d.ts",
|
|
14
|
+
"default": "./lib/contracts.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/types/index.d.ts",
|
|
20
|
+
"default": "./lib/types/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./invariant": {
|
|
23
|
+
"types": "./lib/types/invariant.d.ts",
|
|
24
|
+
"default": "./lib/types/invariant.js"
|
|
25
|
+
},
|
|
26
|
+
"./client": "./lib/client.js",
|
|
27
|
+
"./src/*": "./src/*",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"lib",
|
|
32
|
+
"src",
|
|
33
|
+
"cordis.patch.yml"
|
|
34
|
+
],
|
|
35
|
+
"dsh": {
|
|
36
|
+
"bundle": {
|
|
37
|
+
"patch": "./cordis.patch.yml"
|
|
38
|
+
},
|
|
39
|
+
"client": {
|
|
40
|
+
"platform": "web",
|
|
41
|
+
"inject": [
|
|
42
|
+
"@tita-agent/dsh-surface-bridge",
|
|
43
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
44
|
+
"@deepseek-ai/dsh-client-locale",
|
|
45
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-primitives",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
49
|
+
"@deepseek-ai/dsh-client-ui-renderer"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@deepseek-ai/cordis": "~4.0.4",
|
|
55
|
+
"@deepseek-ai/dsh-client-connection": ">=0.2.0-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-conversation": ">=0.2.0-rc.1",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-layout": ">=0.2.0-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-renderer": ">=0.2.0-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": ">=0.2.0-rc.1",
|
|
62
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.1",
|
|
63
|
+
"@deepseek-ai/dsh-tools": ">=0.2.0-rc.1",
|
|
64
|
+
"@deepseek-ai/dsh-util-values": ">=0.2.0-rc.1"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@deepseek-ai/cordis": "~4.0.4",
|
|
68
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.1",
|
|
69
|
+
"@deepseek-ai/dsh-client-connection": "0.2.0-rc.1",
|
|
70
|
+
"@deepseek-ai/dsh-client-locale": "0.2.0-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.0-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.2.0-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.1",
|
|
74
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.2.0-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
|
|
77
|
+
"@deepseek-ai/dsh-invariants": "0.2.0-rc.1",
|
|
78
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.1",
|
|
79
|
+
"@deepseek-ai/dsh-ptc-runtime": "0.2.0-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-sandbox": "0.2.0-rc.1",
|
|
81
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.0-rc.1",
|
|
82
|
+
"@deepseek-ai/dsh-scope": "0.2.0-rc.1",
|
|
83
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.1",
|
|
84
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.1",
|
|
85
|
+
"@deepseek-ai/dsh-user-approval": "0.2.0-rc.1",
|
|
86
|
+
"@deepseek-ai/dsh-util-values": "0.2.0-rc.1",
|
|
87
|
+
"@types/node": "^26.0.0",
|
|
88
|
+
"@types/react": "~18.3.1",
|
|
89
|
+
"@univerjs/presets": "0.25.1",
|
|
90
|
+
"@univerjs/sheets-crosshair-highlight": "0.25.1",
|
|
91
|
+
"@univerjs/ui": "0.25.1",
|
|
92
|
+
"esbuild": "^0.25.0",
|
|
93
|
+
"lightningcss": "^1.28.0",
|
|
94
|
+
"react": "^18.2.0",
|
|
95
|
+
"react-dom": "^18.2.0",
|
|
96
|
+
"rxjs": "^7.8.2",
|
|
97
|
+
"typescript": "^5.9.0",
|
|
98
|
+
"@tita-agent/ui": "0.1.0"
|
|
99
|
+
},
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"xlsx": "^0.18.5",
|
|
102
|
+
"@tita-agent/dsh-surface-bridge": "0.1.0"
|
|
103
|
+
},
|
|
104
|
+
"scripts": {
|
|
105
|
+
"build": "pnpm --filter @tita-agent/ui build && rm -rf lib && node ../../scripts/copy-plugin-contracts.mjs && tsc -p tsconfig.json && node build-client.mjs",
|
|
106
|
+
"test": "pnpm build && node --test tests/*.test.mjs",
|
|
107
|
+
"sync:profile": "node scripts/sync-profile.mjs"
|
|
108
|
+
}
|
|
6
109
|
}
|
package/src/audit.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit lineage (docs/issue/0022 P3).
|
|
3
|
+
*
|
|
4
|
+
* Workbook writes carry who asked for them: the ids the model passed, filled in
|
|
5
|
+
* from the active intent recorder when it is installed. Both transports need
|
|
6
|
+
* this — the browser sends them in a request body, the Agent receives them in
|
|
7
|
+
* tool arguments — so it is neither one's private concern.
|
|
8
|
+
*/
|
|
9
|
+
import type { LineageContext } from '#contracts'
|
|
10
|
+
|
|
11
|
+
export function lineageOfValue(value: unknown): LineageContext | undefined {
|
|
12
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined
|
|
13
|
+
const args = value as Record<string, unknown>
|
|
14
|
+
const lineage: LineageContext = {}
|
|
15
|
+
const fields: Array<[keyof LineageContext, string]> = [
|
|
16
|
+
['sessionId', 'sessionId'], ['turnId', 'turnId'], ['intentId', 'intentId'],
|
|
17
|
+
['taskId', 'taskId'], ['subtaskId', 'subtaskId'], ['parentSubtaskId', 'parentSubtaskId'], ['runId', 'runId'],
|
|
18
|
+
['traceId', 'traceId'], ['domain', 'domain'],
|
|
19
|
+
]
|
|
20
|
+
for (const [target, source] of fields) if (typeof args[source] === 'string' && args[source].trim()) lineage[target] = args[source].trim().slice(0, 160)
|
|
21
|
+
return Object.keys(lineage).length > 0 ? lineage : undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Active-recorder lineage supplied by `dsh-data-domain-knowledge`'s intent
|
|
26
|
+
* service (`titaDataAgentIntent`; the module was its own package until 0020).
|
|
27
|
+
* Optional: without the recorder plugin, workbook writes keep carrying only the
|
|
28
|
+
* lineage the model passed explicitly.
|
|
29
|
+
*/
|
|
30
|
+
export interface LineageProvider {
|
|
31
|
+
activeLineage(sessionKey: string): { lineage: Partial<LineageContext>; committed: boolean } | undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The scope the intent recorder is resolved from. `apply()` sets it once; it is
|
|
36
|
+
* module state because the recorder is a host service rather than an argument.
|
|
37
|
+
*/
|
|
38
|
+
export let lineageScope: { get(name: string, strict?: boolean): unknown } | undefined
|
|
39
|
+
|
|
40
|
+
export function setLineageScope(scope: { get(name: string, strict?: boolean): unknown } | undefined): void {
|
|
41
|
+
lineageScope = scope
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function lineageProvider(): LineageProvider | undefined {
|
|
45
|
+
const scope = lineageScope
|
|
46
|
+
// Test harnesses pass a minimal context; only a real cordis scope can resolve services.
|
|
47
|
+
if (typeof scope?.get !== 'function') return undefined
|
|
48
|
+
return scope.get('titaDataAgentIntent', false) as LineageProvider | undefined
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function lineageOfArgs(args: Record<string, unknown>, exec?: { agent?: { session?: { header?: { id?: string } } } }): LineageContext | undefined {
|
|
52
|
+
const lineage = lineageOfValue(args)
|
|
53
|
+
const sessionId = lineage?.sessionId ?? exec?.agent?.session?.header?.id
|
|
54
|
+
if (!sessionId) return lineage
|
|
55
|
+
// Explicit arguments win; the recorder only fills the ids a call omitted.
|
|
56
|
+
const inherited = lineageProvider()?.activeLineage(sessionId)?.lineage
|
|
57
|
+
return { sessionId, ...inherited, ...lineage }
|
|
58
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workbook import menu, and the chooser behind it.
|
|
3
|
+
*
|
|
4
|
+
* Import used to start and end in the operating system's file dialog. It now
|
|
5
|
+
* starts in the project: the menu opens a listing of `<project>/storages` with
|
|
6
|
+
* each file's creation and modification time, because a project that keeps its
|
|
7
|
+
* data beside itself should offer its own files first.
|
|
8
|
+
*
|
|
9
|
+
* It is still not a wall. Containment says where a project's files live, not
|
|
10
|
+
* what a user may open, so the chooser's footer keeps "从项目外导入…" — the same
|
|
11
|
+
* OS dialog as before, one click away rather than two.
|
|
12
|
+
*
|
|
13
|
+
* The bytes of a chosen file are read by the Host (a browser cannot open a path),
|
|
14
|
+
* and from there the pipeline is the one that already existed: the buffer goes
|
|
15
|
+
* back as `data-sheet:import-bytes` and `univer/plugins/export.ts` parses it.
|
|
16
|
+
*
|
|
17
|
+
* @module dsh-data-table/client/ProjectImportMenu
|
|
18
|
+
*/
|
|
19
|
+
import { useState, type ReactElement } from 'react'
|
|
20
|
+
import { FilePickerDialog, ToolbarMenu } from '@tita-agent/ui'
|
|
21
|
+
import { FileSpreadsheet, FileText, Upload } from '@tita-agent/ui/icons'
|
|
22
|
+
import { fetchProjectFiles, readProjectFile, type ProjectFileEntry } from './transport/workbookApi.ts'
|
|
23
|
+
|
|
24
|
+
/** The two formats the workbook import understands. */
|
|
25
|
+
type ImportFormat = 'xlsx' | 'csv'
|
|
26
|
+
|
|
27
|
+
/** Extensions each format accepts, as the chooser's filter. */
|
|
28
|
+
const ACCEPT: Record<ImportFormat, string[]> = { xlsx: ['.xlsx', '.xls'], csv: ['.csv'] }
|
|
29
|
+
|
|
30
|
+
/** Copy for each format, used in the menu hint and the dialog's title. */
|
|
31
|
+
const FORMAT_LABEL: Record<ImportFormat, string> = { xlsx: 'Excel', csv: 'CSV' }
|
|
32
|
+
|
|
33
|
+
export interface ProjectImportMenuProps {
|
|
34
|
+
/** True while no workbook is open: importing has nowhere to land. */
|
|
35
|
+
disabled: boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The 导入 menu plus the project file chooser it opens.
|
|
40
|
+
*
|
|
41
|
+
* @param props - See {@link ProjectImportMenuProps}.
|
|
42
|
+
* @returns the menu and, when open, the chooser.
|
|
43
|
+
*/
|
|
44
|
+
export function ProjectImportMenu({ disabled }: ProjectImportMenuProps): ReactElement {
|
|
45
|
+
const [format, setFormat] = useState<ImportFormat | null>(null)
|
|
46
|
+
|
|
47
|
+
/** Hand a chosen file's bytes to the import pipeline. */
|
|
48
|
+
const readAndImport = (entry: ProjectFileEntry, chosen: ImportFormat): void => {
|
|
49
|
+
setFormat(null)
|
|
50
|
+
void readProjectFile(entry.path)
|
|
51
|
+
.then(file => {
|
|
52
|
+
window.dispatchEvent(new CustomEvent('data-sheet:import-bytes', {
|
|
53
|
+
detail: { data: file.data, name: file.name, format: chosen },
|
|
54
|
+
}))
|
|
55
|
+
})
|
|
56
|
+
.catch((error: unknown) => {
|
|
57
|
+
// The panel already listens for this event, so a failure to read the
|
|
58
|
+
// file reports itself the same way a failure to parse it does.
|
|
59
|
+
window.dispatchEvent(new CustomEvent('data-sheet:import-error', {
|
|
60
|
+
detail: { message: error instanceof Error ? error.message : String(error) },
|
|
61
|
+
}))
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<>
|
|
67
|
+
<ToolbarMenu
|
|
68
|
+
label="导入"
|
|
69
|
+
icon={<Upload size={14} aria-hidden="true" />}
|
|
70
|
+
disabled={disabled}
|
|
71
|
+
groups={[{
|
|
72
|
+
items: [
|
|
73
|
+
{ id: 'xlsx', label: '导入 Excel', hint: '从项目 storages/ 选择文件', icon: <FileSpreadsheet size={15} aria-hidden="true" />, onSelect: () => { setFormat('xlsx') } },
|
|
74
|
+
{ id: 'csv', label: '导入 CSV', hint: '从项目 storages/ 选择文件', icon: <FileText size={15} aria-hidden="true" />, onSelect: () => { setFormat('csv') } },
|
|
75
|
+
],
|
|
76
|
+
}]}
|
|
77
|
+
/>
|
|
78
|
+
{format !== null && (
|
|
79
|
+
<FilePickerDialog
|
|
80
|
+
open
|
|
81
|
+
onOpenChange={next => { if (!next) setFormat(null) }}
|
|
82
|
+
title={`导入 ${FORMAT_LABEL[format]} 文件`}
|
|
83
|
+
description={`选择项目 storages/ 下的文件;内容读入当前工作簿,原文件不会被移动或改动。`}
|
|
84
|
+
accept={ACCEPT[format]}
|
|
85
|
+
load={fetchProjectFiles}
|
|
86
|
+
onPick={entry => { readAndImport(entry, format) }}
|
|
87
|
+
onImportOutside={() => {
|
|
88
|
+
const outside = format
|
|
89
|
+
setFormat(null)
|
|
90
|
+
// Literal event names rather than a template: the Univer bridge is
|
|
91
|
+
// looked up by these exact strings, and a name assembled at runtime
|
|
92
|
+
// is a bridge nobody can grep for.
|
|
93
|
+
if (outside === 'csv') window.dispatchEvent(new CustomEvent('data-sheet:request-import-csv'))
|
|
94
|
+
else window.dispatchEvent(new CustomEvent('data-sheet:request-import-xlsx'))
|
|
95
|
+
}}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
</>
|
|
99
|
+
)
|
|
100
|
+
}
|