@botpress/cli 0.2.3 → 0.2.5
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.
- package/dist/api/bot-body.js +54 -0
- package/dist/api/bot-body.js.map +7 -0
- package/dist/{api-client.js → api/client.js} +9 -9
- package/dist/api/client.js.map +7 -0
- package/dist/api/integration-body.js +81 -0
- package/dist/api/integration-body.js.map +7 -0
- package/dist/command-implementations/deploy-command.js +29 -69
- package/dist/command-implementations/deploy-command.js.map +3 -3
- package/dist/command-implementations/dev-command.js +22 -8
- package/dist/command-implementations/dev-command.js.map +3 -3
- package/dist/command-implementations/global-command.js.map +1 -1
- package/dist/command-implementations/index.js +2 -2
- package/dist/command-implementations/index.js.map +2 -2
- package/dist/command-implementations/project-command.js +0 -6
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/utils/record-utils.js +13 -3
- package/dist/utils/record-utils.js.map +2 -2
- package/dist/utils/record-utils.test.js +34 -0
- package/dist/utils/record-utils.test.js.map +7 -0
- package/e2e/api.ts +25 -0
- package/e2e/defaults.ts +20 -0
- package/e2e/index.ts +83 -0
- package/e2e/tests/create-deploy-bot.ts +50 -0
- package/e2e/tests/create-deploy-integration.ts +55 -0
- package/e2e/tests/dev-bot.ts +57 -0
- package/e2e/typings.ts +12 -0
- package/e2e/utils.ts +42 -0
- package/package.json +11 -5
- package/templates/echo-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/dist/api-client.js.map +0 -7
package/dist/api-client.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/api-client.ts"],
|
|
4
|
-
"sourcesContent": ["import { Client, Integration, isApiError } from '@botpress/client'\nimport _ from 'lodash'\nimport { formatIntegrationRef, IntegrationRef } from './integration-ref'\nimport type { Logger } from './logger'\n\nexport type PageLister<R extends object> = (t: { nextToken?: string }) => Promise<R & { meta: { nextToken?: string } }>\n\nexport type ApiClientProps = {\n apiUrl: string\n token: string\n workspaceId?: string\n}\n\nexport type ApiClientFactory = {\n newClient: (props: ApiClientProps, logger: Logger) => ApiClient\n}\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\n public readonly url: string\n public readonly token: string\n public readonly workspaceId?: string\n\n public static newClient = (props: ApiClientProps, logger: Logger) => new ApiClient(props, logger)\n\n public constructor(props: ApiClientProps, private _logger: Logger) {\n const { apiUrl, token, workspaceId } = props\n this.client = new Client({ host: apiUrl, token, workspaceId })\n this.url = apiUrl\n this.token = token\n this.workspaceId = workspaceId\n }\n\n public async findIntegration(ref: IntegrationRef): Promise<Integration | undefined> {\n const formatted = formatIntegrationRef(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: IntegrationRef): Promise<Integration | undefined> {\n if (ref.type === 'id') {\n return this.validateStatus(() => this.client.getIntegration(ref).then((r) => r.integration), [404, 500]) // TODO: fix that\n }\n return this.validateStatus(() => this.client.getIntegrationByName(ref).then((r) => r.integration), [404, 500])\n }\n\n public async findPublicIntegration(ref: IntegrationRef): Promise<Integration | undefined> {\n if (ref.type === 'id') {\n return this.validateStatus(() => this.client.getPublicIntegrationById(ref).then((r) => r.integration), [404, 500])\n }\n return this.validateStatus(() => this.client.getPublicIntegration(ref).then((r) => r.integration), [404, 500])\n }\n\n public async testLogin(): Promise<void> {\n await this.client.listBots({})\n }\n\n public async listAllPages<R extends object>(lister: PageLister<R>): Promise<R[]>\n public async listAllPages<R extends object, M>(lister: PageLister<R>, mapper?: (r: R) => M[]): Promise<M[]>\n public async listAllPages<R extends object, M>(lister: PageLister<R>, mapper?: (r: R) => M[]) {\n let nextToken: string | undefined\n const all: R[] = []\n\n do {\n const { meta, ...r } = await lister({ nextToken })\n all.push(r as R)\n nextToken = meta.nextToken\n } while (nextToken)\n\n if (!mapper) {\n return all\n }\n\n const mapped: M[] = all.flatMap((r) => mapper(r))\n return mapped\n }\n\n public async validateStatus<V>(fn: () => Promise<V>, allowedStatuses: number | number[]): Promise<V | undefined> {\n try {\n const v = await fn()\n return v\n } catch (err) {\n const allowedStatusesArray = _.isArray(allowedStatuses) ? allowedStatuses : [allowedStatuses]\n const isAllowed = isApiError(err) && err.code && allowedStatusesArray.includes(err.code)\n if (isAllowed) {\n return\n }\n throw err\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,oBAAc;AACd,6BAAqD;AAkB9C,MAAM,UAAU;AAAA,EAQd,YAAY,OAA+B,SAAiB;AAAjB;AAChD,UAAM,EAAE,QAAQ,OAAO,YAAY,IAAI;AACvC,SAAK,SAAS,IAAI,qBAAO,EAAE,MAAM,QAAQ,OAAO,YAAY,CAAC;AAC7D,SAAK,MAAM;AACX,SAAK,QAAQ;AACb,SAAK,cAAc;AAAA,EACrB;AAAA,EAbgB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,OAAc,YAAY,CAAC,OAAuB,WAAmB,IAAI,UAAU,OAAO,MAAM;AAAA,EAUhG,MAAa,gBAAgB,KAAuD;AAClF,UAAM,gBAAY,6CAAqB,GAAG;AAE1C,UAAM,qBAAqB,MAAM,KAAK,uBAAuB,GAAG;AAChE,QAAI,oBAAoB;AACtB,WAAK,QAAQ,MAAM,sBAAsB,yBAAyB;AAClE,aAAO;AAAA,IACT;AAEA,UAAM,oBAAoB,MAAM,KAAK,sBAAsB,GAAG;AAC9D,QAAI,mBAAmB;AACrB,WAAK,QAAQ,MAAM,sBAAsB,mBAAmB;AAC5D,aAAO;AAAA,IAC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