@botpress/cli 2.2.5 → 3.0.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 +10 -10
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +10 -2
- package/dist/api/client.js.map +2 -2
- package/dist/api/find-previous-version.test.js +1 -1
- package/dist/api/find-previous-version.test.js.map +2 -2
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +2 -2
- package/dist/api/integration-body.js +6 -19
- package/dist/api/integration-body.js.map +2 -2
- package/dist/api/interface-body.js +1 -5
- package/dist/api/interface-body.js.map +2 -2
- package/dist/api/plugin-body.js +3 -0
- package/dist/api/plugin-body.js.map +2 -2
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-implementation.js +5 -2
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +3 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-typings/index.js +11 -2
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-typings/tables-module.js +64 -0
- package/dist/code-generation/bot-implementation/bot-typings/tables-module.js.map +7 -0
- package/dist/code-generation/generators.js +11 -2
- package/dist/code-generation/generators.js.map +3 -3
- package/dist/code-generation/integration-package/index.js +4 -21
- package/dist/code-generation/integration-package/index.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +10 -1
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js +11 -1
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js +10 -8
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js +10 -5
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js +9 -1
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js +9 -4
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/index.js +12 -3
- package/dist/code-generation/integration-package/integration-package-definition/index.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/interfaces-module.js +61 -0
- package/dist/code-generation/integration-package/integration-package-definition/interfaces-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js +6 -1
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/typings.js.map +1 -1
- package/dist/code-generation/interface-package/index.js +4 -21
- package/dist/code-generation/interface-package/index.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +10 -1
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js +9 -1
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js +9 -1
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js +9 -1
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/index.js +0 -2
- package/dist/code-generation/interface-package/interface-package-definition/index.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/typings.js.map +1 -1
- package/dist/code-generation/module.js +13 -7
- package/dist/code-generation/module.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +27 -4
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +19 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/tables-module.js +64 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/tables-module.js.map +7 -0
- package/dist/code-generation/plugin-package/index.js +4 -46
- package/dist/code-generation/plugin-package/index.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +8 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +10 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +9 -4
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js +15 -3
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/interfaces-module.js +58 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/interfaces-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +6 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js.map +1 -1
- package/dist/code-generation/strings.js +10 -5
- package/dist/code-generation/strings.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/code-generation/typings.test.js +15 -0
- package/dist/code-generation/typings.test.js.map +7 -0
- package/dist/command-implementations/add-command.js +70 -25
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +34 -27
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +26 -68
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +13 -17
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/lint-command.js +5 -8
- package/dist/command-implementations/lint-command.js.map +3 -3
- package/dist/command-implementations/plugin-commands.js +1 -2
- package/dist/command-implementations/plugin-commands.js.map +2 -2
- package/dist/command-implementations/project-command.js +82 -34
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +23 -8
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/command-implementations/serve-command.js +1 -1
- package/dist/command-implementations/serve-command.js.map +1 -1
- package/dist/consts.js +4 -2
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +3 -3
- package/dist/errors.js.map +2 -2
- package/dist/linter/base-linter.test.js +6 -1
- package/dist/linter/base-linter.test.js.map +2 -2
- package/dist/linter/bot-linter.js.map +2 -2
- package/dist/linter/integration-linter.js.map +1 -1
- package/dist/linter/interface-linter.js.map +2 -2
- package/dist/linter/ruleset-tests/bot.ruleset.test.js.map +2 -2
- package/dist/linter/ruleset-tests/interface.ruleset.test.js.map +2 -2
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/index.js.map +2 -2
- package/dist/{sdk/resolve-bot-interfaces.js → tables/index.js} +7 -21
- package/dist/tables/index.js.map +7 -0
- package/dist/tables/schemas.js +106 -0
- package/dist/tables/schemas.js.map +7 -0
- package/dist/tables/tables-publisher.js +157 -0
- package/dist/tables/tables-publisher.js.map +7 -0
- package/dist/utils/esbuild-utils.js +15 -13
- package/dist/utils/esbuild-utils.js.map +2 -2
- package/dist/utils/type-utils.js.map +1 -1
- package/package.json +4 -4
- package/templates/empty-bot/.botpress/implementation/index.ts +5 -2
- package/templates/empty-bot/.botpress/implementation/typings/index.ts +3 -0
- package/templates/empty-bot/.botpress/implementation/typings/tables/index.ts +6 -0
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/.botpress/implementation/index.ts +27 -4
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +3 -0
- package/templates/empty-plugin/.botpress/implementation/typings/tables/index.ts +6 -0
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
- package/dist/sdk/resolve-bot-interfaces.js.map +0 -7
- package/dist/sdk/resolve-integration-interfaces.js +0 -161
- package/dist/sdk/resolve-integration-interfaces.js.map +0 -7
|
@@ -38,47 +38,54 @@ var import_project_command = require("./project-command");
|
|
|
38
38
|
class BundleCommand extends import_project_command.ProjectCommand {
|
|
39
39
|
async run() {
|
|
40
40
|
const projectDef = await this.readProjectDefinitionFromFS();
|
|
41
|
+
const abs = this.projectPaths.abs;
|
|
42
|
+
const rel = this.projectPaths.rel("workDir");
|
|
43
|
+
const line = this.logger.line();
|
|
41
44
|
if (projectDef.type === "interface") {
|
|
42
45
|
this.logger.success("Interface projects have no implementation to bundle.");
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const line = this.logger.line();
|
|
46
|
-
if (projectDef.type === "integration") {
|
|
46
|
+
} else if (projectDef.type === "integration") {
|
|
47
47
|
const { name, __advanced } = projectDef.definition;
|
|
48
48
|
line.started(`Bundling integration ${import_chalk.default.bold(name)}...`);
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
if (projectDef.type === "bot") {
|
|
49
|
+
await this._bundle(abs.outFileCJS, __advanced?.esbuild ?? {});
|
|
50
|
+
} else if (projectDef.type === "bot") {
|
|
52
51
|
line.started("Bundling bot...");
|
|
53
|
-
|
|
52
|
+
await this._bundle(abs.outFileCJS);
|
|
53
|
+
} else if (projectDef.type === "plugin") {
|
|
54
|
+
line.started("Bundling plugin with platform node...");
|
|
55
|
+
await this._bundle(abs.outFileCJS);
|
|
56
|
+
line.started("Bundling plugin with platform browser...");
|
|
57
|
+
await this._bundle(abs.outFileESM, { platform: "browser", format: "esm" });
|
|
58
|
+
} else {
|
|
59
|
+
throw new errors.UnsupportedProjectType();
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
line.started("Bundling plugin...");
|
|
57
|
-
return await this._bundle(line);
|
|
58
|
-
}
|
|
59
|
-
throw new errors.UnsupportedProjectType();
|
|
61
|
+
line.success(`Bundle available at ${import_chalk.default.grey(rel.outDir)}`);
|
|
60
62
|
}
|
|
61
|
-
async _bundle(
|
|
63
|
+
async _bundle(outfile, props = {}) {
|
|
62
64
|
const abs = this.projectPaths.abs;
|
|
65
|
+
await utils.esbuild.buildCode(
|
|
66
|
+
{
|
|
67
|
+
outfile,
|
|
68
|
+
absWorkingDir: abs.workDir,
|
|
69
|
+
code: this._code
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
...this._buildOptions,
|
|
73
|
+
...props
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
get _code() {
|
|
63
78
|
const rel = this.projectPaths.rel("workDir");
|
|
64
79
|
const unixPath = utils.path.toUnix(rel.entryPoint);
|
|
65
80
|
const importFrom = utils.path.rmExtension(unixPath);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
return `import x from './${importFrom}'; export default x; export const handler = x.handler;`;
|
|
82
|
+
}
|
|
83
|
+
get _buildOptions() {
|
|
84
|
+
return {
|
|
69
85
|
logLevel: this.argv.verbose ? "info" : "silent",
|
|
70
86
|
sourcemap: this.argv.sourceMap,
|
|
71
|
-
minify: this.argv.minify
|
|
72
|
-
...props
|
|
87
|
+
minify: this.argv.minify
|
|
73
88
|
};
|
|
74
|
-
await utils.esbuild.buildCode({
|
|
75
|
-
...buildOptions,
|
|
76
|
-
absWorkingDir: abs.workDir,
|
|
77
|
-
outfile: abs.outFile,
|
|
78
|
-
write: true,
|
|
79
|
-
code
|
|
80
|
-
});
|
|
81
|
-
line.success(`Bundle available at ${import_chalk.default.grey(rel.outDir)}`);
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/bundle-command.ts"],
|
|
4
|
-
"sourcesContent": ["import chalk from 'chalk'\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type BundleCommandDefinition = typeof commandDefinitions.bundle\nexport class BundleCommand extends ProjectCommand<BundleCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n const line = this.logger.line()\n\n if (projectDef.type === 'interface') {\n this.logger.success('Interface projects have no implementation to bundle.')\n } else if (projectDef.type === 'integration') {\n const { name, __advanced } = projectDef.definition\n line.started(`Bundling integration ${chalk.bold(name)}...`)\n await this._bundle(abs.outFileCJS, __advanced?.esbuild ?? {})\n } else if (projectDef.type === 'bot') {\n line.started('Bundling bot...')\n await this._bundle(abs.outFileCJS)\n } else if (projectDef.type === 'plugin') {\n line.started('Bundling plugin with platform node...')\n await this._bundle(abs.outFileCJS)\n\n line.started('Bundling plugin with platform browser...')\n await this._bundle(abs.outFileESM, { platform: 'browser', format: 'esm' })\n } else {\n type _assertion = utils.types.AssertNever<typeof projectDef>\n throw new errors.UnsupportedProjectType()\n }\n\n line.success(`Bundle available at ${chalk.grey(rel.outDir)}`)\n }\n\n private async _bundle(outfile: string, props: Partial<utils.esbuild.BuildOptions> = {}) {\n const abs = this.projectPaths.abs\n await utils.esbuild.buildCode(\n {\n outfile,\n absWorkingDir: abs.workDir,\n code: this._code,\n },\n {\n ...this._buildOptions,\n ...props,\n }\n )\n }\n\n private get _code() {\n const rel = this.projectPaths.rel('workDir')\n const unixPath = utils.path.toUnix(rel.entryPoint)\n const importFrom = utils.path.rmExtension(unixPath)\n return `import x from './${importFrom}'; export default x; export const handler = x.handler;`\n }\n\n private get _buildOptions(): Partial<utils.esbuild.BuildOptions> {\n return {\n logLevel: this.argv.verbose ? 'info' : 'silent',\n sourcemap: this.argv.sourceMap,\n minify: this.argv.minify,\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,UAAM,MAAM,KAAK,aAAa;AAC9B,UAAM,MAAM,KAAK,aAAa,IAAI,SAAS;AAC3C,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,QAAI,WAAW,SAAS,aAAa;AACnC,WAAK,OAAO,QAAQ,sDAAsD;AAAA,IAC5E,WAAW,WAAW,SAAS,eAAe;AAC5C,YAAM,EAAE,MAAM,WAAW,IAAI,WAAW;AACxC,WAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,IAAI,MAAM;AAC1D,YAAM,KAAK,QAAQ,IAAI,YAAY,YAAY,WAAW,CAAC,CAAC;AAAA,IAC9D,WAAW,WAAW,SAAS,OAAO;AACpC,WAAK,QAAQ,iBAAiB;AAC9B,YAAM,KAAK,QAAQ,IAAI,UAAU;AAAA,IACnC,WAAW,WAAW,SAAS,UAAU;AACvC,WAAK,QAAQ,uCAAuC;AACpD,YAAM,KAAK,QAAQ,IAAI,UAAU;AAEjC,WAAK,QAAQ,0CAA0C;AACvD,YAAM,KAAK,QAAQ,IAAI,YAAY,EAAE,UAAU,WAAW,QAAQ,MAAM,CAAC;AAAA,IAC3E,OAAO;AAEL,YAAM,IAAI,OAAO,uBAAuB;AAAA,IAC1C;AAEA,SAAK,QAAQ,uBAAuB,aAAAA,QAAM,KAAK,IAAI,MAAM,GAAG;AAAA,EAC9D;AAAA,EAEA,MAAc,QAAQ,SAAiB,QAA6C,CAAC,GAAG;AACtF,UAAM,MAAM,KAAK,aAAa;AAC9B,UAAM,MAAM,QAAQ;AAAA,MAClB;AAAA,QACE;AAAA,QACA,eAAe,IAAI;AAAA,QACnB,MAAM,KAAK;AAAA,MACb;AAAA,MACA;AAAA,QACE,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAY,QAAQ;AAClB,UAAM,MAAM,KAAK,aAAa,IAAI,SAAS;AAC3C,UAAM,WAAW,MAAM,KAAK,OAAO,IAAI,UAAU;AACjD,UAAM,aAAa,MAAM,KAAK,YAAY,QAAQ;AAClD,WAAO,oBAAoB;AAAA,EAC7B;AAAA,EAEA,IAAY,gBAAqD;AAC/D,WAAO;AAAA,MACL,UAAU,KAAK,KAAK,UAAU,SAAS;AAAA,MACvC,WAAW,KAAK,KAAK;AAAA,MACrB,QAAQ,KAAK,KAAK;AAAA,IACpB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -35,15 +35,12 @@ var sdk = __toESM(require("@botpress/sdk"));
|
|
|
35
35
|
var import_chalk = __toESM(require("chalk"));
|
|
36
36
|
var fs = __toESM(require("fs"));
|
|
37
37
|
var import_semver = __toESM(require("semver"));
|
|
38
|
-
var
|
|
39
|
-
var import_integration_body = require("../api/integration-body");
|
|
40
|
-
var import_interface_body = require("../api/interface-body");
|
|
41
|
-
var import_plugin_body = require("../api/plugin-body");
|
|
38
|
+
var apiUtils = __toESM(require("../api"));
|
|
42
39
|
var errors = __toESM(require("../errors"));
|
|
43
|
-
var import_sdk = require("../sdk");
|
|
44
40
|
var utils = __toESM(require("../utils"));
|
|
45
41
|
var import_build_command = require("./build-command");
|
|
46
42
|
var import_project_command = require("./project-command");
|
|
43
|
+
var tables = __toESM(require("../tables"));
|
|
47
44
|
class DeployCommand extends import_project_command.ProjectCommand {
|
|
48
45
|
async run() {
|
|
49
46
|
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
@@ -69,21 +66,18 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
69
66
|
return new import_build_command.BuildCommand(this.api, this.prompt, this.logger, this.argv).run();
|
|
70
67
|
}
|
|
71
68
|
async _deployIntegration(api, integrationDef) {
|
|
72
|
-
const outfile = this.projectPaths.abs.outFile;
|
|
73
|
-
const code = await fs.promises.readFile(outfile, "utf-8");
|
|
74
69
|
const { integration: updatedIntegrationDef, workspaceId } = await this._manageWorkspaceHandle(api, integrationDef);
|
|
75
70
|
integrationDef = updatedIntegrationDef;
|
|
76
71
|
if (workspaceId) {
|
|
77
72
|
api = api.switchWorkspace(workspaceId);
|
|
78
73
|
}
|
|
79
|
-
const { name, version
|
|
80
|
-
if (
|
|
74
|
+
const { name, version } = integrationDef;
|
|
75
|
+
if (integrationDef.icon && !integrationDef.icon.toLowerCase().endsWith(".svg")) {
|
|
81
76
|
throw new errors.BotpressCLIError("Icon must be an SVG file");
|
|
82
77
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const fallbackHandlerScriptFileContent = await this.readProjectFile(identifier?.fallbackHandlerScript);
|
|
78
|
+
if (integrationDef.readme && !integrationDef.readme.toLowerCase().endsWith(".md")) {
|
|
79
|
+
throw new errors.BotpressCLIError("Readme must be a Markdown file");
|
|
80
|
+
}
|
|
87
81
|
const integration = await api.findIntegration({ type: "name", name, version });
|
|
88
82
|
if (integration && integration.workspaceId !== api.workspaceId) {
|
|
89
83
|
throw new errors.BotpressCLIError(
|
|
@@ -108,31 +102,19 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
108
102
|
return;
|
|
109
103
|
}
|
|
110
104
|
this.logger.debug("Preparing integration request body...");
|
|
111
|
-
let createBody = await
|
|
105
|
+
let createBody = await this.prepareCreateIntegrationBody(integrationDef);
|
|
112
106
|
createBody = {
|
|
113
107
|
...createBody,
|
|
114
|
-
interfaces: await this.
|
|
115
|
-
code,
|
|
116
|
-
icon: iconFileContent,
|
|
117
|
-
readme: readmeFileContent,
|
|
118
|
-
configuration: await this.readIntegrationConfigDefinition(createBody.configuration),
|
|
119
|
-
configurations: await utils.promises.awaitRecord(
|
|
120
|
-
utils.records.mapValues(createBody.configurations ?? {}, this.readIntegrationConfigDefinition.bind(this))
|
|
121
|
-
),
|
|
122
|
-
identifier: {
|
|
123
|
-
extractScript: identifierExtractScriptFileContent,
|
|
124
|
-
fallbackHandlerScript: fallbackHandlerScriptFileContent
|
|
125
|
-
},
|
|
108
|
+
interfaces: await this.fetchIntegrationInterfaceInstances(integrationDef, api),
|
|
126
109
|
public: this.argv.public
|
|
127
110
|
};
|
|
128
111
|
const startedMessage = `Deploying integration ${import_chalk.default.bold(name)} v${version}...`;
|
|
129
112
|
const successMessage = "Integration deployed";
|
|
130
113
|
if (integration) {
|
|
131
|
-
const updateBody =
|
|
114
|
+
const updateBody = apiUtils.prepareUpdateIntegrationBody(
|
|
132
115
|
{
|
|
133
116
|
id: integration.id,
|
|
134
|
-
...createBody
|
|
135
|
-
public: this.argv.public
|
|
117
|
+
...createBody
|
|
136
118
|
},
|
|
137
119
|
integration
|
|
138
120
|
);
|
|
@@ -185,11 +167,11 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
185
167
|
this.logger.log("Aborted");
|
|
186
168
|
return;
|
|
187
169
|
}
|
|
188
|
-
const createBody = await
|
|
170
|
+
const createBody = await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration);
|
|
189
171
|
const startedMessage = `Deploying interface ${import_chalk.default.bold(name)} v${version}...`;
|
|
190
172
|
const successMessage = "Interface deployed";
|
|
191
173
|
if (intrface) {
|
|
192
|
-
const updateBody =
|
|
174
|
+
const updateBody = apiUtils.prepareUpdateInterfaceBody(
|
|
193
175
|
{
|
|
194
176
|
id: intrface.id,
|
|
195
177
|
...createBody
|
|
@@ -212,8 +194,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
212
194
|
}
|
|
213
195
|
}
|
|
214
196
|
async _deployPlugin(api, pluginDef) {
|
|
215
|
-
const
|
|
216
|
-
const
|
|
197
|
+
const codeCJS = await fs.promises.readFile(this.projectPaths.abs.outFileCJS, "utf-8");
|
|
198
|
+
const codeESM = await fs.promises.readFile(this.projectPaths.abs.outFileESM, "utf-8");
|
|
217
199
|
const { name, version } = pluginDef;
|
|
218
200
|
const plugin = await api.findPublicPlugin({ type: "name", name, version });
|
|
219
201
|
let message;
|
|
@@ -230,13 +212,16 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
230
212
|
}
|
|
231
213
|
this.logger.debug("Preparing plugin request body...");
|
|
232
214
|
const createBody = {
|
|
233
|
-
...await
|
|
234
|
-
code
|
|
215
|
+
...await apiUtils.prepareCreatePluginBody(pluginDef),
|
|
216
|
+
code: {
|
|
217
|
+
node: codeCJS,
|
|
218
|
+
browser: codeESM
|
|
219
|
+
}
|
|
235
220
|
};
|
|
236
221
|
const startedMessage = `Deploying plugin ${import_chalk.default.bold(name)} v${version}...`;
|
|
237
222
|
const successMessage = "Plugin deployed";
|
|
238
223
|
if (plugin) {
|
|
239
|
-
const updateBody =
|
|
224
|
+
const updateBody = apiUtils.prepareUpdatePluginBody(
|
|
240
225
|
{
|
|
241
226
|
id: plugin.id,
|
|
242
227
|
...createBody
|
|
@@ -294,17 +279,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
294
279
|
throw new errors.BotpressCLIError(errorMessage);
|
|
295
280
|
}
|
|
296
281
|
}
|
|
297
|
-
_readMediaFile = async (filePurpose, filePath) => {
|
|
298
|
-
if (!filePath) {
|
|
299
|
-
return void 0;
|
|
300
|
-
}
|
|
301
|
-
const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath);
|
|
302
|
-
return fs.promises.readFile(absoluteFilePath, "base64").catch((thrown) => {
|
|
303
|
-
throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file "${absoluteFilePath}"`);
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
282
|
async _deployBot(api, botDefinition, argvBotId, argvCreateNew) {
|
|
307
|
-
const outfile = this.projectPaths.abs.
|
|
283
|
+
const outfile = this.projectPaths.abs.outFileCJS;
|
|
308
284
|
const code = await fs.promises.readFile(outfile, "utf-8");
|
|
309
285
|
let bot;
|
|
310
286
|
if (argvBotId && argvCreateNew) {
|
|
@@ -327,8 +303,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
327
303
|
const line = this.logger.line();
|
|
328
304
|
line.started(`Deploying bot ${import_chalk.default.bold(bot.name)}...`);
|
|
329
305
|
const integrationInstances = await this.fetchBotIntegrationInstances(botDefinition, api);
|
|
330
|
-
const createBotBody = await
|
|
331
|
-
const updateBotBody =
|
|
306
|
+
const createBotBody = await apiUtils.prepareCreateBotBody(botDefinition);
|
|
307
|
+
const updateBotBody = apiUtils.prepareUpdateBotBody(
|
|
332
308
|
{
|
|
333
309
|
...createBotBody,
|
|
334
310
|
id: bot.id,
|
|
@@ -340,6 +316,8 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
340
316
|
const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {
|
|
341
317
|
throw errors.BotpressCLIError.wrap(thrown, `Could not update bot "${bot.name}"`);
|
|
342
318
|
});
|
|
319
|
+
const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt });
|
|
320
|
+
await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition });
|
|
343
321
|
line.success("Bot deployed");
|
|
344
322
|
this.displayWebhookUrls(updatedBot);
|
|
345
323
|
}
|
|
@@ -475,26 +453,6 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
475
453
|
const [name] = parts;
|
|
476
454
|
return { name };
|
|
477
455
|
};
|
|
478
|
-
_formatInterfacesImplStatements = async (api, integration) => {
|
|
479
|
-
const interfacesStatements = (0, import_sdk.getImplementationStatements)(integration);
|
|
480
|
-
const interfaces = {};
|
|
481
|
-
for (const [key, i] of Object.entries(interfacesStatements)) {
|
|
482
|
-
const { name, version, entities, actions, events, channels } = i;
|
|
483
|
-
const id = await this._getInterfaceId(api, { id: i.id, name, version });
|
|
484
|
-
interfaces[key] = { id, entities, actions, events, channels };
|
|
485
|
-
}
|
|
486
|
-
return interfaces;
|
|
487
|
-
};
|
|
488
|
-
_getInterfaceId = async (api, ref) => {
|
|
489
|
-
if (ref.id) {
|
|
490
|
-
return ref.id;
|
|
491
|
-
}
|
|
492
|
-
const intrface = await api.findPublicInterface({ type: "name", name: ref.name, version: ref.version });
|
|
493
|
-
if (!intrface) {
|
|
494
|
-
throw new errors.BotpressCLIError(`Could not find interface "${ref.name}@${ref.version}"`);
|
|
495
|
-
}
|
|
496
|
-
return intrface.id;
|
|
497
|
-
};
|
|
498
456
|
}
|
|
499
457
|
// Annotate the CommonJS export names for ESM import in node:
|
|
500
458
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/deploy-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n CreateIntegrationBody,\n prepareUpdateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport { CreateInterfaceBody, prepareCreateInterfaceBody, prepareUpdateInterfaceBody } from '../api/interface-body'\nimport { prepareCreatePluginBody, prepareUpdatePluginBody } from '../api/plugin-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { getImplementationStatements } from '../sdk'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectDef.type === 'plugin') {\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n const { integration: updatedIntegrationDef, workspaceId } = await this._manageWorkspaceHandle(api, integrationDef)\n integrationDef = updatedIntegrationDef\n if (workspaceId) {\n api = api.switchWorkspace(workspaceId)\n }\n\n const { name, version, icon: iconRelativeFilePath, readme: readmeRelativeFilePath, identifier } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this.readProjectFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this.readProjectFile(identifier?.fallbackHandlerScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n let createBody: CreateIntegrationBody = await prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this._formatInterfacesImplStatements(api, integrationDef),\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: await this.readIntegrationConfigDefinition(createBody.configuration),\n configurations: await utils.promises.awaitRecord(\n utils.records.mapValues(createBody.configurations ?? {}, this.readIntegrationConfigDefinition.bind(this))\n ),\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody: CreateInterfaceBody = await prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: ApiClient, pluginDef: sdk.PluginDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n const { name, version } = pluginDef\n\n const plugin = await api.findPublicPlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const createBody = {\n ...(await prepareCreatePluginBody(pluginDef)),\n code,\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _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(\n api: ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botDefinition, api)\n const createBotBody = await prepareCreateBotBody(botDefinition)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...createBotBody,\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<{\n integration: sdk.IntegrationDefinition\n workspaceId?: string // Set if user opted to deploy on another available workspace\n }> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n\n private _formatInterfacesImplStatements = async (\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<CreateIntegrationBody['interfaces']> => {\n const interfacesStatements = getImplementationStatements(integration)\n const interfaces: NonNullable<CreateIntegrationBody['interfaces']> = {}\n for (const [key, i] of Object.entries(interfacesStatements)) {\n const { name, version, entities, actions, events, channels } = i\n const id = await this._getInterfaceId(api, { id: i.id, name, version })\n interfaces[key] = { id, entities, actions, events, channels }\n }\n\n return interfaces\n }\n\n private _getInterfaceId = async (\n api: ApiClient,\n ref: { id?: string; name: string; version: string }\n ): Promise<string> => {\n if (ref.id) {\n return ref.id\n }\n const intrface = await api.findPublicInterface({ type: 'name', name: ref.name, version: ref.version })\n if (!intrface) {\n throw new errors.BotpressCLIError(`Could not find interface \"${ref.name}@${ref.version}\"`)\n }\n return intrface.id\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AACrB,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,sBAA2D;AAE3D,8BAIO;AACP,4BAA4F;AAC5F,yBAAiE;AAEjE,aAAwB;AACxB,iBAA4C;AAC5C,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,eAAe;AACrC,aAAO,KAAK,mBAAmB,KAAK,WAAW,UAAU;AAAA,IAC3D;AACA,QAAI,WAAW,SAAS,aAAa;AACnC,aAAO,KAAK,iBAAiB,KAAK,WAAW,UAAU;AAAA,IACzD;AACA,QAAI,WAAW,SAAS,UAAU;AAChC,aAAO,KAAK,cAAc,KAAK,WAAW,UAAU;AAAA,IACtD;AACA,QAAI,WAAW,SAAS,OAAO;AAC7B,aAAO,KAAK,WAAW,KAAK,WAAW,YAAY,KAAK,KAAK,OAAO,KAAK,KAAK,YAAY;AAAA,IAC5F;AACA,UAAM,IAAI,OAAO,uBAAuB;AAAA,EAC1C;AAAA,EAEA,MAAc,YAAY;AACxB,WAAO,IAAI,kCAAa,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAC7E;AAAA,EAEA,MAAc,mBAAmB,KAAgB,gBAA2C;AAC1F,UAAM,UAAU,K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M,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AAAA,EAEQ,kCAAkC,OACxC,KACA,gBACiD;AACjD,UAAM,2BAAuB,wCAA4B,WAAW;AACpE,UAAM,aAA+D,CAAC;AACtE,eAAW,CAAC,KAAK,CAAC,KAAK,OAAO,QAAQ,oBAAoB,GAAG;AAC3D,YAAM,EAAE,MAAM,SAAS,UAAU,SAAS,QAAQ,SAAS,IAAI;AAC/D,YAAM,KAAK,MAAM,KAAK,gBAAgB,KAAK,EAAE,IAAI,EAAE,IAAI,MAAM,QAAQ,CAAC;AACtE,iBAAW,GAAG,IAAI,EAAE,IAAI,UAAU,SAAS,QAAQ,SAAS;AAAA,IAC9D;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,kBAAkB,OACxB,KACA,QACoB;AACpB,QAAI,IAAI,IAAI;AACV,aAAO,IAAI;AAAA,IACb;AACA,UAAM,WAAW,MAAM,IAAI,oBAAoB,EAAE,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,IAAI,QAAQ,CAAC;AACrG,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,OAAO,iBAAiB,6BAA6B,IAAI,QAAQ,IAAI,UAAU;AAAA,IAC3F;AACA,WAAO,SAAS;AAAA,EAClB;AACF;",
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\nimport * as tables from '../tables'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'integration') {\n return this._deployIntegration(api, projectDef.definition)\n }\n if (projectDef.type === 'interface') {\n return this._deployInterface(api, projectDef.definition)\n }\n if (projectDef.type === 'plugin') {\n return this._deployPlugin(api, projectDef.definition)\n }\n if (projectDef.type === 'bot') {\n return this._deployBot(api, projectDef.definition, this.argv.botId, this.argv.createNewBot)\n }\n throw new errors.UnsupportedProjectType()\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: apiUtils.ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const { integration: updatedIntegrationDef, workspaceId } = await this._manageWorkspaceHandle(api, integrationDef)\n integrationDef = updatedIntegrationDef\n if (workspaceId) {\n api = api.switchWorkspace(workspaceId)\n }\n\n const { name, version } = integrationDef\n\n if (integrationDef.icon && !integrationDef.icon.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n if (integrationDef.readme && !integrationDef.readme.toLowerCase().endsWith('.md')) {\n throw new errors.BotpressCLIError('Readme must be a Markdown file')\n }\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing integration request body...')\n\n let createBody = await this.prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n interfaces: await this.fetchIntegrationInterfaceInstances(integrationDef, api),\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = apiUtils.prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n this.logger.debug(`looking for previous version of integration \"${name}\"`)\n const previousVersion = await api.findPreviousIntegrationVersion({ type: 'name', name, version })\n\n if (previousVersion) {\n this.logger.debug(`previous version found: ${previousVersion.version}`)\n } else {\n this.logger.debug('no previous version found')\n }\n\n const knownSecrets = previousVersion?.secrets\n\n const createSecrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n\n this._detectDeprecatedFeatures(integrationDef, {\n allowDeprecated: this._allowDeprecatedFeatures(integrationDef, previousVersion),\n })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployInterface(api: apiUtils.ApiClient, interfaceDeclaration: sdk.InterfaceDefinition) {\n if (!api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError('Your workspace is not allowed to deploy interfaces.')\n }\n\n const { name, version } = interfaceDeclaration\n const intrface = await api.findPublicInterface({ type: 'name', name, version })\n\n let message: string\n if (intrface) {\n this.logger.warn('Interface already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override interface ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy interface ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n const createBody = await apiUtils.prepareCreateInterfaceBody(interfaceDeclaration)\n\n const startedMessage = `Deploying interface ${chalk.bold(name)} v${version}...`\n const successMessage = 'Interface deployed'\n if (intrface) {\n const updateBody = apiUtils.prepareUpdateInterfaceBody(\n {\n id: intrface.id,\n ...createBody,\n },\n intrface\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateInterface(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update interface \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createInterface(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create interface \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private async _deployPlugin(api: apiUtils.ApiClient, pluginDef: sdk.PluginDefinition) {\n const codeCJS = await fs.promises.readFile(this.projectPaths.abs.outFileCJS, 'utf-8')\n const codeESM = await fs.promises.readFile(this.projectPaths.abs.outFileESM, 'utf-8')\n\n const { name, version } = pluginDef\n\n const plugin = await api.findPublicPlugin({ type: 'name', name, version })\n\n let message: string\n if (plugin) {\n this.logger.warn('Plugin already exists. If you decide to deploy, it will override the existing one.')\n message = `Are you sure you want to override plugin ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy plugin ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n this.logger.debug('Preparing plugin request body...')\n\n const createBody = {\n ...(await apiUtils.prepareCreatePluginBody(pluginDef)),\n code: {\n node: codeCJS,\n browser: codeESM,\n },\n }\n\n const startedMessage = `Deploying plugin ${chalk.bold(name)} v${version}...`\n const successMessage = 'Plugin deployed'\n if (plugin) {\n const updateBody = apiUtils.prepareUpdatePluginBody(\n {\n id: plugin.id,\n ...createBody,\n },\n plugin\n )\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updatePlugin(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update plugin \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createPlugin(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create plugin \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _allowDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n previousVersion: client.Integration | undefined\n ): boolean {\n if (this.argv.allowDeprecated) {\n return true\n }\n\n if (!previousVersion) {\n return false\n }\n\n const versionDiff = semver.diff(integrationDef.version, previousVersion.version)\n if (!versionDiff) {\n return false\n }\n\n return utils.semver.releases.lt(versionDiff, 'major')\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private async _deployBot(\n api: apiUtils.ApiClient,\n botDefinition: sdk.BotDefinition,\n argvBotId: string | undefined,\n argvCreateNew: boolean | undefined\n ) {\n const outfile = this.projectPaths.abs.outFileCJS\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botDefinition, api)\n const createBotBody = await apiUtils.prepareCreateBotBody(botDefinition)\n const updateBotBody = apiUtils.prepareUpdateBotBody(\n {\n ...createBotBody,\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n\n const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt })\n await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition })\n\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: apiUtils.ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: apiUtils.ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: apiUtils.ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<{\n integration: sdk.IntegrationDefinition\n workspaceId?: string // Set if user opted to deploy on another available workspace\n }> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return { integration } // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n let workspaceId: string | undefined = undefined\n if (localHandle !== remoteHandle) {\n const remoteWorkspace = await api.findWorkspaceByHandle(localHandle).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n if (!remoteWorkspace) {\n throw new errors.BotpressCLIError(\n `The integration handle \"${localHandle}\" is not associated with any of your workspaces.`\n )\n }\n this.logger.warn(\n `Your are logged in to workspace \"${workspaceName}\" but integration handle \"${localHandle}\" belongs to \"${remoteWorkspace.name}\".`\n )\n const confirmUseAlternateWorkspace = await this.prompt.confirm(\n 'Do you want to deploy integration on this workspace instead?'\n )\n if (!confirmUseAlternateWorkspace) {\n throw new errors.BotpressCLIError(\n `Cannot deploy integration with handle \"${localHandle}\" on workspace \"${workspaceName}\"`\n )\n }\n\n workspaceId = remoteWorkspace.id\n }\n return { integration, workspaceId }\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return { integration }\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { integration: new sdk.IntegrationDefinition({ ...integration, name: newName }) }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,UAAqB;AACrB,mBAAkB;AAClB,SAAoB;AACpB,oBAAmB;AACnB,eAA0B;AAE1B,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAC/B,aAAwB;AAGjB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,eAAe;AACrC,aAAO,KAAK,mBAAmB,KAAK,WAAW,UAAU;AAAA,IAC3D;AACA,QAAI,WAAW,SAAS,aAAa;AACnC,aAAO,KAAK,iBAAiB,KAAK,WAAW,UAAU;AAAA,IACzD;AACA,QAAI,WAAW,SAAS,UAAU;AAChC,aAAO,KAAK,cAAc,KAAK,WAAW,UAAU;AAAA,IACtD;AACA,QAAI,WAAW,SAAS,OAAO;AAC7B,aAAO,KAAK,WAAW,KAAK,WAAW,YAAY,KAAK,KAAK,OAAO,KAAK,KAAK,YAAY;AAAA,IAC5F;AACA,UAAM,IAAI,OAA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;AAClE,QAAI,gBAAoC;AACxC,OAAG;AACD,YAAM,WAAW,MAAM,KAAK,OAAO,KAAK,iCAAiC;AACzE,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,iBAAiB,6BAA6B;AAAA,MACjE;AAEA,YAAM,EAAE,WAAW,YAAY,IAAI,MAAM,IAAI,OAAO,wBAAwB,EAAE,QAAQ,SAAS,CAAC;AAChG,UAAI,CAAC,WAAW;AACd,aAAK,OAAO,KAAK,WAAW,4CAA4C,YAAY,KAAK,IAAI,GAAG;AAChG;AAAA,MACF;AAEA,sBAAgB;AAChB,YAAM,IAAI,gBAAgB,EAAE,QAAQ,cAAc,CAAC,EAAE,MAAM,CAAC,WAAW;AACrE,cAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B,gBAAgB;AAAA,MACxF,CAAC;AAAA,IACH,SAAS,CAAC;AAEV,SAAK,OAAO,QAAQ,WAAW,0BAA0B;AACzD,UAAM,UAAU,GAAG,iBAAiB;AACpC,WAAO,EAAE,aAAa,IAAI,IAAI,sBAAsB,EAAE,GAAG,aAAa,MAAM,QAAQ,CAAC,EAAE;AAAA,EACzF;AAAA,EAEQ,wBAAwB,CAAC,oBAAwE;AACvG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B;AAAA,MAC/B;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": ["chalk", "semver", "newName", "name"]
|
|
7
7
|
}
|
|
@@ -35,13 +35,13 @@ var import_axios = __toESM(require("axios"));
|
|
|
35
35
|
var import_chalk = __toESM(require("chalk"));
|
|
36
36
|
var pathlib = __toESM(require("path"));
|
|
37
37
|
var uuid = __toESM(require("uuid"));
|
|
38
|
-
var
|
|
39
|
-
var import_integration_body = require("../api/integration-body");
|
|
38
|
+
var apiUtils = __toESM(require("../api"));
|
|
40
39
|
var errors = __toESM(require("../errors"));
|
|
41
40
|
var utils = __toESM(require("../utils"));
|
|
42
41
|
var import_worker = require("../worker");
|
|
43
42
|
var import_build_command = require("./build-command");
|
|
44
43
|
var import_project_command = require("./project-command");
|
|
44
|
+
var tables = __toESM(require("../tables"));
|
|
45
45
|
const DEFAULT_BOT_PORT = 8075;
|
|
46
46
|
const DEFAULT_INTEGRATION_PORT = 8076;
|
|
47
47
|
const TUNNEL_HELLO_INTERVAL = 5e3;
|
|
@@ -188,10 +188,9 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
_spawnWorker = async (env, port) => {
|
|
191
|
-
const outfile = this.projectPaths.abs.
|
|
191
|
+
const outfile = this.projectPaths.abs.outFileCJS;
|
|
192
192
|
const importPath = utils.path.toUnix(outfile);
|
|
193
|
-
const
|
|
194
|
-
const code = `require('${requireFrom}').default.start(${port})`;
|
|
193
|
+
const code = `require('${importPath}').default.start(${port})`;
|
|
195
194
|
const worker = await import_worker.Worker.spawn(
|
|
196
195
|
{
|
|
197
196
|
type: "code",
|
|
@@ -224,20 +223,14 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
224
223
|
}
|
|
225
224
|
const line = this.logger.line();
|
|
226
225
|
line.started(`Deploying dev integration ${import_chalk.default.bold(integrationDef.name)}...`);
|
|
227
|
-
let createIntegrationBody = await
|
|
226
|
+
let createIntegrationBody = await this.prepareCreateIntegrationBody(integrationDef);
|
|
228
227
|
createIntegrationBody = {
|
|
229
228
|
...createIntegrationBody,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
configurations: await utils.promises.awaitRecord(
|
|
233
|
-
utils.records.mapValues(
|
|
234
|
-
createIntegrationBody.configurations ?? {},
|
|
235
|
-
this.readIntegrationConfigDefinition.bind(this)
|
|
236
|
-
)
|
|
237
|
-
)
|
|
229
|
+
interfaces: await this.fetchIntegrationInterfaceInstances(integrationDef, api),
|
|
230
|
+
url: externalUrl
|
|
238
231
|
};
|
|
239
232
|
if (integration) {
|
|
240
|
-
const updateIntegrationBody =
|
|
233
|
+
const updateIntegrationBody = apiUtils.prepareUpdateIntegrationBody(
|
|
241
234
|
{ ...createIntegrationBody, id: integration.id },
|
|
242
235
|
integration
|
|
243
236
|
);
|
|
@@ -287,9 +280,10 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
287
280
|
const updateLine = this.logger.line();
|
|
288
281
|
updateLine.started("Deploying dev bot...");
|
|
289
282
|
const integrationInstances = await this.fetchBotIntegrationInstances(botDef, api);
|
|
290
|
-
const
|
|
283
|
+
const createBotBody = await apiUtils.prepareCreateBotBody(botDef);
|
|
284
|
+
const updateBotBody = apiUtils.prepareUpdateBotBody(
|
|
291
285
|
{
|
|
292
|
-
...
|
|
286
|
+
...createBotBody,
|
|
293
287
|
id: bot.id,
|
|
294
288
|
url: externalUrl,
|
|
295
289
|
integrations: integrationInstances
|
|
@@ -301,6 +295,8 @@ class DevCommand extends import_project_command.ProjectCommand {
|
|
|
301
295
|
});
|
|
302
296
|
updateLine.success(`Dev Bot deployed with id "${updatedBot.id}" at "${externalUrl}"`);
|
|
303
297
|
updateLine.commit();
|
|
298
|
+
const tablesPublisher = new tables.TablesPublisher({ api, logger: this.logger, prompt: this.prompt });
|
|
299
|
+
await tablesPublisher.deployTables({ botId: updatedBot.id, botDefinition: botDef });
|
|
304
300
|
this.displayWebhookUrls(updatedBot);
|
|
305
301
|
}
|
|
306
302
|
_forwardTunnelRequest = async (baseUrl, request) => {
|