@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,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repair --auth: canonical authentication blocks and bearerToken preset.
|
|
3
|
+
*
|
|
4
|
+
* Applies canonical authentication blocks for repair --auth.
|
|
5
|
+
*
|
|
6
|
+
* @fileoverview Repair authentication method application
|
|
7
|
+
* @author AI Fabrix Team
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
buildAuthenticationFromMethod,
|
|
15
|
+
getAuthCredentialTemplate,
|
|
16
|
+
migrateAuthenticationToNestedSchema
|
|
17
|
+
} = require('../utils/authentication-shape');
|
|
18
|
+
|
|
19
|
+
/** Repair CLI --auth values (normalized lowercase). */
|
|
20
|
+
const ALLOWED_REPAIR_AUTH = [
|
|
21
|
+
'oauth2',
|
|
22
|
+
'aad',
|
|
23
|
+
'apikey',
|
|
24
|
+
'bearertoken',
|
|
25
|
+
'bearerkey',
|
|
26
|
+
'basic',
|
|
27
|
+
'queryparam',
|
|
28
|
+
'oidc',
|
|
29
|
+
'hmac',
|
|
30
|
+
'none'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const PRESERVED_VARIABLE_KEYS = ['baseUrl', 'testEndpoint'];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {string} authOption - Raw --auth value
|
|
37
|
+
* @returns {string} Normalized lowercase auth option
|
|
38
|
+
*/
|
|
39
|
+
function normalizeRepairAuthOption(authOption) {
|
|
40
|
+
return String(authOption || '').trim().toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {string} authOption - Normalized --auth value
|
|
45
|
+
* @returns {boolean}
|
|
46
|
+
*/
|
|
47
|
+
function isAllowedRepairAuth(authOption) {
|
|
48
|
+
return ALLOWED_REPAIR_AUTH.includes(normalizeRepairAuthOption(authOption));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Builds authentication block for repair --auth.
|
|
53
|
+
* @param {string} systemKey - System key
|
|
54
|
+
* @param {string} authOption - Normalized repair auth (e.g. bearertoken, apikey)
|
|
55
|
+
* @returns {{ method: string, variables: Object, security: Object }}
|
|
56
|
+
*/
|
|
57
|
+
function buildAuthenticationForRepair(systemKey, authOption) {
|
|
58
|
+
const normalized = normalizeRepairAuthOption(authOption);
|
|
59
|
+
const schemaMethod =
|
|
60
|
+
normalized === 'queryparam'
|
|
61
|
+
? 'queryParam'
|
|
62
|
+
: normalized === 'bearertoken' || normalized === 'bearerkey'
|
|
63
|
+
? 'bearerToken'
|
|
64
|
+
: normalized;
|
|
65
|
+
return buildAuthenticationFromMethod(systemKey, schemaMethod);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Merges preserved connectivity fields from existing auth into template variables.
|
|
70
|
+
* @param {Object} mergedVariables - Target variables object (mutated)
|
|
71
|
+
* @param {Object} existingVars - Prior authentication.variables
|
|
72
|
+
*/
|
|
73
|
+
function mergePreservedAuthVariables(mergedVariables, existingVars) {
|
|
74
|
+
if (!existingVars || typeof existingVars !== 'object') return;
|
|
75
|
+
for (const key of PRESERVED_VARIABLE_KEYS) {
|
|
76
|
+
if (existingVars[key] !== undefined && existingVars[key] !== null) {
|
|
77
|
+
mergedVariables[key] = existingVars[key];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Human-readable label for repair change log.
|
|
84
|
+
* @param {string} authOption - Normalized repair auth
|
|
85
|
+
* @returns {string}
|
|
86
|
+
*/
|
|
87
|
+
function repairAuthChangeLabel(authOption) {
|
|
88
|
+
const normalized = normalizeRepairAuthOption(authOption);
|
|
89
|
+
if (normalized === 'bearertoken' || normalized === 'bearerkey') return 'bearerToken';
|
|
90
|
+
return normalized;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const MISSING_TEST_ENDPOINT_WARNING =
|
|
94
|
+
'authentication.variables.testEndpoint is missing for apikey/bearerToken auth — add a GET URL for credential/E2E tests (e.g. /crm/v3/objects/contacts?limit=1, or a path resolved against baseUrl).';
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Warn when apikey auth (including bearerToken preset) has no testEndpoint.
|
|
98
|
+
* @param {Object} authentication - authentication block on system file
|
|
99
|
+
* @param {string[]} warnings - Mutable warnings list
|
|
100
|
+
*/
|
|
101
|
+
function appendTestEndpointWarningIfMissing(authentication, warnings) {
|
|
102
|
+
const credential = getAuthCredentialTemplate(authentication);
|
|
103
|
+
const method = String(credential?.method || authentication?.method || '').toLowerCase();
|
|
104
|
+
if (method !== 'apikey' && method !== 'bearertoken') return;
|
|
105
|
+
const testEndpoint = String(credential?.variables?.testEndpoint || authentication?.variables?.testEndpoint || '').trim();
|
|
106
|
+
if (testEndpoint) return;
|
|
107
|
+
if (warnings.includes(MISSING_TEST_ENDPOINT_WARNING)) return;
|
|
108
|
+
warnings.push(MISSING_TEST_ENDPOINT_WARNING);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Audit system authentication after repair (with or without --auth).
|
|
113
|
+
* @param {Object} systemParsed - Parsed system config
|
|
114
|
+
* @param {string[]} warnings - Mutable warnings list
|
|
115
|
+
*/
|
|
116
|
+
function auditRepairAuthenticationWarnings(systemParsed, warnings) {
|
|
117
|
+
const authentication = systemParsed?.authentication || systemParsed?.auth;
|
|
118
|
+
if (!authentication || typeof authentication !== 'object') return;
|
|
119
|
+
appendTestEndpointWarningIfMissing(authentication, warnings);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Ensures system file authentication matches nested schema (authType + credential).
|
|
124
|
+
* @param {Object} systemParsed - Parsed system config (mutated)
|
|
125
|
+
* @param {string} systemKey
|
|
126
|
+
* @param {string[]} changes
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
function normalizeAuthenticationSchemaShape(systemParsed, systemKey, changes) {
|
|
130
|
+
const current = systemParsed.authentication || systemParsed.auth;
|
|
131
|
+
const { authentication, changed } = migrateAuthenticationToNestedSchema(current, systemKey);
|
|
132
|
+
if (!changed) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
systemParsed.authentication = authentication;
|
|
136
|
+
delete systemParsed.auth;
|
|
137
|
+
changes.push('Normalized authentication to authType + credential (schema 2.4.x)');
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
module.exports = {
|
|
142
|
+
ALLOWED_REPAIR_AUTH,
|
|
143
|
+
MISSING_TEST_ENDPOINT_WARNING,
|
|
144
|
+
normalizeRepairAuthOption,
|
|
145
|
+
isAllowedRepairAuth,
|
|
146
|
+
buildAuthenticationForRepair,
|
|
147
|
+
mergePreservedAuthVariables,
|
|
148
|
+
repairAuthChangeLabel,
|
|
149
|
+
appendTestEndpointWarningIfMissing,
|
|
150
|
+
auditRepairAuthenticationWarnings,
|
|
151
|
+
normalizeAuthenticationSchemaShape,
|
|
152
|
+
getAuthCredentialTemplate
|
|
153
|
+
};
|
|
@@ -8,17 +8,7 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
const { systemKeyToKvPrefix, securityKeyToVar, kvEnvKeyToPath } = require('../utils/credential-secrets-env');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns true if a kv value looks like legacy format (KeyVault suffix or no path segments).
|
|
14
|
-
* @param {string} val - Value from authentication.security or configuration
|
|
15
|
-
* @returns {boolean}
|
|
16
|
-
*/
|
|
17
|
-
function isLegacyKvValue(val) {
|
|
18
|
-
if (typeof val !== 'string' || !val.trim().toLowerCase().startsWith('kv://')) return false;
|
|
19
|
-
const after = val.trim().slice(5); // after 'kv://'
|
|
20
|
-
return after.includes('KeyVault') || !after.includes('/');
|
|
21
|
-
}
|
|
11
|
+
const { isLegacyKvValue } = require('../utils/platform-kv-ref');
|
|
22
12
|
|
|
23
13
|
/**
|
|
24
14
|
* Normalizes authentication.security keyvault entries to path-style kv:// values (kv://systemKey/variable).
|
|
@@ -87,7 +77,9 @@ function normalizeConfigurationSection(config, prefix, systemKey, changes) {
|
|
|
87
77
|
function normalizeSystemFileAuthAndConfig(systemParsed, systemKey, changes) {
|
|
88
78
|
const prefix = systemKeyToKvPrefix(systemKey);
|
|
89
79
|
if (!prefix) return false;
|
|
90
|
-
const
|
|
80
|
+
const { getAuthCredentialTemplate } = require('../utils/authentication-shape');
|
|
81
|
+
const credential = getAuthCredentialTemplate(systemParsed.authentication);
|
|
82
|
+
const security = credential?.security ?? systemParsed.authentication?.security;
|
|
91
83
|
let updated = (security && typeof security === 'object' && normalizeSecuritySection(security, prefix, systemKey, changes));
|
|
92
84
|
const config = systemParsed.configuration;
|
|
93
85
|
if (Array.isArray(config)) {
|
|
@@ -96,4 +88,7 @@ function normalizeSystemFileAuthAndConfig(systemParsed, systemKey, changes) {
|
|
|
96
88
|
return updated;
|
|
97
89
|
}
|
|
98
90
|
|
|
99
|
-
module.exports = {
|
|
91
|
+
module.exports = {
|
|
92
|
+
normalizeSystemFileAuthAndConfig,
|
|
93
|
+
isLegacyKvValue
|
|
94
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Track integration files touched during repair for CLI summary output.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Repair changed-file tracking
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Ensures backup/repair context has changed-file buckets.
|
|
15
|
+
* @param {Object} ctx - Repair backup context
|
|
16
|
+
* @returns {{ changedFiles: string[], wouldChangeFiles: string[] }}
|
|
17
|
+
*/
|
|
18
|
+
function ensureChangedFileBuckets(ctx) {
|
|
19
|
+
if (!ctx) return { changedFiles: [], wouldChangeFiles: [] };
|
|
20
|
+
if (!Array.isArray(ctx.changedFiles)) ctx.changedFiles = [];
|
|
21
|
+
if (!Array.isArray(ctx.wouldChangeFiles)) ctx.wouldChangeFiles = [];
|
|
22
|
+
return { changedFiles: ctx.changedFiles, wouldChangeFiles: ctx.wouldChangeFiles };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Records a file path that repair wrote or would write (dry-run).
|
|
27
|
+
* @param {string} filePath - Path to file
|
|
28
|
+
* @param {Object} ctx - Repair context with dryRun, changedFiles, wouldChangeFiles
|
|
29
|
+
*/
|
|
30
|
+
function trackRepairWrite(filePath, ctx) {
|
|
31
|
+
if (!filePath || !ctx) return;
|
|
32
|
+
const abs = path.resolve(filePath);
|
|
33
|
+
const { changedFiles, wouldChangeFiles } = ensureChangedFileBuckets(ctx);
|
|
34
|
+
const bucket = ctx.dryRun ? wouldChangeFiles : changedFiles;
|
|
35
|
+
if (!bucket.includes(abs)) bucket.push(abs);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
ensureChangedFileBuckets,
|
|
40
|
+
trackRepairWrite
|
|
41
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COM v2 datasource manifest repair (capabilities objects, strip context).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview repair-datasource-com-v2
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const { repairComV2Manifest } = require('../datasource/capability/capability-manifest');
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
repairComV2Manifest
|
|
15
|
+
};
|
|
@@ -16,6 +16,7 @@ const path = require('path');
|
|
|
16
16
|
const fs = require('fs');
|
|
17
17
|
const { loadConfigFile, writeConfigFile } = require('../utils/config-format');
|
|
18
18
|
const { backupIntegrationFile } = require('../utils/integration-file-backup');
|
|
19
|
+
const { trackRepairWrite } = require('./repair-changed-files');
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Returns suffix from a canonical-format filename: <systemKey>-datasource-<suffix>.<ext>.
|
|
@@ -174,8 +175,9 @@ function normalizeDatasourceKeysAndFilenames(appPath, datasourceFiles, systemKey
|
|
|
174
175
|
|
|
175
176
|
if (parsed.key !== canonicalKey) {
|
|
176
177
|
parsed.key = canonicalKey;
|
|
178
|
+
const fullPath = path.join(appPath, fileName);
|
|
179
|
+
trackRepairWrite(fullPath, backupCtx);
|
|
177
180
|
if (!dryRun) {
|
|
178
|
-
const fullPath = path.join(appPath, fileName);
|
|
179
181
|
backupIntegrationFile(fullPath, backupCtx);
|
|
180
182
|
writeConfigFile(fullPath, parsed);
|
|
181
183
|
}
|
|
@@ -185,6 +187,7 @@ function normalizeDatasourceKeysAndFilenames(appPath, datasourceFiles, systemKey
|
|
|
185
187
|
if (fileName !== canonicalFileName) {
|
|
186
188
|
const oldPath = path.join(appPath, fileName);
|
|
187
189
|
const newPath = path.join(appPath, canonicalFileName);
|
|
190
|
+
trackRepairWrite(newPath, backupCtx);
|
|
188
191
|
if (!dryRun && fs.existsSync(oldPath) && !fs.existsSync(newPath)) {
|
|
189
192
|
backupIntegrationFile(oldPath, backupCtx);
|
|
190
193
|
fs.renameSync(oldPath, newPath);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch datasource file repair during external integration repair.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Run repairDatasourceFile across integration datasource files
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const chalk = require('chalk');
|
|
14
|
+
const logger = require('../utils/logger');
|
|
15
|
+
const { loadConfigFile, writeConfigFile } = require('../utils/config-format');
|
|
16
|
+
const { backupIntegrationFile } = require('../utils/integration-file-backup');
|
|
17
|
+
const { trackRepairWrite } = require('./repair-changed-files');
|
|
18
|
+
const { repairDatasourceFile } = require('./repair-datasource');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} appPath
|
|
22
|
+
* @param {string[]} datasourceFiles
|
|
23
|
+
* @param {Object} options
|
|
24
|
+
* @param {boolean} dryRun
|
|
25
|
+
* @param {string[]} changes
|
|
26
|
+
* @returns {boolean}
|
|
27
|
+
*/
|
|
28
|
+
function runDatasourceRepairs(appPath, datasourceFiles, options, dryRun, changes) {
|
|
29
|
+
if (!datasourceFiles || datasourceFiles.length === 0) return false;
|
|
30
|
+
let updated = false;
|
|
31
|
+
for (const fileName of datasourceFiles) {
|
|
32
|
+
const filePath = path.join(appPath, fileName);
|
|
33
|
+
if (!fs.existsSync(filePath)) continue;
|
|
34
|
+
try {
|
|
35
|
+
const parsed = loadConfigFile(filePath);
|
|
36
|
+
const { updated: fileUpdated, changes: fileChanges } = repairDatasourceFile(parsed, {
|
|
37
|
+
expose: options.expose,
|
|
38
|
+
sync: options.sync,
|
|
39
|
+
test: options.test
|
|
40
|
+
});
|
|
41
|
+
if (fileUpdated) {
|
|
42
|
+
updated = true;
|
|
43
|
+
fileChanges.forEach(c => changes.push(`${fileName}: ${c}`));
|
|
44
|
+
if (!dryRun) {
|
|
45
|
+
backupIntegrationFile(filePath, options.backupCtx);
|
|
46
|
+
writeConfigFile(filePath, parsed);
|
|
47
|
+
}
|
|
48
|
+
trackRepairWrite(filePath, options.backupCtx);
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
logger.log(chalk.yellow(`⚠ Could not repair datasource ${fileName}: ${err.message}`));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return updated;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
runDatasourceRepairs
|
|
59
|
+
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* serviceContract repair helpers — migrate deprecated none+llm manifests (439.1).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview repair-datasource-service-contract
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const LLM_CANONICAL_METADATA_SCHEMA = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
successContent: { type: 'string', nullable: true },
|
|
15
|
+
successEmbedding: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: { type: 'number' },
|
|
18
|
+
nullable: true
|
|
19
|
+
},
|
|
20
|
+
successRole: { type: 'string', nullable: true },
|
|
21
|
+
successModel: { type: 'string', nullable: true },
|
|
22
|
+
successFinishReason: { type: 'string', nullable: true },
|
|
23
|
+
errorCode: { type: 'string', nullable: true },
|
|
24
|
+
errorMessage: { type: 'string', nullable: true },
|
|
25
|
+
errorType: { type: 'string', nullable: true },
|
|
26
|
+
usagePromptTokens: { type: 'integer', nullable: true },
|
|
27
|
+
usageCompletionTokens: { type: 'integer', nullable: true },
|
|
28
|
+
usageTotalTokens: { type: 'integer', nullable: true },
|
|
29
|
+
metadataProvider: { type: 'string', nullable: true },
|
|
30
|
+
metadataOperation: { type: 'string', nullable: true }
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const LLM_CANONICAL_EXPOSED_SCHEMA = {
|
|
35
|
+
success: {
|
|
36
|
+
content: 'metadata.successContent',
|
|
37
|
+
embedding: 'metadata.successEmbedding',
|
|
38
|
+
role: 'metadata.successRole',
|
|
39
|
+
model: 'metadata.successModel',
|
|
40
|
+
finishReason: 'metadata.successFinishReason'
|
|
41
|
+
},
|
|
42
|
+
error: {
|
|
43
|
+
code: 'metadata.errorCode',
|
|
44
|
+
message: 'metadata.errorMessage',
|
|
45
|
+
type: 'metadata.errorType'
|
|
46
|
+
},
|
|
47
|
+
usage: {
|
|
48
|
+
promptTokens: 'metadata.usagePromptTokens',
|
|
49
|
+
completionTokens: 'metadata.usageCompletionTokens',
|
|
50
|
+
totalTokens: 'metadata.usageTotalTokens'
|
|
51
|
+
},
|
|
52
|
+
metadata: {
|
|
53
|
+
provider: 'metadata.metadataProvider',
|
|
54
|
+
operation: 'metadata.metadataOperation'
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const LLM_STUB_FIELD_MAPPINGS = {
|
|
59
|
+
successContent: { expression: '{{raw}}' },
|
|
60
|
+
metadataProvider: { expression: '{{inline.metadataProvider}}' },
|
|
61
|
+
metadataOperation: { expression: '{{inline.metadataOperation}}' }
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {Object} parsed - Parsed datasource manifest
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
function isDeprecatedNoneLlmManifest(parsed) {
|
|
69
|
+
return parsed?.entityType === 'none' && parsed?.resourceType === 'llm';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {Object} parsed
|
|
74
|
+
* @param {string[]} changes
|
|
75
|
+
* @returns {boolean}
|
|
76
|
+
*/
|
|
77
|
+
function stripStorageKeysForServiceContract(parsed, changes) {
|
|
78
|
+
let updated = false;
|
|
79
|
+
for (const key of ['primaryKey', 'labelKey', 'sync']) {
|
|
80
|
+
if (parsed[key] !== undefined) {
|
|
81
|
+
delete parsed[key];
|
|
82
|
+
changes.push(`Removed ${key} (not allowed on serviceContract)`);
|
|
83
|
+
updated = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return updated;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {Object} parsed
|
|
91
|
+
* @param {string} systemKey
|
|
92
|
+
* @param {string[]} changes
|
|
93
|
+
* @returns {boolean}
|
|
94
|
+
*/
|
|
95
|
+
function ensureLlmCipMapSteps(parsed, systemKey, changes) {
|
|
96
|
+
const operations = parsed?.execution?.cip?.operations;
|
|
97
|
+
if (!operations || typeof operations !== 'object') return false;
|
|
98
|
+
let updated = false;
|
|
99
|
+
for (const opKey of ['call', 'embed']) {
|
|
100
|
+
const op = operations[opKey];
|
|
101
|
+
if (!op || !Array.isArray(op.steps)) continue;
|
|
102
|
+
if (op.steps.some((step) => step && step.map)) continue;
|
|
103
|
+
const fetchIdx = op.steps.findIndex((step) => step && step.fetch);
|
|
104
|
+
if (fetchIdx < 0) continue;
|
|
105
|
+
const mapStep = {
|
|
106
|
+
map: {
|
|
107
|
+
useFieldMappings: true,
|
|
108
|
+
inputPath: '$',
|
|
109
|
+
inline: {
|
|
110
|
+
metadataProvider: systemKey || parsed.systemKey || 'provider',
|
|
111
|
+
metadataOperation: opKey
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
op.steps.splice(fetchIdx + 1, 0, mapStep);
|
|
116
|
+
if (!op.steps.some((step) => step && step.output)) {
|
|
117
|
+
op.steps.push({ output: { mode: 'records' } });
|
|
118
|
+
}
|
|
119
|
+
changes.push(`Inserted map+output steps for CIP operation "${opKey}"`);
|
|
120
|
+
updated = true;
|
|
121
|
+
}
|
|
122
|
+
return updated;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {Object} parsed
|
|
127
|
+
* @param {string[]} changes
|
|
128
|
+
* @returns {boolean}
|
|
129
|
+
*/
|
|
130
|
+
function stripDeprecatedServiceCategory(parsed, changes) {
|
|
131
|
+
if (parsed?.serviceCategory === undefined) return false;
|
|
132
|
+
delete parsed.serviceCategory;
|
|
133
|
+
changes.push('Removed deprecated serviceCategory (use resourceType for classification)');
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {*} value
|
|
139
|
+
* @returns {*}
|
|
140
|
+
*/
|
|
141
|
+
function deepClone(value) {
|
|
142
|
+
return JSON.parse(JSON.stringify(value));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param {Object} parsed
|
|
147
|
+
* @param {string[]} changes
|
|
148
|
+
* @returns {boolean}
|
|
149
|
+
*/
|
|
150
|
+
function applyCanonicalLlmSchemaStubs(parsed, changes) {
|
|
151
|
+
parsed.entityType = 'serviceContract';
|
|
152
|
+
changes.push('Migrated entityType none → serviceContract');
|
|
153
|
+
|
|
154
|
+
parsed.metadataSchema = deepClone(LLM_CANONICAL_METADATA_SCHEMA);
|
|
155
|
+
changes.push('Set canonical LLM metadataSchema stub');
|
|
156
|
+
|
|
157
|
+
if (!parsed.exposed) parsed.exposed = {};
|
|
158
|
+
parsed.exposed.schema = deepClone(LLM_CANONICAL_EXPOSED_SCHEMA);
|
|
159
|
+
if (parsed.exposed.attributes !== undefined) {
|
|
160
|
+
delete parsed.exposed.attributes;
|
|
161
|
+
}
|
|
162
|
+
changes.push('Set canonical LLM exposed.schema envelope');
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {Object} parsed
|
|
168
|
+
* @param {string[]} changes
|
|
169
|
+
* @returns {boolean}
|
|
170
|
+
*/
|
|
171
|
+
function applyStubFieldMappingsIfMissing(parsed, changes) {
|
|
172
|
+
const attrs = parsed.fieldMappings?.attributes;
|
|
173
|
+
if (attrs && typeof attrs === 'object' && Object.keys(attrs).length > 0) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (!parsed.fieldMappings) parsed.fieldMappings = {};
|
|
177
|
+
parsed.fieldMappings.attributes = deepClone(LLM_STUB_FIELD_MAPPINGS);
|
|
178
|
+
changes.push(
|
|
179
|
+
'Added stub fieldMappings.attributes — customize provider raw.* expressions'
|
|
180
|
+
);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Migrate deprecated none+llm manifest to serviceContract canonical stub.
|
|
186
|
+
*
|
|
187
|
+
* @param {Object} parsed - Parsed datasource (mutated)
|
|
188
|
+
* @param {string[]} changes - Change log
|
|
189
|
+
* @returns {boolean}
|
|
190
|
+
*/
|
|
191
|
+
function repairNoneLlmToServiceContract(parsed, changes) {
|
|
192
|
+
if (!isDeprecatedNoneLlmManifest(parsed)) return false;
|
|
193
|
+
let updated = applyCanonicalLlmSchemaStubs(parsed, changes);
|
|
194
|
+
updated = applyStubFieldMappingsIfMissing(parsed, changes) || updated;
|
|
195
|
+
updated = stripStorageKeysForServiceContract(parsed, changes) || updated;
|
|
196
|
+
updated = ensureLlmCipMapSteps(parsed, parsed.systemKey, changes) || updated;
|
|
197
|
+
return updated;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
module.exports = {
|
|
201
|
+
LLM_CANONICAL_METADATA_SCHEMA,
|
|
202
|
+
LLM_CANONICAL_EXPOSED_SCHEMA,
|
|
203
|
+
isDeprecatedNoneLlmManifest,
|
|
204
|
+
stripDeprecatedServiceCategory,
|
|
205
|
+
repairNoneLlmToServiceContract
|
|
206
|
+
};
|