@botpress/cli 4.11.2 → 4.11.3

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.
@@ -1,32 +1,32 @@
1
1
 
2
- > @botpress/cli@4.11.2 build /home/runner/work/botpress/botpress/packages/cli
2
+ > @botpress/cli@4.11.3 build /home/runner/work/botpress/botpress/packages/cli
3
3
  > pnpm run bundle && pnpm run template:gen
4
4
 
5
5
 
6
- > @botpress/cli@4.11.2 bundle /home/runner/work/botpress/botpress/packages/cli
6
+ > @botpress/cli@4.11.3 bundle /home/runner/work/botpress/botpress/packages/cli
7
7
  > ts-node -T build.ts
8
8
 
9
9
 
10
- > @botpress/cli@4.11.2 template:gen /home/runner/work/botpress/botpress/packages/cli
10
+ > @botpress/cli@4.11.3 template:gen /home/runner/work/botpress/botpress/packages/cli
11
11
  > pnpm -r --stream -F @bp-templates/* exec bp gen
12
12
 
13
- 🤖 Botpress CLI v4.11.2
14
- 🤖 Botpress CLI v4.11.2
15
- 🤖 Botpress CLI v4.11.2
16
- 🤖 Botpress CLI v4.11.2
17
- ○ Generating typings for plugin empty-plugin...
18
- ✓ Typings available at .botpress
19
-
13
+ 🤖 Botpress CLI v4.11.3
14
+ 🤖 Botpress CLI v4.11.3
15
+ 🤖 Botpress CLI v4.11.3
16
+ 🤖 Botpress CLI v4.11.3
20
17
  ○ Generating typings for integration hello-world...
21
- ○ Generating typings for integration empty-integration...
22
18
  ○ Generating typings for bot...
23
19
  ✓ Typings available at .botpress
24
20
 
25
21
  ✓ Typings available at .botpress
26
22
 
23
+ ○ Generating typings for plugin empty-plugin...
24
+ ✓ Typings available at .botpress
25
+
26
+ ○ Generating typings for integration empty-integration...
27
27
  ✓ Typings available at .botpress
28
28
 
29
- 🤖 Botpress CLI v4.11.2
29
+ 🤖 Botpress CLI v4.11.3
30
30
  ○ Generating typings for integration webhook-message...
31
31
  ✓ Typings available at .botpress
32
32
 
@@ -37,12 +37,19 @@ var import_yn = __toESM(require("yn"));
37
37
  var import_package_ref = require("../package-ref");
38
38
  var import_find_previous_version = require("./find-previous-version");
39
39
  var paging = __toESM(require("./paging"));
40
+ var retry = __toESM(require("./retry"));
40
41
  __reExport(client_exports, require("./types"), module.exports);
41
42
  class ApiClient {
42
43
  constructor(props, _logger) {
43
44
  this._logger = _logger;
44
45
  const { apiUrl, token, workspaceId, botId } = props;
45
- this.client = new client.Client({ apiUrl, token, workspaceId, botId });
46
+ this.client = new client.Client({
47
+ apiUrl,
48
+ token,
49
+ workspaceId,
50
+ botId,
51
+ retry: retry.config
52
+ });
46
53
  this.url = apiUrl;
47
54
  this.token = token;
48
55
  this.workspaceId = workspaceId;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/api/client.ts"],
4
- "sourcesContent": ["import * as client from '@botpress/client'\nimport yn from 'yn'\nimport type { Logger } from '../logger'\nimport { formatPackageRef, ApiPackageRef, NamePackageRef } from '../package-ref'\nimport * as utils from '../utils'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport * as paging from './paging'\n\nimport {\n ApiClientProps,\n PublicIntegration,\n PrivateIntegration,\n PublicOrPrivateIntegration,\n PublicInterface,\n PrivateInterface,\n PublicOrPrivateInterface,\n PrivatePlugin,\n PublicPlugin,\n PublicOrPrivatePlugin,\n BotSummary,\n} from './types'\n\nexport * from './types'\n\n/**\n * This class is used to wrap the Botpress API and provide a more convenient way to interact with it.\n */\nexport class ApiClient {\n public readonly client: client.Client\n public readonly url: string\n public readonly token: string\n public readonly workspaceId: string\n public readonly botId?: string\n\n public static newClient = (props: ApiClientProps, logger: Logger) => new ApiClient(props, logger)\n\n public constructor(\n props: ApiClientProps,\n private _logger: Logger\n ) {\n const { apiUrl, token, workspaceId, botId } = props\n this.client = new client.Client({ apiUrl, token, workspaceId, botId })\n this.url = apiUrl\n this.token = token\n this.workspaceId = workspaceId\n this.botId = botId\n }\n\n public get isBotpressWorkspace(): boolean {\n // this environment variable is undocumented and only used internally for dev purposes\n const isBotpressWorkspace = yn(process.env.BP_IS_BOTPRESS_WORKSPACE)\n if (isBotpressWorkspace !== undefined) {\n return isBotpressWorkspace\n }\n return [\n '6a76fa10-e150-4ff6-8f59-a300feec06c1',\n '95de33eb-1551-4af9-9088-e5dcb02efd09',\n '11111111-1111-1111-aaaa-111111111111',\n ].includes(this.workspaceId)\n }\n\n public async getWorkspace(): Promise<client.ClientOutputs['getWorkspace']> {\n return this.client.getWorkspace({ id: this.workspaceId })\n }\n\n public async findWorkspaceByHandle(handle: string): Promise<client.ClientOutputs['getWorkspace'] | undefined> {\n const { workspaces } = await this.client.listWorkspaces({ handle })\n return workspaces[0] // There should be only one workspace with a given handle\n }\n\n public switchWorkspace(workspaceId: string): ApiClient {\n return ApiClient.newClient({ apiUrl: this.url, token: this.token, workspaceId }, this._logger)\n }\n\n public switchBot(botId: string): ApiClient {\n return ApiClient.newClient(\n { apiUrl: this.url, token: this.token, botId, workspaceId: this.workspaceId },\n this._logger\n )\n }\n\n public async updateWorkspace(\n props: utils.types.SafeOmit<client.ClientInputs['updateWorkspace'], 'id'>\n ): Promise<client.ClientOutputs['updateWorkspace']> {\n return this.client.updateWorkspace({ id: this.workspaceId, ...props })\n }\n\n public async getPublicOrPrivateIntegration(ref: ApiPackageRef): Promise<PublicOrPrivateIntegration> {\n const integration = await this.findPublicOrPrivateIntegration(ref)\n if (!integration) {\n throw new Error(`Integration \"${formatPackageRef(ref)}\" not found`)\n }\n return integration\n }\n\n public async findPublicOrPrivateIntegration(ref: ApiPackageRef): Promise<PublicOrPrivateIntegration | undefined> {\n const formatted = formatPackageRef(ref)\n\n const privateIntegration = await this.findPrivateIntegration(ref)\n if (privateIntegration) {\n this._logger.debug(`Found integration \"${formatted}\" in workspace`)\n return privateIntegration\n }\n\n const publicIntegration = await this.findPublicIntegration(ref)\n if (publicIntegration) {\n this._logger.debug(`Found integration \"${formatted}\" in hub`)\n return publicIntegration\n }\n\n return\n }\n\n public async findPrivateIntegration(ref: ApiPackageRef): Promise<PrivateIntegration | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.client\n .getIntegration(ref)\n .then((r) => ({ ...r.integration, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getIntegrationByName(ref)\n .then((r) => ({ ...r.integration, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicIntegration(ref: ApiPackageRef): Promise<PublicIntegration | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPublicIntegrationById(ref)\n .then((r) => ({ ...r.integration, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getPublicIntegration(ref)\n .then((r) => ({ ...r.integration, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicOrPrivateInterface(ref: ApiPackageRef): Promise<PublicOrPrivateInterface | undefined> {\n const formatted = formatPackageRef(ref)\n\n const privateInterface = await this.findPrivateInterface(ref)\n if (privateInterface) {\n this._logger.debug(`Found interface \"${formatted}\" in workspace`)\n return privateInterface\n }\n\n const publicInterface = await this.findPublicInterface(ref)\n if (publicInterface) {\n this._logger.debug(`Found interface \"${formatted}\" in hub`)\n return publicInterface\n }\n\n return\n }\n\n public async findPrivateInterface(ref: ApiPackageRef): Promise<PrivateInterface | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.client\n .getInterface(ref)\n .then((r) => ({ ...r.interface, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getInterfaceByName(ref)\n .then((r) => ({ ...r.interface, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async getPublicInterface(ref: ApiPackageRef): Promise<PublicInterface> {\n const intrface = await this.findPublicInterface(ref)\n if (!intrface) {\n throw new Error(`Interface \"${formatPackageRef(ref)}\" not found`)\n }\n return intrface\n }\n\n public async findPublicInterface(ref: ApiPackageRef): Promise<PublicInterface | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPublicInterfaceById(ref)\n .then((r) => ({ ...r.interface, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n return this.client\n .getPublicInterface(ref)\n .then((r) => ({ ...r.interface, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicPlugin(ref: ApiPackageRef): Promise<PublicPlugin | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPublicPluginById(ref)\n .then((r) => ({ ...r.plugin, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n return this.client\n .getPublicPlugin(ref)\n .then((r) => ({ ...r.plugin, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async getPublicOrPrivatePlugin(ref: ApiPackageRef): Promise<PublicOrPrivatePlugin> {\n const plugin = await this.findPublicOrPrivatePlugin(ref)\n if (!plugin) {\n throw new Error(`Plugin \"${formatPackageRef(ref)}\" not found`)\n }\n return plugin\n }\n\n public async findPublicOrPrivatePlugin(ref: ApiPackageRef): Promise<PublicOrPrivatePlugin | undefined> {\n const formatted = formatPackageRef(ref)\n\n const privatePlugin = await this.findPrivatePlugin(ref)\n if (privatePlugin) {\n this._logger.debug(`Found plugin \"${formatted}\" in workspace`)\n return privatePlugin\n }\n\n const publicPlugin = await this.findPublicPlugin(ref)\n if (publicPlugin) {\n this._logger.debug(`Found plugin \"${formatted}\" in hub`)\n return publicPlugin\n }\n\n return\n }\n\n public async findPrivatePlugin(ref: ApiPackageRef): Promise<PrivatePlugin | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.client\n .getPlugin(ref)\n .then((r) => ({ ...r.plugin, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getPluginByName(ref)\n .then((r) => ({ ...r.plugin, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async testLogin(): Promise<void> {\n await this.client.listBots({})\n }\n\n public listAllPages = paging.listAllPages\n\n public async findPreviousIntegrationVersion(ref: NamePackageRef): Promise<PublicOrPrivateIntegration | undefined> {\n const previous = await findPreviousIntegrationVersion(this.client, ref)\n if (!previous) {\n return\n }\n return this.findPublicOrPrivateIntegration({ type: 'id', id: previous.id })\n }\n\n public async findBotByName(name: string): Promise<BotSummary | undefined> {\n // api does not allow filtering bots by name\n const allBots = await this.listAllPages(this.client.listBots, (r) => r.bots)\n return allBots.find((b) => b.name === name)\n }\n\n private _returnUndefinedOnError =\n (type: client.ApiError['type']) =>\n (thrown: any): undefined => {\n if (client.isApiError(thrown) && thrown.type === type) {\n return\n }\n throw thrown\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,gBAAe;AAEf,yBAAgE;AAEhE,mCAA+C;AAC/C,aAAwB;AAgBxB,2BAAc,oBAtBd;AA2BO,MAAM,UAAU;AAAA,EASd,YACL,OACQ,SACR;AADQ;AAER,UAAM,EAAE,QAAQ,OAAO,aAAa,MAAM,IAAI;AAC9C,SAAK,SAAS,IAAI,OAAO,OAAO,EAAE,QAAQ,OAAO,aAAa,MAAM,CAAC;AACrE,SAAK,MAAM;AACX,SAAK,QAAQ;AACb,SAAK,cAAc;AACnB,SAAK,QAAQ;AAAA,EACf;AAAA,EAlBgB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,OAAc,YAAY,CAAC,OAAuB,WAAmB,IAAI,UAAU,OAAO,MAAM;AAAA,EAchG,IAAW,sBAA+B;AAExC,UAAM,0BAAsB,UAAAA,SAAG,QAAQ,IAAI,wBAAwB;AACnE,QAAI,wBAAwB,QAAW;AACrC,aAAO;AAAA,IACT;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,SAAS,KAAK,WAAW;AAAA,EAC7B;AA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EA,MAAa,cAAc,MAA+C;AAExE,UAAM,UAAU,MAAM,KAAK,aAAa,KAAK,OAAO,UAAU,CAAC,MAAM,EAAE,IAAI;AAC3E,WAAO,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAAA,EAC5C;AAAA,EAEQ,0BACN,CAAC,SACD,CAAC,WAA2B;AAC1B,QAAI,OAAO,WAAW,MAAM,KAAK,OAAO,SAAS,MAAM;AACrD;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACJ;",
4
+ "sourcesContent": ["import * as client from '@botpress/client'\nimport yn from 'yn'\nimport type { Logger } from '../logger'\nimport { formatPackageRef, ApiPackageRef, NamePackageRef } from '../package-ref'\nimport * as utils from '../utils'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport * as paging from './paging'\nimport * as retry from './retry'\n\nimport {\n ApiClientProps,\n PublicIntegration,\n PrivateIntegration,\n PublicOrPrivateIntegration,\n PublicInterface,\n PrivateInterface,\n PublicOrPrivateInterface,\n PrivatePlugin,\n PublicPlugin,\n PublicOrPrivatePlugin,\n BotSummary,\n} from './types'\n\nexport * from './types'\n\n/**\n * This class is used to wrap the Botpress API and provide a more convenient way to interact with it.\n */\nexport class ApiClient {\n public readonly client: client.Client\n public readonly url: string\n public readonly token: string\n public readonly workspaceId: string\n public readonly botId?: string\n\n public static newClient = (props: ApiClientProps, logger: Logger) => new ApiClient(props, logger)\n\n public constructor(\n props: ApiClientProps,\n private _logger: Logger\n ) {\n const { apiUrl, token, workspaceId, botId } = props\n this.client = new client.Client({\n apiUrl,\n token,\n workspaceId,\n botId,\n retry: retry.config,\n })\n this.url = apiUrl\n this.token = token\n this.workspaceId = workspaceId\n this.botId = botId\n }\n\n public get isBotpressWorkspace(): boolean {\n // this environment variable is undocumented and only used internally for dev purposes\n const isBotpressWorkspace = yn(process.env.BP_IS_BOTPRESS_WORKSPACE)\n if (isBotpressWorkspace !== undefined) {\n return isBotpressWorkspace\n }\n return [\n '6a76fa10-e150-4ff6-8f59-a300feec06c1',\n '95de33eb-1551-4af9-9088-e5dcb02efd09',\n '11111111-1111-1111-aaaa-111111111111',\n ].includes(this.workspaceId)\n }\n\n public async getWorkspace(): Promise<client.ClientOutputs['getWorkspace']> {\n return this.client.getWorkspace({ id: this.workspaceId })\n }\n\n public async findWorkspaceByHandle(handle: string): Promise<client.ClientOutputs['getWorkspace'] | undefined> {\n const { workspaces } = await this.client.listWorkspaces({ handle })\n return workspaces[0] // There should be only one workspace with a given handle\n }\n\n public switchWorkspace(workspaceId: string): ApiClient {\n return ApiClient.newClient({ apiUrl: this.url, token: this.token, workspaceId }, this._logger)\n }\n\n public switchBot(botId: string): ApiClient {\n return ApiClient.newClient(\n { apiUrl: this.url, token: this.token, botId, workspaceId: this.workspaceId },\n this._logger\n )\n }\n\n public async updateWorkspace(\n props: utils.types.SafeOmit<client.ClientInputs['updateWorkspace'], 'id'>\n ): Promise<client.ClientOutputs['updateWorkspace']> {\n return this.client.updateWorkspace({ id: this.workspaceId, ...props })\n }\n\n public async getPublicOrPrivateIntegration(ref: ApiPackageRef): Promise<PublicOrPrivateIntegration> {\n const integration = await this.findPublicOrPrivateIntegration(ref)\n if (!integration) {\n throw new Error(`Integration \"${formatPackageRef(ref)}\" not found`)\n }\n return integration\n }\n\n public async findPublicOrPrivateIntegration(ref: ApiPackageRef): Promise<PublicOrPrivateIntegration | undefined> {\n const formatted = formatPackageRef(ref)\n\n const privateIntegration = await this.findPrivateIntegration(ref)\n if (privateIntegration) {\n this._logger.debug(`Found integration \"${formatted}\" in workspace`)\n return privateIntegration\n }\n\n const publicIntegration = await this.findPublicIntegration(ref)\n if (publicIntegration) {\n this._logger.debug(`Found integration \"${formatted}\" in hub`)\n return publicIntegration\n }\n\n return\n }\n\n public async findPrivateIntegration(ref: ApiPackageRef): Promise<PrivateIntegration | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.client\n .getIntegration(ref)\n .then((r) => ({ ...r.integration, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getIntegrationByName(ref)\n .then((r) => ({ ...r.integration, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicIntegration(ref: ApiPackageRef): Promise<PublicIntegration | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPublicIntegrationById(ref)\n .then((r) => ({ ...r.integration, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getPublicIntegration(ref)\n .then((r) => ({ ...r.integration, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicOrPrivateInterface(ref: ApiPackageRef): Promise<PublicOrPrivateInterface | undefined> {\n const formatted = formatPackageRef(ref)\n\n const privateInterface = await this.findPrivateInterface(ref)\n if (privateInterface) {\n this._logger.debug(`Found interface \"${formatted}\" in workspace`)\n return privateInterface\n }\n\n const publicInterface = await this.findPublicInterface(ref)\n if (publicInterface) {\n this._logger.debug(`Found interface \"${formatted}\" in hub`)\n return publicInterface\n }\n\n return\n }\n\n public async findPrivateInterface(ref: ApiPackageRef): Promise<PrivateInterface | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.client\n .getInterface(ref)\n .then((r) => ({ ...r.interface, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getInterfaceByName(ref)\n .then((r) => ({ ...r.interface, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async getPublicInterface(ref: ApiPackageRef): Promise<PublicInterface> {\n const intrface = await this.findPublicInterface(ref)\n if (!intrface) {\n throw new Error(`Interface \"${formatPackageRef(ref)}\" not found`)\n }\n return intrface\n }\n\n public async findPublicInterface(ref: ApiPackageRef): Promise<PublicInterface | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPublicInterfaceById(ref)\n .then((r) => ({ ...r.interface, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n return this.client\n .getPublicInterface(ref)\n .then((r) => ({ ...r.interface, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicPlugin(ref: ApiPackageRef): Promise<PublicPlugin | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPublicPluginById(ref)\n .then((r) => ({ ...r.plugin, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n return this.client\n .getPublicPlugin(ref)\n .then((r) => ({ ...r.plugin, public: true }) as const)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async getPublicOrPrivatePlugin(ref: ApiPackageRef): Promise<PublicOrPrivatePlugin> {\n const plugin = await this.findPublicOrPrivatePlugin(ref)\n if (!plugin) {\n throw new Error(`Plugin \"${formatPackageRef(ref)}\" not found`)\n }\n return plugin\n }\n\n public async findPublicOrPrivatePlugin(ref: ApiPackageRef): Promise<PublicOrPrivatePlugin | undefined> {\n const formatted = formatPackageRef(ref)\n\n const privatePlugin = await this.findPrivatePlugin(ref)\n if (privatePlugin) {\n this._logger.debug(`Found plugin \"${formatted}\" in workspace`)\n return privatePlugin\n }\n\n const publicPlugin = await this.findPublicPlugin(ref)\n if (publicPlugin) {\n this._logger.debug(`Found plugin \"${formatted}\" in hub`)\n return publicPlugin\n }\n\n return\n }\n\n public async findPrivatePlugin(ref: ApiPackageRef): Promise<PrivatePlugin | undefined> {\n const { workspaceId } = this\n if (ref.type === 'id') {\n return this.client\n .getPlugin(ref)\n .then((r) => ({ ...r.plugin, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getPluginByName(ref)\n .then((r) => ({ ...r.plugin, workspaceId }))\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async testLogin(): Promise<void> {\n await this.client.listBots({})\n }\n\n public listAllPages = paging.listAllPages\n\n public async findPreviousIntegrationVersion(ref: NamePackageRef): Promise<PublicOrPrivateIntegration | undefined> {\n const previous = await findPreviousIntegrationVersion(this.client, ref)\n if (!previous) {\n return\n }\n return this.findPublicOrPrivateIntegration({ type: 'id', id: previous.id })\n }\n\n public async findBotByName(name: string): Promise<BotSummary | undefined> {\n // api does not allow filtering bots by name\n const allBots = await this.listAllPages(this.client.listBots, (r) => r.bots)\n return allBots.find((b) => b.name === name)\n }\n\n private _returnUndefinedOnError =\n (type: client.ApiError['type']) =>\n (thrown: any): undefined => {\n if (client.isApiError(thrown) && thrown.type === type) {\n return\n }\n throw thrown\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,gBAAe;AAEf,yBAAgE;AAEhE,mCAA+C;AAC/C,aAAwB;AACxB,YAAuB;AAgBvB,2BAAc,oBAvBd;AA4BO,MAAM,UAAU;AAAA,EASd,YACL,OACQ,SACR;AADQ;AAER,UAAM,EAAE,QAAQ,OAAO,aAAa,MAAM,IAAI;AAC9C,SAAK,SAAS,IAAI,OAAO,OAAO;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,MAAM;AAAA,IACf,CAAC;AACD,SAAK,MAAM;AACX,SAAK,QAAQ;AACb,SAAK,cAAc;AACnB,SAAK,QAAQ;AAAA,EACf;AAAA,EAxBgB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,OAAc,YAAY,CAAC,OAAuB,WAAmB,IAAI,UAAU,OAAO,MAAM;AAAA,EAoBhG,IAAW,sBAA+B;AAExC,UAAM,0BAAsB,UAAAA,SAAG,QAAQ,IAAI,wBAAwB;AACnE,QAAI,wBAAwB,QAAW;AACrC,aAAO;AAAA,IACT;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,SAAS,KAAK,WAAW;AAAA,EAC7B;AAAA,EAEA,MAAa,eAA8D;AACzE,WAAO,KAAK,OAAO,aAAa,EAAE,IAAI,KAA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O,UAAU,CAAC,MAAM,EAAE,IAAI;AAC3E,WAAO,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AAAA,EAC5C;AAAA,EAEQ,0BACN,CAAC,SACD,CAAC,WAA2B;AAC1B,QAAI,OAAO,WAAW,MAAM,KAAK,OAAO,SAAS,MAAM;AACrD;AAAA,IACF;AACA,UAAM;AAAA,EACR;AACJ;",
6
6
  "names": ["yn"]
7
7
  }
@@ -0,0 +1,45 @@
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
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var retry_exports = {};
30
+ __export(retry_exports, {
31
+ config: () => config
32
+ });
33
+ module.exports = __toCommonJS(retry_exports);
34
+ var client = __toESM(require("@botpress/client"));
35
+ const HTTP_STATUS_TO_RETRY_ON = [429, 500, 502, 503, 504];
36
+ const config = {
37
+ retries: 3,
38
+ retryCondition: (err) => client.axiosRetry.isNetworkOrIdempotentRequestError(err) || HTTP_STATUS_TO_RETRY_ON.includes(err.response?.status ?? 0),
39
+ retryDelay: (retryCount) => retryCount * 1e3
40
+ };
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ config
44
+ });
45
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/api/retry.ts"],
4
+ "sourcesContent": ["import * as client from '@botpress/client'\n\n// TODO: we probably shouldnt retry on 500 errors, but this is a temporary fix for the botpress repo CI\nconst HTTP_STATUS_TO_RETRY_ON = [429, 500, 502, 503, 504]\nexport const config: client.RetryConfig = {\n retries: 3,\n retryCondition: (err) =>\n client.axiosRetry.isNetworkOrIdempotentRequestError(err) ||\n HTTP_STATUS_TO_RETRY_ON.includes(err.response?.status ?? 0),\n retryDelay: (retryCount) => retryCount * 1000,\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AAGxB,MAAM,0BAA0B,CAAC,KAAK,KAAK,KAAK,KAAK,GAAG;AACjD,MAAM,SAA6B;AAAA,EACxC,SAAS;AAAA,EACT,gBAAgB,CAAC,QACf,OAAO,WAAW,kCAAkC,GAAG,KACvD,wBAAwB,SAAS,IAAI,UAAU,UAAU,CAAC;AAAA,EAC5D,YAAY,CAAC,eAAe,aAAa;AAC3C;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/typings.ts"],
4
- "sourcesContent": ["import type yargs from '@bpinternal/yargs-extra'\n\nimport type { YargsConfig, YargsSchema } from '@bpinternal/yargs-extra'\n\nexport type CommandPositionalOption = yargs.PositionalOptions & { positional: true; idx: number }\nexport type CommandNamedOption = YargsSchema[string] & { positional?: false }\nexport type CommandOption = CommandPositionalOption | CommandNamedOption\nexport type CommandSchema = Record<string, CommandOption>\n\nexport type CommandArgv<C extends CommandDefinition = CommandDefinition> = YargsConfig<C['schema']> & {\n /**\n * Ignored: fixes weird typing issue\n */\n _?: string\n}\n\nexport type CommandDefinition<S extends CommandSchema = CommandSchema> = {\n schema: S\n description?: string\n alias?: string\n}\n\nexport type CommandImplementation<C extends CommandDefinition = CommandDefinition> = (\n argv: CommandArgv<C>\n) => Promise<{ exitCode: number }>\n\nexport type CommandLeaf<C extends CommandDefinition = CommandDefinition> = C & {\n handler: CommandImplementation<C>\n}\n"],
4
+ "sourcesContent": ["import type { default as yargs, YargsConfig, YargsSchema } from '@bpinternal/yargs-extra'\n\nexport type CommandPositionalOption = yargs.PositionalOptions & { positional: true; idx: number }\nexport type CommandNamedOption = YargsSchema[string] & { positional?: false }\nexport type CommandOption = CommandPositionalOption | CommandNamedOption\nexport type CommandSchema = Record<string, CommandOption>\n\nexport type CommandArgv<C extends CommandDefinition = CommandDefinition> = YargsConfig<C['schema']> & {\n /**\n * Ignored: fixes weird typing issue\n */\n _?: string\n}\n\nexport type CommandDefinition<S extends CommandSchema = CommandSchema> = {\n schema: S\n description?: string\n alias?: string\n}\n\nexport type CommandImplementation<C extends CommandDefinition = CommandDefinition> = (\n argv: CommandArgv<C>\n) => Promise<{ exitCode: number }>\n\nexport type CommandLeaf<C extends CommandDefinition = CommandDefinition> = C & {\n handler: CommandImplementation<C>\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/cli",
3
- "version": "4.11.2",
3
+ "version": "4.11.3",
4
4
  "description": "Botpress CLI",
5
5
  "scripts": {
6
6
  "build": "pnpm run bundle && pnpm run template:gen",
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@apidevtools/json-schema-ref-parser": "^11.7.0",
23
23
  "@botpress/chat": "0.5.1",
24
- "@botpress/client": "1.17.1",
25
- "@botpress/sdk": "4.14.2",
24
+ "@botpress/client": "1.18.0",
25
+ "@botpress/sdk": "4.14.3",
26
26
  "@bpinternal/const": "^0.1.0",
27
27
  "@bpinternal/tunnel": "^0.1.1",
28
28
  "@bpinternal/yargs-extra": "^0.0.3",
@@ -5,8 +5,8 @@
5
5
  },
6
6
  "private": true,
7
7
  "dependencies": {
8
- "@botpress/client": "1.17.1",
9
- "@botpress/sdk": "4.14.2"
8
+ "@botpress/client": "1.18.0",
9
+ "@botpress/sdk": "4.14.3"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.19.67",
@@ -6,8 +6,8 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/client": "1.17.1",
10
- "@botpress/sdk": "4.14.2"
9
+ "@botpress/client": "1.18.0",
10
+ "@botpress/sdk": "4.14.3"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.19.67",
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/sdk": "4.14.2"
9
+ "@botpress/sdk": "4.14.3"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/node": "^18.19.67",
@@ -6,8 +6,8 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/client": "1.17.1",
10
- "@botpress/sdk": "4.14.2"
9
+ "@botpress/client": "1.18.0",
10
+ "@botpress/sdk": "4.14.3"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/node": "^18.19.67",
@@ -6,8 +6,8 @@
6
6
  },
7
7
  "private": true,
8
8
  "dependencies": {
9
- "@botpress/client": "1.17.1",
10
- "@botpress/sdk": "4.14.2",
9
+ "@botpress/client": "1.18.0",
10
+ "@botpress/sdk": "4.14.3",
11
11
  "axios": "^1.6.8"
12
12
  },
13
13
  "devDependencies": {