@wildo-ai/platform-config-lib 1.1.3 → 1.1.5
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/bootstrap.contracts.d.ts +23 -1
- package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.contracts.js +24 -0
- package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts +150 -1
- package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
- package/dist/esm/bootstrap/bootstrap.schemas.js +124 -4
- package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +16 -0
- package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
- package/dist/esm/bootstrap/platform-runtime-env.contracts.js +28 -0
- package/dist/esm/bootstrap/platform-runtime-env.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/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 +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/materialize-infra-section.d.ts +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js +1 -1
- package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.d.ts +899 -15
- package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-infra-env-config.js +397 -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 +90 -25
- package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
- package/dist/esm/project-config/define-saas-config.js +165 -12
- package/dist/esm/project-config/define-saas-config.js.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 +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 +24 -0
- package/dist/esm/project-config/loader.d.ts.map +1 -1
- package/dist/esm/project-config/loader.js +114 -1
- package/dist/esm/project-config/loader.js.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.d.ts +46 -0
- package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
- package/dist/esm/project-config/provider-companion-discovery.js +155 -13
- package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts +72 -23
- package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
- package/dist/esm/project-config/provider-runtime-artifacts.js +190 -17
- package/dist/esm/project-config/provider-runtime-artifacts.js.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-services.schemas.d.ts +37 -7
- package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/backing-services.schemas.js +37 -7
- package/dist/esm/project-config/shared/backing-services.schemas.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/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 +13 -3
- package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
- package/dist/esm/project-config/shared/infra-providers.schemas.js +0 -3
- package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
- package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +140 -34
- 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 +174 -37
- 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/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/registry/artifact-domain.schemas.d.ts +1 -1
- package/dist/esm/registry/module-manifest.schemas.d.ts +10 -16
- package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
- package/dist/esm/registry/module-manifest.schemas.js +14 -20
- package/dist/esm/registry/module-manifest.schemas.js.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/workspace-scope/workspace-homes.schemas.d.ts +4 -3
- package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
- package/dist/esm/workspace-scope/workspace-homes.schemas.js +6 -5
- 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/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import { resolve as resolvePath } from 'node:path';
|
|
3
|
+
import { join, resolve as resolvePath } from 'node:path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { FrontendProvidersBlockSchema, } from '@wildo-ai/saas-models';
|
|
5
|
+
import { FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY, FrontendProviderPublicConfigError, FrontendProvidersBlockSchema, overlayFrontendProviderPublicConfig, } from '@wildo-ai/saas-models';
|
|
6
6
|
import { SaasLockfileProvidersSectionSchema, } from '../lockfile/wildo-saas-lock.shared.schemas.js';
|
|
7
7
|
import { getDeclaredApplicationModuleIds, getServiceBoundApplicationModuleIds, } from './shared/application-modules.utils.js';
|
|
8
8
|
import { SaasProvidersScopesSchema, SaasProviderScopeSelectionSchema, } from './define-saas-config.js';
|
|
@@ -86,6 +86,30 @@ const RuntimeProviderModulesArtifactSchema = z.strictObject({
|
|
|
86
86
|
moduleIds: z.array(z.string().min(1)).default([]),
|
|
87
87
|
moduleIdsByService: z.record(z.string(), z.array(z.string().min(1))).default({}),
|
|
88
88
|
});
|
|
89
|
+
/**
|
|
90
|
+
* The per-service frontend bootstrap map, keyed by frontend service key.
|
|
91
|
+
*
|
|
92
|
+
* ## It was an ANNOTATED interface until 2026-09-12, and the workaround is gone (#356)
|
|
93
|
+
*
|
|
94
|
+
* `FrontendProvidersBlockSchema` transitively references three atoms — `ProviderFrontendCspOriginBucket`,
|
|
95
|
+
* `ProviderFrontendScriptCrossOrigin`, `ProviderFrontendSelectionDelivery` — that `@wildo-ai/saas-models`
|
|
96
|
+
* published from `/public-runtime` ALONE. While this artifact object stayed small TypeScript inlined the
|
|
97
|
+
* shape and nobody noticed; adding one member past the inline threshold made it reach for the NAME and
|
|
98
|
+
* refuse, here and in `saas-backend-lib` at the same time:
|
|
99
|
+
*
|
|
100
|
+
* `TS2742 … cannot be named without a reference to
|
|
101
|
+
* node_modules/@wildo-ai/saas-models/src/external-providers/provider-frontend-surface.shared.schemas`.
|
|
102
|
+
*
|
|
103
|
+
* #330 stopped the expansion with a locally declared interface, deliberately as a workaround: an
|
|
104
|
+
* interface is written BY NAME in the emitted declaration where a type alias expands structurally and
|
|
105
|
+
* takes the unnameable atoms with it. The boundary has since MOVED — the root barrel now exports that
|
|
106
|
+
* module — so the atoms are nameable through the package root and the workaround has nothing left to do.
|
|
107
|
+
*
|
|
108
|
+
* Verified with the probe `package-public-entrypoints.md` prescribes rather than by re-running the
|
|
109
|
+
* source-mapped packages: a consumer importing ONLY `@wildo-ai/saas-models`, deriving a record over
|
|
110
|
+
* `FrontendProvidersBlockSchema`, compiled with `declaration: true`. It names all three atoms through
|
|
111
|
+
* `import("@wildo-ai/saas-models")` and reaches no relative `node_modules` path at all.
|
|
112
|
+
*/
|
|
89
113
|
const FrontendProviderBootstrapsSchema = z.record(z.string().min(1), FrontendProvidersBlockSchema);
|
|
90
114
|
export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
|
|
91
115
|
__AUTOGENERATED__: z.literal(PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING),
|
|
@@ -106,6 +130,19 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
|
|
|
106
130
|
* without consulting this record, so an un-resynced application is unaffected.
|
|
107
131
|
*/
|
|
108
132
|
providerRuntimeImports: z.record(z.string().min(1), z.string().min(1)).optional(),
|
|
133
|
+
/**
|
|
134
|
+
* Package specifiers that ship SYSTEM-OF-RECORD VENDOR FACETS, in discovery order (#1057).
|
|
135
|
+
*
|
|
136
|
+
* A list rather than a `vendor -> specifier` map, because a facet module contributes a RECORD of
|
|
137
|
+
* vendors rather than one module per vendor: a map would restate the record's own keys in a
|
|
138
|
+
* generated artifact read by a different process, free to disagree with it. The backend imports
|
|
139
|
+
* each specifier in order and takes the first that answers for the vendor.
|
|
140
|
+
*
|
|
141
|
+
* Discovered from the MANIFEST — a package declaring an `./systems-of-record` export — never from
|
|
142
|
+
* loading it. Sync has no business evaluating a vendor facet, and the manifest is the same door
|
|
143
|
+
* `./companion` is found through.
|
|
144
|
+
*/
|
|
145
|
+
systemOfRecordFacetModules: z.array(z.string().min(1)).optional(),
|
|
109
146
|
providerGraphDigest: z.string().min(1),
|
|
110
147
|
lockfileSectionDigest: z.string().min(1),
|
|
111
148
|
artifactKind: z.enum([
|
|
@@ -120,13 +157,29 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
|
|
|
120
157
|
scopes: z.record(z.string(), RuntimeProviderScopeArtifactSchema).optional(),
|
|
121
158
|
frontendProviderBootstraps: FrontendProviderBootstrapsSchema.optional(),
|
|
122
159
|
});
|
|
123
|
-
export function materializeSaasProviderRuntimeArtifacts(
|
|
160
|
+
export function materializeSaasProviderRuntimeArtifacts(
|
|
161
|
+
// `providerConfigurations` is where an application supplies a frontend provider's public keys
|
|
162
|
+
// (#394 P3). Optional here so the lockfile check and every existing caller that narrows the
|
|
163
|
+
// config keep compiling; absent means "the application configured nothing", never a refusal.
|
|
164
|
+
config, options) {
|
|
124
165
|
const scopes = SaasProvidersScopesSchema.parse(config.providers.scopes);
|
|
125
166
|
const generatedAt = options?.generatedAt ?? new Date().toISOString();
|
|
126
167
|
const modules = materializeModules(config);
|
|
127
168
|
const frontendServiceTypes = Object.fromEntries(Object.entries(config.services ?? {})
|
|
128
169
|
.filter(([, definition]) => definition.frontendType !== undefined)
|
|
129
170
|
.map(([serviceKey, definition]) => [serviceKey, definition.frontendType]));
|
|
171
|
+
// Backend requests carry public service names; build-time consumers use declaration keys.
|
|
172
|
+
// Validate before publication so two scopes can never silently overwrite one another.
|
|
173
|
+
const frontendServiceNames = {};
|
|
174
|
+
const publicNames = new Set();
|
|
175
|
+
for (const serviceKey of Object.keys(frontendServiceTypes)) {
|
|
176
|
+
const name = config.services[serviceKey]?.serviceName;
|
|
177
|
+
if (!name?.trim() || publicNames.has(name)) {
|
|
178
|
+
throw new Error(`Frontend service "${serviceKey}" needs a unique non-empty public serviceName; received "${name ?? ''}".`);
|
|
179
|
+
}
|
|
180
|
+
publicNames.add(name);
|
|
181
|
+
frontendServiceNames[serviceKey] = name;
|
|
182
|
+
}
|
|
130
183
|
const discoveryContext = buildProviderRuntimeDiscoveryContext({
|
|
131
184
|
discoveredContributions: options?.discoveredContributions,
|
|
132
185
|
frontendServiceTypes,
|
|
@@ -140,19 +193,23 @@ export function materializeSaasProviderRuntimeArtifacts(config, options) {
|
|
|
140
193
|
const artifactMetadata = buildArtifactMetadata({
|
|
141
194
|
discoveryContext,
|
|
142
195
|
frontendServiceTypes,
|
|
196
|
+
frontendServiceNames,
|
|
143
197
|
lockSection,
|
|
144
198
|
modules,
|
|
145
199
|
nodeWorkerKeys: options?.nodeWorkerKeys,
|
|
146
200
|
scopes,
|
|
201
|
+
providerConfigurations: config.providerConfigurations ?? {},
|
|
147
202
|
});
|
|
148
203
|
const artifacts = materializeRuntimeArtifacts({
|
|
149
204
|
artifactMetadata,
|
|
150
205
|
discoveryContext,
|
|
151
206
|
frontendServiceTypes,
|
|
207
|
+
frontendServiceNames,
|
|
152
208
|
generatedAt,
|
|
153
209
|
modules,
|
|
154
210
|
nodeWorkerKeys: options?.nodeWorkerKeys,
|
|
155
211
|
scopes,
|
|
212
|
+
providerConfigurations: config.providerConfigurations ?? {},
|
|
156
213
|
});
|
|
157
214
|
return { artifacts, lockSection };
|
|
158
215
|
}
|
|
@@ -427,22 +484,26 @@ export function assertProviderRuntimeEnvInSync(input) {
|
|
|
427
484
|
}
|
|
428
485
|
}
|
|
429
486
|
function materializeRuntimeArtifacts(input) {
|
|
430
|
-
const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes } = input;
|
|
487
|
+
const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
|
|
431
488
|
const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
|
|
432
489
|
const nodeWorkerScopes = scopes.workers
|
|
433
490
|
? Object.fromEntries(Object.entries(scopes.workers).filter(([workerKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(workerKey) : true))
|
|
434
491
|
: undefined;
|
|
492
|
+
const backendBootstraps = materializeFrontendProviderBootstraps({
|
|
493
|
+
discoveredContributions: discoveryContext.contributions,
|
|
494
|
+
frontendServiceScopes: scopes.frontendServices ?? {},
|
|
495
|
+
frontendServiceTypes,
|
|
496
|
+
providerConfigurations,
|
|
497
|
+
});
|
|
435
498
|
return pruneUndefined({
|
|
436
499
|
backend: materializeRuntimeArtifactFile({
|
|
437
500
|
artifactKind: 'backend',
|
|
438
501
|
generatedAt,
|
|
439
502
|
modules,
|
|
440
503
|
metadata: artifactMetadata.backend,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
frontendServiceTypes,
|
|
445
|
-
}),
|
|
504
|
+
// Only the HTTP-facing backend map uses public names. Static artifacts below
|
|
505
|
+
// deliberately retain declaration keys for build-time scope selection.
|
|
506
|
+
frontendProviderBootstraps: backendBootstraps && Object.fromEntries(Object.entries(backendBootstraps).map(([serviceKey, block]) => [input.frontendServiceNames[serviceKey], block])),
|
|
446
507
|
scope: materializeRuntimeScope(scopes.backend ?? { providers: {}, selection: {} }),
|
|
447
508
|
}),
|
|
448
509
|
companion: materializeRuntimeArtifactFile({
|
|
@@ -462,6 +523,7 @@ function materializeRuntimeArtifacts(input) {
|
|
|
462
523
|
discoveredContributions: discoveryContext.contributions,
|
|
463
524
|
frontendServiceScopes: scopes.frontendServices,
|
|
464
525
|
frontendServiceTypes,
|
|
526
|
+
providerConfigurations,
|
|
465
527
|
}),
|
|
466
528
|
scopes: mapRecord(scopes.frontendServices, materializeRuntimeScope),
|
|
467
529
|
})
|
|
@@ -494,6 +556,7 @@ function materializeRuntimeArtifactFile(input) {
|
|
|
494
556
|
sourceDigest: input.metadata.sourceDigest,
|
|
495
557
|
providerRefs: input.metadata.providerRefs,
|
|
496
558
|
providerRuntimeImports: input.metadata.providerRuntimeImports,
|
|
559
|
+
systemOfRecordFacetModules: input.metadata.systemOfRecordFacetModules,
|
|
497
560
|
providerGraphDigest: input.metadata.providerGraphDigest,
|
|
498
561
|
lockfileSectionDigest: input.metadata.lockfileSectionDigest,
|
|
499
562
|
artifactKind: input.artifactKind,
|
|
@@ -510,7 +573,7 @@ function materializeRuntimeScope(scope) {
|
|
|
510
573
|
});
|
|
511
574
|
}
|
|
512
575
|
function materializeFrontendProviderBootstraps(input) {
|
|
513
|
-
const { discoveredContributions, frontendServiceScopes, frontendServiceTypes } = input;
|
|
576
|
+
const { discoveredContributions, frontendServiceScopes, frontendServiceTypes, providerConfigurations } = input;
|
|
514
577
|
const entries = Object.entries(frontendServiceScopes).map(([serviceKey, scope]) => {
|
|
515
578
|
const serviceType = frontendServiceTypes[serviceKey];
|
|
516
579
|
if (!serviceType) {
|
|
@@ -534,13 +597,54 @@ function materializeFrontendProviderBootstraps(input) {
|
|
|
534
597
|
}
|
|
535
598
|
return [
|
|
536
599
|
providerRef,
|
|
537
|
-
|
|
600
|
+
applyApplicationPublicConfig({
|
|
601
|
+
serviceKey,
|
|
602
|
+
providerRef,
|
|
603
|
+
entry: matchingContribution[0].frontendEntry,
|
|
604
|
+
supplied: providerConfigurations[providerRef]?.[FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY],
|
|
605
|
+
discoveredContributions,
|
|
606
|
+
}),
|
|
538
607
|
];
|
|
539
608
|
}));
|
|
540
609
|
return [serviceKey, FrontendProvidersBlockSchema.parse({ providers })];
|
|
541
610
|
});
|
|
542
611
|
return entries.length > 0 ? Object.fromEntries(entries) : undefined;
|
|
543
612
|
}
|
|
613
|
+
/**
|
|
614
|
+
* Overlays what the application supplied under `providerConfigurations[ref].frontend_sdk` onto the
|
|
615
|
+
* module's authored `publicConfig` (#394 P3) — the FIRST of the two sites that produce a
|
|
616
|
+
* `FrontendProviderEntry` from a module; the backend fallback is the other, and both call the one
|
|
617
|
+
* function in `saas-models` so they cannot disagree about what crosses.
|
|
618
|
+
*
|
|
619
|
+
* The forbidden set is built from the SAME vendor's non-frontend contributions: a frontend provider
|
|
620
|
+
* owns no secrets (`secretsContractShape: []` by construction), so the only secrets that could be
|
|
621
|
+
* typed into its bag are the backend module's, and those are exactly what this walk has in hand.
|
|
622
|
+
*/
|
|
623
|
+
function applyApplicationPublicConfig(input) {
|
|
624
|
+
const { serviceKey, providerRef, entry, supplied, discoveredContributions } = input;
|
|
625
|
+
if (supplied === undefined)
|
|
626
|
+
return entry;
|
|
627
|
+
const forbiddenKeys = new Set(discoveredContributions
|
|
628
|
+
.filter((contribution) => contribution.ref === providerRef
|
|
629
|
+
&& contribution.runtimeTargets.some((target) => target.kind !== 'frontendService'))
|
|
630
|
+
.flatMap((contribution) => contribution.secretsContractShape.flatMap((slot) => [slot.slug, slot.envVarName])));
|
|
631
|
+
try {
|
|
632
|
+
const publicConfig = overlayFrontendProviderPublicConfig({
|
|
633
|
+
providerRef,
|
|
634
|
+
authored: entry.publicConfig,
|
|
635
|
+
supplied,
|
|
636
|
+
declaredKeys: entry.publicConfigKeys,
|
|
637
|
+
forbiddenKeys,
|
|
638
|
+
});
|
|
639
|
+
return publicConfig === undefined ? entry : { ...entry, publicConfig };
|
|
640
|
+
}
|
|
641
|
+
catch (error) {
|
|
642
|
+
if (error instanceof FrontendProviderPublicConfigError) {
|
|
643
|
+
throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}": ${error.message}`);
|
|
644
|
+
}
|
|
645
|
+
throw error;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
544
648
|
function buildFrontendProviderBootstrapDigestInput(input) {
|
|
545
649
|
const bootstraps = materializeFrontendProviderBootstraps(input);
|
|
546
650
|
if (!bootstraps) {
|
|
@@ -686,25 +790,39 @@ function buildProviderRuntimeDiscoveryContext(input) {
|
|
|
686
790
|
};
|
|
687
791
|
}
|
|
688
792
|
function buildArtifactMetadata(input) {
|
|
689
|
-
const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes } = input;
|
|
793
|
+
const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
|
|
794
|
+
/*
|
|
795
|
+
* Computed ONCE for every artifact kind, because a vendor facet is not scoped to a runtime the way
|
|
796
|
+
* a provider is: it says what a vendor NEEDS, which does not change between a backend and a
|
|
797
|
+
* minion. Only the backend reads it today (#1055 D2 gives the instance environment to that runtime
|
|
798
|
+
* alone), and recording it everywhere is what keeps that a policy of the RUNTIME rather than a
|
|
799
|
+
* property of the artifact.
|
|
800
|
+
*/
|
|
801
|
+
const systemOfRecordFacetModules = discoverSystemOfRecordFacetModules(discoveryContext.contributions);
|
|
690
802
|
const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
|
|
691
803
|
return {
|
|
692
804
|
backend: buildSingleScopeArtifactMetadata({
|
|
805
|
+
systemOfRecordFacetModules,
|
|
693
806
|
modules,
|
|
694
807
|
providers: scopes.backend?.providers ?? {},
|
|
695
808
|
matchingContributions: findMatchingDiscoveredContributions({
|
|
696
809
|
discoveredContributions: discoveryContext.contributions,
|
|
697
810
|
matchesRuntimeTarget: discoveryContext.backend.matchesRuntimeTarget,
|
|
698
811
|
}),
|
|
699
|
-
extraArtifactState:
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
812
|
+
extraArtifactState: {
|
|
813
|
+
frontendServiceNames: input.frontendServiceNames,
|
|
814
|
+
bootstraps: buildFrontendProviderBootstrapDigestInput({
|
|
815
|
+
discoveredContributions: discoveryContext.contributions,
|
|
816
|
+
frontendServiceScopes: scopes.frontendServices ?? {},
|
|
817
|
+
frontendServiceTypes,
|
|
818
|
+
providerConfigurations,
|
|
819
|
+
}),
|
|
820
|
+
},
|
|
704
821
|
runtimeLockSection: lockSection.runtimeScopes.backend ?? {},
|
|
705
822
|
scopes,
|
|
706
823
|
}),
|
|
707
824
|
companion: buildSingleScopeArtifactMetadata({
|
|
825
|
+
systemOfRecordFacetModules,
|
|
708
826
|
modules,
|
|
709
827
|
providers: scopes.companion?.providers ?? {},
|
|
710
828
|
matchingContributions: findMatchingDiscoveredContributions({
|
|
@@ -715,6 +833,7 @@ function buildArtifactMetadata(input) {
|
|
|
715
833
|
scopes,
|
|
716
834
|
}),
|
|
717
835
|
frontendServices: buildMultiScopeArtifactMetadata({
|
|
836
|
+
systemOfRecordFacetModules,
|
|
718
837
|
keyedProviders: Object.fromEntries(Object.entries(scopes.frontendServices ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers])),
|
|
719
838
|
matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.frontendServices ?? {}).map((scopeKey) => [
|
|
720
839
|
scopeKey,
|
|
@@ -728,11 +847,13 @@ function buildArtifactMetadata(input) {
|
|
|
728
847
|
discoveredContributions: discoveryContext.contributions,
|
|
729
848
|
frontendServiceScopes: scopes.frontendServices ?? {},
|
|
730
849
|
frontendServiceTypes,
|
|
850
|
+
providerConfigurations,
|
|
731
851
|
}),
|
|
732
852
|
runtimeLockSection: lockSection.runtimeScopes.frontendServices ?? {},
|
|
733
853
|
scopes,
|
|
734
854
|
}),
|
|
735
855
|
minions: buildMultiScopeArtifactMetadata({
|
|
856
|
+
systemOfRecordFacetModules,
|
|
736
857
|
keyedProviders: Object.fromEntries(Object.entries(scopes.minions ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers])),
|
|
737
858
|
matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.minions ?? {}).map((scopeKey) => [
|
|
738
859
|
scopeKey,
|
|
@@ -746,6 +867,7 @@ function buildArtifactMetadata(input) {
|
|
|
746
867
|
scopes,
|
|
747
868
|
}),
|
|
748
869
|
nodeWorkers: buildMultiScopeArtifactMetadata({
|
|
870
|
+
systemOfRecordFacetModules,
|
|
749
871
|
keyedProviders: Object.fromEntries(Object.entries(scopes.workers ?? {})
|
|
750
872
|
.filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)
|
|
751
873
|
.map(([scopeKey, scope]) => [scopeKey, scope.providers])),
|
|
@@ -784,6 +906,7 @@ function buildSingleScopeArtifactMetadata(input) {
|
|
|
784
906
|
}),
|
|
785
907
|
providerRefs,
|
|
786
908
|
providerRuntimeImports: buildProviderRuntimeImports(providerRefs, input.matchingContributions),
|
|
909
|
+
systemOfRecordFacetModules: input.systemOfRecordFacetModules,
|
|
787
910
|
providerGraphDigest: digestJson(providerGraphDigestInput),
|
|
788
911
|
lockfileSectionDigest: digestJson(input.runtimeLockSection),
|
|
789
912
|
};
|
|
@@ -810,10 +933,60 @@ function buildMultiScopeArtifactMetadata(input) {
|
|
|
810
933
|
}),
|
|
811
934
|
providerRefs,
|
|
812
935
|
providerRuntimeImports: buildProviderRuntimeImports(providerRefs, Object.values(input.matchingContributionsByScope).flat()),
|
|
936
|
+
systemOfRecordFacetModules: input.systemOfRecordFacetModules,
|
|
813
937
|
providerGraphDigest: digestJson(providerGraphDigestInput),
|
|
814
938
|
lockfileSectionDigest: digestJson(input.runtimeLockSection),
|
|
815
939
|
};
|
|
816
940
|
}
|
|
941
|
+
/**
|
|
942
|
+
* Which packages ship SYSTEM-OF-RECORD VENDOR FACETS (#1057).
|
|
943
|
+
*
|
|
944
|
+
* ## Read from the MANIFEST, never by loading
|
|
945
|
+
*
|
|
946
|
+
* A package contributes facets by declaring an `./systems-of-record` export — the same door
|
|
947
|
+
* `./companion` is found through, and the same reason: a build-time consumer has no business
|
|
948
|
+
* EVALUATING a vendor facet to learn that one exists. Loading would also make the discovery depend
|
|
949
|
+
* on the package compiling, which is a different question from whether it declares the surface.
|
|
950
|
+
*
|
|
951
|
+
* ## Derived from the contribution walk rather than from a second walk
|
|
952
|
+
*
|
|
953
|
+
* Every candidate package root is already visited to load its companion exports, so the facet
|
|
954
|
+
* question is answered from what that walk found. The consequence, stated because it is a real
|
|
955
|
+
* bound: a package that ships facets and NO provider contributions is not discovered, because
|
|
956
|
+
* nothing would have visited it. That package does not exist today (the catalogue ships 651
|
|
957
|
+
* contributions), and the day one does, this function needs the walk's targets rather than its
|
|
958
|
+
* results — which is a change here and nowhere else.
|
|
959
|
+
*
|
|
960
|
+
* Sorted, so the artifact does not churn on filesystem order, and de-duplicated because one package
|
|
961
|
+
* root contributes hundreds of providers and exactly one facet module.
|
|
962
|
+
*/
|
|
963
|
+
function discoverSystemOfRecordFacetModules(contributions) {
|
|
964
|
+
const specifiers = new Set();
|
|
965
|
+
const visitedRoots = new Set();
|
|
966
|
+
for (const contribution of contributions) {
|
|
967
|
+
const packageRoot = contribution.owner?.packageRoot;
|
|
968
|
+
if (packageRoot === undefined || visitedRoots.has(packageRoot))
|
|
969
|
+
continue;
|
|
970
|
+
visitedRoots.add(packageRoot);
|
|
971
|
+
let manifest;
|
|
972
|
+
try {
|
|
973
|
+
manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf-8'));
|
|
974
|
+
}
|
|
975
|
+
catch {
|
|
976
|
+
// Unreadable or absent: the companion walk already tolerates that, and a package we could not
|
|
977
|
+
// read is not one we can say anything about.
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
if (manifest.exports?.[SYSTEM_OF_RECORD_FACET_SUBPATH] === undefined)
|
|
981
|
+
continue;
|
|
982
|
+
if (typeof manifest.name !== 'string' || manifest.name.length === 0)
|
|
983
|
+
continue;
|
|
984
|
+
specifiers.add(`${manifest.name}${SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1)}`);
|
|
985
|
+
}
|
|
986
|
+
return [...specifiers].sort();
|
|
987
|
+
}
|
|
988
|
+
/** The export a package declares to contribute system-of-record vendor facets. */
|
|
989
|
+
const SYSTEM_OF_RECORD_FACET_SUBPATH = './systems-of-record';
|
|
817
990
|
/**
|
|
818
991
|
* Project the per-ref runtime import path a host dynamic-imports.
|
|
819
992
|
*
|