@wildo-ai/platform-config-lib 1.1.4 → 1.1.6
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/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts +24 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js +25 -0
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +117 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js +63 -4
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +24 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +24 -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-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-principal.contracts.d.ts.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 +29 -0
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/wildo-owner-organization.contracts.js +39 -0
- 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/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockfile/build-parallelism.d.ts +40 -0
- package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -0
- package/dist/esm/lockfile/build-parallelism.js +64 -0
- package/dist/esm/lockfile/build-parallelism.js.map +1 -0
- 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 +28 -7
- package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js +24 -11
- 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-infra-env-config.d.ts +886 -29
- package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.js +395 -16
- 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 +1 -2
- package/dist/esm/project-config/define-minion-config.js.map +1 -1
- package/dist/esm/project-config/define-saas-config.d.ts +142 -25
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-saas-config.js +229 -26
- 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/hosted-infra-env-config.d.ts +59 -0
- package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -0
- package/dist/esm/project-config/hosted-infra-env-config.js +187 -0
- package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -0
- package/dist/esm/project-config/index.d.ts +6 -0
- package/dist/esm/project-config/index.d.ts.map +1 -1
- package/dist/esm/project-config/index.js +6 -0
- package/dist/esm/project-config/index.js.map +1 -1
- package/dist/esm/project-config/loader.d.ts +35 -0
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- package/dist/esm/project-config/loader.js +148 -8
- package/dist/esm/project-config/loader.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-companion-discovery.d.ts +288 -30
- package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js +795 -46
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts +192 -20
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.js +381 -42
- 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-modules.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.d.ts +14 -35
- package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/auth.schemas.js +14 -35
- 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 +66 -66
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.js +75 -67
- 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.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp-defaults.d.ts.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 +11 -12
- package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/csp.schemas.js +11 -12
- 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/env-example-defaults.d.ts.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.d.ts +152 -12
- package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/environment.schemas.js +186 -9
- package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +185 -10
- 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 -3
- 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/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 +77 -47
- 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 +114 -52
- package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts +50 -0
- package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/platform-services.schemas.js +57 -0
- package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts +35 -0
- package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/platform-storage.schemas.js +37 -0
- package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -0
- package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts +81 -0
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -0
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.js +74 -0
- package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -0
- 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 +1 -1
- package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
- 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.map +0 -1
- package/dist/esm/registry/digest.schemas.d.ts.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 +403 -23
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js +502 -60
- 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-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/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-secrets.schemas.d.ts +12 -1
- package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/framework-secrets.schemas.js +14 -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-secrets.schemas.d.ts.map +1 -1
- package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
- package/dist/esm/workspace-scope/index.d.ts.map +1 -1
- package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +17 -14
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js +8 -7
- package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts +15 -6
- package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-scope.schemas.js +23 -9
- package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
- package/package.json +7 -7
- package/dist/esm/registry/companion-api.schemas.js +0 -165
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { BACKING_SERVICE_APPLICATION_NAME_FIELDS, isHostedInfraEnvConfig, WildoInfraEnvConfigSchema, } from './define-infra-env-config.js';
|
|
2
|
+
import { BackingServiceKind } from './shared/backing-services.schemas.js';
|
|
3
|
+
import { WildoDeploymentRuntime } from './shared/environment.schemas.js';
|
|
4
|
+
/**
|
|
5
|
+
* A hosted descriptor that cannot be resolved against its host. Carries every issue at once: an author
|
|
6
|
+
* fixing a descriptor should not have to rediscover the next problem one load at a time.
|
|
7
|
+
*/
|
|
8
|
+
export class HostedInfraEnvConfigResolutionError extends Error {
|
|
9
|
+
issues;
|
|
10
|
+
constructor(hostedConfigPath, hostConfigPath, issues) {
|
|
11
|
+
super([
|
|
12
|
+
`Cannot resolve the hosted environment descriptor ${hostedConfigPath} against its infrastructure host ${hostConfigPath}:`,
|
|
13
|
+
...issues.map((issue) => ` - ${issue}`),
|
|
14
|
+
].join('\n'));
|
|
15
|
+
this.name = 'HostedInfraEnvConfigResolutionError';
|
|
16
|
+
this.issues = issues;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Turn a hosted descriptor into the environment it actually runs in: the host's platform, the
|
|
21
|
+
* application's own settings.
|
|
22
|
+
*
|
|
23
|
+
* A PURE function of the two evaluated descriptors — no filesystem — so the whole merge contract is
|
|
24
|
+
* testable without a checkout. `loadInfraEnvConfig` does the reading and calls this.
|
|
25
|
+
*
|
|
26
|
+
* ## What comes from where
|
|
27
|
+
*
|
|
28
|
+
* Decided per member by `INFRA_ENV_FIELD_OWNERSHIP`:
|
|
29
|
+
* - HOST members (runtime, location, runtime environment, platform database, remote provider, platform
|
|
30
|
+
* storage) are the host's, verbatim;
|
|
31
|
+
* - APPLICATION members are the hosted descriptor's, verbatim;
|
|
32
|
+
* - `backingServices`: the kinds are the ones the HOSTED application lists (its needs), each of which the
|
|
33
|
+
* host must declare; each entry is the host's server with the host's own name removed, overlaid with the
|
|
34
|
+
* application's name;
|
|
35
|
+
* - `kubernetes`: the host's namespace and ingress class, the application's replica counts;
|
|
36
|
+
* - `deployment`: the host's runtime, the application's branch and tagging. The image registry is the host's
|
|
37
|
+
* `remoteProvider.registryEndpoint` like everything else about where images live (#1165).
|
|
38
|
+
*
|
|
39
|
+
* ## Why the kinds are the application's, not the host's
|
|
40
|
+
*
|
|
41
|
+
* Rejected: handing a hosted application every store its host declares. That would give Wonder CRM a
|
|
42
|
+
* MongoDB address it never asked for, named by the shared `'wildo_app'` fallback — the exact collision
|
|
43
|
+
* the name rule exists to prevent. Declaring a kind stays how an application says it needs a store; what
|
|
44
|
+
* changes is that it cannot say where that store is.
|
|
45
|
+
*
|
|
46
|
+
* ## The merged result is re-validated
|
|
47
|
+
*
|
|
48
|
+
* The merge is parsed through the STANDALONE schema, so every cross-field rule that holds for an owning
|
|
49
|
+
* environment (an application on PostgreSQL needs `backingServices.postgresql`; a local environment cannot
|
|
50
|
+
* author `cdn`; …) holds for the effective hosted one. Validating the hosted descriptor alone could not do
|
|
51
|
+
* that: it does not know whether its host is local or remote.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveHostedInfraEnvConfig(input) {
|
|
54
|
+
const { hosted, host, hostedConfigPath, hostConfigPath } = input;
|
|
55
|
+
const fail = (issues) => {
|
|
56
|
+
throw new HostedInfraEnvConfigResolutionError(hostedConfigPath, hostConfigPath, issues);
|
|
57
|
+
};
|
|
58
|
+
if (isHostedInfraEnvConfig(host)) {
|
|
59
|
+
fail([
|
|
60
|
+
`the host is itself hosted (its infrastructureHost is '${host.infrastructureHost.applicationRoot}'). An infrastructure `
|
|
61
|
+
+ 'host must OWN its infrastructure: point infrastructureHost at the application that does.',
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
const owningHost = host;
|
|
65
|
+
const issues = [];
|
|
66
|
+
if (owningHost.environment !== hosted.environment) {
|
|
67
|
+
issues.push(`the host describes environment '${owningHost.environment}', this descriptor '${hosted.environment}'. A hosted `
|
|
68
|
+
+ 'application shares its host\'s platform for ONE environment at a time, so both must describe the same one.');
|
|
69
|
+
}
|
|
70
|
+
const backingServices = resolveBackingServices(hosted, owningHost, hostConfigPath, issues);
|
|
71
|
+
const kubernetes = resolveKubernetes(hosted, owningHost, issues);
|
|
72
|
+
const deployment = resolveDeployment(hosted, owningHost, issues);
|
|
73
|
+
if (issues.length > 0)
|
|
74
|
+
fail(issues);
|
|
75
|
+
const merged = {
|
|
76
|
+
version: hosted.version,
|
|
77
|
+
environment: hosted.environment,
|
|
78
|
+
locationType: owningHost.locationType,
|
|
79
|
+
runtimeEnvironment: owningHost.runtimeEnvironment,
|
|
80
|
+
runtime: owningHost.runtime,
|
|
81
|
+
database: owningHost.database,
|
|
82
|
+
applicationDatabase: hosted.applicationDatabase,
|
|
83
|
+
publicDomain: hosted.publicDomain,
|
|
84
|
+
serviceHosts: hosted.serviceHosts,
|
|
85
|
+
kubernetes,
|
|
86
|
+
remoteProvider: owningHost.remoteProvider,
|
|
87
|
+
deployment,
|
|
88
|
+
backingServices,
|
|
89
|
+
logging: hosted.logging,
|
|
90
|
+
observability: hosted.observability,
|
|
91
|
+
providerSelection: hosted.providerSelection,
|
|
92
|
+
providerConfigurations: hosted.providerConfigurations,
|
|
93
|
+
systemsOfRecord: hosted.systemsOfRecord,
|
|
94
|
+
documentationSite: hosted.documentationSite,
|
|
95
|
+
applicationCreationVerification: hosted.applicationCreationVerification,
|
|
96
|
+
serviceAuth: hosted.serviceAuth,
|
|
97
|
+
csp: hosted.csp,
|
|
98
|
+
cdn: hosted.cdn,
|
|
99
|
+
platformStorage: owningHost.platformStorage,
|
|
100
|
+
devCompanion: hosted.devCompanion,
|
|
101
|
+
infrastructureHost: {
|
|
102
|
+
applicationRoot: input.hostApplicationRoot,
|
|
103
|
+
infraConfigPath: hostConfigPath,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const parsed = WildoInfraEnvConfigSchema.safeParse(merged);
|
|
107
|
+
if (!parsed.success) {
|
|
108
|
+
fail(parsed.error.issues.map((issue) => {
|
|
109
|
+
const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : '';
|
|
110
|
+
return `the effective environment (host platform + this application) is invalid — ${path}${issue.message}`;
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
return parsed.data;
|
|
114
|
+
}
|
|
115
|
+
function resolveBackingServices(hosted, host, hostConfigPath, issues) {
|
|
116
|
+
const resolved = {};
|
|
117
|
+
for (const kind of Object.values(BackingServiceKind)) {
|
|
118
|
+
const hostedEntry = hosted.backingServices?.[kind];
|
|
119
|
+
if (hostedEntry === undefined)
|
|
120
|
+
continue;
|
|
121
|
+
const hostEntry = host.backingServices[kind];
|
|
122
|
+
if (hostEntry === undefined) {
|
|
123
|
+
issues.push(`this application uses backingServices.${kind}, which its host does not declare. Every backing service a `
|
|
124
|
+
+ `hosted application needs is declared by its host: add backingServices.${kind} to ${hostConfigPath}.`);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const nameField = BACKING_SERVICE_APPLICATION_NAME_FIELDS[kind];
|
|
128
|
+
const server = { ...hostEntry };
|
|
129
|
+
if (nameField !== null)
|
|
130
|
+
delete server[nameField.field];
|
|
131
|
+
if (nameField?.mustDifferFromHost) {
|
|
132
|
+
const hostName = hostEntry[nameField.field];
|
|
133
|
+
if (hostName === undefined) {
|
|
134
|
+
/*
|
|
135
|
+
* An unnamed host slice uses the framework's SHARED fallback (`'wildo_app'`, the default vhost `/`, the
|
|
136
|
+
* fixed bucket). Those constants live with the env generators, not here, so the collision cannot be
|
|
137
|
+
* decided by value — and refusing is the only answer that stays right when a fallback changes. A host
|
|
138
|
+
* whose store is shared names its own slice.
|
|
139
|
+
*/
|
|
140
|
+
issues.push(`the host declares backingServices.${kind} without a ${nameField.field}, so it uses the framework's `
|
|
141
|
+
+ `shared fallback name — which an application on its platform could collide with without either naming it. `
|
|
142
|
+
+ `A host whose ${kind} is shared must name its own ${nameField.field}: add it to ${hostConfigPath}.`);
|
|
143
|
+
}
|
|
144
|
+
else if (hostName === hostedEntry[nameField.field]) {
|
|
145
|
+
issues.push(`backingServices.${kind}.${nameField.field} is '${String(hostedEntry[nameField.field])}', the same as the `
|
|
146
|
+
+ `host's. Both applications would read and write one ${kind} ${nameField.field}: name this application's own.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
resolved[kind] = { ...server, ...hostedEntry };
|
|
150
|
+
}
|
|
151
|
+
return resolved;
|
|
152
|
+
}
|
|
153
|
+
function resolveKubernetes(hosted, host, issues) {
|
|
154
|
+
const services = hosted.kubernetes?.services;
|
|
155
|
+
if (host.kubernetes === undefined) {
|
|
156
|
+
if (services !== undefined) {
|
|
157
|
+
issues.push('kubernetes.services sets replica counts, but the host declares no kubernetes block: there is no cluster '
|
|
158
|
+
+ 'for them to apply to. Remove them, or run the host on Kubernetes.');
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
namespace: host.kubernetes.namespace,
|
|
164
|
+
...(host.kubernetes.ingressClass !== undefined ? { ingressClass: host.kubernetes.ingressClass } : {}),
|
|
165
|
+
...(services !== undefined ? { services } : {}),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function resolveDeployment(hosted, host, issues) {
|
|
169
|
+
const authored = hosted.deployment;
|
|
170
|
+
if (authored === undefined)
|
|
171
|
+
return undefined;
|
|
172
|
+
if (host.runtime === WildoDeploymentRuntime.KUBERNETES) {
|
|
173
|
+
const hostNamespace = host.deployment?.runtime === WildoDeploymentRuntime.KUBERNETES ? host.deployment.namespace : undefined;
|
|
174
|
+
return {
|
|
175
|
+
runtime: WildoDeploymentRuntime.KUBERNETES,
|
|
176
|
+
branch: authored.branch,
|
|
177
|
+
...(authored.imageTagStrategy !== undefined ? { imageTagStrategy: authored.imageTagStrategy } : {}),
|
|
178
|
+
...(hostNamespace !== undefined ? { namespace: hostNamespace } : {}),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
runtime: WildoDeploymentRuntime.DOCKER_COMPOSE,
|
|
183
|
+
branch: authored.branch,
|
|
184
|
+
...(authored.imageTagStrategy !== undefined ? { imageTagStrategy: authored.imageTagStrategy } : {}),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=hosted-infra-env-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-infra-env-config.js","sourceRoot":"","sources":["../../../../src/project-config/hosted-infra-env-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,sBAAsB,EACtB,yBAAyB,GAK1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAiC,MAAM,mCAAmC,CAAC;AACtG,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAiBtE;;;GAGG;AACH,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IACnD,MAAM,CAAoB;IAEn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AgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpG,CAAC;AACJ,CAAC","sourcesContent":["import {\n BACKING_SERVICE_APPLICATION_NAME_FIELDS,\n isHostedInfraEnvConfig,\n WildoInfraEnvConfigSchema,\n type WildoAuthoredInfraEnvConfig,\n type WildoHostedInfraEnvConfig,\n type WildoInfraEnvConfig,\n type WildoInfraEnvConfigInput,\n} from './define-infra-env-config';\nimport { BackingServiceKind, type BackingServicesEnvConfig } from './shared/backing-services.schemas';\nimport { WildoDeploymentRuntime } from './shared/environment.schemas';\n\n/**\n * Everything {@link resolveHostedInfraEnvConfig} needs, with the file paths kept so every refusal can name\n * BOTH descriptors — the one being resolved and the one it depends on.\n */\nexport interface HostedInfraEnvConfigResolutionInput {\n hosted: WildoHostedInfraEnvConfig;\n hostedConfigPath: string;\n /** The host's descriptor as evaluated — refused if it is itself hosted. */\n host: WildoAuthoredInfraEnvConfig;\n /** Absolute. */\n hostApplicationRoot: string;\n /** Absolute. */\n hostConfigPath: string;\n}\n\n/**\n * A hosted descriptor that cannot be resolved against its host. Carries every issue at once: an author\n * fixing a descriptor should not have to rediscover the next problem one load at a time.\n */\nexport class HostedInfraEnvConfigResolutionError extends Error {\n readonly issues: readonly string[];\n\n constructor(hostedConfigPath: string, hostConfigPath: string, issues: readonly string[]) {\n super([\n `Cannot resolve the hosted environment descriptor ${hostedConfigPath} against its infrastructure host ${hostConfigPath}:`,\n ...issues.map((issue) => ` - ${issue}`),\n ].join('\\n'));\n this.name = 'HostedInfraEnvConfigResolutionError';\n this.issues = issues;\n }\n}\n\n/**\n * Turn a hosted descriptor into the environment it actually runs in: the host's platform, the\n * application's own settings.\n *\n * A PURE function of the two evaluated descriptors — no filesystem — so the whole merge contract is\n * testable without a checkout. `loadInfraEnvConfig` does the reading and calls this.\n *\n * ## What comes from where\n *\n * Decided per member by `INFRA_ENV_FIELD_OWNERSHIP`:\n * - HOST members (runtime, location, runtime environment, platform database, remote provider, platform\n * storage) are the host's, verbatim;\n * - APPLICATION members are the hosted descriptor's, verbatim;\n * - `backingServices`: the kinds are the ones the HOSTED application lists (its needs), each of which the\n * host must declare; each entry is the host's server with the host's own name removed, overlaid with the\n * application's name;\n * - `kubernetes`: the host's namespace and ingress class, the application's replica counts;\n * - `deployment`: the host's runtime, the application's branch and tagging. The image registry is the host's\n * `remoteProvider.registryEndpoint` like everything else about where images live (#1165).\n *\n * ## Why the kinds are the application's, not the host's\n *\n * Rejected: handing a hosted application every store its host declares. That would give Wonder CRM a\n * MongoDB address it never asked for, named by the shared `'wildo_app'` fallback — the exact collision\n * the name rule exists to prevent. Declaring a kind stays how an application says it needs a store; what\n * changes is that it cannot say where that store is.\n *\n * ## The merged result is re-validated\n *\n * The merge is parsed through the STANDALONE schema, so every cross-field rule that holds for an owning\n * environment (an application on PostgreSQL needs `backingServices.postgresql`; a local environment cannot\n * author `cdn`; …) holds for the effective hosted one. Validating the hosted descriptor alone could not do\n * that: it does not know whether its host is local or remote.\n */\nexport function resolveHostedInfraEnvConfig(input: HostedInfraEnvConfigResolutionInput): WildoInfraEnvConfig {\n const { hosted, host, hostedConfigPath, hostConfigPath } = input;\n const fail = (issues: readonly string[]): never => {\n throw new HostedInfraEnvConfigResolutionError(hostedConfigPath, hostConfigPath, issues);\n };\n\n if (isHostedInfraEnvConfig(host)) {\n fail([\n `the host is itself hosted (its infrastructureHost is '${host.infrastructureHost.applicationRoot}'). An infrastructure `\n + 'host must OWN its infrastructure: point infrastructureHost at the application that does.',\n ]);\n }\n const owningHost = host as WildoInfraEnvConfig;\n const issues: string[] = [];\n\n if (owningHost.environment !== hosted.environment) {\n issues.push(`the host describes environment '${owningHost.environment}', this descriptor '${hosted.environment}'. A hosted `\n + 'application shares its host\\'s platform for ONE environment at a time, so both must describe the same one.');\n }\n\n const backingServices = resolveBackingServices(hosted, owningHost, hostConfigPath, issues);\n const kubernetes = resolveKubernetes(hosted, owningHost, issues);\n const deployment = resolveDeployment(hosted, owningHost, issues);\n\n if (issues.length > 0) fail(issues);\n\n const merged: WildoInfraEnvConfigInput = {\n version: hosted.version,\n environment: hosted.environment,\n locationType: owningHost.locationType,\n runtimeEnvironment: owningHost.runtimeEnvironment,\n runtime: owningHost.runtime,\n database: owningHost.database,\n applicationDatabase: hosted.applicationDatabase,\n publicDomain: hosted.publicDomain,\n serviceHosts: hosted.serviceHosts,\n kubernetes,\n remoteProvider: owningHost.remoteProvider,\n deployment,\n backingServices,\n logging: hosted.logging,\n observability: hosted.observability,\n providerSelection: hosted.providerSelection,\n providerConfigurations: hosted.providerConfigurations,\n systemsOfRecord: hosted.systemsOfRecord,\n documentationSite: hosted.documentationSite,\n applicationCreationVerification: hosted.applicationCreationVerification,\n serviceAuth: hosted.serviceAuth,\n csp: hosted.csp,\n cdn: hosted.cdn,\n platformStorage: owningHost.platformStorage,\n devCompanion: hosted.devCompanion,\n infrastructureHost: {\n applicationRoot: input.hostApplicationRoot,\n infraConfigPath: hostConfigPath,\n },\n };\n\n const parsed = WildoInfraEnvConfigSchema.safeParse(merged);\n if (!parsed.success) {\n fail(parsed.error.issues.map((issue) => {\n const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : '';\n return `the effective environment (host platform + this application) is invalid — ${path}${issue.message}`;\n }));\n }\n return (parsed as { data: WildoInfraEnvConfig }).data;\n}\n\nfunction resolveBackingServices(\n hosted: WildoHostedInfraEnvConfig,\n host: WildoInfraEnvConfig,\n hostConfigPath: string,\n issues: string[],\n): BackingServicesEnvConfig {\n const resolved: Record<string, Record<string, unknown>> = {};\n for (const kind of Object.values(BackingServiceKind)) {\n const hostedEntry = hosted.backingServices?.[kind] as Record<string, unknown> | undefined;\n if (hostedEntry === undefined) continue;\n\n const hostEntry = host.backingServices[kind] as Record<string, unknown> | undefined;\n if (hostEntry === undefined) {\n issues.push(`this application uses backingServices.${kind}, which its host does not declare. Every backing service a `\n + `hosted application needs is declared by its host: add backingServices.${kind} to ${hostConfigPath}.`);\n continue;\n }\n\n const nameField = BACKING_SERVICE_APPLICATION_NAME_FIELDS[kind];\n const server = { ...hostEntry };\n if (nameField !== null) delete server[nameField.field];\n\n if (nameField?.mustDifferFromHost) {\n const hostName = hostEntry[nameField.field];\n if (hostName === undefined) {\n /*\n * An unnamed host slice uses the framework's SHARED fallback (`'wildo_app'`, the default vhost `/`, the\n * fixed bucket). Those constants live with the env generators, not here, so the collision cannot be\n * decided by value — and refusing is the only answer that stays right when a fallback changes. A host\n * whose store is shared names its own slice.\n */\n issues.push(`the host declares backingServices.${kind} without a ${nameField.field}, so it uses the framework's `\n + `shared fallback name — which an application on its platform could collide with without either naming it. `\n + `A host whose ${kind} is shared must name its own ${nameField.field}: add it to ${hostConfigPath}.`);\n } else if (hostName === hostedEntry[nameField.field]) {\n issues.push(`backingServices.${kind}.${nameField.field} is '${String(hostedEntry[nameField.field])}', the same as the `\n + `host's. Both applications would read and write one ${kind} ${nameField.field}: name this application's own.`);\n }\n }\n\n resolved[kind] = { ...server, ...hostedEntry };\n }\n return resolved as BackingServicesEnvConfig;\n}\n\nfunction resolveKubernetes(\n hosted: WildoHostedInfraEnvConfig,\n host: WildoInfraEnvConfig,\n issues: string[],\n): WildoInfraEnvConfigInput['kubernetes'] {\n const services = hosted.kubernetes?.services;\n if (host.kubernetes === undefined) {\n if (services !== undefined) {\n issues.push('kubernetes.services sets replica counts, but the host declares no kubernetes block: there is no cluster '\n + 'for them to apply to. Remove them, or run the host on Kubernetes.');\n }\n return undefined;\n }\n return {\n namespace: host.kubernetes.namespace,\n ...(host.kubernetes.ingressClass !== undefined ? { ingressClass: host.kubernetes.ingressClass } : {}),\n ...(services !== undefined ? { services } : {}),\n };\n}\n\nfunction resolveDeployment(\n hosted: WildoHostedInfraEnvConfig,\n host: WildoInfraEnvConfig,\n issues: string[],\n): WildoInfraEnvConfigInput['deployment'] {\n const authored = hosted.deployment;\n if (authored === undefined) return undefined;\n\n if (host.runtime === WildoDeploymentRuntime.KUBERNETES) {\n const hostNamespace = host.deployment?.runtime === WildoDeploymentRuntime.KUBERNETES ? host.deployment.namespace : undefined;\n return {\n runtime: WildoDeploymentRuntime.KUBERNETES,\n branch: authored.branch,\n ...(authored.imageTagStrategy !== undefined ? { imageTagStrategy: authored.imageTagStrategy } : {}),\n ...(hostNamespace !== undefined ? { namespace: hostNamespace } : {}),\n };\n }\n\n return {\n runtime: WildoDeploymentRuntime.DOCKER_COMPOSE,\n branch: authored.branch,\n ...(authored.imageTagStrategy !== undefined ? { imageTagStrategy: authored.imageTagStrategy } : {}),\n };\n}\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from './shared/backing-services.schemas';
|
|
2
|
+
export * from './shared/backing-service-servability';
|
|
2
3
|
export * from './shared/auth.schemas';
|
|
3
4
|
export * from './shared/application-creation-verification.schemas';
|
|
4
5
|
export * from './shared/cdn.schemas';
|
|
6
|
+
export * from './shared/systems-of-record-env.schemas';
|
|
7
|
+
export * from './shared/platform-storage.schemas';
|
|
5
8
|
export * from './shared/csp.schemas';
|
|
6
9
|
export * from './shared/csp-defaults';
|
|
7
10
|
export * from './shared/csp-emit';
|
|
@@ -17,8 +20,11 @@ export * from './shared/infrastructure-defaults.schemas';
|
|
|
17
20
|
export * from './shared/k8s-utils';
|
|
18
21
|
export * from './shared/env-example-defaults';
|
|
19
22
|
export * from './loader';
|
|
23
|
+
export * from './static-asset-import-noop';
|
|
24
|
+
export * from './application-public-pricing-catalog.loader';
|
|
20
25
|
export * from './define-framework-config';
|
|
21
26
|
export * from './define-infra-env-config';
|
|
27
|
+
export * from './hosted-infra-env-config';
|
|
22
28
|
export * from './shared/minion-platform-access.vocabulary';
|
|
23
29
|
export * from './define-saas-config';
|
|
24
30
|
export * from './provider-companion-discovery';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/project-config/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oDAAoD,CAAC;AACnE,cAAc,sBAAsB,CAAC;AACrC,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0CAA0C,CAAC;AACzD,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6CAA6C,CAAC;AAE5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from './shared/backing-services.schemas.js';
|
|
2
|
+
export * from './shared/backing-service-servability.js';
|
|
2
3
|
export * from './shared/auth.schemas.js';
|
|
3
4
|
export * from './shared/application-creation-verification.schemas.js';
|
|
4
5
|
export * from './shared/cdn.schemas.js';
|
|
6
|
+
export * from './shared/systems-of-record-env.schemas.js';
|
|
7
|
+
export * from './shared/platform-storage.schemas.js';
|
|
5
8
|
export * from './shared/csp.schemas.js';
|
|
6
9
|
export * from './shared/csp-defaults.js';
|
|
7
10
|
export * from './shared/csp-emit.js';
|
|
@@ -17,8 +20,11 @@ export * from './shared/infrastructure-defaults.schemas.js';
|
|
|
17
20
|
export * from './shared/k8s-utils.js';
|
|
18
21
|
export * from './shared/env-example-defaults.js';
|
|
19
22
|
export * from './loader.js';
|
|
23
|
+
export * from './static-asset-import-noop.js';
|
|
24
|
+
export * from './application-public-pricing-catalog.loader.js';
|
|
20
25
|
export * from './define-framework-config.js';
|
|
21
26
|
export * from './define-infra-env-config.js';
|
|
27
|
+
export * from './hosted-infra-env-config.js';
|
|
22
28
|
export * from './shared/minion-platform-access.vocabulary.js';
|
|
23
29
|
export * from './define-saas-config.js';
|
|
24
30
|
export * from './provider-companion-discovery.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/project-config/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oDAAoD,CAAC;AACnE,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0CAA0C,CAAC;AACzD,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/project-config/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,oDAAoD,CAAC;AACnE,cAAc,sBAAsB,CAAC;AACrC,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0CAA0C,CAAC;AACzD,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAE9C,cAAc,UAAU,CAAC;AACzB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6CAA6C,CAAC;AAE5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './shared/backing-services.schemas';\nexport * from './shared/backing-service-servability';\nexport * from './shared/auth.schemas';\nexport * from './shared/application-creation-verification.schemas';\nexport * from './shared/cdn.schemas';\nexport * from './shared/systems-of-record-env.schemas';\nexport * from './shared/platform-storage.schemas';\nexport * from './shared/csp.schemas';\nexport * from './shared/csp-defaults';\nexport * from './shared/csp-emit';\nexport * from './shared/infra-service.schemas';\nexport * from './shared/infra-providers.schemas';\nexport * from './shared/platform-services.schemas';\nexport * from './shared/data-services.schemas';\nexport * from './shared/application-modules.schemas';\nexport * from './shared/application-modules.utils';\nexport * from './shared/service-definitions.schemas';\nexport * from './shared/environment.schemas';\nexport * from './shared/infrastructure-defaults.schemas';\nexport * from './shared/k8s-utils';\nexport * from './shared/env-example-defaults';\n\nexport * from './loader';\nexport * from './static-asset-import-noop';\nexport * from './application-public-pricing-catalog.loader';\n\nexport * from './define-framework-config';\nexport * from './define-infra-env-config';\nexport * from './hosted-infra-env-config';\nexport * from './shared/minion-platform-access.vocabulary';\nexport * from './define-saas-config';\nexport * from './provider-companion-discovery';\nexport * from './provider-catalog-types';\nexport * from './provider-runtime-artifacts';\nexport * from './define-worker-config';\nexport * from './define-minion-config';\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { WildoFrameworkConfig } from './define-framework-config';
|
|
2
2
|
import type { WildoSaasConfig } from './define-saas-config';
|
|
3
|
+
import { type WildoInfraEnvConfig } from './define-infra-env-config';
|
|
3
4
|
import type { WildoMinionConfig } from './define-minion-config';
|
|
4
5
|
import type { WildoWorkerConfig } from './define-worker-config';
|
|
5
6
|
import { type ConfigArtifactsLocationOptions } from '../workspace-scope/workspace-scope.schemas';
|
|
@@ -71,6 +72,17 @@ export interface LoadConfigOptions {
|
|
|
71
72
|
* @throws If the file doesn't exist, has syntax errors, or Zod validation fails
|
|
72
73
|
*/
|
|
73
74
|
export declare function loadConfig<T>(filePath: string, options?: LoadConfigOptions): Promise<T>;
|
|
75
|
+
/**
|
|
76
|
+
* Load one NAMED export of an application-authored TypeScript module, through the same resolver
|
|
77
|
+
* `loadConfig` uses — framework aliases, the application's own package, the per-file cache.
|
|
78
|
+
*
|
|
79
|
+
* For modules that are not configs and have no default export: the accepted brand assets
|
|
80
|
+
* (`specifications/src/brand/resolved-assets.generated.ts` exports `generatedResolvedBrandAssets`)
|
|
81
|
+
* are read by both the CLI's `wildo brand propagate` and the companion's logo step, and a second
|
|
82
|
+
* TypeScript loader in each would resolve framework imports differently from every other config the
|
|
83
|
+
* application authors. Returns `undefined` when the module does not export `exportName`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function loadConfigExport<T>(filePath: string, exportName: string, options?: LoadConfigOptions): Promise<T | undefined>;
|
|
74
86
|
export declare function resolvePackageCompanionEntryPath(packageRoot: string, subpath?: string, options?: Pick<LoadConfigOptions, 'moduleResolution'>): string;
|
|
75
87
|
/**
|
|
76
88
|
* Normalize tsconfig-shaped compiler path aliases into the exact-prefix form
|
|
@@ -93,6 +105,29 @@ export declare function loadPackageCompanionExport<T>(packageRoot: string, subpa
|
|
|
93
105
|
* Returns `null` if the file doesn't exist (non-throwing variant for optional loading).
|
|
94
106
|
*/
|
|
95
107
|
export declare function loadSaasConfig(filePath: string, options?: LoadConfigOptions): Promise<WildoSaasConfig | null>;
|
|
108
|
+
/**
|
|
109
|
+
* Where an application authors one environment's infra config: `<infrastructure home>/<env>/wildo.infra.<local|remote>.config.ts`.
|
|
110
|
+
*
|
|
111
|
+
* ONE rule, shared by every reader. It lived as a private helper in the CLI and was copied twice more inside it
|
|
112
|
+
* (frontend publish, CSP sync); the dev companion needs it too, to read the application's declared store, so it moved
|
|
113
|
+
* here beside {@link loadSaasConfig}.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resolveInfraEnvConfigPath(saasRoot: string, envName: string): string;
|
|
116
|
+
/**
|
|
117
|
+
* Load one environment's authored `wildo.infra.<env>.config.ts`. Returns `null` when the file does not exist.
|
|
118
|
+
*
|
|
119
|
+
* Refuses a file whose authored `environment` is not the directory it sits in: reading `local`'s file for `staging`
|
|
120
|
+
* would hand one environment another's topology, silently.
|
|
121
|
+
*
|
|
122
|
+
* `freshModuleCache` re-evaluates the file instead of serving jiti's process-wide module cache. A short-lived CLI
|
|
123
|
+
* does not need it; a long-lived reader whose question is "what does the file say NOW" does — the dev companion
|
|
124
|
+
* reads the application's declared store through here, and a cached evaluation would keep answering with the
|
|
125
|
+
* store the file declared when the process first read it (see {@link LoadConfigOptions.freshModuleCache}).
|
|
126
|
+
*/
|
|
127
|
+
export declare function loadInfraEnvConfig(saasRoot: string, envName: string, options?: Pick<LoadConfigOptions, 'freshModuleCache'>): Promise<{
|
|
128
|
+
path: string;
|
|
129
|
+
config: WildoInfraEnvConfig;
|
|
130
|
+
} | null>;
|
|
96
131
|
/**
|
|
97
132
|
* Per-folder file name for a minion config (`wildo.minion.config.ts`).
|
|
98
133
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/project-config/loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AAInC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAIL,KAAK,8BAA8B,EACpC,MAAM,4CAA4C,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,8BAA8B,CAAC;IAClD;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,SAAS,GAAG,kBAAkB,CAAC;IAClD;;;;;;;;;;;;;;OAcG;IACH,oBAAoB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAID;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAM7F;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM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BAA2B,CAAC;AAE/D;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,MAAM,EAAE,CAAC,CAAC;CACX;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAQpD;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAQpD;AA6BD;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GACpD,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAYtC"}
|
|
@@ -3,7 +3,11 @@ import { existsSync, mkdirSync, readFileSync } from 'fs';
|
|
|
3
3
|
import { dirname, join, relative, resolve } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { createJiti } from 'jiti';
|
|
6
|
-
import { resolveFrameworkLayout } from '../workspace-scope/workspace-homes.schemas.js';
|
|
6
|
+
import { resolveAppLayout, resolveFrameworkLayout } from '../workspace-scope/workspace-homes.schemas.js';
|
|
7
|
+
import { isHostedInfraEnvConfig, WildoHostedInfraEnvConfigSchema, } from './define-infra-env-config.js';
|
|
8
|
+
import { realpathSync } from 'fs';
|
|
9
|
+
import { resolveHostedInfraEnvConfig } from './hosted-infra-env-config.js';
|
|
10
|
+
import { AUTHORED_CONFIG_FILE_NAMES } from '../workspace-scope/workspace-scope.schemas.js';
|
|
7
11
|
import { ConfigArtifactsZone, FRAMEWORK_WORKSPACE_MARKER_FILE, resolveConfigArtifactsBaseDir, } from '../workspace-scope/workspace-scope.schemas.js';
|
|
8
12
|
const PACKAGE_COMPANION_SUBPATH = './companion';
|
|
9
13
|
/**
|
|
@@ -17,6 +21,27 @@ const PACKAGE_COMPANION_SUBPATH = './companion';
|
|
|
17
21
|
* @throws If the file doesn't exist, has syntax errors, or Zod validation fails
|
|
18
22
|
*/
|
|
19
23
|
export async function loadConfig(filePath, options) {
|
|
24
|
+
const { absolutePath, module } = await importConfigModule(filePath, options);
|
|
25
|
+
if (!module.default) {
|
|
26
|
+
throw new Error(`Config file must use \`export default\`: ${absolutePath}`);
|
|
27
|
+
}
|
|
28
|
+
return module.default;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load one NAMED export of an application-authored TypeScript module, through the same resolver
|
|
32
|
+
* `loadConfig` uses — framework aliases, the application's own package, the per-file cache.
|
|
33
|
+
*
|
|
34
|
+
* For modules that are not configs and have no default export: the accepted brand assets
|
|
35
|
+
* (`specifications/src/brand/resolved-assets.generated.ts` exports `generatedResolvedBrandAssets`)
|
|
36
|
+
* are read by both the CLI's `wildo brand propagate` and the companion's logo step, and a second
|
|
37
|
+
* TypeScript loader in each would resolve framework imports differently from every other config the
|
|
38
|
+
* application authors. Returns `undefined` when the module does not export `exportName`.
|
|
39
|
+
*/
|
|
40
|
+
export async function loadConfigExport(filePath, exportName, options) {
|
|
41
|
+
const { module } = await importConfigModule(filePath, options);
|
|
42
|
+
return module[exportName];
|
|
43
|
+
}
|
|
44
|
+
async function importConfigModule(filePath, options) {
|
|
20
45
|
const absolutePath = resolve(filePath);
|
|
21
46
|
if (!existsSync(absolutePath)) {
|
|
22
47
|
throw new Error(`Config file not found: ${absolutePath}`);
|
|
@@ -50,11 +75,7 @@ export async function loadConfig(filePath, options) {
|
|
|
50
75
|
}),
|
|
51
76
|
},
|
|
52
77
|
});
|
|
53
|
-
|
|
54
|
-
if (!module.default) {
|
|
55
|
-
throw new Error(`Config file must use \`export default\`: ${absolutePath}`);
|
|
56
|
-
}
|
|
57
|
-
return module.default;
|
|
78
|
+
return { absolutePath, module: await jiti.import(absolutePath) };
|
|
58
79
|
}
|
|
59
80
|
export function resolvePackageCompanionEntryPath(packageRoot, subpath = PACKAGE_COMPANION_SUBPATH, options) {
|
|
60
81
|
const packageJsonPath = join(packageRoot, 'package.json');
|
|
@@ -163,9 +184,19 @@ export function normalizeCompilerPathAliasesForLoader(packageRoot, compilerPathA
|
|
|
163
184
|
return normalized;
|
|
164
185
|
}
|
|
165
186
|
export async function loadPackageCompanionExport(packageRoot, subpath = PACKAGE_COMPANION_SUBPATH, options) {
|
|
187
|
+
/*
|
|
188
|
+
* The REAL path, as Node resolves a linked package (#2038). pnpm installs an injected or workspace package into an
|
|
189
|
+
* importer's `node_modules` as a symlink to its virtual-store copy, and that copy's own dependencies sit beside it
|
|
190
|
+
* there (`.pnpm/<key>/node_modules/…`), not in the importer's `node_modules`. jiti resolves a bare import from the path
|
|
191
|
+
* it was handed, so the symlinked root found a dependency only when the importer happened to declare it too — the
|
|
192
|
+
* catalogue's `@wildo-ai/external-connectors-public/companion` import (#1700) was the first one the backend did not,
|
|
193
|
+
* and every `wildo config sync` of Wonder Todos then refused its ten catalogue providers as uncontributed.
|
|
194
|
+
* A root that is not a link is its own real path, so runtime owners are unchanged.
|
|
195
|
+
*/
|
|
196
|
+
const realPackageRoot = realpathSync(packageRoot);
|
|
166
197
|
const moduleResolution = options?.moduleResolution
|
|
167
|
-
?? inferPackageCompanionModuleResolution(
|
|
168
|
-
const entryPath = resolvePackageCompanionEntryPath(
|
|
198
|
+
?? inferPackageCompanionModuleResolution(realPackageRoot);
|
|
199
|
+
const entryPath = resolvePackageCompanionEntryPath(realPackageRoot, subpath, {
|
|
169
200
|
moduleResolution,
|
|
170
201
|
});
|
|
171
202
|
return loadConfig(entryPath, {
|
|
@@ -342,6 +373,115 @@ export async function loadSaasConfig(filePath, options) {
|
|
|
342
373
|
return null;
|
|
343
374
|
return loadConfig(absolutePath, options);
|
|
344
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Where an application authors one environment's infra config: `<infrastructure home>/<env>/wildo.infra.<local|remote>.config.ts`.
|
|
378
|
+
*
|
|
379
|
+
* ONE rule, shared by every reader. It lived as a private helper in the CLI and was copied twice more inside it
|
|
380
|
+
* (frontend publish, CSP sync); the dev companion needs it too, to read the application's declared store, so it moved
|
|
381
|
+
* here beside {@link loadSaasConfig}.
|
|
382
|
+
*/
|
|
383
|
+
export function resolveInfraEnvConfigPath(saasRoot, envName) {
|
|
384
|
+
return join(resolveAppLayout(saasRoot).authoredInfrastructureHome, envName, envName === 'local' ? 'wildo.infra.local.config.ts' : 'wildo.infra.remote.config.ts');
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Load one environment's authored `wildo.infra.<env>.config.ts`. Returns `null` when the file does not exist.
|
|
388
|
+
*
|
|
389
|
+
* Refuses a file whose authored `environment` is not the directory it sits in: reading `local`'s file for `staging`
|
|
390
|
+
* would hand one environment another's topology, silently.
|
|
391
|
+
*
|
|
392
|
+
* `freshModuleCache` re-evaluates the file instead of serving jiti's process-wide module cache. A short-lived CLI
|
|
393
|
+
* does not need it; a long-lived reader whose question is "what does the file say NOW" does — the dev companion
|
|
394
|
+
* reads the application's declared store through here, and a cached evaluation would keep answering with the
|
|
395
|
+
* store the file declared when the process first read it (see {@link LoadConfigOptions.freshModuleCache}).
|
|
396
|
+
*/
|
|
397
|
+
export async function loadInfraEnvConfig(saasRoot, envName, options) {
|
|
398
|
+
const authored = await loadAuthoredInfraEnvConfigFile(saasRoot, envName, options);
|
|
399
|
+
if (authored === null)
|
|
400
|
+
return null;
|
|
401
|
+
if (!isHostedInfraEnvConfig(authored.config)) {
|
|
402
|
+
return { path: authored.path, config: authored.config };
|
|
403
|
+
}
|
|
404
|
+
/*
|
|
405
|
+
* VALIDATE the hosted descriptor before trusting any of it. `defineHostedInfraEnvConfig` parses it, but this
|
|
406
|
+
* loader also evaluates plain `export default {…}` objects — and an unvalidated `backingServices.postgresql.host`
|
|
407
|
+
* would override the HOST's server in the merge, which is precisely the divergence hosting exists to make
|
|
408
|
+
* impossible. A host-owned member (`runtime`, `database`, …) is refused here too, by name, instead of being
|
|
409
|
+
* silently dropped.
|
|
410
|
+
*/
|
|
411
|
+
const hostedParse = WildoHostedInfraEnvConfigSchema.safeParse(authored.config);
|
|
412
|
+
if (!hostedParse.success) {
|
|
413
|
+
throw new Error(`${authored.path} is a hosted environment descriptor and is invalid:\n`
|
|
414
|
+
+ hostedParse.error.issues.map((issue) => ` - ${issue.path.join('.') || '(root)'}: ${issue.message}`).join('\n'));
|
|
415
|
+
}
|
|
416
|
+
const hostedDescriptor = hostedParse.data;
|
|
417
|
+
/*
|
|
418
|
+
* A HOSTED descriptor resolves here and nowhere else. This is the one function that holds both the
|
|
419
|
+
* application root and the environment name, and every reader of an application's infra descriptor
|
|
420
|
+
* reaches it — so the host's platform is merged in once, and no consumer can see a hosted descriptor
|
|
421
|
+
* that has not been resolved.
|
|
422
|
+
*/
|
|
423
|
+
const declaredHostRoot = hostedDescriptor.infrastructureHost.applicationRoot;
|
|
424
|
+
const hostApplicationRoot = resolve(saasRoot, declaredHostRoot);
|
|
425
|
+
if (isSameDirectory(hostApplicationRoot, saasRoot)) {
|
|
426
|
+
throw new Error(`${authored.path} declares itself as its own infrastructureHost ('${declaredHostRoot}'). `
|
|
427
|
+
+ 'Remove infrastructureHost: an application that owns its infrastructure declares it standalone.');
|
|
428
|
+
}
|
|
429
|
+
if (!existsSync(join(hostApplicationRoot, AUTHORED_CONFIG_FILE_NAMES.SAAS))) {
|
|
430
|
+
throw new Error(`${authored.path} runs on the infrastructure of '${declaredHostRoot}', which resolves to `
|
|
431
|
+
+ `${hostApplicationRoot} — and no Wildo application is there (no ${AUTHORED_CONFIG_FILE_NAMES.SAAS}). A hosted application `
|
|
432
|
+
+ 'needs its host\'s SOURCE: check the host application out at that path, or remove infrastructureHost to run this '
|
|
433
|
+
+ 'application on its own infrastructure.');
|
|
434
|
+
}
|
|
435
|
+
const host = await loadAuthoredInfraEnvConfigFile(hostApplicationRoot, envName, options);
|
|
436
|
+
if (host === null) {
|
|
437
|
+
throw new Error(`${authored.path} runs on the infrastructure of ${hostApplicationRoot} for environment '${envName}', but that `
|
|
438
|
+
+ `application has no descriptor for it (expected ${resolveInfraEnvConfigPath(hostApplicationRoot, envName)}). The host `
|
|
439
|
+
+ 'owns the platform per environment, so it must describe this one.');
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
path: authored.path,
|
|
443
|
+
config: resolveHostedInfraEnvConfig({
|
|
444
|
+
hosted: hostedDescriptor,
|
|
445
|
+
hostedConfigPath: authored.path,
|
|
446
|
+
host: host.config,
|
|
447
|
+
hostApplicationRoot,
|
|
448
|
+
hostConfigPath: host.path,
|
|
449
|
+
}),
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Whether two paths name the same directory. Compared through `realpath` when both exist, so a symlinked
|
|
454
|
+
* `applicationRoot` pointing back at the application itself is still recognised as self-hosting; falls
|
|
455
|
+
* back to lexical resolution when either path does not exist yet.
|
|
456
|
+
*/
|
|
457
|
+
function isSameDirectory(a, b) {
|
|
458
|
+
try {
|
|
459
|
+
return realpathSync(a) === realpathSync(b);
|
|
460
|
+
}
|
|
461
|
+
catch {
|
|
462
|
+
return resolve(a) === resolve(b);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Evaluate one application's descriptor AS AUTHORED — standalone or hosted, unresolved. Private: a hosted
|
|
467
|
+
* descriptor is not an environment until {@link loadInfraEnvConfig} merges its host in.
|
|
468
|
+
*
|
|
469
|
+
* The host's file is evaluated with the HOST as artifact owner, so its jiti cache lives beside its own
|
|
470
|
+
* application rather than inside the hosted one's.
|
|
471
|
+
*/
|
|
472
|
+
async function loadAuthoredInfraEnvConfigFile(saasRoot, envName, options) {
|
|
473
|
+
const path = resolveInfraEnvConfigPath(saasRoot, envName);
|
|
474
|
+
if (!existsSync(path))
|
|
475
|
+
return null;
|
|
476
|
+
const config = await loadConfig(resolve(path), {
|
|
477
|
+
artifactLocation: { zone: ConfigArtifactsZone.SAAS, ownerRoot: saasRoot },
|
|
478
|
+
...(options?.freshModuleCache === true ? { freshModuleCache: true } : {}),
|
|
479
|
+
});
|
|
480
|
+
if (config.environment !== envName) {
|
|
481
|
+
throw new Error(`Authored env descriptor mismatch: directory '${envName}' does not match authored environment '${config.environment}'.`);
|
|
482
|
+
}
|
|
483
|
+
return { path, config };
|
|
484
|
+
}
|
|
345
485
|
/**
|
|
346
486
|
* Per-folder file name for a minion config (`wildo.minion.config.ts`).
|
|
347
487
|
*
|