@botpress/cli 2.2.5 → 3.0.1
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 +10 -10
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +10 -2
- package/dist/api/client.js.map +2 -2
- package/dist/api/find-previous-version.test.js +1 -1
- package/dist/api/find-previous-version.test.js.map +2 -2
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +2 -2
- package/dist/api/integration-body.js +6 -19
- package/dist/api/integration-body.js.map +2 -2
- package/dist/api/interface-body.js +1 -5
- package/dist/api/interface-body.js.map +2 -2
- package/dist/api/plugin-body.js +3 -0
- package/dist/api/plugin-body.js.map +2 -2
- package/dist/api/types.js.map +1 -1
- package/dist/code-generation/bot-implementation/bot-implementation.js +5 -2
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +3 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-typings/index.js +11 -2
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-typings/tables-module.js +64 -0
- package/dist/code-generation/bot-implementation/bot-typings/tables-module.js.map +7 -0
- package/dist/code-generation/generators.js +11 -2
- package/dist/code-generation/generators.js.map +3 -3
- package/dist/code-generation/integration-package/index.js +4 -21
- package/dist/code-generation/integration-package/index.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +10 -1
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js +11 -1
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js +10 -8
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js +10 -5
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js +9 -1
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js +9 -4
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/index.js +12 -3
- package/dist/code-generation/integration-package/integration-package-definition/index.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/interfaces-module.js +61 -0
- package/dist/code-generation/integration-package/integration-package-definition/interfaces-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js +6 -1
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js.map +2 -2
- package/dist/code-generation/integration-package/integration-package-definition/typings.js.map +1 -1
- package/dist/code-generation/interface-package/index.js +4 -21
- package/dist/code-generation/interface-package/index.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +10 -1
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js +9 -1
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js +9 -1
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js +9 -1
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/index.js +0 -2
- package/dist/code-generation/interface-package/interface-package-definition/index.js.map +2 -2
- package/dist/code-generation/interface-package/interface-package-definition/typings.js.map +1 -1
- package/dist/code-generation/module.js +13 -7
- package/dist/code-generation/module.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +27 -4
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +19 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +2 -2
- package/dist/code-generation/plugin-implementation/plugin-typings/tables-module.js +64 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/tables-module.js.map +7 -0
- package/dist/code-generation/plugin-package/index.js +4 -46
- package/dist/code-generation/plugin-package/index.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +8 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +10 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +9 -4
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js +15 -3
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/interfaces-module.js +58 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/interfaces-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +6 -1
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +2 -2
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js.map +1 -1
- package/dist/code-generation/strings.js +10 -5
- package/dist/code-generation/strings.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/code-generation/typings.test.js +15 -0
- package/dist/code-generation/typings.test.js.map +7 -0
- package/dist/command-implementations/add-command.js +70 -25
- package/dist/command-implementations/add-command.js.map +2 -2
- package/dist/command-implementations/bundle-command.js +34 -27
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +26 -68
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +13 -17
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/lint-command.js +5 -8
- package/dist/command-implementations/lint-command.js.map +3 -3
- package/dist/command-implementations/plugin-commands.js +1 -2
- package/dist/command-implementations/plugin-commands.js.map +2 -2
- package/dist/command-implementations/project-command.js +82 -34
- package/dist/command-implementations/project-command.js.map +2 -2
- package/dist/command-implementations/read-command.js +23 -8
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/command-implementations/serve-command.js +1 -1
- package/dist/command-implementations/serve-command.js.map +1 -1
- package/dist/consts.js +4 -2
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +3 -3
- package/dist/errors.js.map +2 -2
- package/dist/linter/base-linter.test.js +6 -1
- package/dist/linter/base-linter.test.js.map +2 -2
- package/dist/linter/bot-linter.js.map +2 -2
- package/dist/linter/integration-linter.js.map +1 -1
- package/dist/linter/interface-linter.js.map +2 -2
- package/dist/linter/ruleset-tests/bot.ruleset.test.js.map +2 -2
- package/dist/linter/ruleset-tests/interface.ruleset.test.js.map +2 -2
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/index.js.map +2 -2
- package/dist/{sdk/resolve-bot-interfaces.js → tables/index.js} +7 -21
- package/dist/tables/index.js.map +7 -0
- package/dist/tables/schemas.js +106 -0
- package/dist/tables/schemas.js.map +7 -0
- package/dist/tables/tables-publisher.js +157 -0
- package/dist/tables/tables-publisher.js.map +7 -0
- package/dist/utils/esbuild-utils.js +15 -13
- package/dist/utils/esbuild-utils.js.map +2 -2
- package/dist/utils/type-utils.js.map +1 -1
- package/package.json +4 -4
- package/templates/empty-bot/.botpress/implementation/index.ts +5 -2
- package/templates/empty-bot/.botpress/implementation/typings/index.ts +3 -0
- package/templates/empty-bot/.botpress/implementation/typings/tables/index.ts +6 -0
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/.botpress/implementation/index.ts +27 -4
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +3 -0
- package/templates/empty-plugin/.botpress/implementation/typings/tables/index.ts +6 -0
- 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/dist/sdk/resolve-bot-interfaces.js.map +0 -7
- package/dist/sdk/resolve-integration-interfaces.js +0 -161
- package/dist/sdk/resolve-integration-interfaces.js.map +0 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@
|
|
2
|
+
> @botpress/cli@3.0.1 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
3
|
> pnpm run bundle && pnpm run template:gen
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/cli@
|
|
6
|
+
> @botpress/cli@3.0.1 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@
|
|
10
|
+
> @botpress/cli@3.0.1 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
|
|
14
|
-
🤖 Botpress CLI
|
|
15
|
-
🤖 Botpress CLI
|
|
16
|
-
🤖 Botpress CLI
|
|
13
|
+
🤖 Botpress CLI v3.0.1
|
|
14
|
+
🤖 Botpress CLI v3.0.1
|
|
15
|
+
🤖 Botpress CLI v3.0.1
|
|
16
|
+
🤖 Botpress CLI v3.0.1
|
|
17
|
+
[2K[1G○ Generating typings for integration hello-world...[2K[1G○ Generating typings for plugin empty-plugin...[2K[1G✓ Typings available at .botpress
|
|
18
|
+
[2K[1G○ Generating typings for bot...[2K[1G✓ Typings available at .botpress
|
|
17
19
|
[2K[1G○ Generating typings for integration empty-integration...[2K[1G✓ Typings available at .botpress
|
|
18
|
-
[2K[1G○ Generating typings for plugin empty-plugin...[2K[1G✓ Typings available at .botpress
|
|
19
|
-
[2K[1G○ Generating typings for integration hello-world...[2K[1G○ Generating typings for bot...[2K[1G✓ Typings available at .botpress
|
|
20
20
|
[2K[1G✓ Typings available at .botpress
|
|
21
|
-
🤖 Botpress CLI
|
|
21
|
+
🤖 Botpress CLI v3.0.1
|
|
22
22
|
[2K[1G○ Generating typings for integration webhook-message...[2K[1G✓ Typings available at .botpress
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;
|
|
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 ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n }))\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.records.setNullOnMissingValues(localBot.events, remoteBot.events),\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})\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,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;AACN;AAEO,MAAM,uBAAuB,CAClC,UACA,eACgC;AAAA,EAChC,GAAG;AAAA,EACH,QAAQ,MAAM,QAAQ,uBAAuB,SAAS,QAAQ,UAAU,MAAM;AAAA,EAC9E,iBAAiB,MAAM,QAAQ,uBAAuB,SAAS,iBAAiB,UAAU,eAAe;AAAA,EACzG,QAAQ,MAAM,QAAQ,uBAAuB,SAAS,QAAQ,UAAU,MAAM;AAAA,EAC9E,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;AAClG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/api/client.js
CHANGED
|
@@ -42,16 +42,18 @@ __reExport(client_exports, require("./types"), module.exports);
|
|
|
42
42
|
class ApiClient {
|
|
43
43
|
constructor(props, _logger) {
|
|
44
44
|
this._logger = _logger;
|
|
45
|
-
const { apiUrl, token, workspaceId } = props;
|
|
46
|
-
this.client = new client.Client({ apiUrl, token, workspaceId });
|
|
45
|
+
const { apiUrl, token, workspaceId, botId } = props;
|
|
46
|
+
this.client = new client.Client({ apiUrl, token, workspaceId, botId });
|
|
47
47
|
this.url = apiUrl;
|
|
48
48
|
this.token = token;
|
|
49
49
|
this.workspaceId = workspaceId;
|
|
50
|
+
this.botId = botId;
|
|
50
51
|
}
|
|
51
52
|
client;
|
|
52
53
|
url;
|
|
53
54
|
token;
|
|
54
55
|
workspaceId;
|
|
56
|
+
botId;
|
|
55
57
|
static newClient = (props, logger) => new ApiClient(props, logger);
|
|
56
58
|
get isBotpressWorkspace() {
|
|
57
59
|
const isBotpressWorkspace = (0, import_yn.default)(process.env.BP_IS_BOTPRESS_WORKSPACE);
|
|
@@ -74,6 +76,12 @@ class ApiClient {
|
|
|
74
76
|
switchWorkspace(workspaceId) {
|
|
75
77
|
return ApiClient.newClient({ apiUrl: this.url, token: this.token, workspaceId }, this._logger);
|
|
76
78
|
}
|
|
79
|
+
switchBot(botId) {
|
|
80
|
+
return ApiClient.newClient(
|
|
81
|
+
{ apiUrl: this.url, token: this.token, botId, workspaceId: this.workspaceId },
|
|
82
|
+
this._logger
|
|
83
|
+
);
|
|
84
|
+
}
|
|
77
85
|
async updateWorkspace(props) {
|
|
78
86
|
return this.client.updateWorkspace({ id: this.workspaceId, ...props });
|
|
79
87
|
}
|
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 semver from 'semver'\nimport yn from 'yn'\nimport type { Logger } from '../logger'\nimport { formatPackageRef, ApiPackageRef, NamePackageRef, isLatest } from '../package-ref'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport * as paging from './paging'\n\nimport {\n ApiClientProps,\n PublicIntegration,\n PrivateIntegration,\n Integration,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,oBAAmB;AACnB,gBAAe;AAEf,yBAA0E;
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport semver from 'semver'\nimport yn from 'yn'\nimport type { Logger } from '../logger'\nimport { formatPackageRef, ApiPackageRef, NamePackageRef, isLatest } 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 Integration,\n Interface,\n Plugin,\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 paging.listAllPages(this.client.listWorkspaces, (r) => r.workspaces)\n return workspaces.find((w) => w.handle === 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 findIntegration(ref: ApiPackageRef): Promise<Integration | 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)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n return this.client\n .getPublicIntegration(ref)\n .then((r) => r.integration)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicInterface(ref: ApiPackageRef): Promise<Interface | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getInterface(ref)\n .then((r) => r.interface)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n if (isLatest(ref)) {\n // TODO: handle latest keyword in backend\n return this._findLatestInterfaceVersion(ref)\n }\n\n return this.client\n .getInterfaceByName(ref)\n .then((r) => r.interface)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n public async findPublicPlugin(ref: ApiPackageRef): Promise<Plugin | undefined> {\n if (ref.type === 'id') {\n return this.client\n .getPlugin(ref)\n .then((r) => r.plugin)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n if (isLatest(ref)) {\n // TODO: handle latest keyword in backend\n return this._findLatestPluginVersion(ref)\n }\n\n return this.client\n .getPluginByName(ref)\n .then((r) => r.plugin)\n .catch(this._returnUndefinedOnError('ResourceNotFound'))\n }\n\n private _findLatestInterfaceVersion = async ({ name }: NamePackageRef): Promise<Interface | undefined> => {\n const { interfaces: allVersions } = await this.client.listInterfaces({ name })\n const sorted = allVersions.sort((a, b) => semver.compare(b.version, a.version))\n const latestVersion = sorted[0]\n if (!latestVersion) {\n return\n }\n return this.client.getInterface({ id: latestVersion.id }).then((r) => r.interface)\n }\n\n private _findLatestPluginVersion = async ({ name }: NamePackageRef): Promise<Plugin | undefined> => {\n const { plugins: allVersions } = await this.client.listPlugins({ name })\n const sorted = allVersions.sort((a, b) => semver.compare(b.version, a.version))\n const latestVersion = sorted[0]\n if (!latestVersion) {\n return\n }\n return this.client.getPlugin({ id: latestVersion.id }).then((r) => r.plugin)\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<Integration | undefined> {\n const previous = await findPreviousIntegrationVersion(this.client, ref)\n if (!previous) {\n return\n }\n return this.findIntegration({ 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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egrationFixtureCreator {
|
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
(0, import_vitest.test)("find previous integration version", async (
|
|
47
|
+
(0, import_vitest.test)("find previous integration version", async () => {
|
|
48
48
|
const client2 = {
|
|
49
49
|
listIntegrations: async ({ name }) => {
|
|
50
50
|
const creator = new IntegrationFixtureCreator(name);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/find-previous-version.test.ts"],
|
|
4
|
-
"sourcesContent": ["import * as uuid from 'uuid'\nimport * as client from '@botpress/client'\nimport { test, expect } from 'vitest'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport { IntegrationSummary } from './types'\n\nclass IntegrationFixtureCreator {\n private t0 = Date.now()\n\n public constructor(private name: string) {}\n\n public create = (version: string): IntegrationSummary => {\n return {\n id: uuid.v4(),\n name: this.name,\n version,\n public: true,\n createdAt: new Date(this.t0++).toISOString(),\n updatedAt: new Date(this.t0++).toISOString(),\n description: 'description',\n title: 'title',\n iconUrl: 'iconUrl',\n verificationStatus: 'approved',\n }\n }\n}\n\ntest('find previous integration version', async (
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAsB;AAEtB,oBAA6B;AAC7B,mCAA+C;AAG/C,MAAM,0BAA0B;AAAA,EAGvB,YAAoB,MAAc;AAAd;AAAA,EAAe;AAAA,EAFlC,KAAK,KAAK,IAAI;AAAA,EAIf,SAAS,CAAC,YAAwC;AACvD,WAAO;AAAA,MACL,IAAI,KAAK,GAAG;AAAA,MACZ,MAAM,KAAK;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,MACR,WAAW,IAAI,KAAK,KAAK,IAAI,EAAE,YAAY;AAAA,MAC3C,WAAW,IAAI,KAAK,KAAK,IAAI,EAAE,YAAY;AAAA,MAC3C,aAAa;AAAA,MACb,OAAO;AAAA,MACP,SAAS;AAAA,MACT,oBAAoB;AAAA,IACtB;AAAA,EACF;AACF;AAAA,IAEA,oBAAK,qCAAqC,
|
|
4
|
+
"sourcesContent": ["import * as uuid from 'uuid'\nimport * as client from '@botpress/client'\nimport { test, expect } from 'vitest'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport { IntegrationSummary } from './types'\n\nclass IntegrationFixtureCreator {\n private t0 = Date.now()\n\n public constructor(private name: string) {}\n\n public create = (version: string): IntegrationSummary => {\n return {\n id: uuid.v4(),\n name: this.name,\n version,\n public: true,\n createdAt: new Date(this.t0++).toISOString(),\n updatedAt: new Date(this.t0++).toISOString(),\n description: 'description',\n title: 'title',\n iconUrl: 'iconUrl',\n verificationStatus: 'approved',\n }\n }\n}\n\ntest('find previous integration version', async () => {\n const client: Partial<client.Client> = {\n listIntegrations: async ({ name }: { name?: string; version?: string }) => {\n const creator = new IntegrationFixtureCreator(name!)\n\n const integrations: IntegrationSummary[] = [\n creator.create('9.2.0'),\n creator.create('9.2.1'),\n creator.create('9.3.0'),\n creator.create('9.2.2'),\n creator.create('10.0.0'),\n ].reverse() // reverse creation order just like the real API\n\n return { integrations, meta: {} }\n },\n }\n\n const getPrevious = async (version: string) => {\n const integration = await findPreviousIntegrationVersion(client as client.Client, {\n type: 'name',\n name: 'slack',\n version,\n })\n return integration?.version\n }\n\n expect(await getPrevious('10.0.1')).toEqual('10.0.0')\n expect(await getPrevious('10.0.0')).toEqual('9.3.0')\n expect(await getPrevious('9.3.0')).toEqual('9.2.2')\n expect(await getPrevious('9.2.2')).toEqual('9.2.1')\n expect(await getPrevious('9.2.1')).toEqual('9.2.0')\n expect(await getPrevious('9.2.0')).toEqual(undefined)\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,WAAsB;AAEtB,oBAA6B;AAC7B,mCAA+C;AAG/C,MAAM,0BAA0B;AAAA,EAGvB,YAAoB,MAAc;AAAd;AAAA,EAAe;AAAA,EAFlC,KAAK,KAAK,IAAI;AAAA,EAIf,SAA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AACtD,CAAC;",
|
|
6
6
|
"names": ["client"]
|
|
7
7
|
}
|
package/dist/api/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __reExport(api_exports, require("./types"), module.exports);
|
|
|
20
20
|
__reExport(api_exports, require("./integration-body"), module.exports);
|
|
21
21
|
__reExport(api_exports, require("./interface-body"), module.exports);
|
|
22
22
|
__reExport(api_exports, require("./bot-body"), module.exports);
|
|
23
|
+
__reExport(api_exports, require("./plugin-body"), module.exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './client'\nexport * from './types'\nexport * from './integration-body'\nexport * from './interface-body'\nexport * from './bot-body'\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;AACA,wBAAc,oBADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,6BAHd;AAIA,wBAAc,uBAJd;",
|
|
4
|
+
"sourcesContent": ["export * from './client'\nexport * from './types'\nexport * from './integration-body'\nexport * from './interface-body'\nexport * from './bot-body'\nexport * from './plugin-body'\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;AACA,wBAAc,oBADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,6BAHd;AAIA,wBAAc,uBAJd;AAKA,wBAAc,0BALd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -36,22 +36,9 @@ var utils = __toESM(require("../utils"));
|
|
|
36
36
|
const prepareCreateIntegrationBody = async (integration) => ({
|
|
37
37
|
name: integration.name,
|
|
38
38
|
version: integration.version,
|
|
39
|
-
title: integration.title,
|
|
40
|
-
description: integration.description,
|
|
41
|
-
icon: integration.icon,
|
|
42
|
-
readme: integration.readme,
|
|
39
|
+
title: "title" in integration ? integration.title : void 0,
|
|
40
|
+
description: "description" in integration ? integration.description : void 0,
|
|
43
41
|
user: integration.user,
|
|
44
|
-
identifier: integration.identifier,
|
|
45
|
-
secrets: void 0,
|
|
46
|
-
interfaces: {},
|
|
47
|
-
configuration: integration.configuration ? {
|
|
48
|
-
...integration.configuration,
|
|
49
|
-
schema: await utils.schema.mapZodToJsonSchema(integration.configuration)
|
|
50
|
-
} : void 0,
|
|
51
|
-
configurations: integration.configurations ? await utils.records.mapValuesAsync(integration.configurations, async (configuration) => ({
|
|
52
|
-
...configuration,
|
|
53
|
-
schema: await utils.schema.mapZodToJsonSchema(configuration)
|
|
54
|
-
})) : void 0,
|
|
55
42
|
events: integration.events ? await utils.records.mapValuesAsync(integration.events, async (event) => ({
|
|
56
43
|
...event,
|
|
57
44
|
schema: await utils.schema.mapZodToJsonSchema(event)
|
|
@@ -92,7 +79,7 @@ const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
|
|
|
92
79
|
...localIntegration.user,
|
|
93
80
|
tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags)
|
|
94
81
|
};
|
|
95
|
-
const channels =
|
|
82
|
+
const channels = _prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels);
|
|
96
83
|
const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces);
|
|
97
84
|
const configurations = utils.records.setNullOnMissingValues(
|
|
98
85
|
localIntegration.configurations,
|
|
@@ -110,12 +97,12 @@ const prepareUpdateIntegrationBody = (localIntegration, remoteIntegration) => {
|
|
|
110
97
|
configurations
|
|
111
98
|
};
|
|
112
99
|
};
|
|
113
|
-
const
|
|
100
|
+
const _prepareUpdateIntegrationChannelsBody = (localChannels, remoteChannels) => {
|
|
114
101
|
const channelBody = {};
|
|
115
102
|
const zipped = utils.records.zipObjects(localChannels, remoteChannels);
|
|
116
103
|
for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {
|
|
117
104
|
if (localChannel && remoteChannel) {
|
|
118
|
-
channelBody[channelName] =
|
|
105
|
+
channelBody[channelName] = _prepareUpdateIntegrationChannelBody(localChannel, remoteChannel);
|
|
119
106
|
} else if (localChannel) {
|
|
120
107
|
channelBody[channelName] = localChannel;
|
|
121
108
|
continue;
|
|
@@ -126,7 +113,7 @@ const prepareUpdateIntegrationChannelsBody = (localChannels, remoteChannels) =>
|
|
|
126
113
|
}
|
|
127
114
|
return channelBody;
|
|
128
115
|
};
|
|
129
|
-
const
|
|
116
|
+
const _prepareUpdateIntegrationChannelBody = (localChannel, remoteChannel) => ({
|
|
130
117
|
...localChannel,
|
|
131
118
|
messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),
|
|
132
119
|
message: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/integration-body.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;
|
|
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 prepareCreateIntegrationBody = async (\n integration: sdk.IntegrationDefinition | sdk.IntegrationPackage['definition']\n): Promise<types.CreateIntegrationRequestBody> => ({\n name: integration.name,\n version: integration.version,\n title: 'title' in integration ? integration.title : undefined,\n description: 'description' in integration ? integration.description : undefined,\n user: integration.user,\n events: integration.events\n ? await utils.records.mapValuesAsync(integration.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n actions: integration.actions\n ? await utils.records.mapValuesAsync(integration.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 channels: integration.channels\n ? await utils.records.mapValuesAsync(integration.channels, async (channel) => ({\n ...channel,\n messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({\n ...message,\n schema: await utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : undefined,\n states: integration.states\n ? await utils.records.mapValuesAsync(integration.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n entities: integration.entities\n ? await utils.records.mapValuesAsync(integration.entities, async (entity) => ({\n ...entity,\n schema: await utils.schema.mapZodToJsonSchema(entity),\n }))\n : undefined,\n})\n\ntype UpdateIntegrationChannelsBody = NonNullable<types.UpdateIntegrationRequestBody['channels']>\ntype UpdateIntegrationChannelBody = UpdateIntegrationChannelsBody[string]\ntype Channels = client.Integration['channels']\ntype Channel = client.Integration['channels'][string]\nexport const prepareUpdateIntegrationBody = (\n localIntegration: types.UpdateIntegrationRequestBody,\n remoteIntegration: client.Integration\n): types.UpdateIntegrationRequestBody => {\n const actions = utils.records.setNullOnMissingValues(localIntegration.actions, remoteIntegration.actions)\n const events = utils.records.setNullOnMissingValues(localIntegration.events, remoteIntegration.events)\n const states = utils.records.setNullOnMissingValues(localIntegration.states, remoteIntegration.states)\n const entities = utils.records.setNullOnMissingValues(localIntegration.entities, remoteIntegration.entities)\n const user = {\n ...localIntegration.user,\n tags: utils.records.setNullOnMissingValues(localIntegration.user?.tags, remoteIntegration.user?.tags),\n }\n\n const channels = _prepareUpdateIntegrationChannelsBody(localIntegration.channels ?? {}, remoteIntegration.channels)\n\n const interfaces = utils.records.setNullOnMissingValues(localIntegration.interfaces, remoteIntegration.interfaces)\n\n const configurations = utils.records.setNullOnMissingValues(\n localIntegration.configurations,\n remoteIntegration.configurations\n )\n\n return {\n ...localIntegration,\n actions,\n events,\n states,\n entities,\n user,\n channels,\n interfaces,\n configurations,\n }\n}\n\nconst _prepareUpdateIntegrationChannelsBody = (\n localChannels: UpdateIntegrationChannelsBody,\n remoteChannels: Channels\n): UpdateIntegrationChannelsBody => {\n const channelBody: UpdateIntegrationChannelsBody = {}\n\n const zipped = utils.records.zipObjects(localChannels, remoteChannels)\n for (const [channelName, [localChannel, remoteChannel]] of Object.entries(zipped)) {\n if (localChannel && remoteChannel) {\n // channel has to be updated\n channelBody[channelName] = _prepareUpdateIntegrationChannelBody(localChannel, remoteChannel)\n } else if (localChannel) {\n // channel has to be created\n channelBody[channelName] = localChannel\n continue\n } else if (remoteChannel) {\n // channel has to be deleted\n channelBody[channelName] = null\n continue\n }\n }\n\n return channelBody\n}\n\nconst _prepareUpdateIntegrationChannelBody = (\n localChannel: UpdateIntegrationChannelBody,\n remoteChannel: Channel\n): UpdateIntegrationChannelBody => ({\n ...localChannel,\n messages: utils.records.setNullOnMissingValues(localChannel?.messages, remoteChannel.messages),\n message: {\n ...localChannel?.message,\n tags: utils.records.setNullOnMissingValues(localChannel?.message?.tags, remoteChannel.message.tags),\n },\n conversation: {\n ...localChannel?.conversation,\n tags: utils.records.setNullOnMissingValues(localChannel?.conversation?.tags, remoteChannel.conversation.tags),\n },\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,+BAA+B,OAC1C,iBACiD;AAAA,EACjD,MAAM,YAAY;AAAA,EAClB,SAAS,YAAY;AAAA,EACrB,OAAO,WAAW,cAAc,YAAY,QAAQ;AAAA,EACpD,aAAa,iBAAiB,cAAc,YAAY,cAAc;AAAA,EACtE,MAAM,YAAY;AAAA,EAClB,QAAQ,YAAY,SAChB,MAAM,MAAM,QAAQ,eAAe,YAAY,QAAQ,OAAO,WAAW;AAAA,IACvE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AAAA,EACJ,SAAS,YAAY,UACjB,MAAM,MAAM,QAAQ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AAM,QAAQ,uBAAuB,cAAc,cAAc,MAAM,cAAc,aAAa,IAAI;AAAA,EAC9G;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -61,11 +61,7 @@ const prepareCreateInterfaceBody = async (intrface) => ({
|
|
|
61
61
|
...message,
|
|
62
62
|
schema: await utils.schema.mapZodToJsonSchema(message)
|
|
63
63
|
}))
|
|
64
|
-
})) : {}
|
|
65
|
-
nameTemplate: intrface.templateName ? {
|
|
66
|
-
script: intrface.templateName,
|
|
67
|
-
language: "handlebars"
|
|
68
|
-
} : void 0
|
|
64
|
+
})) : {}
|
|
69
65
|
});
|
|
70
66
|
const prepareUpdateInterfaceBody = (localInterface, remoteInterface) => {
|
|
71
67
|
const actions = utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/interface-body.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;
|
|
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 prepareCreateInterfaceBody = async (\n intrface: sdk.InterfaceDefinition | sdk.InterfacePackage['definition']\n): Promise<types.CreateInterfaceRequestBody> => ({\n name: intrface.name,\n version: intrface.version,\n entities: intrface.entities\n ? await utils.records.mapValuesAsync(intrface.entities, async (entity) => ({\n ...entity,\n schema: await utils.schema.mapZodToJsonSchema(entity),\n }))\n : {},\n events: intrface.events\n ? await utils.records.mapValuesAsync(intrface.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : {},\n actions: intrface.actions\n ? await utils.records.mapValuesAsync(intrface.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 : {},\n channels: intrface.channels\n ? await utils.records.mapValuesAsync(intrface.channels, async (channel) => ({\n ...channel,\n messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({\n ...message,\n schema: await utils.schema.mapZodToJsonSchema(message),\n })),\n }))\n : {},\n})\n\nexport const prepareUpdateInterfaceBody = (\n localInterface: types.CreateInterfaceRequestBody & { id: string },\n remoteInterface: client.Interface\n): types.UpdateInterfaceRequestBody => {\n const actions = utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions)\n const events = utils.records.setNullOnMissingValues(localInterface.events, remoteInterface.events)\n const entities = utils.records.setNullOnMissingValues(localInterface.entities, remoteInterface.entities)\n\n const currentChannels: types.UpdateInterfaceRequestBody['channels'] = localInterface.channels\n ? utils.records.mapValues(localInterface.channels, (channel, channelName) => ({\n ...channel,\n messages: utils.records.setNullOnMissingValues(\n channel?.messages,\n remoteInterface.channels[channelName]?.messages\n ),\n }))\n : undefined\n\n const channels = utils.records.setNullOnMissingValues(currentChannels, remoteInterface.channels)\n\n return {\n ...localInterface,\n entities,\n actions,\n events,\n channels,\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAGhB,MAAM,6BAA6B,OACxC,cAC+C;AAAA,EAC/C,MAAM,SAAS;AAAA,EACf,SAAS,SAAS;AAAA,EAClB,UAAU,SAAS,WACf,MAAM,MAAM,QAAQ,eAAe,SAAS,UAAU,OAAO,YAAY;AAAA,IACvE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,MAAM;AAAA,EACtD,EAAE,IACF,CAAC;AAAA,EACL,QAAQ,SAAS,SACb,MAAM,MAAM,QAAQ,eAAe,SAAS,QAAQ,OAAO,WAAW;AAAA,IACp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gB,QAAQ;AAE/F,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/api/plugin-body.js
CHANGED
|
@@ -39,6 +39,9 @@ const prepareCreatePluginBody = async (plugin) => ({
|
|
|
39
39
|
user: {
|
|
40
40
|
tags: plugin.user?.tags ?? {}
|
|
41
41
|
},
|
|
42
|
+
conversation: {
|
|
43
|
+
tags: plugin.conversation?.tags ?? {}
|
|
44
|
+
},
|
|
42
45
|
configuration: plugin.configuration ? {
|
|
43
46
|
...plugin.configuration,
|
|
44
47
|
schema: await utils.schema.mapZodToJsonSchema(plugin.configuration)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/plugin-body.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;
|
|
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 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 ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n})\n\nexport const prepareUpdatePluginBody = (\n localPlugin: types.UpdatePluginRequestBody,\n remotePlugin: client.Plugin\n): types.UpdatePluginRequestBody => {\n const actions = utils.records.setNullOnMissingValues(localPlugin.actions, remotePlugin.actions)\n const events = utils.records.setNullOnMissingValues(localPlugin.events, remotePlugin.events)\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,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,SACX,MAAM,MAAM,QAAQ,eAAe,OAAO,QAAQ,OAAO,WAAW;AAAA,IAClE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AACN;AAEO,MAAM,0BAA0B,CACrC,aACA,iBACkC;AAClC,QAAM,UAAU,MAAM,QAAQ,uBAAuB,YAAY,SAAS,aAAa,OAAO;AAC9F,QAAM,SAAS,MAAM,QAAQ,uBAAuB,YAAY,QAAQ,aAAa,MAAM;AAC3F,QAAM,SAAS,MAAM,QAAQ,uBAAuB,YAAY,QAAQ,aAAa,MAAM;AAE3F,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,YAAY;AAAA;AAAA,EACpB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/api/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/types.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport { Logger } from '
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport { Logger } from '../logger'\nimport { SafeOmit, Merge } from '../utils/type-utils'\nimport { ApiClient } from './client'\n\nexport type ApiClientProps = {\n apiUrl: string\n token: string\n workspaceId: string\n botId?: string\n}\n\nexport type ApiClientFactory = {\n newClient: (props: ApiClientProps, logger: Logger) => ApiClient\n}\n\nexport type PublicIntegration = client.Integration\nexport type PrivateIntegration = client.Integration & { workspaceId: string }\nexport type Integration = client.Integration & { workspaceId?: string }\nexport type IntegrationSummary = client.ClientOutputs['listIntegrations']['integrations'][number]\nexport type BotSummary = client.ClientOutputs['listBots']['bots'][number]\nexport type Interface = client.Interface\nexport type Plugin = client.Plugin\n\nexport type CreateBotRequestBody = client.ClientInputs['createBot']\nexport type UpdateBotRequestBody = client.ClientInputs['updateBot']\n\nexport type CreateIntegrationRequestBody = client.ClientInputs['createIntegration']\nexport type UpdateIntegrationRequestBody = client.ClientInputs['updateIntegration']\n\nexport type CreateInterfaceRequestBody = client.ClientInputs['createInterface']\nexport type UpdateInterfaceRequestBody = client.ClientInputs['updateInterface']\n\ntype PluginDependency = client.Plugin['dependencies']['integrations'][string]\n\nexport type CreatePluginRequestBody = Merge<\n SafeOmit<client.ClientInputs['createPlugin'], 'code'>,\n {\n dependencies?: {\n integrations?: Record<string, PluginDependency>\n interfaces?: Record<string, PluginDependency>\n }\n }\n>\n\nexport type UpdatePluginRequestBody = Merge<\n client.ClientInputs['updatePlugin'],\n {\n dependencies?: {\n integrations?: Record<string, PluginDependency | null>\n interfaces?: Record<string, PluginDependency | null>\n }\n }\n>\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -86,11 +86,14 @@ class BotImplementationModule extends import_module.Module {
|
|
|
86
86
|
"// extra types",
|
|
87
87
|
"",
|
|
88
88
|
"type AsyncFunction = (...args: any[]) => Promise<any>",
|
|
89
|
+
"",
|
|
90
|
+
"export type BotHandlers = sdk.BotHandlers<TBot>",
|
|
91
|
+
"",
|
|
89
92
|
"export type EventHandlers = Required<{",
|
|
90
|
-
" [K in keyof
|
|
93
|
+
" [K in keyof BotHandlers['eventHandlers']]: NonNullable<BotHandlers['eventHandlers'][K]>[number]",
|
|
91
94
|
"}>",
|
|
92
95
|
"export type MessageHandlers = Required<{",
|
|
93
|
-
" [K in keyof
|
|
96
|
+
" [K in keyof BotHandlers['messageHandlers']]: NonNullable<BotHandlers['messageHandlers'][K]>[number]",
|
|
94
97
|
"}>",
|
|
95
98
|
"",
|
|
96
99
|
"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/code-generation/bot-implementation/bot-implementation.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { BotPluginsIndexModule } from './bot-plugins'\nimport { BotTypingsModule } from './bot-typings'\n\nexport class BotImplementationModule extends Module {\n private _typingsModule: BotTypingsModule\n private _pluginsModule: BotPluginsIndexModule\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Bot',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new BotTypingsModule(bot)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._pluginsModule = new BotPluginsIndexModule(bot)\n this._pluginsModule.unshift(consts.fromOutDir.pluginsDir)\n this.pushDep(this._pluginsModule)\n }\n\n public async getContent() {\n const {\n //\n _typingsModule: typingsModule,\n _pluginsModule: pluginsModule,\n } = this\n\n const typingsImport = typingsModule.import(this)\n const pluginsImport = pluginsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${pluginsModule.name} from \"./${pluginsImport}\"`,\n '',\n `export * from \"./${typingsImport}\"`,\n `export * from \"./${pluginsImport}\"`,\n '',\n `type TPlugins = ${pluginsModule.name}.TPlugins`,\n `type TBot = sdk.DefaultBot<${typingsModule.name}.${typingsModule.exportName}>`,\n '',\n 'export type BotProps = {',\n ' actions: sdk.BotProps<TBot, TPlugins>[\"actions\"]',\n '}',\n '',\n 'export class Bot extends sdk.Bot<TBot, TPlugins> {',\n ' public constructor(props: BotProps) {',\n ' super({',\n ' actions: props.actions,',\n ` plugins: ${pluginsModule.name}.${pluginsModule.exportName}`,\n ' })',\n ' }',\n '}',\n '',\n '// extra types',\n '',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n 'export type EventHandlers = Required<{',\n \" [K in keyof
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,yBAAsC;AACtC,yBAAiC;AAE1B,MAAM,gCAAgC,qBAAO;AAAA,EAC1C;AAAA,EACA;AAAA,EAED,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,oCAAiB,GAAG;AAC9C,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAEhC,SAAK,iBAAiB,IAAI,yCAAsB,GAAG;AACnD,SAAK,eAAe,QAAQ,OAAO,WAAW,UAAU;AACxD,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM;AAAA;AAAA,MAEJ,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAClB,IAAI;AAEJ,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAC/C,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAE/C,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,cAAc,gBAAgB;AAAA,MAC7C;AAAA,MACA,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB;AAAA,MACA,mBAAmB,cAAc;AAAA,MACjC,8BAA8B,cAAc,QAAQ,cAAc;AAAA,MAClE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB,cAAc,QAAQ,cAAc;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../consts'\nimport { Module } from '../module'\nimport { BotPluginsIndexModule } from './bot-plugins'\nimport { BotTypingsModule } from './bot-typings'\n\nexport class BotImplementationModule extends Module {\n private _typingsModule: BotTypingsModule\n private _pluginsModule: BotPluginsIndexModule\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Bot',\n path: consts.INDEX_FILE,\n })\n\n this._typingsModule = new BotTypingsModule(bot)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._pluginsModule = new BotPluginsIndexModule(bot)\n this._pluginsModule.unshift(consts.fromOutDir.pluginsDir)\n this.pushDep(this._pluginsModule)\n }\n\n public async getContent() {\n const {\n //\n _typingsModule: typingsModule,\n _pluginsModule: pluginsModule,\n } = this\n\n const typingsImport = typingsModule.import(this)\n const pluginsImport = pluginsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${pluginsModule.name} from \"./${pluginsImport}\"`,\n '',\n `export * from \"./${typingsImport}\"`,\n `export * from \"./${pluginsImport}\"`,\n '',\n `type TPlugins = ${pluginsModule.name}.TPlugins`,\n `type TBot = sdk.DefaultBot<${typingsModule.name}.${typingsModule.exportName}>`,\n '',\n 'export type BotProps = {',\n ' actions: sdk.BotProps<TBot, TPlugins>[\"actions\"]',\n '}',\n '',\n 'export class Bot extends sdk.Bot<TBot, TPlugins> {',\n ' public constructor(props: BotProps) {',\n ' super({',\n ' actions: props.actions,',\n ` plugins: ${pluginsModule.name}.${pluginsModule.exportName}`,\n ' })',\n ' }',\n '}',\n '',\n '// extra types',\n '',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n '',\n 'export type BotHandlers = sdk.BotHandlers<TBot>',\n '',\n 'export type EventHandlers = Required<{',\n \" [K in keyof BotHandlers['eventHandlers']]: NonNullable<BotHandlers['eventHandlers'][K]>[number]\",\n '}>',\n 'export type MessageHandlers = Required<{',\n \" [K in keyof BotHandlers['messageHandlers']]: NonNullable<BotHandlers['messageHandlers'][K]>[number]\",\n '}>',\n '',\n \"export type MessageHandlerProps = Parameters<MessageHandlers['*']>[0]\",\n \"export type EventHandlerProps = Parameters<EventHandlers['*']>[0]\",\n '',\n \"export type Client = (MessageHandlerProps | EventHandlerProps)['client']\",\n 'export type ClientOperation = keyof {',\n ' [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null',\n '}',\n 'export type ClientInputs = {',\n ' [K in ClientOperation]: Parameters<Client[K]>[0]',\n '}',\n 'export type ClientOutputs = {',\n ' [K in ClientOperation]: Awaited<ReturnType<Client[K]>>',\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,yBAAsC;AACtC,yBAAiC;AAE1B,MAAM,gCAAgC,qBAAO;AAAA,EAC1C;AAAA,EACA;AAAA,EAED,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,SAAK,iBAAiB,IAAI,oCAAiB,GAAG;AAC9C,SAAK,eAAe,QAAQ,SAAS;AACrC,SAAK,QAAQ,KAAK,cAAc;AAEhC,SAAK,iBAAiB,IAAI,yCAAsB,GAAG;AACnD,SAAK,eAAe,QAAQ,OAAO,WAAW,UAAU;AACxD,SAAK,QAAQ,KAAK,cAAc;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM;AAAA;AAAA,MAEJ,gBAAgB;AAAA,MAChB,gBAAgB;AAAA,IAClB,IAAI;AAEJ,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAC/C,UAAM,gBAAgB,cAAc,OAAO,IAAI;AAE/C,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,cAAc,gBAAgB;AAAA,MAC7C,eAAe,cAAc,gBAAgB;AAAA,MAC7C;AAAA,MACA,oBAAoB;AAAA,MACpB,oBAAoB;AAAA,MACpB;AAAA,MACA,mBAAmB,cAAc;AAAA,MACjC,8BAA8B,cAAc,QAAQ,cAAc;AAAA,MAClE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB,cAAc,QAAQ,cAAc;AAAA,MACtD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -117,6 +117,9 @@ class BotPluginModule extends import_module.Module {
|
|
|
117
117
|
"",
|
|
118
118
|
`export type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,
|
|
119
119
|
"",
|
|
120
|
+
`export const configuration = ${this._configModule.name}.${this._configModule.exportName}.configuration`,
|
|
121
|
+
`export const interfaces = ${this._configModule.name}.${this._configModule.exportName}.interfaces`,
|
|
122
|
+
"",
|
|
120
123
|
`export default bundle.initialize(${this._configModule.name}.${this._configModule.exportName})`,
|
|
121
124
|
""
|
|
122
125
|
].join("\n");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/code-generation/bot-implementation/bot-plugins/plugin-module.ts"],
|
|
4
|
-
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { Module, ModuleProps } from '../../module'\nimport { PluginTypingsModule } from '../../plugin-implementation/plugin-typings'\n\ntype PluginInstance = NonNullable<sdk.BotDefinition['plugins']>[string]\n\nclass BundleJsModule extends Module {\n private _indexJs: string\n public constructor(plugin: PluginInstance) {\n super({\n path: 'bundle.js',\n exportName: 'default',\n })\n this._indexJs = plugin.implementation.toString()\n }\n\n public async getContent() {\n return this._indexJs\n }\n}\n\nclass BundleDtsModule extends Module {\n public constructor(private _typingsModule: PluginTypingsModule) {\n super({\n path: 'bundle.d.ts',\n exportName: 'default',\n })\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n 'export default new sdk.Plugin<TPlugin>({})',\n '',\n ].join('\\n')\n }\n}\n\nclass PluginConfigModule extends Module {\n private _plugin: PluginInstance\n public constructor(config: ModuleProps & { plugin: PluginInstance }) {\n super(config)\n this._plugin = config.plugin\n }\n\n public async getContent() {\n const { interfaces, configuration } = this._plugin\n const content = JSON.stringify({ interfaces, configuration }, null, 2)\n return `export default ${content}`\n }\n}\n\nexport class BotPluginModule extends Module {\n private _typingsModule: PluginTypingsModule\n private _bundleJsModule: BundleJsModule\n private _bundleDtsModule: BundleDtsModule\n private _configModule: PluginConfigModule\n\n public readonly pluginName: string\n\n public constructor(plugin: PluginInstance) {\n super({\n exportName: 'default',\n path: consts.INDEX_FILE,\n })\n\n this.pluginName = plugin.name\n\n this._typingsModule = new PluginTypingsModule(plugin.definition)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._bundleJsModule = new BundleJsModule(plugin)\n this.pushDep(this._bundleJsModule)\n\n this._bundleDtsModule = new BundleDtsModule(this._typingsModule)\n this.pushDep(this._bundleDtsModule)\n\n this._configModule = new PluginConfigModule({\n path: 'config.ts',\n exportName: 'default',\n plugin,\n })\n this.pushDep(this._configModule)\n }\n\n public async getContent() {\n const configImport = this._configModule.import(this)\n const typingsImport = this._typingsModule.import(this)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n 'import bundle from \"./bundle\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${this._configModule.name} from \"./${configImport}\"`,\n '',\n `export type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n `export default bundle.initialize(${this._configModule.name}.${this._configModule.exportName})`,\n '',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAoC;AACpC,4BAAoC;AAIpC,MAAM,uBAAuB,qBAAO;AAAA,EAC1B;AAAA,EACD,YAAY,QAAwB;AACzC,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,OAAO,eAAe,SAAS;AAAA,EACjD;AAAA,EAEA,MAAa,aAAa;AACxB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,MAAM,wBAAwB,qBAAO;AA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AAC;AACD,SAAK,QAAQ,KAAK,aAAa;AAAA,EACjC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,eAAe,KAAK,cAAc,OAAO,IAAI;AACnD,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AACrD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,eAAe,KAAK,cAAc,gBAAgB;AAAA,MAClD;AAAA,MACA,2CAA2C,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MAC3F;AAAA,MACA,oCAAoC,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAClF;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { Module, ModuleProps } from '../../module'\nimport { PluginTypingsModule } from '../../plugin-implementation/plugin-typings'\n\ntype PluginInstance = NonNullable<sdk.BotDefinition['plugins']>[string]\n\nclass BundleJsModule extends Module {\n private _indexJs: string\n public constructor(plugin: PluginInstance) {\n super({\n path: 'bundle.js',\n exportName: 'default',\n })\n this._indexJs = plugin.implementation.toString()\n }\n\n public async getContent() {\n return this._indexJs\n }\n}\n\nclass BundleDtsModule extends Module {\n public constructor(private _typingsModule: PluginTypingsModule) {\n super({\n path: 'bundle.d.ts',\n exportName: 'default',\n })\n }\n\n public async getContent() {\n const typingsImport = this._typingsModule.import(this)\n\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n 'export default new sdk.Plugin<TPlugin>({})',\n '',\n ].join('\\n')\n }\n}\n\nclass PluginConfigModule extends Module {\n private _plugin: PluginInstance\n public constructor(config: ModuleProps & { plugin: PluginInstance }) {\n super(config)\n this._plugin = config.plugin\n }\n\n public async getContent() {\n const { interfaces, configuration } = this._plugin\n const content = JSON.stringify({ interfaces, configuration }, null, 2)\n return `export default ${content}`\n }\n}\n\nexport class BotPluginModule extends Module {\n private _typingsModule: PluginTypingsModule\n private _bundleJsModule: BundleJsModule\n private _bundleDtsModule: BundleDtsModule\n private _configModule: PluginConfigModule\n\n public readonly pluginName: string\n\n public constructor(plugin: PluginInstance) {\n super({\n exportName: 'default',\n path: consts.INDEX_FILE,\n })\n\n this.pluginName = plugin.name\n\n this._typingsModule = new PluginTypingsModule(plugin.definition)\n this._typingsModule.unshift('typings')\n this.pushDep(this._typingsModule)\n\n this._bundleJsModule = new BundleJsModule(plugin)\n this.pushDep(this._bundleJsModule)\n\n this._bundleDtsModule = new BundleDtsModule(this._typingsModule)\n this.pushDep(this._bundleDtsModule)\n\n this._configModule = new PluginConfigModule({\n path: 'config.ts',\n exportName: 'default',\n plugin,\n })\n this.pushDep(this._configModule)\n }\n\n public async getContent() {\n const configImport = this._configModule.import(this)\n const typingsImport = this._typingsModule.import(this)\n return [\n consts.GENERATED_HEADER,\n 'import * as sdk from \"@botpress/sdk\"',\n 'import bundle from \"./bundle\"',\n `import * as ${this._typingsModule.name} from \"./${typingsImport}\"`,\n `import * as ${this._configModule.name} from \"./${configImport}\"`,\n '',\n `export type TPlugin = sdk.DefaultPlugin<${this._typingsModule.name}.${this._typingsModule.exportName}>`,\n '',\n `export const configuration = ${this._configModule.name}.${this._configModule.exportName}.configuration`,\n `export const interfaces = ${this._configModule.name}.${this._configModule.exportName}.interfaces`,\n '',\n `export default bundle.initialize(${this._configModule.name}.${this._configModule.exportName})`,\n '',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAoC;AACpC,4BAAoC;AAIpC,MAAM,uBAAuB,qBAAO;AAAA,EAC1B;AAAA,EACD,YAAY,QAAwB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K,QAAQ,KAAK,eAAe;AAEjC,SAAK,mBAAmB,IAAI,gBAAgB,KAAK,cAAc;AAC/D,SAAK,QAAQ,KAAK,gBAAgB;AAElC,SAAK,gBAAgB,IAAI,mBAAmB;AAAA,MAC1C,MAAM;AAAA,MACN,YAAY;AAAA,MACZ;AAAA,IACF,CAAC;AACD,SAAK,QAAQ,KAAK,aAAa;AAAA,EACjC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,eAAe,KAAK,cAAc,OAAO,IAAI;AACnD,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AACrD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,eAAe,KAAK,cAAc,gBAAgB;AAAA,MAClD;AAAA,MACA,2CAA2C,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MAC3F;AAAA,MACA,gCAAgC,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAC9E,6BAA6B,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAC3E;AAAA,MACA,oCAAoC,KAAK,cAAc,QAAQ,KAAK,cAAc;AAAA,MAClF;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -37,6 +37,7 @@ var import_module = require("../../module");
|
|
|
37
37
|
var import_actions_module = require("./actions-module");
|
|
38
38
|
var import_events_module = require("./events-module");
|
|
39
39
|
var import_states_module = require("./states-module");
|
|
40
|
+
var import_tables_module = require("./tables-module");
|
|
40
41
|
class BotIntegrationsModule extends import_module.ReExportTypeModule {
|
|
41
42
|
constructor(bot) {
|
|
42
43
|
super({
|
|
@@ -65,6 +66,9 @@ class BotTypingsModule extends import_module.Module {
|
|
|
65
66
|
const statesModule = new import_states_module.StatesModule(bot.states ?? {});
|
|
66
67
|
statesModule.unshift("states");
|
|
67
68
|
this.pushDep(statesModule);
|
|
69
|
+
const tablesModule = new import_tables_module.TablesModule(bot.tables ?? {});
|
|
70
|
+
tablesModule.unshift("tables");
|
|
71
|
+
this.pushDep(tablesModule);
|
|
68
72
|
const actionsModule = new import_actions_module.ActionsModule(bot.actions ?? {});
|
|
69
73
|
actionsModule.unshift("actions");
|
|
70
74
|
this.pushDep(actionsModule);
|
|
@@ -72,32 +76,37 @@ class BotTypingsModule extends import_module.Module {
|
|
|
72
76
|
integrationsModule,
|
|
73
77
|
eventsModule,
|
|
74
78
|
statesModule,
|
|
75
|
-
actionsModule
|
|
79
|
+
actionsModule,
|
|
80
|
+
tablesModule
|
|
76
81
|
};
|
|
77
82
|
}
|
|
78
83
|
async getContent() {
|
|
79
|
-
const { integrationsModule, eventsModule, statesModule, actionsModule } = this._dependencies;
|
|
84
|
+
const { integrationsModule, eventsModule, statesModule, actionsModule, tablesModule } = this._dependencies;
|
|
80
85
|
const integrationsImport = integrationsModule.import(this);
|
|
81
86
|
const eventsImport = eventsModule.import(this);
|
|
82
87
|
const statesImport = statesModule.import(this);
|
|
83
88
|
const actionsImport = actionsModule;
|
|
89
|
+
const tablesImport = tablesModule.import(this);
|
|
84
90
|
return [
|
|
85
91
|
consts.GENERATED_HEADER,
|
|
86
92
|
`import * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
87
93
|
`import * as ${eventsModule.name} from './${eventsModule.name}'`,
|
|
88
94
|
`import * as ${statesModule.name} from './${statesModule.name}'`,
|
|
89
95
|
`import * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
96
|
+
`import * as ${tablesModule.name} from './${tablesImport}'`,
|
|
90
97
|
"",
|
|
91
98
|
`export * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
92
99
|
`export * as ${eventsModule.name} from './${eventsImport}'`,
|
|
93
100
|
`export * as ${statesModule.name} from './${statesImport}'`,
|
|
94
101
|
`export * as ${actionsModule.name} from './${actionsImport.name}'`,
|
|
102
|
+
`export * as ${tablesModule.name} from './${tablesImport}'`,
|
|
95
103
|
"",
|
|
96
104
|
"export type TBot = {",
|
|
97
105
|
` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
|
|
98
106
|
` events: ${eventsModule.name}.${eventsModule.exportName}`,
|
|
99
107
|
` states: ${statesModule.name}.${statesModule.exportName}`,
|
|
100
108
|
` actions: ${actionsModule.name}.${actionsModule.exportName}`,
|
|
109
|
+
` tables: ${tablesModule.name}.${tablesModule.exportName}`,
|
|
101
110
|
"}"
|
|
102
111
|
].join("\n");
|
|
103
112
|
}
|