@lark-base-open/base-database-cli 1.1.1 → 1.3.8
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/CHANGELOG.md +97 -0
- package/LICENSE +6 -0
- package/README.md +47 -27
- package/dist/ai-functions.d.ts +53 -0
- package/dist/ai-functions.d.ts.map +1 -0
- package/dist/ai-functions.js +436 -0
- package/dist/ai-functions.js.map +1 -0
- package/dist/archive.d.ts +21 -0
- package/dist/archive.d.ts.map +1 -1
- package/dist/archive.js +69 -10
- package/dist/archive.js.map +1 -1
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +26 -3
- package/dist/auth.js.map +1 -1
- package/dist/check.d.ts +74 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +283 -0
- package/dist/check.js.map +1 -0
- package/dist/dependency-policy.d.ts +10 -0
- package/dist/dependency-policy.d.ts.map +1 -0
- package/dist/dependency-policy.js +162 -0
- package/dist/dependency-policy.js.map +1 -0
- package/dist/deploy.d.ts +5 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +141 -176
- package/dist/deploy.js.map +1 -1
- package/dist/environment-variables.d.ts +52 -0
- package/dist/environment-variables.d.ts.map +1 -0
- package/dist/environment-variables.js +563 -0
- package/dist/environment-variables.js.map +1 -0
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +1 -1
- package/dist/environment.js.map +1 -1
- package/dist/function-input-types.d.ts +10 -0
- package/dist/function-input-types.d.ts.map +1 -0
- package/dist/function-input-types.js +160 -0
- package/dist/function-input-types.js.map +1 -0
- package/dist/function-schema.d.ts.map +1 -1
- package/dist/function-schema.js +89 -36
- package/dist/function-schema.js.map +1 -1
- package/dist/init-field-retry.d.ts +17 -0
- package/dist/init-field-retry.d.ts.map +1 -0
- package/dist/init-field-retry.js +127 -0
- package/dist/init-field-retry.js.map +1 -0
- package/dist/init-journal.d.ts +98 -0
- package/dist/init-journal.d.ts.map +1 -0
- package/dist/init-journal.js +492 -0
- package/dist/init-journal.js.map +1 -0
- package/dist/init-schema.d.ts +8 -0
- package/dist/init-schema.d.ts.map +1 -0
- package/dist/init-schema.js +423 -0
- package/dist/init-schema.js.map +1 -0
- package/dist/init.d.ts +15 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +884 -261
- package/dist/init.js.map +1 -1
- package/dist/lark-cli-error.d.ts +47 -0
- package/dist/lark-cli-error.d.ts.map +1 -0
- package/dist/lark-cli-error.js +201 -0
- package/dist/lark-cli-error.js.map +1 -0
- package/dist/lark-cli.d.ts +1 -1
- package/dist/lark-cli.d.ts.map +1 -1
- package/dist/lark-cli.js +78 -18
- package/dist/lark-cli.js.map +1 -1
- package/dist/mutation-schema.d.ts +146 -0
- package/dist/mutation-schema.d.ts.map +1 -0
- package/dist/mutation-schema.js +153 -0
- package/dist/mutation-schema.js.map +1 -0
- package/dist/mutation.d.ts +10 -0
- package/dist/mutation.d.ts.map +1 -0
- package/dist/mutation.js +131 -0
- package/dist/mutation.js.map +1 -0
- package/dist/npm.d.ts +1 -0
- package/dist/npm.d.ts.map +1 -1
- package/dist/npm.js +2 -2
- package/dist/npm.js.map +1 -1
- package/dist/preview-receipt.d.ts.map +1 -1
- package/dist/preview-receipt.js +15 -5
- package/dist/preview-receipt.js.map +1 -1
- package/dist/process.d.ts +3 -1
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +16 -4
- package/dist/process.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +246 -42
- package/dist/program.js.map +1 -1
- package/dist/project-build.d.ts +25 -0
- package/dist/project-build.d.ts.map +1 -0
- package/dist/project-build.js +229 -0
- package/dist/project-build.js.map +1 -0
- package/dist/project-context.d.ts +344 -0
- package/dist/project-context.d.ts.map +1 -0
- package/dist/project-context.js +485 -0
- package/dist/project-context.js.map +1 -0
- package/dist/project-layout.d.ts +5 -0
- package/dist/project-layout.d.ts.map +1 -0
- package/dist/project-layout.js +24 -0
- package/dist/project-layout.js.map +1 -0
- package/dist/public-sql-error.d.ts +25 -0
- package/dist/public-sql-error.d.ts.map +1 -0
- package/dist/public-sql-error.js +65 -0
- package/dist/public-sql-error.js.map +1 -0
- package/dist/pull.d.ts +1 -0
- package/dist/pull.d.ts.map +1 -1
- package/dist/pull.js +67 -15
- package/dist/pull.js.map +1 -1
- package/dist/site-readme.d.ts +3 -0
- package/dist/site-readme.d.ts.map +1 -0
- package/dist/site-readme.js +83 -0
- package/dist/site-readme.js.map +1 -0
- package/dist/workspace-fingerprint.d.ts +21 -1
- package/dist/workspace-fingerprint.d.ts.map +1 -1
- package/dist/workspace-fingerprint.js +81 -2
- package/dist/workspace-fingerprint.js.map +1 -1
- package/package.json +2 -1
- package/skills/lark-base-database/SKILL.md +86 -52
- package/skills/lark-base-database/references/ai-function.md +479 -0
- package/skills/lark-base-database/references/base-capability-routing.md +7 -7
- package/skills/lark-base-database/references/base-sql-errors.generated.md +403 -0
- package/skills/lark-base-database/references/database-function-limitations.md +29 -0
- package/skills/lark-base-database/references/database-function.md +323 -0
- package/skills/lark-base-database/references/development.md +166 -33
- package/skills/lark-base-database/references/environment-variables.md +55 -0
- package/skills/lark-base-database/references/faas.md +46 -53
- package/skills/lark-base-database/references/file-transfer.md +25 -25
- package/skills/lark-base-database/references/frontend-design-guide.md +151 -65
- package/skills/lark-base-database/references/mutations.md +295 -0
- package/skills/lark-base-database/references/notifications.md +9 -9
- package/skills/lark-base-database/references/permission-design.md +24 -24
- package/skills/lark-base-database/references/release.md +57 -30
- package/skills/lark-base-database/references/style-guide.md +10 -67
- package/skills/lark-base-database/references/verification.md +19 -13
- package/skills/lark-base-database/references/workspace.md +57 -17
- package/templates/database-starter/README.md +34 -4
- package/templates/database-starter/database-functions/README.md +8 -0
- package/templates/database-starter/gitignore +7 -0
- package/templates/database-starter/mutations/README.md +19 -0
- package/templates/database-starter/page/README.md +25 -19
- package/templates/database-starter/page/package-lock.json +8 -16
- package/templates/database-starter/page/package.json +2 -3
- package/templates/database-starter/page/src/App.tsx +23 -3
- package/templates/database-starter/page/src/components/UserSelectorEditor/index.tsx +32 -4
- package/templates/database-starter/page/src/components/UserSelectorPanel/index.tsx +104 -34
- package/templates/database-starter/page/src/components/UserSelectorPanel/user-search.test.ts +55 -11
- package/templates/database-starter/page/src/components/UserSelectorPanel/user-search.ts +68 -25
- package/templates/database-starter/page/src/components/database-runtime-ready.tsx +1 -1
- package/templates/database-starter/page/src/components/database-user-menu/index.tsx +4 -7
- package/templates/database-starter/page/src/components/feedback/page-state.tsx +40 -5
- package/templates/database-starter/page/src/components/floating-button/assets/edit-active.svg +3 -0
- package/templates/database-starter/page/src/components/floating-button/assets/edit-default.svg +3 -0
- package/templates/database-starter/page/src/components/floating-button/assets/toast-close.svg +3 -0
- package/templates/database-starter/page/src/components/floating-button/assets/toast-info.svg +5 -0
- package/templates/database-starter/page/src/components/floating-button/assets/tooltip-caret.svg +3 -0
- package/templates/database-starter/page/src/components/floating-button/index.tsx +193 -113
- package/templates/database-starter/page/src/components/floating-button/utils/project-meta.test.ts +107 -37
- package/templates/database-starter/page/src/components/floating-button/utils/project-meta.ts +13 -50
- package/templates/database-starter/page/src/components/ui-language.test.tsx +101 -0
- package/templates/database-starter/page/src/examples/ai-function/ImageTaskOperation.tsx +202 -0
- package/templates/database-starter/page/src/examples/ai-function/README.md +14 -0
- package/templates/database-starter/page/src/examples/ai-function/TextStreamOperation.tsx +184 -0
- package/templates/database-starter/page/src/examples/ai-function/ai-copy.ts +173 -0
- package/templates/database-starter/page/src/examples/ai-function/ai-delta.test.ts +30 -0
- package/templates/database-starter/page/src/examples/ai-function/ai-delta.ts +26 -0
- package/templates/database-starter/page/src/examples/ai-function/ai-language.test.tsx +86 -0
- package/templates/database-starter/page/src/examples/ai-function/ai-media-panel.test.ts +201 -0
- package/templates/database-starter/page/src/examples/ai-function/ai-media-panel.tsx +382 -0
- package/templates/database-starter/page/src/lib/attachment-image.tsx +144 -0
- package/templates/database-starter/page/src/lib/database-function-inputs.generated.ts +4 -0
- package/templates/database-starter/page/src/lib/database-runtime-attachment.test.ts +180 -76
- package/templates/database-starter/page/src/lib/database-runtime.test.ts +130 -10
- package/templates/database-starter/page/src/lib/database-runtime.ts +484 -51
- package/templates/database-starter/page/src/lib/date-time.ts +61 -0
- package/templates/database-starter/page/src/lib/ui-language.ts +86 -0
- package/templates/database-starter/page/src/main.tsx +1 -1
- package/templates/database-starter/page/tsconfig.json +2 -2
- package/templates/database-starter/page/vite.config.ts +1 -2
- package/templates/database-starter/prettierignore +1 -1
- package/templates/database-starter/server-functions/README.md +2 -2
- package/templates/database-starter/server-functions/package-lock.json +4 -4
- package/templates/database-starter/server-functions/package.json +1 -1
- package/dist/agent-guide.d.ts +0 -19
- package/dist/agent-guide.d.ts.map +0 -1
- package/dist/agent-guide.js +0 -31
- package/dist/agent-guide.js.map +0 -1
- package/dist/database-skill.d.ts +0 -24
- package/dist/database-skill.d.ts.map +0 -1
- package/dist/database-skill.js +0 -148
- package/dist/database-skill.js.map +0 -1
- package/skills/lark-base-database/references/base-sql-unsupported.md +0 -42
- package/skills/lark-base-database/references/database-capability-skill.md +0 -40
- package/skills/lark-base-database/references/sql-function.md +0 -289
- package/templates/database-capability/SKILL.md.tmpl +0 -58
- package/templates/database-starter/page/src/components/floating-button/chatbot-entry.test.ts +0 -23
- package/templates/database-starter/page/src/components/floating-button/chatbot-entry.tsx +0 -873
- package/templates/database-starter/page/src/components/floating-button/local-chat-panel.test.ts +0 -25
- package/templates/database-starter/page/src/components/floating-button/local-chat-panel.tsx +0 -197
- package/templates/database-starter/page/src/components/floating-button/utils/env.ts +0 -18
- package/templates/database-starter/sql/README.md +0 -8
|
@@ -11,14 +11,32 @@ profile 决定账号与品牌,`--env` 决定运行环境。profile 缺失、
|
|
|
11
11
|
|
|
12
12
|
新建、恢复或修改工程前读取。只读设计与评审不执行本文件中的资源变更。
|
|
13
13
|
|
|
14
|
+
### 公开 CLI 版本预检
|
|
15
|
+
|
|
16
|
+
本节的全局安装特指 `npm root -g` 对应的 CLI 包目录;不能仅凭 PATH 中存在同名命令就认定满足更新条件。
|
|
17
|
+
|
|
18
|
+
仅本地公开 CLI:每个会话首次业务操作前,优先确认本机 `base-database-cli` 入口及其 `--help`。已有全局安装时用已核实的全局入口执行 `check-update --json --skill-dir "<当前读取的 lark-base-database 目录>"`;仅通过 npx 使用时沿用已选版本的完整包名入口。使用实际 Skill 加载路径,不猜测默认 Agent 目录。业务命令复用本次确认的入口。
|
|
19
|
+
|
|
20
|
+
仅托管 Builder(设置了 `BASE_SITE_BUILDER_WORKSPACE_SOURCE` 或 `BASE_SITE_BUILDER_SITE_TOKEN`)及 CI 跳过更新检查;其他环境正常检查。检查失败不阻塞任务。
|
|
21
|
+
|
|
22
|
+
- `status=current|unavailable|skipped`:不向用户播报更新检查,继续任务。
|
|
23
|
+
- `status=available`:先确认上述全局入口可用;不可用时按下文说明更新限制并继续任务。可用时说明当前版本和可更新版本,以及会同步已安装的用户级 Lark Base Database Skill,再询问是否升级。拒绝后继续已安装版,本会话不再询问;不要自动执行 npm 或更新命令。
|
|
24
|
+
- 确认全局安装入口且用户同意后,执行 `base-database-cli update --version <返回的 latest 精确版本> --skill-dir "<当前 Skill 目录>" --yes`,成功后重新读取该目录的 SKILL.md 和所需 references。升级会现场查找 Codex、Claude、通用 Agent 用户目录中已安装的本 Skill,并同步这些副本及显式传入的当前目录;不扫描项目或历史自定义目录,不补装已删除的副本。
|
|
25
|
+
- `update` 只允许从全局安装的 CLI 执行,不从 npx 临时副本或项目副本执行,也不移除来源检查。全局命令的 PATH 异常时,通过 `npm root -g` 确认 `@lark-base-open/base-database-cli/dist/cli.js` 的实际位置,用 Node 执行该入口并核对版本。没有全局安装时说明更新限制,继续 npx 业务调用;只有用户明确要求全局安装时才进入安装流程,不将更新确认自动扩展为新建全局安装。
|
|
26
|
+
- `skill.status=mismatch`:简短提示当前 Skill 与 CLI 来自不同版本,可通过本次执行预检的同一 CLI 入口运行 `skill install --dir "<当前 Skill 的父目录>" --force` 同步后重读;不因版本号不同中断业务或自动覆盖。`unknown` 表示未找到有效记录,不推断一致,也不阻塞。
|
|
27
|
+
- 更新失败时按实际结果反馈。`skill-update-failed` 表示 CLI 已更新,但部分 Skill 未同步;说明 `installed` 中的成功目录和 `failed` 中的失败目录,按每项 `repair` 参数数组修复后重读,不宣称整体升级成功,不自动降级或反复重试。
|
|
28
|
+
- 首次使用先确认当前调用入口支持 `check-update`(读取其 `--help`);旧 CLI 没有该子命令时跳过预检,继续业务,不为预检自动升级。
|
|
29
|
+
- 非托管环境优先使用本机已安装的 `base-database-cli`。已知全局安装存在但 PATH 异常时,使用确认过的可执行路径;不自动修改 shell 配置。没有可用本地入口时,回退 `npx @lark-base-open/base-database-cli`;需要固定版本时使用 `npx @lark-base-open/base-database-cli@<已确认的精确版本>`。不猜 npm scope,不全盘搜索或反复安装。托管环境始终使用宿主入口,不走公开包回退。
|
|
30
|
+
|
|
14
31
|
## 环境与依赖
|
|
15
32
|
|
|
16
|
-
公开 CLI 只使用 `online` 环境;`init`、`pull` 等支持环境参数的命令显式传 `--env online`,`deploy` 不接受该参数。托管运行时使用宿主已安装的 `base-database-cli` 与唯一默认环境,不重新安装公开 CLI。CLI、OpenAPI、Accounts
|
|
33
|
+
公开 CLI 只使用 `online` 环境;`init`、`pull` 等支持环境参数的命令显式传 `--env online`,`deploy` 不接受该参数。托管运行时使用宿主已安装的 `base-database-cli` 与唯一默认环境,不重新安装公开 CLI。CLI、OpenAPI、Accounts、应用和 Page runtime 必须处于同一环境;原生资源操作始终使用 `--as user`。
|
|
17
34
|
|
|
18
35
|
首次使用 `lark-cli` 时读取当前入口的 `--help`,本会话复用已确认的命令能力;不只按版本号判断,也不将云电脑等宿主认证环境等同于设置了 `BASE_SITE_BUILDER_*` 的 Builder。
|
|
19
36
|
|
|
20
37
|
| 能力 | 使用方式与缺失时处理 |
|
|
21
38
|
| --- | --- |
|
|
39
|
+
| `lark-cli` 可执行文件 | 公开环境缺失时执行 `npx @larksuite/cli@latest install`,其他安装方式见 [github.com/larksuite/cli](https://github.com/larksuite/cli);托管环境缺失时报告环境阻塞,不自行安装 |
|
|
22
40
|
| `api`、本任务需要的 `base` 命令 | 业务所需能力;按当前帮助和协议执行,真实认证、权限或接口错误按失败阶段处理 |
|
|
23
41
|
| `config` / `auth` | 本地账号管理能力。宿主提供认证时不补建 `default` profile;宿主缺少管理命令但通过 `LARKSUITE_CLI_PROFILE` 选择托管凭证时保留该环境变量,不传宿主禁止的 `--profile` 参数,由真实业务请求校验 profile,不回退账号 |
|
|
24
42
|
| `skills read` | 可选的文档入口。存在时读取 `lark-base` 并沿路由找 reference;不存在时直接读取环境提供的 lark-base 文件与相应命令帮助,后续不反复尝试该入口 |
|
|
@@ -28,42 +46,51 @@ profile 决定账号与品牌,`--env` 决定运行环境。profile 缺失、
|
|
|
28
46
|
|
|
29
47
|
## 先选择工程来源
|
|
30
48
|
|
|
49
|
+
需要确认当前本地工程状态时,先执行一次只读快照:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
base-database-cli context . --summary --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
它只汇总本地配置、Catalog、Function metadata、init/Preview 回执和部署输入 fingerprint;不认证、不访问远端、不构建或发布。摘要保留决策所需的状态、资源数量、readiness 和 next action,不输出本地路径、fingerprint 值或逐项资源。需要排障时去掉 `--summary` 查看完整快照。`project.status=uninitialized` 表示当前目录缺少 `base-database.jsonc`,按下述工程来源选择 init 或 pull,不能仅凭空目录自行推断远端来源。不要从快照推断运行态、权限或发布成功。
|
|
56
|
+
|
|
31
57
|
托管环境先读取 `BASE_SITE_BUILDER_WORKSPACE_SOURCE`,按宿主决定执行,不根据空目录自行推断:
|
|
32
58
|
|
|
33
59
|
| 来源 | 第一项工程操作 | 约束 |
|
|
34
60
|
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
35
61
|
| `snapshot` | 读取现有配置、Catalog、源码和本地修改 | 不执行 init/pull |
|
|
36
62
|
| `artifact` | `base-database-cli pull . --app-token "$BASE_SITE_BUILDER_SITE_TOKEN"` | pull 失败停止恢复,不退回 init |
|
|
37
|
-
| `binding` | `base-database-cli init . --app-token "$BASE_SITE_BUILDER_SITE_TOKEN" --base-token "$BASE_SITE_BUILDER_BASE_TOKEN" --name '
|
|
38
|
-
| `empty` | 执行带 `--app-token "$BASE_SITE_BUILDER_SITE_TOKEN"` 的 init |
|
|
63
|
+
| `binding` | `base-database-cli init . --app-token "$BASE_SITE_BUILDER_SITE_TOKEN" --base-token "$BASE_SITE_BUILDER_BASE_TOKEN" --name '<应用名称>' --description '<应用描述>'` | 已有一个 Base 绑定但无可恢复源码;只初始化一次,复用现有应用与 Base,不新建资源 |
|
|
64
|
+
| `empty` | 执行带 `--app-token "$BASE_SITE_BUILDER_SITE_TOKEN"` 的 init | 复用宿主应用,不创建另一应用 |
|
|
39
65
|
|
|
40
|
-
上述四种来源与宿主工程恢复协议一致。`binding` 还必须有非空 `BASE_SITE_BUILDER_BASE_TOKEN
|
|
66
|
+
上述四种来源与宿主工程恢复协议一致。`binding` 还必须有非空 `BASE_SITE_BUILDER_BASE_TOKEN`,应用名称与描述从当前需求确定。宿主变量存在但取值不在表中、必需 token 缺失或工程与宿主状态矛盾时,报告恢复条件不满足,不创建新资源掩盖问题。会话历史未恢复但工程有效时,先读取现有工程继续;没有工程的合法 binding 模式仍执行表中的恢复路径。
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
非托管环境:已有工程直接增量修改;只有远端应用时,在空目录执行 `base-database-cli pull . --app-token <app-token> --env online`;确认为新建时才 init。保留用户未提交内容,不能以恢复工程为由覆盖非空目录。
|
|
43
69
|
|
|
44
70
|
## 需求与 Base 定位
|
|
45
71
|
|
|
46
|
-
|
|
72
|
+
明确应用名称、一句客观描述、使用者、核心对象及关系、状态流转、页面任务和一条端到端验收路径。描述优先采用用户原文,未提供时根据需求生成使用对象与核心用途,不写营销文案、实现细节或发布状态。
|
|
47
73
|
|
|
48
74
|
用户未指定已有 Base 时,从零设计完整 schema;描述业务表和字段不代表这些资源已经存在。用户指定已有 Base 时,可信 token 直接使用,链接先用 `lark-cli base +url-resolve --url '<url>' --as user`,名称先用 `+title-resolve --title '<keyword>' --as user`;无法唯一定位时再请用户补充,不要求用户重复提供已有信息。
|
|
49
75
|
|
|
50
|
-
**当前 init 将所选 Base
|
|
76
|
+
**当前 init 将所选 Base 的全部表绑定到应用,没有选择部分表的参数。** 复用前只读确认所有表与权限边界;从零建模也只在目标 Base 中建立可全部绑定的业务表。若无关或敏感表使全表绑定不可接受,停止初始化并说明当前限制,按用户决定调整数据范围;不擅自复制、删表或宣称页面隐藏能收缩绑定权限。访问判定见[权限设计](permission-design.md)。
|
|
51
77
|
|
|
52
78
|
已有 Base 初始化只读取表结构,不修改 schema。Catalog 缺少业务必需结构时,只在用户已授权的修改范围内补齐;否则报告缺口和可实现范围。
|
|
53
79
|
|
|
54
80
|
## 初始化
|
|
55
81
|
|
|
56
|
-
初始化前检查 `BASE_SITE_BUILDER_SITE_TOKEN
|
|
82
|
+
初始化前检查 `BASE_SITE_BUILDER_SITE_TOKEN`。变量非空表示宿主已经创建目标应用:使用 环境已安装的 `base-database-cli` 可执行文件,并在本节的 `init` 命令中追加 `--app-token "$BASE_SITE_BUILDER_SITE_TOKEN"`。该模式仍按需求创建或复用 Base,会更新已有应用的名称和描述,再调用 `bind_base` 和 `catalog`,不会调用应用 create。不要手写 `base-database.jsonc`、不要绕过 CLI 拼装低层 `lark-cli` 请求,也不要用新应用掩盖绑定失败。
|
|
57
83
|
|
|
58
84
|
### 从零创建 Base
|
|
59
85
|
|
|
60
|
-
编写 schema 前,按已确认的文档入口读取字段规范:支持 `skills read`
|
|
86
|
+
编写 schema 前,按已确认的文档入口读取字段规范:支持 `skills read` 时先执行 `lark-cli skills read lark-base` 查看文件列表,再读取其中的字段定义 reference(当前为 `references/lark-base-field-json.md`,以列表实际名称为准);否则直接读取环境中 lark-base 的对应 reference,并用 `lark-cli base +table-create --help` 核对当前命令契约,不再尝试已知缺失的入口。不要猜测属性。`tables[].fields` 使用与 `lark-cli base +base-create/+table-create --fields` 相同的字段定义;init 会先创建每张表的主字段,取得全部真实表 ID 后再按原顺序创建其余字段。
|
|
61
87
|
|
|
88
|
+
- 用户所在地或需求明确了时区时,`init --schema` 追加 `--time-zone <IANA 时区>`(例如 `Asia/Tokyo`);未指定时由服务端按租户默认时区创建。
|
|
62
89
|
- 首个字段成为表的主字段,优先采用可读的文本标识;其他类型先核对主字段限制。
|
|
63
90
|
- 单选和多选都用 `select`,多选显式设置 `"multiple": true`,选项按字段规范声明。
|
|
64
91
|
- `link` 字段必须提供 `link_table`,且名称与本次 Schema 中的目标表完全一致;自关联和跨表关联会在所有表创建后补建,不需要按关联依赖调整表顺序。
|
|
65
92
|
- `datetime.style.format` 使用当前 Base 支持的固定枚举,不能自行增加秒级展示格式;底层时间精度与展示格式分别处理。
|
|
66
|
-
- 创建字段的 schema
|
|
93
|
+
- 创建字段的 schema、查询类型与记录 CellValue 是不同协议,不互相替代。
|
|
67
94
|
|
|
68
95
|
把全部表写入一个 schema 文件。这个文件是 `init` 的输入,不是平台请求缓存:
|
|
69
96
|
|
|
@@ -106,7 +133,7 @@ base-database-cli init . \
|
|
|
106
133
|
--schema ./base-schema.json
|
|
107
134
|
```
|
|
108
135
|
|
|
109
|
-
|
|
136
|
+
托管环境 已有应用场景执行:
|
|
110
137
|
|
|
111
138
|
```bash
|
|
112
139
|
base-database-cli init . \
|
|
@@ -128,11 +155,11 @@ base-database-cli init . \
|
|
|
128
155
|
--base-token basxxxxxxxx
|
|
129
156
|
```
|
|
130
157
|
|
|
131
|
-
|
|
158
|
+
托管环境 复用已有 Base 与已有应用时,同样改用 `base-database-cli init` 并追加 `--app-token "$BASE_SITE_BUILDER_SITE_TOKEN"`。
|
|
132
159
|
|
|
133
|
-
该命令调用只读 Base 接口获取 Base 信息并分页列出全部表。未指定 `--app-token`
|
|
160
|
+
该命令调用只读 Base 接口获取 Base 信息并分页列出全部表。未指定 `--app-token` 时,通过应用创建接口的 `baseBindings` 绑定这些表;指定时,通过目标应用的 `bind_base` 绑定这些表。最后从目标应用获取 Catalog。它不会创建或修改 Base、表、字段和记录。
|
|
134
161
|
|
|
135
|
-
两种路径必须且只能传入 `--schema` 或 `--base-token` 之一,并始终传入非空 `--description`。公开 CLI 的 `--env` 默认且只支持 `online
|
|
162
|
+
两种路径必须且只能传入 `--schema` 或 `--base-token` 之一,并始终传入非空 `--description`。公开 CLI 的 `--env` 默认且只支持 `online`;托管环境 使用已配置的默认环境。建表顺序与等待由 CLI 管理。
|
|
136
163
|
|
|
137
164
|
成功结果的 `baseSource` 和 `databaseSource` 分别为 `created` 或 `existing`;新建资源位于 `created`,复用资源位于 `reused`,同时列出表、应用、binding 和工程文件。开始开发前确认以下产物:
|
|
138
165
|
|
|
@@ -141,12 +168,25 @@ base-database.jsonc # 应用 appToken 与 Base binding
|
|
|
141
168
|
base-schema.json # 仅从零路径存在,是本次建库输入
|
|
142
169
|
catalog.json # 已绑定数据表的真实 schema
|
|
143
170
|
page/ # React 页面
|
|
144
|
-
|
|
171
|
+
database-functions/ # Database Functions
|
|
172
|
+
mutations/ # 基础写入声明
|
|
145
173
|
server-functions/ # 服务端 FaaS Functions
|
|
146
174
|
.base-database-cli/ # 被 Git 忽略的 CLI 本地状态与临时制品
|
|
147
175
|
```
|
|
148
176
|
|
|
149
|
-
|
|
177
|
+
旧工程中的 `sql/` 可继续执行 `check` 和 `deploy`,但不要与 `database-functions/` 同时存在。`pull` 恢复旧制品时会把 `sql/` 迁移为 `database-functions/`;新增和修改 Function 使用新目录。
|
|
178
|
+
|
|
179
|
+
只从 `catalog.json` 读取表名、字段名、ID、选项和查询类型,不根据建表输入猜测 Catalog 结果。
|
|
180
|
+
|
|
181
|
+
### 初始化失败与阶段回执
|
|
182
|
+
|
|
183
|
+
`--schema` 路径会在首个远端创建前校验整份 schema;按返回的字段路径修正。本地预检通过不代表权限、配额或服务端语义检查通过。
|
|
184
|
+
|
|
185
|
+
首次写入前,CLI 创建 `.base-database-cli/state/init.json`,持续记录已确认的资源 ID 和步骤结果。初始化失败或中断时保留该回执;`partial` 表示部分写入已成功,`unknown` 或残留的 `running` 表示结果尚未确认。
|
|
186
|
+
|
|
187
|
+
字段创建仅在完整逐项结果明确标记失败项 `retryable=true` 时自动做有限退避,并且只重发该失败字段;已创建项不会重发,后续 `not_attempted` 项在失败字段成功后继续。不要在外层再次自动重跑 `init`;限次耗尽、`retryable=false` 或结果未知时按回执状态处理。
|
|
188
|
+
|
|
189
|
+
普通 `init` 发现已有回执时会停止。回执中没有 `unknown` 或写入中的 `running` 时,可用原命令和原参数追加 `--resume`;CLI 先核对环境、profile、计划摘要及真实资源 ID,再跳过已确认步骤并补齐尚未开始或有完整逐项结果的字段。任一参数变化、资源漂移、未知写入或不完整字段结果都会在恢复写入前停止。恢复不按名称认领资源、不自动删除或整体回滚;需要放弃原计划时保留原回执,在新的空目录按已确认的 Base/应用重新初始化。
|
|
150
190
|
|
|
151
191
|
## 增量修改与追加绑定
|
|
152
192
|
|
|
@@ -163,7 +203,7 @@ base-database-cli lark-cli -- api GET /open-apis/base/v3/sites/<app-token>/catal
|
|
|
163
203
|
|
|
164
204
|
## 开发期调用边界
|
|
165
205
|
|
|
166
|
-
项目级 `base-database-cli lark-cli -- ...` 用于追加 binding
|
|
206
|
+
项目级 `base-database-cli lark-cli -- ...` 用于追加 binding、应用控制面诊断,以及新建 Base 的示例数据写入和 Database Function 回读验证;需在含 `base-database.jsonc` 的目录执行。其他原生 Base 发现和配置直接使用 `lark-cli base +...`。这些 CLI 操作不进入 Page/FaaS 运行时代码。
|
|
167
207
|
|
|
168
208
|
普通 `api` 请求(默认 JSON、`--json` 或 `--format json`)会将宿主自动落盘的 JSON 响应恢复为 stdout JSON,并清理本次临时文件,上传请求同样适用。真实文件下载显式使用 `--output`;该模式以及 `--jq`、`--page-all`、非 JSON 格式、标准输入请求、帮助和 dry-run 保留宿主原始行为。
|
|
169
209
|
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# {{Site name}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> {{One sentence describing who this site helps and what they can do}}
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!-- Template note: Write this README in the language of the user's original site-building request when it is Chinese, Japanese, or English; otherwise use English. Translate the headings and prose using the supported section names in the lark-base-database Skill. Replace every {{...}} placeholder before publishing. Remove this comment and any lines that do not apply. Describe only features that were implemented and verified. -->
|
|
6
|
+
|
|
7
|
+
## Background
|
|
8
|
+
|
|
9
|
+
- **Target users**: {{Who will use this site}}
|
|
10
|
+
- **Use cases**: {{When they will use it}}
|
|
11
|
+
- **Problem to solve**: {{Summarize the original request}}
|
|
12
|
+
|
|
13
|
+
## Requested features
|
|
14
|
+
|
|
15
|
+
1. {{Core feature from the original request}}
|
|
16
|
+
2. {{Another core feature from the original request}}
|
|
17
|
+
|
|
18
|
+
## Implemented capabilities
|
|
19
|
+
|
|
20
|
+
| User or role | Capability | Action and visible result |
|
|
21
|
+
| ------------ | ---------- | ------------------------- |
|
|
22
|
+
| {{User or role}} | {{Feature name}} | {{What users can actually do and see}} |
|
|
23
|
+
|
|
24
|
+
## Status and limitations
|
|
25
|
+
|
|
26
|
+
- **Verified**: {{Checks completed and their results}}
|
|
27
|
+
- **Unverified or unavailable**: {{Requested behavior and current limitations; write None if there are none}}
|
|
28
|
+
- **Demo entry**: Use the `baseAppUrl` delivered with this release. Do not pin a temporary Preview URL here.
|
|
29
|
+
|
|
30
|
+
## Local project
|
|
31
|
+
|
|
32
|
+
This directory contains Page, Database Function, Mutation declarations, and server-side FaaS Function source code. AI Function declarations, when used, live in `ai/`. Page and Server Functions are separate npm projects with their own `package.json` and `package-lock.json` files. The source and build workspace for server functions is `server-functions/`. Follow the installed `lark-base-database` Skill references for business and runtime contracts.
|
|
33
|
+
|
|
34
|
+
Run checks and deployment from the project root containing `base-database.jsonc`:
|
|
6
35
|
|
|
7
36
|
```bash
|
|
37
|
+
base-database-cli check --json
|
|
8
38
|
base-database-cli deploy
|
|
9
39
|
```
|
|
10
40
|
|
|
11
|
-
Server Functions
|
|
41
|
+
The CLI generates Page input types from Function metadata. Do not edit generated files by hand. Server Functions must keep a working `npm run build` script; generated output belongs in the Git-ignored `dist/` directory.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Database Functions
|
|
2
|
+
|
|
3
|
+
Place each Database Function in `database-functions/<functionId>/`:
|
|
4
|
+
|
|
5
|
+
- `main.sql`: Write a query using the supported Database Function syntax. Refer to parameters as `$1`, `$2`, and so on.
|
|
6
|
+
- `meta.json`: Declare `name`, `description`, and the parameter contract. Omit `meta` or `meta.params` when the query has no parameters.
|
|
7
|
+
|
|
8
|
+
Database Functions read Base data. Use `server-functions/functions/` for writes. See the `lark-base-database` Skill's `database-function.md` for parameter, response, Catalog, and SQL dialect contracts.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Mutation Functions
|
|
2
|
+
|
|
3
|
+
每个声明能完整表达的固定业务写入放在 `<functionId>/meta.json` 和 `<functionId>/spec.json`。表和字段必须来自根目录 `catalog.json`。
|
|
4
|
+
|
|
5
|
+
`meta.json` 示例:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{"name":"更新标题"}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`spec.json` 示例(替换真实 table / field ID):
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{"table":{"table_id":"tblTasks"},"operation":"update","params":[{"kind":"RECORD_ID"},{"kind":"TEXT","max_length":100}],"precondition":{"conjunction":"and","conditions":[{"field_id":"rec_id","operator":"is","param":1}]},"set":{"fldTitle":{"param":2}},"returning":["rec_id","fldTitle"]}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
单条调用 `invokeDatabaseFunction('updateTitle', ['recA', '新标题'])`;批量调用 `invokeDatabaseMutationBatch('updateTitle', [['recA', '标题 A'], ['recB', '标题 B']])`。编号从 1 开始;一批最多 200 条。CLI deploy 自动校验、打包并更新 Function,pull 保留声明。
|
|
18
|
+
|
|
19
|
+
Mutation 负责基础单表写入;create 不带 precondition,其他操作通过 precondition 指定记录 ID。需要服务端业务校验、计算或编排时使用 FaaS。字段、附件、权限边界和完整协议见已安装的 lark-base-database Skill 的 `references/mutations.md`。
|
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
# Page
|
|
2
2
|
|
|
3
|
-
React + TypeScript + Vite
|
|
3
|
+
React + TypeScript + Vite page project. This directory's `package.json` defines its dependencies, styling libraries, and scripts.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
See the `lark-base-database` Skill's `development.md` for `invokeDatabaseFunction`, response shapes, and Base read and write boundaries.
|
|
6
6
|
|
|
7
|
-
`vite.config.ts`
|
|
7
|
+
The relative path setting in `vite.config.ts` is required for deployment.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Built-in component language
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
`src/lib/database-runtime.ts` 是与宿主通信的唯一入口,基于
|
|
13
|
-
`@lark-base-open/base-site-channel/runtime` 提供:
|
|
11
|
+
The placeholder `App.tsx` page and the included user selector, account menu, edit button, page state, and attachment image components provide fixed Chinese, English, and Japanese interface text without a translation service. They resolve the language from the host Runtime Context locale, then the browser language, then English. The Page does not pass a language prop. When the host switches language and reloads the Page, they resolve it again. The starter HTML initially uses `lang="en"`; the resolved language updates that attribute. Replace the placeholder page before delivery. Application-specific text and runtime service errors remain the application's responsibility.
|
|
14
12
|
|
|
15
|
-
-
|
|
16
|
-
- `invokeDatabaseFunction(functionId, params)`:Function 调用,打统一网关的
|
|
17
|
-
`POST /space/api/bitable/site/v1/:token/invoke_function/:function_id`,请求体为 `{"params": ...}`
|
|
18
|
-
- `resolveDatabaseContext()`:解析应用 token 与 `prod` / `preview` 环境,**宿主下发优先**,
|
|
19
|
-
宿主未提供时回退 `getDatabaseContext()` 的产物路径推断;业务代码用这个异步版本
|
|
20
|
-
- `getDatabaseContext()`:同步的产物路径推断,仅作兜底,不要在业务代码里直接依赖
|
|
21
|
-
- `siteRuntime`:`ready()` 与 `reportLoadFailed()` 生命周期上报
|
|
13
|
+
Optional AI Function example components use the same language selection for their built-in text. See `src/examples/ai-function/README.md` before reusing or moving them.
|
|
22
14
|
|
|
23
|
-
|
|
15
|
+
## Runtime communication
|
|
24
16
|
|
|
25
|
-
|
|
17
|
+
The application runs in a BaseApp iframe. It does not hold login credentials or call business domains directly. `src/lib/database-runtime.ts` is the single entry point for communication with the host, using `@lark-base-open/base-site-channel/runtime`:
|
|
26
18
|
|
|
27
|
-
`
|
|
28
|
-
`
|
|
29
|
-
|
|
19
|
+
- `fetch` / `invokeHttp`: The parent page proxies business HTTP requests from its own origin. Business paths must start with a single `/`.
|
|
20
|
+
- `invokeDatabaseFunction(functionId, params)`: Calls `POST /space/api/bitable/site/v1/:token/invoke_function/:function_id` through the unified gateway with a `{"params": ...}` body.
|
|
21
|
+
- `src/lib/database-function-inputs.generated.ts`: The CLI generates Page input types from Database Function and FaaS metadata during `check` and Preview `deploy`. Do not edit this file. Page compilation checks Function IDs, query parameter order, and required FaaS fields and enum values. Callers still declare response types and validate them at runtime.
|
|
22
|
+
- `resolveDatabaseContext()`: Resolves the app token and `prod` or `preview` environment. Host-provided context takes precedence; otherwise it infers values from the artifact path through `getDatabaseContext()`. Use this asynchronous function in business code.
|
|
23
|
+
- `getDatabaseContext()`: Synchronous artifact-path inference for fallback use only.
|
|
24
|
+
- `callSiteAIFunction({ functionKey, capability, variables?, messages?, input? })`: Calls the configured AI Function and returns a discriminated result with `type: 'text' | 'image_task' | 'video_task'`. Poll media tasks by task ID and render by `result.type`.
|
|
25
|
+
- `invokeSiteAIFunctionStream({ functionKey, messages, variables? })`: Streams text or image understanding results. It provides subscribable updates and a `destroy()` method. Consume both `delta.reasoningContent` and `delta.content` and render them separately. See `src/examples/ai-function/TextStreamOperation.tsx`.
|
|
26
|
+
- `createSiteAIFunctionTask(params)` / `getSiteAIFunctionTask(functionKey, taskId)`: Submit and poll image or video generation tasks.
|
|
27
|
+
- `siteRuntime`: Reports lifecycle events through `ready()` and `reportLoadFailed()`.
|
|
28
|
+
|
|
29
|
+
Do not call `postMessage`, use the raw Channel Client, or fetch a business domain directly from business code.
|
|
30
|
+
|
|
31
|
+
Declare the model, System Prompt, reasoning depth, image size, video duration, and related settings in `ai/<functionKey>/meta.json` at the project root. Validate with `base-database-cli ai-functions validate <functionKey>` and sync through `deploy`. The page sends call-specific `variables` and `messages` or `input` for the selected `functionKey`. Preview uses the draft configuration; Prod uses it only after production publication. Before calling a Function, confirm that its `functionKey` has been synced and that `disabled` is not `true`.
|
|
32
|
+
|
|
33
|
+
## Request identity and CSRF
|
|
34
|
+
|
|
35
|
+
The parent page proxies business HTTP requests and handles identity and CSRF. The Page must not inject a CSRF script, read host cookies, or set a CSRF header itself. See the `lark-base-database` Skill's `verification.md` for migration and request troubleshooting.
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"name": "page",
|
|
9
9
|
"version": "0.0.0",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@lark-base-open/base-site-channel": "
|
|
12
|
-
"@lark-base-open/base-site-js": "https://lf3-static.bytednsdoc.com/obj/eden-cn/jjjpceh7nulojvhj/@lark-base-open-base-site-js-0.0.1-alpha.25.tgz",
|
|
11
|
+
"@lark-base-open/base-site-channel": "0.1.4",
|
|
13
12
|
"@radix-ui/react-slot": "^1.3.0",
|
|
14
13
|
"class-variance-authority": "^0.7.1",
|
|
15
14
|
"clsx": "^2.1.1",
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
"@types/react-dom": "^19.2.3",
|
|
26
25
|
"@vitejs/plugin-react": "^6.0.3",
|
|
27
26
|
"oxlint": "^1.42.0",
|
|
28
|
-
"prettier": "
|
|
27
|
+
"prettier": "3.6.2",
|
|
29
28
|
"tailwindcss": "^4.3.2",
|
|
30
29
|
"typescript": "~7.0.2",
|
|
31
30
|
"vite": "^8.1.4",
|
|
@@ -120,20 +119,13 @@
|
|
|
120
119
|
}
|
|
121
120
|
},
|
|
122
121
|
"node_modules/@lark-base-open/base-site-channel": {
|
|
123
|
-
"version": "0.
|
|
124
|
-
"resolved": "https://
|
|
125
|
-
"integrity": "sha512-
|
|
126
|
-
"license": "ISC",
|
|
122
|
+
"version": "0.1.4",
|
|
123
|
+
"resolved": "https://registry.npmjs.org/@lark-base-open/base-site-channel/-/base-site-channel-0.1.4.tgz",
|
|
124
|
+
"integrity": "sha512-QBl60LoxLr2kNjCHxiuXtFxegSrMPA11P0IufjOkoonNEvZz3CfDtFwhO+EbkOZahANMRyxEq3DhdpFgEm5QDQ==",
|
|
127
125
|
"dependencies": {
|
|
128
126
|
"lodash-es": "^4.17.21"
|
|
129
127
|
}
|
|
130
128
|
},
|
|
131
|
-
"node_modules/@lark-base-open/base-site-js": {
|
|
132
|
-
"version": "0.0.1-alpha.25",
|
|
133
|
-
"resolved": "https://lf3-static.bytednsdoc.com/obj/eden-cn/jjjpceh7nulojvhj/@lark-base-open-base-site-js-0.0.1-alpha.25.tgz",
|
|
134
|
-
"integrity": "sha512-FtdohEY5YrYIRGxL/FIU8dSQ4326nf7QDZHEZm1HE59RIBAvlkPnqZlE+8AuvQZ+3KL+vmg6ZPmxONlghFyhbw==",
|
|
135
|
-
"license": "ISC"
|
|
136
|
-
},
|
|
137
129
|
"node_modules/@napi-rs/wasm-runtime": {
|
|
138
130
|
"version": "1.1.6",
|
|
139
131
|
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz",
|
|
@@ -2254,9 +2246,9 @@
|
|
|
2254
2246
|
}
|
|
2255
2247
|
},
|
|
2256
2248
|
"node_modules/prettier": {
|
|
2257
|
-
"version": "3.
|
|
2258
|
-
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.
|
|
2259
|
-
"integrity": "sha512
|
|
2249
|
+
"version": "3.6.2",
|
|
2250
|
+
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
|
|
2251
|
+
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
|
|
2260
2252
|
"dev": true,
|
|
2261
2253
|
"license": "MIT",
|
|
2262
2254
|
"bin": {
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lark-base-open/base-site-channel": "
|
|
22
|
-
"@lark-base-open/base-site-js": "https://lf3-static.bytednsdoc.com/obj/eden-cn/jjjpceh7nulojvhj/@lark-base-open-base-site-js-0.0.1-alpha.25.tgz",
|
|
21
|
+
"@lark-base-open/base-site-channel": "0.1.4",
|
|
23
22
|
"@radix-ui/react-slot": "^1.3.0",
|
|
24
23
|
"class-variance-authority": "^0.7.1",
|
|
25
24
|
"clsx": "^2.1.1",
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
"@types/react-dom": "^19.2.3",
|
|
36
35
|
"@vitejs/plugin-react": "^6.0.3",
|
|
37
36
|
"oxlint": "^1.42.0",
|
|
38
|
-
"prettier": "
|
|
37
|
+
"prettier": "3.6.2",
|
|
39
38
|
"tailwindcss": "^4.3.2",
|
|
40
39
|
"typescript": "~7.0.2",
|
|
41
40
|
"vite": "^8.1.4",
|
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
import { useUiLanguage, type UiLanguage } from './lib/ui-language'
|
|
2
|
+
|
|
3
|
+
const APP_COPY = {
|
|
4
|
+
en: {
|
|
5
|
+
heading: 'Start with a real business workflow',
|
|
6
|
+
description:
|
|
7
|
+
'Build the interface with page components. Read Base data through Database Functions and write through FaaS Functions. Replace this starter content before delivery.',
|
|
8
|
+
},
|
|
9
|
+
zh: {
|
|
10
|
+
heading: '从真实业务任务开始构建',
|
|
11
|
+
description:
|
|
12
|
+
'使用页面组件承载交互,通过 Database Function 读取 Base 数据、通过 FaaS Function 写入,并在交付前替换这段起始内容。',
|
|
13
|
+
},
|
|
14
|
+
ja: {
|
|
15
|
+
heading: '実際の業務フローから構築を始めましょう',
|
|
16
|
+
description:
|
|
17
|
+
'ページコンポーネントで操作画面を作成します。Base データは Database Function で読み込み、FaaS Function で書き込みます。公開前にこの初期コンテンツを置き換えてください。',
|
|
18
|
+
},
|
|
19
|
+
} satisfies Record<UiLanguage, { heading: string; description: string }>
|
|
20
|
+
|
|
1
21
|
export default function App() {
|
|
22
|
+
const copy = APP_COPY[useUiLanguage()]
|
|
2
23
|
return (
|
|
3
24
|
<main className="flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground">
|
|
4
25
|
<section className="w-full max-w-2xl rounded-3xl border border-border bg-card p-8 shadow-sm sm:p-12">
|
|
@@ -6,11 +27,10 @@ export default function App() {
|
|
|
6
27
|
Base Database
|
|
7
28
|
</p>
|
|
8
29
|
<h1 className="mt-4 text-3xl font-semibold tracking-tight text-balance sm:text-5xl">
|
|
9
|
-
|
|
30
|
+
{copy.heading}
|
|
10
31
|
</h1>
|
|
11
32
|
<p className="mt-5 max-w-xl text-base leading-7 text-muted-foreground sm:text-lg">
|
|
12
|
-
|
|
13
|
-
FaaS,并在交付前替换这段起始内容。
|
|
33
|
+
{copy.description}
|
|
14
34
|
</p>
|
|
15
35
|
</section>
|
|
16
36
|
</main>
|
|
@@ -9,6 +9,7 @@ import React, {
|
|
|
9
9
|
} from 'react'
|
|
10
10
|
|
|
11
11
|
import { cn } from '../../lib/cn'
|
|
12
|
+
import { useUiLanguage, type UiLanguage } from '../../lib/ui-language'
|
|
12
13
|
import UserSelectorPanel, {
|
|
13
14
|
type User,
|
|
14
15
|
type UserSelectorAction,
|
|
@@ -38,6 +39,31 @@ export interface UserSelectorEditorProps {
|
|
|
38
39
|
onBlur?: FocusEventHandler<HTMLButtonElement>
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
const USER_SELECTOR_EDITOR_COPY = {
|
|
43
|
+
en: {
|
|
44
|
+
clearSelected: 'Clear selected members',
|
|
45
|
+
removeMember: (name: string) => `Remove member ${name}`,
|
|
46
|
+
selectMembers: 'Select members',
|
|
47
|
+
},
|
|
48
|
+
zh: {
|
|
49
|
+
clearSelected: '清除已选成员',
|
|
50
|
+
removeMember: (name: string) => `移除成员 ${name}`,
|
|
51
|
+
selectMembers: '选择成员',
|
|
52
|
+
},
|
|
53
|
+
ja: {
|
|
54
|
+
clearSelected: '選択したメンバーをクリア',
|
|
55
|
+
removeMember: (name: string) => `メンバー ${name} を削除`,
|
|
56
|
+
selectMembers: 'メンバーを選択',
|
|
57
|
+
},
|
|
58
|
+
} satisfies Record<
|
|
59
|
+
UiLanguage,
|
|
60
|
+
{
|
|
61
|
+
clearSelected: string
|
|
62
|
+
removeMember: (name: string) => string
|
|
63
|
+
selectMembers: string
|
|
64
|
+
}
|
|
65
|
+
>
|
|
66
|
+
|
|
41
67
|
/**
|
|
42
68
|
* 展示受控成员值,并闭环管理 UserSelectorPanel 的打开、关闭与值回传。
|
|
43
69
|
*/
|
|
@@ -61,6 +87,8 @@ export default function UserSelectorEditor(
|
|
|
61
87
|
onFocus,
|
|
62
88
|
onBlur,
|
|
63
89
|
} = props
|
|
90
|
+
const uiLanguage = useUiLanguage()
|
|
91
|
+
const i18n = USER_SELECTOR_EDITOR_COPY[uiLanguage]
|
|
64
92
|
const [open, setOpen] = useState(false)
|
|
65
93
|
const rootRef = useRef<HTMLDivElement>(null)
|
|
66
94
|
const panelOpen = open
|
|
@@ -175,8 +203,8 @@ export default function UserSelectorEditor(
|
|
|
175
203
|
<button
|
|
176
204
|
aria-label={
|
|
177
205
|
isMultiple
|
|
178
|
-
?
|
|
179
|
-
:
|
|
206
|
+
? i18n.removeMember(selectedUser.name)
|
|
207
|
+
: i18n.clearSelected
|
|
180
208
|
}
|
|
181
209
|
className="relative ml-0 flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 !text-[#646a73] outline-none hover:!text-[#0442d2]"
|
|
182
210
|
onClick={(event) => {
|
|
@@ -214,7 +242,7 @@ export default function UserSelectorEditor(
|
|
|
214
242
|
))
|
|
215
243
|
) : (
|
|
216
244
|
<button
|
|
217
|
-
aria-label=
|
|
245
|
+
aria-label={i18n.selectMembers}
|
|
218
246
|
aria-expanded={panelOpen}
|
|
219
247
|
aria-haspopup="listbox"
|
|
220
248
|
className="flex h-full min-w-0 flex-1 items-center gap-1 border-0 bg-transparent p-0 text-left text-inherit outline-none"
|
|
@@ -223,7 +251,7 @@ export default function UserSelectorEditor(
|
|
|
223
251
|
type="button"
|
|
224
252
|
>
|
|
225
253
|
<span className="min-w-0 flex-1 truncate text-[#8f959e]">
|
|
226
|
-
|
|
254
|
+
{i18n.selectMembers}
|
|
227
255
|
</span>
|
|
228
256
|
</button>
|
|
229
257
|
)}
|