@botpress/cli 0.2.9 → 0.3.2

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 (76) hide show
  1. package/dist/api/client.js +1 -1
  2. package/dist/api/client.js.map +2 -2
  3. package/dist/code-generation/const.js +1 -1
  4. package/dist/code-generation/const.js.map +1 -1
  5. package/dist/code-generation/{event.js → generators.js} +15 -19
  6. package/dist/code-generation/generators.js.map +7 -0
  7. package/dist/code-generation/index.js +40 -8
  8. package/dist/code-generation/index.js.map +2 -2
  9. package/dist/code-generation/integration-implementation.js +157 -0
  10. package/dist/code-generation/integration-implementation.js.map +7 -0
  11. package/dist/code-generation/integration-instance.js +101 -39
  12. package/dist/code-generation/integration-instance.js.map +2 -2
  13. package/dist/code-generation/{action.js → integration-schemas/actions-module.js} +41 -19
  14. package/dist/code-generation/integration-schemas/actions-module.js.map +7 -0
  15. package/dist/code-generation/integration-schemas/channels-module.js +114 -0
  16. package/dist/code-generation/integration-schemas/channels-module.js.map +7 -0
  17. package/dist/code-generation/{configuration.js → integration-schemas/configuration-module.js} +11 -10
  18. package/dist/code-generation/integration-schemas/configuration-module.js.map +7 -0
  19. package/dist/code-generation/integration-schemas/events-module.js +64 -0
  20. package/dist/code-generation/integration-schemas/events-module.js.map +7 -0
  21. package/dist/code-generation/integration-schemas/states-module.js +64 -0
  22. package/dist/code-generation/integration-schemas/states-module.js.map +7 -0
  23. package/dist/code-generation/module.js +5 -5
  24. package/dist/code-generation/module.js.map +2 -2
  25. package/dist/code-generation/typings.js.map +1 -1
  26. package/dist/command-implementations/deploy-command.js +2 -20
  27. package/dist/command-implementations/deploy-command.js.map +3 -3
  28. package/dist/command-implementations/dev-command.js +26 -13
  29. package/dist/command-implementations/dev-command.js.map +3 -3
  30. package/dist/command-implementations/project-command.js +54 -1
  31. package/dist/command-implementations/project-command.js.map +2 -2
  32. package/dist/{code-generation/message.js → utils/guard-utils.js} +9 -20
  33. package/dist/utils/guard-utils.js.map +7 -0
  34. package/dist/utils/index.js +9 -0
  35. package/dist/utils/index.js.map +2 -2
  36. package/dist/utils/record-utils.js +9 -0
  37. package/dist/utils/record-utils.js.map +2 -2
  38. package/dist/{code-generation/channel.js → utils/schema-utils.js} +25 -22
  39. package/dist/utils/schema-utils.js.map +7 -0
  40. package/dist/utils/type-utils.js +17 -0
  41. package/dist/utils/type-utils.js.map +7 -0
  42. package/e2e/api.ts +4 -4
  43. package/e2e/tests/create-deploy-bot.ts +1 -1
  44. package/e2e/tests/create-deploy-integration.ts +1 -1
  45. package/e2e/tests/dev-bot.ts +5 -4
  46. package/package.json +6 -5
  47. package/templates/echo-bot/package.json +2 -2
  48. package/templates/echo-bot/src/index.ts +7 -20
  49. package/templates/empty-integration/.botpress/implementation/actions/index.ts +0 -1
  50. package/templates/empty-integration/.botpress/implementation/channels/channel/index.ts +6 -34
  51. package/templates/empty-integration/.botpress/implementation/channels/channel/{audio.ts → messages/audio.ts} +1 -1
  52. package/templates/empty-integration/.botpress/implementation/channels/channel/{card.ts → messages/card.ts} +1 -1
  53. package/templates/empty-integration/.botpress/implementation/channels/channel/{carousel.ts → messages/carousel.ts} +1 -1
  54. package/templates/empty-integration/.botpress/implementation/channels/channel/{choice.ts → messages/choice.ts} +1 -1
  55. package/templates/empty-integration/.botpress/implementation/channels/channel/{dropdown.ts → messages/dropdown.ts} +1 -1
  56. package/templates/empty-integration/.botpress/implementation/channels/channel/{file.ts → messages/file.ts} +1 -1
  57. package/templates/empty-integration/.botpress/implementation/channels/channel/{image.ts → messages/image.ts} +1 -1
  58. package/templates/empty-integration/.botpress/implementation/channels/channel/messages/index.ts +39 -0
  59. package/templates/empty-integration/.botpress/implementation/channels/channel/{location.ts → messages/location.ts} +1 -1
  60. package/templates/empty-integration/.botpress/implementation/channels/channel/{markdown.ts → messages/markdown.ts} +1 -1
  61. package/templates/empty-integration/.botpress/implementation/channels/channel/{text.ts → messages/text.ts} +1 -1
  62. package/templates/empty-integration/.botpress/implementation/channels/channel/{video.ts → messages/video.ts} +1 -1
  63. package/templates/empty-integration/.botpress/implementation/channels/index.ts +1 -2
  64. package/templates/empty-integration/.botpress/implementation/{configuration.ts → configuration/index.ts} +2 -2
  65. package/templates/empty-integration/.botpress/implementation/events/index.ts +0 -1
  66. package/templates/empty-integration/.botpress/implementation/index.ts +30 -12
  67. package/templates/empty-integration/.botpress/implementation/states/index.ts +6 -0
  68. package/templates/empty-integration/.botpress/secrets/index.ts +0 -1
  69. package/templates/empty-integration/package.json +2 -2
  70. package/dist/code-generation/action.js.map +0 -7
  71. package/dist/code-generation/channel.js.map +0 -7
  72. package/dist/code-generation/configuration.js.map +0 -7
  73. package/dist/code-generation/event.js.map +0 -7
  74. package/dist/code-generation/integration-impl.js +0 -147
  75. package/dist/code-generation/integration-impl.js.map +0 -7
  76. package/dist/code-generation/message.js.map +0 -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,45 +17,51 @@ 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
- var action_exports = {};
20
- __export(action_exports, {
25
+ var actions_module_exports = {};
26
+ __export(actions_module_exports, {
21
27
  ActionInputModule: () => ActionInputModule,
22
28
  ActionModule: () => ActionModule,
23
- ActionOutputModule: () => ActionOutputModule
29
+ ActionOutputModule: () => ActionOutputModule,
30
+ ActionsModule: () => ActionsModule
24
31
  });
25
- module.exports = __toCommonJS(action_exports);
26
- var import_json_schema_to_typescript = require("json-schema-to-typescript");
27
- var import_utils = require("../utils");
28
- var import_module = require("./module");
32
+ module.exports = __toCommonJS(actions_module_exports);
33
+ var import_bluebird = __toESM(require("bluebird"));
34
+ var import_utils = require("../../utils");
35
+ var import_generators = require("../generators");
36
+ var import_module = require("../module");
29
37
  class ActionInputModule extends import_module.Module {
30
38
  static async create(input) {
31
- const schema = input.schema ?? {};
32
- const filename = "input.ts";
39
+ const schema = input.schema;
40
+ const name = "input";
33
41
  const def = {
34
- path: filename,
42
+ path: `${name}.ts`,
35
43
  exportName: "Input",
36
- content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
44
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
37
45
  };
38
46
  return new ActionInputModule(def);
39
47
  }
40
48
  }
41
49
  class ActionOutputModule extends import_module.Module {
42
50
  static async create(output) {
43
- const schema = output.schema ?? {};
44
- const filename = "output.ts";
51
+ const schema = output.schema;
52
+ const name = "output";
45
53
  const def = {
46
- path: filename,
54
+ path: `${name}.ts`,
47
55
  exportName: "Output",
48
- content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
56
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
49
57
  };
50
58
  return new ActionOutputModule(def);
51
59
  }
52
60
  }
53
61
  class ActionModule extends import_module.ReExportTypeModule {
54
62
  static async create(actionName, action) {
55
- const inputModule = await ActionInputModule.create(action.input ?? {});
56
- const outputModule = await ActionOutputModule.create(action.output ?? {});
63
+ const inputModule = await ActionInputModule.create(action.input);
64
+ const outputModule = await ActionOutputModule.create(action.output);
57
65
  const inst = new ActionModule({
58
66
  exportName: `Action${import_utils.casing.to.pascalCase(actionName)}`
59
67
  });
@@ -62,10 +70,24 @@ class ActionModule extends import_module.ReExportTypeModule {
62
70
  return inst;
63
71
  }
64
72
  }
73
+ class ActionsModule extends import_module.ReExportTypeModule {
74
+ static async create(actions) {
75
+ const actionModules = await import_bluebird.default.map(Object.entries(actions), async ([actionName, action]) => {
76
+ const mod = await ActionModule.create(actionName, action);
77
+ return mod.unshift(actionName);
78
+ });
79
+ const inst = new ActionsModule({
80
+ exportName: "Actions"
81
+ });
82
+ inst.pushDep(...actionModules);
83
+ return inst;
84
+ }
85
+ }
65
86
  // Annotate the CommonJS export names for ESM import in node:
66
87
  0 && (module.exports = {
67
88
  ActionInputModule,
68
89
  ActionModule,
69
- ActionOutputModule
90
+ ActionOutputModule,
91
+ ActionsModule
70
92
  });
71
- //# sourceMappingURL=action.js.map
93
+ //# sourceMappingURL=actions-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/code-generation/integration-schemas/actions-module.ts"],
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { casing } from '../../utils'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport type * as types from '../typings'\n\ntype ActionInput = types.ActionDefinition['input']\ntype ActionOutput = types.ActionDefinition['output']\n\nexport class ActionInputModule extends Module {\n public static async create(input: ActionInput): Promise<ActionInputModule> {\n const schema = input.schema\n const name = 'input'\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName: 'Input',\n content: await jsonSchemaToTypeScriptType(schema, name),\n }\n return new ActionInputModule(def)\n }\n}\n\nexport class ActionOutputModule extends Module {\n public static async create(output: ActionOutput): Promise<ActionOutputModule> {\n const schema = output.schema\n const name = 'output'\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName: 'Output',\n content: await jsonSchemaToTypeScriptType(schema, name),\n }\n return new ActionOutputModule(def)\n }\n}\n\nexport class ActionModule extends ReExportTypeModule {\n public static async create(actionName: string, action: types.ActionDefinition): Promise<ActionModule> {\n const inputModule = await ActionInputModule.create(action.input)\n const outputModule = await ActionOutputModule.create(action.output)\n\n const inst = new ActionModule({\n exportName: `Action${casing.to.pascalCase(actionName)}`,\n })\n\n inst.pushDep(inputModule)\n inst.pushDep(outputModule)\n\n return inst\n }\n}\n\nexport class ActionsModule extends ReExportTypeModule {\n public static async create(actions: Record<string, types.ActionDefinition>): Promise<ActionsModule> {\n const actionModules = await bluebird.map(Object.entries(actions), async ([actionName, action]) => {\n const mod = await ActionModule.create(actionName, action)\n return mod.unshift(actionName)\n })\n\n const inst = new ActionsModule({\n exportName: 'Actions',\n })\n\n inst.pushDep(...actionModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,mBAAuB;AACvB,wBAA2C;AAC3C,oBAAsD;AAM/C,MAAM,0BAA0B,qBAAO;AAAA,EAC5C,aAAoB,OAAO,OAAgD;AACzE,UAAM,SAAS,MAAM;AACrB,UAAM,OAAO;AACb,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,YAAY;AAAA,MACZ,SAAS,UAAM,8CAA2B,QAAQ,IAAI;AAAA,IACxD;AACA,WAAO,IAAI,kBAAkB,GAAG;AAAA,EAClC;AACF;AAEO,MAAM,2BAA2B,qBAAO;AAAA,EAC7C,aAAoB,OAAO,QAAmD;AAC5E,UAAM,SAAS,OAAO;AACtB,UAAM,OAAO;AACb,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,YAAY;AAAA,MACZ,SAAS,UAAM,8CAA2B,QAAQ,IAAI;AAAA,IACxD;AACA,WAAO,IAAI,mBAAmB,GAAG;AAAA,EACnC;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EACnD,aAAoB,OAAO,YAAoB,QAAuD;AACpG,UAAM,cAAc,MAAM,kBAAkB,OAAO,OAAO,KAAK;AAC/D,UAAM,eAAe,MAAM,mBAAmB,OAAO,OAAO,MAAM;AAElE,UAAM,OAAO,IAAI,aAAa;AAAA,MAC5B,YAAY,SAAS,oBAAO,GAAG,WAAW,UAAU;AAAA,IACtD,CAAC;AAED,SAAK,QAAQ,WAAW;AACxB,SAAK,QAAQ,YAAY;AAEzB,WAAO;AAAA,EACT;AACF;AAEO,MAAM,sBAAsB,iCAAmB;AAAA,EACpD,aAAoB,OAAO,SAAyE;AAClG,UAAM,gBAAgB,MAAM,gBAAAA,QAAS,IAAI,OAAO,QAAQ,OAAO,GAAG,OAAO,CAAC,YAAY,MAAM,MAAM;AAChG,YAAM,MAAM,MAAM,aAAa,OAAO,YAAY,MAAM;AACxD,aAAO,IAAI,QAAQ,UAAU;AAAA,IAC/B,CAAC;AAED,UAAM,OAAO,IAAI,cAAc;AAAA,MAC7B,YAAY;AAAA,IACd,CAAC;AAED,SAAK,QAAQ,GAAG,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["bluebird"]
7
+ }
@@ -0,0 +1,114 @@
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
+ ChannelModule: () => ChannelModule,
28
+ ChannelsModule: () => ChannelsModule,
29
+ MessageModule: () => MessageModule,
30
+ MessagesModule: () => MessagesModule
31
+ });
32
+ module.exports = __toCommonJS(channels_module_exports);
33
+ var import_bluebird = __toESM(require("bluebird"));
34
+ var import_utils = require("../../utils");
35
+ var import_const = require("../const");
36
+ var import_generators = require("../generators");
37
+ var import_module = require("../module");
38
+ class MessageModule extends import_module.Module {
39
+ static async create(name, message) {
40
+ const schema = message.schema;
41
+ const def = {
42
+ path: `${name}.ts`,
43
+ exportName: import_utils.casing.to.pascalCase(name),
44
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
45
+ };
46
+ return new MessageModule(def);
47
+ }
48
+ }
49
+ class MessagesModule extends import_module.ReExportTypeModule {
50
+ static async create(channel) {
51
+ const messages = channel.messages ?? {};
52
+ const messageModules = await import_bluebird.default.map(
53
+ Object.entries(messages),
54
+ ([messageName, message]) => MessageModule.create(messageName, message)
55
+ );
56
+ const inst = new MessagesModule({
57
+ exportName: "Messages"
58
+ });
59
+ inst.pushDep(...messageModules);
60
+ return inst;
61
+ }
62
+ }
63
+ class ChannelModule extends import_module.Module {
64
+ constructor(messageModules, channel, def) {
65
+ super(def);
66
+ this.messageModules = messageModules;
67
+ this.channel = channel;
68
+ }
69
+ static async create(channelName, channel) {
70
+ const messagesModule = await MessagesModule.create(channel);
71
+ messagesModule.unshift("messages");
72
+ const inst = new ChannelModule(messagesModule, channel, {
73
+ path: import_const.INDEX_FILE,
74
+ exportName: `Channel${import_utils.casing.to.pascalCase(channelName)}`,
75
+ content: ""
76
+ });
77
+ inst.pushDep(messagesModule);
78
+ return inst;
79
+ }
80
+ get content() {
81
+ const { messageModules } = this;
82
+ const messageImport = messageModules.import(this);
83
+ return [
84
+ import_const.GENERATED_HEADER,
85
+ `import { ${messageModules.exports} } from './${messageImport}'`,
86
+ `export * from './${messageImport}'`,
87
+ "",
88
+ `export type ${this.exports} = {`,
89
+ ` messages: ${messageModules.exports}`,
90
+ ` message: ${(0, import_generators.stringifySingleLine)(this.channel.message)}`,
91
+ ` conversation: ${(0, import_generators.stringifySingleLine)(this.channel.conversation)}`,
92
+ "}"
93
+ ].join("\n");
94
+ }
95
+ }
96
+ class ChannelsModule extends import_module.ReExportTypeModule {
97
+ static async create(channels) {
98
+ const channelModules = await import_bluebird.default.map(Object.entries(channels), async ([channelName, channel]) => {
99
+ const mod = await ChannelModule.create(channelName, channel);
100
+ return mod.unshift(channelName);
101
+ });
102
+ const inst = new ChannelsModule({ exportName: "Channels" });
103
+ inst.pushDep(...channelModules);
104
+ return inst;
105
+ }
106
+ }
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ ChannelModule,
110
+ ChannelsModule,
111
+ MessageModule,
112
+ MessagesModule
113
+ });
114
+ //# sourceMappingURL=channels-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/code-generation/integration-schemas/channels-module.ts"],
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { casing } from '../../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from '../const'\nimport { jsonSchemaToTypeScriptType, stringifySingleLine } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport type * as types from '../typings'\n\nexport class MessageModule extends Module {\n public static async create(name: string, message: types.MessageDefinition): Promise<MessageModule> {\n const schema = message.schema\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName: casing.to.pascalCase(name),\n content: await jsonSchemaToTypeScriptType(schema, name),\n }\n return new MessageModule(def)\n }\n}\n\nexport class MessagesModule extends ReExportTypeModule {\n public static async create(channel: types.ChannelDefinition): Promise<MessagesModule> {\n const messages = channel.messages ?? {}\n const messageModules = await bluebird.map(Object.entries(messages), ([messageName, message]) =>\n MessageModule.create(messageName, message)\n )\n\n const inst = new MessagesModule({\n exportName: 'Messages',\n })\n inst.pushDep(...messageModules)\n return inst\n }\n}\n\nexport class ChannelModule extends Module {\n public static async create(channelName: string, channel: types.ChannelDefinition): Promise<ChannelModule> {\n const messagesModule = await MessagesModule.create(channel)\n messagesModule.unshift('messages')\n\n const inst = new ChannelModule(messagesModule, channel, {\n path: INDEX_FILE,\n exportName: `Channel${casing.to.pascalCase(channelName)}`,\n content: '',\n })\n\n inst.pushDep(messagesModule)\n return inst\n }\n\n private constructor(private messageModules: MessageModule, private channel: types.ChannelDefinition, def: ModuleDef) {\n super(def)\n }\n\n public override get content() {\n const { messageModules } = this\n const messageImport = messageModules.import(this)\n\n return [\n GENERATED_HEADER,\n `import { ${messageModules.exports} } from './${messageImport}'`,\n `export * from './${messageImport}'`,\n '',\n `export type ${this.exports} = {`,\n ` messages: ${messageModules.exports}`,\n ` message: ${stringifySingleLine(this.channel.message)}`,\n ` conversation: ${stringifySingleLine(this.channel.conversation)}`,\n '}',\n ].join('\\n')\n }\n}\n\nexport class ChannelsModule extends ReExportTypeModule {\n public static async create(channels: Record<string, types.ChannelDefinition>): Promise<ChannelsModule> {\n const channelModules = await bluebird.map(Object.entries(channels), async ([channelName, channel]) => {\n const mod = await ChannelModule.create(channelName, channel)\n return mod.unshift(channelName)\n })\n const inst = new ChannelsModule({ exportName: 'Channels' })\n inst.pushDep(...channelModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,mBAAuB;AACvB,mBAA6C;AAC7C,wBAAgE;AAChE,oBAAsD;AAG/C,MAAM,sBAAsB,qBAAO;AAAA,EACxC,aAAoB,OAAO,MAAc,SAA0D;AACjG,UAAM,SAAS,QAAQ;AACvB,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,YAAY,oBAAO,GAAG,WAAW,IAAI;AAAA,MACrC,SAAS,UAAM,8CAA2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AK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,uBAAuB,iCAAmB;AAAA,EACrD,aAAoB,OAAO,UAA4E;AACrG,UAAM,iBAAiB,MAAM,gBAAAA,QAAS,IAAI,OAAO,QAAQ,QAAQ,GAAG,OAAO,CAAC,aAAa,OAAO,MAAM;AACpG,YAAM,MAAM,MAAM,cAAc,OAAO,aAAa,OAAO;AAC3D,aAAO,IAAI,QAAQ,WAAW;AAAA,IAChC,CAAC;AACD,UAAM,OAAO,IAAI,eAAe,EAAE,YAAY,WAAW,CAAC;AAC1D,SAAK,QAAQ,GAAG,cAAc;AAC9B,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["bluebird"]
7
+ }
@@ -16,21 +16,22 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var configuration_exports = {};
20
- __export(configuration_exports, {
19
+ var configuration_module_exports = {};
20
+ __export(configuration_module_exports, {
21
21
  ConfigurationModule: () => ConfigurationModule
22
22
  });
23
- module.exports = __toCommonJS(configuration_exports);
24
- var import_json_schema_to_typescript = require("json-schema-to-typescript");
25
- var import_module = require("./module");
23
+ module.exports = __toCommonJS(configuration_module_exports);
24
+ var import_const = require("../const");
25
+ var import_generators = require("../generators");
26
+ var import_module = require("../module");
26
27
  class ConfigurationModule extends import_module.Module {
27
28
  static async create(configuration) {
28
- const schema = configuration.schema ?? {};
29
- const filename = "configuration";
29
+ const schema = configuration.schema;
30
+ const name = "configuration";
30
31
  return new ConfigurationModule({
31
- path: `${filename}.ts`,
32
+ path: import_const.INDEX_FILE,
32
33
  exportName: "Configuration",
33
- content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
34
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
34
35
  });
35
36
  }
36
37
  }
@@ -38,4 +39,4 @@ class ConfigurationModule extends import_module.Module {
38
39
  0 && (module.exports = {
39
40
  ConfigurationModule
40
41
  });
41
- //# sourceMappingURL=configuration.js.map
42
+ //# sourceMappingURL=configuration-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/code-generation/integration-schemas/configuration-module.ts"],
4
+ "sourcesContent": ["import { INDEX_FILE } from '../const'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module } from '../module'\nimport type * as types from '../typings'\n\nexport class ConfigurationModule extends Module {\n public static async create(configuration: types.ConfigurationDefinition): Promise<ConfigurationModule> {\n const schema = configuration.schema\n const name = 'configuration'\n return new ConfigurationModule({\n path: INDEX_FILE,\n exportName: 'Configuration',\n content: await jsonSchemaToTypeScriptType(schema, name),\n })\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAC3B,wBAA2C;AAC3C,oBAAuB;AAGhB,MAAM,4BAA4B,qBAAO;AAAA,EAC9C,aAAoB,OAAO,eAA4E;AACrG,UAAM,SAAS,cAAc;AAC7B,UAAM,OAAO;AACb,WAAO,IAAI,oBAAoB;AAAA,MAC7B,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,SAAS,UAAM,8CAA2B,QAAQ,IAAI;AAAA,IACxD,CAAC;AAAA,EACH;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,64 @@
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_bluebird = __toESM(require("bluebird"));
32
+ var import_utils = require("../../utils");
33
+ var import_generators = require("../generators");
34
+ var import_module = require("../module");
35
+ class EventModule extends import_module.Module {
36
+ static async create(name, event) {
37
+ const schema = event.schema;
38
+ const def = {
39
+ path: `${name}.ts`,
40
+ exportName: import_utils.casing.to.pascalCase(name),
41
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
42
+ };
43
+ return new EventModule(def);
44
+ }
45
+ }
46
+ class EventsModule extends import_module.ReExportTypeModule {
47
+ static async create(events) {
48
+ const eventModules = await import_bluebird.default.map(
49
+ Object.entries(events),
50
+ async ([eventName, event]) => EventModule.create(eventName, event)
51
+ );
52
+ const inst = new EventsModule({
53
+ exportName: "Events"
54
+ });
55
+ inst.pushDep(...eventModules);
56
+ return inst;
57
+ }
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ EventModule,
62
+ EventsModule
63
+ });
64
+ //# sourceMappingURL=events-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/code-generation/integration-schemas/events-module.ts"],
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { casing } from '../../utils'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport type * as types from '../typings'\n\nexport class EventModule extends Module {\n public static async create(name: string, event: types.EventDefinition): Promise<EventModule> {\n const schema = event.schema\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName: casing.to.pascalCase(name),\n content: await jsonSchemaToTypeScriptType(schema, name),\n }\n return new EventModule(def)\n }\n}\n\nexport class EventsModule extends ReExportTypeModule {\n public static async create(events: Record<string, types.EventDefinition>): Promise<EventsModule> {\n const eventModules = await bluebird.map(Object.entries(events), async ([eventName, event]) =>\n EventModule.create(eventName, event)\n )\n\n const inst = new EventsModule({\n exportName: 'Events',\n })\n inst.pushDep(...eventModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,mBAAuB;AACvB,wBAA2C;AAC3C,oBAAsD;AAG/C,MAAM,oBAAoB,qBAAO;AAAA,EACtC,aAAoB,OAAO,MAAc,OAAoD;AAC3F,UAAM,SAAS,MAAM;AACrB,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,YAAY,oBAAO,GAAG,WAAW,IAAI;AAAA,MACrC,SAAS,UAAM,8CAA2B,QAAQ,IAAI;AAAA,IACxD;AACA,WAAO,IAAI,YAAY,GAAG;AAAA,EAC5B;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EACnD,aAAoB,OAAO,QAAsE;AAC/F,UAAM,eAAe,MAAM,gBAAAA,QAAS;AAAA,MAAI,OAAO,QAAQ,MAAM;AAAA,MAAG,OAAO,CAAC,WAAW,KAAK,MACtF,YAAY,OAAO,WAAW,KAAK;AAAA,IACrC;AAEA,UAAM,OAAO,IAAI,aAAa;AAAA,MAC5B,YAAY;AAAA,IACd,CAAC;AACD,SAAK,QAAQ,GAAG,YAAY;AAC5B,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["bluebird"]
7
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var states_module_exports = {};
26
+ __export(states_module_exports, {
27
+ StateModule: () => StateModule,
28
+ StatesModule: () => StatesModule
29
+ });
30
+ module.exports = __toCommonJS(states_module_exports);
31
+ var import_bluebird = __toESM(require("bluebird"));
32
+ var import_utils = require("../../utils");
33
+ var import_generators = require("../generators");
34
+ var import_module = require("../module");
35
+ class StateModule extends import_module.Module {
36
+ static async create(name, state) {
37
+ const schema = state.schema;
38
+ const def = {
39
+ path: `${name}.ts`,
40
+ exportName: import_utils.casing.to.pascalCase(name),
41
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
42
+ };
43
+ return new StateModule(def);
44
+ }
45
+ }
46
+ class StatesModule extends import_module.ReExportTypeModule {
47
+ static async create(states) {
48
+ const stateModules = await import_bluebird.default.map(
49
+ Object.entries(states),
50
+ async ([stateName, state]) => StateModule.create(stateName, state)
51
+ );
52
+ const inst = new StatesModule({
53
+ exportName: "States"
54
+ });
55
+ inst.pushDep(...stateModules);
56
+ return inst;
57
+ }
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ StateModule,
62
+ StatesModule
63
+ });
64
+ //# sourceMappingURL=states-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/code-generation/integration-schemas/states-module.ts"],
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { casing } from '../../utils'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport type * as types from '../typings'\n\nexport class StateModule extends Module {\n public static async create(name: string, state: types.StateDefinition): Promise<StateModule> {\n const schema = state.schema\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName: casing.to.pascalCase(name),\n content: await jsonSchemaToTypeScriptType(schema, name),\n }\n return new StateModule(def)\n }\n}\n\nexport class StatesModule extends ReExportTypeModule {\n public static async create(states: Record<string, types.StateDefinition>): Promise<StatesModule> {\n const stateModules = await bluebird.map(Object.entries(states), async ([stateName, state]) =>\n StateModule.create(stateName, state)\n )\n\n const inst = new StatesModule({\n exportName: 'States',\n })\n inst.pushDep(...stateModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,mBAAuB;AACvB,wBAA2C;AAC3C,oBAAsD;AAG/C,MAAM,oBAAoB,qBAAO;AAAA,EACtC,aAAoB,OAAO,MAAc,OAAoD;AAC3F,UAAM,SAAS,MAAM;AACrB,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT,YAAY,oBAAO,GAAG,WAAW,IAAI;AAAA,MACrC,SAAS,UAAM,8CAA2B,QAAQ,IAAI;AAAA,IACxD;AACA,WAAO,IAAI,YAAY,GAAG;AAAA,EAC5B;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EACnD,aAAoB,OAAO,QAAsE;AAC/F,UAAM,eAAe,MAAM,gBAAAA,QAAS;AAAA,MAAI,OAAO,QAAQ,MAAM;AAAA,MAAG,OAAO,CAAC,WAAW,KAAK,MACtF,YAAY,OAAO,WAAW,KAAK;AAAA,IACrC;AAEA,UAAM,OAAO,IAAI,aAAa;AAAA,MAC5B,YAAY;AAAA,IACd,CAAC;AACD,SAAK,QAAQ,GAAG,YAAY;AAC5B,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["bluebird"]
7
+ }
@@ -89,23 +89,23 @@ class ReExportTypeModule extends Module {
89
89
  get content() {
90
90
  let content = import_const.GENERATED_HEADER;
91
91
  const dependencies = this.deps;
92
- const { exports: className } = this;
93
92
  for (const m of dependencies) {
94
93
  const { name } = m;
95
94
  const importFrom = m.import(this);
96
- content += `import type * as ${name} from "./${importFrom}";
95
+ content += `import * as ${name} from "./${importFrom}";
97
96
  `;
98
97
  content += `export * as ${name} from "./${importFrom}";
99
98
  `;
100
99
  }
101
100
  content += "\n";
102
- content += `export type ${className} = {
101
+ content += `export type ${this.exports} = {
103
102
  `;
104
- for (const { name, exports } of dependencies) {
103
+ for (const { name, exports } of this.deps) {
105
104
  content += ` ${name}: ${name}.${exports};
106
105
  `;
107
106
  }
108
- content += "}\n";
107
+ content += "}";
108
+ content += "\n";
109
109
  return content;
110
110
  }
111
111
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/module.ts"],
4
- "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport type { File } from './typings'\n\nexport type ModuleDef = File & {\n exportName: string\n}\n\nexport abstract class Module implements File {\n private _localDependencies: Module[] = []\n\n public get path(): string {\n return this._def.path\n }\n\n public get content(): string {\n return this._def.content\n }\n\n public get name(): string {\n const basename = pathlib.basename(this.path)\n if (basename === INDEX_FILE) {\n const dirname = pathlib.basename(pathlib.dirname(this.path))\n return utils.casing.to.camelCase(dirname)\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return utils.casing.to.camelCase(withoutExtension)\n }\n\n public get exports(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n protected constructor(private _def: ModuleDef) {}\n\n public pushDep(...dependencies: Module[]): this {\n this._localDependencies.push(...dependencies)\n return this\n }\n\n public unshift(...basePath: string[]): this {\n this._def = {\n ...this._def,\n path: pathlib.join(...basePath, this._def.path),\n }\n this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath))\n return this\n }\n\n public flatten(): File[] {\n return [this, ...this._localDependencies.flatMap((d) => d.flatten())]\n }\n\n public import(base: Module): string {\n let relativePath = pathlib.relative(pathlib.dirname(base.path), this.path)\n relativePath = pathlib.join('.', relativePath)\n return utils.path.rmExtension(relativePath)\n }\n}\n\nexport abstract class ReExportTypeModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: INDEX_FILE,\n content: '',\n })\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n const dependencies = this.deps\n const { exports: className } = this\n\n for (const m of dependencies) {\n const { name } = m\n const importFrom = m.import(this)\n content += `import type * as ${name} from \"./${importFrom}\";\\n`\n content += `export * as ${name} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${className} = {\\n`\n for (const { name, exports } of dependencies) {\n content += ` ${name}: ${name}.${exports};\\n`\n }\n content += '}\\n'\n\n return content\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,mBAA6C;AAOtC,MAAe,OAAuB;AAAA,EA6BjC,YAAoB,MAAiB;AAAjB;AAAA,EAAkB;AAAA,EA5BxC,qBAA+B,CAAC;AAAA,EAExC,IAAW,OAAe;AACxB,WAAO,KAAK,KAAK;AAA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O,MAAe,2BAA2B,OAAO;AAAA,EAC5C,YAAY,KAA6B;AACjD,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEA,IAAoB,UAAkB;AACpC,QAAI,UAAU;AACd,UAAM,eAAe,KAAK;AAC1B,UAAM,EAAE,SAAS,UAAU,IAAI;AAE/B,eAAW,KAAK,cAAc;AAC5B,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,oBAAoB,gBAAgB;AAAA;AAC/C,iBAAW,eAAe,gBAAgB;AAAA;AAAA,IAC5C;AAEA,eAAW;AAEX,eAAW,eAAe;AAAA;AAC1B,eAAW,EAAE,MAAM,QAAQ,KAAK,cAAc;AAC5C,iBAAW,KAAK,SAAS,QAAQ;AAAA;AAAA,IACnC;AACA,eAAW;AAEX,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport type { File } from './typings'\n\nexport type ModuleDef = File & {\n exportName: string\n}\n\nexport abstract class Module implements File {\n private _localDependencies: Module[] = []\n\n public get path(): string {\n return this._def.path\n }\n\n public get content(): string {\n return this._def.content\n }\n\n public get name(): string {\n const basename = pathlib.basename(this.path)\n if (basename === INDEX_FILE) {\n const dirname = pathlib.basename(pathlib.dirname(this.path))\n return utils.casing.to.camelCase(dirname)\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return utils.casing.to.camelCase(withoutExtension)\n }\n\n public get exports(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n protected constructor(private _def: ModuleDef) {}\n\n public pushDep(...dependencies: Module[]): this {\n this._localDependencies.push(...dependencies)\n return this\n }\n\n public unshift(...basePath: string[]): this {\n this._def = {\n ...this._def,\n path: pathlib.join(...basePath, this._def.path),\n }\n this._localDependencies = this._localDependencies.map((d) => d.unshift(...basePath))\n return this\n }\n\n public flatten(): File[] {\n return [this, ...this._localDependencies.flatMap((d) => d.flatten())]\n }\n\n public import(base: Module): string {\n let relativePath = pathlib.relative(pathlib.dirname(base.path), this.path)\n relativePath = pathlib.join('.', relativePath)\n return utils.path.rmExtension(relativePath)\n }\n}\n\nexport class ReExportTypeModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: INDEX_FILE,\n content: '',\n })\n }\n\n public override get content(): string {\n let content = GENERATED_HEADER\n const dependencies = this.deps\n\n for (const m of dependencies) {\n const { name } = m\n const importFrom = m.import(this)\n content += `import * as ${name} from \"./${importFrom}\";\\n`\n content += `export * as ${name} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exports} = {\\n`\n for (const { name, exports } of this.deps) {\n content += ` ${name}: ${name}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,mBAA6C;AAOtC,MAAe,OAAuB;AAAA,EA6BjC,YAAoB,MAAiB;AAAjB;AAAA,EAAkB;AAAA,EA5BxC,qBAA+B,CAAC;AAAA,EAExC,IAAW,OAAe;AACxB,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,IAAW,UAAkB;AAC3B,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,IAAW,OAAe;AACxB,UAAM,WAAW,YAAAA,MAAQ,SAAS,KAAK,IAAI;AAC3C,QAAI,aAAa,yBAAY;AAC3B,YAAM,UAAU,YAAAA,MAAQ,SAAS,YAAAA,MAAQ,QAAQ,KAAK,IAAI,CAAC;AAC3D,aAAO,MAAM,OAAO,GAAG,UAAU,OAAO;AAAA,IAC1C;AACA,UAAM,mBAAmB,MAAM,KAAK,YAAY,QAAQ;AACxD,WAAO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AAA;AAAA,IAC5C;AAEA,eAAW;AAEX,eAAW,eAAe,KAAK;AAAA;AAC/B,eAAW,EAAE,MAAM,QAAQ,KAAK,KAAK,MAAM;AACzC,iBAAW,KAAK,SAAS,QAAQ;AAAA;AAAA,IACnC;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["pathlib"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/typings.ts"],
4
- "sourcesContent": ["import type { IntegrationDefinition } from '@botpress/sdk'\nimport type { compile } from 'json-schema-to-typescript'\n\nexport type File = { path: string; content: string }\nexport type Schema = Parameters<typeof compile>[0]\n\nexport type Def<T> = Exclude<T, undefined>\nexport type Config = Def<IntegrationDefinition['configuration']>\nexport type Channel = Def<IntegrationDefinition['channels']>[string]\nexport type Message = Def<Channel['messages']>[string]\nexport type Action = Def<IntegrationDefinition['actions']>[string]\nexport type Event = Def<IntegrationDefinition['events']>[string]\n"],
4
+ "sourcesContent": ["import { Integration } from '@botpress/client'\n\nexport type File = { path: string; content: string }\n\nexport type IntegrationDefinition = Pick<\n Integration,\n 'name' | 'version' | 'configuration' | 'channels' | 'states' | 'events' | 'actions' | 'user'\n>\n\ntype Def<T> = NonNullable<T>\n\nexport type ConfigurationDefinition = Def<IntegrationDefinition['configuration']>\nexport type ChannelDefinition = Def<IntegrationDefinition['channels']>[string]\nexport type MessageDefinition = Def<ChannelDefinition['messages']>[string]\nexport type ActionDefinition = Def<IntegrationDefinition['actions']>[string]\nexport type EventDefinition = Def<IntegrationDefinition['events']>[string]\nexport type StateDefinition = Def<IntegrationDefinition['states']>[string]\nexport type UserDefinition = Def<IntegrationDefinition['user']>\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -29,7 +29,6 @@ __export(deploy_command_exports, {
29
29
  module.exports = __toCommonJS(deploy_command_exports);
30
30
  var import_chalk = __toESM(require("chalk"));
31
31
  var fs = __toESM(require("fs"));
32
- var import_lodash = __toESM(require("lodash"));
33
32
  var import_bot_body = require("../api/bot-body");
34
33
  var import_integration_body = require("../api/integration-body");
35
34
  var consts = __toESM(require("../consts"));
@@ -79,7 +78,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
79
78
  return;
80
79
  }
81
80
  const createBody = {
82
- ...integrationDef,
81
+ ...this.parseIntegrationDefinition(integrationDef),
83
82
  icon: iconFileContent,
84
83
  readme: readmeFileContent,
85
84
  code
@@ -117,15 +116,6 @@ class DeployCommand extends import_project_command.ProjectCommand {
117
116
  const outfile = this.projectPaths.abs.outFile;
118
117
  const code = await fs.promises.readFile(outfile, "utf-8");
119
118
  const { default: botImpl } = utils.require.requireJsFile(outfile);
120
- const {
121
- states,
122
- events,
123
- recurringEvents,
124
- configuration: botConfiguration,
125
- user,
126
- conversation,
127
- message
128
- } = botImpl.definition;
129
119
  let bot;
130
120
  if (argvBotId && argvCreateNew) {
131
121
  throw new errors.BotpressCLIError("Cannot specify both --botId and --createNew");
@@ -146,19 +136,11 @@ class DeployCommand extends import_project_command.ProjectCommand {
146
136
  }
147
137
  const line = this.logger.line();
148
138
  line.started(`Deploying bot ${import_chalk.default.bold(bot.name)}...`);
149
- const integrations = (0, import_lodash.default)(botImpl.definition.integrations ?? []).keyBy((i) => i.id).mapValues(({ enabled, configuration }) => ({ enabled, configuration })).value();
150
139
  const updateBotBody = (0, import_bot_body.prepareUpdateBotBody)(
151
140
  {
152
141
  id: bot.id,
153
142
  code,
154
- states,
155
- recurringEvents,
156
- configuration: botConfiguration,
157
- events,
158
- user,
159
- conversation,
160
- message,
161
- integrations
143
+ ...this.parseBot(botImpl)
162
144
  },
163
145
  bot
164
146
  );