@botpress/cli 0.5.2 → 0.5.4

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 (33) hide show
  1. package/dist/api/bot-body.js +17 -0
  2. package/dist/api/bot-body.js.map +2 -2
  3. package/dist/api/client.js +3 -3
  4. package/dist/api/client.js.map +2 -2
  5. package/dist/api/integration-body.js +36 -0
  6. package/dist/api/integration-body.js.map +2 -2
  7. package/dist/code-generation/index.js.map +1 -1
  8. package/dist/code-generation/map-integration.js.map +2 -2
  9. package/dist/command-implementations/add-command.js.map +2 -2
  10. package/dist/command-implementations/deploy-command.js +10 -8
  11. package/dist/command-implementations/deploy-command.js.map +2 -2
  12. package/dist/command-implementations/dev-command.js +9 -7
  13. package/dist/command-implementations/dev-command.js.map +2 -2
  14. package/dist/command-implementations/integration-commands.js.map +1 -1
  15. package/dist/command-implementations/login-command.js +2 -2
  16. package/dist/command-implementations/login-command.js.map +2 -2
  17. package/dist/command-implementations/project-command.js +9 -69
  18. package/dist/command-implementations/project-command.js.map +2 -2
  19. package/dist/command-implementations/serve-command.js +2 -1
  20. package/dist/command-implementations/serve-command.js.map +2 -2
  21. package/dist/sdk/validate-integration.js +68 -0
  22. package/dist/sdk/validate-integration.js.map +7 -0
  23. package/dist/utils/guard-utils.js +2 -1
  24. package/dist/utils/guard-utils.js.map +2 -2
  25. package/dist/utils/index.js +3 -0
  26. package/dist/utils/index.js.map +2 -2
  27. package/dist/utils/record-utils.js +12 -1
  28. package/dist/utils/record-utils.js.map +2 -2
  29. package/dist/utils/string-utils.js +35 -0
  30. package/dist/utils/string-utils.js.map +7 -0
  31. package/package.json +3 -3
  32. package/templates/echo-bot/package.json +2 -2
  33. package/templates/empty-integration/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/integration-commands.ts"],
4
- "sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport chalk from 'chalk'\nimport _ from 'lodash'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parseIntegrationRef } from '../integration-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.get\nexport class GetIntegrationCommand extends GlobalCommand<GetIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local integration')\n }\n\n try {\n const integration = await api.findIntegration(parsedRef)\n if (integration) {\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)}:`)\n this.logger.json(integration)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n}\n\nexport type ListIntegrationsCommandDefinition = typeof commandDefinitions.integrations.subcommands.list\nexport class ListIntegrationsCommand extends GlobalCommand<ListIntegrationsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const { dev, name, versionNumber: version } = this.argv\n\n const privateLister = (req: { nextToken?: string }) =>\n api.client.listIntegrations({ nextToken: req.nextToken, dev, name, version })\n\n const dummyLister: typeof privateLister = async () => ({ integrations: [], meta: {} })\n const publicLister = dev\n ? dummyLister\n : (req: { nextToken?: string }) => api.client.listPublicIntegrations({ nextToken: req.nextToken, name, version })\n\n try {\n const privateIntegrations = await api.listAllPages(privateLister, (r) => r.integrations)\n const publicIntegrations = await api.listAllPages(publicLister, (r) => r.integrations)\n const integrations = _.uniqBy([...privateIntegrations, ...publicIntegrations], (i) => i.id)\n\n this.logger.success('Integrations:')\n this.logger.json(integrations)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list integrations')\n }\n }\n}\n\nexport type DeleteIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.delete\nexport class DeleteIntegrationCommand extends GlobalCommand<DeleteIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local integration')\n }\n\n let integration: bpclient.Integration | undefined\n try {\n integration = await api.findPrivateIntegration(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n if (!integration) {\n const publicIntegration = await api.findPublicIntegration(parsedRef)\n if (publicIntegration) {\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} does not belong to your workspace`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n\n try {\n await api.client.deleteIntegration({ id: integration.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete integration ${this.argv.integrationRef}`)\n }\n\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)} deleted`)\n return\n }\n}\n"],
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport _ from 'lodash'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parseIntegrationRef } from '../integration-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.get\nexport class GetIntegrationCommand extends GlobalCommand<GetIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local integration')\n }\n\n try {\n const integration = await api.findIntegration(parsedRef)\n if (integration) {\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)}:`)\n this.logger.json(integration)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n}\n\nexport type ListIntegrationsCommandDefinition = typeof commandDefinitions.integrations.subcommands.list\nexport class ListIntegrationsCommand extends GlobalCommand<ListIntegrationsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const { dev, name, versionNumber: version } = this.argv\n\n const privateLister = (req: { nextToken?: string }) =>\n api.client.listIntegrations({ nextToken: req.nextToken, dev, name, version })\n\n const dummyLister: typeof privateLister = async () => ({ integrations: [], meta: {} })\n const publicLister = dev\n ? dummyLister\n : (req: { nextToken?: string }) => api.client.listPublicIntegrations({ nextToken: req.nextToken, name, version })\n\n try {\n const privateIntegrations = await api.listAllPages(privateLister, (r) => r.integrations)\n const publicIntegrations = await api.listAllPages(publicLister, (r) => r.integrations)\n const integrations = _.uniqBy([...privateIntegrations, ...publicIntegrations], (i) => i.id)\n\n this.logger.success('Integrations:')\n this.logger.json(integrations)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list integrations')\n }\n }\n}\n\nexport type DeleteIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.delete\nexport class DeleteIntegrationCommand extends GlobalCommand<DeleteIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parseIntegrationRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidIntegrationReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local integration')\n }\n\n let integration: client.Integration | undefined\n try {\n integration = await api.findPrivateIntegration(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n if (!integration) {\n const publicIntegration = await api.findPublicIntegration(parsedRef)\n if (publicIntegration) {\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} does not belong to your workspace`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n\n try {\n await api.client.deleteIntegration({ id: integration.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete integration ${this.argv.integrationRef}`)\n }\n\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)} deleted`)\n return\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAc;AAEd,aAAwB;AACxB,6BAAoC;AACpC,4BAA8B;AAGvB,MAAM,8BAA8B,oCAA+C;AAAA,EACxF,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,4CAAoB,KAAK,KAAK,cAAc;AAC9D,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,OAAO,iCAAiC,KAAK,KAAK,cAAc;AAAA,IAC5E;AACA,QAAI,UAAU,SAAS,QAAQ;AAC7B,YAAM,IAAI,OAAO,iBAAiB,8BAA8B;AAAA,IAClE;AAEA,QAAI;AACF,YAAM,cAAc,MAAM,IAAI,gBAAgB,SAAS;AACvD,UAAI,aAAa;AACf,aAAK,OAAO,QAAQ,eAAe,aAAAA,QAAM,KAAK,KAAK,KAAK,cAAc,IAAI;AAC1E,aAAK,OAAO,KAAK,WAAW;AAC5B;AAAA,MACF;AAAA,IACF,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6BAA6B,KAAK,KAAK,gBAAgB;AAAA,IACpG;AAEA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AAiC;AAAA,IACrE;AAEA,QAAI;AACJ,QAAI;AACF,oBAAc,MAAM,IAAI,uBAAuB,SAAS;AAAA,IAC1D,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6BAA6B,KAAK,KAAK,gBAAgB;AAAA,IACpG;AAEA,QAAI,CAAC,aAAa;AAChB,YAAM,oBAAoB,MAAM,IAAI,sBAAsB,SAAS;AACnE,UAAI,mBAAmB;AACrB,cAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,kDAAkD;AAAA,MAC/G;AAEA,YAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,0BAA0B;AAAA,IACvF;AAEA,QAAI;AACF,YAAM,IAAI,OAAO,kBAAkB,EAAE,IAAI,YAAY,GAAG,CAAC;AAAA,IAC3D,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,gCAAgC,KAAK,KAAK,gBAAgB;AAAA,IACvG;AAEA,SAAK,OAAO,QAAQ,eAAe,aAAAD,QAAM,KAAK,KAAK,KAAK,cAAc,WAAW;AACjF;AAAA,EACF;AACF;",
6
6
  "names": ["chalk", "_"]
7
7
  }
@@ -27,7 +27,7 @@ __export(login_command_exports, {
27
27
  LoginCommand: () => LoginCommand
28
28
  });
29
29
  module.exports = __toCommonJS(login_command_exports);
30
- var bpclient = __toESM(require("@botpress/client"));
30
+ var client = __toESM(require("@botpress/client"));
31
31
  var paging = __toESM(require("../api/paging"));
32
32
  var errors = __toESM(require("../errors"));
33
33
  var import_global_command = require("./global-command");
@@ -43,7 +43,7 @@ class LoginCommand extends import_global_command.GlobalCommand {
43
43
  return prompted;
44
44
  });
45
45
  const promptedWorkspaceId = await this.globalCache.sync("workspaceId", this.argv.workspaceId, async (defaultId) => {
46
- const tmpClient = new bpclient.Client({ apiUrl: this.argv.apiUrl, token: promptedToken });
46
+ const tmpClient = new client.Client({ apiUrl: this.argv.apiUrl, token: promptedToken });
47
47
  const userWorkspaces = await paging.listAllPages(tmpClient.listWorkspaces, (r) => r.workspaces).catch((thrown) => {
48
48
  throw errors.BotpressCLIError.wrap(thrown, "Could not list workspaces");
49
49
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/login-command.ts"],
4
- "sourcesContent": ["import * as bpclient from '@botpress/client'\nimport * as paging from '../api/paging'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { GlobalCommand } from './global-command'\n\nexport type LoginCommandDefinition = typeof commandDefinitions.login\nexport class LoginCommand extends GlobalCommand<LoginCommandDefinition> {\n public async run(): Promise<void> {\n const promptedToken = await this.globalCache.sync('token', this.argv.token, async (previousToken) => {\n const prompted = await this.prompt.text('Enter your Personal Access Token', {\n initial: previousToken,\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Personal Access Token')\n }\n\n return prompted\n })\n\n const promptedWorkspaceId = await this.globalCache.sync('workspaceId', this.argv.workspaceId, async (defaultId) => {\n const tmpClient = new bpclient.Client({ apiUrl: this.argv.apiUrl, token: promptedToken }) // no workspaceId yet\n const userWorkspaces = await paging\n .listAllPages(tmpClient.listWorkspaces, (r) => r.workspaces)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n\n if (userWorkspaces.length === 0) {\n throw new errors.NoWorkspacesFoundError()\n }\n\n const initial = userWorkspaces.find((ws) => ws.id === defaultId)\n\n const prompted = await this.prompt.select('Which workspace do you want to login to?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userWorkspaces.map((ws) => ({ title: ws.name, value: ws.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Workspace Id')\n }\n\n return prompted\n })\n\n await this.globalCache.set('apiUrl', this.argv.apiUrl)\n\n const api = this.api.newClient(\n { apiUrl: this.argv.apiUrl, token: promptedToken, workspaceId: promptedWorkspaceId },\n this.logger\n )\n\n await api.testLogin().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(th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,UAAU;AACb,cAAM,IAAI,OAAO,mBAAmB,cAAc;AAAA,MACpD;AAEA,aAAO;AAAA,IACT,CAAC;AAED,UAAM,KAAK,YAAY,IAAI,UAAU,KAAK,KAAK,MAAM;AAErD,UAAM,MAAM,KAAK,IAAI;AAAA,MACnB,EAAE,QAAQ,KAAK,KAAK,QAAQ,OAAO,eAAe,aAAa,oBAAoB;AAAA,MACnF,KAAK;AAAA,IACP;AAEA,UAAM,IAAI,UAAU,EAAE,MAAM,CAAC,WAAW;AACtC,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6CAA6C;AAAA,IAC1F,CAAC;AAED,SAAK,OAAO,QAAQ,WAAW;AAAA,EACjC;AACF;",
4
+ "sourcesContent": ["import * as client from '@botpress/client'\nimport * as paging from '../api/paging'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { GlobalCommand } from './global-command'\n\nexport type LoginCommandDefinition = typeof commandDefinitions.login\nexport class LoginCommand extends GlobalCommand<LoginCommandDefinition> {\n public async run(): Promise<void> {\n const promptedToken = await this.globalCache.sync('token', this.argv.token, async (previousToken) => {\n const prompted = await this.prompt.text('Enter your Personal Access Token', {\n initial: previousToken,\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Personal Access Token')\n }\n\n return prompted\n })\n\n const promptedWorkspaceId = await this.globalCache.sync('workspaceId', this.argv.workspaceId, async (defaultId) => {\n const tmpClient = new client.Client({ apiUrl: this.argv.apiUrl, token: promptedToken }) // no workspaceId yet\n const userWorkspaces = await paging\n .listAllPages(tmpClient.listWorkspaces, (r) => r.workspaces)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list workspaces')\n })\n\n if (userWorkspaces.length === 0) {\n throw new errors.NoWorkspacesFoundError()\n }\n\n const initial = userWorkspaces.find((ws) => ws.id === defaultId)\n\n const prompted = await this.prompt.select('Which workspace do you want to login to?', {\n initial: initial && { title: initial.name, value: initial.id },\n choices: userWorkspaces.map((ws) => ({ title: ws.name, value: ws.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Workspace Id')\n }\n\n return prompted\n })\n\n await this.globalCache.set('apiUrl', this.argv.apiUrl)\n\n const api = this.api.newClient(\n { apiUrl: this.argv.apiUrl, token: promptedToken, workspaceId: promptedWorkspaceId },\n this.logger\n )\n\n await api.testLogin().catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Login failed. Please check your credentials')\n })\n\n this.logger.success('Logged In')\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,aAAwB;AAExB,aAAwB;AACxB,4BAA8B;AAGvB,MAAM,qBAAqB,oCAAsC;AAAA,EACtE,MAAa,MAAqB;AAChC,UAAM,gBAAgB,MAAM,KAAK,YAAY,KAAK,SAAS,KAAK,KAAK,OAAO,OAAO,kBAAkB;AACnG,YAAM,WAAW,MAAM,KAAK,OAAO,KAAK,oCAAoC;AAAA,QAC1E,SAAS;AAAA,MACX,CAAC;AAED,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,mBAAmB,uBAAuB;AAAA,MAC7D;AAEA,aAAO;AAAA,IACT,CAAC;AAED,UAAM,sBAAsB,MAAM,KAAK,YAAY,KAAK,eAAe,KAAK,KAAK,aAAa,OAAO,cAAc;AACjH,YAAM,YAAY,IAAI,OAAO,OAAO,EAAE,QAAQ,KAAK,KAAK,QAAQ,OAAO,cAAc,CAAC;AACtF,YAAM,iBAAiB,MAAM,OAC1B,aAAa,UAAU,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAC1D,MAAM,CAAC,WAAW;AACjB,cAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B;AAAA,MACxE,CAAC;AAEH,UAAI,eAAe,WAAW,GAAG;AAC/B,cAAM,IAAI,OAAO,uBAAuB;AAAA,MAC1C;AAEA,YAAM,UAAU,eAAe,KAAK,CAAC,OAAO,GAAG,OAAO,SAAS;AAE/D,YAAM,WAAW,MAAM,KAAK,OAAO,OAAO,4CAA4C;AAAA,QACpF,SAAS,WAAW,EAAE,OAAO,QAAQ,MAAM,OAAO,QAAQ,GAAG;AAAA,QAC7D,SAAS,eAAe,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,OAAO,GAAG,GAAG,EAAE;AAAA,MACxE,CAAC;AAED,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,OAAO,mBAAmB,cAAc;AAAA,MACpD;AAEA,aAAO;AAAA,IACT,CAAC;AAED,UAAM,KAAK,YAAY,IAAI,UAAU,KAAK,KAAK,MAAM;AAErD,UAAM,MAAM,KAAK,IAAI;AAAA,MACnB,EAAE,QAAQ,KAAK,KAAK,QAAQ,OAAO,eAAe,aAAa,oBAAoB;AAAA,MACnF,KAAK;AAAA,IACP;AAEA,UAAM,IAAI,UAAU,EAAE,MAAM,CAAC,WAAW;AACtC,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6CAA6C;AAAA,IAC1F,CAAC;AAED,SAAK,OAAO,QAAQ,WAAW;AAAA,EACjC;AACF;",
6
6
  "names": []
7
7
  }
@@ -37,6 +37,7 @@ var codegen = __toESM(require("../code-generation"));
37
37
  var consts = __toESM(require("../consts"));
38
38
  var errors = __toESM(require("../errors"));
39
39
  var import_integration_ref = require("../integration-ref");
40
+ var import_validate_integration = require("../sdk/validate-integration");
40
41
  var utils = __toESM(require("../utils"));
41
42
  var import_global_command = require("./global-command");
42
43
  class ProjectPaths extends utils.path.PathStore {
@@ -64,9 +65,9 @@ class ProjectCommand extends import_global_command.GlobalCommand {
64
65
  get projectCache() {
65
66
  return new utils.cache.FSKeyValueCache(this.projectPaths.abs.projectCacheFile);
66
67
  }
67
- async prepareBotIntegrationInstances(bot, api) {
68
+ async fetchBotIntegrationInstances(bot, api) {
68
69
  const integrationList = (0, import_lodash.default)(bot.props.integrations).values().filter(utils.guards.is.defined).value();
69
- const { apiInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList);
70
+ const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList);
70
71
  const fetchedInstances = await import_bluebird.default.map(localInstances, async (instance) => {
71
72
  const ref = { type: "name", name: instance.name, version: instance.version };
72
73
  const integration = await api.findIntegration(ref);
@@ -76,74 +77,19 @@ class ProjectCommand extends import_global_command.GlobalCommand {
76
77
  }
77
78
  return { ...instance, id: integration.id };
78
79
  });
79
- return {
80
- integrations: (0, import_lodash.default)([...fetchedInstances, ...apiInstances]).keyBy((i) => i.id).mapValues(({ enabled, configuration }) => ({ enabled, configuration })).value()
81
- };
80
+ return (0, import_lodash.default)([...fetchedInstances, ...remoteInstances]).keyBy((i) => i.id).mapValues(({ enabled, configuration }) => ({ enabled, configuration })).value();
82
81
  }
83
82
  _splitApiAndLocalIntegrationInstances(instances) {
84
- const apiInstances = [];
83
+ const remoteInstances = [];
85
84
  const localInstances = [];
86
85
  for (const { id, ...instance } of instances) {
87
86
  if (id) {
88
- apiInstances.push({ ...instance, id });
87
+ remoteInstances.push({ ...instance, id });
89
88
  } else {
90
89
  localInstances.push({ ...instance, id: null });
91
90
  }
92
91
  }
93
- return { apiInstances, localInstances };
94
- }
95
- prepareBot(bot) {
96
- return {
97
- ...bot.props,
98
- configuration: bot.props.configuration ? {
99
- ...bot.props.configuration,
100
- schema: utils.schema.mapZodToJsonSchema(bot.props.configuration)
101
- } : void 0,
102
- events: bot.props.events ? import_lodash.default.mapValues(bot.props.events, (event) => ({
103
- ...event,
104
- schema: utils.schema.mapZodToJsonSchema(event)
105
- })) : void 0,
106
- states: bot.props.states ? import_lodash.default.mapValues(bot.props.states, (state) => ({
107
- ...state,
108
- schema: utils.schema.mapZodToJsonSchema(state)
109
- })) : void 0
110
- };
111
- }
112
- prepareIntegrationDefinition(integration) {
113
- return {
114
- ...integration,
115
- secrets: void 0,
116
- configuration: integration.configuration ? {
117
- ...integration.configuration,
118
- schema: utils.schema.mapZodToJsonSchema(integration.configuration)
119
- } : void 0,
120
- events: integration.events ? import_lodash.default.mapValues(integration.events, (event) => ({
121
- ...event,
122
- schema: utils.schema.mapZodToJsonSchema(event)
123
- })) : void 0,
124
- actions: integration.actions ? import_lodash.default.mapValues(integration.actions, (action) => ({
125
- ...action,
126
- input: {
127
- ...action.input,
128
- schema: utils.schema.mapZodToJsonSchema(action.input)
129
- },
130
- output: {
131
- ...action.output,
132
- schema: utils.schema.mapZodToJsonSchema(action.output)
133
- }
134
- })) : void 0,
135
- channels: integration.channels ? import_lodash.default.mapValues(integration.channels, (channel) => ({
136
- ...channel,
137
- messages: import_lodash.default.mapValues(channel.messages, (message) => ({
138
- ...message,
139
- schema: utils.schema.mapZodToJsonSchema(message)
140
- }))
141
- })) : void 0,
142
- states: integration.states ? import_lodash.default.mapValues(integration.states, (state) => ({
143
- ...state,
144
- schema: utils.schema.mapZodToJsonSchema(state)
145
- })) : void 0
146
- };
92
+ return { remoteInstances, localInstances };
147
93
  }
148
94
  async readIntegrationDefinitionFromFS(projectPaths = this.projectPaths) {
149
95
  const abs = projectPaths.abs;
@@ -163,6 +109,7 @@ class ProjectCommand extends import_global_command.GlobalCommand {
163
109
  throw new errors.BotpressCLIError("Could not read integration definition");
164
110
  }
165
111
  const { default: definition } = utils.require.requireJsCode(artifact.text);
112
+ (0, import_validate_integration.validateIntegrationDefinition)(definition);
166
113
  return definition;
167
114
  }
168
115
  async writeGeneratedFilesToOutFolder(files) {
@@ -253,7 +200,7 @@ class ProjectCommand extends import_global_command.GlobalCommand {
253
200
  _parseArgvSecrets(argvSecrets) {
254
201
  const parsed = {};
255
202
  for (const secret of argvSecrets) {
256
- const [key, value] = this._splitOnce(secret, "=");
203
+ const [key, value] = utils.string.splitOnce(secret, "=");
257
204
  if (!value) {
258
205
  throw new errors.BotpressCLIError(
259
206
  `Secret "${key}" is missing a value. Expected format: "SECRET_NAME=secretValue"`
@@ -263,13 +210,6 @@ class ProjectCommand extends import_global_command.GlobalCommand {
263
210
  }
264
211
  return parsed;
265
212
  }
266
- _splitOnce = (text, separator) => {
267
- const index = text.indexOf(separator);
268
- if (index === -1) {
269
- return [text, void 0];
270
- }
271
- return [text.slice(0, index), text.slice(index + 1)];
272
- };
273
213
  _notifyUpdateSdk = async () => {
274
214
  try {
275
215
  this.logger.debug("Checking if sdk is up to date");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/project-command.ts"],
4
- "sourcesContent": ["import type * as bpclient from '@botpress/client'\nimport type * as bpsdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatIntegrationRef, IntegrationRef } from '../integration-ref'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype ApiIntegrationInstance = utils.types.Merge<bpsdk.IntegrationInstance<string>, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<bpsdk.IntegrationInstance<string>, { id: null }>\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async prepareBotIntegrationInstances(bot: bpsdk.Bot, api: ApiClient) {\n const integrationList = _(bot.props.integrations).values().filter(utils.guards.is.defined).value()\n\n const { apiInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: ApiIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: IntegrationRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatIntegrationRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return {\n integrations: _([...fetchedInstances, ...apiInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configuration }) => ({ enabled, configuration }))\n .value(),\n }\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: bpsdk.IntegrationInstance<string>[]): {\n apiInstances: ApiIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const apiInstances: ApiIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const { id, ...instance } of instances) {\n if (id) {\n apiInstances.push({ ...instance, id })\n } else {\n localInstances.push({ ...instance, id: null })\n }\n }\n\n return { apiInstances, localInstances }\n }\n\n protected prepareBot(bot: bpsdk.Bot) {\n return {\n ...bot.props,\n configuration: bot.props.configuration\n ? {\n ...bot.props.configuration,\n schema: utils.schema.mapZodToJsonSchema(bot.props.configuration),\n }\n : undefined,\n events: bot.props.events\n ? _.mapValues(bot.props.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n states: bot.props.states\n ? _.mapValues(bot.props.states, (state) => ({\n ...state,\n schema: utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n }\n }\n\n protected prepareIntegrationDefinition(integration: bpsdk.IntegrationDefinition) {\n return {\n ...integration,\n secrets: undefined,\n configuration: integration.configuration\n ? {\n ...integration.configuration,\n schema: utils.schema.mapZodToJsonSchema(integration.configuration),\n }\n : undefined,\n events: integration.events\n ? _.mapValues(integration.events, (event) => ({\n ...event,\n schema: utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: integration.actions\n ? _.mapValues(integration.actions, (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n channels: integration.channels\n ? _.mapValues(integration.channels, (channel) => ({\n ...channel,\n messages: _.mapValues(channel.messages, (message) => ({\n ...message,\n schema: utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : undefined,\n states: integration.states\n ? _.mapValues(integration.states, (state) => ({\n ...state,\n schema: utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n }\n }\n\n protected async readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'definition'> = this.projectPaths\n ): Promise<bpsdk.IntegrationDefinition | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.definition)) {\n this.logger.debug(`Integration definition not found at ${rel.definition}`)\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.definition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: bpsdk.IntegrationDefinition }>(artifact.text)\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected displayWebhookUrls(bot: bpclient.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: bpsdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts?: { formatEnv?: boolean }\n ): Promise<Record<string, string>>\n protected async promptSecrets(\n integrationDef: bpsdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts?: { formatEnv?: boolean; knownSecrets: string[] }\n ): Promise<Record<string, string | null>>\n protected async promptSecrets(\n integrationDef: bpsdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = this._splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _splitOnce = (text: string, separator: string): [string, string | undefined] => {\n const index = text.indexOf(separator)\n if (index === -1) {\n return [text, undefined]\n }\n return [text.slice(0, index), text.slice(index + 1)]\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sd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A,YAAM,OAAO,cAAAA,QAAO,KAAK,yBAAyB,yBAAyB;AAC3E,UAAI,CAAC,MAAM;AACT,aAAK,OAAO,MAAM,+BAA+B,iCAAiC,4BAA4B;AAC9G;AAAA,MACF;AAEA,YAAM,WAAW,2BAA2B,2CAA2C;AACvF,UAAI,MAAM,OAAO,SAAS,GAAG,MAAM,OAAO,GAAG;AAC3C,aAAK,OAAO,MAAM,GAAG,gDAAgD;AACrE;AAAA,MACF;AAEA,WAAK,OAAO,KAAK,aAAAD,QAAM,KAAK,GAAG,iDAAiD,CAAC;AAAA,IACnF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport bluebird from 'bluebird'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport pathlib from 'path'\nimport semver from 'semver'\nimport { ApiClient } from '../api/client'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { formatIntegrationRef, IntegrationRef } from '../integration-ref'\nimport { validateIntegrationDefinition } from '../sdk/validate-integration'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\nexport type ProjectCommandDefinition = CommandDefinition<typeof config.schemas.project>\nexport type ProjectCache = { botId: string; devId: string }\n\ntype ConfigurableProjectPaths = { entryPoint: string; outDir: string; workDir: string }\ntype ConstantProjectPaths = typeof consts.fromOutDir & typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype RemoteIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<string>, { id: string }>\ntype LocalIntegrationInstance = utils.types.Merge<sdk.IntegrationInstance<string>, { id: null }>\n\nclass ProjectPaths extends utils.path.PathStore<keyof AllProjectPaths> {\n public constructor(argv: CommandArgv<ProjectCommandDefinition>) {\n const absWorkDir = utils.path.absoluteFrom(utils.path.cwd(), argv.workDir)\n const absEntrypoint = utils.path.absoluteFrom(absWorkDir, argv.entryPoint)\n const absOutDir = utils.path.absoluteFrom(absWorkDir, argv.outDir)\n super({\n workDir: absWorkDir,\n entryPoint: absEntrypoint,\n outDir: absOutDir,\n ..._.mapValues(consts.fromOutDir, (p) => utils.path.absoluteFrom(absOutDir, p)),\n ..._.mapValues(consts.fromWorkDir, (p) => utils.path.absoluteFrom(absWorkDir, p)),\n })\n }\n}\n\nexport abstract class ProjectCommand<C extends ProjectCommandDefinition> extends GlobalCommand<C> {\n protected override async bootstrap() {\n await super.bootstrap()\n await this._notifyUpdateSdk()\n }\n\n protected get projectPaths() {\n return new ProjectPaths(this.argv)\n }\n\n protected get projectCache() {\n return new utils.cache.FSKeyValueCache<ProjectCache>(this.projectPaths.abs.projectCacheFile)\n }\n\n protected async fetchBotIntegrationInstances(bot: sdk.Bot, api: ApiClient) {\n const integrationList = _(bot.props.integrations).values().filter(utils.guards.is.defined).value()\n\n const { remoteInstances, localInstances } = this._splitApiAndLocalIntegrationInstances(integrationList)\n\n const fetchedInstances: RemoteIntegrationInstance[] = await bluebird.map(localInstances, async (instance) => {\n const ref: IntegrationRef = { type: 'name', name: instance.name, version: instance.version }\n const integration = await api.findIntegration(ref)\n if (!integration) {\n const formattedRef = formatIntegrationRef(ref)\n throw new errors.BotpressCLIError(`Integration \"${formattedRef}\" not found`)\n }\n return { ...instance, id: integration.id }\n })\n\n return _([...fetchedInstances, ...remoteInstances])\n .keyBy((i) => i.id)\n .mapValues(({ enabled, configuration }) => ({ enabled, configuration }))\n .value()\n }\n\n private _splitApiAndLocalIntegrationInstances(instances: sdk.IntegrationInstance<string>[]): {\n remoteInstances: RemoteIntegrationInstance[]\n localInstances: LocalIntegrationInstance[]\n } {\n const remoteInstances: RemoteIntegrationInstance[] = []\n const localInstances: LocalIntegrationInstance[] = []\n for (const { id, ...instance } of instances) {\n if (id) {\n remoteInstances.push({ ...instance, id })\n } else {\n localInstances.push({ ...instance, id: null })\n }\n }\n\n return { remoteInstances, localInstances }\n }\n\n protected async readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'definition'> = this.projectPaths\n ): Promise<sdk.IntegrationDefinition | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.definition)) {\n this.logger.debug(`Integration definition not found at ${rel.definition}`)\n return\n }\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n cwd: abs.workDir,\n outfile: '',\n entrypoint: rel.definition,\n write: false,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read integration definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.IntegrationDefinition }>(artifact.text)\n\n validateIntegrationDefinition(definition)\n\n return definition\n }\n\n protected async writeGeneratedFilesToOutFolder(files: codegen.File[]) {\n for (const file of files) {\n const filePath = utils.path.absoluteFrom(this.projectPaths.abs.outDir, file.path)\n const dirPath = pathlib.dirname(filePath)\n await fs.promises.mkdir(dirPath, { recursive: true })\n await fs.promises.writeFile(filePath, file.content)\n }\n }\n\n protected displayWebhookUrls(bot: client.Bot) {\n if (!_.keys(bot.integrations).length) {\n this.logger.debug('No integrations in bot')\n return\n }\n\n this.logger.log('Integrations:')\n for (const integration of Object.values(bot.integrations).filter(utils.guards.is.defined)) {\n if (!integration.enabled) {\n this.logger.log(`${chalk.grey(integration.name)} ${chalk.italic('(disabled)')}: ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CB', indent: 2 },\n })\n } else {\n this.logger.log(`${chalk.bold(integration.name)} : ${integration.webhookUrl}`, {\n prefix: { symbol: '\u25CF', indent: 2 },\n })\n }\n }\n }\n\n protected async promptSecrets(\n integrationDef: sdk.IntegrationDefinition,\n argv: YargsConfig<typeof config.schemas.secrets>,\n opts: { formatEnv?: boolean; knownSecrets?: string[] } = {}\n ): Promise<Record<string, string | null>> {\n const formatEnv = opts.formatEnv ?? false\n const knownSecrets = opts.knownSecrets ?? []\n\n const { secrets: secretDefinitions } = integrationDef\n if (!secretDefinitions) {\n return {}\n }\n\n const secretArgv = this._parseArgvSecrets(argv.secrets)\n const invalidSecret = Object.keys(secretArgv).find((s) => !secretDefinitions[s])\n if (invalidSecret) {\n throw new errors.BotpressCLIError(`Secret ${invalidSecret} is not defined in integration definition`)\n }\n\n const values: Record<string, string | null> = {}\n for (const [secretName, { optional }] of Object.entries(secretDefinitions)) {\n const argvSecret = secretArgv[secretName]\n if (argvSecret) {\n this.logger.debug(`Using secret \"${secretName}\" from argv`)\n values[secretName] = argvSecret\n continue\n }\n\n const alreadyKnown = knownSecrets.includes(secretName)\n let mode: string\n if (alreadyKnown) {\n mode = 'already set'\n } else if (optional) {\n mode = 'optional'\n } else {\n mode = 'required'\n }\n\n const prompted = await this.prompt.text(`Enter value for secret \"${secretName}\" (${mode})`)\n if (prompted) {\n values[secretName] = prompted\n continue\n }\n\n if (alreadyKnown) {\n this.logger.log(`Secret \"${secretName}\" is unchanged`)\n } else if (optional) {\n this.logger.warn(`Secret \"${secretName}\" is unassigned`)\n } else {\n throw new errors.BotpressCLIError(`Secret \"${secretName}\" is required`)\n }\n }\n\n for (const secretName of knownSecrets) {\n const isDefined = secretName in secretDefinitions\n if (isDefined) {\n continue\n }\n const prompted = await this.prompt.confirm(`Secret \"${secretName}\" was removed. Do you wish to delete it?`)\n if (prompted) {\n this.logger.log(`Deleting secret \"${secretName}\"`, { prefix: { symbol: '\u00D7', fg: 'red' } })\n values[secretName] = null\n }\n }\n\n if (!formatEnv) {\n return values\n }\n\n const envVariables = _.mapKeys(values, (_v, k) => codegen.secretEnvVariableName(k))\n return envVariables\n }\n\n private _parseArgvSecrets(argvSecrets: string[]): Record<string, string> {\n const parsed: Record<string, string> = {}\n for (const secret of argvSecrets) {\n const [key, value] = utils.string.splitOnce(secret, '=')\n if (!value) {\n throw new errors.BotpressCLIError(\n `Secret \"${key}\" is missing a value. Expected format: \"SECRET_NAME=secretValue\"`\n )\n }\n parsed[key!] = value\n }\n\n return parsed\n }\n\n private _notifyUpdateSdk = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if sdk is up to date')\n\n const { workDir } = this.projectPaths.abs\n const projectPkgJson = await utils.pkgJson.readPackageJson(workDir)\n if (!projectPkgJson) {\n this.logger.debug(`Could not find package.json at \"${workDir}\"`)\n return\n }\n\n const sdkPackageName = '@botpress/sdk'\n const actualSdkVersion = utils.pkgJson.findDependency(projectPkgJson, sdkPackageName)\n if (!actualSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in project package.json`)\n return\n }\n\n if (actualSdkVersion.startsWith('workspace:')) {\n return\n }\n\n const actualCleanedSdkVersion = semver.valid(semver.coerce(actualSdkVersion))\n if (!actualCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${actualSdkVersion}\" in project package.json`)\n return\n }\n\n const cliPkgJson = await this.readPkgJson()\n const expectedSdkVersion = utils.pkgJson.findDependency(cliPkgJson, sdkPackageName)\n if (!expectedSdkVersion) {\n this.logger.debug(`Could not find dependency \"${sdkPackageName}\" in cli package.json`)\n return\n }\n\n const expectedCleanedSdkVersion = semver.valid(semver.coerce(expectedSdkVersion))\n if (!expectedCleanedSdkVersion) {\n this.logger.debug(`Invalid sdk version \"${expectedSdkVersion}\" in cli package.json`)\n return\n }\n\n if (semver.eq(actualCleanedSdkVersion, expectedCleanedSdkVersion)) {\n return\n }\n\n const diff = semver.diff(actualCleanedSdkVersion, expectedCleanedSdkVersion)\n if (!diff) {\n this.logger.debug(`Could not compare versions \"${actualCleanedSdkVersion}\" and \"${expectedCleanedSdkVersion}\"`)\n return\n }\n\n const errorMsg = `Project SDK version is \"${actualCleanedSdkVersion}\", but expected \"${expectedCleanedSdkVersion}\"`\n if (utils.semver.releases.lt(diff, 'minor')) {\n this.logger.debug(`${errorMsg}. This may cause compatibility issues.`)\n return\n }\n\n this.logger.warn(chalk.bold(`${errorMsg}. This will cause compatibility issues.`))\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if sdk is up to date: ${err.message}`)\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAqB;AACrB,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,kBAAoB;AACpB,oBAAmB;AAEnB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,6BAAqD;AACrD,kCAA8C;AAE9C,YAAuB;AACvB,4BAA8B;AAY9B,MAAM,qBAAqB,MAAM,KAAK,UAAiC;AAAA,EAC9D,YAAY,MAA6C;AAC9D,UAAM,aAAa,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AACzE,UAAM,gBAAgB,MAAM,KAAK,aAAa,YAAY,KAAK,UAAU;AACzE,UAAM,YAAY,MAAM,KAAK,aAAa,YAAY,KAAK,MAAM;AACjE,UAAM;AAAA,MACJ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,GAAG,cAAAA,QAAE,UAAU,OAAO,YAAY,CAAC,MAAM,MAAM,KAAK,aAAa,WAAW,CAAC,CAAC;AAAA,MAC9E,GAAG,cAAAA,QAAE,UAAU,OAAO,aAAa,CAAC,MAAM,MAAM,KAAK,aAAa,YAAY,CAAC,CAAC;AAAA,IAClF,CAAC;AAAA,EACH;AACF;AAEO,MAAe,uBAA2D,oCAAiB;AAAA,EAChG,MAAyB,YAAY;AACnC,UAAM,MAAM,UAAU;AACtB,UAAM,KAAK,iBAAiB;AAAA,EAC9B;AAAA,EAEA,IAAc,eAAe;AAC3B,WAAO,IAAI,aAAa,KAAK,IAAI;AAAA,EACnC;AAAA,EAEA,IAAc,eAA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AAAA,EACF;AACF;",
6
6
  "names": ["_", "bluebird", "fs", "pathlib", "chalk", "semver"]
7
7
  }
@@ -40,7 +40,8 @@ class ServeCommand extends import_project_command.ProjectCommand {
40
40
  const integrationDef = await this.readIntegrationDefinitionFromFS();
41
41
  if (integrationDef) {
42
42
  const secretEnvVariables = await this.promptSecrets(integrationDef, this.argv, { formatEnv: true });
43
- for (const [key, value] of Object.entries(secretEnvVariables)) {
43
+ const nonNullSecretEnvVariables = utils.records.filterValues(secretEnvVariables, utils.guards.is.notNull);
44
+ for (const [key, value] of Object.entries(nonNullSecretEnvVariables)) {
44
45
  process.env[key] = value;
45
46
  }
46
47
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/command-implementations/serve-command.ts"],
4
- "sourcesContent": ["import type { Bot as BotImpl, Integration as IntegrationImpl } from '@botpress/sdk'\nimport * as fs from 'fs'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\ntype Serveable = BotImpl | IntegrationImpl\n\nexport type ServeCommandDefinition = typeof commandDefinitions.serve\nexport class ServeCommand extends ProjectCommand<ServeCommandDefinition> {\n public async run(): Promise<void> {\n const outfile = this.projectPaths.abs.outFile\n if (!fs.existsSync(outfile)) {\n throw new errors.NoBundleFoundError()\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n // TODO: store secrets in local cache to avoid prompting every time\n const secretEnvVariables = await this.promptSecrets(integrationDef, this.argv, { formatEnv: true })\n for (const [key, value] of Object.entries(secretEnvVariables)) {\n process.env[key] = value\n }\n }\n\n this.logger.log(`Serving ${integrationDef ? 'integration' : 'bot'}...`)\n\n const { default: serveable } = utils.require.requireJsFile<{ default: Serveable }>(outfile)\n const server = await serveable.start(this.argv.port)\n\n await new Promise<void>((resolve, reject) => {\n server.on('error', reject)\n server.on('close', resolve)\n })\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAKxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,UAAU,KAAK,aAAa,IAAI;AACtC,QAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AAC3B,YAAM,IAAI,OAAO,mBAAmB;AAAA,IACtC;AAEA,UAAM,iBAAiB,MAAM,KAAK,gCAAgC;AAClE,QAAI,gBAAgB;AAElB,YAAM,qBAAqB,MAAM,KAAK,cAAc,gBAAgB,KAAK,MAAM,EAAE,WAAW,KAAK,CAAC;AAClG,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,kBAAkB,GAAG;AAC7D,gBAAQ,IAAI,OAAO;AAAA,MACrB;AAAA,IACF;AAEA,SAAK,OAAO,IAAI,WAAW,iBAAiB,gBAAgB,UAAU;AAEtE,UAAM,EAAE,SAAS,UAAU,IAAI,MAAM,QAAQ,cAAsC,OAAO;AAC1F,UAAM,SAAS,MAAM,UAAU,MAAM,KAAK,KAAK,IAAI;AAEnD,UAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,aAAO,GAAG,SAAS,MAAM;AACzB,aAAO,GAAG,SAAS,OAAO;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import type { Bot as BotImpl, Integration as IntegrationImpl } from '@botpress/sdk'\nimport * as fs from 'fs'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\ntype Serveable = BotImpl | IntegrationImpl\n\nexport type ServeCommandDefinition = typeof commandDefinitions.serve\nexport class ServeCommand extends ProjectCommand<ServeCommandDefinition> {\n public async run(): Promise<void> {\n const outfile = this.projectPaths.abs.outFile\n if (!fs.existsSync(outfile)) {\n throw new errors.NoBundleFoundError()\n }\n\n const integrationDef = await this.readIntegrationDefinitionFromFS()\n if (integrationDef) {\n // TODO: store secrets in local cache to avoid prompting every time\n const secretEnvVariables = await this.promptSecrets(integrationDef, this.argv, { formatEnv: true })\n const nonNullSecretEnvVariables = utils.records.filterValues(secretEnvVariables, utils.guards.is.notNull)\n for (const [key, value] of Object.entries(nonNullSecretEnvVariables)) {\n process.env[key] = value\n }\n }\n\n this.logger.log(`Serving ${integrationDef ? 'integration' : 'bot'}...`)\n\n const { default: serveable } = utils.require.requireJsFile<{ default: Serveable }>(outfile)\n const server = await serveable.start(this.argv.port)\n\n await new Promise<void>((resolve, reject) => {\n server.on('error', reject)\n server.on('close', resolve)\n })\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAKxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,UAAU,KAAK,aAAa,IAAI;AACtC,QAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AAC3B,YAAM,IAAI,OAAO,mBAAmB;AAAA,IACtC;AAEA,UAAM,iBAAiB,MAAM,KAAK,gCAAgC;AAClE,QAAI,gBAAgB;AAElB,YAAM,qBAAqB,MAAM,KAAK,cAAc,gBAAgB,KAAK,MAAM,EAAE,WAAW,KAAK,CAAC;AAClG,YAAM,4BAA4B,MAAM,QAAQ,aAAa,oBAAoB,MAAM,OAAO,GAAG,OAAO;AACxG,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,yBAAyB,GAAG;AACpE,gBAAQ,IAAI,OAAO;AAAA,MACrB;AAAA,IACF;AAEA,SAAK,OAAO,IAAI,WAAW,iBAAiB,gBAAgB,UAAU;AAEtE,UAAM,EAAE,SAAS,UAAU,IAAI,MAAM,QAAQ,cAAsC,OAAO;AAC1F,UAAM,SAAS,MAAM,UAAU,MAAM,KAAK,KAAK,IAAI;AAEnD,UAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,aAAO,GAAG,SAAS,MAAM;AACzB,aAAO,GAAG,SAAS,OAAO;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,68 @@
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 validate_integration_exports = {};
26
+ __export(validate_integration_exports, {
27
+ validateIntegrationDefinition: () => validateIntegrationDefinition
28
+ });
29
+ module.exports = __toCommonJS(validate_integration_exports);
30
+ var errors = __toESM(require("../errors"));
31
+ var utils = __toESM(require("../utils"));
32
+ const validateIntegrationDefinition = (i) => {
33
+ const { actions, channels, events, states } = i;
34
+ const invalidActionNames = _nonCamelCaseKeys(actions ?? {});
35
+ if (invalidActionNames.length) {
36
+ throw new errors.BotpressCLIError(
37
+ `The following action names are not in camelCase: ${invalidActionNames.join(", ")}`
38
+ );
39
+ }
40
+ const invalidChannelNames = _nonCamelCaseKeys(channels ?? {});
41
+ if (invalidChannelNames.length) {
42
+ throw new errors.BotpressCLIError(
43
+ `The following channel names are not in camelCase: ${invalidChannelNames.join(", ")}`
44
+ );
45
+ }
46
+ const invalidMessageNames = Object.entries(channels ?? {}).flatMap(
47
+ ([channelName, channel]) => _nonCamelCaseKeys(channel.messages ?? {}).map((message) => `${channelName}.${message}`)
48
+ );
49
+ if (invalidMessageNames.length) {
50
+ throw new errors.BotpressCLIError(
51
+ `The following message names are not in camelCase: ${invalidMessageNames.join(", ")}`
52
+ );
53
+ }
54
+ const invalidEventNames = _nonCamelCaseKeys(events ?? {});
55
+ if (invalidEventNames.length) {
56
+ throw new errors.BotpressCLIError(`The following event names are not in camelCase: ${invalidEventNames.join(", ")}`);
57
+ }
58
+ const invalidStateNames = _nonCamelCaseKeys(states ?? {});
59
+ if (invalidStateNames.length) {
60
+ throw new errors.BotpressCLIError(`The following state names are not in camelCase: ${invalidStateNames.join(", ")}`);
61
+ }
62
+ };
63
+ const _nonCamelCaseKeys = (obj) => Object.keys(obj).filter((k) => !utils.casing.is.camelCase(k));
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ validateIntegrationDefinition
67
+ });
68
+ //# sourceMappingURL=validate-integration.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/sdk/validate-integration.ts"],
4
+ "sourcesContent": ["import type * as sdk from '@botpress/sdk'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\n\nexport const validateIntegrationDefinition = (i: sdk.IntegrationDefinition): void => {\n const { actions, channels, events, states } = i\n\n const invalidActionNames = _nonCamelCaseKeys(actions ?? {})\n if (invalidActionNames.length) {\n throw new errors.BotpressCLIError(\n `The following action names are not in camelCase: ${invalidActionNames.join(', ')}`\n )\n }\n\n const invalidChannelNames = _nonCamelCaseKeys(channels ?? {})\n if (invalidChannelNames.length) {\n throw new errors.BotpressCLIError(\n `The following channel names are not in camelCase: ${invalidChannelNames.join(', ')}`\n )\n }\n\n const invalidMessageNames = Object.entries(channels ?? {}).flatMap(([channelName, channel]) =>\n _nonCamelCaseKeys(channel.messages ?? {}).map((message) => `${channelName}.${message}`)\n )\n if (invalidMessageNames.length) {\n throw new errors.BotpressCLIError(\n `The following message names are not in camelCase: ${invalidMessageNames.join(', ')}`\n )\n }\n\n const invalidEventNames = _nonCamelCaseKeys(events ?? {})\n if (invalidEventNames.length) {\n throw new errors.BotpressCLIError(`The following event names are not in camelCase: ${invalidEventNames.join(', ')}`)\n }\n\n const invalidStateNames = _nonCamelCaseKeys(states ?? {})\n if (invalidStateNames.length) {\n throw new errors.BotpressCLIError(`The following state names are not in camelCase: ${invalidStateNames.join(', ')}`)\n }\n}\n\nconst _nonCamelCaseKeys = (obj: Record<string, any>): string[] =>\n Object.keys(obj).filter((k) => !utils.casing.is.camelCase(k))\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,YAAuB;AAEhB,MAAM,gCAAgC,CAAC,MAAuC;AACnF,QAAM,EAAE,SAAS,UAAU,QAAQ,OAAO,IAAI;AAE9C,QAAM,qBAAqB,kBAAkB,WAAW,CAAC,CAAC;AAC1D,MAAI,mBAAmB,QAAQ;AAC7B,UAAM,IAAI,OAAO;AAAA,MACf,oDAAoD,mBAAmB,KAAK,IAAI;AAAA,IAClF;AAAA,EACF;AAEA,QAAM,sBAAsB,kBAAkB,YAAY,CAAC,CAAC;AAC5D,MAAI,oBAAoB,QAAQ;AAC9B,UAAM,IAAI,OAAO;AAAA,MACf,qDAAqD,oBAAoB,KAAK,IAAI;AAAA,IACpF;AAAA,EACF;AAEA,QAAM,sBAAsB,OAAO,QAAQ,YAAY,CAAC,CAAC,EAAE;AAAA,IAAQ,CAAC,CAAC,aAAa,OAAO,MACvF,kBAAkB,QAAQ,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,GAAG,eAAe,SAAS;AAAA,EACxF;AACA,MAAI,oBAAoB,QAAQ;AAC9B,UAAM,IAAI,OAAO;AAAA,MACf,qDAAqD,oBAAoB,KAAK,IAAI;AAAA,IACpF;AAAA,EACF;AAEA,QAAM,oBAAoB,kBAAkB,UAAU,CAAC,CAAC;AACxD,MAAI,kBAAkB,QAAQ;AAC5B,UAAM,IAAI,OAAO,iBAAiB,mDAAmD,kBAAkB,KAAK,IAAI,GAAG;AAAA,EACrH;AAEA,QAAM,oBAAoB,kBAAkB,UAAU,CAAC,CAAC;AACxD,MAAI,kBAAkB,QAAQ;AAC5B,UAAM,IAAI,OAAO,iBAAiB,mDAAmD,kBAAkB,KAAK,IAAI,GAAG;AAAA,EACrH;AACF;AAEA,MAAM,oBAAoB,CAAC,QACzB,OAAO,KAAK,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC;",
6
+ "names": []
7
+ }
@@ -22,7 +22,8 @@ __export(guard_utils_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(guard_utils_exports);
24
24
  const is = {
25
- defined: (value) => value !== void 0
25
+ defined: (value) => value !== void 0,
26
+ notNull: (value) => value !== null
26
27
  };
27
28
  // Annotate the CommonJS export names for ESM import in node:
28
29
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/guard-utils.ts"],
4
- "sourcesContent": ["export const is = {\n defined: <T>(value: T | undefined): value is T => value !== undefined,\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,KAAK;AAAA,EAChB,SAAS,CAAI,UAAqC,UAAU;AAC9D;",
4
+ "sourcesContent": ["export const is = {\n defined: <T>(value: T | undefined): value is T => value !== undefined,\n notNull: <T>(value: T | null): value is T => value !== null,\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,KAAK;AAAA,EAChB,SAAS,CAAI,UAAqC,UAAU;AAAA,EAC5D,SAAS,CAAI,UAAgC,UAAU;AACzD;",
6
6
  "names": []
7
7
  }
@@ -38,6 +38,7 @@ __export(utils_exports, {
38
38
  require: () => require2,
39
39
  schema: () => schema,
40
40
  semver: () => semver,
41
+ string: () => string,
41
42
  tunnel: () => tunnel,
42
43
  types: () => types,
43
44
  url: () => url
@@ -57,6 +58,7 @@ var records = __toESM(require("./record-utils"));
57
58
  var require2 = __toESM(require("./require-utils"));
58
59
  var schema = __toESM(require("./schema-utils"));
59
60
  var semver = __toESM(require("./semver-utils"));
61
+ var string = __toESM(require("./string-utils"));
60
62
  var tunnel = __toESM(require("./tunnel-utils"));
61
63
  var types = __toESM(require("./type-utils"));
62
64
  var url = __toESM(require("./url-utils"));
@@ -76,6 +78,7 @@ var url = __toESM(require("./url-utils"));
76
78
  require,
77
79
  schema,
78
80
  semver,
81
+ string,
79
82
  tunnel,
80
83
  types,
81
84
  url
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/index.ts"],
4
- "sourcesContent": ["export * as cache from './cache-utils'\nexport * as casing from './case-utils'\nexport * as emitter from './event-emitter'\nexport * as esbuild from './esbuild-utils'\nexport * as filewatcher from './file-watcher'\nexport * as guards from './guard-utils'\nexport * as id from './id-utils'\nexport * as path from './path-utils'\nexport * as pkgJson from './pkgjson-utils'\nexport * as prompt from './prompt-utils'\nexport * as records from './record-utils'\nexport * as require from './require-utils'\nexport * as schema from './schema-utils'\nexport * as semver from './semver-utils'\nexport * as tunnel from './tunnel-utils'\nexport * as types from './type-utils'\nexport * as url from './url-utils'\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,cAAyB;AACzB,cAAyB;AACzB,kBAA6B;AAC7B,aAAwB;AACxB,SAAoB;AACpB,WAAsB;AACtB,cAAyB;AACzB,aAAwB;AACxB,cAAyB;AACzB,IAAAA,WAAyB;AACzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,UAAqB;",
4
+ "sourcesContent": ["export * as cache from './cache-utils'\nexport * as casing from './case-utils'\nexport * as emitter from './event-emitter'\nexport * as esbuild from './esbuild-utils'\nexport * as filewatcher from './file-watcher'\nexport * as guards from './guard-utils'\nexport * as id from './id-utils'\nexport * as path from './path-utils'\nexport * as pkgJson from './pkgjson-utils'\nexport * as prompt from './prompt-utils'\nexport * as records from './record-utils'\nexport * as require from './require-utils'\nexport * as schema from './schema-utils'\nexport * as semver from './semver-utils'\nexport * as string from './string-utils'\nexport * as tunnel from './tunnel-utils'\nexport * as types from './type-utils'\nexport * as url from './url-utils'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;AACvB,aAAwB;AACxB,cAAyB;AACzB,cAAyB;AACzB,kBAA6B;AAC7B,aAAwB;AACxB,SAAoB;AACpB,WAAsB;AACtB,cAAyB;AACzB,aAAwB;AACxB,cAAyB;AACzB,IAAAA,WAAyB;AACzB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,UAAqB;",
6
6
  "names": ["require"]
7
7
  }
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var record_utils_exports = {};
20
20
  __export(record_utils_exports, {
21
+ filterValues: () => filterValues,
21
22
  mapValues: () => mapValues,
22
23
  setNullOnMissingValues: () => setNullOnMissingValues,
23
24
  zipObjects: () => zipObjects
@@ -46,12 +47,22 @@ const zipObjects = (recordA, recordB) => {
46
47
  const mapValues = (record, fn) => {
47
48
  const newRecord = {};
48
49
  for (const [key, value] of Object.entries(record)) {
49
- newRecord[key] = fn(value);
50
+ newRecord[key] = fn(value, key);
50
51
  }
51
52
  return newRecord;
52
53
  };
54
+ function filterValues(record, fn) {
55
+ const newRecord = {};
56
+ for (const [key, value] of Object.entries(record)) {
57
+ if (fn(value, key)) {
58
+ newRecord[key] = value;
59
+ }
60
+ }
61
+ return newRecord;
62
+ }
53
63
  // Annotate the CommonJS export names for ESM import in node:
54
64
  0 && (module.exports = {
65
+ filterValues,
55
66
  mapValues,
56
67
  setNullOnMissingValues,
57
68
  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) => 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)\n }\n\n return newRecord\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;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,OAA2C;AACpG,QAAM,YAA+B,CAAC;AAEtC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,cAAU,OAAO,GAAG,KAAK;AAAA,EAC3B;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 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;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,35 @@
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 string_utils_exports = {};
20
+ __export(string_utils_exports, {
21
+ splitOnce: () => splitOnce
22
+ });
23
+ module.exports = __toCommonJS(string_utils_exports);
24
+ const splitOnce = (text, separator) => {
25
+ const index = text.indexOf(separator);
26
+ if (index === -1) {
27
+ return [text, void 0];
28
+ }
29
+ return [text.slice(0, index), text.slice(index + 1)];
30
+ };
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ splitOnce
34
+ });
35
+ //# sourceMappingURL=string-utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/string-utils.ts"],
4
+ "sourcesContent": ["export const splitOnce = (text: string, separator: string): [string, string | undefined] => {\n const index = text.indexOf(separator)\n if (index === -1) {\n return [text, undefined]\n }\n return [text.slice(0, index), text.slice(index + 1)]\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,YAAY,CAAC,MAAc,cAAoD;AAC1F,QAAM,QAAQ,KAAK,QAAQ,SAAS;AACpC,MAAI,UAAU,IAAI;AAChB,WAAO,CAAC,MAAM,MAAS;AAAA,EACzB;AACA,SAAO,CAAC,KAAK,MAAM,GAAG,KAAK,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC;AACrD;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "main": "dist/index.js",
22
22
  "dependencies": {
23
- "@botpress/client": "0.11.0",
23
+ "@botpress/client": "0.11.2",
24
24
  "@bpinternal/const": "^0.0.20",
25
25
  "@bpinternal/tunnel": "^0.1.1",
26
26
  "@bpinternal/yargs-extra": "^0.0.3",
@@ -48,7 +48,7 @@
48
48
  "zod": "^3.20.6"
49
49
  },
50
50
  "devDependencies": {
51
- "@botpress/sdk": "0.5.10",
51
+ "@botpress/sdk": "0.5.12",
52
52
  "@bpinternal/log4bot": "^0.0.4",
53
53
  "@types/bluebird": "^3.5.38",
54
54
  "@types/json-schema": "^7.0.11",
@@ -8,8 +8,8 @@
8
8
  "author": "",
9
9
  "license": "MIT",
10
10
  "dependencies": {
11
- "@botpress/client": "0.11.0",
12
- "@botpress/sdk": "0.5.10",
11
+ "@botpress/client": "0.11.2",
12
+ "@botpress/sdk": "0.5.12",
13
13
  "zod": "^3.20.6"
14
14
  },
15
15
  "devDependencies": {