@lark-base-open/base-database-cli 1.1.0 → 1.3.7
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 +86 -0
- package/LICENSE +6 -0
- package/README.md +55 -31
- package/dist/ai-functions.d.ts +42 -0
- package/dist/ai-functions.d.ts.map +1 -0
- package/dist/ai-functions.js +327 -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 +65 -10
- package/dist/archive.js.map +1 -1
- package/dist/auth.d.ts +8 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +60 -6
- 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 +1 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +122 -175
- 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 +14 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +886 -243
- package/dist/init.js.map +1 -1
- package/dist/lark-cli-error.d.ts +46 -0
- package/dist/lark-cli-error.d.ts.map +1 -0
- package/dist/lark-cli-error.js +171 -0
- package/dist/lark-cli-error.js.map +1 -0
- package/dist/lark-cli.d.ts +2 -1
- package/dist/lark-cli.d.ts.map +1 -1
- package/dist/lark-cli.js +292 -29
- 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 +241 -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 +81 -0
- package/dist/public-sql-error.js.map +1 -0
- package/dist/pull.d.ts.map +1 -1
- package/dist/pull.js +54 -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 +70 -53
- package/skills/lark-base-database/references/ai-function.md +471 -0
- package/skills/lark-base-database/references/base-capability-routing.md +3 -3
- package/skills/lark-base-database/references/database-function-limitations.md +46 -0
- package/skills/lark-base-database/references/database-function.md +349 -0
- package/skills/lark-base-database/references/design/components/actions-fields.md +16 -0
- package/skills/lark-base-database/references/design/components/code/controls.css +122 -0
- package/skills/lark-base-database/references/design/components/code/controls.tsx +73 -0
- package/skills/lark-base-database/references/design/components/code/date-picker.tsx +42 -0
- package/skills/lark-base-database/references/design/components/code/floating.tsx +41 -0
- package/skills/lark-base-database/references/design/components/code/overlays.tsx +19 -0
- package/skills/lark-base-database/references/design/components/code/select.tsx +34 -0
- package/skills/lark-base-database/references/design/components/code/styles.d.ts +1 -0
- package/skills/lark-base-database/references/design/components/code/theme.css +49 -0
- package/skills/lark-base-database/references/design/components/code/usage.tsx +38 -0
- package/skills/lark-base-database/references/design/components/date-time-number.md +9 -0
- package/skills/lark-base-database/references/design/components/feedback-navigation.md +9 -0
- package/skills/lark-base-database/references/design/components/index.md +18 -0
- package/skills/lark-base-database/references/design/components/overlays.md +9 -0
- package/skills/lark-base-database/references/design/components/patterns/flat-business.md +7 -0
- package/skills/lark-base-database/references/design/components/selection.md +24 -0
- package/skills/lark-base-database/references/design/components.md +91 -0
- package/skills/lark-base-database/references/design/composition.md +90 -0
- package/skills/lark-base-database/references/design/control-recipes.md +107 -0
- package/skills/lark-base-database/references/design/examples.md +172 -0
- package/skills/lark-base-database/references/design/foundations.md +126 -0
- package/skills/lark-base-database/references/design/review.md +82 -0
- package/skills/lark-base-database/references/design/scenes/analysis-report.md +66 -0
- package/skills/lark-base-database/references/design/scenes/brand-showcase.md +70 -0
- package/skills/lark-base-database/references/design/scenes/business-operations.md +85 -0
- package/skills/lark-base-database/references/design/scenes/campaign-report.md +66 -0
- package/skills/lark-base-database/references/design/scenes/dashboard.md +77 -0
- package/skills/lark-base-database/references/design/scenes/festive-campaign.md +69 -0
- package/skills/lark-base-database/references/design/theme.md +27 -0
- package/skills/lark-base-database/references/design/typography.md +56 -0
- package/skills/lark-base-database/references/development.md +165 -32
- package/skills/lark-base-database/references/environment-variables.md +55 -0
- package/skills/lark-base-database/references/faas.md +41 -48
- package/skills/lark-base-database/references/file-transfer.md +25 -25
- package/skills/lark-base-database/references/frontend-design-guide.md +33 -77
- package/skills/lark-base-database/references/mutations.md +295 -0
- package/skills/lark-base-database/references/permission-design.md +24 -24
- package/skills/lark-base-database/references/release.md +54 -27
- package/skills/lark-base-database/references/style-guide.md +10 -67
- package/skills/lark-base-database/references/verification.md +17 -13
- package/skills/lark-base-database/references/workspace.md +71 -22
- package/templates/database-starter/README.md +34 -4
- package/templates/database-starter/database-functions/README.md +8 -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/index.tsx +75 -112
- 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 -151
- 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,26 +11,60 @@ 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
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。
|
|
36
|
+
|
|
37
|
+
| 能力 | 使用方式与缺失时处理 |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `api`、本任务需要的 `base` 命令 | 业务所需能力;按当前帮助和协议执行,真实认证、权限或接口错误按失败阶段处理 |
|
|
40
|
+
| `config` / `auth` | 本地账号管理能力。宿主提供认证时不补建 `default` profile;宿主缺少管理命令但通过 `LARKSUITE_CLI_PROFILE` 选择托管凭证时保留该环境变量,不传宿主禁止的 `--profile` 参数,由真实业务请求校验 profile,不回退账号 |
|
|
41
|
+
| `skills read` | 可选的文档入口。存在时读取 `lark-base` 并沿路由找 reference;不存在时直接读取环境提供的 lark-base 文件与相应命令帮助,后续不反复尝试该入口 |
|
|
42
|
+
| `doctor` | 排障入口,不是每次业务操作的必经步骤。先区分管理命令缺失与实际接口失败;旧版 CLI 因缺少管理命令无法继续时报告兼容性阻塞,不伪造配置、认证回执或修改已安装 CLI 来绕过 |
|
|
43
|
+
|
|
44
|
+
自动选择失败时,仅使用当前环境已确认的可执行文件绝对路径设置 `BASE_DATABASE_LARK_CLI_PATH`;不全盘搜索、循环重装或替换宿主认证。只有发生真实认证、身份或 scope 错误时才读取 lark-shared 并恢复原身份,不主动重登或切换 bot。
|
|
19
45
|
|
|
20
46
|
## 先选择工程来源
|
|
21
47
|
|
|
48
|
+
需要确认当前本地工程状态时,先执行一次只读快照:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
base-database-cli context . --summary --json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
它只汇总本地配置、Catalog、Function metadata、init/Preview 回执和部署输入 fingerprint;不认证、不访问远端、不构建或发布。摘要保留决策所需的状态、资源数量、readiness 和 next action,不输出本地路径、fingerprint 值或逐项资源。需要排障时去掉 `--summary` 查看完整快照。`project.status=uninitialized` 表示当前目录缺少 `base-database.jsonc`,按下述工程来源选择 init 或 pull,不能仅凭空目录自行推断远端来源。不要从快照推断运行态、权限或发布成功。
|
|
55
|
+
|
|
22
56
|
托管环境先读取 `BASE_SITE_BUILDER_WORKSPACE_SOURCE`,按宿主决定执行,不根据空目录自行推断:
|
|
23
57
|
|
|
24
|
-
| 来源
|
|
25
|
-
|
|
|
26
|
-
| `snapshot` | 读取现有配置、Catalog、源码和本地修改
|
|
27
|
-
| `artifact` | `base-database-cli pull . --app-token "$BASE_SITE_BUILDER_SITE_TOKEN"`
|
|
28
|
-
| `binding`
|
|
29
|
-
| `empty`
|
|
58
|
+
| 来源 | 第一项工程操作 | 约束 |
|
|
59
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
60
|
+
| `snapshot` | 读取现有配置、Catalog、源码和本地修改 | 不执行 init/pull |
|
|
61
|
+
| `artifact` | `base-database-cli pull . --app-token "$BASE_SITE_BUILDER_SITE_TOKEN"` | pull 失败停止恢复,不退回 init |
|
|
62
|
+
| `binding` | `base-database-cli init . --app-token "$BASE_SITE_BUILDER_SITE_TOKEN" --base-token "$BASE_SITE_BUILDER_BASE_TOKEN" --name '<应用 名称>' --description '<应用 描述>'` | 已有一个 Base 绑定但无可恢复源码;只初始化一次,复用现有 应用 与 Base,不新建资源 |
|
|
63
|
+
| `empty` | 执行带 `--app-token "$BASE_SITE_BUILDER_SITE_TOKEN"` 的 init | 复用宿主 应用,不创建另一 应用 |
|
|
30
64
|
|
|
31
65
|
上述四种来源与宿主工程恢复协议一致。`binding` 还必须有非空 `BASE_SITE_BUILDER_BASE_TOKEN`,应用 名称与描述从当前需求确定。宿主变量存在但取值不在表中、必需 token 缺失或工程与宿主状态矛盾时,报告恢复条件不满足,不创建新资源掩盖问题。会话历史未恢复但工程有效时,先读取现有工程继续;没有工程的合法 binding 模式仍执行表中的恢复路径。
|
|
32
66
|
|
|
33
|
-
非托管环境:已有工程直接增量修改;只有远端 应用 时,在空目录执行 `
|
|
67
|
+
非托管环境:已有工程直接增量修改;只有远端 应用 时,在空目录执行 `base-database-cli pull . --app-token <app-token> --env online`;确认为新建时才 init。保留用户未提交内容,不能以恢复工程为由覆盖非空目录。
|
|
34
68
|
|
|
35
69
|
## 需求与 Base 定位
|
|
36
70
|
|
|
@@ -44,17 +78,17 @@ profile 决定账号与品牌,`--env` 决定运行环境。profile 缺失、
|
|
|
44
78
|
|
|
45
79
|
## 初始化
|
|
46
80
|
|
|
47
|
-
初始化前检查 `BASE_SITE_BUILDER_SITE_TOKEN`。变量非空表示宿主已经创建目标 应用:使用
|
|
81
|
+
初始化前检查 `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` 请求,也不要用新 应用 掩盖绑定失败。
|
|
48
82
|
|
|
49
83
|
### 从零创建 Base
|
|
50
84
|
|
|
51
|
-
编写 schema
|
|
85
|
+
编写 schema 前,按已确认的文档入口读取字段规范:支持 `skills read` 时执行 `lark-cli skills read lark-base references/lark-base-field-schema.md`;否则直接读取环境中 lark-base 的对应 reference,并用 `lark-cli base +table-create --help` 核对当前命令契约,不再尝试已知缺失的入口。不要猜测属性。`tables[].fields` 使用与 `lark-cli base +base-create/+table-create --fields` 相同的字段定义;init 会先创建每张表的主字段,取得全部真实表 ID 后再按原顺序创建其余字段。
|
|
52
86
|
|
|
53
87
|
- 首个字段成为表的主字段,优先采用可读的文本标识;其他类型先核对主字段限制。
|
|
54
88
|
- 单选和多选都用 `select`,多选显式设置 `"multiple": true`,选项按字段规范声明。
|
|
55
|
-
- `link` 字段必须提供 `link_table
|
|
89
|
+
- `link` 字段必须提供 `link_table`,且名称与本次 Schema 中的目标表完全一致;自关联和跨表关联会在所有表创建后补建,不需要按关联依赖调整表顺序。
|
|
56
90
|
- `datetime.style.format` 使用当前 Base 支持的固定枚举,不能自行增加秒级展示格式;底层时间精度与展示格式分别处理。
|
|
57
|
-
- 创建字段的 schema
|
|
91
|
+
- 创建字段的 schema、查询类型与记录 CellValue 是不同协议,不互相替代。
|
|
58
92
|
|
|
59
93
|
把全部表写入一个 schema 文件。这个文件是 `init` 的输入,不是平台请求缓存:
|
|
60
94
|
|
|
@@ -90,14 +124,14 @@ profile 决定账号与品牌,`--env` 决定运行环境。profile 缺失、
|
|
|
90
124
|
在项目目录执行初始化命令:
|
|
91
125
|
|
|
92
126
|
```bash
|
|
93
|
-
|
|
127
|
+
base-database-cli init . \
|
|
94
128
|
--env online \
|
|
95
129
|
--name 'Todo 管理' \
|
|
96
130
|
--description '供个人集中创建、跟踪和完成日常任务' \
|
|
97
131
|
--schema ./base-schema.json
|
|
98
132
|
```
|
|
99
133
|
|
|
100
|
-
|
|
134
|
+
托管环境 已有 应用 场景执行:
|
|
101
135
|
|
|
102
136
|
```bash
|
|
103
137
|
base-database-cli init . \
|
|
@@ -112,18 +146,18 @@ base-database-cli init . \
|
|
|
112
146
|
取得已有 Base 的 `bas...` token 后执行:
|
|
113
147
|
|
|
114
148
|
```bash
|
|
115
|
-
|
|
149
|
+
base-database-cli init . \
|
|
116
150
|
--env online \
|
|
117
151
|
--name 'Todo 管理' \
|
|
118
152
|
--description '供个人集中创建、跟踪和完成日常任务' \
|
|
119
153
|
--base-token basxxxxxxxx
|
|
120
154
|
```
|
|
121
155
|
|
|
122
|
-
|
|
156
|
+
托管环境 复用已有 Base 与已有 应用 时,同样改用 `base-database-cli init` 并追加 `--app-token "$BASE_SITE_BUILDER_SITE_TOKEN"`。
|
|
123
157
|
|
|
124
158
|
该命令调用只读 Base 接口获取 Base 信息并分页列出全部表。未指定 `--app-token` 时,通过 应用 创建接口的 `baseBindings` 绑定这些表;指定时,通过目标 应用 的 `bind_base` 绑定这些表。最后从目标 应用 获取 Catalog。它不会创建或修改 Base、表、字段和记录。
|
|
125
159
|
|
|
126
|
-
两种路径必须且只能传入 `--schema` 或 `--base-token` 之一,并始终传入非空 `--description`。公开 CLI 的 `--env` 默认且只支持 `online
|
|
160
|
+
两种路径必须且只能传入 `--schema` 或 `--base-token` 之一,并始终传入非空 `--description`。公开 CLI 的 `--env` 默认且只支持 `online`;托管环境 使用已配置的默认环境。建表顺序与等待由 CLI 管理。
|
|
127
161
|
|
|
128
162
|
成功结果的 `baseSource` 和 `databaseSource` 分别为 `created` 或 `existing`;新建资源位于 `created`,复用资源位于 `reused`,同时列出表、应用、binding 和工程文件。开始开发前确认以下产物:
|
|
129
163
|
|
|
@@ -132,12 +166,25 @@ base-database.jsonc # 应用 appToken 与 Base binding
|
|
|
132
166
|
base-schema.json # 仅从零路径存在,是本次建库输入
|
|
133
167
|
catalog.json # 已绑定数据表的真实 schema
|
|
134
168
|
page/ # React 页面
|
|
135
|
-
|
|
169
|
+
database-functions/ # Database Functions
|
|
170
|
+
mutations/ # 基础写入声明
|
|
136
171
|
server-functions/ # 服务端 FaaS Functions
|
|
137
172
|
.base-database-cli/ # 被 Git 忽略的 CLI 本地状态与临时制品
|
|
138
173
|
```
|
|
139
174
|
|
|
140
|
-
|
|
175
|
+
旧工程中的 `sql/` 可继续执行 `check` 和 `deploy`,但不要与 `database-functions/` 同时存在。`pull` 恢复旧制品时会把 `sql/` 迁移为 `database-functions/`;新增和修改 Function 使用新目录。
|
|
176
|
+
|
|
177
|
+
只从 `catalog.json` 读取表名、字段名、ID、选项和查询类型,不根据建表输入猜测 Catalog 结果。
|
|
178
|
+
|
|
179
|
+
### 初始化失败与阶段回执
|
|
180
|
+
|
|
181
|
+
`--schema` 路径会在首个远端创建前校验整份 schema;按返回的字段路径修正。本地预检通过不代表权限、配额或服务端语义检查通过。
|
|
182
|
+
|
|
183
|
+
首次写入前,CLI 创建 `.base-database-cli/state/init.json`,持续记录已确认的资源 ID 和步骤结果。初始化失败或中断时保留该回执;`partial` 表示部分写入已成功,`unknown` 或残留的 `running` 表示结果尚未确认。
|
|
184
|
+
|
|
185
|
+
字段创建仅在完整逐项结果明确标记失败项 `retryable=true` 时自动做有限退避,并且只重发该失败字段;已创建项不会重发,后续 `not_attempted` 项在失败字段成功后继续。不要在外层再次自动重跑 `init`;限次耗尽、`retryable=false` 或结果未知时按回执状态处理。
|
|
186
|
+
|
|
187
|
+
普通 `init` 发现已有回执时会停止。回执中没有 `unknown` 或写入中的 `running` 时,可用原命令和原参数追加 `--resume`;CLI 先核对环境、profile、计划摘要及真实资源 ID,再跳过已确认步骤并补齐尚未开始或有完整逐项结果的字段。任一参数变化、资源漂移、未知写入或不完整字段结果都会在恢复写入前停止。恢复不按名称认领资源、不自动删除或整体回滚;需要放弃原计划时保留原回执,在新的空目录按已确认的 Base/应用重新初始化。
|
|
141
188
|
|
|
142
189
|
## 增量修改与追加绑定
|
|
143
190
|
|
|
@@ -146,14 +193,16 @@ server-functions/ # 服务端 FaaS Functions
|
|
|
146
193
|
需要绑定同一 Base 中的新表时,不重新执行 init 或 pull。先从 `lark-cli base +table-list/get` 的真实结果取得 ID,再在项目根目录执行:
|
|
147
194
|
|
|
148
195
|
```bash
|
|
149
|
-
|
|
150
|
-
|
|
196
|
+
base-database-cli lark-cli -- api POST /open-apis/base/v3/sites/<app-token>/bind_base --data '{"baseToken":"<base-token>","tableIds":["<table-id>"]}' --json
|
|
197
|
+
base-database-cli lark-cli -- api GET /open-apis/base/v3/sites/<app-token>/catalog --json
|
|
151
198
|
```
|
|
152
199
|
|
|
153
200
|
`bind_base` 只向同一 Base 追加并去重 Table ID,不覆盖原绑定。将 Catalog 返回 envelope 的 `data` 对象写入 `catalog.json`;在 `base-database.jsonc` 保留原 binding 并合并新 `tableIds`。删除本地 ID 不会触发远程解绑;真实解绑遵守[外部操作与授权](../SKILL.md#外部操作与授权)。
|
|
154
201
|
|
|
155
202
|
## 开发期调用边界
|
|
156
203
|
|
|
157
|
-
项目级 `
|
|
204
|
+
项目级 `base-database-cli lark-cli -- ...` 用于追加 binding、应用 控制面诊断,以及新建 Base 的示例数据写入和 Database Function 回读验证;需在含 `base-database.jsonc` 的目录执行。其他原生 Base 发现和配置直接使用 `lark-cli base +...`。这些 CLI 操作不进入 Page/FaaS 运行时代码。
|
|
205
|
+
|
|
206
|
+
普通 `api` 请求(默认 JSON、`--json` 或 `--format json`)会将宿主自动落盘的 JSON 响应恢复为 stdout JSON,并清理本次临时文件,上传请求同样适用。真实文件下载显式使用 `--output`;该模式以及 `--jq`、`--page-all`、非 JSON 格式、标准输入请求、帮助和 dry-run 保留宿主原始行为。
|
|
158
207
|
|
|
159
208
|
初始化成功后进入[开发阶段路由](../SKILL.md#开发阶段路由),实现完成后按[发布与交付](release.md)处理。
|
|
@@ -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.3",
|
|
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.3",
|
|
123
|
+
"resolved": "https://registry.npmjs.org/@lark-base-open/base-site-channel/-/base-site-channel-0.1.3.tgz",
|
|
124
|
+
"integrity": "sha512-wdc8zRkAX2P7pwBkyoun7oHrUP95xYCgAhhwsq4cUOg7ozIf9Em1DQken7kUeMc58pzDM5ONroWavoa1/oQiEg==",
|
|
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.3",
|
|
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
|
)}
|