@botpress/cli 0.8.34 → 0.8.36
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 +9 -9
- package/dist/api/client.js +6 -0
- package/dist/api/client.js.map +2 -2
- package/dist/api/integration-body.js +1 -0
- package/dist/api/integration-body.js.map +2 -2
- package/dist/api/interface-body.js +76 -0
- package/dist/api/interface-body.js.map +7 -0
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/integration-implementation.js +16 -3
- package/dist/code-generation/integration-implementation.js.map +2 -2
- package/dist/code-generation/integration-instance.js +13 -3
- package/dist/code-generation/integration-instance.js.map +2 -2
- package/dist/code-generation/integration-schemas/actions-module.js +2 -1
- package/dist/code-generation/integration-schemas/actions-module.js.map +2 -2
- package/dist/code-generation/integration-schemas/entities-module.js +66 -0
- package/dist/code-generation/integration-schemas/entities-module.js.map +7 -0
- package/dist/code-generation/map-integration.js +4 -3
- package/dist/code-generation/map-integration.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-definitions.js +10 -2
- package/dist/command-definitions.js.map +2 -2
- package/dist/command-implementations/add-command.js +20 -13
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/build-command.js +5 -1
- package/dist/command-implementations/build-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +5 -1
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +70 -4
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +12 -5
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +4 -3
- package/dist/command-implementations/gen-command.js.map +2 -2
- package/dist/command-implementations/index.js +8 -0
- package/dist/command-implementations/index.js.map +2 -2
- package/dist/command-implementations/interface-commands.js +106 -0
- package/dist/command-implementations/interface-commands.js.map +7 -0
- package/dist/command-implementations/project-command.js +33 -4
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +17 -5
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/command-implementations/serve-command.js +7 -4
- package/dist/command-implementations/serve-command.js.map +2 -2
- package/dist/config.js +22 -1
- package/dist/config.js.map +2 -2
- package/dist/consts.js +2 -1
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +10 -2
- package/dist/errors.js.map +2 -2
- package/package.json +2 -2
- package/templates/echo-bot/package.json +1 -1
- package/templates/empty-integration/.botpress/implementation/entities/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +7 -1
- package/templates/empty-integration/package.json +1 -1
- package/templates/hello-world/.botpress/implementation/entities/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/index.ts +7 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/.botpress/implementation/entities/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/index.ts +7 -1
- package/templates/webhook-message/package.json +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var entities_module_exports = {};
|
|
26
|
+
__export(entities_module_exports, {
|
|
27
|
+
EntitiesModule: () => EntitiesModule,
|
|
28
|
+
EntityModule: () => EntityModule
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(entities_module_exports);
|
|
31
|
+
var import_bluebird = __toESM(require("bluebird"));
|
|
32
|
+
var import_generators = require("../generators");
|
|
33
|
+
var import_module = require("../module");
|
|
34
|
+
var strings = __toESM(require("../strings"));
|
|
35
|
+
class EntityModule extends import_module.Module {
|
|
36
|
+
static async create(name, entity) {
|
|
37
|
+
const entityName = name;
|
|
38
|
+
const schema = entity.schema;
|
|
39
|
+
const exportName = strings.typeName(entityName);
|
|
40
|
+
const def = {
|
|
41
|
+
path: `${name}.ts`,
|
|
42
|
+
exportName,
|
|
43
|
+
content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
|
|
44
|
+
};
|
|
45
|
+
return new EntityModule(def);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class EntitiesModule extends import_module.ReExportTypeModule {
|
|
49
|
+
static async create(entities) {
|
|
50
|
+
const entityModules = await import_bluebird.default.map(
|
|
51
|
+
Object.entries(entities),
|
|
52
|
+
async ([entityName, entity]) => EntityModule.create(entityName, entity)
|
|
53
|
+
);
|
|
54
|
+
const inst = new EntitiesModule({
|
|
55
|
+
exportName: strings.typeName("entities")
|
|
56
|
+
});
|
|
57
|
+
inst.pushDep(...entityModules);
|
|
58
|
+
return inst;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
EntitiesModule,
|
|
64
|
+
EntityModule
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=entities-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/code-generation/integration-schemas/entities-module.ts"],
|
|
4
|
+
"sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\nimport type * as types from '../typings'\n\nexport class EntityModule extends Module {\n public static async create(name: string, entity: types.EntityDefinition): Promise<EntityModule> {\n const entityName = name\n const schema = entity.schema\n const exportName = strings.typeName(entityName)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n }\n return new EntityModule(def)\n }\n}\n\nexport class EntitiesModule extends ReExportTypeModule {\n public static async create(entities: Record<string, types.EntityDefinition>): Promise<EntitiesModule> {\n const entityModules = await bluebird.map(Object.entries(entities), async ([entityName, entity]) =>\n EntityModule.create(entityName, entity)\n )\n\n const inst = new EntitiesModule({\n exportName: strings.typeName('entities'),\n })\n inst.pushDep(...entityModules)\n return inst\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,wBAA2C;AAC3C,oBAAsD;AACtD,cAAyB;AAGlB,MAAM,qBAAqB,qBAAO;AAAA,EACvC,aAAoB,OAAO,MAAc,QAAuD;AAC9F,UAAM,aAAa;AACnB,UAAM,SAAS,OAAO;AACtB,UAAM,aAAa,QAAQ,SAAS,UAAU;AAC9C,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;AACA,WAAO,IAAI,aAAa,GAAG;AAAA,EAC7B;AACF;AAEO,MAAM,uBAAuB,iCAAmB;AAAA,EACrD,aAAoB,OAAO,UAA2E;AACpG,UAAM,gBAAgB,MAAM,gBAAAA,QAAS;AAAA,MAAI,OAAO,QAAQ,QAAQ;AAAA,MAAG,OAAO,CAAC,YAAY,MAAM,MAC3F,aAAa,OAAO,YAAY,MAAM;AAAA,IACxC;AAEA,UAAM,OAAO,IAAI,eAAe;AAAA,MAC9B,YAAY,QAAQ,SAAS,UAAU;AAAA,IACzC,CAAC;AACD,SAAK,QAAQ,GAAG,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["bluebird"]
|
|
7
|
+
}
|
|
@@ -55,12 +55,13 @@ var from;
|
|
|
55
55
|
tags: c.message?.tags ?? {}
|
|
56
56
|
},
|
|
57
57
|
messages: utils.records.mapValues(c.messages, _mapSchema)
|
|
58
|
-
})) : {}
|
|
58
|
+
})) : {},
|
|
59
|
+
entities: i.entities ? utils.records.mapValues(i.entities, _mapSchema) : {}
|
|
59
60
|
};
|
|
60
61
|
};
|
|
61
62
|
from2.client = (i) => {
|
|
62
|
-
const { id, name, version, configuration, channels, states, events, actions, user } = i;
|
|
63
|
-
return { id, name, version, configuration, channels, states, events, actions, user };
|
|
63
|
+
const { id, name, version, configuration, channels, states, events, actions, user, entities } = i;
|
|
64
|
+
return { id, name, version, configuration, channels, states, events, actions, user, entities };
|
|
64
65
|
};
|
|
65
66
|
const _mapSchema = (x) => ({
|
|
66
67
|
...x,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/map-integration.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, channels, states, events, actions, user } = i\n return { id, name, version, configuration, channels, states, events, actions, user }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,MAA8D;AAChF,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,MAAM;AAAA,QACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MACnE;AAAA,MACA,eAAe,EAAE,gBAAgB,WAAW,EAAE,aAAa,IAAI,EAAE,QAAQ,CAAC,EAAE;AAAA,MAC5E,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,SAAS,EAAE,UACP,MAAM,QAAQ,UAAU,EAAE,SAAS,CAAC,OAAO;AAAA,QACzC,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,QAAQ,WAAW,EAAE,MAAM;AAAA,MAC7B,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WACR,MAAM,QAAQ,UAAU,EAAE,UAAU,CAAC,OAAO;AAAA,QAC1C,cAAc;AAAA,UACZ,MAAM,EAAE,cAAc,QAAQ,CAAC;AAAA,UAC/B,UAAU,EAAE,cAAc,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,QAC3E;AAAA,QACA,SAAS;AAAA,UACP,MAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,QAC5B;AAAA,QACA,UAAU,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU;AAAA,MAC1D,EAAE,IACF,CAAC;AAAA,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n entities: i.entities ? utils.records.mapValues(i.entities, _mapSchema) : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, channels, states, events, actions, user, entities } = i\n return { id, name, version, configuration, channels, states, events, actions, user, entities }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,MAA8D;AAChF,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,MAAM;AAAA,QACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MACnE;AAAA,MACA,eAAe,EAAE,gBAAgB,WAAW,EAAE,aAAa,IAAI,EAAE,QAAQ,CAAC,EAAE;AAAA,MAC5E,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,SAAS,EAAE,UACP,MAAM,QAAQ,UAAU,EAAE,SAAS,CAAC,OAAO;AAAA,QACzC,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,QAAQ,WAAW,EAAE,MAAM;AAAA,MAC7B,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WACR,MAAM,QAAQ,UAAU,EAAE,UAAU,CAAC,OAAO;AAAA,QAC1C,cAAc;AAAA,UACZ,MAAM,EAAE,cAAc,QAAQ,CAAC;AAAA,UAC/B,UAAU,EAAE,cAAc,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,QAC3E;AAAA,QACA,SAAS;AAAA,UACP,MAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,QAC5B;AAAA,QACA,UAAU,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU;AAAA,MAC1D,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WAAW,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU,IAAI,CAAC;AAAA,IAC5E;AAAA,EACF;AAEO,EAAMA,MAAA,SAAS,CAAC,MAAuD;AAC5E,UAAM,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS,IAAI;AAChG,WAAO,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,MAAM,SAAS;AAAA,EAC/F;AAEA,QAAM,aAAa,CACjB,OAC0F;AAAA,IAC1F,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,CAAC;AAAA,EAC3C;AAAA,GA7Ce;",
|
|
6
6
|
"names": ["from"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/typings.ts"],
|
|
4
|
-
"sourcesContent": ["import { Integration } from '@botpress/client'\n\nexport type File = { path: string; content: string }\n\nexport type IntegrationDefinition = Pick<\n Integration,\n 'name' | 'version' | 'channels' | 'states' | 'events' | 'actions' | 'user'\n> & {\n id: string | null\n configuration: Omit<Integration['configuration'], 'identifier'>\n}\n\ntype Def<T> = NonNullable<T>\n\nexport type ConfigurationDefinition = Def<IntegrationDefinition['configuration']>\nexport type ChannelDefinition = Def<IntegrationDefinition['channels']>[string]\nexport type MessageDefinition = Def<ChannelDefinition['messages']>[string]\nexport type ActionDefinition = Def<IntegrationDefinition['actions']>[string]\nexport type EventDefinition = Def<IntegrationDefinition['events']>[string]\nexport type StateDefinition = Def<IntegrationDefinition['states']>[string]\nexport type UserDefinition = Def<IntegrationDefinition['user']>\n"],
|
|
4
|
+
"sourcesContent": ["import { Integration } from '@botpress/client'\n\nexport type File = { path: string; content: string }\n\nexport type IntegrationDefinition = Pick<\n Integration,\n 'name' | 'version' | 'channels' | 'states' | 'events' | 'actions' | 'user' | 'entities'\n> & {\n id: string | null\n configuration: Omit<Integration['configuration'], 'identifier'>\n}\n\ntype Def<T> = NonNullable<T>\n\nexport type ConfigurationDefinition = Def<IntegrationDefinition['configuration']>\nexport type ChannelDefinition = Def<IntegrationDefinition['channels']>[string]\nexport type MessageDefinition = Def<ChannelDefinition['messages']>[string]\nexport type ActionDefinition = Def<IntegrationDefinition['actions']>[string]\nexport type EventDefinition = Def<IntegrationDefinition['events']>[string]\nexport type StateDefinition = Def<IntegrationDefinition['states']>[string]\nexport type UserDefinition = Def<IntegrationDefinition['user']>\nexport type EntityDefinition = Def<IntegrationDefinition['entities']>[string]\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,7 +36,7 @@ var command_definitions_default = {
|
|
|
36
36
|
subcommands: {
|
|
37
37
|
create: { description: "Create new bot", schema: config.schemas.createBot, alias: "new" },
|
|
38
38
|
get: { description: "Get bot", schema: config.schemas.getBot },
|
|
39
|
-
delete: { description: "Delete bot", schema: config.schemas.deleteBot },
|
|
39
|
+
delete: { description: "Delete bot", schema: config.schemas.deleteBot, alias: "rm" },
|
|
40
40
|
list: { description: "List bots", schema: config.schemas.listBots, alias: "ls" }
|
|
41
41
|
}
|
|
42
42
|
},
|
|
@@ -44,10 +44,18 @@ var command_definitions_default = {
|
|
|
44
44
|
description: "Integration related commands",
|
|
45
45
|
subcommands: {
|
|
46
46
|
get: { description: "Get integration", schema: config.schemas.getIntegration },
|
|
47
|
-
delete: { description: "Delete integration", schema: config.schemas.deleteIntegration },
|
|
47
|
+
delete: { description: "Delete integration", schema: config.schemas.deleteIntegration, alias: "rm" },
|
|
48
48
|
list: { description: "List integrations", schema: config.schemas.listIntegrations, alias: "ls" }
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
+
interfaces: {
|
|
52
|
+
description: "Interface related commands",
|
|
53
|
+
subcommands: {
|
|
54
|
+
get: { description: "Get interface", schema: config.schemas.getInterface },
|
|
55
|
+
delete: { description: "Delete interface", schema: config.schemas.deleteInterface, alias: "rm" },
|
|
56
|
+
list: { description: "List interfaces", schema: config.schemas.listInterfaces, alias: "ls" }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
51
59
|
init: { description: "Initialize a new project", schema: config.schemas.init },
|
|
52
60
|
generate: { description: "Generate typings for intellisense", schema: config.schemas.generate, alias: "gen" },
|
|
53
61
|
bundle: { description: "Bundle a botpress project", schema: config.schemas.bundle },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/command-definitions.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DefinitionTree } from './command-tree'\nimport * as config from './config'\n\nexport default {\n login: { description: 'Login to Botpress Cloud', schema: config.schemas.login },\n logout: { description: 'Logout of Botpress Cloud', schema: config.schemas.logout },\n bots: {\n description: 'Bot related commands',\n subcommands: {\n create: { description: 'Create new bot', schema: config.schemas.createBot, alias: 'new' },\n get: { description: 'Get bot', schema: config.schemas.getBot },\n delete: { description: 'Delete bot', schema: config.schemas.deleteBot },\n list: { description: 'List bots', schema: config.schemas.listBots, alias: 'ls' },\n },\n },\n integrations: {\n description: 'Integration related commands',\n subcommands: {\n get: { description: 'Get integration', schema: config.schemas.getIntegration },\n delete: { description: 'Delete integration', schema: config.schemas.deleteIntegration },\n list: { description: 'List integrations', schema: config.schemas.listIntegrations, alias: 'ls' },\n },\n },\n init: { description: 'Initialize a new project', schema: config.schemas.init },\n generate: { description: 'Generate typings for intellisense', schema: config.schemas.generate, alias: 'gen' },\n bundle: { description: 'Bundle a botpress project', schema: config.schemas.bundle },\n build: { description: 'Generate typings and bundle a botpress project', schema: config.schemas.build },\n read: { description: 'Read and parse an integration definition', schema: config.schemas.read },\n serve: { description: 'Serve your project locally', schema: config.schemas.serve },\n deploy: { description: 'Deploy your project to the cloud', schema: config.schemas.deploy },\n add: { description: 'Install an integration in your bot', schema: config.schemas.add },\n dev: { description: 'Run your project in dev mode', schema: config.schemas.dev },\n} satisfies DefinitionTree\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,IAAO,8BAAQ;AAAA,EACb,OAAO,EAAE,aAAa,2BAA2B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EAC9E,QAAQ,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACjF,MAAM;AAAA,IACJ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,QAAQ,EAAE,aAAa,kBAAkB,QAAQ,OAAO,QAAQ,WAAW,OAAO,MAAM;AAAA,MACxF,KAAK,EAAE,aAAa,WAAW,QAAQ,OAAO,QAAQ,OAAO;AAAA,MAC7D,QAAQ,EAAE,aAAa,cAAc,QAAQ,OAAO,QAAQ,
|
|
4
|
+
"sourcesContent": ["import type { DefinitionTree } from './command-tree'\nimport * as config from './config'\n\nexport default {\n login: { description: 'Login to Botpress Cloud', schema: config.schemas.login },\n logout: { description: 'Logout of Botpress Cloud', schema: config.schemas.logout },\n bots: {\n description: 'Bot related commands',\n subcommands: {\n create: { description: 'Create new bot', schema: config.schemas.createBot, alias: 'new' },\n get: { description: 'Get bot', schema: config.schemas.getBot },\n delete: { description: 'Delete bot', schema: config.schemas.deleteBot, alias: 'rm' },\n list: { description: 'List bots', schema: config.schemas.listBots, alias: 'ls' },\n },\n },\n integrations: {\n description: 'Integration related commands',\n subcommands: {\n get: { description: 'Get integration', schema: config.schemas.getIntegration },\n delete: { description: 'Delete integration', schema: config.schemas.deleteIntegration, alias: 'rm' },\n list: { description: 'List integrations', schema: config.schemas.listIntegrations, alias: 'ls' },\n },\n },\n interfaces: {\n description: 'Interface related commands',\n subcommands: {\n get: { description: 'Get interface', schema: config.schemas.getInterface },\n delete: { description: 'Delete interface', schema: config.schemas.deleteInterface, alias: 'rm' },\n list: { description: 'List interfaces', schema: config.schemas.listInterfaces, alias: 'ls' },\n },\n },\n init: { description: 'Initialize a new project', schema: config.schemas.init },\n generate: { description: 'Generate typings for intellisense', schema: config.schemas.generate, alias: 'gen' },\n bundle: { description: 'Bundle a botpress project', schema: config.schemas.bundle },\n build: { description: 'Generate typings and bundle a botpress project', schema: config.schemas.build },\n read: { description: 'Read and parse an integration definition', schema: config.schemas.read },\n serve: { description: 'Serve your project locally', schema: config.schemas.serve },\n deploy: { description: 'Deploy your project to the cloud', schema: config.schemas.deploy },\n add: { description: 'Install an integration in your bot', schema: config.schemas.add },\n dev: { description: 'Run your project in dev mode', schema: config.schemas.dev },\n} satisfies DefinitionTree\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,IAAO,8BAAQ;AAAA,EACb,OAAO,EAAE,aAAa,2BAA2B,QAAQ,OAAO,QAAQ,MAAM;AAAA,EAC9E,QAAQ,EAAE,aAAa,4BAA4B,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACjF,MAAM;AAAA,IACJ,aAAa;AAAA,IACb,aAAa;AAAA,MACX,QAAQ,EAAE,aAAa,kBAAkB,QAAQ,OAAO,QAAQ,WAAW,OAAO,MAAM;AAAA,MACxF,KAA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EACjF,QAAQ,EAAE,aAAa,oCAAoC,QAAQ,OAAO,QAAQ,OAAO;AAAA,EACzF,KAAK,EAAE,aAAa,sCAAsC,QAAQ,OAAO,QAAQ,IAAI;AAAA,EACrF,KAAK,EAAE,aAAa,gCAAgC,QAAQ,OAAO,QAAQ,IAAI;AACjF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -39,8 +39,8 @@ var utils = __toESM(require("../utils"));
|
|
|
39
39
|
var import_project_command = require("./project-command");
|
|
40
40
|
class AddCommand extends import_project_command.ProjectCommand {
|
|
41
41
|
async run() {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
42
|
+
const projectDef = await this.readProjectDefinitionFromFS();
|
|
43
|
+
if (projectDef.type !== "bot") {
|
|
44
44
|
throw new errors.ExclusiveBotFeatureError();
|
|
45
45
|
}
|
|
46
46
|
const integrationRef = this.argv.integrationRef;
|
|
@@ -48,7 +48,7 @@ class AddCommand extends import_project_command.ProjectCommand {
|
|
|
48
48
|
if (!parsedRef) {
|
|
49
49
|
throw new errors.InvalidIntegrationReferenceError(integrationRef);
|
|
50
50
|
}
|
|
51
|
-
const integration = parsedRef.type === "path" ? await this.
|
|
51
|
+
const integration = parsedRef.type === "path" ? await this._fetchLocalIntegrationOrInterface(parsedRef) : await this._fetchApiIntegration(parsedRef);
|
|
52
52
|
const allInstances = await this._listIntegrationInstances();
|
|
53
53
|
const existingInstance = allInstances.find((i) => i.name === integration.name);
|
|
54
54
|
if (existingInstance) {
|
|
@@ -62,29 +62,36 @@ class AddCommand extends import_project_command.ProjectCommand {
|
|
|
62
62
|
}
|
|
63
63
|
await this._generateIntegrationInstance(integration);
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
_fetchLocalIntegrationOrInterface = async (integrationOrInterfaceRef) => {
|
|
66
66
|
this.logger.warn(
|
|
67
67
|
"Installing integration from a local path. There is no guarantee that the integration is deployed with the expected schemas."
|
|
68
68
|
);
|
|
69
|
-
const workDir =
|
|
69
|
+
const workDir = integrationOrInterfaceRef.path;
|
|
70
70
|
const pathStore = new utils.path.PathStore({
|
|
71
71
|
workDir,
|
|
72
|
-
|
|
72
|
+
integrationDefinition: utils.path.absoluteFrom(workDir, consts.fromWorkDir.integrationDefinition),
|
|
73
|
+
interfaceDefinition: utils.path.absoluteFrom(workDir, consts.fromWorkDir.interfaceDefinition)
|
|
73
74
|
});
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
75
|
+
const projectDef = await this.readProjectDefinitionFromFS(pathStore);
|
|
76
|
+
if (projectDef.type === "bot") {
|
|
76
77
|
throw new errors.BotpressCLIError(`Integration definition not found at ${workDir}`);
|
|
78
|
+
} else if (projectDef.type === "interface") {
|
|
79
|
+
throw new errors.BotpressCLIError("Installing interfaces is not supported yet");
|
|
77
80
|
}
|
|
78
|
-
return
|
|
81
|
+
return projectDef.definition;
|
|
79
82
|
};
|
|
80
83
|
_fetchApiIntegration = async (integrationRef) => {
|
|
81
84
|
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
82
85
|
const integration = await api.findIntegration(integrationRef);
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
throw new errors.BotpressCLIError(`Integration "${formattedRef}" not found`);
|
|
86
|
+
if (integration) {
|
|
87
|
+
return integration;
|
|
86
88
|
}
|
|
87
|
-
|
|
89
|
+
const intrface = await api.findPublicInterface(integrationRef);
|
|
90
|
+
if (intrface) {
|
|
91
|
+
throw new errors.BotpressCLIError("Installing interfaces is not supported yet");
|
|
92
|
+
}
|
|
93
|
+
const formattedRef = (0, import_integration_ref.formatIntegrationRef)(integrationRef);
|
|
94
|
+
throw new errors.BotpressCLIError(`Integration "${formattedRef}" not found`);
|
|
88
95
|
};
|
|
89
96
|
async _listIntegrationInstances() {
|
|
90
97
|
const installPath = this.projectPaths.abs.installDir;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/add-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport {\n ApiIntegrationRef,\n formatIntegrationRef,\n LocalPathIntegrationRef,\n parseIntegrationRef,\n} from '../integration-ref'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\ntype IntegrationInstallDir = codegen.IntegrationInstanceJson & {\n dirname: string\n}\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends ProjectCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAqB;AACrB,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AACzB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,6BAKO;AACP,YAAuB;AACvB,6BAA+B;AAOxB,MAAM,mBAAmB,sCAAqC;AAAA,EACnE,MAAa,MAAqB;AAChC,UAAM,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\nimport * as codegen from '../code-generation'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport {\n ApiIntegrationRef,\n formatIntegrationRef,\n LocalPathIntegrationRef,\n parseIntegrationRef,\n} from '../integration-ref'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\ntype IntegrationInstallDir = codegen.IntegrationInstanceJson & {\n dirname: string\n}\n\nexport type AddCommandDefinition = typeof commandDefinitions.add\nexport class AddCommand extends ProjectCommand<AddCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n if (projectDef.type !== 'bot') {\n throw new errors.ExclusiveBotFeatureError()\n }\n\n const integrationRef = this.argv.integrationRef\n\n const parsedRef = parseIntegrationRef(integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(integrationRef)\n }\n\n const integration =\n parsedRef.type === 'path'\n ? await this._fetchLocalIntegrationOrInterface(parsedRef)\n : await this._fetchApiIntegration(parsedRef)\n\n const allInstances = await this._listIntegrationInstances()\n const existingInstance = allInstances.find((i) => i.name === integration.name)\n if (existingInstance) {\n this.logger.warn(`Integration with name \"${integration.name}\" already installed.`)\n const res = await this.prompt.confirm('Do you want to overwrite the existing instance?')\n if (!res) {\n this.logger.log('Aborted')\n return\n }\n\n await this._uninstallIntegration(existingInstance)\n }\n\n await this._generateIntegrationInstance(integration)\n }\n\n private _fetchLocalIntegrationOrInterface = async (\n integrationOrInterfaceRef: LocalPathIntegrationRef\n ): Promise<sdk.IntegrationDefinition> => {\n this.logger.warn(\n 'Installing integration from a local path. There is no guarantee that the integration is deployed with the expected schemas.'\n )\n\n const workDir = integrationOrInterfaceRef.path\n const pathStore = new utils.path.PathStore<'workDir' | 'integrationDefinition' | 'interfaceDefinition'>({\n workDir,\n integrationDefinition: utils.path.absoluteFrom(workDir, consts.fromWorkDir.integrationDefinition),\n interfaceDefinition: utils.path.absoluteFrom(workDir, consts.fromWorkDir.interfaceDefinition),\n })\n\n const projectDef = await this.readProjectDefinitionFromFS(pathStore)\n if (projectDef.type === 'bot') {\n throw new errors.BotpressCLIError(`Integration definition not found at ${workDir}`)\n } else if (projectDef.type === 'interface') {\n throw new errors.BotpressCLIError('Installing interfaces is not supported yet')\n }\n\n return projectDef.definition\n }\n\n private _fetchApiIntegration = async (integrationRef: ApiIntegrationRef): Promise<client.Integration> => {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const integration = await api.findIntegration(integrationRef)\n if (integration) {\n return integration\n }\n\n const intrface = await api.findPublicInterface(integrationRef)\n if (intrface) {\n throw new errors.BotpressCLIError('Installing interfaces is not supported yet')\n }\n\n const formattedRef = formatIntegrationRef(integrationRef)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n\n private async _listIntegrationInstances(): Promise<IntegrationInstallDir[]> {\n const installPath = this.projectPaths.abs.installDir\n if (!fs.existsSync(installPath)) {\n this.logger.debug('Install path does not exist. Skipping listing of integration instances')\n return []\n }\n\n const allFiles = await fs.promises.readdir(installPath)\n const allPaths = allFiles.map((name) => pathlib.join(installPath, name))\n const directories = await bluebird.filter(allPaths, async (path) => {\n const stat = await fs.promises.stat(path)\n return stat.isDirectory()\n })\n\n let jsons = directories.map((root) => ({ root, json: pathlib.join(root, codegen.INTEGRATION_JSON) }))\n jsons = jsons.filter(({ json: x }) => fs.existsSync(x))\n\n return bluebird.map(jsons, async ({ root, json }) => {\n const content: string = await fs.promises.readFile(json, 'utf-8')\n const { name, version, id } = JSON.parse(content) as codegen.IntegrationInstanceJson\n const dirname = pathlib.basename(root)\n return {\n dirname,\n id,\n name,\n version,\n }\n })\n }\n\n private async _uninstallIntegration(instance: IntegrationInstallDir) {\n const installDir = this.projectPaths.abs.installDir\n const instancePath = pathlib.join(installDir, instance.dirname)\n await fs.promises.rm(instancePath, { recursive: true })\n await this._generateBotIndex()\n }\n\n private async _generateIntegrationInstance(integration: client.Integration | sdk.IntegrationDefinition) {\n const line = this.logger.line()\n\n const { name, version } = integration\n line.started(`Installing ${chalk.bold(name)} v${version}...`)\n\n const instanceFiles = await codegen.generateIntegrationInstance(\n integration,\n this.projectPaths.rel('outDir').installDir\n )\n await this.writeGeneratedFilesToOutFolder(instanceFiles)\n await this._generateBotIndex()\n\n const rel = this.projectPaths.rel('workDir')\n line.success(`Installed integration available at ${chalk.grey(rel.outDir)}`)\n }\n\n private async _generateBotIndex() {\n const allInstances = await this._listIntegrationInstances()\n const indexFile = await codegen.generateBotIndex(this.projectPaths.rel('outDir').installDir, allInstances)\n await this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MAAM,QAAQ,iBAAiB,KAAK,aAAa,IAAI,QAAQ,EAAE,YAAY,YAAY;AACzG,UAAM,KAAK,+BAA+B,CAAC,SAAS,CAAC;AAAA,EACvD;AACF;",
|
|
6
6
|
"names": ["bluebird", "chalk"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,11 @@ var import_project_command = require("./project-command");
|
|
|
27
27
|
class BuildCommand extends import_project_command.ProjectCommand {
|
|
28
28
|
async run() {
|
|
29
29
|
const t0 = Date.now();
|
|
30
|
-
const integrationDef = await this.
|
|
30
|
+
const { type: projectType, definition: integrationDef } = await this.readProjectDefinitionFromFS();
|
|
31
|
+
if (projectType === "interface") {
|
|
32
|
+
this.logger.success("Interface projects have nothing to build.");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
31
35
|
if (integrationDef) {
|
|
32
36
|
await this._runGenerate();
|
|
33
37
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/build-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type commandDefinitions from '../command-definitions'\nimport { BundleCommand } from './bundle-command'\nimport { GenerateCommand } from './gen-command'\nimport { ProjectCommand } from './project-command'\n\nexport type BuildCommandDefinition = typeof commandDefinitions.build\nexport class BuildCommand extends ProjectCommand<BuildCommandDefinition> {\n public async run(): Promise<void> {\n const t0 = Date.now()\n const integrationDef = await this.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAA8B;AAC9B,yBAAgC;AAChC,6BAA+B;AAGxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,KAAK,KAAK,IAAI;AACpB,UAAM,
|
|
4
|
+
"sourcesContent": ["import type commandDefinitions from '../command-definitions'\nimport { BundleCommand } from './bundle-command'\nimport { GenerateCommand } from './gen-command'\nimport { ProjectCommand } from './project-command'\n\nexport type BuildCommandDefinition = typeof commandDefinitions.build\nexport class BuildCommand extends ProjectCommand<BuildCommandDefinition> {\n public async run(): Promise<void> {\n const t0 = Date.now()\n const { type: projectType, definition: integrationDef } = await this.readProjectDefinitionFromFS()\n\n if (projectType === 'interface') {\n this.logger.success('Interface projects have nothing to build.')\n return\n }\n\n if (integrationDef) {\n await this._runGenerate()\n }\n\n await this._runBundle()\n const dt = Date.now() - t0\n this.logger.log(`Build completed in ${dt}ms`)\n }\n\n private _runGenerate() {\n return new GenerateCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private _runBundle() {\n return new BundleCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAA8B;AAC9B,yBAAgC;AAChC,6BAA+B;AAGxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,KAAK,KAAK,IAAI;AACpB,UAAM,EAAE,MAAM,aAAa,YAAY,eAAe,IAAI,MAAM,KAAK,4BAA4B;AAEjG,QAAI,gBAAgB,aAAa;AAC/B,WAAK,OAAO,QAAQ,2CAA2C;AAC/D;AAAA,IACF;AAEA,QAAI,gBAAgB;AAClB,YAAM,KAAK,aAAa;AAAA,IAC1B;AAEA,UAAM,KAAK,WAAW;AACtB,UAAM,KAAK,KAAK,IAAI,IAAI;AACxB,SAAK,OAAO,IAAI,sBAAsB,MAAM;AAAA,EAC9C;AAAA,EAEQ,eAAe;AACrB,WAAO,IAAI,mCAAgB,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAChF;AAAA,EAEQ,aAAa;AACnB,WAAO,IAAI,oCAAc,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAC9E;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,7 +32,11 @@ var utils = __toESM(require("../utils"));
|
|
|
32
32
|
var import_project_command = require("./project-command");
|
|
33
33
|
class BundleCommand extends import_project_command.ProjectCommand {
|
|
34
34
|
async run() {
|
|
35
|
-
const integrationDef = await this.
|
|
35
|
+
const { type: projectType, definition: integrationDef } = await this.readProjectDefinitionFromFS();
|
|
36
|
+
if (projectType === "interface") {
|
|
37
|
+
this.logger.success("Interface projects have nothing to bundle.");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
36
40
|
const abs = this.projectPaths.abs;
|
|
37
41
|
const rel = this.projectPaths.rel("workDir");
|
|
38
42
|
const line = this.logger.line();
|
|
@@ -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 type commandDefinitions from '../command-definitions'\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 integrationDef = await this.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\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 { type: projectType, definition: integrationDef } = await this.readProjectDefinitionFromFS()\n\n if (projectType === 'interface') {\n this.logger.success('Interface projects have nothing to bundle.')\n return\n }\n\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n\n const line = this.logger.line()\n\n const logLevel = this.argv.verbose ? 'info' : 'silent'\n\n if (integrationDef) {\n const { name } = integrationDef\n line.started(`Bundling integration ${chalk.bold(name)}...`)\n } else {\n line.started('Bundling bot...')\n }\n\n const unixPath = utils.path.toUnix(rel.entryPoint)\n const importFrom = utils.path.rmExtension(unixPath)\n const code = `import x from './${importFrom}'; export default x; export const handler = x.handler;`\n\n const outfile = abs.outFile // TODO: ensure dir exists\n line.debug(`Writing bundle to ${outfile}`)\n\n await utils.esbuild.buildCode({\n code,\n cwd: abs.workDir,\n outfile,\n logLevel,\n write: true,\n sourcemap: this.argv.sourceMap,\n })\n\n line.success(`Bundle available at ${chalk.grey(rel.outDir)}`)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,EAAE,MAAM,aAAa,YAAY,eAAe,IAAI,MAAM,KAAK,4BAA4B;AAEjG,QAAI,gBAAgB,aAAa;AAC/B,WAAK,OAAO,QAAQ,4CAA4C;AAChE;AAAA,IACF;AAEA,UAAM,MAAM,KAAK,aAAa;AAC9B,UAAM,MAAM,KAAK,aAAa,IAAI,SAAS;AAE3C,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,UAAM,WAAW,KAAK,KAAK,UAAU,SAAS;AAE9C,QAAI,gBAAgB;AAClB,YAAM,EAAE,KAAK,IAAI;AACjB,WAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,IAAI,MAAM;AAAA,IAC5D,OAAO;AACL,WAAK,QAAQ,iBAAiB;AAAA,IAChC;AAEA,UAAM,WAAW,MAAM,KAAK,OAAO,IAAI,UAAU;AACjD,UAAM,aAAa,MAAM,KAAK,YAAY,QAAQ;AAClD,UAAM,OAAO,oBAAoB;AAEjC,UAAM,UAAU,IAAI;AACpB,SAAK,MAAM,qBAAqB,SAAS;AAEzC,UAAM,MAAM,QAAQ,UAAU;AAAA,MAC5B;AAAA,MACA,KAAK,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,WAAW,KAAK,KAAK;AAAA,IACvB,CAAC;AAED,SAAK,QAAQ,uBAAuB,aAAAA,QAAM,KAAK,IAAI,MAAM,GAAG;AAAA,EAC9D;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -32,6 +32,7 @@ var fs = __toESM(require("fs"));
|
|
|
32
32
|
var import_semver = __toESM(require("semver"));
|
|
33
33
|
var import_bot_body = require("../api/bot-body");
|
|
34
34
|
var import_integration_body = require("../api/integration-body");
|
|
35
|
+
var import_interface_body = require("../api/interface-body");
|
|
35
36
|
var errors = __toESM(require("../errors"));
|
|
36
37
|
var utils = __toESM(require("../utils"));
|
|
37
38
|
var import_build_command = require("./build-command");
|
|
@@ -42,9 +43,12 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
42
43
|
if (!this.argv.noBuild) {
|
|
43
44
|
await this._runBuild();
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
return this._deployIntegration(api,
|
|
46
|
+
const projectDef = await this.readProjectDefinitionFromFS();
|
|
47
|
+
if (projectDef.type === "integration") {
|
|
48
|
+
return this._deployIntegration(api, projectDef.definition);
|
|
49
|
+
}
|
|
50
|
+
if (projectDef.type === "interface") {
|
|
51
|
+
return this._deployInterface(api, projectDef.definition);
|
|
48
52
|
}
|
|
49
53
|
return this._deployBot(api, this.argv.botId, this.argv.createNewBot);
|
|
50
54
|
}
|
|
@@ -84,7 +88,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
84
88
|
}
|
|
85
89
|
let message;
|
|
86
90
|
if (integration) {
|
|
87
|
-
this.logger.warn("Integration already exists. If you decide to deploy, it will
|
|
91
|
+
this.logger.warn("Integration already exists. If you decide to deploy, it will override the existing one.");
|
|
88
92
|
message = `Are you sure you want to override integration ${name} v${version}?`;
|
|
89
93
|
} else {
|
|
90
94
|
message = `Are you sure you want to deploy integration ${name} v${version}?`;
|
|
@@ -97,6 +101,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
97
101
|
let createBody = (0, import_integration_body.prepareCreateIntegrationBody)(integrationDef);
|
|
98
102
|
createBody = {
|
|
99
103
|
...createBody,
|
|
104
|
+
interfaces: await this._formatInterfacesImplStatements(api, integrationDef),
|
|
100
105
|
code,
|
|
101
106
|
icon: iconFileContent,
|
|
102
107
|
readme: readmeFileContent,
|
|
@@ -149,6 +154,50 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
149
154
|
line.success(successMessage);
|
|
150
155
|
}
|
|
151
156
|
}
|
|
157
|
+
async _deployInterface(api, interfaceDeclaration) {
|
|
158
|
+
if (!api.isBotpressWorkspace) {
|
|
159
|
+
throw new errors.BotpressCLIError("Your workspace is not allowed to deploy interfaces.");
|
|
160
|
+
}
|
|
161
|
+
const { name, version } = interfaceDeclaration;
|
|
162
|
+
const intrface = await api.findPublicInterface({ type: "name", name, version });
|
|
163
|
+
let message;
|
|
164
|
+
if (intrface) {
|
|
165
|
+
this.logger.warn("Interface already exists. If you decide to deploy, it will override the existing one.");
|
|
166
|
+
message = `Are you sure you want to override interface ${name} v${version}?`;
|
|
167
|
+
} else {
|
|
168
|
+
message = `Are you sure you want to deploy interface ${name} v${version}?`;
|
|
169
|
+
}
|
|
170
|
+
const confirm = await this.prompt.confirm(message);
|
|
171
|
+
if (!confirm) {
|
|
172
|
+
this.logger.log("Aborted");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const createBody = (0, import_interface_body.prepareCreateInterfaceBody)(interfaceDeclaration);
|
|
176
|
+
const startedMessage = `Deploying interface ${import_chalk.default.bold(name)} v${version}...`;
|
|
177
|
+
const successMessage = "Interface deployed";
|
|
178
|
+
if (intrface) {
|
|
179
|
+
const updateBody = (0, import_interface_body.prepareUpdateInterfaceBody)(
|
|
180
|
+
{
|
|
181
|
+
id: intrface.id,
|
|
182
|
+
...createBody
|
|
183
|
+
},
|
|
184
|
+
intrface
|
|
185
|
+
);
|
|
186
|
+
const line = this.logger.line();
|
|
187
|
+
line.started(startedMessage);
|
|
188
|
+
await api.client.updateInterface(updateBody).catch((thrown) => {
|
|
189
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not update interface "${name}"`);
|
|
190
|
+
});
|
|
191
|
+
line.success(successMessage);
|
|
192
|
+
} else {
|
|
193
|
+
const line = this.logger.line();
|
|
194
|
+
line.started(startedMessage);
|
|
195
|
+
await api.client.createInterface(createBody).catch((thrown) => {
|
|
196
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not create interface "${name}"`);
|
|
197
|
+
});
|
|
198
|
+
line.success(successMessage);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
152
201
|
_allowDeprecatedFeatures(integrationDef, previousVersion) {
|
|
153
202
|
if (this.argv.allowDeprecated) {
|
|
154
203
|
return true;
|
|
@@ -357,6 +406,23 @@ class DeployCommand extends import_project_command.ProjectCommand {
|
|
|
357
406
|
const [name] = parts;
|
|
358
407
|
return { name };
|
|
359
408
|
};
|
|
409
|
+
_formatInterfacesImplStatements = async (api, integration) => {
|
|
410
|
+
const interfacesEntries = Object.entries(integration.interfaces);
|
|
411
|
+
if (!interfacesEntries.length) {
|
|
412
|
+
return void 0;
|
|
413
|
+
}
|
|
414
|
+
const interfaces = {};
|
|
415
|
+
for (const [key, i] of interfacesEntries) {
|
|
416
|
+
const { name, version, entities, actions, events } = i;
|
|
417
|
+
const intrface = await api.findPublicInterface({ type: "name", name, version });
|
|
418
|
+
if (!intrface) {
|
|
419
|
+
throw new errors.BotpressCLIError(`Could not find interface "${name}@${version}"`);
|
|
420
|
+
}
|
|
421
|
+
const { id } = intrface;
|
|
422
|
+
interfaces[key] = { id, entities, actions, events };
|
|
423
|
+
}
|
|
424
|
+
return interfaces;
|
|
425
|
+
};
|
|
360
426
|
}
|
|
361
427
|
// Annotate the CommonJS export names for ESM import in node:
|
|
362
428
|
0 && (module.exports = {
|