@botpress/cli 0.8.67 ā 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +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 +7 -27
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +8 -3
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/project-command.js +26 -1
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/promise-utils.js +33 -0
- package/dist/utils/promise-utils.js.map +7 -0
- package/dist/utils/promise-utils.test.js +14 -0
- package/dist/utils/promise-utils.test.js.map +7 -0
- package/package.json +3 -3
- package/templates/echo-bot/package.json +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@0.
|
|
2
|
+
> @botpress/cli@0.9.1 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@0.
|
|
6
|
+
> @botpress/cli@0.9.1 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.1 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
š¤ Botpress CLI v0.
|
|
14
|
-
š¤ Botpress CLI v0.
|
|
15
|
-
š¤ Botpress CLI v0.
|
|
16
|
-
š¤ Botpress CLI v0.
|
|
13
|
+
š¤ Botpress CLI v0.9.1
|
|
14
|
+
š¤ Botpress CLI v0.9.1
|
|
15
|
+
š¤ Botpress CLI v0.9.1
|
|
16
|
+
š¤ Botpress CLI v0.9.1
|
|
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 webhook-message...[2K[1Gā Generating typings for integration empty-integration...[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,S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C7F,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;",
|
|
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,KAA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,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]>>',\n '}',\n ].join('\\n')\n\n return content\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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,6CAA6C,qBAAO;AAAA,EAiDvD,YACE,aACA,qBACA,sBACA,eACA,gBACA,cACA,cACA,gBACR,KACA;AACA,UAAM,GAAG;AAVD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAIV;AAAA,EA5DA,aAAoB,OAAO,aAAyF;AAClH,UAAM,sBAAsB,MAAM,uDAA2B,OAAO,YAAY,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAC;AAC/G,wBAAoB,QAAQ,eAAe;AAE3C,UAAM,uBAAuB,MAAM,kDAAqB,OAAO,YAAY,kBAAkB,CAAC,CAAC;AAC/F,yBAAqB,QAAQ,gBAAgB;AAE7C,UAAM,gBAAgB,MAAM,oCAAc,OAAO,YAAY,WAAW,CAAC,CAAC;AAC1E,kBAAc,QAAQ,SAAS;AAE/B,UAAM,iBAAiB,MAAM,sCAAe,OAAO,YAAY,YAAY,CAAC,CAAC;AAC7E,mBAAe,QAAQ,UAAU;AAEjC,UAAM,eAAe,MAAM,kCAAa,OAAO,YAAY,UAAU,CAAC,CAAC;AACvE,iBAAa,QAAQ,QAAQ;AAE7B,UAAM,eAAe,MAAM,kCAAa,OAAO,YAAY,UAAU,CAAC,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EX,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;A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|
|
|
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
|
+
}
|