@botpress/cli 0.8.66 ā 0.9.0
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 +8 -8
- package/dist/api/integration-body.js +10 -1
- package/dist/api/integration-body.js.map +2 -2
- package/dist/code-generation/integration-implementation.js +30 -11
- package/dist/code-generation/integration-implementation.js.map +2 -2
- package/dist/code-generation/integration-instance.js +48 -14
- package/dist/code-generation/integration-instance.js.map +2 -2
- package/dist/code-generation/integration-schemas/configuration-module.js +9 -6
- package/dist/code-generation/integration-schemas/configuration-module.js.map +2 -2
- package/dist/code-generation/integration-schemas/configurations-module.js +72 -0
- package/dist/code-generation/integration-schemas/configurations-module.js.map +7 -0
- package/dist/code-generation/map-integration.js +3 -2
- package/dist/code-generation/map-integration.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-implementations/deploy-command.js +19 -8
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/project-command.js +5 -1
- package/dist/command-implementations/project-command.js.map +2 -2
- package/package.json +2 -2
- package/templates/echo-bot/package.json +1 -1
- package/templates/empty-integration/.botpress/implementation/configurations/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +3 -0
- package/templates/empty-integration/package.json +1 -1
- package/templates/hello-world/.botpress/implementation/configurations/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/index.ts +3 -0
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/.botpress/implementation/configurations/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/index.ts +3 -0
- package/templates/webhook-message/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@0.
|
|
2
|
+
> @botpress/cli@0.9.0 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@0.
|
|
6
|
+
> @botpress/cli@0.9.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@0.
|
|
10
|
+
> @botpress/cli@0.9.0 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
š¤ Botpress CLI v0.
|
|
14
|
-
š¤ Botpress CLI v0.
|
|
15
|
-
š¤ Botpress CLI v0.
|
|
16
|
-
š¤ Botpress CLI v0.
|
|
13
|
+
š¤ Botpress CLI v0.9.0
|
|
14
|
+
š¤ Botpress CLI v0.9.0
|
|
15
|
+
š¤ Botpress CLI v0.9.0
|
|
16
|
+
š¤ Botpress CLI v0.9.0
|
|
17
17
|
ā No typings to generate for bot projects
|
|
18
|
-
[2K[1Gā Generating typings for integration
|
|
18
|
+
[2K[1Gā Generating typings for integration hello-world...[2K[1Gā Generating typings for integration empty-integration...[2K[1Gā Generating typings for integration webhook-message...[2K[1Gā Typings available at .botpress
|
|
19
19
|
[2K[1Gā Typings available at .botpress
|
|
20
20
|
[2K[1Gā Typings available at .botpress
|
|
@@ -44,6 +44,10 @@ const prepareCreateIntegrationBody = (integration) => ({
|
|
|
44
44
|
...integration.configuration,
|
|
45
45
|
schema: utils.schema.mapZodToJsonSchema(integration.configuration)
|
|
46
46
|
} : void 0,
|
|
47
|
+
configurations: integration.configurations ? utils.records.mapValues(integration.configurations, (configuration) => ({
|
|
48
|
+
...configuration,
|
|
49
|
+
schema: utils.schema.mapZodToJsonSchema(configuration)
|
|
50
|
+
})) : void 0,
|
|
47
51
|
events: integration.events ? utils.records.mapValues(integration.events, (event) => ({
|
|
48
52
|
...event,
|
|
49
53
|
schema: utils.schema.mapZodToJsonSchema(event)
|
|
@@ -86,6 +90,10 @@ const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
|
|
|
86
90
|
};
|
|
87
91
|
const channels = prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels);
|
|
88
92
|
const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces);
|
|
93
|
+
const configurations = utils.records.setNullOnMissingValues(
|
|
94
|
+
localIntegration.configurations,
|
|
95
|
+
remoteIntegration.configurations
|
|
96
|
+
);
|
|
89
97
|
return {
|
|
90
98
|
...localIntegration,
|
|
91
99
|
actions,
|
|
@@ -94,7 +102,8 @@ const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
|
|
|
94
102
|
entities,
|
|
95
103
|
user,
|
|
96
104
|
channels,
|
|
97
|
-
interfaces
|
|
105
|
+
interfaces,
|
|
106
|
+
configurations
|
|
98
107
|
};
|
|
99
108
|
};
|
|
100
109
|
const prepareUpdateIntegrationChannelsBody = (localChannels, remoteChannels) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/integration-body.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Client, Integration } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateIntegrationBody = Parameters<Client['createIntegration']>[0]\nexport type UpdateIntegrationBody = Parameters<Client['updateIntegration']>[0]\n\ntype UpdateIntegrationChannelsBody = NonNullable<UpdateIntegrationBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\n\ntype Channels = Integration['channels']\ntype Channel = Integration['channels'][string]\n\nexport const prepareCreateIntegrationBody = (integration: sdk.IntegrationDefinition): CreateIntegrationBody => ({\n name: integration.name,\n version: integration.version,\n title: integration.title,\n description: integration.description,\n icon: integration.icon,\n readme: integration.readme,\n user: integration.user,\n identifier: integration.identifier,\n secrets: undefined,\n interfaces: {},\n configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: utils.schema.mapZodToJsonSchema(integration.configuration),\n }\n : undefined,\n events: integration.events\n ? utils.records.mapValues(integration.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: integration.actions\n ? utils.records.mapValues(integration.actions, (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n channels: integration.channels\n ? utils.records.mapValues(integration.channels, (channel) => ({\n ...channel,\n messages: utils.records.mapValues(channel.messages, (message) => ({\n ...message,\n schema: utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : undefined,\n states: integration.states\n ? utils.records.mapValues(integration.states, (state) => ({\n ...state,\n schema: utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n entities: integration.entities\n ? utils.records.mapValues(integration.entities, (entity) => ({\n ...entity,\n schema: utils.schema.mapZodToJsonSchema(entity),\n }))\n : undefined,\n})\n\nexport const prepareUpdateIntegrationBody = (\n localIntegration: UpdateIntegrationBody,\n remoteIntegration: Integration\n): UpdateIntegrationBody => {\n const actions = utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions)\n const events = utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events)\n const states = utils.records.setNullOnMissingValues(localIntegration.states, remoteIntegration.states)\n const entities = utils.records.setNullOnMissingValues(localIntegration.entities, remoteIntegration.entities)\n const user = {\n ...localIntegration.user,\n tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags),\n }\n\n const channels = prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels)\n\n const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces)\n\n return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n }\n}\n\nconst prepareUpdateIntegrationChannelsBody = (\n localChannels: UpdateIntegrationChannelsBody,\n remoteChannels: Channels\n): UpdateIntegrationChannelsBody => {\n const channelBody: UpdateIntegrationChannelsBody = {}\n\n const zipped = utils.records.zipObjects(localChannels, remoteChannels)\n for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {\n if (localChannel && remoteChannel) {\n // channel has to be updated\n channelBody[channelName] = prepareUpdateIntegrationChannelBody(localChannel, remoteChannel)\n } else if (localChannel) {\n // channel has to be created\n channelBody[channelName] = localChannel\n continue\n } else if (remoteChannel) {\n // channel has to be deleted\n channelBody[channelName] = null\n continue\n }\n }\n\n return channelBody\n}\n\nconst prepareUpdateIntegrationChannelBody = (\n localChannel: UpdateIntegrationChannelBody,\n remoteChannel: Channel\n): UpdateIntegrationChannelBody => ({\n ...localChannel,\n messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),\n message: {\n ...localChannel?.message,\n tags: utils.records.setNullOnMissingValues(localChannel?.message?.tags, remoteChannel.message.tags),\n },\n conversation: {\n ...localChannel?.conversation,\n tags: utils.records.setNullOnMissingValues(localChannel?.conversation?.tags, remoteChannel.conversation.tags),\n },\n})\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAWhB,MAAM,+BAA+B,CAAC,iBAAmE;AAAA,EAC9G,MAAM,YAAY;AAAA,EAClB,SAAS,YAAY;AAAA,EACrB,OAAO,YAAY;AAAA,EACnB,aAAa,YAAY;AAAA,EACzB,MAAM,YAAY;AAAA,EAClB,QAAQ,YAAY;AAAA,EACpB,MAAM,YAAY;AAAA,EAClB,YAAY,YAAY;AAAA,EACxB,SAAS;AAAA,EACT,YAAY,CAAC;AAAA,EACb,eAAe,YAAY,gBACvB;AAAA,IACE,GAAG,YAAY;AAAA,IACf,QAAQ,MAAM,OAAO,mBAAmB,YAAY,aAAa;AAAA,EACnE,IACA;AAAA,EACJ,QAAQ,YAAY,SAChB,MAAM,QAAQ,UAAU,YAAY,QAAQ,CAAC,WAA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cAAc,aAAa,IAAI;AAAA,EAC9G;AACF;",
|
|
4
|
+
"sourcesContent": ["import type { Client, Integration } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateIntegrationBody = Parameters<Client['createIntegration']>[0]\nexport type UpdateIntegrationBody = Parameters<Client['updateIntegration']>[0]\n\ntype UpdateIntegrationChannelsBody = NonNullable<UpdateIntegrationBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\n\ntype Channels = Integration['channels']\ntype Channel = Integration['channels'][string]\n\nexport const prepareCreateIntegrationBody = (integration: sdk.IntegrationDefinition): CreateIntegrationBody => ({\n name: integration.name,\n version: integration.version,\n title: integration.title,\n description: integration.description,\n icon: integration.icon,\n readme: integration.readme,\n user: integration.user,\n identifier: integration.identifier,\n secrets: undefined,\n interfaces: {},\n configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: utils.schema.mapZodToJsonSchema(integration.configuration),\n }\n : undefined,\n configurations: integration.configurations\n ? utils.records.mapValues(integration.configurations, (configuration) => ({\n ...configuration,\n schema: utils.schema.mapZodToJsonSchema(configuration),\n }))\n : undefined,\n events: integration.events\n ? utils.records.mapValues(integration.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: integration.actions\n ? utils.records.mapValues(integration.actions, (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n channels: integration.channels\n ? utils.records.mapValues(integration.channels, (channel) => ({\n ...channel,\n messages: utils.records.mapValues(channel.messages, (message) => ({\n ...message,\n schema: utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : undefined,\n states: integration.states\n ? utils.records.mapValues(integration.states, (state) => ({\n ...state,\n schema: utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n entities: integration.entities\n ? utils.records.mapValues(integration.entities, (entity) => ({\n ...entity,\n schema: utils.schema.mapZodToJsonSchema(entity),\n }))\n : undefined,\n})\n\nexport const prepareUpdateIntegrationBody = (\n localIntegration: UpdateIntegrationBody,\n remoteIntegration: Integration\n): UpdateIntegrationBody => {\n const actions = utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions)\n const events = utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events)\n const states = utils.records.setNullOnMissingValues(localIntegration.states, remoteIntegration.states)\n const entities = utils.records.setNullOnMissingValues(localIntegration.entities, remoteIntegration.entities)\n const user = {\n ...localIntegration.user,\n tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags),\n }\n\n const channels = prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels)\n\n const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces)\n\n const configurations = utils.records.setNullOnMissingValues(\n localIntegration.configurations,\n remoteIntegration.configurations\n )\n\n return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n }\n}\n\nconst prepareUpdateIntegrationChannelsBody = (\n localChannels: UpdateIntegrationChannelsBody,\n remoteChannels: Channels\n): UpdateIntegrationChannelsBody => {\n const channelBody: UpdateIntegrationChannelsBody = {}\n\n const zipped = utils.records.zipObjects(localChannels, remoteChannels)\n for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {\n if (localChannel && remoteChannel) {\n // channel has to be updated\n channelBody[channelName] = prepareUpdateIntegrationChannelBody(localChannel, remoteChannel)\n } else if (localChannel) {\n // channel has to be created\n channelBody[channelName] = localChannel\n continue\n } else if (remoteChannel) {\n // channel has to be deleted\n channelBody[channelName] = null\n continue\n }\n }\n\n return channelBody\n}\n\nconst prepareUpdateIntegrationChannelBody = (\n localChannel: UpdateIntegrationChannelBody,\n remoteChannel: Channel\n): UpdateIntegrationChannelBody => ({\n ...localChannel,\n messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),\n message: {\n ...localChannel?.message,\n tags: utils.records.setNullOnMissingValues(localChannel?.message?.tags, remoteChannel.message.tags),\n },\n conversation: {\n ...localChannel?.conversation,\n tags: utils.records.setNullOnMissingValues(localChannel?.conversation?.tags, remoteChannel.conversation.tags),\n },\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAWhB,MAAM,+BAA+B,CAAC,iBAAmE;AAAA,EAC9G,MAAM,YAAY;AAAA,EAClB,SAAS,YAAY;AAAA,EACrB,OAAO,YAAY;AAAA,EACnB,aAAa,YAAY;AAAA,EACzB,MAAM,YAAY;AAAA,EAClB,QAAQ,YAAY;AAAA,EACpB,MAAM,YAAY;AAAA,EAClB,YAAY,YAAY;AAAA,EACxB,SAAS;AAAA,EACT,YAAY,CAAC;AAAA,EACb,eAAe,YAAY,gBACvB;AAAA,IACE,GAAG,YAAY;AAAA,IACf,QAAQ,MAAM,OAAO,mBAAmB,YAAY,aAAa;AAAA,EACnE,IACA;AAAA,EACJ,gBAAgB,YAAY,iBACxB,MAAM,QAAQ,UAAU,YAAY,gBAAgB,CAAC,mBAAmB;AAAA,IACtE,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,aAAa;AAAA,EACvD,EAAE,IACF;AAAA,EACJ,QAAQ,YAAY,SAChB,MAAM,QAAQ,UAAU,YAAY,QAAQ,CAAC,WAAW;AAAA,IACtD,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,KAAK;AAAA,EAC/C,EAAE,IACF;AAAA,EACJ,SAAS,YAAY,UACjB,MAAM,QAAQ,UAAU,YAAY,SAAS,CAAC,YAAY;AAAA,IACxD,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,OAAO,mBAAmB,OAAO,KAAK;AAAA,IACtD;A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;AAEjH,QAAM,aAAa,MAAM,QAAQ,uBAAuB,iBAAiB,YAAY,kBAAkB,UAAU;AAEjH,QAAM,iBAAiB,MAAM,QAAQ;AAAA,IACnC,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,EACpB;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,uCAAuC,CAC3C,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,eAAe,oCAAoC,cAAc,aAAa;AAAA,IAC5F,WAAW,cAAc;AAEvB,kBAAY,eAAe;AAC3B;AAAA,IACF,WAAW,eAAe;AAExB,kBAAY,eAAe;AAC3B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,MAAM,sCAAsC,CAC1C,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
|
}
|
|
@@ -26,15 +26,17 @@ var import_generators = require("./generators");
|
|
|
26
26
|
var import_actions_module = require("./integration-schemas/actions-module");
|
|
27
27
|
var import_channels_module = require("./integration-schemas/channels-module");
|
|
28
28
|
var import_configuration_module = require("./integration-schemas/configuration-module");
|
|
29
|
+
var import_configurations_module = require("./integration-schemas/configurations-module");
|
|
29
30
|
var import_entities_module = require("./integration-schemas/entities-module");
|
|
30
31
|
var import_events_module = require("./integration-schemas/events-module");
|
|
31
32
|
var import_states_module = require("./integration-schemas/states-module");
|
|
32
33
|
var import_module = require("./module");
|
|
33
34
|
class IntegrationImplementationIndexModule extends import_module.Module {
|
|
34
|
-
constructor(integration,
|
|
35
|
+
constructor(integration, defaultConfigModule, configurationsModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, def) {
|
|
35
36
|
super(def);
|
|
36
37
|
this.integration = integration;
|
|
37
|
-
this.
|
|
38
|
+
this.defaultConfigModule = defaultConfigModule;
|
|
39
|
+
this.configurationsModule = configurationsModule;
|
|
38
40
|
this.actionsModule = actionsModule;
|
|
39
41
|
this.channelsModule = channelsModule;
|
|
40
42
|
this.eventsModule = eventsModule;
|
|
@@ -42,8 +44,10 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
42
44
|
this.entitiesModule = entitiesModule;
|
|
43
45
|
}
|
|
44
46
|
static async create(integration) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
+
const defaultConfigModule = await import_configuration_module.DefaultConfigurationModule.create(integration.configuration ?? { schema: {} });
|
|
48
|
+
defaultConfigModule.unshift("configuration");
|
|
49
|
+
const configurationsModule = await import_configurations_module.ConfigurationsModule.create(integration.configurations ?? {});
|
|
50
|
+
configurationsModule.unshift("configurations");
|
|
47
51
|
const actionsModule = await import_actions_module.ActionsModule.create(integration.actions ?? {});
|
|
48
52
|
actionsModule.unshift("actions");
|
|
49
53
|
const channelsModule = await import_channels_module.ChannelsModule.create(integration.channels ?? {});
|
|
@@ -56,7 +60,8 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
56
60
|
entitiesModule.unshift("entities");
|
|
57
61
|
const inst = new IntegrationImplementationIndexModule(
|
|
58
62
|
integration,
|
|
59
|
-
|
|
63
|
+
defaultConfigModule,
|
|
64
|
+
configurationsModule,
|
|
60
65
|
actionsModule,
|
|
61
66
|
channelsModule,
|
|
62
67
|
eventsModule,
|
|
@@ -68,7 +73,8 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
68
73
|
content: ""
|
|
69
74
|
}
|
|
70
75
|
);
|
|
71
|
-
inst.pushDep(
|
|
76
|
+
inst.pushDep(defaultConfigModule);
|
|
77
|
+
inst.pushDep(configurationsModule);
|
|
72
78
|
inst.pushDep(actionsModule);
|
|
73
79
|
inst.pushDep(channelsModule);
|
|
74
80
|
inst.pushDep(eventsModule);
|
|
@@ -78,8 +84,18 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
78
84
|
}
|
|
79
85
|
get content() {
|
|
80
86
|
let content = import_const.GENERATED_HEADER;
|
|
81
|
-
const {
|
|
82
|
-
|
|
87
|
+
const {
|
|
88
|
+
defaultConfigModule,
|
|
89
|
+
configurationsModule,
|
|
90
|
+
actionsModule,
|
|
91
|
+
channelsModule,
|
|
92
|
+
eventsModule,
|
|
93
|
+
statesModule,
|
|
94
|
+
entitiesModule,
|
|
95
|
+
integration
|
|
96
|
+
} = this;
|
|
97
|
+
const defaultConfigImport = defaultConfigModule.import(this);
|
|
98
|
+
const configurationsImport = configurationsModule.import(this);
|
|
83
99
|
const actionsImport = actionsModule.import(this);
|
|
84
100
|
const channelsImport = channelsModule.import(this);
|
|
85
101
|
const eventsImport = eventsModule.import(this);
|
|
@@ -89,13 +105,15 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
89
105
|
import_const.GENERATED_HEADER,
|
|
90
106
|
'import * as sdk from "@botpress/sdk"',
|
|
91
107
|
"",
|
|
92
|
-
`import type * as ${
|
|
108
|
+
`import type * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
|
|
109
|
+
`import type * as ${configurationsModule.name} from "./${configurationsImport}"`,
|
|
93
110
|
`import type * as ${actionsModule.name} from "./${actionsImport}"`,
|
|
94
111
|
`import type * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
95
112
|
`import type * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
96
113
|
`import type * as ${statesModule.name} from "./${statesImport}"`,
|
|
97
114
|
`import type * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
98
|
-
`export * as ${
|
|
115
|
+
`export * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
|
|
116
|
+
`export * as ${configurationsModule.name} from "./${configurationsImport}"`,
|
|
99
117
|
`export * as ${actionsModule.name} from "./${actionsImport}"`,
|
|
100
118
|
`export * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
101
119
|
`export * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
@@ -110,7 +128,8 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
110
128
|
"type TIntegration = {",
|
|
111
129
|
` name: "${integration.name}"`,
|
|
112
130
|
` version: "${integration.version}"`,
|
|
113
|
-
` configuration: ${
|
|
131
|
+
` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exports}`,
|
|
132
|
+
` configurations: ${configurationsModule.name}.${configurationsModule.exports}`,
|
|
114
133
|
` actions: ${actionsModule.name}.${actionsModule.exports}`,
|
|
115
134
|
` channels: ${channelsModule.name}.${channelsModule.exports}`,
|
|
116
135
|
` events: ${eventsModule.name}.${eventsModule.exports}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/integration-implementation.ts"],
|
|
4
|
-
"sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,
|
|
4
|
+
"sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { DefaultConfigurationModule } from './integration-schemas/configuration-module'\nimport { ConfigurationsModule } from './integration-schemas/configurations-module'\nimport { EntitiesModule } from './integration-schemas/entities-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const defaultConfigModule = await DefaultConfigurationModule.create(integration.configuration ?? { schema: {} })\n defaultConfigModule.unshift('configuration')\n\n const configurationsModule = await ConfigurationsModule.create(integration.configurations ?? {})\n configurationsModule.unshift('configurations')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const entitiesModule = await EntitiesModule.create(integration.entities ?? {})\n entitiesModule.unshift('entities')\n\n const inst = new IntegrationImplementationIndexModule(\n integration,\n defaultConfigModule,\n configurationsModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n entitiesModule,\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(defaultConfigModule)\n inst.pushDep(configurationsModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n inst.pushDep(entitiesModule)\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private defaultConfigModule: DefaultConfigurationModule,\n private configurationsModule: ConfigurationsModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n private entitiesModule: EntitiesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const {\n defaultConfigModule,\n configurationsModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n entitiesModule,\n integration,\n } = this\n\n const defaultConfigImport = defaultConfigModule.import(this)\n const configurationsImport = configurationsModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const entitiesImport = entitiesModule.import(this)\n\n content += [\n GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import type * as ${defaultConfigModule.name} from \"./${defaultConfigImport}\"`,\n `import type * as ${configurationsModule.name} from \"./${configurationsImport}\"`,\n `import type * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import type * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import type * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import type * as ${statesModule.name} from \"./${statesImport}\"`,\n `import type * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n `export * as ${defaultConfigModule.name} from \"./${defaultConfigImport}\"`,\n `export * as ${configurationsModule.name} from \"./${configurationsImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${statesModule.name} from \"./${statesImport}\"`,\n `export * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n '',\n '// type utils',\n 'type Cast<X, Y> = X extends Y ? X : Y',\n 'type ValueOf<T> = T[keyof T]',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n 'type TIntegration = {',\n ` name: \"${integration.name}\"`,\n ` version: \"${integration.version}\"`,\n ` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exports}`,\n ` configurations: ${configurationsModule.name}.${configurationsModule.exports}`,\n ` actions: ${actionsModule.name}.${actionsModule.exports}`,\n ` channels: ${channelsModule.name}.${channelsModule.exports}`,\n ` events: ${eventsModule.name}.${eventsModule.exports}`,\n ` states: ${statesModule.name}.${statesModule.exports}`,\n ` user: ${stringifySingleLine(integration.user)}`,\n ` entities: ${entitiesModule.name}.${entitiesModule.exports}`,\n '}',\n '',\n 'export type IntegrationProps = sdk.IntegrationProps<TIntegration>',\n '',\n 'export class Integration extends sdk.Integration<TIntegration> {}',\n '',\n 'export type Client = sdk.IntegrationSpecificClient<TIntegration>',\n '',\n '// extra types',\n '',\n \"export type HandlerProps = Parameters<IntegrationProps['handler']>[0]\",\n '',\n 'export type ActionProps = {',\n \" [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]\",\n '}',\n 'export type AnyActionProps = ValueOf<ActionProps>',\n '',\n 'export type MessageProps = {',\n \" [TChannel in keyof IntegrationProps['channels']]: {\",\n \" [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<\",\n \" IntegrationProps['channels'][TChannel]['messages'][TMessage]\",\n ' >[0]',\n ' }',\n '}',\n 'export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>',\n '',\n \"export type Context = HandlerProps['ctx']\",\n \"export type Logger = HandlerProps['logger']\",\n '',\n 'export type AckFunctions = {',\n ' [TChannel in keyof MessageProps]: {',\n \" [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']\",\n ' }',\n '}',\n 'export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>',\n '',\n 'export type ClientOperation = ValueOf<{',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K',\n '}>',\n 'export type ClientRequests = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientResponses = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>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AAa,gBAAgB;AAAA,MAC5C,eAAe,eAAe,gBAAgB;AAAA,MAC9C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY,YAAY;AAAA,MACxB,eAAe,YAAY;AAAA,MAC3B,oBAAoB,oBAAoB,QAAQ,oBAAoB;AAAA,MACpE,qBAAqB,qBAAqB,QAAQ,qBAAqB;AAAA,MACvE,cAAc,cAAc,QAAQ,cAAc;AAAA,MAClD,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,eAAW,uCAAoB,YAAY,IAAI;AAAA,MAC/C,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAEX,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,15 +27,17 @@ var import_generators = require("./generators");
|
|
|
27
27
|
var import_actions_module = require("./integration-schemas/actions-module");
|
|
28
28
|
var import_channels_module = require("./integration-schemas/channels-module");
|
|
29
29
|
var import_configuration_module = require("./integration-schemas/configuration-module");
|
|
30
|
+
var import_configurations_module = require("./integration-schemas/configurations-module");
|
|
30
31
|
var import_entities_module = require("./integration-schemas/entities-module");
|
|
31
32
|
var import_events_module = require("./integration-schemas/events-module");
|
|
32
33
|
var import_states_module = require("./integration-schemas/states-module");
|
|
33
34
|
var import_module = require("./module");
|
|
34
35
|
class IntegrationInstanceIndexModule extends import_module.Module {
|
|
35
|
-
constructor(integration,
|
|
36
|
+
constructor(integration, defaultConfigModule, configurationsModule, actionsModule, channelsModule, eventsModule, statesModule, entitiesModule, def) {
|
|
36
37
|
super(def);
|
|
37
38
|
this.integration = integration;
|
|
38
|
-
this.
|
|
39
|
+
this.defaultConfigModule = defaultConfigModule;
|
|
40
|
+
this.configurationsModule = configurationsModule;
|
|
39
41
|
this.actionsModule = actionsModule;
|
|
40
42
|
this.channelsModule = channelsModule;
|
|
41
43
|
this.eventsModule = eventsModule;
|
|
@@ -44,8 +46,10 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
44
46
|
}
|
|
45
47
|
static async create(integration) {
|
|
46
48
|
const { name } = integration;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const defaultConfigModule = await import_configuration_module.DefaultConfigurationModule.create(integration.configuration ?? { schema: {} });
|
|
50
|
+
defaultConfigModule.unshift("configuration");
|
|
51
|
+
const configurationsModule = await import_configurations_module.ConfigurationsModule.create(integration.configurations ?? {});
|
|
52
|
+
configurationsModule.unshift("configurations");
|
|
49
53
|
const actionsModule = await import_actions_module.ActionsModule.create(integration.actions ?? {});
|
|
50
54
|
actionsModule.unshift("actions");
|
|
51
55
|
const channelsModule = await import_channels_module.ChannelsModule.create(integration.channels ?? {});
|
|
@@ -59,7 +63,8 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
59
63
|
const exportName = import_utils.casing.to.pascalCase(name);
|
|
60
64
|
const inst = new IntegrationInstanceIndexModule(
|
|
61
65
|
integration,
|
|
62
|
-
|
|
66
|
+
defaultConfigModule,
|
|
67
|
+
configurationsModule,
|
|
63
68
|
actionsModule,
|
|
64
69
|
channelsModule,
|
|
65
70
|
eventsModule,
|
|
@@ -71,7 +76,8 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
71
76
|
exportName
|
|
72
77
|
}
|
|
73
78
|
);
|
|
74
|
-
inst.pushDep(
|
|
79
|
+
inst.pushDep(defaultConfigModule);
|
|
80
|
+
inst.pushDep(configurationsModule);
|
|
75
81
|
inst.pushDep(actionsModule);
|
|
76
82
|
inst.pushDep(channelsModule);
|
|
77
83
|
inst.pushDep(eventsModule);
|
|
@@ -80,8 +86,18 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
80
86
|
return inst;
|
|
81
87
|
}
|
|
82
88
|
get content() {
|
|
83
|
-
const {
|
|
84
|
-
|
|
89
|
+
const {
|
|
90
|
+
defaultConfigModule,
|
|
91
|
+
configurationsModule,
|
|
92
|
+
actionsModule,
|
|
93
|
+
channelsModule,
|
|
94
|
+
eventsModule,
|
|
95
|
+
statesModule,
|
|
96
|
+
entitiesModule,
|
|
97
|
+
integration
|
|
98
|
+
} = this;
|
|
99
|
+
const defaultConfigImport = defaultConfigModule.import(this);
|
|
100
|
+
const configurationsImport = configurationsModule.import(this);
|
|
85
101
|
const actionsImport = actionsModule.import(this);
|
|
86
102
|
const channelsImport = channelsModule.import(this);
|
|
87
103
|
const eventsImport = eventsModule.import(this);
|
|
@@ -90,33 +106,49 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
90
106
|
const { name, version, id } = integration;
|
|
91
107
|
const className = import_utils.casing.to.pascalCase(name);
|
|
92
108
|
const propsName = `${className}Props`;
|
|
109
|
+
const configName = `${className}Config`;
|
|
93
110
|
const integrationId = id === null ? "null" : `'${id}'`;
|
|
94
111
|
const lines = [
|
|
95
112
|
import_const.GENERATED_HEADER,
|
|
96
113
|
"import type { IntegrationInstance } from '@botpress/sdk'",
|
|
97
114
|
"",
|
|
98
|
-
`import type * as ${
|
|
115
|
+
`import type * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
|
|
116
|
+
`import type * as ${configurationsModule.name} from "./${configurationsImport}"`,
|
|
99
117
|
`import type * as ${actionsModule.name} from "./${actionsImport}"`,
|
|
100
118
|
`import type * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
101
119
|
`import type * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
102
120
|
`import type * as ${statesModule.name} from "./${statesImport}"`,
|
|
103
121
|
`import type * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
104
|
-
`export * as ${
|
|
122
|
+
`export * as ${defaultConfigModule.name} from "./${defaultConfigImport}"`,
|
|
123
|
+
`export * as ${configurationsModule.name} from "./${configurationsImport}"`,
|
|
105
124
|
`export * as ${actionsModule.name} from "./${actionsImport}"`,
|
|
106
125
|
`export * as ${channelsModule.name} from "./${channelsImport}"`,
|
|
107
126
|
`export * as ${eventsModule.name} from "./${eventsImport}"`,
|
|
108
127
|
`export * as ${statesModule.name} from "./${statesImport}"`,
|
|
109
128
|
`export * as ${entitiesModule.name} from "./${entitiesImport}"`,
|
|
110
129
|
"",
|
|
130
|
+
"// type utils",
|
|
131
|
+
"type ValueOf<T> = T[keyof T]",
|
|
132
|
+
"",
|
|
133
|
+
`export type ${configName} = {`,
|
|
134
|
+
" configType?: null",
|
|
135
|
+
` config?: ${defaultConfigModule.name}.${defaultConfigModule.exports}`,
|
|
136
|
+
"} | ValueOf<{",
|
|
137
|
+
` [K in keyof ${configurationsModule.name}.${configurationsModule.exports}]: {`,
|
|
138
|
+
" configType: K",
|
|
139
|
+
` config?: ${configurationsModule.name}.${configurationsModule.exports}[K]`,
|
|
140
|
+
" }",
|
|
141
|
+
"}>",
|
|
142
|
+
"",
|
|
111
143
|
`export type ${propsName} = {`,
|
|
112
144
|
" enabled?: boolean",
|
|
113
|
-
`
|
|
114
|
-
"}",
|
|
145
|
+
`} & ${configName}`,
|
|
115
146
|
"",
|
|
116
147
|
`export type T${className} = {`,
|
|
117
148
|
` name: '${name}'`,
|
|
118
149
|
` version: '${version}'`,
|
|
119
|
-
` configuration: ${
|
|
150
|
+
` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exports}`,
|
|
151
|
+
` configurations: ${configurationsModule.name}.${configurationsModule.exports}`,
|
|
120
152
|
` actions: ${actionsModule.name}.${actionsModule.exports}`,
|
|
121
153
|
` channels: ${channelsModule.name}.${channelsModule.exports}`,
|
|
122
154
|
` events: ${eventsModule.name}.${eventsModule.exports}`,
|
|
@@ -132,10 +164,12 @@ class IntegrationInstanceIndexModule extends import_module.Module {
|
|
|
132
164
|
` public readonly id = ${integrationId}`,
|
|
133
165
|
"",
|
|
134
166
|
" public readonly enabled?: boolean",
|
|
135
|
-
` public readonly
|
|
167
|
+
` public readonly configurationType?: ${configName}['configType']`,
|
|
168
|
+
` public readonly configuration?: ${configName}['config']`,
|
|
136
169
|
"",
|
|
137
170
|
` constructor(props?: ${propsName}) {`,
|
|
138
171
|
" this.enabled = props?.enabled",
|
|
172
|
+
" this.configurationType = props?.configType",
|
|
139
173
|
" this.configuration = props?.config",
|
|
140
174
|
" }",
|
|
141
175
|
"}"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/integration-instance.ts"],
|
|
4
|
-
"sourcesContent": ["import { casing } from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AACvB,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,
|
|
4
|
+
"sourcesContent": ["import { casing } from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { stringifySingleLine } from './generators'\nimport { ActionsModule } from './integration-schemas/actions-module'\nimport { ChannelsModule } from './integration-schemas/channels-module'\nimport { DefaultConfigurationModule } from './integration-schemas/configuration-module'\nimport { ConfigurationsModule } from './integration-schemas/configurations-module'\nimport { EntitiesModule } from './integration-schemas/entities-module'\nimport { EventsModule } from './integration-schemas/events-module'\nimport { StatesModule } from './integration-schemas/states-module'\nimport { Module, ModuleDef } from './module'\nimport * as types from './typings'\n\nexport class IntegrationInstanceIndexModule extends Module {\n public static async create(integration: types.IntegrationDefinition): Promise<IntegrationInstanceIndexModule> {\n const { name } = integration\n\n const defaultConfigModule = await DefaultConfigurationModule.create(integration.configuration ?? { schema: {} })\n defaultConfigModule.unshift('configuration')\n\n const configurationsModule = await ConfigurationsModule.create(integration.configurations ?? {})\n configurationsModule.unshift('configurations')\n\n const actionsModule = await ActionsModule.create(integration.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = await ChannelsModule.create(integration.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = await EventsModule.create(integration.events ?? {})\n eventsModule.unshift('events')\n\n const statesModule = await StatesModule.create(integration.states ?? {})\n statesModule.unshift('states')\n\n const entitiesModule = await EntitiesModule.create(integration.entities ?? {})\n entitiesModule.unshift('entities')\n\n const exportName = casing.to.pascalCase(name)\n\n const inst = new IntegrationInstanceIndexModule(\n integration,\n defaultConfigModule,\n configurationsModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n entitiesModule,\n {\n path: INDEX_FILE,\n content: '',\n exportName,\n }\n )\n\n inst.pushDep(defaultConfigModule)\n inst.pushDep(configurationsModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n inst.pushDep(statesModule)\n inst.pushDep(entitiesModule)\n\n return inst\n }\n\n private constructor(\n private integration: types.IntegrationDefinition,\n private defaultConfigModule: DefaultConfigurationModule,\n private configurationsModule: ConfigurationsModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private statesModule: StatesModule,\n private entitiesModule: EntitiesModule,\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n const {\n defaultConfigModule,\n configurationsModule,\n actionsModule,\n channelsModule,\n eventsModule,\n statesModule,\n entitiesModule,\n integration,\n } = this\n\n const defaultConfigImport = defaultConfigModule.import(this)\n const configurationsImport = configurationsModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const entitiesImport = entitiesModule.import(this)\n\n const { name, version, id } = integration\n const className = casing.to.pascalCase(name)\n const propsName = `${className}Props`\n const configName = `${className}Config`\n\n const integrationId = id === null ? 'null' : `'${id}'`\n\n const lines = [\n GENERATED_HEADER,\n \"import type { IntegrationInstance } from '@botpress/sdk'\",\n '',\n `import type * as ${defaultConfigModule.name} from \"./${defaultConfigImport}\"`,\n `import type * as ${configurationsModule.name} from \"./${configurationsImport}\"`,\n `import type * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import type * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import type * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import type * as ${statesModule.name} from \"./${statesImport}\"`,\n `import type * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n `export * as ${defaultConfigModule.name} from \"./${defaultConfigImport}\"`,\n `export * as ${configurationsModule.name} from \"./${configurationsImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${statesModule.name} from \"./${statesImport}\"`,\n `export * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n '',\n '// type utils',\n 'type ValueOf<T> = T[keyof T]',\n '',\n `export type ${configName} = {`,\n ' configType?: null',\n ` config?: ${defaultConfigModule.name}.${defaultConfigModule.exports}`,\n '} | ValueOf<{',\n ` [K in keyof ${configurationsModule.name}.${configurationsModule.exports}]: {`,\n ' configType: K',\n ` config?: ${configurationsModule.name}.${configurationsModule.exports}[K]`,\n ' }',\n '}>',\n '',\n `export type ${propsName} = {`,\n ' enabled?: boolean',\n `} & ${configName}`,\n '',\n `export type T${className} = {`,\n ` name: '${name}'`,\n ` version: '${version}'`,\n ` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exports}`,\n ` configurations: ${configurationsModule.name}.${configurationsModule.exports}`,\n ` actions: ${actionsModule.name}.${actionsModule.exports}`,\n ` channels: ${channelsModule.name}.${channelsModule.exports}`,\n ` events: ${eventsModule.name}.${eventsModule.exports}`,\n ` states: ${statesModule.name}.${statesModule.exports}`,\n ` user: ${stringifySingleLine(this.integration.user)}`,\n ` entities: ${entitiesModule.name}.${entitiesModule.exports}`,\n '}',\n '',\n `export class ${className} implements IntegrationInstance<T${className}> {`,\n '',\n ` public readonly name = '${name}'`,\n ` public readonly version = '${version}'`,\n ` public readonly id = ${integrationId}`,\n '',\n ' public readonly enabled?: boolean',\n ` public readonly configurationType?: ${configName}['configType']`,\n ` public readonly configuration?: ${configName}['config']`,\n '',\n ` constructor(props?: ${propsName}) {`,\n ' this.enabled = props?.enabled',\n ' this.configurationType = props?.configType',\n ' this.configuration = props?.config',\n ' }',\n '}',\n ]\n\n return `${GENERATED_HEADER}\\n${lines.join('\\n')}`\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AACvB,mBAA6C;AAC7C,wBAAoC;AACpC,4BAA8B;AAC9B,6BAA+B;AAC/B,kCAA2C;AAC3C,mCAAqC;AACrC,6BAA+B;AAC/B,2BAA6B;AAC7B,2BAA6B;AAC7B,oBAAkC;AAG3B,MAAM,uCAAuC,qBAAO;AAAA,EAsDjD,YACE,aACA,qBACA,sBACA,eACA,gBACA,cACA,cACA,gBACR,KACA;AACA,UAAM,GAAG;AAVD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EA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A,iBAAiB,qBAAqB,QAAQ,qBAAqB;AAAA,MACnE;AAAA,MACA,gBAAgB,qBAAqB,QAAQ,qBAAqB;AAAA,MAClE;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,MACf;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA,gBAAgB;AAAA,MAChB,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,oBAAoB,oBAAoB,QAAQ,oBAAoB;AAAA,MACpE,qBAAqB,qBAAqB,QAAQ,qBAAqB;AAAA,MACvE,cAAc,cAAc,QAAQ,cAAc;AAAA,MAClD,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,eAAW,uCAAoB,KAAK,YAAY,IAAI;AAAA,MACpD,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD;AAAA,MACA;AAAA,MACA,gBAAgB,6CAA6C;AAAA,MAC7D;AAAA,MACA,6BAA6B;AAAA,MAC7B,gCAAgC;AAAA,MAChC,0BAA0B;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,yCAAyC;AAAA,MACzC,qCAAqC;AAAA,MACrC;AAAA,MACA,yBAAyB;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO,GAAG;AAAA,EAAqB,MAAM,KAAK,IAAI;AAAA,EAChD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,26 +24,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var configuration_module_exports = {};
|
|
26
26
|
__export(configuration_module_exports, {
|
|
27
|
-
|
|
27
|
+
DefaultConfigurationModule: () => DefaultConfigurationModule
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(configuration_module_exports);
|
|
30
30
|
var import_const = require("../const");
|
|
31
31
|
var import_generators = require("../generators");
|
|
32
32
|
var import_module = require("../module");
|
|
33
33
|
var strings = __toESM(require("../strings"));
|
|
34
|
-
class
|
|
34
|
+
class DefaultConfigurationModule extends import_module.Module {
|
|
35
35
|
static async create(configuration) {
|
|
36
36
|
const { schema } = configuration;
|
|
37
37
|
if (!schema) {
|
|
38
|
-
return new
|
|
38
|
+
return new DefaultConfigurationModule({
|
|
39
39
|
path: import_const.INDEX_FILE,
|
|
40
40
|
exportName: "Configuration",
|
|
41
|
-
content:
|
|
41
|
+
content: [
|
|
42
|
+
"/** Default Configuration of the Integration */",
|
|
43
|
+
"export type Configuration = Record<string, never>;"
|
|
44
|
+
].join("\n")
|
|
42
45
|
});
|
|
43
46
|
}
|
|
44
47
|
const name = "configuration";
|
|
45
48
|
const exportName = strings.typeName(name);
|
|
46
|
-
return new
|
|
49
|
+
return new DefaultConfigurationModule({
|
|
47
50
|
path: import_const.INDEX_FILE,
|
|
48
51
|
exportName,
|
|
49
52
|
content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
|
|
@@ -52,6 +55,6 @@ class ConfigurationModule extends import_module.Module {
|
|
|
52
55
|
}
|
|
53
56
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
57
|
0 && (module.exports = {
|
|
55
|
-
|
|
58
|
+
DefaultConfigurationModule
|
|
56
59
|
});
|
|
57
60
|
//# sourceMappingURL=configuration-module.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/integration-schemas/configuration-module.ts"],
|
|
4
|
-
"sourcesContent": ["import { INDEX_FILE } from '../const'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module } from '../module'\nimport * as strings from '../strings'\nimport type * as types from '../typings'\n\nexport class
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAC3B,wBAA2C;AAC3C,oBAAuB;AACvB,cAAyB;AAGlB,MAAM,
|
|
4
|
+
"sourcesContent": ["import { INDEX_FILE } from '../const'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module } from '../module'\nimport * as strings from '../strings'\nimport type * as types from '../typings'\n\nexport class DefaultConfigurationModule extends Module {\n public static async create(configuration: types.ConfigurationDefinition): Promise<DefaultConfigurationModule> {\n const { schema } = configuration\n if (!schema) {\n return new DefaultConfigurationModule({\n path: INDEX_FILE,\n exportName: 'Configuration',\n content: [\n '/** Default Configuration of the Integration */',\n 'export type Configuration = Record<string, never>;',\n ].join('\\n'),\n })\n }\n\n const name = 'configuration'\n\n const exportName = strings.typeName(name)\n return new DefaultConfigurationModule({\n path: INDEX_FILE,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n })\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAC3B,wBAA2C;AAC3C,oBAAuB;AACvB,cAAyB;AAGlB,MAAM,mCAAmC,qBAAO;AAAA,EACrD,aAAoB,OAAO,eAAmF;AAC5G,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,CAAC,QAAQ;AACX,aAAO,IAAI,2BAA2B;AAAA,QACpC,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,SAAS;AAAA,UACP;AAAA,UACA;AAAA,QACF,EAAE,KAAK,IAAI;AAAA,MACb,CAAC;AAAA,IACH;AAEA,UAAM,OAAO;AAEb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,WAAO,IAAI,2BAA2B;AAAA,MACpC,MAAM;AAAA,MACN;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var configurations_module_exports = {};
|
|
26
|
+
__export(configurations_module_exports, {
|
|
27
|
+
ConfigurationModule: () => ConfigurationModule,
|
|
28
|
+
ConfigurationsModule: () => ConfigurationsModule
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(configurations_module_exports);
|
|
31
|
+
var import_bluebird = __toESM(require("bluebird"));
|
|
32
|
+
var import_generators = require("../generators");
|
|
33
|
+
var import_module = require("../module");
|
|
34
|
+
var strings = __toESM(require("../strings"));
|
|
35
|
+
class ConfigurationModule extends import_module.Module {
|
|
36
|
+
static async create(name, configuration) {
|
|
37
|
+
const configurationName = name;
|
|
38
|
+
const schema = configuration.schema;
|
|
39
|
+
const exportName = strings.typeName(`${configurationName}Config`);
|
|
40
|
+
let content;
|
|
41
|
+
if (schema) {
|
|
42
|
+
content = await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName);
|
|
43
|
+
} else {
|
|
44
|
+
content = `export type ${exportName} = Record<string, never>;`;
|
|
45
|
+
}
|
|
46
|
+
const def = {
|
|
47
|
+
path: `${name}.ts`,
|
|
48
|
+
exportName,
|
|
49
|
+
content
|
|
50
|
+
};
|
|
51
|
+
return new ConfigurationModule(def);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class ConfigurationsModule extends import_module.ReExportTypeModule {
|
|
55
|
+
static async create(configurations) {
|
|
56
|
+
const configurationModules = await import_bluebird.default.map(
|
|
57
|
+
Object.entries(configurations),
|
|
58
|
+
async ([configurationName, configuration]) => ConfigurationModule.create(configurationName, configuration)
|
|
59
|
+
);
|
|
60
|
+
const inst = new ConfigurationsModule({
|
|
61
|
+
exportName: strings.typeName("configurations")
|
|
62
|
+
});
|
|
63
|
+
inst.pushDep(...configurationModules);
|
|
64
|
+
return inst;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
ConfigurationModule,
|
|
70
|
+
ConfigurationsModule
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=configurations-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/code-generation/integration-schemas/configurations-module.ts"],
|
|
4
|
+
"sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\nimport type * as types from '../typings'\n\nexport class ConfigurationModule extends Module {\n public static async create(name: string, configuration: types.ConfigurationDefinition): Promise<ConfigurationModule> {\n const configurationName = name\n const schema = configuration.schema\n const exportName = strings.typeName(`${configurationName}Config`)\n\n let content: string\n if (schema) {\n content = await jsonSchemaToTypeScriptType(schema, exportName)\n } else {\n content = `export type ${exportName} = Record<string, never>;`\n }\n\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content,\n }\n return new ConfigurationModule(def)\n }\n}\n\nexport class ConfigurationsModule extends ReExportTypeModule {\n public static async create(\n configurations: Record<string, types.ConfigurationDefinition>\n ): Promise<ConfigurationsModule> {\n const configurationModules = await bluebird.map(\n Object.entries(configurations),\n async ([configurationName, configuration]) => ConfigurationModule.create(configurationName, configuration)\n )\n\n const inst = new ConfigurationsModule({\n exportName: strings.typeName('configurations'),\n })\n inst.pushDep(...configurationModules)\n return inst\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,wBAA2C;AAC3C,oBAAsD;AACtD,cAAyB;AAGlB,MAAM,4BAA4B,qBAAO;AAAA,EAC9C,aAAoB,OAAO,MAAc,eAA4E;AACnH,UAAM,oBAAoB;AAC1B,UAAM,SAAS,cAAc;AAC7B,UAAM,aAAa,QAAQ,SAAS,GAAG,yBAAyB;AAEhE,QAAI;AACJ,QAAI,QAAQ;AACV,gBAAU,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC/D,OAAO;AACL,gBAAU,eAAe;AAAA,IAC3B;AAEA,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA;AAAA,IACF;AACA,WAAO,IAAI,oBAAoB,GAAG;AAAA,EACpC;AACF;AAEO,MAAM,6BAA6B,iCAAmB;AAAA,EAC3D,aAAoB,OAClB,gBAC+B;AAC/B,UAAM,uBAAuB,MAAM,gBAAAA,QAAS;AAAA,MAC1C,OAAO,QAAQ,cAAc;AAAA,MAC7B,OAAO,CAAC,mBAAmB,aAAa,MAAM,oBAAoB,OAAO,mBAAmB,aAAa;AAAA,IAC3G;AAEA,UAAM,OAAO,IAAI,qBAAqB;AAAA,MACpC,YAAY,QAAQ,SAAS,gBAAgB;AAAA,IAC/C,CAAC;AACD,SAAK,QAAQ,GAAG,oBAAoB;AACpC,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["bluebird"]
|
|
7
|
+
}
|
|
@@ -40,6 +40,7 @@ var from;
|
|
|
40
40
|
creation: i.user?.creation ?? { enabled: false, requiredTags: [] }
|
|
41
41
|
},
|
|
42
42
|
configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },
|
|
43
|
+
configurations: i.configurations ? utils.records.mapValues(i.configurations, _mapSchema) : {},
|
|
43
44
|
events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},
|
|
44
45
|
states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},
|
|
45
46
|
actions: i.actions ? utils.records.mapValues(i.actions, (a) => ({
|
|
@@ -60,8 +61,8 @@ var from;
|
|
|
60
61
|
};
|
|
61
62
|
};
|
|
62
63
|
from2.client = (i) => {
|
|
63
|
-
const { id, name, version, configuration, channels, states, events, actions, user, entities } = i;
|
|
64
|
-
return { id, name, version, configuration, channels, states, events, actions, user, entities };
|
|
64
|
+
const { id, name, version, configuration, configurations, channels, states, events, actions, user, entities } = i;
|
|
65
|
+
return { id, name, version, configuration, configurations, channels, states, events, actions, user, entities };
|
|
65
66
|
};
|
|
66
67
|
const _mapSchema = (x) => ({
|
|
67
68
|
...x,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/map-integration.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n entities: i.entities ? utils.records.mapValues(i.entities, _mapSchema) : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, channels, states, events, actions, user, entities } = i\n return { id, name, version, configuration, channels, states, events, actions, user, entities }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,MAA8D;AAChF,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,MAAM;AAAA,QACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MACnE;AAAA,MACA,eAAe,EAAE,gBAAgB,WAAW,EAAE,aAAa,IAAI,EAAE,QAAQ,CAAC,EAAE;AAAA,MAC5E,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,SAAS,EAAE,UACP,MAAM,QAAQ,UAAU,EAAE,SAAS,CAAC,OAAO;AAAA,QACzC,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,QAAQ,WAAW,EAAE,MAAM;AAAA,MAC7B,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WACR,MAAM,QAAQ,UAAU,EAAE,UAAU,CAAC,OAAO;AAAA,QAC1C,cAAc;AAAA,UACZ,MAAM,EAAE,cAAc,QAAQ,CAAC;AAAA,UAC/B,UAAU,EAAE,cAAc,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,QAC3E;AAAA,QACA,SAAS;AAAA,UACP,MAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,QAC5B;AAAA,QACA,UAAU,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU;AAAA,MAC1D,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WAAW,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU,IAAI,CAAC;AAAA,IAC5E;AAAA,EACF;AAEO,EAAMA,MAAA,SAAS,CAAC,MAAuD;AAC5E,UAAM,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS,IAAI;
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n configurations: i.configurations ? utils.records.mapValues(i.configurations, _mapSchema) : {},\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n entities: i.entities ? utils.records.mapValues(i.entities, _mapSchema) : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, configurations, channels, states, events, actions, user, entities } = i\n return { id, name, version, configuration, configurations, channels, states, events, actions, user, entities }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,MAA8D;AAChF,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,MAAM;AAAA,QACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MACnE;AAAA,MACA,eAAe,EAAE,gBAAgB,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AC1F,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,CAAC;AAAA,EAC3C;AAAA,GA9Ce;",
|
|
6
6
|
"names": ["from"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/typings.ts"],
|
|
4
|
-
"sourcesContent": ["import { Integration } from '@botpress/client'\n\nexport type File = { path: string; content: string }\n\nexport type IntegrationDefinition = Pick<\n Integration,\n 'name' | 'version' | 'channels' | 'states' | 'events' | 'actions' | 'user' | 'entities'\n> & {\n id: string | null\n configuration:
|
|
4
|
+
"sourcesContent": ["import { Integration } from '@botpress/client'\n\nexport type File = { path: string; content: string }\n\nexport type IntegrationDefinition = Pick<\n Integration,\n 'name' | 'version' | 'channels' | 'states' | 'events' | 'actions' | 'user' | 'entities'\n> & {\n id: string | null\n configuration: Pick<Integration['configuration'], 'schema'>\n configurations: Record<string, Pick<Integration['configuration'], 'schema'>>\n}\n\ntype Def<T> = NonNullable<T>\n\nexport type ConfigurationDefinition = Def<IntegrationDefinition['configuration']>\nexport type ConfigurationsDefinition = Def<IntegrationDefinition['configurations']>\nexport type ChannelDefinition = Def<IntegrationDefinition['channels']>[string]\nexport type MessageDefinition = Def<ChannelDefinition['messages']>[string]\nexport type ActionDefinition = Def<IntegrationDefinition['actions']>[string]\nexport type EventDefinition = Def<IntegrationDefinition['events']>[string]\nexport type StateDefinition = Def<IntegrationDefinition['states']>[string]\nexport type UserDefinition = Def<IntegrationDefinition['user']>\nexport type EntityDefinition = Def<IntegrationDefinition['entities']>[string]\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -74,7 +74,6 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
74
74
|
const readmeFileContent = await this._readMediaFile("readme", readmeRelativeFilePath);
|
|
75
75
|
const identifierExtractScriptFileContent = await this._readFile(identifier?.extractScript);
|
|
76
76
|
const fallbackHandlerScriptFileContent = await this._readFile(identifier?.fallbackHandlerScript);
|
|
77
|
-
const identifierLinkTemplateFileContent = await this._readFile(configuration?.identifier?.linkTemplateScript);
|
|
78
77
|
const integration = await api.findIntegration({ type: "name", name, version });
|
|
79
78
|
if (integration && integration.workspaceId !== api.workspaceId) {
|
|
80
79
|
throw new errors.BotpressCLIError(
|
|
@@ -98,6 +97,10 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
98
97
|
this.logger.log("Aborted");
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
100
|
+
const configurations = {};
|
|
101
|
+
for (const [key, config] of Object.entries(integrationDef.configurations ?? {})) {
|
|
102
|
+
configurations[key] = await this._readConfigDefinition(config);
|
|
103
|
+
}
|
|
101
104
|
let createBody = (0, import_integration_body.prepareCreateIntegrationBody)(integrationDef);
|
|
102
105
|
createBody = {
|
|
103
106
|
...createBody,
|
|
@@ -105,13 +108,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
105
108
|
code,
|
|
106
109
|
icon: iconFileContent,
|
|
107
110
|
readme: readmeFileContent,
|
|
108
|
-
configuration:
|
|
109
|
-
|
|
110
|
-
identifier: {
|
|
111
|
-
...createBody.configuration?.identifier ?? {},
|
|
112
|
-
linkTemplateScript: identifierLinkTemplateFileContent
|
|
113
|
-
}
|
|
114
|
-
},
|
|
111
|
+
configuration: await this._readConfigDefinition(configuration),
|
|
112
|
+
configurations,
|
|
115
113
|
identifier: {
|
|
116
114
|
extractScript: identifierExtractScriptFileContent,
|
|
117
115
|
fallbackHandlerScript: fallbackHandlerScriptFileContent
|
|
@@ -423,6 +421,19 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
423
421
|
}
|
|
424
422
|
return interfaces;
|
|
425
423
|
};
|
|
424
|
+
async _readConfigDefinition(config) {
|
|
425
|
+
if (!config?.identifier) {
|
|
426
|
+
return config;
|
|
427
|
+
}
|
|
428
|
+
const identifierLinkTemplateFileContent = await this._readFile(config.identifier.linkTemplateScript);
|
|
429
|
+
return {
|
|
430
|
+
...config,
|
|
431
|
+
identifier: {
|
|
432
|
+
...config.identifier,
|
|
433
|
+
linkTemplateScript: identifierLinkTemplateFileContent
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
426
437
|
}
|
|
427
438
|
// Annotate the CommonJS export names for ESM import in node:
|
|
428
439
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const {\n name,\n version,\n icon: iconRelativeFilePath,\n readme: readmeRelativeFilePath,\n identifier,\n configuration,\n } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this._readFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this._readFile(identifier?.fallbackHandlerScript)\n const identifierLinkTemplateFileContent = await this._readFile(configuration?.identifier?.linkTemplateScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n let createBody: CreateIntegrationBody = prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: {\n ...createBody.configuration,\n identifier: {\n ...(createBody.configuration?.identifier ?? {}),\n linkTemplateScript: identifierLinkTemplateFileContent,\n },\n },\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDeclaration) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readFile = async (filePath: string | undefined): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'utf-8').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...prepareCreateBotBody(botImpl),\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\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 if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\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 throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return integration.clone({ 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.clone({ name: newName })\n }\n\n private _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 private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesEntries = Object.entries(integration.interfaces)\n if (!interfacesEntries.length) {\n return undefined\n }\n\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of interfacesEntries) {\n const { name, version, entities, actions, events } = i\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${name}@${version}\"`)\n }\n const { id } = intrface\n\n interfaces[key] = { id, entities, actions, events }\n }\n\n return interfaces\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,sBAA2D;AAE3D,8BAIO;AACP,4BAA4F;AAE5F,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,eAAe;AACrC,aAAO,KAAK,mBAAmB,KAAK,WAAW,UAAU;AAAA,IAC3D;AACA,QAAI,WAAW,SA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,UAAU;AAC/D,QAAI,CAAC,kBAAkB,QAAQ;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,aAA+D,CAAC;AACtE,eAAW,CAAC,KAAK,CAAC,KAAK,mBAAmB;AACxC,YAAM,EAAE,MAAM,SAAS,UAAU,SAAS,OAAO,IAAI;AACrD,YAAM,WAAW,MAAM,IAAI,oBAAoB,EAAE,MAAM,QAAQ,MAAM,QAAQ,CAAC;AAC9E,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,iBAAiB,6BAA6B,QAAQ,UAAU;AAAA,MACnF;AACA,YAAM,EAAE,GAAG,IAAI;AAEf,iBAAW,OAAO,EAAE,IAAI,UAAU,SAAS,OAAO;AAAA,IACpD;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const {\n name,\n version,\n icon: iconRelativeFilePath,\n readme: readmeRelativeFilePath,\n identifier,\n configuration,\n } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this._readFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this._readFile(identifier?.fallbackHandlerScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const configurations: CreateIntegrationBody['configurations'] = {}\n for (const [key, config] of Object.entries(integrationDef.configurations ?? {})) {\n configurations[key] = await this._readConfigDefinition(config)\n }\n\n let createBody: CreateIntegrationBody = prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: await this._readConfigDefinition(configuration),\n configurations,\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDeclaration) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readFile = async (filePath: string | undefined): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'utf-8').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...prepareCreateBotBody(botImpl),\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\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 if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\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 throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return integration.clone({ 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.clone({ name: newName })\n }\n\n private _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 private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesEntries = Object.entries(integration.interfaces)\n if (!interfacesEntries.length) {\n return undefined\n }\n\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of interfacesEntries) {\n const { name, version, entities, actions, events } = i\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${name}@${version}\"`)\n }\n const { id } = intrface\n\n interfaces[key] = { id, entities, actions, events }\n }\n\n return interfaces\n }\n\n private async _readConfigDefinition(config: undefined): Promise<undefined>\n private async _readConfigDefinition(\n config: NonNullable<sdk.IntegrationDefinition['configuration']>\n ): Promise<NonNullable<CreateIntegrationBody['configuration']>>\n private async _readConfigDefinition(\n config: sdk.IntegrationDefinition['configuration']\n ): Promise<CreateIntegrationBody['configuration']>\n private async _readConfigDefinition(\n config: sdk.IntegrationDefinition['configuration']\n ): Promise<CreateIntegrationBody['configuration']> {\n if (!config?.identifier) {\n return config\n }\n\n const identifierLinkTemplateFileContent = await this._readFile(config.identifier.linkTemplateScript)\n\n return {\n ...config,\n identifier: {\n ...config.identifier,\n linkTemplateScript: identifierLinkTemplateFileContent,\n },\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AA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;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["chalk", "semver", "newName", "name"]
|
|
7
7
|
}
|
|
@@ -77,7 +77,11 @@ class ProjectCommand extends import_global_command.GlobalCommand {
|
|
|
77
77
|
}
|
|
78
78
|
return { ...instance, id: integration.id };
|
|
79
79
|
});
|
|
80
|
-
return (0, import_lodash.default)([...fetchedInstances, ...remoteInstances]).keyBy((i) => i.id).mapValues(({ enabled, configuration }) => ({
|
|
80
|
+
return (0, import_lodash.default)([...fetchedInstances, ...remoteInstances]).keyBy((i) => i.id).mapValues(({ enabled, configurationType, configuration }) => ({
|
|
81
|
+
enabled,
|
|
82
|
+
configurationType: configurationType ?? null,
|
|
83
|
+
configuration
|
|
84
|
+
})).value();
|
|
81
85
|
}
|
|
82
86
|
_splitApiAndLocalIntegrationInstances(instances) {
|
|
83
87
|
const remoteInstances = [];
|
|
@@ -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 type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatIntegrationRef, IntegrationRef } from '../integration-ref'\nimport { validateIntegrationDefinition } from '../sdk/validate-integration'\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 = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype RemoteIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<any>, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<any>, { id: null }>\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition =\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDeclaration }\n | { type: 'bot'; definition: null }\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 const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\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 protected async fetchBotIntegrationInstances(bot: sdk.Bot, api: ApiClient) {\n const integrationList = _(bot.props.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: IntegrationRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatIntegrationRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configuration }) => ({ enabled, configuration }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: sdk.IntegrationInstance<any>[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const { id, ...instance } of instances) {\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push({ ...instance, id: null })\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readProjectDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition' | 'interfaceDefinition'> = this.projectPaths\n ): Promise<ProjectDefinition> {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', definition: integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', definition: interfaceDefinition }\n }\n return { type: 'bot', definition: null }\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'> = this.projectPaths\n ): Promise<sdk.IntegrationDefinition | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.integrationDefinition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n\n validateIntegrationDefinition(definition)\n\n return definition\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'> = this.projectPaths\n ): Promise<sdk.InterfaceDeclaration | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.interfaceDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDeclaration }>(artifact.text)\n\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\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 } = integrationDef\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 integration 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 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 projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\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.readPkgJson()\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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AAO,EAAE,OAAO,MAAM,OAAO,GAAG,OAAO,EAAE,MAAM;AAEjG,UAAM,EAAE,iBAAiB,eAAe,IAAI,KAAK,sCAAsC,eAAe;AAEtG,UAAM,mBAAgD,MAAM,gBAAAC,QAAS,IAAI,gBAAgB,OAAO,aAAa;AAC3G,YAAM,MAAsB,EAAE,MAAM,QAAQ,MAAM,SAAS,MAAM,SAAS,SAAS,QAAQ;AAC3F,YAAM,cAAc,MAAM,IAAI,gBAAgB,GAAG;AACjD,UAAI,CAAC,aAAa;AAChB,cAAM,mBAAe,6CAAqB,GAAG;AAC7C,cAAM,IAAI,OAAO,iBAAiB,gBAAgB,yBAAyB;AAAA,MAC7E;AACA,aAAO,EAAE,GAAG,UAAU,IAAI,YAAY,GAAG;AAAA,IAC3C,CAAC;AAED,eAAO,cAAAD,SAAE,CAAC,GAAG,kBAAkB,GAAG,eAAe,CAAC,EAC/C,MAAM,CAAC,MAAM,EAAE,EAAE,EACjB,UAAU,CAAC,EAAE,SAAS,cAAc,OAAO,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatIntegrationRef, IntegrationRef } from '../integration-ref'\nimport { validateIntegrationDefinition } from '../sdk/validate-integration'\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 = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype RemoteIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<any>, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<any>, { id: null }>\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition =\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDeclaration }\n | { type: 'bot'; definition: null }\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 const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\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 protected async fetchBotIntegrationInstances(bot: sdk.Bot, api: ApiClient) {\n const integrationList = _(bot.props.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: IntegrationRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatIntegrationRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configurationType, configuration }) => ({\n enabled,\n configurationType: configurationType ?? null,\n configuration,\n }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: sdk.IntegrationInstance<any>[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const { id, ...instance } of instances) {\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push({ ...instance, id: null })\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readProjectDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition' | 'interfaceDefinition'> = this.projectPaths\n ): Promise<ProjectDefinition> {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', definition: integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', definition: interfaceDefinition }\n }\n return { type: 'bot', definition: null }\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'> = this.projectPaths\n ): Promise<sdk.IntegrationDefinition | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.integrationDefinition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n\n validateIntegrationDefinition(definition)\n\n return definition\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'> = this.projectPaths\n ): Promise<sdk.InterfaceDeclaration | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.interfaceDefinition,\n write: false,\n minify: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDeclaration }>(artifact.text)\n\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\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 } = integrationDef\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 integration 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 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 projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\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.readPkgJson()\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.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AAM,8BAA8B,qCAAqC;AACrF;AAAA,MACF;AAEA,YAAM,4BAA4B,cAAAA,QAAO,MAAM,cAAAA,QAAO,OAAO,kBAAkB,CAAC;AAChF,UAAI,CAAC,2BAA2B;AAC9B,aAAK,OAAO,MAAM,wBAAwB,yCAAyC;AACnF;AAAA,MACF;AAEA,UAAI,cAAAA,QAAO,GAAG,yBAAyB,yBAAyB,GAAG;AACjE;AAAA,MACF;AAEA,YAAM,OAAO,cAAAA,QAAO,KAAK,yBAAyB,yBAAyB;AAC3E,UAAI,CAAC,MAAM;AACT,aAAK,OAAO,MAAM,+BAA+B,iCAAiC,4BAA4B;AAC9G;AAAA,MACF;AAEA,YAAM,WAAW,2BAA2B,2CAA2C;AACvF,UAAI,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,GAAG;AAC3C,aAAK,OAAO,MAAM,GAAG,gDAAgD;AACrE;AAAA,MACF;AAEA,WAAK,OAAO,KAAK,aAAAD,QAAM,KAAK,GAAG,iDAAiD,CAAC;AAAA,IACnF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["_", "bluebird", "fs", "pathlib", "chalk", "semver"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run bundle && pnpm run template:gen",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"main": "dist/index.js",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@botpress/client": "0.29.3",
|
|
24
|
-
"@botpress/sdk": "0.
|
|
24
|
+
"@botpress/sdk": "0.11.0",
|
|
25
25
|
"@bpinternal/const": "^0.0.20",
|
|
26
26
|
"@bpinternal/tunnel": "^0.1.1",
|
|
27
27
|
"@bpinternal/yargs-extra": "^0.0.3",
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
import * as sdk from "@botpress/sdk"
|
|
9
9
|
|
|
10
10
|
import type * as configuration from "./configuration/index"
|
|
11
|
+
import type * as configurations from "./configurations/index"
|
|
11
12
|
import type * as actions from "./actions/index"
|
|
12
13
|
import type * as channels from "./channels/index"
|
|
13
14
|
import type * as events from "./events/index"
|
|
14
15
|
import type * as states from "./states/index"
|
|
15
16
|
import type * as entities from "./entities/index"
|
|
16
17
|
export * as configuration from "./configuration/index"
|
|
18
|
+
export * as configurations from "./configurations/index"
|
|
17
19
|
export * as actions from "./actions/index"
|
|
18
20
|
export * as channels from "./channels/index"
|
|
19
21
|
export * as events from "./events/index"
|
|
@@ -29,6 +31,7 @@ type TIntegration = {
|
|
|
29
31
|
name: "empty-integration"
|
|
30
32
|
version: "0.0.1"
|
|
31
33
|
configuration: configuration.Configuration
|
|
34
|
+
configurations: configurations.Configurations
|
|
32
35
|
actions: actions.Actions
|
|
33
36
|
channels: channels.Channels
|
|
34
37
|
events: events.Events
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
import * as sdk from "@botpress/sdk"
|
|
9
9
|
|
|
10
10
|
import type * as configuration from "./configuration/index"
|
|
11
|
+
import type * as configurations from "./configurations/index"
|
|
11
12
|
import type * as actions from "./actions/index"
|
|
12
13
|
import type * as channels from "./channels/index"
|
|
13
14
|
import type * as events from "./events/index"
|
|
14
15
|
import type * as states from "./states/index"
|
|
15
16
|
import type * as entities from "./entities/index"
|
|
16
17
|
export * as configuration from "./configuration/index"
|
|
18
|
+
export * as configurations from "./configurations/index"
|
|
17
19
|
export * as actions from "./actions/index"
|
|
18
20
|
export * as channels from "./channels/index"
|
|
19
21
|
export * as events from "./events/index"
|
|
@@ -29,6 +31,7 @@ type TIntegration = {
|
|
|
29
31
|
name: "hello-world"
|
|
30
32
|
version: "0.0.1"
|
|
31
33
|
configuration: configuration.Configuration
|
|
34
|
+
configurations: configurations.Configurations
|
|
32
35
|
actions: actions.Actions
|
|
33
36
|
channels: channels.Channels
|
|
34
37
|
events: events.Events
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
import * as sdk from "@botpress/sdk"
|
|
9
9
|
|
|
10
10
|
import type * as configuration from "./configuration/index"
|
|
11
|
+
import type * as configurations from "./configurations/index"
|
|
11
12
|
import type * as actions from "./actions/index"
|
|
12
13
|
import type * as channels from "./channels/index"
|
|
13
14
|
import type * as events from "./events/index"
|
|
14
15
|
import type * as states from "./states/index"
|
|
15
16
|
import type * as entities from "./entities/index"
|
|
16
17
|
export * as configuration from "./configuration/index"
|
|
18
|
+
export * as configurations from "./configurations/index"
|
|
17
19
|
export * as actions from "./actions/index"
|
|
18
20
|
export * as channels from "./channels/index"
|
|
19
21
|
export * as events from "./events/index"
|
|
@@ -29,6 +31,7 @@ type TIntegration = {
|
|
|
29
31
|
name: "webhook-message"
|
|
30
32
|
version: "0.0.1"
|
|
31
33
|
configuration: configuration.Configuration
|
|
34
|
+
configurations: configurations.Configurations
|
|
32
35
|
actions: actions.Actions
|
|
33
36
|
channels: channels.Channels
|
|
34
37
|
events: events.Events
|