@wildo-ai/platform-config-lib 1.1.5 → 1.1.7
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/dist/esm/_unimplemented/index.d.ts.map +1 -1
- package/dist/esm/_unimplemented/index.js.map +1 -1
- package/dist/esm/_unimplemented/soft-warn.d.ts.map +1 -1
- package/dist/esm/_unimplemented/soft-warn.js.map +1 -1
- package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts.map +1 -1
- package/dist/esm/_unimplemented/unimplemented-field-warning.js.map +1 -1
- package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/application-backend-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/application-creation-verification-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/application-creation-verification-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts +3 -2
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js +3 -2
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +47 -0
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js +8 -0
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +12 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +12 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts +37 -0
- package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -0
- package/dist/esm/bootstrap/platform-store-preconnect.js +43 -0
- package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -0
- package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-backing-service-access.js +8 -4
- package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-policy.js.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
- package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-platform-access.js.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-principal.contracts.js.map +1 -1
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts +36 -3
- package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/runtime-topology.contracts.js +36 -13
- package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
- package/dist/esm/config-authoring.entry.d.ts.map +1 -1
- package/dist/esm/config-authoring.entry.js.map +1 -1
- package/dist/esm/credentials/credential-generator.service.d.ts.map +1 -1
- package/dist/esm/credentials/credential-generator.service.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -1
- package/dist/esm/lockfile/build-parallelism.js.map +1 -1
- package/dist/esm/lockfile/canonical-json.d.ts.map +1 -1
- package/dist/esm/lockfile/canonical-json.js.map +1 -1
- package/dist/esm/lockfile/lockfile-io.d.ts +7 -1
- package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
- package/dist/esm/lockfile/lockfile-io.js +17 -3
- package/dist/esm/lockfile/lockfile-io.js.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.d.ts +27 -6
- package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js +23 -10
- package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +455 -6
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +27 -0
- package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
- package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts +13 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts.map +1 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js +56 -0
- package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -0
- package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-framework-config.js.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.d.ts +0 -27
- package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.js +0 -2
- package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
- package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-minion-config.js.map +1 -1
- package/dist/esm/project-config/define-saas-config.d.ts +52 -0
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-saas-config.js +65 -15
- package/dist/esm/project-config/define-saas-config.js.map +1 -1
- package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-worker-config.js.map +1 -1
- package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -1
- package/dist/esm/project-config/index.d.ts +3 -0
- package/dist/esm/project-config/index.d.ts.map +1 -1
- package/dist/esm/project-config/index.js +3 -0
- package/dist/esm/project-config/index.js.map +1 -1
- package/dist/esm/project-config/loader.d.ts +11 -0
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- package/dist/esm/project-config/loader.js +34 -7
- package/dist/esm/project-config/loader.js.map +1 -1
- package/dist/esm/project-config/minion-local-provider-registration.d.ts.map +1 -1
- package/dist/esm/project-config/minion-local-provider-registration.js.map +1 -1
- package/dist/esm/project-config/npm-version-range.d.ts +23 -0
- package/dist/esm/project-config/npm-version-range.d.ts.map +1 -0
- package/dist/esm/project-config/npm-version-range.js +175 -0
- package/dist/esm/project-config/npm-version-range.js.map +1 -0
- package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
- package/dist/esm/project-config/provider-catalog-types.js.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.d.ts +256 -30
- package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js +719 -40
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts +125 -2
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.js +283 -66
- package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
- package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-creation-verification.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-modules.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-modules.utils.js.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/backing-service-servability.d.ts +157 -0
- package/dist/esm/project-config/shared/backing-service-servability.d.ts.map +1 -0
- package/dist/esm/project-config/shared/backing-service-servability.js +256 -0
- package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -0
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts +62 -67
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.js +71 -68
- package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
- package/dist/esm/project-config/shared/cdn.example.js.map +1 -1
- package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/cdn.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.js.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-emit.js +41 -2
- package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/data-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/env-example-defaults.js.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +180 -4
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.js +40 -0
- package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infra-service.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
- package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
- package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
- package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
- package/dist/esm/project-config/shared/object-storage-session-policy.d.ts.map +1 -1
- package/dist/esm/project-config/shared/object-storage-session-policy.js.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/schema-version.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -1
- package/dist/esm/project-config/static-asset-import-noop.d.ts +26 -0
- package/dist/esm/project-config/static-asset-import-noop.d.ts.map +1 -0
- package/dist/esm/project-config/static-asset-import-noop.js +49 -0
- package/dist/esm/project-config/static-asset-import-noop.js.map +1 -0
- package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
- package/dist/esm/registry/artifact-domain.schemas.js.map +1 -1
- package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/digest.schemas.js.map +1 -1
- package/dist/esm/registry/index.d.ts +3 -1
- package/dist/esm/registry/index.d.ts.map +1 -1
- package/dist/esm/registry/index.js +3 -1
- package/dist/esm/registry/index.js.map +1 -1
- package/dist/esm/registry/local-checkout-source.d.ts +31 -0
- package/dist/esm/registry/local-checkout-source.d.ts.map +1 -0
- package/dist/esm/registry/local-checkout-source.js +45 -0
- package/dist/esm/registry/local-checkout-source.js.map +1 -0
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +174 -14
- package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
- package/dist/esm/registry/lockfile-modules-section.schemas.js +120 -11
- package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.d.ts +79 -0
- package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-artifact.schemas.js +36 -0
- package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.d.ts +393 -7
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js +488 -40
- package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
- package/dist/esm/registry/module-search.schemas.d.ts +80 -0
- package/dist/esm/registry/module-search.schemas.d.ts.map +1 -0
- package/dist/esm/registry/module-search.schemas.js +112 -0
- package/dist/esm/registry/module-search.schemas.js.map +1 -0
- package/dist/esm/registry/registry-config.schemas.d.ts +16 -0
- package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
- package/dist/esm/registry/registry-config.schemas.js +8 -0
- package/dist/esm/registry/registry-config.schemas.js.map +1 -1
- package/dist/esm/registry/registry-defaults.constants.d.ts.map +1 -1
- package/dist/esm/registry/registry-defaults.constants.js.map +1 -1
- package/dist/esm/registry/registry-errors.d.ts +126 -2
- package/dist/esm/registry/registry-errors.d.ts.map +1 -1
- package/dist/esm/registry/registry-errors.js +183 -14
- package/dist/esm/registry/registry-errors.js.map +1 -1
- package/dist/esm/registry/registry-keys.schemas.d.ts +80 -0
- package/dist/esm/registry/registry-keys.schemas.d.ts.map +1 -0
- package/dist/esm/registry/registry-keys.schemas.js +68 -0
- package/dist/esm/registry/registry-keys.schemas.js.map +1 -0
- package/dist/esm/registry/registry-section-schemas.constants.d.ts +25 -3
- package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
- package/dist/esm/registry/registry-section-schemas.constants.js.map +1 -1
- package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
- package/dist/esm/release/framework-release.constants.js.map +1 -1
- package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-info.schemas.js.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.js.map +1 -1
- package/dist/esm/workspace-scope/index.d.ts.map +1 -1
- package/dist/esm/workspace-scope/index.js.map +1 -1
- package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
- package/dist/esm/workspace-scope/resolve-homes.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +13 -11
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js +2 -2
- package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/dist/esm/registry/companion-api.schemas.d.ts +0 -176
- package/dist/esm/registry/companion-api.schemas.d.ts.map +0 -1
- package/dist/esm/registry/companion-api.schemas.js +0 -165
- package/dist/esm/registry/companion-api.schemas.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-backing-service-access.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-backing-service-access.js","sourceRoot":"","sources":["../../../src/bootstrap/runtime-backing-service-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,+BAA+B,EAAoC,MAAM,+BAA+B,CAAC;AAsElH;;;;;;;;;GASG;AACH,MAAM,iCAAiC,GAA+B;IACpE,eAAe,CAAC,cAAc;IAC9B,eAAe,CAAC,aAAa;IAC7B,gFAAgF;IAChF,8EAA8E;IAC9E,iFAAiF;IACjF,gFAAgF;IAChF,eAAe,CAAC,iBAAiB;CAClC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,wBAAwB,GAA+B;IAC3D,eAAe,CAAC,iBAAiB;IACjC,eAAe,CAAC,mBAAmB;IACnC,eAAe,CAAC,cAAc;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kCAAkC,CAChD,SAAkD,EAClD,WAAkD;IAElD,MAAM,sBAAsB,GAAG,WAAW,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAE5E,QAAQ,SAAS,EAAE,IAAI,EAAE,CAAC;QACxB,KAAK,+BAA+B,CAAC,mBAAmB;YACtD,2EAA2E;YAC3E,2EAA2E;YAC3E,wEAAwE;YACxE,mEAAmE;YACnE,sDAAsD;YACtD,OAAO;gBACL,YAAY,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;gBACrD,sBAAsB;aACvB,CAAC;QAEJ,KAAK,+BAA+B,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,iCAAiC,CAAC,CAAC;YAChE,yEAAyE;YACzE,0DAA0D;YAC1D,EAAE;YACF,sEAAsE;YACtE,wEAAwE;YACxE,sEAAsE;YACtE,0EAA0E;YAC1E,uCAAuC;YACvC,IAAI,WAAW,EAAE,cAAc,EAAE,CAAC;gBAChC,KAAK,MAAM,UAAU,IAAI,wBAAwB;oBAAE,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAClF,CAAC;YACD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC;QAClD,CAAC;QAED,KAAK,+BAA+B,CAAC,MAAM;YACzC,yEAAyE;YACzE,4EAA4E;YAC5E,mEAAmE;YACnE,4EAA4E;YAC5E,2EAA2E;YAC3E,+DAA+D;YAC/D,OAAO,EAAE,YAAY,EAAE,IAAI,GAAG,EAAE,EAAE,sBAAsB,EAAE,CAAC;QAE7D;YACE,2EAA2E;YAC3E,wEAAwE;YACxE,sEAAsE;YACtE,mCAAmC;YACnC,OAAO,EAAE,YAAY,EAAE,IAAI,GAAG,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC;IACtE,CAAC;AACH,CAAC","sourcesContent":["import { InfraCapability } from '../project-config/shared/infra-providers.schemas';\nimport { ApplicationRuntimePrincipalKind, type ApplicationRuntimePrincipal } from './runtime-principal.contracts';\n\n/**\n * WHICH backing services a runtime may reach, derived from what it DECLARED.\n *\n * ## Why this exists as one function\n *\n * Three enforcement points must agree about a runtime's backing-service access:\n * the CREDENTIALS apps-manager mints for it, the network MEMBERSHIP its container\n * gets, and the connection TOPOLOGY written into its environment. Each is\n * independently sufficient to deny, which is the point — but only while they\n * describe the same set.\n *\n * They are also each capable of silently disagreeing. A runtime kept off a\n * service's network while still receiving that service's connect URL is the worst\n * of the three combinations: `isConfigured()` reports true, a health probe or a\n * first use runs, and an unroutable host fails as a timeout for a runtime that was\n * never supposed to have the service at all. The fix is not a compensating branch\n * in a health check — it is that the two derive from HERE, so a non-declaring\n * runtime is never configured in the first place and there is nothing to\n * distinguish.\n *\n * So this is deliberately NOT a helper each consumer may reimplement \"for its own\n * needs\". Consumers call it; none re-derives. That is the whole anti-bypass\n * strategy, and the enumeration of who must call it lives in\n * `.claude/plans/minion-nature-and-authority.md` (Step 5-egress).\n *\n * ## The vocabulary is `InfraCapability`, not a new enum\n *\n * That is already what an infra provider module declares it supplies, so a\n * capability named here and a provider that serves it cannot drift into two\n * spellings of one concept.\n */\nexport interface RuntimeBackingServiceAccess {\n /**\n * Capabilities this runtime may reach. Empty is a legitimate, meaningful answer\n * — see the WORKER case — and must never be read as \"unspecified, allow all\".\n */\n readonly capabilities: ReadonlySet<InfraCapability>;\n /**\n * Whether this runtime needs a route off the host at all.\n *\n * Authored, never inferred: a scraper minion legitimately reaches the public\n * internet, and the point of the flag is not to refuse that but to stop egress\n * being universal and unstated. Default false, so the safe answer is the one you\n * get by not thinking about it.\n */\n readonly requiresInternetEgress: boolean;\n}\n\n/**\n * What a minion declares about its access to the application's data.\n *\n * Structural rather than importing the app-declaration type, so this contract does\n * not acquire the whole configuration graph for two fields.\n */\nexport interface RuntimeAccessDeclaration {\n /**\n * The minion's authored `resourceAccess`, or `undefined` when it declared none.\n *\n * The distinction is load-bearing and mirrors `deriveMinionResourceGrants`:\n * ABSENT means application-data access was never requested (D11/R3), so no\n * database credential is minted AND no database network is joined. An empty but\n * PRESENT declaration is a different statement and is not this.\n */\n readonly resourceAccess?: { read?: readonly string[]; write?: readonly string[] } | undefined;\n /** Authored opt-in; see {@link RuntimeBackingServiceAccess.requiresInternetEgress}. */\n readonly requiresInternetEgress?: boolean | undefined;\n}\n\n/**\n * Capabilities every MINION reaches regardless of what it declared.\n *\n * A minion is tick-driven and single-flighted: it consumes its tick queue and its\n * own RPC reply queue (QUEUING_SYSTEM) and holds a per-principal Redis namespace\n * (CACHE_MANAGER) used for its single-flight lease. Both credentials are minted\n * unconditionally for every minion today, so withholding either network would\n * strand a credential the platform issued — the incoherence this module exists to\n * prevent, arriving from the other direction.\n */\nconst MINION_UNCONDITIONAL_CAPABILITIES: readonly InfraCapability[] = [\n InfraCapability.QUEUING_SYSTEM,\n InfraCapability.CACHE_MANAGER,\n // Telemetry is unconditional for the same reason the platform segment is: every\n // runtime emits it, it carries no application data, and withholding it breaks\n // observability with NO signal — the collector appears in no readiness check, so\n // the failure surfaces as \"spans stopped\" long after the change that caused it.\n InfraCapability.METRICS_TELEMETRY,\n];\n\n/**\n * Capabilities a minion reaches ONLY when it declared application-data access.\n *\n * Both database kinds are listed because an application is backed by one or the\n * other and this layer does not know which; the consumer intersects with the\n * capabilities the application actually provisions. Listing only the provisioned\n * one here would make this function depend on infrastructure configuration to\n * answer a question about a DECLARATION.\n */\nconst MINION_DATA_CAPABILITIES: readonly InfraCapability[] = [\n InfraCapability.DOCUMENT_DATABASE,\n InfraCapability.RELATIONAL_DATABASE,\n InfraCapability.OBJECT_STORAGE,\n];\n\n/**\n * Derive a runtime's backing-service access from its principal and declaration.\n *\n * Fails CLOSED on every axis: an unknown principal kind, an absent declaration and\n * an absent `resourceAccess` all narrow rather than widen.\n */\nexport function resolveRuntimeBackingServiceAccess(\n principal: ApplicationRuntimePrincipal | undefined,\n declaration?: RuntimeAccessDeclaration | undefined,\n): RuntimeBackingServiceAccess {\n const requiresInternetEgress = declaration?.requiresInternetEgress === true;\n\n switch (principal?.kind) {\n case ApplicationRuntimePrincipalKind.APPLICATION_BACKEND:\n // The general runtime: it serves every request the application exposes, so\n // its access is the application's own provisioned set rather than anything\n // narrowed here. Returning the full vocabulary and letting the consumer\n // intersect with what the app provisions keeps THIS function about\n // declarations and the consumer about infrastructure.\n return {\n capabilities: new Set(Object.values(InfraCapability)),\n requiresInternetEgress,\n };\n\n case ApplicationRuntimePrincipalKind.MINION: {\n const capabilities = new Set(MINION_UNCONDITIONAL_CAPABILITIES);\n // ABSENT resourceAccess ⇒ no data capability at all: a minion that never\n // asked for application data must not have a route to it.\n //\n // ⚠️ This is NO LONGER the same gate as the credential minting. Since\n // 5c8936f86 the PostgreSQL mint gives such a minion a role carrying the\n // infrastructure floor (observed live 2026-09-26), so a credential is\n // issued that this layer gives no route to use. One rule has to be chosen\n // and derived for both layers — #1771.\n if (declaration?.resourceAccess) {\n for (const capability of MINION_DATA_CAPABILITIES) capabilities.add(capability);\n }\n return { capabilities, requiresInternetEgress };\n }\n\n case ApplicationRuntimePrincipalKind.WORKER:\n // EMPTY, and this is a measured fact rather than a conservative guess: a\n // worker never boots the application lifecycle — it is standalone by design\n // with no backing-service access, which is why it has no member in\n // `ApplicationRuntimeProfile` at all. D22/KD-3 says the same thing from the\n // credential side. Segmentation turns that policy into a reachability fact\n // instead of a promise about what nobody remembered to inject.\n return { capabilities: new Set(), requiresInternetEgress };\n\n default:\n // An unrecognised or absent principal gets NOTHING. Every caller uses this\n // to decide how narrowly a runtime is confined, so a permissive default\n // would widen confinement silently — the one direction that cannot be\n // detected by anything downstream.\n return { capabilities: new Set(), requiresInternetEgress: false };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-network-policy.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-network-policy.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/runtime-network-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAOjF;;;;;;;;;;;;;;;GAeG;AAEH,gEAAgE;AAChE,eAAO,MAAM,4BAA4B,kBAAkB,CAAC;AAE5D;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,2BAA2B,GAAG,SAAS,EAClD,WAAW,CAAC,EAAE,wBAAwB,GAAG,SAAS,EAClD,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED,iFAAiF;AACjF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kCAAkC,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,4BAA4B,EAAE,CAoD9G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-network-policy.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-network-policy.js","sourceRoot":"","sources":["../../../src/bootstrap/runtime-network-policy.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,+BAA+B,GAChC,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;GAeG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,SAAkD,EAClD,WAAkD,EAClD,OAA2C;IAE3C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,OAAO,IAAI,+BAA+B,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC;QACvF,MAAM,CA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;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,SAAS,CAAC,IAAI,CAAC;QACb,UAAU,EAAE,sBAAsB;QAClC,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,IAAI,CAAC,eAAe,mBAAmB,CAAC,MAAM,EAAE,CAAC;QAC3D,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,EAAE,CAAC,GAAG,4BAA4B,GAAG,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE;aAC1F;YACD,WAAW,EAAE,CAAC,QAAQ,CAAC;YACvB,yEAAyE;YACzE,2EAA2E;YAC3E,wEAAwE;YACxE,MAAM,EAAE,CAAC,EAAE,CAAC;SACb;KACF,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { ApplicationRuntimePrincipal } from './runtime-principal.contracts';\nimport type { RuntimeAccessDeclaration } from './runtime-backing-service-access';\nimport {\n WildoRuntimeNetwork,\n isInternalNetwork,\n resolveRuntimeNetworkMembership,\n} from './runtime-network-topology';\n\n/**\n * The Kubernetes rendering of {@link WildoRuntimeNetwork} (Step 5-egress, half A).\n *\n * ## Why labels rather than a policy per runtime\n *\n * Compose expresses segmentation as network MEMBERSHIP; Kubernetes has no such\n * concept — every pod shares one flat pod network and `NetworkPolicy` selects on\n * LABELS. So the same declaration renders two ways: a network list for Compose,\n * and a label set plus a static policy per network for Kubernetes.\n *\n * Keeping the policies STATIC and putting the per-runtime part entirely in labels\n * is what lets the cluster-level manifest generator emit them without knowing the\n * application's runtime inventory — the reason a policy-per-runtime shape was\n * rejected. It also means adding a minion changes only its own pod labels, never\n * a cluster policy, so the two cannot drift out of sync as runtimes come and go.\n */\n\n/** Label prefix marking which segment a pod participates in. */\nexport const RUNTIME_NETWORK_LABEL_PREFIX = 'wildo.ai/net-';\n\n/**\n * Pod labels for a runtime, derived from the SAME call Compose membership uses.\n *\n * A label is only ever `'true'`; ABSENCE is what denies. That asymmetry is\n * deliberate — `'false'` would be a value a selector could match by mistake, and\n * a policy that allowed `net-mongo != 'true'` would admit every pod that simply\n * never set the label.\n */\nexport function buildRuntimeNetworkPodLabels(\n principal: ApplicationRuntimePrincipal | undefined,\n declaration?: RuntimeAccessDeclaration | undefined,\n options?: { readonly servesHttp?: boolean },\n): Record<string, string> {\n const labels: Record<string, string> = {};\n for (const network of resolveRuntimeNetworkMembership(principal, declaration, options)) {\n labels[`${RUNTIME_NETWORK_LABEL_PREFIX}${network}`] = 'true';\n }\n return labels;\n}\n\n/** A `NetworkPolicy` document, in the shape the manifest renderer serialises. */\nexport interface RuntimeNetworkPolicyDocument {\n readonly apiVersion: 'networking.k8s.io/v1';\n readonly kind: 'NetworkPolicy';\n readonly metadata: { readonly name: string; readonly namespace?: string };\n readonly spec: Record<string, unknown>;\n}\n\n/**\n * The static policy set for a namespace.\n *\n * Emits, in order:\n *\n * 1. **A default-deny for ingress AND egress.** Both, because an egress-only\n * policy still lets an unlabelled pod be REACHED, and the pair is what makes\n * absence-of-label mean denial.\n * 2. **One ingress policy per INTERNAL network**, admitting only pods carrying\n * that network's label. The backing service itself is selected by the same\n * label, so a service and its clients are described by one string.\n * 3. **One egress policy for `wildo-egress`**, the only door off the cluster\n * below the edge, admitting only pods that AUTHORED the need.\n *\n * ⚠️ The default-deny is inert until pods carry labels from\n * {@link buildRuntimeNetworkPodLabels}. Emitting the policies WITHOUT wiring the\n * labels would deny everything at the first deployment — so the two must land in\n * the same change. This is the reverse of the usual vacuity trap: not a control\n * that enforces nothing, but a control that enforces everything.\n */\nexport function buildRuntimeNetworkPolicyDocuments(namespace?: string): readonly RuntimeNetworkPolicyDocument[] {\n const meta = (name: string): RuntimeNetworkPolicyDocument['metadata'] =>\n namespace ? { name, namespace } : { name };\n\n const documents: RuntimeNetworkPolicyDocument[] = [\n {\n apiVersion: 'networking.k8s.io/v1',\n kind: 'NetworkPolicy',\n metadata: meta('wildo-default-deny'),\n // An empty podSelector selects EVERY pod in the namespace; naming both\n // policy types with no rules denies both directions.\n spec: { podSelector: {}, policyTypes: ['Ingress', 'Egress'] },\n },\n ];\n\n for (const network of Object.values(WildoRuntimeNetwork)) {\n if (!isInternalNetwork(network)) continue;\n documents.push({\n apiVersion: 'networking.k8s.io/v1',\n kind: 'NetworkPolicy',\n metadata: meta(`wildo-allow-${network}`),\n spec: {\n podSelector: { matchLabels: { [`${RUNTIME_NETWORK_LABEL_PREFIX}${network}`]: 'true' } },\n policyTypes: ['Ingress'],\n ingress: [\n {\n from: [\n { podSelector: { matchLabels: { [`${RUNTIME_NETWORK_LABEL_PREFIX}${network}`]: 'true' } } },\n ],\n },\n ],\n },\n });\n }\n\n documents.push({\n apiVersion: 'networking.k8s.io/v1',\n kind: 'NetworkPolicy',\n metadata: meta(`wildo-allow-${WildoRuntimeNetwork.EGRESS}`),\n spec: {\n podSelector: {\n matchLabels: { [`${RUNTIME_NETWORK_LABEL_PREFIX}${WildoRuntimeNetwork.EGRESS}`]: 'true' },\n },\n policyTypes: ['Egress'],\n // Unrestricted destination, deliberately: this is the AUTHORED door, and\n // narrowing it by CIDR would be a claim about the internet nobody can keep\n // current. What the declaration buys is that the door is not universal.\n egress: [{}],\n },\n });\n\n return documents;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-network-topology.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-network-topology.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/runtime-network-topology.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,oBAAY,mBAAmB;IAC7B,sFAAsF;IACtF,IAAI,eAAe;IACnB;;;;OAIG;IACH,QAAQ,mBAAmB;IAC3B,UAAU,qBAAqB;IAC/B,aAAa,wBAAwB;IACrC,UAAU,qBAAqB;IAC/B,WAAW,sBAAsB;IACjC,YAAY,uBAAuB;IACnC,cAAc,yBAAyB;IACvC,8FAA8F;IAC9F,UAAU,qBAAqB;IAC/B,0FAA0F;IAC1F,cAAc,yBAAyB;IACvC;;;;;OAKG;IACH,MAAM,iBAAiB;CACxB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,eAAe,EAAE,mBAAmB,GAAG,IAAI,CAwBtF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,2BAA2B,GAAG,SAAS,EAClD,WAAW,CAAC,EAAE,wBAAwB,GAAG,SAAS,EAClD,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1C,WAAW,CAAC,mBAAmB,CAAC,CAgClC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAEvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-network-topology.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-network-topology.js","sourceRoot":"","sources":["../../../src/bootstrap/runtime-network-topology.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AAEnF,OAAO,EACL,kCAAkC,GAEnC,MAAM,kCAAkC,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,MAAM,CAAN,IAAY,mBA0BX;AA1BD,WAAY,mBAAmB;IAC7B,sFAAsF;IACtF,0CAAmB,CAAA;IACnB;;;;OAIG;IACH,kDAA2B,CAAA;IAC3B,sDAA+B,CAAA;IAC/B,4DAAqC,CAAA;IACrC,sDAA+B,CAAA;IAC/B,wDAAiC,CAAA;IACjC,0DAAmC,CAAA;IACnC,8DAAuC,CAA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E;IAC3E,2EAA2E;IAC3E,6EAA6E;IAC7E,8EAA8E;IAC9E,kDAAkD;IAClD,EAAE;IACF,6EAA6E;IAC7E,gFAAgF;IAChF,+EAA+E;IAC/E,+EAA+E;IAC/E,qCAAqC;IACrC,IAAI,SAAS;QAAE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE1D,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,OAAO;YAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,4EAA4E;IAC5E,+EAA+E;IAC/E,2EAA2E;IAC3E,qEAAqE;IACrE,IAAI,OAAO,EAAE,UAAU;QAAE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEhE,+DAA+D;IAC/D,IAAI,MAAM,CAAC,sBAAsB;QAAE,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5E,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA4B;IAC5D,OAAO,OAAO,KAAK,mBAAmB,CAAC,IAAI,IAAI,OAAO,KAAK,mBAAmB,CAAC,MAAM,CAAC;AACxF,CAAC","sourcesContent":["import { InfraCapability } from '../project-config/shared/infra-providers.schemas';\nimport type { ApplicationRuntimePrincipal } from './runtime-principal.contracts';\nimport {\n resolveRuntimeBackingServiceAccess,\n type RuntimeAccessDeclaration,\n} from './runtime-backing-service-access';\n\n/**\n * The network segments a Wildo deployment is divided into (Step 5-egress).\n *\n * Docker Compose has no `NetworkPolicy` object, but it has the mechanism that\n * matters for the destination half: membership of user-defined bridge networks,\n * with per-network embedded DNS. A container not attached to a network can\n * neither resolve nor route to the services on it — deny-by-default at the\n * network level. Kubernetes expresses the same division as `NetworkPolicy`\n * egress rules. Both renderers derive from THIS enum so they cannot describe\n * different topologies.\n */\nexport enum WildoRuntimeNetwork {\n /** Reverse proxy + every container serving HTTP. Not internal: it faces the world. */\n EDGE = 'wildo-edge',\n /**\n * The control plane — apps-manager, module-registry, crontabs — plus every\n * runtime that must fetch its secrets and configuration. Internal: nothing here\n * needs a route off the host.\n */\n PLATFORM = 'wildo-platform',\n DATA_MONGO = 'wildo-data-mongo',\n DATA_POSTGRES = 'wildo-data-postgres',\n DATA_REDIS = 'wildo-data-redis',\n DATA_RABBIT = 'wildo-data-rabbit',\n DATA_OBJECTS = 'wildo-data-objects',\n DATA_ANTIVIRUS = 'wildo-data-antivirus',\n /** Tamper-evident audit-log storage (immudb) — a service of its own, not a database table. */\n DATA_AUDIT = 'wildo-data-audit',\n /** The OTel collector. Nearly every runtime emits to it; almost nothing reads from it. */\n DATA_TELEMETRY = 'wildo-data-telemetry',\n /**\n * The ONLY non-internal network below the edge. Attachment to any non-internal\n * network restores NAT, so \"can this runtime reach the internet?\" is decided\n * here and nowhere else — marking the data networks internal is necessary but\n * not sufficient.\n */\n EGRESS = 'wildo-egress',\n}\n\n/**\n * Which network serves each backing-service capability.\n *\n * A total `Record`, deliberately: adding a member to {@link InfraCapability}\n * becomes a COMPILE ERROR here rather than a capability that silently reaches no\n * network — or worse, one whose runtimes silently keep the flat-network\n * reachability this segmentation exists to remove. `null` means the capability\n * needs no network of its own, and every `null` states why.\n */\nexport const NETWORK_FOR_CAPABILITY: Record<InfraCapability, WildoRuntimeNetwork | null> = {\n [InfraCapability.DOCUMENT_DATABASE]: WildoRuntimeNetwork.DATA_MONGO,\n [InfraCapability.RELATIONAL_DATABASE]: WildoRuntimeNetwork.DATA_POSTGRES,\n [InfraCapability.CACHE_MANAGER]: WildoRuntimeNetwork.DATA_REDIS,\n [InfraCapability.QUEUING_SYSTEM]: WildoRuntimeNetwork.DATA_RABBIT,\n [InfraCapability.OBJECT_STORAGE]: WildoRuntimeNetwork.DATA_OBJECTS,\n [InfraCapability.ANTIVIRUS_SCANNING]: WildoRuntimeNetwork.DATA_ANTIVIRUS,\n // ⚠️ CORRECTED 2026-08-12. Both of the entries below were `null`, on reasoning\n // that measurement disproved while building the 5B service table:\n //\n // - AUDIT_LOG_STORAGE was \"served BY the document/relational database\". It is\n // not: `immudb` is a service of its own, with its own container, and a\n // runtime that writes audit records dials IT rather than a database table.\n // - METRICS_TELEMETRY was \"no application runtime dials them directly today\".\n // Also false — runtimes emit spans and metrics to the collector, and that\n // traffic is live in development. A `null` here would have cut tracing for\n // every runtime the moment segmentation was enforced, with NO readiness\n // check covering it: a first-use failure, silent until someone noticed spans\n // had stopped.\n [InfraCapability.AUDIT_LOG_STORAGE]: WildoRuntimeNetwork.DATA_AUDIT,\n [InfraCapability.METRICS_TELEMETRY]: WildoRuntimeNetwork.DATA_TELEMETRY,\n // Backup remains genuinely operator-side: no application runtime dials it, and\n // the backup tooling runs outside the application's network entirely.\n [InfraCapability.BACKUP_MANAGER]: null,\n};\n\n/**\n * The networks a runtime's container joins.\n *\n * Derived from the SAME declaration as its credentials and its environment\n * topology — see {@link resolveRuntimeBackingServiceAccess}. That is the whole\n * point: a runtime kept off a service's network must also not hold that service's\n * credential nor receive its connect URL, and the only way three enforcement\n * points stay in agreement is by not deriving the answer three times.\n *\n * `PLATFORM` is unconditional. Every runtime — including a worker, which holds no\n * backing-service credentials at all — must reach apps-manager to fetch its own\n * bootstrap material. Withholding it would strand every runtime at boot, and it\n * grants no application data.\n */\nexport function resolveRuntimeNetworkMembership(\n principal: ApplicationRuntimePrincipal | undefined,\n declaration?: RuntimeAccessDeclaration | undefined,\n options?: { readonly servesHttp?: boolean },\n): ReadonlySet<WildoRuntimeNetwork> {\n const access = resolveRuntimeBackingServiceAccess(principal, declaration);\n const networks = new Set<WildoRuntimeNetwork>();\n\n // PLATFORM is for runtimes that FETCH their own bootstrap material — every\n // runtime principal does, including a worker that holds no backing-service\n // credentials at all. A caller with NO principal is not a runtime principal:\n // today that is the static frontend, an nginx container that authenticates to\n // nothing and has no bootstrap material to fetch.\n //\n // This was previously unconditional, which put that frontend on the platform\n // segment. Harmless — the segment carries no application data and the container\n // could not authenticate anyway — but it is reachability nobody asked for, and\n // \"unconditional because every case so far needed it\" is exactly the default a\n // later reader assumes was measured.\n if (principal) networks.add(WildoRuntimeNetwork.PLATFORM);\n\n for (const capability of access.capabilities) {\n const network = NETWORK_FOR_CAPABILITY[capability];\n if (network) networks.add(network);\n }\n\n // Serving HTTP is a property of the DEPLOYMENT (does a proxy route to it?),\n // not of what the runtime declared, so it arrives separately rather than being\n // inferred from the principal kind — an application backend that serves no\n // public route should not be on the edge merely for being a backend.\n if (options?.servesHttp) networks.add(WildoRuntimeNetwork.EDGE);\n\n // Authored, never inferred. See `RuntimeBackingServiceAccess`.\n if (access.requiresInternetEgress) networks.add(WildoRuntimeNetwork.EGRESS);\n\n return networks;\n}\n\n/**\n * Networks that must be declared `internal: true`.\n *\n * Derived by EXCLUSION from the two that legitimately carry a route off the host,\n * so a network added to the enum is internal by default. The safe posture is the\n * one you get by not thinking about it.\n */\nexport function isInternalNetwork(network: WildoRuntimeNetwork): boolean {\n return network !== WildoRuntimeNetwork.EDGE && network !== WildoRuntimeNetwork.EGRESS;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-platform-access.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-platform-access.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/runtime-platform-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAGlH,OAAO,EAAE,yBAAyB,EAAE,MAAM,4DAA4D,CAAC;AAEvG;;;;;;;;;;;;;;;GAeG;AAGH,kEAAkE;AAClE,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,yBAAyB,EAAE,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,2BAA2B,GAAG,SAAS,EAClD,WAAW,EAAE,+BAA+B,GAAG,SAAS,GACvD;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-platform-access.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-platform-access.js","sourceRoot":"","sources":["../../../src/bootstrap/runtime-platform-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAoC,MAAM,+BAA+B,CAAC;AAClH,+EAA+E;AAC/E,8DAA8D;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4DAA4D,CAAC;AAyBvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAAkD,EAClD,WAAwD;IAExD,2EAA2E;IAC3E,+EAA+E;IAC/E,6EAA6E;IAC7E,YAAY;IACZ,IAAI,SAAS,EAAE,IAAI,KAAK,+BAA+B,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/F,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,yBAAyB,CAAC,gBAAgB,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5F,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC","sourcesContent":["import { ApplicationRuntimePrincipalKind, type ApplicationRuntimePrincipal } from './runtime-principal.contracts';\n// Declared under `project-config` so an authored config can NAME it — see that\n// file for why the authoring entry cannot reach `bootstrap/`.\nimport { MinionPlatformAccessScope } from '../project-config/shared/minion-platform-access.vocabulary';\n\n/**\n * The PLATFORM-ACCESS axis (Step 3 / R4 / R5) — a minion reading its own\n * platform-level records, today its cron/schedule entries.\n *\n * ## Why this is a SECOND axis and not part of `resourceAccess`\n *\n * `resourceAccess` answers \"which of the APPLICATION's resources may this minion\n * touch?\". This answers \"may it see the PLATFORM's record OF ITSELF?\" — a\n * different subject, a different store, and a different blast radius. R5 requires\n * the two be separately declarable with neither implying the other, so nothing\n * here consults `resourceAccess` and nothing there consults this.\n *\n * A minion that declares data access but no platform access is a normal shape\n * (it works on todos, never inspects its own schedule). So is the reverse (a\n * health-reporting minion that reads its tick history and touches no app data).\n */\n\n\n/** The authored declaration — optional, and absent means none. */\nexport interface MinionPlatformAccessDeclaration {\n readonly scopes?: readonly MinionPlatformAccessScope[];\n}\n\n/**\n * A filter that can ONLY ever address the caller's own records.\n *\n * ## Scoped-to-self BY SHAPE, which is the whole point of R4\n *\n * The obvious implementation takes a minion NAME and refuses when it does not\n * match the caller. That is scoped-to-self by CHECK, and it fails the way every\n * check fails: someone adds an admin path, or an internal caller passes the name\n * it was given, and the refusal is one conditional away from gone.\n *\n * This takes **no target parameter at all**. The subject is derived from the\n * PRINCIPAL, so \"read minion B's schedule\" is not a request that gets refused —\n * it is a request that cannot be expressed. A future caller wanting cross-minion\n * reads must add a new function, which is a reviewable act, rather than passing a\n * different string to this one, which is not.\n *\n * Returns `null` when the principal may not read platform records at all, so the\n * caller has nothing to query WITH — the same fail-closed shape as\n * `deriveMinionResourceGrants` returning `null`.\n *\n * ## ⚠️ PRECONDITION: `principal` must be VERIFIED, not self-asserted\n *\n * The by-shape property above is real and it is CONDITIONAL. This function makes a\n * cross-minion read inexpressible *given a trustworthy principal* — it says\n * nothing about where the principal came from, and a caller that accepts a\n * self-asserted one has a hole this signature cannot close.\n *\n * That is not hypothetical. A minion is delivered the application's\n * `APPLICATION_PLATFORM_REQUEST` **private** key: the delivery projection strips\n * per-app CREDENTIAL paths (`database.*`) and the JWT material is not among them,\n * so it survives in the base blob. A minion can therefore sign a token naming a\n * sibling minion or the application backend, and a by-shape endpoint would\n * satisfy \"no selector exists\" while still failing R4's acceptance criterion.\n *\n * So a caller MUST obtain the principal from a party that learns it from the\n * secret PRESENTED rather than one asserted in a claim — today that is\n * apps-manager, which resolves it by matching the presenting secret against the\n * minted per-principal set. Found by the `Minion Scope` session while building the\n * transport for this axis; recorded here because the precondition belongs with the\n * contract, not only in the transport that happens to satisfy it.\n */\nexport function buildOwnCronRecordFilter(\n principal: ApplicationRuntimePrincipal | undefined,\n declaration: MinionPlatformAccessDeclaration | undefined,\n): { readonly minionName: string } | null {\n // Only a MINION has cron records of its own. The application backend reads\n // schedules through its own authority, and a worker has none — so neither is a\n // subject here, and granting them a filter would invent a record that has no\n // referent.\n if (principal?.kind !== ApplicationRuntimePrincipalKind.MINION || !principal.name) return null;\n if (!declaration?.scopes?.includes(MinionPlatformAccessScope.OWN_CRON_RECORDS)) return null;\n return { minionName: principal.name };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-principal.contracts.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-principal.contracts.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/runtime-principal.contracts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,oBAAY,+BAA+B;IACzC;;;;;OAKG;IACH,mBAAmB,wBAAwB;IAC3C,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,qBAAqB,GACjC,+BAA+B,CAOjC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,+BAA+B,CAAC;IACtC,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,4EAA4E;AAC5E,eAAO,MAAM,6BAA6B,EAAE,2BAE3C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,2BAA2B,GAAG,MAAM,CAIvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,GAAG,IAAI,CAaxF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC/C,GAAG,2BAA2B,EAAE,CAYhC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAErF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sCAAsC,CACpD,cAAc,EAAE,MAAM,GAAG,SAAS,GACjC,+BAA+B,GAAG,SAAS,CAW7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,+BAA+B,GAAG,SAAS,EAC1D,aAAa,EAAE,MAAM,GAAG,SAAS,GAChC,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-principal.contracts.js","sourceRoot":"","sources":["../../../../src/bootstrap/runtime-principal.contracts.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,yDAAyD;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAN,IAAY,+BAUX;AAVD,WAAY,+BAA+B;IACzC;;;;;OAKG;IACH,8EAA2C,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AAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iCAAiC,CAC/C,aAA0D,EAC1D,aAAiC;IAEjC,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,+BAA+B,CAAC,mBAAmB,EAAE,CAAC;QAC5F,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IAC9E,gFAAgF;IAChF,MAAM,SAAS,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC/F,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC","sourcesContent":["// Root barrel, matching the sibling bootstrap files: `BackgroundRuntimeType`\n// lives in the decorator-bound graph, not the browser-safe `/public-runtime`\n// atom subset. This module is platform/CLI-side only and never reaches a\n// browser bundle, so the root import costs nothing here.\nimport { BackgroundRuntimeType } from '@wildo-ai/saas-models';\n\n/**\n * WHOSE credentials are these? — the credential-principal axis.\n *\n * Wildo now has three runtime-identity vocabularies and they answer three\n * different questions. They are deliberately NOT collapsed, even where their\n * members currently coincide:\n *\n * - `BackgroundRuntimeType` (`MINION | WORKER`) — *what kind of deployable is\n * this?* A compose service, a K8s workload, a provider-runtime scope. It has\n * no application-backend member because the backend is not a background\n * runtime.\n * - `ApplicationRuntimeProfile` (`APPLICATION_BACKEND | MINION`) — *does this\n * boot assertion apply to me?* Inside a single process. It has no worker\n * member because workers never boot that lifecycle.\n * - **This enum** (`APPLICATION_BACKEND | MINION | WORKER`) — *which principal\n * is authenticating, and whose secrets may it receive?* It is the only one of\n * the three that spans every runtime capable of presenting a credential, which\n * is exactly why it cannot be expressed as either neighbour.\n *\n * Merging any pair would be convenient and wrong: a future runtime that boots no\n * lifecycle but does hold credentials (or the reverse) would silently inherit a\n * decision made for a different question.\n *\n * @see BackgroundRuntimeType — the deployable-kind axis this maps FROM\n */\nexport enum ApplicationRuntimePrincipalKind {\n /**\n * The application's own backend service. Historically the ONLY principal:\n * before per-runtime identity, one `primarySecret` per application was held\n * identically by the backend and by every minion and worker, so at the\n * apps-manager door they were indistinguishable.\n */\n APPLICATION_BACKEND = 'application_backend',\n MINION = 'minion',\n WORKER = 'worker',\n}\n\n/**\n * Map a deployable background-runtime kind onto its credential principal.\n *\n * The one place the two vocabularies meet. Keeping the translation in a single\n * exhaustive switch means adding a member to `BackgroundRuntimeType` is a\n * COMPILE error here rather than a silent gap at whichever call site happened to\n * assume a mapping.\n */\nexport function principalKindForBackgroundRuntime(\n runtimeType: BackgroundRuntimeType,\n): ApplicationRuntimePrincipalKind {\n switch (runtimeType) {\n case BackgroundRuntimeType.MINION:\n return ApplicationRuntimePrincipalKind.MINION;\n case BackgroundRuntimeType.WORKER:\n return ApplicationRuntimePrincipalKind.WORKER;\n }\n}\n\n/**\n * A runtime principal's stable identity within one application.\n *\n * `name` is the `wildo.saas.config.ts` bucket key (`marketingScrapper`,\n * `myNodeWorker`) — the SAME identity axis the deploy path already carries as\n * `wildo.ai/owned-service-name` and `APP_OWNED_SERVICE_NAME`. Reusing the bucket\n * key rather than the `serviceName` matters: the bucket key is what the\n * declaration, the config lookup and the pod label all agree on, while\n * `serviceName` is a rendering concern that is normalised for DNS.\n *\n * The backend principal carries no name — an application has exactly one, so a\n * name would be a second way to say `APPLICATION_BACKEND`.\n */\nexport interface ApplicationRuntimePrincipal {\n kind: ApplicationRuntimePrincipalKind;\n /** Absent for {@link ApplicationRuntimePrincipalKind.APPLICATION_BACKEND}. */\n name?: string | undefined;\n}\n\n/** The canonical backend principal — one per application, by definition. */\nexport const APPLICATION_BACKEND_PRINCIPAL: ApplicationRuntimePrincipal = {\n kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND,\n};\n\n/**\n * Render a principal as a single stable string.\n *\n * Used as the stored key for a principal's secret, as the URL segment when the\n * CLI asks for a named principal's bootstrap credentials, and in log/audit\n * fields. ONE renderer so those three never drift into three spellings of the\n * same identity.\n *\n * `:` is the separator because neither half can contain it — the kinds are a\n * closed enum, and a bucket key is a TypeScript object key in\n * `wildo.saas.config.ts`. {@link parseRuntimePrincipalKey} rejects anything that\n * does not round-trip, so a key that ever gains a colon fails loudly at the\n * boundary rather than resolving to the wrong principal.\n */\nexport function buildRuntimePrincipalKey(principal: ApplicationRuntimePrincipal): string {\n return principal.kind === ApplicationRuntimePrincipalKind.APPLICATION_BACKEND\n ? ApplicationRuntimePrincipalKind.APPLICATION_BACKEND\n : `${principal.kind}:${principal.name ?? ''}`;\n}\n\n/**\n * Inverse of {@link buildRuntimePrincipalKey}. Returns `null` for anything\n * malformed — an unknown kind, a missing name on a named kind, or a name\n * containing the separator.\n *\n * Fail-closed by returning `null` rather than throwing OR guessing: this parses\n * values that reach the system from a URL segment and from stored rows, and a\n * lenient parse there is how one principal's key resolves to another's secret.\n */\nexport function parseRuntimePrincipalKey(key: string): ApplicationRuntimePrincipal | null {\n if (key === ApplicationRuntimePrincipalKind.APPLICATION_BACKEND) {\n return APPLICATION_BACKEND_PRINCIPAL;\n }\n const separatorIndex = key.indexOf(':');\n if (separatorIndex <= 0) return null;\n const kind = key.slice(0, separatorIndex);\n const name = key.slice(separatorIndex + 1);\n if (name.length === 0 || name.includes(':')) return null;\n if (kind !== ApplicationRuntimePrincipalKind.MINION && kind !== ApplicationRuntimePrincipalKind.WORKER) {\n return null;\n }\n return { kind, name };\n}\n\n/**\n * Every principal an application declares: its backend, plus one per declared\n * minion and worker.\n *\n * Derived from the managed declaration — the same input the config seed already\n * consumes — so the credential set and the deployed runtime set cannot diverge.\n * That is also what makes revocation fall out for free: a runtime removed from\n * `wildo.saas.config.ts` simply stops appearing here, and the mint step prunes\n * any stored secret whose key is no longer in this list (R15).\n *\n * The backend is ALWAYS included, including for an application that declares no\n * minions and no workers — it is the principal that must never be absent.\n */\nexport function enumerateDeclaredRuntimePrincipals(declaration: {\n minions?: Record<string, unknown> | undefined;\n workers?: Record<string, unknown> | undefined;\n}): ApplicationRuntimePrincipal[] {\n return [\n APPLICATION_BACKEND_PRINCIPAL,\n ...Object.keys(declaration.minions ?? {}).map((name) => ({\n kind: ApplicationRuntimePrincipalKind.MINION,\n name,\n })),\n ...Object.keys(declaration.workers ?? {}).map((name) => ({\n kind: ApplicationRuntimePrincipalKind.WORKER,\n name,\n })),\n ];\n}\n\n/**\n * The Redis key namespace a MINION owns (D20).\n *\n * `<appSlug>:minions:<name>:` — a strict extension of the application's own\n * `<appSlug>:` prefix, which is what lets `RedisService` keep enforcing \"an\n * authored prefix must start with `<appSlug>:`\" unchanged.\n *\n * ## One derivation, deliberately, because it is a COUPLED PAIR\n *\n * Two places consume this and they must agree exactly: the Redis ACL key pattern\n * apps-manager grants the minion's user, and the `REDIS_KEY_PREFIX` the CLI\n * writes into that minion's environment. If they disagree by even a character,\n * every Redis operation the minion performs is DENIED — and the error names an\n * ACL, not the mismatch, so nothing in the minion's own configuration explains\n * it. Deriving both from this function is what makes that class of failure\n * unrepresentable rather than merely unlikely.\n *\n * Based on `appSlug` rather than an authored `dataServices.redis.keyPrefix`\n * because the ACL pattern already is (`RedisSelfInfraProviderModule`), and one\n * inconsistency is better than two competing bases. An application that authors\n * a custom prefix therefore has a PRE-EXISTING mismatch with its own ACL; that\n * gap is older than per-principal credentials and is not narrowed here.\n */\nexport function buildMinionRedisKeyPrefix(appSlug: string, minionName: string): string {\n return `${appSlug}:minions:${minionName}:`;\n}\n\n/**\n * Map an `ApplicationRuntimeProfile` value onto the credential-principal axis.\n *\n * The two vocabularies are deliberately SEPARATE — a runtime profile answers\n * \"which declaration class am I?\", a principal kind answers \"whose credential do\n * I hold?\" — but their string values coincide today. A consumer that relies on\n * that coincidence by comparing raw strings has made the coupling invisible; this\n * function is where the crossing is allowed to happen, once.\n *\n * Fail-closed: an unrecognised profile returns `undefined` rather than a\n * plausible default, because every caller uses the result to decide how narrowly\n * a runtime is confined, and guessing there widens confinement silently.\n */\nexport function runtimePrincipalKindFromRuntimeProfile(\n runtimeProfile: string | undefined,\n): ApplicationRuntimePrincipalKind | undefined {\n switch (runtimeProfile) {\n case ApplicationRuntimePrincipalKind.APPLICATION_BACKEND:\n return ApplicationRuntimePrincipalKind.APPLICATION_BACKEND;\n case ApplicationRuntimePrincipalKind.MINION:\n return ApplicationRuntimePrincipalKind.MINION;\n case ApplicationRuntimePrincipalKind.WORKER:\n return ApplicationRuntimePrincipalKind.WORKER;\n default:\n return undefined;\n }\n}\n\n/**\n * The principal segment embedded in a runtime's RPC reply-queue name.\n *\n * ## Why this exists — the same reason as {@link buildMinionRedisKeyPrefix}\n *\n * Two places consume this and they must agree EXACTLY: the broker permission\n * pattern apps-manager grants a minion's user, and the reply-queue name the\n * minion's own AMQP adapter declares and consumes. If they disagree by even a\n * character the minion's every reply is refused with `403 ACCESS_REFUSED`, and\n * the error names a permission rather than the mismatch — so nothing in the\n * minion's own configuration explains it.\n *\n * It previously WAS derived twice: the adapter sanitised its runtime key while\n * the permission builder escaped the raw minion name, coupled only by a comment\n * saying the two \"mirror\" each other. They agreed for `marketingScrapper` and\n * would have diverged for any name containing a character sanitisation rewrites\n * (`marketing.scrapper` → `marketing-scrapper` on one side, `marketing.scrapper`\n * on the other). A comment describing what the other side must do is not a site\n * that upholds an invariant; deriving both from here makes the divergence\n * unrepresentable instead of merely unlikely.\n *\n * Returns `undefined` for the APPLICATION BACKEND, which keeps the historical\n * segment-less reply-queue layout — that is what stops a minion's permission\n * from ever matching the backend's replies.\n */\nexport function buildRuntimePrincipalQueueSegment(\n principalKind: ApplicationRuntimePrincipalKind | undefined,\n principalName: string | undefined,\n): string | undefined {\n if (!principalKind || principalKind === ApplicationRuntimePrincipalKind.APPLICATION_BACKEND) {\n return undefined;\n }\n // Sanitised for the same reason the ACL usernames are: a principal name comes\n // from a TypeScript object key and may hold characters a queue name should not.\n const sanitized = (principalName ?? '').replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '');\n return sanitized ? `${principalKind}-${sanitized}` : undefined;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"runtime-principal.contracts.js","sourceRoot":"","sources":["../../../src/bootstrap/runtime-principal.contracts.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,yDAAyD;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAN,IAAY,+BAUX;AAVD,WAAY,+BAA+B;IACzC;;;;;OAKG;IACH,8EAA2C,CAAA;IAC3C,oDAAiB,CAAA;IACjB,oDAAiB,CAAA;AACnB,CAAC,EAVW,+BAA+B,KAA/B,+BAA+B,QAU1C;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iCAAiC,CAC/C,WAAkC;IAElC,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,qBAAqB,CAAC,MAAM;YAC/B,OAAO,+BAA+B,CAAC,MAAM,CAAC;QAChD,KAAK,qBAAqB,CAAC,MAAM;YAC/B,OAAO,+BAA+B,CAAC,MAAM,CAAC;IAClD,CAAC;AACH,CAAC;AAqBD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,6BAA6B,GAAgC;IACxE,IAAI,EAAE,+BAA+B,CAAC,mBAAmB;CAC1D,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CAAC,SAAsC;IAC7E,OAAO,SAAS,CAAC,IAAI,KAAK,+BAA+B,CAAC,mBAAmB;QAC3E,CAAC,CAAC,+BAA+B,CAAC,mBAAmB;QACrD,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,IAAI,GAAG,KAAK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UAAkB;IAC3E,OAAO,GAAG,OAAO,YAAY,UAAU,GAAG,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sCAAsC,CACpD,cAAkC;IAElC,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,+BAA+B,CAAC,mBAAmB;YACtD,OAAO,+BAA+B,CAAC,mBAAmB,CAAC;QAC7D,KAAK,+BAA+B,CAAC,MAAM;YACzC,OAAO,+BAA+B,CAAC,MAAM,CAAC;QAChD,KAAK,+BAA+B,CAAC,MAAM;YACzC,OAAO,+BAA+B,CAAC,MAAM,CAAC;QAChD;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iCAAiC,CAC/C,aAA0D,EAC1D,aAAiC;IAEjC,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,+BAA+B,CAAC,mBAAmB,EAAE,CAAC;QAC5F,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IAC9E,gFAAgF;IAChF,MAAM,SAAS,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC/F,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC","sourcesContent":["// Root barrel, matching the sibling bootstrap files: `BackgroundRuntimeType`\n// lives in the decorator-bound graph, not the browser-safe `/public-runtime`\n// atom subset. This module is platform/CLI-side only and never reaches a\n// browser bundle, so the root import costs nothing here.\nimport { BackgroundRuntimeType } from '@wildo-ai/saas-models';\n\n/**\n * WHOSE credentials are these? — the credential-principal axis.\n *\n * Wildo now has three runtime-identity vocabularies and they answer three\n * different questions. They are deliberately NOT collapsed, even where their\n * members currently coincide:\n *\n * - `BackgroundRuntimeType` (`MINION | WORKER`) — *what kind of deployable is\n * this?* A compose service, a K8s workload, a provider-runtime scope. It has\n * no application-backend member because the backend is not a background\n * runtime.\n * - `ApplicationRuntimeProfile` (`APPLICATION_BACKEND | MINION`) — *does this\n * boot assertion apply to me?* Inside a single process. It has no worker\n * member because workers never boot that lifecycle.\n * - **This enum** (`APPLICATION_BACKEND | MINION | WORKER`) — *which principal\n * is authenticating, and whose secrets may it receive?* It is the only one of\n * the three that spans every runtime capable of presenting a credential, which\n * is exactly why it cannot be expressed as either neighbour.\n *\n * Merging any pair would be convenient and wrong: a future runtime that boots no\n * lifecycle but does hold credentials (or the reverse) would silently inherit a\n * decision made for a different question.\n *\n * @see BackgroundRuntimeType — the deployable-kind axis this maps FROM\n */\nexport enum ApplicationRuntimePrincipalKind {\n /**\n * The application's own backend service. Historically the ONLY principal:\n * before per-runtime identity, one `primarySecret` per application was held\n * identically by the backend and by every minion and worker, so at the\n * apps-manager door they were indistinguishable.\n */\n APPLICATION_BACKEND = 'application_backend',\n MINION = 'minion',\n WORKER = 'worker',\n}\n\n/**\n * Map a deployable background-runtime kind onto its credential principal.\n *\n * The one place the two vocabularies meet. Keeping the translation in a single\n * exhaustive switch means adding a member to `BackgroundRuntimeType` is a\n * COMPILE error here rather than a silent gap at whichever call site happened to\n * assume a mapping.\n */\nexport function principalKindForBackgroundRuntime(\n runtimeType: BackgroundRuntimeType,\n): ApplicationRuntimePrincipalKind {\n switch (runtimeType) {\n case BackgroundRuntimeType.MINION:\n return ApplicationRuntimePrincipalKind.MINION;\n case BackgroundRuntimeType.WORKER:\n return ApplicationRuntimePrincipalKind.WORKER;\n }\n}\n\n/**\n * A runtime principal's stable identity within one application.\n *\n * `name` is the `wildo.saas.config.ts` bucket key (`marketingScrapper`,\n * `myNodeWorker`) — the SAME identity axis the deploy path already carries as\n * `wildo.ai/owned-service-name` and `APP_OWNED_SERVICE_NAME`. Reusing the bucket\n * key rather than the `serviceName` matters: the bucket key is what the\n * declaration, the config lookup and the pod label all agree on, while\n * `serviceName` is a rendering concern that is normalised for DNS.\n *\n * The backend principal carries no name — an application has exactly one, so a\n * name would be a second way to say `APPLICATION_BACKEND`.\n */\nexport interface ApplicationRuntimePrincipal {\n kind: ApplicationRuntimePrincipalKind;\n /** Absent for {@link ApplicationRuntimePrincipalKind.APPLICATION_BACKEND}. */\n name?: string | undefined;\n}\n\n/** The canonical backend principal — one per application, by definition. */\nexport const APPLICATION_BACKEND_PRINCIPAL: ApplicationRuntimePrincipal = {\n kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND,\n};\n\n/**\n * Render a principal as a single stable string.\n *\n * Used as the stored key for a principal's secret, as the URL segment when the\n * CLI asks for a named principal's bootstrap credentials, and in log/audit\n * fields. ONE renderer so those three never drift into three spellings of the\n * same identity.\n *\n * `:` is the separator because neither half can contain it — the kinds are a\n * closed enum, and a bucket key is a TypeScript object key in\n * `wildo.saas.config.ts`. {@link parseRuntimePrincipalKey} rejects anything that\n * does not round-trip, so a key that ever gains a colon fails loudly at the\n * boundary rather than resolving to the wrong principal.\n */\nexport function buildRuntimePrincipalKey(principal: ApplicationRuntimePrincipal): string {\n return principal.kind === ApplicationRuntimePrincipalKind.APPLICATION_BACKEND\n ? ApplicationRuntimePrincipalKind.APPLICATION_BACKEND\n : `${principal.kind}:${principal.name ?? ''}`;\n}\n\n/**\n * Inverse of {@link buildRuntimePrincipalKey}. Returns `null` for anything\n * malformed — an unknown kind, a missing name on a named kind, or a name\n * containing the separator.\n *\n * Fail-closed by returning `null` rather than throwing OR guessing: this parses\n * values that reach the system from a URL segment and from stored rows, and a\n * lenient parse there is how one principal's key resolves to another's secret.\n */\nexport function parseRuntimePrincipalKey(key: string): ApplicationRuntimePrincipal | null {\n if (key === ApplicationRuntimePrincipalKind.APPLICATION_BACKEND) {\n return APPLICATION_BACKEND_PRINCIPAL;\n }\n const separatorIndex = key.indexOf(':');\n if (separatorIndex <= 0) return null;\n const kind = key.slice(0, separatorIndex);\n const name = key.slice(separatorIndex + 1);\n if (name.length === 0 || name.includes(':')) return null;\n if (kind !== ApplicationRuntimePrincipalKind.MINION && kind !== ApplicationRuntimePrincipalKind.WORKER) {\n return null;\n }\n return { kind, name };\n}\n\n/**\n * Every principal an application declares: its backend, plus one per declared\n * minion and worker.\n *\n * Derived from the managed declaration — the same input the config seed already\n * consumes — so the credential set and the deployed runtime set cannot diverge.\n * That is also what makes revocation fall out for free: a runtime removed from\n * `wildo.saas.config.ts` simply stops appearing here, and the mint step prunes\n * any stored secret whose key is no longer in this list (R15).\n *\n * The backend is ALWAYS included, including for an application that declares no\n * minions and no workers — it is the principal that must never be absent.\n */\nexport function enumerateDeclaredRuntimePrincipals(declaration: {\n minions?: Record<string, unknown> | undefined;\n workers?: Record<string, unknown> | undefined;\n}): ApplicationRuntimePrincipal[] {\n return [\n APPLICATION_BACKEND_PRINCIPAL,\n ...Object.keys(declaration.minions ?? {}).map((name) => ({\n kind: ApplicationRuntimePrincipalKind.MINION,\n name,\n })),\n ...Object.keys(declaration.workers ?? {}).map((name) => ({\n kind: ApplicationRuntimePrincipalKind.WORKER,\n name,\n })),\n ];\n}\n\n/**\n * The Redis key namespace a MINION owns (D20).\n *\n * `<appSlug>:minions:<name>:` — a strict extension of the application's own\n * `<appSlug>:` prefix, which is what lets `RedisService` keep enforcing \"an\n * authored prefix must start with `<appSlug>:`\" unchanged.\n *\n * ## One derivation, deliberately, because it is a COUPLED PAIR\n *\n * Two places consume this and they must agree exactly: the Redis ACL key pattern\n * apps-manager grants the minion's user, and the `REDIS_KEY_PREFIX` the CLI\n * writes into that minion's environment. If they disagree by even a character,\n * every Redis operation the minion performs is DENIED — and the error names an\n * ACL, not the mismatch, so nothing in the minion's own configuration explains\n * it. Deriving both from this function is what makes that class of failure\n * unrepresentable rather than merely unlikely.\n *\n * Based on `appSlug` rather than an authored `dataServices.redis.keyPrefix`\n * because the ACL pattern already is (`RedisSelfInfraProviderModule`), and one\n * inconsistency is better than two competing bases. An application that authors\n * a custom prefix therefore has a PRE-EXISTING mismatch with its own ACL; that\n * gap is older than per-principal credentials and is not narrowed here.\n */\nexport function buildMinionRedisKeyPrefix(appSlug: string, minionName: string): string {\n return `${appSlug}:minions:${minionName}:`;\n}\n\n/**\n * Map an `ApplicationRuntimeProfile` value onto the credential-principal axis.\n *\n * The two vocabularies are deliberately SEPARATE — a runtime profile answers\n * \"which declaration class am I?\", a principal kind answers \"whose credential do\n * I hold?\" — but their string values coincide today. A consumer that relies on\n * that coincidence by comparing raw strings has made the coupling invisible; this\n * function is where the crossing is allowed to happen, once.\n *\n * Fail-closed: an unrecognised profile returns `undefined` rather than a\n * plausible default, because every caller uses the result to decide how narrowly\n * a runtime is confined, and guessing there widens confinement silently.\n */\nexport function runtimePrincipalKindFromRuntimeProfile(\n runtimeProfile: string | undefined,\n): ApplicationRuntimePrincipalKind | undefined {\n switch (runtimeProfile) {\n case ApplicationRuntimePrincipalKind.APPLICATION_BACKEND:\n return ApplicationRuntimePrincipalKind.APPLICATION_BACKEND;\n case ApplicationRuntimePrincipalKind.MINION:\n return ApplicationRuntimePrincipalKind.MINION;\n case ApplicationRuntimePrincipalKind.WORKER:\n return ApplicationRuntimePrincipalKind.WORKER;\n default:\n return undefined;\n }\n}\n\n/**\n * The principal segment embedded in a runtime's RPC reply-queue name.\n *\n * ## Why this exists — the same reason as {@link buildMinionRedisKeyPrefix}\n *\n * Two places consume this and they must agree EXACTLY: the broker permission\n * pattern apps-manager grants a minion's user, and the reply-queue name the\n * minion's own AMQP adapter declares and consumes. If they disagree by even a\n * character the minion's every reply is refused with `403 ACCESS_REFUSED`, and\n * the error names a permission rather than the mismatch — so nothing in the\n * minion's own configuration explains it.\n *\n * It previously WAS derived twice: the adapter sanitised its runtime key while\n * the permission builder escaped the raw minion name, coupled only by a comment\n * saying the two \"mirror\" each other. They agreed for `marketingScrapper` and\n * would have diverged for any name containing a character sanitisation rewrites\n * (`marketing.scrapper` → `marketing-scrapper` on one side, `marketing.scrapper`\n * on the other). A comment describing what the other side must do is not a site\n * that upholds an invariant; deriving both from here makes the divergence\n * unrepresentable instead of merely unlikely.\n *\n * Returns `undefined` for the APPLICATION BACKEND, which keeps the historical\n * segment-less reply-queue layout — that is what stops a minion's permission\n * from ever matching the backend's replies.\n */\nexport function buildRuntimePrincipalQueueSegment(\n principalKind: ApplicationRuntimePrincipalKind | undefined,\n principalName: string | undefined,\n): string | undefined {\n if (!principalKind || principalKind === ApplicationRuntimePrincipalKind.APPLICATION_BACKEND) {\n return undefined;\n }\n // Sanitised for the same reason the ACL usernames are: a principal name comes\n // from a TypeScript object key and may hold characters a queue name should not.\n const sanitized = (principalName ?? '').replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '');\n return sanitized ? `${principalKind}-${sanitized}` : undefined;\n}\n\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type RuntimeEndpointUrls } from '@wildo-ai/platform-core-shared';
|
|
2
|
+
import type { AppServiceDefinition } from '../project-config/shared/service-definitions.schemas';
|
|
2
3
|
export { buildApplicationRuntimeEndpoints, buildPlatformRuntimeEndpoints, parseRuntimeEndpointsRecord, PlatformApplicationType, PlatformRuntimeEndpointKey, serializeRuntimeEndpointsRecord, } from '@wildo-ai/platform-core-shared';
|
|
3
4
|
export type { ApplicationRuntimeEndpointsInput, PlatformRuntimeEndpointsInput, RuntimeEndpointUrls, } from '@wildo-ai/platform-core-shared';
|
|
4
5
|
export declare function buildLocalhostPlatformRuntimeEndpoints(host?: string): Record<string, RuntimeEndpointUrls>;
|
|
@@ -10,6 +11,37 @@ export interface LocalhostApplicationRuntimeEndpointsInput {
|
|
|
10
11
|
host?: string | undefined;
|
|
11
12
|
}
|
|
12
13
|
export declare function buildLocalhostApplicationRuntimeEndpoints(input: LocalhostApplicationRuntimeEndpointsInput): Record<string, RuntimeEndpointUrls>;
|
|
14
|
+
/**
|
|
15
|
+
* Which backend is an application's MAIN backend API — the one its browser-facing
|
|
16
|
+
* surfaces call. The `backendApi` service key when declared, else the first backend
|
|
17
|
+
* row. One rule, used by the CLI's endpoint and ingress derivation and by the public
|
|
18
|
+
* website's local origins, so the three cannot name different backends.
|
|
19
|
+
*/
|
|
20
|
+
export declare function selectPrimaryBackendService<TService extends {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
}>(backendServices: readonly TService[]): TService | undefined;
|
|
23
|
+
/** The origins a locally-running application serves its app and its main API on. */
|
|
24
|
+
export interface LocalhostApplicationOrigins {
|
|
25
|
+
/** The `SAAS_APP` frontend, when one declares a port. */
|
|
26
|
+
readonly app?: string | undefined;
|
|
27
|
+
/** The main backend API ({@link selectPrimaryBackendService}), when it declares a port. */
|
|
28
|
+
readonly api?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The local-development origins of an application's product and API, derived from
|
|
32
|
+
* the `defaultPort` each service already declares in `wildo.saas.config.ts` — the
|
|
33
|
+
* same ports, host and plain-http scheme {@link buildLocalhostApplicationRuntimeEndpoints}
|
|
34
|
+
* advertises, so a local surface that links into the product reaches the process
|
|
35
|
+
* `wildo local dev` actually started.
|
|
36
|
+
*
|
|
37
|
+
* It exists for the public website, which is a separate origin from the product:
|
|
38
|
+
* its CTAs and capture forms must reach `http://localhost:<appPort>` and
|
|
39
|
+
* `http://localhost:<backendPort>` under `astro dev`. Before this, the API origin
|
|
40
|
+
* was a port hardcoded into each site and the app origin had no local form at all,
|
|
41
|
+
* so every "Start free" in local development pointed at a production-shaped host
|
|
42
|
+
* that resolves to nothing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveLocalhostApplicationOrigins(services: Readonly<Record<string, Pick<AppServiceDefinition, 'defaultPort' | 'frontendType'>>>, host?: string): LocalhostApplicationOrigins;
|
|
13
45
|
export declare function buildK8sPlatformRuntimeEndpoints(input: {
|
|
14
46
|
publicDomain: string;
|
|
15
47
|
namespace: string;
|
|
@@ -62,8 +94,9 @@ export interface K8sApplicationIngressRoutesInput {
|
|
|
62
94
|
* the routes match the `runtime.endPoints.publicUrl` that
|
|
63
95
|
* {@link buildK8sApplicationRuntimeEndpoints} produces (both key public hosts on
|
|
64
96
|
* `serviceKey`). Coherence is a property of feeding both the SAME `serviceKey`s,
|
|
65
|
-
* not automatic — see the divergence guards in the domain plan.
|
|
66
|
-
*
|
|
97
|
+
* not automatic — see the divergence guards in the domain plan. Health, webhooks,
|
|
98
|
+
* the OAuth provider and MCP are routes on the backend's own port, so they reach
|
|
99
|
+
* the public host through the backend API route like any other path (#1783).
|
|
67
100
|
*/
|
|
68
101
|
export declare function buildK8sApplicationIngressRoutes(input: K8sApplicationIngressRoutesInput): K8sIngressRoute[];
|
|
69
102
|
/**
|
|
@@ -89,7 +122,7 @@ export interface RemoteApplicationRuntimeEndpointsCommon {
|
|
|
89
122
|
technicalDocumentationServiceKey?: string | undefined;
|
|
90
123
|
/** Backend API `config.services.<key>` (host resolution key). */
|
|
91
124
|
mainBackendApiServiceKey?: string | undefined;
|
|
92
|
-
/** Backend API container port
|
|
125
|
+
/** Backend API container port — the one port the backend process binds (its internal URL). */
|
|
93
126
|
mainBackendApiPort?: number | undefined;
|
|
94
127
|
}
|
|
95
128
|
export interface K8sApplicationRuntimeEndpointsInput extends RemoteApplicationRuntimeEndpointsCommon {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-topology.contracts.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"runtime-topology.contracts.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/runtime-topology.contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,gCAAgC,CAAC;AASxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAEjG,OAAO,EACL,gCAAgC,EAChC,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,gCAAgC,CAAC;AAExC,YAAY,EACV,gCAAgC,E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SAAS,CAAC;IACtD,iEAAiE;IACjE,wBAAwB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,8FAA8F;IAC9F,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,mCAAoC,SAAQ,uCAAuC;IAClG,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uCAAwC,SAAQ,uCAAuC;IACtG;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AA+DD;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,mCAAmC,GACzC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAIrC;AAED;;;;;;;GAOG;AACH,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,uCAAuC,GAC7C,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAErC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildApplicationRuntimeEndpoints, buildPlatformRuntimeEndpoints, } from '@wildo-ai/platform-core-shared';
|
|
2
2
|
import { buildK8sInternalUrl, buildK8sPublicUrl, buildServicePublicHost, buildServicePublicUrl, } from '../project-config/shared/k8s-utils.js';
|
|
3
3
|
import { PLATFORM_DEFAULT_PORTS } from '../project-config/shared/infrastructure-defaults.schemas.js';
|
|
4
|
+
import { AppFrontendType } from '@wildo-ai/saas-models/public-runtime';
|
|
4
5
|
export { buildApplicationRuntimeEndpoints, buildPlatformRuntimeEndpoints, parseRuntimeEndpointsRecord, PlatformApplicationType, PlatformRuntimeEndpointKey, serializeRuntimeEndpointsRecord, } from '@wildo-ai/platform-core-shared';
|
|
5
6
|
export function buildLocalhostPlatformRuntimeEndpoints(host = 'localhost') {
|
|
6
7
|
const buildUrl = (port) => ({
|
|
@@ -46,14 +47,40 @@ export function buildLocalhostApplicationRuntimeEndpoints(input) {
|
|
|
46
47
|
...(input.mainBackendApiPort
|
|
47
48
|
? {
|
|
48
49
|
mainBackendApi: buildUrl(input.mainBackendApiPort),
|
|
49
|
-
healthCheckApi: buildUrl(input.mainBackendApiPort - 1),
|
|
50
|
-
mainWebhookApi: buildUrl(input.mainBackendApiPort - 2),
|
|
51
|
-
oauth2ProviderApi: buildUrl(input.mainBackendApiPort - 3),
|
|
52
|
-
mcpApi: buildUrl(input.mainBackendApiPort - 4),
|
|
53
50
|
}
|
|
54
51
|
: {}),
|
|
55
52
|
});
|
|
56
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Which backend is an application's MAIN backend API — the one its browser-facing
|
|
56
|
+
* surfaces call. The `backendApi` service key when declared, else the first backend
|
|
57
|
+
* row. One rule, used by the CLI's endpoint and ingress derivation and by the public
|
|
58
|
+
* website's local origins, so the three cannot name different backends.
|
|
59
|
+
*/
|
|
60
|
+
export function selectPrimaryBackendService(backendServices) {
|
|
61
|
+
return backendServices.find((backend) => backend.key === 'backendApi') ?? backendServices[0];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The local-development origins of an application's product and API, derived from
|
|
65
|
+
* the `defaultPort` each service already declares in `wildo.saas.config.ts` — the
|
|
66
|
+
* same ports, host and plain-http scheme {@link buildLocalhostApplicationRuntimeEndpoints}
|
|
67
|
+
* advertises, so a local surface that links into the product reaches the process
|
|
68
|
+
* `wildo local dev` actually started.
|
|
69
|
+
*
|
|
70
|
+
* It exists for the public website, which is a separate origin from the product:
|
|
71
|
+
* its CTAs and capture forms must reach `http://localhost:<appPort>` and
|
|
72
|
+
* `http://localhost:<backendPort>` under `astro dev`. Before this, the API origin
|
|
73
|
+
* was a port hardcoded into each site and the app origin had no local form at all,
|
|
74
|
+
* so every "Start free" in local development pointed at a production-shaped host
|
|
75
|
+
* that resolves to nothing.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveLocalhostApplicationOrigins(services, host = 'localhost') {
|
|
78
|
+
const rows = Object.entries(services).map(([key, service]) => ({ key, ...service }));
|
|
79
|
+
const primaryBackend = selectPrimaryBackendService(rows.filter((row) => row.frontendType === undefined));
|
|
80
|
+
const saasApp = rows.find((row) => row.frontendType === AppFrontendType.SAAS_APP);
|
|
81
|
+
const originOf = (port) => (port === undefined ? undefined : `http://${host}:${port}`);
|
|
82
|
+
return { app: originOf(saasApp?.defaultPort), api: originOf(primaryBackend?.defaultPort) };
|
|
83
|
+
}
|
|
57
84
|
export function buildK8sPlatformRuntimeEndpoints(input) {
|
|
58
85
|
return buildPlatformRuntimeEndpoints({
|
|
59
86
|
appsManager: {
|
|
@@ -77,8 +104,9 @@ export function buildK8sPlatformRuntimeEndpoints(input) {
|
|
|
77
104
|
* the routes match the `runtime.endPoints.publicUrl` that
|
|
78
105
|
* {@link buildK8sApplicationRuntimeEndpoints} produces (both key public hosts on
|
|
79
106
|
* `serviceKey`). Coherence is a property of feeding both the SAME `serviceKey`s,
|
|
80
|
-
* not automatic — see the divergence guards in the domain plan.
|
|
81
|
-
*
|
|
107
|
+
* not automatic — see the divergence guards in the domain plan. Health, webhooks,
|
|
108
|
+
* the OAuth provider and MCP are routes on the backend's own port, so they reach
|
|
109
|
+
* the public host through the backend API route like any other path (#1783).
|
|
82
110
|
*/
|
|
83
111
|
export function buildK8sApplicationIngressRoutes(input) {
|
|
84
112
|
const host = (serviceKey) => buildServicePublicHost({ serviceKey, serviceHosts: input.serviceHosts, publicDomain: input.publicDomain });
|
|
@@ -121,8 +149,8 @@ export function buildK8sApplicationIngressRoutes(input) {
|
|
|
121
149
|
* from {@link buildServicePublicUrl} (so ingress hosts, `runtime.endPoints.publicUrl`,
|
|
122
150
|
* and CORS all agree — greenfield, no multi-tenant fan-out). INTERNAL URLs are
|
|
123
151
|
* supplied by `internalUrlFor` (cluster-DNS for k8s, container DNS for compose).
|
|
124
|
-
* The
|
|
125
|
-
*
|
|
152
|
+
* The backend declares ONE endpoint: health, webhooks, the OAuth provider and MCP
|
|
153
|
+
* are routes on its port, not sibling listeners (#1783).
|
|
126
154
|
*/
|
|
127
155
|
function buildRemoteApplicationRuntimeEndpoints(input, internalUrlFor) {
|
|
128
156
|
const { publicDomain, serviceHosts } = input;
|
|
@@ -162,11 +190,6 @@ function buildRemoteApplicationRuntimeEndpoints(input, internalUrlFor) {
|
|
|
162
190
|
publicUrl: pub(mainBackendApiServiceKey),
|
|
163
191
|
internalUrl: internal(mainBackendApiPort),
|
|
164
192
|
},
|
|
165
|
-
// Internal-only APIs — never publicly routed (publicUrl === internal).
|
|
166
|
-
healthCheckApi: { publicUrl: internal(mainBackendApiPort - 1), internalUrl: internal(mainBackendApiPort - 1) },
|
|
167
|
-
mainWebhookApi: { publicUrl: internal(mainBackendApiPort - 2), internalUrl: internal(mainBackendApiPort - 2) },
|
|
168
|
-
oauth2ProviderApi: { publicUrl: internal(mainBackendApiPort - 3), internalUrl: internal(mainBackendApiPort - 3) },
|
|
169
|
-
mcpApi: { publicUrl: internal(mainBackendApiPort - 4), internalUrl: internal(mainBackendApiPort - 4) },
|
|
170
193
|
}
|
|
171
194
|
: {}),
|
|
172
195
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-topology.contracts.js","sourceRoot":"","sources":["../../../../src/bootstrap/runtime-topology.contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,6BAA6B,GAE9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAElG,OAAO,EACL,gCAAgC,EAChC,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,gCAAgC,CAAC;AAQxC,MAAM,UAAU,sCAAsC,CACpD,OAAe,WAAW;IAE1B,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAuB,EA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AAG,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE;gBAC9G,iBAAiB,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE;gBACjH,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE;aACvG;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CACjD,KAA0C;IAE1C,OAAO,sCAAsC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAC5D,mBAAmB,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CACjE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uCAAuC,CACrD,KAA8C;IAE9C,OAAO,sCAAsC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,KAAK,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import {\n buildApplicationRuntimeEndpoints,\n buildPlatformRuntimeEndpoints,\n type RuntimeEndpointUrls,\n} from '@wildo-ai/platform-core-shared';\nimport {\n buildK8sInternalUrl,\n buildK8sPublicUrl,\n buildServicePublicHost,\n buildServicePublicUrl,\n} from '../project-config/shared/k8s-utils';\nimport { PLATFORM_DEFAULT_PORTS } from '../project-config/shared/infrastructure-defaults.schemas';\n\nexport {\n buildApplicationRuntimeEndpoints,\n buildPlatformRuntimeEndpoints,\n parseRuntimeEndpointsRecord,\n PlatformApplicationType,\n PlatformRuntimeEndpointKey,\n serializeRuntimeEndpointsRecord,\n} from '@wildo-ai/platform-core-shared';\n\nexport type {\n ApplicationRuntimeEndpointsInput,\n PlatformRuntimeEndpointsInput,\n RuntimeEndpointUrls,\n} from '@wildo-ai/platform-core-shared';\n\nexport function buildLocalhostPlatformRuntimeEndpoints(\n host: string = 'localhost',\n): Record<string, RuntimeEndpointUrls> {\n const buildUrl = (port: number): RuntimeEndpointUrls => ({\n publicUrl: `http://${host}:${port}`,\n internalUrl: `http://${host}:${port}`,\n });\n\n return buildPlatformRuntimeEndpoints({\n appsManager: buildUrl(PLATFORM_DEFAULT_PORTS.APPS_MANAGER),\n crontabsBatchesManager: buildUrl(PLATFORM_DEFAULT_PORTS.CRONTABS_BATCHES_MANAGER),\n moduleRegistry: buildUrl(PLATFORM_DEFAULT_PORTS.MODULE_REGISTRY),\n });\n}\n\nexport interface LocalhostApplicationRuntimeEndpointsInput {\n mainBackendApiPort?: number | undefined;\n frontendApplicationPorts?: Record<string, number> | undefined;\n websitePort?: number | undefined;\n technicalDocumentationPort?: number | undefined;\n host?: string | undefined;\n}\n\nexport function buildLocalhostApplicationRuntimeEndpoints(\n input: LocalhostApplicationRuntimeEndpointsInput,\n): Record<string, RuntimeEndpointUrls> {\n const host = input.host ?? 'localhost';\n /**\n * Local endpoints are plain http, publicly and internally, and there is no knob.\n *\n * A configurable local scheme existed until 2026-08-14 and was removed: it applied ONE scheme to\n * EVERY endpoint's own port, which is only correct when a single ingress fronts them all. Local\n * Docker Compose has none, so declaring https made `main_backend_api.publicUrl` name a port that\n * held no certificate, and every browser session died on its WebSocket readiness poll.\n *\n * Remote is unaffected and always was: `buildServicePublicUrl` hardcodes `https://` because TLS\n * terminates at Traefik/nginx in front of one origin, where a single scheme IS true for every\n * endpoint. That is the only place the question has a well-defined answer, and it never consulted\n * this input.\n */\n const buildUrl = (port: number): RuntimeEndpointUrls => ({\n publicUrl: `http://${host}:${port}`,\n internalUrl: `http://${host}:${port}`,\n });\n\n return buildApplicationRuntimeEndpoints({\n frontendApplications: input.frontendApplicationPorts\n ? Object.fromEntries(\n Object.entries(input.frontendApplicationPorts).map(([frontendServiceName, port]) => [\n frontendServiceName,\n buildUrl(port),\n ]),\n )\n : undefined,\n ...(input.websitePort ? { website: buildUrl(input.websitePort) } : {}),\n ...(input.technicalDocumentationPort\n ? { technicalDocumentation: buildUrl(input.technicalDocumentationPort) }\n : {}),\n ...(input.mainBackendApiPort\n ? {\n mainBackendApi: buildUrl(input.mainBackendApiPort),\n healthCheckApi: buildUrl(input.mainBackendApiPort - 1),\n mainWebhookApi: buildUrl(input.mainBackendApiPort - 2),\n oauth2ProviderApi: buildUrl(input.mainBackendApiPort - 3),\n mcpApi: buildUrl(input.mainBackendApiPort - 4),\n }\n : {}),\n });\n}\n\nexport function buildK8sPlatformRuntimeEndpoints(input: {\n publicDomain: string;\n namespace: string;\n}): Record<string, RuntimeEndpointUrls> {\n return buildPlatformRuntimeEndpoints({\n appsManager: {\n publicUrl: buildK8sPublicUrl('platform-apps-manager', input.publicDomain),\n internalUrl: buildK8sInternalUrl('platform-apps-manager', PLATFORM_DEFAULT_PORTS.APPS_MANAGER, input.namespace),\n },\n crontabsBatchesManager: {\n publicUrl: buildK8sPublicUrl('platform-crontabs-batches-manager', input.publicDomain),\n internalUrl: buildK8sInternalUrl('platform-crontabs-batches-manager', PLATFORM_DEFAULT_PORTS.CRONTABS_BATCHES_MANAGER, input.namespace),\n },\n moduleRegistry: {\n publicUrl: buildK8sPublicUrl('platform-module-registry', input.publicDomain),\n internalUrl: buildK8sInternalUrl('platform-module-registry', PLATFORM_DEFAULT_PORTS.MODULE_REGISTRY, input.namespace),\n },\n });\n}\n\nexport interface K8sIngressRoute {\n /** Public hostname Traefik/ingress routes on (from the serviceHosts resolver). */\n host: string;\n /**\n * Per-service k8s Service NAME this host routes to. In the per-service deploy\n * model each service is its OWN Deployment+Service, so the route target is the\n * service's `serviceName` (e.g. `wonder-todos-backend-api`, `wonder-todos-app`)\n * — NOT one shared app Service. This is the value stamped into the ingress\n * rule's `backend.service.name`.\n */\n serviceName: string;\n /** Port on that per-service Service to route this host to. */\n port: number;\n}\n\n/**\n * One public frontend in the app's service topology. `serviceName` and\n * `serviceKey` are DECOUPLED on purpose:\n * - `serviceName` — the `runtime.endPoints` map key (the consumer contract:\n * `lookupFrontendPublicUrl` / X-Frontend-Service-Name key by serviceName).\n * - `serviceKey` — the `config.services.<key>`, which is the serviceHosts\n * authoring key. The public HOST resolves from THIS, never from serviceName.\n * Conflating them silently ignores authored `serviceHosts` (the serviceName\n * `wonder-todos-app` misses the authored `app` entry).\n */\nexport interface ApplicationPublicFrontend {\n serviceName: string;\n serviceKey: string;\n port: number;\n}\n\nexport interface K8sApplicationIngressRoutesInput {\n publicDomain: string;\n serviceHosts: Record<string, string> | undefined;\n /** Public frontends. Host resolves from `serviceKey` (config key); route target is the frontend's own `serviceName`. */\n frontends: ReadonlyArray<ApplicationPublicFrontend>;\n /** Backend API `config.services.<key>` (host resolution key). */\n mainBackendApiServiceKey?: string | undefined;\n /** Backend API per-service k8s Service name (the ingress route target). */\n mainBackendApiServiceName?: string | undefined;\n /** Backend API Service port. */\n mainBackendApiPort?: number | undefined;\n}\n\n/**\n * Ingress routes for the app's PUBLIC services (every frontend + the main\n * backend API), serviceHosts-driven. Every host resolves from the service's\n * `config.services.<key>` (`serviceKey`) — so GIVEN THE SAME frontends/keys,\n * the routes match the `runtime.endPoints.publicUrl` that\n * {@link buildK8sApplicationRuntimeEndpoints} produces (both key public hosts on\n * `serviceKey`). Coherence is a property of feeding both the SAME `serviceKey`s,\n * not automatic — see the divergence guards in the domain plan. The internal-only\n * APIs (health/webhook/oauth/mcp) are deliberately NOT routed publicly.\n */\nexport function buildK8sApplicationIngressRoutes(\n input: K8sApplicationIngressRoutesInput,\n): K8sIngressRoute[] {\n const host = (serviceKey: string): string =>\n buildServicePublicHost({ serviceKey, serviceHosts: input.serviceHosts, publicDomain: input.publicDomain });\n\n const entries: Array<{ serviceKey: string; serviceName: string; host: string; port: number }> =\n input.frontends.map((f) => ({\n serviceKey: f.serviceKey,\n serviceName: f.serviceName,\n host: host(f.serviceKey),\n port: f.port,\n }));\n if (\n input.mainBackendApiServiceKey !== undefined &&\n input.mainBackendApiServiceName !== undefined &&\n input.mainBackendApiPort !== undefined\n ) {\n entries.push({\n serviceKey: input.mainBackendApiServiceKey,\n serviceName: input.mainBackendApiServiceName,\n host: host(input.mainBackendApiServiceKey),\n port: input.mainBackendApiPort,\n });\n }\n\n // Fail-closed host-uniqueness guard: each public host routes entirely to ONE\n // service:port (no path-based sharing), so two distinct services resolving to\n // the same host — e.g. both authored to the apex (`''`), or an unauthored key\n // that collides with an authored subdomain — is an ambiguous, silently-broken\n // ingress. Reject it at build time with the colliding keys named, rather than\n // emitting a manifest whose routing is undefined.\n const claimedBy = new Map<string, string>();\n for (const entry of entries) {\n const existing = claimedBy.get(entry.host);\n if (existing !== undefined && existing !== entry.serviceKey) {\n throw new Error(\n `serviceHosts collision: services '${existing}' and '${entry.serviceKey}' both resolve to public host '${entry.host}'. ` +\n `Each service needs a distinct 'serviceHosts' subdomain (only one service may map to the apex '').`,\n );\n }\n claimedBy.set(entry.host, entry.serviceKey);\n }\n\n return entries.map(({ host: h, serviceName, port }) => ({ host: h, serviceName, port }));\n}\n\n/**\n * Fields shared by every REMOTE runtime-endpoints builder (k8s + compose). The\n * PUBLIC side (serviceHosts resolution) is runtime-agnostic; only the INTERNAL\n * URL form differs, injected via the `internalUrlFor` callback of the core\n * builder ({@link buildRemoteApplicationRuntimeEndpoints}).\n */\nexport interface RemoteApplicationRuntimeEndpointsCommon {\n /** Operator's public domain (`WildoInfraEnvConfig.publicDomain`). */\n publicDomain: string;\n /** Authored per-service subdomain map (`wildo.infra.<env>.config.ts`). */\n serviceHosts: Record<string, string> | undefined;\n /**\n * Public frontends. The `runtime.endPoints` map is keyed by each frontend's\n * `serviceName` (consumer contract); the public HOST resolves from its\n * `serviceKey` (config key / serviceHosts key). See {@link ApplicationPublicFrontend}.\n */\n frontends: ReadonlyArray<ApplicationPublicFrontend>;\n /** `serviceKey` of the STATIC_WEBSITE frontend (feeds the fixed website endpoint). */\n websiteServiceKey?: string | undefined;\n /** `serviceKey` of the TECH_DOC frontend (feeds the fixed technical-documentation endpoint). */\n technicalDocumentationServiceKey?: string | undefined;\n /** Backend API `config.services.<key>` (host resolution key). */\n mainBackendApiServiceKey?: string | undefined;\n /** Backend API container port (internal URL + the -1..-4 sibling API ports). */\n mainBackendApiPort?: number | undefined;\n}\n\nexport interface K8sApplicationRuntimeEndpointsInput extends RemoteApplicationRuntimeEndpointsCommon {\n /** K8s namespace for cluster-internal service DNS. */\n namespace: string;\n /**\n * K8s Service name for cluster-internal URLs. Single Service per app (all\n * frontends + APIs ride it on different ports), so this is the app's own\n * service name (= its slug).\n */\n appServiceName: string;\n}\n\nexport interface ComposeApplicationRuntimeEndpointsInput extends RemoteApplicationRuntimeEndpointsCommon {\n /**\n * Compose service (container) name for internal URLs. Single container per\n * app serving all frontends + APIs on their ports, reachable by other\n * containers on the shared network as `http://<appServiceName>:<port>`.\n */\n appServiceName: string;\n}\n\n/**\n * Core REMOTE application runtime-endpoints assembly, shared by the k8s and\n * compose builders so their public-URL semantics never drift. PUBLIC URLs come\n * from {@link buildServicePublicUrl} (so ingress hosts, `runtime.endPoints.publicUrl`,\n * and CORS all agree — greenfield, no multi-tenant fan-out). INTERNAL URLs are\n * supplied by `internalUrlFor` (cluster-DNS for k8s, container DNS for compose).\n * The health/webhook/oauth/mcp APIs are internal only — their `publicUrl` is the\n * internal URL (never publicly routed).\n */\nfunction buildRemoteApplicationRuntimeEndpoints(\n input: RemoteApplicationRuntimeEndpointsCommon,\n internalUrlFor: (port: number) => string,\n): Record<string, RuntimeEndpointUrls> {\n const { publicDomain, serviceHosts } = input;\n const pub = (serviceKey: string): string =>\n buildServicePublicUrl({ serviceKey, serviceHosts, publicDomain });\n const internal = internalUrlFor;\n\n // Map key = serviceName (consumer contract: lookupFrontendPublicUrl keys by\n // serviceName); public host = serviceKey (serviceHosts key). Decoupled.\n const frontendApplications = input.frontends.length > 0\n ? Object.fromEntries(\n input.frontends.map((f) => [\n f.serviceName,\n { publicUrl: pub(f.serviceKey), internalUrl: internal(f.port) },\n ]),\n )\n : undefined;\n\n const websiteFrontend = input.websiteServiceKey\n ? input.frontends.find((f) => f.serviceKey === input.websiteServiceKey)\n : undefined;\n const docsFrontend = input.technicalDocumentationServiceKey\n ? input.frontends.find((f) => f.serviceKey === input.technicalDocumentationServiceKey)\n : undefined;\n const { mainBackendApiServiceKey, mainBackendApiPort } = input;\n\n return buildApplicationRuntimeEndpoints({\n frontendApplications,\n ...(websiteFrontend\n ? { website: { publicUrl: pub(websiteFrontend.serviceKey), internalUrl: internal(websiteFrontend.port) } }\n : {}),\n ...(docsFrontend\n ? {\n technicalDocumentation: {\n publicUrl: pub(docsFrontend.serviceKey),\n internalUrl: internal(docsFrontend.port),\n },\n }\n : {}),\n ...(mainBackendApiServiceKey !== undefined && mainBackendApiPort !== undefined\n ? {\n mainBackendApi: {\n publicUrl: pub(mainBackendApiServiceKey),\n internalUrl: internal(mainBackendApiPort),\n },\n // Internal-only APIs — never publicly routed (publicUrl === internal).\n healthCheckApi: { publicUrl: internal(mainBackendApiPort - 1), internalUrl: internal(mainBackendApiPort - 1) },\n mainWebhookApi: { publicUrl: internal(mainBackendApiPort - 2), internalUrl: internal(mainBackendApiPort - 2) },\n oauth2ProviderApi: { publicUrl: internal(mainBackendApiPort - 3), internalUrl: internal(mainBackendApiPort - 3) },\n mcpApi: { publicUrl: internal(mainBackendApiPort - 4), internalUrl: internal(mainBackendApiPort - 4) },\n }\n : {}),\n });\n}\n\n/**\n * Build K8s application runtime endpoints — the self-hosted, single-app,\n * `serviceHosts`-driven counterpart to {@link buildLocalhostApplicationRuntimeEndpoints}.\n * INTERNAL URLs are the app's own cluster-DNS Service on each port.\n */\nexport function buildK8sApplicationRuntimeEndpoints(\n input: K8sApplicationRuntimeEndpointsInput,\n): Record<string, RuntimeEndpointUrls> {\n return buildRemoteApplicationRuntimeEndpoints(input, (port) =>\n buildK8sInternalUrl(input.appServiceName, port, input.namespace),\n );\n}\n\n/**\n * Build Docker-Compose application runtime endpoints — the compose counterpart\n * of {@link buildK8sApplicationRuntimeEndpoints}. PUBLIC URLs are IDENTICAL\n * (serviceHosts-driven, so the Traefik ingress routes and `runtime.endPoints`\n * agree — the CORS invariant holds for compose too). INTERNAL URLs are the app\n * container's own name on the shared compose network (`http://<appServiceName>:<port>`),\n * NOT localhost — the remote compose stack must not advertise localhost topology.\n */\nexport function buildComposeApplicationRuntimeEndpoints(\n input: ComposeApplicationRuntimeEndpointsInput,\n): Record<string, RuntimeEndpointUrls> {\n return buildRemoteApplicationRuntimeEndpoints(input, (port) => `http://${input.appServiceName}:${port}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime-topology.contracts.js","sourceRoot":"","sources":["../../../src/bootstrap/runtime-topology.contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,6BAA6B,GAE9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGvE,OAAO,EACL,gCAAgC,EAChC,6BAA6B,EAC7B,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,gCAAgC,CAAC;AAQxC,MAAM,UAAU,sCAAsC,CACpD,OAAe,WAAW;IAE1B,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAuB,EAAE,CAAC,CAAC;QACvD,SAAS,EAAE,UAAU,IAAI,IAAI,IAAI,EAAE;QACnC,WAAW,EAAE,UAAU,IAAI,IAAI,IAAI,EAAE;KACtC,CAAC,CAAC;IAEH,OAAO,6BAA6B,CAAC;QAC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CAAC;QACP,GAAG,CAAC,YAAY;YACd,CAAC,CAAC;gBACE,sBAAsB,EAAE;oBACtB,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC;oBACvC,WAAW,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC;iBACzC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,wBAAwB,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS;YAC5E,CAAC,CAAC;gBACE,cAAc,EAAE;oBACd,SAAS,EAAE,GAAG,CAAC,wBAAwB,CAAC;oBACxC,WAAW,EAAE,QAAQ,CAAC,kBAAkB,CAAC;iBAC1C;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CACjD,KAA0C;IAE1C,OAAO,sCAAsC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAC5D,mBAAmB,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,CACjE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uCAAuC,CACrD,KAA8C;IAE9C,OAAO,sCAAsC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,KAAK,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import {\n buildApplicationRuntimeEndpoints,\n buildPlatformRuntimeEndpoints,\n type RuntimeEndpointUrls,\n} from '@wildo-ai/platform-core-shared';\nimport {\n buildK8sInternalUrl,\n buildK8sPublicUrl,\n buildServicePublicHost,\n buildServicePublicUrl,\n} from '../project-config/shared/k8s-utils';\nimport { PLATFORM_DEFAULT_PORTS } from '../project-config/shared/infrastructure-defaults.schemas';\nimport { AppFrontendType } from '@wildo-ai/saas-models/public-runtime';\nimport type { AppServiceDefinition } from '../project-config/shared/service-definitions.schemas';\n\nexport {\n buildApplicationRuntimeEndpoints,\n buildPlatformRuntimeEndpoints,\n parseRuntimeEndpointsRecord,\n PlatformApplicationType,\n PlatformRuntimeEndpointKey,\n serializeRuntimeEndpointsRecord,\n} from '@wildo-ai/platform-core-shared';\n\nexport type {\n ApplicationRuntimeEndpointsInput,\n PlatformRuntimeEndpointsInput,\n RuntimeEndpointUrls,\n} from '@wildo-ai/platform-core-shared';\n\nexport function buildLocalhostPlatformRuntimeEndpoints(\n host: string = 'localhost',\n): Record<string, RuntimeEndpointUrls> {\n const buildUrl = (port: number): RuntimeEndpointUrls => ({\n publicUrl: `http://${host}:${port}`,\n internalUrl: `http://${host}:${port}`,\n });\n\n return buildPlatformRuntimeEndpoints({\n appsManager: buildUrl(PLATFORM_DEFAULT_PORTS.APPS_MANAGER),\n crontabsBatchesManager: buildUrl(PLATFORM_DEFAULT_PORTS.CRONTABS_BATCHES_MANAGER),\n moduleRegistry: buildUrl(PLATFORM_DEFAULT_PORTS.MODULE_REGISTRY),\n });\n}\n\nexport interface LocalhostApplicationRuntimeEndpointsInput {\n mainBackendApiPort?: number | undefined;\n frontendApplicationPorts?: Record<string, number> | undefined;\n websitePort?: number | undefined;\n technicalDocumentationPort?: number | undefined;\n host?: string | undefined;\n}\n\nexport function buildLocalhostApplicationRuntimeEndpoints(\n input: LocalhostApplicationRuntimeEndpointsInput,\n): Record<string, RuntimeEndpointUrls> {\n const host = input.host ?? 'localhost';\n /**\n * Local endpoints are plain http, publicly and internally, and there is no knob.\n *\n * A configurable local scheme existed until 2026-08-14 and was removed: it applied ONE scheme to\n * EVERY endpoint's own port, which is only correct when a single ingress fronts them all. Local\n * Docker Compose has none, so declaring https made `main_backend_api.publicUrl` name a port that\n * held no certificate, and every browser session died on its WebSocket readiness poll.\n *\n * Remote is unaffected and always was: `buildServicePublicUrl` hardcodes `https://` because TLS\n * terminates at Traefik/nginx in front of one origin, where a single scheme IS true for every\n * endpoint. That is the only place the question has a well-defined answer, and it never consulted\n * this input.\n */\n const buildUrl = (port: number): RuntimeEndpointUrls => ({\n publicUrl: `http://${host}:${port}`,\n internalUrl: `http://${host}:${port}`,\n });\n\n return buildApplicationRuntimeEndpoints({\n frontendApplications: input.frontendApplicationPorts\n ? Object.fromEntries(\n Object.entries(input.frontendApplicationPorts).map(([frontendServiceName, port]) => [\n frontendServiceName,\n buildUrl(port),\n ]),\n )\n : undefined,\n ...(input.websitePort ? { website: buildUrl(input.websitePort) } : {}),\n ...(input.technicalDocumentationPort\n ? { technicalDocumentation: buildUrl(input.technicalDocumentationPort) }\n : {}),\n ...(input.mainBackendApiPort\n ? {\n mainBackendApi: buildUrl(input.mainBackendApiPort),\n }\n : {}),\n });\n}\n\n/**\n * Which backend is an application's MAIN backend API — the one its browser-facing\n * surfaces call. The `backendApi` service key when declared, else the first backend\n * row. One rule, used by the CLI's endpoint and ingress derivation and by the public\n * website's local origins, so the three cannot name different backends.\n */\nexport function selectPrimaryBackendService<TService extends { readonly key: string }>(\n backendServices: readonly TService[],\n): TService | undefined {\n return backendServices.find((backend) => backend.key === 'backendApi') ?? backendServices[0];\n}\n\n/** The origins a locally-running application serves its app and its main API on. */\nexport interface LocalhostApplicationOrigins {\n /** The `SAAS_APP` frontend, when one declares a port. */\n readonly app?: string | undefined;\n /** The main backend API ({@link selectPrimaryBackendService}), when it declares a port. */\n readonly api?: string | undefined;\n}\n\n/**\n * The local-development origins of an application's product and API, derived from\n * the `defaultPort` each service already declares in `wildo.saas.config.ts` — the\n * same ports, host and plain-http scheme {@link buildLocalhostApplicationRuntimeEndpoints}\n * advertises, so a local surface that links into the product reaches the process\n * `wildo local dev` actually started.\n *\n * It exists for the public website, which is a separate origin from the product:\n * its CTAs and capture forms must reach `http://localhost:<appPort>` and\n * `http://localhost:<backendPort>` under `astro dev`. Before this, the API origin\n * was a port hardcoded into each site and the app origin had no local form at all,\n * so every \"Start free\" in local development pointed at a production-shaped host\n * that resolves to nothing.\n */\nexport function resolveLocalhostApplicationOrigins(\n services: Readonly<Record<string, Pick<AppServiceDefinition, 'defaultPort' | 'frontendType'>>>,\n host = 'localhost',\n): LocalhostApplicationOrigins {\n const rows = Object.entries(services).map(([key, service]) => ({ key, ...service }));\n const primaryBackend = selectPrimaryBackendService(rows.filter((row) => row.frontendType === undefined));\n const saasApp = rows.find((row) => row.frontendType === AppFrontendType.SAAS_APP);\n const originOf = (port: number | undefined): string | undefined => (port === undefined ? undefined : `http://${host}:${port}`);\n return { app: originOf(saasApp?.defaultPort), api: originOf(primaryBackend?.defaultPort) };\n}\n\nexport function buildK8sPlatformRuntimeEndpoints(input: {\n publicDomain: string;\n namespace: string;\n}): Record<string, RuntimeEndpointUrls> {\n return buildPlatformRuntimeEndpoints({\n appsManager: {\n publicUrl: buildK8sPublicUrl('platform-apps-manager', input.publicDomain),\n internalUrl: buildK8sInternalUrl('platform-apps-manager', PLATFORM_DEFAULT_PORTS.APPS_MANAGER, input.namespace),\n },\n crontabsBatchesManager: {\n publicUrl: buildK8sPublicUrl('platform-crontabs-batches-manager', input.publicDomain),\n internalUrl: buildK8sInternalUrl('platform-crontabs-batches-manager', PLATFORM_DEFAULT_PORTS.CRONTABS_BATCHES_MANAGER, input.namespace),\n },\n moduleRegistry: {\n publicUrl: buildK8sPublicUrl('platform-module-registry', input.publicDomain),\n internalUrl: buildK8sInternalUrl('platform-module-registry', PLATFORM_DEFAULT_PORTS.MODULE_REGISTRY, input.namespace),\n },\n });\n}\n\nexport interface K8sIngressRoute {\n /** Public hostname Traefik/ingress routes on (from the serviceHosts resolver). */\n host: string;\n /**\n * Per-service k8s Service NAME this host routes to. In the per-service deploy\n * model each service is its OWN Deployment+Service, so the route target is the\n * service's `serviceName` (e.g. `wonder-todos-backend-api`, `wonder-todos-app`)\n * — NOT one shared app Service. This is the value stamped into the ingress\n * rule's `backend.service.name`.\n */\n serviceName: string;\n /** Port on that per-service Service to route this host to. */\n port: number;\n}\n\n/**\n * One public frontend in the app's service topology. `serviceName` and\n * `serviceKey` are DECOUPLED on purpose:\n * - `serviceName` — the `runtime.endPoints` map key (the consumer contract:\n * `lookupFrontendPublicUrl` / X-Frontend-Service-Name key by serviceName).\n * - `serviceKey` — the `config.services.<key>`, which is the serviceHosts\n * authoring key. The public HOST resolves from THIS, never from serviceName.\n * Conflating them silently ignores authored `serviceHosts` (the serviceName\n * `wonder-todos-app` misses the authored `app` entry).\n */\nexport interface ApplicationPublicFrontend {\n serviceName: string;\n serviceKey: string;\n port: number;\n}\n\nexport interface K8sApplicationIngressRoutesInput {\n publicDomain: string;\n serviceHosts: Record<string, string> | undefined;\n /** Public frontends. Host resolves from `serviceKey` (config key); route target is the frontend's own `serviceName`. */\n frontends: ReadonlyArray<ApplicationPublicFrontend>;\n /** Backend API `config.services.<key>` (host resolution key). */\n mainBackendApiServiceKey?: string | undefined;\n /** Backend API per-service k8s Service name (the ingress route target). */\n mainBackendApiServiceName?: string | undefined;\n /** Backend API Service port. */\n mainBackendApiPort?: number | undefined;\n}\n\n/**\n * Ingress routes for the app's PUBLIC services (every frontend + the main\n * backend API), serviceHosts-driven. Every host resolves from the service's\n * `config.services.<key>` (`serviceKey`) — so GIVEN THE SAME frontends/keys,\n * the routes match the `runtime.endPoints.publicUrl` that\n * {@link buildK8sApplicationRuntimeEndpoints} produces (both key public hosts on\n * `serviceKey`). Coherence is a property of feeding both the SAME `serviceKey`s,\n * not automatic — see the divergence guards in the domain plan. Health, webhooks,\n * the OAuth provider and MCP are routes on the backend's own port, so they reach\n * the public host through the backend API route like any other path (#1783).\n */\nexport function buildK8sApplicationIngressRoutes(\n input: K8sApplicationIngressRoutesInput,\n): K8sIngressRoute[] {\n const host = (serviceKey: string): string =>\n buildServicePublicHost({ serviceKey, serviceHosts: input.serviceHosts, publicDomain: input.publicDomain });\n\n const entries: Array<{ serviceKey: string; serviceName: string; host: string; port: number }> =\n input.frontends.map((f) => ({\n serviceKey: f.serviceKey,\n serviceName: f.serviceName,\n host: host(f.serviceKey),\n port: f.port,\n }));\n if (\n input.mainBackendApiServiceKey !== undefined &&\n input.mainBackendApiServiceName !== undefined &&\n input.mainBackendApiPort !== undefined\n ) {\n entries.push({\n serviceKey: input.mainBackendApiServiceKey,\n serviceName: input.mainBackendApiServiceName,\n host: host(input.mainBackendApiServiceKey),\n port: input.mainBackendApiPort,\n });\n }\n\n // Fail-closed host-uniqueness guard: each public host routes entirely to ONE\n // service:port (no path-based sharing), so two distinct services resolving to\n // the same host — e.g. both authored to the apex (`''`), or an unauthored key\n // that collides with an authored subdomain — is an ambiguous, silently-broken\n // ingress. Reject it at build time with the colliding keys named, rather than\n // emitting a manifest whose routing is undefined.\n const claimedBy = new Map<string, string>();\n for (const entry of entries) {\n const existing = claimedBy.get(entry.host);\n if (existing !== undefined && existing !== entry.serviceKey) {\n throw new Error(\n `serviceHosts collision: services '${existing}' and '${entry.serviceKey}' both resolve to public host '${entry.host}'. ` +\n `Each service needs a distinct 'serviceHosts' subdomain (only one service may map to the apex '').`,\n );\n }\n claimedBy.set(entry.host, entry.serviceKey);\n }\n\n return entries.map(({ host: h, serviceName, port }) => ({ host: h, serviceName, port }));\n}\n\n/**\n * Fields shared by every REMOTE runtime-endpoints builder (k8s + compose). The\n * PUBLIC side (serviceHosts resolution) is runtime-agnostic; only the INTERNAL\n * URL form differs, injected via the `internalUrlFor` callback of the core\n * builder ({@link buildRemoteApplicationRuntimeEndpoints}).\n */\nexport interface RemoteApplicationRuntimeEndpointsCommon {\n /** Operator's public domain (`WildoInfraEnvConfig.publicDomain`). */\n publicDomain: string;\n /** Authored per-service subdomain map (`wildo.infra.<env>.config.ts`). */\n serviceHosts: Record<string, string> | undefined;\n /**\n * Public frontends. The `runtime.endPoints` map is keyed by each frontend's\n * `serviceName` (consumer contract); the public HOST resolves from its\n * `serviceKey` (config key / serviceHosts key). See {@link ApplicationPublicFrontend}.\n */\n frontends: ReadonlyArray<ApplicationPublicFrontend>;\n /** `serviceKey` of the STATIC_WEBSITE frontend (feeds the fixed website endpoint). */\n websiteServiceKey?: string | undefined;\n /** `serviceKey` of the TECH_DOC frontend (feeds the fixed technical-documentation endpoint). */\n technicalDocumentationServiceKey?: string | undefined;\n /** Backend API `config.services.<key>` (host resolution key). */\n mainBackendApiServiceKey?: string | undefined;\n /** Backend API container port — the one port the backend process binds (its internal URL). */\n mainBackendApiPort?: number | undefined;\n}\n\nexport interface K8sApplicationRuntimeEndpointsInput extends RemoteApplicationRuntimeEndpointsCommon {\n /** K8s namespace for cluster-internal service DNS. */\n namespace: string;\n /**\n * K8s Service name for cluster-internal URLs. Single Service per app (all\n * frontends + APIs ride it on different ports), so this is the app's own\n * service name (= its slug).\n */\n appServiceName: string;\n}\n\nexport interface ComposeApplicationRuntimeEndpointsInput extends RemoteApplicationRuntimeEndpointsCommon {\n /**\n * Compose service (container) name for internal URLs. Single container per\n * app serving all frontends + APIs on their ports, reachable by other\n * containers on the shared network as `http://<appServiceName>:<port>`.\n */\n appServiceName: string;\n}\n\n/**\n * Core REMOTE application runtime-endpoints assembly, shared by the k8s and\n * compose builders so their public-URL semantics never drift. PUBLIC URLs come\n * from {@link buildServicePublicUrl} (so ingress hosts, `runtime.endPoints.publicUrl`,\n * and CORS all agree — greenfield, no multi-tenant fan-out). INTERNAL URLs are\n * supplied by `internalUrlFor` (cluster-DNS for k8s, container DNS for compose).\n * The backend declares ONE endpoint: health, webhooks, the OAuth provider and MCP\n * are routes on its port, not sibling listeners (#1783).\n */\nfunction buildRemoteApplicationRuntimeEndpoints(\n input: RemoteApplicationRuntimeEndpointsCommon,\n internalUrlFor: (port: number) => string,\n): Record<string, RuntimeEndpointUrls> {\n const { publicDomain, serviceHosts } = input;\n const pub = (serviceKey: string): string =>\n buildServicePublicUrl({ serviceKey, serviceHosts, publicDomain });\n const internal = internalUrlFor;\n\n // Map key = serviceName (consumer contract: lookupFrontendPublicUrl keys by\n // serviceName); public host = serviceKey (serviceHosts key). Decoupled.\n const frontendApplications = input.frontends.length > 0\n ? Object.fromEntries(\n input.frontends.map((f) => [\n f.serviceName,\n { publicUrl: pub(f.serviceKey), internalUrl: internal(f.port) },\n ]),\n )\n : undefined;\n\n const websiteFrontend = input.websiteServiceKey\n ? input.frontends.find((f) => f.serviceKey === input.websiteServiceKey)\n : undefined;\n const docsFrontend = input.technicalDocumentationServiceKey\n ? input.frontends.find((f) => f.serviceKey === input.technicalDocumentationServiceKey)\n : undefined;\n const { mainBackendApiServiceKey, mainBackendApiPort } = input;\n\n return buildApplicationRuntimeEndpoints({\n frontendApplications,\n ...(websiteFrontend\n ? { website: { publicUrl: pub(websiteFrontend.serviceKey), internalUrl: internal(websiteFrontend.port) } }\n : {}),\n ...(docsFrontend\n ? {\n technicalDocumentation: {\n publicUrl: pub(docsFrontend.serviceKey),\n internalUrl: internal(docsFrontend.port),\n },\n }\n : {}),\n ...(mainBackendApiServiceKey !== undefined && mainBackendApiPort !== undefined\n ? {\n mainBackendApi: {\n publicUrl: pub(mainBackendApiServiceKey),\n internalUrl: internal(mainBackendApiPort),\n },\n }\n : {}),\n });\n}\n\n/**\n * Build K8s application runtime endpoints — the self-hosted, single-app,\n * `serviceHosts`-driven counterpart to {@link buildLocalhostApplicationRuntimeEndpoints}.\n * INTERNAL URLs are the app's own cluster-DNS Service on each port.\n */\nexport function buildK8sApplicationRuntimeEndpoints(\n input: K8sApplicationRuntimeEndpointsInput,\n): Record<string, RuntimeEndpointUrls> {\n return buildRemoteApplicationRuntimeEndpoints(input, (port) =>\n buildK8sInternalUrl(input.appServiceName, port, input.namespace),\n );\n}\n\n/**\n * Build Docker-Compose application runtime endpoints — the compose counterpart\n * of {@link buildK8sApplicationRuntimeEndpoints}. PUBLIC URLs are IDENTICAL\n * (serviceHosts-driven, so the Traefik ingress routes and `runtime.endPoints`\n * agree — the CORS invariant holds for compose too). INTERNAL URLs are the app\n * container's own name on the shared compose network (`http://<appServiceName>:<port>`),\n * NOT localhost — the remote compose stack must not advertise localhost topology.\n */\nexport function buildComposeApplicationRuntimeEndpoints(\n input: ComposeApplicationRuntimeEndpointsInput,\n): Record<string, RuntimeEndpointUrls> {\n return buildRemoteApplicationRuntimeEndpoints(input, (port) => `http://${input.appServiceName}:${port}`);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wildo-owner-organization.contracts.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"wildo-owner-organization.contracts.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/wildo-owner-organization.contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8D,KAAK,uBAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEvJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,WAAW,8BAA8B;IAC7C,mFAAmF;IACnF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wGAAwG;IACxG,QAAQ,CAAC,IAAI,EAAE,OAAO,gCAAgC,CAAC;CACxD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,WAAW,CAAC;AAExD,eAAO,MAAM,yBAAyB,EAAE,eAIvC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAEpE,eAAO,MAAM,iCAAiC,EAAE,uBAO/C,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,8BAItC,CAAC"}
|