@lark-base-open/base-database-cli 1.4.0 → 1.4.5
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 +74 -0
- package/README.md +118 -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 +30 -0
- package/dist/agent-tools-guide.d.ts.map +1 -0
- package/dist/agent-tools-guide.js +172 -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 +209 -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 +4 -1
- package/dist/lark-cli.d.ts.map +1 -1
- package/dist/lark-cli.js +51 -19
- 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 +123 -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 +103 -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 +47 -20
- 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 +54 -45
- 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/database-runtime-attachment.test.ts +52 -0
- package/templates/database-starter/page/src/lib/database-runtime.test.ts +2 -2
- package/templates/database-starter/page/src/lib/database-runtime.ts +38 -11
- 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
|
@@ -1,138 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { namedSQLParamSchema } from './function-schema.js';
|
|
2
|
+
import { PARAMETER_NAME_PATTERN } from './function-params.js';
|
|
3
|
+
import { readConfig } from './config.js';
|
|
4
|
+
import { requiresSDKCodegen, runSDKCodegen } from './sdk-codegen.js';
|
|
5
|
+
import { projectLayout } from './project-layout.js';
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
2
7
|
import { dirname, join } from 'node:path';
|
|
3
8
|
import { readDatabaseFunctionInputContracts } from './archive.js';
|
|
4
9
|
const GENERATED_INPUT_TYPES = join('page', 'src', 'lib', 'database-function-inputs.generated.ts');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function literalType(value) {
|
|
9
|
-
if (value === null)
|
|
10
|
-
return 'null';
|
|
11
|
-
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
12
|
-
return JSON.stringify(value);
|
|
13
|
-
}
|
|
14
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
15
|
-
return Object.is(value, -0) ? '-0' : String(value);
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
return `[${value.map(literalType).join(', ')}]`;
|
|
19
|
-
}
|
|
20
|
-
if (isRecord(value)) {
|
|
21
|
-
return `{ ${Object.entries(value)
|
|
22
|
-
.map(([key, child]) => `${JSON.stringify(key)}: ${literalType(child)}`)
|
|
23
|
-
.join('; ')} }`;
|
|
24
|
-
}
|
|
25
|
-
return 'never';
|
|
26
|
-
}
|
|
27
|
-
function enumValueMatchesType(value, type) {
|
|
28
|
-
switch (type) {
|
|
29
|
-
case 'string':
|
|
30
|
-
return typeof value === 'string';
|
|
31
|
-
case 'integer':
|
|
32
|
-
return typeof value === 'number' && Number.isInteger(value);
|
|
33
|
-
case 'number':
|
|
34
|
-
return typeof value === 'number' && Number.isFinite(value);
|
|
35
|
-
case 'boolean':
|
|
36
|
-
return typeof value === 'boolean';
|
|
37
|
-
case 'null':
|
|
38
|
-
return value === null;
|
|
39
|
-
case 'array':
|
|
40
|
-
return Array.isArray(value);
|
|
41
|
-
case 'object':
|
|
42
|
-
return isRecord(value);
|
|
43
|
-
default:
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function schemaTypes(schema) {
|
|
48
|
-
if (typeof schema.type === 'string')
|
|
49
|
-
return [schema.type];
|
|
50
|
-
if (Array.isArray(schema.type)) {
|
|
51
|
-
return schema.type.filter((type) => typeof type === 'string');
|
|
52
|
-
}
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
function schemaTypeFor(schema, type) {
|
|
56
|
-
switch (type) {
|
|
57
|
-
case 'string':
|
|
58
|
-
return 'string';
|
|
59
|
-
case 'integer':
|
|
60
|
-
case 'number':
|
|
61
|
-
return 'number';
|
|
62
|
-
case 'boolean':
|
|
63
|
-
return 'boolean';
|
|
64
|
-
case 'null':
|
|
65
|
-
return 'null';
|
|
66
|
-
case 'array': {
|
|
67
|
-
const rawPrefixItems = schema.prefixItems;
|
|
68
|
-
const hasPrefixItems = Array.isArray(rawPrefixItems);
|
|
69
|
-
const prefixItems = hasPrefixItems ? rawPrefixItems.filter(isRecord) : [];
|
|
70
|
-
if (hasPrefixItems &&
|
|
71
|
-
schema.minItems === prefixItems.length &&
|
|
72
|
-
schema.maxItems === prefixItems.length) {
|
|
73
|
-
return `[${prefixItems.map(schemaType).join(', ')}]`;
|
|
74
|
-
}
|
|
75
|
-
const itemType = isRecord(schema.items)
|
|
76
|
-
? schemaType(schema.items)
|
|
77
|
-
: 'unknown';
|
|
78
|
-
if (prefixItems.length === 0)
|
|
79
|
-
return `Array<${itemType}>`;
|
|
80
|
-
const tupleItems = prefixItems.map((item) => `${schemaType(item)}?`);
|
|
81
|
-
return `[${[...tupleItems, `...Array<${itemType}>`].join(', ')}]`;
|
|
82
|
-
}
|
|
83
|
-
case 'object': {
|
|
84
|
-
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
85
|
-
const required = new Set(Array.isArray(schema.required)
|
|
86
|
-
? schema.required.filter((value) => typeof value === 'string')
|
|
87
|
-
: []);
|
|
88
|
-
const propertyEntries = Object.entries(properties).filter((entry) => isRecord(entry[1]));
|
|
89
|
-
const propertyNames = new Set(propertyEntries.map(([key]) => key));
|
|
90
|
-
const missingRequired = [...required].filter((key) => !propertyNames.has(key));
|
|
91
|
-
if (missingRequired.length > 0 && schema.additionalProperties === false) {
|
|
92
|
-
return 'never';
|
|
93
|
-
}
|
|
94
|
-
const members = propertyEntries.map(([key, child]) => `${JSON.stringify(key)}${required.has(key) ? '' : '?'}: ${schemaType(child)}`);
|
|
95
|
-
members.push(...missingRequired.map((key) => `${JSON.stringify(key)}: unknown`));
|
|
96
|
-
const objectType = `{ ${members.join('; ')} }`;
|
|
97
|
-
if (schema.additionalProperties === false) {
|
|
98
|
-
return members.length === 0 ? 'Record<string, never>' : objectType;
|
|
99
|
-
}
|
|
100
|
-
return `${objectType} & Record<string, unknown>`;
|
|
101
|
-
}
|
|
102
|
-
default:
|
|
103
|
-
return 'unknown';
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function schemaType(schema) {
|
|
107
|
-
const types = schemaTypes(schema);
|
|
108
|
-
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
109
|
-
const compatible = schema.enum.filter((value) => types.some((type) => enumValueMatchesType(value, type)));
|
|
110
|
-
if (compatible.length === 0)
|
|
111
|
-
return 'never';
|
|
112
|
-
return compatible.map(literalType).join(' | ');
|
|
113
|
-
}
|
|
114
|
-
const rendered = [
|
|
115
|
-
...new Set(types.map((type) => schemaTypeFor(schema, type))),
|
|
116
|
-
];
|
|
117
|
-
return rendered.length === 0 ? 'unknown' : rendered.join(' | ');
|
|
118
|
-
}
|
|
119
|
-
export function renderDatabaseFunctionInputTypes(contracts) {
|
|
120
|
-
const members = [...contracts]
|
|
121
|
-
.sort((left, right) => left.functionId < right.functionId
|
|
122
|
-
? -1
|
|
123
|
-
: left.functionId > right.functionId
|
|
124
|
-
? 1
|
|
125
|
-
: 0)
|
|
126
|
-
.map((contract) => ` ${JSON.stringify(contract.functionId)}: ${schemaType(contract.inputSchema)}`);
|
|
127
|
-
return [
|
|
128
|
-
'/* Generated by base-database-cli from Function metadata. Do not edit. */',
|
|
129
|
-
'// prettier-ignore',
|
|
130
|
-
'export type DatabaseFunctionInputMap = {',
|
|
131
|
-
...members,
|
|
132
|
-
'}',
|
|
133
|
-
'',
|
|
134
|
-
].join('\n');
|
|
135
|
-
}
|
|
10
|
+
import { renderDatabaseFunctionInputTypes } from './legacy-function-input-renderer.js';
|
|
11
|
+
export { renderDatabaseFunctionInputTypes } from './legacy-function-input-renderer.js';
|
|
136
12
|
function writeIfChanged(path, content) {
|
|
137
13
|
try {
|
|
138
14
|
if (readFileSync(path, 'utf8') === content)
|
|
@@ -146,10 +22,96 @@ function writeIfChanged(path, content) {
|
|
|
146
22
|
writeFileSync(temporary, content);
|
|
147
23
|
renameSync(temporary, path);
|
|
148
24
|
}
|
|
25
|
+
/** Public layout/declaration contract; never inspect Page source or SDK installation. */
|
|
26
|
+
export function resolveFunctionInputMode(workspace, consumer = 'page') {
|
|
27
|
+
const config = readConfig(workspace);
|
|
28
|
+
if (consumer === 'sdk-client' || config.template?.version === 2)
|
|
29
|
+
return 'named';
|
|
30
|
+
return config.functionInputs ?? 'positional';
|
|
31
|
+
}
|
|
32
|
+
export function namedInputSchema(contract) {
|
|
33
|
+
if (contract.functionType === 2)
|
|
34
|
+
return contract.inputSchema;
|
|
35
|
+
const properties = Object.create(null);
|
|
36
|
+
const required = [];
|
|
37
|
+
for (const [index, param] of (contract.parameters ?? []).entries()) {
|
|
38
|
+
const name = param.name;
|
|
39
|
+
if (typeof name !== 'string' ||
|
|
40
|
+
!PARAMETER_NAME_PATTERN.test(name) ||
|
|
41
|
+
Object.hasOwn(properties, name)) {
|
|
42
|
+
throw new Error(`${contract.functionId}: parameter ${index + 1} needs a unique explicit name matching the frozen server declaration; do not infer names from SQL`);
|
|
43
|
+
}
|
|
44
|
+
let schema;
|
|
45
|
+
if (contract.functionType === 1) {
|
|
46
|
+
schema = namedSQLParamSchema(param, index);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const kind = param.kind;
|
|
50
|
+
const type = kind === 'BOOL'
|
|
51
|
+
? 'boolean'
|
|
52
|
+
: ['INT', 'DOUBLE', 'DURATION'].includes(String(kind))
|
|
53
|
+
? 'number'
|
|
54
|
+
: kind === 'ATTACHMENT'
|
|
55
|
+
? 'object'
|
|
56
|
+
: kind === 'TIMESTAMP'
|
|
57
|
+
? ['string', 'number']
|
|
58
|
+
: 'string';
|
|
59
|
+
schema = {
|
|
60
|
+
type,
|
|
61
|
+
...(Array.isArray(param.enum) ? { enum: param.enum } : {}),
|
|
62
|
+
};
|
|
63
|
+
if (param.list === true)
|
|
64
|
+
schema = {
|
|
65
|
+
type: 'array',
|
|
66
|
+
items: schema,
|
|
67
|
+
minItems: 0,
|
|
68
|
+
maxItems: param.maxItems ?? 200,
|
|
69
|
+
};
|
|
70
|
+
if (typeof param.description === 'string')
|
|
71
|
+
schema.description = param.description;
|
|
72
|
+
if (param.required === false)
|
|
73
|
+
schema = { anyOf: [schema, { type: 'null' }] };
|
|
74
|
+
}
|
|
75
|
+
if (typeof param.description === 'string')
|
|
76
|
+
schema.description = param.description;
|
|
77
|
+
properties[name] = schema;
|
|
78
|
+
if (contract.functionType === 1 || param.required !== false)
|
|
79
|
+
required.push(name);
|
|
80
|
+
}
|
|
81
|
+
return { type: 'object', properties, required, additionalProperties: false };
|
|
82
|
+
}
|
|
149
83
|
export function syncDatabaseFunctionInputTypes(workspace) {
|
|
150
|
-
const contracts = readDatabaseFunctionInputContracts(workspace
|
|
151
|
-
|
|
152
|
-
|
|
84
|
+
const contracts = readDatabaseFunctionInputContracts(workspace, {
|
|
85
|
+
enforceDescriptions: false,
|
|
86
|
+
});
|
|
87
|
+
const version = projectLayout(workspace).version;
|
|
88
|
+
const obsolete = join(workspace, 'page/src/generated/function-inputs.d.ts');
|
|
89
|
+
if (version === 2 &&
|
|
90
|
+
existsSync(obsolete) &&
|
|
91
|
+
!readFileSync(obsolete, 'utf8').startsWith('/* Generated by base-database-cli from Function metadata. Do not edit. */'))
|
|
92
|
+
throw new Error('FUNCTION_INPUT_MODULE_CONFLICT: unrecognized function-inputs.d.ts; review it before regenerating');
|
|
93
|
+
const path = join(workspace, version === 2
|
|
94
|
+
? 'page/src/generated/function-inputs.ts'
|
|
95
|
+
: GENERATED_INPUT_TYPES);
|
|
96
|
+
const inputs = resolveFunctionInputMode(workspace) === 'named'
|
|
97
|
+
? contracts.map((c) => ({ ...c, inputSchema: namedInputSchema(c) }))
|
|
98
|
+
: contracts;
|
|
99
|
+
if (requiresSDKCodegen(workspace)) {
|
|
100
|
+
for (const file of runSDKCodegen(workspace, {
|
|
101
|
+
contractFormatVersion: 1,
|
|
102
|
+
layout: version === 2 ? 'workspace' : 'classic',
|
|
103
|
+
schemaHash: '',
|
|
104
|
+
functions: [],
|
|
105
|
+
inputs,
|
|
106
|
+
client: false,
|
|
107
|
+
augmentation: 'none',
|
|
108
|
+
}))
|
|
109
|
+
writeIfChanged(join(workspace, file.path), file.content);
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
writeIfChanged(path, renderDatabaseFunctionInputTypes(inputs));
|
|
113
|
+
if (version === 2 && existsSync(obsolete))
|
|
114
|
+
unlinkSync(obsolete);
|
|
153
115
|
return {
|
|
154
116
|
sql: contracts.filter((contract) => contract.functionType === 1).length,
|
|
155
117
|
faas: contracts.filter((contract) => contract.functionType === 2).length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-input-types.js","sourceRoot":"","sources":["../src/function-input-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"function-input-types.js","sourceRoot":"","sources":["../src/function-input-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,qBAAqB,GAAG,IAAI,CAChC,MAAM,EACN,KAAK,EACL,KAAK,EACL,uCAAuC,CACxC,CAAC;AAEF,OAAO,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAC;AAEvF,SAAS,cAAc,CAAC,IAAY,EAAE,OAAe;IACnD,IAAI,CAAC;QACH,IAAI,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,OAAO;YAAE,OAAO;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,6CAA6C;IAC/C,CAAC;IACD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,MAAM,CAAC,OAAO,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AAI,aAAa,CAAC,SAAS,EAAE;YAC1C,qBAAqB,EAAE,CAAC;YACxB,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;YAC/C,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,MAAM;YACN,MAAM,EAAE,KAAK;YACb,YAAY,EAAE,MAAM;SACrB,CAAC;YACA,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;;QAAM,cAAc,CAAC,IAAI,EAAE,gCAAgC,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,IAAI,OAAO,KAAK,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC;QAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAChE,OAAO;QACL,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM;QACvE,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM;QACxE,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,KAAK,CAAC,CAAC;aAClE,MAAM;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author-declared parameter contract shared by Database Function `meta.params[]`
|
|
3
|
+
* and Mutation `spec.params[]`. The service renders the Agent-facing inputSchema
|
|
4
|
+
* from these declarations; the CLI only checks the same deterministic rules
|
|
5
|
+
* before upload and reports soft hints without blocking.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT_TOOL_DESIGN_REFERENCE = "references/agent-tool-design.md in the lark-base-database Skill";
|
|
8
|
+
export declare const PARAMETER_NAME_PATTERN: RegExp;
|
|
9
|
+
export declare const MAX_PARAMETER_DESCRIPTION = 500;
|
|
10
|
+
export declare const SHORT_DESCRIPTION_THRESHOLD = 8;
|
|
11
|
+
export type FunctionHintKind = 'short_description' | 'binding' | 'enum_unchecked' | 'function_description';
|
|
12
|
+
/** One non-blocking authoring hint; local hints and service `results[].hints[]` share this shape. */
|
|
13
|
+
export interface FunctionHint {
|
|
14
|
+
functionId?: string;
|
|
15
|
+
/** JSON Pointer inside the declaration, prefixed by the source file for local hints. */
|
|
16
|
+
path: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export type EnumValueType = 'string' | 'integer' | 'number' | 'boolean';
|
|
21
|
+
export interface DeclaredParameterResult {
|
|
22
|
+
problems: string[];
|
|
23
|
+
hints: FunctionHint[];
|
|
24
|
+
}
|
|
25
|
+
export declare function shortDescriptionHint(path: string, subject: string): FunctionHint;
|
|
26
|
+
/**
|
|
27
|
+
* Check `description` of one declared parameter or FaaS property.
|
|
28
|
+
* Missing/blank/too long is a problem; shorter than the threshold is only a hint.
|
|
29
|
+
*/
|
|
30
|
+
export declare function checkParameterDescription(description: unknown, label: string, path: string, result: DeclaredParameterResult): void;
|
|
31
|
+
/**
|
|
32
|
+
* Validate `name`, `description` and optional `enum` of a declared parameter list.
|
|
33
|
+
* `enumType` maps one parameter to the JSON type its enum values (or array
|
|
34
|
+
* elements) must use; `undefined` means the kind does not accept enum.
|
|
35
|
+
*/
|
|
36
|
+
export declare function checkDeclaredParameters(params: readonly unknown[], options: {
|
|
37
|
+
/** Label prefix such as `meta.params` or `spec.params`. */
|
|
38
|
+
label: string;
|
|
39
|
+
/** JSON Pointer prefix such as `/meta/params`. */
|
|
40
|
+
pointer: string;
|
|
41
|
+
/** Source file used to prefix hint paths. */
|
|
42
|
+
file: string;
|
|
43
|
+
enumType: (param: Record<string, unknown>) => EnumValueType | undefined;
|
|
44
|
+
}): DeclaredParameterResult;
|
|
45
|
+
/** SQL `meta.params[].kind` → enum value type; `TEXT[]` constrains elements. */
|
|
46
|
+
export declare function sqlEnumType(param: Record<string, unknown>): EnumValueType | undefined;
|
|
47
|
+
/** Mutation `spec.params[].kind` → enum value type; `list:true` constrains elements. */
|
|
48
|
+
export declare function mutationEnumType(param: Record<string, unknown>): EnumValueType | undefined;
|
|
49
|
+
/** Format collected hints for one-line human output. */
|
|
50
|
+
export declare function formatFunctionHint(hint: FunctionHint): string;
|
|
51
|
+
/** Read `results[].hints[]` from a PUT/validate response without failing on absent hints. */
|
|
52
|
+
export declare function responseFunctionHints(data: Record<string, unknown>, functionIds?: readonly string[]): FunctionHint[];
|
|
53
|
+
//# sourceMappingURL=function-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-params.d.ts","sourceRoot":"","sources":["../src/function-params.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,2BAA2B,oEAC2B,CAAC;AAEpE,eAAO,MAAM,sBAAsB,QAAiC,CAAC;AACrE,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAI7C,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,GACnB,SAAS,GACT,gBAAgB,GAChB,sBAAsB,CAAC;AAE3B,qGAAqG;AACrG,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAuBD,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,YAAY,CAMd;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,OAAO,EACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,uBAAuB,GAC9B,IAAI,CAgBN;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,OAAO,EAAE,EAC1B,OAAO,EAAE;IACP,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,aAAa,GAAG,SAAS,CAAC;CACzE,GACA,uBAAuB,CAiFzB;AASD,gFAAgF;AAChF,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,aAAa,GAAG,SAAS,CAM3B;AAYD,wFAAwF;AACxF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,aAAa,GAAG,SAAS,CAI3B;AAED,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAG7D;AAED,6FAA6F;AAC7F,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC,YAAY,EAAE,CAsBhB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Author-declared parameter contract shared by Database Function `meta.params[]`
|
|
3
|
+
* and Mutation `spec.params[]`. The service renders the Agent-facing inputSchema
|
|
4
|
+
* from these declarations; the CLI only checks the same deterministic rules
|
|
5
|
+
* before upload and reports soft hints without blocking.
|
|
6
|
+
*/
|
|
7
|
+
export const AGENT_TOOL_DESIGN_REFERENCE = 'references/agent-tool-design.md in the lark-base-database Skill';
|
|
8
|
+
export const PARAMETER_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
9
|
+
export const MAX_PARAMETER_DESCRIPTION = 500;
|
|
10
|
+
export const SHORT_DESCRIPTION_THRESHOLD = 8;
|
|
11
|
+
const MAX_ENUM_ITEMS = 100;
|
|
12
|
+
const MAX_ENUM_ITEM_LENGTH = 255;
|
|
13
|
+
function codePoints(value) {
|
|
14
|
+
return [...value].length;
|
|
15
|
+
}
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function enumValueMatches(value, type) {
|
|
20
|
+
switch (type) {
|
|
21
|
+
case 'string':
|
|
22
|
+
return typeof value === 'string';
|
|
23
|
+
case 'integer':
|
|
24
|
+
return typeof value === 'number' && Number.isSafeInteger(value);
|
|
25
|
+
case 'number':
|
|
26
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
27
|
+
case 'boolean':
|
|
28
|
+
return typeof value === 'boolean';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function shortDescriptionHint(path, subject) {
|
|
32
|
+
return {
|
|
33
|
+
path,
|
|
34
|
+
kind: 'short_description',
|
|
35
|
+
message: `${subject} description is shorter than ${SHORT_DESCRIPTION_THRESHOLD} characters; state the business meaning, unit and how the caller obtains the value. See ${AGENT_TOOL_DESIGN_REFERENCE}.`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check `description` of one declared parameter or FaaS property.
|
|
40
|
+
* Missing/blank/too long is a problem; shorter than the threshold is only a hint.
|
|
41
|
+
*/
|
|
42
|
+
export function checkParameterDescription(description, label, path, result) {
|
|
43
|
+
if (typeof description !== 'string' || description.trim() === '') {
|
|
44
|
+
result.problems.push(`${label}.description is required and must be a non-blank string`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (codePoints(description) > MAX_PARAMETER_DESCRIPTION) {
|
|
48
|
+
result.problems.push(`${label}.description must contain at most ${MAX_PARAMETER_DESCRIPTION} Unicode characters`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (codePoints(description.trim()) < SHORT_DESCRIPTION_THRESHOLD) {
|
|
52
|
+
result.hints.push(shortDescriptionHint(path, label));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validate `name`, `description` and optional `enum` of a declared parameter list.
|
|
57
|
+
* `enumType` maps one parameter to the JSON type its enum values (or array
|
|
58
|
+
* elements) must use; `undefined` means the kind does not accept enum.
|
|
59
|
+
*/
|
|
60
|
+
export function checkDeclaredParameters(params, options) {
|
|
61
|
+
const result = { problems: [], hints: [] };
|
|
62
|
+
const names = new Set();
|
|
63
|
+
params.forEach((param, index) => {
|
|
64
|
+
const label = `${options.label}[${index}]`;
|
|
65
|
+
const pointer = `${options.pointer}/${index}`;
|
|
66
|
+
if (!isRecord(param)) {
|
|
67
|
+
result.problems.push(`${label} must be an object`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const { name } = param;
|
|
71
|
+
if (typeof name !== 'string' || name === '') {
|
|
72
|
+
result.problems.push(`${label}.name is required; give every parameter a stable name such as "periodId"`);
|
|
73
|
+
}
|
|
74
|
+
else if (!PARAMETER_NAME_PATTERN.test(name)) {
|
|
75
|
+
result.problems.push(`${label}.name must match ${PARAMETER_NAME_PATTERN.source}`);
|
|
76
|
+
}
|
|
77
|
+
else if (names.has(name)) {
|
|
78
|
+
result.problems.push(`${label}.name duplicates ${JSON.stringify(name)}; names must be unique within one Function`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
names.add(name);
|
|
82
|
+
}
|
|
83
|
+
checkParameterDescription(param.description, label, `${options.file}#${pointer}/description`, result);
|
|
84
|
+
if (param.enum === undefined)
|
|
85
|
+
return;
|
|
86
|
+
const values = param.enum;
|
|
87
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
88
|
+
result.problems.push(`${label}.enum must be a non-empty array`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const type = options.enumType(param);
|
|
92
|
+
if (!type) {
|
|
93
|
+
result.problems.push(`${label}.enum is only supported for string, integer, number or boolean kinds (kind ${JSON.stringify(param.kind)})`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (values.length > MAX_ENUM_ITEMS) {
|
|
97
|
+
result.problems.push(`${label}.enum must contain at most ${MAX_ENUM_ITEMS} values`);
|
|
98
|
+
}
|
|
99
|
+
const seen = new Set();
|
|
100
|
+
values.forEach((value, valueIndex) => {
|
|
101
|
+
const valueLabel = `${label}.enum[${valueIndex}]`;
|
|
102
|
+
if (value === null) {
|
|
103
|
+
result.problems.push(`${valueLabel} must not be null; nullable parameters keep their null branch without listing null in enum`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!enumValueMatches(value, type)) {
|
|
107
|
+
result.problems.push(`${valueLabel} must be a JSON ${type} to match kind ${JSON.stringify(param.kind)}`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (typeof value === 'string' &&
|
|
111
|
+
codePoints(value) > MAX_ENUM_ITEM_LENGTH) {
|
|
112
|
+
result.problems.push(`${valueLabel} must contain at most ${MAX_ENUM_ITEM_LENGTH} Unicode characters`);
|
|
113
|
+
}
|
|
114
|
+
const key = JSON.stringify(value);
|
|
115
|
+
if (seen.has(key)) {
|
|
116
|
+
result.problems.push(`${valueLabel} duplicates ${key}`);
|
|
117
|
+
}
|
|
118
|
+
seen.add(key);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
const SQL_ENUM_TYPES = {
|
|
124
|
+
TEXT: 'string',
|
|
125
|
+
INT: 'integer',
|
|
126
|
+
DOUBLE: 'number',
|
|
127
|
+
BOOL: 'boolean',
|
|
128
|
+
};
|
|
129
|
+
/** SQL `meta.params[].kind` → enum value type; `TEXT[]` constrains elements. */
|
|
130
|
+
export function sqlEnumType(param) {
|
|
131
|
+
if (typeof param.kind !== 'string')
|
|
132
|
+
return undefined;
|
|
133
|
+
const scalar = param.kind.endsWith('[]')
|
|
134
|
+
? param.kind.slice(0, -2)
|
|
135
|
+
: param.kind;
|
|
136
|
+
return SQL_ENUM_TYPES[scalar];
|
|
137
|
+
}
|
|
138
|
+
const MUTATION_ENUM_TYPES = {
|
|
139
|
+
TEXT: 'string',
|
|
140
|
+
USER_ID: 'string',
|
|
141
|
+
GROUP_ID: 'string',
|
|
142
|
+
RECORD_ID: 'string',
|
|
143
|
+
INT: 'integer',
|
|
144
|
+
DOUBLE: 'number',
|
|
145
|
+
BOOL: 'boolean',
|
|
146
|
+
};
|
|
147
|
+
/** Mutation `spec.params[].kind` → enum value type; `list:true` constrains elements. */
|
|
148
|
+
export function mutationEnumType(param) {
|
|
149
|
+
return typeof param.kind === 'string'
|
|
150
|
+
? MUTATION_ENUM_TYPES[param.kind]
|
|
151
|
+
: undefined;
|
|
152
|
+
}
|
|
153
|
+
/** Format collected hints for one-line human output. */
|
|
154
|
+
export function formatFunctionHint(hint) {
|
|
155
|
+
const prefix = hint.functionId ? `${hint.functionId}: ` : '';
|
|
156
|
+
return `${prefix}${hint.path}: ${hint.message}`;
|
|
157
|
+
}
|
|
158
|
+
/** Read `results[].hints[]` from a PUT/validate response without failing on absent hints. */
|
|
159
|
+
export function responseFunctionHints(data, functionIds = []) {
|
|
160
|
+
if (!Array.isArray(data.results))
|
|
161
|
+
return [];
|
|
162
|
+
return data.results.flatMap((item, index) => {
|
|
163
|
+
if (!isRecord(item) || !Array.isArray(item.hints))
|
|
164
|
+
return [];
|
|
165
|
+
const functionId = typeof item.functionId === 'string'
|
|
166
|
+
? item.functionId
|
|
167
|
+
: typeof item.function_key === 'string'
|
|
168
|
+
? item.function_key
|
|
169
|
+
: functionIds[index];
|
|
170
|
+
return item.hints.flatMap((hint) => {
|
|
171
|
+
if (!isRecord(hint) || typeof hint.message !== 'string')
|
|
172
|
+
return [];
|
|
173
|
+
return [
|
|
174
|
+
{
|
|
175
|
+
...(functionId ? { functionId } : {}),
|
|
176
|
+
path: typeof hint.path === 'string' ? hint.path : '',
|
|
177
|
+
kind: typeof hint.kind === 'string' ? hint.kind : 'hint',
|
|
178
|
+
message: hint.message,
|
|
179
|
+
},
|
|
180
|
+
];
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=function-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-params.js","sourceRoot":"","sources":["../src/function-params.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GACtC,iEAAiE,CAAC;AAEpE,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AACrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAwBjC,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC;AAC3B,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc,EAAE,IAAmB;IAC3D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,C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C,OAAO,CAAC,CAAC,IAAI,EAAkB,EAAE;YACjD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACnE,OAAO;gBACL;oBACE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACrC,IAAI,EAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;oBACpD,IAAI,EAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;oBACxD,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import { type DeclaredParameterResult } from './function-params.js';
|
|
1
2
|
export declare function normalizeFunctionInputSchema(value: unknown, source: string): string;
|
|
3
|
+
/** Named-route declaration projection; mirrors the server's nullable/range/enum semantics. */
|
|
4
|
+
export declare function namedSQLParamSchema(param: Record<string, unknown>, index: number): Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Local Page input contract for the positional `invoke_function` route.
|
|
7
|
+
* It is never uploaded: the service renders the Agent-facing named-object
|
|
8
|
+
* inputSchema from `meta.params` itself.
|
|
9
|
+
*/
|
|
2
10
|
export declare function deriveSQLInputSchema(meta: Record<string, unknown>, sql: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* FaaS discovery contract on top of the Schema subset: the root is an object and
|
|
13
|
+
* every top-level business property (its key is the parameter name) carries a
|
|
14
|
+
* non-blank description. Short descriptions are hints only.
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkFaaSInputSchemaContract(value: unknown, file: string): DeclaredParameterResult;
|
|
3
17
|
//# sourceMappingURL=function-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-schema.d.ts","sourceRoot":"","sources":["../src/function-schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"function-schema.d.ts","sourceRoot":"","sources":["../src/function-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAqR9B,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAmFD,8FAA8F;AAC9F,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4BzB;AA0ED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,MAAM,GACV,MAAM,CAkCR;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,GACX,uBAAuB,CAiBzB"}
|