@botpress/cli 1.7.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +11 -9
- package/dist/api/bot-body.js +20 -6
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +18 -0
- package/dist/api/client.js.map +2 -2
- package/dist/api/interface-body.js.map +2 -2
- package/dist/api/plugin-body.js +79 -0
- package/dist/api/plugin-body.js.map +7 -0
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-implementation.js +40 -21
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-plugins/index.js +76 -0
- package/dist/code-generation/bot-implementation/bot-plugins/index.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +125 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/index.js +27 -22
- package/dist/code-generation/bot-implementation/index.js.map +2 -2
- package/dist/code-generation/consts.js +3 -0
- package/dist/code-generation/consts.js.map +2 -2
- package/dist/code-generation/generators.js +8 -0
- package/dist/code-generation/generators.js.map +2 -2
- package/dist/code-generation/index.js +6 -0
- package/dist/code-generation/index.js.map +2 -2
- package/dist/code-generation/integration-package/index.js +11 -2
- package/dist/code-generation/integration-package/index.js.map +2 -2
- package/dist/code-generation/interface-implementation/index.js +29 -0
- package/dist/code-generation/interface-implementation/index.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js +84 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js +103 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js +59 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js +59 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js +117 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js.map +7 -0
- package/dist/code-generation/interface-package/index.js +11 -2
- package/dist/code-generation/interface-package/index.js.map +2 -2
- package/dist/code-generation/module.js +17 -4
- package/dist/code-generation/module.js.map +2 -2
- package/dist/code-generation/plugin-implementation/index.js +56 -0
- package/dist/code-generation/plugin-implementation/index.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +86 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js +84 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js +57 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js +59 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +146 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js +60 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js.map +7 -0
- package/dist/code-generation/plugin-package/index.js +146 -0
- package/dist/code-generation/plugin-package/index.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +84 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +52 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +62 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js +103 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +62 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js +17 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js.map +7 -0
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-definitions.js +8 -0
- package/dist/command-definitions.js.map +2 -2
- package/dist/command-implementations/add-command.js +47 -10
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +7 -2
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +51 -0
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +11 -0
- 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/init-command.js +36 -8
- package/dist/command-implementations/init-command.js.map +2 -2
- package/dist/command-implementations/lint-command.js +1 -1
- package/dist/command-implementations/lint-command.js.map +2 -2
- package/dist/command-implementations/plugin-commands.js +107 -0
- package/dist/command-implementations/plugin-commands.js.map +7 -0
- package/dist/command-implementations/project-command.js +30 -3
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +13 -1
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/config.js +23 -2
- package/dist/config.js.map +2 -2
- package/dist/consts.js +7 -0
- package/dist/consts.js.map +2 -2
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.js.map +2 -2
- package/dist/sdk/resolve-bot-interfaces.js +6 -1
- package/dist/sdk/resolve-bot-interfaces.js.map +2 -2
- package/dist/sdk/resolve-integration-interfaces.js +16 -8
- package/dist/sdk/resolve-integration-interfaces.js.map +2 -2
- package/dist/sdk/validate-bot.js +84 -0
- package/dist/sdk/validate-bot.js.map +7 -0
- package/dist/utils/esbuild-utils.js +3 -2
- package/dist/utils/esbuild-utils.js.map +2 -2
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/object-utils.js +32 -0
- package/dist/utils/object-utils.js.map +7 -0
- package/dist/utils/schema-utils.js.map +2 -2
- package/dist/utils/type-utils.js.map +1 -1
- package/e2e/tests/install-package.ts +1 -1
- package/package.json +3 -3
- package/templates/empty-bot/.botpress/implementation/index.ts +27 -18
- package/templates/empty-bot/.botpress/implementation/plugins/index.ts +11 -0
- package/templates/empty-bot/.botpress/index.ts +5 -1
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/.botpress/implementation/index.ts +35 -0
- package/templates/empty-plugin/.botpress/implementation/typings/actions/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/empty-plugin/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +26 -0
- package/templates/empty-plugin/.botpress/implementation/typings/integrations/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/interfaces/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/empty-plugin/.botpress/index.ts +1 -0
- package/templates/empty-plugin/package.json +16 -0
- package/templates/empty-plugin/plugin.definition.ts +7 -0
- package/templates/empty-plugin/src/index.ts +7 -0
- package/templates/empty-plugin/tsconfig.json +28 -0
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
|
@@ -0,0 +1,86 @@
|
|
|
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 plugin_implementation_exports = {};
|
|
26
|
+
__export(plugin_implementation_exports, {
|
|
27
|
+
PluginImplementationModule: () => PluginImplementationModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(plugin_implementation_exports);
|
|
30
|
+
var consts = __toESM(require("../consts"));
|
|
31
|
+
var import_module = require("../module");
|
|
32
|
+
var import_plugin_typings = require("./plugin-typings");
|
|
33
|
+
class PluginImplementationModule extends import_module.Module {
|
|
34
|
+
_typingsModule;
|
|
35
|
+
constructor(plugin) {
|
|
36
|
+
super({
|
|
37
|
+
exportName: "Plugin",
|
|
38
|
+
path: consts.INDEX_FILE
|
|
39
|
+
});
|
|
40
|
+
this._typingsModule = new import_plugin_typings.PluginTypingsModule(plugin);
|
|
41
|
+
this._typingsModule.unshift("typings");
|
|
42
|
+
this.pushDep(this._typingsModule);
|
|
43
|
+
}
|
|
44
|
+
async getContent() {
|
|
45
|
+
const typingsImport = this._typingsModule.import(this);
|
|
46
|
+
return [
|
|
47
|
+
consts.GENERATED_HEADER,
|
|
48
|
+
'import * as sdk from "@botpress/sdk"',
|
|
49
|
+
`import * as ${this._typingsModule.name} from "./${typingsImport}"`,
|
|
50
|
+
`export * from "./${typingsImport}"`,
|
|
51
|
+
"",
|
|
52
|
+
`type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,
|
|
53
|
+
"",
|
|
54
|
+
"export class Plugin extends sdk.Plugin<TPlugin> {}",
|
|
55
|
+
"",
|
|
56
|
+
"// extra types",
|
|
57
|
+
"",
|
|
58
|
+
"type AsyncFunction = (...args: any[]) => Promise<any>",
|
|
59
|
+
"export type EventHandlers = Required<{",
|
|
60
|
+
" [K in keyof Plugin['eventHandlers']]: NonNullable<Plugin['eventHandlers'][K]>[number]",
|
|
61
|
+
"}>",
|
|
62
|
+
"export type MessageHandlers = Required<{",
|
|
63
|
+
" [K in keyof Plugin['messageHandlers']]: NonNullable<Plugin['messageHandlers'][K]>[number]",
|
|
64
|
+
"}>",
|
|
65
|
+
"",
|
|
66
|
+
"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]",
|
|
67
|
+
"export type EventHandlerProps = Parameters<EventHandlers['*']>[0]",
|
|
68
|
+
"",
|
|
69
|
+
"export type Client = (MessageHandlerProps | EventHandlerProps)['client']",
|
|
70
|
+
"export type ClientOperation = keyof {",
|
|
71
|
+
" [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null",
|
|
72
|
+
"}",
|
|
73
|
+
"export type ClientInputs = {",
|
|
74
|
+
" [K in ClientOperation]: Parameters<Client[K]>[0]",
|
|
75
|
+
"}",
|
|
76
|
+
"export type ClientOutputs = {",
|
|
77
|
+
" [K in ClientOperation]: Awaited<ReturnType<Client[K]>>",
|
|
78
|
+
"}"
|
|
79
|
+
].join("\n");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
83
|
+
0 && (module.exports = {
|
|
84
|
+
PluginImplementationModule
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=plugin-implementation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/code-generation/plugin-implementation/plugin-implementation.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { PluginTypingsModule } from './plugin-typings'\n\nexport class PluginImplementationModule extends Module {\n private _typingsModule: PluginTypingsModule\n\n public constructor(plugin: sdk.PluginDefinition) {\n super({\n exportName: 'Plugin',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new PluginTypingsModule(plugin)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `export * from \"./${typingsImport}\"`,\n '',\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n 'export class Plugin extends sdk.Plugin<TPlugin> {}',\n '',\n '// extra types',\n '',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n 'export type EventHandlers = Required<{',\n \" [K in keyof Plugin['eventHandlers']]: NonNullable<Plugin['eventHandlers'][K]>[number]\",\n '}>',\n 'export type MessageHandlers = Required<{',\n \" [K in keyof Plugin['messageHandlers']]: NonNullable<Plugin['messageHandlers'][K]>[number]\",\n '}>',\n '',\n \"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]\",\n \"export type EventHandlerProps = Parameters<EventHandlers['*']>[0]\",\n '',\n \"export type Client = (MessageHandlerProps | EventHandlerProps)['client']\",\n 'export type ClientOperation = keyof {',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null',\n '}',\n 'export type ClientInputs = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientOutputs = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,4BAAoC;AAE7B,MAAM,mCAAmC,qBAAO;AAAA,EAC7C;AAAA,EAED,YAAY,QAA8B;AAC/C,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,0CAAoB,MAAM;AACpD,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oBAAoB;AAAA,MACpB;AAAA,MACA,oCAAoC,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACpF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 actions_module_exports = {};
|
|
26
|
+
__export(actions_module_exports, {
|
|
27
|
+
ActionInputModule: () => ActionInputModule,
|
|
28
|
+
ActionModule: () => ActionModule,
|
|
29
|
+
ActionOutputModule: () => ActionOutputModule,
|
|
30
|
+
ActionsModule: () => ActionsModule
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(actions_module_exports);
|
|
33
|
+
var import_generators = require("../../generators");
|
|
34
|
+
var import_module = require("../../module");
|
|
35
|
+
var strings = __toESM(require("../../strings"));
|
|
36
|
+
class ActionInputModule extends import_module.Module {
|
|
37
|
+
constructor(_input) {
|
|
38
|
+
const name = "input";
|
|
39
|
+
const exportName = strings.typeName(name);
|
|
40
|
+
super({ path: `${name}.ts`, exportName });
|
|
41
|
+
this._input = _input;
|
|
42
|
+
}
|
|
43
|
+
async getContent() {
|
|
44
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._input.schema, this.exportName);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class ActionOutputModule extends import_module.Module {
|
|
48
|
+
constructor(_output) {
|
|
49
|
+
const name = "output";
|
|
50
|
+
const exportName = strings.typeName(name);
|
|
51
|
+
super({ path: `${name}.ts`, exportName });
|
|
52
|
+
this._output = _output;
|
|
53
|
+
}
|
|
54
|
+
async getContent() {
|
|
55
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._output.schema, this.exportName);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
class ActionModule extends import_module.ReExportTypeModule {
|
|
59
|
+
constructor(actionName, action) {
|
|
60
|
+
super({ exportName: strings.typeName(actionName) });
|
|
61
|
+
const inputModule = new ActionInputModule(action.input);
|
|
62
|
+
const outputModule = new ActionOutputModule(action.output);
|
|
63
|
+
this.pushDep(inputModule);
|
|
64
|
+
this.pushDep(outputModule);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
class ActionsModule extends import_module.ReExportTypeModule {
|
|
68
|
+
constructor(actions) {
|
|
69
|
+
super({ exportName: strings.typeName("actions") });
|
|
70
|
+
for (const [actionName, action] of Object.entries(actions)) {
|
|
71
|
+
const module2 = new ActionModule(actionName, action);
|
|
72
|
+
module2.unshift(actionName);
|
|
73
|
+
this.pushDep(module2);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
ActionInputModule,
|
|
80
|
+
ActionModule,
|
|
81
|
+
ActionOutputModule,
|
|
82
|
+
ActionsModule
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=actions-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/plugin-implementation/plugin-typings/actions-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\ntype ActionInput = sdk.BotActionDefinition['input']\ntype ActionOutput = sdk.BotActionDefinition['output']\n\nexport class ActionInputModule extends Module {\n public constructor(private _input: ActionInput) {\n const name = 'input'\n const exportName = strings.typeName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._input.schema, this.exportName)\n }\n}\n\nexport class ActionOutputModule extends Module {\n public constructor(private _output: ActionOutput) {\n const name = 'output'\n const exportName = strings.typeName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._output.schema, this.exportName)\n }\n}\n\nexport class ActionModule extends ReExportTypeModule {\n public constructor(actionName: string, action: sdk.BotActionDefinition) {\n super({ exportName: strings.typeName(actionName) })\n\n const inputModule = new ActionInputModule(action.input)\n const outputModule = new ActionOutputModule(action.output)\n\n this.pushDep(inputModule)\n this.pushDep(outputModule)\n }\n}\n\nexport class ActionsModule extends ReExportTypeModule {\n public constructor(actions: Record<string, sdk.BotActionDefinition>) {\n super({ exportName: strings.typeName('actions') })\n for (const [actionName, action] of Object.entries(actions)) {\n const module = new ActionModule(actionName, action)\n module.unshift(actionName)\n this.pushDep(module)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAKlB,MAAM,0BAA0B,qBAAO;AAAA,EACrC,YAAoB,QAAqB;AAC9C,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHf;AAAA,EAI3B;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,2BAA2B,qBAAO;AAAA,EACtC,YAAoB,SAAuB;AAChD,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHf;AAAA,EAI3B;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,QAAQ,QAAQ,KAAK,UAAU;AAAA,EACvE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,YAAoB,QAAiC;AACtE,UAAM,EAAE,YAAY,QAAQ,SAAS,UAAU,EAAE,CAAC;AAElD,UAAM,cAAc,IAAI,kBAAkB,OAAO,KAAK;AACtD,UAAM,eAAe,IAAI,mBAAmB,OAAO,MAAM;AAEzD,SAAK,QAAQ,WAAW;AACxB,SAAK,QAAQ,YAAY;AAAA,EAC3B;AACF;AAEO,MAAM,sBAAsB,iCAAmB;AAAA,EAC7C,YAAY,SAAkD;AACnE,UAAM,EAAE,YAAY,QAAQ,SAAS,SAAS,EAAE,CAAC;AACjD,eAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,OAAO,GAAG;AAC1D,YAAMA,UAAS,IAAI,aAAa,YAAY,MAAM;AAClD,MAAAA,QAAO,QAAQ,UAAU;AACzB,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["module"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 configuration_module_exports = {};
|
|
26
|
+
__export(configuration_module_exports, {
|
|
27
|
+
DefaultConfigurationModule: () => DefaultConfigurationModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(configuration_module_exports);
|
|
30
|
+
var import_consts = require("../../consts");
|
|
31
|
+
var import_generators = require("../../generators");
|
|
32
|
+
var import_module = require("../../module");
|
|
33
|
+
var strings = __toESM(require("../../strings"));
|
|
34
|
+
class DefaultConfigurationModule extends import_module.Module {
|
|
35
|
+
constructor(_configuration) {
|
|
36
|
+
const name = "configuration";
|
|
37
|
+
const exportName = strings.typeName(name);
|
|
38
|
+
super({
|
|
39
|
+
path: import_consts.INDEX_FILE,
|
|
40
|
+
exportName
|
|
41
|
+
});
|
|
42
|
+
this._configuration = _configuration;
|
|
43
|
+
}
|
|
44
|
+
async getContent() {
|
|
45
|
+
if (!this._configuration) {
|
|
46
|
+
return ["/** Default Configuration of the Plugin */", "export type Configuration = Record<string, never>;"].join(
|
|
47
|
+
"\n"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._configuration.schema, this.exportName);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
DefaultConfigurationModule
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=configuration-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/plugin-implementation/plugin-typings/configuration-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { INDEX_FILE } from '../../consts'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module } from '../../module'\nimport * as strings from '../../strings'\n\nexport class DefaultConfigurationModule extends Module {\n public constructor(private _configuration: sdk.BotConfigurationDefinition | undefined) {\n const name = 'configuration'\n const exportName = strings.typeName(name)\n super({\n path: INDEX_FILE,\n exportName,\n })\n }\n\n public async getContent() {\n if (!this._configuration) {\n return ['/** Default Configuration of the Plugin */', 'export type Configuration = Record<string, never>;'].join(\n '\\n'\n )\n }\n return zuiSchemaToTypeScriptType(this._configuration.schema, this.exportName)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,wBAA0C;AAC1C,oBAAuB;AACvB,cAAyB;AAElB,MAAM,mCAAmC,qBAAO;AAAA,EAC9C,YAAoB,gBAA4D;AACrF,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM;AAAA,MACJ,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AANwB;AAAA,EAO3B;AAAA,EAEA,MAAa,aAAa;AACxB,QAAI,CAAC,KAAK,gBAAgB;AACxB,aAAO,CAAC,8CAA8C,oDAAoD,EAAE;AAAA,QAC1G;AAAA,MACF;AAAA,IACF;AACA,eAAO,6CAA0B,KAAK,eAAe,QAAQ,KAAK,UAAU;AAAA,EAC9E;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 events_module_exports = {};
|
|
26
|
+
__export(events_module_exports, {
|
|
27
|
+
EventModule: () => EventModule,
|
|
28
|
+
EventsModule: () => EventsModule
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(events_module_exports);
|
|
31
|
+
var import_generators = require("../../generators");
|
|
32
|
+
var import_module = require("../../module");
|
|
33
|
+
var strings = __toESM(require("../../strings"));
|
|
34
|
+
class EventModule extends import_module.Module {
|
|
35
|
+
constructor(name, _event) {
|
|
36
|
+
const eventName = name;
|
|
37
|
+
const exportName = strings.typeName(eventName);
|
|
38
|
+
super({ path: `${name}.ts`, exportName });
|
|
39
|
+
this._event = _event;
|
|
40
|
+
}
|
|
41
|
+
async getContent() {
|
|
42
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._event.schema, this.exportName);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class EventsModule extends import_module.ReExportTypeModule {
|
|
46
|
+
constructor(events) {
|
|
47
|
+
super({ exportName: strings.typeName("events") });
|
|
48
|
+
for (const [eventName, event] of Object.entries(events)) {
|
|
49
|
+
const module2 = new EventModule(eventName, event);
|
|
50
|
+
this.pushDep(module2);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
EventModule,
|
|
57
|
+
EventsModule
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=events-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/plugin-implementation/plugin-typings/events-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class EventModule extends Module {\n public constructor(name: string, private _event: sdk.BotEventDefinition) {\n const eventName = name\n const exportName = strings.typeName(eventName)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._event.schema, this.exportName)\n }\n}\n\nexport class EventsModule extends ReExportTypeModule {\n public constructor(events: Record<string, sdk.BotEventDefinition>) {\n super({ exportName: strings.typeName('events') })\n for (const [eventName, event] of Object.entries(events)) {\n const module = new EventModule(eventName, event)\n this.pushDep(module)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YAAY,MAAsB,QAAgC;AACvE,UAAM,YAAY;AAClB,UAAM,aAAa,QAAQ,SAAS,SAAS;AAC7C,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHD;AAAA,EAIzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["module"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
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 plugin_typings_exports = {};
|
|
26
|
+
__export(plugin_typings_exports, {
|
|
27
|
+
PluginTypingsModule: () => PluginTypingsModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(plugin_typings_exports);
|
|
30
|
+
var consts = __toESM(require("../../consts"));
|
|
31
|
+
var import_integration_typings = require("../../integration-implementation/integration-typings");
|
|
32
|
+
var import_interface_implementation = require("../../interface-implementation");
|
|
33
|
+
var import_module = require("../../module");
|
|
34
|
+
var import_actions_module = require("./actions-module");
|
|
35
|
+
var import_configuration_module = require("./configuration-module");
|
|
36
|
+
var import_events_module = require("./events-module");
|
|
37
|
+
var import_states_module = require("./states-module");
|
|
38
|
+
class PluginIntegrationsModule extends import_module.ReExportTypeModule {
|
|
39
|
+
constructor(plugin) {
|
|
40
|
+
super({
|
|
41
|
+
exportName: "Integrations"
|
|
42
|
+
});
|
|
43
|
+
for (const [alias, integration] of Object.entries(plugin.integrations ?? {})) {
|
|
44
|
+
const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition);
|
|
45
|
+
integrationModule.unshift(alias);
|
|
46
|
+
this.pushDep(integrationModule);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class PluginInterfacesModule extends import_module.ReExportTypeModule {
|
|
51
|
+
constructor(plugin) {
|
|
52
|
+
super({
|
|
53
|
+
exportName: "Interfaces"
|
|
54
|
+
});
|
|
55
|
+
for (const [alias, intrface] of Object.entries(plugin.interfaces ?? {})) {
|
|
56
|
+
const interfaceModule = new import_interface_implementation.InterfaceTypingsModule(intrface.definition);
|
|
57
|
+
interfaceModule.unshift(alias);
|
|
58
|
+
this.pushDep(interfaceModule);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const _isLocalPluginDefinition = (plugin) => {
|
|
63
|
+
return "props" in plugin;
|
|
64
|
+
};
|
|
65
|
+
class PluginTypingsModule extends import_module.Module {
|
|
66
|
+
_dependencies;
|
|
67
|
+
constructor(plugin) {
|
|
68
|
+
super({
|
|
69
|
+
exportName: "TPlugin",
|
|
70
|
+
path: consts.INDEX_FILE
|
|
71
|
+
});
|
|
72
|
+
const integrationsModule = _isLocalPluginDefinition(plugin) ? new PluginIntegrationsModule(plugin) : new import_module.SingleFileModule({
|
|
73
|
+
path: consts.INDEX_FILE,
|
|
74
|
+
exportName: "Integrations",
|
|
75
|
+
content: "export type Integrations = {}"
|
|
76
|
+
});
|
|
77
|
+
integrationsModule.unshift("integrations");
|
|
78
|
+
this.pushDep(integrationsModule);
|
|
79
|
+
const interfacesModule = _isLocalPluginDefinition(plugin) ? new PluginInterfacesModule(plugin) : new import_module.SingleFileModule({
|
|
80
|
+
path: consts.INDEX_FILE,
|
|
81
|
+
exportName: "Interfaces",
|
|
82
|
+
content: "export type Interfaces = {}"
|
|
83
|
+
});
|
|
84
|
+
interfacesModule.unshift("interfaces");
|
|
85
|
+
this.pushDep(interfacesModule);
|
|
86
|
+
const defaultConfigModule = new import_configuration_module.DefaultConfigurationModule(plugin.configuration);
|
|
87
|
+
defaultConfigModule.unshift("configuration");
|
|
88
|
+
this.pushDep(defaultConfigModule);
|
|
89
|
+
const eventsModule = new import_events_module.EventsModule(plugin.events ?? {});
|
|
90
|
+
eventsModule.unshift("events");
|
|
91
|
+
this.pushDep(eventsModule);
|
|
92
|
+
const statesModule = new import_states_module.StatesModule(plugin.states ?? {});
|
|
93
|
+
statesModule.unshift("states");
|
|
94
|
+
this.pushDep(statesModule);
|
|
95
|
+
const actionsModule = new import_actions_module.ActionsModule(plugin.actions ?? {});
|
|
96
|
+
actionsModule.unshift("actions");
|
|
97
|
+
this.pushDep(actionsModule);
|
|
98
|
+
this._dependencies = {
|
|
99
|
+
integrationsModule,
|
|
100
|
+
interfacesModule,
|
|
101
|
+
defaultConfigModule,
|
|
102
|
+
eventsModule,
|
|
103
|
+
statesModule,
|
|
104
|
+
actionsModule
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async getContent() {
|
|
108
|
+
const { integrationsModule, interfacesModule, defaultConfigModule, eventsModule, statesModule, actionsModule } = this._dependencies;
|
|
109
|
+
const integrationsImport = integrationsModule.import(this);
|
|
110
|
+
const interfacesImport = interfacesModule.import(this);
|
|
111
|
+
const defaultConfigImport = defaultConfigModule.import(this);
|
|
112
|
+
const eventsImport = eventsModule.import(this);
|
|
113
|
+
const statesImport = statesModule.import(this);
|
|
114
|
+
const actionsImport = actionsModule;
|
|
115
|
+
return [
|
|
116
|
+
consts.GENERATED_HEADER,
|
|
117
|
+
`import * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
118
|
+
`import * as ${interfacesModule.name} from './${interfacesImport}'`,
|
|
119
|
+
`import * as ${defaultConfigModule.name} from './${defaultConfigImport}'`,
|
|
120
|
+
`import * as ${eventsModule.name} from './${eventsModule.name}'`,
|
|
121
|
+
`import * as ${statesModule.name} from './${statesModule.name}'`,
|
|
122
|
+
`import * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
123
|
+
"",
|
|
124
|
+
`export * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
125
|
+
`export * as ${interfacesModule.name} from './${interfacesImport}'`,
|
|
126
|
+
`export * as ${defaultConfigModule.name} from './${defaultConfigImport}'`,
|
|
127
|
+
`export * as ${eventsModule.name} from './${eventsImport}'`,
|
|
128
|
+
`export * as ${statesModule.name} from './${statesImport}'`,
|
|
129
|
+
`export * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
130
|
+
"",
|
|
131
|
+
"export type TPlugin = {",
|
|
132
|
+
` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
|
|
133
|
+
` interfaces: ${interfacesModule.name}.${interfacesModule.exportName}`,
|
|
134
|
+
` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exportName}`,
|
|
135
|
+
` events: ${eventsModule.name}.${eventsModule.exportName}`,
|
|
136
|
+
` states: ${statesModule.name}.${statesModule.exportName}`,
|
|
137
|
+
` actions: ${actionsModule.name}.${actionsModule.exportName}`,
|
|
138
|
+
"}"
|
|
139
|
+
].join("\n");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
PluginTypingsModule
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/plugin-implementation/plugin-typings/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as utils from '../../../utils'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { InterfaceTypingsModule } from '../../interface-implementation'\nimport { Module, ReExportTypeModule, SingleFileModule } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { DefaultConfigurationModule } from './configuration-module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\n\nclass PluginIntegrationsModule extends ReExportTypeModule {\n public constructor(plugin: sdk.PluginDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(plugin.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\nclass PluginInterfacesModule extends ReExportTypeModule {\n public constructor(plugin: sdk.PluginDefinition) {\n super({\n exportName: 'Interfaces',\n })\n\n for (const [alias, intrface] of Object.entries(plugin.interfaces ?? {})) {\n const interfaceModule = new InterfaceTypingsModule(intrface.definition)\n interfaceModule.unshift(alias)\n this.pushDep(interfaceModule)\n }\n }\n}\n\ntype PluginTypingsIndexDependencies = {\n integrationsModule: PluginIntegrationsModule\n interfacesModule: PluginInterfacesModule\n defaultConfigModule: DefaultConfigurationModule\n eventsModule: EventsModule\n statesModule: StatesModule\n actionsModule: ActionsModule\n}\n\ntype _assertPropsInPluginDefinition = utils.types.AssertKeyOf<'props', sdk.PluginDefinition>\nconst _isLocalPluginDefinition = (\n plugin: sdk.PluginDefinition | sdk.PluginPackage['definition']\n): plugin is sdk.PluginDefinition => {\n return 'props' in plugin\n}\n\nexport class PluginTypingsModule extends Module {\n private _dependencies: PluginTypingsIndexDependencies\n\n public constructor(plugin: sdk.PluginDefinition | sdk.PluginPackage['definition']) {\n super({\n exportName: 'TPlugin',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = _isLocalPluginDefinition(plugin)\n ? new PluginIntegrationsModule(plugin)\n : new SingleFileModule({\n path: consts.INDEX_FILE,\n exportName: 'Integrations',\n content: 'export type Integrations = {}',\n })\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const interfacesModule = _isLocalPluginDefinition(plugin)\n ? new PluginInterfacesModule(plugin)\n : new SingleFileModule({\n path: consts.INDEX_FILE,\n exportName: 'Interfaces',\n content: 'export type Interfaces = {}',\n })\n interfacesModule.unshift('interfaces')\n this.pushDep(interfacesModule)\n\n const defaultConfigModule = new DefaultConfigurationModule(plugin.configuration)\n defaultConfigModule.unshift('configuration')\n this.pushDep(defaultConfigModule)\n\n const eventsModule = new EventsModule(plugin.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(plugin.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n const actionsModule = new ActionsModule(plugin.actions ?? {})\n actionsModule.unshift('actions')\n this.pushDep(actionsModule)\n\n this._dependencies = {\n integrationsModule,\n interfacesModule,\n defaultConfigModule,\n eventsModule,\n statesModule,\n actionsModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, interfacesModule, defaultConfigModule, eventsModule, statesModule, actionsModule } =\n this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const interfacesImport = interfacesModule.import(this)\n const defaultConfigImport = defaultConfigModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n const actionsImport = actionsModule\n\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${interfacesModule.name} from './${interfacesImport}'`,\n `import * as ${defaultConfigModule.name} from './${defaultConfigImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n `import * as ${actionsModule.name} from './${actionsImport.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${interfacesModule.name} from './${interfacesImport}'`,\n `export * as ${defaultConfigModule.name} from './${defaultConfigImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n `export * as ${actionsModule.name} from './${actionsImport.name}'`,\n '',\n 'export type TPlugin = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` interfaces: ${interfacesModule.name}.${interfacesModule.exportName}`,\n ` configuration: ${defaultConfigModule.name}.${defaultConfigModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 states_module_exports = {};
|
|
26
|
+
__export(states_module_exports, {
|
|
27
|
+
StateModule: () => StateModule,
|
|
28
|
+
StatesModule: () => StatesModule
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(states_module_exports);
|
|
31
|
+
var import_generators = require("../../generators");
|
|
32
|
+
var import_module = require("../../module");
|
|
33
|
+
var strings = __toESM(require("../../strings"));
|
|
34
|
+
class StateModule extends import_module.Module {
|
|
35
|
+
constructor(name, _state) {
|
|
36
|
+
super({
|
|
37
|
+
path: `${name}.ts`,
|
|
38
|
+
exportName: strings.typeName(name)
|
|
39
|
+
});
|
|
40
|
+
this._state = _state;
|
|
41
|
+
}
|
|
42
|
+
async getContent() {
|
|
43
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._state.schema, this.exportName);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class StatesModule extends import_module.ReExportTypeModule {
|
|
47
|
+
constructor(states) {
|
|
48
|
+
super({ exportName: strings.typeName("states") });
|
|
49
|
+
for (const [stateName, state] of Object.entries(states)) {
|
|
50
|
+
const module2 = new StateModule(stateName, state);
|
|
51
|
+
this.pushDep(module2);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
StateModule,
|
|
58
|
+
StatesModule
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=states-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/plugin-implementation/plugin-typings/states-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class StateModule extends Module {\n public constructor(name: string, private _state: sdk.BotStateDefinition) {\n super({\n path: `${name}.ts`,\n exportName: strings.typeName(name),\n })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._state.schema, this.exportName)\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public constructor(states: Record<string, sdk.BotStateDefinition>) {\n super({ exportName: strings.typeName('states') })\n for (const [stateName, state] of Object.entries(states)) {\n const module = new StateModule(stateName, state)\n this.pushDep(module)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YAAY,MAAsB,QAAgC;AACvE,UAAM;AAAA,MACJ,MAAM,GAAG;AAAA,MACT,YAAY,QAAQ,SAAS,IAAI;AAAA,IACnC,CAAC;AAJsC;AAAA,EAKzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["module"]
|
|
7
|
+
}
|