@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,53 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var build_command_exports = {};
|
|
20
|
+
__export(build_command_exports, {
|
|
21
|
+
BuildCommand: () => BuildCommand
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(build_command_exports);
|
|
24
|
+
var import_bundle_command = require("./bundle-command");
|
|
25
|
+
var import_gen_command = require("./gen-command");
|
|
26
|
+
var import_project_command = require("./project-command");
|
|
27
|
+
class BuildCommand extends import_project_command.ProjectCommand {
|
|
28
|
+
async run() {
|
|
29
|
+
const t0 = Date.now();
|
|
30
|
+
const { type: projectType, definition: integrationDef } = await this.readProjectDefinitionFromFS();
|
|
31
|
+
if (projectType === "interface") {
|
|
32
|
+
this.logger.success("Interface projects have nothing to build.");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (integrationDef) {
|
|
36
|
+
await this._runGenerate();
|
|
37
|
+
}
|
|
38
|
+
await this._runBundle();
|
|
39
|
+
const dt = Date.now() - t0;
|
|
40
|
+
this.logger.log(`Build completed in ${dt}ms`);
|
|
41
|
+
}
|
|
42
|
+
_runGenerate() {
|
|
43
|
+
return new import_gen_command.GenerateCommand(this.api, this.prompt, this.logger, this.argv).run();
|
|
44
|
+
}
|
|
45
|
+
_runBundle() {
|
|
46
|
+
return new import_bundle_command.BundleCommand(this.api, this.prompt, this.logger, this.argv).run();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
BuildCommand
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=build-command.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/build-command.ts"],
|
|
4
|
+
"sourcesContent": ["import type commandDefinitions from '../command-definitions'\nimport { BundleCommand } from './bundle-command'\nimport { GenerateCommand } from './gen-command'\nimport { ProjectCommand } from './project-command'\n\nexport type BuildCommandDefinition = typeof commandDefinitions.build\nexport class BuildCommand extends ProjectCommand<BuildCommandDefinition> {\n public async run(): Promise<void> {\n const t0 = Date.now()\n const { type: projectType, definition: integrationDef } = await this.readProjectDefinitionFromFS()\n\n if (projectType === 'interface') {\n this.logger.success('Interface projects have nothing to build.')\n return\n }\n\n if (integrationDef) {\n await this._runGenerate()\n }\n\n await this._runBundle()\n const dt = Date.now() - t0\n this.logger.log(`Build completed in ${dt}ms`)\n }\n\n private _runGenerate() {\n return new GenerateCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n\n private _runBundle() {\n return new BundleCommand(this.api, this.prompt, this.logger, this.argv).run()\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAA8B;AAC9B,yBAAgC;AAChC,6BAA+B;AAGxB,MAAM,qBAAqB,sCAAuC;AAAA,EACvE,MAAa,MAAqB;AAChC,UAAM,KAAK,KAAK,IAAI;AACpB,UAAM,EAAE,MAAM,aAAa,YAAY,eAAe,IAAI,MAAM,KAAK,4BAA4B;AAEjG,QAAI,gBAAgB,aAAa;AAC/B,WAAK,OAAO,QAAQ,2CAA2C;AAC/D;AAAA,IACF;AAEA,QAAI,gBAAgB;AAClB,YAAM,KAAK,aAAa;AAAA,IAC1B;AAEA,UAAM,KAAK,WAAW;AACtB,UAAM,KAAK,KAAK,IAAI,IAAI;AACxB,SAAK,OAAO,IAAI,sBAAsB,MAAM;AAAA,EAC9C;AAAA,EAEQ,eAAe;AACrB,WAAO,IAAI,mCAAgB,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAChF;AAAA,EAEQ,aAAa;AACnB,WAAO,IAAI,oCAAc,KAAK,KAAK,KAAK,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE,IAAI;AAAA,EAC9E;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 bundle_command_exports = {};
|
|
30
|
+
__export(bundle_command_exports, {
|
|
31
|
+
BundleCommand: () => BundleCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(bundle_command_exports);
|
|
34
|
+
var import_chalk = __toESM(require("chalk"));
|
|
35
|
+
var errors = __toESM(require("../errors"));
|
|
36
|
+
var utils = __toESM(require("../utils"));
|
|
37
|
+
var import_project_command = require("./project-command");
|
|
38
|
+
class BundleCommand extends import_project_command.ProjectCommand {
|
|
39
|
+
async run() {
|
|
40
|
+
const projectDef = await this.readProjectDefinitionFromFS();
|
|
41
|
+
if (projectDef.type === "interface") {
|
|
42
|
+
this.logger.success("Interface projects have no implementation to bundle.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const line = this.logger.line();
|
|
46
|
+
if (projectDef.type === "integration") {
|
|
47
|
+
const { name } = projectDef.definition;
|
|
48
|
+
line.started(`Bundling integration ${import_chalk.default.bold(name)}...`);
|
|
49
|
+
return await this._bundle(line);
|
|
50
|
+
}
|
|
51
|
+
if (projectDef.type === "bot") {
|
|
52
|
+
line.started("Bundling bot...");
|
|
53
|
+
return await this._bundle(line);
|
|
54
|
+
}
|
|
55
|
+
if (projectDef.type === "plugin") {
|
|
56
|
+
line.started("Bundling plugin...");
|
|
57
|
+
return await this._bundle(line);
|
|
58
|
+
}
|
|
59
|
+
throw new errors.UnsupportedProjectType();
|
|
60
|
+
}
|
|
61
|
+
async _bundle(line, props = {}) {
|
|
62
|
+
const logLevel = this.argv.verbose ? "info" : "silent";
|
|
63
|
+
const abs = this.projectPaths.abs;
|
|
64
|
+
const rel = this.projectPaths.rel("workDir");
|
|
65
|
+
const unixPath = utils.path.toUnix(rel.entryPoint);
|
|
66
|
+
const importFrom = utils.path.rmExtension(unixPath);
|
|
67
|
+
const code = `import x from './${importFrom}'; export default x; export const handler = x.handler;`;
|
|
68
|
+
const outfile = abs.outFile;
|
|
69
|
+
line.debug(`Writing bundle to ${outfile}`);
|
|
70
|
+
await utils.esbuild.buildCode({
|
|
71
|
+
code,
|
|
72
|
+
cwd: abs.workDir,
|
|
73
|
+
outfile,
|
|
74
|
+
logLevel,
|
|
75
|
+
write: true,
|
|
76
|
+
sourcemap: this.argv.sourceMap,
|
|
77
|
+
minify: this.argv.minify,
|
|
78
|
+
...props
|
|
79
|
+
});
|
|
80
|
+
line.success(`Bundle available at ${import_chalk.default.grey(rel.outDir)}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
BundleCommand
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=bundle-command.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/bundle-command.ts"],
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport { SingleLineLogger } from 'src/logger'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { ProjectCommand } from './project-command'\n\nexport type BundleCommandDefinition = typeof commandDefinitions.bundle\nexport class BundleCommand extends ProjectCommand<BundleCommandDefinition> {\n public async run(): Promise<void> {\n const projectDef = await this.readProjectDefinitionFromFS()\n\n if (projectDef.type === 'interface') {\n this.logger.success('Interface projects have no implementation to bundle.')\n return\n }\n\n const line = this.logger.line()\n\n if (projectDef.type === 'integration') {\n const { name } = projectDef.definition\n line.started(`Bundling integration ${chalk.bold(name)}...`)\n return await this._bundle(line)\n }\n\n if (projectDef.type === 'bot') {\n line.started('Bundling bot...')\n return await this._bundle(line)\n }\n\n if (projectDef.type === 'plugin') {\n line.started('Bundling plugin...')\n return await this._bundle(line)\n }\n\n throw new errors.UnsupportedProjectType()\n }\n\n private async _bundle(line: SingleLineLogger, props: Partial<utils.esbuild.BuildCodeProps> = {}) {\n const logLevel = this.argv.verbose ? 'info' : 'silent'\n const abs = this.projectPaths.abs\n const rel = this.projectPaths.rel('workDir')\n\n const unixPath = utils.path.toUnix(rel.entryPoint)\n const importFrom = utils.path.rmExtension(unixPath)\n const code = `import x from './${importFrom}'; export default x; export const handler = x.handler;`\n\n const outfile = abs.outFile // TODO: ensure dir exists\n line.debug(`Writing bundle to ${outfile}`)\n\n await utils.esbuild.buildCode({\n code,\n cwd: abs.workDir,\n outfile,\n logLevel,\n write: true,\n sourcemap: this.argv.sourceMap,\n minify: this.argv.minify,\n ...props,\n })\n\n line.success(`Bundle available at ${chalk.grey(rel.outDir)}`)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAGlB,aAAwB;AACxB,YAAuB;AACvB,6BAA+B;AAGxB,MAAM,sBAAsB,sCAAwC;AAAA,EACzE,MAAa,MAAqB;AAChC,UAAM,aAAa,MAAM,KAAK,4BAA4B;AAE1D,QAAI,WAAW,SAAS,aAAa;AACnC,WAAK,OAAO,QAAQ,sDAAsD;AAC1E;AAAA,IACF;AAEA,UAAM,OAAO,KAAK,OAAO,KAAK;AAE9B,QAAI,WAAW,SAAS,eAAe;AACrC,YAAM,EAAE,KAAK,IAAI,WAAW;AAC5B,WAAK,QAAQ,wBAAwB,aAAAA,QAAM,KAAK,IAAI,MAAM;AAC1D,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,QAAI,WAAW,SAAS,OAAO;AAC7B,WAAK,QAAQ,iBAAiB;AAC9B,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,QAAI,WAAW,SAAS,UAAU;AAChC,WAAK,QAAQ,oBAAoB;AACjC,aAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,IAChC;AAEA,UAAM,IAAI,OAAO,uBAAuB;AAAA,EAC1C;AAAA,EAEA,MAAc,QAAQ,MAAwB,QAA+C,CAAC,GAAG;AAC/F,UAAM,WAAW,KAAK,KAAK,UAAU,SAAS;AAC9C,UAAM,MAAM,KAAK,aAAa;AAC9B,UAAM,MAAM,KAAK,aAAa,IAAI,SAAS;AAE3C,UAAM,WAAW,MAAM,KAAK,OAAO,IAAI,UAAU;AACjD,UAAM,aAAa,MAAM,KAAK,YAAY,QAAQ;AAClD,UAAM,OAAO,oBAAoB;AAEjC,UAAM,UAAU,IAAI;AACpB,SAAK,MAAM,qBAAqB,SAAS;AAEzC,UAAM,MAAM,QAAQ,UAAU;AAAA,MAC5B;AAAA,MACA,KAAK,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP,WAAW,KAAK,KAAK;AAAA,MACrB,QAAQ,KAAK,KAAK;AAAA,MAClB,GAAG;AAAA,IACL,CAAC;AAED,SAAK,QAAQ,uBAAuB,aAAAA,QAAM,KAAK,IAAI,MAAM,GAAG;AAAA,EAC9D;AACF;",
|
|
6
|
+
"names": ["chalk"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
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 chat_command_exports = {};
|
|
30
|
+
__export(chat_command_exports, {
|
|
31
|
+
ChatCommand: () => ChatCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(chat_command_exports);
|
|
34
|
+
var chat = __toESM(require("@botpress/chat"));
|
|
35
|
+
var import_semver = __toESM(require("semver"));
|
|
36
|
+
var import_chat = require("../chat");
|
|
37
|
+
var consts = __toESM(require("../consts"));
|
|
38
|
+
var errors = __toESM(require("../errors"));
|
|
39
|
+
var utils = __toESM(require("../utils"));
|
|
40
|
+
var import_global_command = require("./global-command");
|
|
41
|
+
class ChatCommand extends import_global_command.GlobalCommand {
|
|
42
|
+
async run() {
|
|
43
|
+
if (process.platform === "win32") {
|
|
44
|
+
this.logger.warn("The chat command was not tested on Windows and may not work as expected");
|
|
45
|
+
}
|
|
46
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
47
|
+
const botId = this.argv.botId ?? await this._selectBot(api);
|
|
48
|
+
const { bot } = await api.client.getBot({ id: botId }).catch((thrown) => {
|
|
49
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not fetch bot "${botId}"`);
|
|
50
|
+
});
|
|
51
|
+
const targetChatVersion = this._getChatApiTargetVersionRange();
|
|
52
|
+
let chatIntegrationInstance = this._findChatInstance(bot);
|
|
53
|
+
if (!chatIntegrationInstance) {
|
|
54
|
+
this.logger.log(`Chat integration with version ${targetChatVersion} is not installed in the selected bot`);
|
|
55
|
+
const confirmInstall = await this.prompt.confirm("Do you wish to install it now?");
|
|
56
|
+
if (!confirmInstall) {
|
|
57
|
+
throw new errors.BotpressCLIError("Chat integration is required to proceed");
|
|
58
|
+
}
|
|
59
|
+
chatIntegrationInstance = await this._installChatIntegration(api, botId);
|
|
60
|
+
}
|
|
61
|
+
const { webhookId } = chatIntegrationInstance.instance;
|
|
62
|
+
const chatApiBaseUrl = this._getChatApiUrl(api);
|
|
63
|
+
this.logger.debug(`using chat api url: "${chatApiBaseUrl}"`);
|
|
64
|
+
const chatApiUrl = `${chatApiBaseUrl}/${webhookId}`;
|
|
65
|
+
const chatClient = await chat.Client.connect({ apiUrl: chatApiUrl });
|
|
66
|
+
await this._chat(chatClient);
|
|
67
|
+
}
|
|
68
|
+
_chat = async (client2) => {
|
|
69
|
+
const convLine = this.logger.line();
|
|
70
|
+
convLine.started("Creating a conversation...");
|
|
71
|
+
const { conversation } = await client2.createConversation({});
|
|
72
|
+
convLine.success(`Conversation created with id "${conversation.id}"`);
|
|
73
|
+
convLine.commit();
|
|
74
|
+
const chat2 = import_chat.Chat.launch({ client: client2, conversationId: conversation.id });
|
|
75
|
+
await chat2.wait();
|
|
76
|
+
};
|
|
77
|
+
_getChatApiUrl = (api) => {
|
|
78
|
+
if (this.argv.chatApiUrl) {
|
|
79
|
+
return this.argv.chatApiUrl;
|
|
80
|
+
}
|
|
81
|
+
const parseResult = utils.url.parse(api.url);
|
|
82
|
+
if (parseResult.status === "error") {
|
|
83
|
+
return consts.defaultChatApiUrl;
|
|
84
|
+
}
|
|
85
|
+
const { host, ...url } = parseResult.url;
|
|
86
|
+
if (!host.startsWith("api.")) {
|
|
87
|
+
return consts.defaultChatApiUrl;
|
|
88
|
+
}
|
|
89
|
+
const newHost = host.replace("api.", "chat.");
|
|
90
|
+
return utils.url.format({ ...url, host: newHost });
|
|
91
|
+
};
|
|
92
|
+
_selectBot = async (api) => {
|
|
93
|
+
const availableBots = await api.listAllPages(api.client.listBots, (r) => r.bots).catch((thrown) => {
|
|
94
|
+
throw errors.BotpressCLIError.wrap(thrown, "Could not fetch existing bots");
|
|
95
|
+
});
|
|
96
|
+
if (!availableBots.length) {
|
|
97
|
+
throw new errors.NoBotsFoundError();
|
|
98
|
+
}
|
|
99
|
+
const prompted = await this.prompt.select("Which bot do you want to deploy?", {
|
|
100
|
+
choices: availableBots.map((bot) => ({ title: bot.name, value: bot.id }))
|
|
101
|
+
});
|
|
102
|
+
if (!prompted) {
|
|
103
|
+
throw new errors.ParamRequiredError("Bot Id");
|
|
104
|
+
}
|
|
105
|
+
return prompted;
|
|
106
|
+
};
|
|
107
|
+
_installChatIntegration = async (api, botId) => {
|
|
108
|
+
const line = this.logger.line();
|
|
109
|
+
line.started("Installing chat integration...");
|
|
110
|
+
const { integration } = await api.client.getPublicIntegration({
|
|
111
|
+
name: "chat",
|
|
112
|
+
version: this._getChatApiTargetVersion()
|
|
113
|
+
});
|
|
114
|
+
const { bot } = await api.client.updateBot({
|
|
115
|
+
id: botId,
|
|
116
|
+
integrations: {
|
|
117
|
+
[integration.id]: {
|
|
118
|
+
enabled: true,
|
|
119
|
+
configuration: {}
|
|
120
|
+
// empty object will always be a valid chat integration configuration
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
line.success("Chat integration installed");
|
|
125
|
+
line.commit();
|
|
126
|
+
return this._findChatInstance(bot);
|
|
127
|
+
};
|
|
128
|
+
_findChatInstance = (bot) => {
|
|
129
|
+
const integrationInstances = Object.entries(bot.integrations).map(([integrationId, integrationInstance]) => ({
|
|
130
|
+
id: integrationId,
|
|
131
|
+
instance: integrationInstance
|
|
132
|
+
}));
|
|
133
|
+
const targetChatVersion = this._getChatApiTargetVersionRange();
|
|
134
|
+
return integrationInstances.find(
|
|
135
|
+
(i) => i.instance.name === "chat" && import_semver.default.satisfies(i.instance.version, targetChatVersion)
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
_getChatApiTargetVersionRange = () => {
|
|
139
|
+
const targetApiVersion = this._getChatApiTargetVersion();
|
|
140
|
+
const nextMajor = import_semver.default.inc(targetApiVersion, "major");
|
|
141
|
+
return `>=${targetApiVersion} <${nextMajor}`;
|
|
142
|
+
};
|
|
143
|
+
_getChatApiTargetVersion = () => {
|
|
144
|
+
const dummyClient = new chat.Client({ apiUrl: "" });
|
|
145
|
+
return dummyClient.apiVersion;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
+
0 && (module.exports = {
|
|
150
|
+
ChatCommand
|
|
151
|
+
});
|
|
152
|
+
//# sourceMappingURL=chat-command.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/chat-command.ts"],
|
|
4
|
+
"sourcesContent": ["import * as chat from '@botpress/chat'\nimport * as client from '@botpress/client'\nimport semver from 'semver'\nimport { ApiClient } from '../api'\nimport { Chat } from '../chat'\nimport type commandDefinitions from '../command-definitions'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport * as utils from '../utils'\nimport { GlobalCommand } from './global-command'\n\ntype IntegrationInstance = {\n id: string\n instance: client.Bot['integrations'][string]\n}\n\nexport type ChatCommandDefinition = typeof commandDefinitions.chat\nexport class ChatCommand extends GlobalCommand<ChatCommandDefinition> {\n public async run(): Promise<void> {\n if (process.platform === 'win32') {\n this.logger.warn('The chat command was not tested on Windows and may not work as expected')\n }\n\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const botId = this.argv.botId ?? (await this._selectBot(api))\n const { bot } = await api.client.getBot({ id: botId }).catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, `Could not fetch bot \"${botId}\"`)\n })\n\n const targetChatVersion = this._getChatApiTargetVersionRange()\n let chatIntegrationInstance = this._findChatInstance(bot)\n\n if (!chatIntegrationInstance) {\n this.logger.log(`Chat integration with version ${targetChatVersion} is not installed in the selected bot`)\n const confirmInstall = await this.prompt.confirm('Do you wish to install it now?')\n if (!confirmInstall) {\n throw new errors.BotpressCLIError('Chat integration is required to proceed')\n }\n chatIntegrationInstance = await this._installChatIntegration(api, botId)\n }\n\n const { webhookId } = chatIntegrationInstance.instance\n const chatApiBaseUrl = this._getChatApiUrl(api)\n this.logger.debug(`using chat api url: \"${chatApiBaseUrl}\"`)\n\n const chatApiUrl = `${chatApiBaseUrl}/${webhookId}`\n const chatClient = await chat.Client.connect({ apiUrl: chatApiUrl })\n await this._chat(chatClient)\n }\n\n private _chat = async (client: chat.AuthenticatedClient): Promise<void> => {\n const convLine = this.logger.line()\n convLine.started('Creating a conversation...')\n const { conversation } = await client.createConversation({})\n convLine.success(`Conversation created with id \"${conversation.id}\"`)\n convLine.commit()\n\n const chat = Chat.launch({ client, conversationId: conversation.id })\n await chat.wait()\n }\n\n private _getChatApiUrl = (api: ApiClient): string => {\n if (this.argv.chatApiUrl) {\n return this.argv.chatApiUrl\n }\n\n const parseResult = utils.url.parse(api.url)\n if (parseResult.status === 'error') {\n return consts.defaultChatApiUrl\n }\n\n const { host, ...url } = parseResult.url\n if (!host.startsWith('api.')) {\n return consts.defaultChatApiUrl\n }\n\n const newHost = host.replace('api.', 'chat.')\n return utils.url.format({ ...url, host: newHost })\n }\n\n private _selectBot = async (api: ApiClient): Promise<string> => {\n const availableBots = await api\n .listAllPages(api.client.listBots, (r) => r.bots)\n .catch((thrown) => {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not fetch existing bots')\n })\n\n if (!availableBots.length) {\n throw new errors.NoBotsFoundError()\n }\n\n const prompted = await this.prompt.select('Which bot do you want to deploy?', {\n choices: availableBots.map((bot) => ({ title: bot.name, value: bot.id })),\n })\n\n if (!prompted) {\n throw new errors.ParamRequiredError('Bot Id')\n }\n\n return prompted\n }\n\n private _installChatIntegration = async (api: ApiClient, botId: string): Promise<IntegrationInstance> => {\n const line = this.logger.line()\n line.started('Installing chat integration...')\n\n const { integration } = await api.client.getPublicIntegration({\n name: 'chat',\n version: this._getChatApiTargetVersion(),\n })\n\n const { bot } = await api.client.updateBot({\n id: botId,\n integrations: {\n [integration.id]: {\n enabled: true,\n configuration: {}, // empty object will always be a valid chat integration configuration\n },\n },\n })\n\n line.success('Chat integration installed')\n line.commit()\n\n return this._findChatInstance(bot)!\n }\n\n private _findChatInstance = (bot: client.Bot): IntegrationInstance | undefined => {\n const integrationInstances = Object.entries(bot.integrations).map(([integrationId, integrationInstance]) => ({\n id: integrationId,\n instance: integrationInstance,\n }))\n\n const targetChatVersion = this._getChatApiTargetVersionRange()\n return integrationInstances.find(\n (i) => i.instance.name === 'chat' && semver.satisfies(i.instance.version, targetChatVersion)\n )\n }\n\n private _getChatApiTargetVersionRange = (): string => {\n const targetApiVersion = this._getChatApiTargetVersion()\n const nextMajor = semver.inc(targetApiVersion, 'major')\n return `>=${targetApiVersion} <${nextMajor}`\n }\n\n private _getChatApiTargetVersion = (): string => {\n const dummyClient = new chat.Client({ apiUrl: '' })\n return dummyClient.apiVersion\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["client", "chat", "semver"]
|
|
7
|
+
}
|