@botpress/cli 6.8.2 → 6.8.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/.turbo/turbo-build.log +12 -12
- package/dist/api/bot-body.js +26 -3
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/integration-body.js +67 -48
- package/dist/api/integration-body.js.map +2 -2
- package/dist/api/interface-body.js +59 -42
- package/dist/api/interface-body.js.map +2 -2
- package/dist/api/plugin-body.js +64 -50
- package/dist/api/plugin-body.js.map +2 -2
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +2 -2
- package/dist/command-implementations/project-command.js +25 -12
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/register-yargs.js +1 -1
- package/dist/register-yargs.js.map +2 -2
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@6.8.
|
|
2
|
+
> @botpress/cli@6.8.3 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run build:types && pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@6.8.
|
|
6
|
+
> @botpress/cli@6.8.3 build:types /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> tsc -p ./tsconfig.build.json
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@6.8.
|
|
10
|
+
> @botpress/cli@6.8.3 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> ts-node -T build.ts
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
> @botpress/cli@6.8.
|
|
14
|
+
> @botpress/cli@6.8.3 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
15
15
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
16
16
|
|
|
17
|
-
🤖 Botpress CLI v6.8.
|
|
17
|
+
🤖 Botpress CLI v6.8.3
|
|
18
|
+
🤖 Botpress CLI v6.8.3
|
|
18
19
|
● Checking if cli is up to date
|
|
19
|
-
🤖 Botpress CLI v6.8.2
|
|
20
20
|
● Checking if cli is up to date
|
|
21
|
-
🤖 Botpress CLI v6.8.
|
|
21
|
+
🤖 Botpress CLI v6.8.3
|
|
22
22
|
● Checking if cli is up to date
|
|
23
|
-
🤖 Botpress CLI v6.8.
|
|
23
|
+
🤖 Botpress CLI v6.8.3
|
|
24
24
|
● Checking if cli is up to date
|
|
25
25
|
● Checking if sdk is up to date
|
|
26
26
|
● Checking if sdk is up to date
|
|
27
27
|
● Checking if sdk is up to date
|
|
28
28
|
● Checking if sdk is up to date
|
|
29
|
-
○ Generating typings for plugin empty-plugin...
|
|
30
29
|
○ Generating typings for integration empty-integration...
|
|
31
|
-
○ Generating typings for integration hello-world...
|
|
32
30
|
✓ Typings available at .botpress
|
|
33
31
|
|
|
32
|
+
○ Generating typings for bot...
|
|
33
|
+
○ Generating typings for integration hello-world...
|
|
34
34
|
✓ Typings available at .botpress
|
|
35
35
|
|
|
36
|
-
○ Generating typings for
|
|
36
|
+
○ Generating typings for plugin empty-plugin...
|
|
37
37
|
✓ Typings available at .botpress
|
|
38
38
|
|
|
39
39
|
✓ Typings available at .botpress
|
|
40
40
|
|
|
41
|
-
🤖 Botpress CLI v6.8.
|
|
41
|
+
🤖 Botpress CLI v6.8.3
|
|
42
42
|
● Checking if cli is up to date
|
|
43
43
|
● Checking if sdk is up to date
|
|
44
44
|
○ Generating typings for integration webhook-message...
|
package/dist/api/bot-body.js
CHANGED
|
@@ -32,19 +32,25 @@ __export(bot_body_exports, {
|
|
|
32
32
|
prepareUpdateBotBody: () => prepareUpdateBotBody
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(bot_body_exports);
|
|
35
|
+
var errors = __toESM(require("../errors"));
|
|
35
36
|
var utils = __toESM(require("../utils"));
|
|
36
37
|
const prepareCreateBotBody = async (bot) => ({
|
|
37
38
|
user: bot.user,
|
|
38
39
|
conversation: bot.conversation,
|
|
39
40
|
message: bot.message,
|
|
40
41
|
recurringEvents: bot.recurringEvents,
|
|
41
|
-
actions: bot.actions ? await utils.records.mapValuesAsync(bot.actions, async (action) => ({
|
|
42
|
+
actions: bot.actions ? await utils.records.mapValuesAsync(bot.actions, async (action, actionName) => ({
|
|
42
43
|
...action,
|
|
43
44
|
input: {
|
|
44
45
|
...action.input,
|
|
45
46
|
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
46
47
|
useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,
|
|
47
48
|
toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions
|
|
49
|
+
}).catch((thrown) => {
|
|
50
|
+
throw errors.BotpressCLIError.wrap(
|
|
51
|
+
thrown,
|
|
52
|
+
`Failed to convert ZUI to JSON schema for bot action ${actionName} input`
|
|
53
|
+
);
|
|
48
54
|
})
|
|
49
55
|
},
|
|
50
56
|
output: {
|
|
@@ -52,6 +58,11 @@ const prepareCreateBotBody = async (bot) => ({
|
|
|
52
58
|
schema: await utils.schema.mapZodToJsonSchema(action.output, {
|
|
53
59
|
useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,
|
|
54
60
|
toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions
|
|
61
|
+
}).catch((thrown) => {
|
|
62
|
+
throw errors.BotpressCLIError.wrap(
|
|
63
|
+
thrown,
|
|
64
|
+
`Failed to convert ZUI to JSON schema for bot action ${actionName} output`
|
|
65
|
+
);
|
|
55
66
|
})
|
|
56
67
|
}
|
|
57
68
|
})) : void 0,
|
|
@@ -60,21 +71,33 @@ const prepareCreateBotBody = async (bot) => ({
|
|
|
60
71
|
schema: await utils.schema.mapZodToJsonSchema(bot.configuration, {
|
|
61
72
|
useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,
|
|
62
73
|
toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions
|
|
74
|
+
}).catch((thrown) => {
|
|
75
|
+
throw errors.BotpressCLIError.wrap(thrown, "Failed to convert ZUI to JSON schema for bot configuration");
|
|
63
76
|
})
|
|
64
77
|
} : void 0,
|
|
65
|
-
events: bot.events ? await utils.records.mapValuesAsync(bot.events, async (event) => ({
|
|
78
|
+
events: bot.events ? await utils.records.mapValuesAsync(bot.events, async (event, eventName) => ({
|
|
66
79
|
...event,
|
|
67
80
|
schema: await utils.schema.mapZodToJsonSchema(event, {
|
|
68
81
|
useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,
|
|
69
82
|
toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions
|
|
83
|
+
}).catch((thrown) => {
|
|
84
|
+
throw errors.BotpressCLIError.wrap(
|
|
85
|
+
thrown,
|
|
86
|
+
`Failed to convert ZUI to JSON schema for bot event ${eventName}`
|
|
87
|
+
);
|
|
70
88
|
})
|
|
71
89
|
})) : void 0,
|
|
72
90
|
states: bot.states ? utils.records.filterValues(
|
|
73
|
-
await utils.records.mapValuesAsync(bot.states, async (state) => ({
|
|
91
|
+
await utils.records.mapValuesAsync(bot.states, async (state, stateName) => ({
|
|
74
92
|
...state,
|
|
75
93
|
schema: await utils.schema.mapZodToJsonSchema(state, {
|
|
76
94
|
useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,
|
|
77
95
|
toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions
|
|
96
|
+
}).catch((thrown) => {
|
|
97
|
+
throw errors.BotpressCLIError.wrap(
|
|
98
|
+
thrown,
|
|
99
|
+
`Failed to convert ZUI to JSON schema for bot state ${stateName}`
|
|
100
|
+
);
|
|
78
101
|
})
|
|
79
102
|
})),
|
|
80
103
|
({ type }) => type !== "workflow"
|
package/dist/api/bot-body.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/bot-body.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateBotBody = async (bot: sdk.BotDefinition): Promise<types.CreateBotRequestBody> => ({\n user: bot.user,\n conversation: bot.conversation,\n message: bot.message,\n recurringEvents: bot.recurringEvents,\n actions: bot.actions\n ? await utils.records.mapValuesAsync(bot.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input, {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,uBAAuB,OAAO,SAAiE;AAAA,EAC1G,MAAM,IAAI;AAAA,EACV,cAAc,IAAI;AAAA,EAClB,SAAS,IAAI;AAAA,EACb,iBAAiB,IAAI;AAAA,EACrB,SAAS,IAAI,UACT,MAAM,MAAM,QAAQ,eAAe,IAAI,SAAS,OAAO,
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateBotBody = async (bot: sdk.BotDefinition): Promise<types.CreateBotRequestBody> => ({\n user: bot.user,\n conversation: bot.conversation,\n message: bot.message,\n recurringEvents: bot.recurringEvents,\n actions: bot.actions\n ? await utils.records.mapValuesAsync(bot.actions, async (action, actionName) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema\n .mapZodToJsonSchema(action.input, {\n useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `Failed to convert ZUI to JSON schema for bot action ${actionName} input`\n )\n }),\n },\n output: {\n ...action.output,\n schema: await utils.schema\n .mapZodToJsonSchema(action.output, {\n useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `Failed to convert ZUI to JSON schema for bot action ${actionName} output`\n )\n }),\n },\n }))\n : undefined,\n configuration: bot.configuration\n ? {\n ...bot.configuration,\n schema: await utils.schema\n .mapZodToJsonSchema(bot.configuration, {\n useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Failed to convert ZUI to JSON schema for bot configuration')\n }),\n }\n : undefined,\n events: bot.events\n ? await utils.records.mapValuesAsync(bot.events, async (event, eventName) => ({\n ...event,\n schema: await utils.schema\n .mapZodToJsonSchema(event, {\n useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `Failed to convert ZUI to JSON schema for bot event ${eventName}`\n )\n }),\n }))\n : undefined,\n states: bot.states\n ? (utils.records.filterValues(\n await utils.records.mapValuesAsync(bot.states, async (state, stateName) => ({\n ...state,\n schema: await utils.schema\n .mapZodToJsonSchema(state, {\n useLegacyZuiTransformer: bot.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: bot.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `Failed to convert ZUI to JSON schema for bot state ${stateName}`\n )\n }),\n })),\n ({ type }) => type !== 'workflow'\n ) as types.CreateBotRequestBody['states'])\n : undefined,\n tags: bot.attributes,\n})\n\nexport const prepareUpdateBotBody = (\n localBot: types.UpdateBotRequestBody,\n remoteBot: client.Bot\n): types.UpdateBotRequestBody => ({\n ...localBot,\n states: utils.records.setNullOnMissingValues(localBot.states, remoteBot.states),\n recurringEvents: utils.records.setNullOnMissingValues(localBot.recurringEvents, remoteBot.recurringEvents),\n events: utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localBot.events, remoteBot.events),\n remoteItems: remoteBot.events,\n }),\n actions: utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localBot.actions, remoteBot.actions),\n remoteItems: remoteBot.actions,\n }),\n user: {\n ...localBot.user,\n tags: utils.records.setNullOnMissingValues(localBot.user?.tags, remoteBot.user?.tags),\n },\n conversation: {\n ...localBot.conversation,\n tags: utils.records.setNullOnMissingValues(localBot.conversation?.tags, remoteBot.conversation?.tags),\n },\n message: {\n ...localBot.message,\n tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags),\n },\n integrations: utils.integrations.prepareIntegrationsUpdate(\n utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations),\n remoteBot.integrations\n ),\n plugins: utils.records.setNullOnMissingValues(localBot.plugins, remoteBot.plugins),\n tags: localBot.tags, // TODO: allow removing bot tags (aka attributes) by setting to null\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,aAAwB;AACxB,YAAuB;AAGhB,MAAM,uBAAuB,OAAO,SAAiE;AAAA,EAC1G,MAAM,IAAI;AAAA,EACV,cAAc,IAAI;AAAA,EAClB,SAAS,IAAI;AAAA,EACb,iBAAiB,IAAI;AAAA,EACrB,SAAS,IAAI,UACT,MAAM,MAAM,QAAQ,eAAe,IAAI,SAAS,OAAO,QAAQ,gBAAgB;AAAA,IAC7E,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,MAAM,OACjB,mBAAmB,OAAO,OAAO;AAAA,QAChC,yBAAyB,IAAI,YAAY;AAAA,QACzC,qBAAqB,IAAI,YAAY;AAAA,MACvC,CAAC,EACA,MAAM,CAAC,WAAW;AACjB,cAAM,OAAO,iBAAiB;AAAA,UAC5B;AA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AM,QAAQ,uBAAuB,SAAS,cAAc,UAAU,YAAY;AAAA,IAClF,UAAU;AAAA,EACZ;AAAA,EACA,SAAS,MAAM,QAAQ,uBAAuB,SAAS,SAAS,UAAU,OAAO;AAAA,EACjF,MAAM,SAAS;AAAA;AACjB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,64 +32,83 @@ __export(integration_body_exports, {
|
|
|
32
32
|
prepareUpdateIntegrationBody: () => prepareUpdateIntegrationBody
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(integration_body_exports);
|
|
35
|
+
var errors = __toESM(require("../errors"));
|
|
35
36
|
var utils = __toESM(require("../utils"));
|
|
36
|
-
const prepareCreateIntegrationBody = async (integration) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})
|
|
48
|
-
})) : void 0,
|
|
49
|
-
actions: integration.actions ? await utils.records.mapValuesAsync(integration.actions, async (action) => ({
|
|
50
|
-
...action,
|
|
51
|
-
input: {
|
|
52
|
-
...action.input,
|
|
53
|
-
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
37
|
+
const prepareCreateIntegrationBody = async (integration) => {
|
|
38
|
+
const base = `Failed to convert ZUI to JSON schema for integration ${integration.name}`;
|
|
39
|
+
return {
|
|
40
|
+
name: integration.name,
|
|
41
|
+
version: integration.version,
|
|
42
|
+
title: "title" in integration ? integration.title : void 0,
|
|
43
|
+
description: "description" in integration ? integration.description : void 0,
|
|
44
|
+
user: integration.user,
|
|
45
|
+
events: integration.events ? await utils.records.mapValuesAsync(integration.events, async (event, eventName) => ({
|
|
46
|
+
...event,
|
|
47
|
+
schema: await utils.schema.mapZodToJsonSchema(event, {
|
|
54
48
|
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
55
49
|
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
50
|
+
}).catch((thrown) => {
|
|
51
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for event ${eventName}`);
|
|
56
52
|
})
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
...action
|
|
60
|
-
|
|
53
|
+
})) : void 0,
|
|
54
|
+
actions: integration.actions ? await utils.records.mapValuesAsync(integration.actions, async (action, actionName) => ({
|
|
55
|
+
...action,
|
|
56
|
+
input: {
|
|
57
|
+
...action.input,
|
|
58
|
+
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
59
|
+
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
60
|
+
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
61
|
+
}).catch((thrown) => {
|
|
62
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} input`);
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
output: {
|
|
66
|
+
...action.output,
|
|
67
|
+
schema: await utils.schema.mapZodToJsonSchema(action.output, {
|
|
68
|
+
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
69
|
+
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
70
|
+
}).catch((thrown) => {
|
|
71
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} output`);
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
})) : void 0,
|
|
75
|
+
channels: integration.channels ? await utils.records.mapValuesAsync(integration.channels, async (channel, channelName) => ({
|
|
76
|
+
...channel,
|
|
77
|
+
messages: await utils.records.mapValuesAsync(channel.messages, async (message, messageName) => ({
|
|
78
|
+
...message,
|
|
79
|
+
schema: await utils.schema.mapZodToJsonSchema(message, {
|
|
80
|
+
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
81
|
+
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
82
|
+
}).catch((thrown) => {
|
|
83
|
+
throw errors.BotpressCLIError.wrap(
|
|
84
|
+
thrown,
|
|
85
|
+
`${base} for channel ${channelName} for message ${messageName}`
|
|
86
|
+
);
|
|
87
|
+
})
|
|
88
|
+
}))
|
|
89
|
+
})) : void 0,
|
|
90
|
+
states: integration.states ? await utils.records.mapValuesAsync(integration.states, async (state, stateName) => ({
|
|
91
|
+
...state,
|
|
92
|
+
schema: await utils.schema.mapZodToJsonSchema(state, {
|
|
61
93
|
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
62
94
|
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
95
|
+
}).catch((thrown) => {
|
|
96
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for state ${stateName}`);
|
|
63
97
|
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({
|
|
69
|
-
...message,
|
|
70
|
-
schema: await utils.schema.mapZodToJsonSchema(message, {
|
|
98
|
+
})) : void 0,
|
|
99
|
+
entities: integration.entities ? await utils.records.mapValuesAsync(integration.entities, async (entity, entityName) => ({
|
|
100
|
+
...entity,
|
|
101
|
+
schema: await utils.schema.mapZodToJsonSchema(entity, {
|
|
71
102
|
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
72
103
|
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
104
|
+
}).catch((thrown) => {
|
|
105
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for entity ${entityName}`);
|
|
73
106
|
})
|
|
74
|
-
}))
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
80
|
-
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
81
|
-
})
|
|
82
|
-
})) : void 0,
|
|
83
|
-
entities: integration.entities ? await utils.records.mapValuesAsync(integration.entities, async (entity) => ({
|
|
84
|
-
...entity,
|
|
85
|
-
schema: await utils.schema.mapZodToJsonSchema(entity, {
|
|
86
|
-
useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,
|
|
87
|
-
toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions
|
|
88
|
-
})
|
|
89
|
-
})) : void 0,
|
|
90
|
-
attributes: integration.attributes,
|
|
91
|
-
extraOperations: "__advanced" in integration ? integration.__advanced?.extraOperations : void 0
|
|
92
|
-
});
|
|
107
|
+
})) : void 0,
|
|
108
|
+
attributes: integration.attributes,
|
|
109
|
+
extraOperations: "__advanced" in integration ? integration.__advanced?.extraOperations : void 0
|
|
110
|
+
};
|
|
111
|
+
};
|
|
93
112
|
const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
|
|
94
113
|
const actions = utils.attributes.prepareAttributeUpdateBody({
|
|
95
114
|
localItems: utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/integration-body.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateIntegrationBody = async (\n integration: sdk.IntegrationDefinition\n): Promise<types.CreateIntegrationRequestBody> => ({\n name: integration.name,\n version: integration.version,\n title: 'title' in integration ? integration.title : undefined,\n description: 'description' in integration ? integration.description : undefined,\n user: integration.user,\n events: integration.events\n ? await utils.records.mapValuesAsync(integration.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n }),\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 useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n }),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n }),\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 useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n }),\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 useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n }),\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 useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n }),\n }))\n : undefined,\n attributes: integration.attributes,\n extraOperations: '__advanced' in integration ? integration.__advanced?.extraOperations : undefined,\n})\n\ntype UpdateIntegrationChannelsBody = NonNullable<types.UpdateIntegrationRequestBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\ntype Channels = client.Integration['channels']\ntype Channel = client.Integration['channels'][string]\nexport const prepareUpdateIntegrationBody = (\n localIntegration: types.UpdateIntegrationRequestBody,\n remoteIntegration: client.Integration\n): types.UpdateIntegrationRequestBody => {\n const actions = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions),\n remoteItems: remoteIntegration.actions,\n })\n const events = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events),\n remoteItems: remoteIntegration.events,\n })\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 const readme = localIntegration.readme\n const icon = localIntegration.icon\n\n const attributes = utils.records.setNullOnMissingValues(localIntegration.attributes, remoteIntegration.attributes)\n\n const extraOperations = localIntegration.extraOperations\n return {\n ..._maybeRemoveVrlScripts(localIntegration, remoteIntegration),\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n readme,\n icon,\n attributes,\n extraOperations,\n }\n}\n\nconst _maybeRemoveVrlScripts = (\n localIntegration: types.UpdateIntegrationRequestBody,\n remoteIntegration: client.Integration\n): types.UpdateIntegrationRequestBody => {\n const newIntegration = structuredClone(localIntegration)\n\n if (\n remoteIntegration.configuration?.identifier?.linkTemplateScript &&\n !localIntegration.configuration?.identifier?.linkTemplateScript\n ) {\n newIntegration.configuration ??= remoteIntegration.configuration\n newIntegration.configuration.identifier ??= remoteIntegration.configuration.identifier\n newIntegration.configuration.identifier.linkTemplateScript = null\n newIntegration.configuration.identifier.required = false\n }\n\n if (remoteIntegration.identifier.extractScript && !localIntegration.identifier?.extractScript) {\n newIntegration.identifier ??= remoteIntegration.identifier\n newIntegration.identifier.extractScript = null\n }\n\n if (remoteIntegration.identifier.fallbackHandlerScript && !localIntegration.identifier?.fallbackHandlerScript) {\n newIntegration.identifier ??= remoteIntegration.identifier\n newIntegration.identifier.fallbackHandlerScript = null\n }\n\n for (const configName of Object.keys(localIntegration.configurations ?? {})) {\n if (\n remoteIntegration.configurations[configName]?.identifier.linkTemplateScript &&\n !localIntegration.configurations?.[configName]?.identifier?.linkTemplateScript\n ) {\n newIntegration.configurations ??= remoteIntegration.configurations\n newIntegration.configurations[configName] ??= remoteIntegration.configurations[configName]\n newIntegration.configurations[configName].identifier ??= remoteIntegration.configurations[configName].identifier\n newIntegration.configurations[configName].identifier.linkTemplateScript = null\n newIntegration.configurations[configName].identifier.required = false\n }\n }\n\n return newIntegration\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,+BAA+B,OAC1C,
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateIntegrationBody = async (\n integration: sdk.IntegrationDefinition\n): Promise<types.CreateIntegrationRequestBody> => {\n const base = `Failed to convert ZUI to JSON schema for integration ${integration.name}`\n return {\n name: integration.name,\n version: integration.version,\n title: 'title' in integration ? integration.title : undefined,\n description: 'description' in integration ? integration.description : undefined,\n user: integration.user,\n events: integration.events\n ? await utils.records.mapValuesAsync(integration.events, async (event, eventName) => ({\n ...event,\n schema: await utils.schema\n .mapZodToJsonSchema(event, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for event ${eventName}`)\n }),\n }))\n : undefined,\n actions: integration.actions\n ? await utils.records.mapValuesAsync(integration.actions, async (action, actionName) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema\n .mapZodToJsonSchema(action.input, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} input`)\n }),\n },\n output: {\n ...action.output,\n schema: await utils.schema\n .mapZodToJsonSchema(action.output, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} output`)\n }),\n },\n }))\n : undefined,\n channels: integration.channels\n ? await utils.records.mapValuesAsync(integration.channels, async (channel, channelName) => ({\n ...channel,\n messages: await utils.records.mapValuesAsync(channel.messages, async (message, messageName) => ({\n ...message,\n schema: await utils.schema\n .mapZodToJsonSchema(message, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `${base} for channel ${channelName} for message ${messageName}`\n )\n }),\n })),\n }))\n : undefined,\n states: integration.states\n ? await utils.records.mapValuesAsync(integration.states, async (state, stateName) => ({\n ...state,\n schema: await utils.schema\n .mapZodToJsonSchema(state, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for state ${stateName}`)\n }),\n }))\n : undefined,\n entities: integration.entities\n ? await utils.records.mapValuesAsync(integration.entities, async (entity, entityName) => ({\n ...entity,\n schema: await utils.schema\n .mapZodToJsonSchema(entity, {\n useLegacyZuiTransformer: integration.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integration.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for entity ${entityName}`)\n }),\n }))\n : undefined,\n attributes: integration.attributes,\n extraOperations: '__advanced' in integration ? integration.__advanced?.extraOperations : undefined,\n }\n}\n\ntype UpdateIntegrationChannelsBody = NonNullable<types.UpdateIntegrationRequestBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\ntype Channels = client.Integration['channels']\ntype Channel = client.Integration['channels'][string]\nexport const prepareUpdateIntegrationBody = (\n localIntegration: types.UpdateIntegrationRequestBody,\n remoteIntegration: client.Integration\n): types.UpdateIntegrationRequestBody => {\n const actions = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions),\n remoteItems: remoteIntegration.actions,\n })\n const events = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events),\n remoteItems: remoteIntegration.events,\n })\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 const readme = localIntegration.readme\n const icon = localIntegration.icon\n\n const attributes = utils.records.setNullOnMissingValues(localIntegration.attributes, remoteIntegration.attributes)\n\n const extraOperations = localIntegration.extraOperations\n return {\n ..._maybeRemoveVrlScripts(localIntegration, remoteIntegration),\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n readme,\n icon,\n attributes,\n extraOperations,\n }\n}\n\nconst _maybeRemoveVrlScripts = (\n localIntegration: types.UpdateIntegrationRequestBody,\n remoteIntegration: client.Integration\n): types.UpdateIntegrationRequestBody => {\n const newIntegration = structuredClone(localIntegration)\n\n if (\n remoteIntegration.configuration?.identifier?.linkTemplateScript &&\n !localIntegration.configuration?.identifier?.linkTemplateScript\n ) {\n newIntegration.configuration ??= remoteIntegration.configuration\n newIntegration.configuration.identifier ??= remoteIntegration.configuration.identifier\n newIntegration.configuration.identifier.linkTemplateScript = null\n newIntegration.configuration.identifier.required = false\n }\n\n if (remoteIntegration.identifier.extractScript && !localIntegration.identifier?.extractScript) {\n newIntegration.identifier ??= remoteIntegration.identifier\n newIntegration.identifier.extractScript = null\n }\n\n if (remoteIntegration.identifier.fallbackHandlerScript && !localIntegration.identifier?.fallbackHandlerScript) {\n newIntegration.identifier ??= remoteIntegration.identifier\n newIntegration.identifier.fallbackHandlerScript = null\n }\n\n for (const configName of Object.keys(localIntegration.configurations ?? {})) {\n if (\n remoteIntegration.configurations[configName]?.identifier.linkTemplateScript &&\n !localIntegration.configurations?.[configName]?.identifier?.linkTemplateScript\n ) {\n newIntegration.configurations ??= remoteIntegration.configurations\n newIntegration.configurations[configName] ??= remoteIntegration.configurations[configName]\n newIntegration.configurations[configName].identifier ??= remoteIntegration.configurations[configName].identifier\n newIntegration.configurations[configName].identifier.linkTemplateScript = null\n newIntegration.configurations[configName].identifier.required = false\n }\n }\n\n return newIntegration\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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AAE,WAAW,qBAAqB;AAC1E,qBAAe,eAAe,UAAU,EAAE,WAAW,WAAW;AAAA,IAClE;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,wCAAwC,CAC5C,eACA,mBACkC;AAClC,QAAM,cAA6C,CAAC;AAEpD,QAAM,SAAS,MAAM,QAAQ,WAAW,eAAe,cAAc;AACrE,aAAW,CAAC,aAAa,CAAC,cAAc,aAAa,CAAC,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjF,QAAI,gBAAgB,eAAe;AAEjC,kBAAY,WAAW,IAAI,qCAAqC,cAAc,aAAa;AAAA,IAC7F,WAAW,cAAc;AAEvB,kBAAY,WAAW,IAAI;AAC3B;AAAA,IACF,WAAW,eAAe;AAExB,kBAAY,WAAW,IAAI;AAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,uCAAuC,CAC3C,cACA,mBACkC;AAAA,EAClC,GAAG;AAAA,EACH,UAAU,MAAM,QAAQ,uBAAuB,cAAc,UAAU,cAAc,QAAQ;AAAA,EAC7F,SAAS;AAAA,IACP,GAAG,cAAc;AAAA,IACjB,MAAM,MAAM,QAAQ,uBAAuB,cAAc,SAAS,MAAM,cAAc,QAAQ,IAAI;AAAA,EACpG;AAAA,EACA,cAAc;AAAA,IACZ,GAAG,cAAc;AAAA,IACjB,MAAM,MAAM,QAAQ,uBAAuB,cAAc,cAAc,MAAM,cAAc,aAAa,IAAI;AAAA,EAC9G;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,55 +32,72 @@ __export(interface_body_exports, {
|
|
|
32
32
|
prepareUpdateInterfaceBody: () => prepareUpdateInterfaceBody
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(interface_body_exports);
|
|
35
|
+
var errors = __toESM(require("../errors"));
|
|
35
36
|
var utils = __toESM(require("../utils"));
|
|
36
|
-
const prepareCreateInterfaceBody = async (intrface) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
})
|
|
47
|
-
})) : {},
|
|
48
|
-
events: intrface.events ? await utils.records.mapValuesAsync(intrface.events, async (event) => ({
|
|
49
|
-
...event,
|
|
50
|
-
schema: await utils.schema.mapZodToJsonSchema(event, {
|
|
51
|
-
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
52
|
-
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
53
|
-
})
|
|
54
|
-
})) : {},
|
|
55
|
-
actions: intrface.actions ? await utils.records.mapValuesAsync(intrface.actions, async (action) => ({
|
|
56
|
-
...action,
|
|
57
|
-
input: {
|
|
58
|
-
...action.input,
|
|
59
|
-
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
60
|
-
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
61
|
-
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
output: {
|
|
65
|
-
...action.output,
|
|
66
|
-
schema: await utils.schema.mapZodToJsonSchema(action.output, {
|
|
37
|
+
const prepareCreateInterfaceBody = async (intrface) => {
|
|
38
|
+
const base = `Failed to convert ZUI to JSON schema for interface ${intrface.name}`;
|
|
39
|
+
return {
|
|
40
|
+
name: intrface.name,
|
|
41
|
+
version: intrface.version,
|
|
42
|
+
title: "title" in intrface ? intrface.title : void 0,
|
|
43
|
+
description: "description" in intrface ? intrface.description : void 0,
|
|
44
|
+
entities: intrface.entities ? await utils.records.mapValuesAsync(intrface.entities, async (entity, entityName) => ({
|
|
45
|
+
...entity,
|
|
46
|
+
schema: await utils.schema.mapZodToJsonSchema(entity, {
|
|
67
47
|
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
68
48
|
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
49
|
+
}).catch((thrown) => {
|
|
50
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for entity ${entityName}`);
|
|
69
51
|
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({
|
|
75
|
-
...message,
|
|
76
|
-
schema: await utils.schema.mapZodToJsonSchema(message, {
|
|
52
|
+
})) : {},
|
|
53
|
+
events: intrface.events ? await utils.records.mapValuesAsync(intrface.events, async (event, eventName) => ({
|
|
54
|
+
...event,
|
|
55
|
+
schema: await utils.schema.mapZodToJsonSchema(event, {
|
|
77
56
|
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
78
57
|
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
58
|
+
}).catch((thrown) => {
|
|
59
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for event ${eventName}`);
|
|
79
60
|
})
|
|
80
|
-
}))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
61
|
+
})) : {},
|
|
62
|
+
actions: intrface.actions ? await utils.records.mapValuesAsync(intrface.actions, async (action, actionName) => ({
|
|
63
|
+
...action,
|
|
64
|
+
input: {
|
|
65
|
+
...action.input,
|
|
66
|
+
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
67
|
+
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
68
|
+
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
69
|
+
}).catch((thrown) => {
|
|
70
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} input`);
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
output: {
|
|
74
|
+
...action.output,
|
|
75
|
+
schema: await utils.schema.mapZodToJsonSchema(action.output, {
|
|
76
|
+
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
77
|
+
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
78
|
+
}).catch((thrown) => {
|
|
79
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} output`);
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
})) : {},
|
|
83
|
+
channels: intrface.channels ? await utils.records.mapValuesAsync(intrface.channels, async (channel, channelName) => ({
|
|
84
|
+
...channel,
|
|
85
|
+
messages: await utils.records.mapValuesAsync(channel.messages, async (message, messageName) => ({
|
|
86
|
+
...message,
|
|
87
|
+
schema: await utils.schema.mapZodToJsonSchema(message, {
|
|
88
|
+
useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,
|
|
89
|
+
toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions
|
|
90
|
+
}).catch((thrown) => {
|
|
91
|
+
throw errors.BotpressCLIError.wrap(
|
|
92
|
+
thrown,
|
|
93
|
+
`${base} for channel ${channelName} for message ${messageName}`
|
|
94
|
+
);
|
|
95
|
+
})
|
|
96
|
+
}))
|
|
97
|
+
})) : {},
|
|
98
|
+
attributes: intrface.attributes
|
|
99
|
+
};
|
|
100
|
+
};
|
|
84
101
|
const prepareUpdateInterfaceBody = (localInterface, remoteInterface) => {
|
|
85
102
|
const actions = utils.attributes.prepareAttributeUpdateBody({
|
|
86
103
|
localItems: utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/interface-body.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateInterfaceBody = async (\n intrface: sdk.InterfaceDefinition\n): Promise<types.CreateInterfaceRequestBody> =>
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,6BAA6B,OACxC,
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateInterfaceBody = async (\n intrface: sdk.InterfaceDefinition\n): Promise<types.CreateInterfaceRequestBody> => {\n const base = `Failed to convert ZUI to JSON schema for interface ${intrface.name}`\n return {\n name: intrface.name,\n version: intrface.version,\n title: 'title' in intrface ? intrface.title : undefined,\n description: 'description' in intrface ? intrface.description : undefined,\n entities: intrface.entities\n ? await utils.records.mapValuesAsync(intrface.entities, async (entity, entityName) => ({\n ...entity,\n schema: await utils.schema\n .mapZodToJsonSchema(entity, {\n useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for entity ${entityName}`)\n }),\n }))\n : {},\n events: intrface.events\n ? await utils.records.mapValuesAsync(intrface.events, async (event, eventName) => ({\n ...event,\n schema: await utils.schema\n .mapZodToJsonSchema(event, {\n useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for event ${eventName}`)\n }),\n }))\n : {},\n actions: intrface.actions\n ? await utils.records.mapValuesAsync(intrface.actions, async (action, actionName) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema\n .mapZodToJsonSchema(action.input, {\n useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} input`)\n }),\n },\n output: {\n ...action.output,\n schema: await utils.schema\n .mapZodToJsonSchema(action.output, {\n useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} output`)\n }),\n },\n }))\n : {},\n channels: intrface.channels\n ? await utils.records.mapValuesAsync(intrface.channels, async (channel, channelName) => ({\n ...channel,\n messages: await utils.records.mapValuesAsync(channel.messages, async (message, messageName) => ({\n ...message,\n schema: await utils.schema\n .mapZodToJsonSchema(message, {\n useLegacyZuiTransformer: intrface.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: intrface.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `${base} for channel ${channelName} for message ${messageName}`\n )\n }),\n })),\n }))\n : {},\n attributes: intrface.attributes,\n }\n}\n\nexport const prepareUpdateInterfaceBody = (\n localInterface: types.CreateInterfaceRequestBody & { id: string },\n remoteInterface: client.Interface\n): types.UpdateInterfaceRequestBody => {\n const actions = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions),\n remoteItems: remoteInterface.actions,\n })\n const events = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localInterface.events, remoteInterface.events),\n remoteItems: remoteInterface.events,\n })\n const entities = utils.records.setNullOnMissingValues(localInterface.entities, remoteInterface.entities)\n\n const currentChannels: types.UpdateInterfaceRequestBody['channels'] = localInterface.channels\n ? utils.records.mapValues(localInterface.channels, (channel, channelName) => ({\n ...channel,\n messages: utils.records.setNullOnMissingValues(\n channel?.messages,\n remoteInterface.channels[channelName]?.messages\n ),\n }))\n : undefined\n\n const channels = utils.records.setNullOnMissingValues(currentChannels, remoteInterface.channels)\n\n const attributes = utils.records.setNullOnMissingValues(localInterface.attributes, remoteInterface.attributes)\n\n return {\n ...localInterface,\n entities,\n actions,\n events,\n channels,\n attributes,\n }\n}\n"],
|
|
5
|
+
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WAAW,2BAA2B;AAAA,IAC1D,YAAY,MAAM,QAAQ,uBAAuB,eAAe,SAAS,gBAAgB,OAAO;AAAA,IAChG,aAAa,gBAAgB;AAAA,EAC/B,CAAC;AACD,QAAM,SAAS,MAAM,WAAW,2BAA2B;AAAA,IACzD,YAAY,MAAM,QAAQ,uBAAuB,eAAe,QAAQ,gBAAgB,MAAM;AAAA,IAC9F,aAAa,gBAAgB;AAAA,EAC/B,CAAC;AACD,QAAM,WAAW,MAAM,QAAQ,uBAAuB,eAAe,UAAU,gBAAgB,QAAQ;AAEvG,QAAM,kBAAgE,eAAe,WACjF,MAAM,QAAQ,UAAU,eAAe,UAAU,CAAC,SAAS,iBAAiB;AAAA,IAC1E,GAAG;AAAA,IACH,UAAU,MAAM,QAAQ;AAAA,MACtB,SAAS;AAAA,MACT,gBAAgB,SAAS,WAAW,GAAG;AAAA,IACzC;AAAA,EACF,EAAE,IACF;AAEJ,QAAM,WAAW,MAAM,QAAQ,uBAAuB,iBAAiB,gBAAgB,QAAQ;AAE/F,QAAM,aAAa,MAAM,QAAQ,uBAAuB,eAAe,YAAY,gBAAgB,UAAU;AAE7G,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/api/plugin-body.js
CHANGED
|
@@ -32,64 +32,78 @@ __export(plugin_body_exports, {
|
|
|
32
32
|
prepareUpdatePluginBody: () => prepareUpdatePluginBody
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(plugin_body_exports);
|
|
35
|
+
var errors = __toESM(require("../errors"));
|
|
35
36
|
var utils = __toESM(require("../utils"));
|
|
36
|
-
const prepareCreatePluginBody = async (plugin) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
tags: plugin.message?.tags ?? {}
|
|
49
|
-
},
|
|
50
|
-
configuration: plugin.configuration ? {
|
|
51
|
-
...plugin.configuration,
|
|
52
|
-
schema: await utils.schema.mapZodToJsonSchema(plugin.configuration, {
|
|
53
|
-
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
54
|
-
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
55
|
-
})
|
|
56
|
-
} : void 0,
|
|
57
|
-
events: plugin.events ? await utils.records.mapValuesAsync(plugin.events, async (event) => ({
|
|
58
|
-
...event,
|
|
59
|
-
schema: await utils.schema.mapZodToJsonSchema(event, {
|
|
60
|
-
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
61
|
-
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
62
|
-
})
|
|
63
|
-
})) : void 0,
|
|
64
|
-
actions: plugin.actions ? await utils.records.mapValuesAsync(plugin.actions, async (action) => ({
|
|
65
|
-
...action,
|
|
66
|
-
input: {
|
|
67
|
-
...action.input,
|
|
68
|
-
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
69
|
-
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
70
|
-
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
71
|
-
})
|
|
37
|
+
const prepareCreatePluginBody = async (plugin) => {
|
|
38
|
+
const base = `Failed to convert ZUI to JSON schema for plugin ${plugin.name}`;
|
|
39
|
+
return {
|
|
40
|
+
name: plugin.name,
|
|
41
|
+
version: plugin.version,
|
|
42
|
+
title: "title" in plugin ? plugin.title : void 0,
|
|
43
|
+
description: "description" in plugin ? plugin.description : void 0,
|
|
44
|
+
user: {
|
|
45
|
+
tags: plugin.user?.tags ?? {}
|
|
46
|
+
},
|
|
47
|
+
conversation: {
|
|
48
|
+
tags: plugin.conversation?.tags ?? {}
|
|
72
49
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
message: {
|
|
51
|
+
tags: plugin.message?.tags ?? {}
|
|
52
|
+
},
|
|
53
|
+
configuration: plugin.configuration ? {
|
|
54
|
+
...plugin.configuration,
|
|
55
|
+
schema: await utils.schema.mapZodToJsonSchema(plugin.configuration, {
|
|
76
56
|
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
77
57
|
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
58
|
+
}).catch((thrown) => {
|
|
59
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for configuration`);
|
|
78
60
|
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
...state,
|
|
84
|
-
schema: await utils.schema.mapZodToJsonSchema(state, {
|
|
61
|
+
} : void 0,
|
|
62
|
+
events: plugin.events ? await utils.records.mapValuesAsync(plugin.events, async (event, eventName) => ({
|
|
63
|
+
...event,
|
|
64
|
+
schema: await utils.schema.mapZodToJsonSchema(event, {
|
|
85
65
|
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
86
66
|
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
67
|
+
}).catch((thrown) => {
|
|
68
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for event ${eventName}`);
|
|
87
69
|
})
|
|
88
|
-
})),
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
70
|
+
})) : void 0,
|
|
71
|
+
actions: plugin.actions ? await utils.records.mapValuesAsync(plugin.actions, async (action, actionName) => ({
|
|
72
|
+
...action,
|
|
73
|
+
input: {
|
|
74
|
+
...action.input,
|
|
75
|
+
schema: await utils.schema.mapZodToJsonSchema(action.input, {
|
|
76
|
+
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
77
|
+
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
78
|
+
}).catch((thrown) => {
|
|
79
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} input`);
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
output: {
|
|
83
|
+
...action.output,
|
|
84
|
+
schema: await utils.schema.mapZodToJsonSchema(action.output, {
|
|
85
|
+
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
86
|
+
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
87
|
+
}).catch((thrown) => {
|
|
88
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} output`);
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
})) : void 0,
|
|
92
|
+
states: plugin.states ? utils.records.filterValues(
|
|
93
|
+
await utils.records.mapValuesAsync(plugin.states, async (state, stateName) => ({
|
|
94
|
+
...state,
|
|
95
|
+
schema: await utils.schema.mapZodToJsonSchema(state, {
|
|
96
|
+
useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,
|
|
97
|
+
toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions
|
|
98
|
+
}).catch((thrown) => {
|
|
99
|
+
throw errors.BotpressCLIError.wrap(thrown, `${base} for state ${stateName}`);
|
|
100
|
+
})
|
|
101
|
+
})),
|
|
102
|
+
({ type }) => type !== "workflow"
|
|
103
|
+
) : void 0,
|
|
104
|
+
attributes: plugin.attributes
|
|
105
|
+
};
|
|
106
|
+
};
|
|
93
107
|
const prepareUpdatePluginBody = (localPlugin, remotePlugin) => {
|
|
94
108
|
const actions = utils.attributes.prepareAttributeUpdateBody({
|
|
95
109
|
localItems: utils.records.setNullOnMissingValues(localPlugin.actions, remotePlugin.actions),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/plugin-body.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreatePluginBody = async (
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,0BAA0B,
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreatePluginBody = async (plugin: sdk.PluginDefinition): Promise<types.CreatePluginRequestBody> => {\n const base = `Failed to convert ZUI to JSON schema for plugin ${plugin.name}`\n return {\n name: plugin.name,\n version: plugin.version,\n title: 'title' in plugin ? plugin.title : undefined,\n description: 'description' in plugin ? plugin.description : undefined,\n user: {\n tags: plugin.user?.tags ?? {},\n },\n conversation: {\n tags: plugin.conversation?.tags ?? {},\n },\n message: {\n tags: plugin.message?.tags ?? {},\n },\n configuration: plugin.configuration\n ? {\n ...plugin.configuration,\n schema: await utils.schema\n .mapZodToJsonSchema(plugin.configuration, {\n useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for configuration`)\n }),\n }\n : undefined,\n events: plugin.events\n ? await utils.records.mapValuesAsync(plugin.events, async (event, eventName) => ({\n ...event,\n schema: await utils.schema\n .mapZodToJsonSchema(event, {\n useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for event ${eventName}`)\n }),\n }))\n : undefined,\n actions: plugin.actions\n ? await utils.records.mapValuesAsync(plugin.actions, async (action, actionName) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema\n .mapZodToJsonSchema(action.input, {\n useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} input`)\n }),\n },\n output: {\n ...action.output,\n schema: await utils.schema\n .mapZodToJsonSchema(action.output, {\n useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for action ${actionName} output`)\n }),\n },\n }))\n : undefined,\n states: plugin.states\n ? (utils.records.filterValues(\n await utils.records.mapValuesAsync(plugin.states, async (state, stateName) => ({\n ...state,\n schema: await utils.schema\n .mapZodToJsonSchema(state, {\n useLegacyZuiTransformer: plugin.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: plugin.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `${base} for state ${stateName}`)\n }),\n })),\n ({ type }) => type !== 'workflow'\n ) as types.CreatePluginRequestBody['states'])\n : undefined,\n attributes: plugin.attributes,\n }\n}\n\nexport const prepareUpdatePluginBody = (\n localPlugin: types.UpdatePluginRequestBody,\n remotePlugin: client.Plugin\n): types.UpdatePluginRequestBody => {\n const actions = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localPlugin.actions, remotePlugin.actions),\n remoteItems: remotePlugin.actions,\n })\n const events = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localPlugin.events, remotePlugin.events),\n remoteItems: remotePlugin.events,\n })\n const states = utils.records.setNullOnMissingValues(localPlugin.states, remotePlugin.states)\n\n const attributes = utils.records.setNullOnMissingValues(localPlugin.attributes, remotePlugin.attributes)\n\n const dependencies: types.UpdatePluginRequestBody['dependencies'] = {\n integrations: utils.records.setNullOnMissingValues(\n localPlugin.dependencies?.integrations,\n remotePlugin.dependencies?.integrations\n ),\n interfaces: utils.records.setNullOnMissingValues(\n localPlugin.dependencies?.interfaces,\n remotePlugin.dependencies?.interfaces\n ),\n }\n\n // TODO: set null to conversation, user and message tags that are removed\n\n return {\n ...localPlugin,\n actions,\n events,\n states,\n attributes,\n dependencies,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,aAAwB;AACxB,YAAuB;AAGhB,MAAM,0BAA0B,OAAO,WAAyE;AACrH,QAAM,OAAO,mDAAmD,OAAO,IAAI;AAC3E,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,SAAS,OAAO;AAAA,IAChB,OAAO,WAAW,SAAS,OAAO,QAAQ;AAAA,IAC1C,aAAa,iBAAiB,SAAS,OAAO,cAAc;AAAA,IAC5D,MAAM;AAAA,MACJ,MAAM,OAAO,MAAM,QAAQ,CAAC;AAAA,IAC9B;AAAA,IACA,cAAc;AAAA,MACZ,MAAM,OAAO,cAAc,QAAQ,CAAC;AAAA,IACtC;AAAA,IACA,SAAS;AAAA,MACP,MAAM,OAAO,SAAS,QAAQ,CAAC;AAAA,IACjC;AAAA,IACA,eAAe,OAAO,gBAClB;AAAA,MACE,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,MAAM,OACjB,mBAAmB,OAAO,eAAe;AAAA,QACxC,yBAAyB,OAAO,YAAY;AAAA,QAC5C,qBAAqB,OAAO,YAAY;AAAA,MAC1C,CAAC,EACA,MAAM,CAAC,WAAW;AACjB,cAAM,OAAO,iBAAiB,KAAK,QAAQ,GAAG,IAAI,oBAAoB;AAAA,MACxE,CAAC;AAAA,IACL,IACA;AAAA,IACJ,QAAQ,OAAO,SACX,MAAM,MAAM,QAAQ,eAAe,OAAO,QAAQ,OAAO,OAAO,eAAe;AAAA,MAC7E,GAAG;AAAA,MACH,QAAQ,MAAM,MAAM,OACjB,mBAAmB,OAAO;AAAA,QACzB,yBAAyB,OAAO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AAM,OAAO,iBAAiB,KAAK,QAAQ,GAAG,IAAI,cAAc,SAAS,EAAE;AAAA,QAC7E,CAAC;AAAA,MACL,EAAE;AAAA,MACF,CAAC,EAAE,KAAK,MAAM,SAAS;AAAA,IACzB,IACA;AAAA,IACJ,YAAY,OAAO;AAAA,EACrB;AACF;AAEO,MAAM,0BAA0B,CACrC,aACA,iBACkC;AAClC,QAAM,UAAU,MAAM,WAAW,2BAA2B;AAAA,IAC1D,YAAY,MAAM,QAAQ,uBAAuB,YAAY,SAAS,aAAa,OAAO;AAAA,IAC1F,aAAa,aAAa;AAAA,EAC5B,CAAC;AACD,QAAM,SAAS,MAAM,WAAW,2BAA2B;AAAA,IACzD,YAAY,MAAM,QAAQ,uBAAuB,YAAY,QAAQ,aAAa,MAAM;AAAA,IACxF,aAAa,aAAa;AAAA,EAC5B,CAAC;AACD,QAAM,SAAS,MAAM,QAAQ,uBAAuB,YAAY,QAAQ,aAAa,MAAM;AAE3F,QAAM,aAAa,MAAM,QAAQ,uBAAuB,YAAY,YAAY,aAAa,UAAU;AAEvG,QAAM,eAA8D;AAAA,IAClE,cAAc,MAAM,QAAQ;AAAA,MAC1B,YAAY,cAAc;AAAA,MAC1B,aAAa,cAAc;AAAA,IAC7B;AAAA,IACA,YAAY,MAAM,QAAQ;AAAA,MACxB,YAAY,cAAc;AAAA,MAC1B,aAAa,cAAc;AAAA,IAC7B;AAAA,EACF;AAIA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cli.js
CHANGED
|
@@ -38,8 +38,10 @@ const onError = (thrown) => {
|
|
|
38
38
|
process.exit(1);
|
|
39
39
|
};
|
|
40
40
|
const yargsFail = (msg) => {
|
|
41
|
-
|
|
41
|
+
if (msg !== void 0) {
|
|
42
|
+
new import_logger.Logger().error(`${msg}
|
|
42
43
|
`);
|
|
44
|
+
}
|
|
43
45
|
import_yargs_extra.default.showHelp();
|
|
44
46
|
process.exit(1);
|
|
45
47
|
};
|
package/dist/cli.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts"],
|
|
4
|
-
"sourcesContent": ["import 'dotenv/config'\nimport yargs from '@bpinternal/yargs-extra'\nimport commandDefinitions from './command-definitions'\nimport commandImplementations from './command-implementations'\nimport * as tree from './command-tree'\nimport * as errors from './errors'\nimport { Logger } from './logger'\nimport { registerYargs } from './register-yargs'\n\nconst logError = (thrown: unknown) => {\n const error = errors.BotpressCLIError.map(thrown)\n // genuine crashes only: print the full chain so headless callers (no -v) still get the reason.\n new Logger().error(errors.BotpressCLIError.fullStack(error))\n}\n\nconst onError = (thrown: unknown) => {\n logError(thrown)\n process.exit(1)\n}\n\nconst yargsFail = (msg
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAO;AACP,yBAAkB;AAClB,iCAA+B;AAC/B,qCAAmC;AACnC,WAAsB;AACtB,aAAwB;AACxB,oBAAuB;AACvB,4BAA8B;AAE9B,MAAM,WAAW,CAAC,WAAoB;AACpC,QAAM,QAAQ,OAAO,iBAAiB,IAAI,MAAM;AAEhD,MAAI,qBAAO,EAAE,MAAM,OAAO,iBAAiB,UAAU,KAAK,CAAC;AAC7D;AAEA,MAAM,UAAU,CAAC,WAAoB;AACnC,WAAS,MAAM;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,YAAY,CAAC,
|
|
4
|
+
"sourcesContent": ["import 'dotenv/config'\nimport yargs from '@bpinternal/yargs-extra'\nimport commandDefinitions from './command-definitions'\nimport commandImplementations from './command-implementations'\nimport * as tree from './command-tree'\nimport * as errors from './errors'\nimport { Logger } from './logger'\nimport { registerYargs } from './register-yargs'\n\nconst logError = (thrown: unknown) => {\n const error = errors.BotpressCLIError.map(thrown)\n // genuine crashes only: print the full chain so headless callers (no -v) still get the reason.\n new Logger().error(errors.BotpressCLIError.fullStack(error))\n}\n\nconst onError = (thrown: unknown) => {\n logError(thrown)\n process.exit(1)\n}\n\nconst yargsFail = (msg?: string) => {\n // usage errors are bad input, not crashes; show the clean message and help, never a stack.\n if (msg !== undefined) {\n new Logger().error(`${msg}\\n`)\n }\n yargs.showHelp()\n process.exit(1)\n}\n\nprocess.on('uncaughtException', (thrown: unknown) => onError(thrown))\nprocess.on('unhandledRejection', (thrown: unknown) => onError(thrown))\n\nconst commands = tree.zipTree(commandDefinitions, commandImplementations)\n\nregisterYargs(yargs, commands)\n\nvoid yargs\n .version()\n .scriptName('bp')\n .demandCommand(1, \"You didn't provide any command. Use the --help flag to see the list of available commands.\")\n .recommendCommands()\n .strict()\n .help()\n .fail(yargsFail)\n .parse()\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,oBAAO;AACP,yBAAkB;AAClB,iCAA+B;AAC/B,qCAAmC;AACnC,WAAsB;AACtB,aAAwB;AACxB,oBAAuB;AACvB,4BAA8B;AAE9B,MAAM,WAAW,CAAC,WAAoB;AACpC,QAAM,QAAQ,OAAO,iBAAiB,IAAI,MAAM;AAEhD,MAAI,qBAAO,EAAE,MAAM,OAAO,iBAAiB,UAAU,KAAK,CAAC;AAC7D;AAEA,MAAM,UAAU,CAAC,WAAoB;AACnC,WAAS,MAAM;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,YAAY,CAAC,QAAiB;AAElC,MAAI,QAAQ,QAAW;AACrB,QAAI,qBAAO,EAAE,MAAM,GAAG,GAAG;AAAA,CAAI;AAAA,EAC/B;AACA,qBAAAA,QAAM,SAAS;AACf,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,GAAG,qBAAqB,CAAC,WAAoB,QAAQ,MAAM,CAAC;AACpE,QAAQ,GAAG,sBAAsB,CAAC,WAAoB,QAAQ,MAAM,CAAC;AAErE,MAAM,WAAW,KAAK,QAAQ,2BAAAC,SAAoB,+BAAAC,OAAsB;AAAA,IAExE,qCAAc,mBAAAF,SAAO,QAAQ;AAE7B,KAAK,mBAAAA,QACF,QAAQ,EACR,WAAW,IAAI,EACf,cAAc,GAAG,4FAA4F,EAC7G,kBAAkB,EAClB,OAAO,EACP,KAAK,EACL,KAAK,SAAS,EACd,MAAM;",
|
|
6
6
|
"names": ["yargs", "commandDefinitions", "commandImplementations"]
|
|
7
7
|
}
|
|
@@ -446,6 +446,11 @@ class ProjectCommand extends import_global_command.GlobalCommand {
|
|
|
446
446
|
schema: await utils.schema.mapZodToJsonSchema(integrationDef.configuration, {
|
|
447
447
|
useLegacyZuiTransformer: integrationDef.__advanced?.useLegacyZuiTransformer,
|
|
448
448
|
toJSONSchemaOptions: integrationDef.__advanced?.toJSONSchemaOptions
|
|
449
|
+
}).catch((thrown) => {
|
|
450
|
+
throw errors.BotpressCLIError.wrap(
|
|
451
|
+
thrown,
|
|
452
|
+
`Failed to convert ZUI to JSON schema for integration ${integrationDef.name} for configuration`
|
|
453
|
+
);
|
|
449
454
|
}),
|
|
450
455
|
identifier: {
|
|
451
456
|
required: integrationDef.configuration.identifier?.required,
|
|
@@ -454,18 +459,26 @@ class ProjectCommand extends import_global_command.GlobalCommand {
|
|
|
454
459
|
)
|
|
455
460
|
}
|
|
456
461
|
} : void 0,
|
|
457
|
-
configurations: integrationDef.configurations ? await utils.records.mapValuesAsync(
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
462
|
+
configurations: integrationDef.configurations ? await utils.records.mapValuesAsync(
|
|
463
|
+
integrationDef.configurations,
|
|
464
|
+
async (configuration, configurationName) => ({
|
|
465
|
+
title: configuration.title,
|
|
466
|
+
description: configuration.description,
|
|
467
|
+
schema: await utils.schema.mapZodToJsonSchema(configuration, {
|
|
468
|
+
useLegacyZuiTransformer: integrationDef.__advanced?.useLegacyZuiTransformer,
|
|
469
|
+
toJSONSchemaOptions: integrationDef.__advanced?.toJSONSchemaOptions
|
|
470
|
+
}).catch((thrown) => {
|
|
471
|
+
throw errors.BotpressCLIError.wrap(
|
|
472
|
+
thrown,
|
|
473
|
+
`Failed to convert ZUI to JSON schema for integration ${integrationDef.name} for configuration ${configurationName}`
|
|
474
|
+
);
|
|
475
|
+
}),
|
|
476
|
+
identifier: {
|
|
477
|
+
required: configuration.identifier?.required,
|
|
478
|
+
linkTemplateScript: await this.readProjectFile(configuration.identifier?.linkTemplateScript)
|
|
479
|
+
}
|
|
480
|
+
})
|
|
481
|
+
) : void 0
|
|
469
482
|
};
|
|
470
483
|
}
|
|
471
484
|
async prepareBotDependencies(botDef, api) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/project-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { validateIntegrationDefinition, validateBotDefinition } from '../sdk'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = {\n botId: string\n devId: string\n tunnelId: string\n secrets: {\n [secretName: string]: string\n }\n}\n\ntype ConfigurableProjectPaths = { workDir: string }\ntype ConstantProjectPaths = typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype LintIgnoredConfig = { bpLintDisabled?: boolean }\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition = LintIgnoredConfig &\n (\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDefinition }\n | { type: 'bot'; definition: sdk.BotDefinition }\n | { type: 'plugin'; definition: sdk.PluginDefinition }\n )\n\ntype ProjectDefinitionResolver<T> = () => Promise<LintIgnoredConfig & T>\n\nexport type ProjectDefinitionLazy =\n | {\n projectType: 'integration'\n resolveProjectDefinition: ProjectDefinitionResolver<{\n type: 'integration'\n definition: sdk.IntegrationDefinition\n }>\n }\n | {\n projectType: 'bot'\n resolveProjectDefinition: ProjectDefinitionResolver<{ type: 'bot'; definition: sdk.BotDefinition }>\n }\n | {\n projectType: 'interface'\n resolveProjectDefinition: ProjectDefinitionResolver<{ type: 'interface'; definition: sdk.InterfaceDefinition }>\n }\n | {\n projectType: 'plugin'\n resolveProjectDefinition: ProjectDefinitionResolver<{ type: 'plugin'; definition: sdk.PluginDefinition }>\n }\n\ntype UpdatedBot = client.Bot\n\ntype ClientIntegrationDefinitions = Record<string, client.Integration>\ntype ClientIntegration = client.Bot['integrations'][string]\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n super({\n workDir: absWorkDir,\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport class ProjectDefinitionContext {\n private _codeCache: Map<string, object> = new Map()\n private _buildContext: utils.esbuild.BuildEntrypointContext = new utils.esbuild.BuildEntrypointContext()\n\n public getOrResolveDefinition<T extends object>(code: string): T {\n const definition = this._codeCache.get(code)\n if (definition) {\n return definition as T\n }\n const result = utils.require.requireJsCode<{ default: object }>(code)\n this._codeCache.set(code, result.default)\n return result.default as T\n }\n\n public rebuildEntrypoint(...args: Parameters<utils.esbuild.BuildEntrypointContext['rebuild']>) {\n return this._buildContext.rebuild(...args)\n }\n}\n\ntype ResolvedDependency = { id: string }\ntype DependencyCacheKey = `${'integration' | 'plugin' | 'interface'}:${string}@${string}`\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected projectContext: ProjectDefinitionContext = new ProjectDefinitionContext()\n private _dependencyCache = new Map<DependencyCacheKey, ResolvedDependency>()\n\n public setProjectContext(projectContext: ProjectDefinitionContext) {\n this.projectContext = projectContext\n return this\n }\n\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n private _readProjectType(projectPaths: ProjectPaths): ProjectType {\n const abs = projectPaths.abs\n if (fs.existsSync(abs.integrationDefinition)) {\n return 'integration'\n }\n if (fs.existsSync(abs.interfaceDefinition)) {\n return 'interface'\n }\n if (fs.existsSync(abs.botDefinition)) {\n return 'bot'\n }\n if (fs.existsSync(abs.pluginDefinition)) {\n return 'plugin'\n }\n throw new errors.UnsupportedProjectType()\n }\n\n protected readProjectDefinitionFromFS(): ProjectDefinitionLazy {\n try {\n const type = this._readProjectType(this.projectPaths)\n if (type === 'integration') {\n return {\n projectType: 'integration',\n resolveProjectDefinition: async () => ({\n type: 'integration',\n ...(await this._readIntegrationDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n if (type === 'plugin') {\n return {\n projectType: 'plugin',\n resolveProjectDefinition: async () => ({\n type: 'plugin',\n ...(await this._readPluginDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n if (type === 'interface') {\n return {\n projectType: 'interface',\n resolveProjectDefinition: async () => ({\n type: 'interface',\n ...(await this._readInterfaceDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n if (type === 'bot') {\n return {\n projectType: 'bot',\n resolveProjectDefinition: async () => ({\n type: 'bot',\n ...(await this._readBotDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n } catch (thrown: unknown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Error while reading project definition')\n }\n throw new errors.ProjectDefinitionNotFoundError(this.projectPaths.abs.workDir)\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'>\n ): Promise<{ definition: sdk.IntegrationDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.integrationDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.IntegrationDefinition>(artifact.text)\n validateIntegrationDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'>\n ): Promise<{ definition: sdk.InterfaceDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.interfaceDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.InterfaceDefinition>(artifact.text)\n\n return { definition, bpLintDisabled }\n }\n\n private async _readBotDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'botDefinition'>\n ): Promise<{ definition: sdk.BotDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.botDefinition)) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.botDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.BotDefinition>(artifact.text)\n validateBotDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readPluginDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'pluginDefinition'>\n ): Promise<{ definition: sdk.PluginDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.pluginDefinition)) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.pluginDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.PluginDefinition>(artifact.text)\n // TODO: validate plugin definition\n return { definition, bpLintDisabled }\n }\n\n private async _isBpLintDisabled(definitionPath: string): Promise<boolean> {\n const tsContent = await fs.promises.readFile(definitionPath, 'utf-8')\n const regex = /\\/\\* bplint-disable \\*\\//\n return regex.test(tsContent)\n }\n\n protected async displayIntegrationUrls({ api, bot }: { api: apiUtils.ApiClient; bot: client.Bot }) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n const integrationDefinitions = await utils.records.mapValuesAsync(bot.integrations, async (integration) =>\n api.getPublicOrPrivateIntegration({\n type: 'id',\n id: integration.id,\n })\n )\n\n this.logger.log('Integrations:')\n for (const [alias, integration] of Object.entries(bot.integrations)) {\n if (integration.enabled) {\n this.logger.log(`${alias} ${integration.version}:`, { prefix: { symbol: '\u2192', indent: 2 } })\n } else {\n this.logger.log(`${alias} ${integration.version} ${chalk.italic('(disabled)')}:`, {\n prefix: { symbol: '\u2192', indent: 2 },\n })\n }\n\n const integrationDefinition = integrationDefinitions[alias]\n const linkTemplateScript = integrationDefinition\n ? this._getLinkTemplateScript({ integration, integrationDefinition })\n : undefined\n this._displayWebhookUrl({ integration, integrationDefinition, linkTemplateScript })\n if (!integrationDefinition) {\n this.logger.debug(\n `No integration definition for integration ${alias} (${integration.name}, ${integration.id}), skipping OAuth or Sandbox links`\n )\n this.logger.line().commit()\n continue\n }\n const isSandbox =\n integration.configurationType === 'sandbox' && !!integrationDefinition.sandbox?.identifierExtractScript\n const showLink = !!linkTemplateScript && (isSandbox || !!integrationDefinition.identifier?.extractScript)\n if (showLink && isSandbox) {\n await this._displaySandboxLinkAndCode({ integration, alias, bot, api, linkTemplateScript })\n } else if (showLink) {\n this._displayAuthorizationLink({ integration, api, linkTemplateScript })\n }\n this.logger.line().commit()\n }\n }\n\n private _getLinkTemplateScript({\n integration,\n integrationDefinition,\n }: {\n integration: ClientIntegration\n integrationDefinition?: ClientIntegrationDefinitions[string]\n }) {\n const config =\n integration.configurationType === null\n ? integrationDefinition?.configuration\n : integrationDefinition?.configurations[integration.configurationType]\n return config?.identifier?.linkTemplateScript\n }\n\n private _displayWebhookUrl({\n integration,\n integrationDefinition,\n linkTemplateScript,\n }: {\n integration: ClientIntegration\n integrationDefinition?: ClientIntegrationDefinitions[string]\n linkTemplateScript?: string\n }) {\n const needsWebhook = !(integrationDefinition?.identifier && linkTemplateScript)\n const logFn = (needsWebhook ? this.logger.log : this.logger.debug).bind(this.logger)\n\n if (integration.enabled) {\n logFn(`${chalk.bold('Webhook')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 4 },\n })\n } else {\n logFn(`Webhook: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 4 },\n })\n }\n }\n\n private _displayAuthorizationLink({\n integration,\n api,\n linkTemplateScript,\n }: {\n integration: ClientIntegration\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n const authorizationLink = this._getAuthorizationLink({ integration, api, linkTemplateScript })\n const isAuthorized = !!integration.identifier\n const authorizationStatus = integration.identifier ? 'Authorized \u2713' : 'Authorize'\n if (integration.enabled && isAuthorized) {\n this.logger.log(`${chalk.bold(authorizationStatus)} : ${authorizationLink}`, {\n prefix: { symbol: '\u25CF', indent: 4 },\n })\n } else {\n this.logger.log(`${authorizationStatus}: ${authorizationLink}`, {\n prefix: { symbol: '\u25CB', indent: 4 },\n })\n }\n }\n\n private _getLinkTemplateArgs({ integration, api }: { integration: ClientIntegration; api: apiUtils.ApiClient }) {\n // These are the values used by the studio\n let env: 'development' | 'preview' | 'production'\n if (api.url.includes(consts.stagingBotpressDomain)) {\n env = 'preview'\n } else if (api.url.includes(consts.productionBotpressDomain)) {\n env = 'production'\n } else {\n env = 'development'\n }\n return {\n env,\n webhookId: integration.webhookId,\n webhookUrl: api.url.replace('api', 'webhook'),\n }\n }\n\n private _getAuthorizationLink({\n integration,\n api,\n linkTemplateScript,\n }: {\n integration: client.Bot['integrations'][string]\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n return utils.vrl.getStringResult({\n code: linkTemplateScript,\n data: this._getLinkTemplateArgs({ integration, api }),\n })\n }\n\n private _getSandboxLink({\n shareableId,\n integration,\n api,\n linkTemplateScript,\n }: {\n shareableId: string\n integration: ClientIntegration\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n return utils.vrl.getStringResult({\n code: linkTemplateScript,\n data: { shareableId, ...this._getLinkTemplateArgs({ integration, api }) },\n })\n }\n\n private async _displaySandboxLinkAndCode({\n integration,\n alias,\n bot,\n api,\n linkTemplateScript,\n }: {\n integration: ClientIntegration\n alias: string\n bot: client.Bot\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n const shareableId = await api.getOrGenerateShareableId(bot.id, integration.id, alias)\n const sandboxLink = this._getSandboxLink({ shareableId, integration, api, linkTemplateScript })\n const sandboxInstruction = `Send '${shareableId}' to ${sandboxLink}`\n if (integration.enabled) {\n this.logger.log(`${chalk.bold('Sandbox')}: ${sandboxInstruction}`, {\n prefix: { symbol: '\u25CF', indent: 4 },\n })\n } else {\n this.logger.log(`Sandbox: ${sandboxInstruction}`, {\n prefix: { symbol: '\u25CB', indent: 4 },\n })\n }\n }\n\n protected async promptSecrets(\n def: { secrets?: Record<string, sdk.SecretDefinition> },\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = def\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in the definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n protected async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n const partialBody = await apiUtils.prepareCreateIntegrationBody(integrationDef)\n\n let code: string | undefined = undefined\n if (fs.existsSync(this.projectPaths.abs.outFileCJS)) {\n code = await this.readProjectFile(this.projectPaths.abs.outFileCJS)\n }\n\n const icon = await this.readProjectFile(integrationDef.icon, 'base64')\n const readme = await this.readProjectFile(integrationDef.readme, 'base64')\n const extractScript = await this.readProjectFile(integrationDef.identifier?.extractScript)\n const fallbackHandlerScript = await this.readProjectFile(integrationDef.identifier?.fallbackHandlerScript)\n return {\n ...partialBody,\n code,\n icon,\n readme,\n identifier: {\n extractScript,\n fallbackHandlerScript,\n },\n configuration: integrationDef.configuration\n ? {\n schema: await utils.schema.mapZodToJsonSchema(integrationDef.configuration, {\n useLegacyZuiTransformer: integrationDef.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integrationDef.__advanced?.toJSONSchemaOptions,\n }),\n identifier: {\n required: integrationDef.configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(\n integrationDef.configuration.identifier?.linkTemplateScript\n ),\n },\n }\n : undefined,\n configurations: integrationDef.configurations\n ? await utils.records.mapValuesAsync(integrationDef.configurations, async (configuration) => ({\n title: configuration.title,\n description: configuration.description,\n schema: await utils.schema.mapZodToJsonSchema(configuration, {\n useLegacyZuiTransformer: integrationDef.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integrationDef.__advanced?.toJSONSchemaOptions,\n }),\n identifier: {\n required: configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(configuration.identifier?.linkTemplateScript),\n },\n }))\n : undefined,\n }\n }\n\n protected async prepareBotDependencies(\n botDef: sdk.BotDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.UpdateBotRequestBody>> {\n const integrations = await this._fetchDependencies({\n deps: botDef.integrations ?? {},\n fetcher: ({ name, version }) => api.getPublicOrPrivateIntegration({ type: 'name', name, version }),\n cacheKey: ({ name, version }) => `integration:${name}@${version}`,\n })\n\n const plugins = await this._fetchDependencies({\n deps: botDef.plugins ?? {},\n fetcher: async ({ name, version }) => await api.getPublicOrPrivatePlugin({ type: 'name', name, version }),\n cacheKey: ({ name, version }) => `plugin:${name}@${version}`,\n })\n\n const pluginsWithBackingIntegrations = await utils.records.mapValuesAsync(plugins, async (plugin) => ({\n ...plugin,\n interfaces: await this._fetchDependencies({\n deps: plugin.interfaces ?? {},\n fetcher: async ({ name, version }) => await api.getPublicOrPrivateIntegration({ name, version, type: 'name' }),\n cacheKey: ({ name, version }) => `interface:${name}@${version}`,\n }),\n integrations: await this._fetchDependencies({\n deps: plugin.integrations ?? {},\n fetcher: async ({ name, version }) => await api.getPublicOrPrivateIntegration({ name, version, type: 'name' }),\n cacheKey: ({ name, version }) => `integration:${name}@${version}`,\n }),\n }))\n\n return {\n integrations: utils.records.mapValues(\n integrations,\n ({ enabled, configurationType, configuration, disabledChannels, id }) =>\n ({\n enabled,\n configurationType,\n configuration,\n disabledChannels,\n integrationId: id,\n }) satisfies NonNullable<apiUtils.UpdateBotRequestBody['integrations']>[string]\n ),\n plugins: utils.records.mapValues(pluginsWithBackingIntegrations, (plugin) => ({\n ...plugin,\n interfaces: utils.records.mapValues(\n plugin.interfaces ?? {},\n (iface) =>\n ({\n integrationId: iface.id,\n integrationAlias: iface.integrationAlias,\n integrationInterfaceAlias: iface.integrationInterfaceAlias,\n }) satisfies NonNullable<\n NonNullable<NonNullable<apiUtils.UpdateBotRequestBody['plugins']>[string]>['interfaces']\n >[string]\n ),\n integrations: utils.records.mapValues(\n plugin.integrations ?? {},\n (integration) =>\n ({\n integrationId: integration.id,\n integrationAlias: integration.integrationAlias,\n }) satisfies NonNullable<\n NonNullable<NonNullable<apiUtils.UpdateBotRequestBody['plugins']>[string]>['integrations']\n >[string]\n ),\n })),\n }\n }\n\n protected async prepareIntegrationDependencies(\n integrationDef: sdk.IntegrationDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreateIntegrationRequestBody>> {\n const interfaces = await this._fetchDependencies({\n deps: integrationDef.interfaces ?? {},\n fetcher: ({ name, version }) => api.getPublicInterface({ type: 'name', name, version }),\n cacheKey: (dep) => `interface:${dep.name}@${dep.version}`,\n })\n return { interfaces }\n }\n\n protected async preparePluginDependencies(\n pluginDef: sdk.PluginDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreatePluginRequestBody>> {\n const integrations = await this._fetchDependencies({\n deps: pluginDef.integrations ?? {},\n fetcher: ({ name, version }) => api.getPublicOrPrivateIntegration({ type: 'name', name, version }),\n cacheKey: (dep) => `integration:${dep.name}@${dep.version}`,\n })\n const interfaces = await this._fetchDependencies({\n deps: pluginDef.interfaces ?? {},\n fetcher: ({ name, version }) => api.getPublicInterface({ type: 'name', name, version }),\n cacheKey: (dep) => `interface:${dep.name}@${dep.version}`,\n })\n return {\n dependencies: {\n integrations,\n interfaces,\n },\n }\n }\n\n private _fetchDependencies = async <T extends { id?: string; name: string; version: string }>({\n deps,\n fetcher,\n cacheKey: getCacheKey,\n }: {\n deps: Record<string, T>\n fetcher: (dep: T) => Promise<ResolvedDependency>\n cacheKey: (dep: T) => DependencyCacheKey\n }): Promise<Record<string, T & ResolvedDependency>> => {\n const isRemote = (dep: T): dep is T & ResolvedDependency => dep.id !== undefined\n return utils.records.mapValuesAsync(deps, async (dep): Promise<T & ResolvedDependency> => {\n if (isRemote(dep)) {\n return dep\n }\n\n const cacheKey = getCacheKey(dep)\n const cached = this._dependencyCache.get(cacheKey)\n\n if (cached) {\n return { ...dep, id: cached.id }\n }\n\n const { id } = await fetcher(dep)\n this._dependencyCache.set(cacheKey, { id })\n\n return { ...dep, id }\n })\n }\n\n protected readProjectFile = async (\n filePath: string | undefined,\n encoding: BufferEncoding = 'utf-8'\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, encoding).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const readProjectPkgJsonResult = await utils.pkgJson.safeReadPackageJson(workDir)\n if (!readProjectPkgJsonResult.success) {\n this.logger.debug(`Could not read package.json at \"${workDir}\": ${readProjectPkgJsonResult.error.message}`)\n return\n }\n\n if (!readProjectPkgJsonResult.pkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const { pkgJson: projectPkgJson } = readProjectPkgJsonResult\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readCLIPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sdk is up to date: ${err.message}`)\n }\n }\n protected validateIntegrationRegistration(\n updatedBot: UpdatedBot,\n onFailCallback: (failedIntegrations: UpdatedBot['integrations']) => void\n ) {\n let failedIntegrations: UpdatedBot['integrations'] = {}\n for (const [integrationName, integration] of Object.entries(updatedBot.integrations)) {\n if (integration.status === 'registration_failed') {\n failedIntegrations = { ...failedIntegrations, [integrationName]: integration }\n }\n }\n if (Object.keys(failedIntegrations).length > 0) {\n onFailCallback(failedIntegrations)\n }\n }\n\n protected async manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<\n | {\n integration: sdk.IntegrationDefinition\n workspaceId?: string\n }\n | undefined\n > {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n this.logger.log('Aborted')\n return\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n protected _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;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C;AAChG,UAAI,CAAC,WAAW;AACd,aAAK,OAAO,KAAK,WAAW,QAAQ,oCAAoC,YAAY,KAAK,IAAI,CAAC,EAAE;AAChG;AAAA,MACF;AAEA,sBAAgB;AAChB,YAAM,IAAI,gBAAgB,EAAE,QAAQ,cAAc,CAAC,EAAE,MAAM,CAAC,WAAW;AACrE,cAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B,aAAa,GAAG;AAAA,MACxF,CAAC;AAAA,IACH,SAAS,CAAC;AAEV,SAAK,OAAO,QAAQ,WAAW,aAAa,aAAa;AACzD,UAAM,UAAU,GAAG,aAAa,IAAI,SAAS;AAC7C,WAAO,EAAE,aAAa,IAAI,IAAI,sBAAsB,EAAE,GAAG,aAAa,MAAM,QAAQ,CAAC,EAAE;AAAA,EACzF;AAAA,EAEU,wBAAwB,CAAC,oBAAwE;AACzG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { validateIntegrationDefinition, validateBotDefinition } from '../sdk'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = {\n botId: string\n devId: string\n tunnelId: string\n secrets: {\n [secretName: string]: string\n }\n}\n\ntype ConfigurableProjectPaths = { workDir: string }\ntype ConstantProjectPaths = typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype LintIgnoredConfig = { bpLintDisabled?: boolean }\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition = LintIgnoredConfig &\n (\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDefinition }\n | { type: 'bot'; definition: sdk.BotDefinition }\n | { type: 'plugin'; definition: sdk.PluginDefinition }\n )\n\ntype ProjectDefinitionResolver<T> = () => Promise<LintIgnoredConfig & T>\n\nexport type ProjectDefinitionLazy =\n | {\n projectType: 'integration'\n resolveProjectDefinition: ProjectDefinitionResolver<{\n type: 'integration'\n definition: sdk.IntegrationDefinition\n }>\n }\n | {\n projectType: 'bot'\n resolveProjectDefinition: ProjectDefinitionResolver<{ type: 'bot'; definition: sdk.BotDefinition }>\n }\n | {\n projectType: 'interface'\n resolveProjectDefinition: ProjectDefinitionResolver<{ type: 'interface'; definition: sdk.InterfaceDefinition }>\n }\n | {\n projectType: 'plugin'\n resolveProjectDefinition: ProjectDefinitionResolver<{ type: 'plugin'; definition: sdk.PluginDefinition }>\n }\n\ntype UpdatedBot = client.Bot\n\ntype ClientIntegrationDefinitions = Record<string, client.Integration>\ntype ClientIntegration = client.Bot['integrations'][string]\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n super({\n workDir: absWorkDir,\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport class ProjectDefinitionContext {\n private _codeCache: Map<string, object> = new Map()\n private _buildContext: utils.esbuild.BuildEntrypointContext = new utils.esbuild.BuildEntrypointContext()\n\n public getOrResolveDefinition<T extends object>(code: string): T {\n const definition = this._codeCache.get(code)\n if (definition) {\n return definition as T\n }\n const result = utils.require.requireJsCode<{ default: object }>(code)\n this._codeCache.set(code, result.default)\n return result.default as T\n }\n\n public rebuildEntrypoint(...args: Parameters<utils.esbuild.BuildEntrypointContext['rebuild']>) {\n return this._buildContext.rebuild(...args)\n }\n}\n\ntype ResolvedDependency = { id: string }\ntype DependencyCacheKey = `${'integration' | 'plugin' | 'interface'}:${string}@${string}`\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected projectContext: ProjectDefinitionContext = new ProjectDefinitionContext()\n private _dependencyCache = new Map<DependencyCacheKey, ResolvedDependency>()\n\n public setProjectContext(projectContext: ProjectDefinitionContext) {\n this.projectContext = projectContext\n return this\n }\n\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n private _readProjectType(projectPaths: ProjectPaths): ProjectType {\n const abs = projectPaths.abs\n if (fs.existsSync(abs.integrationDefinition)) {\n return 'integration'\n }\n if (fs.existsSync(abs.interfaceDefinition)) {\n return 'interface'\n }\n if (fs.existsSync(abs.botDefinition)) {\n return 'bot'\n }\n if (fs.existsSync(abs.pluginDefinition)) {\n return 'plugin'\n }\n throw new errors.UnsupportedProjectType()\n }\n\n protected readProjectDefinitionFromFS(): ProjectDefinitionLazy {\n try {\n const type = this._readProjectType(this.projectPaths)\n if (type === 'integration') {\n return {\n projectType: 'integration',\n resolveProjectDefinition: async () => ({\n type: 'integration',\n ...(await this._readIntegrationDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n if (type === 'plugin') {\n return {\n projectType: 'plugin',\n resolveProjectDefinition: async () => ({\n type: 'plugin',\n ...(await this._readPluginDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n if (type === 'interface') {\n return {\n projectType: 'interface',\n resolveProjectDefinition: async () => ({\n type: 'interface',\n ...(await this._readInterfaceDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n if (type === 'bot') {\n return {\n projectType: 'bot',\n resolveProjectDefinition: async () => ({\n type: 'bot',\n ...(await this._readBotDefinitionFromFS(this.projectPaths)),\n }),\n }\n }\n } catch (thrown: unknown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Error while reading project definition')\n }\n throw new errors.ProjectDefinitionNotFoundError(this.projectPaths.abs.workDir)\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'>\n ): Promise<{ definition: sdk.IntegrationDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.integrationDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.IntegrationDefinition>(artifact.text)\n validateIntegrationDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'>\n ): Promise<{ definition: sdk.InterfaceDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.interfaceDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.InterfaceDefinition>(artifact.text)\n\n return { definition, bpLintDisabled }\n }\n\n private async _readBotDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'botDefinition'>\n ): Promise<{ definition: sdk.BotDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.botDefinition)) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.botDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.BotDefinition>(artifact.text)\n validateBotDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readPluginDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'pluginDefinition'>\n ): Promise<{ definition: sdk.PluginDefinition } & LintIgnoredConfig> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.pluginDefinition)) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition)\n\n const { outputFiles } = await this.projectContext.rebuildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.pluginDefinition,\n })\n\n const artifact = outputFiles?.[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const definition = this.projectContext.getOrResolveDefinition<sdk.PluginDefinition>(artifact.text)\n // TODO: validate plugin definition\n return { definition, bpLintDisabled }\n }\n\n private async _isBpLintDisabled(definitionPath: string): Promise<boolean> {\n const tsContent = await fs.promises.readFile(definitionPath, 'utf-8')\n const regex = /\\/\\* bplint-disable \\*\\//\n return regex.test(tsContent)\n }\n\n protected async displayIntegrationUrls({ api, bot }: { api: apiUtils.ApiClient; bot: client.Bot }) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n const integrationDefinitions = await utils.records.mapValuesAsync(bot.integrations, async (integration) =>\n api.getPublicOrPrivateIntegration({\n type: 'id',\n id: integration.id,\n })\n )\n\n this.logger.log('Integrations:')\n for (const [alias, integration] of Object.entries(bot.integrations)) {\n if (integration.enabled) {\n this.logger.log(`${alias} ${integration.version}:`, { prefix: { symbol: '\u2192', indent: 2 } })\n } else {\n this.logger.log(`${alias} ${integration.version} ${chalk.italic('(disabled)')}:`, {\n prefix: { symbol: '\u2192', indent: 2 },\n })\n }\n\n const integrationDefinition = integrationDefinitions[alias]\n const linkTemplateScript = integrationDefinition\n ? this._getLinkTemplateScript({ integration, integrationDefinition })\n : undefined\n this._displayWebhookUrl({ integration, integrationDefinition, linkTemplateScript })\n if (!integrationDefinition) {\n this.logger.debug(\n `No integration definition for integration ${alias} (${integration.name}, ${integration.id}), skipping OAuth or Sandbox links`\n )\n this.logger.line().commit()\n continue\n }\n const isSandbox =\n integration.configurationType === 'sandbox' && !!integrationDefinition.sandbox?.identifierExtractScript\n const showLink = !!linkTemplateScript && (isSandbox || !!integrationDefinition.identifier?.extractScript)\n if (showLink && isSandbox) {\n await this._displaySandboxLinkAndCode({ integration, alias, bot, api, linkTemplateScript })\n } else if (showLink) {\n this._displayAuthorizationLink({ integration, api, linkTemplateScript })\n }\n this.logger.line().commit()\n }\n }\n\n private _getLinkTemplateScript({\n integration,\n integrationDefinition,\n }: {\n integration: ClientIntegration\n integrationDefinition?: ClientIntegrationDefinitions[string]\n }) {\n const config =\n integration.configurationType === null\n ? integrationDefinition?.configuration\n : integrationDefinition?.configurations[integration.configurationType]\n return config?.identifier?.linkTemplateScript\n }\n\n private _displayWebhookUrl({\n integration,\n integrationDefinition,\n linkTemplateScript,\n }: {\n integration: ClientIntegration\n integrationDefinition?: ClientIntegrationDefinitions[string]\n linkTemplateScript?: string\n }) {\n const needsWebhook = !(integrationDefinition?.identifier && linkTemplateScript)\n const logFn = (needsWebhook ? this.logger.log : this.logger.debug).bind(this.logger)\n\n if (integration.enabled) {\n logFn(`${chalk.bold('Webhook')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 4 },\n })\n } else {\n logFn(`Webhook: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 4 },\n })\n }\n }\n\n private _displayAuthorizationLink({\n integration,\n api,\n linkTemplateScript,\n }: {\n integration: ClientIntegration\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n const authorizationLink = this._getAuthorizationLink({ integration, api, linkTemplateScript })\n const isAuthorized = !!integration.identifier\n const authorizationStatus = integration.identifier ? 'Authorized \u2713' : 'Authorize'\n if (integration.enabled && isAuthorized) {\n this.logger.log(`${chalk.bold(authorizationStatus)} : ${authorizationLink}`, {\n prefix: { symbol: '\u25CF', indent: 4 },\n })\n } else {\n this.logger.log(`${authorizationStatus}: ${authorizationLink}`, {\n prefix: { symbol: '\u25CB', indent: 4 },\n })\n }\n }\n\n private _getLinkTemplateArgs({ integration, api }: { integration: ClientIntegration; api: apiUtils.ApiClient }) {\n // These are the values used by the studio\n let env: 'development' | 'preview' | 'production'\n if (api.url.includes(consts.stagingBotpressDomain)) {\n env = 'preview'\n } else if (api.url.includes(consts.productionBotpressDomain)) {\n env = 'production'\n } else {\n env = 'development'\n }\n return {\n env,\n webhookId: integration.webhookId,\n webhookUrl: api.url.replace('api', 'webhook'),\n }\n }\n\n private _getAuthorizationLink({\n integration,\n api,\n linkTemplateScript,\n }: {\n integration: client.Bot['integrations'][string]\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n return utils.vrl.getStringResult({\n code: linkTemplateScript,\n data: this._getLinkTemplateArgs({ integration, api }),\n })\n }\n\n private _getSandboxLink({\n shareableId,\n integration,\n api,\n linkTemplateScript,\n }: {\n shareableId: string\n integration: ClientIntegration\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n return utils.vrl.getStringResult({\n code: linkTemplateScript,\n data: { shareableId, ...this._getLinkTemplateArgs({ integration, api }) },\n })\n }\n\n private async _displaySandboxLinkAndCode({\n integration,\n alias,\n bot,\n api,\n linkTemplateScript,\n }: {\n integration: ClientIntegration\n alias: string\n bot: client.Bot\n api: apiUtils.ApiClient\n linkTemplateScript: string\n }) {\n const shareableId = await api.getOrGenerateShareableId(bot.id, integration.id, alias)\n const sandboxLink = this._getSandboxLink({ shareableId, integration, api, linkTemplateScript })\n const sandboxInstruction = `Send '${shareableId}' to ${sandboxLink}`\n if (integration.enabled) {\n this.logger.log(`${chalk.bold('Sandbox')}: ${sandboxInstruction}`, {\n prefix: { symbol: '\u25CF', indent: 4 },\n })\n } else {\n this.logger.log(`Sandbox: ${sandboxInstruction}`, {\n prefix: { symbol: '\u25CB', indent: 4 },\n })\n }\n }\n\n protected async promptSecrets(\n def: { secrets?: Record<string, sdk.SecretDefinition> },\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = def\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in the definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n protected async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n const partialBody = await apiUtils.prepareCreateIntegrationBody(integrationDef)\n\n let code: string | undefined = undefined\n if (fs.existsSync(this.projectPaths.abs.outFileCJS)) {\n code = await this.readProjectFile(this.projectPaths.abs.outFileCJS)\n }\n\n const icon = await this.readProjectFile(integrationDef.icon, 'base64')\n const readme = await this.readProjectFile(integrationDef.readme, 'base64')\n const extractScript = await this.readProjectFile(integrationDef.identifier?.extractScript)\n const fallbackHandlerScript = await this.readProjectFile(integrationDef.identifier?.fallbackHandlerScript)\n return {\n ...partialBody,\n code,\n icon,\n readme,\n identifier: {\n extractScript,\n fallbackHandlerScript,\n },\n configuration: integrationDef.configuration\n ? {\n schema: await utils.schema\n .mapZodToJsonSchema(integrationDef.configuration, {\n useLegacyZuiTransformer: integrationDef.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integrationDef.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `Failed to convert ZUI to JSON schema for integration ${integrationDef.name} for configuration`\n )\n }),\n identifier: {\n required: integrationDef.configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(\n integrationDef.configuration.identifier?.linkTemplateScript\n ),\n },\n }\n : undefined,\n configurations: integrationDef.configurations\n ? await utils.records.mapValuesAsync(\n integrationDef.configurations,\n async (configuration, configurationName) => ({\n title: configuration.title,\n description: configuration.description,\n schema: await utils.schema\n .mapZodToJsonSchema(configuration, {\n useLegacyZuiTransformer: integrationDef.__advanced?.useLegacyZuiTransformer,\n toJSONSchemaOptions: integrationDef.__advanced?.toJSONSchemaOptions,\n })\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(\n thrown,\n `Failed to convert ZUI to JSON schema for integration ${integrationDef.name} for configuration ${configurationName}`\n )\n }),\n identifier: {\n required: configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(configuration.identifier?.linkTemplateScript),\n },\n })\n )\n : undefined,\n }\n }\n\n protected async prepareBotDependencies(\n botDef: sdk.BotDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.UpdateBotRequestBody>> {\n const integrations = await this._fetchDependencies({\n deps: botDef.integrations ?? {},\n fetcher: ({ name, version }) => api.getPublicOrPrivateIntegration({ type: 'name', name, version }),\n cacheKey: ({ name, version }) => `integration:${name}@${version}`,\n })\n\n const plugins = await this._fetchDependencies({\n deps: botDef.plugins ?? {},\n fetcher: async ({ name, version }) => await api.getPublicOrPrivatePlugin({ type: 'name', name, version }),\n cacheKey: ({ name, version }) => `plugin:${name}@${version}`,\n })\n\n const pluginsWithBackingIntegrations = await utils.records.mapValuesAsync(plugins, async (plugin) => ({\n ...plugin,\n interfaces: await this._fetchDependencies({\n deps: plugin.interfaces ?? {},\n fetcher: async ({ name, version }) => await api.getPublicOrPrivateIntegration({ name, version, type: 'name' }),\n cacheKey: ({ name, version }) => `interface:${name}@${version}`,\n }),\n integrations: await this._fetchDependencies({\n deps: plugin.integrations ?? {},\n fetcher: async ({ name, version }) => await api.getPublicOrPrivateIntegration({ name, version, type: 'name' }),\n cacheKey: ({ name, version }) => `integration:${name}@${version}`,\n }),\n }))\n\n return {\n integrations: utils.records.mapValues(\n integrations,\n ({ enabled, configurationType, configuration, disabledChannels, id }) =>\n ({\n enabled,\n configurationType,\n configuration,\n disabledChannels,\n integrationId: id,\n }) satisfies NonNullable<apiUtils.UpdateBotRequestBody['integrations']>[string]\n ),\n plugins: utils.records.mapValues(pluginsWithBackingIntegrations, (plugin) => ({\n ...plugin,\n interfaces: utils.records.mapValues(\n plugin.interfaces ?? {},\n (iface) =>\n ({\n integrationId: iface.id,\n integrationAlias: iface.integrationAlias,\n integrationInterfaceAlias: iface.integrationInterfaceAlias,\n }) satisfies NonNullable<\n NonNullable<NonNullable<apiUtils.UpdateBotRequestBody['plugins']>[string]>['interfaces']\n >[string]\n ),\n integrations: utils.records.mapValues(\n plugin.integrations ?? {},\n (integration) =>\n ({\n integrationId: integration.id,\n integrationAlias: integration.integrationAlias,\n }) satisfies NonNullable<\n NonNullable<NonNullable<apiUtils.UpdateBotRequestBody['plugins']>[string]>['integrations']\n >[string]\n ),\n })),\n }\n }\n\n protected async prepareIntegrationDependencies(\n integrationDef: sdk.IntegrationDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreateIntegrationRequestBody>> {\n const interfaces = await this._fetchDependencies({\n deps: integrationDef.interfaces ?? {},\n fetcher: ({ name, version }) => api.getPublicInterface({ type: 'name', name, version }),\n cacheKey: (dep) => `interface:${dep.name}@${dep.version}`,\n })\n return { interfaces }\n }\n\n protected async preparePluginDependencies(\n pluginDef: sdk.PluginDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreatePluginRequestBody>> {\n const integrations = await this._fetchDependencies({\n deps: pluginDef.integrations ?? {},\n fetcher: ({ name, version }) => api.getPublicOrPrivateIntegration({ type: 'name', name, version }),\n cacheKey: (dep) => `integration:${dep.name}@${dep.version}`,\n })\n const interfaces = await this._fetchDependencies({\n deps: pluginDef.interfaces ?? {},\n fetcher: ({ name, version }) => api.getPublicInterface({ type: 'name', name, version }),\n cacheKey: (dep) => `interface:${dep.name}@${dep.version}`,\n })\n return {\n dependencies: {\n integrations,\n interfaces,\n },\n }\n }\n\n private _fetchDependencies = async <T extends { id?: string; name: string; version: string }>({\n deps,\n fetcher,\n cacheKey: getCacheKey,\n }: {\n deps: Record<string, T>\n fetcher: (dep: T) => Promise<ResolvedDependency>\n cacheKey: (dep: T) => DependencyCacheKey\n }): Promise<Record<string, T & ResolvedDependency>> => {\n const isRemote = (dep: T): dep is T & ResolvedDependency => dep.id !== undefined\n return utils.records.mapValuesAsync(deps, async (dep): Promise<T & ResolvedDependency> => {\n if (isRemote(dep)) {\n return dep\n }\n\n const cacheKey = getCacheKey(dep)\n const cached = this._dependencyCache.get(cacheKey)\n\n if (cached) {\n return { ...dep, id: cached.id }\n }\n\n const { id } = await fetcher(dep)\n this._dependencyCache.set(cacheKey, { id })\n\n return { ...dep, id }\n })\n }\n\n protected readProjectFile = async (\n filePath: string | undefined,\n encoding: BufferEncoding = 'utf-8'\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, encoding).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const readProjectPkgJsonResult = await utils.pkgJson.safeReadPackageJson(workDir)\n if (!readProjectPkgJsonResult.success) {\n this.logger.debug(`Could not read package.json at \"${workDir}\": ${readProjectPkgJsonResult.error.message}`)\n return\n }\n\n if (!readProjectPkgJsonResult.pkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const { pkgJson: projectPkgJson } = readProjectPkgJsonResult\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readCLIPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sdk is up to date: ${err.message}`)\n }\n }\n protected validateIntegrationRegistration(\n updatedBot: UpdatedBot,\n onFailCallback: (failedIntegrations: UpdatedBot['integrations']) => void\n ) {\n let failedIntegrations: UpdatedBot['integrations'] = {}\n for (const [integrationName, integration] of Object.entries(updatedBot.integrations)) {\n if (integration.status === 'registration_failed') {\n failedIntegrations = { ...failedIntegrations, [integrationName]: integration }\n }\n }\n if (Object.keys(failedIntegrations).length > 0) {\n onFailCallback(failedIntegrations)\n }\n }\n\n protected async manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<\n | {\n integration: sdk.IntegrationDefinition\n workspaceId?: string\n }\n | undefined\n > {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n this.logger.log('Aborted')\n return\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n protected _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AAErB,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,oBAAmB;AACnB,eAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,iBAAqE;AAErE,YAAuB;AACvB,4BAA8B;AAuD9B,MAAM,qBAAqB,MAAM,KAAK,UAAiC;AAAA,EAC9D,YAAY,MAA6C;AAC9D,UAAM,aAAa,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AACzE,UAAM;AAAA,MACJ,SAAS;AAAA,MACT,GAAG,cAAAA,QAAE,UAAU,OAAO,aAAa,CAAC,MAAM,MAAM,KAAK,aAAa,YAAY,CAAC,CAAC;AAAA,IAClF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,yBAAyB;AAAA,EAC5B,aAAkC,oBAAI,IAAI;AAAA,EAC1C,gBAAsD,IAAI,MAAM,QAAQ,uBAAuB;AAAA,EAEhG,uBAAyC,MAAiB;AAC/D,UAAM,aAAa,KAAK,WAAW,IAAI,IAAI;AAC3C,QAAI,YAAY;A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,GAAG,aAAa,MAAM,QAAQ,CAAC,EAAE;AAAA,EACzF;AAAA,EAEU,wBAAwB,CAAC,oBAAwE;AACzG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B,eAAe;AAAA,MAC9C;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": ["_", "fs", "chalk", "config", "semver", "newName", "name"]
|
|
7
7
|
}
|
package/dist/register-yargs.js
CHANGED
|
@@ -44,7 +44,7 @@ const registerYargs = (yargz, commands) => {
|
|
|
44
44
|
if (tree.guards.command.isSubTree(command)) {
|
|
45
45
|
yargz.command(cmdName, command.description ?? cmdName, (y) => {
|
|
46
46
|
registerYargs(y, command.subcommands);
|
|
47
|
-
return y;
|
|
47
|
+
return y.demandCommand(1);
|
|
48
48
|
});
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/register-yargs.ts"],
|
|
4
|
-
"sourcesContent": ["import yargs, { YargsArgv, YargsConfig, cleanupConfig, parseEnv } from '@bpinternal/yargs-extra'\nimport _ from 'lodash'\nimport * as tree from './command-tree'\nimport type * as typings from './typings'\n\nexport type YargsInstance = typeof yargs\n\nconst parseArguments = <S extends typings.CommandSchema>(schema: S, argv: YargsArgv<S>): YargsConfig<S> => {\n const yargsEnv = parseEnv(schema, 'BP')\n return cleanupConfig(schema, { ...argv, ...yargsEnv })\n}\n\nexport const registerYargs = (yargz: YargsInstance, commands: tree.CommandTree) => {\n for (const cmdName in commands) {\n const command = commands[cmdName] as tree.CommandTreeNode\n\n if (tree.guards.command.isSubTree(command)) {\n yargz.command(cmdName, command.description ?? cmdName, (y) => {\n registerYargs(y, command.subcommands)\n return y\n })\n continue\n }\n\n const { schema, description, alias } = command\n let aliases: string[]\n if (Array.isArray(alias)) {\n aliases = [cmdName, ...alias]\n } else if (alias) {\n aliases = [cmdName, alias]\n } else {\n aliases = [cmdName]\n }\n\n const options = Object.entries(schema)\n let positionals = options.filter(\n (value): value is [string, typings.CommandPositionalOption] => !!value[1].positional\n )\n\n let usage = aliases\n if (positionals.length) {\n positionals = _.sortBy(positionals, ([, option]) => option.idx)\n const positionalArgs = positionals.map(([optName, option]) =>\n option.demandOption ? `<${optName}>` : `[${optName}]`\n )\n const positionalStr = positionalArgs.join(' ')\n usage = aliases.map((optAlias) => `${optAlias} ${positionalStr}`)\n }\n\n yargz.command(\n usage,\n description ?? cmdName,\n (y) => {\n for (const [key, option] of Object.entries(schema)) {\n if (option.positional) {\n y = y.positional(key, option)\n } else {\n y = y.option(key, option)\n }\n }\n return y\n },\n async (argv) => {\n const parsed = parseArguments(schema, argv)\n const { exitCode } = await command.handler({ ...parsed })\n process.exit(exitCode)\n }\n )\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuE;AACvE,oBAAc;AACd,WAAsB;AAKtB,MAAM,iBAAiB,CAAkC,QAAW,SAAuC;AACzG,QAAM,eAAW,6BAAS,QAAQ,IAAI;AACtC,aAAO,kCAAc,QAAQ,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;AACvD;AAEO,MAAM,gBAAgB,CAAC,OAAsB,aAA+B;AACjF,aAAW,WAAW,UAAU;AAC9B,UAAM,UAAU,SAAS,OAAO;AAEhC,QAAI,KAAK,OAAO,QAAQ,UAAU,OAAO,GAAG;AAC1C,YAAM,QAAQ,SAAS,QAAQ,eAAe,SAAS,CAAC,MAAM;AAC5D,sBAAc,GAAG,QAAQ,WAAW;AACpC,eAAO;AAAA,
|
|
4
|
+
"sourcesContent": ["import yargs, { YargsArgv, YargsConfig, cleanupConfig, parseEnv } from '@bpinternal/yargs-extra'\nimport _ from 'lodash'\nimport * as tree from './command-tree'\nimport type * as typings from './typings'\n\nexport type YargsInstance = typeof yargs\n\nconst parseArguments = <S extends typings.CommandSchema>(schema: S, argv: YargsArgv<S>): YargsConfig<S> => {\n const yargsEnv = parseEnv(schema, 'BP')\n return cleanupConfig(schema, { ...argv, ...yargsEnv })\n}\n\nexport const registerYargs = (yargz: YargsInstance, commands: tree.CommandTree) => {\n for (const cmdName in commands) {\n const command = commands[cmdName] as tree.CommandTreeNode\n\n if (tree.guards.command.isSubTree(command)) {\n yargz.command(cmdName, command.description ?? cmdName, (y) => {\n registerYargs(y, command.subcommands)\n return y.demandCommand(1)\n })\n continue\n }\n\n const { schema, description, alias } = command\n let aliases: string[]\n if (Array.isArray(alias)) {\n aliases = [cmdName, ...alias]\n } else if (alias) {\n aliases = [cmdName, alias]\n } else {\n aliases = [cmdName]\n }\n\n const options = Object.entries(schema)\n let positionals = options.filter(\n (value): value is [string, typings.CommandPositionalOption] => !!value[1].positional\n )\n\n let usage = aliases\n if (positionals.length) {\n positionals = _.sortBy(positionals, ([, option]) => option.idx)\n const positionalArgs = positionals.map(([optName, option]) =>\n option.demandOption ? `<${optName}>` : `[${optName}]`\n )\n const positionalStr = positionalArgs.join(' ')\n usage = aliases.map((optAlias) => `${optAlias} ${positionalStr}`)\n }\n\n yargz.command(\n usage,\n description ?? cmdName,\n (y) => {\n for (const [key, option] of Object.entries(schema)) {\n if (option.positional) {\n y = y.positional(key, option)\n } else {\n y = y.option(key, option)\n }\n }\n return y\n },\n async (argv) => {\n const parsed = parseArguments(schema, argv)\n const { exitCode } = await command.handler({ ...parsed })\n process.exit(exitCode)\n }\n )\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AA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