zero-db-tool 0.0.0-stage → 1.0.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 +28 -0
- package/README.md +86 -2
- package/assets/icon.png +0 -0
- package/client/client.js +543 -0
- package/client/src/AntdWorkbench.tsx +632 -0
- package/client/src/DatabaseConnectionsPage.tsx +455 -0
- package/client/src/api.ts +71 -0
- package/client/src/base.css +82 -0
- package/client/src/console-shim.ts +5 -0
- package/client/src/database-workbench.css +905 -0
- package/client/src/icons.tsx +33 -0
- package/client/src/main.tsx +83 -0
- package/client/src/text.d.ts +4 -0
- package/client/src/theme-fixes.css +29 -0
- package/client/src/theme.ts +25 -0
- package/client/src/workbench.css +156 -0
- package/cordis.patch.yml +4 -0
- package/dist/connections.js +909 -0
- package/dist/http.js +215 -0
- package/dist/index.js +77 -0
- package/dist/manager.js +193 -0
- package/dist/plugin-types.js +1 -0
- package/dist/sql-guard.js +239 -0
- package/dist/tools.js +229 -0
- package/package.json +63 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, dsh-loop-db contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# zero-db-tool
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness 的数据库工作台:连接下拉 + 对象树 + 数据/结构/SQL 三页,只读优先。
|
|
4
|
+
|
|
5
|
+
- **模型侧**:`sql_query` / `sql_exec` / `sql_schema` / `sql_stats` / `sql_health` / `sql_connections`
|
|
6
|
+
- **界面侧**:右侧栏 DBeaver 风格工作台——连接下拉、可拖拽对象树(库 → 表/视图)、数据/结构/SQL 页签、CSV 导出、SQL 历史、双击单元格复制
|
|
7
|
+
- **引擎**:SQLite / PostgreSQL / MySQL
|
|
8
|
+
- **数据**:`<我的文档>/DSH/zero-db-tool`(`ZERO_DB_TOOL_DIR` 可覆盖),密码 AES-256-GCM 加密
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
本地目录(当前方式):
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
dsh plugin --profile web add "link:D:\\kaifawork\\AIWORK\\zero-db-tool"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
私有仓库:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/zerui-chen/zero-db-tool.git
|
|
22
|
+
dsh plugin --profile web add "link:<克隆目录>"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
安装后完全退出并重启 DSH。
|
|
26
|
+
|
|
27
|
+
## 工具
|
|
28
|
+
|
|
29
|
+
| 工具 | 行为 |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `sql_query` | 单条只读语句(SELECT / PRAGMA / EXPLAIN / SHOW / DESCRIBE / WITH),拒绝多语句、锁读、`SELECT ... INTO`、写型 PRAGMA |
|
|
32
|
+
| `sql_exec` | 只允许 INSERT / UPDATE;含 UPDATE 时在调用内向用户请求批准,拒绝则不执行;DELETE / DDL / 事务一律拒绝 |
|
|
33
|
+
| `sql_schema` | 列出表与视图,或描述一张表的列(三种引擎通用) |
|
|
34
|
+
| `sql_stats` | 表数量、逐表行数(最多 100 张)、SQLite 文件大小 |
|
|
35
|
+
| `sql_health` | 逐连接探活与治理摘要 |
|
|
36
|
+
| `sql_connections` | list / add / remove / test |
|
|
37
|
+
|
|
38
|
+
## 界面
|
|
39
|
+
|
|
40
|
+
- **连接**:顶部下拉切换;测试、编辑、删除在右侧
|
|
41
|
+
- **对象树**:宽屏常驻且可拖拽(20%–55%),按钮可隐藏;窄于 560px 自动改为抽屉,选表后关闭
|
|
42
|
+
- **数据**:行号、PK 标记、斑马纹、悬停高亮、分页、CSV 导出、双击复制
|
|
43
|
+
- **结构**:字段 / 类型 / 约束(主键、可空)
|
|
44
|
+
- **SQL**:等宽编辑器、Ctrl+Enter、历史回填、结果 CSV、只读单语句
|
|
45
|
+
|
|
46
|
+
MySQL / 未配置默认库的 PostgreSQL 在树里先列库,展开某个库时才按库拉表。
|
|
47
|
+
|
|
48
|
+
## 安全模型
|
|
49
|
+
|
|
50
|
+
| 层次 | 机制 |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| 读 | 词法闸门只放行只读语句;单语句;拒绝写型构造 |
|
|
53
|
+
| 写 | 仅 INSERT / UPDATE;UPDATE 逐批人工批准;DELETE / DDL / 事务 / 权限语句永不执行 |
|
|
54
|
+
| 凭据 | AES-256-GCM 加密文件(0600),密钥由用户名 + 主机名 + 数据目录派生;列表与导出不回显密码 |
|
|
55
|
+
| 传输 | 密码可走本地加密 / 本次运行 / 环境变量三种模式 |
|
|
56
|
+
| HTTP | 仅接受 loopback 或受信 Host,Origin/Referer 同源校验;宿主提供鉴权时优先采用 |
|
|
57
|
+
|
|
58
|
+
## 与 dsh-db-tool 共存
|
|
59
|
+
|
|
60
|
+
两者连接库互相独立,工具名不冲突(`sql_*` vs `DatabaseManager`)。本插件更窄:三种引擎、默认只读、无数据传输/审计/事务。
|
|
61
|
+
|
|
62
|
+
## 数据目录
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
<Documents>/DSH/zero-db-tool/
|
|
66
|
+
connections.json 连接定义(密码只存引用)
|
|
67
|
+
credentials.enc 加密凭据库(0600)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 开发
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm install
|
|
74
|
+
npm run build # tsc + esbuild 客户端单文件
|
|
75
|
+
npm test # vitest
|
|
76
|
+
node --check client/client.js
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 已知限制
|
|
80
|
+
|
|
81
|
+
- 无审计日志、事务、数据传输
|
|
82
|
+
- SQL 编辑器是 antd 文本域,没有语法高亮与补全
|
|
83
|
+
- 表行数统计对超大库可能较慢(最多扫 100 张表)
|
|
84
|
+
|
|
85
|
+
## 许可证
|
|
86
|
+
|
|
87
|
+
BSD-3-Clause。
|
package/assets/icon.png
ADDED
|
Binary file
|