@botpress/cli 0.0.9 → 0.0.10

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 (86) hide show
  1. package/dist/api-client.js +107 -0
  2. package/dist/app/api-utils.js +9 -3
  3. package/dist/app/base.js +1 -3
  4. package/dist/app/errors.js +8 -0
  5. package/dist/app/file-paths.js +4 -2
  6. package/dist/app/index.js +17 -12
  7. package/dist/app/user.js +73 -23
  8. package/dist/code-generation/action.js +70 -0
  9. package/dist/code-generation/channel.js +51 -0
  10. package/dist/code-generation/configuration.js +40 -0
  11. package/dist/code-generation/const.js +31 -0
  12. package/dist/code-generation/event.js +41 -0
  13. package/dist/code-generation/index.js +80 -0
  14. package/dist/code-generation/integration-impl.js +147 -0
  15. package/dist/code-generation/integration-instance.js +79 -0
  16. package/dist/code-generation/message.js +41 -0
  17. package/dist/code-generation/module.js +115 -0
  18. package/dist/code-generation/typings.js +16 -0
  19. package/dist/command-definitions.js +61 -0
  20. package/dist/command-implementations/add-command.js +124 -0
  21. package/dist/command-implementations/base-command.js +53 -0
  22. package/dist/command-implementations/bot-commands.js +89 -0
  23. package/dist/command-implementations/build-command.js +48 -0
  24. package/dist/command-implementations/bundle-command.js +58 -0
  25. package/dist/command-implementations/deploy-command.js +162 -0
  26. package/dist/command-implementations/dev-command.js +168 -0
  27. package/dist/command-implementations/gen-command.js +58 -0
  28. package/dist/command-implementations/global-command.js +111 -0
  29. package/dist/command-implementations/index.js +78 -0
  30. package/dist/command-implementations/init-command.js +85 -0
  31. package/dist/command-implementations/integration-commands.js +107 -0
  32. package/dist/command-implementations/login-command.js +75 -0
  33. package/dist/command-implementations/logout-command.js +34 -0
  34. package/dist/command-implementations/project-command.js +115 -0
  35. package/dist/command-implementations/serve-command.js +53 -0
  36. package/dist/command-tree.js +59 -0
  37. package/dist/config.js +18 -2
  38. package/dist/consts.js +13 -0
  39. package/dist/errors.js +156 -0
  40. package/dist/index.js +33 -20
  41. package/dist/integration-ref.js +61 -0
  42. package/dist/path-utils.js +6 -0
  43. package/dist/register-yargs.js +85 -0
  44. package/dist/typings.js +16 -0
  45. package/dist/utils/cache-utils.js +99 -0
  46. package/dist/utils/esbuild-utils.js +89 -0
  47. package/dist/utils/event-emitter.js +62 -0
  48. package/dist/utils/file-watcher.js +68 -0
  49. package/dist/utils/index.js +55 -0
  50. package/dist/utils/path-utils.js +83 -0
  51. package/dist/utils/prompt-utils.js +75 -0
  52. package/dist/utils/require-utils.js +49 -0
  53. package/dist/utils/string-utils.js +38 -0
  54. package/package.json +6 -4
  55. package/templates/echo-bot/.botpress/project.cache.json +1 -0
  56. package/templates/echo-bot/package.json +22 -0
  57. package/templates/echo-bot/readme.md +5 -0
  58. package/templates/echo-bot/src/index.ts +44 -0
  59. package/templates/echo-bot/tsconfig.json +15 -0
  60. package/templates/empty-integration/.botpress/implementation/actions/index.ts +7 -0
  61. package/templates/empty-integration/.botpress/implementation/channels/channel/audio.ts +10 -0
  62. package/templates/empty-integration/.botpress/implementation/channels/channel/card.ts +17 -0
  63. package/templates/empty-integration/.botpress/implementation/channels/channel/carousel.ts +19 -0
  64. package/templates/empty-integration/.botpress/implementation/channels/channel/choice.ts +14 -0
  65. package/templates/empty-integration/.botpress/implementation/channels/channel/dropdown.ts +14 -0
  66. package/templates/empty-integration/.botpress/implementation/channels/channel/file.ts +11 -0
  67. package/templates/empty-integration/.botpress/implementation/channels/channel/image.ts +10 -0
  68. package/templates/empty-integration/.botpress/implementation/channels/channel/index.ts +40 -0
  69. package/templates/empty-integration/.botpress/implementation/channels/channel/location.ts +11 -0
  70. package/templates/empty-integration/.botpress/implementation/channels/channel/markdown.ts +10 -0
  71. package/templates/empty-integration/.botpress/implementation/channels/channel/text.ts +10 -0
  72. package/templates/empty-integration/.botpress/implementation/channels/channel/video.ts +10 -0
  73. package/templates/empty-integration/.botpress/implementation/channels/index.ts +10 -0
  74. package/templates/empty-integration/.botpress/implementation/configuration.ts +10 -0
  75. package/templates/empty-integration/.botpress/implementation/events/index.ts +7 -0
  76. package/templates/empty-integration/.botpress/implementation/index.ts +17 -0
  77. package/templates/empty-integration/.botpress/index.ts +1 -0
  78. package/templates/empty-integration/.botpress/project.cache.json +1 -0
  79. package/templates/empty-integration/integration.definition.ts +13 -0
  80. package/templates/empty-integration/package.json +22 -0
  81. package/templates/empty-integration/readme.md +5 -0
  82. package/templates/empty-integration/src/index.ts +58 -0
  83. package/templates/empty-integration/tsconfig.json +15 -0
  84. package/.ignore.me.github/index.ts +0 -38
  85. package/dist/github-download.js +0 -159
  86. package/dist/github-fetch.js +0 -173
@@ -0,0 +1,107 @@
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 api_client_exports = {};
26
+ __export(api_client_exports, {
27
+ ApiClient: () => ApiClient
28
+ });
29
+ module.exports = __toCommonJS(api_client_exports);
30
+ var import_client = require("@botpress/client");
31
+ var import_lodash = __toESM(require("lodash"));
32
+ var import_integration_ref = require("./integration-ref");
33
+ class ApiClient {
34
+ constructor(props, _logger) {
35
+ this._logger = _logger;
36
+ const { host, token, workspaceId } = props;
37
+ this.client = new import_client.Client({ host, token, workspaceId });
38
+ this.host = host;
39
+ this.token = token;
40
+ this.workspaceId = workspaceId;
41
+ }
42
+ client;
43
+ host;
44
+ token;
45
+ workspaceId;
46
+ static newClient = (props, logger) => new ApiClient(props, logger);
47
+ async findIntegration(ref) {
48
+ const formatted = (0, import_integration_ref.formatIntegrationRef)(ref);
49
+ const privateIntegration = await this.findPrivateIntegration(ref);
50
+ if (privateIntegration) {
51
+ this._logger.debug(`Found integration "${formatted}" in workspace`);
52
+ return privateIntegration;
53
+ }
54
+ const publicIntegration = await this.findPublicIntegration(ref);
55
+ if (publicIntegration) {
56
+ this._logger.debug(`Found integration "${formatted}" in hub`);
57
+ return publicIntegration;
58
+ }
59
+ return;
60
+ }
61
+ async findPrivateIntegration(ref) {
62
+ if (ref.type === "id") {
63
+ return this.validateStatus(() => this.client.getIntegration(ref).then((r) => r.integration), [404, 500]);
64
+ }
65
+ return this.validateStatus(() => this.client.getIntegrationByName(ref).then((r) => r.integration), [404, 500]);
66
+ }
67
+ async findPublicIntegration(ref) {
68
+ if (ref.type === "id") {
69
+ return this.validateStatus(() => this.client.getPublicIntegrationById(ref).then((r) => r.integration), [404, 500]);
70
+ }
71
+ return this.validateStatus(() => this.client.getPublicIntegration(ref).then((r) => r.integration), [404, 500]);
72
+ }
73
+ async testLogin() {
74
+ await this.client.listBots({});
75
+ }
76
+ async listAllPages(lister, mapper) {
77
+ let nextToken;
78
+ const all = [];
79
+ do {
80
+ const { meta, ...r } = await lister({ nextToken });
81
+ all.push(r);
82
+ nextToken = meta.nextToken;
83
+ } while (nextToken);
84
+ if (!mapper) {
85
+ return all;
86
+ }
87
+ const mapped = all.flatMap((r) => mapper(r));
88
+ return mapped;
89
+ }
90
+ async validateStatus(fn, allowedStatuses) {
91
+ try {
92
+ const v = await fn();
93
+ return v;
94
+ } catch (err) {
95
+ const allowedStatusesArray = import_lodash.default.isArray(allowedStatuses) ? allowedStatuses : [allowedStatuses];
96
+ const isAllowed = (0, import_client.isApiError)(err) && err.code && allowedStatusesArray.includes(err.code);
97
+ if (isAllowed) {
98
+ return;
99
+ }
100
+ throw err;
101
+ }
102
+ }
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ ApiClient
107
+ });
@@ -27,17 +27,23 @@ __export(api_utils_exports, {
27
27
  ApiUtils: () => ApiUtils
28
28
  });
29
29
  module.exports = __toCommonJS(api_utils_exports);
30
+ var import_client = require("@botpress/client");
30
31
  var import_lodash = __toESM(require("lodash"));
31
32
  var errors = __toESM(require("./errors"));
32
33
  var import_integration_ref = require("./integration-ref");
33
34
  class ApiUtils {
34
- constructor(client, host, token, workspaceId, _logger) {
35
- this.client = client;
35
+ constructor(props, _logger) {
36
+ this._logger = _logger;
37
+ const { host, token, workspaceId } = props;
38
+ this.client = new import_client.Client({ host, token, workspaceId });
36
39
  this.host = host;
37
40
  this.token = token;
38
41
  this.workspaceId = workspaceId;
39
- this._logger = _logger;
40
42
  }
43
+ client;
44
+ host;
45
+ token;
46
+ workspaceId;
41
47
  async findIntegration(ref) {
42
48
  const formatted = (0, import_integration_ref.formatIntegrationRef)(ref);
43
49
  const privateIntegration = await this.findPrivateIntegration(ref);
package/dist/app/base.js CHANGED
@@ -27,7 +27,6 @@ __export(base_exports, {
27
27
  BaseCommands: () => BaseCommands
28
28
  });
29
29
  module.exports = __toCommonJS(base_exports);
30
- var bpclient = __toESM(require("@botpress/client"));
31
30
  var import_prompts = __toESM(require("prompts"));
32
31
  var import_api_utils = require("./api-utils");
33
32
  var errors = __toESM(require("./errors"));
@@ -47,8 +46,7 @@ class BaseCommands {
47
46
  if (!(token && workspaceId && host)) {
48
47
  throw new errors.NotLoggedInError();
49
48
  }
50
- const client = new bpclient.Client({ host, token, workspaceId });
51
- return new import_api_utils.ApiUtils(client, host, token, workspaceId, this._logger);
49
+ return new import_api_utils.ApiUtils({ host, token, workspaceId }, this._logger);
52
50
  }
53
51
  async _confirm(message) {
54
52
  if (this._props.confirm) {
@@ -31,6 +31,7 @@ __export(errors_exports, {
31
31
  InvalidIntegrationReferenceError: () => InvalidIntegrationReferenceError,
32
32
  NoBotsFoundError: () => NoBotsFoundError,
33
33
  NoBundleFoundError: () => NoBundleFoundError,
34
+ NoWorkspacesFoundError: () => NoWorkspacesFoundError,
34
35
  NotLoggedInError: () => NotLoggedInError,
35
36
  ParamRequiredError: () => ParamRequiredError
36
37
  });
@@ -116,6 +117,12 @@ class NoBotsFoundError extends BotpressCLIError {
116
117
  super(message);
117
118
  }
118
119
  }
120
+ class NoWorkspacesFoundError extends BotpressCLIError {
121
+ constructor() {
122
+ const message = "No Workspace found. Please create one first.";
123
+ super(message);
124
+ }
125
+ }
119
126
  class NotLoggedInError extends BotpressCLIError {
120
127
  constructor() {
121
128
  const message = "Not logged in. Please run `bp login` first.";
@@ -143,6 +150,7 @@ class InvalidIntegrationReferenceError extends BotpressCLIError {
143
150
  InvalidIntegrationReferenceError,
144
151
  NoBotsFoundError,
145
152
  NoBundleFoundError,
153
+ NoWorkspacesFoundError,
146
154
  NotLoggedInError,
147
155
  ParamRequiredError
148
156
  });
@@ -55,11 +55,13 @@ class ProjectPaths {
55
55
  }
56
56
  class UserPaths {
57
57
  abs;
58
- constructor({ botpressHomeDir }) {
58
+ constructor({ botpressHomeDir, cliRootDir: absCliRootDir }) {
59
59
  const absBotpressHome = pathutils.absoluteFrom(pathutils.cwd(), botpressHomeDir);
60
60
  this.abs = {
61
+ cliRootDir: absCliRootDir,
61
62
  botpressHomeDir: absBotpressHome,
62
- ...import_lodash.default.mapValues(consts.fromHomeDir, (p) => pathutils.absoluteFrom(absBotpressHome, p))
63
+ ...import_lodash.default.mapValues(consts.fromHomeDir, (p) => pathutils.absoluteFrom(absBotpressHome, p)),
64
+ ...import_lodash.default.mapValues(consts.fromCliRootDir, (p) => pathutils.absoluteFrom(absCliRootDir, p))
63
65
  };
64
66
  }
65
67
  get rel() {
package/dist/app/index.js CHANGED
@@ -39,35 +39,40 @@ var import_file_paths = require("./file-paths");
39
39
  var import_project = require("./project");
40
40
  var import_user = require("./user");
41
41
  var errors = __toESM(require("./errors"));
42
- const logBootInfo = async (logger, props) => {
43
- const versionText = import_chalk.default.bold(`v${props.version}`);
42
+ const readPackageJson = async (paths) => {
43
+ const pkgJson = await import_fs.default.promises.readFile(paths.abs.packageJson, "utf-8");
44
+ return JSON.parse(pkgJson);
45
+ };
46
+ const logBootInfo = async (logger, paths) => {
47
+ const packageJson = await readPackageJson(paths);
48
+ const versionText = import_chalk.default.bold(`v${packageJson.version}`);
44
49
  logger.log(`Botpress CLI ${versionText}`, { prefix: "\u{1F916}" });
45
- await (0, import_update_notif.notifyUpdate)(props, logger);
46
- if (props.botpressHome !== consts.defaultBotpressHome) {
47
- logger.log(`Using custom botpress home: ${props.botpressHome}`, { prefix: "\u{1F3E0}" });
50
+ await (0, import_update_notif.notifyUpdate)(packageJson, logger);
51
+ if (paths.abs.botpressHomeDir !== consts.defaultBotpressHome) {
52
+ logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: "\u{1F3E0}" });
48
53
  }
49
54
  };
50
55
  const forProject = async (props) => {
51
56
  const logger = new import_logger.Logger(props);
52
- await logBootInfo(logger, props);
53
- const { workDir, entryPoint, outDir, botpressHome } = props;
57
+ const { workDir, entryPoint, outDir, botpressHome, cliRootPath } = props;
54
58
  const projectPaths = new import_file_paths.ProjectPaths({ workDir, entryPoint, outDir });
55
59
  const projectCachePath = projectPaths.abs.projectCacheFile;
56
60
  const projectCache = await import_cache.FSConfigCache.loadFrom(projectCachePath);
57
- const userPaths = new import_file_paths.UserPaths({ botpressHomeDir: botpressHome });
61
+ const userPaths = new import_file_paths.UserPaths({ botpressHomeDir: botpressHome, cliRootDir: cliRootPath });
58
62
  const userCacheFile = userPaths.abs.userCacheFile;
59
63
  const userCache = await import_cache.FSConfigCache.loadFrom(userCacheFile);
60
64
  await import_fs.default.promises.mkdir(projectPaths.abs.distDir, { recursive: true });
65
+ await logBootInfo(logger, userPaths);
61
66
  return new import_project.ProjectCommands(props, projectPaths, projectCache, userCache, logger);
62
67
  };
63
68
  const forUser = async (props) => {
64
69
  const logger = new import_logger.Logger(props);
65
- await logBootInfo(logger, props);
66
- const { botpressHome } = props;
67
- const userPaths = new import_file_paths.UserPaths({ botpressHomeDir: botpressHome });
70
+ const { botpressHome, cliRootPath } = props;
71
+ const userPaths = new import_file_paths.UserPaths({ botpressHomeDir: botpressHome, cliRootDir: cliRootPath });
68
72
  const userCacheFile = userPaths.abs.userCacheFile;
69
73
  const userCache = await import_cache.FSConfigCache.loadFrom(userCacheFile);
70
- return new import_user.UserCommands(props, userCache, logger);
74
+ await logBootInfo(logger, userPaths);
75
+ return new import_user.UserCommands(props, userPaths, userCache, logger);
71
76
  };
72
77
  // Annotate the CommonJS export names for ESM import in node:
73
78
  0 && (module.exports = {
package/dist/app/user.js CHANGED
@@ -27,17 +27,21 @@ __export(user_exports, {
27
27
  UserCommands: () => UserCommands
28
28
  });
29
29
  module.exports = __toCommonJS(user_exports);
30
- var bpclient = __toESM(require("@botpress/client"));
31
30
  var import_chalk = __toESM(require("chalk"));
31
+ var import_fs = __toESM(require("fs"));
32
32
  var import_lodash = __toESM(require("lodash"));
33
+ var import_path = __toESM(require("path"));
33
34
  var import_prompts = __toESM(require("prompts"));
35
+ var consts = __toESM(require("../consts"));
36
+ var pathutils = __toESM(require("../path-utils"));
34
37
  var import_api_utils = require("./api-utils");
35
38
  var import_base = require("./base");
36
39
  var errors = __toESM(require("./errors"));
37
40
  var import_integration_ref = require("./integration-ref");
38
41
  class UserCommands extends import_base.BaseCommands {
39
- constructor(props, userCache, logger) {
42
+ constructor(props, _paths, userCache, logger) {
40
43
  super(props, userCache, logger);
44
+ this._paths = _paths;
41
45
  }
42
46
  async login(argv) {
43
47
  const promptedToken = await this._userCache.sync("token", argv.token, async (previousToken) => {
@@ -52,29 +56,29 @@ class UserCommands extends import_base.BaseCommands {
52
56
  }
53
57
  return prompted;
54
58
  });
55
- const promptedWorkspaceId = await this._userCache.sync(
56
- "workspaceId",
57
- argv.workspaceId,
58
- async (previousWorkspace) => {
59
- const { prompted } = await (0, import_prompts.default)({
60
- type: "text",
61
- name: "prompted",
62
- message: "Enter your default Workspace Id",
63
- initial: previousWorkspace
64
- });
65
- if (!prompted) {
66
- throw new errors.ParamRequiredError("Workspace Id");
67
- }
68
- return prompted;
59
+ const promptedWorkspaceId = await this._userCache.sync("workspaceId", argv.workspaceId, async (defaultId) => {
60
+ const tmpApi = new import_api_utils.ApiUtils({ host: argv.host, token: promptedToken }, this._logger);
61
+ const userWorkspaces = await tmpApi.listAllPages(tmpApi.client.listWorkspaces, (r) => r.workspaces).catch((thrown) => {
62
+ throw errors.BotpressCLIError.wrap(thrown, "Could not list workspaces");
63
+ });
64
+ if (userWorkspaces.length === 0) {
65
+ throw new errors.NoWorkspacesFoundError();
69
66
  }
70
- );
71
- await this._userCache.set("host", argv.host);
72
- const client = new bpclient.Client({
73
- host: argv.host,
74
- token: promptedToken,
75
- workspaceId: promptedWorkspaceId
67
+ const initial = userWorkspaces.find((ws) => ws.id === defaultId);
68
+ const { prompted } = await (0, import_prompts.default)({
69
+ type: "autocomplete",
70
+ name: "prompted",
71
+ message: "Which workspace do you want to login to?",
72
+ initial: initial?.name,
73
+ choices: userWorkspaces.map((ws) => ({ title: ws.name, value: ws.id }))
74
+ });
75
+ if (!prompted) {
76
+ throw new errors.ParamRequiredError("Workspace Id");
77
+ }
78
+ return prompted;
76
79
  });
77
- const api = new import_api_utils.ApiUtils(client, argv.host, promptedToken, promptedWorkspaceId, this._logger);
80
+ await this._userCache.set("host", argv.host);
81
+ const api = new import_api_utils.ApiUtils({ host: argv.host, token: promptedToken, workspaceId: promptedWorkspaceId }, this._logger);
78
82
  await api.testLogin();
79
83
  this._logger.success("Logged In");
80
84
  }
@@ -180,6 +184,52 @@ class UserCommands extends import_base.BaseCommands {
180
184
  this._logger.success(`Integration ${import_chalk.default.bold(integrationRef)} deleted`);
181
185
  return;
182
186
  }
187
+ async initProject(argv) {
188
+ let { type: projectType } = argv;
189
+ if (!projectType) {
190
+ const { promptedType } = await (0, import_prompts.default)({
191
+ type: "autocomplete",
192
+ name: "promptedType",
193
+ message: "What type of project do you wish to initialize?",
194
+ choices: ["bot", "integration"].map((t) => ({ title: t, value: t }))
195
+ });
196
+ if (!promptedType) {
197
+ throw new errors.ParamRequiredError("Project Type");
198
+ }
199
+ projectType = promptedType;
200
+ }
201
+ const workDir = pathutils.absoluteFrom(pathutils.cwd(), argv.workDir);
202
+ if (projectType === "bot") {
203
+ const destination2 = import_path.default.join(workDir, argv.name ?? consts.echoBotName);
204
+ const exist2 = await this._checkIfDestinationExists(destination2);
205
+ if (exist2) {
206
+ return;
207
+ }
208
+ await import_fs.default.promises.cp(this._paths.abs.echoBotTemplate, destination2, { recursive: true });
209
+ this._logger.success(`Bot project initialized in ${import_chalk.default.bold(workDir)}`);
210
+ return;
211
+ }
212
+ const destination = import_path.default.join(workDir, argv.name ?? consts.emptyIntegrationName);
213
+ const exist = await this._checkIfDestinationExists(destination);
214
+ if (exist) {
215
+ return;
216
+ }
217
+ await import_fs.default.promises.cp(this._paths.abs.emptyIntegrationTemplate, destination, { recursive: true });
218
+ this._logger.success(`Integration project initialized in ${import_chalk.default.bold(argv.workDir)}`);
219
+ return;
220
+ }
221
+ _checkIfDestinationExists = async (destination) => {
222
+ if (import_fs.default.existsSync(destination)) {
223
+ const override = await this._confirm(
224
+ `Directory ${import_chalk.default.bold(destination)} already exists. Do you want to overwrite it?`
225
+ );
226
+ if (!override) {
227
+ this._logger.log("Aborting");
228
+ return true;
229
+ }
230
+ }
231
+ return false;
232
+ };
183
233
  }
184
234
  // Annotate the CommonJS export names for ESM import in node:
185
235
  0 && (module.exports = {
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var action_exports = {};
20
+ __export(action_exports, {
21
+ ActionInputModule: () => ActionInputModule,
22
+ ActionModule: () => ActionModule,
23
+ ActionOutputModule: () => ActionOutputModule
24
+ });
25
+ module.exports = __toCommonJS(action_exports);
26
+ var import_json_schema_to_typescript = require("json-schema-to-typescript");
27
+ var import_utils = require("../utils");
28
+ var import_module = require("./module");
29
+ class ActionInputModule extends import_module.Module {
30
+ static async create(input) {
31
+ const schema = input.schema ?? {};
32
+ const filename = "input.ts";
33
+ const def = {
34
+ path: filename,
35
+ exportName: "Input",
36
+ content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
37
+ };
38
+ return new ActionInputModule(def);
39
+ }
40
+ }
41
+ class ActionOutputModule extends import_module.Module {
42
+ static async create(output) {
43
+ const schema = output.schema ?? {};
44
+ const filename = "output.ts";
45
+ const def = {
46
+ path: filename,
47
+ exportName: "Output",
48
+ content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
49
+ };
50
+ return new ActionOutputModule(def);
51
+ }
52
+ }
53
+ class ActionModule extends import_module.ReExportModule {
54
+ static async create(actionName, action) {
55
+ const inputModule = await ActionInputModule.create(action.input ?? {});
56
+ const outputModule = await ActionOutputModule.create(action.output ?? {});
57
+ const inst = new ActionModule({
58
+ exportName: `Action${import_utils.strings.pascalCase(actionName)}`
59
+ });
60
+ inst.pushDep(inputModule);
61
+ inst.pushDep(outputModule);
62
+ return inst;
63
+ }
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ ActionInputModule,
68
+ ActionModule,
69
+ ActionOutputModule
70
+ });
@@ -0,0 +1,51 @@
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 channel_exports = {};
26
+ __export(channel_exports, {
27
+ ChannelModule: () => ChannelModule
28
+ });
29
+ module.exports = __toCommonJS(channel_exports);
30
+ var import_bluebird = __toESM(require("bluebird"));
31
+ var import_utils = require("../utils");
32
+ var import_message = require("./message");
33
+ var import_module = require("./module");
34
+ class ChannelModule extends import_module.ReExportModule {
35
+ static async create(channelName, channel) {
36
+ const messages = channel.messages ?? {};
37
+ const messageModules = await import_bluebird.default.map(
38
+ Object.entries(messages),
39
+ ([messageName, message]) => import_message.MessageModule.create(messageName, message)
40
+ );
41
+ const inst = new ChannelModule({
42
+ exportName: `Channel${import_utils.strings.pascalCase(channelName)}`
43
+ });
44
+ inst.pushDep(...messageModules);
45
+ return inst;
46
+ }
47
+ }
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ ChannelModule
51
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var configuration_exports = {};
20
+ __export(configuration_exports, {
21
+ ConfigurationModule: () => ConfigurationModule
22
+ });
23
+ module.exports = __toCommonJS(configuration_exports);
24
+ var import_json_schema_to_typescript = require("json-schema-to-typescript");
25
+ var import_module = require("./module");
26
+ class ConfigurationModule extends import_module.Module {
27
+ static async create(configuration) {
28
+ const schema = configuration.schema ?? {};
29
+ const filename = "configuration";
30
+ return new ConfigurationModule({
31
+ path: `${filename}.ts`,
32
+ exportName: "Configuration",
33
+ content: await (0, import_json_schema_to_typescript.compile)(schema, filename)
34
+ });
35
+ }
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ ConfigurationModule
40
+ });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var const_exports = {};
20
+ __export(const_exports, {
21
+ GENERATED_HEADER: () => GENERATED_HEADER,
22
+ INDEX_FILE: () => INDEX_FILE
23
+ });
24
+ module.exports = __toCommonJS(const_exports);
25
+ const GENERATED_HEADER = "/* tslint:disable */\n// This file is generated\n// Do not edit this file\n\n";
26
+ const INDEX_FILE = "index.ts";
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ GENERATED_HEADER,
30
+ INDEX_FILE
31
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var event_exports = {};
20
+ __export(event_exports, {
21
+ EventModule: () => EventModule
22
+ });
23
+ module.exports = __toCommonJS(event_exports);
24
+ var import_json_schema_to_typescript = require("json-schema-to-typescript");
25
+ var import_utils = require("../utils");
26
+ var import_module = require("./module");
27
+ class EventModule extends import_module.Module {
28
+ static async create(name, event) {
29
+ const schema = event.schema ?? {};
30
+ const def = {
31
+ path: `${name}.ts`,
32
+ exportName: import_utils.strings.pascalCase(name),
33
+ content: await (0, import_json_schema_to_typescript.compile)(schema, name)
34
+ };
35
+ return new EventModule(def);
36
+ }
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ EventModule
41
+ });