@botpress/cli 2.1.0 → 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 +3 -3
- 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-bot/package.json +2 -2
- 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-integration/package.json +2 -2
- 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/empty-plugin/package.json +1 -1
- 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/hello-world/package.json +2 -2
- 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
- package/templates/webhook-message/package.json +2 -2
- package/e2e/api.ts +0 -25
- package/e2e/defaults.ts +0 -20
- package/e2e/index.ts +0 -118
- package/e2e/tests/create-deploy-bot.ts +0 -51
- package/e2e/tests/create-deploy-integration.ts +0 -62
- package/e2e/tests/dev-bot.ts +0 -59
- package/e2e/tests/install-interfaces.ts +0 -49
- package/e2e/tests/install-package.ts +0 -164
- package/e2e/tests/integration-secrets.ts +0 -102
- package/e2e/tests/manage-workspace-handle.ts +0 -105
- package/e2e/typings.ts +0 -17
- package/e2e/utils.ts +0 -99
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Client } from '@botpress/client'
|
|
2
|
-
import pathlib from 'path'
|
|
3
|
-
import * as uuid from 'uuid'
|
|
4
|
-
import impl from '../../src/command-implementations'
|
|
5
|
-
import { ApiBot, fetchAllBots } from '../api'
|
|
6
|
-
import defaults from '../defaults'
|
|
7
|
-
import { Test } from '../typings'
|
|
8
|
-
import * as utils from '../utils'
|
|
9
|
-
|
|
10
|
-
const fetchBot = async (client: Client, botName: string): Promise<ApiBot | undefined> => {
|
|
11
|
-
const bots = await fetchAllBots(client)
|
|
12
|
-
return bots.find(({ name }) => name === botName)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const createDeployBot: Test = {
|
|
16
|
-
name: 'cli should allow creating, building, deploying and mannaging a bot',
|
|
17
|
-
handler: async ({ tmpDir, dependencies, ...creds }) => {
|
|
18
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
19
|
-
const baseDir = pathlib.join(tmpDir, 'bots')
|
|
20
|
-
const botName = uuid.v4()
|
|
21
|
-
const botDir = pathlib.join(baseDir, botName)
|
|
22
|
-
|
|
23
|
-
const argv = {
|
|
24
|
-
...defaults,
|
|
25
|
-
botpressHome: botpressHomeDir,
|
|
26
|
-
confirm: true,
|
|
27
|
-
...creds,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const client = new Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
|
|
31
|
-
|
|
32
|
-
await impl.init({ ...argv, workDir: baseDir, name: botName, type: 'bot' }).then(utils.handleExitCode)
|
|
33
|
-
await utils.fixBotpressDependencies({ workDir: botDir, target: dependencies })
|
|
34
|
-
await utils.npmInstall({ workDir: botDir }).then(utils.handleExitCode)
|
|
35
|
-
await impl.build({ ...argv, workDir: botDir }).then(utils.handleExitCode)
|
|
36
|
-
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
37
|
-
await impl.bots.subcommands.create({ ...argv, name: botName, ifNotExists: false }).then(utils.handleExitCode)
|
|
38
|
-
|
|
39
|
-
const bot = await fetchBot(client, botName)
|
|
40
|
-
if (!bot) {
|
|
41
|
-
throw new Error(`Bot ${botName} should have been created`)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
await impl.deploy({ ...argv, workDir: botDir, createNewBot: false, botId: bot.id }).then(utils.handleExitCode)
|
|
45
|
-
await impl.bots.subcommands.delete({ ...argv, botRef: bot.id }).then(utils.handleExitCode)
|
|
46
|
-
|
|
47
|
-
if (await fetchBot(client, botName)) {
|
|
48
|
-
throw new Error(`Bot ${botName} should have been deleted`)
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Client } from '@botpress/client'
|
|
2
|
-
|
|
3
|
-
import pathlib from 'path'
|
|
4
|
-
import * as uuid from 'uuid'
|
|
5
|
-
import impl from '../../src/command-implementations'
|
|
6
|
-
import { ApiIntegration, fetchAllIntegrations } from '../api'
|
|
7
|
-
import defaults from '../defaults'
|
|
8
|
-
import { Test } from '../typings'
|
|
9
|
-
import * as utils from '../utils'
|
|
10
|
-
|
|
11
|
-
const fetchIntegration = async (client: Client, integrationName: string): Promise<ApiIntegration | undefined> => {
|
|
12
|
-
const integrations = await fetchAllIntegrations(client)
|
|
13
|
-
return integrations.find(({ name }) => name === integrationName)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const createDeployIntegration: Test = {
|
|
17
|
-
name: 'cli should allow creating, building, deploying and mannaging an integration',
|
|
18
|
-
handler: async ({ tmpDir, dependencies, workspaceHandle, logger, ...creds }) => {
|
|
19
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
20
|
-
const baseDir = pathlib.join(tmpDir, 'integrations')
|
|
21
|
-
|
|
22
|
-
const integrationSuffix = uuid.v4().replace(/-/g, '')
|
|
23
|
-
const name = `myintegration${integrationSuffix}`
|
|
24
|
-
const integrationName = `${workspaceHandle}/${name}`
|
|
25
|
-
const integrationDirName = `${workspaceHandle}-${name}`
|
|
26
|
-
const integrationDir = pathlib.join(baseDir, integrationDirName)
|
|
27
|
-
|
|
28
|
-
const argv = {
|
|
29
|
-
...defaults,
|
|
30
|
-
botpressHome: botpressHomeDir,
|
|
31
|
-
confirm: true,
|
|
32
|
-
...creds,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const client = new Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
|
|
36
|
-
|
|
37
|
-
await impl
|
|
38
|
-
.init({ ...argv, workDir: baseDir, name: integrationName, type: 'integration' })
|
|
39
|
-
.then(utils.handleExitCode)
|
|
40
|
-
await utils.fixBotpressDependencies({ workDir: integrationDir, target: dependencies })
|
|
41
|
-
await utils.npmInstall({ workDir: integrationDir }).then(utils.handleExitCode)
|
|
42
|
-
await impl.build({ ...argv, workDir: integrationDir }).then(utils.handleExitCode)
|
|
43
|
-
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
44
|
-
|
|
45
|
-
await impl
|
|
46
|
-
.deploy({ ...argv, createNewBot: undefined, botId: undefined, workDir: integrationDir })
|
|
47
|
-
.then(utils.handleExitCode)
|
|
48
|
-
|
|
49
|
-
logger.debug(`Fetching integration "${integrationName}"`)
|
|
50
|
-
const integration = await fetchIntegration(client, integrationName)
|
|
51
|
-
if (!integration) {
|
|
52
|
-
throw new Error(`Integration ${integrationName} should have been created`)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
logger.debug(`Deleting integration "${integrationName}"`)
|
|
56
|
-
await impl.integrations.subcommands.delete({ ...argv, integrationRef: integration.id }).then(utils.handleExitCode)
|
|
57
|
-
|
|
58
|
-
if (await fetchIntegration(client, integrationName)) {
|
|
59
|
-
throw new Error(`Integration ${integrationName} should have been deleted`)
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
}
|
package/e2e/tests/dev-bot.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import findProcess from 'find-process'
|
|
2
|
-
import pathlib from 'path'
|
|
3
|
-
import * as uuid from 'uuid'
|
|
4
|
-
import impl from '../../src/command-implementations'
|
|
5
|
-
import defaults from '../defaults'
|
|
6
|
-
import { Test } from '../typings'
|
|
7
|
-
import * as utils from '../utils'
|
|
8
|
-
|
|
9
|
-
const handleExitCode = ({ exitCode }: { exitCode: number }) => {
|
|
10
|
-
if (exitCode !== 0) {
|
|
11
|
-
throw new Error(`Command exited with code ${exitCode}`)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const PORT = 8075
|
|
16
|
-
|
|
17
|
-
export const devBot: Test = {
|
|
18
|
-
name: 'cli should allow creating and running a bot locally',
|
|
19
|
-
handler: async ({ tmpDir, tunnelUrl, dependencies, ...creds }) => {
|
|
20
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
21
|
-
const baseDir = pathlib.join(tmpDir, 'bots')
|
|
22
|
-
const botName = uuid.v4()
|
|
23
|
-
const botDir = pathlib.join(baseDir, botName)
|
|
24
|
-
|
|
25
|
-
const argv = {
|
|
26
|
-
...defaults,
|
|
27
|
-
botpressHome: botpressHomeDir,
|
|
28
|
-
confirm: true,
|
|
29
|
-
...creds,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await impl.init({ ...argv, workDir: baseDir, name: botName, type: 'bot' }).then(handleExitCode)
|
|
33
|
-
await utils.fixBotpressDependencies({ workDir: botDir, target: dependencies })
|
|
34
|
-
await utils.npmInstall({ workDir: botDir }).then(handleExitCode)
|
|
35
|
-
await impl.login({ ...argv }).then(handleExitCode)
|
|
36
|
-
|
|
37
|
-
const cmdPromise = impl.dev({ ...argv, workDir: botDir, port: PORT, tunnelUrl }).then(handleExitCode)
|
|
38
|
-
await utils.sleep(5000)
|
|
39
|
-
|
|
40
|
-
const allProcess = await findProcess('port', PORT)
|
|
41
|
-
|
|
42
|
-
const [botProcess] = allProcess
|
|
43
|
-
if (allProcess.length > 1) {
|
|
44
|
-
throw new Error(`Expected to find only one process listening on port ${PORT}`)
|
|
45
|
-
}
|
|
46
|
-
if (!botProcess) {
|
|
47
|
-
throw new Error(`Expected to find a process listening on port ${PORT}`)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* TODO:
|
|
52
|
-
* - try calling the Bot locally to see if it works
|
|
53
|
-
* - allow listing dev bots in API and find the one we just created (by name)
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
process.kill(botProcess.pid)
|
|
57
|
-
await cmdPromise
|
|
58
|
-
},
|
|
59
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import pathlib from 'path'
|
|
2
|
-
import impl from '../../src/command-implementations'
|
|
3
|
-
import defaults from '../defaults'
|
|
4
|
-
import { Test } from '../typings'
|
|
5
|
-
import * as utils from '../utils'
|
|
6
|
-
|
|
7
|
-
export const installAllInterfaces: Test = {
|
|
8
|
-
name: 'cli should allow installing public interfaces',
|
|
9
|
-
handler: async ({ tmpDir, logger, ...creds }) => {
|
|
10
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
11
|
-
const baseDir = pathlib.join(tmpDir, 'interfaces')
|
|
12
|
-
|
|
13
|
-
const argv = {
|
|
14
|
-
...defaults,
|
|
15
|
-
botpressHome: botpressHomeDir,
|
|
16
|
-
confirm: true,
|
|
17
|
-
...creds,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
21
|
-
|
|
22
|
-
const interfaces: string[] = [
|
|
23
|
-
'creatable',
|
|
24
|
-
'deletable',
|
|
25
|
-
'hitl',
|
|
26
|
-
'listable',
|
|
27
|
-
'llm',
|
|
28
|
-
'readable',
|
|
29
|
-
'speechToText',
|
|
30
|
-
'textToImage',
|
|
31
|
-
'typingIndicator',
|
|
32
|
-
'updatable',
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
for (const iface of interfaces) {
|
|
36
|
-
logger.info(`Installing interface: ${iface}`)
|
|
37
|
-
await impl
|
|
38
|
-
.add({
|
|
39
|
-
...argv,
|
|
40
|
-
packageRef: iface,
|
|
41
|
-
packageType: 'interface',
|
|
42
|
-
installPath: baseDir,
|
|
43
|
-
useDev: false,
|
|
44
|
-
})
|
|
45
|
-
.then(utils.handleExitCode)
|
|
46
|
-
// TODO: also run a type check on the installed interface
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import * as client from '@botpress/client'
|
|
2
|
-
import * as sdk from '@botpress/sdk'
|
|
3
|
-
import * as fslib from 'fs'
|
|
4
|
-
import * as pathlib from 'path'
|
|
5
|
-
import * as uuid from 'uuid'
|
|
6
|
-
import * as apiUtils from '../../src/api'
|
|
7
|
-
import impl from '../../src/command-implementations'
|
|
8
|
-
import defaults from '../defaults'
|
|
9
|
-
import { Test, TestProps } from '../typings'
|
|
10
|
-
import * as utils from '../utils'
|
|
11
|
-
|
|
12
|
-
const issueSchema = sdk.z.object({
|
|
13
|
-
id: sdk.z.string(),
|
|
14
|
-
priority: sdk.z.enum(['high', 'medium', 'low']),
|
|
15
|
-
title: sdk.z.string(),
|
|
16
|
-
body: sdk.z.string(),
|
|
17
|
-
})
|
|
18
|
-
const INTEGRATION = {
|
|
19
|
-
version: '0.0.1',
|
|
20
|
-
title: 'An Integration',
|
|
21
|
-
description: 'An integration',
|
|
22
|
-
user: { tags: { id: { title: 'ID', description: 'The user ID' } } },
|
|
23
|
-
configuration: { schema: sdk.z.object({}), identifier: { required: true, linkTemplateScript: '' } },
|
|
24
|
-
configurations: {
|
|
25
|
-
token: {
|
|
26
|
-
title: 'API Token',
|
|
27
|
-
description: 'The token to authenticate with',
|
|
28
|
-
schema: sdk.z.object({ token: sdk.z.string() }),
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
actions: {
|
|
32
|
-
getIssue: {
|
|
33
|
-
input: { schema: sdk.z.object({ id: sdk.z.string() }) },
|
|
34
|
-
output: { schema: issueSchema },
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
events: {
|
|
38
|
-
issueCreated: {
|
|
39
|
-
title: 'Issue Created',
|
|
40
|
-
description: 'An issue was created',
|
|
41
|
-
schema: issueSchema,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
channels: {
|
|
45
|
-
issueComment: {
|
|
46
|
-
title: 'Issue Comment',
|
|
47
|
-
description: 'Comment on an issue',
|
|
48
|
-
messages: { text: sdk.messages.defaults.text },
|
|
49
|
-
conversation: { tags: { id: { title: 'ID', description: 'The issue ID' } } },
|
|
50
|
-
message: { tags: { id: { title: 'ID', description: 'The issue comment ID' } } },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
entities: {
|
|
54
|
-
issue: {
|
|
55
|
-
title: 'Issue',
|
|
56
|
-
description: 'An issue',
|
|
57
|
-
schema: issueSchema,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
states: {
|
|
61
|
-
lastCreatedIssue: {
|
|
62
|
-
type: 'integration',
|
|
63
|
-
schema: issueSchema,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
identifier: {
|
|
67
|
-
extractScript: '',
|
|
68
|
-
},
|
|
69
|
-
} satisfies Omit<sdk.IntegrationDefinitionProps, 'name'>
|
|
70
|
-
|
|
71
|
-
const getHomeDir = (props: { tmpDir: string }) => pathlib.join(props.tmpDir, '.botpresshome')
|
|
72
|
-
const initBot = async (props: TestProps, definitionFile: string) => {
|
|
73
|
-
const { tmpDir, dependencies, ...creds } = props
|
|
74
|
-
const argv = {
|
|
75
|
-
...defaults,
|
|
76
|
-
botpressHome: getHomeDir(props),
|
|
77
|
-
confirm: true,
|
|
78
|
-
...creds,
|
|
79
|
-
}
|
|
80
|
-
const botName = uuid.v4().replace(/-/g, '')
|
|
81
|
-
const botDir = pathlib.join(tmpDir, botName)
|
|
82
|
-
await impl.init({ ...argv, workDir: tmpDir, name: botName, type: 'bot' }).then(utils.handleExitCode)
|
|
83
|
-
await utils.fixBotpressDependencies({ workDir: botDir, target: dependencies })
|
|
84
|
-
await utils.npmInstall({ workDir: botDir }).then(utils.handleExitCode)
|
|
85
|
-
await fslib.promises.writeFile(pathlib.join(botDir, 'bot.definition.ts'), definitionFile)
|
|
86
|
-
return { botDir }
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// TODO: add an equivalent test with an interface once interfaces can be created by any workspace
|
|
90
|
-
|
|
91
|
-
export const addIntegration: Test = {
|
|
92
|
-
name: 'cli should allow installing an integration',
|
|
93
|
-
handler: async (props) => {
|
|
94
|
-
const { tmpDir, workspaceHandle, logger, ...creds } = props
|
|
95
|
-
const argv = {
|
|
96
|
-
...defaults,
|
|
97
|
-
botpressHome: getHomeDir({ tmpDir }),
|
|
98
|
-
confirm: true,
|
|
99
|
-
...creds,
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const bpClient = new client.Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
|
|
103
|
-
|
|
104
|
-
const integrationSuffix = uuid.v4().replace(/-/g, '')
|
|
105
|
-
const name = `myintegration${integrationSuffix}`
|
|
106
|
-
const integrationName = `${workspaceHandle}/${name}`
|
|
107
|
-
|
|
108
|
-
const createIntegrationBody = await apiUtils.prepareCreateIntegrationBody(
|
|
109
|
-
new sdk.IntegrationDefinition({
|
|
110
|
-
...INTEGRATION,
|
|
111
|
-
name: integrationName,
|
|
112
|
-
})
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
const { integration } = await bpClient.createIntegration({
|
|
116
|
-
...createIntegrationBody,
|
|
117
|
-
dev: true, // this way we ensure the integration will eventually be janitored if the test fails
|
|
118
|
-
url: creds.apiUrl,
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
logger.info('Initializing bot')
|
|
123
|
-
const { botDir } = await initBot(
|
|
124
|
-
props,
|
|
125
|
-
[
|
|
126
|
-
'import * as sdk from "@botpress/sdk"',
|
|
127
|
-
`import anIntegration from "./bp_modules/${workspaceHandle}-${name}"`,
|
|
128
|
-
'export default new sdk.BotDefinition({}).addIntegration(anIntegration, {',
|
|
129
|
-
' enabled: true,',
|
|
130
|
-
' configurationType: null,',
|
|
131
|
-
' configuration: {},',
|
|
132
|
-
'})',
|
|
133
|
-
].join('\n')
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
logger.info('Logging in')
|
|
137
|
-
await impl.login(argv).then(utils.handleExitCode)
|
|
138
|
-
|
|
139
|
-
logger.info('Installing integration')
|
|
140
|
-
await impl
|
|
141
|
-
.add({
|
|
142
|
-
...argv,
|
|
143
|
-
packageType: undefined,
|
|
144
|
-
installPath: botDir,
|
|
145
|
-
packageRef: integration.id,
|
|
146
|
-
useDev: false,
|
|
147
|
-
})
|
|
148
|
-
.then(utils.handleExitCode)
|
|
149
|
-
|
|
150
|
-
logger.info('Building bot')
|
|
151
|
-
await impl.build({ ...argv, workDir: botDir }).then(utils.handleExitCode)
|
|
152
|
-
await utils.tscCheck({ workDir: botDir }).then(utils.handleExitCode)
|
|
153
|
-
} finally {
|
|
154
|
-
await impl.integrations.subcommands
|
|
155
|
-
.delete({
|
|
156
|
-
...argv,
|
|
157
|
-
integrationRef: integration.id,
|
|
158
|
-
})
|
|
159
|
-
.catch(() => {
|
|
160
|
-
logger.warn(`Failed to delete integration ${integration.id}`) // this is not the purpose of the test
|
|
161
|
-
})
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Client } from '@botpress/client'
|
|
2
|
-
import * as sdk from '@botpress/sdk'
|
|
3
|
-
import fs from 'fs'
|
|
4
|
-
import pathlib from 'path'
|
|
5
|
-
import * as uuid from 'uuid'
|
|
6
|
-
import impl from '../../src/command-implementations'
|
|
7
|
-
import { fetchAllIntegrations, ApiIntegration } from '../api'
|
|
8
|
-
import defaults from '../defaults'
|
|
9
|
-
import { Test } from '../typings'
|
|
10
|
-
import * as utils from '../utils'
|
|
11
|
-
|
|
12
|
-
type SecretDef = NonNullable<sdk.IntegrationDefinitionProps['secrets']>
|
|
13
|
-
|
|
14
|
-
const fetchIntegration = async (client: Client, integrationName: string): Promise<ApiIntegration | undefined> => {
|
|
15
|
-
const integrations = await fetchAllIntegrations(client)
|
|
16
|
-
return integrations.find(({ name }) => name === integrationName)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const appendSecretDefinition = (originalTsContent: string, secrets: SecretDef): string => {
|
|
20
|
-
const regex = /( *)version: (['"].*['"]),/
|
|
21
|
-
const replacement = [
|
|
22
|
-
'version: $2,',
|
|
23
|
-
'secrets: {',
|
|
24
|
-
...Object.entries(secrets).map(([secretName, secretDef]) => ` ${secretName}: ${JSON.stringify(secretDef)},`),
|
|
25
|
-
'},',
|
|
26
|
-
]
|
|
27
|
-
.map((s) => `$1${s}`) // for indentation
|
|
28
|
-
.join('\n')
|
|
29
|
-
|
|
30
|
-
const modifiedTsContent = originalTsContent.replace(regex, replacement)
|
|
31
|
-
return modifiedTsContent
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const requiredSecrets: Test = {
|
|
35
|
-
name: 'cli should require required secrets',
|
|
36
|
-
handler: async ({ tmpDir, workspaceHandle, dependencies, ...creds }) => {
|
|
37
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
38
|
-
const baseDir = pathlib.join(tmpDir, 'integrations')
|
|
39
|
-
|
|
40
|
-
const integrationSuffix = uuid.v4().replace(/-/g, '')
|
|
41
|
-
const name = `myintegration${integrationSuffix}`
|
|
42
|
-
const integrationName = `${workspaceHandle}/${name}`
|
|
43
|
-
const integrationDirName = `${workspaceHandle}-${name}`
|
|
44
|
-
const integrationDir = pathlib.join(baseDir, integrationDirName)
|
|
45
|
-
|
|
46
|
-
const definitionPath = pathlib.join(integrationDir, 'integration.definition.ts')
|
|
47
|
-
|
|
48
|
-
const argv = {
|
|
49
|
-
...defaults,
|
|
50
|
-
botpressHome: botpressHomeDir,
|
|
51
|
-
confirm: true,
|
|
52
|
-
...creds,
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const client = new Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
|
|
56
|
-
|
|
57
|
-
await impl
|
|
58
|
-
.init({ ...argv, workDir: baseDir, name: integrationName, type: 'integration' })
|
|
59
|
-
.then(utils.handleExitCode)
|
|
60
|
-
|
|
61
|
-
const originalDefinition: string = fs.readFileSync(definitionPath, 'utf-8')
|
|
62
|
-
const modifiedDefinition = appendSecretDefinition(originalDefinition, {
|
|
63
|
-
REQUIRED_SECRET: {},
|
|
64
|
-
OPTIONAL_SECRET: { optional: true },
|
|
65
|
-
})
|
|
66
|
-
fs.writeFileSync(definitionPath, modifiedDefinition, 'utf-8')
|
|
67
|
-
await impl.build({ ...argv, workDir: integrationDir }).then(utils.handleExitCode)
|
|
68
|
-
|
|
69
|
-
await utils.fixBotpressDependencies({ workDir: integrationDir, target: dependencies })
|
|
70
|
-
await utils.npmInstall({ workDir: integrationDir }).then(utils.handleExitCode)
|
|
71
|
-
await impl.build({ ...argv, workDir: integrationDir }).then(utils.handleExitCode)
|
|
72
|
-
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
73
|
-
|
|
74
|
-
const { exitCode } = await impl.deploy({
|
|
75
|
-
...argv,
|
|
76
|
-
workDir: integrationDir,
|
|
77
|
-
secrets: ['OPTIONAL_SECRET=lol'],
|
|
78
|
-
botId: undefined,
|
|
79
|
-
createNewBot: undefined,
|
|
80
|
-
})
|
|
81
|
-
if (exitCode === 0) {
|
|
82
|
-
throw new Error('Expected deploy to fail')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
await impl
|
|
86
|
-
.deploy({
|
|
87
|
-
...argv,
|
|
88
|
-
workDir: integrationDir,
|
|
89
|
-
secrets: ['REQUIRED_SECRET=lol'],
|
|
90
|
-
botId: undefined,
|
|
91
|
-
createNewBot: undefined,
|
|
92
|
-
})
|
|
93
|
-
.then(utils.handleExitCode)
|
|
94
|
-
|
|
95
|
-
// cleanup deployed integration
|
|
96
|
-
const integration = await fetchIntegration(client, integrationName)
|
|
97
|
-
if (!integration) {
|
|
98
|
-
throw new Error(`Integration ${integrationName} should have been created`)
|
|
99
|
-
}
|
|
100
|
-
await client.deleteIntegration({ id: integration.id })
|
|
101
|
-
},
|
|
102
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Client } from '@botpress/client'
|
|
2
|
-
import pathlib from 'path'
|
|
3
|
-
import impl from '../../src/command-implementations'
|
|
4
|
-
import { ApiIntegration, fetchAllIntegrations } from '../api'
|
|
5
|
-
import defaults from '../defaults'
|
|
6
|
-
import { Test } from '../typings'
|
|
7
|
-
import * as utils from '../utils'
|
|
8
|
-
|
|
9
|
-
const fetchIntegration = async (client: Client, integrationName: string): Promise<ApiIntegration | undefined> => {
|
|
10
|
-
const integrations = await fetchAllIntegrations(client)
|
|
11
|
-
return integrations.find(({ name }) => name === integrationName)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const prependWorkspaceHandle: Test = {
|
|
15
|
-
name: 'cli should automatically preprend the workspace handle to the integration name when deploying',
|
|
16
|
-
handler: async ({ tmpDir, dependencies, workspaceHandle, logger, ...creds }) => {
|
|
17
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
18
|
-
const baseDir = pathlib.join(tmpDir, 'integrations')
|
|
19
|
-
|
|
20
|
-
const integrationSuffix = utils.getUUID()
|
|
21
|
-
const integrationName = `myintegration${integrationSuffix}`
|
|
22
|
-
const integrationDirName = integrationName
|
|
23
|
-
const integrationDir = pathlib.join(baseDir, integrationDirName)
|
|
24
|
-
|
|
25
|
-
const argv = {
|
|
26
|
-
...defaults,
|
|
27
|
-
botpressHome: botpressHomeDir,
|
|
28
|
-
confirm: true,
|
|
29
|
-
...creds,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const client = new Client({ apiUrl: creds.apiUrl, token: creds.token, workspaceId: creds.workspaceId })
|
|
33
|
-
|
|
34
|
-
await impl
|
|
35
|
-
.init({ ...argv, workDir: baseDir, name: integrationName, type: 'integration' })
|
|
36
|
-
.then(utils.handleExitCode)
|
|
37
|
-
await utils.fixBotpressDependencies({ workDir: integrationDir, target: dependencies })
|
|
38
|
-
await utils.npmInstall({ workDir: integrationDir }).then(utils.handleExitCode)
|
|
39
|
-
await impl.build({ ...argv, workDir: integrationDir }).then(utils.handleExitCode)
|
|
40
|
-
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
41
|
-
|
|
42
|
-
await impl
|
|
43
|
-
.deploy({ ...argv, createNewBot: undefined, botId: undefined, workDir: integrationDir })
|
|
44
|
-
.then(utils.handleExitCode)
|
|
45
|
-
|
|
46
|
-
logger.debug(`Fetching integration "${integrationName}"`)
|
|
47
|
-
let integration = await fetchIntegration(client, integrationName)
|
|
48
|
-
if (integration) {
|
|
49
|
-
throw new Error(`Integration ${integrationName} should not have been created`)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const expectedIntegrationName = `${workspaceHandle}/${integrationName}`
|
|
53
|
-
logger.debug(`Fetching integration "${expectedIntegrationName}"`)
|
|
54
|
-
integration = await fetchIntegration(client, expectedIntegrationName)
|
|
55
|
-
if (!integration) {
|
|
56
|
-
throw new Error(`Integration ${expectedIntegrationName} should have been created`)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
logger.debug(`Deleting integration "${integrationName}"`)
|
|
60
|
-
await impl.integrations.subcommands.delete({ ...argv, integrationRef: integration.id }).then(({ exitCode }) => {
|
|
61
|
-
exitCode !== 0 && logger.warn(`Failed to delete integration "${integrationName}"`) // not enough to fail the test
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const enforceWorkspaceHandle: Test = {
|
|
67
|
-
name: 'cli should fail when attempting to deploy an integration with incorrect workspace handle',
|
|
68
|
-
handler: async ({ tmpDir, dependencies, ...creds }) => {
|
|
69
|
-
const botpressHomeDir = pathlib.join(tmpDir, '.botpresshome')
|
|
70
|
-
const baseDir = pathlib.join(tmpDir, 'integrations')
|
|
71
|
-
|
|
72
|
-
const randomSuffix = utils.getUUID().slice(0, 8)
|
|
73
|
-
|
|
74
|
-
const name = 'myintegration'
|
|
75
|
-
const handle = `myhandle${randomSuffix}`
|
|
76
|
-
const integrationName = `${handle}/${name}`
|
|
77
|
-
const integrationDirName = `${handle}-${name}`
|
|
78
|
-
const integrationDir = pathlib.join(baseDir, integrationDirName)
|
|
79
|
-
|
|
80
|
-
const argv = {
|
|
81
|
-
...defaults,
|
|
82
|
-
botpressHome: botpressHomeDir,
|
|
83
|
-
confirm: true,
|
|
84
|
-
...creds,
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
await impl
|
|
88
|
-
.init({ ...argv, workDir: baseDir, name: integrationName, type: 'integration' })
|
|
89
|
-
.then(utils.handleExitCode)
|
|
90
|
-
await utils.fixBotpressDependencies({ workDir: integrationDir, target: dependencies })
|
|
91
|
-
await utils.npmInstall({ workDir: integrationDir }).then(utils.handleExitCode)
|
|
92
|
-
await impl.login({ ...argv }).then(utils.handleExitCode)
|
|
93
|
-
|
|
94
|
-
const { exitCode } = await impl.deploy({
|
|
95
|
-
...argv,
|
|
96
|
-
createNewBot: undefined,
|
|
97
|
-
botId: undefined,
|
|
98
|
-
workDir: integrationDir,
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
if (exitCode === 0) {
|
|
102
|
-
throw new Error(`Integration ${integrationName} should not have been deployed`)
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
}
|
package/e2e/typings.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@bpinternal/log4bot'
|
|
2
|
-
|
|
3
|
-
export type TestProps = {
|
|
4
|
-
logger: Logger
|
|
5
|
-
tmpDir: string
|
|
6
|
-
workspaceId: string
|
|
7
|
-
workspaceHandle: string
|
|
8
|
-
token: string
|
|
9
|
-
apiUrl: string
|
|
10
|
-
tunnelUrl: string
|
|
11
|
-
dependencies: Record<string, string | undefined>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Test = {
|
|
15
|
-
name: string
|
|
16
|
-
handler: (props: TestProps) => Promise<void>
|
|
17
|
-
}
|