@aifabrix/builder 2.53.1 → 2.54.1
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/bin/aifabrix.js +2 -2
- package/lib/api/assistants.api.js +8 -5
- package/lib/api/channel-identity.api.js +41 -0
- package/lib/api/evidence-authoring.api.js +5 -1
- package/lib/api/evidence.api.js +2 -0
- package/lib/api/types/evidence.types.js +2 -0
- package/lib/api/work-search.api.js +136 -0
- package/lib/channels/add-channel.js +163 -126
- package/lib/channels/approval-guides/chatgpt.js +14 -18
- package/lib/channels/approval-guides/claude.js +29 -0
- package/lib/channels/approval-guides/index.js +88 -22
- package/lib/channels/approval-guides/mcp-client.js +27 -0
- package/lib/channels/approval-guides/microsoft-copilot.js +52 -3
- package/lib/channels/approval-guides/slack.js +10 -10
- package/lib/channels/approval-guides/teams-bot.js +8 -12
- package/lib/channels/channel-add-continuations.js +91 -0
- package/lib/channels/channel-add-ensure.js +124 -27
- package/lib/channels/channel-add-existing.js +160 -28
- package/lib/channels/channel-add-failure.js +60 -0
- package/lib/channels/channel-add-remaining.js +486 -0
- package/lib/channels/channel-add-tty.js +190 -0
- package/lib/channels/channel-add-wizard-config.js +138 -0
- package/lib/channels/channel-add-wizard.js +250 -0
- package/lib/channels/channel-artifact-generator.js +27 -13
- package/lib/channels/channel-cardinality.js +83 -0
- package/lib/channels/channel-catalog-icon.js +45 -0
- package/lib/channels/channel-cli-instructions.js +75 -0
- package/lib/channels/channel-configuration-map.js +213 -0
- package/lib/channels/channel-credential.js +11 -14
- package/lib/channels/channel-definition-project.js +101 -0
- package/lib/channels/channel-definition-registry.js +154 -0
- package/lib/channels/channel-description.js +59 -2
- package/lib/channels/channel-discovery.js +16 -2
- package/lib/channels/channel-external-system.js +86 -9
- package/lib/channels/channel-install-envelope-actions.js +88 -0
- package/lib/channels/channel-install-envelope-microsoft.js +155 -0
- package/lib/channels/channel-install-envelope.js +356 -0
- package/lib/channels/channel-install-help-md.js +172 -0
- package/lib/channels/channel-install-http-payload.js +62 -0
- package/lib/channels/channel-install-inventory.js +115 -0
- package/lib/channels/channel-install-profiles.js +90 -0
- package/lib/channels/channel-instance-collision.js +118 -0
- package/lib/channels/channel-instance-key.js +100 -0
- package/lib/channels/channel-instance-materialize.js +240 -0
- package/lib/channels/channel-integration-generator.js +16 -9
- package/lib/channels/channel-integration-template.js +101 -22
- package/lib/channels/channel-inventory-fetch.js +79 -0
- package/lib/channels/channel-oauth-preflight.js +104 -0
- package/lib/channels/channel-package-version.js +76 -0
- package/lib/channels/channel-predefined-client.js +154 -0
- package/lib/channels/channel-probe.js +7 -2
- package/lib/channels/channel-runtime-resolver.js +180 -72
- package/lib/channels/channel-status-display.js +86 -16
- package/lib/channels/channel-targets.js +106 -92
- package/lib/channels/chatgpt-callback.js +318 -0
- package/lib/channels/chatgpt-channel-add.js +229 -0
- package/lib/channels/chatgpt-preflight.js +396 -0
- package/lib/channels/chatgpt-runtime-contract.js +17 -0
- package/lib/channels/chatgpt-setup-values.js +124 -0
- package/lib/channels/claude-callback.js +67 -0
- package/lib/channels/claude-channel-add.js +254 -0
- package/lib/channels/claude-runtime-contract.js +40 -0
- package/lib/channels/claude-runtime.js +58 -0
- package/lib/channels/claude-setup-values.js +89 -0
- package/lib/channels/mcp-client/config-merge.js +148 -0
- package/lib/channels/mcp-client/ensure-client.js +231 -0
- package/lib/channels/mcp-client/paths.js +53 -0
- package/lib/channels/mcp-client/profiles.js +122 -0
- package/lib/channels/mcp-client/redirect-uris.js +99 -0
- package/lib/channels/mcp-client/runtime.js +59 -0
- package/lib/channels/mcp-client-channel-add.js +186 -0
- package/lib/channels/microsoft-copilot-channel-add.js +117 -7
- package/lib/channels/microsoft-copilot-entra-identifier-uris.js +187 -0
- package/lib/channels/microsoft-copilot-entra-sso-form.js +106 -18
- package/lib/channels/microsoft-copilot-entra-sso.js +31 -2
- package/lib/channels/microsoft-copilot-package-prior.js +107 -0
- package/lib/channels/microsoft-copilot-package.js +29 -28
- package/lib/channels/microsoft-provisioning/a365.js +80 -0
- package/lib/channels/microsoft-provisioning/auth-config.js +240 -0
- package/lib/channels/microsoft-provisioning/auth.js +179 -0
- package/lib/channels/microsoft-provisioning/cli.js +71 -0
- package/lib/channels/microsoft-provisioning/constants.js +75 -0
- package/lib/channels/microsoft-provisioning/errors.js +117 -0
- package/lib/channels/microsoft-provisioning/index.js +55 -0
- package/lib/channels/microsoft-provisioning/install-atk.js +158 -0
- package/lib/channels/microsoft-provisioning/install-teams.js +115 -0
- package/lib/channels/microsoft-provisioning/login-portal-device.js +236 -0
- package/lib/channels/microsoft-provisioning/login-portal-parse.js +71 -0
- package/lib/channels/microsoft-provisioning/login-portal-teams.js +193 -0
- package/lib/channels/microsoft-provisioning/login-portal.js +230 -0
- package/lib/channels/microsoft-provisioning/persist.js +110 -0
- package/lib/channels/microsoft-provisioning/teams-bot-args.js +119 -0
- package/lib/channels/microsoft-provisioning/teams-bot-controller.js +123 -0
- package/lib/channels/microsoft-provisioning/teams-bot-parse.js +134 -0
- package/lib/channels/microsoft-provisioning/teams-bot-persist.js +113 -0
- package/lib/channels/microsoft-provisioning/teams-bot-provision.js +234 -0
- package/lib/channels/microsoft-provisioning/teams-bot-secrets.js +45 -0
- package/lib/channels/microsoft-provisioning/teams-cli.js +82 -0
- package/lib/channels/runtime-tool-catalog.js +5 -2
- package/lib/channels/slack-channel-add-portal.js +130 -0
- package/lib/channels/slack-channel-add-tty-auth.js +95 -0
- package/lib/channels/slack-channel-add.js +258 -0
- package/lib/channels/slack-provisioning/apps.js +181 -0
- package/lib/channels/slack-provisioning/auth-store.js +110 -0
- package/lib/channels/slack-provisioning/auth-ticket.js +185 -0
- package/lib/channels/slack-provisioning/auth.js +115 -0
- package/lib/channels/slack-provisioning/callbacks.js +41 -0
- package/lib/channels/slack-provisioning/cli.js +226 -0
- package/lib/channels/slack-provisioning/constants.js +37 -0
- package/lib/channels/slack-provisioning/credentials.js +169 -0
- package/lib/channels/slack-provisioning/curl-shim.js +132 -0
- package/lib/channels/slack-provisioning/developer-install.js +118 -0
- package/lib/channels/slack-provisioning/env-file.js +120 -0
- package/lib/channels/slack-provisioning/errors.js +47 -0
- package/lib/channels/slack-provisioning/go-ca-bundle.js +137 -0
- package/lib/channels/slack-provisioning/index.js +250 -0
- package/lib/channels/slack-provisioning/install-cli.js +323 -0
- package/lib/channels/slack-provisioning/manifest.js +89 -0
- package/lib/channels/slack-provisioning/oauth-lock.js +33 -0
- package/lib/channels/slack-provisioning/offer-cli.js +113 -0
- package/lib/channels/slack-provisioning/onboard-members.js +122 -0
- package/lib/channels/slack-provisioning/onboard.js +89 -0
- package/lib/channels/slack-provisioning/persist.js +95 -0
- package/lib/channels/slack-provisioning/remaining-urls.js +158 -0
- package/lib/channels/slack-provisioning/with-curl-on-path.js +48 -0
- package/lib/channels/teams-bot-channel-add.js +94 -0
- package/lib/channels/vendor-dataplane-url.js +249 -0
- package/lib/cli/setup-certification.help.js +2 -0
- package/lib/cli/setup-external-system-help.js +2 -0
- package/lib/cli/setup-external-system.js +1 -1
- package/lib/commands/channel-add-help.js +366 -0
- package/lib/commands/channel-add-setup.js +162 -80
- package/lib/commands/channel-configure.js +118 -0
- package/lib/commands/channel.js +10 -1
- package/lib/commands/governance-upload-external.js +6 -3
- package/lib/commands/lifecycle-command-action.js +2 -5
- package/lib/commands/lifecycle-external.js +93 -21
- package/lib/commands/repair-datasource-test-payload.js +4 -2
- package/lib/commands/repair-datasource-webhooks-sync-bridge.js +23 -2
- package/lib/commands/repair-datasource.js +3 -0
- package/lib/commands/repair-external-run.js +59 -25
- package/lib/commands/repair-openapi-rest-runtime.js +127 -0
- package/lib/commands/repair-orchestration-tag-merge.js +339 -0
- package/lib/commands/repair-rbac-catalog-defaults.js +96 -0
- package/lib/commands/repair-rbac-platform-preset.js +26 -15
- package/lib/commands/repair-rbac-reader-roles.js +8 -21
- package/lib/commands/repair-rbac.js +10 -34
- package/lib/commands/repair-system-permissions.js +24 -22
- package/lib/commands/role-assistant-test-output.js +14 -0
- package/lib/commands/role-assistant.js +59 -21
- package/lib/commands/test-e2e-external.js +148 -21
- package/lib/commands/upload-credential-push-log.js +2 -1
- package/lib/commands/upload-publish-context.js +1 -1
- package/lib/commands/upload-role-assistant-shell.js +124 -0
- package/lib/commands/upload-sidecar-followups.js +6 -3
- package/lib/commands/upload.js +18 -3
- package/lib/core/secrets-docker-env.js +4 -1
- package/lib/core/secrets-env-content.js +17 -3
- package/lib/datasource/capability/capability-manifest.js +0 -3
- package/lib/datasource/capability/copy-test-payload.js +3 -0
- package/lib/external-system/deploy-helpers.js +26 -1
- package/lib/external-system/deploy.js +10 -6
- package/lib/external-system/download-helpers.js +29 -2
- package/lib/external-system/download-role-assistant.js +83 -4
- package/lib/external-system/download.js +40 -30
- package/lib/external-system/sync-deploy-manifest.js +3 -2
- package/lib/external-system/upload-identity.js +42 -0
- package/lib/generator/index.js +19 -15
- package/lib/generator/split.js +13 -2
- package/lib/lifecycle/role-assistant-governance.js +146 -0
- package/lib/lifecycle/scenario-upload.js +181 -30
- package/lib/programmatic/builder-api-cors.js +143 -0
- package/lib/programmatic/builder-api-request.js +6 -0
- package/lib/programmatic/builder-api-route-dispatch.js +56 -42
- package/lib/programmatic/builder-api-server.js +8 -1
- package/lib/programmatic/capability-registry.js +54 -0
- package/lib/programmatic/channel-install-help-resolve.js +359 -0
- package/lib/programmatic/channel-install-session.js +218 -0
- package/lib/programmatic/help-content/channel-onboarding.md +2 -0
- package/lib/programmatic/help-content/cip-overview.md +3 -1
- package/lib/programmatic/http-raw-response.js +62 -0
- package/lib/programmatic/openapi-channel-install-bindings.js +179 -0
- package/lib/programmatic/openapi-channel-install-schemas.js +286 -0
- package/lib/programmatic/openapi-component-schemas.js +18 -1
- package/lib/programmatic/openapi-description-enricher.js +3 -1
- package/lib/programmatic/openapi-descriptions.js +74 -3
- package/lib/programmatic/openapi-envelope-examples.js +117 -0
- package/lib/programmatic/openapi-operation-bindings.js +4 -1
- package/lib/programmatic/openapi-schema-descriptions-channel.js +316 -0
- package/lib/programmatic/openapi-spec.js +12 -8
- package/lib/programmatic/platform-rbac-catalog.js +36 -18
- package/lib/programmatic/route-handler-map.js +51 -1
- package/lib/programmatic/route-handlers-context.js +2 -1
- package/lib/programmatic/run-auth-permissions.js +54 -0
- package/lib/programmatic/run-channel-catalog.js +196 -0
- package/lib/programmatic/run-channel-install-artifacts.js +137 -0
- package/lib/programmatic/run-channel-install-copilot.js +353 -0
- package/lib/programmatic/run-channel-install-options.js +232 -0
- package/lib/programmatic/run-channel-install-teams-bot.js +204 -0
- package/lib/programmatic/run-channel-install.js +346 -0
- package/lib/programmatic/run-channel-package.js +87 -7
- package/lib/programmatic/workspace-context.js +2 -0
- package/lib/role-assistant/evidence-sync.js +4 -2
- package/lib/role-assistant/evidence-validation-issues.js +51 -0
- package/lib/role-assistant/knowledge-sync.js +10 -4
- package/lib/role-assistant/settings.js +49 -2
- package/lib/role-assistant/test-cases-evaluate.js +30 -2
- package/lib/role-assistant/test-cases-evidence.js +175 -0
- package/lib/role-assistant/test-cases-search.js +229 -0
- package/lib/role-assistant/test-cases.js +37 -4
- package/lib/role-assistant/test-runner-search.js +149 -0
- package/lib/role-assistant/test-runner-workhub-helpers.js +40 -2
- package/lib/role-assistant/test-runner-workhub-soft.js +9 -3
- package/lib/role-assistant/test-runner-workhub.js +29 -11
- package/lib/role-assistant/test-runner.js +16 -1
- package/lib/schema/external-datasource.schema.json +112 -18
- package/lib/schema/external-system.schema.json +159 -2
- package/lib/schema/mcp-client-profile.schema.json +103 -0
- package/lib/utils/app-path-resolve.js +4 -0
- package/lib/utils/authentication-env-template.js +44 -6
- package/lib/utils/credential-secrets-env.js +6 -1
- package/lib/utils/env-copy.js +19 -7
- package/lib/utils/external-env-template.js +20 -2
- package/lib/utils/paths.js +18 -1
- package/lib/utils/platform-shell-package.js +69 -0
- package/lib/utils/port-resolver.js +50 -1
- package/lib/utils/rewrite-name-flag.js +20 -0
- package/lib/utils/role-assistant-paths.js +13 -10
- package/lib/utils/schema-resolver.js +11 -1
- package/lib/utils/secrets-helpers.js +12 -21
- package/lib/utils/token-manager.js +10 -5
- package/lib/validation/validate.js +40 -0
- package/package.json +1 -1
- package/templates/README.md +1 -1
- package/templates/applications/builder-api/Dockerfile +1 -1
- package/templates/applications/builder-api/env.template +7 -0
- package/templates/applications/dataplane/application.yaml +6 -5
- package/templates/applications/dataplane/env.template +2 -2
- package/templates/applications/dataplane/rbac.yaml +7 -2
- package/templates/applications/keycloak/Dockerfile +30 -4
- package/templates/applications/keycloak/application.yaml +2 -2
- package/templates/applications/keycloak/cimd-lenient-parse/AbstractClientIdMetadataDocumentExecutor.java +896 -0
- package/templates/applications/keycloak/cimd-lenient-parse/SOURCE.md +19 -0
- package/templates/applications/keycloak/env.template +3 -0
- package/templates/applications/miso-controller/application.yaml +1 -2
- package/templates/applications/miso-controller/env.template +2 -0
- package/templates/channels/README.md +5 -5
- package/templates/channels/chatgpt/TROUBLESHOOTING.md +51 -0
- package/templates/channels/chatgpt/channel.json +59 -0
- package/templates/channels/chatgpt/icon.svg +1 -0
- package/templates/channels/chatgpt/install.template.md.hbs +20 -95
- package/templates/channels/chatgpt/integration/README.md +1 -1
- package/templates/channels/chatgpt/integration/application.json +2 -2
- package/templates/channels/chatgpt/integration/chatgpt-system.json +49 -4
- package/templates/channels/chatgpt/integration/env.template +2 -4
- package/templates/channels/chatgpt/integration/rbac.json +13 -0
- package/templates/channels/claude/TROUBLESHOOTING.md +41 -0
- package/templates/channels/claude/channel.json +59 -0
- package/templates/channels/claude/icon.svg +1 -0
- package/templates/channels/claude/install.template.md.hbs +21 -0
- package/templates/channels/claude/integration/README.md +14 -0
- package/templates/channels/claude/integration/application.json +15 -0
- package/templates/channels/claude/integration/claude-system.json +59 -0
- package/templates/channels/claude/integration/env.template +2 -0
- package/templates/channels/claude/integration/rbac.json +13 -0
- package/templates/channels/claude/manifest.template.json.hbs +40 -0
- package/templates/channels/mcp-client/channel.json +72 -0
- package/templates/channels/mcp-client/icon.svg +1 -0
- package/templates/channels/mcp-client/install.template.md.hbs +24 -0
- package/templates/channels/mcp-client/integration/README.md +13 -0
- package/templates/channels/mcp-client/integration/application.json +15 -0
- package/templates/channels/mcp-client/integration/env.template +2 -0
- package/templates/channels/mcp-client/integration/mcp-client-system.json +72 -0
- package/templates/channels/mcp-client/integration/rbac.json +13 -0
- package/templates/channels/mcp-client/manifest.template.json.hbs +41 -0
- package/templates/channels/mcp-client/profiles/cursor.json +26 -0
- package/templates/channels/mcp-client/profiles/github-copilot.json +29 -0
- package/templates/channels/mcp-client/profiles/vscode.json +29 -0
- package/templates/channels/microsoft-copilot/channel.json +73 -0
- package/templates/channels/microsoft-copilot/declarative-agent.template.json.hbs +8 -4
- package/templates/channels/microsoft-copilot/entra-sso-registration.template.md.hbs +65 -5
- package/templates/channels/microsoft-copilot/icon.svg +1 -0
- package/templates/channels/microsoft-copilot/install.template.md.hbs +9 -9
- package/templates/channels/microsoft-copilot/integration/README.md +1 -1
- package/templates/channels/microsoft-copilot/integration/application.json +2 -2
- package/templates/channels/microsoft-copilot/integration/env.template +3 -6
- package/templates/channels/microsoft-copilot/integration/microsoft-copilot-system.json +63 -4
- package/templates/channels/microsoft-copilot/integration/rbac.json +13 -0
- package/templates/channels/microsoft-copilot/oauth-plugin-vault-required.template.md.hbs +5 -5
- package/templates/channels/slack/channel.json +223 -0
- package/templates/channels/slack/icon.svg +1 -0
- package/templates/channels/slack/install.template.md.hbs +36 -28
- package/templates/channels/slack/integration/README.md +245 -22
- package/templates/channels/slack/integration/application.json +44 -7
- package/templates/channels/slack/integration/env.template +15 -6
- package/templates/channels/slack/integration/openapi/openapi.json +126 -0
- package/templates/channels/slack/integration/rbac.json +84 -0
- package/templates/channels/slack/integration/slack-datasource-commands.json +154 -0
- package/templates/channels/slack/integration/slack-datasource-conversations.json +28 -3
- package/templates/channels/slack/integration/slack-datasource-events.json +154 -0
- package/templates/channels/slack/integration/slack-datasource-interactive.json +154 -0
- package/templates/channels/slack/integration/slack-datasource-messages.json +40 -2
- package/templates/channels/slack/integration/slack-system.json +155 -77
- package/templates/channels/slack/manifest.template.json.hbs +5 -2
- package/templates/channels/teams-bot/channel.json +161 -0
- package/templates/channels/teams-bot/icon.svg +1 -0
- package/templates/channels/teams-bot/install.template.md.hbs +12 -13
- package/templates/channels/teams-bot/integration/README.md +5 -4
- package/templates/channels/teams-bot/integration/application.json +6 -4
- package/templates/channels/teams-bot/integration/env.template +5 -4
- package/templates/channels/teams-bot/integration/openapi/openapi.json +68 -0
- package/templates/channels/teams-bot/integration/rbac.json +21 -0
- package/templates/channels/teams-bot/integration/teams-bot-datasource-activities.json +154 -0
- package/templates/channels/teams-bot/integration/teams-bot-system.json +128 -23
- package/templates/channels/web-embed/channel.json +60 -0
- package/templates/channels/web-embed/install.template.md.hbs +1 -1
- package/templates/channels/web-embed/integration/README.md +2 -2
- package/templates/channels/web-embed/integration/application.json +2 -2
- package/templates/channels/web-embed/integration/env.template +1 -1
- package/templates/channels/web-embed/integration/rbac.json +13 -0
- package/templates/channels/web-embed/integration/web-embed-system.json +50 -4
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spawn Teams Developer CLI (`teams`) without scattering argv.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Documented CLI only; skipped under Jest unless deps allow it
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const { shouldSkipLiveToolkit, runAtk } = require('./cli');
|
|
10
|
+
const { findOrInstallTeamsBinary } = require('./install-teams');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {Object} [deps]
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
function shouldSkipLiveTeamsCli(deps = {}) {
|
|
17
|
+
return shouldSkipLiveToolkit(deps);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {Object} [deps]
|
|
22
|
+
* @returns {Promise<string|null>}
|
|
23
|
+
*/
|
|
24
|
+
async function resolveTeamsBinary(deps = {}) {
|
|
25
|
+
if (typeof deps.teamsBinary === 'string' && deps.teamsBinary.trim()) {
|
|
26
|
+
return deps.teamsBinary.trim();
|
|
27
|
+
}
|
|
28
|
+
if (shouldSkipLiveTeamsCli(deps)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return findOrInstallTeamsBinary(deps);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} bin
|
|
36
|
+
* @param {string[]} args
|
|
37
|
+
* @param {Object} [opts]
|
|
38
|
+
* @param {Object} [deps]
|
|
39
|
+
* @returns {Promise<{ stdout: string, stderr: string }>}
|
|
40
|
+
*/
|
|
41
|
+
async function runTeams(bin, args, opts = {}, deps = {}) {
|
|
42
|
+
return runAtk(bin, args, opts, deps);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} text
|
|
47
|
+
* @returns {boolean}
|
|
48
|
+
*/
|
|
49
|
+
function teamsStatusLooksLoggedIn(text) {
|
|
50
|
+
const blob = String(text || '');
|
|
51
|
+
if (/not logged in/i.test(blob)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return /logged in as|sideloading:\s*enabled/i.test(blob);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {Object} [deps]
|
|
59
|
+
* @returns {Promise<boolean>}
|
|
60
|
+
*/
|
|
61
|
+
async function isTeamsCliLoggedIn(deps = {}) {
|
|
62
|
+
const bin = await resolveTeamsBinary(deps);
|
|
63
|
+
if (!bin) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const result = await runTeams(bin, ['status'], { timeout: 20000 }, deps);
|
|
68
|
+
return teamsStatusLooksLoggedIn(`${result.stdout}\n${result.stderr}`);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const stdout = error && error.stdout ? String(error.stdout) : '';
|
|
71
|
+
const stderr = error && error.stderr ? String(error.stderr) : '';
|
|
72
|
+
return teamsStatusLooksLoggedIn(`${stdout}\n${stderr}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = {
|
|
77
|
+
shouldSkipLiveTeamsCli,
|
|
78
|
+
resolveTeamsBinary,
|
|
79
|
+
runTeams,
|
|
80
|
+
teamsStatusLooksLoggedIn,
|
|
81
|
+
isTeamsCliLoggedIn
|
|
82
|
+
};
|
|
@@ -108,9 +108,12 @@ function preferLayerBToolNames(names) {
|
|
|
108
108
|
*/
|
|
109
109
|
async function fetchRuntimeLayerBToolNames(dataplaneUrl, authConfig, channelTarget) {
|
|
110
110
|
const target = getChannelTarget(channelTarget);
|
|
111
|
-
const
|
|
111
|
+
const runtimeKey =
|
|
112
|
+
(target.runtimeTarget && target.runtimeTarget.defaultSystemKey) ||
|
|
113
|
+
target.routeSystemKey ||
|
|
114
|
+
'runtime-orchestration';
|
|
112
115
|
const client = createDataplaneApiClient(dataplaneUrl, authConfig);
|
|
113
|
-
const endpoints = buildToolCatalogEndpoints(
|
|
116
|
+
const endpoints = buildToolCatalogEndpoints(runtimeKey);
|
|
114
117
|
for (const endpoint of endpoints) {
|
|
115
118
|
try {
|
|
116
119
|
const response = await client.get(endpoint, { timeoutMs: 10000 });
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portal HTTP Slack auth: start ticket, return slash command, complete with challenge.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Do not tell the browser user to install Slack CLI or re-run channel add
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
looksLikeSlackAccessToken,
|
|
11
|
+
slashCommandForTicket,
|
|
12
|
+
startSlackAuthTicket,
|
|
13
|
+
completeSlackAuthTicket
|
|
14
|
+
} = require('./slack-provisioning/auth-ticket');
|
|
15
|
+
const { SLACK_AUTH_HANDSHAKE_STEPS } = require('./channel-add-remaining');
|
|
16
|
+
const { redactSlackSecrets } = require('./slack-provisioning/errors');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} slashCommand
|
|
20
|
+
* @param {string} ticket
|
|
21
|
+
* @returns {{ waiting: true, result: Object }}
|
|
22
|
+
*/
|
|
23
|
+
function handshakeWaiting(slashCommand, ticket) {
|
|
24
|
+
return {
|
|
25
|
+
waiting: true,
|
|
26
|
+
result: {
|
|
27
|
+
connected: false,
|
|
28
|
+
remaining: [...SLACK_AUTH_HANDSHAKE_STEPS],
|
|
29
|
+
slashCommand,
|
|
30
|
+
slackAuthTicket: ticket
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {Error} error
|
|
37
|
+
* @returns {{ waiting: true, result: Object }}
|
|
38
|
+
*/
|
|
39
|
+
function handshakeFailed(error) {
|
|
40
|
+
const code = error && error.code;
|
|
41
|
+
const remaining = code === 'SLACK_CLI_MISSING'
|
|
42
|
+
? ['Slack authentication could not start on this host.']
|
|
43
|
+
: [redactSlackSecrets((error && error.message) || 'Slack authentication could not start.')];
|
|
44
|
+
return {
|
|
45
|
+
waiting: true,
|
|
46
|
+
result: {
|
|
47
|
+
connected: false,
|
|
48
|
+
remaining,
|
|
49
|
+
handshakeFailed: true
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {string} ticket
|
|
56
|
+
* @param {Error} error
|
|
57
|
+
* @returns {{ waiting: true, result: Object }}
|
|
58
|
+
*/
|
|
59
|
+
function handshakeRetry(ticket, error) {
|
|
60
|
+
const slashCommand = slashCommandForTicket(ticket);
|
|
61
|
+
if (!slashCommand) {
|
|
62
|
+
return handshakeFailed(error);
|
|
63
|
+
}
|
|
64
|
+
return handshakeWaiting(slashCommand, ticket);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {Error|Object|null} error
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
function isStaleSlackLoginError(error) {
|
|
72
|
+
const message = String((error && error.message) || '');
|
|
73
|
+
return /run the slack login command again|error handling your login/i.test(message);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {Object} [deps]
|
|
78
|
+
* @returns {Promise<{ waiting: true, result: Object }>}
|
|
79
|
+
*/
|
|
80
|
+
async function startOrFailHandshake(deps = {}) {
|
|
81
|
+
try {
|
|
82
|
+
const started = await startSlackAuthTicket(deps);
|
|
83
|
+
return handshakeWaiting(started.slashCommand, started.ticket);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return handshakeFailed(error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Quiet HTTP install: start or complete the Slack CLI ticket handshake.
|
|
91
|
+
* @param {Object} options
|
|
92
|
+
* @param {Object} deps
|
|
93
|
+
* @returns {Promise<{ waiting: boolean, result?: Object }>}
|
|
94
|
+
*/
|
|
95
|
+
async function preparePortalSlackAuth(options = {}, deps = {}) {
|
|
96
|
+
if (options.retryLogin === true) {
|
|
97
|
+
return startOrFailHandshake(deps);
|
|
98
|
+
}
|
|
99
|
+
const submitted = typeof options.vendorSessionToken === 'string'
|
|
100
|
+
? options.vendorSessionToken.trim()
|
|
101
|
+
: '';
|
|
102
|
+
const ticket = typeof options.slackAuthTicket === 'string'
|
|
103
|
+
? options.slackAuthTicket.trim()
|
|
104
|
+
: '';
|
|
105
|
+
if (looksLikeSlackAccessToken(submitted)) {
|
|
106
|
+
deps.slackUserToken = submitted;
|
|
107
|
+
return { waiting: false };
|
|
108
|
+
}
|
|
109
|
+
if (submitted && ticket) {
|
|
110
|
+
try {
|
|
111
|
+
deps.slackUserToken = await completeSlackAuthTicket({ ticket, challenge: submitted }, deps);
|
|
112
|
+
return { waiting: false };
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (isStaleSlackLoginError(error)) {
|
|
115
|
+
return startOrFailHandshake(deps);
|
|
116
|
+
}
|
|
117
|
+
return handshakeRetry(ticket, error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (ticket) {
|
|
121
|
+
return handshakeWaiting(slashCommandForTicket(ticket), ticket);
|
|
122
|
+
}
|
|
123
|
+
return startOrFailHandshake(deps);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = {
|
|
127
|
+
preparePortalSlackAuth,
|
|
128
|
+
handshakeWaiting,
|
|
129
|
+
handshakeFailed
|
|
130
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive Slack ticket handshake for `aifabrix channel add`.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Print slash command, collect challenge, complete auth token
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const inquirer = require('inquirer');
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const logger = require('../utils/logger');
|
|
12
|
+
const { printLabeledUrl } = require('./channel-add-tty');
|
|
13
|
+
const { isChannelAddInteractive } = require('./channel-add-wizard');
|
|
14
|
+
const { handshakeFailed, handshakeWaiting } = require('./slack-channel-add-portal');
|
|
15
|
+
const {
|
|
16
|
+
startSlackAuthTicket,
|
|
17
|
+
completeSlackAuthTicket
|
|
18
|
+
} = require('./slack-provisioning/auth-ticket');
|
|
19
|
+
const { slackProvisioningError } = require('./slack-provisioning/errors');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {Object} options
|
|
23
|
+
* @param {Object} deps
|
|
24
|
+
* @returns {boolean}
|
|
25
|
+
*/
|
|
26
|
+
function canRefreshInteractive(options = {}, deps = {}) {
|
|
27
|
+
if (options.quiet === true) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (typeof deps.promptChallenge === 'function') {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return isChannelAddInteractive(options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {Object} [deps]
|
|
38
|
+
* @returns {Promise<string>}
|
|
39
|
+
*/
|
|
40
|
+
async function promptChallengeCode(deps = {}) {
|
|
41
|
+
if (typeof deps.promptChallenge === 'function') {
|
|
42
|
+
return String((await deps.promptChallenge()) || '').trim();
|
|
43
|
+
}
|
|
44
|
+
const answers = await inquirer.prompt([
|
|
45
|
+
{
|
|
46
|
+
type: 'input',
|
|
47
|
+
name: 'challenge',
|
|
48
|
+
message: 'Challenge code',
|
|
49
|
+
validate: (value) => Boolean(String(value || '').trim()) || 'Challenge code is required'
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
return String(answers.challenge || '').trim();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @param {Object} started
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
function printHandshakeCommand(started) {
|
|
60
|
+
printLabeledUrl('Run in Slack', started.slashCommand);
|
|
61
|
+
logger.log(chalk.white('Approve the permissions Slack shows, then paste the challenge code.'));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Start a new Slack ticket, prompt for the challenge, store the session token on deps.
|
|
66
|
+
* @param {Object} deps
|
|
67
|
+
* @returns {Promise<{ ok: boolean, result?: Object }>}
|
|
68
|
+
*/
|
|
69
|
+
async function refreshInteractiveSlackAuth(deps = {}) {
|
|
70
|
+
let started = null;
|
|
71
|
+
try {
|
|
72
|
+
started = await startSlackAuthTicket(deps);
|
|
73
|
+
printHandshakeCommand(started);
|
|
74
|
+
const challenge = await promptChallengeCode(deps);
|
|
75
|
+
if (!challenge) {
|
|
76
|
+
throw slackProvisioningError('Challenge code is required.', 'SLACK_CLI');
|
|
77
|
+
}
|
|
78
|
+
deps.slackUserToken = await completeSlackAuthTicket({
|
|
79
|
+
ticket: started.ticket,
|
|
80
|
+
challenge
|
|
81
|
+
}, deps);
|
|
82
|
+
return { ok: true };
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (started && started.slashCommand) {
|
|
85
|
+
return { ok: false, result: handshakeWaiting(started.slashCommand, started.ticket).result };
|
|
86
|
+
}
|
|
87
|
+
return { ok: false, result: handshakeFailed(error).result };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
canRefreshInteractive,
|
|
93
|
+
promptChallengeCode,
|
|
94
|
+
refreshInteractiveSlackAuth
|
|
95
|
+
};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack channel-add provisioning hook (plan 176.0).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Keep add-channel.js free of Slack CLI/HTTP
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const { provisionSlackChannel } = require('./slack-provisioning');
|
|
10
|
+
const { ensureSlackCliReady } = require('./slack-provisioning/offer-cli');
|
|
11
|
+
const { SLACK_CLI_DOCS_URL } = require('./slack-provisioning/constants');
|
|
12
|
+
const { redactSlackSecrets } = require('./slack-provisioning/errors');
|
|
13
|
+
const { isSlackAuthDeadError } = require('./slack-provisioning/auth-ticket');
|
|
14
|
+
const { preparePortalSlackAuth } = require('./slack-channel-add-portal');
|
|
15
|
+
const { canRefreshInteractive, refreshInteractiveSlackAuth } = require('./slack-channel-add-tty-auth');
|
|
16
|
+
const { SLACK_AUTH_HANDSHAKE_STEPS } = require('./channel-add-remaining');
|
|
17
|
+
const { readProvisioningState, hasProvenAppIdentity } = require('./slack-provisioning/persist');
|
|
18
|
+
const { slackConsentRemaining, slackConsentUrls } = require('./slack-provisioning/remaining-urls');
|
|
19
|
+
const { ensureChannelUploaded } = require('./channel-add-ensure');
|
|
20
|
+
const {
|
|
21
|
+
maybeOnboardSlackUsers,
|
|
22
|
+
unmatchedRemainingStep
|
|
23
|
+
} = require('./slack-provisioning/onboard');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {Error} error
|
|
27
|
+
* @returns {string[]}
|
|
28
|
+
*/
|
|
29
|
+
function remainingFromError(error) {
|
|
30
|
+
const code = error && error.code;
|
|
31
|
+
if (code === 'CALLBACKS') {
|
|
32
|
+
return [
|
|
33
|
+
'Use a public HTTPS dataplane URL for Slack Events, Interactivity, and commands'
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
if (code === 'UNPROVEN_IDENTITY' && error && error.message) {
|
|
37
|
+
return [error.message];
|
|
38
|
+
}
|
|
39
|
+
if (code === 'SLACK_CLI_MISSING') {
|
|
40
|
+
return [
|
|
41
|
+
`Install Slack CLI (${SLACK_CLI_DOCS_URL}) and run slack login`,
|
|
42
|
+
'Re-run channel add to create the Slack app automatically',
|
|
43
|
+
'Approve the workspace install if Slack asks'
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
if (isSlackAuthDeadError(error)) {
|
|
47
|
+
return [...SLACK_AUTH_HANDSHAKE_STEPS];
|
|
48
|
+
}
|
|
49
|
+
const detail = redactSlackSecrets(
|
|
50
|
+
(error && error.message) || 'Slack app provisioning failed'
|
|
51
|
+
);
|
|
52
|
+
return [detail, 'Approve the workspace install if Slack asks'];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @param {Error} error
|
|
57
|
+
* @param {boolean} hasApp
|
|
58
|
+
* @returns {boolean}
|
|
59
|
+
*/
|
|
60
|
+
function shouldUseConsentRemaining(error, hasApp) {
|
|
61
|
+
if (!hasApp) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const code = error && error.code;
|
|
65
|
+
if (isSlackAuthDeadError(error)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return code !== 'CALLBACKS' && code !== 'SLACK_CLI_MISSING' && code !== 'UNPROVEN_IDENTITY';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Existing Slack app: print app + install-on-team URLs, not the generic apps list.
|
|
73
|
+
* @param {string} projectRoot
|
|
74
|
+
* @param {Error} error
|
|
75
|
+
* @returns {Object}
|
|
76
|
+
*/
|
|
77
|
+
function recoveryFromExistingApp(projectRoot, error) {
|
|
78
|
+
const state = readProvisioningState(projectRoot);
|
|
79
|
+
const hasApp = hasProvenAppIdentity(state);
|
|
80
|
+
const urls = hasApp ? slackConsentUrls(state) : {};
|
|
81
|
+
return {
|
|
82
|
+
connected: false,
|
|
83
|
+
remaining: shouldUseConsentRemaining(error, hasApp)
|
|
84
|
+
? slackConsentRemaining({ storedSigningSecret: Boolean(state && state.secretsStored) })
|
|
85
|
+
: remainingFromError(error),
|
|
86
|
+
recovery: true,
|
|
87
|
+
error: error && error.message ? error.message : String(error),
|
|
88
|
+
appId: hasApp ? state.appId : undefined,
|
|
89
|
+
...urls
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Prompt/run Slack email onboard and attach TTY counts (no member dump).
|
|
95
|
+
* @param {Object} ttyCtx
|
|
96
|
+
* @param {Object} options
|
|
97
|
+
* @returns {Promise<Object>}
|
|
98
|
+
*/
|
|
99
|
+
async function applySlackOnboardToCtx(ttyCtx, options = {}) {
|
|
100
|
+
const deps = options.slackProvisioningDeps || {};
|
|
101
|
+
try {
|
|
102
|
+
const onboard = await maybeOnboardSlackUsers({ ctx: ttyCtx, options }, deps);
|
|
103
|
+
if (!onboard.ran) {
|
|
104
|
+
return ttyCtx;
|
|
105
|
+
}
|
|
106
|
+
const extra = unmatchedRemainingStep(onboard.unmatched);
|
|
107
|
+
return {
|
|
108
|
+
...ttyCtx,
|
|
109
|
+
slackOnboarded: onboard.linked,
|
|
110
|
+
slackRemaining: [...(ttyCtx.slackRemaining || []), extra].filter(Boolean)
|
|
111
|
+
};
|
|
112
|
+
} catch {
|
|
113
|
+
return {
|
|
114
|
+
...ttyCtx,
|
|
115
|
+
slackRemaining: [
|
|
116
|
+
...(ttyCtx.slackRemaining || []),
|
|
117
|
+
'Slack user onboard could not finish'
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Publish the Slack instance CS so webhookInbound and channel.definitionKey
|
|
125
|
+
* can be patched even when Slack CLI has not returned a bot token yet.
|
|
126
|
+
*
|
|
127
|
+
* @param {Object} result
|
|
128
|
+
* @param {Object} options
|
|
129
|
+
* @param {Object} deps
|
|
130
|
+
* @returns {Promise<void>}
|
|
131
|
+
*/
|
|
132
|
+
async function publishSlackAfterSecrets(_result, options, deps) {
|
|
133
|
+
const publish = deps.ensureChannelUploaded || ensureChannelUploaded;
|
|
134
|
+
await publish('slack', {
|
|
135
|
+
...options,
|
|
136
|
+
force: true,
|
|
137
|
+
suppressUploadedLine: true
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Portal HTTP has no Slack CLI: still publish the instance CS, then remaining steps.
|
|
143
|
+
* @param {string} projectRoot
|
|
144
|
+
* @param {Error} error
|
|
145
|
+
* @param {Object} options
|
|
146
|
+
* @param {Object} deps
|
|
147
|
+
* @returns {Promise<Object>}
|
|
148
|
+
*/
|
|
149
|
+
async function recoverSlackProvisionFailure(projectRoot, error, options, deps) {
|
|
150
|
+
if (error && error.code === 'MANIFEST') {
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
await publishSlackAfterSecrets({ connected: false }, options, deps);
|
|
154
|
+
return recoveryFromExistingApp(projectRoot, error);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {Object} [options]
|
|
159
|
+
* @returns {Object}
|
|
160
|
+
*/
|
|
161
|
+
function slackDepsFromOptions(options = {}) {
|
|
162
|
+
const deps = { ...(options.slackProvisioningDeps || {}) };
|
|
163
|
+
const token = typeof options.vendorSessionToken === 'string'
|
|
164
|
+
? options.vendorSessionToken.trim()
|
|
165
|
+
: '';
|
|
166
|
+
if (token) {
|
|
167
|
+
deps.slackUserToken = token;
|
|
168
|
+
}
|
|
169
|
+
return deps;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @param {Object} params
|
|
174
|
+
* @returns {Promise<Object|null>}
|
|
175
|
+
*/
|
|
176
|
+
async function provisionAndPublish(params, options, deps, ctx, projectRoot) {
|
|
177
|
+
const result = await provisionSlackChannel(
|
|
178
|
+
{
|
|
179
|
+
projectRoot,
|
|
180
|
+
runtimeValues: params.runtimeValues,
|
|
181
|
+
artifact: params.artifact,
|
|
182
|
+
ctx,
|
|
183
|
+
environment: ctx.environment,
|
|
184
|
+
expectedTeamId: options.expectedTeamId,
|
|
185
|
+
force: options.force === true,
|
|
186
|
+
quiet: options.quiet === true
|
|
187
|
+
},
|
|
188
|
+
deps
|
|
189
|
+
);
|
|
190
|
+
await publishSlackAfterSecrets(result, options, deps);
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @param {Error} error
|
|
196
|
+
* @param {Object} params
|
|
197
|
+
* @param {Object} options
|
|
198
|
+
* @param {Object} deps
|
|
199
|
+
* @param {Object} ctx
|
|
200
|
+
* @param {string} projectRoot
|
|
201
|
+
* @returns {Promise<Object>}
|
|
202
|
+
*/
|
|
203
|
+
async function recoverOrRefreshAuth(error, params, options, deps, ctx, projectRoot) {
|
|
204
|
+
if (error && error.code === 'MANIFEST') {
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
if (isSlackAuthDeadError(error) && canRefreshInteractive(options, deps)) {
|
|
208
|
+
const refresh = await refreshInteractiveSlackAuth(deps);
|
|
209
|
+
if (refresh.ok) {
|
|
210
|
+
try {
|
|
211
|
+
return await provisionAndPublish(params, options, deps, ctx, projectRoot);
|
|
212
|
+
} catch (retryError) {
|
|
213
|
+
return recoverSlackProvisionFailure(projectRoot, retryError, options, deps);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
await publishSlackAfterSecrets({ connected: false }, options, deps);
|
|
217
|
+
return refresh.result;
|
|
218
|
+
}
|
|
219
|
+
return recoverSlackProvisionFailure(projectRoot, error, options, deps);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @param {Object} params
|
|
224
|
+
* @returns {Promise<Object|null>}
|
|
225
|
+
*/
|
|
226
|
+
async function maybeProvisionSlackChannel(params) {
|
|
227
|
+
if (!params || params.channelTarget !== 'slack') {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
if (params.options && params.options.dryRun === true) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
const ctx = params.ctx || {};
|
|
234
|
+
const options = params.options || {};
|
|
235
|
+
const deps = slackDepsFromOptions(options);
|
|
236
|
+
const projectRoot = options.projectRoot || process.cwd();
|
|
237
|
+
if (options.quiet === true) {
|
|
238
|
+
const portal = await preparePortalSlackAuth(options, deps);
|
|
239
|
+
if (portal.waiting) {
|
|
240
|
+
await publishSlackAfterSecrets({ connected: false }, options, deps);
|
|
241
|
+
return portal.result;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
if (options.quiet !== true) {
|
|
246
|
+
await ensureSlackCliReady(options, deps);
|
|
247
|
+
}
|
|
248
|
+
return await provisionAndPublish(params, options, deps, ctx, projectRoot);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
return recoverOrRefreshAuth(error, params, options, deps, ctx, projectRoot);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
module.exports = {
|
|
255
|
+
maybeProvisionSlackChannel,
|
|
256
|
+
applySlackOnboardToCtx,
|
|
257
|
+
remainingFromError
|
|
258
|
+
};
|