@botpress/cli 4.5.4 → 4.7.0
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/.turbo/turbo-build.log +11 -11
- package/dist/api/bot-body.js +9 -5
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +7 -0
- package/dist/api/client.js.map +2 -2
- package/dist/api/plugin-body.js +7 -4
- package/dist/api/plugin-body.js.map +2 -2
- package/dist/command-implementations/plugin-commands.js +2 -2
- package/dist/command-implementations/plugin-commands.js.map +2 -2
- package/dist/command-implementations/project-command.js +6 -1
- package/dist/command-implementations/project-command.js.map +2 -2
- package/package.json +3 -3
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@4.
|
|
2
|
+
> @botpress/cli@4.7.0 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.
|
|
6
|
+
> @botpress/cli@4.7.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@4.
|
|
10
|
+
> @botpress/cli@4.7.0 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.
|
|
14
|
-
🤖 Botpress CLI v4.
|
|
15
|
-
🤖 Botpress CLI v4.
|
|
16
|
-
🤖 Botpress CLI v4.
|
|
13
|
+
🤖 Botpress CLI v4.7.0
|
|
14
|
+
🤖 Botpress CLI v4.7.0
|
|
15
|
+
🤖 Botpress CLI v4.7.0
|
|
16
|
+
🤖 Botpress CLI v4.7.0
|
|
17
17
|
○ Generating typings for plugin empty-plugin...
|
|
18
18
|
✓ Typings available at .botpress
|
|
19
19
|
|
|
20
|
-
○ Generating typings for bot...
|
|
21
|
-
✓ Typings available at .botpress
|
|
22
|
-
|
|
23
20
|
○ Generating typings for integration empty-integration...
|
|
24
21
|
✓ Typings available at .botpress
|
|
25
22
|
|
|
26
23
|
○ Generating typings for integration hello-world...
|
|
24
|
+
○ Generating typings for bot...
|
|
25
|
+
✓ Typings available at .botpress
|
|
26
|
+
|
|
27
27
|
✓ Typings available at .botpress
|
|
28
28
|
|
|
29
|
-
🤖 Botpress CLI v4.
|
|
29
|
+
🤖 Botpress CLI v4.7.0
|
|
30
30
|
○ Generating typings for integration webhook-message...
|
|
31
31
|
✓ Typings available at .botpress
|
|
32
32
|
|
package/dist/api/bot-body.js
CHANGED
|
@@ -57,10 +57,13 @@ const prepareCreateBotBody = async (bot) => ({
|
|
|
57
57
|
...event,
|
|
58
58
|
schema: await utils.schema.mapZodToJsonSchema(event)
|
|
59
59
|
})) : void 0,
|
|
60
|
-
states: bot.states ?
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
states: bot.states ? utils.records.filterValues(
|
|
61
|
+
await utils.records.mapValuesAsync(bot.states, async (state) => ({
|
|
62
|
+
...state,
|
|
63
|
+
schema: await utils.schema.mapZodToJsonSchema(state)
|
|
64
|
+
})),
|
|
65
|
+
({ type }) => type !== "workflow"
|
|
66
|
+
) : void 0
|
|
64
67
|
});
|
|
65
68
|
const prepareUpdateBotBody = (localBot, remoteBot) => ({
|
|
66
69
|
...localBot,
|
|
@@ -86,7 +89,8 @@ const prepareUpdateBotBody = (localBot, remoteBot) => ({
|
|
|
86
89
|
...localBot.message,
|
|
87
90
|
tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags)
|
|
88
91
|
},
|
|
89
|
-
integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations)
|
|
92
|
+
integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations),
|
|
93
|
+
plugins: utils.records.setNullOnMissingValues(localBot.plugins, remoteBot.plugins)
|
|
90
94
|
});
|
|
91
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
92
96
|
0 && (module.exports = {
|
package/dist/api/bot-body.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/bot-body.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateBotBody = async (bot: sdk.BotDefinition): Promise<types.CreateBotRequestBody> => ({\n user: bot.user,\n conversation: bot.conversation,\n message: bot.message,\n recurringEvents: bot.recurringEvents,\n actions: bot.actions\n ? await utils.records.mapValuesAsync(bot.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n configuration: bot.configuration\n ? {\n ...bot.configuration,\n schema: await utils.schema.mapZodToJsonSchema(bot.configuration),\n }\n : undefined,\n events: bot.events\n ? await utils.records.mapValuesAsync(bot.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n states: bot.states\n ? await utils.records.mapValuesAsync(bot.states, async (state) => ({\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,uBAAuB,OAAO,SAAiE;AAAA,EAC1G,MAAM,IAAI;AAAA,EACV,cAAc,IAAI;AAAA,EAClB,SAAS,IAAI;AAAA,EACb,iBAAiB,IAAI;AAAA,EACrB,SAAS,IAAI,UACT,MAAM,MAAM,QAAQ,eAAe,IAAI,SAAS,OAAO,YAAY;AAAA,IACjE,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO,KAAK;AAAA,IAC5D;AAAA,IACA,QAAQ;AAAA,MACN,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO,MAAM;AAAA,IAC7D;AAAA,EACF,EAAE,IACF;AAAA,EACJ,eAAe,IAAI,gBACf;AAAA,IACE,GAAG,IAAI;AAAA,IACP,QAAQ,MAAM,MAAM,OAAO,mBAAmB,IAAI,aAAa;AAAA,EACjE,IACA;AAAA,EACJ,QAAQ,IAAI,SACR,MAAM,MAAM,QAAQ,eAAe,IAAI,QAAQ,OAAO,WAAW;AAAA,IAC/D,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AAAA,EACJ,QAAQ,IAAI,
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreateBotBody = async (bot: sdk.BotDefinition): Promise<types.CreateBotRequestBody> => ({\n user: bot.user,\n conversation: bot.conversation,\n message: bot.message,\n recurringEvents: bot.recurringEvents,\n actions: bot.actions\n ? await utils.records.mapValuesAsync(bot.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n configuration: bot.configuration\n ? {\n ...bot.configuration,\n schema: await utils.schema.mapZodToJsonSchema(bot.configuration),\n }\n : undefined,\n events: bot.events\n ? await utils.records.mapValuesAsync(bot.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n states: bot.states\n ? (utils.records.filterValues(\n await utils.records.mapValuesAsync(bot.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n })),\n ({ type }) => type !== 'workflow'\n ) as types.CreateBotRequestBody['states'])\n : undefined,\n})\n\nexport const prepareUpdateBotBody = (\n localBot: types.UpdateBotRequestBody,\n remoteBot: client.Bot\n): types.UpdateBotRequestBody => ({\n ...localBot,\n states: utils.records.setNullOnMissingValues(localBot.states, remoteBot.states),\n recurringEvents: utils.records.setNullOnMissingValues(localBot.recurringEvents, remoteBot.recurringEvents),\n events: utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localBot.events, remoteBot.events),\n remoteItems: remoteBot.events,\n }),\n actions: utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localBot.actions, remoteBot.actions),\n remoteItems: remoteBot.actions,\n }),\n user: {\n ...localBot.user,\n tags: utils.records.setNullOnMissingValues(localBot.user?.tags, remoteBot.user?.tags),\n },\n conversation: {\n ...localBot.conversation,\n tags: utils.records.setNullOnMissingValues(localBot.conversation?.tags, remoteBot.conversation?.tags),\n },\n message: {\n ...localBot.message,\n tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags),\n },\n integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations),\n plugins: utils.records.setNullOnMissingValues(localBot.plugins, remoteBot.plugins),\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,uBAAuB,OAAO,SAAiE;AAAA,EAC1G,MAAM,IAAI;AAAA,EACV,cAAc,IAAI;AAAA,EAClB,SAAS,IAAI;AAAA,EACb,iBAAiB,IAAI;AAAA,EACrB,SAAS,IAAI,UACT,MAAM,MAAM,QAAQ,eAAe,IAAI,SAAS,OAAO,YAAY;AAAA,IACjE,GAAG;AAAA,IACH,OAAO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AAa,UAAU;AAAA,EACzB,CAAC;AAAA,EACD,MAAM;AAAA,IACJ,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,MAAM,MAAM,UAAU,MAAM,IAAI;AAAA,EACtF;AAAA,EACA,cAAc;AAAA,IACZ,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,cAAc,MAAM,UAAU,cAAc,IAAI;AAAA,EACtG;AAAA,EACA,SAAS;AAAA,IACP,GAAG,SAAS;AAAA,IACZ,MAAM,MAAM,QAAQ,uBAAuB,SAAS,SAAS,MAAM,UAAU,SAAS,IAAI;AAAA,EAC5F;AAAA,EACA,cAAc,MAAM,QAAQ,uBAAuB,SAAS,cAAc,UAAU,YAAY;AAAA,EAChG,SAAS,MAAM,QAAQ,uBAAuB,SAAS,SAAS,UAAU,OAAO;AACnF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/api/client.js
CHANGED
|
@@ -158,6 +158,13 @@ class ApiClient {
|
|
|
158
158
|
}
|
|
159
159
|
return this.client.getPublicPlugin(ref).then((r) => ({ ...r.plugin, public: true })).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
160
160
|
}
|
|
161
|
+
async getPublicOrPrivatePlugin(ref) {
|
|
162
|
+
const plugin = await this.findPublicOrPrivatePlugin(ref);
|
|
163
|
+
if (!plugin) {
|
|
164
|
+
throw new Error(`Plugin "${(0, import_package_ref.formatPackageRef)(ref)}" not found`);
|
|
165
|
+
}
|
|
166
|
+
return plugin;
|
|
167
|
+
}
|
|
161
168
|
async findPublicOrPrivatePlugin(ref) {
|
|
162
169
|
const formatted = (0, import_package_ref.formatPackageRef)(ref);
|
|
163
170
|
const privatePlugin = await this.findPrivatePlugin(ref);
|
package/dist/api/client.js.map
CHANGED
|
@@ -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 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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AAQ,YAAY,EAAE,EAC1C,MAAM,KAAK,wBAAwB,kBAAkB,CAAC;AAAA,EAC3D;AAAA,EAEA,MAAa,YAA2B;AACtC,UAAM,KAAK,OAAO,SAAS,CAAC,CAAC;AAAA,EAC/B;AAAA,EAEO,eAAe,OAAO;AAAA,EAE7B,MAAa,+BAA+B,KAAsE;AAChH,UAAM,WAAW,UAAM,6DAA+B,KAAK,QAAQ,GAAG;AACtE,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AACA,WAAO,KAAK,+BAA+B,EAAE,MAAM,MAAM,IAAI,SAAS,GAAG,CAAC;AAAA,EAC5E;AAAA,EAEA,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'\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,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AA,EAEO,eAAe,OAAO;AAAA,EAE7B,MAAa,+BAA+B,KAAsE;AAChH,UAAM,WAAW,UAAM,6DAA+B,KAAK,QAAQ,GAAG;AACtE,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AACA,WAAO,KAAK,+BAA+B,EAAE,MAAM,MAAM,IAAI,SAAS,GAAG,CAAC;AAAA,EAC5E;AAAA,EAEA,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;",
|
|
6
6
|
"names": ["yn"]
|
|
7
7
|
}
|
package/dist/api/plugin-body.js
CHANGED
|
@@ -63,10 +63,13 @@ const prepareCreatePluginBody = async (plugin) => ({
|
|
|
63
63
|
schema: await utils.schema.mapZodToJsonSchema(action.output)
|
|
64
64
|
}
|
|
65
65
|
})) : void 0,
|
|
66
|
-
states: plugin.states ?
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
states: plugin.states ? utils.records.filterValues(
|
|
67
|
+
await utils.records.mapValuesAsync(plugin.states, async (state) => ({
|
|
68
|
+
...state,
|
|
69
|
+
schema: await utils.schema.mapZodToJsonSchema(state)
|
|
70
|
+
})),
|
|
71
|
+
({ type }) => type !== "workflow"
|
|
72
|
+
) : void 0
|
|
70
73
|
});
|
|
71
74
|
const prepareUpdatePluginBody = (localPlugin, remotePlugin) => {
|
|
72
75
|
const actions = utils.attributes.prepareAttributeUpdateBody({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/plugin-body.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreatePluginBody = async (\n plugin: sdk.PluginDefinition | sdk.PluginPackage['definition']\n): Promise<types.CreatePluginRequestBody> => ({\n name: plugin.name,\n version: plugin.version,\n title: 'title' in plugin ? plugin.title : undefined,\n description: 'description' in plugin ? plugin.description : undefined,\n user: {\n tags: plugin.user?.tags ?? {},\n },\n conversation: {\n tags: plugin.conversation?.tags ?? {},\n },\n configuration: plugin.configuration\n ? {\n ...plugin.configuration,\n schema: await utils.schema.mapZodToJsonSchema(plugin.configuration),\n }\n : undefined,\n events: plugin.events\n ? await utils.records.mapValuesAsync(plugin.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: plugin.actions\n ? await utils.records.mapValuesAsync(plugin.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n states: plugin.states\n ? await utils.records.mapValuesAsync(plugin.states, async (state) => ({\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,0BAA0B,OACrC,YAC4C;AAAA,EAC5C,MAAM,OAAO;AAAA,EACb,SAAS,OAAO;AAAA,EAChB,OAAO,WAAW,SAAS,OAAO,QAAQ;AAAA,EAC1C,aAAa,iBAAiB,SAAS,OAAO,cAAc;AAAA,EAC5D,MAAM;AAAA,IACJ,MAAM,OAAO,MAAM,QAAQ,CAAC;AAAA,EAC9B;AAAA,EACA,cAAc;AAAA,IACZ,MAAM,OAAO,cAAc,QAAQ,CAAC;AAAA,EACtC;AAAA,EACA,eAAe,OAAO,gBAClB;AAAA,IACE,GAAG,OAAO;AAAA,IACV,QAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO,aAAa;AAAA,EACpE,IACA;AAAA,EACJ,QAAQ,OAAO,SACX,MAAM,MAAM,QAAQ,eAAe,OAAO,QAAQ,OAAO,WAAW;AAAA,IAClE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AAAA,EACJ,SAAS,OAAO,UACZ,MAAM,MAAM,QAAQ,eAAe,OAAO,SAAS,OAAO,YAAY;AAAA,IACpE,GAAG;AAAA,IACH,OAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO,KAAK;AAAA,IAC5D;AAAA,IACA,QAAQ;AAAA,MACN,GAAG,OAAO;AAAA,MACV,QAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO,MAAM;AAAA,IAC7D;AAAA,EACF,EAAE,IACF;AAAA,EACJ,QAAQ,OAAO,
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\nimport * as types from './types'\n\nexport const prepareCreatePluginBody = async (\n plugin: sdk.PluginDefinition | sdk.PluginPackage['definition']\n): Promise<types.CreatePluginRequestBody> => ({\n name: plugin.name,\n version: plugin.version,\n title: 'title' in plugin ? plugin.title : undefined,\n description: 'description' in plugin ? plugin.description : undefined,\n user: {\n tags: plugin.user?.tags ?? {},\n },\n conversation: {\n tags: plugin.conversation?.tags ?? {},\n },\n configuration: plugin.configuration\n ? {\n ...plugin.configuration,\n schema: await utils.schema.mapZodToJsonSchema(plugin.configuration),\n }\n : undefined,\n events: plugin.events\n ? await utils.records.mapValuesAsync(plugin.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: plugin.actions\n ? await utils.records.mapValuesAsync(plugin.actions, async (action) => ({\n ...action,\n input: {\n ...action.input,\n schema: await utils.schema.mapZodToJsonSchema(action.input),\n },\n output: {\n ...action.output,\n schema: await utils.schema.mapZodToJsonSchema(action.output),\n },\n }))\n : undefined,\n states: plugin.states\n ? (utils.records.filterValues(\n await utils.records.mapValuesAsync(plugin.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n })),\n ({ type }) => type !== 'workflow'\n ) as types.CreatePluginRequestBody['states'])\n : undefined,\n})\n\nexport const prepareUpdatePluginBody = (\n localPlugin: types.UpdatePluginRequestBody,\n remotePlugin: client.Plugin\n): types.UpdatePluginRequestBody => {\n const actions = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localPlugin.actions, remotePlugin.actions),\n remoteItems: remotePlugin.actions,\n })\n const events = utils.attributes.prepareAttributeUpdateBody({\n localItems: utils.records.setNullOnMissingValues(localPlugin.events, remotePlugin.events),\n remoteItems: remotePlugin.events,\n })\n const states = utils.records.setNullOnMissingValues(localPlugin.states, remotePlugin.states)\n\n return {\n ...localPlugin,\n actions,\n events,\n states,\n user: localPlugin.user, // TODO: allow deleting user tags with null\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,0BAA0B,OACrC,YAC4C;AAAA,EAC5C,MAAM,OAAO;AAAA,EACb,SAAS,OAAO;AAAA,EAChB,OAAO,WAAW,SAAS,OAAO,QAAQ;AAAA,EAC1C,aAAa,iBAAiB,SAAS,OAAO,cAAc;AAAA,EAC5D,MAAM;AAAA,IACJ,MAAM,OAAO,MAAM,QAAQ,CAAC;AAAA,EAC9B;AAAA,EACA,cAAc;AAAA,IACZ,MAAM,OAAO,cAAc,QAAQ,CAAC;AAAA,EACtC;AAAA,EACA,eAAe,OAAO,gBAClB;AAAA,IACE,GAAG,OAAO;AAAA,IACV,QAAQ,MAAM,MAAM,OAAO,mBAAmB,OAAO,aAAa;AAAA,EACpE,IACA;AAAA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AM,YAAY;AAAA;AAAA,EACpB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -48,7 +48,7 @@ class GetPluginCommand extends import_global_command.GlobalCommand {
|
|
|
48
48
|
throw new errors.BotpressCLIError("Cannot get local plugin");
|
|
49
49
|
}
|
|
50
50
|
try {
|
|
51
|
-
const plugin = await api.
|
|
51
|
+
const plugin = await api.findPublicOrPrivatePlugin(parsedRef);
|
|
52
52
|
if (plugin) {
|
|
53
53
|
this.logger.success(`Plugin ${import_chalk.default.bold(this.argv.pluginRef)}:`);
|
|
54
54
|
this.logger.json(plugin);
|
|
@@ -85,7 +85,7 @@ class DeletePluginCommand extends import_global_command.GlobalCommand {
|
|
|
85
85
|
}
|
|
86
86
|
let plugin;
|
|
87
87
|
try {
|
|
88
|
-
plugin = await api.
|
|
88
|
+
plugin = await api.findPublicOrPrivatePlugin(parsedRef);
|
|
89
89
|
} catch (thrown) {
|
|
90
90
|
throw errors.BotpressCLIError.wrap(thrown, `Could not get plugin ${this.argv.pluginRef}`);
|
|
91
91
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/plugin-commands.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetPluginCommandDefinition = typeof commandDefinitions.plugins.subcommands.get\nexport class GetPluginCommand extends GlobalCommand<GetPluginCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.pluginRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.pluginRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local plugin')\n }\n\n try {\n const plugin = await api.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAElB,aAAwB;AACxB,yBAAgC;AAChC,4BAA8B;AAGvB,MAAM,yBAAyB,oCAA0C;AAAA,EAC9E,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,oCAAgB,KAAK,KAAK,SAAS;AACrD,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,OAAO,6BAA6B,KAAK,KAAK,SAAS;AAAA,IACnE;AACA,QAAI,UAAU,SAAS,QAAQ;AAC7B,YAAM,IAAI,OAAO,iBAAiB,yBAAyB;AAAA,IAC7D;AAEA,QAAI;AACF,YAAM,SAAS,MAAM,IAAI,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetPluginCommandDefinition = typeof commandDefinitions.plugins.subcommands.get\nexport class GetPluginCommand extends GlobalCommand<GetPluginCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.pluginRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.pluginRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local plugin')\n }\n\n try {\n const plugin = await api.findPublicOrPrivatePlugin(parsedRef)\n if (plugin) {\n this.logger.success(`Plugin ${chalk.bold(this.argv.pluginRef)}:`)\n this.logger.json(plugin)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get plugin ${this.argv.pluginRef}`)\n }\n\n throw new errors.BotpressCLIError(`Plugin ${this.argv.pluginRef} not found`)\n }\n}\n\nexport type ListPluginsCommandDefinition = typeof commandDefinitions.plugins.subcommands.list\nexport class ListPluginsCommand extends GlobalCommand<ListPluginsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const lister = (req: { nextToken?: string }) => api.client.listPlugins({ nextToken: req.nextToken })\n\n try {\n const plugins = await api.listAllPages(lister, (r) => r.plugins)\n\n this.logger.success('Plugins:')\n this.logger.json(plugins)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list plugins')\n }\n }\n}\n\nexport type DeletePluginCommandDefinition = typeof commandDefinitions.plugins.subcommands.delete\nexport class DeletePluginCommand extends GlobalCommand<DeletePluginCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.pluginRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.pluginRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local plugin')\n }\n\n let plugin: client.Plugin | undefined\n try {\n plugin = await api.findPublicOrPrivatePlugin(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get plugin ${this.argv.pluginRef}`)\n }\n\n if (!plugin) {\n throw new errors.BotpressCLIError(`Plugin ${this.argv.pluginRef} not found`)\n }\n\n try {\n await api.client.deletePlugin({ id: plugin.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete plugin ${this.argv.pluginRef}`)\n }\n\n this.logger.success(`Plugin ${chalk.bold(this.argv.pluginRef)} deleted`)\n return\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAElB,aAAwB;AACxB,yBAAgC;AAChC,4BAA8B;AAGvB,MAAM,yBAAyB,oCAA0C;AAAA,EAC9E,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BA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AO,6BAA6B,KAAK,KAAK,SAAS;AAAA,IACnE;AACA,QAAI,UAAU,SAAS,QAAQ;AAC7B,YAAM,IAAI,OAAO,iBAAiB,4BAA4B;AAAA,IAChE;AAEA,QAAI;AACJ,QAAI;AACF,eAAS,MAAM,IAAI,0BAA0B,SAAS;AAAA,IACxD,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,wBAAwB,KAAK,KAAK,WAAW;AAAA,IAC1F;AAEA,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,OAAO,iBAAiB,UAAU,KAAK,KAAK,qBAAqB;AAAA,IAC7E;AAEA,QAAI;AACF,YAAM,IAAI,OAAO,aAAa,EAAE,IAAI,OAAO,GAAG,CAAC;AAAA,IACjD,SAAS,QAAP;AACA,YAAM,OAAO,iBAAiB,KAAK,QAAQ,2BAA2B,KAAK,KAAK,WAAW;AAAA,IAC7F;AAEA,SAAK,OAAO,QAAQ,UAAU,aAAAA,QAAM,KAAK,KAAK,KAAK,SAAS,WAAW;AACvE;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -286,8 +286,13 @@ class ProjectCommand extends import_global_command.GlobalCommand {
|
|
|
286
286
|
botDef.integrations ?? {},
|
|
287
287
|
({ name, version }) => api.getPublicOrPrivateIntegration({ type: "name", name, version })
|
|
288
288
|
);
|
|
289
|
+
const plugins = await this._fetchDependencies(
|
|
290
|
+
botDef.plugins ?? {},
|
|
291
|
+
({ name, version }) => api.getPublicOrPrivatePlugin({ type: "name", name, version })
|
|
292
|
+
);
|
|
289
293
|
return {
|
|
290
|
-
integrations: (0, import_lodash.default)(integrations).keyBy((i) => i.id).value()
|
|
294
|
+
integrations: (0, import_lodash.default)(integrations).keyBy((i) => i.id).value(),
|
|
295
|
+
plugins
|
|
291
296
|
};
|
|
292
297
|
}
|
|
293
298
|
async prepareIntegrationDependencies(integrationDef, api) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/command-implementations/project-command.ts"],
|
|
4
|
-
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { validateIntegrationDefinition, validateBotDefinition } from '../sdk'\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 = { workDir: string }\ntype ConstantProjectPaths = typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype LintIgnoredConfig = { bpLintDisabled?: boolean }\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition = LintIgnoredConfig &\n (\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDefinition }\n | { type: 'bot'; definition: sdk.BotDefinition }\n | { type: 'plugin'; definition: sdk.PluginDefinition }\n )\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 super({\n workDir: absWorkDir,\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 readProjectDefinitionFromFS(): Promise<ProjectDefinition> {\n const projectPaths = this.projectPaths\n try {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', ...integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', ...interfaceDefinition }\n }\n const botDefinition = await this._readBotDefinitionFromFS(projectPaths)\n if (botDefinition) {\n return { type: 'bot', ...botDefinition }\n }\n const pluginDefinition = await this._readPluginDefinitionFromFS(projectPaths)\n if (pluginDefinition) {\n return { type: 'plugin', ...pluginDefinition }\n }\n } catch (thrown: unknown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Error while reading project definition')\n }\n\n throw new errors.ProjectDefinitionNotFoundError(this.projectPaths.abs.workDir)\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'>\n ): Promise<({ definition: sdk.IntegrationDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.integrationDefinition,\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 validateIntegrationDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'>\n ): Promise<({ definition: sdk.InterfaceDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.interfaceDefinition,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDefinition }>(artifact.text)\n\n return { definition, bpLintDisabled }\n }\n\n private async _readBotDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'botDefinition'>\n ): Promise<({ definition: sdk.BotDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.botDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.botDefinition,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.BotDefinition }>(artifact.text)\n validateBotDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readPluginDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'pluginDefinition'>\n ): Promise<({ definition: sdk.PluginDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.pluginDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.pluginDefinition,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.PluginDefinition }>(artifact.text)\n // TODO: validate plugin definition\n return { definition, bpLintDisabled }\n }\n\n private async _isBpLintDisabled(definitionPath: string): Promise<boolean> {\n const tsContent = await fs.promises.readFile(definitionPath, 'utf-8')\n const regex = /\\/\\* bplint-disable \\*\\//\n return regex.test(tsContent)\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 protected async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n const partialBody = await apiUtils.prepareCreateIntegrationBody(integrationDef)\n\n let code: string | undefined = undefined\n if (fs.existsSync(this.projectPaths.abs.outFileCJS)) {\n code = await this.readProjectFile(this.projectPaths.abs.outFileCJS)\n }\n\n const icon = await this.readProjectFile(integrationDef.icon, 'base64')\n const readme = await this.readProjectFile(integrationDef.readme, 'base64')\n const extractScript = await this.readProjectFile(integrationDef.identifier?.extractScript)\n const fallbackHandlerScript = await this.readProjectFile(integrationDef.identifier?.fallbackHandlerScript)\n return {\n ...partialBody,\n code,\n icon,\n readme,\n identifier: {\n extractScript,\n fallbackHandlerScript,\n },\n configuration: integrationDef.configuration\n ? {\n schema: await utils.schema.mapZodToJsonSchema(integrationDef.configuration),\n identifier: {\n required: integrationDef.configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(\n integrationDef.configuration.identifier?.linkTemplateScript\n ),\n },\n }\n : undefined,\n configurations: integrationDef.configurations\n ? await utils.records.mapValuesAsync(integrationDef.configurations, async (configuration) => ({\n title: configuration.title,\n description: configuration.description,\n schema: await utils.schema.mapZodToJsonSchema(configuration),\n identifier: {\n required: configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(configuration.identifier?.linkTemplateScript),\n },\n }))\n : undefined,\n }\n }\n\n protected async prepareBotDependencies(\n botDef: sdk.BotDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.UpdateBotRequestBody>> {\n const integrations = await this._fetchDependencies(botDef.integrations ?? {}, ({ name, version }) =>\n api.getPublicOrPrivateIntegration({ type: 'name', name, version })\n )\n return {\n integrations: _(integrations)\n .keyBy((i) => i.id)\n .value(),\n }\n }\n\n protected async prepareIntegrationDependencies(\n integrationDef: sdk.IntegrationDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreateIntegrationRequestBody>> {\n const interfaces = await this._fetchDependencies(integrationDef.interfaces ?? {}, ({ name, version }) =>\n api.getPublicInterface({ type: 'name', name, version })\n )\n return { interfaces }\n }\n\n protected async preparePluginDependencies(\n pluginDef: sdk.PluginDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreatePluginRequestBody>> {\n const integrations = await this._fetchDependencies(pluginDef.integrations ?? {}, ({ name, version }) =>\n api.getPublicOrPrivateIntegration({ type: 'name', name, version })\n )\n const interfaces = await this._fetchDependencies(pluginDef.interfaces ?? {}, ({ name, version }) =>\n api.getPublicInterface({ type: 'name', name, version })\n )\n return {\n dependencies: {\n integrations,\n interfaces,\n },\n }\n }\n\n private _fetchDependencies = async <T extends { id?: string; name: string; version: string }>(\n deps: Record<string, T>,\n fetcher: (dep: T) => Promise<{ id: string }>\n ): Promise<Record<string, T & { id: string }>> => {\n const isRemote = (dep: T): dep is T & { id: string } => dep.id !== undefined\n return utils.records.mapValuesAsync(deps, async (dep): Promise<T & { id: string }> => {\n if (isRemote(dep)) {\n return dep\n }\n const { id } = await fetcher(dep)\n return { ...dep, id }\n })\n }\n\n protected readProjectFile = async (\n filePath: string | undefined,\n encoding: BufferEncoding = 'utf-8'\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, encoding).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\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,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,oBAAmB;AACnB,eAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,iBAAqE;AAErE,YAAuB;AACvB,4BAA8B;AAoB9B,MAAM,qBAAqB,MAAM,KAAK,UAAiC;AAAA,EAC9D,YAAY,MAA6C;AAC9D,UAAM,aAAa,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AACzE,UAAM;AAAA,MACJ,SAAS;AAAA,MACT,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,IAA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MACA,eAAe,eAAe,gBAC1B;AAAA,QACE,QAAQ,MAAM,MAAM,OAAO,mBAAmB,eAAe,aAAa;AAAA,QAC1E,YAAY;AAAA,UACV,UAAU,eAAe,cAAc,YAAY;AAAA,UACnD,oBAAoB,MAAM,KAAK;AAAA,YAC7B,eAAe,cAAc,YAAY;AAAA,UAC3C;AAAA,QACF;AAAA,MACF,IACA;AAAA,MACJ,gBAAgB,eAAe,iBAC3B,MAAM,MAAM,QAAQ,eAAe,eAAe,gBAAgB,OAAO,mBAAmB;AAAA,QAC1F,OAAO,cAAc;AAAA,QACrB,aAAa,cAAc;AAAA,QAC3B,QAAQ,MAAM,MAAM,OAAO,mBAAmB,aAAa;AAAA,QAC3D,YAAY;AAAA,UACV,UAAU,cAAc,YAAY;AAAA,UACpC,oBAAoB,MAAM,KAAK,gBAAgB,cAAc,YAAY,kBAAkB;AAAA,QAC7F;AAAA,MACF,EAAE,IACF;AAAA,IACN;AAAA,EACF;AAAA,EAEA,MAAgB,uBACd,QACA,KACiD;AACjD,UAAM,eAAe,MAAM,KAAK;AAAA,MAAmB,OAAO,gBAAgB,CAAC;AAAA,MAAG,CAAC,EAAE,MAAM,QAAQ,MAC7F,IAAI,8BAA8B,EAAE,MAAM,QAAQ,MAAM,QAAQ,CAAC;AAAA,IACnE;AACA,WAAO;AAAA,MACL,kBAAc,cAAAD,SAAE,YAAY,EACzB,MAAM,CAAC,MAAM,EAAE,EAAE,EACjB,MAAM;AAAA,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport fs from 'fs'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport * as apiUtils from '../api'\nimport * as codegen from '../code-generation'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport { validateIntegrationDefinition, validateBotDefinition } from '../sdk'\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 = { workDir: string }\ntype ConstantProjectPaths = typeof consts.fromWorkDir\ntype AllProjectPaths = ConfigurableProjectPaths & ConstantProjectPaths\n\ntype LintIgnoredConfig = { bpLintDisabled?: boolean }\n\nexport type ProjectType = ProjectDefinition['type']\nexport type ProjectDefinition = LintIgnoredConfig &\n (\n | { type: 'integration'; definition: sdk.IntegrationDefinition }\n | { type: 'interface'; definition: sdk.InterfaceDefinition }\n | { type: 'bot'; definition: sdk.BotDefinition }\n | { type: 'plugin'; definition: sdk.PluginDefinition }\n )\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 super({\n workDir: absWorkDir,\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 readProjectDefinitionFromFS(): Promise<ProjectDefinition> {\n const projectPaths = this.projectPaths\n try {\n const integrationDefinition = await this._readIntegrationDefinitionFromFS(projectPaths)\n if (integrationDefinition) {\n return { type: 'integration', ...integrationDefinition }\n }\n const interfaceDefinition = await this._readInterfaceDefinitionFromFS(projectPaths)\n if (interfaceDefinition) {\n return { type: 'interface', ...interfaceDefinition }\n }\n const botDefinition = await this._readBotDefinitionFromFS(projectPaths)\n if (botDefinition) {\n return { type: 'bot', ...botDefinition }\n }\n const pluginDefinition = await this._readPluginDefinitionFromFS(projectPaths)\n if (pluginDefinition) {\n return { type: 'plugin', ...pluginDefinition }\n }\n } catch (thrown: unknown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Error while reading project definition')\n }\n\n throw new errors.ProjectDefinitionNotFoundError(this.projectPaths.abs.workDir)\n }\n\n private async _readIntegrationDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'integrationDefinition'>\n ): Promise<({ definition: sdk.IntegrationDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.integrationDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.integrationDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.integrationDefinition,\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 validateIntegrationDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readInterfaceDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'interfaceDefinition'>\n ): Promise<({ definition: sdk.InterfaceDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.interfaceDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.interfaceDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.interfaceDefinition,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read interface definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.InterfaceDefinition }>(artifact.text)\n\n return { definition, bpLintDisabled }\n }\n\n private async _readBotDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'botDefinition'>\n ): Promise<({ definition: sdk.BotDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.botDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.botDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.botDefinition,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read bot definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.BotDefinition }>(artifact.text)\n validateBotDefinition(definition)\n return { definition, bpLintDisabled }\n }\n\n private async _readPluginDefinitionFromFS(\n projectPaths: utils.path.PathStore<'workDir' | 'pluginDefinition'>\n ): Promise<({ definition: sdk.PluginDefinition } & LintIgnoredConfig) | undefined> {\n const abs = projectPaths.abs\n const rel = projectPaths.rel('workDir')\n\n if (!fs.existsSync(abs.pluginDefinition)) {\n return\n }\n\n const bpLintDisabled = await this._isBpLintDisabled(abs.pluginDefinition)\n\n const { outputFiles } = await utils.esbuild.buildEntrypoint({\n absWorkingDir: abs.workDir,\n entrypoint: rel.pluginDefinition,\n })\n\n const artifact = outputFiles[0]\n if (!artifact) {\n throw new errors.BotpressCLIError('Could not read plugin definition')\n }\n\n const { default: definition } = utils.require.requireJsCode<{ default: sdk.PluginDefinition }>(artifact.text)\n // TODO: validate plugin definition\n return { definition, bpLintDisabled }\n }\n\n private async _isBpLintDisabled(definitionPath: string): Promise<boolean> {\n const tsContent = await fs.promises.readFile(definitionPath, 'utf-8')\n const regex = /\\/\\* bplint-disable \\*\\//\n return regex.test(tsContent)\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 protected async prepareCreateIntegrationBody(\n integrationDef: sdk.IntegrationDefinition\n ): Promise<apiUtils.CreateIntegrationRequestBody> {\n const partialBody = await apiUtils.prepareCreateIntegrationBody(integrationDef)\n\n let code: string | undefined = undefined\n if (fs.existsSync(this.projectPaths.abs.outFileCJS)) {\n code = await this.readProjectFile(this.projectPaths.abs.outFileCJS)\n }\n\n const icon = await this.readProjectFile(integrationDef.icon, 'base64')\n const readme = await this.readProjectFile(integrationDef.readme, 'base64')\n const extractScript = await this.readProjectFile(integrationDef.identifier?.extractScript)\n const fallbackHandlerScript = await this.readProjectFile(integrationDef.identifier?.fallbackHandlerScript)\n return {\n ...partialBody,\n code,\n icon,\n readme,\n identifier: {\n extractScript,\n fallbackHandlerScript,\n },\n configuration: integrationDef.configuration\n ? {\n schema: await utils.schema.mapZodToJsonSchema(integrationDef.configuration),\n identifier: {\n required: integrationDef.configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(\n integrationDef.configuration.identifier?.linkTemplateScript\n ),\n },\n }\n : undefined,\n configurations: integrationDef.configurations\n ? await utils.records.mapValuesAsync(integrationDef.configurations, async (configuration) => ({\n title: configuration.title,\n description: configuration.description,\n schema: await utils.schema.mapZodToJsonSchema(configuration),\n identifier: {\n required: configuration.identifier?.required,\n linkTemplateScript: await this.readProjectFile(configuration.identifier?.linkTemplateScript),\n },\n }))\n : undefined,\n }\n }\n\n protected async prepareBotDependencies(\n botDef: sdk.BotDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.UpdateBotRequestBody>> {\n const integrations = await this._fetchDependencies(botDef.integrations ?? {}, ({ name, version }) =>\n api.getPublicOrPrivateIntegration({ type: 'name', name, version })\n )\n const plugins = await this._fetchDependencies(botDef.plugins ?? {}, ({ name, version }) =>\n api.getPublicOrPrivatePlugin({ type: 'name', name, version })\n )\n return {\n integrations: _(integrations)\n .keyBy((i) => i.id)\n .value(),\n plugins,\n }\n }\n\n protected async prepareIntegrationDependencies(\n integrationDef: sdk.IntegrationDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreateIntegrationRequestBody>> {\n const interfaces = await this._fetchDependencies(integrationDef.interfaces ?? {}, ({ name, version }) =>\n api.getPublicInterface({ type: 'name', name, version })\n )\n return { interfaces }\n }\n\n protected async preparePluginDependencies(\n pluginDef: sdk.PluginDefinition,\n api: apiUtils.ApiClient\n ): Promise<Partial<apiUtils.CreatePluginRequestBody>> {\n const integrations = await this._fetchDependencies(pluginDef.integrations ?? {}, ({ name, version }) =>\n api.getPublicOrPrivateIntegration({ type: 'name', name, version })\n )\n const interfaces = await this._fetchDependencies(pluginDef.interfaces ?? {}, ({ name, version }) =>\n api.getPublicInterface({ type: 'name', name, version })\n )\n return {\n dependencies: {\n integrations,\n interfaces,\n },\n }\n }\n\n private _fetchDependencies = async <T extends { id?: string; name: string; version: string }>(\n deps: Record<string, T>,\n fetcher: (dep: T) => Promise<{ id: string }>\n ): Promise<Record<string, T & { id: string }>> => {\n const isRemote = (dep: T): dep is T & { id: string } => dep.id !== undefined\n return utils.records.mapValuesAsync(deps, async (dep): Promise<T & { id: string }> => {\n if (isRemote(dep)) {\n return dep\n }\n const { id } = await fetcher(dep)\n return { ...dep, id }\n })\n }\n\n protected readProjectFile = async (\n filePath: string | undefined,\n encoding: BufferEncoding = 'utf-8'\n ): Promise<string | undefined> => {\n if (!filePath) {\n return undefined\n }\n const absoluteFilePath = utils.path.absoluteFrom(this.projectPaths.abs.workDir, filePath)\n return fs.promises.readFile(absoluteFilePath, encoding).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not read file \"${absoluteFilePath}\"`)\n })\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,mBAAkB;AAClB,gBAAe;AACf,oBAAc;AACd,oBAAmB;AACnB,eAA0B;AAC1B,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,iBAAqE;AAErE,YAAuB;AACvB,4BAA8B;AAoB9B,MAAM,qBAAqB,MAAM,KAAK,UAAiC;AAAA,EAC9D,YAAY,MAA6C;AAC9D,UAAM,aAAa,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,OAAO;AACzE,UAAM;AAAA,MACJ,SAAS;AAAA,MACT,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,eAAe;AAC3B,WAAO,IAAI,MAAM,MAAM,gBAA8B,KAAK,aAAa,IAAI,gBAAgB;AAAA,EAC7F;AAAA,EAEA,MAAgB,8BAA0D;AACxE,UAAM,eAAe,KAAK;AAC1B,QAAI;AACF,YAAM,wBAAwB,MAAM,KAAK,iCAAiC,YAAY;AACtF,UAAI,uBAAuB;AACzB,eAAO,EAAE,MAAM,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3C,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;",
|
|
6
6
|
"names": ["_", "fs", "chalk", "semver"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
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.
|
|
25
|
-
"@botpress/sdk": "4.
|
|
24
|
+
"@botpress/client": "1.13.0",
|
|
25
|
+
"@botpress/sdk": "4.7.0",
|
|
26
26
|
"@bpinternal/const": "^0.1.0",
|
|
27
27
|
"@bpinternal/tunnel": "^0.1.1",
|
|
28
28
|
"@bpinternal/yargs-extra": "^0.0.3",
|