@lark-base-open/base-database-app-sdk 0.5.0-durable.0 → 0.5.1
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 +25 -73
- package/README.md +4 -40
- package/capabilities.json +7 -1
- package/dist/chunk-OF7TEKK6.js +1 -0
- package/dist/components.js +1 -1
- package/dist/page.js +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -1
- package/dist/testing.d.ts +1 -2
- package/dist/theme.css +129 -8
- package/docs/README.md +1 -1
- package/docs/capabilities.md +3 -2
- package/docs/codegen.md +3 -3
- package/docs/compat.md +2 -2
- package/docs/components.md +2 -2
- package/docs/exports.md +2 -14
- package/docs/page.md +4 -4
- package/docs/server.md +4 -4
- package/docs/shared.md +1 -1
- package/docs/start-base-app.md +6 -8
- package/docs/testing.md +4 -24
- package/docs/upgrade.md +73 -0
- package/examples/upgrade.ts +1 -1
- package/package.json +3 -63
- package/dist/chunk-KJQ3P646.js +0 -1
- package/dist/durable/activity.cjs +0 -25
- package/dist/durable/activity.d.cts +0 -6
- package/dist/durable/activity.d.ts +0 -6
- package/dist/durable/workflow.cjs +0 -107
- package/dist/durable/workflow.d.cts +0 -15
- package/dist/durable/workflow.d.ts +0 -15
- package/docs/durable.md +0 -54
- package/examples/durable-activities.ts +0 -3
- package/examples/durable-workflow.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.5.1 - 2026-10-27
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- 完善错误监控。
|
|
8
|
+
|
|
9
|
+
## 0.5.0 - 2026-10-27
|
|
4
10
|
|
|
5
11
|
### Added
|
|
6
12
|
|
|
7
|
-
-
|
|
13
|
+
- 页面启动时向平台报告所用的 SDK 版本,便于排查问题。
|
|
14
|
+
- 页面出现未处理的错误时,错误信息会上报给平台;内容会截断,并去掉链接里的参数。
|
|
15
|
+
|
|
16
|
+
## 0.4.2 - 2026-10-26
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- 悬浮编辑控件的中文隐藏提示改为“隐藏”,悬停关闭按钮时编辑图标保持高亮。
|
|
21
|
+
- 修复隐藏通知在常见屏宽下意外换行的问题;极窄屏幕下保留完整文案并自然换行。
|
|
22
|
+
|
|
23
|
+
## 0.4.1 - 2026-10-26
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- 恢复悬浮编辑按钮、隐藏按钮和隐藏提示的样式。
|
|
28
|
+
- 修复悬浮按钮提示框在窄屏和左右定位时超出视口的问题。
|
|
8
29
|
|
|
9
30
|
## 0.4.0 - 2026-10-23
|
|
10
31
|
|
|
@@ -42,41 +63,7 @@
|
|
|
42
63
|
|
|
43
64
|
- 批量 Mutation 调用只能使用已生成契约中的 Mutation ID,每组参数与返回值按该 ID 推断;移除调用方指定返回类型的泛型,错误 ID、错误参数或缺少契约映射会在编译时失败。
|
|
44
65
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#### 会坏什么
|
|
48
|
-
|
|
49
|
-
`invokeDatabaseMutationBatch<MyType>` 不再接受调用方指定的返回类型。任意字符串 ID、非 Mutation ID、错误参数及缺少生成映射的旧调用会编译失败;动态 ID 必须与它对应的参数保持关联。Mutation 无输出 Schema 时,生成结果由 `unknown` 变为平台固定的 `DatabaseMutationResult`。HTTP 请求和一层响应 envelope 保持原协议;从 0.1.x 升级还须完成下方 0.2.0 的不兼容迁移。
|
|
50
|
-
|
|
51
|
-
#### 怎么在代码里找受影响处
|
|
52
|
-
|
|
53
|
-
在 Page 源码中定位 Mutation 调用及结果处理,再核对对应的 `mutations/<functionId>/spec.json`。例如在工程根运行:
|
|
54
|
-
|
|
55
|
-
```sh
|
|
56
|
-
rg -n -U 'invokeDatabaseMutationBatch\s*<' page/src
|
|
57
|
-
rg -n 'invokeDatabaseFunction|invokeDatabaseMutationBatch|record_ids|record_not_found|ignored_fields' page/src
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
核对批量调用的真实 SDK 导入来源、ID 对应的 Mutation 声明,以及每组参数的名称、类型和必填字段;检查宽泛的字符串 ID、联合 ID 与参数错配。再定位手写的 Mutation 返回类型、平台字段结构校验及处理 `unknown` 的类型断言,保留应用自有业务校验。
|
|
61
|
-
|
|
62
|
-
#### 修改步骤
|
|
63
|
-
|
|
64
|
-
1. 使用配套 CLI 和同包 Skill。用户授权升级后,将 Page 和 Server 的 SDK 依赖一起升级到目标版本并更新锁文件;单独升级 CLI 不会更换工程内的 SDK。
|
|
65
|
-
2. 运行 `base-database-cli contracts generate`,由工程内 SDK 更新输入、输出及 Mutation ID 映射;不手改生成文件。没有 Mutation 标记或任一输入/输出映射时,先核对 Function 声明与 codegen 结果。
|
|
66
|
-
3. 删除批量 helper 的返回泛型,使用已声明的 Mutation ID 和对应的命名参数对象数组。动态选择 ID 时同时保留其参数关联,不用强转或宽泛类型回退消除错误。直接调用和批量调用都按 ID 推断结果;无输出 Schema 时使用 `DatabaseMutationResult`,需要引用时从 SDK `/page` 导入,删除重复的本地类型和平台结构校验。
|
|
67
|
-
4. 保留顶层 `code`、`data` 缺失、`record_not_found` / `ignored_fields` 部分失败及预期写入数量的业务检查。FaaS 无输出 Schema 时仍为 `unknown`,不按 Mutation 处理。
|
|
68
|
-
|
|
69
|
-
#### 验证命令
|
|
70
|
-
|
|
71
|
-
在 workspace 工程根运行:
|
|
72
|
-
|
|
73
|
-
```sh
|
|
74
|
-
base-database-cli contracts generate
|
|
75
|
-
base-database-cli check --json
|
|
76
|
-
npm run build --workspace page
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
classic 工程的 Page 构建改用 `npm run build --prefix page`。确认生成结果包含 Mutation ID 与输入/输出映射,错误 ID、参数和手写返回泛型被编译拒绝,并覆盖完整成功、部分失败及结果缺失的业务分支;本地构建通过不代表远端写入或权限验收完成。
|
|
66
|
+
- 升级步骤见[升级指引](docs/upgrade.md)。
|
|
80
67
|
|
|
81
68
|
## 0.2.0 - 2026-10-16
|
|
82
69
|
|
|
@@ -85,39 +72,4 @@ classic 工程的 Page 构建改用 `npm run build --prefix page`。确认生成
|
|
|
85
72
|
- `invokeDatabaseFunction` 现在按 Function ID 推断 `data` 类型。SQL Function 的 `data` 是 `{ rows: Row[] }`,而不是行数组;无可信行 Schema 时 `Row` 为 `unknown`。
|
|
86
73
|
- 未生成输出映射的 Function ID 在类型检查时被拒绝。FaaS 或 Mutation 没有输出 Schema 时,`data` 为 `unknown`,调用方不能再使用 `invokeDatabaseFunction<MyType>` 自行指定返回类型。
|
|
87
74
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
#### 会坏什么
|
|
91
|
-
|
|
92
|
-
`invokeDatabaseFunction<MyType>` 不再接受调用方指定的返回类型,结果由 Function ID 对应的生成映射决定;没有生成映射的 ID 会被类型检查拒绝。SQL 的 `data` 是含 `rows` 的对象,无可信列 Schema 时行类型为 `unknown`。本次改变编译期契约,不改变一层 `{code,msg,data}` 的运行时响应。
|
|
93
|
-
|
|
94
|
-
#### 怎么在代码里找受影响处
|
|
95
|
-
|
|
96
|
-
在工程根定位直接调用、旧返回泛型及结果处理;重新导出或自定义包装的调用也要核对:
|
|
97
|
-
|
|
98
|
-
```sh
|
|
99
|
-
rg -n -U 'invokeDatabaseFunction\s*<' page/src
|
|
100
|
-
rg -n 'invokeDatabaseFunction|invokeDatabaseMutationBatch|result\.data|FunctionInputMap|FunctionOutputMap' page/src
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
重点检查把 SQL `data` 当成数组、二次解包 `data`、手写模块扩充,以及用 `as` 或 `any` 绕过返回类型的地方。classic 自有 helper 的泛型不属于 SDK API,须先核对真实导入来源。
|
|
104
|
-
|
|
105
|
-
#### 修改步骤
|
|
106
|
-
|
|
107
|
-
1. 先使用支持 Function 输出映射的配套 CLI 和同包 Skill。旧 CLI 若未向 codegen 传递 `functionType`,先升级 CLI;CLI 更新不会自动升级工程 SDK。
|
|
108
|
-
2. 未获用户授权时保留工程依赖,按实际安装版本的包内 docs 开发。获授权后,将 Page 和 Server 的 SDK 一起升级到目标版本并更新锁文件;跨多个不兼容版本时逐一阅读 Migration。
|
|
109
|
-
3. 运行 `base-database-cli contracts generate`,生成输入和输出映射。纯 SQL 工程也要生成;已有生成客户端提供模块扩充时复用其唯一来源,不手改生成文件或重复声明扩充。
|
|
110
|
-
4. 删除 SDK 直接调用中的手写返回泛型,按 Function ID 推断类型。SQL 先检查业务码和 `data`,再读取 `result.data.rows`;不把结果当行数组,也不二次解包。
|
|
111
|
-
5. 本版本没有输出 Schema 的 FaaS/Mutation 仍返回 `unknown`,使用前按真实契约校验;Mutation 固定返回类型在 0.3.0 提供。不要添加类型断言或恢复旧泛型来绕过升级产生的错误。
|
|
112
|
-
|
|
113
|
-
#### 验证命令
|
|
114
|
-
|
|
115
|
-
在 workspace 工程根运行:
|
|
116
|
-
|
|
117
|
-
```sh
|
|
118
|
-
base-database-cli contracts generate
|
|
119
|
-
base-database-cli check --json
|
|
120
|
-
npm run build --workspace page
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
classic 工程的 Page 构建改用 `npm run build --prefix page`。逐项修复生成、类型或构建诊断后重跑;保留原有业务回归,覆盖 SQL 结果读取及错误分支。命令通过只证明本地迁移完成,远端行为另按工程验收流程确认。
|
|
75
|
+
- 升级步骤见[升级指引](docs/upgrade.md)。
|
package/README.md
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
用于开发以飞书多维表格为数据后端的 Base Database 应用,提供页面与服务端运行时、平台组件、版本化能力查询与测试工具。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
安装:`npm install @lark-base-open/base-database-app-sdk@0.5.1`。从旧版本升级前请阅读 [变更记录](CHANGELOG.md)。
|
|
6
6
|
|
|
7
|
-
运行环境需支持 ES2022;页面 API 需要 Base Database 页面宿主,服务端 API 用于 Node.js / FaaS。组件需要 React 与 React DOM 19.2,页面查询能力使用 @tanstack/react-query 5.104.1;npm 会安装声明的依赖与必需 peer。底层通信依赖 base-site-channel 0.
|
|
7
|
+
运行环境需支持 ES2022;页面 API 需要 Base Database 页面宿主,服务端 API 用于 Node.js / FaaS。组件需要 React 与 React DOM 19.2,页面查询能力使用 @tanstack/react-query 5.104.1;npm 会安装声明的依赖与必需 peer。底层通信依赖 base-site-channel 0.2.0。
|
|
8
8
|
|
|
9
9
|
server/shared 同时提供 ESM 和 CJS;page/components/testing/vite 仅 ESM。
|
|
10
10
|
|
|
11
11
|
公开入口:`page` 页面 API;`server` [`defineFunction`](docs/exports.md#server) 与 records;`shared` 能力及诊断类型/[`SDKError`](docs/exports.md#page);`testing` 测试宿主与 MSW 工厂。另有 components 平台组件、vite 开发插件及 page/styles.css 样式入口。没有根入口,不支持私有源码路径。
|
|
12
12
|
|
|
13
13
|
文档:[完整索引](docs/README.md)、[导出清单](docs/exports.md)、[page](docs/page.md)、[server(defineFunction / ctx.records / 结果语义)](docs/server.md)、[shared](docs/shared.md)、[testing](docs/testing.md)、[components](docs/components.md)、[start-base-app](docs/start-base-app.md)、[capabilities](docs/capabilities.md)、[compat](docs/compat.md)、[upgrade](docs/upgrade.md)。
|
|
14
|
-
所有示例在 examples
|
|
14
|
+
所有示例在 examples/。
|
|
15
15
|
|
|
16
16
|
<!-- example: page.ts -->
|
|
17
17
|
```ts
|
|
@@ -28,42 +28,6 @@ export function mountPage() {
|
|
|
28
28
|
|
|
29
29
|
平台启动与组件:见 [startBaseApp](docs/start-base-app.md) 与 [组件](docs/components.md)。
|
|
30
30
|
|
|
31
|
-
SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务规则、服务端契约、Mutation 结果、CLI
|
|
31
|
+
SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务规则、服务端契约、Mutation 结果、CLI 命令与应用发布流程,请查阅 [@lark-base-open/base-database-cli](https://www.npmjs.com/package/@lark-base-open/base-database-cli) 随包安装的 lark-base-database Skill 及其 references。升级 CLI 时以该版本随包 Skill 为准。
|
|
32
32
|
|
|
33
33
|
页面类型客户端生成使用 [codegen](docs/codegen.md) 入口;CLI 仅提取契约、隔离调用并写入返回文件。
|
|
34
|
-
|
|
35
|
-
## npm 发布
|
|
36
|
-
|
|
37
|
-
本版本依赖已发布的 channel 0.1.6,锁文件必须解析到 `registry.npmjs.org` 的制品。AI Function 调用需要后端与宿主支持 `functions/:key/invoke`。
|
|
38
|
-
|
|
39
|
-
本预发布版本使用 `durable` 标签,保留 `latest` 指向 0.4.0。0.4.0 默认开启写后读,数据未就绪时自动重试并可能抛出 `DataNotReadyError`;需要按[写后读说明](docs/page.md#写后读)处理新异常,或传入 `{ readYourWrites: false }` 保持普通查询行为。契约生成使用工程安装的 SDK `./codegen` 入口;已安装旧 SDK 的工程不会因为单独升级 CLI 而自动切换到 0.4.0。0.3.0 将批量 Mutation 的 ID、输入和输出绑定到生成契约,收紧公开类型接口;0.2.0 对直接 Function 调用的返回泛型也有不兼容变化,跨版本升级见[升级指引](docs/upgrade.md)。
|
|
40
|
-
|
|
41
|
-
`CHANGELOG.md` 只记录简要版本变化,升级与迁移指导由[升级指引](docs/upgrade.md)及配套 CLI 的建站 Skill 提供。`check:migrations` 检查当前版本、重复编号和已有 Migration 的格式,不强制新增 Migration 章节。
|
|
42
|
-
|
|
43
|
-
Changelog 检查不能证明迁移可用。发布者还须按升级指导在旧 SDK 工程中定位受影响代码,验证未授权时保留依赖、授权升级后完成 `contracts generate → check → build`;核对使用目标包内 docs,保留实际 SDK/CLI 制品、修改与验证结果。跨过多个不兼容版本时逐一核对相关指导,不以全新 starter 的构建代替存量迁移。
|
|
44
|
-
|
|
45
|
-
在本 SDK 目录按顺序执行以下发布前检查(`npm test` 包含Changelog 检查、构建、公开文档与包边界检查、类型和组件测试;`prepublishOnly` 也会执行Changelog 检查):
|
|
46
|
-
|
|
47
|
-
- `npm ci --registry=https://registry.npmjs.org/`
|
|
48
|
-
- `npm run check:migrations`
|
|
49
|
-
- `npm test`
|
|
50
|
-
- `node scripts/sync-contract-schema.mjs --check`
|
|
51
|
-
- `node scripts/sync-capabilities.mjs --check`
|
|
52
|
-
- `npm run docs:exports`
|
|
53
|
-
- `npm pack --dry-run --json`
|
|
54
|
-
- `npm publish --dry-run --tag durable --registry=https://registry.npmjs.org/`
|
|
55
|
-
|
|
56
|
-
核对打包清单包含 dist、docs、examples、README、CHANGELOG、LICENSE、capabilities.json 与 development-pairing.json,以及所有 exports 指向的文件;不得包含测试、私有源码或本地配置。SDK 不提供根入口。
|
|
57
|
-
|
|
58
|
-
检查通过后,由有发布权限的用户本人执行;先确认 `npm whoami` 返回预期账号:
|
|
59
|
-
|
|
60
|
-
- `npm whoami --registry=https://registry.npmjs.org/`
|
|
61
|
-
- `npm publish --tag durable --registry=https://registry.npmjs.org/`
|
|
62
|
-
- `npm view @lark-base-open/base-database-app-sdk@0.5.0-durable.0 version dist --json --registry=https://registry.npmjs.org/`
|
|
63
|
-
- `npm view @lark-base-open/base-database-app-sdk dist-tags versions --json --registry=https://registry.npmjs.org/`
|
|
64
|
-
|
|
65
|
-
回读应确认 `durable` 为 `0.5.0-durable.0`,`latest` 仍为 `0.4.0`。
|
|
66
|
-
|
|
67
|
-
## Durable Function(预发布)
|
|
68
|
-
|
|
69
|
-
`/durable/workflow` 和 `/durable/activity` 提供持久化函数 API,使用方法与运行环境见 [Durable 文档](docs/durable.md)。新增入口从 0.5.0-durable.0 提供,0.4.0 不包含这些入口。使用前需确认目标平台已部署匹配的 Durable 运行时;发布 SDK 不代表平台已开放该能力。Temporal 为可选 peer,仅 Durable 开发和执行环境安装匹配版本;普通页面和普通 Function 不依赖它。ESM import 与 CJS require 共享 Durable 模块。
|
package/capabilities.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"sdkVersion": "0.5.
|
|
3
|
+
"sdkVersion": "0.5.1",
|
|
4
4
|
"capabilities": {
|
|
5
|
+
"runtime.diagnostic": {
|
|
6
|
+
"required": [
|
|
7
|
+
"site.v1.runtime.diagnostic"
|
|
8
|
+
],
|
|
9
|
+
"baseline": false
|
|
10
|
+
},
|
|
5
11
|
"runtime.context": {
|
|
6
12
|
"required": [
|
|
7
13
|
"site.v1.runtime.context"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as He,b as re,c as ze}from"./chunk-ZKBZAK4L.js";import{a as oe}from"./chunk-3JX3FIBG.js";import{a as $}from"./chunk-OHPYKFCM.js";import{createContext as sn,useContext as ct}from"react";import{createContext as Zt,useContext as Xt,useEffect as en,useSyncExternalStore as tn}from"react";import{capabilityNames as Tt}from"@lark-base-open/base-site-channel/capabilities";import*as I from"@lark-base-open/base-site-channel/runtime";import{SITE_RUNTIME_PROTOCOL_VERSION as qn,SiteRuntimeApi as le,SiteRuntimeEvent as Yn,SiteRuntimeFunction as Gn,SiteRuntimeErrorCode as Kn,readSiteAITextDelta as Jn,isValidSiteFunctionName as Qn}from"@lark-base-open/base-site-channel/runtime-contract";var J=()=>{throw new oe(re.ContextInvalid,"\u5BBF\u4E3B\u80FD\u529B\u5B57\u6BB5\u65E0\u6548")};function ve(e){if(!e||typeof e!="object")return J();if(e.capabilities===void 0)return Object.fromEntries(Object.entries(He).filter(([,o])=>o.baseline).map(([o])=>[o,{version:1}]));let t=e.capabilities;if(!t||typeof t!="object"||Array.isArray(t))return J();let n=Object.entries(t);return n.some(([,o])=>!o||typeof o!="object"||Array.isArray(o)||!Number.isSafeInteger(o.version)||o.version<=0)?J():Object.fromEntries(n.map(([o,r])=>[o,{version:r.version}]))}function It(e,t,n=1){if(!Number.isSafeInteger(n)||n<1)return J();let o=ve(e);return Object.prototype.hasOwnProperty.call(o,t)&&o[t].version>=n}async function kt(e=P){return ve(await e.getRuntimeContext())}var Xn=kt;async function Lt(e,t=1,n=P){let o=await n.getRuntimeContext(),r=ve(o),i=It(o,e,t),a=o.capabilityUnavailable;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return J();let s=a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:void 0;return s!==void 0&&(!s||typeof s!="object"||!["permission-denied","region-unavailable","temporarily-unavailable"].includes(s.reason)||typeof s.retryable!="boolean")?J():{name:e,requiredVersion:t,version:Object.prototype.hasOwnProperty.call(r,e)?r[e].version:null,supported:i,source:o.capabilities===void 0?"host-baseline":"advertised",availability:i?s?.reason??"unknown":"unsupported"}}async function Ve(e,t=1,n=P){let o=await n.getRuntimeContext(),r=await Lt(e,t,{getRuntimeContext:async()=>o});if(!r.supported)throw new ze(e,t);let i={"permission-denied":re.PermissionDenied,"region-unavailable":re.RegionUnavailable,"temporarily-unavailable":re.TemporarilyUnavailable};if(r.availability in i)throw new oe(i[r.availability],"\u5BBF\u4E3B\u660E\u786E\u62D2\u7EDD\u6B64\u80FD\u529B",void 0,o.capabilityUnavailable?.[e]?.retryable)}function qe(e,t){let n,o=!1,r,i=new Promise(a=>{r=a});return e.registerApi($.pairApi,async a=>{if(!a||!/^[A-Za-z0-9_-]{43}$/.test(a.challenge))throw new Error("INVALID_PAIRING_CHALLENGE");n=a.challenge;let s=n;o&&(o=!1,i=new Promise(u=>{r=u}));let c=await t($.endpoint,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:s})});if(!c.ok)throw new Error("DEVELOPMENT_PAIRING_FAILED");let d=await c.json();if(!/^[A-Za-z0-9_-]{43}$/.test(d.proof))throw new Error("INVALID_PAIRING_PROOF");return{proof:d.proof}}),e.subscribeEvent($.pairedEvent,a=>{n&&a?.challenge===n&&(o=!0,r())}),{reset:()=>{n=void 0,o&&(o=!1,i=new Promise(a=>{r=a}))},wait:async()=>{let a;do a=i,await a;while(a!==i)}}}var Ye=typeof window<"u"&&window.location.protocol==="http:"&&window.location.hostname===$.host&&Number(window.location.port)>=$.portMin&&Number(window.location.port)<=$.portMax;var Ge=I.siteRuntime,M=Ge.getChannel?.()??Ge.channel,_t=Ye&&typeof window<"u"&&window.parent!==window?qe(M,globalThis.fetch.bind(globalThis)):void 0;function Ke(e,t=async()=>{}){let n=new Map,o=async(r,i)=>{await t();for(let a of Tt(r,i))try{await Ve(a,1,{getRuntimeContext:()=>e.invokeApi(le.RuntimeContext,void 0)})}catch(s){throw s instanceof Error&&"code"in s?Object.assign(new I.SiteRuntimeInvocationError(String(s.code),s.message),s):s}};return{subscribeEvent:(r,i)=>e.subscribeEvent(r,i),emitEvent:async(r,i)=>(await o(r,i),e.emitEvent(r,i)),invokeApi:async(r,i,a)=>{let s=i?.requestId??i?.subscriptionId??i?.uploadId,c=r===le.HttpRequestCancel||r===le.AttachmentUploadCancel||r.endsWith(".close");if(c&&s&&n.has(s)){n.get(s).canceled=!0;return}let d={canceled:!1};!c&&s&&n.set(s,d);try{if(await o(r,i),d.canceled)throw new DOMException("The operation was aborted","AbortError");return s&&n.delete(s),await e.invokeApi(r,i,a)}finally{s&&n.get(s)===d&&n.delete(s)}}}}var Mt={invokeApi:M.invokeApi.bind(M),emitEvent:M.emitEvent.bind(M),subscribeEvent:M.subscribeEvent.bind(M)},Re=Ke(Mt,async()=>{if(typeof window<"u"&&window.parent===window)throw new I.SiteRuntimeInvocationError("CHANNEL_UNAVAILABLE","\u9875\u9762\u672A\u8FDE\u63A5\u5BBF\u4E3B channel");await _t?.wait()});M.invokeApi=Re.invokeApi;M.emitEvent=Re.emitEvent;var Ce=class extends I.SiteRuntimeClient{constructor(t){super(t?Ke(t):Re)}},so=e=>new Ce(e),P=I.siteRuntime,{invokeHttp:ue,invokeApi:co,getCurrentUser:ae,logout:Ee,requestEdit:Dt,uploadAttachment:lo,openLink:de}=P,Ft=(e=P,t)=>I.createSiteRuntimeFetch(e,t),N=Ft();var Ot=ue,Nt=/^\/?(preview\/)?app\/([^/]+)(\/|$)/,Je=/^[A-Za-z0-9_-]+$/,We="/space/api/bitable/site/v1",Bt="/space/api/box/file/temporary_download_url",Q="preview",ie=null;function jt(){let t=(typeof globalThis.location>"u"?void 0:globalThis.location)?.ancestorOrigins?.[0];if(t)return t;let n=typeof globalThis.document>"u"?"":globalThis.document.referrer;if(!n)return"";try{return new URL(n).origin}catch{return""}}function Ue(){let e=typeof globalThis.location>"u"?"":globalThis.location.pathname,t=Nt.exec(e),n=jt();return t?{env:t[1]?Q:"prod",gatewayOrigin:n,token:decodeURIComponent(t[2]??"")}:{env:"prod",gatewayOrigin:n,token:""}}function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $t(e){return e===Q||e==="prod"}function Ht(e){if(!H(e))return{};let t=typeof e.siteToken=="string"?e.siteToken.trim():"";return{...t?{token:t}:{},...$t(e.env)?{env:e.env}:{}}}async function z(){return ie||(ie=(async()=>{let e=Ue(),t={},n;try{n=await P.getRuntimeContext(),t=Ht(n)}catch(r){console.warn("Could not read the host Runtime context; inferring it from the artifact path",r)}pe=Qt(n);let o={env:t.env??e.env,gatewayOrigin:e.gatewayOrigin,token:t.token??e.token};return o.token||console.error("Cannot determine the app token: the host did not provide siteToken and the current path does not match an artifact path"),o})().catch(e=>{throw ie=null,pe={...Pe},e}),ie)}function Se(e){return!!(e.tableId.trim()&&e.fieldId.trim()&&e.recordId.trim()&&e.fileToken.trim())}function Ze(e,t){return JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},siteToken:e.token,siteEnv:e.env}})}function Xe(e,t){if(t instanceof Error)return t;let n=H(t)?t.code:void 0,o=typeof n=="string"||typeof n=="number"?String(n):"",r=o==="REQUEST_TIMEOUT"||o==="10005"?`${e} timed out`:`${e} failed`;return Object.assign(new Error(`${r}${o?` (code ${o})`:""}`),{cause:t,...o?{code:o}:{}})}async function et(e,t=360,n={}){if(n.signal?.throwIfAborted(),!Se(e)||!Number.isFinite(t)||t<=0)throw new Error("Attachment location or image size is invalid");let o=await z();if(n.signal?.throwIfAborted(),!o.token)throw new Error("Cannot load the attachment image without an app token");let r=[120,360,720,1280].find(c=>c>=t)??1280,i=new URLSearchParams({extra:Ze(o,e),width:String(r),height:String(r),policy:"allow_up",fallback_source:"1"}),a=await Ot({url:`/space/api/box/stream/download/v2/cover/${encodeURIComponent(e.fileToken)}?${i}`,init:{method:"GET",responseType:"arrayBuffer",timeoutMs:45e3},signal:n.signal}).catch(c=>{throw Xe("Attachment image request",c)});if(!a.ok){let c=a.headers.get("x-tt-logid");throw new Error(`Failed to load attachment image: HTTP ${a.status}${c?`, LogID ${c}`:""}`)}let s=await a.blob();if(!s.size||!s.type.startsWith("image/"))throw new Error("The host did not return a valid image");return s}async function zt(e,t){if(!e.token)throw new Error("Cannot get an attachment download URL without an app token");if(!Se(t))throw new Error("Cannot get an attachment download URL: the attachment location is incomplete");let n=await N(Bt,{body:JSON.stringify({extra:Ze(e,t),file_token:t.fileToken}),headers:{"content-type":"application/json"},method:"POST"}).catch(s=>{throw Xe("Attachment download URL request",s)}),o=n.headers?.get("x-tt-logid")?.trim(),r;try{r=await n.json()}catch{throw new Error(n.ok?`Attachment download URL response is not valid JSON${o?`, LogID ${o}`:""}`:`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`)}let i=H(r)?r.code:void 0;if(typeof i=="number"&&i!==0||typeof i=="string"&&i.trim()!==""&&i.trim()!=="0"){let s=new Error(`Attachment service could not provide a download URL (code ${String(i)}${o?`, LogID ${o}`:""})`);throw Object.assign(s,{code:String(i),cause:r})}if(!n.ok)throw new Error(`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`);let a=H(r)&&H(r.data)&&typeof r.data.url=="string"?r.data.url.trim():"";if(!a)throw new Error(`Attachment download URL response is missing data.url${o?`, LogID ${o}`:""}`);return a}function tt(e){let t=new URLSearchParams;e.env===Q&&t.set("env",Q);let n=t.toString(),o=`${We}/${encodeURIComponent(e.token)}/invoke_get`;return n?`${o}?${n}`:o}function nt(e,t){if(!Je.test(t))throw new TypeError(`functionId ${t} does not match the required pattern ${String(Je)}`);let n=`${We}/${encodeURIComponent(e.token)}/functions/${encodeURIComponent(t)}/invoke`;return e.env===Q?`${n}?env=${encodeURIComponent(Q)}`:n}var Vt="x-base-site-session-id",qt="x-base-site-read-your-writes",Yt=800008918,Qe=new Map,Pe={maxRetries:3,intervalMs:300},pe={...Pe},Gt=10,Kt=100,Jt=2e3;function Qt(e){let t=H(e)?e.readYourWritesRetry:void 0;return H(t)&&Number.isInteger(t.maxRetries)&&t.maxRetries>=0&&t.maxRetries<=Gt&&Number.isInteger(t.intervalMs)&&t.intervalMs>=Kt&&t.intervalMs<=Jt?{maxRetries:t.maxRetries,intervalMs:t.intervalMs}:{...Pe}}function Wt(e){let t=Qe.get(e);if(t)return t;let n=`baseSite:session:${e}`,o;try{o=localStorage.getItem(n)||void 0}catch{o=void 0}if(!o){try{o=crypto.randomUUID()}catch{return}try{localStorage.setItem(n,o)}catch{}}return Qe.set(e,o),o}function ot(e){let t=Wt(e);return{"content-type":"application/json",...t?{[Vt]:t}:{}}}var xe=class extends oe{logId;constructor(t={}){super("FUNCTION_INVOKE_FAILED","The write has succeeded but the data is not readable yet. Do not repeat the write; retry the query shortly.","800008918",!0),this.name="DataNotReadyError",this.logId=t.logId}};async function fo(e,t,n){let o=await z();if(!o.token)throw new Error(`Cannot invoke Function ${e} without an app token`);let r=n?.readYourWrites!==!1,i={...ot(o.token),...r?{[qt]:"1"}:{}},a=()=>ue({url:nt(o,e),init:{body:JSON.stringify({params:t}),headers:i,method:"POST"}});for(let s=0;;s++){let c=await a();if(!c.ok)throw new Error(`Function ${e} request failed: HTTP ${c.status}`);let d=await c.json();if(r&&d?.code===Yt){if(s<pe.maxRetries){await new Promise(u=>setTimeout(u,pe.intervalMs));continue}throw new xe({logId:d.data?.log_id})}return d}}async function go(e,t){if(!Array.isArray(t)||t.length<1||t.length>200||t.some(r=>r===null||typeof r!="object"||Array.isArray(r)))throw new TypeError("Mutation batch requires 1 to 200 named parameter objects");let n=await z();if(!n.token)throw new Error("\u5E94\u7528 token \u672A\u786E\u5B9A\uFF0C\u65E0\u6CD5\u8C03\u7528 Mutation");let o=await ue({url:nt(n,e),init:{body:JSON.stringify({batch:t.map(r=>({params:r}))}),headers:ot(n.token),method:"POST"}});if(!o.ok)throw new Error(`Mutation \u8C03\u7528\u5931\u8D25\uFF1AHTTP ${o.status}`);return await o.json()}async function ho(e,t){let n=await zt(e,t);if(!(await de(n)).opened)throw new Error("The host did not open the attachment download link")}function bo(e,t,n=360){if(!e.gatewayOrigin||!e.token||!Se(t))return"";let o=[120,360,720,1280].find(i=>i>=n)??1280,r=new URLSearchParams({extra:JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},baseAppToken:e.token}}),width:String(o),height:String(o),policy:"allow_up",fallback_source:"1"});return`${e.gatewayOrigin}/space/api/box/stream/download/v2/cover/${encodeURIComponent(t.fileToken)}?${r.toString()}`}var Le=Zt(void 0),at=[{id:"en",locale:"en-US",match:/^en(?:-|$)/},{id:"zh",locale:"zh-CN",match:/^zh(?:-|$)/},{id:"ja",locale:"ja-JP",match:/^ja(?:-|$)/}],Ie=new Set,it,Ae=null;function ke(e){if(typeof e!="string")return;let t=e.trim().replace(/_/g,"-").toLowerCase();return at.find(({match:n})=>n.test(t))?.id}function nn(){return typeof navigator>"u"?void 0:navigator.language}function on(e,t){return ke(e)??ke(t)??"en"}function V(){return it??on(void 0,nn())}function Te(e=V()){return at.find(({id:t})=>t===e)?.locale??"en-US"}function rn(e){return Ie.add(e),()=>Ie.delete(e)}function rt(e){it=ke(e);let t=V();st(t);for(let n of Ie)n();return t}function st(e){typeof document<"u"&&(document.documentElement.lang=Te(e))}function an(){return Ae||(st(V()),Ae=P.getRuntimeContext().then(e=>rt(e?.locale)).catch(()=>rt(void 0))),Ae}function k(){let e=Xt(Le),t=tn(rn,V,()=>"en");return en(()=>{e||an()},[e]),e??t}import{jsx as _e}from"react/jsx-runtime";var Me=sn(null);function So({children:e,...t}){return _e(Me.Provider,{value:t,children:_e(Le.Provider,{value:t.locale,children:_e("div",{className:"base-app-platform","data-theme":t.theme,children:e})})})}function Po(){let e=ct(Me);if(!e)throw new Error("BASE_APP_PROVIDER_REQUIRED");return e}function me(){return ct(Me)}import{useState as Z,useEffect as gt,useLayoutEffect as hn,useRef as Fe,useId as bn}from"react";import{jsx as D,jsxs as cn}from"react/jsx-runtime";function lt(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:D("path",{d:"M17.1956 16.3595C17.6558 16.3595 18.0289 16.7326 18.0289 17.1928C18.0287 17.6529 17.6557 18.0261 17.1956 18.0261H9.48724C9.0273 18.0259 8.65411 17.6527 8.6539 17.1928C8.6539 16.7327 9.02717 16.3597 9.48724 16.3595H17.1956ZM12.5732 2.47195C13.8817 1.28992 15.902 1.32977 17.163 2.59076L17.281 2.71527C18.4249 3.98149 18.4257 5.91435 17.2818 7.18061L17.163 7.3043L9.32366 15.1445C9.12419 15.3439 8.89959 15.5169 8.65716 15.6596L8.40976 15.7923L4.13079 17.8471C2.75554 18.5075 1.31776 17.1336 1.84889 15.7565L1.90667 15.623L3.96152 11.344C4.12431 11.0051 4.34347 10.696 4.60931 10.4301L12.4495 2.59076L12.5732 2.47195ZM5.78769 11.6093C5.65491 11.7421 5.54596 11.8966 5.46461 12.0659L3.40976 16.344L7.68792 14.2892C7.85719 14.2078 8.01164 14.0989 8.14446 13.9661L13.4643 8.64545L11.1075 6.28868L5.78769 11.6093ZM15.9846 3.76915C15.3338 3.11835 14.2788 3.11851 13.6279 3.76915L12.2867 5.11029L14.6435 7.46706L15.9846 6.12592C16.6353 5.47503 16.6354 4.41994 15.9846 3.76915Z",fill:"currentColor"})})}function ut(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"24",height:"6",viewBox:"0 0 24 6",fill:"none",children:D("path",{d:"M8.4383 1.99309L11.2526 5.15916C11.6504 5.60668 12.3496 5.60668 12.7474 5.15916L15.5617 1.99309C16.6886 0.725344 18.3038 0 20 0L12 0L4 0C5.69619 0 7.31142 0.725345 8.4383 1.99309Z",fill:"#1F2329"})})}function dt(){return cn("svg",{"aria-hidden":"true",focusable:"false",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[D("circle",{cx:"8.00008",cy:"8.00033",r:"7.33333",fill:"#1456F0"}),D("path",{d:"M8 5.33333C8.36819 5.33333 8.66667 5.03486 8.66667 4.66667C8.66667 4.29848 8.36819 4 8 4C7.63181 4 7.33333 4.29848 7.33333 4.66667C7.33333 5.03486 7.63181 5.33333 8 5.33333Z",fill:"white"}),D("path",{d:"M7.33333 6C6.96514 6 6.66667 6.29848 6.66667 6.66667C6.66667 7.03486 6.96514 7.33333 7.33333 7.33333V10H6.66667C6.29848 10 6 10.2985 6 10.6667C6 11.0349 6.29848 11.3333 6.66667 11.3333H9.33333C9.70152 11.3333 10 11.0349 10 10.6667C10 10.2985 9.70152 10 9.33333 10H8.66667V6.66667C8.66667 6.29848 8.36819 6 8 6H7.33333Z",fill:"white"})]})}function pt(){return D("svg",{"aria-hidden":"true",focusable:"false",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:D("path",{d:"M13.5043 13.5042C13.7646 13.2439 13.7665 12.8237 13.5062 12.5633L8.94298 8.00013L13.5061 3.43697C13.7665 3.17662 13.7646 2.7564 13.5043 2.49605C13.2439 2.2357 12.8237 2.23382 12.5633 2.49416C12.303 2.75451 8.00017 7.05732 8.00017 7.05732L3.43697 2.49413C3.17662 2.23378 2.7564 2.23566 2.49605 2.49601C2.2357 2.75636 2.23381 3.17658 2.49416 3.43693L7.05736 8.00013L2.49413 12.5634C2.23378 12.8237 2.23566 13.2439 2.49601 13.5043C2.75636 13.7646 3.17659 13.7665 3.43693 13.5062L8.00017 8.94294L12.5634 13.5061C12.8237 13.7665 13.2439 13.7646 13.5043 13.5042Z",fill:"#646A73"})})}import{QueryClient as ln}from"@tanstack/react-query";var De=new ln({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}});function fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ge(e,t){let n=e[t];return typeof n=="string"?n.trim():""}function un(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function q(){return{baseBindings:[],name:"",description:"",isOwner:!1,allowEdit:!1,organization:""}}function dn(){let e=document.querySelector('meta[name="description"]');return e instanceof HTMLMetaElement?e:null}function pn(e){if(e.name&&(document.title=e.name),e.description){let t=dn();t&&(t.content=e.description)}}function mn(e){return Array.isArray(e)?e.reduce((t,n)=>{if(!fe(n))return t;let o=ge(n,"baseToken");return o&&t.push({baseToken:o,tableIds:un(n.tableIds)}),t},[]):[]}function fn(e){if(!fe(e)||e.code!==0)return q();let t=e.data;if(!fe(t))return q();let n=t.site;return fe(n)?{baseBindings:mn(n.baseBindings),description:ge(n,"description"),name:ge(n,"name"),isOwner:t.isOwner===!0,allowEdit:n.allowEdit===void 0?t.isOwner===!0:n.allowEdit===!0,organization:ge(n,"organization")}:q()}async function mt(e){try{let t=await N(tt(e),{method:"GET"});if(!t.ok)return q();let n=await t.json(),o=fn(n);return pn(o),o}catch{return q()}}async function W(){let e=await z();if(!e.token)return q();let t=await ae().catch(()=>null);return t?.userId?De.fetchQuery({queryKey:["project-meta",e.token,e.env,t.userId],queryFn:()=>mt(e)}):mt(e)}var gn="https://feishu.cn/base/site/detail/overview";async function ft(){try{await P.requestEdit();return}catch{let{token:e}=await z(),t=new URL(gn);if(t.searchParams.set("token",e),!(await de(t.toString())).opened)throw new Error("Management page was not opened")}}import{jsx as U,jsxs as he}from"react/jsx-runtime";var yn={en:{openFailed:"Unable to open the management page. Please try again.",editSite:"Edit and manage your apps",hidePanel:"Hide until next visit",hiddenConfirmation:"Edit button hidden until you reopen the app",dismissNotification:"Dismiss notification"},zh:{openFailed:"\u65E0\u6CD5\u6253\u5F00\u7BA1\u7406\u9875\u9762\uFF0C\u8BF7\u91CD\u8BD5",editSite:"\u7F16\u8F91\u4E0E\u7BA1\u7406\u5E94\u7528",hidePanel:"\u9690\u85CF",hiddenConfirmation:"\u7F16\u8F91\u6309\u94AE\u5DF2\u9690\u85CF\uFF0C\u76F4\u81F3\u4E0B\u6B21\u91CD\u65B0\u6253\u5F00\u5E94\u7528",dismissNotification:"\u5173\u95ED\u63D0\u793A"},ja:{openFailed:"\u7BA1\u7406\u30DA\u30FC\u30B8\u3092\u958B\u3051\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",editSite:"\u30A2\u30D7\u30EA\u3092\u7DE8\u96C6\u30FB\u7BA1\u7406",hidePanel:"\u6B21\u56DE\u306E\u30A2\u30AF\u30BB\u30B9\u307E\u3067\u975E\u8868\u793A",hiddenConfirmation:"\u7DE8\u96C6\u30DC\u30BF\u30F3\u3092\u975E\u8868\u793A\u306B\u3057\u307E\u3057\u305F\u3002\u30A2\u30D7\u30EA\u3092\u518D\u5EA6\u958B\u304F\u3068\u8868\u793A\u3055\u308C\u307E\u3059",dismissNotification:"\u901A\u77E5\u3092\u9589\u3058\u308B"}};function Yo({position:e="bottom-right",className:t="",slots:n={}}){let o=yn[k()],[r,i]=Z(!1),[a,s]=Z(!1),[c,d]=Z(!1),[u,p]=Z(!1),[m,g]=Z(null),[f,E]=Z(null),x=Fe(null),O=Fe(null),S=Fe(null),_=bn();hn(()=>{if(!m)return;let h=m==="edit"?x.current:O.current,w=S.current;if(!h||!w)return;let v=()=>{let X=h.getBoundingClientRect(),ee=X.left+X.width/2,te=Math.ceil(w.getBoundingClientRect().width),ne=Math.max(8,Math.min(ee-te/2,window.innerWidth-te-8));E({left:ne,top:X.top-w.offsetHeight-14,arrowLeft:ee-ne})};v(),window.addEventListener("resize",v);let K=new ResizeObserver(v);return K.observe(w),()=>{window.removeEventListener("resize",v),K.disconnect()}},[m,o,e,n.tooltip]),gt(()=>{let h=!0;return W().then(w=>{h&&i(w.allowEdit&&Ue().env==="prod")}).catch(()=>{}),()=>{h=!1}},[]),gt(()=>{if(!c)return;let h=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(h)},[c]);let A=n.trigger,y=n.tooltip;return r?a?c?he("div",{className:"base-app-platform base-app-notice",role:"status",children:[U(dt,{}),U("span",{children:o.hiddenConfirmation}),U("button",{type:"button","aria-label":o.dismissNotification,onClick:()=>d(!1),children:U(pt,{})})]}):null:he("div",{className:`base-app-platform base-app-floating ${t}`,"data-position":e,children:[u?U("div",{role:"alert",children:o.openFailed}):null,m?he("div",{ref:S,id:_,role:"tooltip",style:f?{left:f.left,top:f.top}:{visibility:"hidden"},children:[y?U(y,{text:m==="edit"?o.editSite:o.hidePanel}):m==="edit"?o.editSite:o.hidePanel,U("span",{className:"base-app-floating-caret",style:{left:f?.arrowLeft},children:U(ut,{})})]}):null,he("div",{className:"base-app-floating-controls",children:[U("button",{ref:x,type:"button",className:"base-app-floating-edit","aria-describedby":m==="edit"?_:void 0,"aria-label":o.editSite,onFocus:()=>g("edit"),onBlur:()=>g(null),onMouseEnter:()=>g("edit"),onMouseLeave:()=>g(null),onClick:()=>{p(!1),ft().catch(()=>p(!0))},children:A?U(A,{}):U(lt,{})}),U("button",{ref:O,type:"button",className:"base-app-floating-hide","aria-describedby":m==="hide"?_:void 0,"aria-label":o.hidePanel,onFocus:()=>g("hide"),onBlur:()=>g(null),onMouseEnter:()=>g("hide"),onMouseLeave:()=>g(null),onClick:()=>{s(!0),g(null),d(!0)},children:U("span",{"aria-hidden":"true",children:"\xD7"})})]})]}):null}var Oe=new Set;function ht(e){return Oe.add(e),()=>{Oe.delete(e)}}function bt(){for(let e of Oe)e()}import{useEffect as wn,useState as wt}from"react";import*as B from"@radix-ui/react-popover";async function yt(){try{let e=await ae();if(typeof e?.name=="string"&&e.name)return{name:e.name,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:"",tenantName:""}}catch{}try{let e=await N("/space/api/user/",{headers:{accept:"application/json"}});if(!e.ok)return null;let n=(await e.json()).data;return!n||typeof n.name!="string"||!n.name?null:{name:n.name,avatarUrl:typeof n.avatar_url=="string"?n.avatar_url:"",tenantName:typeof n.tenant_name=="string"?n.tenant_name:""}}catch{return null}}import{Fragment as Cn,jsx as L,jsxs as Ne}from"react/jsx-runtime";var vn={en:{account:"Account",logout:"Log out"},zh:{account:"\u8D26\u53F7",logout:"\u9000\u51FA\u767B\u5F55"},ja:{account:"\u30A2\u30AB\u30A6\u30F3\u30C8",logout:"\u30ED\u30B0\u30A2\u30A6\u30C8"}};function ir({audience:e="enterprise",align:t="right",side:n="down",showName:o=!0,className:r="",slots:i={}}){let[a,s]=wt(null),[c,d]=wt(""),u=me(),p=vn[k()];if(wn(()=>{if(e!=="enterprise")return;let f=!0;return Promise.all([yt(),W().catch(()=>null)]).then(([E,x])=>{f&&(s(E),d(E?.tenantName||x?.organization||""))}),()=>{f=!1}},[e]),e!=="enterprise"||!a)return null;let m=i.trigger,g=i.organization;return Ne(B.Root,{children:[L(B.Trigger,{asChild:!0,children:L("button",{className:`base-app-platform base-app-user-menu ${r}`,"aria-label":p.account,children:m?L(m,{user:a}):Ne(Cn,{children:[a.avatarUrl?L("img",{src:a.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):L("span",{children:a.name.slice(0,1)}),o?a.name:null]})})}),L(B.Portal,{children:Ne(B.Content,{"data-theme":u?.theme,className:"base-app-platform base-app-popover",align:t==="right"?"end":"start",side:n==="up"?"top":"bottom",sideOffset:8,collisionPadding:8,children:[L("strong",{children:a.name}),g?L(g,{name:c}):L("p",{children:c}),L("button",{onClick:()=>{bt(),De.clear(),Ee().catch(()=>{for(let f of["base-site-session","session","sl_session"])document.cookie=`${f}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;window.location.reload()})},children:p.logout})]})})]})}import{useEffect as be,useRef as Rt,useState as Y}from"react";import{Command as se}from"cmdk";import{QueryClient as _n,useQuery as Mn}from"@tanstack/react-query";var Rn="/space/api/mention/recommend.v2/",En="8",xn="4",Un="0",Sn=20,vt={en:{businessError:e=>`Could not search members (error code ${e})`,httpError:e=>`Member search request failed: HTTP ${e}`,invalidResponse:"Member search response has an invalid structure",noBoundBase:"Cannot search members: the application is not bound to a Base"},zh:{businessError:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,httpError:e=>`\u641C\u7D22\u6210\u5458\u8BF7\u6C42\u5931\u8D25\uFF1AHTTP ${e}`,invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",noBoundBase:"\u65E0\u6CD5\u641C\u7D22\u6210\u5458\uFF1A\u5E94\u7528\u5C1A\u672A\u7ED1\u5B9A\u591A\u7EF4\u8868\u683C"},ja:{businessError:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,httpError:e=>`\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF1AHTTP ${e}`,invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",noBoundBase:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\uFF1A\u30A2\u30D7\u30EA\u306BBase\u304C\u95A2\u9023\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093"}};async function Ct(e,t,n){let o=t??V(),r=vt[o],a=(await W()).baseBindings[0]?.baseToken;if(!a)throw new Error(r.noBoundBase);let s=new URLSearchParams({config_source:"0",obj_type:En,source:xn,token:a,type:Un,user_type:"0",content:e.trim().slice(0,50)}).toString(),c=await N(Rn,{signal:n,body:s,headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST"});if(!c.ok)throw new Error(r.httpError(c.status));let d=await c.json();return{code:0,msg:"ok",data:Pn(d,o)}}function Pn(e,t=V()){let n=Te(t),o=vt[t],r=An(e,o);if(!r)throw new Error(o.invalidResponse);let i=r.entities,a=T(i)?i.users:void 0;if(!T(a)||!Array.isArray(r.result_list))throw new Error(o.invalidResponse);let s=[],c=new Set;for(let d of r.result_list){if(!T(d)||Number(d.type)!==0)continue;let u=b(d.token);if(!u)continue;let p=a[u];if(!T(p))continue;let m=b(p.user_id)||b(p.id)||u,g=In(p,n);if(!m||!g||c.has(m))continue;c.add(m);let f=b(p.avatar_url),E=b(p.open_id);if(s.push({avatar:{avatar_72:f,avatar_240:f,avatar_640:f,avatar_origin:f},department_ids:Tn(p.department_ids),description:kn(p,n),is_external:p.is_external===!0,name:g,user_id:m,...E?{open_id:E}:{}}),s.length>=Sn)break}return{users:s}}function An(e,t){if(T(e)){if(typeof e.code=="number"&&e.code!==0){let n=b(e.msg);throw Object.assign(new Error(n||t.businessError(e.code)),{code:String(e.code),cause:e})}return"entities"in e&&"result_list"in e?e:T(e.data)?e.data:void 0}}function In(e,t){let n=e.display_name;if(typeof n=="string"&&n.trim())return n.trim();let o=t.toLowerCase().replace("-","_"),r=o.split("_")[0],i=T(n)?n:{},a=T(i.i18n_value)?i.i18n_value:i,s=r==="zh"?e.cn_name:r==="en"?e.en_name:void 0;return b(a[o])||b(a[r])||b(s)||b(i.value)||b(e.name)||b(e.en_name)||b(e.cn_name)}function kn(e,t){let n=e.is_external===!0?e.i18n_tenant:e.i18n_department;return Ln(n,t)||b(e.department)}function Ln(e,t){if(typeof e=="string")return e.trim();if(!T(e))return"";let n=t.toLowerCase().replace("-","_"),o=n.split("_")[0]??"",r=T(e.i18n_value)?e.i18n_value:e,i=b(r[n])||b(r[o]);if("i18n_value"in e)return i||b(e.value);let a=o==="zh"?b(r.zh_cn)||b(r.en_us):b(r.en_us)||b(r.zh_cn);return i||b(e.value)||a}function b(e){return typeof e=="string"?e.trim():""}function Tn(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Fragment as xt,jsx as R,jsxs as Be}from"react/jsx-runtime";var Ut={en:{invalidResponse:"Member search response has an invalid structure",loading:"Loading...",memberList:"Member list",noMatches:"No matching members. Try another search term.",noRecommendations:"No recommended members yet",recordCreator:"Add the person who created this record",searchFailed:"Member search failed",searchFailedCode:e=>`Could not search members (error code ${e})`,searchMembers:"Search members"},zh:{invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",loading:"\u52A0\u8F7D\u4E2D...",memberList:"\u6210\u5458\u5217\u8868",noMatches:"\u6CA1\u6709\u5339\u914D\u7684\u6210\u5458\uFF0C\u8BF7\u6362\u4E2A\u5173\u952E\u8BCD",noRecommendations:"\u6682\u65E0\u63A8\u8350\u6210\u5458",recordCreator:"\u6DFB\u52A0\u6B64\u8BB0\u5F55\u7684\u4EBA\u5458",searchFailed:"\u641C\u7D22\u6210\u5458\u5931\u8D25",searchFailedCode:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,searchMembers:"\u641C\u7D22\u6210\u5458"},ja:{invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",memberList:"\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7",noMatches:"\u4E00\u81F4\u3059\u308B\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093\u3002\u5225\u306E\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22\u3057\u3066\u304F\u3060\u3055\u3044\u3002",noRecommendations:"\u304A\u3059\u3059\u3081\u306E\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093",recordCreator:"\u3053\u306E\u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210\u8005\u3092\u8FFD\u52A0",searchFailed:"\u30E1\u30F3\u30D0\u30FC\u306E\u691C\u7D22\u306B\u5931\u6557\u3057\u307E\u3057\u305F",searchFailedCode:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,searchMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22"}};function ye(e){let[t,n]=Y(!1),[o,r]=Y(!1);be(()=>r(!0),[]);let i=k(),a=Ut[i],[s]=Y(()=>new _n({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}}));be(()=>{let l=ht(()=>{n(!0),s.clear()});return()=>{l(),s.clear()}},[s]);let c=Object.prototype.hasOwnProperty.call(e,"value"),d=Rt(c);be(()=>{c!==d.current&&console.warn("UserSelectorPanel controlled mode changed")},[c]);let[u,p]=Y(e.defaultValue),m=c?e.value:u,g=Array.isArray(m)?m:m?[m]:[],[f,E]=Y(""),[x,O]=Y(""),[S,_]=Y(!1),A=Rt(!1);be(()=>{if(S)return;let l=setTimeout(()=>O(f.trim()),f.trim()?400:0);return()=>clearTimeout(l)},[f,S]);let y=Mn({queryKey:["members",i,x],queryFn:async({signal:l})=>{let C=await Ct(x,i,l);return Dn(C,i)},enabled:!t&&o&&!S&&f.trim()===x},s),h=e.loading||y.isFetching||f.trim()!==x,w=!t&&!h&&!y.error&&y.data?[...y.data.users,...g.filter(l=>!y.data.users.some(C=>C.user_id===l.user_id))]:[],v=(l,C)=>{E(l),e.onSearch?.(l,{action:C})},K=()=>{v("","AutoClear"),e.onClose?.()},X=l=>{if(A.current)return;let C=g.some(we=>we.user_id===l.user_id),ce=e.mode==="multiple"?C?g.filter(we=>we.user_id!==l.user_id):[...g,l]:C?void 0:l;c||p(ce),e.onChange?.(ce,{option:l,action:C?"Remove":"Select"}),C||e.onSelect?.(l,{option:l}),e.mode==="multiple"?v("","AutoClear"):K()},ee=e.slots?.empty,te=e.slots?.loading,ne=e.slots?.option,$e=e.slots?.footer;return Be(se,{shouldFilter:!1,loop:!0,className:`base-app-platform base-app-selector ${e.className??""}`,label:a.memberList,children:[R(se.Input,{autoFocus:!0,placeholder:a.searchMembers,"aria-label":a.searchMembers,value:f,onValueChange:l=>v(l,"Input"),onCompositionStart:()=>{A.current=!0,_(!0)},onCompositionEnd:()=>{A.current=!1,_(!1)},onKeyDown:l=>{if(e.onKeyDown?.(l),l.defaultPrevented){l.stopPropagation();return}if(A.current||Fn(l)){l.stopPropagation();return}l.key==="Escape"&&(l.preventDefault(),K())}}),R(se.List,{"aria-label":a.memberList,"aria-multiselectable":e.mode==="multiple"||void 0,children:h?R("div",{role:"status",children:te?R(te,{}):a.loading}):y.error?R("div",{role:"alert",children:a.searchFailed}):Be(xt,{children:[e.onSelectRecordCreator?R(se.Item,{value:"record-creator",onSelect:()=>{e.onSelectRecordCreator?.(),K()},children:a.recordCreator}):null,w.map(l=>{let C=g.some(ce=>ce.user_id===l.user_id);return R(se.Item,{value:l.user_id,onSelect:()=>X(l),"data-checked":C,children:ne?R(ne,{user:l,selected:C}):Be(xt,{children:[R("span",{children:l.name}),R("small",{children:e.getUserDescription?.(l)??l.description}),C?R("span",{"aria-label":"selected",children:"\u2713"}):null]})},l.user_id)}),!w.length&&!e.onSelectRecordCreator?R("div",{role:"status",children:ee?R(ee,{}):f.trim()?a.noMatches:a.noRecommendations}):null]})}),$e?R($e,{}):null]})}function Dn(e,t){let n=Ut[t];if(!Et(e)||typeof e.code!="number")throw new Error(n.invalidResponse);if(e.code!==0){let o=typeof e.msg=="string"?e.msg.trim():"";throw Object.assign(new Error(o||n.searchFailedCode(e.code)),{code:String(e.code),cause:e})}if(!Et(e.data)||!Array.isArray(e.data.users))throw new Error(n.invalidResponse);return{users:e.data.users}}function Et(e){return typeof e=="object"&&e!==null}function Fn(e){return e.nativeEvent?.isComposing===!0||e.keyCode===229}import{useState as On,useRef as Nn}from"react";import*as j from"@radix-ui/react-popover";import{jsx as F,jsxs as St}from"react/jsx-runtime";var Bn={en:{clearSelected:"Clear selected members",removeMember:e=>`Remove member ${e}`,selectMembers:"Select members"},zh:{clearSelected:"\u6E05\u9664\u5DF2\u9009\u6210\u5458",removeMember:e=>`\u79FB\u9664\u6210\u5458 ${e}`,selectMembers:"\u9009\u62E9\u6210\u5458"},ja:{clearSelected:"\u9078\u629E\u3057\u305F\u30E1\u30F3\u30D0\u30FC\u3092\u30AF\u30EA\u30A2",removeMember:e=>`\u30E1\u30F3\u30D0\u30FC ${e} \u3092\u524A\u9664`,selectMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u9078\u629E"}};function Pt(e){let t=Nn(null),n=me(),o=Bn[k()],[r,i]=On(!1),a=Array.isArray(e.value)?e.value:e.value?[e.value]:[],s=u=>{i(u),u!==r&&e.onDropdownVisibleChange?.(u)},c=e.slots?.trigger,d=e.slots?.chip;return St(j.Root,{open:r,onOpenChange:s,children:[St("div",{ref:t,className:`base-app-platform base-app-editor ${e.className??""}`,onClickCapture:u=>{u.target.closest("[data-base-app-trigger]")&&e.onClick?.(u)},children:[F(j.Trigger,{asChild:!0,children:F("button",{type:"button","data-base-app-trigger":"","aria-label":o.selectMembers,onFocus:e.onFocus,onBlur:e.onBlur,children:c?F(c,{value:e.value}):a.length?a.map(u=>F("span",{children:d?F(d,{user:u}):u.name},u.user_id)):o.selectMembers})}),a.map(u=>F("button",{type:"button","aria-label":e.mode==="multiple"?o.removeMember(u.name):o.clearSelected,onClick:p=>{p.stopPropagation(),e.onChange?.(e.mode==="multiple"?a.filter(m=>m.user_id!==u.user_id):void 0),e.mode==="multiple"?e.onRemove?.(u):e.onClear?.()},children:"\xD7"},u.user_id))]}),F(j.Portal,{container:e.portalContainer??t.current?.closest("dialog")??void 0,children:F(j.Content,{"data-theme":n?.theme,className:"base-app-platform base-app-popover",sideOffset:4,collisionPadding:8,children:F(ye,{...e,slots:void 0,onChange:(u,p)=>{e.onChange?.(u),p.action==="Remove"&&p.option&&e.onRemove?.(p.option)},onClose:()=>s(!1)})})})]})}import{useEffect as At,useRef as jn,useState as je}from"react";import{jsx as G,jsxs as Hn}from"react/jsx-runtime";var $n={en:{decodeFailed:"Image could not be decoded",loadFailed:"Failed to load image",loading:"Loading image",retry:"Retry image"},zh:{decodeFailed:"\u56FE\u7247\u65E0\u6CD5\u89E3\u7801",loadFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",loading:"\u56FE\u7247\u52A0\u8F7D\u4E2D",retry:"\u91CD\u8BD5\u56FE\u7247"},ja:{decodeFailed:"\u753B\u50CF\u3092\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",loadFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",loading:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D",retry:"\u753B\u50CF\u3092\u518D\u8AAD\u307F\u8FBC\u307F"}};function Tr({attachment:e,size:t=360,alt:n,className:o,slots:r={}}){let i=k(),a=$n[i],s=jn(null),[c,d]=je(!1),[u,p]=je(0),[m,g]=je({key:"",url:"",error:""}),{tableId:f,fieldId:E,recordId:x,fileToken:O}=e,S=JSON.stringify([f,E,x,O,t,u]);At(()=>{if(typeof IntersectionObserver>"u"){d(!0);return}let h=new IntersectionObserver(w=>{w.some(v=>v.isIntersecting)&&(d(!0),h.disconnect())},{rootMargin:"200px"});return s.current&&h.observe(s.current),()=>h.disconnect()},[]),At(()=>{if(!c)return;let h=new AbortController,w="";return et({tableId:f,fieldId:E,recordId:x,fileToken:O},t,{signal:h.signal}).then(v=>{h.signal.aborted||(w=URL.createObjectURL(v),g({key:S,url:w,error:""}))}).catch(v=>{h.signal.aborted||g({key:S,url:"",error:v instanceof Error?v.message:"",localError:v instanceof Error?void 0:"loadFailed"})}),()=>{h.abort(),w&&URL.revokeObjectURL(w)}},[c,S,f,E,x,O,t]);let _=r.loading,A=r.error,y=m.key===S?m:void 0;return G("span",{ref:s,className:`base-app-platform base-app-attachment ${o??""}`,"aria-busy":!y,children:y?.url?G("img",{src:y.url,alt:n,onError:()=>g({key:S,url:"",error:"",localError:"decodeFailed"})}):y?.error||y?.localError?A?G(A,{code:"ATTACHMENT_LOAD_FAILED",retry:()=>p(h=>h+1)}):Hn("span",{children:[G("span",{role:"status",children:y.localError?a[y.localError]:y.error}),G("button",{type:"button",onClick:()=>p(h=>h+1),children:a.retry})]}):G("span",{role:"status",children:_?G(_,{}):a.loading})})}export{qn as a,le as b,Yn as c,Gn as d,Kn as e,Jn as f,Qn as g,Ke as h,Re as i,Ce as j,so as k,P as l,ue as m,co as n,ae as o,Ee as p,Dt as q,lo as r,de as s,Ft as t,N as u,ve as v,It as w,kt as x,Xn as y,Lt as z,Ve as A,Ue as B,z as C,et as D,zt as E,tt as F,nt as G,xe as H,fo as I,go as J,ho as K,bo as L,Le as M,on as N,V as O,Te as P,an as Q,k as R,So as S,Po as T,me as U,De as V,Yo as W,ir as X,ye as Y,Pt as Z,Tr as _};
|
package/dist/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h,U as i,W as j,X as k,Y as l,Z as m,_ as n}from"./chunk-
|
|
1
|
+
import{M as a,N as b,O as c,P as d,Q as e,R as f,S as g,T as h,U as i,W as j,X as k,Y as l,Z as m,_ as n}from"./chunk-OF7TEKK6.js";import"./chunk-ZKBZAK4L.js";import"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export{n as AttachmentImage,g as BaseAppProvider,k as DatabaseUserMenu,j as FloatingButton,a as UiLanguageContext,m as UserSelectorEditor,l as UserSelectorPanel,c as getUiLanguage,d as getUiLocale,e as initializeUiLanguage,b as selectUiLanguage,h as useBaseApp,i as useOptionalBaseApp,f as useUiLanguage};
|
package/dist/page.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as Ye,B as le,C as pe,D as fe,E as Se,F as Ae,G as ge,H as Ie,I as ke,J as ye,K as he,L as Re,M as Je,N as
|
|
1
|
+
import{A as Ye,B as le,C as pe,D as fe,E as Se,F as Ae,G as ge,H as Ie,I as ke,J as ye,K as he,L as Re,M as Je,N as O,O as Xe,P as L,Q as Ze,R as $e,S as B,T as et,U as tt,V as N,W as U,X as nt,Y as it,Z as rt,_ as at,a as j,b as Y,c as J,d as X,e as Z,f as $,g as ee,h as x,i as D,j as te,k as ne,l as m,m as ie,n as re,o as ae,p as oe,q as se,r as ce,s as ue,t as de,u as me,v as Ke,w as v,x as We,y as Qe,z as je}from"./chunk-OF7TEKK6.js";import{a as He,b as ze,c as w,d as R}from"./chunk-ZKBZAK4L.js";import{a as qe}from"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export*from"@lark-base-open/base-site-channel/runtime";import{installLinkGuard as Fe}from"@lark-base-open/base-site-channel/runtime";function M(e={}){let t=!0,n,i=s=>{let c=R(s);e.onDiagnostic?e.onDiagnostic(c):console.warn("[Base Database SDK]",c)},a=e.runtime??m;return Promise.resolve().then(()=>a.getRuntimeContext()).then(s=>{if(t){if(!v(s,"link.open")){i(new w("link.open",1));return}n=Fe(e)}}).catch(s=>{t&&i(s)}),()=>{t=!1,n?.()}}export*from"@lark-base-open/base-site-channel/runtime-contract";import{SiteChatbotStreamError as Ot}from"@lark-base-open/base-site-channel/runtime";import*as u from"@lark-base-open/base-site-channel/runtime";var P=class extends u.SiteChatbotStreamAdapter{constructor(t){super({...t,channel:t.channel?x(t.channel):D})}},F=e=>({...e,channel:e?.channel?x(e.channel):D}),G=(e,t)=>u.callSiteAIFunction(e,F(t)),V=(e,t)=>u.invokeSiteAIFunctionStream(e,F(t)),q=(e,t)=>u.createSiteAIFunctionTask(e,F(t)),H=(e,t,n)=>u.getSiteAIFunctionTask(e,t,F(n));var Te=new Set(["cancelled","failed","queued","running","succeeded"]);async function be(e){let t=await G(e);return e.input&&!e.messages?k(t):t}function Ce(e){return V(e)}function o(e,t){for(let n of t){let i=e[n];if(typeof i=="string"&&i.trim())return i}}function xe(e,t){for(let n of t){let i=e[n];if(typeof i=="number"&&Number.isFinite(i))return i}}function De(e){let t=o(e,["capabilityType","capability_type","CapabilityType"]);return t==="image"||t==="video"?t:void 0}function Me(e){if(Array.isArray(e))return e.filter(b).map(t=>{let n=o(t,["size","Size"]),i=o(t,["token","Token"]),a=o(t,["url","URL"]);return{safetyStatus:o(t,["safetyStatus","safety_status","SafetyStatus"])??"",...n?{size:n}:{},...i?{token:i}:{},...a?{url:a}:{}}})}function Pe(e){if(!b(e))return;let t=e.durationSeconds??e.duration_seconds??e.DurationSeconds,n=o(e,["token","Token"]),i=o(e,["url","URL"]);return{...typeof t=="number"?{durationSeconds:t}:{},...n?{token:n}:{},...i?{url:i}:{}}}function T(e,t="INVALID_AI_FUNCTION_TASK"){let n=new Error(e);return n.name="SiteAIFunctionTaskError",n.code=t,n}function k(e){if(!b(e))throw T("AI Function task response has an invalid structure");let t=_e(e);if(t)throw T(t.message,t.code);if("data"in e&&e.data!==void 0)return k(e.data);let n=o(e,["type","Type"]),i=o(e,["taskId","task_id","TaskID"]),a=e.status??e.Status;if(n!=="image_task"&&n!=="video_task"||!i||typeof a!="string"||!Te.has(a))throw T("AI Function task response has an invalid structure");let s=Me(e.imageAssets??e.image_assets??e.ImageAssets),c=Pe(e.videoAsset??e.video_asset??e.VideoAsset),l=xe(e,["progress","Progress"]),I=De(e),p=o(e,["errCode","err_code","ErrCode"]),f=o(e,["errMessage","err_message","ErrMessage"]);return{...I?{capabilityType:I}:{},...p?{errCode:p}:{},...f?{errMessage:f}:{},...s?{imageAssets:s}:{},...l!==void 0?{progress:l}:{},...c?{videoAsset:c}:{},requestId:o(e,["requestId","request_id","RequestID"])??"",status:a,taskId:i,type:n}}function _e(e){let t=e.code??e.Code;if(typeof t=="number"&&t!==0||typeof t=="string"&&t&&t!=="0")return{code:String(t),message:o(e,["msg","message","Message"])??"Failed to create the AI Function task"};let n=e.BaseResp??e.base_resp??e.baseResp;if(!b(n))return;let i=n.StatusCode??n.status_code??n.statusCode;if(typeof i=="number"&&i!==0||typeof i=="string"&&i&&i!=="0")return{code:String(i),message:o(n,["StatusMessage","status_message","statusMessage"])??"Failed to create the AI Function task"}}function Ee(e){return!!e.taskId.trim()&&(e.status==="queued"||e.status==="running")}async function we(e){return k(await q(e))}async function ve(e,t){if(!t.trim())throw T("AI Function task ID must not be empty");return k(await H(e,t))}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Component as Oe,StrictMode as Le,useEffect as Be,useState as Ne}from"react";import{createRoot as Ue}from"react-dom/client";import{Fragment as Ge,jsx as d,jsxs as Ve}from"react/jsx-runtime";var _=new WeakSet,C=class extends Oe{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){this.props.failed(t)}render(){let t=this.props.fallback;return this.state.failed?t?d(t,{code:"APP_BOOT_FAILED"}):d("div",{role:"alert",children:"APP_BOOT_FAILED"}):this.props.children}};function bt(e){let t,n,i=new Promise((r,g)=>{t=r,n=g});i.catch(()=>{});let a=!1,s=!1,c=!1,l,I=()=>{},p=()=>{},f=r=>{try{e.onDiagnostic?.(R(r))}catch{}},S=r=>{f(r),!(a||s||c)&&(c=!0,n(r),e.reportLifecycle!==!1&&m.reportLoadFailed("APP_BOOT_FAILED",{appSdk:"0.5.1"}).catch(f))},A;try{A=typeof e.root=="string"?document.querySelector(e.root):e.root??document.querySelector("#root")}catch(r){return S(r),{ready:i,dispose(){a=!0}}}if(!A)return S(new Error("APP_ROOT_NOT_FOUND")),{ready:i,dispose(){a=!0}};if(_.has(A))throw new Error("APP_ALREADY_STARTED");_.add(A);let z=()=>{a||(a=!0,I(),p(),l?.unmount(),_.delete(A),N.clear(),!s&&!c&&n(new Error("APP_DISPOSED")))},K=()=>{queueMicrotask(()=>{a||c||s||(s=!0,e.reportLifecycle===!1?t():m.ready({appSdk:"0.5.1"}).then(t,r=>{f(r),n(r)}))})};function W({locale:r,theme:g}){let[y,h]=Ne();Be(()=>(p=m.subscribeModeChanged(h),K(),()=>p()),[]);let Q=e.app,E=Ve(Ge,{children:[d(Q,{}),e.platformUI===!1?null:d(U,{})]});return d(B,{runtime:m,theme:g,locale:r,mode:y,onDiagnostic:e.onDiagnostic,children:e.providers?e.providers(E):E})}try{l=Ue(A);let r=e.slots?.loading;r&&l.render(d(C,{failed:S,fallback:e.slots?.error,children:d(r,{})})),m.getRuntimeContext().then(g=>{if(a||c)return;let y=e.locale&&e.locale!=="host"?e.locale:O(g.locale,"en");document.documentElement.lang=L(y),e.linkGuard!==!1&&(I=M({onDiagnostic:e.onDiagnostic}));let h=d(C,{failed:S,fallback:e.slots?.error,children:d(W,{locale:y,theme:e.theme&&e.theme!=="host"?e.theme:g.colorScheme==="dark"?"dark":"light"})});l.render(e.strictMode===!1?h:d(Le,{children:h}))}).catch(S)}catch(r){S(r)}return{ready:i,dispose:z}}export{at as AttachmentImage,B as BaseAppProvider,He as CAPABILITY_CATALOG,w as CapabilityUnavailableError,Ie as DataNotReadyError,nt as DatabaseUserMenu,ze as DiagnosticCode,U as FloatingButton,qe as SDKError,j as SITE_RUNTIME_PROTOCOL_VERSION,P as SiteChatbotStreamAdapter,Ot as SiteChatbotStreamError,Y as SiteRuntimeApi,te as SiteRuntimeClient,Z as SiteRuntimeErrorCode,J as SiteRuntimeEvent,X as SiteRuntimeFunction,Je as UiLanguageContext,rt as UserSelectorEditor,it as UserSelectorPanel,Re as buildAttachmentCoverUrl,ge as buildDatabaseInvokeFunctionPath,Ae as buildDatabaseInvokeGetPath,be as callSiteAIFunction,R as classifyRuntimeError,we as createSiteAIFunctionTask,ne as createSiteRuntimeClient,de as createSiteRuntimeFetch,me as fetch,fe as fetchAttachmentCover,Se as fetchAttachmentDownloadUrl,We as getCapabilities,ae as getCurrentUser,le as getDatabaseContext,Qe as getRuntimeCapabilities,ve as getSiteAIFunctionTask,Xe as getUiLanguage,L as getUiLocale,v as hasCapability,Ee as hasRunnableMediaTask,Ze as initializeUiLanguage,M as installLinkGuard,re as invokeApi,ke as invokeDatabaseFunction,ye as invokeDatabaseMutationBatch,ie as invokeHttp,Ce as invokeSiteAIFunctionStream,ee as isValidSiteFunctionName,oe as logout,k as normalizeSiteAIMediaTask,he as openAttachmentDownload,ue as openLink,je as queryCapability,Ke as readCapabilities,$ as readSiteAITextDelta,se as requestEdit,Ye as requireCapability,pe as resolveDatabaseContext,O as selectUiLanguage,m as siteRuntime,bt as startBaseApp,ce as uploadAttachment,et as useBaseApp,tt as useOptionalBaseApp,$e as useUiLanguage};
|
package/dist/server.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var J=(t,s)=>{for(var o in s)k(t,o,{get:s[o],enumerable:!0})},V=(t,s,o,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let
|
|
1
|
+
"use strict";var k=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var J=(t,s)=>{for(var o in s)k(t,o,{get:s[o],enumerable:!0})},V=(t,s,o,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of L(s))!W.call(t,r)&&r!==o&&k(t,r,{get:()=>s[r],enumerable:!(e=U(s,r))||e.enumerable});return t};var z=t=>V(k({},"__esModule",{value:!0}),t);var v={};J(v,{SDKError:()=>f,bindFunctionRuntime:()=>j,createServerContext:()=>_,defineFunction:()=>K,normalizeRecordsResult:()=>x});module.exports=z(v);var F=Symbol.for("@lark-base-open/base-database-app-sdk/SDKError/v1"),f=class extends Error{constructor(o,e,r,n){super(e);this.code=o;this.name="SDKError",this.safeMessage=e;let c=typeof r=="object"?r:{};this.upstreamCode=typeof r=="string"?r:void 0,this.wireCode=Number.isSafeInteger(c.wireCode)&&c.wireCode!==0?c.wireCode:o==="SDK_TIMEOUT"?504:o==="SDK_CANCELLED"?499:o==="SDK_INPUT_INVALID"?400:500,this.retryable=c.retryable??n??!1,this.outcome=c.outcome??"failed",this.paths=c.paths??[]}[F]=!0;static[Symbol.hasInstance](o){return this!==f?Function.prototype[Symbol.hasInstance].call(this,o):o!==null&&typeof o=="object"&&o[F]===!0}wireCode;safeMessage;retryable;outcome;paths;upstreamCode};var d=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),R=t=>typeof t=="string"&&/^rec[A-Za-z0-9]{1,32}$/.test(t);function S(t){let s=new Set,o=e=>{if(!(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))){if(typeof e!="object"||!e||s.has(e)||Array.isArray(e)&&Object.getPrototypeOf(e)!==Array.prototype||!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null||Array.isArray(e)&&(Object.keys(e).length!==e.length||Object.keys(e).some((r,n)=>r!==String(n))))throw 0;s.add(e);for(let r of Reflect.ownKeys(e)){if(Array.isArray(e)&&r==="length")continue;if(typeof r!="string")throw 0;let n=Object.getOwnPropertyDescriptor(e,r);if(!n.enumerable||!("value"in n))throw 0;o(n.value)}s.delete(e)}};try{o(t)}catch{throw new f("SDK_OUTPUT_NOT_JSON","\u8F93\u51FA\u5FC5\u987B\u662F\u65E0\u635F JSON \u503C")}}function O(t,s,o){return{status:"unknown",code:t,retryable:!1,...s?{requestedIds:[...s]}:{},...o?{logid:o}:{}}}var B=t=>typeof t=="number"&&[401,403,404,91403,1254302,1254043,1254044].includes(t),A=t=>({status:"failed",code:"SDK_RECORDS_REJECTED",upstreamCode:t,retryable:!1,appliedIds:[]}),D=t=>Array.isArray(t)&&t.every(R)&&new Set(t).size===t.length;function x(t,s){let o=()=>O("SDK_RECORDS_RESULT_UNKNOWN",s.requestedIds);if(d(t)&&B(t.code))return A(t.code);if(!d(t)||t.code!==0||!d(t.data))return o();let e=t.data,r=e.ignored_fields??[];if(!Array.isArray(r)||!r.every(a=>d(a)&&["id","name","reason"].every(i=>typeof a[i]=="string")))return o();let n=e.record_not_found??[];if(!D(n))return o();let c=s.requestedIds??[],u,y;if(s.operation==="appendAttachments"||s.operation==="removeAttachments"){if(!d(e.attachments))return o();try{S(e.attachments)}catch{return o()}for(let[a,i]of Object.entries(e.attachments)){if(!R(a)||!c.includes(a)||!d(i)||!Object.keys(i).length)return o();for(let[p,m]of Object.entries(i))if(!/^fld[A-Za-z0-9]+$/.test(p)||!Array.isArray(m)||!m.every(g=>d(g)&&typeof g.file_token=="string"&&g.file_token.length>0))return o()}if(u=Object.keys(e.attachments),n.some(a=>!c.includes(a)||u.includes(a))||!r.length&&c.some(a=>!u.includes(a)&&!n.includes(a)))return o();y=e.attachments}else{if(!D(e.record_id_list))return o();let a=e.record_id_list;if(s.operation==="create"){if(a.length!==s.count||Object.hasOwn(e,"record_not_found"))return o();u=a}else if(s.operation==="update"){if(a.some(i=>!c.includes(i)||n.includes(i))||n.some(i=>!c.includes(i))||a.length+n.length!==c.length)return o();u=a}else{if(a.length!==c.length||a.some((i,p)=>i!==c[p])||n.some(i=>!c.includes(i)))return o();u=a.filter(i=>!n.includes(i))}}let l=y===void 0?{}:{attachments:y};return n.length||r.length?{status:"partial",appliedIds:u,notFoundIds:n,ignoredFields:r,...l}:{status:"success",appliedIds:u,notFoundIds:[],ignoredFields:[],...l}}var E={create:"records/batch_create",update:"records/batch_update",delete:"records/batch_delete",appendAttachments:"append_attachments",removeAttachments:"remove_attachments"},I=t=>({status:"failed",code:t,retryable:!1,appliedIds:[]});function $(t){if(t?.platformEnv==="online")return t.brand==="feishu"?"https://open.feishu.cn":t.brand==="lark"?"https://open.larksuite.com":void 0;if(t?.brand==="feishu"){if(t.platformEnv==="pre")return"https://open.feishu-pre.cn";if(t.platformEnv==="boe")return"https://open.feishu-boe.cn"}}function T(t,s){let o=async(e,r,n,c)=>{if(!s)return I("SDK_RUNTIME_PROFILE_MISSING");let u=$(s);if(!u)return I("SDK_RUNTIME_PROFILE_UNSUPPORTED");if(c?.signal?.aborted)return I("SDK_CANCELLED");let y,l,a;try{if(!d(r)||typeof r.baseToken!="string"||typeof r.tableId!="string"||!/^[A-Za-z0-9]+$/.test(r.baseToken)||!/^tbl[A-Za-z0-9]+$/.test(r.tableId))throw 0;if(S(n),e==="create"){if(!Array.isArray(n)||!n.every(d))throw 0;a=n.length,y={create_records:n}}else if(e==="update"){if(!d(n)||!Object.values(n).every(d))throw 0;l=Object.keys(n),a=l.length,y={update_records:n}}else if(e==="delete"){if(!Array.isArray(n)||!n.every(R))throw 0;l=n,a=n.length,y={record_id_list:n}}else{if(!d(n))throw 0;let i=Object.create(null),p=0;for(let[m,g]of Object.entries(n)){if(!R(m)||!d(g))throw 0;for(let[C,w]of Object.entries(g)){if(!C.trim()||!Array.isArray(w))throw 0;for(let h of w){if(!d(h)||typeof h.file_token!="string"||!h.file_token.trim()||Object.keys(h).some(b=>!["file_token",...e==="appendAttachments"?["image_width","image_height"]:[]].includes(b)))throw 0;for(let b of["image_width","image_height"])if(h[b]!==void 0&&(typeof h[b]!="number"||!Number.isInteger(h[b])||h[b]<=0))throw 0}p+=w.length,w.length&&(i[m]??=Object.create(null),i[m][C]=w)}}if(p>50)throw 0;if(!p)return{status:"success",appliedIds:[],notFoundIds:[],ignoredFields:[],noop:!0};l=Object.keys(i),y={attachments:i}}if(a!==void 0&&(a<1||a>200)||l&&(!l.every(R)||new Set(l).size!==l.length))throw 0}catch{return I("SDK_RECORDS_INPUT_INVALID")}try{let i=await t.fetch(`${u}/open-apis/bitable/v1/apps/${encodeURIComponent(r.baseToken)}/tables/${encodeURIComponent(r.tableId)}/${E[e]}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(y),signal:c?.signal}),p=i.headers.get("x-tt-logid")??void 0;if([401,403,404].includes(i.status))return A(i.status);if(!i.ok)return O("SDK_RECORDS_HTTP_ERROR",l,p);let m=x(await i.json(),{operation:e,requestedIds:l,count:a});return m.status==="unknown"&&p?{...m,logid:p}:m}catch(i){let p=i instanceof Error?i.name:"";return O(p==="AbortError"?"SDK_CANCELLED":p==="TimeoutError"?"SDK_TIMEOUT":"SDK_RECORDS_RESULT_UNKNOWN",l)}};return Object.fromEntries(Object.keys(E).map(e=>[e,(r,n,c)=>o(e,r,n,c)]))}var P=Symbol("base-database-runtime-profile");function j(t,s){let o=Object.freeze({platformEnv:s.platformEnv,brand:s.brand});return function(e,r){let n=Object.defineProperty({...r},P,{value:o});return t.call(this,e,n)}}function _(t){return{...t,records:T(t,t[P])}}async function N(t,s,o){let e;try{e=await t["~standard"].validate(s)}catch{throw new f("SDK_VALIDATOR_FAILED","Schema \u6821\u9A8C\u5668\u6267\u884C\u5931\u8D25")}if(e.issues){let r=e.issues.map(n=>(n.path??[]).map(c=>{let u=typeof c=="object"?c.key:c;return typeof u=="number"||typeof u=="string"?u:"[symbol]"}));throw new f(`SDK_${o}_INVALID`,o==="INPUT"?"\u8F93\u5165\u4E0D\u7B26\u5408\u5951\u7EA6":"\u8F93\u51FA\u4E0D\u7B26\u5408\u5951\u7EA6",{paths:r})}return e.value}function K(t){return async(s,o)=>{try{let e=await N(t.input,s,"INPUT"),r=await t.handler(e,_(o)),n=await N(t.output,r,"OUTPUT");return S(n),{code:0,msg:"success",data:n}}catch(e){let r=e instanceof f?e:new f("SDK_HANDLER_FAILED","\u51FD\u6570\u6267\u884C\u5931\u8D25");console.error(JSON.stringify({source:"sdk",code:r.code,paths:r.paths,retryable:r.retryable,outcome:r.outcome}));let n={code:r.wireCode,msg:r.safeMessage};return e instanceof f||Object.defineProperty(n,Symbol.for("base-site.function-error"),{value:e}),n}}}0&&(module.exports={SDKError,bindFunctionRuntime,createServerContext,defineFunction,normalizeRecordsResult});
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as h}from"./chunk-3JX3FIBG.js";var d=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),b=t=>typeof t=="string"&&/^rec[A-Za-z0-9]{1,32}$/.test(t);function O(t){let a=new Set,i=e=>{if(!(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))){if(typeof e!="object"||!e||a.has(e)||Array.isArray(e)&&Object.getPrototypeOf(e)!==Array.prototype||!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null||Array.isArray(e)&&(Object.keys(e).length!==e.length||Object.keys(e).some((r,n)=>r!==String(n))))throw 0;a.add(e);for(let r of Reflect.ownKeys(e)){if(Array.isArray(e)&&r==="length")continue;if(typeof r!="string")throw 0;let n=Object.getOwnPropertyDescriptor(e,r);if(!n.enumerable||!("value"in n))throw 0;i(n.value)}a.delete(e)}};try{i(t)}catch{throw new h("SDK_OUTPUT_NOT_JSON","\u8F93\u51FA\u5FC5\u987B\u662F\u65E0\u635F JSON \u503C")}}function x(t,a,i){return{status:"unknown",code:t,retryable:!1,...a?{requestedIds:[...a]}:{},...i?{logid:i}:{}}}var P=t=>typeof t=="number"&&[401,403,404,91403,1254302,1254043,1254044].includes(t),I=t=>({status:"failed",code:"SDK_RECORDS_REJECTED",upstreamCode:t,retryable:!1,appliedIds:[]}),F=t=>Array.isArray(t)&&t.every(b)&&new Set(t).size===t.length;function _(t,a){let i=()=>x("SDK_RECORDS_RESULT_UNKNOWN",a.requestedIds);if(d(t)&&P(t.code))return I(t.code);if(!d(t)||t.code!==0||!d(t.data))return i();let e=t.data,r=e.ignored_fields??[];if(!Array.isArray(r)||!r.every(s=>d(s)&&["id","name","reason"].every(o=>typeof s[o]=="string")))return i();let n=e.record_not_found??[];if(!F(n))return i();let c=a.requestedIds??[],u,m;if(a.operation==="appendAttachments"||a.operation==="removeAttachments"){if(!d(e.attachments))return i();try{O(e.attachments)}catch{return i()}for(let[s,o]of Object.entries(e.attachments)){if(!b(s)||!c.includes(s)||!d(o)||!Object.keys(o).length)return i();for(let[p,f]of Object.entries(o))if(!/^fld[A-Za-z0-9]+$/.test(p)||!Array.isArray(f)||!f.every(g=>d(g)&&typeof g.file_token=="string"&&g.file_token.length>0))return i()}if(u=Object.keys(e.attachments),n.some(s=>!c.includes(s)||u.includes(s))||!r.length&&c.some(s=>!u.includes(s)&&!n.includes(s)))return i();m=e.attachments}else{if(!F(e.record_id_list))return i();let s=e.record_id_list;if(a.operation==="create"){if(s.length!==a.count||Object.hasOwn(e,"record_not_found"))return i();u=s}else if(a.operation==="update"){if(s.some(o=>!c.includes(o)||n.includes(o))||n.some(o=>!c.includes(o))||s.length+n.length!==c.length)return i();u=s}else{if(s.length!==c.length||s.some((o,p)=>o!==c[p])||n.some(o=>!c.includes(o)))return i();u=s.filter(o=>!n.includes(o))}}let l=m===void 0?{}:{attachments:m};return n.length||r.length?{status:"partial",appliedIds:u,notFoundIds:n,ignoredFields:r,...l}:{status:"success",appliedIds:u,notFoundIds:[],ignoredFields:[],...l}}var C={create:"records/batch_create",update:"records/batch_update",delete:"records/batch_delete",appendAttachments:"append_attachments",removeAttachments:"remove_attachments"},S=t=>({status:"failed",code:t,retryable:!1,appliedIds:[]});function j(t){if(t?.platformEnv==="online")return t.brand==="feishu"?"https://open.feishu.cn":t.brand==="lark"?"https://open.larksuite.com":void 0;if(t?.brand==="feishu"){if(t.platformEnv==="pre")return"https://open.feishu-pre.cn";if(t.platformEnv==="boe")return"https://open.feishu-boe.cn"}}function E(t,a){let i=async(e,r,n,c)=>{if(!a)return S("SDK_RUNTIME_PROFILE_MISSING");let u=j(a);if(!u)return S("SDK_RUNTIME_PROFILE_UNSUPPORTED");if(c?.signal?.aborted)return S("SDK_CANCELLED");let m,l,s;try{if(!d(r)||typeof r.baseToken!="string"||typeof r.tableId!="string"||!/^[A-Za-z0-9]+$/.test(r.baseToken)||!/^tbl[A-Za-z0-9]+$/.test(r.tableId))throw 0;if(O(n),e==="create"){if(!Array.isArray(n)||!n.every(d))throw 0;s=n.length,m={create_records:n}}else if(e==="update"){if(!d(n)||!Object.values(n).every(d))throw 0;l=Object.keys(n),s=l.length,m={update_records:n}}else if(e==="delete"){if(!Array.isArray(n)||!n.every(b))throw 0;l=n,s=n.length,m={record_id_list:n}}else{if(!d(n))throw 0;let o=Object.create(null),p=0;for(let[f,g]of Object.entries(n)){if(!b(f)||!d(g))throw 0;for(let[A,w]of Object.entries(g)){if(!A.trim()||!Array.isArray(w))throw 0;for(let y of w){if(!d(y)||typeof y.file_token!="string"||!y.file_token.trim()||Object.keys(y).some(R=>!["file_token",...e==="appendAttachments"?["image_width","image_height"]:[]].includes(R)))throw 0;for(let R of["image_width","image_height"])if(y[R]!==void 0&&(typeof y[R]!="number"||!Number.isInteger(y[R])||y[R]<=0))throw 0}p+=w.length,w.length&&(o[f]??=Object.create(null),o[f][A]=w)}}if(p>50)throw 0;if(!p)return{status:"success",appliedIds:[],notFoundIds:[],ignoredFields:[],noop:!0};l=Object.keys(o),m={attachments:o}}if(s!==void 0&&(s<1||s>200)||l&&(!l.every(b)||new Set(l).size!==l.length))throw 0}catch{return S("SDK_RECORDS_INPUT_INVALID")}try{let o=await t.fetch(`${u}/open-apis/bitable/v1/apps/${encodeURIComponent(r.baseToken)}/tables/${encodeURIComponent(r.tableId)}/${C[e]}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m),signal:c?.signal}),p=o.headers.get("x-tt-logid")??void 0;if([401,403,404].includes(o.status))return I(o.status);if(!o.ok)return x("SDK_RECORDS_HTTP_ERROR",l,p);let f=_(await o.json(),{operation:e,requestedIds:l,count:s});return f.status==="unknown"&&p?{...f,logid:p}:f}catch(o){let p=o instanceof Error?o.name:"";return x(p==="AbortError"?"SDK_CANCELLED":p==="TimeoutError"?"SDK_TIMEOUT":"SDK_RECORDS_RESULT_UNKNOWN",l)}};return Object.fromEntries(Object.keys(C).map(e=>[e,(r,n,c)=>i(e,r,n,c)]))}var T=Symbol("base-database-runtime-profile");function N(t,a){let i=Object.freeze({platformEnv:a.platformEnv,brand:a.brand});return function(e,r){let n=Object.defineProperty({...r},T,{value:i});return t.call(this,e,n)}}function k(t){return{...t,records:E(t,t[T])}}async function D(t,a,i){let e;try{e=await t["~standard"].validate(a)}catch{throw new h("SDK_VALIDATOR_FAILED","Schema \u6821\u9A8C\u5668\u6267\u884C\u5931\u8D25")}if(e.issues){let r=e.issues.map(n=>(n.path??[]).map(c=>{let u=typeof c=="object"?c.key:c;return typeof u=="number"||typeof u=="string"?u:"[symbol]"}));throw new h(`SDK_${i}_INVALID`,i==="INPUT"?"\u8F93\u5165\u4E0D\u7B26\u5408\u5951\u7EA6":"\u8F93\u51FA\u4E0D\u7B26\u5408\u5951\u7EA6",{paths:r})}return e.value}function K(t){return async(a,i)=>{try{let e=await D(t.input,a,"INPUT"),r=await t.handler(e,k(i)),n=await D(t.output,r,"OUTPUT");return O(n),{code:0,msg:"success",data:n}}catch(e){let r=e instanceof h?e:new h("SDK_HANDLER_FAILED","\u51FD\u6570\u6267\u884C\u5931\u8D25");console.error(JSON.stringify({source:"sdk",code:r.code,paths:r.paths,retryable:r.retryable,outcome:r.outcome}));let n={code:r.wireCode,msg:r.safeMessage};return e instanceof h||Object.defineProperty(n,Symbol.for("base-site.function-error"),{value:e}),n}}}export{h as SDKError,N as bindFunctionRuntime,k as createServerContext,K as defineFunction,_ as normalizeRecordsResult};
|
package/dist/testing.d.ts
CHANGED
|
@@ -13,8 +13,7 @@ interface SiteHttpBridgeAllowlistConfig {
|
|
|
13
13
|
routes: SiteHttpBridgeRoute[];
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* 避免把 bridge 重新退化为任意同源请求代理。
|
|
16
|
+
* 模拟宿主的默认 HTTP 路由白名单;仅允许清单内的方法和路径。
|
|
18
17
|
*/
|
|
19
18
|
declare const DEFAULT_SITE_HTTP_BRIDGE_ALLOWLIST: SiteHttpBridgeAllowlistConfig;
|
|
20
19
|
|
package/dist/theme.css
CHANGED
|
@@ -114,17 +114,97 @@
|
|
|
114
114
|
}
|
|
115
115
|
.base-app-floating {
|
|
116
116
|
position: fixed;
|
|
117
|
-
bottom:
|
|
117
|
+
bottom: 40px;
|
|
118
118
|
right: 24px;
|
|
119
119
|
z-index: var(--base-app-z-floating);
|
|
120
|
-
display: flex;
|
|
121
|
-
gap: 4px;
|
|
122
120
|
}
|
|
123
121
|
.base-app-floating[data-position="bottom-left"] {
|
|
124
122
|
left: 24px;
|
|
125
123
|
right: auto;
|
|
126
124
|
}
|
|
127
|
-
.base-app-floating
|
|
125
|
+
.base-app-floating-controls {
|
|
126
|
+
position: relative;
|
|
127
|
+
display: flex;
|
|
128
|
+
padding: 2px;
|
|
129
|
+
border-radius: 50%;
|
|
130
|
+
background: #fff;
|
|
131
|
+
box-shadow:
|
|
132
|
+
0 4px 4px rgb(31 35 41 / 6%),
|
|
133
|
+
0 6px 6px rgb(31 35 41 / 4%),
|
|
134
|
+
0 8px 12px rgb(31 35 41 / 4%);
|
|
135
|
+
}
|
|
136
|
+
.base-app-floating .base-app-floating-edit {
|
|
137
|
+
display: flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
width: 48px;
|
|
141
|
+
height: 48px;
|
|
142
|
+
padding: 0;
|
|
143
|
+
border: 0;
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
background: transparent;
|
|
146
|
+
color: #2b2f36;
|
|
147
|
+
}
|
|
148
|
+
.base-app-floating-controls:hover .base-app-floating-edit,
|
|
149
|
+
.base-app-floating-edit:focus-visible {
|
|
150
|
+
color: #1456f0;
|
|
151
|
+
}
|
|
152
|
+
.base-app-floating .base-app-floating-hide {
|
|
153
|
+
position: absolute;
|
|
154
|
+
top: -4px;
|
|
155
|
+
right: -4px;
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
justify-content: center;
|
|
159
|
+
width: 16px;
|
|
160
|
+
height: 16px;
|
|
161
|
+
padding: 0;
|
|
162
|
+
border: 0;
|
|
163
|
+
border-radius: 50%;
|
|
164
|
+
background: #c8c9cc;
|
|
165
|
+
color: #646a73;
|
|
166
|
+
font-size: 14px;
|
|
167
|
+
line-height: 1;
|
|
168
|
+
opacity: 0;
|
|
169
|
+
transition: opacity 150ms;
|
|
170
|
+
}
|
|
171
|
+
.base-app-floating-controls:hover .base-app-floating-hide,
|
|
172
|
+
.base-app-floating-hide:focus-visible {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
}
|
|
175
|
+
.base-app-floating .base-app-floating-hide:hover {
|
|
176
|
+
background: #b7b9bd;
|
|
177
|
+
}
|
|
178
|
+
.base-app-floating [role="tooltip"] {
|
|
179
|
+
pointer-events: none;
|
|
180
|
+
position: fixed;
|
|
181
|
+
z-index: var(--base-app-z-popover);
|
|
182
|
+
box-sizing: border-box;
|
|
183
|
+
width: max-content;
|
|
184
|
+
max-width: calc(100vw - 16px);
|
|
185
|
+
padding: 8px 12px;
|
|
186
|
+
border-radius: 8px;
|
|
187
|
+
background: #1f2329;
|
|
188
|
+
color: #fff;
|
|
189
|
+
font-size: 12px;
|
|
190
|
+
line-height: 20px;
|
|
191
|
+
white-space: normal;
|
|
192
|
+
overflow-wrap: anywhere;
|
|
193
|
+
box-shadow:
|
|
194
|
+
0 8px 24px 8px rgb(31 35 41 / 4%),
|
|
195
|
+
0 6px 12px rgb(31 35 41 / 4%),
|
|
196
|
+
0 4px 8px -8px rgb(31 35 41 / 6%);
|
|
197
|
+
}
|
|
198
|
+
.base-app-floating-caret {
|
|
199
|
+
position: absolute;
|
|
200
|
+
top: 100%;
|
|
201
|
+
width: 24px;
|
|
202
|
+
height: 6px;
|
|
203
|
+
transform: translateX(-50%);
|
|
204
|
+
}
|
|
205
|
+
.base-app-floating-caret svg {
|
|
206
|
+
display: block;
|
|
207
|
+
}
|
|
128
208
|
.base-app-floating [role="alert"] {
|
|
129
209
|
position: absolute;
|
|
130
210
|
bottom: 100%;
|
|
@@ -136,12 +216,53 @@
|
|
|
136
216
|
}
|
|
137
217
|
.base-app-notice {
|
|
138
218
|
position: fixed;
|
|
139
|
-
top:
|
|
219
|
+
top: 32px;
|
|
140
220
|
left: 50%;
|
|
141
221
|
transform: translateX(-50%);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
222
|
+
display: flex;
|
|
223
|
+
align-items: center;
|
|
224
|
+
gap: 8px;
|
|
225
|
+
width: max-content;
|
|
226
|
+
max-width: calc(100vw - 32px);
|
|
227
|
+
min-height: 54px;
|
|
228
|
+
padding: 16px 20px;
|
|
229
|
+
border-radius: 6px;
|
|
230
|
+
background: #f0f4ff;
|
|
231
|
+
color: #1f2329;
|
|
232
|
+
font-size: 14px;
|
|
233
|
+
font-weight: 500;
|
|
234
|
+
line-height: 22px;
|
|
235
|
+
box-shadow:
|
|
236
|
+
inset 0 0 0 1px #1456f0,
|
|
237
|
+
0 8px 24px 8px rgb(31 35 41 / 4%),
|
|
238
|
+
0 6px 12px rgb(31 35 41 / 4%),
|
|
239
|
+
0 4px 8px -8px rgb(31 35 41 / 6%);
|
|
240
|
+
z-index: var(--base-app-z-popover);
|
|
241
|
+
}
|
|
242
|
+
.base-app-notice > svg,
|
|
243
|
+
.base-app-notice button {
|
|
244
|
+
flex-shrink: 0;
|
|
245
|
+
}
|
|
246
|
+
.base-app-notice > span {
|
|
247
|
+
flex: 1;
|
|
248
|
+
min-width: 0;
|
|
249
|
+
padding: 0 8px 0 4px;
|
|
250
|
+
}
|
|
251
|
+
.base-app-notice button {
|
|
252
|
+
display: flex;
|
|
253
|
+
width: 16px;
|
|
254
|
+
height: 16px;
|
|
255
|
+
padding: 0;
|
|
256
|
+
border: 0;
|
|
257
|
+
background: transparent;
|
|
258
|
+
}
|
|
259
|
+
@media (max-width: 400px) {
|
|
260
|
+
.base-app-notice {
|
|
261
|
+
padding-inline: 8px;
|
|
262
|
+
}
|
|
263
|
+
.base-app-notice > span {
|
|
264
|
+
padding-inline: 0;
|
|
265
|
+
}
|
|
145
266
|
}
|
|
146
267
|
.base-app-user-menu {
|
|
147
268
|
display: inline-flex;
|
package/docs/README.md
CHANGED
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
- [upgrade:工程迁移与 SDK 升级](upgrade.md)
|
|
14
14
|
- [可编译示例](../examples)
|
|
15
15
|
|
|
16
|
-
SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务规则、服务端契约、Mutation 结果、CLI
|
|
16
|
+
SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务规则、服务端契约、Mutation 结果、CLI 命令与应用发布流程,请查阅 [@lark-base-open/base-database-cli](https://www.npmjs.com/package/@lark-base-open/base-database-cli) 随包安装的 lark-base-database Skill 及其 references。升级 CLI 时以该版本随包 Skill 为准。
|