dsh-db-tool 1.5.8 → 1.5.91

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/README.md CHANGED
@@ -14,6 +14,18 @@ DSH 社区插件:在聊天中安全操作数据库,配套侧边栏管理台
14
14
  - **侧边栏 4 面板**(dsh-better-sidebar,zh/en):连接管理、项目授权、数据浏览、SQL 控制台
15
15
  - **db-admin skill**:随插件分发,覆盖 8 库方言速查、安全规范、确认流程
16
16
 
17
+ ### SQL 控制台
18
+
19
+ 侧边栏 SQL 控制台面板已升级为 Navicat 式多标签编辑器(CodeMirror 6):
20
+
21
+ - **多标签**:新建/关闭/切换查询标签,每个标签独立保存 SQL、结果与历史(历史上限 50 条,可展开点击回填)
22
+ - **语法高亮与补全**:按方言切换——mysql→MySQL、postgresql/gaussdb→PostgreSQL、sqlite→SQLite、oracle/dmdb→PL/SQL;Redis/Mongo 为关键字/方法补全的纯文本编辑;表列元数据自动拉取注入补全(上限 50 表)。编辑器 bundle(`vendor/codemirror-sql.cjs`,`npm run build:codemirror` 生成,`npm run build` 自动串接)加载失败时静默降级 textarea
23
+ - **快捷键**:`Ctrl/Cmd+Enter` 执行全部,`Ctrl/Cmd+Shift+Enter` 执行选中
24
+ - **格式化**:sql-formatter 按方言格式化,解析失败回退原文
25
+ - **逐条执行**:客户端预分类读/写语句分别路由 `/api/query` 与 `/api/execute`,只读授权下写语句自动跳过并标注;出错可一键定位到对应语句起始处
26
+ - **事务**:rw 授权下可开始/提交/回滚(服务端粘性连接会话;空闲 5 分钟超时自动回滚并审计,授权回收/降级即时生效)
27
+ - **结果网格**:表头三态排序、50 行/页分页、单元格点击复制、CSV/JSON 导出
28
+
17
29
  ## 数据布局
18
30
 
19
31
  `$DSH_HOME/db-tool/`(0700):
@@ -74,11 +86,11 @@ npx stryker run # 变异测试(范围 lib/guard + lib/manager + lib/store,
74
86
  lib/ host 插件(store / adapters×8 / guard / manager / http / index)
75
87
  client/ 侧边栏单文件产物(client.js,即源码)
76
88
  skills/ db-admin skill
77
- scripts/ 构建与工具脚本(mongodb 驱动 bundle、DSH 宿主热修复 patch:dsh 等)
89
+ scripts/ 构建与工具脚本(mongodb 驱动 / CodeMirror 编辑器 bundle、DSH 宿主热修复 patch:dsh 等)
78
90
  patches/ DSH 宿主 dsh-app-boot 热修复补丁(patch:dsh 按宿主版本选用)
79
91
  docs/ 预留(当前为空)
80
92
  tests/ vitest(离线 mock + DBT_TEST_* 门控真机)
81
- vendor/ mongodb-driver.cjs bundle(gitignore,发布经 files 白名单收录)
93
+ vendor/ mongodb-driver.cjs 与 codemirror-sql.cjs bundle(gitignore,发布经 files 白名单收录)
82
94
  ```
83
95
 
84
96
  ## 许可证
package/README_EN.md CHANGED
@@ -14,6 +14,18 @@ A DSH community plugin for operating databases safely from chat, with a sidebar
14
14
  - **Sidebar with 4 panels** (dsh-better-sidebar, zh/en): connections, project grants, data browser, SQL console
15
15
  - **db-admin skill**: shipped with the plugin, covering dialect cheat sheets for all 8 databases, safety rules, and the confirmation flow
16
16
 
17
+ ### SQL Console
18
+
19
+ The sidebar SQL console panel has been upgraded to a Navicat-style multi-tab editor (CodeMirror 6):
20
+
21
+ - **Multi-tab**: create/close/switch query tabs; each tab keeps its own SQL, result, and history (capped at 50 entries, expandable and click-to-refill)
22
+ - **Syntax highlighting & completion**: switches with the dialect — mysql→MySQL, postgresql/gaussdb→PostgreSQL, sqlite→SQLite, oracle/dmdb→PL/SQL; Redis/Mongo get keyword/method completion over plain text; table/column metadata is fetched to feed completion (up to 50 tables). If the editor bundle (`vendor/codemirror-sql.cjs`, built by `npm run build:codemirror`, chained after `npm run build`) fails to load, it silently falls back to a textarea
23
+ - **Shortcuts**: `Ctrl/Cmd+Enter` runs everything, `Ctrl/Cmd+Shift+Enter` runs the selection
24
+ - **Formatting**: dialect-aware formatting via sql-formatter, falling back to the original text on parse failure
25
+ - **Per-statement execution**: statements are pre-classified client-side as read/write and routed to `/api/query` vs `/api/execute`; write statements are skipped and flagged under read-only grants; errors can jump to the offending statement
26
+ - **Transactions**: begin/commit/rollback under rw grants (server-side sticky-connection session; idle sessions roll back after a 5-minute TTL and are audited; grant revocation takes effect immediately)
27
+ - **Result grid**: tri-state column sorting, pagination at 50 rows/page, click-to-copy cells, CSV/JSON export
28
+
17
29
  ## Data Layout
18
30
 
19
31
  `$DSH_HOME/db-tool/` (0700):
@@ -74,11 +86,11 @@ Live-database smoke tests (run only when set): `DBT_TEST_MYSQL_URL / DBT_TEST_PG
74
86
  lib/ host plugin (store / adapters×8 / guard / manager / http / index)
75
87
  client/ sidebar single-file artifact (client.js — this is the source)
76
88
  skills/ db-admin skill
77
- scripts/ build & tooling scripts (MongoDB driver bundle, DSH host hotfix patch:dsh, etc.)
89
+ scripts/ build & tooling scripts (MongoDB driver / CodeMirror editor bundles, DSH host hotfix patch:dsh, etc.)
78
90
  patches/ DSH host dsh-app-boot hotfix patches (selected by host version for patch:dsh)
79
91
  docs/ reserved (currently empty)
80
92
  tests/ vitest (offline mocks + DBT_TEST_*-gated live runs)
81
- vendor/ mongodb-driver.cjs bundle (gitignored; shipped via the files whitelist)
93
+ vendor/ mongodb-driver.cjs and codemirror-sql.cjs bundles (gitignored; shipped via the files whitelist)
82
94
  ```
83
95
 
84
96
  ## License