@botpress/cli 0.1.2 → 0.1.4
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/dist/code-generation/integration-impl.js +2 -0
- package/dist/code-generation/integration-impl.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +57 -3
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/record-utils.js +40 -0
- package/dist/utils/record-utils.js.map +7 -0
- package/package.json +2 -2
- package/templates/echo-bot/package.json +1 -1
- package/templates/empty-integration/.botpress/implementation/index.ts +1 -0
- package/templates/empty-integration/package.json +1 -1
|
@@ -97,6 +97,8 @@ class IntegrationImplementationIndexModule extends import_module.Module {
|
|
|
97
97
|
content += "\n";
|
|
98
98
|
content += `export class Integration
|
|
99
99
|
extends sdk.Integration<${configModule.name}.${configModule.exports}, ${actionsModule.name}.${actionsModule.exports}, ${channelsModule.name}.${channelsModule.exports}, ${eventsModule.name}.${eventsModule.exports}> {}
|
|
100
|
+
`;
|
|
101
|
+
content += `export type IntegrationProps = sdk.IntegrationProps<${configModule.name}.${configModule.exports}, ${actionsModule.name}.${actionsModule.exports}, ${channelsModule.name}.${channelsModule.exports}, ${eventsModule.name}.${eventsModule.exports}>;
|
|
100
102
|
`;
|
|
101
103
|
return content;
|
|
102
104
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/integration-impl.ts"],
|
|
4
|
-
"sourcesContent": ["import type { IntegrationDefinition } from '@botpress/sdk'\nimport bluebird from 'bluebird'\nimport { ActionModule } from './action'\nimport { ChannelModule } from './channel'\nimport { ConfigurationModule } from './configuration'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { EventModule } from './event'\nimport { Module, ModuleDef, ReExportTypeModule } from './module'\nimport type * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\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 { name, version } = integration\n const inst = new IntegrationImplementationIndexModule(\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n { name, version },\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n return inst\n }\n\n private constructor(\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private integrationID: { name: string; version: string },\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const { configModule, actionsModule, channelsModule, eventsModule } = this\n\n content += 'import * as sdk from \"@botpress/sdk\";\\n\\n'\n\n const configImport = configModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n\n content += `import type * as ${configModule.name} from \"./${configImport}\";\\n`\n content += `import type * as ${actionsModule.name} from \"./${actionsImport}\";\\n`\n content += `import type * as ${channelsModule.name} from \"./${channelsImport}\";\\n`\n content += `import type * as ${eventsModule.name} from \"./${eventsImport}\";\\n`\n content += `export * as ${configModule.name} from \"./${configImport}\";\\n`\n content += `export * as ${actionsModule.name} from \"./${actionsImport}\";\\n`\n content += `export * as ${channelsModule.name} from \"./${channelsImport}\";\\n`\n content += `export * as ${eventsModule.name} from \"./${eventsImport}\";\\n`\n\n content += '\\n'\n\n content += `export class Integration\n extends sdk.Integration<${configModule.name}.${configModule.exports}, ${actionsModule.name}.${actionsModule.exports}, ${channelsModule.name}.${channelsModule.exports}, ${eventsModule.name}.${eventsModule.exports}> {}\\n`\n\n return content\n }\n}\n\nclass ChannelsModule extends ReExportTypeModule {\n public static async create(channels: Record<string, types.Channel>): Promise<ChannelsModule> {\n const channelModules = await bluebird.map(Object.entries(channels), async ([channelName, channel]) => {\n const mod = await ChannelModule.create(channelName, channel)\n return mod.unshift(channelName)\n })\n const inst = new ChannelsModule({ exportName: 'Channels' })\n inst.pushDep(...channelModules)\n return inst\n }\n}\n\nclass ActionsModule extends ReExportTypeModule {\n public static async create(actions: Record<string, types.Action>): Promise<ActionsModule> {\n const actionModules = await bluebird.map(Object.entries(actions), async ([actionName, action]) => {\n const mod = await ActionModule.create(actionName, action)\n return mod.unshift(actionName)\n })\n\n const inst = new ActionsModule({\n exportName: 'Actions',\n })\n\n inst.pushDep(...actionModules)\n return inst\n }\n}\n\nclass EventsModule extends ReExportTypeModule {\n public static async create(events: Record<string, types.Event>): Promise<EventsModule> {\n const eventModules = await bluebird.map(Object.entries(events), async ([eventName, event]) =>\n EventModule.create(eventName, event)\n )\n\n const inst = new EventsModule({\n exportName: 'Events',\n })\n inst.pushDep(...eventModules)\n return inst\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AACrB,oBAA6B;AAC7B,qBAA8B;AAC9B,2BAAoC;AACpC,mBAA6C;AAC7C,mBAA4B;AAC5B,oBAAsD;AAG/C,MAAM,6CAA6C,qBAAO;AAAA,EAkCvD,YACE,cACA,eACA,gBACA,cACA,eACR,KACA;AACA,UAAM,GAAG;AAPD;AACA;AACA;AACA;AACA;AAAA,EAIV;AAAA,EA1CA,aAAoB,OAAO,aAAmF;AAC5G,UAAM,eAAe,MAAM,yCAAoB,OAAO,YAAY,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAC;AAEjG,UAAM,gBAAgB,MAAM,cAAc,OAAO,YAAY,WAA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rationDefinition } from '@botpress/sdk'\nimport bluebird from 'bluebird'\nimport { ActionModule } from './action'\nimport { ChannelModule } from './channel'\nimport { ConfigurationModule } from './configuration'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport { EventModule } from './event'\nimport { Module, ModuleDef, ReExportTypeModule } from './module'\nimport type * as types from './typings'\n\nexport class IntegrationImplementationIndexModule extends Module {\n public static async create(integration: IntegrationDefinition): Promise<IntegrationImplementationIndexModule> {\n const configModule = await ConfigurationModule.create(integration.configuration ?? { schema: {} })\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 { name, version } = integration\n const inst = new IntegrationImplementationIndexModule(\n configModule,\n actionsModule,\n channelsModule,\n eventsModule,\n { name, version },\n {\n path: INDEX_FILE,\n exportName: 'Integration',\n content: '',\n }\n )\n\n inst.pushDep(configModule)\n inst.pushDep(actionsModule)\n inst.pushDep(channelsModule)\n inst.pushDep(eventsModule)\n return inst\n }\n\n private constructor(\n private configModule: ConfigurationModule,\n private actionsModule: ActionsModule,\n private channelsModule: ChannelsModule,\n private eventsModule: EventsModule,\n private integrationID: { name: string; version: string },\n def: ModuleDef\n ) {\n super(def)\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n\n const { configModule, actionsModule, channelsModule, eventsModule } = this\n\n content += 'import * as sdk from \"@botpress/sdk\";\\n\\n'\n\n const configImport = configModule.import(this)\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n\n content += `import type * as ${configModule.name} from \"./${configImport}\";\\n`\n content += `import type * as ${actionsModule.name} from \"./${actionsImport}\";\\n`\n content += `import type * as ${channelsModule.name} from \"./${channelsImport}\";\\n`\n content += `import type * as ${eventsModule.name} from \"./${eventsImport}\";\\n`\n content += `export * as ${configModule.name} from \"./${configImport}\";\\n`\n content += `export * as ${actionsModule.name} from \"./${actionsImport}\";\\n`\n content += `export * as ${channelsModule.name} from \"./${channelsImport}\";\\n`\n content += `export * as ${eventsModule.name} from \"./${eventsImport}\";\\n`\n\n content += '\\n'\n\n content += `export class Integration\n extends sdk.Integration<${configModule.name}.${configModule.exports}, ${actionsModule.name}.${actionsModule.exports}, ${channelsModule.name}.${channelsModule.exports}, ${eventsModule.name}.${eventsModule.exports}> {}\\n`\n\n content += `export type IntegrationProps = sdk.IntegrationProps<${configModule.name}.${configModule.exports}, ${actionsModule.name}.${actionsModule.exports}, ${channelsModule.name}.${channelsModule.exports}, ${eventsModule.name}.${eventsModule.exports}>;\\n`\n\n return content\n }\n}\n\nclass ChannelsModule extends ReExportTypeModule {\n public static async create(channels: Record<string, types.Channel>): Promise<ChannelsModule> {\n const channelModules = await bluebird.map(Object.entries(channels), async ([channelName, channel]) => {\n const mod = await ChannelModule.create(channelName, channel)\n return mod.unshift(channelName)\n })\n const inst = new ChannelsModule({ exportName: 'Channels' })\n inst.pushDep(...channelModules)\n return inst\n }\n}\n\nclass ActionsModule extends ReExportTypeModule {\n public static async create(actions: Record<string, types.Action>): Promise<ActionsModule> {\n const actionModules = await bluebird.map(Object.entries(actions), async ([actionName, action]) => {\n const mod = await ActionModule.create(actionName, action)\n return mod.unshift(actionName)\n })\n\n const inst = new ActionsModule({\n exportName: 'Actions',\n })\n\n inst.pushDep(...actionModules)\n return inst\n }\n}\n\nclass EventsModule extends ReExportTypeModule {\n public static async create(events: Record<string, types.Event>): Promise<EventsModule> {\n const eventModules = await bluebird.map(Object.entries(events), async ([eventName, event]) =>\n EventModule.create(eventName, event)\n )\n\n const inst = new EventsModule({\n exportName: 'Events',\n })\n inst.pushDep(...eventModules)\n return inst\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AACrB,oBAA6B;AAC7B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AAED,UAAM,OAAO,IAAI,cAAc;AAAA,MAC7B,YAAY;AAAA,IACd,CAAC;AAED,SAAK,QAAQ,GAAG,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;AAEA,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,aAAoB,OAAO,QAA4D;AACrF,UAAM,eAAe,MAAM,gBAAAA,QAAS;AAAA,MAAI,OAAO,QAAQ,MAAM;AAAA,MAAG,OAAO,CAAC,WAAW,KAAK,MACtF,yBAAY,OAAO,WAAW,KAAK;AAAA,IACrC;AAEA,UAAM,OAAO,IAAI,aAAa;AAAA,MAC5B,YAAY;AAAA,IACd,CAAC;AACD,SAAK,QAAQ,GAAG,YAAY;AAC5B,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["bluebird"]
|
|
7
7
|
}
|
|
@@ -84,7 +84,11 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
84
84
|
const line = this.logger.line();
|
|
85
85
|
line.started(`Deploying integration ${import_chalk.default.bold(integrationDef.name)} v${integrationDef.version}...`);
|
|
86
86
|
if (integration) {
|
|
87
|
-
|
|
87
|
+
const publishUpdateBody = this._prepareUpdateIntegrationBody(integration, {
|
|
88
|
+
id: integration.id,
|
|
89
|
+
...publishBody
|
|
90
|
+
});
|
|
91
|
+
await api.client.updateIntegration(publishUpdateBody).catch((thrown) => {
|
|
88
92
|
throw errors.BotpressCLIError.wrap(thrown, `Could not update integration "${integrationDef.name}"`);
|
|
89
93
|
});
|
|
90
94
|
} else {
|
|
@@ -94,6 +98,37 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
94
98
|
}
|
|
95
99
|
line.success("Integration deployed");
|
|
96
100
|
}
|
|
101
|
+
_prepareUpdateIntegrationBody = (integration, body) => ({
|
|
102
|
+
...body,
|
|
103
|
+
actions: utils.records.setOnNullMissingValues(body.actions, integration.actions),
|
|
104
|
+
events: utils.records.setOnNullMissingValues(body.events, integration.events),
|
|
105
|
+
states: utils.records.setOnNullMissingValues(body.states, integration.states),
|
|
106
|
+
user: {
|
|
107
|
+
...body.user,
|
|
108
|
+
tags: utils.records.setOnNullMissingValues(body.user?.tags, integration.user?.tags)
|
|
109
|
+
},
|
|
110
|
+
channels: Object.entries(body.channels ?? {}).reduce((acc, [channelName, channelDef]) => {
|
|
111
|
+
const currentChannel = integration.channels[channelName];
|
|
112
|
+
return {
|
|
113
|
+
...acc,
|
|
114
|
+
[channelName]: {
|
|
115
|
+
...channelDef,
|
|
116
|
+
messages: utils.records.setOnNullMissingValues(channelDef.messages, currentChannel?.messages),
|
|
117
|
+
message: {
|
|
118
|
+
...channelDef.message,
|
|
119
|
+
tags: utils.records.setOnNullMissingValues(channelDef.message?.tags, currentChannel?.message.tags)
|
|
120
|
+
},
|
|
121
|
+
conversation: {
|
|
122
|
+
...channelDef.conversation,
|
|
123
|
+
tags: utils.records.setOnNullMissingValues(
|
|
124
|
+
channelDef.conversation?.tags,
|
|
125
|
+
currentChannel?.conversation.tags
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}, {})
|
|
131
|
+
});
|
|
97
132
|
_readMediaFile = async (filePurpose, filePath) => {
|
|
98
133
|
if (!filePath) {
|
|
99
134
|
return void 0;
|
|
@@ -137,7 +172,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
137
172
|
const integrations = this.prepareIntegrations(botImpl, bot);
|
|
138
173
|
const line = this.logger.line();
|
|
139
174
|
line.started(`Deploying bot ${import_chalk.default.bold(bot.name)}...`);
|
|
140
|
-
const
|
|
175
|
+
const updateBotBody = this._prepareUpdateBotBody(bot, {
|
|
141
176
|
id: bot.id,
|
|
142
177
|
code,
|
|
143
178
|
states,
|
|
@@ -148,12 +183,31 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
148
183
|
conversation,
|
|
149
184
|
message,
|
|
150
185
|
integrations
|
|
151
|
-
})
|
|
186
|
+
});
|
|
187
|
+
const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {
|
|
152
188
|
throw errors.BotpressCLIError.wrap(thrown, `Could not update bot "${bot.name}"`);
|
|
153
189
|
});
|
|
154
190
|
line.success("Bot deployed");
|
|
155
191
|
this.displayWebhookUrls(updatedBot);
|
|
156
192
|
}
|
|
193
|
+
_prepareUpdateBotBody = (bot, body) => ({
|
|
194
|
+
...body,
|
|
195
|
+
states: utils.records.setOnNullMissingValues(body.states, bot.states),
|
|
196
|
+
recurringEvents: utils.records.setOnNullMissingValues(body.recurringEvents, bot.recurringEvents),
|
|
197
|
+
events: utils.records.setOnNullMissingValues(body.events, bot.events),
|
|
198
|
+
user: {
|
|
199
|
+
...body.user,
|
|
200
|
+
tags: utils.records.setOnNullMissingValues(body.user?.tags, bot.user?.tags)
|
|
201
|
+
},
|
|
202
|
+
conversation: {
|
|
203
|
+
...body.conversation,
|
|
204
|
+
tags: utils.records.setOnNullMissingValues(body.conversation?.tags, bot.conversation?.tags)
|
|
205
|
+
},
|
|
206
|
+
message: {
|
|
207
|
+
...body.message,
|
|
208
|
+
tags: utils.records.setOnNullMissingValues(body.message?.tags, bot.message?.tags)
|
|
209
|
+
}
|
|
210
|
+
});
|
|
157
211
|
async _createNewBot(api) {
|
|
158
212
|
const line = this.logger.line();
|
|
159
213
|
const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { Bot as BotImpl, IntegrationDefinition } from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport type { ApiClient } from 'src/api-client'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\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 if (api.host !== consts.defaultBotpressApi) {\n this.logger.log(`Using custom host ${api.host}`)\n }\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n return this._deployIntegration(api, integrationDef)\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: IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n let code = await fs.promises.readFile(outfile, 'utf-8')\n\n const secrets = await this.promptSecrets(integrationDef, this.argv)\n // TODO: provide these secrets to the backend by API and remove this string replacement hack\n for (const [secretName, secretValue] of Object.entries(secrets)) {\n code = code.replace(new RegExp(`process\\\\.env\\\\.${secretName}`, 'g'), `\"${secretValue}\"`)\n }\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath } = integrationDef\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will overwrite the existing one.')\n message = `Are you sure you want to override integration ${integrationDef.name} v${integrationDef.version}?`\n } else {\n message = `Are you sure you want to deploy integration ${integrationDef.name} v${integrationDef.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 publishBody: Parameters<typeof api.client.createIntegration>[0] = {\n ...integrationDef,\n icon: iconFileContent,\n readme: readmeFileContent,\n code,\n }\n\n const line = this.logger.line()\n line.started(`Deploying integration ${chalk.bold(integrationDef.name)} v${integrationDef.version}...`)\n if (integration) {\n await api.client.updateIntegration({ id: integration.id, ...publishBody }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${integrationDef.name}\"`)\n })\n } else {\n await api.client.createIntegration(publishBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${integrationDef.name}\"`)\n })\n }\n line.success('Integration deployed')\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: BotImpl }>(outfile)\n\n const {\n states,\n events,\n recurringEvents,\n configuration: botConfiguration,\n user,\n conversation,\n message,\n } = botImpl.definition\n\n let bot: bpclient.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 integrations = this.prepareIntegrations(botImpl, bot)\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n const { bot: updatedBot } = await api.client\n .updateBot({\n id: bot.id,\n code,\n states,\n recurringEvents,\n configuration: botConfiguration,\n events,\n user,\n conversation,\n message,\n integrations,\n })\n .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<bpclient.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<bpclient.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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AAGpB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;
|
|
4
|
+
"sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type { Bot as BotImpl, IntegrationDefinition } from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport type { ApiClient } from 'src/api-client'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\ntype CreateIntegrationBody = Parameters<bpclient.Client['createIntegration']>[0]\ntype UpdateIntegrationBody = Parameters<bpclient.Client['updateIntegration']>[0]\ntype UpdateBotBody = Parameters<bpclient.Client['updateBot']>[0]\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 if (api.host !== consts.defaultBotpressApi) {\n this.logger.log(`Using custom host ${api.host}`)\n }\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n return this._deployIntegration(api, integrationDef)\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: IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n let code = await fs.promises.readFile(outfile, 'utf-8')\n\n const secrets = await this.promptSecrets(integrationDef, this.argv)\n // TODO: provide these secrets to the backend by API and remove this string replacement hack\n for (const [secretName, secretValue] of Object.entries(secrets)) {\n code = code.replace(new RegExp(`process\\\\.env\\\\.${secretName}`, 'g'), `\"${secretValue}\"`)\n }\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath } = integrationDef\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will overwrite the existing one.')\n message = `Are you sure you want to override integration ${integrationDef.name} v${integrationDef.version}?`\n } else {\n message = `Are you sure you want to deploy integration ${integrationDef.name} v${integrationDef.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 publishBody: CreateIntegrationBody = {\n ...integrationDef,\n icon: iconFileContent,\n readme: readmeFileContent,\n code,\n }\n\n const line = this.logger.line()\n line.started(`Deploying integration ${chalk.bold(integrationDef.name)} v${integrationDef.version}...`)\n if (integration) {\n const publishUpdateBody: UpdateIntegrationBody = this._prepareUpdateIntegrationBody(integration, {\n id: integration.id,\n ...publishBody,\n })\n\n await api.client.updateIntegration(publishUpdateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${integrationDef.name}\"`)\n })\n } else {\n await api.client.createIntegration(publishBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${integrationDef.name}\"`)\n })\n }\n line.success('Integration deployed')\n }\n\n // all fields that were removed are replaced by null for the API to remove them\n private _prepareUpdateIntegrationBody = (\n integration: bpclient.Integration,\n body: UpdateIntegrationBody\n ): UpdateIntegrationBody => ({\n ...body,\n actions: utils.records.setOnNullMissingValues(body.actions, integration.actions),\n events: utils.records.setOnNullMissingValues(body.events, integration.events),\n states: utils.records.setOnNullMissingValues(body.states, integration.states),\n user: {\n ...body.user,\n tags: utils.records.setOnNullMissingValues(body.user?.tags, integration.user?.tags),\n },\n channels: Object.entries(body.channels ?? {}).reduce((acc, [channelName, channelDef]) => {\n const currentChannel = integration.channels[channelName]\n return {\n ...acc,\n [channelName]: {\n ...channelDef,\n messages: utils.records.setOnNullMissingValues(channelDef.messages, currentChannel?.messages),\n message: {\n ...channelDef.message,\n tags: utils.records.setOnNullMissingValues(channelDef.message?.tags, currentChannel?.message.tags),\n },\n conversation: {\n ...channelDef.conversation,\n tags: utils.records.setOnNullMissingValues(\n channelDef.conversation?.tags,\n currentChannel?.conversation.tags\n ),\n },\n },\n }\n }, {} as UpdateIntegrationBody['channels']),\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: BotImpl }>(outfile)\n\n const {\n states,\n events,\n recurringEvents,\n configuration: botConfiguration,\n user,\n conversation,\n message,\n } = botImpl.definition\n\n let bot: bpclient.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 integrations = this.prepareIntegrations(botImpl, bot)\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const updateBotBody: UpdateBotBody = this._prepareUpdateBotBody(bot, {\n id: bot.id,\n code,\n states,\n recurringEvents,\n configuration: botConfiguration,\n events,\n user,\n conversation,\n message,\n integrations,\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 // all fields that were removed are replaced by null for the API to remove them\n private _prepareUpdateBotBody = (bot: bpclient.Bot, body: UpdateBotBody): UpdateBotBody => ({\n ...body,\n states: utils.records.setOnNullMissingValues(body.states, bot.states),\n recurringEvents: utils.records.setOnNullMissingValues(body.recurringEvents, bot.recurringEvents),\n events: utils.records.setOnNullMissingValues(body.events, bot.events),\n user: {\n ...body.user,\n tags: utils.records.setOnNullMissingValues(body.user?.tags, bot.user?.tags),\n },\n conversation: {\n ...body.conversation,\n tags: utils.records.setOnNullMissingValues(body.conversation?.tags, bot.conversation?.tags),\n },\n message: {\n ...body.message,\n tags: utils.records.setOnNullMissingValues(body.message?.tags, bot.message?.tags),\n },\n })\n\n private async _createNewBot(api: ApiClient): Promise<bpclient.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<bpclient.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 })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,YAAM,WAAW,MAAM,IACpB,aAAa,IAAI,OAAO,UAAU,CAAC,MAAM,EAAE,IAAI,EAC/C,MAAM,CAAC,WAAW;AACjB,cAAM,OAAO,iBAAiB,KAAK,QAAQ,+BAA+B;AAAA,MAC5E,CAAC;AAEH,UAAI,CAAC,SAAS,QAAQ;AACpB,cAAM,IAAI,OAAO,iBAAiB;AAAA,MACpC;AAEA,YAAM,UAAU,SAAS,KAAK,CAAC,QAAQ,IAAI,OAAO,SAAS;AAE3D,YAAM,WAAW,MAAM,KAAK,OAAO,OAAO,oCAAoC;AAAA,QAC5E,SAAS,WAAW,EAAE,OAAO,QAAQ,MAAM,OAAO,QAAQ,GAAG;AAAA,QAC7D,SAAS,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,IAAI,MAAM,OAAO,IAAI,GAAG,EAAE;AAAA,MACrE,CAAC;AAED,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,mBAAmB,QAAQ;AAAA,MAC9C;AAEA,aAAO;AAAA,IACT,CAAC;AAED,UAAM,EAAE,KAAK,WAAW,IAAI,MAAM,IAAI,OAAO,OAAO,EAAE,IAAI,cAAc,CAAC,EAAE,MAAM,CAAC,WAAW;AAC3F,YAAM,OAAO,iBAAiB,KAAK,QAAQ,wBAAwB;AAAA,IACrE,CAAC;AAED,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/utils/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(utils_exports, {
|
|
|
31
31
|
filewatcher: () => filewatcher,
|
|
32
32
|
path: () => path,
|
|
33
33
|
prompt: () => prompt,
|
|
34
|
+
records: () => records,
|
|
34
35
|
require: () => require2
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -42,6 +43,7 @@ var emitter = __toESM(require("./event-emitter"));
|
|
|
42
43
|
var cache = __toESM(require("./cache-utils"));
|
|
43
44
|
var casing = __toESM(require("./case-utils"));
|
|
44
45
|
var prompt = __toESM(require("./prompt-utils"));
|
|
46
|
+
var records = __toESM(require("./record-utils"));
|
|
45
47
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
48
|
0 && (module.exports = {
|
|
47
49
|
cache,
|
|
@@ -51,6 +53,7 @@ var prompt = __toESM(require("./prompt-utils"));
|
|
|
51
53
|
filewatcher,
|
|
52
54
|
path,
|
|
53
55
|
prompt,
|
|
56
|
+
records,
|
|
54
57
|
require
|
|
55
58
|
});
|
|
56
59
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * as esbuild from './esbuild-utils'\nexport * as path from './path-utils'\nexport * as require from './require-utils'\nexport * as filewatcher from './file-watcher'\nexport * as emitter from './event-emitter'\nexport * as cache from './cache-utils'\nexport * as casing from './case-utils'\nexport * as prompt from './prompt-utils'\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;AAAA,cAAyB;AACzB,WAAsB;AACtB,IAAAA,WAAyB;AACzB,kBAA6B;AAC7B,cAAyB;AACzB,YAAuB;AACvB,aAAwB;AACxB,aAAwB;",
|
|
4
|
+
"sourcesContent": ["export * as esbuild from './esbuild-utils'\nexport * as path from './path-utils'\nexport * as require from './require-utils'\nexport * as filewatcher from './file-watcher'\nexport * as emitter from './event-emitter'\nexport * as cache from './cache-utils'\nexport * as casing from './case-utils'\nexport * as prompt from './prompt-utils'\nexport * as records from './record-utils'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;AAAA,cAAyB;AACzB,WAAsB;AACtB,IAAAA,WAAyB;AACzB,kBAA6B;AAC7B,cAAyB;AACzB,YAAuB;AACvB,aAAwB;AACxB,aAAwB;AACxB,cAAyB;",
|
|
6
6
|
"names": ["require"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var record_utils_exports = {};
|
|
20
|
+
__export(record_utils_exports, {
|
|
21
|
+
setOnNullMissingValues: () => setOnNullMissingValues
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(record_utils_exports);
|
|
24
|
+
const setOnNullMissingValues = (record = {}, oldRecord = {}) => {
|
|
25
|
+
const newRecord = {};
|
|
26
|
+
for (const [key, value] of Object.entries(record)) {
|
|
27
|
+
newRecord[key] = value;
|
|
28
|
+
}
|
|
29
|
+
for (const value of Object.keys(oldRecord)) {
|
|
30
|
+
if (!record[value]) {
|
|
31
|
+
newRecord[value] = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return newRecord;
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
setOnNullMissingValues
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=record-utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/record-utils.ts"],
|
|
4
|
+
"sourcesContent": ["export const setOnNullMissingValues = <A, B>(\n record: Record<string, A> = {},\n oldRecord: Record<string, B> = {}\n): Record<string, A | null> => {\n const newRecord: Record<string, A | null> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = value\n }\n\n for (const value of Object.keys(oldRecord)) {\n if (!record[value]) {\n newRecord[value] = null\n }\n }\n\n return newRecord\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,yBAAyB,CACpC,SAA4B,CAAC,GAC7B,YAA+B,CAAC,MACH;AAC7B,QAAM,YAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO;AAAA,EACnB;AAEA,aAAW,SAAS,OAAO,KAAK,SAAS,GAAG;AAC1C,QAAI,CAAC,OAAO,QAAQ;AAClB,gBAAU,SAAS;AAAA,IACrB;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run bundle && pnpm run template:gen",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"zod-to-json-schema": "^3.20.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@botpress/sdk": "0.1.
|
|
47
|
+
"@botpress/sdk": "0.1.3",
|
|
48
48
|
"@types/bluebird": "^3.5.38",
|
|
49
49
|
"@types/prompts": "^2.0.14",
|
|
50
50
|
"@types/semver": "^7.3.11",
|
|
@@ -15,3 +15,4 @@ export * as events from "./events/index";
|
|
|
15
15
|
|
|
16
16
|
export class Integration
|
|
17
17
|
extends sdk.Integration<configuration.Configuration, actions.Actions, channels.Channels, events.Events> {}
|
|
18
|
+
export type IntegrationProps = sdk.IntegrationProps<configuration.Configuration, actions.Actions, channels.Channels, events.Events>;
|