@botpress/cli 1.7.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/.turbo/turbo-build.log +12 -10
  2. package/dist/api/bot-body.js +20 -6
  3. package/dist/api/bot-body.js.map +2 -2
  4. package/dist/api/client.js +18 -0
  5. package/dist/api/client.js.map +2 -2
  6. package/dist/api/interface-body.js.map +2 -2
  7. package/dist/api/plugin-body.js +79 -0
  8. package/dist/api/plugin-body.js.map +7 -0
  9. package/dist/api/types.js.map +1 -1
  10. package/dist/code-generation/bot-implementation/bot-implementation.js +40 -21
  11. package/dist/code-generation/bot-implementation/bot-implementation.js.map +2 -2
  12. package/dist/code-generation/bot-implementation/bot-plugins/index.js +76 -0
  13. package/dist/code-generation/bot-implementation/bot-plugins/index.js.map +7 -0
  14. package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +125 -0
  15. package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +7 -0
  16. package/dist/code-generation/bot-implementation/index.js +27 -22
  17. package/dist/code-generation/bot-implementation/index.js.map +2 -2
  18. package/dist/code-generation/consts.js +3 -0
  19. package/dist/code-generation/consts.js.map +2 -2
  20. package/dist/code-generation/generators.js +8 -0
  21. package/dist/code-generation/generators.js.map +2 -2
  22. package/dist/code-generation/index.js +6 -0
  23. package/dist/code-generation/index.js.map +2 -2
  24. package/dist/code-generation/integration-package/index.js +11 -2
  25. package/dist/code-generation/integration-package/index.js.map +2 -2
  26. package/dist/code-generation/interface-implementation/index.js +29 -0
  27. package/dist/code-generation/interface-implementation/index.js.map +7 -0
  28. package/dist/code-generation/interface-implementation/integration-typings/actions-module.js +84 -0
  29. package/dist/code-generation/interface-implementation/integration-typings/actions-module.js.map +7 -0
  30. package/dist/code-generation/interface-implementation/integration-typings/channels-module.js +103 -0
  31. package/dist/code-generation/interface-implementation/integration-typings/channels-module.js.map +7 -0
  32. package/dist/code-generation/interface-implementation/integration-typings/entities-module.js +59 -0
  33. package/dist/code-generation/interface-implementation/integration-typings/entities-module.js.map +7 -0
  34. package/dist/code-generation/interface-implementation/integration-typings/events-module.js +59 -0
  35. package/dist/code-generation/interface-implementation/integration-typings/events-module.js.map +7 -0
  36. package/dist/code-generation/interface-implementation/integration-typings/index.js +117 -0
  37. package/dist/code-generation/interface-implementation/integration-typings/index.js.map +7 -0
  38. package/dist/code-generation/interface-package/index.js +11 -2
  39. package/dist/code-generation/interface-package/index.js.map +2 -2
  40. package/dist/code-generation/module.js +17 -4
  41. package/dist/code-generation/module.js.map +2 -2
  42. package/dist/code-generation/plugin-implementation/index.js +56 -0
  43. package/dist/code-generation/plugin-implementation/index.js.map +7 -0
  44. package/dist/code-generation/plugin-implementation/plugin-implementation.js +86 -0
  45. package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +7 -0
  46. package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js +84 -0
  47. package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js.map +7 -0
  48. package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js +57 -0
  49. package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js.map +7 -0
  50. package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js +59 -0
  51. package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js.map +7 -0
  52. package/dist/code-generation/plugin-implementation/plugin-typings/index.js +146 -0
  53. package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +7 -0
  54. package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js +60 -0
  55. package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js.map +7 -0
  56. package/dist/code-generation/plugin-package/index.js +146 -0
  57. package/dist/code-generation/plugin-package/index.js.map +7 -0
  58. package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +84 -0
  59. package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +7 -0
  60. package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +52 -0
  61. package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +7 -0
  62. package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +62 -0
  63. package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +7 -0
  64. package/dist/code-generation/plugin-package/plugin-package-definition/index.js +103 -0
  65. package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +7 -0
  66. package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +62 -0
  67. package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +7 -0
  68. package/dist/code-generation/plugin-package/plugin-package-definition/typings.js +17 -0
  69. package/dist/code-generation/plugin-package/plugin-package-definition/typings.js.map +7 -0
  70. package/dist/code-generation/typings.js.map +1 -1
  71. package/dist/command-definitions.js +8 -0
  72. package/dist/command-definitions.js.map +2 -2
  73. package/dist/command-implementations/add-command.js +47 -10
  74. package/dist/command-implementations/add-command.js.map +2 -2
  75. package/dist/command-implementations/bundle-command.js +7 -2
  76. package/dist/command-implementations/bundle-command.js.map +2 -2
  77. package/dist/command-implementations/deploy-command.js +51 -0
  78. package/dist/command-implementations/deploy-command.js.map +2 -2
  79. package/dist/command-implementations/gen-command.js +11 -0
  80. package/dist/command-implementations/gen-command.js.map +2 -2
  81. package/dist/command-implementations/index.js +8 -0
  82. package/dist/command-implementations/index.js.map +2 -2
  83. package/dist/command-implementations/init-command.js +36 -8
  84. package/dist/command-implementations/init-command.js.map +2 -2
  85. package/dist/command-implementations/lint-command.js +1 -1
  86. package/dist/command-implementations/lint-command.js.map +2 -2
  87. package/dist/command-implementations/plugin-commands.js +107 -0
  88. package/dist/command-implementations/plugin-commands.js.map +7 -0
  89. package/dist/command-implementations/project-command.js +30 -3
  90. package/dist/command-implementations/project-command.js.map +2 -2
  91. package/dist/command-implementations/read-command.js +13 -1
  92. package/dist/command-implementations/read-command.js.map +2 -2
  93. package/dist/config.js +23 -2
  94. package/dist/config.js.map +2 -2
  95. package/dist/consts.js +7 -0
  96. package/dist/consts.js.map +2 -2
  97. package/dist/sdk/index.js +1 -0
  98. package/dist/sdk/index.js.map +2 -2
  99. package/dist/sdk/resolve-bot-interfaces.js +6 -1
  100. package/dist/sdk/resolve-bot-interfaces.js.map +2 -2
  101. package/dist/sdk/resolve-integration-interfaces.js +16 -8
  102. package/dist/sdk/resolve-integration-interfaces.js.map +2 -2
  103. package/dist/sdk/validate-bot.js +84 -0
  104. package/dist/sdk/validate-bot.js.map +7 -0
  105. package/dist/utils/esbuild-utils.js +3 -2
  106. package/dist/utils/esbuild-utils.js.map +2 -2
  107. package/dist/utils/index.js +3 -0
  108. package/dist/utils/index.js.map +2 -2
  109. package/dist/utils/object-utils.js +32 -0
  110. package/dist/utils/object-utils.js.map +7 -0
  111. package/dist/utils/schema-utils.js.map +2 -2
  112. package/dist/utils/type-utils.js.map +1 -1
  113. package/e2e/tests/install-package.ts +1 -1
  114. package/package.json +2 -2
  115. package/templates/empty-bot/.botpress/implementation/index.ts +27 -18
  116. package/templates/empty-bot/.botpress/implementation/plugins/index.ts +11 -0
  117. package/templates/empty-bot/.botpress/index.ts +5 -1
  118. package/templates/empty-bot/package.json +1 -1
  119. package/templates/empty-integration/package.json +1 -1
  120. package/templates/empty-plugin/.botpress/implementation/index.ts +35 -0
  121. package/templates/empty-plugin/.botpress/implementation/typings/actions/index.ts +6 -0
  122. package/templates/empty-plugin/.botpress/implementation/typings/configuration/index.ts +2 -0
  123. package/templates/empty-plugin/.botpress/implementation/typings/events/index.ts +6 -0
  124. package/templates/empty-plugin/.botpress/implementation/typings/index.ts +26 -0
  125. package/templates/empty-plugin/.botpress/implementation/typings/integrations/index.ts +6 -0
  126. package/templates/empty-plugin/.botpress/implementation/typings/interfaces/index.ts +6 -0
  127. package/templates/empty-plugin/.botpress/implementation/typings/states/index.ts +6 -0
  128. package/templates/empty-plugin/.botpress/index.ts +1 -0
  129. package/templates/empty-plugin/package.json +16 -0
  130. package/templates/empty-plugin/plugin.definition.ts +7 -0
  131. package/templates/empty-plugin/src/index.ts +7 -0
  132. package/templates/empty-plugin/tsconfig.json +28 -0
  133. package/templates/hello-world/package.json +1 -1
  134. package/templates/webhook-message/package.json +1 -1
@@ -0,0 +1,103 @@
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.typeName(name)
39
+ });
40
+ this._message = _message;
41
+ }
42
+ async getContent() {
43
+ return (0, import_generators.zuiSchemaToTypeScriptType)(this._message.schema, this.exportName);
44
+ }
45
+ }
46
+ class MessagesModule extends import_module.ReExportTypeModule {
47
+ constructor(channel) {
48
+ super({ exportName: strings.typeName("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.typeName(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
+ const conversation = {
70
+ tags: this._channel.conversation?.tags ?? {},
71
+ creation: this._channel.conversation?.creation ?? { enabled: false, requiredTags: [] }
72
+ };
73
+ const message = {
74
+ tags: this._channel.message?.tags ?? {}
75
+ };
76
+ return [
77
+ import_consts.GENERATED_HEADER,
78
+ `import { ${this._messagesModule.exportName} } from './${messageImport}'`,
79
+ `export * from './${messageImport}'`,
80
+ "",
81
+ `export type ${this.exportName} = {`,
82
+ ` messages: ${this._messagesModule.exportName}`,
83
+ ` message: ${(0, import_generators.stringifySingleLine)(message)}`,
84
+ ` conversation: ${(0, import_generators.stringifySingleLine)(conversation)}`,
85
+ "}"
86
+ ].join("\n");
87
+ }
88
+ }
89
+ class ChannelsModule extends import_module.ReExportTypeModule {
90
+ constructor(channels) {
91
+ super({ exportName: strings.typeName("channels") });
92
+ for (const [channelName, channel] of Object.entries(channels)) {
93
+ const module2 = new ChannelModule(channelName, channel);
94
+ module2.unshift(channelName);
95
+ this.pushDep(module2);
96
+ }
97
+ }
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ ChannelsModule
102
+ });
103
+ //# sourceMappingURL=channels-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-implementation/integration-typings/channels-module.ts"],
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { GENERATED_HEADER, INDEX_FILE } from '../../consts'\nimport { zuiSchemaToTypeScriptType, stringifySingleLine } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nclass MessageModule extends Module {\n public constructor(name: string, private _message: sdk.MessageDefinition) {\n super({\n path: `${name}.ts`,\n exportName: strings.typeName(name),\n })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._message.schema, this.exportName)\n }\n}\n\nclass MessagesModule extends ReExportTypeModule {\n public constructor(channel: sdk.ChannelDefinition) {\n super({ exportName: strings.typeName('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: sdk.ChannelDefinition) {\n super({\n path: INDEX_FILE,\n exportName: strings.typeName(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 const conversation = {\n tags: this._channel.conversation?.tags ?? {},\n creation: this._channel.conversation?.creation ?? { enabled: false, requiredTags: [] },\n }\n\n const message = {\n tags: this._channel.message?.tags ?? {},\n }\n\n return [\n GENERATED_HEADER,\n `import { ${this._messagesModule.exportName} } from './${messageImport}'`,\n `export * from './${messageImport}'`,\n '',\n `export type ${this.exportName} = {`,\n ` messages: ${this._messagesModule.exportName}`,\n ` message: ${stringifySingleLine(message)}`,\n ` conversation: ${stringifySingleLine(conversation)}`,\n '}',\n ].join('\\n')\n }\n}\n\nexport class ChannelsModule extends ReExportTypeModule {\n public constructor(channels: Record<string, sdk.ChannelDefinition>) {\n super({ exportName: strings.typeName('channels') })\n for (const [channelName, channel] of Object.entries(channels)) {\n const module = new ChannelModule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CAAC,EAAE;AAAA,IACvF;AAEA,UAAM,UAAU;AAAA,MACd,MAAM,KAAK,SAAS,SAAS,QAAQ,CAAC;AAAA,IACxC;AAEA,WAAO;AAAA,MACL;AAAA,MACA,YAAY,KAAK,gBAAgB,wBAAwB;AAAA,MACzD,oBAAoB;AAAA,MACpB;AAAA,MACA,eAAe,KAAK;AAAA,MACpB,eAAe,KAAK,gBAAgB;AAAA,MACpC,kBAAc,uCAAoB,OAAO;AAAA,MACzC,uBAAmB,uCAAoB,YAAY;AAAA,MACnD;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAEO,MAAM,uBAAuB,iCAAmB;AAAA,EAC9C,YAAY,UAAiD;AAClE,UAAM,EAAE,YAAY,QAAQ,SAAS,UAAU,EAAE,CAAC;AAClD,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.typeName(entityName);
38
+ super({ path: `${name}.ts`, exportName });
39
+ this._entity = _entity;
40
+ }
41
+ async getContent() {
42
+ return (0, import_generators.zuiSchemaToTypeScriptType)(this._entity.schema, this.exportName);
43
+ }
44
+ }
45
+ class EntitiesModule extends import_module.ReExportTypeModule {
46
+ constructor(entities) {
47
+ super({ exportName: strings.typeName("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-implementation/integration-typings/entities-module.ts"],
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class EntityModule extends Module {\n public constructor(name: string, private _entity: sdk.EntityDefinition) {\n const entityName = name\n const exportName = strings.typeName(entityName)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._entity.schema, this.exportName)\n }\n}\n\nexport class EntitiesModule extends ReExportTypeModule {\n public constructor(entities: Record<string, sdk.EntityDefinition>) {\n super({ exportName: strings.typeName('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;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,qBAAqB,qBAAO;AAAA,EAChC,YAAY,MAAsB,SAA+B;AACtE,UAAM,aAAa;AACnB,UAAM,aAAa,QAAQ,SAAS,UAAU;AAC9C,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHD;AAAA,EAIzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,QAAQ,QAAQ,KAAK,UAAU;AAAA,EACvE;AACF;AAEO,MAAM,uBAAuB,iCAAmB;AAAA,EAC9C,YAAY,UAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,UAAU,EAAE,CAAC;AAElD,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,59 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var events_module_exports = {};
26
+ __export(events_module_exports, {
27
+ EventModule: () => EventModule,
28
+ EventsModule: () => EventsModule
29
+ });
30
+ module.exports = __toCommonJS(events_module_exports);
31
+ var import_generators = require("../../generators");
32
+ var import_module = require("../../module");
33
+ var strings = __toESM(require("../../strings"));
34
+ class EventModule extends import_module.Module {
35
+ constructor(name, _event) {
36
+ const eventName = name;
37
+ const exportName = strings.typeName(eventName);
38
+ super({ path: `${name}.ts`, exportName });
39
+ this._event = _event;
40
+ }
41
+ async getContent() {
42
+ return (0, import_generators.zuiSchemaToTypeScriptType)(this._event.schema, this.exportName);
43
+ }
44
+ }
45
+ class EventsModule extends import_module.ReExportTypeModule {
46
+ constructor(events) {
47
+ super({ exportName: strings.typeName("events") });
48
+ for (const [eventName, event] of Object.entries(events)) {
49
+ const module2 = new EventModule(eventName, event);
50
+ this.pushDep(module2);
51
+ }
52
+ }
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ EventModule,
57
+ EventsModule
58
+ });
59
+ //# sourceMappingURL=events-module.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-implementation/integration-typings/events-module.ts"],
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class EventModule extends Module {\n public constructor(name: string, private _event: sdk.EventDefinition) {\n const eventName = name\n const exportName = strings.typeName(eventName)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._event.schema, this.exportName)\n }\n}\n\nexport class EventsModule extends ReExportTypeModule {\n public constructor(events: Record<string, sdk.EventDefinition>) {\n super({ exportName: strings.typeName('events') })\n for (const [eventName, event] of Object.entries(events)) {\n const module = new EventModule(eventName, event)\n this.pushDep(module)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YAAY,MAAsB,QAA6B;AACpE,UAAM,YAAY;AAClB,UAAM,aAAa,QAAQ,SAAS,SAAS;AAC7C,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHD;AAAA,EAIzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAA6C;AAC9D,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": ["module"]
7
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var integration_typings_exports = {};
26
+ __export(integration_typings_exports, {
27
+ InterfaceTypingsModule: () => InterfaceTypingsModule
28
+ });
29
+ module.exports = __toCommonJS(integration_typings_exports);
30
+ var import_lodash = __toESM(require("lodash"));
31
+ var import_consts = require("../../consts");
32
+ var import_module = require("../../module");
33
+ var import_actions_module = require("./actions-module");
34
+ var import_channels_module = require("./channels-module");
35
+ var import_entities_module = require("./entities-module");
36
+ var import_events_module = require("./events-module");
37
+ class InterfaceTypingsModule extends import_module.Module {
38
+ constructor(_interface) {
39
+ super({
40
+ path: import_consts.INDEX_FILE,
41
+ exportName: "TInterface"
42
+ });
43
+ this._interface = _interface;
44
+ const references = import_lodash.default.mapValues(_interface.entities, (e) => e.schema);
45
+ const derefObject = (obj) => {
46
+ return {
47
+ ...obj,
48
+ schema: obj.schema.dereference(references)
49
+ };
50
+ };
51
+ _interface = {
52
+ ..._interface,
53
+ actions: import_lodash.default.mapValues(_interface.actions, (a) => ({
54
+ ...a,
55
+ input: derefObject(a.input),
56
+ output: derefObject(a.output)
57
+ })),
58
+ channels: import_lodash.default.mapValues(_interface.channels, (c) => ({
59
+ ...c,
60
+ messages: import_lodash.default.mapValues(c.messages, (m) => derefObject(m))
61
+ })),
62
+ events: import_lodash.default.mapValues(_interface.events, (e) => derefObject(e))
63
+ };
64
+ const actionsModule = new import_actions_module.ActionsModule(_interface.actions ?? {});
65
+ actionsModule.unshift("actions");
66
+ const channelsModule = new import_channels_module.ChannelsModule(_interface.channels ?? {});
67
+ channelsModule.unshift("channels");
68
+ const eventsModule = new import_events_module.EventsModule(_interface.events ?? {});
69
+ eventsModule.unshift("events");
70
+ const entitiesModule = new import_entities_module.EntitiesModule(_interface.entities ?? {});
71
+ entitiesModule.unshift("entities");
72
+ this._dependencies = {
73
+ actionsModule,
74
+ channelsModule,
75
+ eventsModule,
76
+ entitiesModule
77
+ };
78
+ for (const dep of Object.values(this._dependencies)) {
79
+ this.pushDep(dep);
80
+ }
81
+ }
82
+ _dependencies;
83
+ async getContent() {
84
+ let content = "";
85
+ const { actionsModule, channelsModule, eventsModule, entitiesModule } = this._dependencies;
86
+ const actionsImport = actionsModule.import(this);
87
+ const channelsImport = channelsModule.import(this);
88
+ const eventsImport = eventsModule.import(this);
89
+ const entitiesImport = entitiesModule.import(this);
90
+ content += [
91
+ import_consts.GENERATED_HEADER,
92
+ `import * as ${actionsModule.name} from "./${actionsImport}"`,
93
+ `import * as ${channelsModule.name} from "./${channelsImport}"`,
94
+ `import * as ${eventsModule.name} from "./${eventsImport}"`,
95
+ `import * as ${entitiesModule.name} from "./${entitiesImport}"`,
96
+ `export * as ${actionsModule.name} from "./${actionsImport}"`,
97
+ `export * as ${channelsModule.name} from "./${channelsImport}"`,
98
+ `export * as ${eventsModule.name} from "./${eventsImport}"`,
99
+ `export * as ${entitiesModule.name} from "./${entitiesImport}"`,
100
+ "",
101
+ "export type TInterface = {",
102
+ ` name: "${this._interface.name}"`,
103
+ ` version: "${this._interface.version}"`,
104
+ ` actions: ${actionsModule.name}.${actionsModule.exportName}`,
105
+ ` channels: ${channelsModule.name}.${channelsModule.exportName}`,
106
+ ` events: ${eventsModule.name}.${eventsModule.exportName}`,
107
+ ` entities: ${entitiesModule.name}.${entitiesModule.exportName}`,
108
+ "}"
109
+ ].join("\n");
110
+ return content;
111
+ }
112
+ }
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ InterfaceTypingsModule
116
+ });
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/code-generation/interface-implementation/integration-typings/index.ts"],
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport _ from 'lodash'\nimport { GENERATED_HEADER, INDEX_FILE } 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'\n\ntype InterfaceTypingsModuleDependencies = {\n actionsModule: ActionsModule\n channelsModule: ChannelsModule\n eventsModule: EventsModule\n entitiesModule: EntitiesModule\n}\n\nexport class InterfaceTypingsModule extends Module {\n private _dependencies: InterfaceTypingsModuleDependencies\n\n public constructor(private _interface: sdk.InterfacePackage['definition']) {\n super({\n path: INDEX_FILE,\n exportName: 'TInterface',\n })\n\n const references: Record<string, sdk.z.Schema> = _.mapValues(_interface.entities, (e) => e.schema)\n\n type ZodObjectSchema = sdk.z.ZodObject | sdk.z.ZodRecord\n const derefObject = (obj: { schema: ZodObjectSchema }) => {\n return {\n ...obj,\n schema: obj.schema.dereference(references) as ZodObjectSchema,\n }\n }\n\n _interface = {\n ..._interface,\n actions: _.mapValues(_interface.actions, (a) => ({\n ...a,\n input: derefObject(a.input),\n output: derefObject(a.output),\n })),\n channels: _.mapValues(_interface.channels, (c) => ({\n ...c,\n messages: _.mapValues(c.messages, (m) => derefObject(m)),\n })),\n events: _.mapValues(_interface.events, (e) => derefObject(e)),\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 content += [\n GENERATED_HEADER,\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 type TInterface = {',\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 '}',\n ].join('\\n')\n\n return content\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAc;AACd,oBAA6C;AAC7C,oBAAuB;AACvB,4BAA8B;AAC9B,6BAA+B;AAC/B,6BAA+B;AAC/B,2BAA6B;AAStB,MAAM,+BAA+B,qBAA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a,GAAG;AACnD,WAAK,QAAQ,GAAG;AAAA,IAClB;AAAA,EACF;AAAA,EAtDQ;AAAA,EAwDR,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,eAAW;AAAA,MACT;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;AAAA,IACF,EAAE,KAAK,IAAI;AAEX,WAAO;AAAA,EACT;AACF;",
6
+ "names": ["_"]
7
+ }
@@ -29,9 +29,15 @@ __export(interface_package_exports, {
29
29
  module.exports = __toCommonJS(interface_package_exports);
30
30
  var utils = __toESM(require("../../utils"));
31
31
  var consts = __toESM(require("../consts"));
32
+ var gen = __toESM(require("../generators"));
32
33
  var import_interface_package_definition = require("./interface-package-definition");
33
34
  const generateInterfacePackageModule = (definitionImport, pkg) => {
34
- const refLine = pkg.source === "local" ? `uri: "${utils.path.win32.escapeBackslashes(pkg.path)}"` : `id: "${pkg.interface.id}"`;
35
+ const id = pkg.source === "remote" ? pkg.interface.id : void 0;
36
+ const uri = pkg.source === "local" ? utils.path.win32.escapeBackslashes(pkg.path) : void 0;
37
+ const tsId = gen.primitiveToTypescriptValue(id);
38
+ const tsUri = gen.primitiveToTypescriptValue(uri);
39
+ const tsName = gen.primitiveToTypescriptValue(pkg.name);
40
+ const tsVersion = gen.primitiveToTypescriptValue(pkg.version);
35
41
  return [
36
42
  consts.GENERATED_HEADER,
37
43
  'import * as sdk from "@botpress/sdk"',
@@ -40,7 +46,10 @@ const generateInterfacePackageModule = (definitionImport, pkg) => {
40
46
  "",
41
47
  "export default {",
42
48
  ' type: "interface",',
43
- ` ${refLine},`,
49
+ ` id: ${tsId},`,
50
+ ` uri: ${tsUri},`,
51
+ ` name: ${tsName},`,
52
+ ` version: ${tsVersion},`,
44
53
  " definition,",
45
54
  "} satisfies sdk.InterfacePackage"
46
55
  ].join("\n");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/code-generation/interface-package/index.ts"],
4
- "sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as types from '../typings'\nimport { InterfacePackageDefinitionModule } from './interface-package-definition'\n\nconst generateInterfacePackageModule = (definitionImport: string, pkg: types.InterfaceInstallablePackage): string => {\n const refLine =\n pkg.source === 'local' ? `uri: \"${utils.path.win32.escapeBackslashes(pkg.path)}\"` : `id: \"${pkg.interface.id}\"`\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.win32.escapeBackslashes(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"interface\",',\n ` ${refLine},`,\n ' definition,',\n '} satisfies sdk.InterfacePackage',\n ].join('\\n')\n}\n\nconst generateInterfacePackageFromRemote = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new InterfacePackageDefinitionModule(pkg.interface)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateInterfacePackageFromLocal = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.interfaceDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateInterfacePackage = async (pkg: types.InterfaceInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateInterfacePackageFromRemote(pkg)\n }\n return generateInterfacePackageFromLocal(pkg)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AAExB,0CAAiD;AAEjD,MAAM,iCAAiC,CAAC,kBAA0B,QAAmD;AACnH,QAAM,UACJ,IAAI,WAAW,UAAU,SAAS,MAAM,KAAK,MAAM,kBAAkB,IAAI,IAAI,OAAO,QAAQ,IAAI,UAAU;AAC5G,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,2BAA2B,MAAM,KAAK,MAAM,kBAAkB,gBAAgB;AAAA,IAC9E;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,MAAM,qCAAqC,OACzC,QAC0B;AAC1B,QAAM,gBAAgB;AACtB,QAAM,mBAAmB,IAAI,qEAAiC,IAAI,SAAS;AAC3E,mBAAiB,QAAQ,aAAa;AAEtC,QAAM,kBAAkB,MAAM,iBAAiB,QAAQ;AACvD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,+BAA+B,KAAK,iBAAiB,GAAG;AAAA,IACnE;AAAA,EACF;AACF;AAEA,MAAM,oCAAoC,OACxC,QAC0B;AAC1B,MAAI,mBAA2B,MAAM,KAAK,KAAK,IAAI,MAAM,OAAO,YAAY,mBAAmB;AAC/F,qBAAmB,MAAM,KAAK,YAAY,gBAAgB;AAC1D,SAAO;AAAA,IACL;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,+BAA+B,kBAAkB,GAAG;AAAA,IAC/D;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,OAAO,QAAkE;AAC/G,MAAI,IAAI,WAAW,UAAU;AAC3B,WAAO,mCAAmC,GAAG;AAAA,EAC/C;AACA,SAAO,kCAAkC,GAAG;AAC9C;",
4
+ "sourcesContent": ["import * as utils from '../../utils'\nimport * as consts from '../consts'\nimport * as gen from '../generators'\nimport * as types from '../typings'\nimport { InterfacePackageDefinitionModule } from './interface-package-definition'\n\nconst generateInterfacePackageModule = (definitionImport: string, pkg: types.InterfaceInstallablePackage): string => {\n const id = pkg.source === 'remote' ? pkg.interface.id : undefined\n const uri = pkg.source === 'local' ? utils.path.win32.escapeBackslashes(pkg.path) : undefined\n\n const tsId = gen.primitiveToTypescriptValue(id)\n const tsUri = gen.primitiveToTypescriptValue(uri)\n const tsName = gen.primitiveToTypescriptValue(pkg.name)\n const tsVersion = gen.primitiveToTypescriptValue(pkg.version)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n '',\n `import definition from \"${utils.path.win32.escapeBackslashes(definitionImport)}\"`,\n '',\n 'export default {',\n ' type: \"interface\",',\n ` id: ${tsId},`,\n ` uri: ${tsUri},`,\n ` name: ${tsName},`,\n ` version: ${tsVersion},`,\n ' definition,',\n '} satisfies sdk.InterfacePackage',\n ].join('\\n')\n}\n\nconst generateInterfacePackageFromRemote = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'remote' }>\n): Promise<types.File[]> => {\n const definitionDir = 'definition'\n const definitionModule = new InterfacePackageDefinitionModule(pkg.interface)\n definitionModule.unshift(definitionDir)\n\n const definitionFiles = await definitionModule.flatten()\n return [\n ...definitionFiles,\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(`./${definitionDir}`, pkg),\n },\n ]\n}\n\nconst generateInterfacePackageFromLocal = async (\n pkg: Extract<types.InterfaceInstallablePackage, { source: 'local' }>\n): Promise<types.File[]> => {\n let definitionImport: string = utils.path.join(pkg.path, consts.fromWorkDir.interfaceDefinition)\n definitionImport = utils.path.rmExtension(definitionImport)\n return [\n {\n path: consts.INDEX_FILE,\n content: generateInterfacePackageModule(definitionImport, pkg),\n },\n ]\n}\n\nexport const generateInterfacePackage = async (pkg: types.InterfaceInstallablePackage): Promise<types.File[]> => {\n if (pkg.source === 'remote') {\n return generateInterfacePackageFromRemote(pkg)\n }\n return generateInterfacePackageFromLocal(pkg)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,UAAqB;AAErB,0CAAiD;AAEjD,MAAM,iCAAiC,CAAC,kBAA0B,QAAmD;AACnH,QAAM,KAAK,IAAI,WAAW,WAAW,IAAI,UAAU,KAAK;AACxD,QAAM,MAAM,IAAI,WAAW,UAAU,MAAM,KAAK,MAAM,kBAAkB,IAAI,IAAI,IAAI;AAEpF,QAAM,OAAO,IAAI,2BAA2B,EAAE;AAC9C,QAAM,QAAQ,IAAI,2BAA2B,GAAG;AAChD,QAAM,SAAS,IAAI,2BAA2B,IAAI,IAAI;AACtD,QAAM,YAAY,IAAI,2BAA2B,IAAI,OAAO;AAC5D,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,2BAA2B,MAAM,KAAK,MAAM,kBAAkB,gBAAgB;AAAA,IAC9E;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,EAAE,KAAK,IAAI;AACb;AAEA,MAAM,qCAAqC,OACzC,QAC0B;AAC1B,QAAM,gBAAgB;AACtB,QAAM,mBAAmB,IAAI,qEAAiC,IAAI,SAAS;AAC3E,mBAAiB,QAAQ,aAAa;AAEtC,QAAM,kBAAkB,MAAM,iBAAiB,QAAQ;AACvD,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,+BAA+B,KAAK,iBAAiB,GAAG;AAAA,IACnE;AAAA,EACF;AACF;AAEA,MAAM,oCAAoC,OACxC,QAC0B;AAC1B,MAAI,mBAA2B,MAAM,KAAK,KAAK,IAAI,MAAM,OAAO,YAAY,mBAAmB;AAC/F,qBAAmB,MAAM,KAAK,YAAY,gBAAgB;AAC1D,SAAO;AAAA,IACL;AAAA,MACE,MAAM,OAAO;AAAA,MACb,SAAS,+BAA+B,kBAAkB,GAAG;AAAA,IAC/D;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,OAAO,QAAkE;AAC/G,MAAI,IAAI,WAAW,UAAU;AAC3B,WAAO,mCAAmC,GAAG;AAAA,EAC/C;AACA,SAAO,kCAAkC,GAAG;AAC9C;",
6
6
  "names": []
7
7
  }
@@ -26,7 +26,8 @@ var module_exports = {};
26
26
  __export(module_exports, {
27
27
  Module: () => Module,
28
28
  ReExportTypeModule: () => ReExportTypeModule,
29
- ReExportVariableModule: () => ReExportVariableModule
29
+ ReExportVariableModule: () => ReExportVariableModule,
30
+ SingleFileModule: () => SingleFileModule
30
31
  });
31
32
  module.exports = __toCommonJS(module_exports);
32
33
  var import_path = require("path");
@@ -43,8 +44,9 @@ class Module {
43
44
  }
44
45
  get name() {
45
46
  const basename = import_path.posix.basename(this.path);
46
- if (basename === consts.INDEX_FILE) {
47
- const dirname = import_path.posix.basename(import_path.posix.dirname(this.path));
47
+ if (basename === consts.INDEX_FILE || basename === consts.INDEX_DECLARATION_FILE) {
48
+ const dirPath = import_path.posix.dirname(this.path);
49
+ const dirname = import_path.posix.basename(dirPath);
48
50
  return dirname;
49
51
  }
50
52
  const withoutExtension = utils.path.rmExtension(basename);
@@ -154,10 +156,21 @@ class ReExportVariableModule extends Module {
154
156
  return content;
155
157
  }
156
158
  }
159
+ class SingleFileModule extends Module {
160
+ _content;
161
+ constructor(def) {
162
+ super(def);
163
+ this._content = def.content;
164
+ }
165
+ async getContent() {
166
+ return this._content;
167
+ }
168
+ }
157
169
  // Annotate the CommonJS export names for ESM import in node:
158
170
  0 && (module.exports = {
159
171
  Module,
160
172
  ReExportTypeModule,
161
- ReExportVariableModule
173
+ ReExportVariableModule,
174
+ SingleFileModule
162
175
  });
163
176
  //# sourceMappingURL=module.js.map
@@ -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 * as consts from './consts'\nimport * as strings from './strings'\nimport { File } from './typings'\n\nexport type ModuleProps = {\n path: string\n exportName: string\n}\n\nexport abstract class Module {\n private _localDependencies: Module[] = []\n\n public get path(): string {\n return this._def.path\n }\n\n /**\n * @returns file name without extension\n */\n public get name(): string {\n const basename = pathlib.basename(this.path)\n if (basename === consts.INDEX_FILE) {\n const dirname = pathlib.basename(pathlib.dirname(this.path))\n return dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return withoutExtension\n }\n\n public get isDefaultExport(): boolean {\n return this._def.exportName === consts.DEFAULT_EXPORT_NAME\n }\n\n public get exportName(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n protected constructor(private _def: ModuleProps) {}\n\n public abstract getContent(): Promise<string>\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 async toFile(): Promise<File> {\n return {\n path: this.path,\n content: await this.getContent(),\n }\n }\n\n public async flatten(): Promise<File[]> {\n const self = await this.toFile()\n const allFiles: File[] = [self]\n for (const dep of this._localDependencies) {\n const depFiles = await dep.flatten()\n allFiles.push(...depFiles)\n }\n return allFiles\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: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exportName} = {\\n`\n for (const { name, exportName: exports } of this.deps) {\n const importAlias = strings.importAlias(name)\n content += ` \"${name}\": ${importAlias}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class ReExportVariableModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export const ${this.exportName} = {\\n`\n for (const { name, exportName: exports } of this.deps) {\n const importAlias = strings.importAlias(name)\n content += ` \"${name}\": ${importAlias}.${exports},\\n`\n }\n content += '}'\n\n content += '\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,CAAC;AAAA,EACH;AAAA,EAEA,MAAa,aAA8B;AACzC,QAAI,UAAU,OAAO;AAErB,eAAW,KAAK,KAAK,MAAM;AACzB,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,cAAc,QAAQ,YAAY,IAAI;AAC5C,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,eAAe,uBAAuB;AAAA;AACjD,iBAAW,eAAe,uBAAuB;AAAA;AAAA,IACnD;AAEA,eAAW;AAEX,eAAW,gBAAgB,KAAK;AAAA;AAChC,eAAW,EAAE,MAAM,YAAY,QAAQ,KAAK,KAAK,MAAM;AACrD,YAAM,cAAc,QAAQ,YAAY,IAAI;AAC5C,iBAAW,MAAM,UAAU,eAAe;AAAA;AAAA,IAC5C;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport * as consts from './consts'\nimport * as strings from './strings'\nimport { File } from './typings'\n\nexport type ModuleProps = {\n path: string\n exportName: string\n}\n\nexport abstract class Module {\n private _localDependencies: Module[] = []\n\n public get path(): string {\n return this._def.path\n }\n\n /**\n * @returns file name without extension\n */\n public get name(): string {\n const basename = pathlib.basename(this.path)\n if (basename === consts.INDEX_FILE || basename === consts.INDEX_DECLARATION_FILE) {\n const dirPath = pathlib.dirname(this.path)\n const dirname = pathlib.basename(dirPath)\n return dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return withoutExtension\n }\n\n public get isDefaultExport(): boolean {\n return this._def.exportName === consts.DEFAULT_EXPORT_NAME\n }\n\n public get exportName(): string {\n return this._def.exportName\n }\n\n public get deps(): Module[] {\n return [...this._localDependencies]\n }\n\n protected constructor(private _def: ModuleProps) {}\n\n public abstract getContent(): Promise<string>\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 async toFile(): Promise<File> {\n return {\n path: this.path,\n content: await this.getContent(),\n }\n }\n\n public async flatten(): Promise<File[]> {\n const self = await this.toFile()\n const allFiles: File[] = [self]\n for (const dep of this._localDependencies) {\n const depFiles = await dep.flatten()\n allFiles.push(...depFiles)\n }\n return allFiles\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: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export type ${this.exportName} = {\\n`\n for (const { name, exportName: exports } of this.deps) {\n const importAlias = strings.importAlias(name)\n content += ` \"${name}\": ${importAlias}.${exports};\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class ReExportVariableModule extends Module {\n protected constructor(def: { exportName: string }) {\n super({\n ...def,\n path: consts.INDEX_FILE,\n })\n }\n\n public async getContent(): Promise<string> {\n let content = consts.GENERATED_HEADER\n\n for (const m of this.deps) {\n const { name } = m\n const importAlias = strings.importAlias(name)\n const importFrom = m.import(this)\n content += `import * as ${importAlias} from \"./${importFrom}\";\\n`\n content += `export * as ${importAlias} from \"./${importFrom}\";\\n`\n }\n\n content += '\\n'\n\n content += `export const ${this.exportName} = {\\n`\n for (const { name, exportName: exports } of this.deps) {\n const importAlias = strings.importAlias(name)\n content += ` \"${name}\": ${importAlias}.${exports},\\n`\n }\n content += '}'\n\n content += '\\n'\n\n return content\n }\n}\n\nexport class SingleFileModule extends Module {\n private _content: string\n public constructor(def: ModuleProps & { content: string }) {\n super(def)\n this._content = def.content\n }\n\n public async getContent(): Promise<string> {\n return this._content\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,aAAwB;AACxB,cAAyB;AAQlB,MAAe,OAAO;AAAA,EAiCjB,YAAoB,MAAmB;AAAnB;AAAA,EAAoB;AAAA,EAhC1C,qBAA+B,CAAC;AAAA,EAExC,IAAW,OAAe;AACxB,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAKA,IAAW,OAAe;AACxB,UAAM,WAAW,YAAAA,MAAQ,SAAS,KAAK,IAAI;AAC3C,QAAI,aAAa,OAAO,cAAc,aAAa,OAAO,wBAAwB;AAChF,YAAM,UAAU,YAAAA,MAAQ,QAAQ,KAAK,IAAI;AACzC,YAAM,UAAU,YAAAA,MAAQ,SAAS,OAAO;AACxC,aAAO;AAAA,IACT;AACA,UAAM,mBAAmB,MAAM,KAAK,YAAY,QAAQ;AACxD,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,kBAA2B;AACpC,WAAO,KAAK,KAAK,eAAe,OAAO;AAAA,EACzC;AAAA,EAEA,IAAW,aAAqB;AAC9B,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,IAAW,OAAiB;AAC1B,WAAO,CAAC,GAAG,KAAK,kBAAkB;AAAA,EACpC;AAAA,EAMO,WAAW,cAA8B;AAC9C,SAAK,mBAAmB,KAAK,GAAG,YAAY;AAC5C,WAAO;AAAA,EACT;AAAA,EAEO,WAAW,UAA0B;AAC1C,SAAK,OAAO;AAAA,MACV,GAAG,KAAK;AAAA,MACR,MAAM,YAAAA,MAAQ,KAAK,GAAG,UAAU,KAAK,KAAK,IAAI;AAAA,IAChD;AACA,SAAK,qBAAqB,KAAK,mBAAmB,IAAI,CAAC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W;AAEX,WAAO;AAAA,EACT;AACF;AAEO,MAAM,+BAA+B,OAAO;AAAA,EACvC,YAAY,KAA6B;AACjD,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,MAAM,OAAO;AAAA,IACf,CAAC;AAAA,EACH;AAAA,EAEA,MAAa,aAA8B;AACzC,QAAI,UAAU,OAAO;AAErB,eAAW,KAAK,KAAK,MAAM;AACzB,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,cAAc,QAAQ,YAAY,IAAI;AAC5C,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,eAAe,uBAAuB;AAAA;AACjD,iBAAW,eAAe,uBAAuB;AAAA;AAAA,IACnD;AAEA,eAAW;AAEX,eAAW,gBAAgB,KAAK;AAAA;AAChC,eAAW,EAAE,MAAM,YAAY,QAAQ,KAAK,KAAK,MAAM;AACrD,YAAM,cAAc,QAAQ,YAAY,IAAI;AAC5C,iBAAW,MAAM,UAAU,eAAe;AAAA;AAAA,IAC5C;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;AAEO,MAAM,yBAAyB,OAAO;AAAA,EACnC;AAAA,EACD,YAAY,KAAwC;AACzD,UAAM,GAAG;AACT,SAAK,WAAW,IAAI;AAAA,EACtB;AAAA,EAEA,MAAa,aAA8B;AACzC,WAAO,KAAK;AAAA,EACd;AACF;",
6
6
  "names": ["pathlib"]
7
7
  }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var plugin_implementation_exports = {};
26
+ __export(plugin_implementation_exports, {
27
+ generatePluginImplementation: () => generatePluginImplementation
28
+ });
29
+ module.exports = __toCommonJS(plugin_implementation_exports);
30
+ var consts = __toESM(require("../consts"));
31
+ var import_plugin_implementation = require("./plugin-implementation");
32
+ const generatePluginImplementationCls = async (sdkPluginDefinition, implPath) => {
33
+ const indexModule = new import_plugin_implementation.PluginImplementationModule(sdkPluginDefinition);
34
+ indexModule.unshift(implPath);
35
+ return indexModule.flatten();
36
+ };
37
+ const generatePluginIndex = async (implPath) => {
38
+ let content = "";
39
+ content += `export * from './${implPath}'
40
+ `;
41
+ return {
42
+ path: consts.INDEX_FILE,
43
+ content
44
+ };
45
+ };
46
+ const generatePluginImplementation = async (sdkPluginDefinition) => {
47
+ const implPath = consts.fromOutDir.implementationDir;
48
+ const typingFiles = await generatePluginImplementationCls(sdkPluginDefinition, implPath);
49
+ const indexFile = await generatePluginIndex(implPath);
50
+ return [...typingFiles, indexFile];
51
+ };
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ generatePluginImplementation
55
+ });
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/code-generation/plugin-implementation/index.ts"],
4
+ "sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport * as types from '../typings'\nimport { PluginImplementationModule } from './plugin-implementation'\n\nconst generatePluginImplementationCls = async (\n sdkPluginDefinition: sdk.PluginDefinition,\n implPath: string\n): Promise<types.File[]> => {\n const indexModule = new PluginImplementationModule(sdkPluginDefinition)\n indexModule.unshift(implPath)\n return indexModule.flatten()\n}\n\nconst generatePluginIndex = async (implPath: string): Promise<types.File> => {\n let content = ''\n content += `export * from './${implPath}'\\n`\n return {\n path: consts.INDEX_FILE,\n content,\n }\n}\n\nexport const generatePluginImplementation = async (\n sdkPluginDefinition: sdk.PluginDefinition\n): Promise<types.File[]> => {\n const implPath = consts.fromOutDir.implementationDir\n const typingFiles = await generatePluginImplementationCls(sdkPluginDefinition, implPath)\n const indexFile = await generatePluginIndex(implPath)\n return [...typingFiles, indexFile]\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AAExB,mCAA2C;AAE3C,MAAM,kCAAkC,OACtC,qBACA,aAC0B;AAC1B,QAAM,cAAc,IAAI,wDAA2B,mBAAmB;AACtE,cAAY,QAAQ,QAAQ;AAC5B,SAAO,YAAY,QAAQ;AAC7B;AAEA,MAAM,sBAAsB,OAAO,aAA0C;AAC3E,MAAI,UAAU;AACd,aAAW,oBAAoB;AAAA;AAC/B,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEO,MAAM,+BAA+B,OAC1C,wBAC0B;AAC1B,QAAM,WAAW,OAAO,WAAW;AACnC,QAAM,cAAc,MAAM,gCAAgC,qBAAqB,QAAQ;AACvF,QAAM,YAAY,MAAM,oBAAoB,QAAQ;AACpD,SAAO,CAAC,GAAG,aAAa,SAAS;AACnC;",
6
+ "names": []
7
+ }