@botpress/cli 2.1.1 → 2.1.2
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 +22 -0
- package/dist/api/bot-body.js +89 -0
- package/dist/api/bot-body.js.map +7 -0
- package/dist/api/client.js +169 -0
- package/dist/api/client.js.map +7 -0
- package/dist/api/find-previous-version.js +66 -0
- package/dist/api/find-previous-version.js.map +7 -0
- package/dist/api/find-previous-version.test.js +76 -0
- package/dist/api/find-previous-version.test.js.map +7 -0
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +7 -0
- package/dist/api/integration-body.js +146 -0
- package/dist/api/integration-body.js.map +7 -0
- package/dist/api/interface-body.js +95 -0
- package/dist/api/interface-body.js.map +7 -0
- package/dist/api/paging.js +42 -0
- package/dist/api/paging.js.map +7 -0
- package/dist/api/plugin-body.js +84 -0
- package/dist/api/plugin-body.js.map +7 -0
- package/dist/api/types.js +17 -0
- package/dist/api/types.js.map +7 -0
- package/dist/chat/index.js +211 -0
- package/dist/chat/index.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-implementation.js +116 -0
- package/dist/code-generation/bot-implementation/bot-implementation.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-plugins/index.js +80 -0
- package/dist/code-generation/bot-implementation/bot-plugins/index.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js +129 -0
- package/dist/code-generation/bot-implementation/bot-plugins/plugin-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-typings/actions-module.js +88 -0
- package/dist/code-generation/bot-implementation/bot-typings/actions-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-typings/events-module.js +63 -0
- package/dist/code-generation/bot-implementation/bot-typings/events-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js +109 -0
- package/dist/code-generation/bot-implementation/bot-typings/index.js.map +7 -0
- package/dist/code-generation/bot-implementation/bot-typings/states-module.js +64 -0
- package/dist/code-generation/bot-implementation/bot-typings/states-module.js.map +7 -0
- package/dist/code-generation/bot-implementation/index.js +66 -0
- package/dist/code-generation/bot-implementation/index.js.map +7 -0
- package/dist/code-generation/consts.js +45 -0
- package/dist/code-generation/consts.js.map +7 -0
- package/dist/code-generation/generators.js +81 -0
- package/dist/code-generation/generators.js.map +7 -0
- package/dist/code-generation/index.js +49 -0
- package/dist/code-generation/index.js.map +7 -0
- package/dist/code-generation/integration-implementation/index.js +70 -0
- package/dist/code-generation/integration-implementation/index.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js +114 -0
- package/dist/code-generation/integration-implementation/integration-implementation.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-secret.js +78 -0
- package/dist/code-generation/integration-implementation/integration-secret.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/actions-module.js +88 -0
- 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 +107 -0
- package/dist/code-generation/integration-implementation/integration-typings/channels-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js +62 -0
- package/dist/code-generation/integration-implementation/integration-typings/configuration-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js +70 -0
- package/dist/code-generation/integration-implementation/integration-typings/configurations-module.js.map +7 -0
- package/dist/code-generation/integration-implementation/integration-typings/entities-module.js +63 -0
- 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 +63 -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 +64 -0
- package/dist/code-generation/integration-implementation/integration-typings/states-module.js.map +7 -0
- package/dist/code-generation/integration-package/index.js +94 -0
- package/dist/code-generation/integration-package/index.js.map +7 -0
- package/dist/code-generation/integration-package/integration-package-definition/actions-module.js +88 -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 +107 -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 +63 -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 +70 -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 +63 -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 +66 -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 +140 -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 +66 -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-implementation/index.js +29 -0
- package/dist/code-generation/interface-implementation/index.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js +88 -0
- package/dist/code-generation/interface-implementation/integration-typings/actions-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js +107 -0
- package/dist/code-generation/interface-implementation/integration-typings/channels-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js +63 -0
- package/dist/code-generation/interface-implementation/integration-typings/entities-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js +63 -0
- package/dist/code-generation/interface-implementation/integration-typings/events-module.js.map +7 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js +121 -0
- package/dist/code-generation/interface-implementation/integration-typings/index.js.map +7 -0
- package/dist/code-generation/interface-package/index.js +94 -0
- package/dist/code-generation/interface-package/index.js.map +7 -0
- package/dist/code-generation/interface-package/interface-package-definition/actions-module.js +88 -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 +98 -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 +63 -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 +66 -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 +104 -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 +183 -0
- package/dist/code-generation/module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/index.js +60 -0
- package/dist/code-generation/plugin-implementation/index.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js +90 -0
- package/dist/code-generation/plugin-implementation/plugin-implementation.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js +88 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/actions-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js +61 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/configuration-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js +63 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/events-module.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js +150 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/index.js.map +7 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js +64 -0
- package/dist/code-generation/plugin-implementation/plugin-typings/states-module.js.map +7 -0
- package/dist/code-generation/plugin-package/index.js +151 -0
- package/dist/code-generation/plugin-package/index.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js +88 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/actions-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js +56 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/configuration-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js +66 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/events-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js +107 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/index.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js +66 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/states-module.js.map +7 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js +17 -0
- package/dist/code-generation/plugin-package/plugin-package-definition/typings.js.map +7 -0
- package/dist/code-generation/strings.js +115 -0
- package/dist/code-generation/strings.js.map +7 -0
- package/dist/code-generation/typings.js +17 -0
- package/dist/code-generation/typings.js.map +7 -0
- package/dist/command-definitions.js +85 -0
- package/dist/command-definitions.js.map +7 -0
- package/dist/command-implementations/add-command.js +262 -0
- package/dist/command-implementations/add-command.js.map +7 -0
- package/dist/command-implementations/base-command.js +69 -0
- package/dist/command-implementations/base-command.js.map +7 -0
- package/dist/command-implementations/bot-commands.js +117 -0
- package/dist/command-implementations/bot-commands.js.map +7 -0
- package/dist/command-implementations/build-command.js +53 -0
- package/dist/command-implementations/build-command.js.map +7 -0
- package/dist/command-implementations/bundle-command.js +87 -0
- package/dist/command-implementations/bundle-command.js.map +7 -0
- package/dist/command-implementations/chat-command.js +152 -0
- package/dist/command-implementations/chat-command.js.map +7 -0
- package/dist/command-implementations/deploy-command.js +503 -0
- package/dist/command-implementations/deploy-command.js.map +7 -0
- package/dist/command-implementations/dev-command.js +345 -0
- package/dist/command-implementations/dev-command.js.map +7 -0
- package/dist/command-implementations/gen-command.js +110 -0
- package/dist/command-implementations/gen-command.js.map +7 -0
- package/dist/command-implementations/global-command.js +137 -0
- package/dist/command-implementations/global-command.js.map +7 -0
- package/dist/command-implementations/index.js +105 -0
- package/dist/command-implementations/index.js.map +7 -0
- package/dist/command-implementations/init-command.js +162 -0
- package/dist/command-implementations/init-command.js.map +7 -0
- package/dist/command-implementations/integration-commands.js +130 -0
- package/dist/command-implementations/integration-commands.js.map +7 -0
- package/dist/command-implementations/interface-commands.js +110 -0
- package/dist/command-implementations/interface-commands.js.map +7 -0
- package/dist/command-implementations/lint-command.js +151 -0
- package/dist/command-implementations/lint-command.js.map +7 -0
- package/dist/command-implementations/login-command.js +82 -0
- package/dist/command-implementations/login-command.js.map +7 -0
- package/dist/command-implementations/logout-command.js +35 -0
- package/dist/command-implementations/logout-command.js.map +7 -0
- package/dist/command-implementations/plugin-commands.js +111 -0
- package/dist/command-implementations/plugin-commands.js.map +7 -0
- package/dist/command-implementations/project-command.js +383 -0
- package/dist/command-implementations/project-command.js.map +7 -0
- package/dist/command-implementations/read-command.js +70 -0
- package/dist/command-implementations/read-command.js.map +7 -0
- package/dist/command-implementations/serve-command.js +68 -0
- package/dist/command-implementations/serve-command.js.map +7 -0
- package/dist/command-tree.js +60 -0
- package/dist/command-tree.js.map +7 -0
- package/dist/config.js +352 -0
- package/dist/config.js.map +7 -0
- package/dist/consts.js +127 -0
- package/dist/consts.js.map +7 -0
- package/dist/errors.js +202 -0
- package/dist/errors.js.map +7 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +7 -0
- package/dist/init.js +50 -0
- package/dist/init.js.map +7 -0
- package/dist/linter/base-linter.js +75 -0
- package/dist/linter/base-linter.js.map +7 -0
- package/dist/linter/base-linter.test.js +187 -0
- package/dist/linter/base-linter.test.js.map +7 -0
- package/dist/linter/bot-linter.js +35 -0
- package/dist/linter/bot-linter.js.map +7 -0
- package/dist/linter/integration-linter.js +35 -0
- package/dist/linter/integration-linter.js.map +7 -0
- package/dist/linter/interface-linter.js +35 -0
- package/dist/linter/interface-linter.js.map +7 -0
- package/dist/linter/ruleset-tests/bot.ruleset.test.js +358 -0
- package/dist/linter/ruleset-tests/bot.ruleset.test.js.map +7 -0
- package/dist/linter/ruleset-tests/common.js +37 -0
- package/dist/linter/ruleset-tests/common.js.map +7 -0
- package/dist/linter/ruleset-tests/integration.ruleset.test.js +887 -0
- package/dist/linter/ruleset-tests/integration.ruleset.test.js.map +7 -0
- package/dist/linter/ruleset-tests/interface.ruleset.test.js +383 -0
- package/dist/linter/ruleset-tests/interface.ruleset.test.js.map +7 -0
- package/dist/linter/rulesets/bot.ruleset.js +191 -0
- package/dist/linter/rulesets/bot.ruleset.js.map +7 -0
- package/dist/linter/rulesets/integration.ruleset.js +378 -0
- package/dist/linter/rulesets/integration.ruleset.js.map +7 -0
- package/dist/linter/rulesets/interface.ruleset.js +157 -0
- package/dist/linter/rulesets/interface.ruleset.js.map +7 -0
- package/dist/linter/spectral-functions.js +36 -0
- package/dist/linter/spectral-functions.js.map +7 -0
- package/dist/logger/base-logger.js +170 -0
- package/dist/logger/base-logger.js.map +7 -0
- package/dist/logger/index.js +86 -0
- package/dist/logger/index.js.map +7 -0
- package/dist/package-ref.js +107 -0
- package/dist/package-ref.js.map +7 -0
- package/dist/package-ref.test.js +109 -0
- package/dist/package-ref.test.js.map +7 -0
- package/dist/register-yargs.js +91 -0
- package/dist/register-yargs.js.map +7 -0
- package/dist/root.js +41 -0
- package/dist/root.js.map +7 -0
- package/dist/sdk/index.js +22 -0
- package/dist/sdk/index.js.map +7 -0
- package/dist/sdk/resolve-bot-interfaces.js +43 -0
- package/dist/sdk/resolve-bot-interfaces.js.map +7 -0
- package/dist/sdk/resolve-integration-interfaces.js +161 -0
- package/dist/sdk/resolve-integration-interfaces.js.map +7 -0
- package/dist/sdk/validate-bot.js +88 -0
- package/dist/sdk/validate-bot.js.map +7 -0
- package/dist/sdk/validate-integration.js +72 -0
- package/dist/sdk/validate-integration.js.map +7 -0
- package/dist/typings.js +17 -0
- package/dist/typings.js.map +7 -0
- package/dist/utils/cache-utils.js +104 -0
- package/dist/utils/cache-utils.js.map +7 -0
- package/dist/utils/case-utils.js +84 -0
- package/dist/utils/case-utils.js.map +7 -0
- package/dist/utils/case-utils.test.js +75 -0
- package/dist/utils/case-utils.test.js.map +7 -0
- package/dist/utils/esbuild-utils.js +92 -0
- package/dist/utils/esbuild-utils.js.map +7 -0
- package/dist/utils/event-emitter.js +63 -0
- package/dist/utils/event-emitter.js.map +7 -0
- package/dist/utils/file-watcher.js +73 -0
- package/dist/utils/file-watcher.js.map +7 -0
- package/dist/utils/guard-utils.js +32 -0
- package/dist/utils/guard-utils.js.map +7 -0
- package/dist/utils/id-utils.js +59 -0
- package/dist/utils/id-utils.js.map +7 -0
- package/dist/utils/index.js +99 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/object-utils.js +32 -0
- package/dist/utils/object-utils.js.map +7 -0
- package/dist/utils/path-utils.js +106 -0
- package/dist/utils/path-utils.js.map +7 -0
- package/dist/utils/path-utils.test.js +72 -0
- package/dist/utils/path-utils.test.js.map +7 -0
- package/dist/utils/pkgjson-utils.js +57 -0
- package/dist/utils/pkgjson-utils.js.map +7 -0
- package/dist/utils/promise-utils.js +36 -0
- package/dist/utils/promise-utils.js.map +7 -0
- package/dist/utils/promise-utils.test.js +14 -0
- package/dist/utils/promise-utils.test.js.map +7 -0
- package/dist/utils/prompt-utils.js +105 -0
- package/dist/utils/prompt-utils.js.map +7 -0
- package/dist/utils/record-utils.js +118 -0
- package/dist/utils/record-utils.js.map +7 -0
- package/dist/utils/record-utils.test.js +38 -0
- package/dist/utils/record-utils.test.js.map +7 -0
- package/dist/utils/require-utils.js +90 -0
- package/dist/utils/require-utils.js.map +7 -0
- package/dist/utils/require-utils.test.js +54 -0
- package/dist/utils/require-utils.test.js.map +7 -0
- package/dist/utils/schema-utils.js +64 -0
- package/dist/utils/schema-utils.js.map +7 -0
- package/dist/utils/schema-utils.test.js +50 -0
- package/dist/utils/schema-utils.test.js.map +7 -0
- package/dist/utils/semver-utils.js +45 -0
- package/dist/utils/semver-utils.js.map +7 -0
- package/dist/utils/string-utils.js +42 -0
- package/dist/utils/string-utils.js.map +7 -0
- package/dist/utils/template-utils.js +51 -0
- package/dist/utils/template-utils.js.map +7 -0
- package/dist/utils/tunnel-utils.js +129 -0
- package/dist/utils/tunnel-utils.js.map +7 -0
- package/dist/utils/type-utils.js +17 -0
- package/dist/utils/type-utils.js.map +7 -0
- package/dist/utils/url-utils.js +67 -0
- package/dist/utils/url-utils.js.map +7 -0
- package/dist/worker/child-entrypoint.js +58 -0
- package/dist/worker/child-entrypoint.js.map +7 -0
- package/dist/worker/child-wrapper.js +119 -0
- package/dist/worker/child-wrapper.js.map +7 -0
- package/dist/worker/config.js +44 -0
- package/dist/worker/config.js.map +7 -0
- package/dist/worker/index.js +32 -0
- package/dist/worker/index.js.map +7 -0
- package/dist/worker/is-child.js +55 -0
- package/dist/worker/is-child.js.map +7 -0
- package/dist/worker/worker-state.js +71 -0
- package/dist/worker/worker-state.js.map +7 -0
- package/dist/worker/worker.js +91 -0
- package/dist/worker/worker.js.map +7 -0
- package/package.json +1 -1
- package/templates/empty-bot/.botpress/implementation/index.ts +50 -0
- package/templates/empty-bot/.botpress/implementation/plugins/index.ts +11 -0
- package/templates/empty-bot/.botpress/implementation/typings/actions/index.ts +6 -0
- package/templates/empty-bot/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/empty-bot/.botpress/implementation/typings/index.ts +20 -0
- package/templates/empty-bot/.botpress/implementation/typings/integrations/index.ts +6 -0
- package/templates/empty-bot/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/empty-bot/.botpress/index.ts +5 -0
- package/templates/empty-integration/.botpress/implementation/index.ts +57 -0
- package/templates/empty-integration/.botpress/implementation/typings/actions/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/typings/channels/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/empty-integration/.botpress/implementation/typings/configurations/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/typings/entities/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/empty-integration/.botpress/implementation/typings/index.ts +31 -0
- package/templates/empty-integration/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/empty-integration/.botpress/index.ts +2 -0
- package/templates/empty-integration/.botpress/secrets/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/index.ts +35 -0
- package/templates/empty-plugin/.botpress/implementation/typings/actions/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/empty-plugin/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/index.ts +26 -0
- package/templates/empty-plugin/.botpress/implementation/typings/integrations/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/interfaces/index.ts +6 -0
- package/templates/empty-plugin/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/empty-plugin/.botpress/index.ts +1 -0
- package/templates/hello-world/.botpress/implementation/index.ts +57 -0
- package/templates/hello-world/.botpress/implementation/typings/actions/helloWorld/index.ts +12 -0
- 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/actions/index.ts +9 -0
- package/templates/hello-world/.botpress/implementation/typings/channels/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/typings/configuration/index.ts +2 -0
- package/templates/hello-world/.botpress/implementation/typings/configurations/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/typings/entities/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/typings/events/index.ts +6 -0
- package/templates/hello-world/.botpress/implementation/typings/index.ts +31 -0
- package/templates/hello-world/.botpress/implementation/typings/states/index.ts +6 -0
- package/templates/hello-world/.botpress/index.ts +2 -0
- package/templates/hello-world/.botpress/secrets/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/index.ts +57 -0
- package/templates/webhook-message/.botpress/implementation/typings/actions/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/typings/channels/index.ts +9 -0
- package/templates/webhook-message/.botpress/implementation/typings/channels/webhook/index.ts +12 -0
- package/templates/webhook-message/.botpress/implementation/typings/channels/webhook/messages/index.ts +9 -0
- 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/configurations/index.ts +6 -0
- package/templates/webhook-message/.botpress/implementation/typings/entities/index.ts +6 -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/.botpress/index.ts +2 -0
- package/templates/webhook-message/.botpress/secrets/index.ts +6 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
> @botpress/cli@2.1.2 build /home/runner/work/botpress/botpress/packages/cli
|
|
3
|
+
> pnpm run bundle && pnpm run template:gen
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @botpress/cli@2.1.2 bundle /home/runner/work/botpress/botpress/packages/cli
|
|
7
|
+
> ts-node -T build.ts
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
> @botpress/cli@2.1.2 template:gen /home/runner/work/botpress/botpress/packages/cli
|
|
11
|
+
> pnpm -r --stream -F @bp-templates/* exec bp gen
|
|
12
|
+
|
|
13
|
+
🤖 Botpress CLI v2.1.2
|
|
14
|
+
🤖 Botpress CLI v2.1.2
|
|
15
|
+
🤖 Botpress CLI v2.1.2
|
|
16
|
+
🤖 Botpress CLI v2.1.2
|
|
17
|
+
[2K[1G○ Generating typings for integration empty-integration...[2K[1G✓ Typings available at .botpress
|
|
18
|
+
[2K[1G○ Generating typings for bot...[2K[1G✓ Typings available at .botpress
|
|
19
|
+
[2K[1G○ Generating typings for plugin empty-plugin...[2K[1G✓ Typings available at .botpress
|
|
20
|
+
[2K[1G○ Generating typings for integration hello-world...[2K[1G✓ Typings available at .botpress
|
|
21
|
+
🤖 Botpress CLI v2.1.2
|
|
22
|
+
[2K[1G○ Generating typings for integration webhook-message...[2K[1G✓ Typings available at .botpress
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var bot_body_exports = {};
|
|
30
|
+
__export(bot_body_exports, {
|
|
31
|
+
prepareCreateBotBody: () => prepareCreateBotBody,
|
|
32
|
+
prepareUpdateBotBody: () => prepareUpdateBotBody
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(bot_body_exports);
|
|
35
|
+
var utils = __toESM(require("../utils"));
|
|
36
|
+
const prepareCreateBotBody = async (bot) => ({
|
|
37
|
+
user: bot.user,
|
|
38
|
+
conversation: bot.conversation,
|
|
39
|
+
message: bot.message,
|
|
40
|
+
recurringEvents: bot.recurringEvents,
|
|
41
|
+
actions: bot.actions ? await utils.records.mapValuesAsync(bot.actions, async (action) => ({
|
|
42
|
+
...action,
|
|
43
|
+
input: {
|
|
44
|
+
...action.input,
|
|
45
|
+
schema: await utils.schema.mapZodToJsonSchema(action.input)
|
|
46
|
+
},
|
|
47
|
+
output: {
|
|
48
|
+
...action.output,
|
|
49
|
+
schema: await utils.schema.mapZodToJsonSchema(action.output)
|
|
50
|
+
}
|
|
51
|
+
})) : void 0,
|
|
52
|
+
configuration: bot.configuration ? {
|
|
53
|
+
...bot.configuration,
|
|
54
|
+
schema: await utils.schema.mapZodToJsonSchema(bot.configuration)
|
|
55
|
+
} : void 0,
|
|
56
|
+
events: bot.events ? await utils.records.mapValuesAsync(bot.events, async (event) => ({
|
|
57
|
+
...event,
|
|
58
|
+
schema: await utils.schema.mapZodToJsonSchema(event)
|
|
59
|
+
})) : void 0,
|
|
60
|
+
states: bot.states ? await utils.records.mapValuesAsync(bot.states, async (state) => ({
|
|
61
|
+
...state,
|
|
62
|
+
schema: await utils.schema.mapZodToJsonSchema(state)
|
|
63
|
+
})) : void 0
|
|
64
|
+
});
|
|
65
|
+
const prepareUpdateBotBody = (localBot, remoteBot) => ({
|
|
66
|
+
...localBot,
|
|
67
|
+
states: utils.records.setNullOnMissingValues(localBot.states, remoteBot.states),
|
|
68
|
+
recurringEvents: utils.records.setNullOnMissingValues(localBot.recurringEvents, remoteBot.recurringEvents),
|
|
69
|
+
events: utils.records.setNullOnMissingValues(localBot.events, remoteBot.events),
|
|
70
|
+
user: {
|
|
71
|
+
...localBot.user,
|
|
72
|
+
tags: utils.records.setNullOnMissingValues(localBot.user?.tags, remoteBot.user?.tags)
|
|
73
|
+
},
|
|
74
|
+
conversation: {
|
|
75
|
+
...localBot.conversation,
|
|
76
|
+
tags: utils.records.setNullOnMissingValues(localBot.conversation?.tags, remoteBot.conversation?.tags)
|
|
77
|
+
},
|
|
78
|
+
message: {
|
|
79
|
+
...localBot.message,
|
|
80
|
+
tags: utils.records.setNullOnMissingValues(localBot.message?.tags, remoteBot.message?.tags)
|
|
81
|
+
},
|
|
82
|
+
integrations: utils.records.setNullOnMissingValues(localBot.integrations, remoteBot.integrations)
|
|
83
|
+
});
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
prepareCreateBotBody,
|
|
87
|
+
prepareUpdateBotBody
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=bot-body.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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.BotDefinition): Promise<CreateBotBody> => ({\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 = (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,MAAM,IAAI;AAAA,EACV,cAAc,IAAI;AAAA,EAClB,SAAS,IAAI;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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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var client_exports = {};
|
|
31
|
+
__export(client_exports, {
|
|
32
|
+
ApiClient: () => ApiClient
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(client_exports);
|
|
35
|
+
var client = __toESM(require("@botpress/client"));
|
|
36
|
+
var import_semver = __toESM(require("semver"));
|
|
37
|
+
var import_yn = __toESM(require("yn"));
|
|
38
|
+
var import_package_ref = require("../package-ref");
|
|
39
|
+
var import_find_previous_version = require("./find-previous-version");
|
|
40
|
+
var paging = __toESM(require("./paging"));
|
|
41
|
+
__reExport(client_exports, require("./types"), module.exports);
|
|
42
|
+
class ApiClient {
|
|
43
|
+
constructor(props, _logger) {
|
|
44
|
+
this._logger = _logger;
|
|
45
|
+
const { apiUrl, token, workspaceId } = props;
|
|
46
|
+
this.client = new client.Client({ apiUrl, token, workspaceId });
|
|
47
|
+
this.url = apiUrl;
|
|
48
|
+
this.token = token;
|
|
49
|
+
this.workspaceId = workspaceId;
|
|
50
|
+
}
|
|
51
|
+
client;
|
|
52
|
+
url;
|
|
53
|
+
token;
|
|
54
|
+
workspaceId;
|
|
55
|
+
static newClient = (props, logger) => new ApiClient(props, logger);
|
|
56
|
+
get isBotpressWorkspace() {
|
|
57
|
+
const isBotpressWorkspace = (0, import_yn.default)(process.env.BP_IS_BOTPRESS_WORKSPACE);
|
|
58
|
+
if (isBotpressWorkspace !== void 0) {
|
|
59
|
+
return isBotpressWorkspace;
|
|
60
|
+
}
|
|
61
|
+
return [
|
|
62
|
+
"6a76fa10-e150-4ff6-8f59-a300feec06c1",
|
|
63
|
+
"95de33eb-1551-4af9-9088-e5dcb02efd09",
|
|
64
|
+
"11111111-1111-1111-aaaa-111111111111"
|
|
65
|
+
].includes(this.workspaceId);
|
|
66
|
+
}
|
|
67
|
+
async getWorkspace() {
|
|
68
|
+
return this.client.getWorkspace({ id: this.workspaceId });
|
|
69
|
+
}
|
|
70
|
+
async findWorkspaceByHandle(handle) {
|
|
71
|
+
const workspaces = await paging.listAllPages(this.client.listWorkspaces, (r) => r.workspaces);
|
|
72
|
+
return workspaces.find((w) => w.handle === handle);
|
|
73
|
+
}
|
|
74
|
+
switchWorkspace(workspaceId) {
|
|
75
|
+
return ApiClient.newClient({ apiUrl: this.url, token: this.token, workspaceId }, this._logger);
|
|
76
|
+
}
|
|
77
|
+
async updateWorkspace(props) {
|
|
78
|
+
return this.client.updateWorkspace({ id: this.workspaceId, ...props });
|
|
79
|
+
}
|
|
80
|
+
async findIntegration(ref) {
|
|
81
|
+
const formatted = (0, import_package_ref.formatPackageRef)(ref);
|
|
82
|
+
const privateIntegration = await this.findPrivateIntegration(ref);
|
|
83
|
+
if (privateIntegration) {
|
|
84
|
+
this._logger.debug(`Found integration "${formatted}" in workspace`);
|
|
85
|
+
return privateIntegration;
|
|
86
|
+
}
|
|
87
|
+
const publicIntegration = await this.findPublicIntegration(ref);
|
|
88
|
+
if (publicIntegration) {
|
|
89
|
+
this._logger.debug(`Found integration "${formatted}" in hub`);
|
|
90
|
+
return publicIntegration;
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
async findPrivateIntegration(ref) {
|
|
95
|
+
const { workspaceId } = this;
|
|
96
|
+
if (ref.type === "id") {
|
|
97
|
+
return this.client.getIntegration(ref).then((r) => ({ ...r.integration, workspaceId })).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
98
|
+
}
|
|
99
|
+
return this.client.getIntegrationByName(ref).then((r) => ({ ...r.integration, workspaceId })).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
100
|
+
}
|
|
101
|
+
async findPublicIntegration(ref) {
|
|
102
|
+
if (ref.type === "id") {
|
|
103
|
+
return this.client.getPublicIntegrationById(ref).then((r) => r.integration).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
104
|
+
}
|
|
105
|
+
return this.client.getPublicIntegration(ref).then((r) => r.integration).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
106
|
+
}
|
|
107
|
+
async findPublicInterface(ref) {
|
|
108
|
+
if (ref.type === "id") {
|
|
109
|
+
return this.client.getInterface(ref).then((r) => r.interface).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
110
|
+
}
|
|
111
|
+
if ((0, import_package_ref.isLatest)(ref)) {
|
|
112
|
+
return this._findLatestInterfaceVersion(ref);
|
|
113
|
+
}
|
|
114
|
+
return this.client.getInterfaceByName(ref).then((r) => r.interface).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
115
|
+
}
|
|
116
|
+
async findPublicPlugin(ref) {
|
|
117
|
+
if (ref.type === "id") {
|
|
118
|
+
return this.client.getPlugin(ref).then((r) => r.plugin).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
119
|
+
}
|
|
120
|
+
if ((0, import_package_ref.isLatest)(ref)) {
|
|
121
|
+
return this._findLatestPluginVersion(ref);
|
|
122
|
+
}
|
|
123
|
+
return this.client.getPluginByName(ref).then((r) => r.plugin).catch(this._returnUndefinedOnError("ResourceNotFound"));
|
|
124
|
+
}
|
|
125
|
+
_findLatestInterfaceVersion = async ({ name }) => {
|
|
126
|
+
const { interfaces: allVersions } = await this.client.listInterfaces({ name });
|
|
127
|
+
const sorted = allVersions.sort((a, b) => import_semver.default.compare(b.version, a.version));
|
|
128
|
+
const latestVersion = sorted[0];
|
|
129
|
+
if (!latestVersion) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
return this.client.getInterface({ id: latestVersion.id }).then((r) => r.interface);
|
|
133
|
+
};
|
|
134
|
+
_findLatestPluginVersion = async ({ name }) => {
|
|
135
|
+
const { plugins: allVersions } = await this.client.listPlugins({ name });
|
|
136
|
+
const sorted = allVersions.sort((a, b) => import_semver.default.compare(b.version, a.version));
|
|
137
|
+
const latestVersion = sorted[0];
|
|
138
|
+
if (!latestVersion) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
return this.client.getPlugin({ id: latestVersion.id }).then((r) => r.plugin);
|
|
142
|
+
};
|
|
143
|
+
async testLogin() {
|
|
144
|
+
await this.client.listBots({});
|
|
145
|
+
}
|
|
146
|
+
listAllPages = paging.listAllPages;
|
|
147
|
+
async findPreviousIntegrationVersion(ref) {
|
|
148
|
+
const previous = await (0, import_find_previous_version.findPreviousIntegrationVersion)(this.client, ref);
|
|
149
|
+
if (!previous) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
return this.findIntegration({ type: "id", id: previous.id });
|
|
153
|
+
}
|
|
154
|
+
async findBotByName(name) {
|
|
155
|
+
const allBots = await this.listAllPages(this.client.listBots, (r) => r.bots);
|
|
156
|
+
return allBots.find((b) => b.name === name);
|
|
157
|
+
}
|
|
158
|
+
_returnUndefinedOnError = (type) => (thrown) => {
|
|
159
|
+
if (client.isApiError(thrown) && thrown.type === type) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
throw thrown;
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
ApiClient
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 Requests,\n Responses,\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\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 // 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<Responses['getWorkspace']> {\n return this.client.getWorkspace({ id: this.workspaceId })\n }\n\n public async findWorkspaceByHandle(handle: string): Promise<Responses['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 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\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.isApiError(thrown) && thrown.type === type) {\n return\n }\n throw thrown\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAwB;AACxB,oBAAmB;AACnB,gBAAe;AAEf,yBAA0E;AAC1E,mCAA+C;AAC/C,aAAwB;AAcxB,2BAAc,oBApBd;AAyBO,MAAM,UAAU;AAAA,EAQd,YAAY,OAA+B,SAAiB;AAAjB;AAChD,UAAM,EAAE,QAAQ,OAAO,YAAY,IAAI;AACvC,SAAK,SAAS,IAAI,OAAO,OAAO,EAAE,QAAQ,OAAO,YAAY,CAAC;AAC9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EAEO,eAAe,OAAO;AAAA,EAE7B,MAAa,+BAA+B,KAAuD;AACjG,UAAM,WAAW,UAAM,6DAA+B,KAAK,QAAQ,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": ["yn", "semver"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var find_previous_version_exports = {};
|
|
30
|
+
__export(find_previous_version_exports, {
|
|
31
|
+
findPreviousIntegrationVersion: () => findPreviousIntegrationVersion
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(find_previous_version_exports);
|
|
34
|
+
var import_semver = __toESM(require("semver"));
|
|
35
|
+
var paging = __toESM(require("./paging"));
|
|
36
|
+
const findPreviousIntegrationVersion = async (client2, ref) => {
|
|
37
|
+
const { name, version: targetVersion } = ref;
|
|
38
|
+
const allVersions = await paging.listAllPages(
|
|
39
|
+
async ({ nextToken }) => client2.listIntegrations({ name, nextToken }),
|
|
40
|
+
(r) => r.integrations
|
|
41
|
+
);
|
|
42
|
+
const orderedVersions = allVersions.sort((a, b) => import_semver.default.compare(b.version, a.version));
|
|
43
|
+
const latestVersion = orderedVersions[0];
|
|
44
|
+
if (!latestVersion) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
let current = [0, latestVersion];
|
|
48
|
+
while (import_semver.default.gte(current[1].version, targetVersion)) {
|
|
49
|
+
const nextIdx = current[0] + 1;
|
|
50
|
+
const nextIntegration = orderedVersions[nextIdx];
|
|
51
|
+
if (!nextIntegration) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
current = [nextIdx, nextIntegration];
|
|
55
|
+
}
|
|
56
|
+
const previous = current[1];
|
|
57
|
+
if (import_semver.default.gte(previous.version, targetVersion)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return previous;
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
findPreviousIntegrationVersion
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=find-previous-version.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/api/find-previous-version.ts"],
|
|
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
|
+
"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,CAAC;AACvC,MAAI,CAAC,eAAe;AAClB;AAAA,EACF;AAIA,MAAI,UAAsB,CAAC,GAAG,aAAa;AAC3C,SAAO,cAAAA,QAAO,IAAI,QAAQ,CAAC,EAAE,SAAS,aAAa,GAAG;AACpD,UAAM,UAAU,QAAQ,CAAC,IAAI;AAC7B,UAAM,kBAAkB,gBAAgB,OAAO;AAC/C,QAAI,CAAC,iBAAiB;AACpB;AAAA,IACF;AACA,cAAU,CAAC,SAAS,eAAe;AAAA,EACrC;AAEA,QAAM,WAAW,QAAQ,CAAC;AAC1B,MAAI,cAAAA,QAAO,IAAI,SAAS,SAAS,aAAa,GAAG;AAC/C;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["client", "semver"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var uuid = __toESM(require("uuid"));
|
|
25
|
+
var import_vitest = require("vitest");
|
|
26
|
+
var import_find_previous_version = require("./find-previous-version");
|
|
27
|
+
class IntegrationFixtureCreator {
|
|
28
|
+
constructor(name) {
|
|
29
|
+
this.name = name;
|
|
30
|
+
}
|
|
31
|
+
t0 = Date.now();
|
|
32
|
+
create = (version) => {
|
|
33
|
+
return {
|
|
34
|
+
id: uuid.v4(),
|
|
35
|
+
name: this.name,
|
|
36
|
+
version,
|
|
37
|
+
public: true,
|
|
38
|
+
createdAt: new Date(this.t0++).toISOString(),
|
|
39
|
+
updatedAt: new Date(this.t0++).toISOString(),
|
|
40
|
+
description: "description",
|
|
41
|
+
title: "title",
|
|
42
|
+
iconUrl: "iconUrl",
|
|
43
|
+
verificationStatus: "approved"
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
(0, import_vitest.test)("find previous integration version", async ({}) => {
|
|
48
|
+
const client2 = {
|
|
49
|
+
listIntegrations: async ({ name }) => {
|
|
50
|
+
const creator = new IntegrationFixtureCreator(name);
|
|
51
|
+
const integrations = [
|
|
52
|
+
creator.create("9.2.0"),
|
|
53
|
+
creator.create("9.2.1"),
|
|
54
|
+
creator.create("9.3.0"),
|
|
55
|
+
creator.create("9.2.2"),
|
|
56
|
+
creator.create("10.0.0")
|
|
57
|
+
].reverse();
|
|
58
|
+
return { integrations, meta: {} };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const getPrevious = async (version) => {
|
|
62
|
+
const integration = await (0, import_find_previous_version.findPreviousIntegrationVersion)(client2, {
|
|
63
|
+
type: "name",
|
|
64
|
+
name: "slack",
|
|
65
|
+
version
|
|
66
|
+
});
|
|
67
|
+
return integration?.version;
|
|
68
|
+
};
|
|
69
|
+
(0, import_vitest.expect)(await getPrevious("10.0.1")).toEqual("10.0.0");
|
|
70
|
+
(0, import_vitest.expect)(await getPrevious("10.0.0")).toEqual("9.3.0");
|
|
71
|
+
(0, import_vitest.expect)(await getPrevious("9.3.0")).toEqual("9.2.2");
|
|
72
|
+
(0, import_vitest.expect)(await getPrevious("9.2.2")).toEqual("9.2.1");
|
|
73
|
+
(0, import_vitest.expect)(await getPrevious("9.2.1")).toEqual("9.2.0");
|
|
74
|
+
(0, import_vitest.expect)(await getPrevious("9.2.0")).toEqual(void 0);
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=find-previous-version.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 ({}) => {\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,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,OAAO,CAAC,MAAM;AACtD,QAAMA,UAAiC;AAAA,IACrC,kBAAkB,OAAO,EAAE,KAAK,MAA2C;AACzE,YAAM,UAAU,IAAI,0BAA0B,IAAK;AAEnD,YAAM,eAAqC;AAAA,QACzC,QAAQ,OAAO,OAAO;AAAA,QACtB,QAAQ,OAAO,OAAO;AAAA,QACtB,QAAQ,OAAO,OAAO;AAAA,QACtB,QAAQ,OAAO,OAAO;AAAA,QACtB,QAAQ,OAAO,QAAQ;AAAA,MACzB,EAAE,QAAQ;AAEV,aAAO,EAAE,cAAc,MAAM,CAAC,EAAE;AAAA,IAClC;AAAA,EACF;AAEA,QAAM,cAAc,OAAO,YAAoB;AAC7C,UAAM,cAAc,UAAM,6DAA+BA,SAAyB;AAAA,MAChF,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,WAAO,aAAa;AAAA,EACtB;AAEA,4BAAO,MAAM,YAAY,QAAQ,CAAC,EAAE,QAAQ,QAAQ;AACpD,4BAAO,MAAM,YAAY,QAAQ,CAAC,EAAE,QAAQ,OAAO;AACnD,4BAAO,MAAM,YAAY,OAAO,CAAC,EAAE,QAAQ,OAAO;AAClD,4BAAO,MAAM,YAAY,OAAO,CAAC,EAAE,QAAQ,OAAO;AAClD,4BAAO,MAAM,YAAY,OAAO,CAAC,EAAE,QAAQ,OAAO;AAClD,4BAAO,MAAM,YAAY,OAAO,CAAC,EAAE,QAAQ,MAAS;AACtD,CAAC;",
|
|
6
|
+
"names": ["client"]
|
|
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
|
+
}
|