@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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/global-command.ts"],
|
|
4
|
+
"sourcesContent": ["import type { YargsConfig } from '@bpinternal/yargs-extra'\nimport chalk from 'chalk'\nimport latestVersion from 'latest-version'\nimport _ from 'lodash'\nimport semver from 'semver'\nimport type { ApiClientFactory } from '../api/client'\nimport type * as config from '../config'\nimport * as consts from '../consts'\nimport * as errors from '../errors'\nimport type { CommandArgv, CommandDefinition } from '../typings'\nimport * as utils from '../utils'\nimport { BaseCommand } from './base-command'\n\nexport type GlobalCommandDefinition = CommandDefinition<typeof config.schemas.global>\nexport type GlobalCache = { apiUrl: string; token: string; workspaceId: string }\n\nexport type ConfigurableGlobalPaths = { botpressHomeDir: string; cliRootDir: utils.path.AbsolutePath }\nexport type ConstantGlobalPaths = typeof consts.fromHomeDir & typeof consts.fromCliRootDir\nexport type AllGlobalPaths = ConfigurableGlobalPaths & ConstantGlobalPaths\n\nclass GlobalPaths extends utils.path.PathStore<keyof AllGlobalPaths> {\n public constructor(argv: CommandArgv<GlobalCommandDefinition>) {\n const absBotpressHome = utils.path.absoluteFrom(utils.path.cwd(), argv.botpressHome)\n super({\n cliRootDir: consts.cliRootDir,\n botpressHomeDir: absBotpressHome,\n ..._.mapValues(consts.fromHomeDir, (p) => utils.path.absoluteFrom(absBotpressHome, p)),\n ..._.mapValues(consts.fromCliRootDir, (p) => utils.path.absoluteFrom(consts.cliRootDir, p)),\n })\n }\n}\n\nexport abstract class GlobalCommand<C extends GlobalCommandDefinition> extends BaseCommand<C> {\n protected api: ApiClientFactory\n protected prompt: utils.prompt.CLIPrompt\n private _pkgJson: utils.pkgJson.PackageJson | undefined\n\n public constructor(\n api: ApiClientFactory,\n prompt: utils.prompt.CLIPrompt,\n ...args: ConstructorParameters<typeof BaseCommand<C>>\n ) {\n super(...args)\n this.api = api\n this.prompt = prompt\n }\n\n protected get globalPaths() {\n return new GlobalPaths(this.argv)\n }\n\n protected get globalCache() {\n return new utils.cache.FSKeyValueCache<GlobalCache>(this.globalPaths.abs.globalCacheFile)\n }\n\n protected override async bootstrap() {\n const pkgJson = await this.readPkgJson()\n const versionText = chalk.bold(`v${pkgJson.version}`)\n this.logger.log(`Botpress CLI ${versionText}`, { prefix: '\uD83E\uDD16' })\n\n await this._notifyUpdateCli()\n\n const paths = this.globalPaths\n if (paths.abs.botpressHomeDir !== consts.defaultBotpressHome) {\n this.logger.log(`Using custom botpress home: ${paths.abs.botpressHomeDir}`, { prefix: '\uD83C\uDFE0' })\n }\n }\n\n protected override teardown = async () => {\n this.logger.cleanup()\n }\n\n protected async ensureLoginAndCreateClient(credentials: YargsConfig<typeof config.schemas.credentials>) {\n const cache = this.globalCache\n const token = await cache.get('token')\n const workspaceId = credentials.workspaceId ?? (await cache.get('workspaceId'))\n const apiUrl = credentials.apiUrl ?? (await cache.get('apiUrl'))\n\n if (!(token && workspaceId && apiUrl)) {\n throw new errors.NotLoggedInError()\n }\n\n if (apiUrl !== consts.defaultBotpressApiUrl) {\n this.logger.log(`Using custom url ${apiUrl}`, { prefix: '\uD83D\uDD17' })\n }\n\n return this.api.newClient({ apiUrl, token, workspaceId }, this.logger)\n }\n\n private _notifyUpdateCli = async (): Promise<void> => {\n try {\n this.logger.debug('Checking if cli is up to date')\n\n const pkgJson = await this.readPkgJson()\n if (!pkgJson.version) {\n throw new errors.BotpressCLIError('Could not find version in package.json')\n }\n\n const latest = await latestVersion(pkgJson.name)\n const isOutdated = semver.lt(pkgJson.version, latest)\n if (isOutdated) {\n this.logger.box(\n [\n `${chalk.bold('Update available')} ${chalk.dim(pkgJson.version)} \u2192 ${chalk.green(latest)}`,\n '',\n 'To update, run:',\n ` for npm ${chalk.cyan(`npm i -g ${pkgJson.name}`)}`,\n ` for yarn ${chalk.cyan(`yarn global add ${pkgJson.name}`)}`,\n ` for pnpm ${chalk.cyan(`pnpm i -g ${pkgJson.name}`)}`,\n ].join('\\n')\n )\n }\n } catch (thrown) {\n const err = errors.BotpressCLIError.map(thrown)\n this.logger.debug(`Failed to check if cli is up to date: ${err.message}`)\n }\n }\n\n protected async readPkgJson(): Promise<utils.pkgJson.PackageJson> {\n if (this._pkgJson) {\n return this._pkgJson\n }\n const { cliRootDir } = this.globalPaths.abs\n const pkgJson = await utils.pkgJson.readPackageJson(cliRootDir)\n if (!pkgJson) {\n throw new errors.BotpressCLIError(`Could not find package.json at \"${cliRootDir}\"`)\n }\n\n this._pkgJson = pkgJson\n return pkgJson\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AACl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AAM;AAAA,UACtD,EAAE,KAAK,IAAI;AAAA,QACb;AAAA,MACF;AAAA,IACF,SAAS,QAAP;AACA,YAAM,MAAM,OAAO,iBAAiB,IAAI,MAAM;AAC9C,WAAK,OAAO,MAAM,yCAAyC,IAAI,SAAS;AAAA,IAC1E;AAAA,EACF;AAAA,EAEA,MAAgB,cAAkD;AAChE,QAAI,KAAK,UAAU;AACjB,aAAO,KAAK;AAAA,IACd;AACA,UAAM,EAAE,WAAW,IAAI,KAAK,YAAY;AACxC,UAAM,UAAU,MAAM,MAAM,QAAQ,gBAAgB,UAAU;AAC9D,QAAI,CAAC,SAAS;AACZ,YAAM,IAAI,OAAO,iBAAiB,mCAAmC,aAAa;AAAA,IACpF;AAEA,SAAK,WAAW;AAChB,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["_", "chalk", "latestVersion", "semver"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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 command_implementations_exports = {};
|
|
30
|
+
__export(command_implementations_exports, {
|
|
31
|
+
default: () => command_implementations_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(command_implementations_exports);
|
|
34
|
+
var import_client = require("../api/client");
|
|
35
|
+
var import_logger = require("../logger");
|
|
36
|
+
var utils = __toESM(require("../utils"));
|
|
37
|
+
var import_add_command = require("./add-command");
|
|
38
|
+
var bots = __toESM(require("./bot-commands"));
|
|
39
|
+
var import_build_command = require("./build-command");
|
|
40
|
+
var import_bundle_command = require("./bundle-command");
|
|
41
|
+
var import_chat_command = require("./chat-command");
|
|
42
|
+
var import_deploy_command = require("./deploy-command");
|
|
43
|
+
var import_dev_command = require("./dev-command");
|
|
44
|
+
var import_gen_command = require("./gen-command");
|
|
45
|
+
var import_init_command = require("./init-command");
|
|
46
|
+
var integrations = __toESM(require("./integration-commands"));
|
|
47
|
+
var interfaces = __toESM(require("./interface-commands"));
|
|
48
|
+
var import_lint_command = require("./lint-command");
|
|
49
|
+
var import_login_command = require("./login-command");
|
|
50
|
+
var import_logout_command = require("./logout-command");
|
|
51
|
+
var plugins = __toESM(require("./plugin-commands"));
|
|
52
|
+
var import_read_command = require("./read-command");
|
|
53
|
+
var import_serve_command = require("./serve-command");
|
|
54
|
+
const getHandler = (cls) => async (argv) => {
|
|
55
|
+
const logger = new import_logger.Logger(argv);
|
|
56
|
+
const prompt = new utils.prompt.CLIPrompt(argv, logger);
|
|
57
|
+
return new cls(import_client.ApiClient, prompt, logger, argv).handler();
|
|
58
|
+
};
|
|
59
|
+
var command_implementations_default = {
|
|
60
|
+
login: getHandler(import_login_command.LoginCommand),
|
|
61
|
+
logout: getHandler(import_logout_command.LogoutCommand),
|
|
62
|
+
bots: {
|
|
63
|
+
subcommands: {
|
|
64
|
+
create: getHandler(bots.CreateBotCommand),
|
|
65
|
+
get: getHandler(bots.GetBotCommand),
|
|
66
|
+
delete: getHandler(bots.DeleteBotCommand),
|
|
67
|
+
list: getHandler(bots.ListBotsCommand)
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
integrations: {
|
|
71
|
+
subcommands: {
|
|
72
|
+
get: getHandler(integrations.GetIntegrationCommand),
|
|
73
|
+
list: getHandler(integrations.ListIntegrationsCommand),
|
|
74
|
+
delete: getHandler(integrations.DeleteIntegrationCommand)
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
interfaces: {
|
|
78
|
+
subcommands: {
|
|
79
|
+
get: getHandler(interfaces.GetInterfaceCommand),
|
|
80
|
+
list: getHandler(interfaces.ListInterfacesCommand),
|
|
81
|
+
delete: getHandler(interfaces.DeleteInterfaceCommand)
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
plugins: {
|
|
85
|
+
subcommands: {
|
|
86
|
+
get: getHandler(plugins.GetPluginCommand),
|
|
87
|
+
list: getHandler(plugins.ListPluginsCommand),
|
|
88
|
+
delete: getHandler(plugins.DeletePluginCommand)
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
init: getHandler(import_init_command.InitCommand),
|
|
92
|
+
generate: getHandler(import_gen_command.GenerateCommand),
|
|
93
|
+
bundle: getHandler(import_bundle_command.BundleCommand),
|
|
94
|
+
build: getHandler(import_build_command.BuildCommand),
|
|
95
|
+
read: getHandler(import_read_command.ReadCommand),
|
|
96
|
+
serve: getHandler(import_serve_command.ServeCommand),
|
|
97
|
+
deploy: getHandler(import_deploy_command.DeployCommand),
|
|
98
|
+
add: getHandler(import_add_command.AddCommand),
|
|
99
|
+
dev: getHandler(import_dev_command.DevCommand),
|
|
100
|
+
lint: getHandler(import_lint_command.LintCommand),
|
|
101
|
+
chat: getHandler(import_chat_command.ChatCommand)
|
|
102
|
+
};
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {});
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { ApiClient } from '../api/client'\nimport type commandDefinitions from '../command-definitions'\nimport type { ImplementationTree } from '../command-tree'\nimport { Logger } from '../logger'\nimport type { CommandArgv } from '../typings'\nimport * as utils from '../utils'\nimport { AddCommand } from './add-command'\nimport type { BaseCommand } from './base-command'\nimport * as bots from './bot-commands'\nimport { BuildCommand } from './build-command'\nimport { BundleCommand } from './bundle-command'\nimport { ChatCommand } from './chat-command'\nimport { DeployCommand } from './deploy-command'\nimport { DevCommand } from './dev-command'\nimport { GenerateCommand } from './gen-command'\nimport type { GlobalCommand, GlobalCommandDefinition } from './global-command'\nimport { InitCommand } from './init-command'\nimport * as integrations from './integration-commands'\nimport * as interfaces from './interface-commands'\nimport { LintCommand } from './lint-command'\nimport { LoginCommand } from './login-command'\nimport { LogoutCommand } from './logout-command'\nimport * as plugins from './plugin-commands'\nimport { ReadCommand } from './read-command'\nimport { ServeCommand } from './serve-command'\n\ntype GlobalCtor<C extends GlobalCommandDefinition> = new (\n ...args: ConstructorParameters<typeof GlobalCommand<C>>\n) => BaseCommand<C>\n\nconst getHandler =\n <C extends GlobalCommandDefinition>(cls: GlobalCtor<C>) =>\n async (argv: CommandArgv<C>) => {\n const logger = new Logger(argv)\n const prompt = new utils.prompt.CLIPrompt(argv, logger)\n return new cls(ApiClient, prompt, logger, argv).handler()\n }\n\nexport default {\n login: getHandler(LoginCommand),\n logout: getHandler(LogoutCommand),\n bots: {\n subcommands: {\n create: getHandler(bots.CreateBotCommand),\n get: getHandler(bots.GetBotCommand),\n delete: getHandler(bots.DeleteBotCommand),\n list: getHandler(bots.ListBotsCommand),\n },\n },\n integrations: {\n subcommands: {\n get: getHandler(integrations.GetIntegrationCommand),\n list: getHandler(integrations.ListIntegrationsCommand),\n delete: getHandler(integrations.DeleteIntegrationCommand),\n },\n },\n interfaces: {\n subcommands: {\n get: getHandler(interfaces.GetInterfaceCommand),\n list: getHandler(interfaces.ListInterfacesCommand),\n delete: getHandler(interfaces.DeleteInterfaceCommand),\n },\n },\n plugins: {\n subcommands: {\n get: getHandler(plugins.GetPluginCommand),\n list: getHandler(plugins.ListPluginsCommand),\n delete: getHandler(plugins.DeletePluginCommand),\n },\n },\n init: getHandler(InitCommand),\n generate: getHandler(GenerateCommand),\n bundle: getHandler(BundleCommand),\n build: getHandler(BuildCommand),\n read: getHandler(ReadCommand),\n serve: getHandler(ServeCommand),\n deploy: getHandler(DeployCommand),\n add: getHandler(AddCommand),\n dev: getHandler(DevCommand),\n lint: getHandler(LintCommand),\n chat: getHandler(ChatCommand),\n} satisfies ImplementationTree<typeof commandDefinitions>\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0B;AAG1B,oBAAuB;AAEvB,YAAuB;AACvB,yBAA2B;AAE3B,WAAsB;AACtB,2BAA6B;AAC7B,4BAA8B;AAC9B,0BAA4B;AAC5B,4BAA8B;AAC9B,yBAA2B;AAC3B,yBAAgC;AAEhC,0BAA4B;AAC5B,mBAA8B;AAC9B,iBAA4B;AAC5B,0BAA4B;AAC5B,2BAA6B;AAC7B,4BAA8B;AAC9B,cAAyB;AACzB,0BAA4B;AAC5B,2BAA6B;AAM7B,MAAM,aACJ,CAAoC,QACpC,OAAO,SAAyB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W,6BAAU;AAAA,EAC1B,KAAK,WAAW,6BAAU;AAAA,EAC1B,MAAM,WAAW,+BAAW;AAAA,EAC5B,MAAM,WAAW,+BAAW;AAC9B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
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 init_command_exports = {};
|
|
30
|
+
__export(init_command_exports, {
|
|
31
|
+
InitCommand: () => InitCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(init_command_exports);
|
|
34
|
+
var import_chalk = __toESM(require("chalk"));
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
36
|
+
var pathlib = __toESM(require("path"));
|
|
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
|
+
const projectTypes = ["bot", "integration", "plugin"];
|
|
42
|
+
class InitCommand extends import_global_command.GlobalCommand {
|
|
43
|
+
async run() {
|
|
44
|
+
let { type: projectType } = this.argv;
|
|
45
|
+
if (!projectType) {
|
|
46
|
+
const promptedType = await this.prompt.select("What type of project do you wish to initialize?", {
|
|
47
|
+
choices: projectTypes.map((t) => ({ title: t, value: t }))
|
|
48
|
+
});
|
|
49
|
+
if (!promptedType) {
|
|
50
|
+
throw new errors.ParamRequiredError("Project Type");
|
|
51
|
+
}
|
|
52
|
+
projectType = promptedType;
|
|
53
|
+
}
|
|
54
|
+
const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir);
|
|
55
|
+
if (projectType === "bot") {
|
|
56
|
+
await this._initBot({ workDir });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (projectType === "integration") {
|
|
60
|
+
await this._initIntegration({ workDir });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (projectType === "plugin") {
|
|
64
|
+
await this._initPlugin({ workDir });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`);
|
|
68
|
+
}
|
|
69
|
+
_initPlugin = async (args) => {
|
|
70
|
+
const { workDir } = args;
|
|
71
|
+
const name = await this._getName("plugin", consts.emptyPluginDirName);
|
|
72
|
+
await this._copy({
|
|
73
|
+
srcDir: this.globalPaths.abs.emptyPluginTemplate,
|
|
74
|
+
destDir: workDir,
|
|
75
|
+
name,
|
|
76
|
+
pkgJson: {
|
|
77
|
+
pluginName: name
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
this.logger.success(`Plugin project initialized in ${import_chalk.default.bold(workDir)}`);
|
|
81
|
+
};
|
|
82
|
+
_initBot = async (args) => {
|
|
83
|
+
const { workDir } = args;
|
|
84
|
+
const name = await this._getName("bot", consts.emptyBotDirName);
|
|
85
|
+
await this._copy({ srcDir: this.globalPaths.abs.emptyBotTemplate, destDir: workDir, name, pkgJson: {} });
|
|
86
|
+
this.logger.success(`Bot project initialized in ${import_chalk.default.bold(workDir)}`);
|
|
87
|
+
};
|
|
88
|
+
_initIntegration = async (args) => {
|
|
89
|
+
const { workDir } = args;
|
|
90
|
+
const template = await this.prompt.select("Which template do you want to use?", {
|
|
91
|
+
choices: [
|
|
92
|
+
{ title: "Empty Integration", value: consts.emptyIntegrationDirName },
|
|
93
|
+
{ title: "Hello World", value: consts.helloWorldIntegrationDirName },
|
|
94
|
+
{ title: "Webhook Message", value: consts.webhookMessageIntegrationDirName }
|
|
95
|
+
],
|
|
96
|
+
default: consts.emptyIntegrationDirName
|
|
97
|
+
});
|
|
98
|
+
let srcDirPath;
|
|
99
|
+
if (template === consts.helloWorldIntegrationDirName) {
|
|
100
|
+
srcDirPath = this.globalPaths.abs.helloWorldIntegrationTemplate;
|
|
101
|
+
} else if (template === consts.webhookMessageIntegrationDirName) {
|
|
102
|
+
srcDirPath = this.globalPaths.abs.webhookMessageIntegrationTemplate;
|
|
103
|
+
} else {
|
|
104
|
+
srcDirPath = this.globalPaths.abs.emptyIntegrationTemplate;
|
|
105
|
+
}
|
|
106
|
+
const name = await this._getName("integration", template ?? consts.emptyIntegrationDirName);
|
|
107
|
+
await this._copy({
|
|
108
|
+
srcDir: srcDirPath,
|
|
109
|
+
destDir: workDir,
|
|
110
|
+
name,
|
|
111
|
+
pkgJson: {
|
|
112
|
+
integrationName: name
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
this.logger.success(`Integration project initialized in ${import_chalk.default.bold(this.argv.workDir)}`);
|
|
116
|
+
return;
|
|
117
|
+
};
|
|
118
|
+
_getName = async (projectType, defaultName) => {
|
|
119
|
+
if (this.argv.name) {
|
|
120
|
+
return this.argv.name;
|
|
121
|
+
}
|
|
122
|
+
const promptMessage = `What is the name of your ${projectType}?`;
|
|
123
|
+
const promptedName = await this.prompt.text(promptMessage, { initial: defaultName });
|
|
124
|
+
if (!promptedName) {
|
|
125
|
+
throw new errors.ParamRequiredError("Project Name");
|
|
126
|
+
}
|
|
127
|
+
return promptedName;
|
|
128
|
+
};
|
|
129
|
+
_copy = async (props) => {
|
|
130
|
+
const { srcDir, destDir, name, pkgJson } = props;
|
|
131
|
+
const dirName = utils.casing.to.kebabCase(name);
|
|
132
|
+
const destination = pathlib.join(destDir, dirName);
|
|
133
|
+
const exist = await this._checkIfDestinationExists(destination);
|
|
134
|
+
if (exist) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
await fs.promises.cp(srcDir, destination, { recursive: true });
|
|
138
|
+
const pkgJsonPath = pathlib.join(destination, "package.json");
|
|
139
|
+
const strContent = await fs.promises.readFile(pkgJsonPath, "utf-8");
|
|
140
|
+
const json = JSON.parse(strContent);
|
|
141
|
+
const pkgJsonName = utils.casing.to.snakeCase(name);
|
|
142
|
+
const updatedJson = { name: pkgJsonName, ...json, ...pkgJson };
|
|
143
|
+
await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2));
|
|
144
|
+
};
|
|
145
|
+
_checkIfDestinationExists = async (destination) => {
|
|
146
|
+
if (fs.existsSync(destination)) {
|
|
147
|
+
const override = await this.prompt.confirm(
|
|
148
|
+
`Directory ${import_chalk.default.bold(destination)} already exists. Do you want to overwrite it?`
|
|
149
|
+
);
|
|
150
|
+
if (!override) {
|
|
151
|
+
this.logger.log("Aborting");
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
InitCommand
|
|
161
|
+
});
|
|
162
|
+
//# sourceMappingURL=init-command.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/init-command.ts"],
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport * as fs from 'fs'\nimport * as pathlib from 'path'\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\nconst projectTypes = ['bot', 'integration', 'plugin'] as const\ntype ProjectType = (typeof projectTypes)[number]\n\ntype CopyProps = { srcDir: string; destDir: string; name: string; pkgJson: Record<string, unknown> }\n\nexport type InitCommandDefinition = typeof commandDefinitions.init\nexport class InitCommand extends GlobalCommand<InitCommandDefinition> {\n public async run(): Promise<void> {\n let { type: projectType } = this.argv\n\n if (!projectType) {\n const promptedType = await this.prompt.select('What type of project do you wish to initialize?', {\n choices: projectTypes.map((t) => ({ title: t, value: t })),\n })\n\n if (!promptedType) {\n throw new errors.ParamRequiredError('Project Type')\n }\n\n projectType = promptedType\n }\n\n const workDir = utils.path.absoluteFrom(utils.path.cwd(), this.argv.workDir)\n\n if (projectType === 'bot') {\n await this._initBot({ workDir })\n return\n }\n\n if (projectType === 'integration') {\n await this._initIntegration({ workDir })\n return\n }\n\n if (projectType === 'plugin') {\n await this._initPlugin({ workDir })\n return\n }\n\n type _assertion = utils.types.AssertNever<typeof projectType>\n throw new errors.BotpressCLIError(`Unknown project type: ${projectType}`)\n }\n\n private _initPlugin = async (args: { workDir: string }) => {\n const { workDir } = args\n const name = await this._getName('plugin', consts.emptyPluginDirName)\n await this._copy({\n srcDir: this.globalPaths.abs.emptyPluginTemplate,\n destDir: workDir,\n name,\n pkgJson: {\n pluginName: name,\n },\n })\n this.logger.success(`Plugin project initialized in ${chalk.bold(workDir)}`)\n }\n\n private _initBot = async (args: { workDir: string }) => {\n const { workDir } = args\n const name = await this._getName('bot', consts.emptyBotDirName)\n await this._copy({ srcDir: this.globalPaths.abs.emptyBotTemplate, destDir: workDir, name, pkgJson: {} })\n this.logger.success(`Bot project initialized in ${chalk.bold(workDir)}`)\n }\n\n private _initIntegration = async (args: { workDir: string }) => {\n const { workDir } = args\n\n const template = await this.prompt.select('Which template do you want to use?', {\n choices: [\n { title: 'Empty Integration', value: consts.emptyIntegrationDirName },\n { title: 'Hello World', value: consts.helloWorldIntegrationDirName },\n { title: 'Webhook Message', value: consts.webhookMessageIntegrationDirName },\n ],\n default: consts.emptyIntegrationDirName,\n })\n\n let srcDirPath: string\n if (template === consts.helloWorldIntegrationDirName) {\n srcDirPath = this.globalPaths.abs.helloWorldIntegrationTemplate\n } else if (template === consts.webhookMessageIntegrationDirName) {\n srcDirPath = this.globalPaths.abs.webhookMessageIntegrationTemplate\n } else {\n srcDirPath = this.globalPaths.abs.emptyIntegrationTemplate\n }\n\n const name = await this._getName('integration', template ?? consts.emptyIntegrationDirName)\n\n await this._copy({\n srcDir: srcDirPath,\n destDir: workDir,\n name,\n pkgJson: {\n integrationName: name,\n },\n })\n this.logger.success(`Integration project initialized in ${chalk.bold(this.argv.workDir)}`)\n return\n }\n\n private _getName = async (projectType: ProjectType, defaultName: string): Promise<string> => {\n if (this.argv.name) {\n return this.argv.name\n }\n const promptMessage = `What is the name of your ${projectType}?`\n const promptedName = await this.prompt.text(promptMessage, { initial: defaultName })\n if (!promptedName) {\n throw new errors.ParamRequiredError('Project Name')\n }\n return promptedName\n }\n\n private _copy = async (props: CopyProps) => {\n const { srcDir, destDir, name, pkgJson } = props\n\n const dirName = utils.casing.to.kebabCase(name)\n const destination = pathlib.join(destDir, dirName)\n\n const exist = await this._checkIfDestinationExists(destination)\n if (exist) {\n return\n }\n\n await fs.promises.cp(srcDir, destination, { recursive: true })\n\n const pkgJsonPath = pathlib.join(destination, 'package.json')\n const strContent = await fs.promises.readFile(pkgJsonPath, 'utf-8')\n const json = JSON.parse(strContent)\n\n const pkgJsonName = utils.casing.to.snakeCase(name)\n const updatedJson = { name: pkgJsonName, ...json, ...pkgJson }\n await fs.promises.writeFile(pkgJsonPath, JSON.stringify(updatedJson, null, 2))\n }\n\n private _checkIfDestinationExists = async (destination: string) => {\n if (fs.existsSync(destination)) {\n const override = await this.prompt.confirm(\n `Directory ${chalk.bold(destination)} already exists. Do you want to overwrite it?`\n )\n if (!override) {\n this.logger.log('Aborting')\n return true\n }\n }\n return false\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,SAAoB;AACpB,cAAyB;AAEzB,aAAwB;AACxB,aAAwB;AACxB,YAAuB;AACvB,4BAA8B;AAE9B,MAAM,eAAe,CAAC,OAAO,eAAe,QAAQ;AAM7C,MAAM,oBAAoB,oCAAqC;AAAA,EACpE,MAAa,MAAqB;AAChC,QAAI,EAAE,MAAM,YAAY,IAAI,KAAK;AAEjC,QAAI,CAAC,aAAa;AAChB,YAAM,eAAe,MAAM,KAAK,OAAO,OAAO,mDAAmD;AAAA,QAC/F,SAAS,aAAa,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,EAAE;AAAA,MAC3D,CAAC;AAED,UAAI,CAAC,cAAc;AACjB,cAAM,IAAI,OAAO,mBAAmB,cAAc;AAAA,MACpD;AAEA,oBAAc;AAAA,IAChB;AAEA,UAAM,UAAU,MAAM,KAAK,aAAa,MAAM,KAAK,IAAI,GAAG,KAAK,KAAK,OAAO;AAE3E,QAAI,gBAAgB,OAAO;AACzB,YAAM,KAAK,SAAS,EAAE,QAAQ,CAAC;AAC/B;AAAA,IACF;AAEA,QAAI,gBAAgB,eAAe;AACjC,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AAU;AAElC,UAAM,cAAc,MAAM,OAAO,GAAG,UAAU,IAAI;AAClD,UAAM,cAAc,EAAE,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ;AAC7D,UAAM,GAAG,SAAS,UAAU,aAAa,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC;AAAA,EAC/E;AAAA,EAEQ,4BAA4B,OAAO,gBAAwB;AACjE,QAAI,GAAG,WAAW,WAAW,GAAG;AAC9B,YAAM,WAAW,MAAM,KAAK,OAAO;AAAA,QACjC,aAAa,aAAAA,QAAM,KAAK,WAAW;AAAA,MACrC;AACA,UAAI,CAAC,UAAU;AACb,aAAK,OAAO,IAAI,UAAU;AAC1B,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["chalk"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
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 integration_commands_exports = {};
|
|
30
|
+
__export(integration_commands_exports, {
|
|
31
|
+
DeleteIntegrationCommand: () => DeleteIntegrationCommand,
|
|
32
|
+
GetIntegrationCommand: () => GetIntegrationCommand,
|
|
33
|
+
ListIntegrationsCommand: () => ListIntegrationsCommand
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(integration_commands_exports);
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var import_lodash = __toESM(require("lodash"));
|
|
38
|
+
var errors = __toESM(require("../errors"));
|
|
39
|
+
var import_package_ref = require("../package-ref");
|
|
40
|
+
var import_global_command = require("./global-command");
|
|
41
|
+
class GetIntegrationCommand extends import_global_command.GlobalCommand {
|
|
42
|
+
async run() {
|
|
43
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
44
|
+
const parsedRef = (0, import_package_ref.parsePackageRef)(this.argv.integrationRef);
|
|
45
|
+
if (!parsedRef) {
|
|
46
|
+
throw new errors.InvalidPackageReferenceError(this.argv.integrationRef);
|
|
47
|
+
}
|
|
48
|
+
if (parsedRef.type === "path") {
|
|
49
|
+
throw new errors.BotpressCLIError("Cannot get local integration");
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const integration = await api.findIntegration(parsedRef);
|
|
53
|
+
if (integration) {
|
|
54
|
+
this.logger.success(`Integration ${import_chalk.default.bold(this.argv.integrationRef)}:`);
|
|
55
|
+
this.logger.json(integration);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
} catch (thrown) {
|
|
59
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`);
|
|
60
|
+
}
|
|
61
|
+
throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class ListIntegrationsCommand extends import_global_command.GlobalCommand {
|
|
65
|
+
async run() {
|
|
66
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
67
|
+
const { dev, name, versionNumber: version } = this.argv;
|
|
68
|
+
const privateLister = (req) => api.client.listIntegrations({ nextToken: req.nextToken, dev, name, version });
|
|
69
|
+
const dummyLister = async () => ({ integrations: [], meta: {} });
|
|
70
|
+
const publicLister = dev ? dummyLister : (req) => api.client.listPublicIntegrations({ nextToken: req.nextToken, name, version });
|
|
71
|
+
try {
|
|
72
|
+
const privateIntegrations = await api.listAllPages(privateLister, (r) => r.integrations);
|
|
73
|
+
const publicIntegrations = await api.listAllPages(publicLister, (r) => r.integrations);
|
|
74
|
+
const integrations = import_lodash.default.uniqBy([...privateIntegrations, ...publicIntegrations], (i) => i.id);
|
|
75
|
+
this.logger.success("Integrations:");
|
|
76
|
+
this.logger.json(integrations);
|
|
77
|
+
} catch (thrown) {
|
|
78
|
+
throw errors.BotpressCLIError.wrap(thrown, "Could not list integrations");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
class DeleteIntegrationCommand extends import_global_command.GlobalCommand {
|
|
83
|
+
async run() {
|
|
84
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
85
|
+
const parsedRef = (0, import_package_ref.parsePackageRef)(this.argv.integrationRef);
|
|
86
|
+
if (!parsedRef) {
|
|
87
|
+
throw new errors.InvalidPackageReferenceError(this.argv.integrationRef);
|
|
88
|
+
}
|
|
89
|
+
if (parsedRef.type === "path") {
|
|
90
|
+
throw new errors.BotpressCLIError("Cannot delete local integration");
|
|
91
|
+
}
|
|
92
|
+
let integrationId;
|
|
93
|
+
if (parsedRef.type === "id") {
|
|
94
|
+
integrationId = parsedRef.id;
|
|
95
|
+
} else {
|
|
96
|
+
const integration = await this._findIntegration(api, parsedRef);
|
|
97
|
+
integrationId = integration.id;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
await api.client.deleteIntegration({ id: integrationId });
|
|
101
|
+
} catch (thrown) {
|
|
102
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not delete integration ${this.argv.integrationRef}`);
|
|
103
|
+
}
|
|
104
|
+
this.logger.success(`Integration ${import_chalk.default.bold(this.argv.integrationRef)} deleted`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
_findIntegration = async (api, parsedRef) => {
|
|
108
|
+
let integration;
|
|
109
|
+
try {
|
|
110
|
+
integration = await api.findPrivateIntegration(parsedRef);
|
|
111
|
+
} catch (thrown) {
|
|
112
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`);
|
|
113
|
+
}
|
|
114
|
+
if (!integration) {
|
|
115
|
+
const publicIntegration = await api.findPublicIntegration(parsedRef);
|
|
116
|
+
if (publicIntegration) {
|
|
117
|
+
throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} does not belong to your workspace`);
|
|
118
|
+
}
|
|
119
|
+
throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`);
|
|
120
|
+
}
|
|
121
|
+
return integration;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
+
0 && (module.exports = {
|
|
126
|
+
DeleteIntegrationCommand,
|
|
127
|
+
GetIntegrationCommand,
|
|
128
|
+
ListIntegrationsCommand
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=integration-commands.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/integration-commands.ts"],
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk'\nimport _ from 'lodash'\nimport { ApiClient, Integration } from 'src/api/client'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { NamePackageRef, parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.get\nexport class GetIntegrationCommand extends GlobalCommand<GetIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local integration')\n }\n\n try {\n const integration = await api.findIntegration(parsedRef)\n if (integration) {\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)}:`)\n this.logger.json(integration)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n}\n\nexport type ListIntegrationsCommandDefinition = typeof commandDefinitions.integrations.subcommands.list\nexport class ListIntegrationsCommand extends GlobalCommand<ListIntegrationsCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const { dev, name, versionNumber: version } = this.argv\n\n const privateLister = (req: { nextToken?: string }) =>\n api.client.listIntegrations({ nextToken: req.nextToken, dev, name, version })\n\n const dummyLister: typeof privateLister = async () => ({ integrations: [], meta: {} })\n const publicLister = dev\n ? dummyLister\n : (req: { nextToken?: string }) => api.client.listPublicIntegrations({ nextToken: req.nextToken, name, version })\n\n try {\n const privateIntegrations = await api.listAllPages(privateLister, (r) => r.integrations)\n const publicIntegrations = await api.listAllPages(publicLister, (r) => r.integrations)\n const integrations = _.uniqBy([...privateIntegrations, ...publicIntegrations], (i) => i.id)\n\n this.logger.success('Integrations:')\n this.logger.json(integrations)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list integrations')\n }\n }\n}\n\nexport type DeleteIntegrationCommandDefinition = typeof commandDefinitions.integrations.subcommands.delete\nexport class DeleteIntegrationCommand extends GlobalCommand<DeleteIntegrationCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.integrationRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.integrationRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local integration')\n }\n\n let integrationId: string | undefined\n if (parsedRef.type === 'id') {\n integrationId = parsedRef.id\n } else {\n const integration = await this._findIntegration(api, parsedRef)\n integrationId = integration.id\n }\n\n try {\n await api.client.deleteIntegration({ id: integrationId })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete integration ${this.argv.integrationRef}`)\n }\n\n this.logger.success(`Integration ${chalk.bold(this.argv.integrationRef)} deleted`)\n return\n }\n\n private _findIntegration = async (api: ApiClient, parsedRef: NamePackageRef) => {\n let integration: Integration | undefined\n\n try {\n integration = await api.findPrivateIntegration(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get integration ${this.argv.integrationRef}`)\n }\n\n if (!integration) {\n const publicIntegration = await api.findPublicIntegration(parsedRef)\n if (publicIntegration) {\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} does not belong to your workspace`)\n }\n\n throw new errors.BotpressCLIError(`Integration ${this.argv.integrationRef} not found`)\n }\n\n return integration\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,oBAAc;AAGd,aAAwB;AACxB,y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,YAAM,OAAO,iBAAiB,KAAK,QAAQ,6BAA6B,KAAK,KAAK,gBAAgB;AAAA,IACpG;AAEA,QAAI,CAAC,aAAa;AAChB,YAAM,oBAAoB,MAAM,IAAI,sBAAsB,SAAS;AACnE,UAAI,mBAAmB;AACrB,cAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,kDAAkD;AAAA,MAC/G;AAEA,YAAM,IAAI,OAAO,iBAAiB,eAAe,KAAK,KAAK,0BAA0B;AAAA,IACvF;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["chalk", "_"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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 interface_commands_exports = {};
|
|
30
|
+
__export(interface_commands_exports, {
|
|
31
|
+
DeleteInterfaceCommand: () => DeleteInterfaceCommand,
|
|
32
|
+
GetInterfaceCommand: () => GetInterfaceCommand,
|
|
33
|
+
ListInterfacesCommand: () => ListInterfacesCommand
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(interface_commands_exports);
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
var errors = __toESM(require("../errors"));
|
|
38
|
+
var import_package_ref = require("../package-ref");
|
|
39
|
+
var import_global_command = require("./global-command");
|
|
40
|
+
class GetInterfaceCommand extends import_global_command.GlobalCommand {
|
|
41
|
+
async run() {
|
|
42
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
43
|
+
const parsedRef = (0, import_package_ref.parsePackageRef)(this.argv.interfaceRef);
|
|
44
|
+
if (!parsedRef) {
|
|
45
|
+
throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef);
|
|
46
|
+
}
|
|
47
|
+
if (parsedRef.type === "path") {
|
|
48
|
+
throw new errors.BotpressCLIError("Cannot get local interface");
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const intrface = await api.findPublicInterface(parsedRef);
|
|
52
|
+
if (intrface) {
|
|
53
|
+
this.logger.success(`Interface ${import_chalk.default.bold(this.argv.interfaceRef)}:`);
|
|
54
|
+
this.logger.json(intrface);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
} catch (thrown) {
|
|
58
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`);
|
|
59
|
+
}
|
|
60
|
+
throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class ListInterfacesCommand extends import_global_command.GlobalCommand {
|
|
64
|
+
async run() {
|
|
65
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
66
|
+
const lister = (req) => api.client.listInterfaces({ nextToken: req.nextToken });
|
|
67
|
+
try {
|
|
68
|
+
const interfaces = await api.listAllPages(lister, (r) => r.interfaces);
|
|
69
|
+
this.logger.success("Interfaces:");
|
|
70
|
+
this.logger.json(interfaces);
|
|
71
|
+
} catch (thrown) {
|
|
72
|
+
throw errors.BotpressCLIError.wrap(thrown, "Could not list interfaces");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
class DeleteInterfaceCommand extends import_global_command.GlobalCommand {
|
|
77
|
+
async run() {
|
|
78
|
+
const api = await this.ensureLoginAndCreateClient(this.argv);
|
|
79
|
+
const parsedRef = (0, import_package_ref.parsePackageRef)(this.argv.interfaceRef);
|
|
80
|
+
if (!parsedRef) {
|
|
81
|
+
throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef);
|
|
82
|
+
}
|
|
83
|
+
if (parsedRef.type === "path") {
|
|
84
|
+
throw new errors.BotpressCLIError("Cannot delete local interface");
|
|
85
|
+
}
|
|
86
|
+
let intrface;
|
|
87
|
+
try {
|
|
88
|
+
intrface = await api.findPublicInterface(parsedRef);
|
|
89
|
+
} catch (thrown) {
|
|
90
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`);
|
|
91
|
+
}
|
|
92
|
+
if (!intrface) {
|
|
93
|
+
throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`);
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
await api.client.deleteInterface({ id: intrface.id });
|
|
97
|
+
} catch (thrown) {
|
|
98
|
+
throw errors.BotpressCLIError.wrap(thrown, `Could not delete interface ${this.argv.interfaceRef}`);
|
|
99
|
+
}
|
|
100
|
+
this.logger.success(`Interface ${import_chalk.default.bold(this.argv.interfaceRef)} deleted`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
DeleteInterfaceCommand,
|
|
107
|
+
GetInterfaceCommand,
|
|
108
|
+
ListInterfacesCommand
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=interface-commands.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command-implementations/interface-commands.ts"],
|
|
4
|
+
"sourcesContent": ["import type * as client from '@botpress/client'\nimport chalk from 'chalk'\nimport type commandDefinitions from '../command-definitions'\nimport * as errors from '../errors'\nimport { parsePackageRef } from '../package-ref'\nimport { GlobalCommand } from './global-command'\n\nexport type GetInterfaceCommandDefinition = typeof commandDefinitions.interfaces.subcommands.get\nexport class GetInterfaceCommand extends GlobalCommand<GetInterfaceCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.interfaceRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot get local interface')\n }\n\n try {\n const intrface = await api.findPublicInterface(parsedRef)\n if (intrface) {\n this.logger.success(`Interface ${chalk.bold(this.argv.interfaceRef)}:`)\n this.logger.json(intrface)\n return\n }\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`)\n }\n\n throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`)\n }\n}\n\nexport type ListInterfacesCommandDefinition = typeof commandDefinitions.interfaces.subcommands.list\nexport class ListInterfacesCommand extends GlobalCommand<ListInterfacesCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n\n const lister = (req: { nextToken?: string }) => api.client.listInterfaces({ nextToken: req.nextToken })\n\n try {\n const interfaces = await api.listAllPages(lister, (r) => r.interfaces)\n\n this.logger.success('Interfaces:')\n this.logger.json(interfaces)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, 'Could not list interfaces')\n }\n }\n}\n\nexport type DeleteInterfaceCommandDefinition = typeof commandDefinitions.interfaces.subcommands.delete\nexport class DeleteInterfaceCommand extends GlobalCommand<DeleteInterfaceCommandDefinition> {\n public async run(): Promise<void> {\n const api = await this.ensureLoginAndCreateClient(this.argv)\n const parsedRef = parsePackageRef(this.argv.interfaceRef)\n if (!parsedRef) {\n throw new errors.InvalidPackageReferenceError(this.argv.interfaceRef)\n }\n if (parsedRef.type === 'path') {\n throw new errors.BotpressCLIError('Cannot delete local interface')\n }\n\n let intrface: client.Interface | undefined\n try {\n intrface = await api.findPublicInterface(parsedRef)\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not get interface ${this.argv.interfaceRef}`)\n }\n\n if (!intrface) {\n throw new errors.BotpressCLIError(`Interface ${this.argv.interfaceRef} not found`)\n }\n\n try {\n await api.client.deleteInterface({ id: intrface.id })\n } catch (thrown) {\n throw errors.BotpressCLIError.wrap(thrown, `Could not delete interface ${this.argv.interfaceRef}`)\n }\n\n this.logger.success(`Interface ${chalk.bold(this.argv.interfaceRef)} deleted`)\n return\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAElB,aAAwB;AACxB,yBAAgC;AAChC,4BAA8B;AAGvB,MAAM,4BAA4B,oCAA6C;AAAA,EACpF,MAAa,MAAqB;AAChC,UAAM,MAAM,MAAM,KAAK,2BAA2B,KAAK,IAAI;AAC3D,UAAM,gBAAY,oCAAgB,KAAK,KAAK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