@botpress/cli 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-generation/action.js +2 -2
- package/dist/code-generation/channel.js +2 -2
- package/dist/code-generation/event.js +1 -1
- package/dist/code-generation/index.js +25 -7
- package/dist/code-generation/integration-impl.js +3 -3
- package/dist/code-generation/integration-instance.js +3 -2
- package/dist/code-generation/integration-secret.js +54 -0
- package/dist/code-generation/message.js +1 -1
- package/dist/code-generation/module.js +6 -5
- package/dist/command-implementations/base-command.js +7 -2
- package/dist/command-implementations/deploy-command.js +5 -1
- package/dist/command-implementations/dev-command.js +7 -4
- package/dist/command-implementations/gen-command.js +24 -2
- package/dist/command-implementations/global-command.js +3 -0
- package/dist/command-implementations/init-command.js +1 -1
- package/dist/command-implementations/project-command.js +48 -0
- package/dist/command-implementations/serve-command.js +8 -2
- package/dist/config.js +13 -0
- package/dist/consts.js +1 -0
- package/dist/utils/case-utils.js +69 -0
- package/dist/utils/index.js +5 -5
- package/dist/utils/prompt-utils.js +8 -4
- package/package.json +3 -3
- package/templates/echo-bot/package.json +1 -2
- package/templates/empty-integration/.botpress/index.ts +2 -1
- package/templates/empty-integration/.botpress/secrets/index.ts +7 -0
- package/templates/empty-integration/integration.definition.ts +2 -2
- package/templates/empty-integration/package.json +1 -2
- package/dist/app/api-utils.js +0 -112
- package/dist/app/base.js +0 -71
- package/dist/app/cache.js +0 -95
- package/dist/app/errors.js +0 -156
- package/dist/app/file-paths.js +0 -79
- package/dist/app/generator/action.js +0 -76
- package/dist/app/generator/channel.js +0 -51
- package/dist/app/generator/configuration.js +0 -40
- package/dist/app/generator/const.js +0 -31
- package/dist/app/generator/event.js +0 -47
- package/dist/app/generator/index.js +0 -83
- package/dist/app/generator/integration-impl.js +0 -147
- package/dist/app/generator/integration-instance.js +0 -85
- package/dist/app/generator/message.js +0 -47
- package/dist/app/generator/module.js +0 -115
- package/dist/app/generator/strings.js +0 -38
- package/dist/app/generator/typings.js +0 -16
- package/dist/app/index.js +0 -82
- package/dist/app/integration-ref.js +0 -61
- package/dist/app/project.js +0 -486
- package/dist/app/typings.js +0 -16
- package/dist/app/user.js +0 -237
- package/dist/esbuild-utils.js +0 -89
- package/dist/event-emitter.js +0 -62
- package/dist/path-utils.js +0 -72
- package/dist/require-utils.js +0 -49
- package/dist/update-notif.js +0 -47
- package/dist/utils/string-utils.js +0 -57
- package/dist/watcher.js +0 -68
- package/templates/echo-bot/.botpress/project.cache.json +0 -1
- package/templates/empty-integration/.botpress/project.cache.json +0 -1
|
@@ -1,76 +0,0 @@
|
|
|
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 action_exports = {};
|
|
26
|
-
__export(action_exports, {
|
|
27
|
-
ActionInputModule: () => ActionInputModule,
|
|
28
|
-
ActionModule: () => ActionModule,
|
|
29
|
-
ActionOutputModule: () => ActionOutputModule
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(action_exports);
|
|
32
|
-
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
33
|
-
var import_module = require("./module");
|
|
34
|
-
var strings = __toESM(require("./strings"));
|
|
35
|
-
class ActionInputModule extends import_module.Module {
|
|
36
|
-
static async create(input) {
|
|
37
|
-
const schema = input.schema ?? {};
|
|
38
|
-
const filename = "input.ts";
|
|
39
|
-
const def = {
|
|
40
|
-
path: filename,
|
|
41
|
-
exportName: "Input",
|
|
42
|
-
content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
|
|
43
|
-
};
|
|
44
|
-
return new ActionInputModule(def);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
class ActionOutputModule extends import_module.Module {
|
|
48
|
-
static async create(output) {
|
|
49
|
-
const schema = output.schema ?? {};
|
|
50
|
-
const filename = "output.ts";
|
|
51
|
-
const def = {
|
|
52
|
-
path: filename,
|
|
53
|
-
exportName: "Output",
|
|
54
|
-
content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
|
|
55
|
-
};
|
|
56
|
-
return new ActionOutputModule(def);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
class ActionModule extends import_module.ReExportModule {
|
|
60
|
-
static async create(actionName, action) {
|
|
61
|
-
const inputModule = await ActionInputModule.create(action.input ?? {});
|
|
62
|
-
const outputModule = await ActionOutputModule.create(action.output ?? {});
|
|
63
|
-
const inst = new ActionModule({
|
|
64
|
-
exportName: `Action${strings.pascalCase(actionName)}`
|
|
65
|
-
});
|
|
66
|
-
inst.pushDep(inputModule);
|
|
67
|
-
inst.pushDep(outputModule);
|
|
68
|
-
return inst;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
-
0 && (module.exports = {
|
|
73
|
-
ActionInputModule,
|
|
74
|
-
ActionModule,
|
|
75
|
-
ActionOutputModule
|
|
76
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
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 channel_exports = {};
|
|
26
|
-
__export(channel_exports, {
|
|
27
|
-
ChannelModule: () => ChannelModule
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(channel_exports);
|
|
30
|
-
var import_bluebird = __toESM(require("bluebird"));
|
|
31
|
-
var import_message = require("./message");
|
|
32
|
-
var import_module = require("./module");
|
|
33
|
-
var strings = __toESM(require("./strings"));
|
|
34
|
-
class ChannelModule extends import_module.ReExportModule {
|
|
35
|
-
static async create(channelName, channel) {
|
|
36
|
-
const messages = channel.messages ?? {};
|
|
37
|
-
const messageModules = await import_bluebird.default.map(
|
|
38
|
-
Object.entries(messages),
|
|
39
|
-
([messageName, message]) => import_message.MessageModule.create(messageName, message)
|
|
40
|
-
);
|
|
41
|
-
const inst = new ChannelModule({
|
|
42
|
-
exportName: `Channel${strings.pascalCase(channelName)}`
|
|
43
|
-
});
|
|
44
|
-
inst.pushDep(...messageModules);
|
|
45
|
-
return inst;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
ChannelModule
|
|
51
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var configuration_exports = {};
|
|
20
|
-
__export(configuration_exports, {
|
|
21
|
-
ConfigurationModule: () => ConfigurationModule
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(configuration_exports);
|
|
24
|
-
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
25
|
-
var import_module = require("./module");
|
|
26
|
-
class ConfigurationModule extends import_module.Module {
|
|
27
|
-
static async create(configuration) {
|
|
28
|
-
const schema = configuration.schema ?? {};
|
|
29
|
-
const filename = "configuration";
|
|
30
|
-
return new ConfigurationModule({
|
|
31
|
-
path: `${filename}.ts`,
|
|
32
|
-
exportName: "Configuration",
|
|
33
|
-
content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
ConfigurationModule
|
|
40
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var const_exports = {};
|
|
20
|
-
__export(const_exports, {
|
|
21
|
-
GENERATED_HEADER: () => GENERATED_HEADER,
|
|
22
|
-
INDEX_FILE: () => INDEX_FILE
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(const_exports);
|
|
25
|
-
const GENERATED_HEADER = "/* tslint:disable */\n// This file is generated\n// Do not edit this file\n\n";
|
|
26
|
-
const INDEX_FILE = "index.ts";
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
GENERATED_HEADER,
|
|
30
|
-
INDEX_FILE
|
|
31
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
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 event_exports = {};
|
|
26
|
-
__export(event_exports, {
|
|
27
|
-
EventModule: () => EventModule
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(event_exports);
|
|
30
|
-
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
31
|
-
var import_module = require("./module");
|
|
32
|
-
var strings = __toESM(require("./strings"));
|
|
33
|
-
class EventModule extends import_module.Module {
|
|
34
|
-
static async create(name, event) {
|
|
35
|
-
const schema = event.schema ?? {};
|
|
36
|
-
const def = {
|
|
37
|
-
path: `${name}.ts`,
|
|
38
|
-
exportName: strings.pascalCase(name),
|
|
39
|
-
content: await (0, import_json_schema_to_typescript.compile)(schema, name)
|
|
40
|
-
};
|
|
41
|
-
return new EventModule(def);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
EventModule
|
|
47
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
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 generator_exports = {};
|
|
26
|
-
__export(generator_exports, {
|
|
27
|
-
File: () => import_typings.File,
|
|
28
|
-
INTEGRATION_JSON: () => INTEGRATION_JSON,
|
|
29
|
-
generateBotIndex: () => generateBotIndex,
|
|
30
|
-
generateIntegrationImplementationTypings: () => generateIntegrationImplementationTypings,
|
|
31
|
-
generateIntegrationIndex: () => generateIntegrationIndex,
|
|
32
|
-
generateIntegrationInstance: () => generateIntegrationInstance,
|
|
33
|
-
strings: () => strings2
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(generator_exports);
|
|
36
|
-
var import_path = __toESM(require("path"));
|
|
37
|
-
var import_const = require("./const");
|
|
38
|
-
var import_integration_impl = require("./integration-impl");
|
|
39
|
-
var import_integration_instance = require("./integration-instance");
|
|
40
|
-
var strings = __toESM(require("./strings"));
|
|
41
|
-
var import_typings = require("./typings");
|
|
42
|
-
var strings2 = __toESM(require("./strings"));
|
|
43
|
-
const INTEGRATION_JSON = "integration.json";
|
|
44
|
-
const generateIntegrationImplementationTypings = async (integration, implementationTypingsPath) => {
|
|
45
|
-
const indexModule = await import_integration_impl.IntegrationImplementationIndexModule.create(integration);
|
|
46
|
-
indexModule.unshift(implementationTypingsPath);
|
|
47
|
-
return indexModule.flatten();
|
|
48
|
-
};
|
|
49
|
-
const generateIntegrationIndex = async (implementationTypingsPath) => ({
|
|
50
|
-
path: import_const.INDEX_FILE,
|
|
51
|
-
content: `export * from './${implementationTypingsPath}'`
|
|
52
|
-
});
|
|
53
|
-
const generateIntegrationInstance = async (integration, installPath) => {
|
|
54
|
-
const indexModule = await import_integration_instance.IntegrationInstanceIndexModule.create(integration);
|
|
55
|
-
const dirname = strings.kebabCase(integration.name);
|
|
56
|
-
indexModule.unshift(installPath, dirname);
|
|
57
|
-
const files = indexModule.flatten();
|
|
58
|
-
const { name, version, id } = integration;
|
|
59
|
-
const json = {
|
|
60
|
-
name,
|
|
61
|
-
version,
|
|
62
|
-
id
|
|
63
|
-
};
|
|
64
|
-
files.push({
|
|
65
|
-
path: import_path.default.join(installPath, dirname, INTEGRATION_JSON),
|
|
66
|
-
content: JSON.stringify(json, null, 2)
|
|
67
|
-
});
|
|
68
|
-
return files;
|
|
69
|
-
};
|
|
70
|
-
const generateBotIndex = async (installPath, instances) => ({
|
|
71
|
-
path: import_const.INDEX_FILE,
|
|
72
|
-
content: instances.map((instance) => `export * from './${installPath}/${instance}'`).join("\n")
|
|
73
|
-
});
|
|
74
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
-
0 && (module.exports = {
|
|
76
|
-
File,
|
|
77
|
-
INTEGRATION_JSON,
|
|
78
|
-
generateBotIndex,
|
|
79
|
-
generateIntegrationImplementationTypings,
|
|
80
|
-
generateIntegrationIndex,
|
|
81
|
-
generateIntegrationInstance,
|
|
82
|
-
strings
|
|
83
|
-
});
|
|
@@ -1,147 +0,0 @@
|
|
|
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 integration_impl_exports = {};
|
|
26
|
-
__export(integration_impl_exports, {
|
|
27
|
-
IntegrationImplementationIndexModule: () => IntegrationImplementationIndexModule
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(integration_impl_exports);
|
|
30
|
-
var import_bluebird = __toESM(require("bluebird"));
|
|
31
|
-
var import_action = require("./action");
|
|
32
|
-
var import_channel = require("./channel");
|
|
33
|
-
var import_configuration = require("./configuration");
|
|
34
|
-
var import_const = require("./const");
|
|
35
|
-
var import_event = require("./event");
|
|
36
|
-
var import_module = require("./module");
|
|
37
|
-
var strings = __toESM(require("./strings"));
|
|
38
|
-
class IntegrationImplementationIndexModule extends import_module.Module {
|
|
39
|
-
constructor(configModule, actionsModule, channelsModule, eventsModule, integrationID, def) {
|
|
40
|
-
super(def);
|
|
41
|
-
this.configModule = configModule;
|
|
42
|
-
this.actionsModule = actionsModule;
|
|
43
|
-
this.channelsModule = channelsModule;
|
|
44
|
-
this.eventsModule = eventsModule;
|
|
45
|
-
this.integrationID = integrationID;
|
|
46
|
-
}
|
|
47
|
-
static async create(integration) {
|
|
48
|
-
const configModule = await import_configuration.ConfigurationModule.create(integration.configuration ?? { schema: {} });
|
|
49
|
-
const actionsModule = await ActionsModule.create(integration.actions ?? {});
|
|
50
|
-
actionsModule.unshift("actions");
|
|
51
|
-
const channelsModule = await ChannelsModule.create(integration.channels ?? {});
|
|
52
|
-
channelsModule.unshift("channels");
|
|
53
|
-
const eventsModule = await EventsModule.create(integration.events ?? {});
|
|
54
|
-
eventsModule.unshift("events");
|
|
55
|
-
const { name, version } = integration;
|
|
56
|
-
const inst = new IntegrationImplementationIndexModule(
|
|
57
|
-
configModule,
|
|
58
|
-
actionsModule,
|
|
59
|
-
channelsModule,
|
|
60
|
-
eventsModule,
|
|
61
|
-
{ name, version },
|
|
62
|
-
{
|
|
63
|
-
path: import_const.INDEX_FILE,
|
|
64
|
-
exportName: "Integration",
|
|
65
|
-
content: ""
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
inst.pushDep(configModule);
|
|
69
|
-
inst.pushDep(actionsModule);
|
|
70
|
-
inst.pushDep(channelsModule);
|
|
71
|
-
inst.pushDep(eventsModule);
|
|
72
|
-
return inst;
|
|
73
|
-
}
|
|
74
|
-
get content() {
|
|
75
|
-
let content = import_const.GENERATED_HEADER;
|
|
76
|
-
const { configModule, actionsModule, channelsModule, eventsModule } = this;
|
|
77
|
-
content += 'import { Integration } from "@botpress/sdk";\n\n';
|
|
78
|
-
const configImport = configModule.import(this);
|
|
79
|
-
const actionsImport = actionsModule.import(this);
|
|
80
|
-
const channelsImport = channelsModule.import(this);
|
|
81
|
-
const eventsImport = eventsModule.import(this);
|
|
82
|
-
content += `import type * as ${configModule.name} from "./${configImport}";
|
|
83
|
-
`;
|
|
84
|
-
content += `import type * as ${actionsModule.name} from "./${actionsImport}";
|
|
85
|
-
`;
|
|
86
|
-
content += `import type * as ${channelsModule.name} from "./${channelsImport}";
|
|
87
|
-
`;
|
|
88
|
-
content += `import type * as ${eventsModule.name} from "./${eventsImport}";
|
|
89
|
-
`;
|
|
90
|
-
content += `export * as ${configModule.name} from "./${configImport}";
|
|
91
|
-
`;
|
|
92
|
-
content += `export * as ${actionsModule.name} from "./${actionsImport}";
|
|
93
|
-
`;
|
|
94
|
-
content += `export * as ${channelsModule.name} from "./${channelsImport}";
|
|
95
|
-
`;
|
|
96
|
-
content += `export * as ${eventsModule.name} from "./${eventsImport}";
|
|
97
|
-
`;
|
|
98
|
-
content += "\n";
|
|
99
|
-
const { name } = this.integrationID;
|
|
100
|
-
const className = strings.pascalCase(name);
|
|
101
|
-
content += `export class Integration${className}
|
|
102
|
-
extends Integration<${configModule.name}.${configModule.exports}, ${actionsModule.name}.${actionsModule.exports}, ${channelsModule.name}.${channelsModule.exports}, ${eventsModule.name}.${eventsModule.exports}> {}
|
|
103
|
-
`;
|
|
104
|
-
return content;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
class ChannelsModule extends import_module.ReExportModule {
|
|
108
|
-
static async create(channels) {
|
|
109
|
-
const channelModules = await import_bluebird.default.map(Object.entries(channels), async ([channelName, channel]) => {
|
|
110
|
-
const mod = await import_channel.ChannelModule.create(channelName, channel);
|
|
111
|
-
return mod.unshift(channelName);
|
|
112
|
-
});
|
|
113
|
-
const inst = new ChannelsModule({ exportName: "Channels" });
|
|
114
|
-
inst.pushDep(...channelModules);
|
|
115
|
-
return inst;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
class ActionsModule extends import_module.ReExportModule {
|
|
119
|
-
static async create(actions) {
|
|
120
|
-
const actionModules = await import_bluebird.default.map(Object.entries(actions), async ([actionName, action]) => {
|
|
121
|
-
const mod = await import_action.ActionModule.create(actionName, action);
|
|
122
|
-
return mod.unshift(actionName);
|
|
123
|
-
});
|
|
124
|
-
const inst = new ActionsModule({
|
|
125
|
-
exportName: "Actions"
|
|
126
|
-
});
|
|
127
|
-
inst.pushDep(...actionModules);
|
|
128
|
-
return inst;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
class EventsModule extends import_module.ReExportModule {
|
|
132
|
-
static async create(events) {
|
|
133
|
-
const eventModules = await import_bluebird.default.map(
|
|
134
|
-
Object.entries(events),
|
|
135
|
-
async ([eventName, event]) => import_event.EventModule.create(eventName, event)
|
|
136
|
-
);
|
|
137
|
-
const inst = new EventsModule({
|
|
138
|
-
exportName: "Events"
|
|
139
|
-
});
|
|
140
|
-
inst.pushDep(...eventModules);
|
|
141
|
-
return inst;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
145
|
-
0 && (module.exports = {
|
|
146
|
-
IntegrationImplementationIndexModule
|
|
147
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
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 integration_instance_exports = {};
|
|
26
|
-
__export(integration_instance_exports, {
|
|
27
|
-
IntegrationInstanceIndexModule: () => IntegrationInstanceIndexModule
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(integration_instance_exports);
|
|
30
|
-
var import_configuration = require("./configuration");
|
|
31
|
-
var import_module = require("./module");
|
|
32
|
-
var strings = __toESM(require("./strings"));
|
|
33
|
-
const CONTENT = ({
|
|
34
|
-
name,
|
|
35
|
-
className,
|
|
36
|
-
propsName,
|
|
37
|
-
version,
|
|
38
|
-
id
|
|
39
|
-
}) => `
|
|
40
|
-
import type { IntegrationInstance } from '@botpress/sdk'
|
|
41
|
-
import type { Configuration } from './configuration'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export type ${propsName} = {
|
|
45
|
-
enabled: true
|
|
46
|
-
config: Configuration
|
|
47
|
-
} | {
|
|
48
|
-
enabled: false
|
|
49
|
-
config?: Configuration
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class ${className} implements IntegrationInstance {
|
|
53
|
-
|
|
54
|
-
public readonly enabled: boolean
|
|
55
|
-
|
|
56
|
-
public readonly name = '${name}'
|
|
57
|
-
public readonly version = '${version}'
|
|
58
|
-
public readonly id = '${id}'
|
|
59
|
-
|
|
60
|
-
public readonly configuration: Configuration
|
|
61
|
-
|
|
62
|
-
constructor(props?: ${propsName}) {
|
|
63
|
-
this.enabled = props?.enabled ?? false
|
|
64
|
-
this.configuration = props?.config ?? <Configuration>{}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
class IntegrationInstanceIndexModule extends import_module.Module {
|
|
69
|
-
static async create(integration) {
|
|
70
|
-
const { name, version, id } = integration;
|
|
71
|
-
const configModule = await import_configuration.ConfigurationModule.create(integration.configuration ?? { schema: {} });
|
|
72
|
-
const exportName = strings.pascalCase(name);
|
|
73
|
-
const content = CONTENT({ name, className: exportName, propsName: `${exportName}Props`, version, id });
|
|
74
|
-
const inst = new IntegrationInstanceIndexModule({ path: "index.ts", content, exportName });
|
|
75
|
-
inst.pushDep(configModule);
|
|
76
|
-
return inst;
|
|
77
|
-
}
|
|
78
|
-
constructor(def) {
|
|
79
|
-
super(def);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
-
0 && (module.exports = {
|
|
84
|
-
IntegrationInstanceIndexModule
|
|
85
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
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 message_exports = {};
|
|
26
|
-
__export(message_exports, {
|
|
27
|
-
MessageModule: () => MessageModule
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(message_exports);
|
|
30
|
-
var import_json_schema_to_typescript = require("json-schema-to-typescript");
|
|
31
|
-
var import_module = require("./module");
|
|
32
|
-
var strings = __toESM(require("./strings"));
|
|
33
|
-
class MessageModule extends import_module.Module {
|
|
34
|
-
static async create(name, message) {
|
|
35
|
-
const schema = message.schema ?? {};
|
|
36
|
-
const def = {
|
|
37
|
-
path: `${name}.ts`,
|
|
38
|
-
exportName: strings.pascalCase(name),
|
|
39
|
-
content: await (0, import_json_schema_to_typescript.compile)(schema, name)
|
|
40
|
-
};
|
|
41
|
-
return new MessageModule(def);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
MessageModule
|
|
47
|
-
});
|