Repository navigation
feat(ui-plugins): add DB Admin Generator (db-admin-generator) - #249
Open
ppppp2005-p wants to merge 12 commits into
Open
ppppp2005-p wants to merge 12 commits into
ppppp2005-p wants to merge 12 commits into
Conversation
Author
|
ZCode desktop demo (ZCode 4.0.0, macOS arm64) db-admin-generator-demo.mp4How this was tested:
演示说明:本地 marketplace 安装 → 正式运行 |
Collaborator
|
✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin type (required) / 插件类型(必填)
Affected plugin name(s) / 涉及的插件名称:
db-admin-generator(UI Plugin, new)What / 改动内容
New community UI plugin DB Admin Generator / 数据库转管理后台: a SQLite database becomes a dependency-free admin panel (Node.js server plus browser UI), which is started and self-tested against a temporary copy of the database before it's handed over.
Tools:
db_inspect(read-only),db_generate,db_selftest.db_state,db_files.How it works:
src/runtime/schema.mjs, shared by the plugin and the generated server):sqlite_master,PRAGMA table_xinfo,foreign_key_list, andindex_list/index_info(single-column unique indexes).CHECK (col IN (...))options,VARCHAR(n)lengths and AUTOINCREMENT / INTEGER PRIMARY KEY.validateRow()coerces and validates input (zh/en messages); on insert, empty NOT NULL columns that have defaults fall back to the SQLite default.src/generate.ts):.db-admin-generator/plans.json.src/runtime/*, copied todist/runtime):server.mjsuses onlynode:http,node:sqliteandnode:crypto.users.json(0600). Sessions are HMAC-signed cookies (HttpOnly, SameSite=Strict, Secure behind HTTPS), and non-GET requests must sendX-Admin: 1.default-src 'self',X-Frame-Options: DENYand nosniff.audit.log.adminwith a random password printed once.public/app.js(vanilla) provides sign-in, a table sidebar, a list with search, filters, sort, paging and reference labels, and a modal form with column defaults prefilled and server field errors shown. Viewers and views are read-only.src/selftest.ts):PORT=0,ELECTRON_RUN_AS_NODE=1).Panel:
Network / API / side effects: none. No API keys. The self-test uses 127.0.0.1 only. Writes
<out>/and.db-admin-generator/plans.json. The source database is opened read-only and never modified (asserted by hash in the tests). No hooks. SQLite only; Postgres/MySQL are out of scope for v0.1. Needs Node ≥ 22.13 fornode:sqlite.Testing:
samples/db/make-db.mjs: FKs incl. ON DELETE CASCADE, UNIQUE, CHECK IN, BOOLEAN, DATE/DATETIME, a view, a table without PK) plus an accounts DB with secrets and a migrations table:db_selftest.A ZCode Desktop demo recording is attached in the comments. / ZCode 桌面版演示录屏见评论。
Self-check / 自查清单
external_plugins/<name>/categoryis set (productivity)version0.1.0 in bothplugin.jsonandmarketplace.jsonREADME.md(EN) andREADME_CN.md(中文) both provided and equivalentdescription_i18nhas bothenandzh-CNpython3 scripts/validate.pyandpython3 scripts/build_dist.pypass locallydb/harbor-bikes.dband generate a Chinese admin; the agent randb_inspect→db_generate(5 tables + 1 read-only view, built-in self-test 93/93 passed); a second short task randb_selfteston the generated admin with the panel shown: 93/93 passed; demo video in the comments)