@botpress/cli 0.11.6 → 1.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 +9 -9
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +14 -28
- package/dist/api/client.js.map +3 -3
- package/dist/api/find-previous-version.js.map +1 -1
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +7 -0
- package/dist/api/interface-body.js +25 -10
- package/dist/api/interface-body.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-implementation.js +92 -0
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +7 -0
- package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/events-module.js +15 -22
- package/dist/code-generation/bot-implementation/bot-typings/events-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js +96 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +7 -0
- package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/states-module.js +17 -22
- package/dist/code-generation/bot-implementation/bot-typings/states-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/index.js +56 -0
- package/dist/code-generation/bot-implementation/index.js.map +7 -0
- package/dist/code-generation/{const.js → consts.js} +9 -4
- package/dist/code-generation/consts.js.map +7 -0
- package/dist/code-generation/generators.js +37 -7
- package/dist/code-generation/generators.js.map +2 -2
- package/dist/code-generation/index.js +15 -105
- package/dist/code-generation/index.js.map +3 -3
- package/dist/code-generation/integration-implementation/index.js +66 -0
- package/dist/code-generation/integration-implementation/index.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js +110 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js.map +7 -0
- package/dist/code-generation/{integration-secret.js → integration-implementation/integration-secret.js} +17 -7
- package/dist/code-generation/integration-implementation/integration-secret.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/actions-module.js +28 -40
- package/dist/code-generation/integration-implementation/integration-typings/actions-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js +103 -0
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/configuration-module.js +18 -20
- package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/configurations-module.js +21 -27
- package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/entities-module.js +15 -22
- package/dist/code-generation/integration-implementation/integration-typings/entities-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/events-module.js +59 -0
- package/dist/code-generation/integration-implementation/integration-typings/events-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/index.js +128 -0
- package/dist/code-generation/integration-implementation/integration-typings/index.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js +60 -0
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js.map +7 -0
- package/dist/code-generation/integration-package/index.js +81 -0
- package/dist/code-generation/integration-package/index.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +84 -0
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js +103 -0
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js +58 -0
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js +66 -0
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js +59 -0
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js +62 -0
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/index.js +136 -0
- package/dist/code-generation/integration-package/integration-package-definition/index.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js +62 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/typings.js +17 -0
- package/dist/code-generation/integration-package/integration-package-definition/typings.js.map +7 -0
- package/dist/code-generation/interface-package/index.js +81 -0
- package/dist/code-generation/interface-package/index.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +84 -0
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js +94 -0
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js +59 -0
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js +62 -0
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/index.js +100 -0
- package/dist/code-generation/interface-package/interface-package-definition/index.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/typings.js +17 -0
- package/dist/code-generation/interface-package/interface-package-definition/typings.js.map +7 -0
- package/dist/code-generation/module.js +60 -16
- package/dist/code-generation/module.js.map +2 -2
- package/dist/code-generation/strings.js +5 -2
- package/dist/code-generation/strings.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-implementations/add-command.js +102 -91
- package/dist/command-implementations/add-command.js.map +3 -3
- package/dist/command-implementations/bundle-command.js +16 -9
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +27 -19
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +15 -12
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +31 -12
- package/dist/command-implementations/gen-command.js.map +3 -3
- package/dist/command-implementations/init-command.js +2 -2
- package/dist/command-implementations/init-command.js.map +2 -2
- package/dist/command-implementations/integration-commands.js +5 -5
- package/dist/command-implementations/integration-commands.js.map +2 -2
- package/dist/command-implementations/interface-commands.js +5 -5
- package/dist/command-implementations/interface-commands.js.map +2 -2
- package/dist/command-implementations/lint-command.js +3 -1
- package/dist/command-implementations/lint-command.js.map +3 -3
- package/dist/command-implementations/project-command.js +40 -23
- package/dist/command-implementations/project-command.js.map +3 -3
- package/dist/command-implementations/read-command.js +0 -5
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/config.js +22 -7
- package/dist/config.js.map +2 -2
- package/dist/consts.js +15 -6
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +19 -11
- package/dist/errors.js.map +2 -2
- package/dist/logger/index.js +4 -2
- package/dist/logger/index.js.map +2 -2
- package/dist/{integration-ref.js → package-ref.js} +11 -11
- package/dist/package-ref.js.map +7 -0
- package/dist/{integration-ref.test.js → package-ref.test.js} +18 -18
- package/dist/package-ref.test.js.map +7 -0
- package/dist/sdk/index.js +21 -0
- package/dist/sdk/index.js.map +7 -0
- package/dist/sdk/resolve-bot-interfaces.js +38 -0
- package/dist/sdk/resolve-bot-interfaces.js.map +7 -0
- package/dist/sdk/resolve-integration-interfaces.js +148 -0
- package/dist/sdk/resolve-integration-interfaces.js.map +7 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/path-utils.js +25 -8
- package/dist/utils/path-utils.js.map +3 -3
- package/dist/utils/path-utils.test.js +69 -0
- package/dist/utils/path-utils.test.js.map +7 -0
- package/dist/utils/record-utils.js +25 -0
- package/dist/utils/record-utils.js.map +3 -3
- package/dist/utils/schema-utils.js +11 -0
- package/dist/utils/schema-utils.js.map +2 -2
- package/dist/utils/schema-utils.test.js +51 -0
- package/dist/utils/schema-utils.test.js.map +7 -0
- package/dist/utils/template-utils.js +47 -0
- package/dist/utils/template-utils.js.map +7 -0
- package/dist/utils/type-utils.js.map +1 -1
- package/e2e/index.ts +2 -0
- package/e2e/tests/install-package.ts +163 -0
- package/e2e/utils.ts +25 -2
- package/package.json +5 -4
- package/templates/empty-bot/.botpress/implementation/index.ts +41 -0
- package/templates/empty-bot/.botpress/implementation/typings/index.ts +17 -0
- package/templates/empty-bot/.botpress/implementation/typings/integrations/index.ts +6 -0
- package/templates/empty-bot/.botpress/index.ts +1 -0
- package/templates/empty-bot/bot.definition.ts +2 -0
- package/templates/{echo-bot → empty-bot}/package.json +2 -2
- package/templates/empty-bot/src/index.ts +5 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +7 -35
- package/templates/empty-integration/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/empty-integration/.botpress/implementation/typings/index.ts +31 -0
- package/templates/empty-integration/package.json +1 -1
- package/templates/hello-world/.botpress/implementation/index.ts +7 -35
- package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/input.ts +5 -0
- package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/output.ts +5 -0
- package/templates/hello-world/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/hello-world/.botpress/implementation/typings/index.ts +31 -0
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/.botpress/implementation/index.ts +7 -35
- package/templates/webhook-message/.botpress/implementation/typings/channels/webhook/messages/text.ts +5 -0
- package/templates/webhook-message/.botpress/implementation/typings/configuration/index.ts +8 -0
- package/templates/webhook-message/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/typings/index.ts +31 -0
- package/templates/webhook-message/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/webhook-message/package.json +1 -1
- package/dist/code-generation/const.js.map +0 -7
- package/dist/code-generation/integration-implementation.js +0 -192
- package/dist/code-generation/integration-implementation.js.map +0 -7
- package/dist/code-generation/integration-instance.js +0 -185
- package/dist/code-generation/integration-instance.js.map +0 -7
- package/dist/code-generation/integration-schemas/actions-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/channels-module.js +0 -117
- package/dist/code-generation/integration-schemas/channels-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/configuration-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/configurations-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/entities-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/events-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/states-module.js.map +0 -7
- package/dist/code-generation/integration-secret.js.map +0 -7
- package/dist/code-generation/map-integration.js +0 -76
- package/dist/code-generation/map-integration.js.map +0 -7
- package/dist/integration-ref.js.map +0 -7
- package/dist/integration-ref.test.js.map +0 -7
- package/templates/echo-bot/src/index.ts +0 -30
- package/templates/empty-integration/.botpress/implementation/configuration/index.ts +0 -10
- package/templates/hello-world/.botpress/implementation/actions/helloWorld/input.ts +0 -10
- package/templates/hello-world/.botpress/implementation/actions/helloWorld/output.ts +0 -10
- package/templates/hello-world/.botpress/implementation/configuration/index.ts +0 -10
- package/templates/webhook-message/.botpress/implementation/channels/webhook/messages/text.ts +0 -10
- package/templates/webhook-message/.botpress/implementation/configuration/index.ts +0 -13
- /package/templates/{empty-integration/.botpress/implementation → empty-bot/.botpress/implementation/typings}/events/index.ts +0 -0
- /package/templates/{empty-integration/.botpress/implementation → empty-bot/.botpress/implementation/typings}/states/index.ts +0 -0
- /package/templates/{echo-bot → empty-bot}/tsconfig.json +0 -0
- /package/templates/empty-integration/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
- /package/templates/empty-integration/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
- /package/templates/empty-integration/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
- /package/templates/empty-integration/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
- /package/templates/{hello-world/.botpress/implementation → empty-integration/.botpress/implementation/typings}/events/index.ts +0 -0
- /package/templates/{hello-world/.botpress/implementation → empty-integration/.botpress/implementation/typings}/states/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{actions → typings/actions}/helloWorld/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
- /package/templates/{webhook-message/.botpress/implementation → hello-world/.botpress/implementation/typings}/events/index.ts +0 -0
- /package/templates/{webhook-message/.botpress/implementation → hello-world/.botpress/implementation/typings}/states/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/webhook/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/webhook/messages/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/states-module.js
RENAMED
|
@@ -28,33 +28,28 @@ __export(states_module_exports, {
|
|
|
28
28
|
StatesModule: () => StatesModule
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(states_module_exports);
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var strings = __toESM(require("../strings"));
|
|
31
|
+
var import_generators = require("../../generators");
|
|
32
|
+
var import_module = require("../../module");
|
|
33
|
+
var strings = __toESM(require("../../strings"));
|
|
35
34
|
class StateModule extends import_module.Module {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const exportName = strings.typeName(name);
|
|
39
|
-
const def = {
|
|
35
|
+
constructor(name, _state) {
|
|
36
|
+
super({
|
|
40
37
|
path: `${name}.ts`,
|
|
41
|
-
exportName
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
class StatesModule extends import_module.ReExportTypeModule {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
exportName: strings.typeName("states")
|
|
55
|
-
});
|
|
56
|
-
inst.pushDep(...stateModules);
|
|
57
|
-
return inst;
|
|
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
|
+
}
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/bot-implementation/bot-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
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 bot_implementation_exports = {};
|
|
26
|
+
__export(bot_implementation_exports, {
|
|
27
|
+
generateBotImplementation: () => generateBotImplementation
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(bot_implementation_exports);
|
|
30
|
+
var consts = __toESM(require("../consts"));
|
|
31
|
+
var import_bot_implementation = require("./bot-implementation");
|
|
32
|
+
const generateBotImplementationCls = async (sdkBotDefinition, implPath) => {
|
|
33
|
+
const indexModule = new import_bot_implementation.BotImplementationModule(sdkBotDefinition);
|
|
34
|
+
indexModule.unshift(implPath);
|
|
35
|
+
return indexModule.flatten();
|
|
36
|
+
};
|
|
37
|
+
const generateBotIndex = async (implPath) => {
|
|
38
|
+
let content = "";
|
|
39
|
+
content += `export * from './${implPath}'
|
|
40
|
+
`;
|
|
41
|
+
return {
|
|
42
|
+
path: consts.INDEX_FILE,
|
|
43
|
+
content
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const generateBotImplementation = async (sdkBotDefinition) => {
|
|
47
|
+
const implPath = consts.fromOutDir.implementationDir;
|
|
48
|
+
const typingFiles = await generateBotImplementationCls(sdkBotDefinition, implPath);
|
|
49
|
+
const indexFile = await generateBotIndex(implPath);
|
|
50
|
+
return [...typingFiles, indexFile];
|
|
51
|
+
};
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
generateBotImplementation
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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\nconst generateBotImplementationCls = async (\n sdkBotDefinition: sdk.BotDefinition,\n implPath: string\n): Promise<types.File[]> => {\n const indexModule = new BotImplementationModule(sdkBotDefinition)\n indexModule.unshift(implPath)\n return indexModule.flatten()\n}\n\nconst generateBotIndex = async (implPath: string): Promise<types.File> => {\n let content = ''\n content += `export * from './${implPath}'\\n`\n return {\n path: consts.INDEX_FILE,\n content,\n }\n}\n\nexport const generateBotImplementation = async (sdkBotDefinition: sdk.BotDefinition): Promise<types.File[]> => {\n const implPath = consts.fromOutDir.implementationDir\n const typingFiles = await generateBotImplementationCls(sdkBotDefinition, implPath)\n const indexFile = await generateBotIndex(implPath)\n return [...typingFiles, indexFile]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,gCAAwC;AAExC,MAAM,+BAA+B,OACnC,kBACA,aAC0B;AAC1B,QAAM,cAAc,IAAI,kDAAwB,gBAAgB;AAChE,cAAY,QAAQ,QAAQ;AAC5B,SAAO,YAAY,QAAQ;AAC7B;AAEA,MAAM,mBAAmB,OAAO,aAA0C;AACxE,MAAI,UAAU;AACd,aAAW,oBAAoB;AAAA;AAC/B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEO,MAAM,4BAA4B,OAAO,qBAA+D;AAC7G,QAAM,WAAW,OAAO,WAAW;AACnC,QAAM,cAAc,MAAM,6BAA6B,kBAAkB,QAAQ;AACjF,QAAM,YAAY,MAAM,iBAAiB,QAAQ;AACjD,SAAO,CAAC,GAAG,aAAa,SAAS;AACnC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -15,18 +15,23 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
20
|
+
var consts_exports = {};
|
|
21
|
+
__export(consts_exports, {
|
|
22
|
+
DEFAULT_EXPORT_NAME: () => DEFAULT_EXPORT_NAME,
|
|
21
23
|
GENERATED_HEADER: () => GENERATED_HEADER,
|
|
22
24
|
INDEX_FILE: () => INDEX_FILE
|
|
23
25
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
26
|
+
module.exports = __toCommonJS(consts_exports);
|
|
27
|
+
__reExport(consts_exports, require("../consts"), module.exports);
|
|
25
28
|
const GENERATED_HEADER = "/* tslint:disable */\n// This file is generated\n// Do not edit this file\n";
|
|
26
29
|
const INDEX_FILE = "index.ts";
|
|
30
|
+
const DEFAULT_EXPORT_NAME = "default";
|
|
27
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
32
|
0 && (module.exports = {
|
|
33
|
+
DEFAULT_EXPORT_NAME,
|
|
29
34
|
GENERATED_HEADER,
|
|
30
35
|
INDEX_FILE
|
|
31
36
|
});
|
|
32
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=consts.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/code-generation/consts.ts"],
|
|
4
|
+
"sourcesContent": ["export * from '../consts'\nexport const GENERATED_HEADER = '/* tslint:disable */\\n// This file is generated\\n// Do not edit this file\\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;AACzB,MAAM,aAAa;AACnB,MAAM,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,16 +17,43 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
25
|
var generators_exports = {};
|
|
20
26
|
__export(generators_exports, {
|
|
21
|
-
|
|
22
|
-
stringifySingleLine: () => stringifySingleLine
|
|
27
|
+
jsonSchemaToTypescriptZuiSchema: () => jsonSchemaToTypescriptZuiSchema,
|
|
28
|
+
stringifySingleLine: () => stringifySingleLine,
|
|
29
|
+
zuiSchemaToTypeScriptType: () => zuiSchemaToTypeScriptType
|
|
23
30
|
});
|
|
24
31
|
module.exports = __toCommonJS(generators_exports);
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
var sdk = __toESM(require("@botpress/sdk"));
|
|
33
|
+
var prettier = __toESM(require("prettier"));
|
|
34
|
+
var utils = __toESM(require("../utils"));
|
|
35
|
+
var consts = __toESM(require("./consts"));
|
|
36
|
+
const zuiSchemaToTypeScriptType = async (zuiSchema, name) => {
|
|
37
|
+
let code = zuiSchema.toTypescript();
|
|
38
|
+
code = `export type ${name} = ${code}`;
|
|
39
|
+
code = prettier.format(code, { parser: "typescript" });
|
|
40
|
+
return [
|
|
41
|
+
consts.GENERATED_HEADER,
|
|
42
|
+
code
|
|
43
|
+
].join("\n");
|
|
44
|
+
};
|
|
45
|
+
const jsonSchemaToTypescriptZuiSchema = async (schema, name, extraProps = {}) => {
|
|
46
|
+
schema = await utils.schema.dereferenceSchema(schema);
|
|
47
|
+
const zuiSchema = sdk.z.fromJsonSchema(schema);
|
|
48
|
+
let code = [
|
|
49
|
+
consts.GENERATED_HEADER,
|
|
50
|
+
'import { z } from "@botpress/sdk"',
|
|
51
|
+
`export const ${name} = {`,
|
|
52
|
+
...Object.entries(extraProps).map(([key, value]) => ` ${key}: ${value},`),
|
|
53
|
+
` schema: ${zuiSchema.toTypescriptSchema()}`,
|
|
54
|
+
"}"
|
|
55
|
+
].join("\n");
|
|
56
|
+
code = prettier.format(code, { parser: "typescript" });
|
|
28
57
|
return code;
|
|
29
58
|
};
|
|
30
59
|
const stringifySingleLine = (x) => {
|
|
@@ -32,7 +61,8 @@ const stringifySingleLine = (x) => {
|
|
|
32
61
|
};
|
|
33
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
34
63
|
0 && (module.exports = {
|
|
35
|
-
|
|
36
|
-
stringifySingleLine
|
|
64
|
+
jsonSchemaToTypescriptZuiSchema,
|
|
65
|
+
stringifySingleLine,
|
|
66
|
+
zuiSchemaToTypeScriptType
|
|
37
67
|
});
|
|
38
68
|
//# sourceMappingURL=generators.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/generators.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
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.AnyZodObject, 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAErB,eAA0B;AAC1B,YAAuB;AACvB,aAAwB;AAEjB,MAAM,4BAA4B,OAAO,WAA+B,SAAkC;AAC/G,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,117 +15,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
24
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
20
|
var code_generation_exports = {};
|
|
26
21
|
__export(code_generation_exports, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
generateIntegrationInstance: () => generateIntegrationInstance,
|
|
33
|
-
generateIntegrationSecrets: () => generateIntegrationSecrets,
|
|
34
|
-
secretEnvVariableName: () => import_integration_secret2.secretEnvVariableName
|
|
22
|
+
generateBotImplementation: () => import_bot_implementation.generateBotImplementation,
|
|
23
|
+
generateIntegrationImplementation: () => import_integration_implementation.generateIntegrationImplementation,
|
|
24
|
+
generateIntegrationPackage: () => import_integration_package.generateIntegrationPackage,
|
|
25
|
+
generateInterfacePackage: () => import_interface_package.generateInterfacePackage,
|
|
26
|
+
secretEnvVariableName: () => import_integration_secret.secretEnvVariableName
|
|
35
27
|
});
|
|
36
28
|
module.exports = __toCommonJS(code_generation_exports);
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
var
|
|
29
|
+
__reExport(code_generation_exports, require("./typings"), module.exports);
|
|
30
|
+
var import_integration_secret = require("./integration-implementation/integration-secret");
|
|
31
|
+
var import_bot_implementation = require("./bot-implementation");
|
|
40
32
|
var import_integration_implementation = require("./integration-implementation");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var mapIntegration = __toESM(require("./map-integration"));
|
|
44
|
-
var import_typings = require("./typings");
|
|
45
|
-
var import_integration_secret2 = require("./integration-secret");
|
|
46
|
-
const INTEGRATION_JSON = "integration.json";
|
|
47
|
-
const generateIntegrationImplementationTypings = async (sdkIntegration, implementationTypingsPath) => {
|
|
48
|
-
const integration = await mapIntegration.from.sdk(sdkIntegration);
|
|
49
|
-
const indexModule = await import_integration_implementation.IntegrationImplementationIndexModule.create(integration);
|
|
50
|
-
indexModule.unshift(implementationTypingsPath);
|
|
51
|
-
return indexModule.flatten();
|
|
52
|
-
};
|
|
53
|
-
const generateIntegrationSecrets = async (sdkIntegration, secretsPath) => {
|
|
54
|
-
const indexModule = await import_integration_secret.IntegrationSecretIndexModule.create(sdkIntegration);
|
|
55
|
-
indexModule.unshift(secretsPath);
|
|
56
|
-
return indexModule.flatten();
|
|
57
|
-
};
|
|
58
|
-
const generateIntegrationIndex = async (implementationTypingsPath, implementationSecretsPath) => {
|
|
59
|
-
let content = "";
|
|
60
|
-
content += `export * from './${implementationTypingsPath}'
|
|
61
|
-
`;
|
|
62
|
-
content += `export * from './${implementationSecretsPath}'
|
|
63
|
-
`;
|
|
64
|
-
return {
|
|
65
|
-
path: import_const.INDEX_FILE,
|
|
66
|
-
content
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
const generateIntegrationInstance = async (anyIntegration, installPath) => {
|
|
70
|
-
let integration;
|
|
71
|
-
if ("id" in anyIntegration) {
|
|
72
|
-
integration = mapIntegration.from.client(anyIntegration);
|
|
73
|
-
} else {
|
|
74
|
-
integration = await mapIntegration.from.sdk(anyIntegration);
|
|
75
|
-
}
|
|
76
|
-
const indexModule = await import_integration_instance.IntegrationInstanceIndexModule.create(integration);
|
|
77
|
-
const dirname = utils.casing.to.kebabCase(integration.name);
|
|
78
|
-
indexModule.unshift(installPath, dirname);
|
|
79
|
-
const files = indexModule.flatten();
|
|
80
|
-
const { name, version, id } = integration;
|
|
81
|
-
const json = {
|
|
82
|
-
name,
|
|
83
|
-
version,
|
|
84
|
-
id
|
|
85
|
-
};
|
|
86
|
-
files.push({
|
|
87
|
-
path: import_path.default.join(installPath, dirname, INTEGRATION_JSON),
|
|
88
|
-
content: JSON.stringify(json, null, 2)
|
|
89
|
-
});
|
|
90
|
-
return files;
|
|
91
|
-
};
|
|
92
|
-
const generateBotIndex = async (installPath, instances) => {
|
|
93
|
-
const lines = [
|
|
94
|
-
import_const.GENERATED_HEADER,
|
|
95
|
-
"import * as sdk from '@botpress/sdk'",
|
|
96
|
-
...instances.map((i) => `import * as ${utils.casing.to.camelCase(i.name)} from './${installPath}/${i.dirname}'`),
|
|
97
|
-
...instances.map((i) => `export * as ${utils.casing.to.camelCase(i.name)} from './${installPath}/${i.dirname}'`),
|
|
98
|
-
"",
|
|
99
|
-
"type TIntegrations = {",
|
|
100
|
-
...instances.map(
|
|
101
|
-
(i) => ` "${i.name}": ${utils.casing.to.camelCase(i.name)}.T${utils.casing.to.pascalCase(i.dirname)}`
|
|
102
|
-
),
|
|
103
|
-
"}",
|
|
104
|
-
"",
|
|
105
|
-
"type BaseStates = sdk.Bot extends sdk.Bot<any, infer TStates, any> ? TStates : never",
|
|
106
|
-
"type BaseEvents = sdk.Bot extends sdk.Bot<any, any, infer TEvents> ? TEvents : never",
|
|
107
|
-
"",
|
|
108
|
-
"export class Bot<",
|
|
109
|
-
" TStates extends BaseStates,",
|
|
110
|
-
" TEvents extends BaseEvents",
|
|
111
|
-
"> extends sdk.Bot<",
|
|
112
|
-
" TIntegrations,",
|
|
113
|
-
" TStates,",
|
|
114
|
-
" TEvents",
|
|
115
|
-
"> {}"
|
|
116
|
-
];
|
|
117
|
-
return {
|
|
118
|
-
path: import_const.INDEX_FILE,
|
|
119
|
-
content: lines.join("\n")
|
|
120
|
-
};
|
|
121
|
-
};
|
|
33
|
+
var import_integration_package = require("./integration-package");
|
|
34
|
+
var import_interface_package = require("./interface-package");
|
|
122
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
123
36
|
0 && (module.exports = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
generateIntegrationIndex,
|
|
129
|
-
generateIntegrationInstance,
|
|
130
|
-
generateIntegrationSecrets,
|
|
37
|
+
generateBotImplementation,
|
|
38
|
+
generateIntegrationImplementation,
|
|
39
|
+
generateIntegrationPackage,
|
|
40
|
+
generateInterfacePackage,
|
|
131
41
|
secretEnvVariableName
|
|
132
42
|
});
|
|
133
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code-generation/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
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;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var integration_implementation_exports = {};
|
|
26
|
+
__export(integration_implementation_exports, {
|
|
27
|
+
generateIntegrationImplementation: () => generateIntegrationImplementation
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(integration_implementation_exports);
|
|
30
|
+
var consts = __toESM(require("../consts"));
|
|
31
|
+
var import_integration_implementation = require("./integration-implementation");
|
|
32
|
+
var import_integration_secret = require("./integration-secret");
|
|
33
|
+
const generateIntegrationImplementationCls = async (sdkIntegrationDefinition, implPath) => {
|
|
34
|
+
const indexModule = new import_integration_implementation.IntegrationImplementationModule(sdkIntegrationDefinition);
|
|
35
|
+
indexModule.unshift(implPath);
|
|
36
|
+
return indexModule.flatten();
|
|
37
|
+
};
|
|
38
|
+
const generateIntegrationSecrets = async (sdkIntegrationDefinition, secretsPath) => {
|
|
39
|
+
const indexModule = new import_integration_secret.IntegrationSecretIndexModule(sdkIntegrationDefinition);
|
|
40
|
+
indexModule.unshift(secretsPath);
|
|
41
|
+
return indexModule.flatten();
|
|
42
|
+
};
|
|
43
|
+
const generateIntegrationImplementationIndex = async (implPath, secretsPath) => {
|
|
44
|
+
let content = "";
|
|
45
|
+
content += `export * from './${implPath}'
|
|
46
|
+
`;
|
|
47
|
+
content += `export * from './${secretsPath}'
|
|
48
|
+
`;
|
|
49
|
+
return {
|
|
50
|
+
path: consts.INDEX_FILE,
|
|
51
|
+
content
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const generateIntegrationImplementation = async (sdkIntegrationDefinition) => {
|
|
55
|
+
const implPath = consts.fromOutDir.implementationDir;
|
|
56
|
+
const secretsPath = consts.fromOutDir.secretsDir;
|
|
57
|
+
const implFiles = await generateIntegrationImplementationCls(sdkIntegrationDefinition, implPath);
|
|
58
|
+
const secretFiles = await generateIntegrationSecrets(sdkIntegrationDefinition, secretsPath);
|
|
59
|
+
const indexFile = await generateIntegrationImplementationIndex(implPath, secretsPath);
|
|
60
|
+
return [...implFiles, ...secretFiles, indexFile];
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
generateIntegrationImplementation
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/code-generation/integration-implementation/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport * as types from '../typings'\nimport { IntegrationImplementationModule } from './integration-implementation'\nimport { IntegrationSecretIndexModule } from './integration-secret'\n\nconst generateIntegrationImplementationCls = async (\n sdkIntegrationDefinition: sdk.IntegrationDefinition,\n implPath: string\n): Promise<types.File[]> => {\n const indexModule = new IntegrationImplementationModule(sdkIntegrationDefinition)\n indexModule.unshift(implPath)\n return indexModule.flatten()\n}\n\nconst generateIntegrationSecrets = async (\n sdkIntegrationDefinition: sdk.IntegrationDefinition,\n secretsPath: string\n): Promise<types.File[]> => {\n const indexModule = new IntegrationSecretIndexModule(sdkIntegrationDefinition)\n indexModule.unshift(secretsPath)\n return indexModule.flatten()\n}\n\nconst generateIntegrationImplementationIndex = async (implPath: string, secretsPath: string): Promise<types.File> => {\n let content = ''\n content += `export * from './${implPath}'\\n`\n content += `export * from './${secretsPath}'\\n`\n return {\n path: consts.INDEX_FILE,\n content,\n }\n}\n\nexport const generateIntegrationImplementation = async (\n sdkIntegrationDefinition: sdk.IntegrationDefinition\n): Promise<types.File[]> => {\n const implPath = consts.fromOutDir.implementationDir\n const secretsPath = consts.fromOutDir.secretsDir\n const implFiles = await generateIntegrationImplementationCls(sdkIntegrationDefinition, implPath)\n const secretFiles = await generateIntegrationSecrets(sdkIntegrationDefinition, secretsPath)\n const indexFile = await generateIntegrationImplementationIndex(implPath, secretsPath)\n return [...implFiles, ...secretFiles, indexFile]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,wCAAgD;AAChD,gCAA6C;AAE7C,MAAM,uCAAuC,OAC3C,0BACA,aAC0B;AAC1B,QAAM,cAAc,IAAI,kEAAgC,wBAAwB;AAChF,cAAY,QAAQ,QAAQ;AAC5B,SAAO,YAAY,QAAQ;AAC7B;AAEA,MAAM,6BAA6B,OACjC,0BACA,gBAC0B;AAC1B,QAAM,cAAc,IAAI,uDAA6B,wBAAwB;AAC7E,cAAY,QAAQ,WAAW;AAC/B,SAAO,YAAY,QAAQ;AAC7B;AAEA,MAAM,yCAAyC,OAAO,UAAkB,gBAA6C;AACnH,MAAI,UAAU;AACd,aAAW,oBAAoB;AAAA;AAC/B,aAAW,oBAAoB;AAAA;AAC/B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEO,MAAM,oCAAoC,OAC/C,6BAC0B;AAC1B,QAAM,WAAW,OAAO,WAAW;AACnC,QAAM,cAAc,OAAO,WAAW;AACtC,QAAM,YAAY,MAAM,qCAAqC,0BAA0B,QAAQ;AAC/F,QAAM,cAAc,MAAM,2BAA2B,0BAA0B,WAAW;AAC1F,QAAM,YAAY,MAAM,uCAAuC,UAAU,WAAW;AACpF,SAAO,CAAC,GAAG,WAAW,GAAG,aAAa,SAAS;AACjD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var integration_implementation_exports = {};
|
|
26
|
+
__export(integration_implementation_exports, {
|
|
27
|
+
IntegrationImplementationModule: () => IntegrationImplementationModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(integration_implementation_exports);
|
|
30
|
+
var consts = __toESM(require("../consts"));
|
|
31
|
+
var import_module = require("../module");
|
|
32
|
+
var import_integration_typings = require("./integration-typings");
|
|
33
|
+
class IntegrationImplementationModule extends import_module.Module {
|
|
34
|
+
_typingsModule;
|
|
35
|
+
constructor(integration) {
|
|
36
|
+
super({
|
|
37
|
+
path: consts.INDEX_FILE,
|
|
38
|
+
exportName: "Integration"
|
|
39
|
+
});
|
|
40
|
+
this._typingsModule = new import_integration_typings.IntegrationTypingsModule(integration);
|
|
41
|
+
this._typingsModule.unshift("typings");
|
|
42
|
+
this.pushDep(this._typingsModule);
|
|
43
|
+
}
|
|
44
|
+
async getContent() {
|
|
45
|
+
let content = "";
|
|
46
|
+
const typingsImport = this._typingsModule.import(this);
|
|
47
|
+
content += [
|
|
48
|
+
consts.GENERATED_HEADER,
|
|
49
|
+
'import * as sdk from "@botpress/sdk"',
|
|
50
|
+
`import * as ${this._typingsModule.name} from "./${typingsImport}"`,
|
|
51
|
+
`export * from "./${typingsImport}"`,
|
|
52
|
+
"",
|
|
53
|
+
`type TIntegration = ${this._typingsModule.name}.${this._typingsModule.exportName}`,
|
|
54
|
+
"",
|
|
55
|
+
"export type IntegrationProps = sdk.IntegrationProps<TIntegration>",
|
|
56
|
+
"",
|
|
57
|
+
"export class Integration extends sdk.Integration<TIntegration> {}",
|
|
58
|
+
"",
|
|
59
|
+
"export type Client = sdk.IntegrationSpecificClient<TIntegration>",
|
|
60
|
+
"",
|
|
61
|
+
"// extra types",
|
|
62
|
+
"",
|
|
63
|
+
"type Cast<X, Y> = X extends Y ? X : Y",
|
|
64
|
+
"type ValueOf<T> = T[keyof T]",
|
|
65
|
+
"type AsyncFunction = (...args: any[]) => Promise<any>",
|
|
66
|
+
"",
|
|
67
|
+
"export type HandlerProps = Parameters<IntegrationProps['handler']>[0]",
|
|
68
|
+
"",
|
|
69
|
+
"export type ActionProps = {",
|
|
70
|
+
" [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]",
|
|
71
|
+
"}",
|
|
72
|
+
"export type AnyActionProps = ValueOf<ActionProps>",
|
|
73
|
+
"",
|
|
74
|
+
"export type MessageProps = {",
|
|
75
|
+
" [TChannel in keyof IntegrationProps['channels']]: {",
|
|
76
|
+
" [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<",
|
|
77
|
+
" IntegrationProps['channels'][TChannel]['messages'][TMessage]",
|
|
78
|
+
" >[0]",
|
|
79
|
+
" }",
|
|
80
|
+
"}",
|
|
81
|
+
"export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>",
|
|
82
|
+
"",
|
|
83
|
+
"export type Context = HandlerProps['ctx']",
|
|
84
|
+
"export type Logger = HandlerProps['logger']",
|
|
85
|
+
"",
|
|
86
|
+
"export type AckFunctions = {",
|
|
87
|
+
" [TChannel in keyof MessageProps]: {",
|
|
88
|
+
" [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']",
|
|
89
|
+
" }",
|
|
90
|
+
"}",
|
|
91
|
+
"export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>",
|
|
92
|
+
"",
|
|
93
|
+
"export type ClientOperation = ValueOf<{",
|
|
94
|
+
" [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K",
|
|
95
|
+
"}>",
|
|
96
|
+
"export type ClientRequests = {",
|
|
97
|
+
" [K in ClientOperation]: Parameters<Client[K]>[0]",
|
|
98
|
+
"}",
|
|
99
|
+
"export type ClientResponses = {",
|
|
100
|
+
" [K in ClientOperation]: Awaited<ReturnType<Client[K]>>",
|
|
101
|
+
"}"
|
|
102
|
+
].join("\n");
|
|
103
|
+
return content;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
IntegrationImplementationModule
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=integration-implementation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/code-generation/integration-implementation/integration-implementation.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { IntegrationTypingsModule } from './integration-typings'\n\nexport class IntegrationImplementationModule extends Module {\n private _typingsModule: IntegrationTypingsModule\n\n public constructor(integration: sdk.IntegrationDefinition) {\n super({\n path: consts.INDEX_FILE,\n exportName: 'Integration',\n })\n this._typingsModule = new IntegrationTypingsModule(integration)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n }\n\n public async getContent() {\n let content = ''\n\n const typingsImport = this._typingsModule.import(this)\n\n content += [\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 TIntegration = ${this._typingsModule.name}.${this._typingsModule.exportName}`,\n '',\n 'export type IntegrationProps = sdk.IntegrationProps<TIntegration>',\n '',\n 'export class Integration extends sdk.Integration<TIntegration> {}',\n '',\n 'export type Client = sdk.IntegrationSpecificClient<TIntegration>',\n '',\n '// extra types',\n '',\n 'type Cast<X, Y> = X extends Y ? X : Y',\n 'type ValueOf<T> = T[keyof T]',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n \"export type HandlerProps = Parameters<IntegrationProps['handler']>[0]\",\n '',\n 'export type ActionProps = {',\n \" [K in keyof IntegrationProps['actions']]: Parameters<IntegrationProps['actions'][K]>[0]\",\n '}',\n 'export type AnyActionProps = ValueOf<ActionProps>',\n '',\n 'export type MessageProps = {',\n \" [TChannel in keyof IntegrationProps['channels']]: {\",\n \" [TMessage in keyof IntegrationProps['channels'][TChannel]['messages']]: Parameters<\",\n \" IntegrationProps['channels'][TChannel]['messages'][TMessage]\",\n ' >[0]',\n ' }',\n '}',\n 'export type AnyMessageProps = ValueOf<ValueOf<MessageProps>>',\n '',\n \"export type Context = HandlerProps['ctx']\",\n \"export type Logger = HandlerProps['logger']\",\n '',\n 'export type AckFunctions = {',\n ' [TChannel in keyof MessageProps]: {',\n \" [TMessage in keyof MessageProps[TChannel]]: Cast<MessageProps[TChannel][TMessage], AnyMessageProps>['ack']\",\n ' }',\n '}',\n 'export type AnyAckFunction = ValueOf<ValueOf<AckFunctions>>',\n '',\n 'export type ClientOperation = ValueOf<{',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: K',\n '}>',\n 'export type ClientRequests = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientResponses = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n\n return content\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,iCAAyC;AAElC,MAAM,wCAAwC,qBAAO;AAAA,EAClD;AAAA,EAED,YAAY,aAAwC;AACzD,UAAM;AAAA,MACJ,MAAM,OAAO;AAAA,MACb,YAAY;AAAA,IACd,CAAC;AACD,SAAK,iBAAiB,IAAI,oDAAyB,WAAW;AAC9D,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,QAAI,UAAU;AAEd,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,eAAW;AAAA,MACT,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oBAAoB;AAAA,MACpB;AAAA,MACA,uBAAuB,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MACvE;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,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;AAEX,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|