@lark-base-open/base-database-cli 1.3.9 → 1.4.3
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 +75 -0
- package/README.md +119 -15
- package/THIRD_PARTY_LICENSES.json +1662 -0
- package/config-schema.json +64 -3
- package/data/template-hmr-scripts.json +9 -0
- package/data/template-index-html/17e698eef687ece8f1628e3e2c4801da5e7233faa87076b3424acde8df57b825.html +24 -0
- package/dist/agent-tools-guide.d.ts +29 -0
- package/dist/agent-tools-guide.d.ts.map +1 -0
- package/dist/agent-tools-guide.js +169 -0
- package/dist/agent-tools-guide.js.map +1 -0
- package/dist/agent-tools-skill.d.ts +16 -0
- package/dist/agent-tools-skill.d.ts.map +1 -0
- package/dist/agent-tools-skill.js +183 -0
- package/dist/agent-tools-skill.js.map +1 -0
- package/dist/agent-tools.d.ts +20 -0
- package/dist/agent-tools.d.ts.map +1 -0
- package/dist/agent-tools.js +137 -0
- package/dist/agent-tools.js.map +1 -0
- package/dist/ai-functions.d.ts +10 -0
- package/dist/ai-functions.d.ts.map +1 -1
- package/dist/ai-functions.js +264 -212
- package/dist/ai-functions.js.map +1 -1
- package/dist/app-builder/core.d.mts +37 -0
- package/dist/app-builder/core.d.mts.map +1 -0
- package/dist/app-builder/core.mjs +673 -0
- package/dist/app-builder/core.mjs.map +1 -0
- package/dist/app-builder/package.json +1 -0
- package/dist/app-builder/schema.d.ts +4 -0
- package/dist/app-builder/schema.d.ts.map +1 -0
- package/dist/app-builder/schema.js +72 -0
- package/dist/app-builder/schema.js.map +1 -0
- package/dist/archive.d.ts +22 -2
- package/dist/archive.d.ts.map +1 -1
- package/dist/archive.js +311 -74
- package/dist/archive.js.map +1 -1
- package/dist/auth.d.ts +2 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +13 -8
- package/dist/auth.js.map +1 -1
- package/dist/build-server.d.ts +25 -0
- package/dist/build-server.d.ts.map +1 -0
- package/dist/build-server.js +32 -0
- package/dist/build-server.js.map +1 -0
- package/dist/business-update-notice.d.ts +37 -0
- package/dist/business-update-notice.d.ts.map +1 -0
- package/dist/business-update-notice.js +24 -0
- package/dist/business-update-notice.js.map +1 -0
- package/dist/check.d.ts +11 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +85 -15
- package/dist/check.js.map +1 -1
- package/dist/cloud-build-diagnostic.d.ts +9 -0
- package/dist/cloud-build-diagnostic.d.ts.map +1 -0
- package/dist/cloud-build-diagnostic.js +65 -0
- package/dist/cloud-build-diagnostic.js.map +1 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +41 -11
- package/dist/config.js.map +1 -1
- package/dist/contract-extractor.d.ts +21 -0
- package/dist/contract-extractor.d.ts.map +1 -0
- package/dist/contract-extractor.js +260 -0
- package/dist/contract-extractor.js.map +1 -0
- package/dist/contract-worker.d.ts +12 -0
- package/dist/contract-worker.d.ts.map +1 -0
- package/dist/contract-worker.js +90 -0
- package/dist/contract-worker.js.map +1 -0
- package/dist/dependency-policy.d.ts.map +1 -1
- package/dist/dependency-policy.js +6 -1
- package/dist/dependency-policy.js.map +1 -1
- package/dist/deploy.d.ts +20 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +181 -52
- package/dist/deploy.js.map +1 -1
- package/dist/dev-bootstrap.d.ts +5 -0
- package/dist/dev-bootstrap.d.ts.map +1 -0
- package/dist/dev-bootstrap.js +185 -0
- package/dist/dev-bootstrap.js.map +1 -0
- package/dist/dev-events.d.ts +24 -0
- package/dist/dev-events.d.ts.map +1 -0
- package/dist/dev-events.js +67 -0
- package/dist/dev-events.js.map +1 -0
- package/dist/dev-pairing.d.ts +4 -0
- package/dist/dev-pairing.d.ts.map +1 -0
- package/dist/dev-pairing.js +54 -0
- package/dist/dev-pairing.js.map +1 -0
- package/dist/dev-url.d.ts +4 -0
- package/dist/dev-url.d.ts.map +1 -0
- package/dist/dev-url.js +29 -0
- package/dist/dev-url.js.map +1 -0
- package/dist/dev-vite.d.ts +9 -0
- package/dist/dev-vite.d.ts.map +1 -0
- package/dist/dev-vite.js +237 -0
- package/dist/dev-vite.js.map +1 -0
- package/dist/dev-watch.d.ts +33 -0
- package/dist/dev-watch.d.ts.map +1 -0
- package/dist/dev-watch.js +246 -0
- package/dist/dev-watch.js.map +1 -0
- package/dist/dev.d.ts +24 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +244 -0
- package/dist/dev.js.map +1 -0
- package/dist/development-pairing.generated.d.ts +12 -0
- package/dist/development-pairing.generated.d.ts.map +1 -0
- package/dist/development-pairing.generated.js +13 -0
- package/dist/development-pairing.generated.js.map +1 -0
- package/dist/diagnostic-platforms.d.ts +3 -0
- package/dist/diagnostic-platforms.d.ts.map +1 -0
- package/dist/diagnostic-platforms.js +3 -0
- package/dist/diagnostic-platforms.js.map +1 -0
- package/dist/diagnostic-schema.d.ts +151 -0
- package/dist/diagnostic-schema.d.ts.map +1 -0
- package/dist/diagnostic-schema.js +129 -0
- package/dist/diagnostic-schema.js.map +1 -0
- package/dist/diagnostics.d.ts +78 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +333 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/distribution-commands.d.ts.map +1 -1
- package/dist/distribution-commands.js +6 -2
- package/dist/distribution-commands.js.map +1 -1
- package/dist/distribution-npm.d.ts +2 -2
- package/dist/distribution-npm.d.ts.map +1 -1
- package/dist/distribution-npm.js +14 -1
- package/dist/distribution-npm.js.map +1 -1
- package/dist/environment-variables.d.ts.map +1 -1
- package/dist/environment-variables.js +2 -1
- package/dist/environment-variables.js.map +1 -1
- package/dist/function-contracts.d.ts +40 -0
- package/dist/function-contracts.d.ts.map +1 -0
- package/dist/function-contracts.js +357 -0
- package/dist/function-contracts.js.map +1 -0
- package/dist/function-description.d.ts +11 -4
- package/dist/function-description.d.ts.map +1 -1
- package/dist/function-description.js +22 -12
- package/dist/function-description.js.map +1 -1
- package/dist/function-input-types.d.ts +6 -4
- package/dist/function-input-types.d.ts.map +1 -1
- package/dist/function-input-types.js +97 -135
- package/dist/function-input-types.js.map +1 -1
- package/dist/function-params.d.ts +53 -0
- package/dist/function-params.d.ts.map +1 -0
- package/dist/function-params.js +184 -0
- package/dist/function-params.js.map +1 -0
- package/dist/function-schema.d.ts +14 -0
- package/dist/function-schema.d.ts.map +1 -1
- package/dist/function-schema.js +99 -9
- package/dist/function-schema.js.map +1 -1
- package/dist/init-journal.d.ts +1 -0
- package/dist/init-journal.d.ts.map +1 -1
- package/dist/init-journal.js +21 -7
- package/dist/init-journal.js.map +1 -1
- package/dist/init.d.ts +1 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +55 -5
- package/dist/init.js.map +1 -1
- package/dist/lark-cli-error.d.ts +13 -2
- package/dist/lark-cli-error.d.ts.map +1 -1
- package/dist/lark-cli-error.js +54 -13
- package/dist/lark-cli-error.js.map +1 -1
- package/dist/lark-cli-passthrough.d.ts +9 -0
- package/dist/lark-cli-passthrough.d.ts.map +1 -0
- package/dist/lark-cli-passthrough.js +101 -0
- package/dist/lark-cli-passthrough.js.map +1 -0
- package/dist/lark-cli.d.ts +5 -2
- package/dist/lark-cli.d.ts.map +1 -1
- package/dist/lark-cli.js +96 -29
- package/dist/lark-cli.js.map +1 -1
- package/dist/legacy-function-input-renderer.d.ts +6 -0
- package/dist/legacy-function-input-renderer.d.ts.map +1 -0
- package/dist/legacy-function-input-renderer.js +175 -0
- package/dist/legacy-function-input-renderer.js.map +1 -0
- package/dist/link-guard-check.d.ts +12 -0
- package/dist/link-guard-check.d.ts.map +1 -0
- package/dist/link-guard-check.js +138 -0
- package/dist/link-guard-check.js.map +1 -0
- package/dist/managed-agent-docs.d.ts +14 -0
- package/dist/managed-agent-docs.d.ts.map +1 -0
- package/dist/managed-agent-docs.js +172 -0
- package/dist/managed-agent-docs.js.map +1 -0
- package/dist/mutation-schema.d.ts +6 -0
- package/dist/mutation-schema.d.ts.map +1 -1
- package/dist/mutation-schema.js +6 -0
- package/dist/mutation-schema.js.map +1 -1
- package/dist/mutation.d.ts +4 -1
- package/dist/mutation.d.ts.map +1 -1
- package/dist/mutation.js +17 -2
- package/dist/mutation.js.map +1 -1
- package/dist/npm.d.ts +1 -0
- package/dist/npm.d.ts.map +1 -1
- package/dist/npm.js +28 -0
- package/dist/npm.js.map +1 -1
- package/dist/preview-receipt.d.ts +0 -2
- package/dist/preview-receipt.d.ts.map +1 -1
- package/dist/preview-receipt.js +0 -28
- package/dist/preview-receipt.js.map +1 -1
- package/dist/process.d.ts +1 -0
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +25 -0
- package/dist/process.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +239 -26
- package/dist/program.js.map +1 -1
- package/dist/project-build.d.ts +2 -1
- package/dist/project-build.d.ts.map +1 -1
- package/dist/project-build.js +53 -16
- package/dist/project-build.js.map +1 -1
- package/dist/project-capabilities.d.ts +8 -0
- package/dist/project-capabilities.d.ts.map +1 -0
- package/dist/project-capabilities.js +47 -0
- package/dist/project-capabilities.js.map +1 -0
- package/dist/project-context.d.ts +66 -0
- package/dist/project-context.d.ts.map +1 -1
- package/dist/project-context.js +68 -6
- package/dist/project-context.js.map +1 -1
- package/dist/project-layout.d.ts +11 -0
- package/dist/project-layout.d.ts.map +1 -1
- package/dist/project-layout.js +63 -1
- package/dist/project-layout.js.map +1 -1
- package/dist/public-exports.d.ts +5 -0
- package/dist/public-exports.d.ts.map +1 -0
- package/dist/public-exports.js +76 -0
- package/dist/public-exports.js.map +1 -0
- package/dist/public-sql-error.d.ts +3 -1
- package/dist/public-sql-error.d.ts.map +1 -1
- package/dist/public-sql-error.js +5 -2
- package/dist/public-sql-error.js.map +1 -1
- package/dist/pull.d.ts +1 -0
- package/dist/pull.d.ts.map +1 -1
- package/dist/pull.js +103 -20
- package/dist/pull.js.map +1 -1
- package/dist/sdk-codegen.d.ts +16 -0
- package/dist/sdk-codegen.d.ts.map +1 -0
- package/dist/sdk-codegen.js +181 -0
- package/dist/sdk-codegen.js.map +1 -0
- package/dist/sdk-install.d.ts +4 -0
- package/dist/sdk-install.d.ts.map +1 -0
- package/dist/sdk-install.js +33 -0
- package/dist/sdk-install.js.map +1 -0
- package/dist/skill-frontmatter.d.ts +5 -0
- package/dist/skill-frontmatter.d.ts.map +1 -0
- package/dist/skill-frontmatter.js +28 -0
- package/dist/skill-frontmatter.js.map +1 -0
- package/dist/skill.d.ts +2 -1
- package/dist/skill.d.ts.map +1 -1
- package/dist/skill.js +18 -12
- package/dist/skill.js.map +1 -1
- package/dist/source-format.d.ts +10 -0
- package/dist/source-format.d.ts.map +1 -0
- package/dist/source-format.js +49 -0
- package/dist/source-format.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/unified-functions.d.ts +22 -0
- package/dist/unified-functions.d.ts.map +1 -0
- package/dist/unified-functions.js +114 -0
- package/dist/unified-functions.js.map +1 -0
- package/dist/updates.d.ts +13 -1
- package/dist/updates.d.ts.map +1 -1
- package/dist/updates.js +65 -29
- package/dist/updates.js.map +1 -1
- package/dist/workspace-fingerprint.d.ts.map +1 -1
- package/dist/workspace-fingerprint.js +5 -0
- package/dist/workspace-fingerprint.js.map +1 -1
- package/package.json +17 -5
- package/skills/lark-base-database/SKILL.md +21 -55
- package/skills/lark-base-database/references/agent-tool-design.md +181 -0
- package/skills/lark-base-database/references/agent-tools.md +101 -0
- package/skills/lark-base-database/references/ai-function.md +80 -186
- package/skills/lark-base-database/references/database-function-limitations.md +12 -4
- package/skills/lark-base-database/references/database-function.md +49 -21
- package/skills/lark-base-database/references/development.md +81 -109
- package/skills/lark-base-database/references/environment-variables.md +2 -2
- package/skills/lark-base-database/references/faas.md +43 -16
- package/skills/lark-base-database/references/file-transfer.md +10 -33
- package/skills/lark-base-database/references/frontend-design-guide.md +1 -1
- package/skills/lark-base-database/references/legacy-ai-function.md +120 -0
- package/skills/lark-base-database/references/legacy-development.md +156 -0
- package/skills/lark-base-database/references/legacy-file-transfer.md +68 -0
- package/skills/lark-base-database/references/mutations.md +38 -29
- package/skills/lark-base-database/references/notifications.md +1 -1
- package/skills/lark-base-database/references/permission-design.md +11 -5
- package/skills/lark-base-database/references/release.md +22 -7
- package/skills/lark-base-database/references/verification.md +55 -16
- package/skills/lark-base-database/references/workspace-migration.md +86 -0
- package/skills/lark-base-database/references/workspace.md +55 -44
- package/templates/database-starter/README.md +2 -0
- package/templates/database-starter/database-functions/README.md +2 -2
- package/templates/database-starter/mutations/README.md +2 -2
- package/templates/database-starter/page/README.md +5 -4
- package/templates/database-starter/page/src/examples/ai-function/TextStreamOperation.tsx +6 -6
- package/templates/database-starter/page/src/lib/attachment-image.tsx +19 -5
- package/templates/database-starter/page/src/lib/database-runtime-attachment.test.ts +124 -5
- package/templates/database-starter/page/src/lib/database-runtime.test.ts +2 -2
- package/templates/database-starter/page/src/lib/database-runtime.ts +77 -13
- package/templates/database-starter/server-functions/scripts/run-tsc.mjs +3 -2
- package/templates/database-starter-v2/README.md +25 -0
- package/templates/database-starter-v2/base-app.config.ts +10 -0
- package/templates/database-starter-v2/database-functions/README.md +1 -0
- package/templates/database-starter-v2/gitignore +6 -0
- package/templates/database-starter-v2/mutations/README.md +1 -0
- package/templates/database-starter-v2/package-lock.json +2239 -0
- package/templates/database-starter-v2/package.json +18 -0
- package/templates/database-starter-v2/page/index.html +2 -0
- package/templates/database-starter-v2/page/package.json +25 -0
- package/templates/database-starter-v2/page/src/App.tsx +12 -0
- package/templates/database-starter-v2/page/src/generated/README.md +1 -0
- package/templates/database-starter-v2/page/src/index.css +1 -0
- package/templates/database-starter-v2/page/src/lib/date-time.ts +61 -0
- package/templates/database-starter-v2/page/src/main.tsx +6 -0
- package/templates/database-starter-v2/page/tsconfig.json +19 -0
- package/templates/database-starter-v2/page/vite.config.ts +3 -0
- package/templates/database-starter-v2/prettierignore +3 -0
- package/templates/database-starter-v2/server/functions/README.md +1 -0
- package/templates/database-starter-v2/server/functions/hello/contract.ts +5 -0
- package/templates/database-starter-v2/server/functions/hello/index.ts +7 -0
- package/templates/database-starter-v2/server/functions/hello/meta.json +1 -0
- package/templates/database-starter-v2/server/generated/runtime-profile.ts +5 -0
- package/templates/database-starter-v2/server/package.json +17 -0
- package/templates/database-starter-v2/server/tsconfig.json +14 -0
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
getSiteAIFunctionTask as getRuntimeAIFunctionTask,
|
|
5
5
|
invokeSiteAIFunctionStream as invokeRuntimeAIFunctionStream,
|
|
6
6
|
invokeHttp,
|
|
7
|
+
openLink,
|
|
7
8
|
siteRuntime,
|
|
8
9
|
fetch as siteRuntimeFetch,
|
|
9
10
|
type CallSiteAIFunctionParams as RuntimeCallSiteAIFunctionParams,
|
|
@@ -59,6 +60,8 @@ export interface DatabaseAttachmentRef {
|
|
|
59
60
|
fieldId: string
|
|
60
61
|
recordId: string
|
|
61
62
|
fileToken: string
|
|
63
|
+
name?: string
|
|
64
|
+
mimeType?: string
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
/** 产物环境沿用 site.v1 协议的规范类型,避免两侧各自声明后漂移。 */
|
|
@@ -87,7 +90,10 @@ export type SiteAIMessage =
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
type WithSiteAIMessages<T> = T extends unknown
|
|
90
|
-
? Omit<T, 'messages'> & {
|
|
93
|
+
? Omit<T, 'messages' | 'variables' | 'params'> & {
|
|
94
|
+
messages?: SiteAIMessage[]
|
|
95
|
+
params?: Record<string, unknown>
|
|
96
|
+
}
|
|
91
97
|
: never
|
|
92
98
|
|
|
93
99
|
export type CallSiteAIFunctionParams =
|
|
@@ -95,8 +101,8 @@ export type CallSiteAIFunctionParams =
|
|
|
95
101
|
|
|
96
102
|
export type InvokeSiteAIFunctionStreamParams = Omit<
|
|
97
103
|
RuntimeInvokeSiteAIFunctionStreamParams,
|
|
98
|
-
'messages'
|
|
99
|
-
> & { messages: SiteAIMessage[] }
|
|
104
|
+
'messages' | 'variables' | 'params'
|
|
105
|
+
> & { messages: SiteAIMessage[]; params?: Record<string, unknown> }
|
|
100
106
|
|
|
101
107
|
/** 单帧增量与可取消的流句柄。 */
|
|
102
108
|
export type { SiteAIStreamDelta, SiteAIFunctionStreamHandle }
|
|
@@ -145,6 +151,8 @@ const FUNCTION_ID_PATTERN = /^[A-Za-z0-9_-]+$/
|
|
|
145
151
|
const DATABASE_RUNTIME_GATEWAY_PREFIX = '/space/api/bitable/site/v1'
|
|
146
152
|
const ATTACHMENT_DOWNLOAD_URL_PATH =
|
|
147
153
|
'/space/api/box/file/temporary_download_url'
|
|
154
|
+
const COVER_NOT_SUPPORTED = '90002005'
|
|
155
|
+
const COVER_NOT_FOUND = '90002006'
|
|
148
156
|
const PREVIEW_ENV: DatabaseEnv = 'preview'
|
|
149
157
|
|
|
150
158
|
let databaseContextPromise: Promise<DatabaseContext> | null = null
|
|
@@ -402,7 +410,11 @@ export function hasRunnableMediaTask(
|
|
|
402
410
|
export async function createSiteAIFunctionTask(
|
|
403
411
|
params: CallSiteAIFunctionParams,
|
|
404
412
|
): Promise<SiteAIMediaTask> {
|
|
405
|
-
return normalizeSiteAIMediaTask(
|
|
413
|
+
return normalizeSiteAIMediaTask(
|
|
414
|
+
await createRuntimeAIFunctionTask(
|
|
415
|
+
params as unknown as RuntimeCallSiteAIFunctionParams,
|
|
416
|
+
),
|
|
417
|
+
)
|
|
406
418
|
}
|
|
407
419
|
|
|
408
420
|
/** 轮询文生图或文生视频任务进度与最终资源。 */
|
|
@@ -577,6 +589,31 @@ function attachmentRequestError(operation: string, cause: unknown): Error {
|
|
|
577
589
|
)
|
|
578
590
|
}
|
|
579
591
|
|
|
592
|
+
async function readSvgCoverError(
|
|
593
|
+
blob: Blob,
|
|
594
|
+
logId?: string,
|
|
595
|
+
): Promise<Error | undefined> {
|
|
596
|
+
let body: unknown
|
|
597
|
+
try {
|
|
598
|
+
body = JSON.parse(await blob.text())
|
|
599
|
+
} catch {
|
|
600
|
+
return undefined
|
|
601
|
+
}
|
|
602
|
+
if (!isRecord(body) || String(body.code).trim() !== COVER_NOT_FOUND)
|
|
603
|
+
return undefined
|
|
604
|
+
return Object.assign(
|
|
605
|
+
new Error(
|
|
606
|
+
`File Type Not Support Covers (code ${COVER_NOT_SUPPORTED}${logId ? `, LogID ${logId}` : ''})`,
|
|
607
|
+
),
|
|
608
|
+
{
|
|
609
|
+
code: COVER_NOT_SUPPORTED,
|
|
610
|
+
originalCode: COVER_NOT_FOUND,
|
|
611
|
+
cause: body,
|
|
612
|
+
logId,
|
|
613
|
+
},
|
|
614
|
+
)
|
|
615
|
+
}
|
|
616
|
+
|
|
580
617
|
/** 宿主用当前访问者身份同源取图,返回可创建本地 URL 的图片字节。
|
|
581
618
|
* 调用方在替换或卸载时取消请求并释放自己创建的 Blob URL。
|
|
582
619
|
*/
|
|
@@ -609,23 +646,31 @@ export async function fetchAttachmentCover(
|
|
|
609
646
|
}).catch((cause: unknown) => {
|
|
610
647
|
throw attachmentRequestError('Attachment image request', cause)
|
|
611
648
|
})
|
|
649
|
+
const logId = response.headers.get('x-tt-logid')?.trim() || undefined
|
|
650
|
+
const blob = await response.blob()
|
|
651
|
+
// Box 的缺封面响应可能是 HTTP 202,不能只依赖 response.ok。
|
|
652
|
+
const svg =
|
|
653
|
+
ref.name?.trim().toLowerCase().endsWith('.svg') ||
|
|
654
|
+
ref.mimeType?.split(';')[0]?.trim().toLowerCase() === 'image/svg+xml'
|
|
655
|
+
if (svg && !blob.type.startsWith('image/')) {
|
|
656
|
+
const error = await readSvgCoverError(blob, logId)
|
|
657
|
+
if (error) throw error
|
|
658
|
+
}
|
|
612
659
|
if (!response.ok) {
|
|
613
|
-
const logId = response.headers.get('x-tt-logid')
|
|
614
660
|
throw new Error(
|
|
615
661
|
`Failed to load attachment image: HTTP ${response.status}${logId ? `, LogID ${logId}` : ''}`,
|
|
616
662
|
)
|
|
617
663
|
}
|
|
618
|
-
const blob = await response.blob()
|
|
619
664
|
if (!blob.size || !blob.type.startsWith('image/')) {
|
|
620
665
|
throw new Error('The host did not return a valid image')
|
|
621
666
|
}
|
|
622
667
|
return blob
|
|
623
668
|
}
|
|
624
669
|
|
|
625
|
-
/** 经父页面 bridge
|
|
670
|
+
/** 经父页面 bridge 取短时效自证链接;原文件不进入页面 JavaScript。
|
|
626
671
|
* 下载链接不代表附件增删已完成,也不提供并发或重试保证。
|
|
627
672
|
*
|
|
628
|
-
* @returns
|
|
673
|
+
* @returns 临时链接,供需要 URL 本身的能力使用。用户下载请调用 openAttachmentDownload。
|
|
629
674
|
*/
|
|
630
675
|
export async function fetchAttachmentDownloadUrl(
|
|
631
676
|
context: DatabaseContext,
|
|
@@ -697,6 +742,20 @@ export async function fetchAttachmentDownloadUrl(
|
|
|
697
742
|
return url
|
|
698
743
|
}
|
|
699
744
|
|
|
745
|
+
/** 请求宿主打开附件原文件。浏览器是否完成落盘由浏览器决定,不能据此报告下载完成。
|
|
746
|
+
* 每次点击都重新获取临时 URL,避免缓存签名链接;不要在 iframe 内创建 a[download]。
|
|
747
|
+
*/
|
|
748
|
+
export async function openAttachmentDownload(
|
|
749
|
+
context: DatabaseContext,
|
|
750
|
+
ref: DatabaseAttachmentRef,
|
|
751
|
+
): Promise<void> {
|
|
752
|
+
const url = await fetchAttachmentDownloadUrl(context, ref)
|
|
753
|
+
const result = await openLink(url)
|
|
754
|
+
if (!result.opened) {
|
|
755
|
+
throw new Error('The host did not open the attachment download link')
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
700
759
|
/** 构造运行态读取应用信息的统一网关地址。
|
|
701
760
|
*
|
|
702
761
|
* @param context 当前应用上下文。
|
|
@@ -736,7 +795,7 @@ export function buildDatabaseInvokeFunctionPath(
|
|
|
736
795
|
|
|
737
796
|
const path =
|
|
738
797
|
`${DATABASE_RUNTIME_GATEWAY_PREFIX}/${encodeURIComponent(context.token)}` +
|
|
739
|
-
`/
|
|
798
|
+
`/functions/${encodeURIComponent(functionId)}/invoke`
|
|
740
799
|
|
|
741
800
|
return context.env === PREVIEW_ENV
|
|
742
801
|
? `${path}?env=${encodeURIComponent(PREVIEW_ENV)}`
|
|
@@ -750,7 +809,7 @@ export function buildDatabaseInvokeFunctionPath(
|
|
|
750
809
|
* 4xx/5xx 直接抛错,业务码由调用方按 operation 契约校验一次顶层 code。
|
|
751
810
|
*
|
|
752
811
|
* @param functionId Base Database Function ID。
|
|
753
|
-
* @param params 函数入参:
|
|
812
|
+
* @param params 函数入参:SQL / Mutation 用命名对象,FaaS 用业务对象。
|
|
754
813
|
* @returns 统一包裹的函数响应。
|
|
755
814
|
*/
|
|
756
815
|
export type DatabaseFunctionInvocation<Inputs extends object> = [
|
|
@@ -794,15 +853,20 @@ export async function invokeDatabaseFunction<Data = unknown>(
|
|
|
794
853
|
/** 每组参数应用同一份已发布 Mutation 声明;总记录数最多 200。 */
|
|
795
854
|
export async function invokeDatabaseMutationBatch<Data = unknown>(
|
|
796
855
|
functionId: string,
|
|
797
|
-
parameterGroups: unknown[]
|
|
856
|
+
parameterGroups: Record<string, unknown>[],
|
|
798
857
|
): Promise<DatabaseFunctionResponse<Data>> {
|
|
799
858
|
if (
|
|
800
859
|
!Array.isArray(parameterGroups) ||
|
|
801
860
|
parameterGroups.length < 1 ||
|
|
802
861
|
parameterGroups.length > 200 ||
|
|
803
|
-
parameterGroups.some(
|
|
862
|
+
parameterGroups.some(
|
|
863
|
+
(params) =>
|
|
864
|
+
params === null || typeof params !== 'object' || Array.isArray(params),
|
|
865
|
+
)
|
|
804
866
|
) {
|
|
805
|
-
throw new TypeError(
|
|
867
|
+
throw new TypeError(
|
|
868
|
+
'Mutation batch requires 1 to 200 named parameter objects',
|
|
869
|
+
)
|
|
806
870
|
}
|
|
807
871
|
const context = await resolveDatabaseContext()
|
|
808
872
|
if (!context.token) throw new Error('应用 token 未确定,无法调用 Mutation')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readdirSync, rmSync } from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
import { join } from 'node:path'
|
|
3
4
|
import { spawnSync } from 'node:child_process'
|
|
4
5
|
|
|
@@ -18,13 +19,13 @@ if (!hasTypeScriptSource('functions')) {
|
|
|
18
19
|
process.exit(0)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
+
const tsc = createRequire(import.meta.url).resolve('typescript/bin/tsc')
|
|
22
23
|
const args = ['-p', 'tsconfig.json']
|
|
23
24
|
if (mode === 'check') {
|
|
24
25
|
args.push('--noEmit')
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
const result = spawnSync(
|
|
28
|
+
const result = spawnSync(process.execPath, [tsc, ...args], { stdio: 'inherit' })
|
|
28
29
|
if (result.error) {
|
|
29
30
|
throw result.error
|
|
30
31
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Base Database 应用
|
|
2
|
+
|
|
3
|
+
基于飞书多维表格的业务应用。
|
|
4
|
+
|
|
5
|
+
## Background
|
|
6
|
+
|
|
7
|
+
workspace 工程结构。
|
|
8
|
+
|
|
9
|
+
## Requested features
|
|
10
|
+
|
|
11
|
+
页面启动与服务端问候示例。
|
|
12
|
+
|
|
13
|
+
## Implemented capabilities
|
|
14
|
+
|
|
15
|
+
页面展示应用标题,hello Function 接收姓名并返回问候文本。
|
|
16
|
+
|
|
17
|
+
## Status and limitations
|
|
18
|
+
|
|
19
|
+
模板使用已正式发布的 SDK;远端构建与业务系统仍需单独验收。
|
|
20
|
+
|
|
21
|
+
## Local project
|
|
22
|
+
|
|
23
|
+
workspace 使用唯一根 npm workspace(page、server)和根 package-lock.json,SDK 正式版本由 page、server 的 package.json 精确固定,需提供 codegen 入口;缺失时按 CLI 报错给出的安装命令执行,版本与新建工程模板一致;安装依赖后执行 contracts generate,再运行 check。
|
|
24
|
+
|
|
25
|
+
安装后阅读 node_modules/@lark-base-open/base-database-app-sdk/docs/README.md。运行 contracts generate → check;本地 check 使用 CLI 内置平台构建器。云端根 npm ci 后直接调用平台构建器,Page 执行 npm run build --workspace page,不从工程脚本调用 CLI。classic 仅保留存量兼容。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
+
import type { StartBaseAppOptions } from '@lark-base-open/base-database-app-sdk/page';
|
|
4
|
+
import App from './page/src/App';
|
|
5
|
+
const queryClient = new QueryClient();
|
|
6
|
+
export default {
|
|
7
|
+
app: App,
|
|
8
|
+
providers: (children) =>
|
|
9
|
+
createElement(QueryClientProvider, { client: queryClient }, children),
|
|
10
|
+
} satisfies StartBaseAppOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
业务函数目录;格式与模板 1 相同。参阅 lark-base-database Skill。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
业务函数目录;格式与模板 1 相同。参阅 lark-base-database Skill。
|