@botpress/cli 4.8.2 → 4.8.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/.turbo/turbo-build.log +10 -10
- package/dist/code-generation/generators.js +2 -2
- package/dist/code-generation/generators.js.map +2 -2
- package/dist/command-implementations/interface-commands.js +6 -2
- package/dist/command-implementations/interface-commands.js.map +3 -3
- package/dist/command-implementations/plugin-commands.js +6 -2
- package/dist/command-implementations/plugin-commands.js.map +3 -3
- package/dist/tables/tables-publisher.js +4 -3
- package/dist/tables/tables-publisher.js.map +2 -2
- package/dist/utils/schema-utils.js +1 -1
- package/dist/utils/schema-utils.js.map +2 -2
- package/package.json +2 -2
- package/templates/empty-bot/package.json +1 -1
- package/templates/empty-integration/package.json +1 -1
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@4.8.
|
|
2
|
+
> @botpress/cli@4.8.4 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@4.8.
|
|
6
|
+
> @botpress/cli@4.8.4 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@4.8.
|
|
10
|
+
> @botpress/cli@4.8.4 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
11
|
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
12
|
|
|
13
|
-
🤖 Botpress CLI v4.8.
|
|
14
|
-
🤖 Botpress CLI v4.8.
|
|
15
|
-
🤖 Botpress CLI v4.8.
|
|
16
|
-
🤖 Botpress CLI v4.8.
|
|
13
|
+
🤖 Botpress CLI v4.8.4
|
|
14
|
+
🤖 Botpress CLI v4.8.4
|
|
15
|
+
🤖 Botpress CLI v4.8.4
|
|
16
|
+
🤖 Botpress CLI v4.8.4
|
|
17
17
|
○ Generating typings for integration empty-integration...
|
|
18
18
|
✓ Typings available at .botpress
|
|
19
19
|
|
|
20
|
-
○ Generating typings for
|
|
20
|
+
○ Generating typings for bot...
|
|
21
21
|
✓ Typings available at .botpress
|
|
22
22
|
|
|
23
|
-
○ Generating typings for
|
|
23
|
+
○ Generating typings for plugin empty-plugin...
|
|
24
24
|
○ Generating typings for integration hello-world...
|
|
25
25
|
✓ Typings available at .botpress
|
|
26
26
|
|
|
27
27
|
✓ Typings available at .botpress
|
|
28
28
|
|
|
29
|
-
🤖 Botpress CLI v4.8.
|
|
29
|
+
🤖 Botpress CLI v4.8.4
|
|
30
30
|
○ Generating typings for integration webhook-message...
|
|
31
31
|
✓ Typings available at .botpress
|
|
32
32
|
|
|
@@ -43,7 +43,7 @@ var prettier = __toESM(require("prettier"));
|
|
|
43
43
|
var utils = __toESM(require("../utils"));
|
|
44
44
|
var consts = __toESM(require("./consts"));
|
|
45
45
|
const zuiSchemaToTypeScriptType = async (zuiSchema, name) => {
|
|
46
|
-
let code = zuiSchema.
|
|
46
|
+
let code = zuiSchema.toTypescriptType();
|
|
47
47
|
code = `export type ${name} = ${code}`;
|
|
48
48
|
code = await prettier.format(code, { parser: "typescript" });
|
|
49
49
|
return [
|
|
@@ -54,7 +54,7 @@ const zuiSchemaToTypeScriptType = async (zuiSchema, name) => {
|
|
|
54
54
|
};
|
|
55
55
|
const jsonSchemaToTypescriptZuiSchema = async (schema, name, extraProps = {}) => {
|
|
56
56
|
schema = await utils.schema.dereferenceSchema(schema);
|
|
57
|
-
const zuiSchema = sdk.
|
|
57
|
+
const zuiSchema = sdk.transforms.fromJSONSchemaLegacy(schema);
|
|
58
58
|
const allProps = {
|
|
59
59
|
...extraProps,
|
|
60
60
|
schema: zuiSchema.toTypescriptSchema()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/generators.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\nimport _ from 'lodash'\nimport * as prettier from 'prettier'\nimport * as utils from '../utils'\nimport * as consts from './consts'\n\nexport type Primitive = string | number | boolean | null | undefined\n\nexport const zuiSchemaToTypeScriptType = async (zuiSchema: sdk.z.Schema, name: string): Promise<string> => {\n let code = zuiSchema.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,oBAAc;AACd,eAA0B;AAC1B,YAAuB;AACvB,aAAwB;AAIjB,MAAM,4BAA4B,OAAO,WAAyB,SAAkC;AACzG,MAAI,OAAO,UAAU,
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\nimport _ from 'lodash'\nimport * as prettier from 'prettier'\nimport * as utils from '../utils'\nimport * as consts from './consts'\n\nexport type Primitive = string | number | boolean | null | undefined\n\nexport const zuiSchemaToTypeScriptType = async (zuiSchema: sdk.z.Schema, name: string): Promise<string> => {\n let code = zuiSchema.toTypescriptType()\n code = `export type ${name} = ${code}`\n code = await prettier.format(code, { parser: 'typescript' })\n return [\n //\n consts.GENERATED_HEADER,\n code,\n ].join('\\n')\n}\n\nexport const jsonSchemaToTypescriptZuiSchema = async (\n schema: JSONSchema7,\n name: string,\n extraProps: Record<string, string> = {}\n): Promise<string> => {\n schema = await utils.schema.dereferenceSchema(schema)\n const zuiSchema = sdk.transforms.fromJSONSchemaLegacy(schema)\n\n const allProps = {\n ...extraProps,\n schema: zuiSchema.toTypescriptSchema(),\n }\n\n let code = [\n consts.GENERATED_HEADER,\n 'import { z } from \"@botpress/sdk\"',\n `export const ${name} = ${typescriptValuesToRecordString(allProps)}`,\n ].join('\\n')\n code = await prettier.format(code, { parser: 'typescript' })\n return code\n}\n\nexport const stringifySingleLine = (x: object): string => {\n return JSON.stringify(x, null, 1).replace(/\\n */g, ' ')\n}\n\nexport function primitiveToTypescriptValue(x: Primitive): string {\n if (typeof x === 'undefined') {\n return 'undefined'\n }\n return JSON.stringify(x)\n}\n\nexport function primitiveRecordToTypescriptValues(x: Record<string, Primitive>): Record<string, string> {\n return _(x)\n .toPairs()\n .filter(([_key, value]) => value !== undefined)\n .map(([key, value]) => [key, primitiveToTypescriptValue(value)])\n .fromPairs()\n .value()\n}\n\nexport const primitiveRecordToRecordString = (record: Record<string, Primitive>): string =>\n typescriptValuesToRecordString(primitiveRecordToTypescriptValues(record))\n\nexport const typescriptValuesToRecordString = (record: Record<string, string>): string =>\n ['{', ...Object.entries(record).map(([key, value]) => ` ${key}: ${value},`), '}'].join('\\n')\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,oBAAc;AACd,eAA0B;AAC1B,YAAuB;AACvB,aAAwB;AAIjB,MAAM,4BAA4B,OAAO,WAAyB,SAAkC;AACzG,MAAI,OAAO,UAAU,iBAAiB;AACtC,SAAO,eAAe,UAAU;AAChC,SAAO,MAAM,SAAS,OAAO,MAAM,EAAE,QAAQ,aAAa,CAAC;AAC3D,SAAO;AAAA;AAAA,IAEL,OAAO;AAAA,IACP;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEO,MAAM,kCAAkC,OAC7C,QACA,MACA,aAAqC,CAAC,MAClB;AACpB,WAAS,MAAM,MAAM,OAAO,kBAAkB,MAAM;AACpD,QAAM,YAAY,IAAI,WAAW,qBAAqB,MAAM;AAE5D,QAAM,WAAW;AAAA,IACf,GAAG;AAAA,IACH,QAAQ,UAAU,mBAAmB;AAAA,EACvC;AAEA,MAAI,OAAO;AAAA,IACT,OAAO;AAAA,IACP;AAAA,IACA,gBAAgB,UAAU,+BAA+B,QAAQ;AAAA,EACnE,EAAE,KAAK,IAAI;AACX,SAAO,MAAM,SAAS,OAAO,MAAM,EAAE,QAAQ,aAAa,CAAC;AAC3D,SAAO;AACT;AAEO,MAAM,sBAAsB,CAAC,MAAsB;AACxD,SAAO,KAAK,UAAU,GAAG,MAAM,CAAC,EAAE,QAAQ,SAAS,GAAG;AACxD;AAEO,SAAS,2BAA2B,GAAsB;AAC/D,MAAI,OAAO,MAAM,aAAa;AAC5B,WAAO;AAAA,EACT;AACA,SAAO,KAAK,UAAU,CAAC;AACzB;AAEO,SAAS,kCAAkC,GAAsD;AACtG,aAAO,cAAAA,SAAE,CAAC,EACP,QAAQ,EACR,OAAO,CAAC,CAAC,MAAM,KAAK,MAAM,UAAU,MAAS,EAC7C,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,2BAA2B,KAAK,CAAC,CAAC,EAC9D,UAAU,EACV,MAAM;AACX;AAEO,MAAM,gCAAgC,CAAC,WAC5C,+BAA+B,kCAAkC,MAAM,CAAC;AAEnE,MAAM,iCAAiC,CAAC,WAC7C,CAAC,KAAK,GAAG,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,KAAK,QAAQ,QAAQ,GAAG,GAAG,EAAE,KAAK,IAAI;",
|
|
6
6
|
"names": ["_"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ __export(interface_commands_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(interface_commands_exports);
|
|
36
36
|
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var import_lodash = __toESM(require("lodash"));
|
|
37
38
|
var errors = __toESM(require("../errors"));
|
|
38
39
|
var import_package_ref = require("../package-ref");
|
|
39
40
|
var import_global_command = require("./global-command");
|
|
@@ -63,9 +64,12 @@ class GetInterfaceCommand extends import_global_command.GlobalCommand {
|
|
|
63
64
|
class ListInterfacesCommand extends import_global_command.GlobalCommand {
|
|
64
65
|
async run() {
|
|
65
66
|
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
66
|
-
const
|
|
67
|
+
const privateLister = (req) => api.client.listInterfaces({ nextToken: req.nextToken });
|
|
68
|
+
const publicLister = (req) => api.client.listPublicInterfaces({ nextToken: req.nextToken });
|
|
67
69
|
try {
|
|
68
|
-
const
|
|
70
|
+
const privateInterfaces = await api.listAllPages(privateLister, (r) => r.interfaces);
|
|
71
|
+
const publicInterfaces = await api.listAllPages(publicLister, (r) => r.interfaces);
|
|
72
|
+
const interfaces = import_lodash.default.uniqBy([...privateInterfaces, ...publicInterfaces], (i) => i.id);
|
|
69
73
|
this.logger.success("Interfaces:");
|
|
70
74
|
this.logger.json(interfaces);
|
|
71
75
|
} catch (thrown) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/interface-commands.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetInterfaceCommandDefinition = typeof commandDefinitions.interfaces.subcommands.get\nexport class GetInterfaceCommand extends GlobalCommand<GetInterfaceCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.interfaceRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local interface')\n }\n\n try {\n const intrface = await api.findPublicInterface(parsedRef)\n if (intrface) {\n this.logger.success(`Interface ${chalk.bold(this.argv.interfaceRef)}:`)\n this.logger.json(intrface)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`)\n }\n\n throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`)\n }\n}\n\nexport type ListInterfacesCommandDefinition = typeof commandDefinitions.interfaces.subcommands.list\nexport class ListInterfacesCommand extends GlobalCommand<ListInterfacesCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;
|
|
6
|
-
"names": ["chalk"]
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport _ from 'lodash'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetInterfaceCommandDefinition = typeof commandDefinitions.interfaces.subcommands.get\nexport class GetInterfaceCommand extends GlobalCommand<GetInterfaceCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.interfaceRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local interface')\n }\n\n try {\n const intrface = await api.findPublicInterface(parsedRef)\n if (intrface) {\n this.logger.success(`Interface ${chalk.bold(this.argv.interfaceRef)}:`)\n this.logger.json(intrface)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`)\n }\n\n throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`)\n }\n}\n\nexport type ListInterfacesCommandDefinition = typeof commandDefinitions.interfaces.subcommands.list\nexport class ListInterfacesCommand extends GlobalCommand<ListInterfacesCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const privateLister = (req: { nextToken?: string }) => api.client.listInterfaces({ nextToken: req.nextToken })\n const publicLister = (req: { nextToken?: string }) => api.client.listPublicInterfaces({ nextToken: req.nextToken })\n\n try {\n const privateInterfaces = await api.listAllPages(privateLister, (r) => r.interfaces)\n const publicInterfaces = await api.listAllPages(publicLister, (r) => r.interfaces)\n const interfaces = _.uniqBy([...privateInterfaces, ...publicInterfaces], (i) => i.id)\n\n this.logger.success('Interfaces:')\n this.logger.json(interfaces)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list interfaces')\n }\n }\n}\n\nexport type DeleteInterfaceCommandDefinition = typeof commandDefinitions.interfaces.subcommands.delete\nexport class DeleteInterfaceCommand extends GlobalCommand<DeleteInterfaceCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.interfaceRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local interface')\n }\n\n let intrface: client.Interface | undefined\n try {\n intrface = await api.findPublicInterface(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`)\n }\n\n if (!intrface) {\n throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`)\n }\n\n try {\n await api.client.deleteInterface({ id: intrface.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete interface ${this.argv.interfaceRef}`)\n }\n\n this.logger.success(`Interface ${chalk.bold(this.argv.interfaceRef)} deleted`)\n return\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAc;AAEd,aAAwB;AACxB,yBAAgC;AAChC,4BAA8B;AAGvB,MAA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AAa;AACjC,WAAK,OAAO,KAAK,UAAU;AAAA,IAC7B,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B;AAAA,IACxE;AAAA,EACF;AACF;AAGO,MAAM,+BAA+B,oCAAgD;AAAA,EAC1F,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,oCAAgB,KAAK,KAAK,YAAY;AACxD,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,OAAO,6BAA6B,KAAK,KAAK,YAAY;AAAA,IACtE;AACA,QAAI,UAAU,SAAS,QAAQ;AAC7B,YAAM,IAAI,OAAO,iBAAiB,+BAA+B;AAAA,IACnE;AAEA,QAAI;AACJ,QAAI;AACF,iBAAW,MAAM,IAAI,oBAAoB,SAAS;AAAA,IACpD,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B,KAAK,KAAK,cAAc;AAAA,IAChG;AAEA,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,OAAO,iBAAiB,aAAa,KAAK,KAAK,wBAAwB;AAAA,IACnF;AAEA,QAAI;AACF,YAAM,IAAI,OAAO,gBAAgB,EAAE,IAAI,SAAS,GAAG,CAAC;AAAA,IACtD,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,8BAA8B,KAAK,KAAK,cAAc;AAAA,IACnG;AAEA,SAAK,OAAO,QAAQ,aAAa,aAAAD,QAAM,KAAK,KAAK,KAAK,YAAY,WAAW;AAC7E;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["chalk", "_"]
|
|
7
7
|
}
|
|
@@ -34,6 +34,7 @@ __export(plugin_commands_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(plugin_commands_exports);
|
|
36
36
|
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var import_lodash = __toESM(require("lodash"));
|
|
37
38
|
var errors = __toESM(require("../errors"));
|
|
38
39
|
var import_package_ref = require("../package-ref");
|
|
39
40
|
var import_global_command = require("./global-command");
|
|
@@ -63,9 +64,12 @@ class GetPluginCommand extends import_global_command.GlobalCommand {
|
|
|
63
64
|
class ListPluginsCommand extends import_global_command.GlobalCommand {
|
|
64
65
|
async run() {
|
|
65
66
|
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
66
|
-
const
|
|
67
|
+
const privateLister = (req) => api.client.listPlugins({ nextToken: req.nextToken });
|
|
68
|
+
const publicLister = (req) => api.client.listPublicPlugins({ nextToken: req.nextToken });
|
|
67
69
|
try {
|
|
68
|
-
const
|
|
70
|
+
const privatePlugins = await api.listAllPages(privateLister, (r) => r.plugins);
|
|
71
|
+
const publicPlugins = await api.listAllPages(publicLister, (r) => r.plugins);
|
|
72
|
+
const plugins = import_lodash.default.uniqBy([...privatePlugins, ...publicPlugins], (p) => p.id);
|
|
69
73
|
this.logger.success("Plugins:");
|
|
70
74
|
this.logger.json(plugins);
|
|
71
75
|
} catch (thrown) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/plugin-commands.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetPluginCommandDefinition = typeof commandDefinitions.plugins.subcommands.get\nexport class GetPluginCommand extends GlobalCommand<GetPluginCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.pluginRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.pluginRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local plugin')\n }\n\n try {\n const plugin = await api.findPublicOrPrivatePlugin(parsedRef)\n if (plugin) {\n this.logger.success(`Plugin ${chalk.bold(this.argv.pluginRef)}:`)\n this.logger.json(plugin)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get plugin ${this.argv.pluginRef}`)\n }\n\n throw new errors.BotpressCLIError(`Plugin ${this.argv.pluginRef} not found`)\n }\n}\n\nexport type ListPluginsCommandDefinition = typeof commandDefinitions.plugins.subcommands.list\nexport class ListPluginsCommand extends GlobalCommand<ListPluginsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;
|
|
6
|
-
"names": ["chalk"]
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport _ from 'lodash'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetPluginCommandDefinition = typeof commandDefinitions.plugins.subcommands.get\nexport class GetPluginCommand extends GlobalCommand<GetPluginCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.pluginRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.pluginRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local plugin')\n }\n\n try {\n const plugin = await api.findPublicOrPrivatePlugin(parsedRef)\n if (plugin) {\n this.logger.success(`Plugin ${chalk.bold(this.argv.pluginRef)}:`)\n this.logger.json(plugin)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get plugin ${this.argv.pluginRef}`)\n }\n\n throw new errors.BotpressCLIError(`Plugin ${this.argv.pluginRef} not found`)\n }\n}\n\nexport type ListPluginsCommandDefinition = typeof commandDefinitions.plugins.subcommands.list\nexport class ListPluginsCommand extends GlobalCommand<ListPluginsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const privateLister = (req: { nextToken?: string }) => api.client.listPlugins({ nextToken: req.nextToken })\n const publicLister = (req: { nextToken?: string }) => api.client.listPublicPlugins({ nextToken: req.nextToken })\n\n try {\n const privatePlugins = await api.listAllPages(privateLister, (r) => r.plugins)\n const publicPlugins = await api.listAllPages(publicLister, (r) => r.plugins)\n const plugins = _.uniqBy([...privatePlugins, ...publicPlugins], (p) => p.id)\n\n this.logger.success('Plugins:')\n this.logger.json(plugins)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list plugins')\n }\n }\n}\n\nexport type DeletePluginCommandDefinition = typeof commandDefinitions.plugins.subcommands.delete\nexport class DeletePluginCommand extends GlobalCommand<DeletePluginCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.pluginRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.pluginRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local plugin')\n }\n\n let plugin: client.Plugin | undefined\n try {\n plugin = await api.findPublicOrPrivatePlugin(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get plugin ${this.argv.pluginRef}`)\n }\n\n if (!plugin) {\n throw new errors.BotpressCLIError(`Plugin ${this.argv.pluginRef} not found`)\n }\n\n try {\n await api.client.deletePlugin({ id: plugin.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete plugin ${this.argv.pluginRef}`)\n }\n\n this.logger.success(`Plugin ${chalk.bold(this.argv.pluginRef)} deleted`)\n return\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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toCommonJS(tables_publisher_exports);
|
|
34
|
+
var sdk = __toESM(require("@botpress/sdk"));
|
|
34
35
|
var errors = __toESM(require("../errors"));
|
|
35
36
|
var schemas = __toESM(require("./schemas"));
|
|
36
37
|
class TablesPublisher {
|
|
@@ -100,7 +101,7 @@ class TablesPublisher {
|
|
|
100
101
|
}
|
|
101
102
|
await api.client.updateTable({
|
|
102
103
|
table: existingTable.name,
|
|
103
|
-
schema: updatedTableDef.schema
|
|
104
|
+
schema: sdk.transforms.toJSONSchemaLegacy(updatedTableDef.schema),
|
|
104
105
|
frozen: updatedTableDef.frozen,
|
|
105
106
|
tags: updatedTableDef.tags,
|
|
106
107
|
isComputeEnabled: updatedTableDef.isComputeEnabled
|
|
@@ -111,7 +112,7 @@ class TablesPublisher {
|
|
|
111
112
|
tableName,
|
|
112
113
|
tableDef
|
|
113
114
|
}) {
|
|
114
|
-
const columns = tableDef.schema
|
|
115
|
+
const columns = sdk.transforms.toJSONSchemaLegacy(tableDef.schema).properties;
|
|
115
116
|
const validColumns = await Promise.all(
|
|
116
117
|
Object.entries(columns).map(async ([columnName, columnSchema]) => {
|
|
117
118
|
const validatedSchema = await schemas.columnSchema.safeParseAsync(columnSchema);
|
|
@@ -141,7 +142,7 @@ class TablesPublisher {
|
|
|
141
142
|
}) {
|
|
142
143
|
await api.client.createTable({
|
|
143
144
|
name: tableName,
|
|
144
|
-
schema: tableDef.schema
|
|
145
|
+
schema: sdk.transforms.toJSONSchemaLegacy(tableDef.schema),
|
|
145
146
|
frozen: tableDef.frozen,
|
|
146
147
|
tags: tableDef.tags,
|
|
147
148
|
factor: tableDef.factor,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tables/tables-publisher.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as apiUtils from '../api'\nimport * as errors from '../errors'\nimport * as logger from '../logger'\nimport * as utils from '../utils'\nimport * as schemas from './schemas'\n\nexport class TablesPublisher {\n private readonly _api: apiUtils.ApiClient\n private readonly _logger: logger.Logger\n private readonly _prompt: utils.prompt.CLIPrompt\n\n public constructor({\n api,\n logger,\n prompt,\n }: {\n api: apiUtils.ApiClient\n logger: logger.Logger\n prompt: utils.prompt.CLIPrompt\n }) {\n this._api = api\n this._logger = logger\n this._prompt = prompt\n }\n\n public async deployTables({ botId, botDefinition }: { botId: string; botDefinition: sdk.BotDefinition }) {\n const api = this._api.switchBot(botId)\n\n this._logger.log('Synchronizing tables...')\n\n const tablesFromBotDef = Object.entries(botDefinition.tables ?? {})\n const { tables: existingTables } = await api.client.listTables({})\n\n for (const [tableName, tableDef] of tablesFromBotDef) {\n const existingTable = existingTables.find((t) => t.name === tableName)\n\n this._logger.log(`Deploying table \"${tableName}\"...`)\n\n if (existingTable) {\n await this._deployExistingTable({ api, existingTable, updatedTableDef: tableDef })\n } else {\n await this._deployNewTable({ api, tableName, tableDef })\n }\n }\n\n for (const existingTable of existingTables) {\n if (!tablesFromBotDef.find(([tableName]) => tableName === existingTable.name)) {\n this._logger.log(\n `Table \"${existingTable.name}\" was previously defined but is not present in your bot definition. ` +\n 'This table will be ignored. ' +\n 'If you wish to delete this table, you may do so from the studio.'\n )\n }\n }\n }\n\n private async _deployExistingTable({\n api,\n existingTable,\n updatedTableDef,\n }: {\n api: apiUtils.ApiClient\n existingTable: Awaited<ReturnType<apiUtils.ApiClient['client']['listTables']>>['tables'][number]\n updatedTableDef: sdk.BotTableDefinition\n }) {\n if (existingTable.frozen) {\n this._logger.warn(`Table \"${existingTable.name}\" is frozen and will not be updated.`)\n return\n }\n\n const existingColumns = existingTable.schema.properties\n const updatedColumns = await this._parseTableColumns({ tableName: existingTable.name, tableDef: updatedTableDef })\n\n for (const [columnName, existingColumn] of Object.entries(existingColumns)) {\n const updatedColumn = updatedColumns[columnName]\n\n if (!updatedColumn) {\n const wishToContinue = await this._warnAndConfirm(\n `Column \"${columnName}\" is missing from the schema of table \"${existingTable.name}\" in your bot definition. ` +\n 'If you are attempting to rename this column, please do so from the studio. ' +\n 'Renaming a column in your bot definition will cause a new column to be created. ' +\n 'If this is not a rename and you wish to proceed, the old column will be kept unchanged. ' +\n 'You can delete columns from the studio if you no longer need them.'\n )\n\n // TODO: ask the user whether this is a rename. If it is a rename, list\n // all other columns and ask which one has the new name, then do\n // the rename operation with client.renameTableColumn()\n\n if (!wishToContinue) {\n return\n }\n }\n\n if (updatedColumn && existingColumn.type !== updatedColumn.type) {\n const wishToContinue = await this._warnAndConfirm(\n 'DATA LOSS WARNING: ' +\n `Type of column \"${columnName}\" has changed from \"${existingColumn.type}\" to \"${updatedColumn.type}\" in table \"${existingTable.name}\". ` +\n 'If you proceed, the value of this column will be reset to NULL for all rows in the table.'\n )\n\n if (!wishToContinue) {\n return\n }\n }\n }\n\n await api.client.updateTable({\n table: existingTable.name,\n schema: updatedTableDef.schema
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as apiUtils from '../api'\nimport * as errors from '../errors'\nimport * as logger from '../logger'\nimport * as utils from '../utils'\nimport * as schemas from './schemas'\n\nexport class TablesPublisher {\n private readonly _api: apiUtils.ApiClient\n private readonly _logger: logger.Logger\n private readonly _prompt: utils.prompt.CLIPrompt\n\n public constructor({\n api,\n logger,\n prompt,\n }: {\n api: apiUtils.ApiClient\n logger: logger.Logger\n prompt: utils.prompt.CLIPrompt\n }) {\n this._api = api\n this._logger = logger\n this._prompt = prompt\n }\n\n public async deployTables({ botId, botDefinition }: { botId: string; botDefinition: sdk.BotDefinition }) {\n const api = this._api.switchBot(botId)\n\n this._logger.log('Synchronizing tables...')\n\n const tablesFromBotDef = Object.entries(botDefinition.tables ?? {})\n const { tables: existingTables } = await api.client.listTables({})\n\n for (const [tableName, tableDef] of tablesFromBotDef) {\n const existingTable = existingTables.find((t) => t.name === tableName)\n\n this._logger.log(`Deploying table \"${tableName}\"...`)\n\n if (existingTable) {\n await this._deployExistingTable({ api, existingTable, updatedTableDef: tableDef })\n } else {\n await this._deployNewTable({ api, tableName, tableDef })\n }\n }\n\n for (const existingTable of existingTables) {\n if (!tablesFromBotDef.find(([tableName]) => tableName === existingTable.name)) {\n this._logger.log(\n `Table \"${existingTable.name}\" was previously defined but is not present in your bot definition. ` +\n 'This table will be ignored. ' +\n 'If you wish to delete this table, you may do so from the studio.'\n )\n }\n }\n }\n\n private async _deployExistingTable({\n api,\n existingTable,\n updatedTableDef,\n }: {\n api: apiUtils.ApiClient\n existingTable: Awaited<ReturnType<apiUtils.ApiClient['client']['listTables']>>['tables'][number]\n updatedTableDef: sdk.BotTableDefinition\n }) {\n if (existingTable.frozen) {\n this._logger.warn(`Table \"${existingTable.name}\" is frozen and will not be updated.`)\n return\n }\n\n const existingColumns = existingTable.schema.properties\n const updatedColumns = await this._parseTableColumns({ tableName: existingTable.name, tableDef: updatedTableDef })\n\n for (const [columnName, existingColumn] of Object.entries(existingColumns)) {\n const updatedColumn = updatedColumns[columnName]\n\n if (!updatedColumn) {\n const wishToContinue = await this._warnAndConfirm(\n `Column \"${columnName}\" is missing from the schema of table \"${existingTable.name}\" in your bot definition. ` +\n 'If you are attempting to rename this column, please do so from the studio. ' +\n 'Renaming a column in your bot definition will cause a new column to be created. ' +\n 'If this is not a rename and you wish to proceed, the old column will be kept unchanged. ' +\n 'You can delete columns from the studio if you no longer need them.'\n )\n\n // TODO: ask the user whether this is a rename. If it is a rename, list\n // all other columns and ask which one has the new name, then do\n // the rename operation with client.renameTableColumn()\n\n if (!wishToContinue) {\n return\n }\n }\n\n if (updatedColumn && existingColumn.type !== updatedColumn.type) {\n const wishToContinue = await this._warnAndConfirm(\n 'DATA LOSS WARNING: ' +\n `Type of column \"${columnName}\" has changed from \"${existingColumn.type}\" to \"${updatedColumn.type}\" in table \"${existingTable.name}\". ` +\n 'If you proceed, the value of this column will be reset to NULL for all rows in the table.'\n )\n\n if (!wishToContinue) {\n return\n }\n }\n }\n\n await api.client.updateTable({\n table: existingTable.name,\n schema: sdk.transforms.toJSONSchemaLegacy(updatedTableDef.schema),\n frozen: updatedTableDef.frozen,\n tags: updatedTableDef.tags,\n isComputeEnabled: updatedTableDef.isComputeEnabled,\n })\n\n this._logger.success(`Table \"${existingTable.name}\" has been updated`)\n }\n\n private async _parseTableColumns({\n tableName,\n tableDef,\n }: {\n tableName: string\n tableDef: sdk.BotTableDefinition\n }): Promise<Record<string, sdk.z.infer<typeof schemas.columnSchema>>> {\n const columns = sdk.transforms.toJSONSchemaLegacy(tableDef.schema).properties!\n\n const validColumns = await Promise.all(\n Object.entries(columns).map(async ([columnName, columnSchema]) => {\n const validatedSchema = await schemas.columnSchema.safeParseAsync(columnSchema)\n\n if (!validatedSchema.success) {\n throw new errors.BotpressCLIError(\n `Column \"${columnName}\" in table \"${tableName}\" has an invalid schema: ${validatedSchema.error.message}`\n )\n }\n\n return [columnName, validatedSchema.data] as const\n })\n )\n\n return Object.fromEntries(validColumns)\n }\n\n private async _warnAndConfirm(warningMessage: string, confirmMessage: string = 'Are you sure you want to continue?') {\n this._logger.warn(warningMessage)\n\n const confirm = await this._prompt.confirm(confirmMessage)\n\n if (!confirm) {\n this._logger.log('Aborted')\n return false\n }\n return true\n }\n\n private async _deployNewTable({\n api,\n tableName,\n tableDef,\n }: {\n api: apiUtils.ApiClient\n tableName: string\n tableDef: sdk.BotTableDefinition\n }) {\n await api.client.createTable({\n name: tableName,\n schema: sdk.transforms.toJSONSchemaLegacy(tableDef.schema),\n frozen: tableDef.frozen,\n tags: tableDef.tags,\n factor: tableDef.factor,\n isComputeEnabled: tableDef.isComputeEnabled,\n })\n\n this._logger.success(`Table \"${tableName}\" has been created`)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,aAAwB;AAGx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AAAA,MAC1C,CAAC;AAAA,IACH;AAEA,WAAO,OAAO,YAAY,YAAY;AAAA,EACxC;AAAA,EAEA,MAAc,gBAAgB,gBAAwB,iBAAyB,sCAAsC;AACnH,SAAK,QAAQ,KAAK,cAAc;AAEhC,UAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ,cAAc;AAEzD,QAAI,CAAC,SAAS;AACZ,WAAK,QAAQ,IAAI,SAAS;AAC1B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,gBAAgB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIG;AACD,UAAM,IAAI,OAAO,YAAY;AAAA,MAC3B,MAAM;AAAA,MACN,QAAQ,IAAI,WAAW,mBAAmB,SAAS,MAAM;AAAA,MACzD,QAAQ,SAAS;AAAA,MACjB,MAAM,SAAS;AAAA,MACf,QAAQ,SAAS;AAAA,MACjB,kBAAkB,SAAS;AAAA,IAC7B,CAAC;AAED,SAAK,QAAQ,QAAQ,UAAU,6BAA6B;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": ["logger"]
|
|
7
7
|
}
|
|
@@ -26,7 +26,7 @@ var import_json_schema_ref_parser = require("@apidevtools/json-schema-ref-parser
|
|
|
26
26
|
var import_sdk = require("@botpress/sdk");
|
|
27
27
|
const isObjectSchema = (schema) => schema.type === "object";
|
|
28
28
|
async function mapZodToJsonSchema(definition) {
|
|
29
|
-
let schema = import_sdk.transforms.
|
|
29
|
+
let schema = import_sdk.transforms.toJSONSchemaLegacy(definition.schema, { target: "jsonSchema7" });
|
|
30
30
|
schema = await dereferenceSchema(schema);
|
|
31
31
|
if (!isObjectSchema(schema) || !definition.ui) {
|
|
32
32
|
return schema;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/schema-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport { z, transforms } from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof transforms.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,iBAA8B;
|
|
4
|
+
"sourcesContent": ["import { dereference } from '@apidevtools/json-schema-ref-parser'\nimport { z, transforms } from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\n\ntype ZuiToJsonSchema = typeof transforms.toJSONSchemaLegacy\ntype JsonSchema = ReturnType<ZuiToJsonSchema>\n\ntype SchemaOptions = {\n title?: string\n examples?: any[]\n}\n\ntype ZodObjectSchema = z.ZodObject | z.ZodRecord\ntype SchemaDefinition = {\n schema: ZodObjectSchema\n ui?: Record<string, SchemaOptions | undefined>\n}\n\nconst isObjectSchema = (schema: JsonSchema): boolean => schema.type === 'object'\n\nexport async function mapZodToJsonSchema(\n definition: SchemaDefinition\n): Promise<ReturnType<typeof transforms.toJSONSchemaLegacy>> {\n let schema = transforms.toJSONSchemaLegacy(definition.schema, { target: 'jsonSchema7' })\n schema = (await dereferenceSchema(schema)) as typeof schema\n\n if (!isObjectSchema(schema) || !definition.ui) {\n return schema\n }\n\n for (const [key, value] of Object.entries(definition.ui ?? {})) {\n const property = schema.properties?.[key]\n\n if (!property) {\n continue\n }\n\n if (!!value?.title) {\n ;(property as any).title = value.title\n }\n\n if (!!value?.examples) {\n ;(property as any).examples = value.examples\n }\n }\n\n return schema\n}\n\nexport const dereferenceSchema = async (schema: JSONSchema7): Promise<JSONSchema7> => {\n return dereference(schema, {\n resolve: {\n external: false,\n file: false,\n http: false,\n },\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAA4B;AAC5B,iBAA8B;AAiB9B,MAAM,iBAAiB,CAAC,WAAgC,OAAO,SAAS;AAExE,eAAsB,mBACpB,YAC2D;AAC3D,MAAI,SAAS,sBAAW,mBAAmB,WAAW,QAAQ,EAAE,QAAQ,cAAc,CAAC;AACvF,WAAU,MAAM,kBAAkB,MAAM;AAExC,MAAI,CAAC,eAAe,MAAM,KAAK,CAAC,WAAW,IAAI;AAC7C,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,WAAW,MAAM,CAAC,CAAC,GAAG;AAC9D,UAAM,WAAW,OAAO,aAAa,GAAG;AAExC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,OAAO,OAAO;AAClB;AAAC,MAAC,SAAiB,QAAQ,MAAM;AAAA,IACnC;AAEA,QAAI,CAAC,CAAC,OAAO,UAAU;AACrB;AAAC,MAAC,SAAiB,WAAW,MAAM;AAAA,IACtC;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,oBAAoB,OAAO,WAA8C;AACpF,aAAO,2CAAY,QAAQ;AAAA,IACzB,SAAS;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.4",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run bundle && pnpm run template:gen",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@apidevtools/json-schema-ref-parser": "^11.7.0",
|
|
23
23
|
"@botpress/chat": "0.5.1",
|
|
24
24
|
"@botpress/client": "1.15.1",
|
|
25
|
-
"@botpress/sdk": "4.8.
|
|
25
|
+
"@botpress/sdk": "4.8.3",
|
|
26
26
|
"@bpinternal/const": "^0.1.0",
|
|
27
27
|
"@bpinternal/tunnel": "^0.1.1",
|
|
28
28
|
"@bpinternal/yargs-extra": "^0.0.3",
|