@botpress/cli 1.7.3 → 2.0.0
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 +12 -10
- 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 +2 -2
- 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 +1 -1
- package/templates/empty-integration/package.json +1 -1
- 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 +1 -1
- package/templates/webhook-message/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
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_module_exports = {};
|
|
26
|
+
__export(plugin_module_exports, {
|
|
27
|
+
BotPluginModule: () => BotPluginModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(plugin_module_exports);
|
|
30
|
+
var consts = __toESM(require("../../consts"));
|
|
31
|
+
var import_module = require("../../module");
|
|
32
|
+
var import_plugin_typings = require("../../plugin-implementation/plugin-typings");
|
|
33
|
+
class BundleJsModule extends import_module.Module {
|
|
34
|
+
_indexJs;
|
|
35
|
+
constructor(plugin) {
|
|
36
|
+
super({
|
|
37
|
+
path: "bundle.js",
|
|
38
|
+
exportName: "default"
|
|
39
|
+
});
|
|
40
|
+
this._indexJs = plugin.implementation.toString();
|
|
41
|
+
}
|
|
42
|
+
async getContent() {
|
|
43
|
+
return this._indexJs;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class BundleDtsModule extends import_module.Module {
|
|
47
|
+
constructor(_typingsModule) {
|
|
48
|
+
super({
|
|
49
|
+
path: "bundle.d.ts",
|
|
50
|
+
exportName: "default"
|
|
51
|
+
});
|
|
52
|
+
this._typingsModule = _typingsModule;
|
|
53
|
+
}
|
|
54
|
+
async getContent() {
|
|
55
|
+
const typingsImport = this._typingsModule.import(this);
|
|
56
|
+
return [
|
|
57
|
+
consts.GENERATED_HEADER,
|
|
58
|
+
'import * as sdk from "@botpress/sdk"',
|
|
59
|
+
`import * as ${this._typingsModule.name} from "./${typingsImport}"`,
|
|
60
|
+
`type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,
|
|
61
|
+
"export default new sdk.Plugin<TPlugin>({})",
|
|
62
|
+
""
|
|
63
|
+
].join("\n");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class PluginConfigModule extends import_module.Module {
|
|
67
|
+
_plugin;
|
|
68
|
+
constructor(config) {
|
|
69
|
+
super(config);
|
|
70
|
+
this._plugin = config.plugin;
|
|
71
|
+
}
|
|
72
|
+
async getContent() {
|
|
73
|
+
const { interfaces, configuration } = this._plugin;
|
|
74
|
+
const content = JSON.stringify({ interfaces, configuration }, null, 2);
|
|
75
|
+
return `export default ${content}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
class BotPluginModule extends import_module.Module {
|
|
79
|
+
_typingsModule;
|
|
80
|
+
_bundleJsModule;
|
|
81
|
+
_bundleDtsModule;
|
|
82
|
+
_configModule;
|
|
83
|
+
pluginName;
|
|
84
|
+
constructor(plugin) {
|
|
85
|
+
super({
|
|
86
|
+
exportName: "default",
|
|
87
|
+
path: consts.INDEX_FILE
|
|
88
|
+
});
|
|
89
|
+
this.pluginName = plugin.name;
|
|
90
|
+
this._typingsModule = new import_plugin_typings.PluginTypingsModule(plugin.definition);
|
|
91
|
+
this._typingsModule.unshift("typings");
|
|
92
|
+
this.pushDep(this._typingsModule);
|
|
93
|
+
this._bundleJsModule = new BundleJsModule(plugin);
|
|
94
|
+
this.pushDep(this._bundleJsModule);
|
|
95
|
+
this._bundleDtsModule = new BundleDtsModule(this._typingsModule);
|
|
96
|
+
this.pushDep(this._bundleDtsModule);
|
|
97
|
+
this._configModule = new PluginConfigModule({
|
|
98
|
+
path: "config.ts",
|
|
99
|
+
exportName: "default",
|
|
100
|
+
plugin
|
|
101
|
+
});
|
|
102
|
+
this.pushDep(this._configModule);
|
|
103
|
+
}
|
|
104
|
+
async getContent() {
|
|
105
|
+
const configImport = this._configModule.import(this);
|
|
106
|
+
const typingsImport = this._typingsModule.import(this);
|
|
107
|
+
return [
|
|
108
|
+
consts.GENERATED_HEADER,
|
|
109
|
+
'import * as sdk from "@botpress/sdk"',
|
|
110
|
+
'import bundle from "./bundle"',
|
|
111
|
+
`import * as ${this._typingsModule.name} from "./${typingsImport}"`,
|
|
112
|
+
`import * as ${this._configModule.name} from "./${configImport}"`,
|
|
113
|
+
"",
|
|
114
|
+
`export type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,
|
|
115
|
+
"",
|
|
116
|
+
`export default bundle.initialize(${this._configModule.name}.${this._configModule.exportName})`,
|
|
117
|
+
""
|
|
118
|
+
].join("\n");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
BotPluginModule
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=plugin-module.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/bot-implementation/bot-plugins/plugin-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { Module, ModuleProps } from '../../module'\nimport { PluginTypingsModule } from '../../plugin-implementation/plugin-typings'\n\ntype PluginInstance = NonNullable<sdk.BotDefinition['plugins']>[string]\n\nclass BundleJsModule extends Module {\n private _indexJs: string\n public constructor(plugin: PluginInstance) {\n super({\n path: 'bundle.js',\n exportName: 'default',\n })\n this._indexJs = plugin.implementation.toString()\n }\n\n public async getContent() {\n return this._indexJs\n }\n}\n\nclass BundleDtsModule extends Module {\n public constructor(private _typingsModule: PluginTypingsModule) {\n super({\n path: 'bundle.d.ts',\n exportName: 'default',\n })\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 `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n 'export default new sdk.Plugin<TPlugin>({})',\n '',\n ].join('\\n')\n }\n}\n\nclass PluginConfigModule extends Module {\n private _plugin: PluginInstance\n public constructor(config: ModuleProps & { plugin: PluginInstance }) {\n super(config)\n this._plugin = config.plugin\n }\n\n public async getContent() {\n const { interfaces, configuration } = this._plugin\n const content = JSON.stringify({ interfaces, configuration }, null, 2)\n return `export default ${content}`\n }\n}\n\nexport class BotPluginModule extends Module {\n private _typingsModule: PluginTypingsModule\n private _bundleJsModule: BundleJsModule\n private _bundleDtsModule: BundleDtsModule\n private _configModule: PluginConfigModule\n\n public readonly pluginName: string\n\n public constructor(plugin: PluginInstance) {\n super({\n exportName: 'default',\n path: consts.INDEX_FILE,\n })\n\n this.pluginName = plugin.name\n\n this._typingsModule = new PluginTypingsModule(plugin.definition)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._bundleJsModule = new BundleJsModule(plugin)\n this.pushDep(this._bundleJsModule)\n\n this._bundleDtsModule = new BundleDtsModule(this._typingsModule)\n this.pushDep(this._bundleDtsModule)\n\n this._configModule = new PluginConfigModule({\n path: 'config.ts',\n exportName: 'default',\n plugin,\n })\n this.pushDep(this._configModule)\n }\n\n public async getContent() {\n const configImport = this._configModule.import(this)\n const typingsImport = this._typingsModule.import(this)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n 'import bundle from \"./bundle\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${this._configModule.name} from \"./${configImport}\"`,\n '',\n `export type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n `export default bundle.initialize(${this._configModule.name}.${this._configModule.exportName})`,\n '',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAoC;AACpC,4BAAoC;AAIpC,MAAM,uBAAuB,qBAAO;AAAA,EAC1B;AAAA,EACD,YAAY,QAAwB;AACzC,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,OAAO,eAAe,SAAS;AAAA,EACjD;AAAA,EAEA,MAAa,aAAa;AACxB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,MAAM,wBAAwB,qBAAO;AAAA,EAC5B,YAAoB,gBAAqC;AAC9D,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AAJwB;AAAA,EAK3B;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,oCAAoC,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACpF;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEA,MAAM,2BAA2B,qBAAO;AAAA,EAC9B;AAAA,EACD,YAAY,QAAkD;AACnE,UAAM,MAAM;AACZ,SAAK,UAAU,OAAO;AAAA,EACxB;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,EAAE,YAAY,cAAc,IAAI,KAAK;AAC3C,UAAM,UAAU,KAAK,UAAU,EAAE,YAAY,cAAc,GAAG,MAAM,CAAC;AACrE,WAAO,kBAAkB;AAAA,EAC3B;AACF;AAEO,MAAM,wBAAwB,qBAAO;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEQ;AAAA,EAET,YAAY,QAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,aAAa,OAAO;AAEzB,SAAK,iBAAiB,IAAI,0CAAoB,OAAO,UAAU;AAC/D,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAEhC,SAAK,kBAAkB,IAAI,eAAe,MAAM;AAChD,SAAK,QAAQ,KAAK,eAAe;AAEjC,SAAK,mBAAmB,IAAI,gBAAgB,KAAK,cAAc;AAC/D,SAAK,QAAQ,KAAK,gBAAgB;AAElC,SAAK,gBAAgB,IAAI,mBAAmB;AAAA,MAC1C,MAAM;AAAA,MACN,YAAY;AAAA,MACZ;AAAA,IACF,CAAC;AACD,SAAK,QAAQ,KAAK,aAAa;AAAA,EACjC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,eAAe,KAAK,cAAc,OAAO,IAAI;AACnD,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AACrD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,eAAe,KAAK,cAAc,gBAAgB;AAAA,MAClD;AAAA,MACA,2CAA2C,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MAC3F;AAAA,MACA,oCAAoC,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAClF;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -17,37 +17,42 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (
|
|
21
|
-
isNodeMode || !
|
|
22
|
-
|
|
20
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
22
|
+
mod2
|
|
23
23
|
));
|
|
24
|
-
var __toCommonJS = (
|
|
24
|
+
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
25
25
|
var bot_implementation_exports = {};
|
|
26
26
|
__export(bot_implementation_exports, {
|
|
27
27
|
generateBotImplementation: () => generateBotImplementation
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(bot_implementation_exports);
|
|
30
30
|
var consts = __toESM(require("../consts"));
|
|
31
|
+
var mod = __toESM(require("../module"));
|
|
31
32
|
var import_bot_implementation = require("./bot-implementation");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
class BotIndexModule extends mod.Module {
|
|
34
|
+
_botImplModule;
|
|
35
|
+
constructor(sdkBotDefinition) {
|
|
36
|
+
super({
|
|
37
|
+
path: consts.INDEX_FILE,
|
|
38
|
+
exportName: ""
|
|
39
|
+
});
|
|
40
|
+
const botImpl = new import_bot_implementation.BotImplementationModule(sdkBotDefinition);
|
|
41
|
+
botImpl.unshift(consts.fromOutDir.implementationDir);
|
|
42
|
+
this.pushDep(botImpl);
|
|
43
|
+
this._botImplModule = botImpl;
|
|
44
|
+
}
|
|
45
|
+
async getContent() {
|
|
46
|
+
const botImplImport = this._botImplModule.import(this);
|
|
47
|
+
return [
|
|
48
|
+
consts.GENERATED_HEADER,
|
|
49
|
+
`export * from "./${botImplImport}"`
|
|
50
|
+
].join("\n");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
46
53
|
const generateBotImplementation = async (sdkBotDefinition) => {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const indexFile = await generateBotIndex(implPath);
|
|
50
|
-
return [...typingFiles, indexFile];
|
|
54
|
+
const botIndexModule = new BotIndexModule(sdkBotDefinition);
|
|
55
|
+
return botIndexModule.flatten();
|
|
51
56
|
};
|
|
52
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
58
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/bot-implementation/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport * as types from '../typings'\nimport { BotImplementationModule } from './bot-implementation'\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport * as mod from '../module'\nimport * as types from '../typings'\nimport { BotImplementationModule } from './bot-implementation'\n\nclass BotIndexModule extends mod.Module {\n private _botImplModule: BotImplementationModule\n\n public constructor(sdkBotDefinition: sdk.BotDefinition) {\n super({\n path: consts.INDEX_FILE,\n exportName: '',\n })\n\n const botImpl = new BotImplementationModule(sdkBotDefinition)\n botImpl.unshift(consts.fromOutDir.implementationDir)\n this.pushDep(botImpl)\n\n this._botImplModule = botImpl\n }\n\n public async getContent(): Promise<string> {\n const botImplImport = this._botImplModule.import(this)\n\n return [\n //\n consts.GENERATED_HEADER,\n `export * from \"./${botImplImport}\"`,\n ].join('\\n')\n }\n}\n\nexport const generateBotImplementation = async (sdkBotDefinition: sdk.BotDefinition): Promise<types.File[]> => {\n const botIndexModule = new BotIndexModule(sdkBotDefinition)\n return botIndexModule.flatten()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,UAAqB;AAErB,gCAAwC;AAExC,MAAM,uBAAuB,IAAI,OAAO;AAAA,EAC9B;AAAA,EAED,YAAY,kBAAqC;AACtD,UAAM;AAAA,MACJ,MAAM,OAAO;AAAA,MACb,YAAY;AAAA,IACd,CAAC;AAED,UAAM,UAAU,IAAI,kDAAwB,gBAAgB;AAC5D,YAAQ,QAAQ,OAAO,WAAW,iBAAiB;AACnD,SAAK,QAAQ,OAAO;AAEpB,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEA,MAAa,aAA8B;AACzC,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MAEL,OAAO;AAAA,MACP,oBAAoB;AAAA,IACtB,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,4BAA4B,OAAO,qBAA+D;AAC7G,QAAM,iBAAiB,IAAI,eAAe,gBAAgB;AAC1D,SAAO,eAAe,QAAQ;AAChC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,6 +21,7 @@ var consts_exports = {};
|
|
|
21
21
|
__export(consts_exports, {
|
|
22
22
|
DEFAULT_EXPORT_NAME: () => DEFAULT_EXPORT_NAME,
|
|
23
23
|
GENERATED_HEADER: () => GENERATED_HEADER,
|
|
24
|
+
INDEX_DECLARATION_FILE: () => INDEX_DECLARATION_FILE,
|
|
24
25
|
INDEX_FILE: () => INDEX_FILE
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(consts_exports);
|
|
@@ -32,11 +33,13 @@ const GENERATED_HEADER = [
|
|
|
32
33
|
""
|
|
33
34
|
].join("\n");
|
|
34
35
|
const INDEX_FILE = "index.ts";
|
|
36
|
+
const INDEX_DECLARATION_FILE = "index.d.ts";
|
|
35
37
|
const DEFAULT_EXPORT_NAME = "default";
|
|
36
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
39
|
0 && (module.exports = {
|
|
38
40
|
DEFAULT_EXPORT_NAME,
|
|
39
41
|
GENERATED_HEADER,
|
|
42
|
+
INDEX_DECLARATION_FILE,
|
|
40
43
|
INDEX_FILE
|
|
41
44
|
});
|
|
42
45
|
//# sourceMappingURL=consts.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/consts.ts"],
|
|
4
|
-
"sourcesContent": ["export * from '../consts'\nexport const GENERATED_HEADER = [\n '/* eslint-disable */',\n '/* tslint:disable */',\n '// This file is generated. Do not edit it manually.',\n '',\n].join('\\n')\nexport const INDEX_FILE = 'index.ts'\nexport const DEFAULT_EXPORT_NAME = 'default'\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAc,sBAAd;AACO,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AACJ,MAAM,aAAa;AACnB,MAAM,sBAAsB;",
|
|
4
|
+
"sourcesContent": ["export * from '../consts'\nexport const GENERATED_HEADER = [\n '/* eslint-disable */',\n '/* tslint:disable */',\n '// This file is generated. Do not edit it manually.',\n '',\n].join('\\n')\nexport const INDEX_FILE = 'index.ts'\nexport const INDEX_DECLARATION_FILE = 'index.d.ts'\nexport const DEFAULT_EXPORT_NAME = 'default'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAc,sBAAd;AACO,MAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AACJ,MAAM,aAAa;AACnB,MAAM,yBAAyB;AAC/B,MAAM,sBAAsB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -25,6 +25,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
25
25
|
var generators_exports = {};
|
|
26
26
|
__export(generators_exports, {
|
|
27
27
|
jsonSchemaToTypescriptZuiSchema: () => jsonSchemaToTypescriptZuiSchema,
|
|
28
|
+
primitiveToTypescriptValue: () => primitiveToTypescriptValue,
|
|
28
29
|
stringifySingleLine: () => stringifySingleLine,
|
|
29
30
|
zuiSchemaToTypeScriptType: () => zuiSchemaToTypeScriptType
|
|
30
31
|
});
|
|
@@ -59,9 +60,16 @@ const jsonSchemaToTypescriptZuiSchema = async (schema, name, extraProps = {}) =>
|
|
|
59
60
|
const stringifySingleLine = (x) => {
|
|
60
61
|
return JSON.stringify(x, null, 1).replace(/\n */g, " ");
|
|
61
62
|
};
|
|
63
|
+
function primitiveToTypescriptValue(x) {
|
|
64
|
+
if (typeof x === "undefined") {
|
|
65
|
+
return "undefined";
|
|
66
|
+
}
|
|
67
|
+
return JSON.stringify(x);
|
|
68
|
+
}
|
|
62
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
70
|
0 && (module.exports = {
|
|
64
71
|
jsonSchemaToTypescriptZuiSchema,
|
|
72
|
+
primitiveToTypescriptValue,
|
|
65
73
|
stringifySingleLine,
|
|
66
74
|
zuiSchemaToTypeScriptType
|
|
67
75
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/generators.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\nimport * as prettier from 'prettier'\nimport * as utils from '../utils'\nimport * as consts from './consts'\n\nexport const zuiSchemaToTypeScriptType = async (zuiSchema: sdk.z.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,eAA0B;AAC1B,YAAuB;AACvB,aAAwB;AAEjB,MAAM,4BAA4B,OAAO,
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { JSONSchema7 } from 'json-schema'\nimport * as prettier from 'prettier'\nimport * as utils from '../utils'\nimport * as consts from './consts'\n\nexport const zuiSchemaToTypeScriptType = async (zuiSchema: sdk.z.Schema, name: string): Promise<string> => {\n let code = zuiSchema.toTypescript()\n code = `export type ${name} = ${code}`\n code = prettier.format(code, { parser: 'typescript' })\n return [\n //\n consts.GENERATED_HEADER,\n code,\n ].join('\\n')\n}\n\nexport const jsonSchemaToTypescriptZuiSchema = async (\n schema: JSONSchema7,\n name: string,\n extraProps: Record<string, string> = {}\n): Promise<string> => {\n schema = await utils.schema.dereferenceSchema(schema)\n const zuiSchema = sdk.z.fromJsonSchema(schema)\n let code = [\n consts.GENERATED_HEADER,\n 'import { z } from \"@botpress/sdk\"',\n `export const ${name} = {`,\n ...Object.entries(extraProps).map(([key, value]) => ` ${key}: ${value},`),\n ` schema: ${zuiSchema.toTypescriptSchema()}`,\n '}',\n ].join('\\n')\n code = prettier.format(code, { parser: 'typescript' })\n return code\n}\n\nexport const stringifySingleLine = (x: object): string => {\n return JSON.stringify(x, null, 1).replace(/\\n */g, ' ')\n}\n\nexport function primitiveToTypescriptValue(x: string | number | boolean | null | undefined): string {\n if (typeof x === 'undefined') {\n return 'undefined'\n }\n return JSON.stringify(x)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,eAA0B;AAC1B,YAAuB;AACvB,aAAwB;AAEjB,MAAM,4BAA4B,OAAO,WAAyB,SAAkC;AACzG,MAAI,OAAO,UAAU,aAAa;AAClC,SAAO,eAAe,UAAU;AAChC,SAAO,SAAS,OAAO,MAAM,EAAE,QAAQ,aAAa,CAAC;AACrD,SAAO;AAAA,IAEL,OAAO;AAAA,IACP;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEO,MAAM,kCAAkC,OAC7C,QACA,MACA,aAAqC,CAAC,MAClB;AACpB,WAAS,MAAM,MAAM,OAAO,kBAAkB,MAAM;AACpD,QAAM,YAAY,IAAI,EAAE,eAAe,MAAM;AAC7C,MAAI,OAAO;AAAA,IACT,OAAO;AAAA,IACP;AAAA,IACA,gBAAgB;AAAA,IAChB,GAAG,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,KAAK,QAAQ,QAAQ;AAAA,IACzE,aAAa,UAAU,mBAAmB;AAAA,IAC1C;AAAA,EACF,EAAE,KAAK,IAAI;AACX,SAAO,SAAS,OAAO,MAAM,EAAE,QAAQ,aAAa,CAAC;AACrD,SAAO;AACT;AAEO,MAAM,sBAAsB,CAAC,MAAsB;AACxD,SAAO,KAAK,UAAU,GAAG,MAAM,CAAC,EAAE,QAAQ,SAAS,GAAG;AACxD;AAEO,SAAS,2BAA2B,GAAyD;AAClG,MAAI,OAAO,MAAM,aAAa;AAC5B,WAAO;AAAA,EACT;AACA,SAAO,KAAK,UAAU,CAAC;AACzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,6 +23,8 @@ __export(code_generation_exports, {
|
|
|
23
23
|
generateIntegrationImplementation: () => import_integration_implementation.generateIntegrationImplementation,
|
|
24
24
|
generateIntegrationPackage: () => import_integration_package.generateIntegrationPackage,
|
|
25
25
|
generateInterfacePackage: () => import_interface_package.generateInterfacePackage,
|
|
26
|
+
generatePluginImplementation: () => import_plugin_implementation.generatePluginImplementation,
|
|
27
|
+
generatePluginPackage: () => import_plugin_package.generatePluginPackage,
|
|
26
28
|
secretEnvVariableName: () => import_integration_secret.secretEnvVariableName
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(code_generation_exports);
|
|
@@ -30,14 +32,18 @@ __reExport(code_generation_exports, require("./typings"), module.exports);
|
|
|
30
32
|
var import_integration_secret = require("./integration-implementation/integration-secret");
|
|
31
33
|
var import_bot_implementation = require("./bot-implementation");
|
|
32
34
|
var import_integration_implementation = require("./integration-implementation");
|
|
35
|
+
var import_plugin_implementation = require("./plugin-implementation");
|
|
33
36
|
var import_integration_package = require("./integration-package");
|
|
34
37
|
var import_interface_package = require("./interface-package");
|
|
38
|
+
var import_plugin_package = require("./plugin-package");
|
|
35
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
40
|
0 && (module.exports = {
|
|
37
41
|
generateBotImplementation,
|
|
38
42
|
generateIntegrationImplementation,
|
|
39
43
|
generateIntegrationPackage,
|
|
40
44
|
generateInterfacePackage,
|
|
45
|
+
generatePluginImplementation,
|
|
46
|
+
generatePluginPackage,
|
|
41
47
|
secretEnvVariableName
|
|
42
48
|
});
|
|
43
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './typings'\nexport { secretEnvVariableName } from './integration-implementation/integration-secret'\nexport { generateBotImplementation } from './bot-implementation'\nexport { generateIntegrationImplementation } from './integration-implementation'\nexport { generateIntegrationPackage } from './integration-package'\nexport { generateInterfacePackage } from './interface-package'\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAc,sBAAd;AACA,gCAAsC;AACtC,gCAA0C;AAC1C,wCAAkD;AAClD,iCAA2C;AAC3C,+BAAyC;",
|
|
4
|
+
"sourcesContent": ["export * from './typings'\nexport { secretEnvVariableName } from './integration-implementation/integration-secret'\nexport { generateBotImplementation } from './bot-implementation'\nexport { generateIntegrationImplementation } from './integration-implementation'\nexport { generatePluginImplementation } from './plugin-implementation'\nexport { generateIntegrationPackage } from './integration-package'\nexport { generateInterfacePackage } from './interface-package'\nexport { generatePluginPackage } from './plugin-package'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAc,sBAAd;AACA,gCAAsC;AACtC,gCAA0C;AAC1C,wCAAkD;AAClD,mCAA6C;AAC7C,iCAA2C;AAC3C,+BAAyC;AACzC,4BAAsC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,9 +29,15 @@ __export(integration_package_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(integration_package_exports);
|
|
30
30
|
var utils = __toESM(require("../../utils"));
|
|
31
31
|
var consts = __toESM(require("../consts"));
|
|
32
|
+
var gen = __toESM(require("../generators"));
|
|
32
33
|
var import_integration_package_definition = require("./integration-package-definition");
|
|
33
34
|
const generateIntegrationPackageModule = (definitionImport, pkg) => {
|
|
34
|
-
const
|
|
35
|
+
const id = pkg.source === "remote" ? pkg.integration.id : void 0;
|
|
36
|
+
const uri = pkg.source === "local" ? utils.path.win32.escapeBackslashes(pkg.path) : void 0;
|
|
37
|
+
const tsId = gen.primitiveToTypescriptValue(id);
|
|
38
|
+
const tsUri = gen.primitiveToTypescriptValue(uri);
|
|
39
|
+
const tsName = gen.primitiveToTypescriptValue(pkg.name);
|
|
40
|
+
const tsVersion = gen.primitiveToTypescriptValue(pkg.version);
|
|
35
41
|
return [
|
|
36
42
|
consts.GENERATED_HEADER,
|
|
37
43
|
'import * as sdk from "@botpress/sdk"',
|
|
@@ -40,7 +46,10 @@ const generateIntegrationPackageModule = (definitionImport, pkg) => {
|
|
|
40
46
|
"",
|
|
41
47
|
"export default {",
|
|
42
48
|
' type: "integration",',
|
|
43
|
-
` ${
|
|
49
|
+
` id: ${tsId},`,
|
|
50
|
+
` uri: ${tsUri},`,
|
|
51
|
+
` name: ${tsName},`,
|
|
52
|
+
` version: ${tsVersion},`,
|
|
44
53
|
" definition,",
|
|
45
54
|
"} satisfies sdk.IntegrationPackage"
|
|
46
55
|
].join("\n");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/integration-package/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as types from '../typings'\nimport { IntegrationPackageDefinitionModule } from './integration-package-definition'\n\nconst generateIntegrationPackageModule = (\n definitionImport: string,\n pkg: types.IntegrationInstallablePackage\n): string => {\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;
|
|
4
|
+
"sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as types from '../typings'\nimport { IntegrationPackageDefinitionModule } from './integration-package-definition'\n\nconst generateIntegrationPackageModule = (\n definitionImport: string,\n pkg: types.IntegrationInstallablePackage\n): string => {\n const id = pkg.source === 'remote' ? pkg.integration.id : undefined\n const uri = pkg.source === 'local' ? utils.path.win32.escapeBackslashes(pkg.path) : undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(pkg.version)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.win32.escapeBackslashes(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"integration\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n '} satisfies sdk.IntegrationPackage',\n ].join('\\n')\n}\n\nconst generateIntegrationPackageFromRemote = async (\n pkg: Extract<types.IntegrationInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new IntegrationPackageDefinitionModule(pkg.integration)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateIntegrationPackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateIntegrationPackageFromLocal = async (\n pkg: Extract<types.IntegrationInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.integrationDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateIntegrationPackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateIntegrationPackage = async (pkg: types.IntegrationInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateIntegrationPackageFromRemote(pkg)\n }\n return generateIntegrationPackageFromLocal(pkg)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,UAAqB;AAErB,4CAAmD;AAEnD,MAAM,mCAAmC,CACvC,kBACA,QACW;AACX,QAAM,KAAK,IAAI,WAAW,WAAW,IAAI,YAAY,KAAK;AAC1D,QAAM,MAAM,IAAI,WAAW,UAAU,MAAM,KAAK,MAAM,kBAAkB,IAAI,IAAI,IAAI;AAEpF,QAAM,OAAO,IAAI,2BAA2B,EAAE;AAC9C,QAAM,QAAQ,IAAI,2BAA2B,GAAG;AAChD,QAAM,SAAS,IAAI,2BAA2B,IAAI,IAAI;AACtD,QAAM,YAAY,IAAI,2BAA2B,IAAI,OAAO;AAE5D,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,2BAA2B,MAAM,KAAK,MAAM,kBAAkB,gBAAgB;AAAA,IAC9E;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,MAAM,uCAAuC,OAC3C,QAC0B;AAC1B,QAAM,gBAAgB;AACtB,QAAM,mBAAmB,IAAI,yEAAmC,IAAI,WAAW;AAC/E,mBAAiB,QAAQ,aAAa;AAEtC,QAAM,kBAAkB,MAAM,iBAAiB,QAAQ;AACvD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,iCAAiC,KAAK,iBAAiB,GAAG;AAAA,IACrE;AAAA,EACF;AACF;AAEA,MAAM,sCAAsC,OAC1C,QAC0B;AAC1B,MAAI,mBAA2B,MAAM,KAAK,KAAK,IAAI,MAAM,OAAO,YAAY,qBAAqB;AACjG,qBAAmB,MAAM,KAAK,YAAY,gBAAgB;AAC1D,SAAO;AAAA,IACL;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,iCAAiC,kBAAkB,GAAG;AAAA,IACjE;AAAA,EACF;AACF;AAEO,MAAM,6BAA6B,OAAO,QAAoE;AACnH,MAAI,IAAI,WAAW,UAAU;AAC3B,WAAO,qCAAqC,GAAG;AAAA,EACjD;AACA,SAAO,oCAAoC,GAAG;AAChD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 interface_implementation_exports = {};
|
|
20
|
+
__export(interface_implementation_exports, {
|
|
21
|
+
InterfaceTypingsModule: () => import_integration_typings.InterfaceTypingsModule
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(interface_implementation_exports);
|
|
24
|
+
var import_integration_typings = require("./integration-typings");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
InterfaceTypingsModule
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/code-generation/interface-implementation/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * An interface has no implementation, but its typings are used by the plugin and bot implementations.\n */\nexport { InterfaceTypingsModule } from './integration-typings'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAAuC;",
|
|
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
|
package/dist/code-generation/interface-implementation/integration-typings/actions-module.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/interface-implementation/integration-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.ActionDefinition['input']\ntype ActionOutput = sdk.ActionDefinition['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.ActionDefinition) {\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.ActionDefinition>) {\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,QAA8B;AACnE,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,SAA+C;AAChE,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
|
+
}
|