@botpress/cli 0.11.6 → 1.0.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 +9 -9
- package/dist/api/bot-body.js.map +2 -2
- package/dist/api/client.js +14 -28
- package/dist/api/client.js.map +3 -3
- package/dist/api/find-previous-version.js.map +1 -1
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +7 -0
- package/dist/api/interface-body.js +25 -10
- package/dist/api/interface-body.js.map +2 -2
- package/dist/code-generation/bot-implementation/bot-implementation.js +92 -0
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +7 -0
- package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/events-module.js +15 -22
- package/dist/code-generation/bot-implementation/bot-typings/events-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js +96 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +7 -0
- package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/states-module.js +17 -22
- package/dist/code-generation/bot-implementation/bot-typings/states-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/index.js +56 -0
- package/dist/code-generation/bot-implementation/index.js.map +7 -0
- package/dist/code-generation/{const.js → consts.js} +9 -4
- package/dist/code-generation/consts.js.map +7 -0
- package/dist/code-generation/generators.js +37 -7
- package/dist/code-generation/generators.js.map +2 -2
- package/dist/code-generation/index.js +15 -105
- package/dist/code-generation/index.js.map +3 -3
- package/dist/code-generation/integration-implementation/index.js +66 -0
- package/dist/code-generation/integration-implementation/index.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js +110 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js.map +7 -0
- package/dist/code-generation/{integration-secret.js → integration-implementation/integration-secret.js} +17 -7
- package/dist/code-generation/integration-implementation/integration-secret.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/actions-module.js +28 -40
- package/dist/code-generation/integration-implementation/integration-typings/actions-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js +103 -0
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/configuration-module.js +18 -20
- package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/configurations-module.js +21 -27
- package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js.map +7 -0
- package/dist/code-generation/{integration-schemas → integration-implementation/integration-typings}/entities-module.js +15 -22
- package/dist/code-generation/integration-implementation/integration-typings/entities-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/events-module.js +59 -0
- package/dist/code-generation/integration-implementation/integration-typings/events-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/index.js +128 -0
- package/dist/code-generation/integration-implementation/integration-typings/index.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js +60 -0
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js.map +7 -0
- package/dist/code-generation/integration-package/index.js +81 -0
- package/dist/code-generation/integration-package/index.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +84 -0
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js +103 -0
- package/dist/code-generation/integration-package/integration-package-definition/channels-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js +58 -0
- package/dist/code-generation/integration-package/integration-package-definition/configuration-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js +66 -0
- package/dist/code-generation/integration-package/integration-package-definition/configurations-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js +59 -0
- package/dist/code-generation/integration-package/integration-package-definition/entities-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js +62 -0
- package/dist/code-generation/integration-package/integration-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/index.js +136 -0
- package/dist/code-generation/integration-package/integration-package-definition/index.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js +62 -0
- package/dist/code-generation/integration-package/integration-package-definition/states-module.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/typings.js +17 -0
- package/dist/code-generation/integration-package/integration-package-definition/typings.js.map +7 -0
- package/dist/code-generation/interface-package/index.js +81 -0
- package/dist/code-generation/interface-package/index.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +84 -0
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js +94 -0
- package/dist/code-generation/interface-package/interface-package-definition/channels-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js +59 -0
- package/dist/code-generation/interface-package/interface-package-definition/entities-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js +62 -0
- package/dist/code-generation/interface-package/interface-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/index.js +100 -0
- package/dist/code-generation/interface-package/interface-package-definition/index.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/typings.js +17 -0
- package/dist/code-generation/interface-package/interface-package-definition/typings.js.map +7 -0
- package/dist/code-generation/module.js +60 -16
- package/dist/code-generation/module.js.map +2 -2
- package/dist/code-generation/strings.js +5 -2
- package/dist/code-generation/strings.js.map +2 -2
- package/dist/code-generation/typings.js.map +1 -1
- package/dist/command-implementations/add-command.js +102 -91
- package/dist/command-implementations/add-command.js.map +3 -3
- package/dist/command-implementations/bundle-command.js +16 -9
- package/dist/command-implementations/bundle-command.js.map +2 -2
- package/dist/command-implementations/deploy-command.js +27 -19
- package/dist/command-implementations/deploy-command.js.map +2 -2
- package/dist/command-implementations/dev-command.js +15 -12
- package/dist/command-implementations/dev-command.js.map +2 -2
- package/dist/command-implementations/gen-command.js +31 -12
- package/dist/command-implementations/gen-command.js.map +3 -3
- package/dist/command-implementations/init-command.js +2 -2
- package/dist/command-implementations/init-command.js.map +2 -2
- package/dist/command-implementations/integration-commands.js +5 -5
- package/dist/command-implementations/integration-commands.js.map +2 -2
- package/dist/command-implementations/interface-commands.js +5 -5
- package/dist/command-implementations/interface-commands.js.map +2 -2
- package/dist/command-implementations/lint-command.js +3 -1
- package/dist/command-implementations/lint-command.js.map +3 -3
- package/dist/command-implementations/project-command.js +40 -23
- package/dist/command-implementations/project-command.js.map +3 -3
- package/dist/command-implementations/read-command.js +0 -5
- package/dist/command-implementations/read-command.js.map +2 -2
- package/dist/config.js +22 -7
- package/dist/config.js.map +2 -2
- package/dist/consts.js +15 -6
- package/dist/consts.js.map +2 -2
- package/dist/errors.js +19 -11
- package/dist/errors.js.map +2 -2
- package/dist/logger/index.js +4 -2
- package/dist/logger/index.js.map +2 -2
- package/dist/{integration-ref.js → package-ref.js} +11 -11
- package/dist/package-ref.js.map +7 -0
- package/dist/{integration-ref.test.js → package-ref.test.js} +18 -18
- package/dist/package-ref.test.js.map +7 -0
- package/dist/sdk/index.js +21 -0
- package/dist/sdk/index.js.map +7 -0
- package/dist/sdk/resolve-bot-interfaces.js +38 -0
- package/dist/sdk/resolve-bot-interfaces.js.map +7 -0
- package/dist/sdk/resolve-integration-interfaces.js +148 -0
- package/dist/sdk/resolve-integration-interfaces.js.map +7 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +2 -2
- package/dist/utils/path-utils.js +25 -8
- package/dist/utils/path-utils.js.map +3 -3
- package/dist/utils/path-utils.test.js +69 -0
- package/dist/utils/path-utils.test.js.map +7 -0
- package/dist/utils/record-utils.js +25 -0
- package/dist/utils/record-utils.js.map +3 -3
- package/dist/utils/schema-utils.js +11 -0
- package/dist/utils/schema-utils.js.map +2 -2
- package/dist/utils/schema-utils.test.js +51 -0
- package/dist/utils/schema-utils.test.js.map +7 -0
- package/dist/utils/template-utils.js +47 -0
- package/dist/utils/template-utils.js.map +7 -0
- package/dist/utils/type-utils.js.map +1 -1
- package/e2e/index.ts +2 -0
- package/e2e/tests/install-package.ts +163 -0
- package/e2e/utils.ts +25 -2
- package/package.json +5 -4
- package/templates/empty-bot/.botpress/implementation/index.ts +41 -0
- package/templates/empty-bot/.botpress/implementation/typings/index.ts +17 -0
- package/templates/empty-bot/.botpress/implementation/typings/integrations/index.ts +6 -0
- package/templates/empty-bot/.botpress/index.ts +1 -0
- package/templates/empty-bot/bot.definition.ts +2 -0
- package/templates/{echo-bot → empty-bot}/package.json +2 -2
- package/templates/empty-bot/src/index.ts +5 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +7 -35
- package/templates/empty-integration/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/empty-integration/.botpress/implementation/typings/index.ts +31 -0
- package/templates/empty-integration/package.json +1 -1
- package/templates/hello-world/.botpress/implementation/index.ts +7 -35
- package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/input.ts +5 -0
- package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/output.ts +5 -0
- package/templates/hello-world/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/hello-world/.botpress/implementation/typings/index.ts +31 -0
- package/templates/hello-world/package.json +1 -1
- package/templates/webhook-message/.botpress/implementation/index.ts +7 -35
- package/templates/webhook-message/.botpress/implementation/typings/channels/webhook/messages/text.ts +5 -0
- package/templates/webhook-message/.botpress/implementation/typings/configuration/index.ts +8 -0
- package/templates/webhook-message/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/typings/index.ts +31 -0
- package/templates/webhook-message/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/webhook-message/package.json +1 -1
- package/dist/code-generation/const.js.map +0 -7
- package/dist/code-generation/integration-implementation.js +0 -192
- package/dist/code-generation/integration-implementation.js.map +0 -7
- package/dist/code-generation/integration-instance.js +0 -185
- package/dist/code-generation/integration-instance.js.map +0 -7
- package/dist/code-generation/integration-schemas/actions-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/channels-module.js +0 -117
- package/dist/code-generation/integration-schemas/channels-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/configuration-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/configurations-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/entities-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/events-module.js.map +0 -7
- package/dist/code-generation/integration-schemas/states-module.js.map +0 -7
- package/dist/code-generation/integration-secret.js.map +0 -7
- package/dist/code-generation/map-integration.js +0 -76
- package/dist/code-generation/map-integration.js.map +0 -7
- package/dist/integration-ref.js.map +0 -7
- package/dist/integration-ref.test.js.map +0 -7
- package/templates/echo-bot/src/index.ts +0 -30
- package/templates/empty-integration/.botpress/implementation/configuration/index.ts +0 -10
- package/templates/hello-world/.botpress/implementation/actions/helloWorld/input.ts +0 -10
- package/templates/hello-world/.botpress/implementation/actions/helloWorld/output.ts +0 -10
- package/templates/hello-world/.botpress/implementation/configuration/index.ts +0 -10
- package/templates/webhook-message/.botpress/implementation/channels/webhook/messages/text.ts +0 -10
- package/templates/webhook-message/.botpress/implementation/configuration/index.ts +0 -13
- /package/templates/{empty-integration/.botpress/implementation → empty-bot/.botpress/implementation/typings}/events/index.ts +0 -0
- /package/templates/{empty-integration/.botpress/implementation → empty-bot/.botpress/implementation/typings}/states/index.ts +0 -0
- /package/templates/{echo-bot → empty-bot}/tsconfig.json +0 -0
- /package/templates/empty-integration/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
- /package/templates/empty-integration/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
- /package/templates/empty-integration/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
- /package/templates/empty-integration/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
- /package/templates/{hello-world/.botpress/implementation → empty-integration/.botpress/implementation/typings}/events/index.ts +0 -0
- /package/templates/{hello-world/.botpress/implementation → empty-integration/.botpress/implementation/typings}/states/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{actions → typings/actions}/helloWorld/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
- /package/templates/hello-world/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
- /package/templates/{webhook-message/.botpress/implementation → hello-world/.botpress/implementation/typings}/events/index.ts +0 -0
- /package/templates/{webhook-message/.botpress/implementation → hello-world/.botpress/implementation/typings}/states/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{actions → typings/actions}/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/webhook/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{channels → typings/channels}/webhook/messages/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{configurations → typings/configurations}/index.ts +0 -0
- /package/templates/webhook-message/.botpress/implementation/{entities → typings/entities}/index.ts +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/cli@0.
|
|
2
|
+
> @botpress/cli@1.0.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@0.
|
|
6
|
+
> @botpress/cli@1.0.0 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
7
|
> ts-node -T build.ts
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/cli@0.
|
|
10
|
+
> @botpress/cli@1.0.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
|
|
14
|
-
🤖 Botpress CLI
|
|
15
|
-
🤖 Botpress CLI
|
|
16
|
-
🤖 Botpress CLI
|
|
17
|
-
|
|
18
|
-
[2K[1G○ Generating typings for
|
|
13
|
+
🤖 Botpress CLI v1.0.0
|
|
14
|
+
🤖 Botpress CLI v1.0.0
|
|
15
|
+
🤖 Botpress CLI v1.0.0
|
|
16
|
+
🤖 Botpress CLI v1.0.0
|
|
17
|
+
[2K[1G○ Generating typings for integration hello-world...[2K[1G○ Generating typings for integration empty-integration...[2K[1G✓ Typings available at .botpress
|
|
18
|
+
[2K[1G○ Generating typings for bot...[2K[1G○ Generating typings for integration webhook-message...[2K[1G✓ Typings available at .botpress
|
|
19
19
|
[2K[1G✓ Typings available at .botpress
|
|
20
20
|
[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 type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateBotBody = Parameters<client.Client['createBot']>[0]\nexport type UpdateBotBody = Parameters<client.Client['updateBot']>[0]\n\nexport const prepareCreateBotBody = async (bot: sdk.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAKhB,MAAM,uBAAuB,OAAO,
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateBotBody = Parameters<client.Client['createBot']>[0]\nexport type UpdateBotBody = Parameters<client.Client['updateBot']>[0]\n\nexport const prepareCreateBotBody = async (bot: sdk.BotDefinition): Promise<CreateBotBody> => ({\n ...bot.props,\n configuration: bot.props.configuration\n ? {\n ...bot.props.configuration,\n schema: await utils.schema.mapZodToJsonSchema(bot.props.configuration),\n }\n : undefined,\n events: bot.props.events\n ? await utils.records.mapValuesAsync(bot.props.events, async (event) => ({\n ...event,\n schema: await utils.schema.mapZodToJsonSchema(event),\n }))\n : undefined,\n states: bot.props.states\n ? await utils.records.mapValuesAsync(bot.props.states, async (state) => ({\n ...state,\n schema: await utils.schema.mapZodToJsonSchema(state),\n }))\n : undefined,\n})\n\nexport const prepareUpdateBotBody = (localBot: UpdateBotBody, remoteBot: client.Bot): UpdateBotBody => ({\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;AAKhB,MAAM,uBAAuB,OAAO,SAAoD;AAAA,EAC7F,GAAG,IAAI;AAAA,EACP,eAAe,IAAI,MAAM,gBACrB;AAAA,IACE,GAAG,IAAI,MAAM;AAAA,IACb,QAAQ,MAAM,MAAM,OAAO,mBAAmB,IAAI,MAAM,aAAa;AAAA,EACvE,IACA;AAAA,EACJ,QAAQ,IAAI,MAAM,SACd,MAAM,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,WAAW;AAAA,IACrE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AAAA,EACJ,QAAQ,IAAI,MAAM,SACd,MAAM,MAAM,QAAQ,eAAe,IAAI,MAAM,QAAQ,OAAO,WAAW;AAAA,IACrE,GAAG;AAAA,IACH,QAAQ,MAAM,MAAM,OAAO,mBAAmB,KAAK;AAAA,EACrD,EAAE,IACF;AACN;AAEO,MAAM,uBAAuB,CAAC,UAAyB,eAA0C;AAAA,EACtG,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
|
@@ -29,8 +29,7 @@ __export(client_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(client_exports);
|
|
31
31
|
var client = __toESM(require("@botpress/client"));
|
|
32
|
-
var
|
|
33
|
-
var import_integration_ref = require("../integration-ref");
|
|
32
|
+
var import_package_ref = require("../package-ref");
|
|
34
33
|
var import_find_previous_version = require("./find-previous-version");
|
|
35
34
|
var paging = __toESM(require("./paging"));
|
|
36
35
|
__reExport(client_exports, require("./types"), module.exports);
|
|
@@ -62,7 +61,7 @@ class ApiClient {
|
|
|
62
61
|
return this.client.updateWorkspace({ id: this.workspaceId, ...props });
|
|
63
62
|
}
|
|
64
63
|
async findIntegration(ref) {
|
|
65
|
-
const formatted = (0,
|
|
64
|
+
const formatted = (0, import_package_ref.formatPackageRef)(ref);
|
|
66
65
|
const privateIntegration = await this.findPrivateIntegration(ref);
|
|
67
66
|
if (privateIntegration) {
|
|
68
67
|
this._logger.debug(`Found integration "${formatted}" in workspace`);
|
|
@@ -78,45 +77,26 @@ class ApiClient {
|
|
|
78
77
|
async findPrivateIntegration(ref) {
|
|
79
78
|
const { workspaceId } = this;
|
|
80
79
|
if (ref.type === "id") {
|
|
81
|
-
return this.
|
|
82
|
-
() => this.client.getIntegration(ref).then((r) => ({ ...r.integration, workspaceId })),
|
|
83
|
-
404
|
|
84
|
-
);
|
|
80
|
+
return this.client.getIntegration(ref).then((r) => ({ ...r.integration, workspaceId })).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
85
81
|
}
|
|
86
|
-
return this.
|
|
87
|
-
() => this.client.getIntegrationByName(ref).then((r) => ({ ...r.integration, workspaceId })),
|
|
88
|
-
404
|
|
89
|
-
);
|
|
82
|
+
return this.client.getIntegrationByName(ref).then((r) => ({ ...r.integration, workspaceId })).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
90
83
|
}
|
|
91
84
|
async findPublicIntegration(ref) {
|
|
92
85
|
if (ref.type === "id") {
|
|
93
|
-
return this.
|
|
86
|
+
return this.client.getPublicIntegrationById(ref).then((r) => r.integration).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
94
87
|
}
|
|
95
|
-
return this.
|
|
88
|
+
return this.client.getPublicIntegration(ref).then((r) => r.integration).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
96
89
|
}
|
|
97
90
|
async findPublicInterface(ref) {
|
|
98
91
|
if (ref.type === "id") {
|
|
99
|
-
return this.
|
|
92
|
+
return this.client.getInterface(ref).then((r) => r.interface).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
100
93
|
}
|
|
101
|
-
return this.
|
|
94
|
+
return this.client.getInterfaceByName(ref).then((r) => r.interface).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
102
95
|
}
|
|
103
96
|
async testLogin() {
|
|
104
97
|
await this.client.listBots({});
|
|
105
98
|
}
|
|
106
99
|
listAllPages = paging.listAllPages;
|
|
107
|
-
async validateStatus(fn, allowedStatuses) {
|
|
108
|
-
try {
|
|
109
|
-
const v = await fn();
|
|
110
|
-
return v;
|
|
111
|
-
} catch (err) {
|
|
112
|
-
const allowedStatusesArray = import_lodash.default.isArray(allowedStatuses) ? allowedStatuses : [allowedStatuses];
|
|
113
|
-
const isAllowed = client.isApiError(err) && err.code && allowedStatusesArray.includes(err.code);
|
|
114
|
-
if (isAllowed) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
throw err;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
100
|
async findPreviousIntegrationVersion(ref) {
|
|
121
101
|
const previous = await (0, import_find_previous_version.findPreviousIntegrationVersion)(this.client, ref);
|
|
122
102
|
if (!previous) {
|
|
@@ -128,6 +108,12 @@ class ApiClient {
|
|
|
128
108
|
const allBots = await this.listAllPages(this.client.listBots, (r) => r.bots);
|
|
129
109
|
return allBots.find((b) => b.name === name);
|
|
130
110
|
}
|
|
111
|
+
_returnUndefinedOnError = (type) => (thrown) => {
|
|
112
|
+
if (client.isApiError(thrown) && thrown.type === type) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
throw thrown;
|
|
116
|
+
};
|
|
131
117
|
}
|
|
132
118
|
// Annotate the CommonJS export names for ESM import in node:
|
|
133
119
|
0 && (module.exports = {
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport type { Logger } from '../logger'\nimport { formatPackageRef, ApiPackageRef, NamePackageRef } from '../package-ref'\nimport { findPreviousIntegrationVersion } from './find-previous-version'\nimport * as paging from './paging'\nimport {\n ApiClientProps,\n PublicIntegration,\n PrivateIntegration,\n Integration,\n Requests,\n Responses,\n Interface,\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\n public static newClient = (props: ApiClientProps, logger: Logger) => new ApiClient(props, logger)\n\n public constructor(props: ApiClientProps, private _logger: Logger) {\n const { apiUrl, token, workspaceId } = props\n this.client = new client.Client({ apiUrl, token, workspaceId })\n this.url = apiUrl\n this.token = token\n this.workspaceId = workspaceId\n }\n\n public get isBotpressWorkspace(): boolean {\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<Responses['getWorkspace']> {\n return this.client.getWorkspace({ id: this.workspaceId })\n }\n\n public async updateWorkspace(props: Omit<Requests['updateWorkspace'], 'id'>): Promise<Responses['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 return this.client\n .getInterfaceByName(ref)\n .then((r) => r.interface)\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<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.isApi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AQ,GAAG;AACtE,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AACA,WAAO,KAAK,gBAAgB,EAAE,MAAM,MAAM,IAAI,SAAS,GAAG,CAAC;AAAA,EAC7D;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
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/find-previous-version.ts"],
|
|
4
|
-
"sourcesContent": ["import * as client from '@botpress/client'\nimport semver from 'semver'\nimport {
|
|
4
|
+
"sourcesContent": ["import * as client from '@botpress/client'\nimport semver from 'semver'\nimport { NamePackageRef } from '../package-ref'\nimport * as paging from './paging'\nimport { IntegrationSummary } from './types'\n\nexport const findPreviousIntegrationVersion = async (\n client: client.Client,\n ref: NamePackageRef\n): Promise<IntegrationSummary | undefined> => {\n const { name, version: targetVersion } = ref\n const allVersions = await paging.listAllPages(\n async ({ nextToken }) => client.listIntegrations({ name, nextToken }),\n (r) => r.integrations\n )\n\n const orderedVersions = allVersions.sort((a, b) => semver.compare(b.version, a.version))\n const latestVersion = orderedVersions[0]\n if (!latestVersion) {\n return\n }\n\n type VersionIdx = [number, IntegrationSummary]\n\n let current: VersionIdx = [0, latestVersion]\n while (semver.gte(current[1].version, targetVersion)) {\n const nextIdx = current[0] + 1\n const nextIntegration = orderedVersions[nextIdx]\n if (!nextIntegration) {\n break\n }\n current = [nextIdx, nextIntegration]\n }\n\n const previous = current[1]\n if (semver.gte(previous.version, targetVersion)) {\n return\n }\n\n return previous\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAmB;AAEnB,aAAwB;AAGjB,MAAM,iCAAiC,OAC5CA,SACA,QAC4C;AAC5C,QAAM,EAAE,MAAM,SAAS,cAAc,IAAI;AACzC,QAAM,cAAc,MAAM,OAAO;AAAA,IAC/B,OAAO,EAAE,UAAU,MAAMA,QAAO,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAAA,IACpE,CAAC,MAAM,EAAE;AAAA,EACX;AAEA,QAAM,kBAAkB,YAAY,KAAK,CAAC,GAAG,MAAM,cAAAC,QAAO,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;AACvF,QAAM,gBAAgB,gBAAgB;AACtC,MAAI,CAAC,eAAe;AAClB;AAAA,EACF;AAIA,MAAI,UAAsB,CAAC,GAAG,aAAa;AAC3C,SAAO,cAAAA,QAAO,IAAI,QAAQ,GAAG,SAAS,aAAa,GAAG;AACpD,UAAM,UAAU,QAAQ,KAAK;AAC7B,UAAM,kBAAkB,gBAAgB;AACxC,QAAI,CAAC,iBAAiB;AACpB;AAAA,IACF;AACA,cAAU,CAAC,SAAS,eAAe;AAAA,EACrC;AAEA,QAAM,WAAW,QAAQ;AACzB,MAAI,cAAAA,QAAO,IAAI,SAAS,SAAS,aAAa,GAAG;AAC/C;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": ["client", "semver"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var api_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(api_exports);
|
|
18
|
+
__reExport(api_exports, require("./client"), module.exports);
|
|
19
|
+
__reExport(api_exports, require("./types"), module.exports);
|
|
20
|
+
__reExport(api_exports, require("./integration-body"), module.exports);
|
|
21
|
+
__reExport(api_exports, require("./interface-body"), module.exports);
|
|
22
|
+
__reExport(api_exports, require("./bot-body"), module.exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -28,7 +28,6 @@ __export(interface_body_exports, {
|
|
|
28
28
|
prepareUpdateInterfaceBody: () => prepareUpdateInterfaceBody
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(interface_body_exports);
|
|
31
|
-
var import_sdk = require("@botpress/sdk");
|
|
32
31
|
var utils = __toESM(require("../utils"));
|
|
33
32
|
const prepareCreateInterfaceBody = async (intrface) => ({
|
|
34
33
|
name: intrface.name,
|
|
@@ -39,35 +38,51 @@ const prepareCreateInterfaceBody = async (intrface) => ({
|
|
|
39
38
|
})) : {},
|
|
40
39
|
events: intrface.events ? await utils.records.mapValuesAsync(intrface.events, async (event) => ({
|
|
41
40
|
...event,
|
|
42
|
-
schema: await utils.schema.mapZodToJsonSchema(
|
|
41
|
+
schema: await utils.schema.mapZodToJsonSchema(event)
|
|
43
42
|
})) : {},
|
|
44
43
|
actions: intrface.actions ? await utils.records.mapValuesAsync(intrface.actions, async (action) => ({
|
|
45
44
|
...action,
|
|
46
45
|
input: {
|
|
47
46
|
...action.input,
|
|
48
|
-
schema: await utils.schema.mapZodToJsonSchema(
|
|
47
|
+
schema: await utils.schema.mapZodToJsonSchema(action.input)
|
|
49
48
|
},
|
|
50
49
|
output: {
|
|
51
50
|
...action.output,
|
|
52
|
-
schema: await utils.schema.mapZodToJsonSchema(
|
|
51
|
+
schema: await utils.schema.mapZodToJsonSchema(action.output)
|
|
53
52
|
}
|
|
54
|
-
})) : {}
|
|
53
|
+
})) : {},
|
|
54
|
+
channels: intrface.channels ? await utils.records.mapValuesAsync(intrface.channels, async (channel) => ({
|
|
55
|
+
...channel,
|
|
56
|
+
messages: await utils.records.mapValuesAsync(channel.messages, async (message) => ({
|
|
57
|
+
...message,
|
|
58
|
+
schema: await utils.schema.mapZodToJsonSchema(message)
|
|
59
|
+
}))
|
|
60
|
+
})) : {},
|
|
61
|
+
nameTemplate: intrface.templateName ? {
|
|
62
|
+
script: intrface.templateName,
|
|
63
|
+
language: "handlebars"
|
|
64
|
+
} : void 0
|
|
55
65
|
});
|
|
56
66
|
const prepareUpdateInterfaceBody = (localInterface, remoteInterface) => {
|
|
57
67
|
const actions = utils.records.setNullOnMissingValues(localInterface.actions, remoteInterface.actions);
|
|
58
68
|
const events = utils.records.setNullOnMissingValues(localInterface.events, remoteInterface.events);
|
|
59
69
|
const entities = utils.records.setNullOnMissingValues(localInterface.entities, remoteInterface.entities);
|
|
70
|
+
const currentChannels = localInterface.channels ? utils.records.mapValues(localInterface.channels, (channel, channelName) => ({
|
|
71
|
+
...channel,
|
|
72
|
+
messages: utils.records.setNullOnMissingValues(
|
|
73
|
+
channel?.messages,
|
|
74
|
+
remoteInterface.channels[channelName]?.messages
|
|
75
|
+
)
|
|
76
|
+
})) : void 0;
|
|
77
|
+
const channels = utils.records.setNullOnMissingValues(currentChannels, remoteInterface.channels);
|
|
60
78
|
return {
|
|
61
79
|
...localInterface,
|
|
62
80
|
entities,
|
|
63
81
|
actions,
|
|
64
|
-
events
|
|
82
|
+
events,
|
|
83
|
+
channels
|
|
65
84
|
};
|
|
66
85
|
};
|
|
67
|
-
const _dereference = (intrface, { schema }) => {
|
|
68
|
-
const typeArguments = utils.records.mapValues(intrface.entities, (_, entityName) => import_sdk.z.ref(entityName));
|
|
69
|
-
return { schema: schema(typeArguments) };
|
|
70
|
-
};
|
|
71
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
87
|
0 && (module.exports = {
|
|
73
88
|
prepareCreateInterfaceBody,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/api/interface-body.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Client, Interface } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,
|
|
4
|
+
"sourcesContent": ["import type { Client, Interface } from '@botpress/client'\nimport type * as sdk from '@botpress/sdk'\nimport * as utils from '../utils'\n\nexport type CreateInterfaceBody = Parameters<Client['createInterface']>[0]\nexport type UpdateInterfaceBody = Parameters<Client['updateInterface']>[0]\n\nexport const prepareCreateInterfaceBody = async (intrface: sdk.InterfaceDeclaration): Promise<CreateInterfaceBody> => ({\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 nameTemplate: intrface.templateName\n ? {\n script: intrface.templateName,\n language: 'handlebars',\n }\n : undefined,\n})\n\nexport const prepareUpdateInterfaceBody = (\n localInterface: CreateInterfaceBody & { id: string },\n remoteInterface: Interface\n): UpdateInterfaceBody => {\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: UpdateInterfaceBody['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;AAKhB,MA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AAgB,OAAO;AACpG,QAAM,SAAS,MAAM,QAAQ,uBAAuB,eAAe,QAAQ,gBAAgB,MAAM;AACjG,QAAM,WAAW,MAAM,QAAQ,uBAAuB,eAAe,UAAU,gBAAgB,QAAQ;AAEvG,QAAM,kBAAmD,eAAe,WACpE,MAAM,QAAQ,UAAU,eAAe,UAAU,CAAC,SAAS,iBAAiB;AAAA,IAC1E,GAAG;AAAA,IACH,UAAU,MAAM,QAAQ;AAAA,MACtB,SAAS;AAAA,MACT,gBAAgB,SAAS,cAAc;AAAA,IACzC;AAAA,EACF,EAAE,IACF;AAEJ,QAAM,WAAW,MAAM,QAAQ,uBAAuB,iBAAiB,gBAAgB,QAAQ;AAE/F,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var bot_implementation_exports = {};
|
|
26
|
+
__export(bot_implementation_exports, {
|
|
27
|
+
BotImplementationModule: () => BotImplementationModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(bot_implementation_exports);
|
|
30
|
+
var consts = __toESM(require("../consts"));
|
|
31
|
+
var import_module = require("../module");
|
|
32
|
+
var import_bot_typings = require("./bot-typings");
|
|
33
|
+
class BotImplementationModule extends import_module.Module {
|
|
34
|
+
_typingsModule;
|
|
35
|
+
constructor(bot) {
|
|
36
|
+
super({
|
|
37
|
+
exportName: "Bot",
|
|
38
|
+
path: consts.INDEX_FILE
|
|
39
|
+
});
|
|
40
|
+
this._typingsModule = new import_bot_typings.BotTypingsModule(bot);
|
|
41
|
+
this._typingsModule.unshift("typings");
|
|
42
|
+
this.pushDep(this._typingsModule);
|
|
43
|
+
}
|
|
44
|
+
async getContent() {
|
|
45
|
+
const typingsImport = this._typingsModule.import(this);
|
|
46
|
+
return [
|
|
47
|
+
consts.GENERATED_HEADER,
|
|
48
|
+
'import * as sdk from "@botpress/sdk"',
|
|
49
|
+
`import * as ${this._typingsModule.name} from "./${typingsImport}"`,
|
|
50
|
+
`export * from "./${typingsImport}"`,
|
|
51
|
+
"",
|
|
52
|
+
`type TBot = ${this._typingsModule.name}.${this._typingsModule.exportName}`,
|
|
53
|
+
"",
|
|
54
|
+
"export class Bot extends sdk.Bot<TBot> {}",
|
|
55
|
+
"",
|
|
56
|
+
"// extra types",
|
|
57
|
+
"",
|
|
58
|
+
"type AsyncFunction = (...args: any[]) => Promise<any>",
|
|
59
|
+
"export type EventHandler = Parameters<Bot['event']>[0]",
|
|
60
|
+
"export type EventHandlerProps = Parameters<EventHandler>[0]",
|
|
61
|
+
"export type MessageHandler = Parameters<Bot['message']>[0]",
|
|
62
|
+
"export type MessageHandlerProps = Parameters<MessageHandler>[0]",
|
|
63
|
+
"export type Client = EventHandlerProps['client']",
|
|
64
|
+
"export type ClientOperation = keyof {",
|
|
65
|
+
" [K in keyof Client as Client[K] extends AsyncFunction ? K : never]: null",
|
|
66
|
+
"}",
|
|
67
|
+
"export type ClientInputs = {",
|
|
68
|
+
" [K in ClientOperation]: Parameters<Client[K]>[0]",
|
|
69
|
+
"}",
|
|
70
|
+
"export type ClientOutputs = {",
|
|
71
|
+
" [K in ClientOperation]: Awaited<ReturnType<Client[K]>>",
|
|
72
|
+
"}",
|
|
73
|
+
"// @deprecated",
|
|
74
|
+
"export type BotEvent = EventHandlerProps['event']",
|
|
75
|
+
"// @deprecated",
|
|
76
|
+
"export type BotEvents = {",
|
|
77
|
+
" [K in BotEvent['type']]: Extract<BotEvent, { type: K }>",
|
|
78
|
+
"}",
|
|
79
|
+
"// @deprecated",
|
|
80
|
+
"export type BotState = ClientOutputs['getState']['state']",
|
|
81
|
+
"// @deprecated",
|
|
82
|
+
"export type BotStates = {",
|
|
83
|
+
" [K in BotState['name']]: Extract<BotState, { type: K }>['payload']",
|
|
84
|
+
"}"
|
|
85
|
+
].join("\n");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
BotImplementationModule
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=bot-implementation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 { BotTypingsModule } from './bot-typings'\n\nexport class BotImplementationModule extends Module {\n private _typingsModule: BotTypingsModule\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\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 `export * from \"./${typingsImport}\"`,\n '',\n `type TBot = ${this._typingsModule.name}.${this._typingsModule.exportName}`,\n '',\n 'export class Bot extends sdk.Bot<TBot> {}',\n '',\n '// extra types',\n '',\n 'type AsyncFunction = (...args: any[]) => Promise<any>',\n \"export type EventHandler = Parameters<Bot['event']>[0]\",\n 'export type EventHandlerProps = Parameters<EventHandler>[0]',\n \"export type MessageHandler = Parameters<Bot['message']>[0]\",\n 'export type MessageHandlerProps = Parameters<MessageHandler>[0]',\n \"export type Client = 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 '// @deprecated',\n \"export type BotEvent = EventHandlerProps['event']\",\n '// @deprecated',\n 'export type BotEvents = {',\n \" [K in BotEvent['type']]: Extract<BotEvent, { type: K }>\",\n '}',\n '// @deprecated',\n \"export type BotState = ClientOutputs['getState']['state']\",\n '// @deprecated',\n 'export type BotStates = {',\n \" [K in BotState['name']]: Extract<BotState, { type: K }>['payload']\",\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,oBAAuB;AACvB,yBAAiC;AAE1B,MAAM,gCAAgC,qBAAO;AAAA,EAC1C;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;AAAA,EAClC;AAAA,EAEA,MAAa,aAAa;AACxB,UAAM,gBAAgB,KAAK,eAAe,OAAO,IAAI;AAErD,WAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA,eAAe,KAAK,eAAe,gBAAgB;AAAA,MACnD,oBAAoB;AAAA,MACpB;AAAA,MACA,eAAe,KAAK,eAAe,QAAQ,KAAK,eAAe;AAAA,MAC/D;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,MACA;AAAA,MACA;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,EACb;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/code-generation/{integration-schemas → bot-implementation/bot-typings}/events-module.js
RENAMED
|
@@ -28,34 +28,27 @@ __export(events_module_exports, {
|
|
|
28
28
|
EventsModule: () => EventsModule
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(events_module_exports);
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var strings = __toESM(require("../strings"));
|
|
31
|
+
var import_generators = require("../../generators");
|
|
32
|
+
var import_module = require("../../module");
|
|
33
|
+
var strings = __toESM(require("../../strings"));
|
|
35
34
|
class EventModule extends import_module.Module {
|
|
36
|
-
|
|
35
|
+
constructor(name, _event) {
|
|
37
36
|
const eventName = name;
|
|
38
|
-
const schema = event.schema;
|
|
39
37
|
const exportName = strings.typeName(eventName);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return new EventModule(def);
|
|
38
|
+
super({ path: `${name}.ts`, exportName });
|
|
39
|
+
this._event = _event;
|
|
40
|
+
}
|
|
41
|
+
async getContent() {
|
|
42
|
+
return (0, import_generators.zuiSchemaToTypeScriptType)(this._event.schema, this.exportName);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
class EventsModule extends import_module.ReExportTypeModule {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
exportName: strings.typeName("events")
|
|
56
|
-
});
|
|
57
|
-
inst.pushDep(...eventModules);
|
|
58
|
-
return inst;
|
|
46
|
+
constructor(events) {
|
|
47
|
+
super({ exportName: strings.typeName("events") });
|
|
48
|
+
for (const [eventName, event] of Object.entries(events)) {
|
|
49
|
+
const module2 = new EventModule(eventName, event);
|
|
50
|
+
this.pushDep(module2);
|
|
51
|
+
}
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/bot-implementation/bot-typings/events-module.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport { zuiSchemaToTypeScriptType } from '../../generators'\nimport { Module, ReExportTypeModule } from '../../module'\nimport * as strings from '../../strings'\n\nexport class EventModule extends Module {\n public constructor(name: string, private _event: sdk.BotEventDefinition) {\n const eventName = name\n const exportName = strings.typeName(eventName)\n super({ path: `${name}.ts`, exportName })\n }\n\n public async getContent() {\n return zuiSchemaToTypeScriptType(this._event.schema, this.exportName)\n }\n}\n\nexport class EventsModule extends ReExportTypeModule {\n public constructor(events: Record<string, sdk.BotEventDefinition>) {\n super({ exportName: strings.typeName('events') })\n for (const [eventName, event] of Object.entries(events)) {\n const module = new EventModule(eventName, event)\n this.pushDep(module)\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA0C;AAC1C,oBAA2C;AAC3C,cAAyB;AAElB,MAAM,oBAAoB,qBAAO;AAAA,EAC/B,YAAY,MAAsB,QAAgC;AACvE,UAAM,YAAY;AAClB,UAAM,aAAa,QAAQ,SAAS,SAAS;AAC7C,UAAM,EAAE,MAAM,GAAG,WAAW,WAAW,CAAC;AAHD;AAAA,EAIzC;AAAA,EAEA,MAAa,aAAa;AACxB,eAAO,6CAA0B,KAAK,OAAO,QAAQ,KAAK,UAAU;AAAA,EACtE;AACF;AAEO,MAAM,qBAAqB,iCAAmB;AAAA,EAC5C,YAAY,QAAgD;AACjE,UAAM,EAAE,YAAY,QAAQ,SAAS,QAAQ,EAAE,CAAC;AAChD,eAAW,CAAC,WAAW,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACvD,YAAMA,UAAS,IAAI,YAAY,WAAW,KAAK;AAC/C,WAAK,QAAQA,OAAM;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["module"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var bot_typings_exports = {};
|
|
26
|
+
__export(bot_typings_exports, {
|
|
27
|
+
BotTypingsModule: () => BotTypingsModule
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(bot_typings_exports);
|
|
30
|
+
var consts = __toESM(require("../../consts"));
|
|
31
|
+
var import_integration_typings = require("../../integration-implementation/integration-typings");
|
|
32
|
+
var import_module = require("../../module");
|
|
33
|
+
var import_events_module = require("./events-module");
|
|
34
|
+
var import_states_module = require("./states-module");
|
|
35
|
+
class BotIntegrationsModule extends import_module.ReExportTypeModule {
|
|
36
|
+
constructor(bot) {
|
|
37
|
+
super({
|
|
38
|
+
exportName: "Integrations"
|
|
39
|
+
});
|
|
40
|
+
for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {
|
|
41
|
+
const integrationModule = new import_integration_typings.IntegrationTypingsModule(integration.definition);
|
|
42
|
+
integrationModule.unshift(alias);
|
|
43
|
+
this.pushDep(integrationModule);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class BotTypingsModule extends import_module.Module {
|
|
48
|
+
_dependencies;
|
|
49
|
+
constructor(bot) {
|
|
50
|
+
super({
|
|
51
|
+
exportName: "TBot",
|
|
52
|
+
path: consts.INDEX_FILE
|
|
53
|
+
});
|
|
54
|
+
const integrationsModule = new BotIntegrationsModule(bot);
|
|
55
|
+
integrationsModule.unshift("integrations");
|
|
56
|
+
this.pushDep(integrationsModule);
|
|
57
|
+
const eventsModule = new import_events_module.EventsModule(bot.events ?? {});
|
|
58
|
+
eventsModule.unshift("events");
|
|
59
|
+
this.pushDep(eventsModule);
|
|
60
|
+
const statesModule = new import_states_module.StatesModule(bot.states ?? {});
|
|
61
|
+
statesModule.unshift("states");
|
|
62
|
+
this.pushDep(statesModule);
|
|
63
|
+
this._dependencies = {
|
|
64
|
+
integrationsModule,
|
|
65
|
+
eventsModule,
|
|
66
|
+
statesModule
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async getContent() {
|
|
70
|
+
const { integrationsModule, eventsModule, statesModule } = this._dependencies;
|
|
71
|
+
const integrationsImport = integrationsModule.import(this);
|
|
72
|
+
const eventsImport = eventsModule.import(this);
|
|
73
|
+
const statesImport = statesModule.import(this);
|
|
74
|
+
return [
|
|
75
|
+
consts.GENERATED_HEADER,
|
|
76
|
+
`import * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
77
|
+
`import * as ${eventsModule.name} from './${eventsModule.name}'`,
|
|
78
|
+
`import * as ${statesModule.name} from './${statesModule.name}'`,
|
|
79
|
+
"",
|
|
80
|
+
`export * as ${integrationsModule.name} from './${integrationsImport}'`,
|
|
81
|
+
`export * as ${eventsModule.name} from './${eventsImport}'`,
|
|
82
|
+
`export * as ${statesModule.name} from './${statesImport}'`,
|
|
83
|
+
"",
|
|
84
|
+
"export type TBot = {",
|
|
85
|
+
` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,
|
|
86
|
+
` events: ${eventsModule.name}.${eventsModule.exportName}`,
|
|
87
|
+
` states: ${statesModule.name}.${statesModule.exportName}`,
|
|
88
|
+
"}"
|
|
89
|
+
].join("\n");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
BotTypingsModule
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/code-generation/bot-implementation/bot-typings/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as sdk from '@botpress/sdk'\nimport * as consts from '../../consts'\nimport { IntegrationTypingsModule } from '../../integration-implementation/integration-typings'\nimport { Module, ReExportTypeModule } from '../../module'\nimport { EventsModule } from './events-module'\nimport { StatesModule } from './states-module'\n\nclass BotIntegrationsModule extends ReExportTypeModule {\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'Integrations',\n })\n\n for (const [alias, integration] of Object.entries(bot.integrations ?? {})) {\n const integrationModule = new IntegrationTypingsModule(integration.definition)\n integrationModule.unshift(alias)\n this.pushDep(integrationModule)\n }\n }\n}\n\ntype BotTypingsIndexDependencies = {\n integrationsModule: BotIntegrationsModule\n eventsModule: EventsModule\n statesModule: StatesModule\n}\n\nexport class BotTypingsModule extends Module {\n private _dependencies: BotTypingsIndexDependencies\n\n public constructor(bot: sdk.BotDefinition) {\n super({\n exportName: 'TBot',\n path: consts.INDEX_FILE,\n })\n\n const integrationsModule = new BotIntegrationsModule(bot)\n integrationsModule.unshift('integrations')\n this.pushDep(integrationsModule)\n\n const eventsModule = new EventsModule(bot.events ?? {})\n eventsModule.unshift('events')\n this.pushDep(eventsModule)\n\n const statesModule = new StatesModule(bot.states ?? {})\n statesModule.unshift('states')\n this.pushDep(statesModule)\n\n this._dependencies = {\n integrationsModule,\n eventsModule,\n statesModule,\n }\n }\n\n public async getContent() {\n const { integrationsModule, eventsModule, statesModule } = this._dependencies\n\n const integrationsImport = integrationsModule.import(this)\n const eventsImport = eventsModule.import(this)\n const statesImport = statesModule.import(this)\n return [\n consts.GENERATED_HEADER,\n `import * as ${integrationsModule.name} from './${integrationsImport}'`,\n `import * as ${eventsModule.name} from './${eventsModule.name}'`,\n `import * as ${statesModule.name} from './${statesModule.name}'`,\n '',\n `export * as ${integrationsModule.name} from './${integrationsImport}'`,\n `export * as ${eventsModule.name} from './${eventsImport}'`,\n `export * as ${statesModule.name} from './${statesImport}'`,\n '',\n 'export type TBot = {',\n ` integrations: ${integrationsModule.name}.${integrationsModule.exportName}`,\n ` events: ${eventsModule.name}.${eventsModule.exportName}`,\n ` states: ${statesModule.name}.${statesModule.exportName}`,\n '}',\n ].join('\\n')\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,aAAwB;AACxB,iCAAyC;AACzC,oBAA2C;AAC3C,2BAA6B;AAC7B,2BAA6B;AAE7B,MAAM,8BAA8B,iCAAmB;AAAA,EAC9C,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,IACd,CAAC;AAED,eAAW,CAAC,OAAO,WAAW,KAAK,OAAO,QAAQ,IAAI,gBAAgB,CAAC,CAAC,GAAG;AACzE,YAAM,oBAAoB,IAAI,oDAAyB,YAAY,UAAU;AAC7E,wBAAkB,QAAQ,KAAK;AAC/B,WAAK,QAAQ,iBAAiB;AAAA,IAChC;AAAA,EACF;AACF;AAQO,MAAM,yBAAyB,qBAAO;AAAA,EACnC;AAAA,EAED,YAAY,KAAwB;AACzC,UAAM;AAAA,MACJ,YAAY;AAAA,MACZ,MAAM,OAAO;AAAA,IACf,CAAC;AAED,UAAM,qBAAqB,IAAI,sBAAsB,GAAG;AACxD,uBAAmB,QAAQ,cAAc;AACzC,SAAK,QAAQ,kBAAkB;AAE/B,UAAM,eAAe,IAAI,kCAAa,IAAI,UAAU,CAAC,CAAC;AACtD,iB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