@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.
Files changed (216) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/dist/api/bot-body.js.map +2 -2
  3. package/dist/api/client.js +14 -28
  4. package/dist/api/client.js.map +3 -3
  5. package/dist/api/find-previous-version.js.map +1 -1
  6. package/dist/api/index.js +23 -0
  7. package/dist/api/index.js.map +7 -0
  8. package/dist/api/interface-body.js +25 -10
  9. package/dist/api/interface-body.js.map +2 -2
  10. package/dist/code-generation/bot-implementation/bot-implementation.js +92 -0
  11. package/dist/code-generation/bot-implementation/bot-implementation.js.map +7 -0
  12. package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/events-module.js +15 -22
  13. package/dist/code-generation/bot-implementation/bot-typings/events-module.js.map +7 -0
  14. package/dist/code-generation/bot-implementation/bot-typings/index.js +96 -0
  15. package/dist/code-generation/bot-implementation/bot-typings/index.js.map +7 -0
  16. package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/states-module.js +17 -22
  17. package/dist/code-generation/bot-implementation/bot-typings/states-module.js.map +7 -0
  18. package/dist/code-generation/bot-implementation/index.js +56 -0
  19. package/dist/code-generation/bot-implementation/index.js.map +7 -0
  20. package/dist/code-generation/{const.js → consts.js} +9 -4
  21. package/dist/code-generation/consts.js.map +7 -0
  22. package/dist/code-generation/generators.js +37 -7
  23. package/dist/code-generation/generators.js.map +2 -2
  24. package/dist/code-generation/index.js +15 -105
  25. package/dist/code-generation/index.js.map +3 -3
  26. package/dist/code-generation/integration-implementation/index.js +66 -0
  27. package/dist/code-generation/integration-implementation/index.js.map +7 -0
  28. package/dist/code-generation/integration-implementation/integration-implementation.js +110 -0
  29. package/dist/code-generation/integration-implementation/integration-implementation.js.map +7 -0
  30. package/dist/code-generation/{integration-secret.js → integration-implementation/integration-secret.js} +17 -7
  31. package/dist/code-generation/integration-implementation/integration-secret.js.map +7 -0
  32. package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/actions-module.js +28 -40
  33. package/dist/code-generation/integration-implementation/integration-typings/actions-module.js.map +7 -0
  34. package/dist/code-generation/integration-implementation/integration-typings/channels-module.js +103 -0
  35. package/dist/code-generation/integration-implementation/integration-typings/channels-module.js.map +7 -0
  36. package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/configuration-module.js +18 -20
  37. package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js.map +7 -0
  38. package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/configurations-module.js +21 -27
  39. package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js.map +7 -0
  40. package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/entities-module.js +15 -22
  41. package/dist/code-generation/integration-implementation/integration-typings/entities-module.js.map +7 -0
  42. package/dist/code-generation/integration-implementation/integration-typings/events-module.js +59 -0
  43. package/dist/code-generation/integration-implementation/integration-typings/events-module.js.map +7 -0
  44. package/dist/code-generation/integration-implementation/integration-typings/index.js +128 -0
  45. package/dist/code-generation/integration-implementation/integration-typings/index.js.map +7 -0
  46. package/dist/code-generation/integration-implementation/integration-typings/states-module.js +60 -0
  47. package/dist/code-generation/integration-implementation/integration-typings/states-module.js.map +7 -0
  48. package/dist/code-generation/integration-package/index.js +81 -0
  49. package/dist/code-generation/integration-package/index.js.map +7 -0
  50. package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +84 -0
  51. package/dist/code-generation/integration-package/integration-package-definition/actions-module.js.map +7 -0
  52. package/dist/code-generation/integration-package/integration-package-definition/channels-module.js +103 -0
  53. package/dist/code-generation/integration-package/integration-package-definition/channels-module.js.map +7 -0
  54. package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js +58 -0
  55. package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js.map +7 -0
  56. package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js +66 -0
  57. package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js.map +7 -0
  58. package/dist/code-generation/integration-package/integration-package-definition/entities-module.js +59 -0
  59. package/dist/code-generation/integration-package/integration-package-definition/entities-module.js.map +7 -0
  60. package/dist/code-generation/integration-package/integration-package-definition/events-module.js +62 -0
  61. package/dist/code-generation/integration-package/integration-package-definition/events-module.js.map +7 -0
  62. package/dist/code-generation/integration-package/integration-package-definition/index.js +136 -0
  63. package/dist/code-generation/integration-package/integration-package-definition/index.js.map +7 -0
  64. package/dist/code-generation/integration-package/integration-package-definition/states-module.js +62 -0
  65. package/dist/code-generation/integration-package/integration-package-definition/states-module.js.map +7 -0
  66. package/dist/code-generation/integration-package/integration-package-definition/typings.js +17 -0
  67. package/dist/code-generation/integration-package/integration-package-definition/typings.js.map +7 -0
  68. package/dist/code-generation/interface-package/index.js +81 -0
  69. package/dist/code-generation/interface-package/index.js.map +7 -0
  70. package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +84 -0
  71. package/dist/code-generation/interface-package/interface-package-definition/actions-module.js.map +7 -0
  72. package/dist/code-generation/interface-package/interface-package-definition/channels-module.js +94 -0
  73. package/dist/code-generation/interface-package/interface-package-definition/channels-module.js.map +7 -0
  74. package/dist/code-generation/interface-package/interface-package-definition/entities-module.js +59 -0
  75. package/dist/code-generation/interface-package/interface-package-definition/entities-module.js.map +7 -0
  76. package/dist/code-generation/interface-package/interface-package-definition/events-module.js +62 -0
  77. package/dist/code-generation/interface-package/interface-package-definition/events-module.js.map +7 -0
  78. package/dist/code-generation/interface-package/interface-package-definition/index.js +100 -0
  79. package/dist/code-generation/interface-package/interface-package-definition/index.js.map +7 -0
  80. package/dist/code-generation/interface-package/interface-package-definition/typings.js +17 -0
  81. package/dist/code-generation/interface-package/interface-package-definition/typings.js.map +7 -0
  82. package/dist/code-generation/module.js +60 -16
  83. package/dist/code-generation/module.js.map +2 -2
  84. package/dist/code-generation/strings.js +5 -2
  85. package/dist/code-generation/strings.js.map +2 -2
  86. package/dist/code-generation/typings.js.map +1 -1
  87. package/dist/command-implementations/add-command.js +102 -91
  88. package/dist/command-implementations/add-command.js.map +3 -3
  89. package/dist/command-implementations/bundle-command.js +16 -9
  90. package/dist/command-implementations/bundle-command.js.map +2 -2
  91. package/dist/command-implementations/deploy-command.js +27 -19
  92. package/dist/command-implementations/deploy-command.js.map +2 -2
  93. package/dist/command-implementations/dev-command.js +15 -12
  94. package/dist/command-implementations/dev-command.js.map +2 -2
  95. package/dist/command-implementations/gen-command.js +31 -12
  96. package/dist/command-implementations/gen-command.js.map +3 -3
  97. package/dist/command-implementations/init-command.js +2 -2
  98. package/dist/command-implementations/init-command.js.map +2 -2
  99. package/dist/command-implementations/integration-commands.js +5 -5
  100. package/dist/command-implementations/integration-commands.js.map +2 -2
  101. package/dist/command-implementations/interface-commands.js +5 -5
  102. package/dist/command-implementations/interface-commands.js.map +2 -2
  103. package/dist/command-implementations/lint-command.js +3 -1
  104. package/dist/command-implementations/lint-command.js.map +3 -3
  105. package/dist/command-implementations/project-command.js +40 -23
  106. package/dist/command-implementations/project-command.js.map +3 -3
  107. package/dist/command-implementations/read-command.js +0 -5
  108. package/dist/command-implementations/read-command.js.map +2 -2
  109. package/dist/config.js +22 -7
  110. package/dist/config.js.map +2 -2
  111. package/dist/consts.js +15 -6
  112. package/dist/consts.js.map +2 -2
  113. package/dist/errors.js +19 -11
  114. package/dist/errors.js.map +2 -2
  115. package/dist/logger/index.js +4 -2
  116. package/dist/logger/index.js.map +2 -2
  117. package/dist/{integration-ref.js → package-ref.js} +11 -11
  118. package/dist/package-ref.js.map +7 -0
  119. package/dist/{integration-ref.test.js → package-ref.test.js} +18 -18
  120. package/dist/package-ref.test.js.map +7 -0
  121. package/dist/sdk/index.js +21 -0
  122. package/dist/sdk/index.js.map +7 -0
  123. package/dist/sdk/resolve-bot-interfaces.js +38 -0
  124. package/dist/sdk/resolve-bot-interfaces.js.map +7 -0
  125. package/dist/sdk/resolve-integration-interfaces.js +148 -0
  126. package/dist/sdk/resolve-integration-interfaces.js.map +7 -0
  127. package/dist/utils/index.js +3 -0
  128. package/dist/utils/index.js.map +2 -2
  129. package/dist/utils/path-utils.js +25 -8
  130. package/dist/utils/path-utils.js.map +3 -3
  131. package/dist/utils/path-utils.test.js +69 -0
  132. package/dist/utils/path-utils.test.js.map +7 -0
  133. package/dist/utils/record-utils.js +25 -0
  134. package/dist/utils/record-utils.js.map +3 -3
  135. package/dist/utils/schema-utils.js +11 -0
  136. package/dist/utils/schema-utils.js.map +2 -2
  137. package/dist/utils/schema-utils.test.js +51 -0
  138. package/dist/utils/schema-utils.test.js.map +7 -0
  139. package/dist/utils/template-utils.js +47 -0
  140. package/dist/utils/template-utils.js.map +7 -0
  141. package/dist/utils/type-utils.js.map +1 -1
  142. package/e2e/index.ts +2 -0
  143. package/e2e/tests/install-package.ts +163 -0
  144. package/e2e/utils.ts +25 -2
  145. package/package.json +5 -4
  146. package/templates/empty-bot/.botpress/implementation/index.ts +41 -0
  147. package/templates/empty-bot/.botpress/implementation/typings/index.ts +17 -0
  148. package/templates/empty-bot/.botpress/implementation/typings/integrations/index.ts +6 -0
  149. package/templates/empty-bot/.botpress/index.ts +1 -0
  150. package/templates/empty-bot/bot.definition.ts +2 -0
  151. package/templates/{echo-bot → empty-bot}/package.json +2 -2
  152. package/templates/empty-bot/src/index.ts +5 -0
  153. package/templates/empty-integration/.botpress/implementation/index.ts +7 -35
  154. package/templates/empty-integration/.botpress/implementation/typings/configuration/index.ts +2 -0
  155. package/templates/empty-integration/.botpress/implementation/typings/index.ts +31 -0
  156. package/templates/empty-integration/package.json +1 -1
  157. package/templates/hello-world/.botpress/implementation/index.ts +7 -35
  158. package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/input.ts +5 -0
  159. package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/output.ts +5 -0
  160. package/templates/hello-world/.botpress/implementation/typings/configuration/index.ts +2 -0
  161. package/templates/hello-world/.botpress/implementation/typings/index.ts +31 -0
  162. package/templates/hello-world/package.json +1 -1
  163. package/templates/webhook-message/.botpress/implementation/index.ts +7 -35
  164. package/templates/webhook-message/.botpress/implementation/typings/channels/webhook/messages/text.ts +5 -0
  165. package/templates/webhook-message/.botpress/implementation/typings/configuration/index.ts +8 -0
  166. package/templates/webhook-message/.botpress/implementation/typings/events/index.ts +6 -0
  167. package/templates/webhook-message/.botpress/implementation/typings/index.ts +31 -0
  168. package/templates/webhook-message/.botpress/implementation/typings/states/index.ts +6 -0
  169. package/templates/webhook-message/package.json +1 -1
  170. package/dist/code-generation/const.js.map +0 -7
  171. package/dist/code-generation/integration-implementation.js +0 -192
  172. package/dist/code-generation/integration-implementation.js.map +0 -7
  173. package/dist/code-generation/integration-instance.js +0 -185
  174. package/dist/code-generation/integration-instance.js.map +0 -7
  175. package/dist/code-generation/integration-schemas/actions-module.js.map +0 -7
  176. package/dist/code-generation/integration-schemas/channels-module.js +0 -117
  177. package/dist/code-generation/integration-schemas/channels-module.js.map +0 -7
  178. package/dist/code-generation/integration-schemas/configuration-module.js.map +0 -7
  179. package/dist/code-generation/integration-schemas/configurations-module.js.map +0 -7
  180. package/dist/code-generation/integration-schemas/entities-module.js.map +0 -7
  181. package/dist/code-generation/integration-schemas/events-module.js.map +0 -7
  182. package/dist/code-generation/integration-schemas/states-module.js.map +0 -7
  183. package/dist/code-generation/integration-secret.js.map +0 -7
  184. package/dist/code-generation/map-integration.js +0 -76
  185. package/dist/code-generation/map-integration.js.map +0 -7
  186. package/dist/integration-ref.js.map +0 -7
  187. package/dist/integration-ref.test.js.map +0 -7
  188. package/templates/echo-bot/src/index.ts +0 -30
  189. package/templates/empty-integration/.botpress/implementation/configuration/index.ts +0 -10
  190. package/templates/hello-world/.botpress/implementation/actions/helloWorld/input.ts +0 -10
  191. package/templates/hello-world/.botpress/implementation/actions/helloWorld/output.ts +0 -10
  192. package/templates/hello-world/.botpress/implementation/configuration/index.ts +0 -10
  193. package/templates/webhook-message/.botpress/implementation/channels/webhook/messages/text.ts +0 -10
  194. package/templates/webhook-message/.botpress/implementation/configuration/index.ts +0 -13
  195. /package/templates/{empty-integration/.botpress/implementation → empty-bot/.botpress/implementation/typings}/events/index.ts +0 -0
  196. /package/templates/{empty-integration/.botpress/implementation → empty-bot/.botpress/implementation/typings}/states/index.ts +0 -0
  197. /package/templates/{echo-bot → empty-bot}/tsconfig.json +0 -0
  198. /package/templates/empty-integration/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
  199. /package/templates/empty-integration/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
  200. /package/templates/empty-integration/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
  201. /package/templates/empty-integration/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
  202. /package/templates/{hello-world/.botpress/implementation → empty-integration/.botpress/implementation/typings}/events/index.ts +0 -0
  203. /package/templates/{hello-world/.botpress/implementation → empty-integration/.botpress/implementation/typings}/states/index.ts +0 -0
  204. /package/templates/hello-world/.botpress/implementation/{actions → typings/actions}/helloWorld/index.ts +0 -0
  205. /package/templates/hello-world/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
  206. /package/templates/hello-world/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
  207. /package/templates/hello-world/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
  208. /package/templates/hello-world/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
  209. /package/templates/{webhook-message/.botpress/implementation → hello-world/.botpress/implementation/typings}/events/index.ts +0 -0
  210. /package/templates/{webhook-message/.botpress/implementation → hello-world/.botpress/implementation/typings}/states/index.ts +0 -0
  211. /package/templates/webhook-message/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
  212. /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
  213. /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/webhook/index.ts +0 -0
  214. /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/webhook/messages/index.ts +0 -0
  215. /package/templates/webhook-message/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
  216. /package/templates/webhook-message/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
@@ -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.varName(name);
40
+ super({ path: `${name}.ts`, exportName });
41
+ this._input = _input;
42
+ }
43
+ async getContent() {
44
+ return (0, import_generators.jsonSchemaToTypescriptZuiSchema)(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.varName(name);
51
+ super({ path: `${name}.ts`, exportName });
52
+ this._output = _output;
53
+ }
54
+ async getContent() {
55
+ return (0, import_generators.jsonSchemaToTypescriptZuiSchema)(this._output.schema, this.exportName);
56
+ }
57
+ }
58
+ class ActionModule extends import_module.ReExportVariableModule {
59
+ constructor(actionName, action) {
60
+ super({ exportName: strings.varName(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.ReExportVariableModule {
68
+ constructor(actions) {
69
+ super({ exportName: strings.varName("actions") });
70
+ for (const [actionName, action] of Object.entries(actions)) {
71
+ const module2 = new ActionModule(actionName, action);
72
+ module2.unshift(actionName);
73
+ this.pushDep(module2);
74
+ }
75
+ }
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ ActionInputModule,
80
+ ActionModule,
81
+ ActionOutputModule,
82
+ ActionsModule
83
+ });
84
+ //# sourceMappingURL=actions-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-package/interface-package-definition/actions-module.ts"],
4
+ "sourcesContent": ["import { jsonSchemaToTypescriptZuiSchema } from '../../generators'\nimport { Module, ReExportVariableModule } from '../../module'\nimport * as strings from '../../strings'\nimport * as types from './typings'\n\ntype ActionInput = types.ApiActionDefinition['input']\ntype ActionOutput = types.ApiActionDefinition['output']\n\nexport class ActionInputModule extends Module {\n public constructor(private _input: ActionInput) {\n const name = 'input'\n const exportName = strings.varName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return jsonSchemaToTypescriptZuiSchema(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.varName(name)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return jsonSchemaToTypescriptZuiSchema(this._output.schema, this.exportName)\n }\n}\n\nexport class ActionModule extends ReExportVariableModule {\n public constructor(actionName: string, action: types.ApiActionDefinition) {\n super({ exportName: strings.varName(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 ReExportVariableModule {\n public constructor(actions: Record<string, types.ApiActionDefinition>) {\n super({ exportName: strings.varName('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;AAAA,wBAAgD;AAChD,oBAA+C;AAC/C,cAAyB;AAMlB,MAAM,0BAA0B,qBAAO;AAAA,EACrC,YAAoB,QAAqB;AAC9C,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,QAAQ,IAAI;AACvC,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHf;AAAA,EAI3B;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,mDAAgC,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EAC5E;AACF;AAEO,MAAM,2BAA2B,qBAAO;AAAA,EACtC,YAAoB,SAAuB;AAChD,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,QAAQ,IAAI;AACvC,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHf;AAAA,EAI3B;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,mDAAgC,KAAK,QAAQ,QAAQ,KAAK,UAAU;AAAA,EAC7E;AACF;AAEO,MAAM,qBAAqB,qCAAuB;AAAA,EAChD,YAAY,YAAoB,QAAmC;AACxE,UAAM,EAAE,YAAY,QAAQ,QAAQ,UAAU,EAAE,CAAC;AAEjD,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,qCAAuB;AAAA,EACjD,YAAY,SAAoD;AACrE,UAAM,EAAE,YAAY,QAAQ,QAAQ,SAAS,EAAE,CAAC;AAChD,eAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,OAAO,GAAG;AAC1D,YAAMA,UAAS,IAAI,aAAa,YAAY,MAAM;AAClD,MAAAA,QAAO,QAAQ,UAAU;AACzB,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": ["module"]
7
+ }
@@ -0,0 +1,94 @@
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 channels_module_exports = {};
26
+ __export(channels_module_exports, {
27
+ ChannelsModule: () => ChannelsModule
28
+ });
29
+ module.exports = __toCommonJS(channels_module_exports);
30
+ var import_consts = require("../../consts");
31
+ var import_generators = require("../../generators");
32
+ var import_module = require("../../module");
33
+ var strings = __toESM(require("../../strings"));
34
+ class MessageModule extends import_module.Module {
35
+ constructor(name, _message) {
36
+ super({
37
+ path: `${name}.ts`,
38
+ exportName: strings.varName(name)
39
+ });
40
+ this._message = _message;
41
+ }
42
+ async getContent() {
43
+ return (0, import_generators.jsonSchemaToTypescriptZuiSchema)(this._message.schema, this.exportName);
44
+ }
45
+ }
46
+ class MessagesModule extends import_module.ReExportVariableModule {
47
+ constructor(channel) {
48
+ super({ exportName: strings.varName("messages") });
49
+ for (const [messageName, message] of Object.entries(channel.messages ?? {})) {
50
+ const module2 = new MessageModule(messageName, message);
51
+ this.pushDep(module2);
52
+ }
53
+ }
54
+ }
55
+ class ChannelModule extends import_module.Module {
56
+ constructor(channelName, _channel) {
57
+ super({
58
+ path: import_consts.INDEX_FILE,
59
+ exportName: strings.varName(channelName)
60
+ });
61
+ this._channel = _channel;
62
+ this._messagesModule = new MessagesModule(_channel);
63
+ this._messagesModule.unshift("messages");
64
+ this.pushDep(this._messagesModule);
65
+ }
66
+ _messagesModule;
67
+ async getContent() {
68
+ const messageImport = this._messagesModule.import(this);
69
+ return [
70
+ import_consts.GENERATED_HEADER,
71
+ `import { ${this._messagesModule.exportName} } from './${messageImport}'`,
72
+ `export * from './${messageImport}'`,
73
+ "",
74
+ `export const ${this.exportName} = {`,
75
+ ` messages: ${this._messagesModule.exportName},`,
76
+ "}"
77
+ ].join("\n");
78
+ }
79
+ }
80
+ class ChannelsModule extends import_module.ReExportVariableModule {
81
+ constructor(channels) {
82
+ super({ exportName: strings.varName("channels") });
83
+ for (const [channelName, channel] of Object.entries(channels)) {
84
+ const module2 = new ChannelModule(channelName, channel);
85
+ module2.unshift(channelName);
86
+ this.pushDep(module2);
87
+ }
88
+ }
89
+ }
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ ChannelsModule
93
+ });
94
+ //# sourceMappingURL=channels-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-package/interface-package-definition/channels-module.ts"],
4
+ "sourcesContent": ["import { GENERATED_HEADER, INDEX_FILE } from '../../consts'\nimport { jsonSchemaToTypescriptZuiSchema } from '../../generators'\nimport { Module, ReExportVariableModule } from '../../module'\nimport * as strings from '../../strings'\nimport * as types from './typings'\n\nclass MessageModule extends Module {\n public constructor(name: string, private _message: types.ApiMessageDefinition) {\n super({\n path: `${name}.ts`,\n exportName: strings.varName(name),\n })\n }\n\n public async getContent() {\n return jsonSchemaToTypescriptZuiSchema(this._message.schema, this.exportName)\n }\n}\n\nclass MessagesModule extends ReExportVariableModule {\n public constructor(channel: types.ApiChannelDefinition) {\n super({ exportName: strings.varName('messages') })\n for (const [messageName, message] of Object.entries(channel.messages ?? {})) {\n const module = new MessageModule(messageName, message)\n this.pushDep(module)\n }\n }\n}\n\nclass ChannelModule extends Module {\n private _messagesModule: MessagesModule\n\n public constructor(channelName: string, private _channel: types.ApiChannelDefinition) {\n super({\n path: INDEX_FILE,\n exportName: strings.varName(channelName),\n })\n\n this._messagesModule = new MessagesModule(_channel)\n this._messagesModule.unshift('messages')\n this.pushDep(this._messagesModule)\n }\n\n public async getContent() {\n const messageImport = this._messagesModule.import(this)\n\n return [\n GENERATED_HEADER,\n `import { ${this._messagesModule.exportName} } from './${messageImport}'`,\n `export * from './${messageImport}'`,\n '',\n `export const ${this.exportName} = {`,\n ` messages: ${this._messagesModule.exportName},`,\n '}',\n ].join('\\n')\n }\n}\n\nexport class ChannelsModule extends ReExportVariableModule {\n public constructor(channels: Record<string, types.ApiChannelDefinition>) {\n super({ exportName: strings.varName('channels') })\n for (const [channelName, channel] of Object.entries(channels)) {\n const module = new ChannelModule(channelName, channel)\n module.unshift(channelName)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA6C;AAC7C,wBAAgD;AAChD,oBAA+C;AAC/C,cAAyB;AAGzB,MAAM,sBAAsB,qBAAO;AAAA,EAC1B,YAAY,MAAsB,UAAsC;AAC7E,UAAM;AAAA,MACJ,MAAM,GAAG;AAAA,MACT,YAAY,QAAQ,QAAQ,IAAI;AAAA,IAClC,CAAC;AAJsC;AAAA,EAKzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,mDAAgC,KAAK,SAAS,QAAQ,KAAK,UAAU;AAAA,EAC9E;AACF;AAEA,MAAM,uBAAuB,qCAAuB;AAAA,EAC3C,YAAY,SAAqC;AACtD,UAAM,EAAE,YAAY,QAAQ,QAAQ,UAAU,EAAE,CAAC;AACjD,eAAW,CAAC,aAAa,OAAO,KAAK,OAAO,QAAQ,QAAQ,YAAY,CAAC,CAAC,GAAG;AAC3E,YAAMA,UAAS,IAAI,cAAc,aAAa,OAAO;AACrD,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;AAEA,MAAM,sBAAsB,qBAAO;AAAA,EAG1B,YAAY,aAA6B,UAAsC;AACpF,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY,QAAQ,QAAQ,WAAW;AAAA,IACzC,CAAC;AAJ6C;AAM9C,SAAK,kBAAkB,IAAI,eAAe,QAAQ;AAClD,SAAK,gBAAgB,QAAQ,UAAU;AACvC,SAAK,QAAQ,KAAK,eAAe;AAAA,EACnC;AAAA,EAXQ;AAAA,EAaR,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,gBAAgB,OAAO,IAAI;AAEtD,WAAO;AAAA,MACL;AAAA,MACA,YAAY,KAAK,gBAAgB,wBAAwB;AAAA,MACzD,oBAAoB;AAAA,MACpB;AAAA,MACA,gBAAgB,KAAK;AAAA,MACrB,eAAe,KAAK,gBAAgB;AAAA,MACpC;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,uBAAuB,qCAAuB;AAAA,EAClD,YAAY,UAAsD;AACvE,UAAM,EAAE,YAAY,QAAQ,QAAQ,UAAU,EAAE,CAAC;AACjD,eAAW,CAAC,aAAa,OAAO,KAAK,OAAO,QAAQ,QAAQ,GAAG;AAC7D,YAAMA,UAAS,IAAI,cAAc,aAAa,OAAO;AACrD,MAAAA,QAAO,QAAQ,WAAW;AAC1B,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": ["module"]
7
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var entities_module_exports = {};
26
+ __export(entities_module_exports, {
27
+ EntitiesModule: () => EntitiesModule,
28
+ EntityModule: () => EntityModule
29
+ });
30
+ module.exports = __toCommonJS(entities_module_exports);
31
+ var import_generators = require("../../generators");
32
+ var import_module = require("../../module");
33
+ var strings = __toESM(require("../../strings"));
34
+ class EntityModule extends import_module.Module {
35
+ constructor(name, _entity) {
36
+ const entityName = name;
37
+ const exportName = strings.varName(entityName);
38
+ super({ path: `${name}.ts`, exportName });
39
+ this._entity = _entity;
40
+ }
41
+ async getContent() {
42
+ return (0, import_generators.jsonSchemaToTypescriptZuiSchema)(this._entity.schema, this.exportName);
43
+ }
44
+ }
45
+ class EntitiesModule extends import_module.ReExportVariableModule {
46
+ constructor(entities) {
47
+ super({ exportName: strings.varName("entities") });
48
+ for (const [entityName, entity] of Object.entries(entities)) {
49
+ const module2 = new EntityModule(entityName, entity);
50
+ this.pushDep(module2);
51
+ }
52
+ }
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ EntitiesModule,
57
+ EntityModule
58
+ });
59
+ //# sourceMappingURL=entities-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-package/interface-package-definition/entities-module.ts"],
4
+ "sourcesContent": ["import { jsonSchemaToTypescriptZuiSchema } from '../../generators'\nimport { Module, ReExportVariableModule } from '../../module'\nimport * as strings from '../../strings'\nimport * as types from './typings'\n\nexport class EntityModule extends Module {\n public constructor(name: string, private _entity: types.ApiEntityDefinition) {\n const entityName = name\n const exportName = strings.varName(entityName)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return jsonSchemaToTypescriptZuiSchema(this._entity.schema, this.exportName)\n }\n}\n\nexport class EntitiesModule extends ReExportVariableModule {\n public constructor(entities: Record<string, types.ApiEntityDefinition>) {\n super({ exportName: strings.varName('entities') })\n\n for (const [entityName, entity] of Object.entries(entities)) {\n const module = new EntityModule(entityName, entity)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAgD;AAChD,oBAA+C;AAC/C,cAAyB;AAGlB,MAAM,qBAAqB,qBAAO;AAAA,EAChC,YAAY,MAAsB,SAAoC;AAC3E,UAAM,aAAa;AACnB,UAAM,aAAa,QAAQ,QAAQ,UAAU;AAC7C,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHD;AAAA,EAIzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,mDAAgC,KAAK,QAAQ,QAAQ,KAAK,UAAU;AAAA,EAC7E;AACF;AAEO,MAAM,uBAAuB,qCAAuB;AAAA,EAClD,YAAY,UAAqD;AACtE,UAAM,EAAE,YAAY,QAAQ,QAAQ,UAAU,EAAE,CAAC;AAEjD,eAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,QAAQ,GAAG;AAC3D,YAAMA,UAAS,IAAI,aAAa,YAAY,MAAM;AAClD,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": ["module"]
7
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var events_module_exports = {};
26
+ __export(events_module_exports, {
27
+ EventModule: () => EventModule,
28
+ EventsModule: () => EventsModule
29
+ });
30
+ module.exports = __toCommonJS(events_module_exports);
31
+ var import_generators = require("../../generators");
32
+ var import_module = require("../../module");
33
+ var strings = __toESM(require("../../strings"));
34
+ class EventModule extends import_module.Module {
35
+ constructor(name, _event) {
36
+ const eventName = name;
37
+ const exportName = strings.varName(eventName);
38
+ super({ path: `${name}.ts`, exportName });
39
+ this._event = _event;
40
+ }
41
+ async getContent() {
42
+ if (!this._event.schema) {
43
+ return `export const ${this.exportName} = z.object({});`;
44
+ }
45
+ return (0, import_generators.jsonSchemaToTypescriptZuiSchema)(this._event.schema, this.exportName);
46
+ }
47
+ }
48
+ class EventsModule extends import_module.ReExportVariableModule {
49
+ constructor(events) {
50
+ super({ exportName: strings.varName("events") });
51
+ for (const [eventName, event] of Object.entries(events)) {
52
+ const module2 = new EventModule(eventName, event);
53
+ this.pushDep(module2);
54
+ }
55
+ }
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ EventModule,
60
+ EventsModule
61
+ });
62
+ //# sourceMappingURL=events-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-package/interface-package-definition/events-module.ts"],
4
+ "sourcesContent": ["import { jsonSchemaToTypescriptZuiSchema } from '../../generators'\nimport { Module, ReExportVariableModule } from '../../module'\nimport * as strings from '../../strings'\nimport * as types from './typings'\n\nexport class EventModule extends Module {\n public constructor(name: string, private _event: types.ApiEventDefinition) {\n const eventName = name\n const exportName = strings.varName(eventName)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n if (!this._event.schema) {\n return `export const ${this.exportName} = z.object({});`\n }\n return jsonSchemaToTypescriptZuiSchema(this._event.schema, this.exportName)\n }\n}\n\nexport class EventsModule extends ReExportVariableModule {\n public constructor(events: Record<string, types.ApiEventDefinition>) {\n super({ exportName: strings.varName('events') })\n for (const [eventName, event] of Object.entries(events)) {\n const module = new EventModule(eventName, event)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAgD;AAChD,oBAA+C;AAC/C,cAAyB;AAGlB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YAAY,MAAsB,QAAkC;AACzE,UAAM,YAAY;AAClB,UAAM,aAAa,QAAQ,QAAQ,SAAS;AAC5C,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHD;AAAA,EAIzC;AAAA,EAEA,MAAa,aAAa;AACxB,QAAI,CAAC,KAAK,OAAO,QAAQ;AACvB,aAAO,gBAAgB,KAAK;AAAA,IAC9B;AACA,eAAO,mDAAgC,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EAC5E;AACF;AAEO,MAAM,qBAAqB,qCAAuB;AAAA,EAChD,YAAY,QAAkD;AACnE,UAAM,EAAE,YAAY,QAAQ,QAAQ,QAAQ,EAAE,CAAC;AAC/C,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,100 @@
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 interface_package_definition_exports = {};
26
+ __export(interface_package_definition_exports, {
27
+ InterfacePackageDefinitionModule: () => InterfacePackageDefinitionModule
28
+ });
29
+ module.exports = __toCommonJS(interface_package_definition_exports);
30
+ var consts = __toESM(require("../../consts"));
31
+ var import_module = require("../../module");
32
+ var import_actions_module = require("./actions-module");
33
+ var import_channels_module = require("./channels-module");
34
+ var import_entities_module = require("./entities-module");
35
+ var import_events_module = require("./events-module");
36
+ class InterfacePackageDefinitionModule extends import_module.Module {
37
+ constructor(_interface) {
38
+ super({
39
+ path: consts.INDEX_FILE,
40
+ exportName: consts.DEFAULT_EXPORT_NAME
41
+ });
42
+ this._interface = _interface;
43
+ const actionsModule = new import_actions_module.ActionsModule(_interface.actions ?? {});
44
+ actionsModule.unshift("actions");
45
+ const channelsModule = new import_channels_module.ChannelsModule(_interface.channels ?? {});
46
+ channelsModule.unshift("channels");
47
+ const eventsModule = new import_events_module.EventsModule(_interface.events ?? {});
48
+ eventsModule.unshift("events");
49
+ const entitiesModule = new import_entities_module.EntitiesModule(_interface.entities ?? {});
50
+ entitiesModule.unshift("entities");
51
+ this._dependencies = {
52
+ actionsModule,
53
+ channelsModule,
54
+ eventsModule,
55
+ entitiesModule
56
+ };
57
+ for (const dep of Object.values(this._dependencies)) {
58
+ this.pushDep(dep);
59
+ }
60
+ }
61
+ _dependencies;
62
+ async getContent() {
63
+ let content = "";
64
+ const { actionsModule, channelsModule, eventsModule, entitiesModule } = this._dependencies;
65
+ const actionsImport = actionsModule.import(this);
66
+ const channelsImport = channelsModule.import(this);
67
+ const eventsImport = eventsModule.import(this);
68
+ const entitiesImport = entitiesModule.import(this);
69
+ const templateName = this._interface.nameTemplate === void 0 ? "undefined" : `"${this._interface.nameTemplate.script}"`;
70
+ content += [
71
+ consts.GENERATED_HEADER,
72
+ 'import * as sdk from "@botpress/sdk"',
73
+ "",
74
+ `import * as ${actionsModule.name} from "./${actionsImport}"`,
75
+ `import * as ${channelsModule.name} from "./${channelsImport}"`,
76
+ `import * as ${eventsModule.name} from "./${eventsImport}"`,
77
+ `import * as ${entitiesModule.name} from "./${entitiesImport}"`,
78
+ `export * as ${actionsModule.name} from "./${actionsImport}"`,
79
+ `export * as ${channelsModule.name} from "./${channelsImport}"`,
80
+ `export * as ${eventsModule.name} from "./${eventsImport}"`,
81
+ `export * as ${entitiesModule.name} from "./${entitiesImport}"`,
82
+ "",
83
+ "export default {",
84
+ ` name: "${this._interface.name}",`,
85
+ ` version: "${this._interface.version}",`,
86
+ ` actions: ${actionsModule.name}.${actionsModule.exportName},`,
87
+ ` channels: ${channelsModule.name}.${channelsModule.exportName},`,
88
+ ` events: ${eventsModule.name}.${eventsModule.exportName},`,
89
+ ` entities: ${entitiesModule.name}.${entitiesModule.exportName},`,
90
+ ` templateName: ${templateName},`,
91
+ '} satisfies sdk.InterfacePackage["definition"]'
92
+ ].join("\n");
93
+ return content;
94
+ }
95
+ }
96
+ // Annotate the CommonJS export names for ESM import in node:
97
+ 0 && (module.exports = {
98
+ InterfacePackageDefinitionModule
99
+ });
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-package/interface-package-definition/index.ts"],
4
+ "sourcesContent": ["import * as consts from '../../consts'\nimport { Module } from '../../module'\nimport { ActionsModule } from './actions-module'\nimport { ChannelsModule } from './channels-module'\nimport { EntitiesModule } from './entities-module'\nimport { EventsModule } from './events-module'\nimport * as types from './typings'\n\ntype InterfacePackageModuleDependencies = {\n actionsModule: ActionsModule\n channelsModule: ChannelsModule\n eventsModule: EventsModule\n entitiesModule: EntitiesModule\n}\n\nexport class InterfacePackageDefinitionModule extends Module {\n private _dependencies: InterfacePackageModuleDependencies\n\n public constructor(private _interface: types.ApiInterfaceDefinition) {\n super({\n path: consts.INDEX_FILE,\n exportName: consts.DEFAULT_EXPORT_NAME,\n })\n\n const actionsModule = new ActionsModule(_interface.actions ?? {})\n actionsModule.unshift('actions')\n\n const channelsModule = new ChannelsModule(_interface.channels ?? {})\n channelsModule.unshift('channels')\n\n const eventsModule = new EventsModule(_interface.events ?? {})\n eventsModule.unshift('events')\n\n const entitiesModule = new EntitiesModule(_interface.entities ?? {})\n entitiesModule.unshift('entities')\n\n this._dependencies = {\n actionsModule,\n channelsModule,\n eventsModule,\n entitiesModule,\n }\n\n for (const dep of Object.values(this._dependencies)) {\n this.pushDep(dep)\n }\n }\n\n public async getContent() {\n let content = ''\n\n const { actionsModule, channelsModule, eventsModule, entitiesModule } = this._dependencies\n\n const actionsImport = actionsModule.import(this)\n const channelsImport = channelsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const entitiesImport = entitiesModule.import(this)\n\n const templateName =\n this._interface.nameTemplate === undefined ? 'undefined' : `\"${this._interface.nameTemplate.script}\"`\n\n content += [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `import * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `import * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `import * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n `export * as ${actionsModule.name} from \"./${actionsImport}\"`,\n `export * as ${channelsModule.name} from \"./${channelsImport}\"`,\n `export * as ${eventsModule.name} from \"./${eventsImport}\"`,\n `export * as ${entitiesModule.name} from \"./${entitiesImport}\"`,\n '',\n 'export default {',\n ` name: \"${this._interface.name}\",`,\n ` version: \"${this._interface.version}\",`,\n ` actions: ${actionsModule.name}.${actionsModule.exportName},`,\n ` channels: ${channelsModule.name}.${channelsModule.exportName},`,\n ` events: ${eventsModule.name}.${eventsModule.exportName},`,\n ` entities: ${entitiesModule.name}.${entitiesModule.exportName},`,\n ` templateName: ${templateName},`,\n '} satisfies sdk.InterfacePackage[\"definition\"]',\n ].join('\\n')\n\n return content\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,oBAAuB;AACvB,4BAA8B;AAC9B,6BAA+B;AAC/B,6BAA+B;AAC/B,2BAA6B;AAUtB,MAAM,yCAAyC,qBAAO;AAAA,EAGpD,YAAoB,YAA0C;AACnE,UAAM;AAAA,MACJ,MAAM,OAAO;AAAA,MACb,YAAY,OAAO;AAAA,IACrB,CAAC;AAJwB;AAMzB,UAAM,gBAAgB,IAAI,oCAAc,WAAW,WAAW,CAAC,CAAC;AAChE,kBAAc,QAAQ,SAAS;AAE/B,UAAM,iBAAiB,IAAI,sCAAe,WAAW,YAAY,CAAC,CAAC;AACnE,mBAAe,QAAQ,UAAU;AAEjC,UAAM,eAAe,IAAI,kCAAa,WAAW,UAAU,CAAC,CAAC;AAC7D,iBAAa,QAAQ,QAAQ;AAE7B,UAAM,iBAAiB,IAAI,sCAAe,WAAW,YAAY,CAAC,CAAC;AACnE,mBAAe,QAAQ,UAAU;AAEjC,SAAK,gBAAgB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,eAAW,OAAO,OAAO,OAAO,KAAK,aAAa,GAAG;AACnD,WAAK,QAAQ,GAAG;AAAA,IAClB;AAAA,EACF;AAAA,EA9BQ;AAAA,EAgCR,MAAa,aAAa;AACxB,QAAI,UAAU;AAEd,UAAM,EAAE,eAAe,gBAAgB,cAAc,eAAe,IAAI,KAAK;AAE7E,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAC/C,UAAM,iBAAiB,eAAe,OAAO,IAAI;AACjD,UAAM,eAAe,aAAa,OAAO,IAAI;AAC7C,UAAM,iBAAiB,eAAe,OAAO,IAAI;AAEjD,UAAM,eACJ,KAAK,WAAW,iBAAiB,SAAY,cAAc,IAAI,KAAK,WAAW,aAAa;AAE9F,eAAW;AAAA,MACT,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,eAAe,gBAAgB;AAAA,MAC9C,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,eAAe,gBAAgB;AAAA,MAC9C,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,eAAe,gBAAgB;AAAA,MAC9C,eAAe,aAAa,gBAAgB;AAAA,MAC5C,eAAe,eAAe,gBAAgB;AAAA,MAC9C;AAAA,MACA;AAAA,MACA,YAAY,KAAK,WAAW;AAAA,MAC5B,eAAe,KAAK,WAAW;AAAA,MAC/B,cAAc,cAAc,QAAQ,cAAc;AAAA,MAClD,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD,aAAa,aAAa,QAAQ,aAAa;AAAA,MAC/C,eAAe,eAAe,QAAQ,eAAe;AAAA,MACrD,mBAAmB;AAAA,MACnB;AAAA,IACF,EAAE,KAAK,IAAI;AAEX,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,17 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var typings_exports = {};
16
+ module.exports = __toCommonJS(typings_exports);
17
+ //# sourceMappingURL=typings.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-package/interface-package-definition/typings.ts"],
4
+ "sourcesContent": ["import * as client from '@botpress/client'\nexport type ApiInterfaceDefinition = client.Interface\nexport type ApiActionDefinition = ApiInterfaceDefinition['actions'][string]\nexport type ApiChannelDefinition = ApiInterfaceDefinition['channels'][string]\nexport type ApiMessageDefinition = ApiChannelDefinition['messages'][string]\nexport type ApiEntityDefinition = ApiInterfaceDefinition['entities'][string]\nexport type ApiEventDefinition = ApiInterfaceDefinition['events'][string]\n"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -25,12 +25,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
25
25
  var module_exports = {};
26
26
  __export(module_exports, {
27
27
  Module: () => Module,
28
- ReExportTypeModule: () => ReExportTypeModule
28
+ ReExportTypeModule: () => ReExportTypeModule,
29
+ ReExportVariableModule: () => ReExportVariableModule
29
30
  });
30
31
  module.exports = __toCommonJS(module_exports);
31
32
  var import_path = require("path");
32
33
  var utils = __toESM(require("../utils"));
33
- var import_const = require("./const");
34
+ var consts = __toESM(require("./consts"));
34
35
  var strings = __toESM(require("./strings"));
35
36
  class Module {
36
37
  constructor(_def) {
@@ -40,19 +41,19 @@ class Module {
40
41
  get path() {
41
42
  return this._def.path;
42
43
  }
43
- get content() {
44
- return this._def.content;
45
- }
46
44
  get name() {
47
45
  const basename = import_path.posix.basename(this.path);
48
- if (basename === import_const.INDEX_FILE) {
46
+ if (basename === consts.INDEX_FILE) {
49
47
  const dirname = import_path.posix.basename(import_path.posix.dirname(this.path));
50
48
  return dirname;
51
49
  }
52
50
  const withoutExtension = utils.path.rmExtension(basename);
53
51
  return withoutExtension;
54
52
  }
55
- get exports() {
53
+ get isDefaultExport() {
54
+ return this._def.exportName === consts.DEFAULT_EXPORT_NAME;
55
+ }
56
+ get exportName() {
56
57
  return this._def.exportName;
57
58
  }
58
59
  get deps() {
@@ -70,8 +71,20 @@ class Module {
70
71
  this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath));
71
72
  return this;
72
73
  }
73
- flatten() {
74
- return [this, ...this._localDependencies.flatMap((d) => d.flatten())];
74
+ async toFile() {
75
+ return {
76
+ path: this.path,
77
+ content: await this.getContent()
78
+ };
79
+ }
80
+ async flatten() {
81
+ const self = await this.toFile();
82
+ const allFiles = [self];
83
+ for (const dep of this._localDependencies) {
84
+ const depFiles = await dep.flatten();
85
+ allFiles.push(...depFiles);
86
+ }
87
+ return allFiles;
75
88
  }
76
89
  import(base) {
77
90
  let relativePath = import_path.posix.relative(import_path.posix.dirname(base.path), this.path);
@@ -83,12 +96,11 @@ class ReExportTypeModule extends Module {
83
96
  constructor(def) {
84
97
  super({
85
98
  ...def,
86
- path: import_const.INDEX_FILE,
87
- content: ""
99
+ path: consts.INDEX_FILE
88
100
  });
89
101
  }
90
- get content() {
91
- let content = import_const.GENERATED_HEADER;
102
+ async getContent() {
103
+ let content = consts.GENERATED_HEADER;
92
104
  for (const m of this.deps) {
93
105
  const { name } = m;
94
106
  const importAlias = strings.importAlias(name);
@@ -99,9 +111,9 @@ class ReExportTypeModule extends Module {
99
111
  `;
100
112
  }
101
113
  content += "\n";
102
- content += `export type ${this.exports} = {
114
+ content += `export type ${this.exportName} = {
103
115
  `;
104
- for (const { name, exports } of this.deps) {
116
+ for (const { name, exportName: exports } of this.deps) {
105
117
  const importAlias = strings.importAlias(name);
106
118
  content += ` "${name}": ${importAlias}.${exports};
107
119
  `;
@@ -111,9 +123,41 @@ class ReExportTypeModule extends Module {
111
123
  return content;
112
124
  }
113
125
  }
126
+ class ReExportVariableModule extends Module {
127
+ constructor(def) {
128
+ super({
129
+ ...def,
130
+ path: consts.INDEX_FILE
131
+ });
132
+ }
133
+ async getContent() {
134
+ let content = consts.GENERATED_HEADER;
135
+ for (const m of this.deps) {
136
+ const { name } = m;
137
+ const importAlias = strings.importAlias(name);
138
+ const importFrom = m.import(this);
139
+ content += `import * as ${importAlias} from "./${importFrom}";
140
+ `;
141
+ content += `export * as ${importAlias} from "./${importFrom}";
142
+ `;
143
+ }
144
+ content += "\n";
145
+ content += `export const ${this.exportName} = {
146
+ `;
147
+ for (const { name, exportName: exports } of this.deps) {
148
+ const importAlias = strings.importAlias(name);
149
+ content += ` "${name}": ${importAlias}.${exports},
150
+ `;
151
+ }
152
+ content += "}";
153
+ content += "\n";
154
+ return content;
155
+ }
156
+ }
114
157
  // Annotate the CommonJS export names for ESM import in node:
115
158
  0 && (module.exports = {
116
159
  Module,
117
- ReExportTypeModule
160
+ ReExportTypeModule,
161
+ ReExportVariableModule
118
162
  });
119
163
  //# sourceMappingURL=module.js.map