@botpress/cli 0.8.21 → 0.8.22

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 (35) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/dist/code-generation/integration-schemas/actions-module.js +9 -7
  3. package/dist/code-generation/integration-schemas/actions-module.js.map +2 -2
  4. package/dist/code-generation/integration-schemas/channels-module.js +9 -6
  5. package/dist/code-generation/integration-schemas/channels-module.js.map +2 -2
  6. package/dist/code-generation/integration-schemas/configuration-module.js +10 -2
  7. package/dist/code-generation/integration-schemas/configuration-module.js.map +2 -2
  8. package/dist/code-generation/integration-schemas/events-module.js +6 -4
  9. package/dist/code-generation/integration-schemas/events-module.js.map +2 -2
  10. package/dist/code-generation/integration-schemas/states-module.js +5 -4
  11. package/dist/code-generation/integration-schemas/states-module.js.map +2 -2
  12. package/dist/code-generation/map-integration.js +27 -25
  13. package/dist/code-generation/map-integration.js.map +2 -2
  14. package/dist/code-generation/module.js +9 -7
  15. package/dist/code-generation/module.js.map +2 -2
  16. package/dist/code-generation/strings.js +40 -0
  17. package/dist/code-generation/strings.js.map +7 -0
  18. package/dist/command-implementations/deploy-command.js +2 -2
  19. package/dist/command-implementations/deploy-command.js.map +2 -2
  20. package/dist/utils/case-utils.js +13 -2
  21. package/dist/utils/case-utils.js.map +2 -2
  22. package/dist/utils/case-utils.test.js +19 -5
  23. package/dist/utils/case-utils.test.js.map +2 -2
  24. package/dist/utils/record-utils.js +10 -0
  25. package/dist/utils/record-utils.js.map +2 -2
  26. package/package.json +2 -2
  27. package/templates/echo-bot/package.json +1 -1
  28. package/templates/empty-integration/package.json +1 -1
  29. package/templates/hello-world/.botpress/implementation/actions/helloWorld/index.ts +3 -3
  30. package/templates/hello-world/.botpress/implementation/actions/index.ts +1 -1
  31. package/templates/hello-world/package.json +1 -1
  32. package/templates/webhook-message/.botpress/implementation/channels/index.ts +1 -1
  33. package/templates/webhook-message/.botpress/implementation/channels/webhook/index.ts +1 -1
  34. package/templates/webhook-message/.botpress/implementation/channels/webhook/messages/index.ts +1 -1
  35. package/templates/webhook-message/package.json +1 -1
@@ -1,19 +1,19 @@
1
1
 
2
- > @botpress/cli@0.8.21 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@0.8.22 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@0.8.21 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@0.8.22 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@0.8.21 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@0.8.22 template:gen /home/runner/work/botpress/botpress/packages/cli
11
11
  > pnpm -r --stream -F @bp-templates/* exec bp gen
12
12
 
13
- šŸ¤– Botpress CLI v0.8.21
14
- šŸ¤– Botpress CLI v0.8.21
15
- šŸ¤– Botpress CLI v0.8.21
16
- šŸ¤– Botpress CLI v0.8.21
13
+ šŸ¤– Botpress CLI v0.8.22
14
+ šŸ¤– Botpress CLI v0.8.22
15
+ šŸ¤– Botpress CLI v0.8.22
16
+ šŸ¤– Botpress CLI v0.8.22
17
17
  ⚠ No typings to generate for bot
18
18
  ā—‹ Generating typings for integration empty-integration...ā—‹ Generating typings for integration hello-world...ā—‹ Generating typings for integration webhook-message...āœ“ Typings available at .botpress
19
19
  āœ“ Typings available at .botpress
@@ -31,17 +31,18 @@ __export(actions_module_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(actions_module_exports);
33
33
  var import_bluebird = __toESM(require("bluebird"));
34
- var import_utils = require("../../utils");
35
34
  var import_generators = require("../generators");
36
35
  var import_module = require("../module");
36
+ var strings = __toESM(require("../strings"));
37
37
  class ActionInputModule extends import_module.Module {
38
38
  static async create(input) {
39
39
  const schema = input.schema;
40
40
  const name = "input";
41
+ const exportName = strings.typeName(name);
41
42
  const def = {
42
43
  path: `${name}.ts`,
43
- exportName: "Input",
44
- content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
44
+ exportName,
45
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
45
46
  };
46
47
  return new ActionInputModule(def);
47
48
  }
@@ -50,10 +51,11 @@ class ActionOutputModule extends import_module.Module {
50
51
  static async create(output) {
51
52
  const schema = output.schema;
52
53
  const name = "output";
54
+ const exportName = strings.typeName(name);
53
55
  const def = {
54
56
  path: `${name}.ts`,
55
- exportName: "Output",
56
- content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
57
+ exportName,
58
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
57
59
  };
58
60
  return new ActionOutputModule(def);
59
61
  }
@@ -63,7 +65,7 @@ class ActionModule extends import_module.ReExportTypeModule {
63
65
  const inputModule = await ActionInputModule.create(action.input);
64
66
  const outputModule = await ActionOutputModule.create(action.output);
65
67
  const inst = new ActionModule({
66
- exportName: `Action${import_utils.casing.to.pascalCase(actionName)}`
68
+ exportName: strings.typeName(actionName)
67
69
  });
68
70
  inst.pushDep(inputModule);
69
71
  inst.pushDep(outputModule);
@@ -77,7 +79,7 @@ class ActionsModule extends import_module.ReExportTypeModule {
77
79
  return mod.unshift(actionName);
78
80
  });
79
81
  const inst = new ActionsModule({
80
- exportName: "Actions"
82
+ exportName: strings.typeName("actions")
81
83
  });
82
84
  inst.pushDep(...actionModules);
83
85
  return inst;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\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 exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\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 exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\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: strings.typeName(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: strings.typeName('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,wBAA2C;AAC3C,oBAAsD;AACtD,cAAyB;AAMlB,MAAM,0BAA0B,qBAAO;AAAA,EAC5C,aAAoB,OAAO,OAAgD;AACzE,UAAM,SAAS,MAAM;AACrB,UAAM,OAAO;AACb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;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,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;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,QAAQ,SAAS,UAAU;AAAA,IACzC,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,QAAQ,SAAS,SAAS;AAAA,IACxC,CAAC;AAED,SAAK,QAAQ,GAAG,aAAa;AAC7B,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["bluebird"]
7
7
  }
@@ -31,17 +31,18 @@ __export(channels_module_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(channels_module_exports);
33
33
  var import_bluebird = __toESM(require("bluebird"));
34
- var import_utils = require("../../utils");
35
34
  var import_const = require("../const");
36
35
  var import_generators = require("../generators");
37
36
  var import_module = require("../module");
37
+ var strings = __toESM(require("../strings"));
38
38
  class MessageModule extends import_module.Module {
39
39
  static async create(name, message) {
40
40
  const schema = message.schema;
41
+ const exportName = strings.typeName(name);
41
42
  const def = {
42
43
  path: `${name}.ts`,
43
- exportName: import_utils.casing.to.pascalCase(name),
44
- content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
44
+ exportName,
45
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
45
46
  };
46
47
  return new MessageModule(def);
47
48
  }
@@ -54,7 +55,7 @@ class MessagesModule extends import_module.ReExportTypeModule {
54
55
  ([messageName, message]) => MessageModule.create(messageName, message)
55
56
  );
56
57
  const inst = new MessagesModule({
57
- exportName: "Messages"
58
+ exportName: strings.typeName("messages")
58
59
  });
59
60
  inst.pushDep(...messageModules);
60
61
  return inst;
@@ -69,9 +70,10 @@ class ChannelModule extends import_module.Module {
69
70
  static async create(channelName, channel) {
70
71
  const messagesModule = await MessagesModule.create(channel);
71
72
  messagesModule.unshift("messages");
73
+ const exportName = strings.typeName(channelName);
72
74
  const inst = new ChannelModule(messagesModule, channel, {
73
75
  path: import_const.INDEX_FILE,
74
- exportName: `Channel${import_utils.casing.to.pascalCase(channelName)}`,
76
+ exportName,
75
77
  content: ""
76
78
  });
77
79
  inst.pushDep(messagesModule);
@@ -99,7 +101,8 @@ class ChannelsModule extends import_module.ReExportTypeModule {
99
101
  const mod = await ChannelModule.create(channelName, channel);
100
102
  return mod.unshift(channelName);
101
103
  });
102
- const inst = new ChannelsModule({ exportName: "Channels" });
104
+ const exportName = strings.typeName("channels");
105
+ const inst = new ChannelsModule({ exportName });
103
106
  inst.pushDep(...channelModules);
104
107
  return inst;
105
108
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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,8CAA2B,QAAQ,IAAI;AAAA,IACxD;AACA,WAAO,IAAI,cAAc,GAAG;AAAA,EAC9B;AACF;AAEO,MAAM,uBAAuB,iCAAmB;AAAA,EACrD,aAAoB,OAAO,SAA2D;AACpF,UAAM,WAAW,QAAQ,YAAY,CAAC;AACtC,UAAM,iBAAiB,MAAM,gBAAAA,QAAS;AAAA,MAAI,OAAO,QAAQ,QAAQ;AAAA,MAAG,CAAC,CAAC,aAAa,OAAO,MACxF,cAAc,OAAO,aAAa,OAAO;AAAA,IAC3C;AAEA,UAAM,OAAO,IAAI,eAAe;AAAA,MAC9B,YAAY;AAAA,IACd,CAAC;AACD,SAAK,QAAQ,GAAG,cAAc;AAC9B,WAAO;AAAA,EACT;AACF;AAEO,MAAM,sBAAsB,qBAAO;AAAA,EAehC,YAAoB,gBAAuC,SAAkC,KAAgB;AACnH,UAAM,GAAG;AADiB;AAAuC;AAAA,EAEnE;AAAA,EAhBA,aAAoB,OAAO,aAAqB,SAA0D;AACxG,UAAM,iBAAiB,MAAM,eAAe,OAAO,OAAO;AAC1D,mBAAe,QAAQ,UAAU;AAEjC,UAAM,OAAO,IAAI,cAAc,gBAAgB,SAAS;AAAA,MACtD,MAAM;AAAA,MACN,YAAY,UAAU,oBAAO,GAAG,WAAW,WAAW;AAAA,MACtD,SAAS;AAAA,IACX,CAAC;AAED,SAAK,QAAQ,cAAc;AAC3B,WAAO;AAAA,EACT;AAAA,EAMA,IAAoB,UAAU;AAC5B,UAAM,EAAE,eAAe,IAAI;AAC3B,UAAM,gBAAgB,eAAe,OAAO,IAAI;AAEhD,WAAO;AAAA,MACL;AAAA,MACA,YAAY,eAAe,qBAAqB;AAAA,MAChD,oBAAoB;AAAA,MACpB;AAAA,MACA,eAAe,KAAK;AAAA,MACpB,eAAe,eAAe;AAAA,MAC9B,kBAAc,uCAAoB,KAAK,QAAQ,OAAO;AAAA,MACtD,uBAAmB,uCAAoB,KAAK,QAAQ,YAAY;AAAA,MAChE;AAAA,IACF,EAAE,KAAK,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;",
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { GENERATED_HEADER, INDEX_FILE } from '../const'\nimport { jsonSchemaToTypeScriptType, stringifySingleLine } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\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 exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\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: strings.typeName('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 exportName = strings.typeName(channelName)\n const inst = new ChannelModule(messagesModule, channel, {\n path: INDEX_FILE,\n exportName,\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\n const exportName = strings.typeName('channels')\n const inst = new ChannelsModule({ exportName })\n inst.pushDep(...channelModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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I;AAC3B,UAAM,gBAAgB,eAAe,OAAO,IAAI;AAEhD,WAAO;AAAA,MACL;AAAA,MACA,YAAY,eAAe,qBAAqB;AAAA,MAChD,oBAAoB;AAAA,MACpB;AAAA,MACA,eAAe,KAAK;AAAA,MACpB,eAAe,eAAe;AAAA,MAC9B,kBAAc,uCAAoB,KAAK,QAAQ,OAAO;AAAA,MACtD,uBAAmB,uCAAoB,KAAK,QAAQ,YAAY;AAAA,MAChE;AAAA,IACF,EAAE,KAAK,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;AAED,UAAM,aAAa,QAAQ,SAAS,UAAU;AAC9C,UAAM,OAAO,IAAI,eAAe,EAAE,WAAW,CAAC;AAC9C,SAAK,QAAQ,GAAG,cAAc;AAC9B,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["bluebird"]
7
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,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
18
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
25
  var configuration_module_exports = {};
20
26
  __export(configuration_module_exports, {
@@ -24,6 +30,7 @@ module.exports = __toCommonJS(configuration_module_exports);
24
30
  var import_const = require("../const");
25
31
  var import_generators = require("../generators");
26
32
  var import_module = require("../module");
33
+ var strings = __toESM(require("../strings"));
27
34
  class ConfigurationModule extends import_module.Module {
28
35
  static async create(configuration) {
29
36
  const { schema } = configuration;
@@ -35,10 +42,11 @@ class ConfigurationModule extends import_module.Module {
35
42
  });
36
43
  }
37
44
  const name = "configuration";
45
+ const exportName = strings.typeName(name);
38
46
  return new ConfigurationModule({
39
47
  path: import_const.INDEX_FILE,
40
- exportName: "Configuration",
41
- content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
48
+ exportName,
49
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
42
50
  });
43
51
  }
44
52
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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\n if (!schema) {\n return new ConfigurationModule({\n path: INDEX_FILE,\n exportName: 'Configuration',\n content: 'export type Configuration = Record<string, never>;',\n })\n }\n\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,EAAE,OAAO,IAAI;AACnB,QAAI,CAAC,QAAQ;AACX,aAAO,IAAI,oBAAoB;AAAA,QAC7B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAEA,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;",
4
+ "sourcesContent": ["import { INDEX_FILE } from '../const'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module } from '../module'\nimport * as strings from '../strings'\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\n if (!schema) {\n return new ConfigurationModule({\n path: INDEX_FILE,\n exportName: 'Configuration',\n content: 'export type Configuration = Record<string, never>;',\n })\n }\n\n const name = 'configuration'\n\n const exportName = strings.typeName(name)\n return new ConfigurationModule({\n path: INDEX_FILE,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\n })\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAC3B,wBAA2C;AAC3C,oBAAuB;AACvB,cAAyB;AAGlB,MAAM,4BAA4B,qBAAO;AAAA,EAC9C,aAAoB,OAAO,eAA4E;AACrG,UAAM,EAAE,OAAO,IAAI;AACnB,QAAI,CAAC,QAAQ;AACX,aAAO,IAAI,oBAAoB;AAAA,QAC7B,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,SAAS;AAAA,MACX,CAAC;AAAA,IACH;AAEA,UAAM,OAAO;AAEb,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,WAAO,IAAI,oBAAoB;AAAA,MAC7B,MAAM;AAAA,MACN;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -29,16 +29,18 @@ __export(events_module_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(events_module_exports);
31
31
  var import_bluebird = __toESM(require("bluebird"));
32
- var import_utils = require("../../utils");
33
32
  var import_generators = require("../generators");
34
33
  var import_module = require("../module");
34
+ var strings = __toESM(require("../strings"));
35
35
  class EventModule extends import_module.Module {
36
36
  static async create(name, event) {
37
+ const eventName = name;
37
38
  const schema = event.schema;
39
+ const exportName = strings.typeName(eventName);
38
40
  const def = {
39
41
  path: `${name}.ts`,
40
- exportName: import_utils.casing.to.pascalCase(name),
41
- content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
42
+ exportName,
43
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
42
44
  };
43
45
  return new EventModule(def);
44
46
  }
@@ -50,7 +52,7 @@ class EventsModule extends import_module.ReExportTypeModule {
50
52
  async ([eventName, event]) => EventModule.create(eventName, event)
51
53
  );
52
54
  const inst = new EventsModule({
53
- exportName: "Events"
55
+ exportName: strings.typeName("events")
54
56
  });
55
57
  inst.pushDep(...eventModules);
56
58
  return inst;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\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 eventName = name\n const schema = event.schema\n const exportName = strings.typeName(eventName)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\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: strings.typeName('events'),\n })\n inst.pushDep(...eventModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,wBAA2C;AAC3C,oBAAsD;AACtD,cAAyB;AAGlB,MAAM,oBAAoB,qBAAO;AAAA,EACtC,aAAoB,OAAO,MAAc,OAAoD;AAC3F,UAAM,YAAY;AAClB,UAAM,SAAS,MAAM;AACrB,UAAM,aAAa,QAAQ,SAAS,SAAS;AAC7C,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;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,QAAQ,SAAS,QAAQ;AAAA,IACvC,CAAC;AACD,SAAK,QAAQ,GAAG,YAAY;AAC5B,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["bluebird"]
7
7
  }
@@ -29,16 +29,17 @@ __export(states_module_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(states_module_exports);
31
31
  var import_bluebird = __toESM(require("bluebird"));
32
- var import_utils = require("../../utils");
33
32
  var import_generators = require("../generators");
34
33
  var import_module = require("../module");
34
+ var strings = __toESM(require("../strings"));
35
35
  class StateModule extends import_module.Module {
36
36
  static async create(name, state) {
37
37
  const schema = state.schema;
38
+ const exportName = strings.typeName(name);
38
39
  const def = {
39
40
  path: `${name}.ts`,
40
- exportName: import_utils.casing.to.pascalCase(name),
41
- content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, name)
41
+ exportName,
42
+ content: await (0, import_generators.jsonSchemaToTypeScriptType)(schema, exportName)
42
43
  };
43
44
  return new StateModule(def);
44
45
  }
@@ -50,7 +51,7 @@ class StatesModule extends import_module.ReExportTypeModule {
50
51
  async ([stateName, state]) => StateModule.create(stateName, state)
51
52
  );
52
53
  const inst = new StatesModule({
53
- exportName: "States"
54
+ exportName: strings.typeName("states")
54
55
  });
55
56
  inst.pushDep(...stateModules);
56
57
  return inst;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
4
+ "sourcesContent": ["import bluebird from 'bluebird'\nimport { jsonSchemaToTypeScriptType } from '../generators'\nimport { Module, ModuleDef, ReExportTypeModule } from '../module'\nimport * as strings from '../strings'\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 exportName = strings.typeName(name)\n const def: ModuleDef = {\n path: `${name}.ts`,\n exportName,\n content: await jsonSchemaToTypeScriptType(schema, exportName),\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: strings.typeName('states'),\n })\n inst.pushDep(...stateModules)\n return inst\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,wBAA2C;AAC3C,oBAAsD;AACtD,cAAyB;AAGlB,MAAM,oBAAoB,qBAAO;AAAA,EACtC,aAAoB,OAAO,MAAc,OAAoD;AAC3F,UAAM,SAAS,MAAM;AACrB,UAAM,aAAa,QAAQ,SAAS,IAAI;AACxC,UAAM,MAAiB;AAAA,MACrB,MAAM,GAAG;AAAA,MACT;AAAA,MACA,SAAS,UAAM,8CAA2B,QAAQ,UAAU;AAAA,IAC9D;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,QAAQ,SAAS,QAAQ;AAAA,IACvC,CAAC;AACD,SAAK,QAAQ,GAAG,YAAY;AAC5B,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["bluebird"]
7
7
  }
@@ -30,32 +30,34 @@ module.exports = __toCommonJS(map_integration_exports);
30
30
  var utils = __toESM(require("../utils"));
31
31
  var from;
32
32
  ((from2) => {
33
- from2.sdk = (i) => ({
34
- id: null,
35
- name: i.name,
36
- version: i.version,
37
- user: {
38
- tags: i.user?.tags ?? {},
39
- creation: i.user?.creation ?? { enabled: false, requiredTags: [] }
40
- },
41
- configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },
42
- events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},
43
- states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},
44
- actions: i.actions ? utils.records.mapValues(i.actions, (a) => ({
45
- input: _mapSchema(a.input),
46
- output: _mapSchema(a.output)
47
- })) : {},
48
- channels: i.channels ? utils.records.mapValues(i.channels, (c) => ({
49
- conversation: {
50
- tags: c.conversation?.tags ?? {},
51
- creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] }
33
+ from2.sdk = (i) => {
34
+ return {
35
+ id: null,
36
+ name: i.name,
37
+ version: i.version,
38
+ user: {
39
+ tags: i.user?.tags ?? {},
40
+ creation: i.user?.creation ?? { enabled: false, requiredTags: [] }
52
41
  },
53
- message: {
54
- tags: c.message?.tags ?? {}
55
- },
56
- messages: utils.records.mapValues(c.messages, _mapSchema)
57
- })) : {}
58
- });
42
+ configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },
43
+ events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},
44
+ states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},
45
+ actions: i.actions ? utils.records.mapValues(i.actions, (a) => ({
46
+ input: _mapSchema(a.input),
47
+ output: _mapSchema(a.output)
48
+ })) : {},
49
+ channels: i.channels ? utils.records.mapValues(i.channels, (c) => ({
50
+ conversation: {
51
+ tags: c.conversation?.tags ?? {},
52
+ creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] }
53
+ },
54
+ message: {
55
+ tags: c.message?.tags ?? {}
56
+ },
57
+ messages: utils.records.mapValues(c.messages, _mapSchema)
58
+ })) : {}
59
+ };
60
+ };
59
61
  from2.client = (i) => {
60
62
  const { id, name, version, configuration, channels, states, events, actions, user } = i;
61
63
  return { id, name, version, configuration, channels, states, events, actions, user };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/code-generation/map-integration.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => ({\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n })\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, channels, states, events, actions, user } = i\n return { id, name, version, configuration, channels, states, events, actions, user }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,OAA+D;AAAA,IACjF,IAAI;AAAA,IACJ,MAAM,EAAE;AAAA,IACR,SAAS,EAAE;AAAA,IACX,MAAM;AAAA,MACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,MACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,IACnE;AAAA,IACA,eAAe,EAAE,gBAAgB,WAAW,EAAE,aAAa,IAAI,EAAE,QAAQ,CAAC,EAAE;AAAA,IAC5E,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,IACpE,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,IACpE,SAAS,EAAE,UACP,MAAM,QAAQ,UAAU,EAAE,SAAS,CAAC,OAAO;AAAA,MACzC,OAAO,WAAW,EAAE,KAAK;AAAA,MACzB,QAAQ,WAAW,EAAE,MAAM;AAAA,IAC7B,EAAE,IACF,CAAC;AAAA,IACL,UAAU,EAAE,WACR,MAAM,QAAQ,UAAU,EAAE,UAAU,CAAC,OAAO;AAAA,MAC1C,cAAc;AAAA,QACZ,MAAM,EAAE,cAAc,QAAQ,CAAC;AAAA,QAC/B,UAAU,EAAE,cAAc,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MAC3E;AAAA,MACA,SAAS;AAAA,QACP,MAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,MAC5B;AAAA,MACA,UAAU,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU;AAAA,IAC1D,EAAE,IACF,CAAC;AAAA,EACP;AAEO,EAAMA,MAAA,SAAS,CAAC,MAAuD;AAC5E,UAAM,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,KAAK,IAAI;AACtF,WAAO,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,KAAK;AAAA,EACrF;AAEA,QAAM,aAAa,CACjB,OAC0F;AAAA,IAC1F,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,CAAC;AAAA,EAC3C;AAAA,GA1Ce;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport { z } from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './typings'\n\nexport namespace from {\n export const sdk = (i: sdk.IntegrationDefinition): types.IntegrationDefinition => {\n return {\n id: null,\n name: i.name,\n version: i.version,\n user: {\n tags: i.user?.tags ?? {},\n creation: i.user?.creation ?? { enabled: false, requiredTags: [] },\n },\n configuration: i.configuration ? _mapSchema(i.configuration) : { schema: {} },\n events: i.events ? utils.records.mapValues(i.events, _mapSchema) : {},\n states: i.states ? utils.records.mapValues(i.states, _mapSchema) : {},\n actions: i.actions\n ? utils.records.mapValues(i.actions, (a) => ({\n input: _mapSchema(a.input),\n output: _mapSchema(a.output),\n }))\n : {},\n channels: i.channels\n ? utils.records.mapValues(i.channels, (c) => ({\n conversation: {\n tags: c.conversation?.tags ?? {},\n creation: c.conversation?.creation ?? { enabled: false, requiredTags: [] },\n },\n message: {\n tags: c.message?.tags ?? {},\n },\n messages: utils.records.mapValues(c.messages, _mapSchema),\n }))\n : {},\n }\n }\n\n export const client = (i: client.Integration): types.IntegrationDefinition => {\n const { id, name, version, configuration, channels, states, events, actions, user } = i\n return { id, name, version, configuration, channels, states, events, actions, user }\n }\n\n const _mapSchema = <T extends { schema: z.ZodObject<any> }>(\n x: T\n ): utils.types.Merge<T, { schema: ReturnType<typeof utils.schema.mapZodToJsonSchema> }> => ({\n ...x,\n schema: utils.schema.mapZodToJsonSchema(x),\n })\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB;AAGhB,IAAU;AAAA,CAAV,CAAUA,UAAV;AACE,EAAMA,MAAA,MAAM,CAAC,MAA8D;AAChF,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,MAAM,EAAE;AAAA,MACR,SAAS,EAAE;AAAA,MACX,MAAM;AAAA,QACJ,MAAM,EAAE,MAAM,QAAQ,CAAC;AAAA,QACvB,UAAU,EAAE,MAAM,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,MACnE;AAAA,MACA,eAAe,EAAE,gBAAgB,WAAW,EAAE,aAAa,IAAI,EAAE,QAAQ,CAAC,EAAE;AAAA,MAC5E,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,QAAQ,EAAE,SAAS,MAAM,QAAQ,UAAU,EAAE,QAAQ,UAAU,IAAI,CAAC;AAAA,MACpE,SAAS,EAAE,UACP,MAAM,QAAQ,UAAU,EAAE,SAAS,CAAC,OAAO;AAAA,QACzC,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,QAAQ,WAAW,EAAE,MAAM;AAAA,MAC7B,EAAE,IACF,CAAC;AAAA,MACL,UAAU,EAAE,WACR,MAAM,QAAQ,UAAU,EAAE,UAAU,CAAC,OAAO;AAAA,QAC1C,cAAc;AAAA,UACZ,MAAM,EAAE,cAAc,QAAQ,CAAC;AAAA,UAC/B,UAAU,EAAE,cAAc,YAAY,EAAE,SAAS,OAAO,cAAc,CAAC,EAAE;AAAA,QAC3E;AAAA,QACA,SAAS;AAAA,UACP,MAAM,EAAE,SAAS,QAAQ,CAAC;AAAA,QAC5B;AAAA,QACA,UAAU,MAAM,QAAQ,UAAU,EAAE,UAAU,UAAU;AAAA,MAC1D,EAAE,IACF,CAAC;AAAA,IACP;AAAA,EACF;AAEO,EAAMA,MAAA,SAAS,CAAC,MAAuD;AAC5E,UAAM,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,KAAK,IAAI;AACtF,WAAO,EAAE,IAAI,MAAM,SAAS,eAAe,UAAU,QAAQ,QAAQ,SAAS,KAAK;AAAA,EACrF;AAEA,QAAM,aAAa,CACjB,OAC0F;AAAA,IAC1F,GAAG;AAAA,IACH,QAAQ,MAAM,OAAO,mBAAmB,CAAC;AAAA,EAC3C;AAAA,GA5Ce;",
6
6
  "names": ["from"]
7
7
  }
@@ -31,6 +31,7 @@ module.exports = __toCommonJS(module_exports);
31
31
  var import_path = require("path");
32
32
  var utils = __toESM(require("../utils"));
33
33
  var import_const = require("./const");
34
+ var strings = __toESM(require("./strings"));
34
35
  class Module {
35
36
  constructor(_def) {
36
37
  this._def = _def;
@@ -46,10 +47,10 @@ class Module {
46
47
  const basename = import_path.posix.basename(this.path);
47
48
  if (basename === import_const.INDEX_FILE) {
48
49
  const dirname = import_path.posix.basename(import_path.posix.dirname(this.path));
49
- return utils.casing.to.camelCase(dirname);
50
+ return dirname;
50
51
  }
51
52
  const withoutExtension = utils.path.rmExtension(basename);
52
- return utils.casing.to.camelCase(withoutExtension);
53
+ return withoutExtension;
53
54
  }
54
55
  get exports() {
55
56
  return this._def.exportName;
@@ -88,20 +89,21 @@ class ReExportTypeModule extends Module {
88
89
  }
89
90
  get content() {
90
91
  let content = import_const.GENERATED_HEADER;
91
- const dependencies = this.deps;
92
- for (const m of dependencies) {
92
+ for (const m of this.deps) {
93
93
  const { name } = m;
94
+ const importAlias = strings.importAlias(name);
94
95
  const importFrom = m.import(this);
95
- content += `import * as ${name} from "./${importFrom}";
96
+ content += `import * as ${importAlias} from "./${importFrom}";
96
97
  `;
97
- content += `export * as ${name} from "./${importFrom}";
98
+ content += `export * as ${importAlias} from "./${importFrom}";
98
99
  `;
99
100
  }
100
101
  content += "\n";
101
102
  content += `export type ${this.exports} = {
102
103
  `;
103
104
  for (const { name, exports } of this.deps) {
104
- content += ` ${name}: ${name}.${exports};
105
+ const importAlias = strings.importAlias(name);
106
+ content += ` "${name}": ${importAlias}.${exports};
105
107
  `;
106
108
  }
107
109
  content += "}";
@@ -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 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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A,EACH;AAAA,EAEA,IAAoB,UAAkB;AACpC,QAAI,UAAU;AACd,UAAM,eAAe,KAAK;AAE1B,eAAW,KAAK,cAAc;AAC5B,YAAM,EAAE,KAAK,IAAI;AACjB,YAAM,aAAa,EAAE,OAAO,IAAI;AAChC,iBAAW,eAAe,gBAAgB;AAAA;AAC1C,iBAAW,eAAe,gBAAgB;AAAA;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;",
4
+ "sourcesContent": ["import { posix as pathlib } from 'path'\nimport * as utils from '../utils'\nimport { GENERATED_HEADER, INDEX_FILE } from './const'\nimport * as strings from './strings'\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 /**\n * @returns file name without extension\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 dirname\n }\n const withoutExtension = utils.path.rmExtension(basename)\n return 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\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.exports} = {\\n`\n for (const { name, 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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiC;AACjC,YAAuB;AACvB,mBAA6C;AAC7C,cAAyB;AAOlB,MAAe,OAAuB;AAAA,EAgCjC,YAAoB,MAAiB;AAAjB;AAAA,EAAkB;AAAA,EA/BxC,qBAA+B,CAAC;AAAA,EAExC,IAAW,OAAe;AACxB,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,IAAW,UAAkB;AAC3B,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAKA,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;AAAA,IACT;AACA,UAAM,mBAAmB,MAAM,KAAK,YAAY,QAAQ;AACxD,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,UAAkB;AAC3B,WAAO,KAAK,KAAK;AAAA,EACnB;AAAA,EAEA,IAAW,OAAiB;AAC1B,WAAO,CAAC,GAA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Y,IAAI;AAC5C,iBAAW,MAAM,UAAU,eAAe;AAAA;AAAA,IAC5C;AACA,eAAW;AAEX,eAAW;AAEX,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["pathlib"]
7
7
  }
@@ -0,0 +1,40 @@
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 strings_exports = {};
26
+ __export(strings_exports, {
27
+ importAlias: () => importAlias,
28
+ typeName: () => typeName
29
+ });
30
+ module.exports = __toCommonJS(strings_exports);
31
+ var utils = __toESM(require("../utils"));
32
+ const apply = (str, ...transforms) => transforms.reduce((acc, transform) => transform(acc), str);
33
+ const typeName = (name) => apply(name, utils.casing.to.pascalCase);
34
+ const importAlias = (name) => apply(name, utils.casing.to.camelCase);
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ importAlias,
38
+ typeName
39
+ });
40
+ //# sourceMappingURL=strings.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/code-generation/strings.ts"],
4
+ "sourcesContent": ["import * as utils from '../utils'\ntype StrTransform = (str: string) => string\n\nconst apply = (str: string, ...transforms: StrTransform[]) => transforms.reduce((acc, transform) => transform(acc), str)\n\nexport const typeName = (name: string) => apply(name, utils.casing.to.pascalCase)\nexport const importAlias = (name: string) => apply(name, utils.casing.to.camelCase)\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AAGvB,MAAM,QAAQ,CAAC,QAAgB,eAA+B,WAAW,OAAO,CAAC,KAAK,cAAc,UAAU,GAAG,GAAG,GAAG;AAEhH,MAAM,WAAW,CAAC,SAAiB,MAAM,MAAM,MAAM,OAAO,GAAG,UAAU;AACzE,MAAM,cAAc,CAAC,SAAiB,MAAM,MAAM,MAAM,OAAO,GAAG,SAAS;",
6
+ "names": []
7
+ }
@@ -283,7 +283,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
283
283
  throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg);
284
284
  }
285
285
  const newName2 = `${remoteHandle}/${localName}`;
286
- return { ...integration, name: newName2 };
286
+ return integration.clone({ name: newName2 });
287
287
  }
288
288
  if (localHandle && !remoteHandle) {
289
289
  const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {
@@ -323,7 +323,7 @@ class DeployCommand extends import_project_command.ProjectCommand {
323
323
  } while (!claimedHandle);
324
324
  this.logger.success(`Handle "${claimedHandle}" is yours!`);
325
325
  const newName = `${claimedHandle}/${localName}`;
326
- return { ...integration, name: newName };
326
+ return integration.clone({ name: newName });
327
327
  }
328
328
  _parseIntegrationName = (integrationName) => {
329
329
  const parts = integrationName.split("/");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/deploy-command.ts"],
4
- "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n prepareUpdateIntegrationBody,\n CreateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n return this._deployIntegration(api, integrationDef)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const {\n name,\n version,\n icon: iconRelativeFilePath,\n readme: readmeRelativeFilePath,\n identifier,\n configuration,\n } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this._readFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this._readFile(identifier?.fallbackHandlerScript)\n const identifierLinkTemplateFileContent = await this._readFile(configuration?.identifier?.linkTemplateScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will overwrite the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n let createBody: CreateIntegrationBody = prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: {\n ...createBody.configuration,\n identifier: {\n ...(createBody.configuration?.identifier ?? {}),\n linkTemplateScript: identifierLinkTemplateFileContent,\n },\n },\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const createSecrets = await this.promptSecrets(integrationDef, this.argv)\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n this._detectDeprecatedFeatures(integrationDef, this.argv)\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readFile = async (filePath: string | undefined): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'utf-8').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...prepareCreateBotBody(botImpl),\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return integration // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return { ...integration, name: newName }\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return integration\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return { ...integration, name: newName }\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AACpB,sBAA2D;AAE3D,8BAIO;AAEP,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK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AAY,KAAK,IAAI,GAAG;AAChG;AAAA,MACF;AAEA,sBAAgB;AAChB,YAAM,IAAI,gBAAgB,EAAE,QAAQ,cAAc,CAAC,EAAE,MAAM,CAAC,WAAW;AACrE,cAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B,gBAAgB;AAAA,MACxF,CAAC;AAAA,IACH,SAAS,CAAC;AAEV,SAAK,OAAO,QAAQ,WAAW,0BAA0B;AACzD,UAAM,UAAU,GAAG,iBAAiB;AACpC,WAAO,EAAE,GAAG,aAAa,MAAM,QAAQ;AAAA,EACzC;AAAA,EAEQ,wBAAwB,CAAC,oBAAwE;AACvG,UAAM,QAAQ,gBAAgB,MAAM,GAAG;AACvC,QAAI,MAAM,SAAS,GAAG;AACpB,YAAM,IAAI,OAAO;AAAA,QACf,6BAA6B;AAAA,MAC/B;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport chalk from 'chalk'\nimport * as fs from 'fs'\nimport { prepareCreateBotBody, prepareUpdateBotBody } from '../api/bot-body'\nimport type { ApiClient } from '../api/client'\nimport {\n prepareUpdateIntegrationBody,\n CreateIntegrationBody,\n prepareCreateIntegrationBody,\n} from '../api/integration-body'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { BuildCommand } from './build-command'\nimport { ProjectCommand } from './project-command'\n\nexport type DeployCommandDefinition = typeof commandDefinitions.deploy\nexport class DeployCommand extends ProjectCommand<DeployCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n if (!this.argv.noBuild) {\n await this._runBuild() // This ensures the bundle is always synced with source code\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n return this._deployIntegration(api, integrationDef)\n }\n return this._deployBot(api, this.argv.botId, this.argv.createNewBot)\n }\n\n private async _runBuild() {\n return new BuildCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private async _deployIntegration(api: ApiClient, integrationDef: sdk.IntegrationDefinition) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n\n integrationDef = await this._manageWorkspaceHandle(api, integrationDef)\n\n const {\n name,\n version,\n icon: iconRelativeFilePath,\n readme: readmeRelativeFilePath,\n identifier,\n configuration,\n } = integrationDef\n\n if (iconRelativeFilePath && !iconRelativeFilePath.toLowerCase().endsWith('.svg')) {\n throw new errors.BotpressCLIError('Icon must be an SVG file')\n }\n\n const iconFileContent = await this._readMediaFile('icon', iconRelativeFilePath)\n const readmeFileContent = await this._readMediaFile('readme', readmeRelativeFilePath)\n const identifierExtractScriptFileContent = await this._readFile(identifier?.extractScript)\n const fallbackHandlerScriptFileContent = await this._readFile(identifier?.fallbackHandlerScript)\n const identifierLinkTemplateFileContent = await this._readFile(configuration?.identifier?.linkTemplateScript)\n\n const integration = await api.findIntegration({ type: 'name', name, version })\n if (integration && integration.workspaceId !== api.workspaceId) {\n throw new errors.BotpressCLIError(\n `Public integration ${name} v${version} is already deployed in another workspace.`\n )\n }\n\n if (integration && integration.public && !api.isBotpressWorkspace) {\n throw new errors.BotpressCLIError(\n `Integration ${name} v${version} is already deployed publicly and cannot be updated. Please bump the version.`\n )\n }\n\n let message: string\n if (integration) {\n this.logger.warn('Integration already exists. If you decide to deploy, it will overwrite the existing one.')\n message = `Are you sure you want to override integration ${name} v${version}?`\n } else {\n message = `Are you sure you want to deploy integration ${name} v${version}?`\n }\n\n const confirm = await this.prompt.confirm(message)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n let createBody: CreateIntegrationBody = prepareCreateIntegrationBody(integrationDef)\n createBody = {\n ...createBody,\n code,\n icon: iconFileContent,\n readme: readmeFileContent,\n configuration: {\n ...createBody.configuration,\n identifier: {\n ...(createBody.configuration?.identifier ?? {}),\n linkTemplateScript: identifierLinkTemplateFileContent,\n },\n },\n identifier: {\n extractScript: identifierExtractScriptFileContent,\n fallbackHandlerScript: fallbackHandlerScriptFileContent,\n },\n public: this.argv.public,\n }\n\n const startedMessage = `Deploying integration ${chalk.bold(name)} v${version}...`\n const successMessage = 'Integration deployed'\n if (integration) {\n const updateBody = prepareUpdateIntegrationBody(\n {\n id: integration.id,\n ...createBody,\n public: this.argv.public,\n },\n integration\n )\n\n const { secrets: knownSecrets } = integration\n updateBody.secrets = await this.promptSecrets(integrationDef, this.argv, { knownSecrets })\n this._detectDeprecatedFeatures(integrationDef, { allowDeprecated: true })\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.updateIntegration(updateBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update integration \"${name}\"`)\n })\n line.success(successMessage)\n } else {\n const createSecrets = await this.promptSecrets(integrationDef, this.argv)\n createBody.secrets = utils.records.filterValues(createSecrets, utils.guards.is.notNull)\n this._detectDeprecatedFeatures(integrationDef, this.argv)\n\n const line = this.logger.line()\n line.started(startedMessage)\n await api.client.createIntegration(createBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not create integration \"${name}\"`)\n })\n line.success(successMessage)\n }\n }\n\n private _detectDeprecatedFeatures(\n integrationDef: sdk.IntegrationDefinition,\n opts: { allowDeprecated?: boolean } = {}\n ) {\n const deprecatedFields: string[] = []\n const { user, channels } = integrationDef\n if (user?.creation?.enabled) {\n deprecatedFields.push('user.creation')\n }\n\n for (const [channelName, channel] of Object.entries(channels ?? {})) {\n if (channel?.conversation?.creation?.enabled) {\n deprecatedFields.push(`channels.${channelName}.creation`)\n }\n }\n\n if (!deprecatedFields.length) {\n return\n }\n\n const errorMessage = `The following fields of the integration's definition are deprecated: ${deprecatedFields.join(\n ', '\n )}`\n\n if (opts.allowDeprecated) {\n this.logger.warn(errorMessage)\n } else {\n throw new errors.BotpressCLIError(errorMessage)\n }\n }\n\n private _readFile = async (filePath: string | undefined): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'utf-8').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\n }\n\n private _readMediaFile = async (\n filePurpose: 'icon' | 'readme',\n filePath: string | undefined\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, 'base64').catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read ${filePurpose} file \"${absoluteFilePath}\"`)\n })\n }\n\n private async _deployBot(api: ApiClient, argvBotId: string | undefined, argvCreateNew: boolean | undefined) {\n const outfile = this.projectPaths.abs.outFile\n const code = await fs.promises.readFile(outfile, 'utf-8')\n const { default: botImpl } = utils.require.requireJsFile<{ default: sdk.Bot }>(outfile)\n\n let bot: client.Bot\n if (argvBotId && argvCreateNew) {\n throw new errors.BotpressCLIError('Cannot specify both --botId and --createNew')\n } else if (argvCreateNew) {\n const confirm = await this.prompt.confirm('Are you sure you want to create a new bot ?')\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n\n bot = await this._createNewBot(api)\n } else {\n bot = await this._getExistingBot(api, argvBotId)\n\n const confirm = await this.prompt.confirm(`Are you sure you want to deploy the bot \"${bot.name}\"?`)\n if (!confirm) {\n this.logger.log('Aborted')\n return\n }\n }\n\n const line = this.logger.line()\n line.started(`Deploying bot ${chalk.bold(bot.name)}...`)\n\n const integrationInstances = await this.fetchBotIntegrationInstances(botImpl, api)\n const updateBotBody = prepareUpdateBotBody(\n {\n ...prepareCreateBotBody(botImpl),\n id: bot.id,\n code,\n integrations: integrationInstances,\n },\n bot\n )\n\n const { bot: updatedBot } = await api.client.updateBot(updateBotBody).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not update bot \"${bot.name}\"`)\n })\n line.success('Bot deployed')\n this.displayWebhookUrls(updatedBot)\n }\n\n private async _createNewBot(api: ApiClient): Promise<client.Bot> {\n const line = this.logger.line()\n const { bot: createdBot } = await api.client.createBot({}).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not create bot')\n })\n line.success(`Bot created with ID \"${createdBot.id}\" and name \"${createdBot.name}\"`)\n await this.projectCache.set('botId', createdBot.id)\n return createdBot\n }\n\n private async _getExistingBot(api: ApiClient, botId: string | undefined): Promise<client.Bot> {\n const promptedBotId = await this.projectCache.sync('botId', botId, async (defaultId) => {\n const userBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!userBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const initial = userBots.find((bot) => bot.id === defaultId)\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n })\n\n const { bot: fetchedBot } = await api.client.getBot({ id: promptedBotId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not get bot info')\n })\n\n return fetchedBot\n }\n\n private async _manageWorkspaceHandle(\n api: ApiClient,\n integration: sdk.IntegrationDefinition\n ): Promise<sdk.IntegrationDefinition> {\n const { name: localName, workspaceHandle: localHandle } = this._parseIntegrationName(integration.name)\n if (!localHandle && api.isBotpressWorkspace) {\n this.logger.debug('Botpress workspace detected; workspace handle omitted')\n return integration // botpress has the right to omit workspace handle\n }\n\n const { handle: remoteHandle, name: workspaceName } = await api.getWorkspace().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch workspace')\n })\n\n if (localHandle && remoteHandle) {\n if (localHandle !== remoteHandle) {\n throw new errors.BotpressCLIError(\n `Your current workspace handle is \"${remoteHandle}\" but the integration handle is \"${localHandle}\".`\n )\n }\n return integration\n }\n\n const workspaceHandleIsMandatoryMsg = 'Cannot deploy integration without workspace handle'\n\n if (!localHandle && remoteHandle) {\n const confirmAddHandle = await this.prompt.confirm(\n `Your current workspace handle is \"${remoteHandle}\". Do you want to use the name \"${remoteHandle}/${localName}\"?`\n )\n if (!confirmAddHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n const newName = `${remoteHandle}/${localName}`\n return integration.clone({ name: newName })\n }\n\n if (localHandle && !remoteHandle) {\n const { available } = await api.client.checkHandleAvailability({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not check handle availability')\n })\n\n if (!available) {\n throw new errors.BotpressCLIError(`Handle \"${localHandle}\" is not yours and is not available`)\n }\n\n const confirmClaimHandle = await this.prompt.confirm(\n `Handle \"${localHandle}\" is available. Do you want to claim it for your workspace ${workspaceName}?`\n )\n if (!confirmClaimHandle) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n await api.updateWorkspace({ handle: localHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${localHandle}\"`)\n })\n\n this.logger.success(`Handle \"${localHandle}\" is now yours!`)\n return integration\n }\n\n this.logger.warn(\"It seems you don't have a workspace handle yet.\")\n let claimedHandle: string | undefined = undefined\n do {\n const prompted = await this.prompt.text('Please enter a workspace handle')\n if (!prompted) {\n throw new errors.BotpressCLIError(workspaceHandleIsMandatoryMsg)\n }\n\n const { available, suggestions } = await api.client.checkHandleAvailability({ handle: prompted })\n if (!available) {\n this.logger.warn(`Handle \"${prompted}\" is not available. Suggestions: ${suggestions.join(', ')}`)\n continue\n }\n\n claimedHandle = prompted\n await api.updateWorkspace({ handle: claimedHandle }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not claim handle \"${claimedHandle}\"`)\n })\n } while (!claimedHandle)\n\n this.logger.success(`Handle \"${claimedHandle}\" is yours!`)\n const newName = `${claimedHandle}/${localName}`\n return integration.clone({ name: newName })\n }\n\n private _parseIntegrationName = (integrationName: string): { name: string; workspaceHandle?: string } => {\n const parts = integrationName.split('/')\n if (parts.length > 2) {\n throw new errors.BotpressCLIError(\n `Invalid integration name \"${integrationName}\": a single forward slash is allowed`\n )\n }\n if (parts.length === 2) {\n const [workspaceHandle, name] = parts as [string, string]\n return { name, workspaceHandle }\n }\n const [name] = parts as [string]\n return { name }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkB;AAClB,SAAoB;AACpB,sBAA2D;AAE3D,8BAIO;AAEP,aAAwB;AACxB,YAAuB;AACvB,2BAA6B;AAC7B,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAE3D,QAAI,CAAC,KAAK,KAAK,SAAS;AACtB,YAAM,KAAK,UAAU;AAAA,IACvB;AAEA,UAAM,iBAAiB,MAAM,KAAK,gCAAgC;AAClE,QAAI,gBAAgB;AAClB,aAAO,KAAK,mBAAmB,KAAK,cAAc;AAAA,IACpD;AACA,WAAO,KAAK,WAAW,KAAK,KAAK,KAAK,OAAO,KAAK,KAAK,YAAY;AAAA,EACrE;AAAA,EAEA,MAAc,YAAY;AACxB,WAAO,IAAI,kCAAa,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAC7E;AAAA,EAEA,MAAc,mBAAmB,KAAgB,gBAA2C;AAC1F,UAAM,UAAU,KAAK,aAAa,IAAI;AACtC,UA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AAM,IAAI,OAAO;AAAA,QACf,6BAA6B;AAAA,MAC/B;AAAA,IACF;AACA,QAAI,MAAM,WAAW,GAAG;AACtB,YAAM,CAAC,iBAAiBC,KAAI,IAAI;AAChC,aAAO,EAAE,MAAAA,OAAM,gBAAgB;AAAA,IACjC;AACA,UAAM,CAAC,IAAI,IAAI;AACf,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;",
6
6
  "names": ["chalk", "newName", "name"]
7
7
  }
@@ -29,11 +29,21 @@ __export(case_utils_exports, {
29
29
  });
30
30
  module.exports = __toCommonJS(case_utils_exports);
31
31
  var import_lodash = __toESM(require("lodash"));
32
+ const specialChars = /[^a-zA-Z0-9_-]/g;
32
33
  const capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();
33
34
  const splitChar = (char) => (tokens) => tokens.flatMap((token) => token.split(char));
35
+ const splitRegex = (regex) => (tokens) => tokens.flatMap((token) => token.split(regex));
34
36
  const splitCaseChange = (tokens) => tokens.flatMap((token) => token.split(/(?<=[a-z])(?=[A-Z])/));
35
37
  const splitTokens = (tokens) => {
36
- return [splitChar("/"), splitChar("-"), splitChar("_"), splitCaseChange].reduce((acc, step) => step(acc), tokens);
38
+ return [splitRegex(specialChars), splitChar("-"), splitChar("_"), splitCaseChange].reduce(
39
+ (acc, step) => step(acc),
40
+ tokens
41
+ );
42
+ };
43
+ const filterOutEmpty = (tokens) => tokens.filter((token) => token.length > 0);
44
+ const filterOutRegex = (regex) => (tokens) => tokens.filter((token) => !regex.test(token));
45
+ const filterTokens = (tokens) => {
46
+ return [filterOutEmpty, filterOutRegex(specialChars)].reduce((acc, step) => step(acc), tokens);
37
47
  };
38
48
  const fromTokens = {
39
49
  pascalCase: (tokens) => {
@@ -54,7 +64,8 @@ const fromTokens = {
54
64
  }
55
65
  };
56
66
  const to = import_lodash.default.mapValues(fromTokens, (fn) => (text) => {
57
- const tokens = splitTokens([text]);
67
+ let tokens = splitTokens([text]);
68
+ tokens = filterTokens(tokens);
58
69
  return fn(tokens);
59
70
  });
60
71
  const is = import_lodash.default.mapValues(to, (fn) => (text) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/case-utils.ts"],
4
- "sourcesContent": ["import _ from 'lodash'\n\nconst capitalizeFirstLetter = (text: string) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase()\n\nconst splitChar = (char: string) => (tokens: string[]) => tokens.flatMap((token) => token.split(char))\nconst splitCaseChange = (tokens: string[]) => tokens.flatMap((token) => token.split(/(?<=[a-z])(?=[A-Z])/))\nconst splitTokens = (tokens: string[]) => {\n return [splitChar('/'), splitChar('-'), splitChar('_'), splitCaseChange].reduce((acc, step) => step(acc), tokens)\n}\n\ntype SupportedCase = `${'pascal' | 'kebab' | 'snake' | 'screamingSnake' | 'camel'}Case`\n\nconst fromTokens = {\n pascalCase: (tokens: string[]) => {\n return tokens.map(capitalizeFirstLetter).join('')\n },\n kebabCase: (tokens: string[]) => {\n return tokens.map((token) => token.toLowerCase()).join('-')\n },\n snakeCase: (tokens: string[]) => {\n return tokens.map((token) => token.toLowerCase()).join('_')\n },\n screamingSnakeCase: (tokens: string[]) => {\n return tokens.map((token) => token.toUpperCase()).join('_')\n },\n camelCase: (tokens: string[]) => {\n const [first, ...others] = tokens\n return [first!.toLowerCase(), ...others.map(capitalizeFirstLetter)].join('')\n },\n} as Record<SupportedCase, (tokens: string[]) => string>\n\nexport const to = _.mapValues(fromTokens, (fn) => (text: string) => {\n const tokens = splitTokens([text])\n return fn(tokens)\n}) satisfies Record<SupportedCase, (text: string) => string>\n\nexport const is = _.mapValues(to, (fn) => (text: string) => {\n const result = fn(text)\n return result === text\n}) satisfies Record<SupportedCase, (text: string) => boolean>\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AAEd,MAAM,wBAAwB,CAAC,SAAiB,KAAK,OAAO,CAAC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,OAAO,CAAC,SAAiB;AAC1D,QAAM,SAAS,GAAG,IAAI;AACtB,SAAO,WAAW;AACpB,CAAC;",
4
+ "sourcesContent": ["import _ from 'lodash'\n\nconst specialChars = /[^a-zA-Z0-9_-]/g\n\nconst capitalizeFirstLetter = (text: string) => text.charAt(0).toUpperCase() + text.slice(1).toLowerCase()\n\nconst splitChar = (char: string) => (tokens: string[]) => tokens.flatMap((token) => token.split(char))\nconst splitRegex = (regex: RegExp) => (tokens: string[]) => tokens.flatMap((token) => token.split(regex))\nconst splitCaseChange = (tokens: string[]) => tokens.flatMap((token) => token.split(/(?<=[a-z])(?=[A-Z])/))\nconst splitTokens = (tokens: string[]) => {\n return [splitRegex(specialChars), splitChar('-'), splitChar('_'), splitCaseChange].reduce(\n (acc, step) => step(acc),\n tokens\n )\n}\n\nconst filterOutEmpty = (tokens: string[]) => tokens.filter((token) => token.length > 0)\nconst filterOutRegex = (regex: RegExp) => (tokens: string[]) => tokens.filter((token) => !regex.test(token))\nconst filterTokens = (tokens: string[]) => {\n return [filterOutEmpty, filterOutRegex(specialChars)].reduce((acc, step) => step(acc), tokens)\n}\n\ntype SupportedCase = `${'pascal' | 'kebab' | 'snake' | 'screamingSnake' | 'camel'}Case`\n\nconst fromTokens = {\n pascalCase: (tokens: string[]) => {\n return tokens.map(capitalizeFirstLetter).join('')\n },\n kebabCase: (tokens: string[]) => {\n return tokens.map((token) => token.toLowerCase()).join('-')\n },\n snakeCase: (tokens: string[]) => {\n return tokens.map((token) => token.toLowerCase()).join('_')\n },\n screamingSnakeCase: (tokens: string[]) => {\n return tokens.map((token) => token.toUpperCase()).join('_')\n },\n camelCase: (tokens: string[]) => {\n const [first, ...others] = tokens\n return [first!.toLowerCase(), ...others.map(capitalizeFirstLetter)].join('')\n },\n} as Record<SupportedCase, (tokens: string[]) => string>\n\nexport const to = _.mapValues(fromTokens, (fn) => (text: string) => {\n let tokens = splitTokens([text])\n tokens = filterTokens(tokens)\n return fn(tokens)\n}) satisfies Record<SupportedCase, (text: string) => string>\n\nexport const is = _.mapValues(to, (fn) => (text: string) => {\n const result = fn(text)\n return result === text\n}) satisfies Record<SupportedCase, (text: string) => boolean>\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAc;AAEd,MAAM,eAAe;AAErB,MAAM,wBAAwB,CAAC,SAAiB,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAEzG,MAAM,YAAY,CAAC,SAAiB,CAAC,WAAqB,OAAO,QAAQ,CAAC,UAAU,MAAM,MAAM,IAAI,CAAC;AACrG,MAAM,aAAa,CAAC,UAAkB,CAAC,WAAqB,OAAO,QAAQ,CAAC,UAAU,MAAM,MAAM,KAAK,CAAC;AACxG,MAAM,kBAAkB,CAAC,WAAqB,OAAO,QAAQ,CAAC,UAAU,MAAM,MAAM,qBAAqB,CAAC;AAC1G,MAAM,cAAc,CAAC,WAAqB;AACxC,SAAO,CAAC,WAAW,YAAY,GAAG,UAAU,GAAG,GAAG,UAAU,GAAG,GAAG,eAAe,EAAE;AAAA,IACjF,CAAC,KAAK,SAAS,KAAK,GAAG;AAAA,IACvB;AAAA,EACF;AACF;AAEA,MAAM,iBAAiB,CAAC,WAAqB,OAAO,OAAO,CAAC,UAAU,MAAM,SAAS,CAAC;AACtF,MAAM,iBAAiB,CAAC,UAAkB,CAAC,WAAqB,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC;AAC3G,MAAM,eAAe,CAAC,WAAqB;AACzC,SAAO,CAAC,gBAAgB,eAAe,YAAY,CAAC,EAAE,OAAO,CAAC,KAAK,SAAS,KAAK,GAAG,GAAG,MAAM;AAC/F;AAIA,MAAM,aAAa;AAAA,EACjB,YAAY,CAAC,WAAqB;AAChC,WAAO,OAAO,IAAI,qBAAqB,EAAE,KAAK,EAAE;AAAA,EAClD;AAAA,EACA,WAAW,CAAC,WAAqB;AAC/B,WAAO,OAAO,IAAI,CAAC,UAAU,MAAM,YAAY,CAAC,EAAE,KAAK,GAAG;AAAA,EAC5D;AAAA,EACA,WAAW,CAAC,WAAqB;AAC/B,WAAO,OAAO,IAAI,CAAC,UAAU,MAAM,YAAY,CAAC,EAAE,KAAK,GAAG;AAAA,EAC5D;AAAA,EACA,oBAAoB,CAAC,WAAqB;AACxC,WAAO,OAAO,IAAI,CAAC,UAAU,MAAM,YAAY,CAAC,EAAE,KAAK,GAAG;AAAA,EAC5D;AAAA,EACA,WAAW,CAAC,WAAqB;AAC/B,UAAM,CAAC,UAAU,MAAM,IAAI;AAC3B,WAAO,CAAC,MAAO,YAAY,GAAG,GAAG,OAAO,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE;AAAA,EAC7E;AACF;AAEO,MAAM,KAAK,cAAAA,QAAE,UAAU,YAAY,CAAC,OAAO,CAAC,SAAiB;AAClE,MAAI,SAAS,YAAY,CAAC,IAAI,CAAC;AAC/B,WAAS,aAAa,MAAM;AAC5B,SAAO,GAAG,MAAM;AAClB,CAAC;AAEM,MAAM,KAAK,cAAAA,QAAE,UAAU,IAAI,CAAC,OAAO,CAAC,SAAiB;AAC1D,QAAM,SAAS,GAAG,IAAI;AACtB,SAAO,WAAW;AACpB,CAAC;",
6
6
  "names": ["_"]
7
7
  }
@@ -19,11 +19,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
19
  ));
20
20
  var import_vitest = require("vitest");
21
21
  var caseUtils = __toESM(require("./case-utils"));
22
- const pascalCase = "HelloWorld";
23
- const kebabCase = "hello-world";
24
- const snakeCase = "hello_world";
25
- const screamingSnakeCase = "HELLO_WORLD";
26
- const camelCase = "helloWorld";
22
+ const pascalCase = "HelloLittleWorld";
23
+ const kebabCase = "hello-little-world";
24
+ const snakeCase = "hello_little_world";
25
+ const screamingSnakeCase = "HELLO_LITTLE_WORLD";
26
+ const camelCase = "helloLittleWorld";
27
27
  (0, import_vitest.test)("case utils should convert from pascal case to all other cases", () => {
28
28
  (0, import_vitest.expect)(caseUtils.to.kebabCase(pascalCase)).toBe(kebabCase);
29
29
  (0, import_vitest.expect)(caseUtils.to.snakeCase(pascalCase)).toBe(snakeCase);
@@ -54,4 +54,18 @@ const camelCase = "helloWorld";
54
54
  (0, import_vitest.expect)(caseUtils.to.snakeCase(camelCase)).toBe(snakeCase);
55
55
  (0, import_vitest.expect)(caseUtils.to.screamingSnakeCase(camelCase)).toBe(screamingSnakeCase);
56
56
  });
57
+ (0, import_vitest.test)("case utils should split special characters when converting", () => {
58
+ (0, import_vitest.expect)(caseUtils.to.pascalCase(`${pascalCase}.2`)).toBe(`${pascalCase}2`);
59
+ (0, import_vitest.expect)(caseUtils.to.kebabCase(`${kebabCase}.2`)).toBe(`${kebabCase}-2`);
60
+ (0, import_vitest.expect)(caseUtils.to.snakeCase(`${snakeCase}.2`)).toBe(`${snakeCase}_2`);
61
+ (0, import_vitest.expect)(caseUtils.to.screamingSnakeCase(`${screamingSnakeCase}.2`)).toBe(`${screamingSnakeCase}_2`);
62
+ (0, import_vitest.expect)(caseUtils.to.camelCase(`${camelCase}.2`)).toBe(`${camelCase}2`);
63
+ });
64
+ (0, import_vitest.test)("case utils should prevent special characters when checking", () => {
65
+ (0, import_vitest.expect)(caseUtils.is.pascalCase(`${pascalCase}.2`)).toBe(false);
66
+ (0, import_vitest.expect)(caseUtils.is.kebabCase(`${kebabCase}.2`)).toBe(false);
67
+ (0, import_vitest.expect)(caseUtils.is.snakeCase(`${snakeCase}.2`)).toBe(false);
68
+ (0, import_vitest.expect)(caseUtils.is.screamingSnakeCase(`${screamingSnakeCase}.2`)).toBe(false);
69
+ (0, import_vitest.expect)(caseUtils.is.camelCase(`${camelCase}.2`)).toBe(false);
70
+ });
57
71
  //# sourceMappingURL=case-utils.test.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/case-utils.test.ts"],
4
- "sourcesContent": ["import { test, expect } from 'vitest'\nimport * as caseUtils from './case-utils'\n\nconst pascalCase = 'HelloWorld'\nconst kebabCase = 'hello-world'\nconst snakeCase = 'hello_world'\nconst screamingSnakeCase = 'HELLO_WORLD'\nconst camelCase = 'helloWorld'\n\ntest('case utils should convert from pascal case to all other cases', () => {\n expect(caseUtils.to.kebabCase(pascalCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(pascalCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(pascalCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(pascalCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from kebab case to all other cases', () => {\n expect(caseUtils.to.pascalCase(kebabCase)).toBe(pascalCase)\n expect(caseUtils.to.snakeCase(kebabCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(kebabCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(kebabCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from snake case to all other cases', () => {\n expect(caseUtils.to.pascalCase(snakeCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(snakeCase)).toBe(kebabCase)\n expect(caseUtils.to.screamingSnakeCase(snakeCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(snakeCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from screaming snake case to all other cases', () => {\n expect(caseUtils.to.pascalCase(screamingSnakeCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(screamingSnakeCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(screamingSnakeCase)).toBe(snakeCase)\n expect(caseUtils.to.camelCase(screamingSnakeCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from camel case to all other cases', () => {\n expect(caseUtils.to.pascalCase(camelCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(camelCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(camelCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(camelCase)).toBe(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AAS;AACjE,4BAAO,UAAU,GAAG,UAAU,kBAAkB,CAAC,EAAE,KAAK,SAAS;AACjE,4BAAO,UAAU,GAAG,UAAU,kBAAkB,CAAC,EAAE,KAAK,SAAS;AACnE,CAAC;AAAA,IAED,oBAAK,gEAAgE,MAAM;AACzE,4BAAO,UAAU,GAAG,WAAW,SAAS,CAAC,EAAE,KAAK,UAAU;AAC1D,4BAAO,UAAU,GAAG,UAAU,SAAS,CAAC,EAAE,KAAK,SAAS;AACxD,4BAAO,UAAU,GAAG,UAAU,SAAS,CAAC,EAAE,KAAK,SAAS;AACxD,4BAAO,UAAU,GAAG,mBAAmB,SAAS,CAAC,EAAE,KAAK,kBAAkB;AAC5E,CAAC;",
4
+ "sourcesContent": ["import { test, expect } from 'vitest'\nimport * as caseUtils from './case-utils'\n\nconst pascalCase = 'HelloLittleWorld'\nconst kebabCase = 'hello-little-world'\nconst snakeCase = 'hello_little_world'\nconst screamingSnakeCase = 'HELLO_LITTLE_WORLD'\nconst camelCase = 'helloLittleWorld'\n\ntest('case utils should convert from pascal case to all other cases', () => {\n expect(caseUtils.to.kebabCase(pascalCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(pascalCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(pascalCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(pascalCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from kebab case to all other cases', () => {\n expect(caseUtils.to.pascalCase(kebabCase)).toBe(pascalCase)\n expect(caseUtils.to.snakeCase(kebabCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(kebabCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(kebabCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from snake case to all other cases', () => {\n expect(caseUtils.to.pascalCase(snakeCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(snakeCase)).toBe(kebabCase)\n expect(caseUtils.to.screamingSnakeCase(snakeCase)).toBe(screamingSnakeCase)\n expect(caseUtils.to.camelCase(snakeCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from screaming snake case to all other cases', () => {\n expect(caseUtils.to.pascalCase(screamingSnakeCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(screamingSnakeCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(screamingSnakeCase)).toBe(snakeCase)\n expect(caseUtils.to.camelCase(screamingSnakeCase)).toBe(camelCase)\n})\n\ntest('case utils should convert from camel case to all other cases', () => {\n expect(caseUtils.to.pascalCase(camelCase)).toBe(pascalCase)\n expect(caseUtils.to.kebabCase(camelCase)).toBe(kebabCase)\n expect(caseUtils.to.snakeCase(camelCase)).toBe(snakeCase)\n expect(caseUtils.to.screamingSnakeCase(camelCase)).toBe(screamingSnakeCase)\n})\n\ntest('case utils should split special characters when converting', () => {\n expect(caseUtils.to.pascalCase(`${pascalCase}.2`)).toBe(`${pascalCase}2`)\n expect(caseUtils.to.kebabCase(`${kebabCase}.2`)).toBe(`${kebabCase}-2`)\n expect(caseUtils.to.snakeCase(`${snakeCase}.2`)).toBe(`${snakeCase}_2`)\n expect(caseUtils.to.screamingSnakeCase(`${screamingSnakeCase}.2`)).toBe(`${screamingSnakeCase}_2`)\n expect(caseUtils.to.camelCase(`${camelCase}.2`)).toBe(`${camelCase}2`)\n})\n\ntest('case utils should prevent special characters when checking', () => {\n expect(caseUtils.is.pascalCase(`${pascalCase}.2`)).toBe(false)\n expect(caseUtils.is.kebabCase(`${kebabCase}.2`)).toBe(false)\n expect(caseUtils.is.snakeCase(`${snakeCase}.2`)).toBe(false)\n expect(caseUtils.is.screamingSnakeCase(`${screamingSnakeCase}.2`)).toBe(false)\n expect(caseUtils.is.camelCase(`${camelCase}.2`)).toBe(false)\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA,oBAA6B;AAC7B,gBAA2B;AAE3B,MAAM,aAAa;AACnB,MAAM,YAAY;AAClB,MAAM,YAAY;AAClB,MAAM,qBA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BAAK,gEAAgE,MAAM;AACzE,4BAAO,UAAU,GAAG,WAAW,SAAS,CAAC,EAAE,KAAK,UAAU;AAC1D,4BAAO,UAAU,GAAG,UAAU,SAAS,CAAC,EAAE,KAAK,SAAS;AACxD,4BAAO,UAAU,GAAG,UAAU,SAAS,CAAC,EAAE,KAAK,SAAS;AACxD,4BAAO,UAAU,GAAG,mBAAmB,SAAS,CAAC,EAAE,KAAK,kBAAkB;AAC5E,CAAC;AAAA,IAED,oBAAK,8DAA8D,MAAM;AACvE,4BAAO,UAAU,GAAG,WAAW,GAAG,cAAc,CAAC,EAAE,KAAK,GAAG,aAAa;AACxE,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,GAAG,aAAa;AACtE,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,GAAG,aAAa;AACtE,4BAAO,UAAU,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,KAAK,GAAG,sBAAsB;AACjG,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,GAAG,YAAY;AACvE,CAAC;AAAA,IAED,oBAAK,8DAA8D,MAAM;AACvE,4BAAO,UAAU,GAAG,WAAW,GAAG,cAAc,CAAC,EAAE,KAAK,KAAK;AAC7D,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,KAAK;AAC3D,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,KAAK;AAC3D,4BAAO,UAAU,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,KAAK,KAAK;AAC7E,4BAAO,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC,EAAE,KAAK,KAAK;AAC7D,CAAC;",
6
6
  "names": []
7
7
  }
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var record_utils_exports = {};
20
20
  __export(record_utils_exports, {
21
21
  filterValues: () => filterValues,
22
+ mapKeys: () => mapKeys,
22
23
  mapValues: () => mapValues,
23
24
  setNullOnMissingValues: () => setNullOnMissingValues,
24
25
  zipObjects: () => zipObjects
@@ -51,6 +52,14 @@ const mapValues = (record, fn) => {
51
52
  }
52
53
  return newRecord;
53
54
  };
55
+ const mapKeys = (record, fn) => {
56
+ const newRecord = {};
57
+ for (const [key, value] of Object.entries(record)) {
58
+ const newKey = fn(value, key);
59
+ newRecord[newKey] = value;
60
+ }
61
+ return newRecord;
62
+ };
54
63
  function filterValues(record, fn) {
55
64
  const newRecord = {};
56
65
  for (const [key, value] of Object.entries(record)) {
@@ -63,6 +72,7 @@ function filterValues(record, fn) {
63
72
  // Annotate the CommonJS export names for ESM import in node:
64
73
  0 && (module.exports = {
65
74
  filterValues,
75
+ mapKeys,
66
76
  mapValues,
67
77
  setNullOnMissingValues,
68
78
  zipObjects
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/record-utils.ts"],
4
- "sourcesContent": ["export const setNullOnMissingValues = <A, B>(\n record: Record<string, A> = {},\n oldRecord: Record<string, B> = {}\n): Record<string, A | null> => {\n const newRecord: Record<string, A | null> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = value\n }\n\n for (const value of Object.keys(oldRecord)) {\n if (!record[value]) {\n newRecord[value] = null\n }\n }\n\n return newRecord\n}\n\nexport const zipObjects = <A, B>(\n recordA: Record<string, A>,\n recordB: Record<string, B>\n): Record<string, [A | null, B | null]> => {\n const allKeys = new Set([...Object.keys(recordA), ...Object.keys(recordB)])\n const newRecord: Record<string, [A | null, B | null]> = {}\n\n for (const key of allKeys) {\n newRecord[key] = [recordA[key] ?? null, recordB[key] ?? null]\n }\n\n return newRecord\n}\n\nexport const mapValues = <A, B>(record: Record<string, A>, fn: (value: A, key: string) => B): Record<string, B> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = fn(value, key)\n }\n\n return newRecord\n}\n\nexport function filterValues<A, B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => value is B\n): Record<string, B>\nexport function filterValues<A, _B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => boolean\n): Record<string, A>\nexport function filterValues<A>(record: Record<string, A>, fn: (value: A, key: string) => boolean) {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n if (fn(value, key)) {\n newRecord[key] = value\n }\n }\n\n return newRecord\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,yBAAyB,CACpC,SAA4B,CAAC,GAC7B,YAA+B,CAAC,MACH;AAC7B,QAAM,YAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO;AAAA,EACnB;AAEA,aAAW,SAAS,OAAO,KAAK,SAAS,GAAG;AAC1C,QAAI,CAAC,OAAO,QAAQ;AAClB,gBAAU,SAAS;AAAA,IACrB;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,aAAa,CACxB,SACA,YACyC;AACzC,QAAM,UAAU,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC;AAC1E,QAAM,YAAkD,CAAC;AAEzD,aAAW,OAAO,SAAS;AACzB,cAAU,OAAO,CAAC,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,IAAI;AAAA,EAC9D;AAEA,SAAO;AACT;AAEO,MAAM,YAAY,CAAO,QAA2B,OAAwD;AACjH,QAAM,YAA+B,CAAC;AAEtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO,GAAG,OAAO,GAAG;AAAA,EAChC;AAEA,SAAO;AACT;AAUO,SAAS,aAAgB,QAA2B,IAAwC;AACjG,QAAM,YAA+B,CAAC;AAEtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,GAAG,OAAO,GAAG,GAAG;AAClB,gBAAU,OAAO;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["export const setNullOnMissingValues = <A, B>(\n record: Record<string, A> = {},\n oldRecord: Record<string, B> = {}\n): Record<string, A | null> => {\n const newRecord: Record<string, A | null> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = value\n }\n\n for (const value of Object.keys(oldRecord)) {\n if (!record[value]) {\n newRecord[value] = null\n }\n }\n\n return newRecord\n}\n\nexport const zipObjects = <A, B>(\n recordA: Record<string, A>,\n recordB: Record<string, B>\n): Record<string, [A | null, B | null]> => {\n const allKeys = new Set([...Object.keys(recordA), ...Object.keys(recordB)])\n const newRecord: Record<string, [A | null, B | null]> = {}\n\n for (const key of allKeys) {\n newRecord[key] = [recordA[key] ?? null, recordB[key] ?? null]\n }\n\n return newRecord\n}\n\nexport const mapValues = <A, B>(record: Record<string, A>, fn: (value: A, key: string) => B): Record<string, B> => {\n const newRecord: Record<string, B> = {}\n\n for (const [key, value] of Object.entries(record)) {\n newRecord[key] = fn(value, key)\n }\n\n return newRecord\n}\n\nexport const mapKeys = <A>(record: Record<string, A>, fn: (value: A, key: string) => string): Record<string, A> => {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n const newKey = fn(value, key) as string\n newRecord[newKey] = value\n }\n\n return newRecord\n}\n\nexport function filterValues<A, B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => value is B\n): Record<string, B>\nexport function filterValues<A, _B extends A>(\n record: Record<string, A>,\n fn: (value: A, key: string) => boolean\n): Record<string, A>\nexport function filterValues<A>(record: Record<string, A>, fn: (value: A, key: string) => boolean) {\n const newRecord: Record<string, A> = {}\n\n for (const [key, value] of Object.entries(record)) {\n if (fn(value, key)) {\n newRecord[key] = value\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M,GAAG;AACjD,QAAI,GAAG,OAAO,GAAG,GAAG;AAClB,gBAAU,OAAO;AAAA,IACnB;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.8.21",
3
+ "version": "0.8.22",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -21,7 +21,7 @@
21
21
  "main": "dist/index.js",
22
22
  "dependencies": {
23
23
  "@botpress/client": "0.19.0",
24
- "@botpress/sdk": "0.8.17",
24
+ "@botpress/sdk": "0.8.18",
25
25
  "@bpinternal/const": "^0.0.20",
26
26
  "@bpinternal/tunnel": "^0.1.1",
27
27
  "@bpinternal/yargs-extra": "^0.0.3",
@@ -6,7 +6,7 @@
6
6
  "private": true,
7
7
  "dependencies": {
8
8
  "@botpress/client": "0.19.0",
9
- "@botpress/sdk": "0.8.17"
9
+ "@botpress/sdk": "0.8.18"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.11.17",
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.19.0",
10
- "@botpress/sdk": "0.8.17"
10
+ "@botpress/sdk": "0.8.18"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.11.17",
@@ -6,7 +6,7 @@ export * as input from "./input";
6
6
  import * as output from "./output";
7
7
  export * as output from "./output";
8
8
 
9
- export type ActionHelloWorld = {
10
- input: input.Input;
11
- output: output.Output;
9
+ export type HelloWorld = {
10
+ "input": input.Input;
11
+ "output": output.Output;
12
12
  }
@@ -5,5 +5,5 @@ import * as helloWorld from "./helloWorld/index";
5
5
  export * as helloWorld from "./helloWorld/index";
6
6
 
7
7
  export type Actions = {
8
- helloWorld: helloWorld.ActionHelloWorld;
8
+ "helloWorld": helloWorld.HelloWorld;
9
9
  }
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.19.0",
10
- "@botpress/sdk": "0.8.17"
10
+ "@botpress/sdk": "0.8.18"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.11.17",
@@ -5,5 +5,5 @@ import * as webhook from "./webhook/index";
5
5
  export * as webhook from "./webhook/index";
6
6
 
7
7
  export type Channels = {
8
- webhook: webhook.ChannelWebhook;
8
+ "webhook": webhook.Webhook;
9
9
  }
@@ -5,7 +5,7 @@
5
5
  import { Messages } from './messages/index'
6
6
  export * from './messages/index'
7
7
 
8
- export type ChannelWebhook = {
8
+ export type Webhook = {
9
9
  messages: Messages
10
10
  message: { "tags": {} }
11
11
  conversation: { "tags": { "id": { "title": "Conversation ID", "description": "The ID of the conversation" } }, "creation": { "enabled": false, "requiredTags": [] } }
@@ -5,5 +5,5 @@ import * as text from "./text";
5
5
  export * as text from "./text";
6
6
 
7
7
  export type Messages = {
8
- text: text.Text;
8
+ "text": text.Text;
9
9
  }
@@ -7,7 +7,7 @@
7
7
  "private": true,
8
8
  "dependencies": {
9
9
  "@botpress/client": "0.19.0",
10
- "@botpress/sdk": "0.8.17",
10
+ "@botpress/sdk": "0.8.18",
11
11
  "axios": "^1.6.8"
12
12
  },
13
13
  "devDependencies": {