@botpress/cli 1.1.0 ā 1.2.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/.turbo/turbo-build.log +9 -9
- package/dist/api/integration-body.js +9 -9
- package/dist/api/integration-body.js.map +2 -2
- package/dist/command-implementations/lint-command.js +1 -1
- package/dist/command-implementations/lint-command.js.map +2 -2
- package/dist/utils/schema-utils.js +2 -4
- package/dist/utils/schema-utils.js.map +2 -2
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@1.1
|
|
2
|
+
> @botpress/cli@1.2.1 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@1.1
|
|
6
|
+
> @botpress/cli@1.2.1 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@1.1
|
|
10
|
+
> @botpress/cli@1.2.1 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
š¤ Botpress CLI v1.1
|
|
14
|
-
š¤ Botpress CLI v1.1
|
|
15
|
-
š¤ Botpress CLI v1.1
|
|
16
|
-
š¤ Botpress CLI v1.1
|
|
17
|
-
[2K[1Gā Generating typings for integration
|
|
18
|
-
[2K[1Gā Generating typings for integration
|
|
13
|
+
š¤ Botpress CLI v1.2.1
|
|
14
|
+
š¤ Botpress CLI v1.2.1
|
|
15
|
+
š¤ Botpress CLI v1.2.1
|
|
16
|
+
š¤ Botpress CLI v1.2.1
|
|
17
|
+
[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Generating typings for bot...[2K[1Gā Typings available at .botpress
|
|
18
|
+
[2K[1Gā Generating typings for integration empty-integration...[2K[1Gā Generating typings for integration webhook-message...[2K[1Gā Typings available at .botpress
|
|
19
19
|
[2K[1Gā Typings available at .botpress
|
|
20
20
|
[2K[1Gā Typings available at .botpress
|
|
@@ -29,7 +29,7 @@ __export(integration_body_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(integration_body_exports);
|
|
31
31
|
var utils = __toESM(require("../utils"));
|
|
32
|
-
const prepareCreateIntegrationBody = async (integration
|
|
32
|
+
const prepareCreateIntegrationBody = async (integration) => ({
|
|
33
33
|
name: integration.name,
|
|
34
34
|
version: integration.version,
|
|
35
35
|
title: integration.title,
|
|
@@ -42,41 +42,41 @@ const prepareCreateIntegrationBody = async (integration, options = {}) => ({
|
|
|
42
42
|
interfaces: {},
|
|
43
43
|
configuration: integration.configuration ? {
|
|
44
44
|
...integration.configuration,
|
|
45
|
-
schema: await utils.schema.mapZodToJsonSchema(integration.configuration
|
|
45
|
+
schema: await utils.schema.mapZodToJsonSchema(integration.configuration)
|
|
46
46
|
} : void 0,
|
|
47
47
|
configurations: integration.configurations ? await utils.records.mapValuesAsync(integration.configurations, async (configuration) => ({
|
|
48
48
|
...configuration,
|
|
49
|
-
schema: await utils.schema.mapZodToJsonSchema(configuration
|
|
49
|
+
schema: await utils.schema.mapZodToJsonSchema(configuration)
|
|
50
50
|
})) : void 0,
|
|
51
51
|
events: integration.events ? await utils.records.mapValuesAsync(integration.events, async (event) => ({
|
|
52
52
|
...event,
|
|
53
|
-
schema: await utils.schema.mapZodToJsonSchema(event
|
|
53
|
+
schema: await utils.schema.mapZodToJsonSchema(event)
|
|
54
54
|
})) : void 0,
|
|
55
55
|
actions: integration.actions ? await utils.records.mapValuesAsync(integration.actions, async (action) => ({
|
|
56
56
|
...action,
|
|
57
57
|
input: {
|
|
58
58
|
...action.input,
|
|
59
|
-
schema: await utils.schema.mapZodToJsonSchema(action.input
|
|
59
|
+
schema: await utils.schema.mapZodToJsonSchema(action.input)
|
|
60
60
|
},
|
|
61
61
|
output: {
|
|
62
62
|
...action.output,
|
|
63
|
-
schema: await utils.schema.mapZodToJsonSchema(action.output
|
|
63
|
+
schema: await utils.schema.mapZodToJsonSchema(action.output)
|
|
64
64
|
}
|
|
65
65
|
})) : void 0,
|
|
66
66
|
channels: integration.channels ? await utils.records.mapValuesAsync(integration.channels, async (channel) => ({
|
|
67
67
|
...channel,
|
|
68
68
|
messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({
|
|
69
69
|
...message,
|
|
70
|
-
schema: await utils.schema.mapZodToJsonSchema(message
|
|
70
|
+
schema: await utils.schema.mapZodToJsonSchema(message)
|
|
71
71
|
}))
|
|
72
72
|
})) : void 0,
|
|
73
73
|
states: integration.states ? await utils.records.mapValuesAsync(integration.states, async (state) => ({
|
|
74
74
|
...state,
|
|
75
|
-
schema: await utils.schema.mapZodToJsonSchema(state
|
|
75
|
+
schema: await utils.schema.mapZodToJsonSchema(state)
|
|
76
76
|
})) : void 0,
|
|
77
77
|
entities: integration.entities ? await utils.records.mapValuesAsync(integration.entities, async (entity) => ({
|
|
78
78
|
...entity,
|
|
79
|
-
schema: await utils.schema.mapZodToJsonSchema(entity
|
|
79
|
+
schema: await utils.schema.mapZodToJsonSchema(entity)
|
|
80
80
|
})) : void 0
|
|
81
81
|
});
|
|
82
82
|
const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/integration-body.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Client, Integration } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type { Client, Integration } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateIntegrationBody = Parameters<Client['createIntegration']>[0]\nexport type UpdateIntegrationBody = Parameters<Client['updateIntegration']>[0]\n\ntype UpdateIntegrationChannelsBody = NonNullable<UpdateIntegrationBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\n\ntype Channels = Integration['channels']\ntype Channel = Integration['channels'][string]\n\nexport const prepareCreateIntegrationBody = async (\n integration: sdk.IntegrationDefinition\n): Promise<CreateIntegrationBody> => ({\n name: integration.name,\n version: integration.version,\n title: integration.title,\n description: integration.description,\n icon: integration.icon,\n readme: integration.readme,\n user: integration.user,\n identifier: integration.identifier,\n secrets: undefined,\n interfaces: {},\n configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: await utils.schema.mapZodToJsonSchema(integration.configuration),\n }\n : undefined,\n configurations: integration.configurations\n ? await utils.records.mapValuesAsync(integration.configurations, async (configuration) => ({\n ...configuration,\n schema: await utils.schema.mapZodToJsonSchema(configuration),\n }))\n : undefined,\n events: integration.events\n ? await utils.records.mapValuesAsync(integration.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: integration.actions\n ? await utils.records.mapValuesAsync(integration.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n channels: integration.channels\n ? await utils.records.mapValuesAsync(integration.channels, async (channel) => ({\n ...channel,\n messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({\n ...message,\n schema: await utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : undefined,\n states: integration.states\n ? await utils.records.mapValuesAsync(integration.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n entities: integration.entities\n ? await utils.records.mapValuesAsync(integration.entities, async (entity) => ({\n ...entity,\n schema: await utils.schema.mapZodToJsonSchema(entity),\n }))\n : undefined,\n})\n\nexport const prepareUpdateIntegrationBody = (\n localIntegration: UpdateIntegrationBody,\n remoteIntegration: Integration\n): UpdateIntegrationBody => {\n const actions = utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions)\n const events = utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events)\n const states = utils.records.setNullOnMissingValues(localIntegration.states, remoteIntegration.states)\n const entities = utils.records.setNullOnMissingValues(localIntegration.entities, remoteIntegration.entities)\n const user = {\n ...localIntegration.user,\n tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags),\n }\n\n const channels = prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels)\n\n const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces)\n\n const configurations = utils.records.setNullOnMissingValues(\n localIntegration.configurations,\n remoteIntegration.configurations\n )\n\n return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n }\n}\n\nconst prepareUpdateIntegrationChannelsBody = (\n localChannels: UpdateIntegrationChannelsBody,\n remoteChannels: Channels\n): UpdateIntegrationChannelsBody => {\n const channelBody: UpdateIntegrationChannelsBody = {}\n\n const zipped = utils.records.zipObjects(localChannels, remoteChannels)\n for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {\n if (localChannel && remoteChannel) {\n // channel has to be updated\n channelBody[channelName] = prepareUpdateIntegrationChannelBody(localChannel, remoteChannel)\n } else if (localChannel) {\n // channel has to be created\n channelBody[channelName] = localChannel\n continue\n } else if (remoteChannel) {\n // channel has to be deleted\n channelBody[channelName] = null\n continue\n }\n }\n\n return channelBody\n}\n\nconst prepareUpdateIntegrationChannelBody = (\n localChannel: UpdateIntegrationChannelBody,\n remoteChannel: Channel\n): UpdateIntegrationChannelBody => ({\n ...localChannel,\n messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),\n message: {\n ...localChannel?.message,\n tags: utils.records.setNullOnMissingValues(localChannel?.message?.tags, remoteChannel.message.tags),\n },\n conversation: {\n ...localChannel?.conversation,\n tags: utils.records.setNullOnMissingValues(localChannel?.conversation?.tags, remoteChannel.conversation.tags),\n },\n})\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,7 +48,7 @@ class LintCommand extends import_project_command.ProjectCommand {
|
|
|
48
48
|
}
|
|
49
49
|
async _runLintForIntegration(definition) {
|
|
50
50
|
const strippedDefinition = this._stripAutoGeneratedContentFromIntegration(definition);
|
|
51
|
-
const parsedIntegrationDefinition = await (0, import_integration_body.prepareCreateIntegrationBody)(strippedDefinition
|
|
51
|
+
const parsedIntegrationDefinition = await (0, import_integration_body.prepareCreateIntegrationBody)(strippedDefinition);
|
|
52
52
|
const linter = new import_integration_linter.IntegrationLinter({ ...parsedIntegrationDefinition, secrets: strippedDefinition.secrets });
|
|
53
53
|
await linter.lint();
|
|
54
54
|
linter.logResults(this.logger);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/lint-command.ts"],
|
|
4
|
-
"sourcesContent": ["import { IntegrationDefinition } from '@botpress/sdk'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { IntegrationLinter } from '../linter/integration-linter'\nimport { getImplementationStatements } from '../sdk'\nimport { ProjectCommand } from './project-command'\n\nexport type LintCommandDefinition = typeof commandDefinitions.lint\nexport class LintCommand extends ProjectCommand<LintCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n switch (projectDef.type) {\n case 'integration':\n return this._runLintForIntegration(projectDef.definition)\n case 'bot':\n throw new errors.BotpressCLIError('Bot linting is not yet implemented')\n case 'interface':\n throw new errors.BotpressCLIError('Interface linting is not yet implemented')\n default:\n throw new errors.BotpressCLIError('Unsupported project type')\n }\n }\n\n private async _runLintForIntegration(definition: IntegrationDefinition): Promise<void> {\n const strippedDefinition = this._stripAutoGeneratedContentFromIntegration(definition)\n const parsedIntegrationDefinition = await prepareCreateIntegrationBody(strippedDefinition
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;AAE7C,aAAwB;AACxB,gCAAkC;AAClC,IAAAA,cAA4C;AAC5C,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,YAAQ,WAAW,MAAM;AAAA,MACvB,KAAK;AACH,eAAO,KAAK,uBAAuB,WAAW,UAAU;AAAA,MAC1D,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,oCAAoC;AAAA,MACxE,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,0CAA0C;AAAA,MAC9E;AACE,cAAM,IAAI,OAAO,iBAAiB,0BAA0B;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,MAAc,uBAAuB,YAAkD;AACrF,UAAM,qBAAqB,KAAK,0CAA0C,UAAU;AACpF,UAAM,8BAA8B,UAAM,sDAA6B,
|
|
4
|
+
"sourcesContent": ["import { IntegrationDefinition } from '@botpress/sdk'\nimport { prepareCreateIntegrationBody } from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { IntegrationLinter } from '../linter/integration-linter'\nimport { getImplementationStatements } from '../sdk'\nimport { ProjectCommand } from './project-command'\n\nexport type LintCommandDefinition = typeof commandDefinitions.lint\nexport class LintCommand extends ProjectCommand<LintCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n switch (projectDef.type) {\n case 'integration':\n return this._runLintForIntegration(projectDef.definition)\n case 'bot':\n throw new errors.BotpressCLIError('Bot linting is not yet implemented')\n case 'interface':\n throw new errors.BotpressCLIError('Interface linting is not yet implemented')\n default:\n throw new errors.BotpressCLIError('Unsupported project type')\n }\n }\n\n private async _runLintForIntegration(definition: IntegrationDefinition): Promise<void> {\n const strippedDefinition = this._stripAutoGeneratedContentFromIntegration(definition)\n const parsedIntegrationDefinition = await prepareCreateIntegrationBody(strippedDefinition)\n const linter = new IntegrationLinter({ ...parsedIntegrationDefinition, secrets: strippedDefinition.secrets })\n\n await linter.lint()\n linter.logResults(this.logger)\n }\n\n private _stripAutoGeneratedContentFromIntegration(definition: IntegrationDefinition) {\n const { actionNames, eventNames } = this._getAutoGeneratedContentOfIntegration(definition)\n\n return {\n ...definition,\n actions: Object.fromEntries(Object.entries(definition.actions ?? {}).filter(([key]) => !actionNames.has(key))),\n events: Object.fromEntries(Object.entries(definition.events ?? {}).filter(([key]) => !eventNames.has(key))),\n } as IntegrationDefinition\n }\n\n private _getAutoGeneratedContentOfIntegration(definition: IntegrationDefinition) {\n const actionNames = new Set<string>()\n const eventNames = new Set<string>()\n\n const interfacesStatements = getImplementationStatements(definition)\n for (const iface of Object.values(interfacesStatements)) {\n for (const actionDefinition of Object.values(iface.actions)) {\n actionNames.add(actionDefinition.name)\n }\n for (const eventDefinition of Object.values(iface.events)) {\n eventNames.add(eventDefinition.name)\n }\n }\n\n return { actionNames, eventNames } as const\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;AAE7C,aAAwB;AACxB,gCAAkC;AAClC,IAAAA,cAA4C;AAC5C,6BAA+B;AAGxB,MAAM,oBAAoB,sCAAsC;AAAA,EACrE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,YAAQ,WAAW,MAAM;AAAA,MACvB,KAAK;AACH,eAAO,KAAK,uBAAuB,WAAW,UAAU;AAAA,MAC1D,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,oCAAoC;AAAA,MACxE,KAAK;AACH,cAAM,IAAI,OAAO,iBAAiB,0CAA0C;AAAA,MAC9E;AACE,cAAM,IAAI,OAAO,iBAAiB,0BAA0B;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,MAAc,uBAAuB,YAAkD;AACrF,UAAM,qBAAqB,KAAK,0CAA0C,UAAU;AACpF,UAAM,8BAA8B,UAAM,sDAA6B,kBAAkB;AACzF,UAAM,SAAS,IAAI,4CAAkB,EAAE,GAAG,6BAA6B,SAAS,mBAAmB,QAAQ,CAAC;AAE5G,UAAM,OAAO,KAAK;AAClB,WAAO,WAAW,KAAK,MAAM;AAAA,EAC/B;AAAA,EAEQ,0CAA0C,YAAmC;AACnF,UAAM,EAAE,aAAa,WAAW,IAAI,KAAK,sCAAsC,UAAU;AAEzF,WAAO;AAAA,MACL,GAAG;AAAA,MACH,SAAS,OAAO,YAAY,OAAO,QAAQ,WAAW,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;AAAA,MAC7G,QAAQ,OAAO,YAAY,OAAO,QAAQ,WAAW,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC;AAAA,IAC5G;AAAA,EACF;AAAA,EAEQ,sCAAsC,YAAmC;AAC/E,UAAM,cAAc,oBAAI,IAAY;AACpC,UAAM,aAAa,oBAAI,IAAY;AAEnC,UAAM,2BAAuB,yCAA4B,UAAU;AACnE,eAAW,SAAS,OAAO,OAAO,oBAAoB,GAAG;AACvD,iBAAW,oBAAoB,OAAO,OAAO,MAAM,OAAO,GAAG;AAC3D,oBAAY,IAAI,iBAAiB,IAAI;AAAA,MACvC;AACA,iBAAW,mBAAmB,OAAO,OAAO,MAAM,MAAM,GAAG;AACzD,mBAAW,IAAI,gBAAgB,IAAI;AAAA,MACrC;AAAA,IACF;AAEA,WAAO,EAAE,aAAa,WAAW;AAAA,EACnC;AACF;",
|
|
6
6
|
"names": ["import_sdk"]
|
|
7
7
|
}
|
|
@@ -25,11 +25,9 @@ module.exports = __toCommonJS(schema_utils_exports);
|
|
|
25
25
|
var import_json_schema_ref_parser = require("@apidevtools/json-schema-ref-parser");
|
|
26
26
|
var import_sdk = require("@botpress/sdk");
|
|
27
27
|
const isObjectSchema = (schema) => schema.type === "object";
|
|
28
|
-
async function mapZodToJsonSchema(definition
|
|
28
|
+
async function mapZodToJsonSchema(definition) {
|
|
29
29
|
let schema = import_sdk.transforms.zuiToJsonSchema(definition.schema, { target: "jsonSchema7" });
|
|
30
|
-
|
|
31
|
-
schema = await (0, import_json_schema_ref_parser.dereference)(schema);
|
|
32
|
-
}
|
|
30
|
+
schema = await dereferenceSchema(schema);
|
|
33
31
|
if (!isObjectSchema(schema) || !definition.ui) {
|
|
34
32
|
return schema;
|
|
35
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/schema-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport { z, transforms } from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof transforms.zuiToJsonSchema\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\ntype ObjectJsonSchema = Extract<JsonSchema, { type: 'object' }>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype SchemaDefinition = {\n schema: z.ZodObject<any>\n ui?: Record<string, SchemaOptions | undefined>\n}\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,iBAA8B;
|
|
4
|
+
"sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport { z, transforms } from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof transforms.zuiToJsonSchema\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\ntype ObjectJsonSchema = Extract<JsonSchema, { type: 'object' }>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype SchemaDefinition = {\n schema: z.ZodObject<any>\n ui?: Record<string, SchemaOptions | undefined>\n}\n\nconst isObjectSchema = (schema: JsonSchema): schema is ObjectJsonSchema => schema.type === 'object'\n\nexport async function mapZodToJsonSchema(\n definition: SchemaDefinition\n): Promise<ReturnType<typeof transforms.zuiToJsonSchema>> {\n let schema = transforms.zuiToJsonSchema(definition.schema, { target: 'jsonSchema7' })\n schema = (await dereferenceSchema(schema)) as typeof schema\n\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n\nexport const dereferenceSchema = async (schema: JSONSchema7): Promise<JSONSchema7> => {\n return dereference(schema, {\n resolve: {\n external: false,\n file: false,\n http: false,\n },\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,iBAA8B;AAiB9B,MAAM,iBAAiB,CAAC,WAAmD,OAAO,SAAS;AAE3F,eAAsB,mBACpB,YACwD;AACxD,MAAI,SAAS,sBAAW,gBAAgB,WAAW,QAAQ,EAAE,QAAQ,cAAc,CAAC;AACpF,WAAU,MAAM,kBAAkB,MAAM;AAExC,MAAI,CAAC,eAAe,MAAM,KAAK,CAAC,WAAW,IAAI;AAC7C,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,MAAM,CAAC,CAAC,GAAG;AAC9D,UAAM,WAAW,OAAO,aAAa;AAErC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,OAAO,OAAO;AAClB;AAAC,MAAC,SAAiB,QAAQ,MAAM;AAAA,IACnC;AAEA,QAAI,CAAC,CAAC,OAAO,UAAU;AACrB;AAAC,MAAC,SAAiB,WAAW,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,oBAAoB,OAAO,WAA8C;AACpF,aAAO,2CAAY,QAAQ;AAAA,IACzB,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|