@wildo-ai/platform-config-lib 1.1.2 → 1.1.4

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.
Files changed (130) hide show
  1. package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
  2. package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
  3. package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
  4. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +129 -1
  5. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  6. package/dist/esm/bootstrap/bootstrap.schemas.js +105 -2
  7. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  8. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +6 -3
  9. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  10. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +18 -3
  11. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  12. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
  13. package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
  14. package/dist/esm/bootstrap/runtime-network-topology.d.ts +0 -1
  15. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  16. package/dist/esm/bootstrap/runtime-network-topology.js +0 -2
  17. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  18. package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
  19. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
  20. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
  21. package/dist/esm/config-authoring.entry.d.ts +1 -2
  22. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  23. package/dist/esm/config-authoring.entry.js +35 -2
  24. package/dist/esm/config-authoring.entry.js.map +1 -1
  25. package/dist/esm/index.d.ts.map +1 -1
  26. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
  27. package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
  28. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +0 -20
  29. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  30. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +0 -1
  31. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  32. package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
  33. package/dist/esm/project-config/define-infra-env-config.d.ts +3 -39
  34. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  35. package/dist/esm/project-config/define-infra-env-config.js +2 -2
  36. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  37. package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
  38. package/dist/esm/project-config/define-saas-config.d.ts +366 -14
  39. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  40. package/dist/esm/project-config/define-saas-config.js +121 -11
  41. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  42. package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
  43. package/dist/esm/project-config/index.d.ts.map +1 -1
  44. package/dist/esm/project-config/loader.d.ts.map +1 -1
  45. package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
  46. package/dist/esm/project-config/provider-companion-discovery.d.ts +88 -1
  47. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  48. package/dist/esm/project-config/provider-companion-discovery.js +275 -6
  49. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  50. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +42 -16
  51. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  52. package/dist/esm/project-config/provider-runtime-artifacts.js +132 -12
  53. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  54. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
  55. package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
  56. package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
  57. package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
  58. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +32 -43
  59. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  60. package/dist/esm/project-config/shared/backing-services.schemas.js +38 -30
  61. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  62. package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
  63. package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
  64. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
  65. package/dist/esm/project-config/shared/csp-emit.d.ts +36 -5
  66. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  67. package/dist/esm/project-config/shared/csp-emit.js +65 -5
  68. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  69. package/dist/esm/project-config/shared/csp.schemas.d.ts +46 -10
  70. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  71. package/dist/esm/project-config/shared/csp.schemas.js +45 -10
  72. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  73. package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
  74. package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
  75. package/dist/esm/project-config/shared/environment.schemas.d.ts +8 -6
  76. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  77. package/dist/esm/project-config/shared/environment.schemas.js +7 -5
  78. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  79. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +29 -3
  80. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  81. package/dist/esm/project-config/shared/infra-providers.schemas.js +34 -2
  82. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  83. package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
  84. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +0 -2
  85. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  86. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +0 -2
  87. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  88. package/dist/esm/project-config/shared/k8s-utils.d.ts +70 -10
  89. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  90. package/dist/esm/project-config/shared/k8s-utils.js +75 -11
  91. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  92. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts +15 -15
  93. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
  94. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js +15 -15
  95. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  96. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +76 -0
  97. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
  98. package/dist/esm/project-config/shared/minion-resource-access.validation.js +76 -1
  99. package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
  100. package/dist/esm/project-config/shared/platform-services.schemas.d.ts +30 -0
  101. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  102. package/dist/esm/project-config/shared/platform-services.schemas.js +31 -0
  103. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  104. package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
  105. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
  106. package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
  107. package/dist/esm/registry/companion-api.schemas.d.ts.map +1 -1
  108. package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
  109. package/dist/esm/registry/index.d.ts.map +1 -1
  110. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
  111. package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
  112. package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
  113. package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
  114. package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
  115. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  116. package/dist/esm/release/framework-release.constants.js.map +1 -1
  117. package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
  118. package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
  119. package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
  120. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
  121. package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
  122. package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
  123. package/dist/esm/workspace-scope/index.d.ts.map +1 -1
  124. package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
  125. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +14 -0
  126. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  127. package/dist/esm/workspace-scope/workspace-homes.schemas.js +2 -0
  128. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  129. package/dist/tsconfig.build.tsbuildinfo +1 -1
  130. package/package.json +7 -7
@@ -78,12 +78,46 @@ declare const RuntimeProviderModulesArtifactSchema: z.ZodObject<{
78
78
  moduleIdsByService: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
79
79
  }, z.core.$strict>;
80
80
  export type RuntimeProviderModulesArtifact = z.infer<typeof RuntimeProviderModulesArtifactSchema>;
81
+ /**
82
+ * The per-service frontend bootstrap map, ANNOTATED through a nominal interface rather than inferred.
83
+ *
84
+ * `FrontendProvidersBlockSchema` transitively references three atoms that `@wildo-ai/saas-models`
85
+ * publishes from `/public-runtime` alone, so a consumer that resolves this package's dependency to
86
+ * SOURCE — the minion and worker libraries do, deliberately — has no public specifier through which
87
+ * to NAME them. While the artifact object stayed small TypeScript inlined the shape and nobody
88
+ * noticed; the moment it grew one member past the inline threshold it needed the name and refused:
89
+ * `TS2742 … cannot be named without a reference to
90
+ * node_modules/@wildo-ai/saas-models/src/external-providers/provider-frontend-surface.shared.schemas`.
91
+ *
92
+ * An INTERFACE is what stops the expansion — a type alias is written out structurally in the emitted
93
+ * declaration and takes the unnameable atoms with it, while an interface is written by name. The
94
+ * underlying defect is a root-exported contract depending on a subpath-only module
95
+ * (`package-public-entrypoints.md`, "The root barrel must not DEPEND on a subpath-only surface");
96
+ * that module is the frozen provider contract, so it is filed as #356 rather than fixed here. Runtime
97
+ * behaviour and the inferred field type are unchanged.
98
+ */
99
+ export interface RuntimeProviderFrontendBootstraps {
100
+ [serviceKey: string]: FrontendProvidersBlock;
101
+ }
81
102
  export declare const SaasRuntimeProvidersArtifactSchema: z.ZodObject<{
82
103
  __AUTOGENERATED__: z.ZodLiteral<"AUTO-GENERATED FILE. DO NOT EDIT. Regenerate with `wildo config sync`.">;
83
104
  generatedBy: z.ZodLiteral<"wildo provider-runtime-artifact">;
84
105
  generatedAt: z.ZodString;
85
106
  sourceDigest: z.ZodString;
86
107
  providerRefs: z.ZodDefault<z.ZodArray<z.ZodString>>;
108
+ /**
109
+ * `providerRef` -> the package specifier a host dynamic-imports to obtain that provider's backend
110
+ * module (#330).
111
+ *
112
+ * `providerRefs` says WHICH providers a process may expose; this says WHERE each one comes from,
113
+ * and it is what makes a provider shipped as its own npm package loadable at all. Derived from
114
+ * the discovered contribution whose `runtimeTargets` match the host — never authored.
115
+ *
116
+ * Optional, so an artifact written before this field existed still parses. Every ref such an
117
+ * artifact names is engine-shipped, and a host resolves those from the engine's own on-demand map
118
+ * without consulting this record, so an un-resynced application is unaffected.
119
+ */
120
+ providerRuntimeImports: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
87
121
  providerGraphDigest: z.ZodString;
88
122
  lockfileSectionDigest: z.ZodString;
89
123
  artifactKind: z.ZodEnum<{
@@ -106,10 +140,12 @@ export declare const SaasRuntimeProvidersArtifactSchema: z.ZodObject<{
106
140
  engineCapabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<typeof import("@wildo-ai/saas-models").EngineCapability>>>;
107
141
  providerCapabilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
108
142
  protocols: z.ZodDefault<z.ZodArray<z.ZodString>>;
143
+ tier: z.ZodOptional<z.ZodEnum<typeof import("@wildo-ai/saas-models").ProviderTier>>;
144
+ vendor: z.ZodOptional<z.ZodString>;
109
145
  }, z.core.$strict>>>;
110
146
  selection: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
111
147
  primary: z.ZodString;
112
- fallbacks: z.ZodDefault<z.ZodArray<z.ZodString>>;
148
+ whenUnavailable: z.ZodDefault<z.ZodArray<z.ZodString>>;
113
149
  }, z.core.$strict>>>;
114
150
  }, z.core.$strict>>;
115
151
  scopes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -117,32 +153,22 @@ export declare const SaasRuntimeProvidersArtifactSchema: z.ZodObject<{
117
153
  engineCapabilities: z.ZodDefault<z.ZodArray<z.ZodEnum<typeof import("@wildo-ai/saas-models").EngineCapability>>>;
118
154
  providerCapabilities: z.ZodDefault<z.ZodArray<z.ZodString>>;
119
155
  protocols: z.ZodDefault<z.ZodArray<z.ZodString>>;
156
+ tier: z.ZodOptional<z.ZodEnum<typeof import("@wildo-ai/saas-models").ProviderTier>>;
157
+ vendor: z.ZodOptional<z.ZodString>;
120
158
  }, z.core.$strict>>>;
121
159
  selection: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
122
160
  primary: z.ZodString;
123
- fallbacks: z.ZodDefault<z.ZodArray<z.ZodString>>;
161
+ whenUnavailable: z.ZodDefault<z.ZodArray<z.ZodString>>;
124
162
  }, z.core.$strict>>>;
125
163
  }, z.core.$strict>>>;
126
- frontendProviderBootstraps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
127
- providers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
128
- metadata: z.ZodObject<{
129
- ref: z.ZodString;
130
- displayNameLabelKey: z.ZodOptional<z.ZodString>;
131
- displayName: z.ZodOptional<z.ZodString>;
132
- iconRef: z.ZodOptional<z.ZodString>;
133
- }, z.core.$strip>;
134
- providerCapabilities: z.ZodArray<z.ZodString>;
135
- protocols: z.ZodArray<z.ZodString>;
136
- publicConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
137
- }, z.core.$strip>>>;
138
- }, z.core.$strip>>>;
164
+ frontendProviderBootstraps: z.ZodOptional<z.ZodType<RuntimeProviderFrontendBootstraps, unknown, z.core.$ZodTypeInternals<RuntimeProviderFrontendBootstraps, unknown>>>;
139
165
  }, z.core.$strict>;
140
166
  export type SaasRuntimeProvidersArtifact = z.infer<typeof SaasRuntimeProvidersArtifactSchema>;
141
167
  export interface MaterializedSaasProviderRuntimeArtifacts {
142
168
  artifacts: Partial<Record<ProviderRuntimeArtifactKind, SaasRuntimeProvidersArtifact>>;
143
169
  lockSection: SaasLockfileProvidersSection;
144
170
  }
145
- export declare function materializeSaasProviderRuntimeArtifacts(config: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services'>, options?: {
171
+ export declare function materializeSaasProviderRuntimeArtifacts(config: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services'> & Partial<Pick<WildoSaasConfig, 'providerConfigurations'>>, options?: {
146
172
  generatedAt?: string;
147
173
  nodeWorkerKeys?: string[];
148
174
  discoveredContributions?: DiscoveredProviderCompanionContribution[];
@@ -1 +1 @@
1
- {"version":3,"file":"provider-runtime-artifacts.d.ts","sourceRoot":"","sources":["../../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAA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B,CAAC;AAEN;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,sCAAsC,CAqCzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,IAAI,CA8BP;AAED,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;CACJ,CAAC"}
1
+ {"version":3,"file":"provider-runtime-artifacts.d.ts","sourceRoot":"","sources":["../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAOL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,4CAA4C,CAAC;AAMpD,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,gCAAgC,CAAC;AAE9F,eAAO,MAAM,+CAA+C,2EACc,CAAC;AAE3E,eAAO,MAAM,mCAAm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C,KAAK,EAAE;IACjD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,sCAAsC,CAqCzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,IAAI,CA8BP;AAED,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;CACJ,CAAC"}
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { 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';
@@ -75,7 +75,7 @@ const RuntimeProviderScopeArtifactSchema = z.strictObject({
75
75
  providers: z.record(z.string(), SaasProviderScopeSelectionSchema).default({}),
76
76
  selection: z.record(z.string(), z.strictObject({
77
77
  primary: z.string().min(1),
78
- fallbacks: z.array(z.string().min(1)).default([]),
78
+ whenUnavailable: z.array(z.string().min(1)).default([]),
79
79
  })).default({}),
80
80
  });
81
81
  const RuntimeProviderModulesArtifactSchema = z.strictObject({
@@ -93,6 +93,19 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
93
93
  generatedAt: z.string().datetime({ offset: true }),
94
94
  sourceDigest: z.string().min(1),
95
95
  providerRefs: z.array(z.string().min(1)).default([]),
96
+ /**
97
+ * `providerRef` -> the package specifier a host dynamic-imports to obtain that provider's backend
98
+ * module (#330).
99
+ *
100
+ * `providerRefs` says WHICH providers a process may expose; this says WHERE each one comes from,
101
+ * and it is what makes a provider shipped as its own npm package loadable at all. Derived from
102
+ * the discovered contribution whose `runtimeTargets` match the host — never authored.
103
+ *
104
+ * Optional, so an artifact written before this field existed still parses. Every ref such an
105
+ * artifact names is engine-shipped, and a host resolves those from the engine's own on-demand map
106
+ * without consulting this record, so an un-resynced application is unaffected.
107
+ */
108
+ providerRuntimeImports: z.record(z.string().min(1), z.string().min(1)).optional(),
96
109
  providerGraphDigest: z.string().min(1),
97
110
  lockfileSectionDigest: z.string().min(1),
98
111
  artifactKind: z.enum([
@@ -107,7 +120,11 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
107
120
  scopes: z.record(z.string(), RuntimeProviderScopeArtifactSchema).optional(),
108
121
  frontendProviderBootstraps: FrontendProviderBootstrapsSchema.optional(),
109
122
  });
110
- export function materializeSaasProviderRuntimeArtifacts(config, options) {
123
+ export function materializeSaasProviderRuntimeArtifacts(
124
+ // `providerConfigurations` is where an application supplies a frontend provider's public keys
125
+ // (#394 P3). Optional here so the lockfile check and every existing caller that narrows the
126
+ // config keep compiling; absent means "the application configured nothing", never a refusal.
127
+ config, options) {
111
128
  const scopes = SaasProvidersScopesSchema.parse(config.providers.scopes);
112
129
  const generatedAt = options?.generatedAt ?? new Date().toISOString();
113
130
  const modules = materializeModules(config);
@@ -131,6 +148,7 @@ export function materializeSaasProviderRuntimeArtifacts(config, options) {
131
148
  modules,
132
149
  nodeWorkerKeys: options?.nodeWorkerKeys,
133
150
  scopes,
151
+ providerConfigurations: config.providerConfigurations ?? {},
134
152
  });
135
153
  const artifacts = materializeRuntimeArtifacts({
136
154
  artifactMetadata,
@@ -140,6 +158,7 @@ export function materializeSaasProviderRuntimeArtifacts(config, options) {
140
158
  modules,
141
159
  nodeWorkerKeys: options?.nodeWorkerKeys,
142
160
  scopes,
161
+ providerConfigurations: config.providerConfigurations ?? {},
143
162
  });
144
163
  return { artifacts, lockSection };
145
164
  }
@@ -170,6 +189,11 @@ export function selectScopedProviderRuntimeArtifact(artifact, scopeKey) {
170
189
  return SaasRuntimeProvidersArtifactSchema.parse({
171
190
  ...artifact,
172
191
  providerRefs: projectedProviderRefs,
192
+ // Narrowed for the same reason `providerRefs` is recomputed above: the multi-scope artifact's
193
+ // import map is the union across every host, and a per-host projection that advertised a
194
+ // sibling's packages would tell this host it can load something it never declared.
195
+ providerRuntimeImports: Object.fromEntries(Object.entries(artifact.providerRuntimeImports ?? {})
196
+ .filter(([providerRef]) => projectedProviderRefs.includes(providerRef))),
173
197
  frontendProviderBootstraps: artifact.frontendProviderBootstraps?.[scopeKey]
174
198
  ? { [scopeKey]: artifact.frontendProviderBootstraps[scopeKey] }
175
199
  : undefined,
@@ -215,11 +239,30 @@ export function loadMaterializedFrontendProviders(input) {
215
239
  if (!existsSync(artifactPath)) {
216
240
  return undefined;
217
241
  }
218
- const artifact = SaasRuntimeProvidersArtifactSchema.parse(JSON.parse(readFileSync(artifactPath, 'utf8')));
219
- const providerBlock = artifact.frontendProviderBootstraps?.[serviceKey];
220
- return providerBlock === undefined
221
- ? undefined
222
- : FrontendProvidersBlockSchema.parse(providerBlock);
242
+ const parsedArtifact = SaasRuntimeProvidersArtifactSchema.safeParse(JSON.parse(readFileSync(artifactPath, 'utf8')));
243
+ if (!parsedArtifact.success) {
244
+ throw staleGeneratedArtifactError(artifactPath, parsedArtifact.error.issues);
245
+ }
246
+ const providerBlock = parsedArtifact.data.frontendProviderBootstraps?.[serviceKey];
247
+ if (providerBlock === undefined)
248
+ return undefined;
249
+ const parsedBlock = FrontendProvidersBlockSchema.safeParse(providerBlock);
250
+ if (!parsedBlock.success) {
251
+ throw staleGeneratedArtifactError(artifactPath, parsedBlock.error.issues);
252
+ }
253
+ return parsedBlock.data;
254
+ }
255
+ /**
256
+ * A materialized artifact that does not satisfy the current schema was almost always generated
257
+ * before the contract changed (#328 added the provider identity to every frontend entry). A raw
258
+ * Zod issue list reads as a logic defect in the consumer; the remedy is regeneration, so the
259
+ * error names it. The backend's `applyProviderRuntime` says the same thing for its own reader —
260
+ * one message, two readers.
261
+ */
262
+ function staleGeneratedArtifactError(artifactPath, issues) {
263
+ return new Error(`The generated provider runtime artifact at ${artifactPath} does not satisfy the current contract — it was most `
264
+ + 'likely generated before the contract changed. Regenerate it with `wildo config sync`. Issues: '
265
+ + issues.map((issue) => `${issue.path.map(String).join('.')}: ${issue.message}`).join('; '));
223
266
  }
224
267
  export function renderProviderRuntimeGeneratedModule(artifact) {
225
268
  const artifactLiteral = JSON.stringify(artifact, null, 2);
@@ -390,7 +433,7 @@ export function assertProviderRuntimeEnvInSync(input) {
390
433
  }
391
434
  }
392
435
  function materializeRuntimeArtifacts(input) {
393
- const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes } = input;
436
+ const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
394
437
  const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
395
438
  const nodeWorkerScopes = scopes.workers
396
439
  ? Object.fromEntries(Object.entries(scopes.workers).filter(([workerKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(workerKey) : true))
@@ -405,6 +448,7 @@ function materializeRuntimeArtifacts(input) {
405
448
  discoveredContributions: discoveryContext.contributions,
406
449
  frontendServiceScopes: scopes.frontendServices ?? {},
407
450
  frontendServiceTypes,
451
+ providerConfigurations,
408
452
  }),
409
453
  scope: materializeRuntimeScope(scopes.backend ?? { providers: {}, selection: {} }),
410
454
  }),
@@ -425,6 +469,7 @@ function materializeRuntimeArtifacts(input) {
425
469
  discoveredContributions: discoveryContext.contributions,
426
470
  frontendServiceScopes: scopes.frontendServices,
427
471
  frontendServiceTypes,
472
+ providerConfigurations,
428
473
  }),
429
474
  scopes: mapRecord(scopes.frontendServices, materializeRuntimeScope),
430
475
  })
@@ -456,6 +501,7 @@ function materializeRuntimeArtifactFile(input) {
456
501
  generatedAt: input.generatedAt,
457
502
  sourceDigest: input.metadata.sourceDigest,
458
503
  providerRefs: input.metadata.providerRefs,
504
+ providerRuntimeImports: input.metadata.providerRuntimeImports,
459
505
  providerGraphDigest: input.metadata.providerGraphDigest,
460
506
  lockfileSectionDigest: input.metadata.lockfileSectionDigest,
461
507
  artifactKind: input.artifactKind,
@@ -472,7 +518,7 @@ function materializeRuntimeScope(scope) {
472
518
  });
473
519
  }
474
520
  function materializeFrontendProviderBootstraps(input) {
475
- const { discoveredContributions, frontendServiceScopes, frontendServiceTypes } = input;
521
+ const { discoveredContributions, frontendServiceScopes, frontendServiceTypes, providerConfigurations } = input;
476
522
  const entries = Object.entries(frontendServiceScopes).map(([serviceKey, scope]) => {
477
523
  const serviceType = frontendServiceTypes[serviceKey];
478
524
  if (!serviceType) {
@@ -496,13 +542,54 @@ function materializeFrontendProviderBootstraps(input) {
496
542
  }
497
543
  return [
498
544
  providerRef,
499
- matchingContribution[0].frontendEntry,
545
+ applyApplicationPublicConfig({
546
+ serviceKey,
547
+ providerRef,
548
+ entry: matchingContribution[0].frontendEntry,
549
+ supplied: providerConfigurations[providerRef]?.[FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY],
550
+ discoveredContributions,
551
+ }),
500
552
  ];
501
553
  }));
502
554
  return [serviceKey, FrontendProvidersBlockSchema.parse({ providers })];
503
555
  });
504
556
  return entries.length > 0 ? Object.fromEntries(entries) : undefined;
505
557
  }
558
+ /**
559
+ * Overlays what the application supplied under `providerConfigurations[ref].frontend_sdk` onto the
560
+ * module's authored `publicConfig` (#394 P3) — the FIRST of the two sites that produce a
561
+ * `FrontendProviderEntry` from a module; the backend fallback is the other, and both call the one
562
+ * function in `saas-models` so they cannot disagree about what crosses.
563
+ *
564
+ * The forbidden set is built from the SAME vendor's non-frontend contributions: a frontend provider
565
+ * owns no secrets (`secretsContractShape: []` by construction), so the only secrets that could be
566
+ * typed into its bag are the backend module's, and those are exactly what this walk has in hand.
567
+ */
568
+ function applyApplicationPublicConfig(input) {
569
+ const { serviceKey, providerRef, entry, supplied, discoveredContributions } = input;
570
+ if (supplied === undefined)
571
+ return entry;
572
+ const forbiddenKeys = new Set(discoveredContributions
573
+ .filter((contribution) => contribution.ref === providerRef
574
+ && contribution.runtimeTargets.some((target) => target.kind !== 'frontendService'))
575
+ .flatMap((contribution) => contribution.secretsContractShape.flatMap((slot) => [slot.slug, slot.envVarName])));
576
+ try {
577
+ const publicConfig = overlayFrontendProviderPublicConfig({
578
+ providerRef,
579
+ authored: entry.publicConfig,
580
+ supplied,
581
+ declaredKeys: entry.publicConfigKeys,
582
+ forbiddenKeys,
583
+ });
584
+ return publicConfig === undefined ? entry : { ...entry, publicConfig };
585
+ }
586
+ catch (error) {
587
+ if (error instanceof FrontendProviderPublicConfigError) {
588
+ throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}": ${error.message}`);
589
+ }
590
+ throw error;
591
+ }
592
+ }
506
593
  function buildFrontendProviderBootstrapDigestInput(input) {
507
594
  const bootstraps = materializeFrontendProviderBootstraps(input);
508
595
  if (!bootstraps) {
@@ -648,7 +735,7 @@ function buildProviderRuntimeDiscoveryContext(input) {
648
735
  };
649
736
  }
650
737
  function buildArtifactMetadata(input) {
651
- const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes } = input;
738
+ const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
652
739
  const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
653
740
  return {
654
741
  backend: buildSingleScopeArtifactMetadata({
@@ -662,6 +749,7 @@ function buildArtifactMetadata(input) {
662
749
  discoveredContributions: discoveryContext.contributions,
663
750
  frontendServiceScopes: scopes.frontendServices ?? {},
664
751
  frontendServiceTypes,
752
+ providerConfigurations,
665
753
  }),
666
754
  runtimeLockSection: lockSection.runtimeScopes.backend ?? {},
667
755
  scopes,
@@ -690,6 +778,7 @@ function buildArtifactMetadata(input) {
690
778
  discoveredContributions: discoveryContext.contributions,
691
779
  frontendServiceScopes: scopes.frontendServices ?? {},
692
780
  frontendServiceTypes,
781
+ providerConfigurations,
693
782
  }),
694
783
  runtimeLockSection: lockSection.runtimeScopes.frontendServices ?? {},
695
784
  scopes,
@@ -745,6 +834,7 @@ function buildSingleScopeArtifactMetadata(input) {
745
834
  extraArtifactState: input.extraArtifactState,
746
835
  }),
747
836
  providerRefs,
837
+ providerRuntimeImports: buildProviderRuntimeImports(providerRefs, input.matchingContributions),
748
838
  providerGraphDigest: digestJson(providerGraphDigestInput),
749
839
  lockfileSectionDigest: digestJson(input.runtimeLockSection),
750
840
  };
@@ -770,10 +860,40 @@ function buildMultiScopeArtifactMetadata(input) {
770
860
  extraArtifactState: input.extraArtifactState,
771
861
  }),
772
862
  providerRefs,
863
+ providerRuntimeImports: buildProviderRuntimeImports(providerRefs, Object.values(input.matchingContributionsByScope).flat()),
773
864
  providerGraphDigest: digestJson(providerGraphDigestInput),
774
865
  lockfileSectionDigest: digestJson(input.runtimeLockSection),
775
866
  };
776
867
  }
868
+ /**
869
+ * Project the per-ref runtime import path a host dynamic-imports.
870
+ *
871
+ * Only refs actually in scope are recorded, so a per-host artifact never advertises a sibling's
872
+ * packages. A ref no contribution covers is simply absent: the host then resolves it from the
873
+ * engine's on-demand map, and the single fail-loud refusal in the backend registry names it if that
874
+ * map does not hold it either.
875
+ *
876
+ * When several contributions claim one ref with DIFFERENT import paths, the sorted-first path wins
877
+ * — deterministically, so the artifact does not churn. Divergence is possible today only between an
878
+ * application's hand-authored engine projection (`@wildo-ai/saas-backend-lib`) and the engine's own
879
+ * companion export, and neither is consulted for an engine-shipped ref, so the choice cannot change
880
+ * which module a host loads. A package provider is contributed by exactly one package.
881
+ */
882
+ function buildProviderRuntimeImports(providerRefs, contributions) {
883
+ const inScope = new Set(providerRefs);
884
+ const candidatesByRef = new Map();
885
+ for (const contribution of contributions) {
886
+ if (!inScope.has(contribution.ref)) {
887
+ continue;
888
+ }
889
+ const candidates = candidatesByRef.get(contribution.ref) ?? new Set();
890
+ candidates.add(contribution.runtimeImportPath);
891
+ candidatesByRef.set(contribution.ref, candidates);
892
+ }
893
+ return Object.fromEntries([...candidatesByRef.entries()]
894
+ .sort(([left], [right]) => left.localeCompare(right))
895
+ .map(([ref, candidates]) => [ref, [...candidates].sort()[0]]));
896
+ }
777
897
  function findMatchingDiscoveredContributions(input) {
778
898
  return input.discoveredContributions.flatMap((contribution) => {
779
899
  if (input.providerRef && contribution.ref !== input.providerRef) {