@aifabrix/builder 2.45.5 → 2.47.0
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/.cursor/rules/cli-layout.mdc +2 -0
- package/.cursor/rules/cli-product-neutral.mdc +43 -0
- package/.cursor/rules/project-rules.mdc +1 -0
- package/.npmrc.token +1 -0
- package/.temp/jest-protection-convert/run-IFN2nv/.protection/hubspot-companies.json +1 -0
- package/.temp/jest-protection-convert/run-IvmKLO/.protection/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-convert/run-SdvblF/.protection/hubspot-companies.json +1 -0
- package/.temp/jest-protection-convert/run-b51TsW/.protection/hubspot-companies.json +1 -0
- package/.temp/jest-protection-convert/run-fiLmb1/.protection/hubspot-companies.json +1 -0
- package/.temp/jest-protection-convert/run-qYGHMU/.protection/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-fixtures/hubspot-Mq5re8/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-fixtures/hubspot-f3u4YL/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-fixtures/hubspot-iQtd1O/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-fixtures/hubspot-mdmz5M/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-fixtures/hubspot-qbKYxQ/hubspot-companies.yaml +17 -0
- package/.temp/jest-protection-fixtures/hubspot-yzlJy6/hubspot-companies.yaml +17 -0
- package/.temp/validation/summary.txt +5 -0
- package/README.md +43 -17
- package/integration/hubspot-test/test-artifacts/wizard-hubspot-credential-real.yaml +1 -1
- package/integration/hubspot-test/test-artifacts/wizard-hubspot-env-vars.yaml +1 -1
- package/jest.config.default.js +2 -1
- package/jest.config.isolated.js +2 -1
- package/jest.global-live-fabrix-hooks.js +36 -0
- package/jest.isolated-projects.js +146 -0
- package/jest.projects.js +65 -136
- package/lib/api/api-response-errors.js +124 -0
- package/lib/api/dataplane-health.api.js +19 -7
- package/lib/api/governance-scenario-pack.api.js +159 -0
- package/lib/api/index.js +43 -3
- package/lib/api/lifecycle.api.js +98 -0
- package/lib/api/pipeline.api.js +3 -1
- package/lib/api/records-bulk.api.js +14 -1
- package/lib/api/resource-types.api.js +107 -0
- package/lib/api/runtime-configuration.api.js +72 -0
- package/lib/api/types/resource-types.types.js +45 -0
- package/lib/api/user-groups.api.js +9 -9
- package/lib/api/users.api.js +8 -8
- package/lib/api/validation-runner.js +3 -1
- package/lib/api/wizard.api.js +10 -2
- package/lib/app/deploy-config.js +4 -1
- package/lib/app/down.js +78 -27
- package/lib/app/index.js +2 -2
- package/lib/app/push.js +4 -5
- package/lib/app/register.js +7 -4
- package/lib/app/run-env-compose.js +84 -30
- package/lib/app/run-resolve-image.js +2 -1
- package/lib/app/run-stop-containers.js +113 -0
- package/lib/app/run.js +1 -31
- package/lib/app/show-display.js +35 -0
- package/lib/app/show.js +32 -1
- package/lib/build/index.js +22 -5
- package/lib/build/miso-controller-npm-sdk-guard.js +25 -0
- package/lib/certification/sync-system-certification.js +13 -6
- package/lib/channels/add-channel.js +348 -0
- package/lib/channels/channel-artifact-generator.js +141 -0
- package/lib/channels/channel-audit.js +101 -0
- package/lib/channels/channel-auth-context.js +37 -0
- package/lib/channels/channel-credential.js +200 -0
- package/lib/channels/channel-display-name.js +64 -0
- package/lib/channels/channel-external-system.js +106 -0
- package/lib/channels/channel-integration-generator.js +274 -0
- package/lib/channels/channel-probe.js +89 -0
- package/lib/channels/channel-runtime-resolver.js +152 -0
- package/lib/channels/channel-status-display.js +141 -0
- package/lib/channels/channel-targets.js +115 -0
- package/lib/cli/index.js +20 -4
- package/lib/cli/infra-guided-auth.js +109 -0
- package/lib/cli/infra-guided.js +84 -81
- package/lib/cli/setup-app.help.js +0 -31
- package/lib/cli/setup-app.js +82 -5
- package/lib/cli/setup-app.test-commands.js +5 -57
- package/lib/cli/setup-auth.js +25 -0
- package/lib/cli/setup-certification-commands.js +147 -0
- package/lib/cli/setup-certification.help.js +141 -0
- package/lib/cli/setup-environment.js +19 -2
- package/lib/cli/setup-external-system-help.js +62 -0
- package/lib/cli/setup-external-system.js +25 -3
- package/lib/cli/setup-infra-up-dataplane-action.js +2 -2
- package/lib/cli/setup-infra-up-platform-action.js +2 -1
- package/lib/cli/setup-infra.js +9 -1
- package/lib/cli/setup-platform.js +6 -1
- package/lib/cli/setup-secrets.js +33 -1
- package/lib/cli/setup-utility-help-after.js +25 -2
- package/lib/cli/setup-utility-repair.js +198 -0
- package/lib/cli/setup-utility-resolve.js +44 -5
- package/lib/cli/setup-utility-validate.js +197 -0
- package/lib/cli/setup-utility.js +4 -239
- package/lib/commands/app-logs.js +54 -26
- package/lib/commands/app.js +41 -0
- package/lib/commands/auth-status-client-tokens.js +214 -0
- package/lib/commands/auth-status-dataplane-version.js +142 -68
- package/lib/commands/auth-status.js +43 -54
- package/lib/commands/channel.js +58 -0
- package/lib/commands/datasource-test-trust-cli.js +27 -23
- package/lib/commands/datasource-unified-test-cli.js +6 -3
- package/lib/commands/datasource-unified-test-cli.options.js +5 -1
- package/lib/commands/datasource.js +8 -8
- package/lib/commands/dev-show-display.js +8 -1
- package/lib/commands/governance-cli-shared.js +94 -0
- package/lib/commands/governance-command-action.js +132 -0
- package/lib/commands/governance-download-external.js +34 -0
- package/lib/commands/governance-generate-external.js +71 -0
- package/lib/commands/governance-upload-external.js +36 -0
- package/lib/commands/governance-verify-external.js +64 -0
- package/lib/commands/governance.js +144 -0
- package/lib/commands/identity-apply-sync.js +49 -8
- package/lib/commands/identity-group-cli.js +66 -26
- package/lib/commands/identity-membership-role-cache.js +58 -37
- package/lib/commands/identity-shared.js +22 -1
- package/lib/commands/identity-user-cli.js +80 -34
- package/lib/commands/lifecycle-command-action.js +123 -0
- package/lib/commands/lifecycle-external.js +268 -0
- package/lib/commands/login.js +11 -2
- package/lib/commands/repair-auth-apply.js +153 -0
- package/lib/commands/repair-auth-config.js +8 -13
- package/lib/commands/repair-changed-files.js +41 -0
- package/lib/commands/repair-datasource-com-v2.js +15 -0
- package/lib/commands/repair-datasource-keys.js +4 -1
- package/lib/commands/repair-datasource-run.js +59 -0
- package/lib/commands/repair-datasource-service-contract.js +206 -0
- package/lib/commands/repair-datasource-test-payload.js +259 -0
- package/lib/commands/repair-datasource.js +49 -64
- package/lib/commands/repair-env-template.js +76 -25
- package/lib/commands/repair-external-run.js +216 -0
- package/lib/commands/repair-openapi-sync.js +49 -4
- package/lib/commands/repair-persist.js +4 -0
- package/lib/commands/repair-rbac.js +52 -1
- package/lib/commands/repair-steps.js +160 -0
- package/lib/commands/repair-system-alignment.js +7 -4
- package/lib/commands/repair.js +29 -296
- package/lib/commands/resource-type.js +371 -0
- package/lib/commands/secrets-get.js +184 -0
- package/lib/commands/secrets-remove-all.js +3 -1
- package/lib/commands/setup-image-refresh.js +146 -0
- package/lib/commands/setup-modes.js +158 -162
- package/lib/commands/setup-platform-auth.js +76 -0
- package/lib/commands/setup-prompts-admin.js +244 -0
- package/lib/commands/setup-prompts-platform-mode.js +70 -0
- package/lib/commands/setup-prompts-validators.js +36 -0
- package/lib/commands/setup-prompts.js +24 -76
- package/lib/commands/setup-run-context.js +45 -0
- package/lib/commands/setup-spinners.js +39 -0
- package/lib/commands/setup.js +27 -5
- package/lib/commands/teardown.js +39 -0
- package/lib/commands/test-e2e-external.js +24 -8
- package/lib/commands/test-governance-external.js +3 -24
- package/lib/commands/test-trust-external.js +48 -100
- package/lib/commands/up-common.js +57 -13
- package/lib/commands/up-dataplane.js +56 -15
- package/lib/commands/upload-publish-context.js +75 -0
- package/lib/commands/upload-sidecar-followups.js +89 -0
- package/lib/commands/upload.js +113 -110
- package/lib/commands/verify-governance-combined-external.js +61 -0
- package/lib/commands/verify-governance-command-action.js +64 -0
- package/lib/commands/verify-governance-db.js +102 -0
- package/lib/commands/verify-governance-external.js +77 -0
- package/lib/commands/verify-governance-result-builders.js +71 -0
- package/lib/commands/verify-operations-command-action.js +68 -0
- package/lib/commands/verify-operations-external.js +268 -0
- package/lib/commands/verify-operations-persist.js +75 -0
- package/lib/commands/verify-operations-step-plan.js +68 -0
- package/lib/commands/verify-operations-steps.js +111 -0
- package/lib/commands/verify-trust-command-action.js +73 -0
- package/lib/commands/verify-trust-external.js +59 -0
- package/lib/commands/wizard-config-normalizer.js +43 -23
- package/lib/commands/wizard-core.js +2 -0
- package/lib/core/admin-password-generator.js +38 -0
- package/lib/core/admin-secrets-bundle.js +111 -0
- package/lib/core/admin-secrets-env-overlay.js +62 -0
- package/lib/core/admin-secrets.js +32 -4
- package/lib/core/config-attach-extensions.js +3 -0
- package/lib/core/config-platform-controller.js +44 -0
- package/lib/core/config-setup-installation-profile.js +42 -0
- package/lib/core/config-setup-platform-mode.js +46 -0
- package/lib/core/config.js +46 -36
- package/lib/core/secrets-admin-env.js +6 -2
- package/lib/core/secrets-ensure.js +4 -0
- package/lib/core/secrets-env-content.js +54 -48
- package/lib/core/secrets-env-write.js +10 -1
- package/lib/core/secrets-infra-placeholder-sync.js +2 -0
- package/lib/core/setup-installation-profile.js +43 -0
- package/lib/core/setup-platform-mode.js +90 -0
- package/lib/datasource/agent-trust-debug-log.js +1 -1
- package/lib/datasource/agent-trust-run.js +5 -3
- package/lib/datasource/audit-evidence-extract-debug.js +30 -18
- package/lib/datasource/audit-evidence-extract.js +7 -4
- package/lib/datasource/audit-evidence-verify-matrix.js +54 -26
- package/lib/datasource/bulk-loader-run-batches.js +15 -3
- package/lib/datasource/capability/capability-diff-slice.js +2 -2
- package/lib/datasource/capability/capability-manifest.js +254 -0
- package/lib/datasource/capability/capability-resolve.js +3 -4
- package/lib/datasource/capability/copy-operations.js +5 -3
- package/lib/datasource/capability/remove-operations.js +2 -1
- package/lib/datasource/capability/run-capability-copy.js +32 -4
- package/lib/datasource/capability/run-capability-diff.js +3 -3
- package/lib/datasource/capability/run-capability-dimension.js +2 -4
- package/lib/datasource/capability/run-capability-edit.js +4 -7
- package/lib/datasource/capability/run-capability-relate.js +2 -4
- package/lib/datasource/capability/run-capability-remove.js +2 -4
- package/lib/datasource/capability/validate-capability-slice.js +2 -1
- package/lib/datasource/datasource-identifier.js +2 -1
- package/lib/datasource/datasource-load-export-context.js +3 -0
- package/lib/datasource/datasource-validate-display.js +1 -1
- package/lib/datasource/field-reference-validator.js +24 -3
- package/lib/datasource/log-cleaner.js +2 -2
- package/lib/datasource/log-viewer.js +8 -8
- package/lib/datasource/orphan-profiles-validator.js +98 -0
- package/lib/datasource/test-e2e.js +4 -1
- package/lib/datasource/unified-validation-run-body.js +3 -1
- package/lib/datasource/unified-validation-run.js +5 -2
- package/lib/datasource/validate.js +41 -23
- package/lib/deployment/environment-poll-status.js +138 -0
- package/lib/deployment/environment.js +42 -34
- package/lib/external-system/download-helpers.js +87 -0
- package/lib/external-system/download.js +78 -138
- package/lib/external-system/generator.js +1 -55
- package/lib/external-system/integration-auth-context.js +45 -0
- package/lib/external-system/test-auth.js +12 -5
- package/lib/external-system/test.js +16 -21
- package/lib/generator/builders.js +11 -1
- package/lib/generator/external-controller-manifest.js +18 -0
- package/lib/generator/split.js +3 -1
- package/lib/generator/wizard.js +1 -28
- package/lib/governance/governance-cli-errors.js +96 -0
- package/lib/governance/governance-download-display.js +38 -0
- package/lib/governance/governance-run-display.js +215 -25
- package/lib/identity/fk-reference.js +65 -0
- package/lib/identity/identity-apply-core.js +13 -58
- package/lib/identity/identity-apply-phases.js +5 -1
- package/lib/identity/identity-display.js +243 -0
- package/lib/identity/identity-response-helpers.js +52 -0
- package/lib/identity/identity-sync-errors.js +62 -0
- package/lib/identity/resolve-user-id.js +129 -0
- package/lib/identity/username-default.js +31 -0
- package/lib/infrastructure/admin-secrets-apply.js +84 -0
- package/lib/infrastructure/admin-secrets-ensure.js +130 -0
- package/lib/infrastructure/admin-secrets-resolve.js +95 -0
- package/lib/infrastructure/admin-secrets-sync.js +91 -0
- package/lib/infrastructure/helpers.js +23 -129
- package/lib/infrastructure/index.js +5 -6
- package/lib/infrastructure/orphan-infra-docker-teardown.js +11 -5
- package/lib/lifecycle/certification-progress.js +231 -0
- package/lib/lifecycle/dataplane-ui-url.js +145 -0
- package/lib/lifecycle/exit-codes.js +24 -0
- package/lib/lifecycle/json-envelope.js +25 -0
- package/lib/lifecycle/lifecycle-governance-options.js +51 -0
- package/lib/lifecycle/logger-quiet.js +29 -0
- package/lib/lifecycle/open-api-published.js +59 -0
- package/lib/lifecycle/operations-readiness-metrics.js +101 -0
- package/lib/lifecycle/product-model.js +196 -0
- package/lib/lifecycle/report-display-trust.js +70 -0
- package/lib/lifecycle/report-display.js +472 -0
- package/lib/lifecycle/scenario-upload.js +191 -0
- package/lib/lifecycle/verify-step-progress.js +87 -0
- package/lib/parameters/infra-kv-discovery.js +27 -2
- package/lib/protection/auth-context.js +10 -4
- package/lib/resolvers/datasource-resolver.js +2 -3
- package/lib/resolvers/resource-type-file.js +159 -0
- package/lib/schema/application-schema.json +17 -1
- package/lib/schema/datasource-test-run.schema.json +89 -6
- package/lib/schema/deployment-rules.yaml +2 -1
- package/lib/schema/external-datasource.schema.json +2947 -2619
- package/lib/schema/external-system.schema.json +1418 -761
- package/lib/schema/infra.parameter.yaml +45 -0
- package/lib/schema/type/credential-field-registry.json +103 -97
- package/lib/schema/type/document-storage.json +9 -5
- package/lib/utils/aifabrix-test-runtime-guard.js +125 -0
- package/lib/utils/api.js +55 -31
- package/lib/utils/app-relative-path-env.js +112 -0
- package/lib/utils/app-run-containers.js +25 -2
- package/lib/utils/authentication-shape.js +224 -0
- package/lib/utils/build-copy.js +36 -5
- package/lib/utils/build-resolve-image.js +66 -12
- package/lib/utils/celery-companion-apps.js +53 -0
- package/lib/utils/cli-secrets-error-format.js +83 -21
- package/lib/utils/cli-utils.js +20 -4
- package/lib/utils/compose-celery-worker.js +23 -0
- package/lib/utils/compose-generate-docker-compose.js +13 -1
- package/lib/utils/compose-traefik-ingress-base.js +16 -1
- package/lib/utils/config-secrets-path.js +46 -0
- package/lib/utils/configuration-env-resolver.js +36 -0
- package/lib/utils/controller-url.js +88 -1
- package/lib/utils/credential-secrets-env-kv.js +216 -0
- package/lib/utils/credential-secrets-env.js +175 -257
- package/lib/utils/dataplane-resolver.js +18 -2
- package/lib/utils/declarative-url-ports.js +27 -4
- package/lib/utils/deployment-auth-mode.js +41 -0
- package/lib/utils/developer-volume-id.js +33 -0
- package/lib/utils/docker-build.js +1 -4
- package/lib/utils/env-copy.js +14 -9
- package/lib/utils/env-kv-orphan-lines.js +43 -0
- package/lib/utils/error-formatters/network-errors.js +13 -4
- package/lib/utils/external-env-template.js +11 -3
- package/lib/utils/external-system-readiness-core.js +10 -0
- package/lib/utils/external-system-readiness-display.js +80 -23
- package/lib/utils/external-system-validators.js +8 -2
- package/lib/utils/health-check.js +4 -1
- package/lib/utils/help-builder.js +13 -8
- package/lib/utils/keycloak-realm-ready.js +101 -0
- package/lib/utils/load-cip-capacity-display-config.js +61 -15
- package/lib/utils/manifest-source-emit.js +2 -0
- package/lib/utils/paths.js +25 -0
- package/lib/utils/pipeline-upload-auth-retry.js +82 -0
- package/lib/utils/platform-controller-url.js +157 -0
- package/lib/utils/platform-kv-ref.js +57 -0
- package/lib/utils/postgres-platform-bootstrap.js +199 -0
- package/lib/utils/postgres-wipe.js +9 -2
- package/lib/utils/resolve-env-mode.js +47 -0
- package/lib/utils/runtime-configuration-download.js +189 -0
- package/lib/utils/runtime-configuration-values.js +119 -0
- package/lib/utils/schema-loader.js +19 -4
- package/lib/utils/secrets-generator.js +31 -25
- package/lib/utils/secrets-missing-error.js +164 -0
- package/lib/utils/service-url-label.js +81 -0
- package/lib/utils/setup-quiet-output.js +25 -0
- package/lib/utils/template-helpers.js +15 -0
- package/lib/utils/token-manager-client-credentials.js +201 -0
- package/lib/utils/token-manager-messages.js +8 -0
- package/lib/utils/token-manager-refresh.js +12 -2
- package/lib/utils/token-manager.js +86 -105
- package/lib/utils/upload-pipeline-ui.js +12 -5
- package/lib/utils/upload-sync-options.js +42 -0
- package/lib/utils/url-declarative-public-base.js +21 -3
- package/lib/utils/url-declarative-vdir-inactive-env.js +14 -4
- package/lib/utils/validation-poll-ui.js +8 -0
- package/lib/utils/validation-run-stage.js +45 -0
- package/lib/utils/worker-sidecars.js +142 -0
- package/lib/validation/external-manifest-validator.js +2 -0
- package/lib/validation/runtime-configuration-rules.js +98 -0
- package/lib/validation/validate-display-dimensions.js +154 -0
- package/lib/validation/validate-display-sections.js +276 -0
- package/lib/validation/validate-display-steps.js +67 -0
- package/lib/validation/validate-display.js +24 -402
- package/package.json +1 -1
- package/templates/applications/dataplane/application.yaml +7 -1
- package/templates/applications/dataplane/env.template +50 -14
- package/templates/applications/dataplane/rbac.yaml +108 -1
- package/templates/applications/miso-controller/application.yaml +2 -2
- package/templates/applications/miso-controller/env.template +53 -122
- package/templates/applications/miso-controller/rbac.yaml +28 -13
- package/templates/channels/chatgpt/install.template.md.hbs +49 -0
- package/templates/channels/chatgpt/manifest.template.json.hbs +9 -0
- package/templates/channels/microsoft-copilot/install.template.md.hbs +49 -0
- package/templates/channels/microsoft-copilot/manifest.template.json.hbs +8 -0
- package/templates/channels/slack/install.template.md.hbs +49 -0
- package/templates/channels/slack/manifest.template.json.hbs +66 -0
- package/templates/channels/teams-bot/install.template.md.hbs +49 -0
- package/templates/channels/teams-bot/manifest.template.json.hbs +13 -0
- package/templates/channels/web-embed/install.template.md.hbs +49 -0
- package/templates/channels/web-embed/manifest.template.json.hbs +8 -0
- package/templates/external-system/README.md.hbs +74 -17
- package/templates/python/docker-compose.hbs +75 -18
- package/templates/typescript/docker-compose.hbs +70 -17
- package/lib/commands/test-governance-command-action.js +0 -55
- package/lib/commands/test-trust-command-action.js +0 -118
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External integration repair orchestration (local file updates, manifest, README).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Repair external integration run pipeline
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const { normalizeDatasourceKeysAndFilenames } = require('./repair-datasource-keys');
|
|
12
|
+
const { resolveSystemContext } = require('./repair-system-alignment');
|
|
13
|
+
const { persistChangesAndRegenerate, regenerateReadmeIfRequested } = require('./repair-persist');
|
|
14
|
+
const { runRepairSteps } = require('./repair-steps');
|
|
15
|
+
const { runDatasourceRepairs } = require('./repair-datasource-run');
|
|
16
|
+
const { maybeRepairRbac } = require('./repair-rbac');
|
|
17
|
+
const { maybeRunOpenApiSyncForMcp } = require('./repair-openapi-sync');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {Object} steps
|
|
21
|
+
* @param {boolean} anyUpdated
|
|
22
|
+
* @param {boolean} manifestRegenerated
|
|
23
|
+
* @param {boolean} readmeRegenerated
|
|
24
|
+
* @param {Object} ctx
|
|
25
|
+
* @returns {Object}
|
|
26
|
+
*/
|
|
27
|
+
function buildRepairResult(steps, anyUpdated, manifestRegenerated, readmeRegenerated, ctx) {
|
|
28
|
+
return Object.assign(
|
|
29
|
+
{
|
|
30
|
+
updated: anyUpdated,
|
|
31
|
+
actionsPerformed: ctx.actionsPerformed === true,
|
|
32
|
+
changes: ctx.changes,
|
|
33
|
+
warnings: ctx.warnings || [],
|
|
34
|
+
changedFiles: ctx.changedFiles || [],
|
|
35
|
+
systemFiles: ctx.systemFiles,
|
|
36
|
+
datasourceFiles: ctx.datasourceFiles,
|
|
37
|
+
backupPaths: ctx.backupPaths || []
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
appKeyFixed: steps.appKeyFixed,
|
|
41
|
+
datasourceKeysFixed: steps.datasourceKeysFixed,
|
|
42
|
+
rbacFileCreated: steps.rbacFileCreated,
|
|
43
|
+
envTemplateRepaired: steps.envTemplateRepaired,
|
|
44
|
+
manifestRegenerated,
|
|
45
|
+
readmeRegenerated
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {Object} params
|
|
52
|
+
* @returns {Object}
|
|
53
|
+
*/
|
|
54
|
+
function prepareRepairWorkspace(params) {
|
|
55
|
+
const {
|
|
56
|
+
options,
|
|
57
|
+
appPath,
|
|
58
|
+
configPath,
|
|
59
|
+
dryRun,
|
|
60
|
+
authOption,
|
|
61
|
+
backupCtx,
|
|
62
|
+
variables,
|
|
63
|
+
systemFiles,
|
|
64
|
+
datasourceFiles: initialDatasourceFiles
|
|
65
|
+
} = params;
|
|
66
|
+
const changes = [];
|
|
67
|
+
const warnings = [];
|
|
68
|
+
const { systemFilePath, systemParsed, systemKey } = resolveSystemContext(appPath, systemFiles);
|
|
69
|
+
const rbacFmt = options.format === 'json' ? 'json' : 'yaml';
|
|
70
|
+
const { updated: keysNormalized, datasourceFiles } = normalizeDatasourceKeysAndFilenames(
|
|
71
|
+
appPath,
|
|
72
|
+
initialDatasourceFiles,
|
|
73
|
+
systemKey,
|
|
74
|
+
{ variables, dryRun, changes, backupCtx }
|
|
75
|
+
);
|
|
76
|
+
return {
|
|
77
|
+
options,
|
|
78
|
+
appPath,
|
|
79
|
+
configPath,
|
|
80
|
+
dryRun,
|
|
81
|
+
authOption,
|
|
82
|
+
backupCtx,
|
|
83
|
+
variables,
|
|
84
|
+
systemFiles,
|
|
85
|
+
changes,
|
|
86
|
+
warnings,
|
|
87
|
+
systemFilePath,
|
|
88
|
+
systemParsed,
|
|
89
|
+
systemKey,
|
|
90
|
+
rbacFmt,
|
|
91
|
+
keysNormalized,
|
|
92
|
+
datasourceFiles
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {Object} ws
|
|
98
|
+
* @returns {Promise<Object>}
|
|
99
|
+
*/
|
|
100
|
+
async function runRepairIntegrationFileSteps(ws) {
|
|
101
|
+
const steps = runRepairSteps({
|
|
102
|
+
appPath: ws.appPath,
|
|
103
|
+
configPath: ws.configPath,
|
|
104
|
+
variables: ws.variables,
|
|
105
|
+
systemFilePath: ws.systemFilePath,
|
|
106
|
+
systemParsed: ws.systemParsed,
|
|
107
|
+
systemKey: ws.systemKey,
|
|
108
|
+
systemFiles: ws.systemFiles,
|
|
109
|
+
datasourceFiles: ws.datasourceFiles,
|
|
110
|
+
dryRun: ws.dryRun,
|
|
111
|
+
changes: ws.changes,
|
|
112
|
+
warnings: ws.warnings,
|
|
113
|
+
auth: ws.authOption,
|
|
114
|
+
format: ws.rbacFmt,
|
|
115
|
+
backupCtx: ws.backupCtx
|
|
116
|
+
});
|
|
117
|
+
const datasourceRepairUpdated = runDatasourceRepairs(
|
|
118
|
+
ws.appPath,
|
|
119
|
+
ws.datasourceFiles,
|
|
120
|
+
{
|
|
121
|
+
expose: Boolean(ws.options.expose),
|
|
122
|
+
sync: Boolean(ws.options.sync),
|
|
123
|
+
test: Boolean(ws.options.test),
|
|
124
|
+
backupCtx: ws.backupCtx
|
|
125
|
+
},
|
|
126
|
+
ws.dryRun,
|
|
127
|
+
ws.changes
|
|
128
|
+
);
|
|
129
|
+
const openapiActionsPerformed = await maybeRunOpenApiSyncForMcp({
|
|
130
|
+
options: ws.options,
|
|
131
|
+
dryRun: ws.dryRun,
|
|
132
|
+
appPath: ws.appPath,
|
|
133
|
+
systemKey: ws.systemKey,
|
|
134
|
+
datasourceFiles: ws.datasourceFiles,
|
|
135
|
+
changes: ws.changes
|
|
136
|
+
});
|
|
137
|
+
const { rbacMigratedFromSystem, rbacMergeUpdated } = maybeRepairRbac(
|
|
138
|
+
ws.appPath,
|
|
139
|
+
ws.systemFilePath,
|
|
140
|
+
ws.systemParsed,
|
|
141
|
+
ws.datasourceFiles,
|
|
142
|
+
{ rbac: Boolean(ws.options.rbac), rbacFmt: ws.rbacFmt, dryRun: ws.dryRun, changes: ws.changes, backupCtx: ws.backupCtx }
|
|
143
|
+
);
|
|
144
|
+
const anyLocalUpdated =
|
|
145
|
+
ws.keysNormalized || steps.updated || datasourceRepairUpdated || rbacMigratedFromSystem || rbacMergeUpdated;
|
|
146
|
+
return {
|
|
147
|
+
steps,
|
|
148
|
+
anyLocalUpdated,
|
|
149
|
+
changes: ws.changes,
|
|
150
|
+
warnings: ws.warnings,
|
|
151
|
+
openapiActionsPerformed,
|
|
152
|
+
systemFiles: ws.systemFiles,
|
|
153
|
+
datasourceFiles: ws.datasourceFiles
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {Object} params
|
|
159
|
+
* @returns {Promise<Object>}
|
|
160
|
+
*/
|
|
161
|
+
async function runRepairLocalUpdates(params) {
|
|
162
|
+
const ws = prepareRepairWorkspace(params);
|
|
163
|
+
return runRepairIntegrationFileSteps(ws);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {Object} params
|
|
168
|
+
* @param {Object} local
|
|
169
|
+
* @returns {Promise<Object>}
|
|
170
|
+
*/
|
|
171
|
+
async function finalizeRepairIntegration(params, local) {
|
|
172
|
+
const { appName, options, appPath, configPath, dryRun, backupPaths, backupCtx, variables, originalYamlContent } =
|
|
173
|
+
params;
|
|
174
|
+
const { steps, anyLocalUpdated, changes, warnings, openapiActionsPerformed, systemFiles, datasourceFiles } = local;
|
|
175
|
+
let manifestRegenerated = false;
|
|
176
|
+
if (anyLocalUpdated && !dryRun) {
|
|
177
|
+
manifestRegenerated = await persistChangesAndRegenerate({
|
|
178
|
+
configPath,
|
|
179
|
+
variables,
|
|
180
|
+
appName,
|
|
181
|
+
appPath,
|
|
182
|
+
changes,
|
|
183
|
+
originalYamlContent,
|
|
184
|
+
backupCtx
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const readmeRegenerated = await regenerateReadmeIfRequested(
|
|
188
|
+
appName,
|
|
189
|
+
appPath,
|
|
190
|
+
{ ...options, backupCtx },
|
|
191
|
+
changes
|
|
192
|
+
);
|
|
193
|
+
const changedFiles = dryRun ? backupCtx.wouldChangeFiles : backupCtx.changedFiles;
|
|
194
|
+
return buildRepairResult(steps, anyLocalUpdated, manifestRegenerated, readmeRegenerated, {
|
|
195
|
+
actionsPerformed: openapiActionsPerformed,
|
|
196
|
+
changes,
|
|
197
|
+
warnings,
|
|
198
|
+
changedFiles,
|
|
199
|
+
systemFiles,
|
|
200
|
+
datasourceFiles,
|
|
201
|
+
backupPaths
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @param {Object} params
|
|
207
|
+
* @returns {Promise<Object>}
|
|
208
|
+
*/
|
|
209
|
+
async function runRepairExternalIntegration(params) {
|
|
210
|
+
const local = await runRepairLocalUpdates(params);
|
|
211
|
+
return finalizeRepairIntegration(params, local);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
module.exports = {
|
|
215
|
+
runRepairExternalIntegration
|
|
216
|
+
};
|
|
@@ -15,10 +15,15 @@ const path = require('path');
|
|
|
15
15
|
const fs = require('fs');
|
|
16
16
|
|
|
17
17
|
const { resolveControllerUrl } = require('../utils/controller-url');
|
|
18
|
-
const {
|
|
18
|
+
const {
|
|
19
|
+
getDeploymentAuth,
|
|
20
|
+
requireBearerForDataplanePipeline,
|
|
21
|
+
applyLabDataplaneApiKeyBearer
|
|
22
|
+
} = require('../utils/token-manager');
|
|
19
23
|
const { resolveDataplaneUrl } = require('../utils/dataplane-resolver');
|
|
20
24
|
const { uploadFileAs } = require('../utils/file-upload');
|
|
21
25
|
const { listOpenAPIFiles } = require('../api/external-systems.api');
|
|
26
|
+
const { resolveLabDataplaneApiKey } = require('../utils/credential-secrets-env');
|
|
22
27
|
|
|
23
28
|
async function fileExistsAsync(filePath) {
|
|
24
29
|
try {
|
|
@@ -29,11 +34,25 @@ async function fileExistsAsync(filePath) {
|
|
|
29
34
|
}
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
function authForJwtOnlyDataplaneRoutes(authConfig) {
|
|
38
|
+
const copy = { ...(authConfig || {}) };
|
|
39
|
+
if (copy.type === 'client-token' && resolveLabDataplaneApiKey()) {
|
|
40
|
+
return applyLabDataplaneApiKeyBearer(copy);
|
|
41
|
+
}
|
|
42
|
+
return copy;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function resolveDataplaneAndAuth(systemKey, preResolved = {}) {
|
|
46
|
+
if (preResolved.dataplaneUrl && preResolved.authConfig) {
|
|
47
|
+
const authConfig = authForJwtOnlyDataplaneRoutes(preResolved.authConfig);
|
|
48
|
+
return { dataplaneUrl: preResolved.dataplaneUrl, authConfig };
|
|
49
|
+
}
|
|
33
50
|
const { resolveEnvironment } = require('../core/config');
|
|
34
51
|
const environment = await resolveEnvironment();
|
|
35
52
|
const controllerUrl = await resolveControllerUrl();
|
|
36
|
-
const authConfig =
|
|
53
|
+
const authConfig = authForJwtOnlyDataplaneRoutes(
|
|
54
|
+
await getDeploymentAuth(controllerUrl, environment, systemKey)
|
|
55
|
+
);
|
|
37
56
|
requireBearerForDataplanePipeline(authConfig);
|
|
38
57
|
const dataplaneUrl = await resolveDataplaneUrl(controllerUrl, environment, authConfig, { silent: true });
|
|
39
58
|
return { dataplaneUrl, authConfig };
|
|
@@ -115,7 +134,10 @@ async function syncOpenApiFilesForMcp(opts) {
|
|
|
115
134
|
const openapiDir = path.join(appPath, 'openapi');
|
|
116
135
|
if (!(await fileExistsAsync(openapiDir))) return { uploaded: 0, skipped: 0 };
|
|
117
136
|
|
|
118
|
-
const { dataplaneUrl, authConfig } = await resolveDataplaneAndAuth(systemKey
|
|
137
|
+
const { dataplaneUrl, authConfig } = await resolveDataplaneAndAuth(systemKey, {
|
|
138
|
+
dataplaneUrl: opts.dataplaneUrl,
|
|
139
|
+
authConfig: opts.authConfig
|
|
140
|
+
});
|
|
119
141
|
const existingKeys = await getExistingOpenApiKeys(dataplaneUrl, systemKey, authConfig);
|
|
120
142
|
const uploadedKeys = new Set(existingKeys);
|
|
121
143
|
let uploaded = 0;
|
|
@@ -164,9 +186,32 @@ async function maybeSyncOpenApiFilesForMcp(opts) {
|
|
|
164
186
|
return lines;
|
|
165
187
|
}
|
|
166
188
|
|
|
189
|
+
/**
|
|
190
|
+
* @param {Object} args
|
|
191
|
+
* @returns {Promise<boolean>}
|
|
192
|
+
*/
|
|
193
|
+
async function maybeRunOpenApiSyncForMcp({ options, dryRun, appPath, systemKey, datasourceFiles, changes }) {
|
|
194
|
+
if (!options.api) return false;
|
|
195
|
+
try {
|
|
196
|
+
const openapiLines = await maybeSyncOpenApiFilesForMcp({
|
|
197
|
+
enabled: true,
|
|
198
|
+
dryRun,
|
|
199
|
+
appPath,
|
|
200
|
+
systemKey,
|
|
201
|
+
datasourceFiles
|
|
202
|
+
});
|
|
203
|
+
openapiLines.forEach((l) => changes.push(l));
|
|
204
|
+
return openapiLines.length > 0;
|
|
205
|
+
} catch (err) {
|
|
206
|
+
changes.push(`OpenAPI upload for MCP failed: ${err.message}`);
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
167
211
|
module.exports = {
|
|
168
212
|
documentKeyToLocalOpenApiPath,
|
|
169
213
|
maybeSyncOpenApiFilesForMcp,
|
|
214
|
+
maybeRunOpenApiSyncForMcp,
|
|
170
215
|
syncOpenApiFilesForMcp
|
|
171
216
|
};
|
|
172
217
|
|
|
@@ -17,6 +17,7 @@ const { getDeployJsonPath } = require('../utils/paths');
|
|
|
17
17
|
const { resolveApplicationConfigPath } = require('../utils/app-config-resolver');
|
|
18
18
|
const { writeConfigFile, writeYamlPreservingComments, isYamlPath } = require('../utils/config-format');
|
|
19
19
|
const { backupIntegrationFile } = require('../utils/integration-file-backup');
|
|
20
|
+
const { trackRepairWrite } = require('./repair-changed-files');
|
|
20
21
|
const logger = require('../utils/logger');
|
|
21
22
|
const generator = require('../generator');
|
|
22
23
|
const { generateReadmeFromDeployJson } = require('../generator/split-readme');
|
|
@@ -40,6 +41,7 @@ function inferExternalReadmeFileExt(appPath) {
|
|
|
40
41
|
async function regenerateManifest(appName, appPath, changes, backupCtx) {
|
|
41
42
|
try {
|
|
42
43
|
const deployPath = getDeployJsonPath(appName, 'external', true);
|
|
44
|
+
trackRepairWrite(deployPath, backupCtx);
|
|
43
45
|
backupIntegrationFile(deployPath, backupCtx);
|
|
44
46
|
const outPath = await generator.generateDeployJson(appName, { appPath });
|
|
45
47
|
changes.push(`Regenerated ${path.basename(outPath)}`);
|
|
@@ -70,6 +72,7 @@ async function regenerateReadmeIfRequested(appName, appPath, options, changes) {
|
|
|
70
72
|
const fileExt = inferExternalReadmeFileExt(appPath);
|
|
71
73
|
const readmeContent = generateReadmeFromDeployJson(deployment, { fileExt });
|
|
72
74
|
const readmePath = path.join(appPath, 'README.md');
|
|
75
|
+
trackRepairWrite(readmePath, options.backupCtx);
|
|
73
76
|
if (!options.dryRun) {
|
|
74
77
|
backupIntegrationFile(readmePath, options.backupCtx);
|
|
75
78
|
fs.writeFileSync(readmePath, readmeContent, { mode: 0o644, encoding: 'utf8' });
|
|
@@ -84,6 +87,7 @@ async function regenerateReadmeIfRequested(appName, appPath, options, changes) {
|
|
|
84
87
|
|
|
85
88
|
function persistChangesAndRegenerate(opts) {
|
|
86
89
|
const { configPath, variables, appName, appPath, changes, originalYamlContent, backupCtx } = opts;
|
|
90
|
+
trackRepairWrite(configPath, backupCtx);
|
|
87
91
|
backupIntegrationFile(configPath, backupCtx);
|
|
88
92
|
if (originalYamlContent !== null && originalYamlContent !== undefined && typeof originalYamlContent === 'string' && isYamlPath(configPath)) {
|
|
89
93
|
writeYamlPreservingComments(configPath, originalYamlContent, variables);
|
|
@@ -361,10 +361,61 @@ function mergeRbacFromDatasources(appPath, systemParsed, datasourceFiles, extrac
|
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
const { migrateSystemRbacIntoRbacFile } = require('./repair-rbac-migrate');
|
|
364
|
+
const { resolveRbacPath } = require('../utils/app-config-resolver');
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* @param {Object} opts
|
|
368
|
+
* @returns {boolean}
|
|
369
|
+
*/
|
|
370
|
+
function createRbacFromSystemIfNeeded(opts) {
|
|
371
|
+
const { appPath, systemFilePath, systemParsed, dryRun, changes, format, backupCtx } = opts;
|
|
372
|
+
if (resolveRbacPath(appPath)) return false;
|
|
373
|
+
const rbacFromSystem = extractRbacFromSystem(systemParsed);
|
|
374
|
+
if (!rbacFromSystem) return false;
|
|
375
|
+
if (!dryRun) {
|
|
376
|
+
const rbacFormat = format === 'json' ? 'json' : 'yaml';
|
|
377
|
+
const defaultRbacPath = path.join(appPath, rbacFormat === 'json' ? 'rbac.json' : 'rbac.yaml');
|
|
378
|
+
writeConfigFile(defaultRbacPath, rbacFromSystem, rbacFormat);
|
|
379
|
+
delete systemParsed.roles;
|
|
380
|
+
delete systemParsed.permissions;
|
|
381
|
+
backupIntegrationFile(systemFilePath, backupCtx);
|
|
382
|
+
writeConfigFile(systemFilePath, systemParsed);
|
|
383
|
+
}
|
|
384
|
+
changes.push('Created rbac.yaml from system roles/permissions');
|
|
385
|
+
changes.push('Removed roles/permissions from system file (now in rbac file)');
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* @param {string} appPath
|
|
391
|
+
* @param {string} systemFilePath
|
|
392
|
+
* @param {Object} systemParsed
|
|
393
|
+
* @param {string[]} datasourceFiles
|
|
394
|
+
* @param {Object} options
|
|
395
|
+
* @returns {{ rbacMigratedFromSystem: boolean, rbacMergeUpdated: boolean }}
|
|
396
|
+
*/
|
|
397
|
+
function maybeRepairRbac(appPath, systemFilePath, systemParsed, datasourceFiles, options) {
|
|
398
|
+
if (!options.rbac) return { rbacMigratedFromSystem: false, rbacMergeUpdated: false };
|
|
399
|
+
const { dryRun, changes, backupCtx, rbacFmt } = options;
|
|
400
|
+
const rbacMigratedFromSystem = migrateSystemRbacIntoRbacFile(appPath, systemFilePath, systemParsed, {
|
|
401
|
+
dryRun,
|
|
402
|
+
changes,
|
|
403
|
+
backupCtx
|
|
404
|
+
});
|
|
405
|
+
const rbacMergeUpdated = mergeRbacFromDatasources(appPath, systemParsed, datasourceFiles, extractRbacFromSystem, {
|
|
406
|
+
format: rbacFmt,
|
|
407
|
+
dryRun,
|
|
408
|
+
changes,
|
|
409
|
+
backupCtx
|
|
410
|
+
});
|
|
411
|
+
return { rbacMigratedFromSystem, rbacMergeUpdated };
|
|
412
|
+
}
|
|
364
413
|
|
|
365
414
|
module.exports = {
|
|
366
415
|
extractRbacFromSystem,
|
|
367
416
|
getCapabilitiesFromDatasource,
|
|
368
417
|
mergeRbacFromDatasources,
|
|
369
|
-
migrateSystemRbacIntoRbacFile
|
|
418
|
+
migrateSystemRbacIntoRbacFile,
|
|
419
|
+
createRbacFromSystemIfNeeded,
|
|
420
|
+
maybeRepairRbac
|
|
370
421
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core repair step runner (integration block, system alignment, auth, RBAC file, env.template).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Repair step orchestration
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const { backupIntegrationFile } = require('../utils/integration-file-backup');
|
|
12
|
+
const { writeConfigFile } = require('../utils/config-format');
|
|
13
|
+
const { trackRepairWrite } = require('./repair-changed-files');
|
|
14
|
+
const { repairEnvTemplate, normalizeSystemFileAuthAndConfig } = require('./repair-env-template');
|
|
15
|
+
const { createRbacFromSystemIfNeeded } = require('./repair-rbac');
|
|
16
|
+
const {
|
|
17
|
+
alignAppKeyWithSystem,
|
|
18
|
+
alignDatasourceSystemKeys,
|
|
19
|
+
alignSystemFileDataSources,
|
|
20
|
+
ensureExternalIntegrationBlock,
|
|
21
|
+
removeAuthVarsFromConfiguration
|
|
22
|
+
} = require('./repair-system-alignment');
|
|
23
|
+
const {
|
|
24
|
+
isAllowedRepairAuth,
|
|
25
|
+
normalizeRepairAuthOption,
|
|
26
|
+
buildAuthenticationForRepair,
|
|
27
|
+
mergePreservedAuthVariables,
|
|
28
|
+
repairAuthChangeLabel,
|
|
29
|
+
auditRepairAuthenticationWarnings,
|
|
30
|
+
normalizeAuthenticationSchemaShape,
|
|
31
|
+
getAuthCredentialTemplate
|
|
32
|
+
} = require('./repair-auth-apply');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Apply --auth: replace system file authentication with canonical block for the given method.
|
|
36
|
+
* @param {Object} ctx - Context with systemParsed, systemKey, auth, dryRun, changes
|
|
37
|
+
* @returns {boolean} True if auth was replaced
|
|
38
|
+
*/
|
|
39
|
+
function applyAuthMethod(ctx) {
|
|
40
|
+
if (!ctx.auth || typeof ctx.auth !== 'string') return false;
|
|
41
|
+
const authOption = normalizeRepairAuthOption(ctx.auth);
|
|
42
|
+
if (!isAllowedRepairAuth(authOption)) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'Invalid --auth "' +
|
|
45
|
+
`${ctx.auth}". Allowed methods: oauth2, aad, apikey, bearerToken, basic, queryParam, oidc, hmac, none`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const existingAuth = ctx.systemParsed.authentication || ctx.systemParsed.auth || {};
|
|
49
|
+
const newAuth = buildAuthenticationForRepair(ctx.systemKey, authOption);
|
|
50
|
+
const existingCredential = getAuthCredentialTemplate(existingAuth) || {};
|
|
51
|
+
const mergedVariables = { ...(newAuth.credential?.variables || {}) };
|
|
52
|
+
mergePreservedAuthVariables(
|
|
53
|
+
mergedVariables,
|
|
54
|
+
existingCredential.variables && typeof existingCredential.variables === 'object'
|
|
55
|
+
? existingCredential.variables
|
|
56
|
+
: existingAuth.variables
|
|
57
|
+
);
|
|
58
|
+
if (newAuth.authType === 'credential' && newAuth.credential) {
|
|
59
|
+
newAuth.credential.variables = mergedVariables;
|
|
60
|
+
if (existingCredential.displayName !== undefined) {
|
|
61
|
+
newAuth.credential.displayName = existingCredential.displayName;
|
|
62
|
+
} else if (existingAuth.displayName !== undefined) {
|
|
63
|
+
newAuth.credential.displayName = existingAuth.displayName;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
ctx.systemParsed.authentication = newAuth;
|
|
67
|
+
delete ctx.systemParsed.auth;
|
|
68
|
+
ctx.changes.push(`Set authentication method to ${repairAuthChangeLabel(authOption)}`);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {Object} ctx
|
|
74
|
+
* @param {Object} flags
|
|
75
|
+
* @returns {boolean}
|
|
76
|
+
*/
|
|
77
|
+
function persistSystemFileRepair(ctx, flags) {
|
|
78
|
+
const systemFileUpdated =
|
|
79
|
+
flags.authReplaced ||
|
|
80
|
+
flags.authShapeNormalized ||
|
|
81
|
+
flags.systemAuthConfigNormalized ||
|
|
82
|
+
flags.systemDataSourcesAligned ||
|
|
83
|
+
flags.authVarsRemoved;
|
|
84
|
+
if (!systemFileUpdated) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
trackRepairWrite(ctx.systemFilePath, ctx.backupCtx);
|
|
88
|
+
if (!ctx.dryRun) {
|
|
89
|
+
backupIntegrationFile(ctx.systemFilePath, ctx.backupCtx);
|
|
90
|
+
writeConfigFile(ctx.systemFilePath, ctx.systemParsed);
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {Object} ctx
|
|
97
|
+
* @returns {{ updated: boolean, appKeyFixed: boolean, datasourceKeysFixed: boolean, rbacFileCreated: boolean, envTemplateRepaired: boolean }}
|
|
98
|
+
*/
|
|
99
|
+
function runRepairSteps(ctx) {
|
|
100
|
+
const bc = ctx.backupCtx;
|
|
101
|
+
let updated = ensureExternalIntegrationBlock(
|
|
102
|
+
ctx.variables, ctx.systemFiles, ctx.datasourceFiles, ctx.changes
|
|
103
|
+
);
|
|
104
|
+
const authReplaced = applyAuthMethod(ctx);
|
|
105
|
+
updated = updated || authReplaced;
|
|
106
|
+
const authShapeNormalized = normalizeAuthenticationSchemaShape(
|
|
107
|
+
ctx.systemParsed,
|
|
108
|
+
ctx.systemKey,
|
|
109
|
+
ctx.changes
|
|
110
|
+
);
|
|
111
|
+
updated = updated || authShapeNormalized;
|
|
112
|
+
const systemAuthConfigNormalized = normalizeSystemFileAuthAndConfig(
|
|
113
|
+
ctx.systemParsed, ctx.systemKey, ctx.changes
|
|
114
|
+
);
|
|
115
|
+
const systemDataSourcesAligned = alignSystemFileDataSources(
|
|
116
|
+
ctx.appPath, ctx.systemParsed, ctx.datasourceFiles, ctx.systemKey, ctx.dryRun, ctx.changes
|
|
117
|
+
);
|
|
118
|
+
const authVarsRemoved = removeAuthVarsFromConfiguration(
|
|
119
|
+
ctx.systemParsed, ctx.systemKey, ctx.dryRun, ctx.changes
|
|
120
|
+
);
|
|
121
|
+
const systemFileUpdated = persistSystemFileRepair(ctx, {
|
|
122
|
+
authReplaced,
|
|
123
|
+
authShapeNormalized,
|
|
124
|
+
systemAuthConfigNormalized,
|
|
125
|
+
systemDataSourcesAligned,
|
|
126
|
+
authVarsRemoved
|
|
127
|
+
});
|
|
128
|
+
updated = updated || systemFileUpdated;
|
|
129
|
+
const appKeyFixed = alignAppKeyWithSystem(
|
|
130
|
+
ctx.variables, ctx.systemKey, ctx.systemParsed, ctx.changes
|
|
131
|
+
);
|
|
132
|
+
const datasourceKeysFixed = alignDatasourceSystemKeys(
|
|
133
|
+
ctx.appPath, ctx.datasourceFiles, ctx.systemKey, ctx.dryRun, ctx.changes, bc
|
|
134
|
+
);
|
|
135
|
+
const rbacFileCreated = createRbacFromSystemIfNeeded({
|
|
136
|
+
appPath: ctx.appPath,
|
|
137
|
+
systemFilePath: ctx.systemFilePath,
|
|
138
|
+
systemParsed: ctx.systemParsed,
|
|
139
|
+
dryRun: ctx.dryRun,
|
|
140
|
+
changes: ctx.changes,
|
|
141
|
+
format: ctx.format,
|
|
142
|
+
backupCtx: bc
|
|
143
|
+
});
|
|
144
|
+
const envTemplateRepaired = repairEnvTemplate(
|
|
145
|
+
ctx.appPath, ctx.systemParsed, ctx.systemKey, ctx.dryRun, ctx.changes, bc
|
|
146
|
+
);
|
|
147
|
+
updated = updated || appKeyFixed || datasourceKeysFixed || rbacFileCreated || envTemplateRepaired;
|
|
148
|
+
auditRepairAuthenticationWarnings(ctx.systemParsed, ctx.warnings);
|
|
149
|
+
return {
|
|
150
|
+
updated,
|
|
151
|
+
appKeyFixed,
|
|
152
|
+
datasourceKeysFixed,
|
|
153
|
+
rbacFileCreated,
|
|
154
|
+
envTemplateRepaired
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module.exports = {
|
|
159
|
+
runRepairSteps
|
|
160
|
+
};
|
|
@@ -177,13 +177,16 @@ function alignSystemFileDataSources(appPath, systemParsed, datasourceFiles, syst
|
|
|
177
177
|
function buildAuthVarNames(systemParsed, _systemKey) {
|
|
178
178
|
const names = new Set();
|
|
179
179
|
const auth = systemParsed.authentication;
|
|
180
|
-
if (auth
|
|
181
|
-
|
|
180
|
+
if (!auth || typeof auth !== 'object') return names;
|
|
181
|
+
const credential =
|
|
182
|
+
auth.credential && typeof auth.credential === 'object' ? auth.credential : auth;
|
|
183
|
+
if (typeof credential.variables === 'object') {
|
|
184
|
+
for (const k of Object.keys(credential.variables)) {
|
|
182
185
|
names.add(String(k).toUpperCase().replace(/_/g, ''));
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
|
-
if (
|
|
186
|
-
for (const k of Object.keys(
|
|
188
|
+
if (typeof credential.security === 'object') {
|
|
189
|
+
for (const k of Object.keys(credential.security)) {
|
|
187
190
|
names.add(securityKeyToVar(k));
|
|
188
191
|
}
|
|
189
192
|
}
|