@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/auth.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"auth.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/auth.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,YAAY,CAAC;IAClD;;;;;;;;;OASG;IACH,4BAA4B,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACrE;;;;;;OAMG;IACH,0BAA0B,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CACpE,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\n\n/**\n * Authored JWT TTL policy block for `wildo.infra.<env>.config.ts`.\n *\n * Source-of-truth contract (Slice 3.3, F-24):\n * - `accessTokenExpirationMinutes` and `refreshTokenExpirationDays` are\n * threaded by the CLI through the apps-manager init endpoint\n * (`AdminAppInitializeRequest.serviceAuth`) into\n * `Wildo_Application_Config.jwt.{accessTokenExpirationMinutes,\n * refreshTokenExpirationDays}`. The runtime backend reads them at\n * token-sign time (`auth-token-issuer.backend.service.ts`,\n * `jwt.backend.service.ts`).\n * - First registration uses the schema defaults when `serviceAuth` is absent. Ordinary\n * re-registration preserves the stored policy when the whole block is omitted. A present\n * block resolves omitted members through these defaults and reconciles both lifetimes.\n *\n * Default tightening (Auth-hardening Slice A Step 5, 2026-04-13):\n * - `accessTokenExpirationMinutes` default was lowered from 60 \\u2192 15 in\n * conjunction with the cookie migration (Slice A Steps 2 + 3). With the\n * refresh token now confined to an `HttpOnly` cookie, an XSS bug only\n * exposes the SHORT-lived access token; the smaller the access-token\n * window, the smaller the residual XSS-stolen-token blast radius.\n * Operator overrides via `serviceAuth.accessTokenExpirationMinutes` in\n * `wildo.infra.<env>.config.ts` are untouched \\u2014 author a value to\n * deviate from the framework recommendation. The refresh-token TTL\n * (`refreshTokenExpirationDays`) is unchanged at 30 days because the\n * cookie-confined refresh token does not benefit from an additional\n * TTL squeeze (rotation + JTI blacklist + reuse detection already bound\n * the steal window per use).\n *\n * Algorithm selection is intentionally NOT authored here: the application\n * JWT signing path (`jwt.backend.service.ts`) selects per the per-service\n * key convention, and the apps-manager response-signer pins ES256 for the\n * config-handshake envelope (anti-replay, see F-55 JSDoc on\n * `platform-services-to-manager.apps-manager.platform.controller.ts`).\n * Authoring an algorithm here would add a knob with no honest consumer.\n *\n * Publication lifecycle:\n * - The CLI forwards `env.serviceAuth` through the admin initialization request. Existing\n * applications reconcile an explicitly supplied policy even when no other settings changed;\n * no broad initialization override is required for a token-lifetime-only change.\n * - Ordinary initialization with an omitted block preserves existing lifetimes, including\n * incidental public-key/database repairs. Explicit `override:true` retains its wider reset\n * semantics: absent `serviceAuth` resets lifetimes to the schema defaults below.\n * - Applications retrieve the persisted policy at startup. Running processes do not receive\n * live policy updates, and existing tokens retain the expiration already encoded in them.\n *\n * Pinned by `managed-token-policy-convergence.apps-manager.platform.test.ts` and the lifecycle\n * default derivation tests; the former exercises persistence and the bootstrap consumer offline.\n */\n/**\n * `z.strictObject` (Zod 4) is intentional: any unknown key (e.g. a\n * re-introduced `jwtAlgorithm`, or a typo'd `accessTokenExpirationMinute`)\n * must surface as a parse error instead of being silently stripped. This\n * is the framework-mindset enforcement of the \"no honest consumer => no\n * authored knob\" rule documented in the file-level JSDoc above.\n */\nexport const WildoAuthConfigSchema = z.strictObject({\n /**\n * Access-token TTL in minutes. Authored value > schema default (15).\n * Threaded into `Wildo_Application_Config.jwt.accessTokenExpiration\n * Minutes` at apps-manager init time; consumed at token-sign time by\n * `AuthTokenIssuerBackendService.issueAccessToken`.\n *\n * Default = 15 (Auth-hardening Slice A Step 5, 2026-04-13). Pre-Slice-A\n * the default was 60 \\u2014 the file-level JSDoc above documents the\n * threat-model rationale for the tightening.\n */\n accessTokenExpirationMinutes: z.number().int().positive().default(15),\n /**\n * Refresh-token TTL in days. Authored value > schema default (30).\n * Threaded into `Wildo_Application_Config.jwt.refreshTokenExpiration\n * Days` at apps-manager init time; consumed at token-sign time by\n * `JwtBackendService.createRefreshToken` and at session-bookkeeping\n * time by `AuthTokenIssuerBackendService.invalidateAllTokensForUser`.\n */\n refreshTokenExpirationDays: z.number().int().positive().default(30),\n});\nexport type WildoAuthConfig = z.infer<typeof WildoAuthConfigSchema>;\nexport type WildoAuthConfigInput = z.input<typeof WildoAuthConfigSchema>;\n"]}
|
|
@@ -260,6 +260,7 @@ export declare const BackingServicesEnvConfigSchema: z.ZodObject<{
|
|
|
260
260
|
}, z.core.$strict>;
|
|
261
261
|
export type BackingServicesEnvConfig = z.infer<typeof BackingServicesEnvConfigSchema>;
|
|
262
262
|
/** @wildo_source:part:end platform.config.backing-services */
|
|
263
|
+
/** @wildo_source:part:start platform.config.infra-provider-resolution facet:layer:platform facet:audience:app-developer */
|
|
263
264
|
/**
|
|
264
265
|
* `BackingServiceKind` → `InfraCapability`. Every extension to `BackingServiceKind` MUST extend this
|
|
265
266
|
* map in the same commit, otherwise the planner cannot project the new kind to its capability slot.
|
|
@@ -290,20 +291,49 @@ export declare const BackingServiceKindToInfraCapability: Record<BackingServiceK
|
|
|
290
291
|
* | `POSTGRESQL` | `MANAGED` | `'supabase'` | `POSTGRES_SUPABASE` |
|
|
291
292
|
* | `POSTGRESQL` | `MANAGED` | `'neon'` | `POSTGRES_NEON` |
|
|
292
293
|
* | `POSTGRESQL` | `MANAGED` | `'render'` | `POSTGRES_RENDER` |
|
|
293
|
-
* | `POSTGRESQL` | `MANAGED` |
|
|
294
|
+
* | `POSTGRESQL` | `MANAGED` | unset or unrecognized | `POSTGRES_MANAGED` (generic fallback) |
|
|
294
295
|
* | `REDIS` | `SELF` | (any) | `REDIS_SELF` |
|
|
295
296
|
* | `RABBITMQ` | `SELF` | (any) | `RABBITMQ_SELF` |
|
|
296
|
-
* | `S3` |
|
|
297
|
-
* | `S3` |
|
|
297
|
+
* | `S3` | (either) | `'minio'` | `MINIO_SELF` |
|
|
298
|
+
* | `S3` | (either) | `'aws'` | `AWS_S3` |
|
|
299
|
+
* | `S3` | `SELF` | unset or unrecognized | `MINIO_SELF` |
|
|
300
|
+
* | `S3` | `MANAGED` | unset or unrecognized | `AWS_S3` |
|
|
298
301
|
* | `CLAMAV` | `SELF` | (any) | `CLAMAV_SELF` |
|
|
302
|
+
* | `IMMUDB` | `SELF` | (any) | `IMMUDB_SELF` |
|
|
299
303
|
*
|
|
300
304
|
* Returns `undefined` for combinations not in the table — for kinds
|
|
301
|
-
* whose `InfraProvider` catalog has no concrete entry yet (
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* unlike Postgres). Callers decide whether `undefined` is fail-closed
|
|
305
|
+
* whose `InfraProvider` catalog has no concrete entry yet (BACKUP)
|
|
306
|
+
* and for unrecognized managed Mongo brands. PostgreSQL has a generic
|
|
307
|
+
* managed fallback; S3 uses brand-first resolution, then source-based defaults. Callers decide whether `undefined` is fail-closed
|
|
305
308
|
* (planner running with unknown infra catalog) or accepted (lockfile
|
|
306
309
|
* pre-declaration).
|
|
310
|
+
*
|
|
311
|
+
* ## What this means when you author an environment
|
|
312
|
+
*
|
|
313
|
+
* **`MANAGED` does not reach every kind.** The table above is the whole of it: a managed vendor
|
|
314
|
+
* resolves for the relational database (six named brands plus a generic fallback), the document
|
|
315
|
+
* database (`'atlas'` only) and object storage. Declaring `{ source: MANAGED }` on the cache, the
|
|
316
|
+
* broker, the antivirus scanner, the audit store or the backup target resolves to NOTHING — those
|
|
317
|
+
* kinds are self-hosted only until their vendor catalogue is built.
|
|
318
|
+
*
|
|
319
|
+
* **And nothing tells you.** A kind that resolves to no provider is SKIPPED when the lockfile's infra
|
|
320
|
+
* section is materialised, silently, because recording an entry with no provider would lie. So a
|
|
321
|
+
* managed declaration the catalogue cannot serve looks exactly like a correct one: `wildo config
|
|
322
|
+
* sync` succeeds, the file says `MANAGED`, and the environment has no managed anything. Read the
|
|
323
|
+
* lockfile's infra section to see which of your declarations were actually resolved.
|
|
324
|
+
*
|
|
325
|
+
* **An unrecognised brand is not the same failure on every kind.** On the relational database it
|
|
326
|
+
* falls back to the generic managed entry, so a typo still resolves. On the document database,
|
|
327
|
+
* an unknown managed brand resolves to nothing. Object storage recognizes minio/aws first, then
|
|
328
|
+
* falls back by source: SELF to MinIO, MANAGED to AWS S3, including unrecognized brands.
|
|
329
|
+
*
|
|
330
|
+
* **Provider resolution and workload inclusion answer different questions.** Compose and Kubernetes
|
|
331
|
+
* both use the same per-kind inclusion policy, separately from catalogue resolution. Cache, broker
|
|
332
|
+
* and S3 default to self-hosted unless explicitly MANAGED; ClamAV and immudb require explicit SELF.
|
|
333
|
+
* MongoDB and PostgreSQL also include the platform database requirement: an application-level
|
|
334
|
+
* managed choice does not remove a self-hosted database still needed by the platform. Backup has
|
|
335
|
+
* no rendered workload. Do not infer workload inclusion from this provider resolver.
|
|
307
336
|
*/
|
|
308
337
|
export declare function resolveInfraProvider(kind: BackingServiceKind, source: BackingServiceSource, provider?: string): InfraProvider | undefined;
|
|
338
|
+
/** @wildo_source:part:end platform.config.infra-provider-resolution */
|
|
309
339
|
//# sourceMappingURL=backing-services.schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backing-services.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/backing-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,eAAe,EACf,aAAa,EACd,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,EAAE,OAAO;IACT,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB;;;;OAIG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,MAAM,WAAW;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,oBAAY,oBAAoB;IAC9B,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAuDD;;;;;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/B,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,oBAAoB,GACpB,gBAAgB,GAChB,oBAAoB,GACpB,oBAAoB,GACpB,oBAAoB,CAAC;AAEzB;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAShC,CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,8DAA8D;AAe9D;;;;;;;GAOG;AACH,eAAO,MAAM,mCAAmC,EAAE,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAS3F,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"backing-services.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/backing-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,eAAe,EACf,aAAa,EACd,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AACH,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,EAAE,OAAO;IACT,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB;;;;OAIG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,MAAM,WAAW;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,oBAAY,oBAAoB;IAC9B,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAuDD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB;;;;;;kBAE3B,CAAC;AACZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB;;;;;;kBAE3B,CAAC;AACZ,MAAM,MAAM,mBAAmB,GAAG,CA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CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,8DAA8D;AAe9D,2HAA2H;AAC3H;;;;;;;GAOG;AACH,eAAO,MAAM,mCAAmC,EAAE,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAS3F,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,oBAAoB,EAC5B,QAAQ,CAAC,EAAE,MAAM,GAChB,aAAa,GAAG,SAAS,CAsE3B;AACD,uEAAuE"}
|
|
@@ -228,6 +228,7 @@ export const BackingServicesEnvConfigSchema = z.object({
|
|
|
228
228
|
// walks "what infra is selected per env"). The mappings below are the
|
|
229
229
|
// single source of truth for that projection — no other code may
|
|
230
230
|
// reconstruct them locally.
|
|
231
|
+
/** @wildo_source:part:start platform.config.infra-provider-resolution facet:layer:platform facet:audience:app-developer */
|
|
231
232
|
/**
|
|
232
233
|
* `BackingServiceKind` → `InfraCapability`. Every extension to `BackingServiceKind` MUST extend this
|
|
233
234
|
* map in the same commit, otherwise the planner cannot project the new kind to its capability slot.
|
|
@@ -267,20 +268,48 @@ export const BackingServiceKindToInfraCapability = {
|
|
|
267
268
|
* | `POSTGRESQL` | `MANAGED` | `'supabase'` | `POSTGRES_SUPABASE` |
|
|
268
269
|
* | `POSTGRESQL` | `MANAGED` | `'neon'` | `POSTGRES_NEON` |
|
|
269
270
|
* | `POSTGRESQL` | `MANAGED` | `'render'` | `POSTGRES_RENDER` |
|
|
270
|
-
* | `POSTGRESQL` | `MANAGED` |
|
|
271
|
+
* | `POSTGRESQL` | `MANAGED` | unset or unrecognized | `POSTGRES_MANAGED` (generic fallback) |
|
|
271
272
|
* | `REDIS` | `SELF` | (any) | `REDIS_SELF` |
|
|
272
273
|
* | `RABBITMQ` | `SELF` | (any) | `RABBITMQ_SELF` |
|
|
273
|
-
* | `S3` |
|
|
274
|
-
* | `S3` |
|
|
274
|
+
* | `S3` | (either) | `'minio'` | `MINIO_SELF` |
|
|
275
|
+
* | `S3` | (either) | `'aws'` | `AWS_S3` |
|
|
276
|
+
* | `S3` | `SELF` | unset or unrecognized | `MINIO_SELF` |
|
|
277
|
+
* | `S3` | `MANAGED` | unset or unrecognized | `AWS_S3` |
|
|
275
278
|
* | `CLAMAV` | `SELF` | (any) | `CLAMAV_SELF` |
|
|
279
|
+
* | `IMMUDB` | `SELF` | (any) | `IMMUDB_SELF` |
|
|
276
280
|
*
|
|
277
281
|
* Returns `undefined` for combinations not in the table — for kinds
|
|
278
|
-
* whose `InfraProvider` catalog has no concrete entry yet (
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
* unlike Postgres). Callers decide whether `undefined` is fail-closed
|
|
282
|
+
* whose `InfraProvider` catalog has no concrete entry yet (BACKUP)
|
|
283
|
+
* and for unrecognized managed Mongo brands. PostgreSQL has a generic
|
|
284
|
+
* managed fallback; S3 uses brand-first resolution, then source-based defaults. Callers decide whether `undefined` is fail-closed
|
|
282
285
|
* (planner running with unknown infra catalog) or accepted (lockfile
|
|
283
286
|
* pre-declaration).
|
|
287
|
+
*
|
|
288
|
+
* ## What this means when you author an environment
|
|
289
|
+
*
|
|
290
|
+
* **`MANAGED` does not reach every kind.** The table above is the whole of it: a managed vendor
|
|
291
|
+
* resolves for the relational database (six named brands plus a generic fallback), the document
|
|
292
|
+
* database (`'atlas'` only) and object storage. Declaring `{ source: MANAGED }` on the cache, the
|
|
293
|
+
* broker, the antivirus scanner, the audit store or the backup target resolves to NOTHING — those
|
|
294
|
+
* kinds are self-hosted only until their vendor catalogue is built.
|
|
295
|
+
*
|
|
296
|
+
* **And nothing tells you.** A kind that resolves to no provider is SKIPPED when the lockfile's infra
|
|
297
|
+
* section is materialised, silently, because recording an entry with no provider would lie. So a
|
|
298
|
+
* managed declaration the catalogue cannot serve looks exactly like a correct one: `wildo config
|
|
299
|
+
* sync` succeeds, the file says `MANAGED`, and the environment has no managed anything. Read the
|
|
300
|
+
* lockfile's infra section to see which of your declarations were actually resolved.
|
|
301
|
+
*
|
|
302
|
+
* **An unrecognised brand is not the same failure on every kind.** On the relational database it
|
|
303
|
+
* falls back to the generic managed entry, so a typo still resolves. On the document database,
|
|
304
|
+
* an unknown managed brand resolves to nothing. Object storage recognizes minio/aws first, then
|
|
305
|
+
* falls back by source: SELF to MinIO, MANAGED to AWS S3, including unrecognized brands.
|
|
306
|
+
*
|
|
307
|
+
* **Provider resolution and workload inclusion answer different questions.** Compose and Kubernetes
|
|
308
|
+
* both use the same per-kind inclusion policy, separately from catalogue resolution. Cache, broker
|
|
309
|
+
* and S3 default to self-hosted unless explicitly MANAGED; ClamAV and immudb require explicit SELF.
|
|
310
|
+
* MongoDB and PostgreSQL also include the platform database requirement: an application-level
|
|
311
|
+
* managed choice does not remove a self-hosted database still needed by the platform. Backup has
|
|
312
|
+
* no rendered workload. Do not infer workload inclusion from this provider resolver.
|
|
284
313
|
*/
|
|
285
314
|
export function resolveInfraProvider(kind, source, provider) {
|
|
286
315
|
switch (kind) {
|
|
@@ -364,4 +393,5 @@ export function resolveInfraProvider(kind, source, provider) {
|
|
|
364
393
|
return undefined;
|
|
365
394
|
}
|
|
366
395
|
}
|
|
396
|
+
/** @wildo_source:part:end platform.config.infra-provider-resolution */
|
|
367
397
|
//# sourceMappingURL=backing-services.schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backing-services.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/backing-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,eAAe,EACf,aAAa,GACd,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAN,IAAY,kBAiBX;AAjBD,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C3E,OAAO,SAAS,CAAC;QACnB,KAAK,kBAAkB,CAAC,MAAM;YAC5B,IAAI,MAAM,KAAK,oBAAoB,CAAC,IAAI;gBAAE,OAAO,aAAa,CAAC,WAAW,CAAC;YAC3E,wEAAwE;YACxE,OAAO,SAAS,CAAC;QACnB,KAAK,kBAAkB,CAAC,MAAM;YAC5B,4FAA4F;YAC5F,oFAAoF;YACpF,EAAE;YACF,2FAA2F;YAC3F,0EAA0E;YAC1E,wFAAwF;YACxF,uEAAuE;YACvE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n InfraCapability,\n InfraProvider,\n} from './infra-providers.schemas';\n\n/**\n * The backing-service authoring surface of `wildo.infra.<env>.config.ts`.\n *\n * Import from `@wildo-ai/platform-config-lib`. Everything below is what an\n * environment file may declare under `backingServices: { ... }` — the closed kind\n * vocabulary, the hosting-model axis, and the per-kind entry shape. The\n * `InfraCapability` / `InfraProvider` projections further down this file are\n * planner-internal and deliberately outside the anchor: an app author never writes\n * them.\n *\n * Declare a kind ONLY when the environment actually runs it — keys are optional so a\n * flattened app declaration stays truthful about what it enables. Omitting a kind an\n * enabled engine capability depends on is the classic silent-degradation bug: e.g.\n * `COMPLIANCE_AUDIT_TRAIL` without `immudb` leaves the tamper-evident audit store\n * unbacked, which `wildo config sync` reports as a warning per environment.\n *\n * @wildo_source:part:start platform.config.backing-services facet:layer:platform facet:family:infra\n */\nexport enum BackingServiceKind {\n MONGODB = 'mongodb',\n REDIS = 'redis',\n RABBITMQ = 'rabbitmq',\n S3 = 's3',\n POSTGRESQL = 'postgresql',\n CLAMAV = 'clamav',\n /**\n * immudb — an immutable, cryptographically-verifiable database used as a\n * tamper-evident audit-log store (fills the `AUDIT_LOG_STORAGE` capability).\n * A stateful DB: a data volume in dev, self-hosted or immudb Vault in prod.\n */\n IMMUDB = 'immudb',\n /**\n * Backup orchestration target. Stateless base for now.\n */\n BACKUP = 'backup',\n}\n\n/**\n * Hosting model of a backing service instance — the orthogonal axis to\n * the **brand** (which is captured by the per-kind `provider` field).\n *\n * - `self`: self-hosted (Docker/K8s container managed by the platform,\n * or operator-managed on-prem). Brands here are open-source\n * software names (e.g. MinIO for S3, vanilla Postgres / MongoDB).\n * - `managed`: external vendor-managed service. Brands here are\n * vendor names (e.g. `'atlas'` for MongoDB Atlas, `'aws-rds'` for\n * AWS RDS, `'supabase'` for Supabase Postgres, `'aws'` for AWS S3).\n *\n * **Slice 4.B.0 reshape (2026-05-07)**: the `ATLAS` value was removed.\n * Pre-reshape `source: ATLAS` becomes `source: MANAGED, provider:\n * 'atlas'`. The reshape generalizes from \"Mongo + S3 are the only\n * brand-aware kinds\" to \"every kind can be brand-aware when the\n * managed market has multiple vendors\" — Postgres in particular\n * (RDS / GCP Cloud SQL / Supabase / Neon / Render / Azure).\n */\nexport enum BackingServiceSource {\n SELF = 'self',\n MANAGED = 'managed',\n}\n\n/**\n * Common fields every backing-service entry shares.\n *\n * Per-kind extensions add the fields that are SEMANTICALLY meaningful\n * for that kind only. Slice 3 closeout (M-4 + L-5): the previous shared\n * `BackingServiceEnvConfigSchema` collapsed `database` into a\n * `union(int, string)` and put `name` only on Mongo; both compromised\n * the framework-mindset rule that \"every field must carry its semantic\n * weight\". The split below means a typo like `redis: { database:\n * 'staging' }` (string on a kind that needs an integer DB index) is\n * rejected at parse time instead of crashing the runtime client at\n * connect time.\n */\nconst BackingServiceBaseSchema = z.object({\n source: z.enum(BackingServiceSource),\n /**\n * Brand of the backing service. Orthogonal to `source` (hosting\n * model). Required-in-spirit when `source === MANAGED` and the\n * managed market has multiple vendors (Mongo: `'atlas'` /\n * `'aws-documentdb'` / …; Postgres: `'aws-rds'` / `'gcp-cloud-sql'`\n * / `'supabase'` / `'neon'` / `'render'` / `'azure-database'`;\n * S3: `'aws'` / `'cloudflare-r2'` / …); optional when `source ===\n * SELF` (e.g. S3-self-hosted defaults to MinIO; `provider:\n * 'minio'` is allowed but redundant).\n *\n * Modeled as `z.string().optional()` rather than per-kind enum\n * unions to keep this base schema simple — the canonical brand\n * vocabulary lives in `resolveInfraProvider`'s dispatch table\n * (each kind documents which brand strings it recognizes; unknown\n * brands fall back to the kind's generic `<KIND>_MANAGED` /\n * `<KIND>_SELF` entry where one exists, otherwise return\n * `undefined`).\n *\n * Slice 4.B.0 (2026-05-07) generalized this from \"S3-only\" to\n * every brand-aware kind.\n */\n provider: z.string().min(1).optional(),\n /**\n * Override the catalog-derived hostname for this kind. Honored at\n * `HOST_FACING` perspective (always) and at `CONTAINER_INTERNAL` for\n * `MANAGED` sources. SELF + `CONTAINER_INTERNAL` keeps the catalog\n * container name because that is the only DNS the container network\n * can resolve.\n */\n host: z.string().min(1).optional(),\n /**\n * Override the catalog-derived listen port. Threaded into both\n * docker-compose `<authored>:<authored>` publish and the per-app\n * env-vars (`<KIND>_PORT`).\n */\n port: z.number().int().positive().optional(),\n}).strict();\n\n/**\n * MongoDB backing service. `database` is the database NAME (string).\n *\n * Mongo's connection URL has the shape `mongodb://host:port/<database>`\n * — this string corresponds to the path segment. Pre-3 the field was\n * `name`; renamed to `database` in Slice 3 closeout (L-5) so all\n * data-store kinds use the same property name for the same concept\n * (vs. Postgres which already used `database`).\n */\nexport const MongoBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.string().min(1).optional(),\n}).strict();\nexport type MongoBackingService = z.infer<typeof MongoBackingServiceSchema>;\n\n/**\n * Redis backing service. `database` is the LOGICAL DB INDEX (integer).\n *\n * Redis exposes 16 logical databases (0–15) on a single connection.\n * Authoring a string here (e.g. `'staging'`) would silently parse on\n * the pre-3 union schema and crash ioredis at connect; the integer\n * constraint with `max(15)` fails loud at parse time.\n */\nexport const RedisBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.number().int().min(0).max(15).optional(),\n}).strict();\nexport type RedisBackingService = z.infer<typeof RedisBackingServiceSchema>;\n\n/**\n * PostgreSQL backing service. `database` is the database NAME (string).\n *\n * Symmetric with `MongoBackingService.database` — both are the\n * database identifier in their respective connection URLs.\n */\nexport const PostgresBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.string().min(1).optional(),\n}).strict();\nexport type PostgresBackingService = z.infer<typeof PostgresBackingServiceSchema>;\n\n/**\n * RabbitMQ backing service. `vhost` is the RabbitMQ virtual host.\n *\n * AMQP virtual hosts isolate exchange/queue namespaces inside a single\n * broker. NOT a database — RabbitMQ has no DB concept — so the field\n * is intentionally NOT named `database`.\n */\nexport const RabbitBackingServiceSchema = BackingServiceBaseSchema.extend({\n vhost: z.string().min(1).optional(),\n}).strict();\nexport type RabbitBackingService = z.infer<typeof RabbitBackingServiceSchema>;\n\n/**\n * S3-compatible backing service (MinIO, Scaleway Object Storage, AWS).\n *\n * `endpoint` is a URL (`http://localhost:9000`, `https://s3.eu-west.amazonaws.com`)\n * — the resolver parses it into host/port. `bucket` is the S3 bucket\n * name. NOT a database — S3 has no DB concept.\n */\nexport const S3BackingServiceSchema = BackingServiceBaseSchema.extend({\n endpoint: z.string().min(1).optional(),\n bucket: z.string().min(1).optional(),\n}).strict();\nexport type S3BackingService = z.infer<typeof S3BackingServiceSchema>;\n\n/** ClamAV anti-virus daemon. Stateless, no database/vhost/bucket. */\nexport const ClamAvBackingServiceSchema = BackingServiceBaseSchema;\nexport type ClamAvBackingService = z.infer<typeof ClamAvBackingServiceSchema>;\n\n/**\n * immudb backing service (tamper-evident audit-log store). A stateful DB —\n * `database` names the immudb database (defaults to `defaultdb` at runtime);\n * credentials come from the secrets pipeline like every other backing service.\n *\n * Declare this in EVERY environment where the `COMPLIANCE_AUDIT_TRAIL` engine\n * capability is enabled. `wildo config sync` warns per environment when the audit\n * capability is on but no environment declares an audit store, and the audit client\n * then has nowhere tamper-evident to write.\n *\n * You do NOT author the state-signing keypair that makes the store's\n * whole-server-substitution defense work. The framework provisions it (private half\n * mounted into a `source: SELF` immudb via `--signingKey`, public half pinned by the\n * audit client as `IMMUDB_STATE_PUBLIC_KEY`) — declaring the service is the whole job.\n *\n * @example\n * ```ts\n * backingServices: {\n * immudb: { source: BackingServiceSource.SELF },\n * }\n * ```\n */\nexport const ImmudbBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.string().min(1).optional(),\n}).strict();\nexport type ImmudbBackingService = z.infer<typeof ImmudbBackingServiceSchema>;\n\n/**\n * Backup orchestration target. Stateless base for now.\n */\nexport const BackupBackingServiceSchema = BackingServiceBaseSchema;\nexport type BackupBackingService = z.infer<typeof BackupBackingServiceSchema>;\n\n/**\n * Discriminated UNION over all backing-service kinds. Used by the\n * `ServiceAddressResolver` and helpers that accept any kind and read\n * only base fields (`source`, `host`, `port`). Consumers that need\n * kind-specific fields MUST narrow first (e.g. via the per-kind type\n * exports above).\n */\nexport type BackingServiceEnvConfig =\n | MongoBackingService\n | RedisBackingService\n | PostgresBackingService\n | RabbitBackingService\n | S3BackingService\n | ClamAvBackingService\n | ImmudbBackingService\n | BackupBackingService;\n\n/**\n * Per-environment backing services config (source for each service).\n * Used in environment-specific infra descriptors.\n *\n * Keys stay optional because an app-owned environment only needs to declare the\n * backing services it actually enables. Requiring the full enum-keyed record\n * would force disabled services (for example `postgresql`) into every env file\n * and breaks truthful flattened targeted-app declarations.\n */\nexport const BackingServicesEnvConfigSchema = z.object({\n [BackingServiceKind.MONGODB]: MongoBackingServiceSchema.optional(),\n [BackingServiceKind.REDIS]: RedisBackingServiceSchema.optional(),\n [BackingServiceKind.RABBITMQ]: RabbitBackingServiceSchema.optional(),\n [BackingServiceKind.S3]: S3BackingServiceSchema.optional(),\n [BackingServiceKind.POSTGRESQL]: PostgresBackingServiceSchema.optional(),\n [BackingServiceKind.CLAMAV]: ClamAvBackingServiceSchema.optional(),\n [BackingServiceKind.IMMUDB]: ImmudbBackingServiceSchema.optional(),\n [BackingServiceKind.BACKUP]: BackupBackingServiceSchema.optional(),\n}).strict();\nexport type BackingServicesEnvConfig = z.infer<typeof BackingServicesEnvConfigSchema>;\n/** @wildo_source:part:end platform.config.backing-services */\n\n// =============================================================================\n// BackingServiceKind ↔ InfraCapability / InfraProvider projections\n// =============================================================================\n//\n// Per `infra-provider-planner.md` R-B (locked 2026-05-06): `BackingServicesEnvConfig`\n// IS the canonical per-env infra-selection authoring surface. The\n// `InfraCapability` / `InfraProvider` enums are the planner's projection\n// vocabulary (used by `InfraProviderModule.supportedCapabilities`,\n// `wildo-saas.lock.json sections.infra` keying, and any tooling that\n// walks \"what infra is selected per env\"). The mappings below are the\n// single source of truth for that projection — no other code may\n// reconstruct them locally.\n\n/**\n * `BackingServiceKind` → `InfraCapability`. Every extension to `BackingServiceKind` MUST extend this\n * map in the same commit, otherwise the planner cannot project the new kind to its capability slot.\n *\n * INJECTIVE, not bijective — and the difference is a real property of the model rather than a gap.\n * A capability may be granted to a runtime without any environment declaring a backing service for\n * it; see {@link RUNTIME_GRANTED_INFRA_CAPABILITIES} for the ones that are, and why.\n */\nexport const BackingServiceKindToInfraCapability: Record<BackingServiceKind, InfraCapability> = {\n [BackingServiceKind.MONGODB]: InfraCapability.DOCUMENT_DATABASE,\n [BackingServiceKind.POSTGRESQL]: InfraCapability.RELATIONAL_DATABASE,\n [BackingServiceKind.RABBITMQ]: InfraCapability.QUEUING_SYSTEM,\n [BackingServiceKind.REDIS]: InfraCapability.CACHE_MANAGER,\n [BackingServiceKind.S3]: InfraCapability.OBJECT_STORAGE,\n [BackingServiceKind.CLAMAV]: InfraCapability.ANTIVIRUS_SCANNING,\n [BackingServiceKind.IMMUDB]: InfraCapability.AUDIT_LOG_STORAGE,\n [BackingServiceKind.BACKUP]: InfraCapability.BACKUP_MANAGER,\n};\n\n/**\n * Project `(BackingServiceKind, source, provider?)` → `InfraProvider`.\n *\n * The three-axis dispatch (kind × hosting-model × brand) generalizes\n * the source/brand split across all kinds (Slice 4.B.0, 2026-05-07\n * — was source-only with Atlas as a special source value before).\n *\n * **Brand vocabulary** per kind (`provider` field on the authored\n * `BackingService<X>Schema`):\n *\n * | Kind | source | provider | InfraProvider |\n * |---|---|---|---|\n * | `MONGODB` | `SELF` | (any) | `MONGODB_SELF` |\n * | `MONGODB` | `MANAGED` | `'atlas'` | `MONGODB_ATLAS` |\n * | `POSTGRESQL` | `SELF` | (any) | `POSTGRES_SELF` |\n * | `POSTGRESQL` | `MANAGED` | `'aws-rds'` | `POSTGRES_AWS_RDS` |\n * | `POSTGRESQL` | `MANAGED` | `'gcp-cloud-sql'` | `POSTGRES_GCP_CLOUD_SQL` |\n * | `POSTGRESQL` | `MANAGED` | `'azure-database'` | `POSTGRES_AZURE_DATABASE` |\n * | `POSTGRESQL` | `MANAGED` | `'supabase'` | `POSTGRES_SUPABASE` |\n * | `POSTGRESQL` | `MANAGED` | `'neon'` | `POSTGRES_NEON` |\n * | `POSTGRESQL` | `MANAGED` | `'render'` | `POSTGRES_RENDER` |\n * | `POSTGRESQL` | `MANAGED` | (unset) | `POSTGRES_MANAGED` (generic fallback) |\n * | `REDIS` | `SELF` | (any) | `REDIS_SELF` |\n * | `RABBITMQ` | `SELF` | (any) | `RABBITMQ_SELF` |\n * | `S3` | `SELF` | (`'minio'` or unset) | `MINIO_SELF` |\n * | `S3` | `MANAGED` | `'aws'` | `AWS_S3` |\n * | `CLAMAV` | `SELF` | (any) | `CLAMAV_SELF` |\n *\n * Returns `undefined` for combinations not in the table — for kinds\n * whose `InfraProvider` catalog has no concrete entry yet (METRICS,\n * BACKUP) and for unrecognized brand strings on managed\n * Mongo / S3 (they don't have a generic `<KIND>_MANAGED` fallback,\n * unlike Postgres). Callers decide whether `undefined` is fail-closed\n * (planner running with unknown infra catalog) or accepted (lockfile\n * pre-declaration).\n */\nexport function resolveInfraProvider(\n kind: BackingServiceKind,\n source: BackingServiceSource,\n provider?: string,\n): InfraProvider | undefined {\n switch (kind) {\n case BackingServiceKind.MONGODB:\n if (source === BackingServiceSource.SELF) return InfraProvider.MONGODB_SELF;\n if (source === BackingServiceSource.MANAGED && provider === 'atlas') return InfraProvider.MONGODB_ATLAS;\n // Other Mongo managed brands (e.g., AWS DocumentDB) — extend\n // the `InfraProvider` enum + this branch in the same slice\n // that adds the first concrete consumer.\n return undefined;\n case BackingServiceKind.POSTGRESQL:\n if (source === BackingServiceSource.SELF) return InfraProvider.POSTGRES_SELF;\n if (source === BackingServiceSource.MANAGED) {\n switch (provider) {\n case 'aws-rds': return InfraProvider.POSTGRES_AWS_RDS;\n case 'gcp-cloud-sql': return InfraProvider.POSTGRES_GCP_CLOUD_SQL;\n case 'azure-database': return InfraProvider.POSTGRES_AZURE_DATABASE;\n case 'supabase': return InfraProvider.POSTGRES_SUPABASE;\n case 'neon': return InfraProvider.POSTGRES_NEON;\n case 'render': return InfraProvider.POSTGRES_RENDER;\n // Generic fallback when the operator has authored\n // `source: MANAGED` without naming a brand (or with an\n // unrecognized brand). Acceptable while the brand catalog\n // is incomplete — the lockfile records `POSTGRES_MANAGED`\n // and the planner can still emit env vars + compose\n // contributions; brand-specific runtime behavior is what\n // the named-brand modules (Slice 4.B+) layer on top.\n default: return InfraProvider.POSTGRES_MANAGED;\n }\n }\n return undefined;\n case BackingServiceKind.REDIS:\n if (source === BackingServiceSource.SELF) return InfraProvider.REDIS_SELF;\n // Managed Redis brands (ElastiCache, Upstash, Redis Cloud, …)\n // — not catalogued yet; future expansion.\n return undefined;\n case BackingServiceKind.RABBITMQ:\n if (source === BackingServiceSource.SELF) return InfraProvider.RABBITMQ_SELF;\n // Managed RabbitMQ brands (CloudAMQP, AWS MQ, …) —\n // not catalogued yet; future expansion.\n return undefined;\n case BackingServiceKind.S3:\n // S3 dispatch is brand-first because the protocol is\n // standardized (S3-compatible) and the same `source` can host\n // multiple software stacks — `source: SELF` could be MinIO or\n // a self-managed AWS S3 cluster (theoretically). The brand is\n // the canonical disambiguator.\n if (provider === 'minio') return InfraProvider.MINIO_SELF;\n if (provider === 'aws') return InfraProvider.AWS_S3;\n // Default source-based mapping for unbranded S3 — MinIO is\n // the canonical self-hosted; AWS is the canonical managed.\n if (source === BackingServiceSource.SELF) return InfraProvider.MINIO_SELF;\n if (source === BackingServiceSource.MANAGED) return InfraProvider.AWS_S3;\n return undefined;\n case BackingServiceKind.CLAMAV:\n if (source === BackingServiceSource.SELF) return InfraProvider.CLAMAV_SELF;\n return undefined;\n case BackingServiceKind.IMMUDB:\n if (source === BackingServiceSource.SELF) return InfraProvider.IMMUDB_SELF;\n // Managed immudb (immudb Vault) — not catalogued yet; future expansion.\n return undefined;\n case BackingServiceKind.BACKUP:\n // No concrete `InfraProvider` declared yet for this kind. Extend the `InfraProvider` enum +\n // this branch in the same slice that introduces the first concrete provider for it.\n //\n // `METRICS` was the other kind here and was WITHDRAWN 2026-09-09: telemetry is authored at\n // `observability.telemetry` and its auth header derived from the selected\n // `OBSERVABILITY_TELEMETRY` provider, so a backing-service kind was a third declaration\n // surface that nothing read. See `RUNTIME_GRANTED_INFRA_CAPABILITIES`.\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"backing-services.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/backing-services.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,eAAe,EACf,aAAa,GACd,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAN,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,qCAAe,CAAA;IACf,2CAAqB,CAAA;IACrB,+BAAS,CAAA;IACT,+CAAyB,CAAA;IACzB,uCAAiB,CAAA;IACjB;;;;OAIG;IACH,uCAAiB,CAAA;IACjB;;OAEG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAjBW,kBAAkB,KAAlB,kBAAkB,QAiB7B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,2CAAmB,CAAA;AACrB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B;AA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cesContent":["import { z } from 'zod';\nimport {\n InfraCapability,\n InfraProvider,\n} from './infra-providers.schemas';\n\n/**\n * The backing-service authoring surface of `wildo.infra.<env>.config.ts`.\n *\n * Import from `@wildo-ai/platform-config-lib`. Everything below is what an\n * environment file may declare under `backingServices: { ... }` — the closed kind\n * vocabulary, the hosting-model axis, and the per-kind entry shape. The\n * `InfraCapability` / `InfraProvider` projections further down this file are\n * planner-internal and deliberately outside the anchor: an app author never writes\n * them.\n *\n * Declare a kind ONLY when the environment actually runs it — keys are optional so a\n * flattened app declaration stays truthful about what it enables. Omitting a kind an\n * enabled engine capability depends on is the classic silent-degradation bug: e.g.\n * `COMPLIANCE_AUDIT_TRAIL` without `immudb` leaves the tamper-evident audit store\n * unbacked, which `wildo config sync` reports as a warning per environment.\n *\n * @wildo_source:part:start platform.config.backing-services facet:layer:platform facet:family:infra\n */\nexport enum BackingServiceKind {\n MONGODB = 'mongodb',\n REDIS = 'redis',\n RABBITMQ = 'rabbitmq',\n S3 = 's3',\n POSTGRESQL = 'postgresql',\n CLAMAV = 'clamav',\n /**\n * immudb — an immutable, cryptographically-verifiable database used as a\n * tamper-evident audit-log store (fills the `AUDIT_LOG_STORAGE` capability).\n * A stateful DB: a data volume in dev, self-hosted or immudb Vault in prod.\n */\n IMMUDB = 'immudb',\n /**\n * Backup orchestration target. Stateless base for now.\n */\n BACKUP = 'backup',\n}\n\n/**\n * Hosting model of a backing service instance — the orthogonal axis to\n * the **brand** (which is captured by the per-kind `provider` field).\n *\n * - `self`: self-hosted (Docker/K8s container managed by the platform,\n * or operator-managed on-prem). Brands here are open-source\n * software names (e.g. MinIO for S3, vanilla Postgres / MongoDB).\n * - `managed`: external vendor-managed service. Brands here are\n * vendor names (e.g. `'atlas'` for MongoDB Atlas, `'aws-rds'` for\n * AWS RDS, `'supabase'` for Supabase Postgres, `'aws'` for AWS S3).\n *\n * **Slice 4.B.0 reshape (2026-05-07)**: the `ATLAS` value was removed.\n * Pre-reshape `source: ATLAS` becomes `source: MANAGED, provider:\n * 'atlas'`. The reshape generalizes from \"Mongo + S3 are the only\n * brand-aware kinds\" to \"every kind can be brand-aware when the\n * managed market has multiple vendors\" — Postgres in particular\n * (RDS / GCP Cloud SQL / Supabase / Neon / Render / Azure).\n */\nexport enum BackingServiceSource {\n SELF = 'self',\n MANAGED = 'managed',\n}\n\n/**\n * Common fields every backing-service entry shares.\n *\n * Per-kind extensions add the fields that are SEMANTICALLY meaningful\n * for that kind only. Slice 3 closeout (M-4 + L-5): the previous shared\n * `BackingServiceEnvConfigSchema` collapsed `database` into a\n * `union(int, string)` and put `name` only on Mongo; both compromised\n * the framework-mindset rule that \"every field must carry its semantic\n * weight\". The split below means a typo like `redis: { database:\n * 'staging' }` (string on a kind that needs an integer DB index) is\n * rejected at parse time instead of crashing the runtime client at\n * connect time.\n */\nconst BackingServiceBaseSchema = z.object({\n source: z.enum(BackingServiceSource),\n /**\n * Brand of the backing service. Orthogonal to `source` (hosting\n * model). Required-in-spirit when `source === MANAGED` and the\n * managed market has multiple vendors (Mongo: `'atlas'` /\n * `'aws-documentdb'` / …; Postgres: `'aws-rds'` / `'gcp-cloud-sql'`\n * / `'supabase'` / `'neon'` / `'render'` / `'azure-database'`;\n * S3: `'aws'` / `'cloudflare-r2'` / …); optional when `source ===\n * SELF` (e.g. S3-self-hosted defaults to MinIO; `provider:\n * 'minio'` is allowed but redundant).\n *\n * Modeled as `z.string().optional()` rather than per-kind enum\n * unions to keep this base schema simple — the canonical brand\n * vocabulary lives in `resolveInfraProvider`'s dispatch table\n * (each kind documents which brand strings it recognizes; unknown\n * brands fall back to the kind's generic `<KIND>_MANAGED` /\n * `<KIND>_SELF` entry where one exists, otherwise return\n * `undefined`).\n *\n * Slice 4.B.0 (2026-05-07) generalized this from \"S3-only\" to\n * every brand-aware kind.\n */\n provider: z.string().min(1).optional(),\n /**\n * Override the catalog-derived hostname for this kind. Honored at\n * `HOST_FACING` perspective (always) and at `CONTAINER_INTERNAL` for\n * `MANAGED` sources. SELF + `CONTAINER_INTERNAL` keeps the catalog\n * container name because that is the only DNS the container network\n * can resolve.\n */\n host: z.string().min(1).optional(),\n /**\n * Override the catalog-derived listen port. Threaded into both\n * docker-compose `<authored>:<authored>` publish and the per-app\n * env-vars (`<KIND>_PORT`).\n */\n port: z.number().int().positive().optional(),\n}).strict();\n\n/**\n * MongoDB backing service. `database` is the database NAME (string).\n *\n * Mongo's connection URL has the shape `mongodb://host:port/<database>`\n * — this string corresponds to the path segment. Pre-3 the field was\n * `name`; renamed to `database` in Slice 3 closeout (L-5) so all\n * data-store kinds use the same property name for the same concept\n * (vs. Postgres which already used `database`).\n */\nexport const MongoBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.string().min(1).optional(),\n}).strict();\nexport type MongoBackingService = z.infer<typeof MongoBackingServiceSchema>;\n\n/**\n * Redis backing service. `database` is the LOGICAL DB INDEX (integer).\n *\n * Redis exposes 16 logical databases (0–15) on a single connection.\n * Authoring a string here (e.g. `'staging'`) would silently parse on\n * the pre-3 union schema and crash ioredis at connect; the integer\n * constraint with `max(15)` fails loud at parse time.\n */\nexport const RedisBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.number().int().min(0).max(15).optional(),\n}).strict();\nexport type RedisBackingService = z.infer<typeof RedisBackingServiceSchema>;\n\n/**\n * PostgreSQL backing service. `database` is the database NAME (string).\n *\n * Symmetric with `MongoBackingService.database` — both are the\n * database identifier in their respective connection URLs.\n */\nexport const PostgresBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.string().min(1).optional(),\n}).strict();\nexport type PostgresBackingService = z.infer<typeof PostgresBackingServiceSchema>;\n\n/**\n * RabbitMQ backing service. `vhost` is the RabbitMQ virtual host.\n *\n * AMQP virtual hosts isolate exchange/queue namespaces inside a single\n * broker. NOT a database — RabbitMQ has no DB concept — so the field\n * is intentionally NOT named `database`.\n */\nexport const RabbitBackingServiceSchema = BackingServiceBaseSchema.extend({\n vhost: z.string().min(1).optional(),\n}).strict();\nexport type RabbitBackingService = z.infer<typeof RabbitBackingServiceSchema>;\n\n/**\n * S3-compatible backing service (MinIO, Scaleway Object Storage, AWS).\n *\n * `endpoint` is a URL (`http://localhost:9000`, `https://s3.eu-west.amazonaws.com`)\n * — the resolver parses it into host/port. `bucket` is the S3 bucket\n * name. NOT a database — S3 has no DB concept.\n */\nexport const S3BackingServiceSchema = BackingServiceBaseSchema.extend({\n endpoint: z.string().min(1).optional(),\n bucket: z.string().min(1).optional(),\n}).strict();\nexport type S3BackingService = z.infer<typeof S3BackingServiceSchema>;\n\n/** ClamAV anti-virus daemon. Stateless, no database/vhost/bucket. */\nexport const ClamAvBackingServiceSchema = BackingServiceBaseSchema;\nexport type ClamAvBackingService = z.infer<typeof ClamAvBackingServiceSchema>;\n\n/**\n * immudb backing service (tamper-evident audit-log store). A stateful DB —\n * `database` names the immudb database (defaults to `defaultdb` at runtime);\n * credentials come from the secrets pipeline like every other backing service.\n *\n * Declare this in EVERY environment where the `COMPLIANCE_AUDIT_TRAIL` engine\n * capability is enabled. `wildo config sync` warns per environment when the audit\n * capability is on but no environment declares an audit store, and the audit client\n * then has nowhere tamper-evident to write.\n *\n * You do NOT author the state-signing keypair that makes the store's\n * whole-server-substitution defense work. The framework provisions it (private half\n * mounted into a `source: SELF` immudb via `--signingKey`, public half pinned by the\n * audit client as `IMMUDB_STATE_PUBLIC_KEY`) — declaring the service is the whole job.\n *\n * @example\n * ```ts\n * backingServices: {\n * immudb: { source: BackingServiceSource.SELF },\n * }\n * ```\n */\nexport const ImmudbBackingServiceSchema = BackingServiceBaseSchema.extend({\n database: z.string().min(1).optional(),\n}).strict();\nexport type ImmudbBackingService = z.infer<typeof ImmudbBackingServiceSchema>;\n\n/**\n * Backup orchestration target. Stateless base for now.\n */\nexport const BackupBackingServiceSchema = BackingServiceBaseSchema;\nexport type BackupBackingService = z.infer<typeof BackupBackingServiceSchema>;\n\n/**\n * Discriminated UNION over all backing-service kinds. Used by the\n * `ServiceAddressResolver` and helpers that accept any kind and read\n * only base fields (`source`, `host`, `port`). Consumers that need\n * kind-specific fields MUST narrow first (e.g. via the per-kind type\n * exports above).\n */\nexport type BackingServiceEnvConfig =\n | MongoBackingService\n | RedisBackingService\n | PostgresBackingService\n | RabbitBackingService\n | S3BackingService\n | ClamAvBackingService\n | ImmudbBackingService\n | BackupBackingService;\n\n/**\n * Per-environment backing services config (source for each service).\n * Used in environment-specific infra descriptors.\n *\n * Keys stay optional because an app-owned environment only needs to declare the\n * backing services it actually enables. Requiring the full enum-keyed record\n * would force disabled services (for example `postgresql`) into every env file\n * and breaks truthful flattened targeted-app declarations.\n */\nexport const BackingServicesEnvConfigSchema = z.object({\n [BackingServiceKind.MONGODB]: MongoBackingServiceSchema.optional(),\n [BackingServiceKind.REDIS]: RedisBackingServiceSchema.optional(),\n [BackingServiceKind.RABBITMQ]: RabbitBackingServiceSchema.optional(),\n [BackingServiceKind.S3]: S3BackingServiceSchema.optional(),\n [BackingServiceKind.POSTGRESQL]: PostgresBackingServiceSchema.optional(),\n [BackingServiceKind.CLAMAV]: ClamAvBackingServiceSchema.optional(),\n [BackingServiceKind.IMMUDB]: ImmudbBackingServiceSchema.optional(),\n [BackingServiceKind.BACKUP]: BackupBackingServiceSchema.optional(),\n}).strict();\nexport type BackingServicesEnvConfig = z.infer<typeof BackingServicesEnvConfigSchema>;\n/** @wildo_source:part:end platform.config.backing-services */\n\n// =============================================================================\n// BackingServiceKind ↔ InfraCapability / InfraProvider projections\n// =============================================================================\n//\n// Per `infra-provider-planner.md` R-B (locked 2026-05-06): `BackingServicesEnvConfig`\n// IS the canonical per-env infra-selection authoring surface. The\n// `InfraCapability` / `InfraProvider` enums are the planner's projection\n// vocabulary (used by `InfraProviderModule.supportedCapabilities`,\n// `wildo-saas.lock.json sections.infra` keying, and any tooling that\n// walks \"what infra is selected per env\"). The mappings below are the\n// single source of truth for that projection — no other code may\n// reconstruct them locally.\n\n/** @wildo_source:part:start platform.config.infra-provider-resolution facet:layer:platform facet:audience:app-developer */\n/**\n * `BackingServiceKind` → `InfraCapability`. Every extension to `BackingServiceKind` MUST extend this\n * map in the same commit, otherwise the planner cannot project the new kind to its capability slot.\n *\n * INJECTIVE, not bijective — and the difference is a real property of the model rather than a gap.\n * A capability may be granted to a runtime without any environment declaring a backing service for\n * it; see {@link RUNTIME_GRANTED_INFRA_CAPABILITIES} for the ones that are, and why.\n */\nexport const BackingServiceKindToInfraCapability: Record<BackingServiceKind, InfraCapability> = {\n [BackingServiceKind.MONGODB]: InfraCapability.DOCUMENT_DATABASE,\n [BackingServiceKind.POSTGRESQL]: InfraCapability.RELATIONAL_DATABASE,\n [BackingServiceKind.RABBITMQ]: InfraCapability.QUEUING_SYSTEM,\n [BackingServiceKind.REDIS]: InfraCapability.CACHE_MANAGER,\n [BackingServiceKind.S3]: InfraCapability.OBJECT_STORAGE,\n [BackingServiceKind.CLAMAV]: InfraCapability.ANTIVIRUS_SCANNING,\n [BackingServiceKind.IMMUDB]: InfraCapability.AUDIT_LOG_STORAGE,\n [BackingServiceKind.BACKUP]: InfraCapability.BACKUP_MANAGER,\n};\n\n/**\n * Project `(BackingServiceKind, source, provider?)` → `InfraProvider`.\n *\n * The three-axis dispatch (kind × hosting-model × brand) generalizes\n * the source/brand split across all kinds (Slice 4.B.0, 2026-05-07\n * — was source-only with Atlas as a special source value before).\n *\n * **Brand vocabulary** per kind (`provider` field on the authored\n * `BackingService<X>Schema`):\n *\n * | Kind | source | provider | InfraProvider |\n * |---|---|---|---|\n * | `MONGODB` | `SELF` | (any) | `MONGODB_SELF` |\n * | `MONGODB` | `MANAGED` | `'atlas'` | `MONGODB_ATLAS` |\n * | `POSTGRESQL` | `SELF` | (any) | `POSTGRES_SELF` |\n * | `POSTGRESQL` | `MANAGED` | `'aws-rds'` | `POSTGRES_AWS_RDS` |\n * | `POSTGRESQL` | `MANAGED` | `'gcp-cloud-sql'` | `POSTGRES_GCP_CLOUD_SQL` |\n * | `POSTGRESQL` | `MANAGED` | `'azure-database'` | `POSTGRES_AZURE_DATABASE` |\n * | `POSTGRESQL` | `MANAGED` | `'supabase'` | `POSTGRES_SUPABASE` |\n * | `POSTGRESQL` | `MANAGED` | `'neon'` | `POSTGRES_NEON` |\n * | `POSTGRESQL` | `MANAGED` | `'render'` | `POSTGRES_RENDER` |\n * | `POSTGRESQL` | `MANAGED` | unset or unrecognized | `POSTGRES_MANAGED` (generic fallback) |\n * | `REDIS` | `SELF` | (any) | `REDIS_SELF` |\n * | `RABBITMQ` | `SELF` | (any) | `RABBITMQ_SELF` |\n * | `S3` | (either) | `'minio'` | `MINIO_SELF` |\n * | `S3` | (either) | `'aws'` | `AWS_S3` |\n * | `S3` | `SELF` | unset or unrecognized | `MINIO_SELF` |\n * | `S3` | `MANAGED` | unset or unrecognized | `AWS_S3` |\n * | `CLAMAV` | `SELF` | (any) | `CLAMAV_SELF` |\n * | `IMMUDB` | `SELF` | (any) | `IMMUDB_SELF` |\n *\n * Returns `undefined` for combinations not in the table — for kinds\n * whose `InfraProvider` catalog has no concrete entry yet (BACKUP)\n * and for unrecognized managed Mongo brands. PostgreSQL has a generic\n * managed fallback; S3 uses brand-first resolution, then source-based defaults. Callers decide whether `undefined` is fail-closed\n * (planner running with unknown infra catalog) or accepted (lockfile\n * pre-declaration).\n *\n * ## What this means when you author an environment\n *\n * **`MANAGED` does not reach every kind.** The table above is the whole of it: a managed vendor\n * resolves for the relational database (six named brands plus a generic fallback), the document\n * database (`'atlas'` only) and object storage. Declaring `{ source: MANAGED }` on the cache, the\n * broker, the antivirus scanner, the audit store or the backup target resolves to NOTHING — those\n * kinds are self-hosted only until their vendor catalogue is built.\n *\n * **And nothing tells you.** A kind that resolves to no provider is SKIPPED when the lockfile's infra\n * section is materialised, silently, because recording an entry with no provider would lie. So a\n * managed declaration the catalogue cannot serve looks exactly like a correct one: `wildo config\n * sync` succeeds, the file says `MANAGED`, and the environment has no managed anything. Read the\n * lockfile's infra section to see which of your declarations were actually resolved.\n *\n * **An unrecognised brand is not the same failure on every kind.** On the relational database it\n * falls back to the generic managed entry, so a typo still resolves. On the document database,\n * an unknown managed brand resolves to nothing. Object storage recognizes minio/aws first, then\n * falls back by source: SELF to MinIO, MANAGED to AWS S3, including unrecognized brands.\n *\n * **Provider resolution and workload inclusion answer different questions.** Compose and Kubernetes\n * both use the same per-kind inclusion policy, separately from catalogue resolution. Cache, broker\n * and S3 default to self-hosted unless explicitly MANAGED; ClamAV and immudb require explicit SELF.\n * MongoDB and PostgreSQL also include the platform database requirement: an application-level\n * managed choice does not remove a self-hosted database still needed by the platform. Backup has\n * no rendered workload. Do not infer workload inclusion from this provider resolver.\n */\nexport function resolveInfraProvider(\n kind: BackingServiceKind,\n source: BackingServiceSource,\n provider?: string,\n): InfraProvider | undefined {\n switch (kind) {\n case BackingServiceKind.MONGODB:\n if (source === BackingServiceSource.SELF) return InfraProvider.MONGODB_SELF;\n if (source === BackingServiceSource.MANAGED && provider === 'atlas') return InfraProvider.MONGODB_ATLAS;\n // Other Mongo managed brands (e.g., AWS DocumentDB) — extend\n // the `InfraProvider` enum + this branch in the same slice\n // that adds the first concrete consumer.\n return undefined;\n case BackingServiceKind.POSTGRESQL:\n if (source === BackingServiceSource.SELF) return InfraProvider.POSTGRES_SELF;\n if (source === BackingServiceSource.MANAGED) {\n switch (provider) {\n case 'aws-rds': return InfraProvider.POSTGRES_AWS_RDS;\n case 'gcp-cloud-sql': return InfraProvider.POSTGRES_GCP_CLOUD_SQL;\n case 'azure-database': return InfraProvider.POSTGRES_AZURE_DATABASE;\n case 'supabase': return InfraProvider.POSTGRES_SUPABASE;\n case 'neon': return InfraProvider.POSTGRES_NEON;\n case 'render': return InfraProvider.POSTGRES_RENDER;\n // Generic fallback when the operator has authored\n // `source: MANAGED` without naming a brand (or with an\n // unrecognized brand). Acceptable while the brand catalog\n // is incomplete — the lockfile records `POSTGRES_MANAGED`\n // and the planner can still emit env vars + compose\n // contributions; brand-specific runtime behavior is what\n // the named-brand modules (Slice 4.B+) layer on top.\n default: return InfraProvider.POSTGRES_MANAGED;\n }\n }\n return undefined;\n case BackingServiceKind.REDIS:\n if (source === BackingServiceSource.SELF) return InfraProvider.REDIS_SELF;\n // Managed Redis brands (ElastiCache, Upstash, Redis Cloud, …)\n // — not catalogued yet; future expansion.\n return undefined;\n case BackingServiceKind.RABBITMQ:\n if (source === BackingServiceSource.SELF) return InfraProvider.RABBITMQ_SELF;\n // Managed RabbitMQ brands (CloudAMQP, AWS MQ, …) —\n // not catalogued yet; future expansion.\n return undefined;\n case BackingServiceKind.S3:\n // S3 dispatch is brand-first because the protocol is\n // standardized (S3-compatible) and the same `source` can host\n // multiple software stacks — `source: SELF` could be MinIO or\n // a self-managed AWS S3 cluster (theoretically). The brand is\n // the canonical disambiguator.\n if (provider === 'minio') return InfraProvider.MINIO_SELF;\n if (provider === 'aws') return InfraProvider.AWS_S3;\n // Default source-based mapping for unbranded S3 — MinIO is\n // the canonical self-hosted; AWS is the canonical managed.\n if (source === BackingServiceSource.SELF) return InfraProvider.MINIO_SELF;\n if (source === BackingServiceSource.MANAGED) return InfraProvider.AWS_S3;\n return undefined;\n case BackingServiceKind.CLAMAV:\n if (source === BackingServiceSource.SELF) return InfraProvider.CLAMAV_SELF;\n return undefined;\n case BackingServiceKind.IMMUDB:\n if (source === BackingServiceSource.SELF) return InfraProvider.IMMUDB_SELF;\n // Managed immudb (immudb Vault) — not catalogued yet; future expansion.\n return undefined;\n case BackingServiceKind.BACKUP:\n // No concrete `InfraProvider` declared yet for this kind. Extend the `InfraProvider` enum +\n // this branch in the same slice that introduces the first concrete provider for it.\n //\n // `METRICS` was the other kind here and was WITHDRAWN 2026-09-09: telemetry is authored at\n // `observability.telemetry` and its auth header derived from the selected\n // `OBSERVABILITY_TELEMETRY` provider, so a backing-service kind was a third declaration\n // surface that nothing read. See `RUNTIME_GRANTED_INFRA_CAPABILITIES`.\n return undefined;\n }\n}\n/** @wildo_source:part:end platform.config.infra-provider-resolution */\n"]}
|
|
@@ -149,11 +149,11 @@ export type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;
|
|
|
149
149
|
*
|
|
150
150
|
* Declaring a Content-Security-Policy for one of the application's frontends.
|
|
151
151
|
*
|
|
152
|
-
* ⚠️ **
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
152
|
+
* ⚠️ **Every browser surface ships a policy; what differs is what happens when you author none.** On
|
|
153
|
+
* the application (`services.<key>.csp`) an omitted block resolves at sync to `enabled: true,
|
|
154
|
+
* reportOnly: true` — a policy that reports violations and blocks nothing. A website or technical-doc
|
|
155
|
+
* config with no block is refused at sync, naming the file. A policy that resolves DISABLED is refused
|
|
156
|
+
* on every surface, so `enabled: false` cannot switch the header off.
|
|
157
157
|
*
|
|
158
158
|
* ## The generated file is the only one read
|
|
159
159
|
*
|
|
@@ -178,10 +178,8 @@ export type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;
|
|
|
178
178
|
* `wildo.website.config.ts.csp?`, and `services.<key>.csp` on the
|
|
179
179
|
* `SAAS_APP` service definition.
|
|
180
180
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* their third-party JS / fetch surface should not ship a half-baked
|
|
184
|
-
* CSP that breaks features without protecting anything.
|
|
181
|
+
* An AUTHORED block that omits `enabled` parses as `enabled: false`, which the resolver turns into no
|
|
182
|
+
* policy and the sync then refuses — so author `enabled: true` explicitly whenever you write a block.
|
|
185
183
|
*
|
|
186
184
|
* `z.strictObject` (Zod 4) is intentional — typos like `enable: true`
|
|
187
185
|
* (no `d`) or `directive: { … }` (no plural) MUST surface as parse
|
|
@@ -191,9 +189,10 @@ export type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;
|
|
|
191
189
|
*/
|
|
192
190
|
export declare const WildoCspConfigSchema: z.ZodObject<{
|
|
193
191
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
192
|
+
* `true` => baseline (+ overrides) emitted on both channels per `reportOnly`.
|
|
193
|
+
* `false` — also the parse default for an authored block — makes the resolver return `null`, and
|
|
194
|
+
* `wildo dev sync-csp` refuses that for every CSP-capable surface. It is not a way to turn the
|
|
195
|
+
* header off.
|
|
197
196
|
*/
|
|
198
197
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
199
198
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,+MAetB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,oBAAY,gBAAgB;IAC1B,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;CACtC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,8RAOvC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"csp.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,+MAetB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,oBAAY,gBAAgB;IAC1B,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;CACtC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,8RAOvC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;OAKG;;IAEH;;;;;;;;;;;OAWG;;IAEH;;;;OAIG;;IAIH;;;OAGG;;IAEH;;;;;;;OAOG;;kBAEH,CAAC;AACH,iEAAiE;AACjE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;OAKG;;IAEH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;;IAEH;;;;;;OAMG;;IAEH;;;OAGG;;kBAEH,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -166,11 +166,11 @@ export const CspDirectivesOverrideSchema = z.strictObject(Object.fromEntries(CSP
|
|
|
166
166
|
*
|
|
167
167
|
* Declaring a Content-Security-Policy for one of the application's frontends.
|
|
168
168
|
*
|
|
169
|
-
* ⚠️ **
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
169
|
+
* ⚠️ **Every browser surface ships a policy; what differs is what happens when you author none.** On
|
|
170
|
+
* the application (`services.<key>.csp`) an omitted block resolves at sync to `enabled: true,
|
|
171
|
+
* reportOnly: true` — a policy that reports violations and blocks nothing. A website or technical-doc
|
|
172
|
+
* config with no block is refused at sync, naming the file. A policy that resolves DISABLED is refused
|
|
173
|
+
* on every surface, so `enabled: false` cannot switch the header off.
|
|
174
174
|
*
|
|
175
175
|
* ## The generated file is the only one read
|
|
176
176
|
*
|
|
@@ -195,10 +195,8 @@ export const CspDirectivesOverrideSchema = z.strictObject(Object.fromEntries(CSP
|
|
|
195
195
|
* `wildo.website.config.ts.csp?`, and `services.<key>.csp` on the
|
|
196
196
|
* `SAAS_APP` service definition.
|
|
197
197
|
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* their third-party JS / fetch surface should not ship a half-baked
|
|
201
|
-
* CSP that breaks features without protecting anything.
|
|
198
|
+
* An AUTHORED block that omits `enabled` parses as `enabled: false`, which the resolver turns into no
|
|
199
|
+
* policy and the sync then refuses — so author `enabled: true` explicitly whenever you write a block.
|
|
202
200
|
*
|
|
203
201
|
* `z.strictObject` (Zod 4) is intentional — typos like `enable: true`
|
|
204
202
|
* (no `d`) or `directive: { … }` (no plural) MUST surface as parse
|
|
@@ -208,9 +206,10 @@ export const CspDirectivesOverrideSchema = z.strictObject(Object.fromEntries(CSP
|
|
|
208
206
|
*/
|
|
209
207
|
export const WildoCspConfigSchema = z.strictObject({
|
|
210
208
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
209
|
+
* `true` => baseline (+ overrides) emitted on both channels per `reportOnly`.
|
|
210
|
+
* `false` — also the parse default for an authored block — makes the resolver return `null`, and
|
|
211
|
+
* `wildo dev sync-csp` refuses that for every CSP-capable surface. It is not a way to turn the
|
|
212
|
+
* header off.
|
|
214
213
|
*/
|
|
215
214
|
enabled: z.boolean().default(false),
|
|
216
215
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,YAAY;IACZ,WAAW;IACX,SAAS;IACT,aAAa;IACb,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,cAAc;IACd,WAAW;IACX,YAAY;CACJ,CAAC;AAIX;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uDAAmC,CAAA;IACnC,yDAAqC,CAAA;AACvC,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,YAAY,CACvD,MAAM,CAAC,WAAW,CAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAChC,IAAI;IACJ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CACiE,CACtE,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;OAIG;IACH,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACtC;;;;OAIG;IACH,aAAa,EAAE,CAAC;SACb,IAAI,CAAC,gBAAgB,CAAC;SACtB,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC;IAC5C;;;OAGG;IACH,UAAU,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IACnD;;;;;;;OAOG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC;AAKH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;;OAKG;IACH,eAAe,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACxC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC","sourcesContent":["/**\n * Content-Security-Policy authoring schema for per-frontend opt-in.\n *\n * # Where this fits in the layered CSP cake\n *\n * 1. Platform default — `./csp-defaults.ts` ships per-`AppFrontendType`\n * baselines (`SAAS_APP`, `STATIC_WEBSITE`, `TECH_DOC`). The baseline\n * is opinionated but conservative: `default-src 'self'` plus the\n * narrowest set of relaxations each frontend kind genuinely needs\n * to render (e.g., Docusaurus 3.x's `'unsafe-inline'` script /\n * style requirement for `TECH_DOC`).\n * 2. App-static — this `WildoCspConfigSchema`, authored on each\n * service-definition's `csp?` field. `SAAS_APP` authors this on\n * `wildo.saas.config.ts > services.<key>.csp`; `STATIC_WEBSITE` authors\n * it on `wildo.website.config.ts`; `TECH_DOC` authors it on\n * `wildo.tech-doc.config.ts`.\n * 3. Env-specific — `EnvCspOverrideSchema` below, authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. `WildoInfraEnvConfigSchema`\n * declares that field, so the layer is live. Its build-time consumer is\n * `wildo dev sync-csp`, which reads `parsed.csp[serviceKey]` when emitting\n * generated frontend CSP artifacts.\n * 4. Declared providers — NOT authored here at all (#332). Each frontend\n * provider declares the origins it needs to reach on its own module, that\n * footprint travels as data into the materialized frontend-services\n * artifact, and `resolveCspPolicy` merges the footprints of the providers\n * declared FOR THIS SERVICE. Layers 1–3 say what the application decided;\n * layer 4 says what the things it declared actually need in order to work,\n * which is why it is additive even under `replace-baseline`.\n *\n * # Resolution semantics (consumed by `platform-config-lib/src/project-config/shared/csp-emit.ts`)\n *\n * - `enabled: false` (default) => no policy emitted; the resolver\n * returns `null` and both nginx + meta channels stay silent. The\n * opt-in shape (vs opt-out) is deliberate — frontends that have not\n * audited their third-party surface should not ship a half-baked\n * CSP that breaks features without protecting anything.\n * - `enabled: true` with no `directives` override => baseline emitted\n * verbatim (see `./csp-defaults.ts`).\n * - `enabled: true` with `directives` AND `mergeStrategy: 'extend-baseline'`\n * (default) => per-directive ADDITIVE merge: each authored source\n * list is concatenated to the baseline's source list for that\n * directive (de-duplicated, baseline order preserved, app sources\n * appended in author order). Directives the baseline doesn't ship\n * are added wholesale.\n * - `enabled: true` with `mergeStrategy: 'replace-baseline'` =>\n * authored `directives` map REPLACES the baseline entirely; missing\n * directives are simply absent from the policy. Use only when the\n * baseline is fundamentally wrong for the surface (e.g., a\n * `STATIC_WEBSITE` that actually serves an embedded SaaS app and\n * wants the tighter `SAAS_APP`-style policy from scratch). The\n * escape hatch exists; the merge default exists for the common\n * case (additive tightening / loosening).\n * - `reportOnly: true` => header name flips to\n * `Content-Security-Policy-Report-Only` AND the `<meta http-equiv>`\n * channel goes silent (browsers reject the report-only header via\n * meta — W3C CSP3 §4.2.1). `reportOnly: false` (default once the\n * pilot triages clean) emits the enforcing header AND the meta\n * tag (with header-only directives stripped from the meta tag —\n * see `META_INVALID_DIRECTIVES` in `csp-emit.ts`).\n * - `reportUri` => header-only directive value (the meta tag would\n * ignore it). The resolver feeds it to the nginx channel only.\n *\n * # Why the `directives` keys are an explicit closed set vs a free-form `Record<string, ...>`\n *\n * CSP grew organically over a decade and a half. The closed set below\n * (`default-src` / `script-src` / `style-src` / `img-src` / `connect-src`\n * / `font-src` / `frame-src` / `frame-ancestors` / `object-src` /\n * `form-action` / `base-uri` / `manifest-src` / `media-src` / `worker-src`)\n * covers every directive the platform's three frontend kinds genuinely\n * use today. Forcing authors to spell directive names through the schema\n * surface (vs `Record<string, string[]>`) catches typos at parse time\n * (`script-source` !== `script-src`) and gives IDE autocompletion. Adding\n * a new directive is a one-line schema edit when a real consumer asks\n * for it; meanwhile the default-deny stance prevents authors from\n * accidentally shipping a directive name the browser silently ignores.\n *\n * # Author-friendly source lists\n *\n * Each directive's value is `string[]`. The resolver does NOT validate\n * the contents of the source list (that would require importing a CSP\n * grammar — out of scope for this commit). Common shapes:\n *\n * - `\"'self'\"` — single-quoted keyword, MUST keep the quotes.\n * - `'data:'`, `'blob:'` — scheme sources.\n * - `'https://api.example.com'` — origin source.\n * - `\"'unsafe-inline'\"`, `\"'unsafe-eval'\"` — single-quoted keywords.\n * - `\"'nonce-<base64>'\"` — nonce keyword (rendered per-request).\n * - `\"'sha256-<hash>'\"` — hash keyword.\n *\n * The `csp-emit.ts` serializer joins source lists with single spaces\n * and separates directives with `; ` (no leading/trailing semicolon —\n * matches Mozilla / OWASP recommended whitespace).\n */\n\nimport { z } from 'zod';\n\n/**\n * Closed set of directive names we accept on the `csp.directives`\n * authoring map. Adding a new directive name requires:\n *\n * 1. Adding the literal here.\n * 2. Updating any per-`AppFrontendType` baseline that should ship the\n * directive by default in `./csp-defaults.ts`.\n * 3. Verifying the `csp-emit.ts` serializer handles the directive\n * (it does — the serializer is generic over directive names — so\n * step 3 is usually a no-op).\n *\n * The `META_INVALID_DIRECTIVES` set in `csp-emit.ts` lists the\n * directives the browser ignores when emitted via `<meta http-equiv>`\n * (`frame-ancestors`, `report-uri`, `report-to`, `sandbox`); they're\n * stripped from the meta-channel output but remain on the nginx\n * channel. Keep that set in sync if a new header-only directive lands\n * here.\n */\nexport const CSP_DIRECTIVE_NAMES = [\n 'default-src',\n 'script-src',\n 'style-src',\n 'img-src',\n 'connect-src',\n 'font-src',\n 'frame-src',\n 'frame-ancestors',\n 'object-src',\n 'form-action',\n 'base-uri',\n 'manifest-src',\n 'media-src',\n 'worker-src',\n] as const;\n\nexport type CspDirectiveName = (typeof CSP_DIRECTIVE_NAMES)[number];\n\n/**\n * Author-side merge strategy for the app-static layer over the baseline.\n *\n * - `'extend-baseline'` (default) — per-directive ADDITIVE merge:\n * each authored source list is APPENDED to the baseline source\n * list for that directive. Directives the baseline doesn't ship\n * are added wholesale. Common case: an app needs to add ONE extra\n * `connect-src` origin without re-authoring the rest of the policy.\n * - `'replace-baseline'` — authored `directives` map REPLACES the\n * baseline entirely. Use when the baseline is fundamentally wrong\n * for the surface (e.g., a tighter or fundamentally different\n * posture). Escape hatch — the merge default is the right answer\n * in 95% of cases.\n */\nexport enum CspMergeStrategy {\n EXTEND_BASELINE = 'extend-baseline',\n REPLACE_BASELINE = 'replace-baseline',\n}\n\n/**\n * Author-side directive overrides — partial map keyed by the closed\n * directive-name set above. Each value is a source list of strings\n * (joined with single spaces by the serializer).\n *\n * Authoring `directives: { 'connect-src': ['https://api.example.com'] }`\n * with the default `'extend-baseline'` strategy APPENDS that origin to\n * the baseline `connect-src` source list (which already contains\n * `'self'` for every baseline) — it does NOT replace the baseline's\n * `connect-src`. Use `mergeStrategy: 'replace-baseline'` to opt out of\n * additive merging.\n */\nexport const CspDirectivesOverrideSchema = z.strictObject(\n Object.fromEntries(\n CSP_DIRECTIVE_NAMES.map((name) => [\n name,\n z.array(z.string().min(1)).optional(),\n ]),\n ) as Record<CspDirectiveName, z.ZodOptional<z.ZodArray<z.ZodString>>>,\n);\nexport type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;\n\n/**\n * @wildo_source:part:start saas.config.content-security-policy facet:layer:shared facet:audience:app-developer\n *\n * Declaring a Content-Security-Policy for one of the application's frontends.\n *\n * ⚠️ **It is OPT-IN, and omitting the block emits NO policy on either channel.** `enabled: false` and\n * an absent block are the same thing: no header, no protection. That default is deliberate — a\n * frontend that has not audited its third-party script and fetch surface should not ship a half-baked\n * policy that breaks features without protecting anything — but it does mean an application acquires\n * no CSP by existing.\n *\n * ## The generated file is the only one read\n *\n * Author the static posture here, add per-environment entries under `csp.<serviceKey>` in that\n * environment's infrastructure configuration, then run `wildo dev sync-csp --env <env>` (starting\n * development runs it for you). Each surface reads ONLY the generated artifact — hand-editing a\n * surface's own policy file changes nothing and is overwritten on the next sync.\n *\n * ## `reportOnly` is a posture, not a formality\n *\n * `reportOnly: true` emits the report-only header: the browser reports violations and BLOCKS\n * NOTHING. Flipping it is one field. Note also that a `report-uri` is supported by the schema and the\n * emitter and no baseline ships a collector, so with nothing authored there the reports a browser\n * generates have nowhere to go — report-only plus no collector is a policy that neither blocks nor\n * tells you anything.\n *\n * Nonces and hashes are not generated per request or at build time. A source list may name one by\n * hand, but there is no generation, which is why a baseline that must admit inline script still does.\n *\n * Per-frontend CSP block. Authored on each service-definition's `csp?`\n * field. All three surfaces carry it: `wildo.tech-doc.config.ts.csp?`,\n * `wildo.website.config.ts.csp?`, and `services.<key>.csp` on the\n * `SAAS_APP` service definition.\n *\n * Opt-in by default: `enabled: false` (or omitting the block entirely)\n * emits NO policy on either channel. Frontends that have not audited\n * their third-party JS / fetch surface should not ship a half-baked\n * CSP that breaks features without protecting anything.\n *\n * `z.strictObject` (Zod 4) is intentional — typos like `enable: true`\n * (no `d`) or `directive: { … }` (no plural) MUST surface as parse\n * errors, not silently strip to `enabled: false` (i.e. CSP off, the\n * worst possible default). Same framework-mindset enforcement as\n * `WildoAuthConfigSchema`.\n */\nexport const WildoCspConfigSchema = z.strictObject({\n /**\n * Opt-in switch. `false` (default) => no policy emitted; the\n * resolver returns `null`. `true` => baseline (+ overrides) emitted\n * on both channels per `reportOnly`.\n */\n enabled: z.boolean().default(false),\n /**\n * `true` => header name flips to `Content-Security-Policy-Report-Only`\n * AND the `<meta http-equiv>` channel goes silent (browsers reject the\n * report-only header via meta — W3C CSP3 §4.2.1). Use during the\n * pilot to triage console-surfaced violations without breaking real\n * traffic. Flip to `false` once the directive overrides settle.\n *\n * Default: `false` (enforcing). Authors opting into CSP for the first\n * time SHOULD set `reportOnly: true` for the first PR; the schema\n * default is intentionally enforcing so the steady state (post-pilot)\n * doesn't require a per-app authored `reportOnly: false`.\n */\n reportOnly: z.boolean().default(false),\n /**\n * Merge strategy for authored `directives` over the baseline. Default:\n * `'extend-baseline'` (per-directive additive merge — see\n * `CspMergeStrategy`).\n */\n mergeStrategy: z\n .enum(CspMergeStrategy)\n .default(CspMergeStrategy.EXTEND_BASELINE),\n /**\n * Per-directive overrides, keyed by directive name. Default: empty\n * map (baseline emitted verbatim).\n */\n directives: CspDirectivesOverrideSchema.default({}),\n /**\n * Optional `report-uri` directive value (header-only — meta tag\n * ignores it; the resolver feeds it to the nginx channel only).\n * No `report-to` field today — `report-to` requires the parallel\n * Reporting API endpoint config which the platform doesn't ship; add\n * when the violation-collector lands (`auth-hardening.md` \"Cheap\n * Bonuses — CSP violation monitoring endpoint\").\n */\n reportUri: z.string().min(1).optional(),\n});\n/** @wildo_source:part:end saas.config.content-security-policy */\nexport type WildoCspConfig = z.infer<typeof WildoCspConfigSchema>;\nexport type WildoCspConfigInput = z.input<typeof WildoCspConfigSchema>;\n\n/**\n * Env-specific overrides — authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. The loader merges\n * these on top of the app-static layer (which itself is on top of the\n * baseline).\n *\n * `WildoInfraEnvConfigSchema` declares `csp` as a record of these,\n * keyed by service key, and the resolver in `csp-emit.ts` consumes it.\n *\n * `extraDirectives` is ADDITIVE only — env-layer entries are APPENDED\n * to whatever the app-static layer produced for that directive. There\n * is no `'replace-baseline'`-equivalent at the env layer because env\n * config exists to LOOSEN policies for specific deployments (Sentry\n * origin in staging, dev hot-reload `'unsafe-eval'`), not to replace\n * an app's chosen posture. If an env genuinely needs a different\n * posture the right answer is to fix the app-static layer.\n */\nexport const EnvCspOverrideSchema = z.strictObject({\n /**\n * Per-directive ADDITIVE merge. Each entry's source list is\n * APPENDED to the app-static layer's source list for that directive\n * (de-duplicated, app order preserved, env sources appended in\n * author order). No replace semantics at this layer.\n */\n extraDirectives: CspDirectivesOverrideSchema.default({}),\n /**\n * Vite dev-mode CSP loosening: adds BOTH `'unsafe-inline'` and\n * `'unsafe-eval'` to `script-src`. Vite's dev server injects an\n * inline `<script>` for the HMR client bootstrap AND uses `eval()`\n * for lazy module / sourcemap transforms — both block under a strict\n * `script-src 'self'` policy and produce ~120+ CSP violations per\n * page load. Production Vite builds emit `<script type=\"module\">`\n * only and use no `eval()`, so this loosening is dev-only by design.\n *\n * AUTO-DEFAULT: `true` when the resolved env id is `'local'` AND the\n * frontend type is `SAAS_APP` (the only Vite-bundled frontend kind in\n * the framework). The framework applies the loosening automatically so\n * every Wildo app gets a clean dev console without per-app\n * configuration; opting in app-by-app would scatter the same\n * framework-shipped Vite knowledge across N infrastructure files.\n *\n * EXPLICIT OPT-OUT: set to `false` to keep tight `script-src` in\n * local dev. Useful only when actively debugging a real CSP issue\n * and willing to accept Vite-induced noise. Production envs ignore\n * this flag's auto-default and require explicit opt-in (extremely\n * unusual — a production app that needs `'unsafe-inline'` /\n * `'unsafe-eval'` is almost always a sign of a misconfigured asset\n * pipeline).\n */\n viteDevLoosening: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportOnly` flag. When\n * present (not `undefined`), takes precedence over the app-static\n * value. Common shape: app-static ships `reportOnly: false`\n * (enforcing in prod), env-layer flips to `reportOnly: true` for\n * staging while the violation collector ramps up.\n */\n reportOnly: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportUri` (e.g., per-env\n * collector endpoint).\n */\n reportUri: z.string().min(1).optional(),\n});\nexport type EnvCspOverride = z.infer<typeof EnvCspOverrideSchema>;\nexport type EnvCspOverrideInput = z.input<typeof EnvCspOverrideSchema>;\n"]}
|
|
1
|
+
{"version":3,"file":"csp.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/csp.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa;IACb,YAAY;IACZ,WAAW;IACX,SAAS;IACT,aAAa;IACb,UAAU;IACV,WAAW;IACX,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,UAAU;IACV,cAAc;IACd,WAAW;IACX,YAAY;CACJ,CAAC;AAIX;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,uDAAmC,CAAA;IACnC,yDAAqC,CAAA;AACvC,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,YAAY,CACvD,MAAM,CAAC,WAAW,CAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IAChC,IAAI;IACJ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACtC,CAAC,CACiE,CACtE,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;;OAKG;IACH,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACtC;;;;OAIG;IACH,aAAa,EAAE,CAAC;SACb,IAAI,CAAC,gBAAgB,CAAC;SACtB,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC;IAC5C;;;OAGG;IACH,UAAU,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IACnD;;;;;;;OAOG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC;AAKH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD;;;;;OAKG;IACH,eAAe,EAAE,2BAA2B,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACxC;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC;;;OAGG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC","sourcesContent":["/**\n * Content-Security-Policy authoring schema for per-frontend opt-in.\n *\n * # Where this fits in the layered CSP cake\n *\n * 1. Platform default — `./csp-defaults.ts` ships per-`AppFrontendType`\n * baselines (`SAAS_APP`, `STATIC_WEBSITE`, `TECH_DOC`). The baseline\n * is opinionated but conservative: `default-src 'self'` plus the\n * narrowest set of relaxations each frontend kind genuinely needs\n * to render (e.g., Docusaurus 3.x's `'unsafe-inline'` script /\n * style requirement for `TECH_DOC`).\n * 2. App-static — this `WildoCspConfigSchema`, authored on each\n * service-definition's `csp?` field. `SAAS_APP` authors this on\n * `wildo.saas.config.ts > services.<key>.csp`; `STATIC_WEBSITE` authors\n * it on `wildo.website.config.ts`; `TECH_DOC` authors it on\n * `wildo.tech-doc.config.ts`.\n * 3. Env-specific — `EnvCspOverrideSchema` below, authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. `WildoInfraEnvConfigSchema`\n * declares that field, so the layer is live. Its build-time consumer is\n * `wildo dev sync-csp`, which reads `parsed.csp[serviceKey]` when emitting\n * generated frontend CSP artifacts.\n * 4. Declared providers — NOT authored here at all (#332). Each frontend\n * provider declares the origins it needs to reach on its own module, that\n * footprint travels as data into the materialized frontend-services\n * artifact, and `resolveCspPolicy` merges the footprints of the providers\n * declared FOR THIS SERVICE. Layers 1–3 say what the application decided;\n * layer 4 says what the things it declared actually need in order to work,\n * which is why it is additive even under `replace-baseline`.\n *\n * # Resolution semantics (consumed by `platform-config-lib/src/project-config/shared/csp-emit.ts`)\n *\n * - `enabled: false` (default) => no policy emitted; the resolver\n * returns `null` and both nginx + meta channels stay silent. The\n * opt-in shape (vs opt-out) is deliberate — frontends that have not\n * audited their third-party surface should not ship a half-baked\n * CSP that breaks features without protecting anything.\n * - `enabled: true` with no `directives` override => baseline emitted\n * verbatim (see `./csp-defaults.ts`).\n * - `enabled: true` with `directives` AND `mergeStrategy: 'extend-baseline'`\n * (default) => per-directive ADDITIVE merge: each authored source\n * list is concatenated to the baseline's source list for that\n * directive (de-duplicated, baseline order preserved, app sources\n * appended in author order). Directives the baseline doesn't ship\n * are added wholesale.\n * - `enabled: true` with `mergeStrategy: 'replace-baseline'` =>\n * authored `directives` map REPLACES the baseline entirely; missing\n * directives are simply absent from the policy. Use only when the\n * baseline is fundamentally wrong for the surface (e.g., a\n * `STATIC_WEBSITE` that actually serves an embedded SaaS app and\n * wants the tighter `SAAS_APP`-style policy from scratch). The\n * escape hatch exists; the merge default exists for the common\n * case (additive tightening / loosening).\n * - `reportOnly: true` => header name flips to\n * `Content-Security-Policy-Report-Only` AND the `<meta http-equiv>`\n * channel goes silent (browsers reject the report-only header via\n * meta — W3C CSP3 §4.2.1). `reportOnly: false` (default once the\n * pilot triages clean) emits the enforcing header AND the meta\n * tag (with header-only directives stripped from the meta tag —\n * see `META_INVALID_DIRECTIVES` in `csp-emit.ts`).\n * - `reportUri` => header-only directive value (the meta tag would\n * ignore it). The resolver feeds it to the nginx channel only.\n *\n * # Why the `directives` keys are an explicit closed set vs a free-form `Record<string, ...>`\n *\n * CSP grew organically over a decade and a half. The closed set below\n * (`default-src` / `script-src` / `style-src` / `img-src` / `connect-src`\n * / `font-src` / `frame-src` / `frame-ancestors` / `object-src` /\n * `form-action` / `base-uri` / `manifest-src` / `media-src` / `worker-src`)\n * covers every directive the platform's three frontend kinds genuinely\n * use today. Forcing authors to spell directive names through the schema\n * surface (vs `Record<string, string[]>`) catches typos at parse time\n * (`script-source` !== `script-src`) and gives IDE autocompletion. Adding\n * a new directive is a one-line schema edit when a real consumer asks\n * for it; meanwhile the default-deny stance prevents authors from\n * accidentally shipping a directive name the browser silently ignores.\n *\n * # Author-friendly source lists\n *\n * Each directive's value is `string[]`. The resolver does NOT validate\n * the contents of the source list (that would require importing a CSP\n * grammar — out of scope for this commit). Common shapes:\n *\n * - `\"'self'\"` — single-quoted keyword, MUST keep the quotes.\n * - `'data:'`, `'blob:'` — scheme sources.\n * - `'https://api.example.com'` — origin source.\n * - `\"'unsafe-inline'\"`, `\"'unsafe-eval'\"` — single-quoted keywords.\n * - `\"'nonce-<base64>'\"` — nonce keyword (rendered per-request).\n * - `\"'sha256-<hash>'\"` — hash keyword.\n *\n * The `csp-emit.ts` serializer joins source lists with single spaces\n * and separates directives with `; ` (no leading/trailing semicolon —\n * matches Mozilla / OWASP recommended whitespace).\n */\n\nimport { z } from 'zod';\n\n/**\n * Closed set of directive names we accept on the `csp.directives`\n * authoring map. Adding a new directive name requires:\n *\n * 1. Adding the literal here.\n * 2. Updating any per-`AppFrontendType` baseline that should ship the\n * directive by default in `./csp-defaults.ts`.\n * 3. Verifying the `csp-emit.ts` serializer handles the directive\n * (it does — the serializer is generic over directive names — so\n * step 3 is usually a no-op).\n *\n * The `META_INVALID_DIRECTIVES` set in `csp-emit.ts` lists the\n * directives the browser ignores when emitted via `<meta http-equiv>`\n * (`frame-ancestors`, `report-uri`, `report-to`, `sandbox`); they're\n * stripped from the meta-channel output but remain on the nginx\n * channel. Keep that set in sync if a new header-only directive lands\n * here.\n */\nexport const CSP_DIRECTIVE_NAMES = [\n 'default-src',\n 'script-src',\n 'style-src',\n 'img-src',\n 'connect-src',\n 'font-src',\n 'frame-src',\n 'frame-ancestors',\n 'object-src',\n 'form-action',\n 'base-uri',\n 'manifest-src',\n 'media-src',\n 'worker-src',\n] as const;\n\nexport type CspDirectiveName = (typeof CSP_DIRECTIVE_NAMES)[number];\n\n/**\n * Author-side merge strategy for the app-static layer over the baseline.\n *\n * - `'extend-baseline'` (default) — per-directive ADDITIVE merge:\n * each authored source list is APPENDED to the baseline source\n * list for that directive. Directives the baseline doesn't ship\n * are added wholesale. Common case: an app needs to add ONE extra\n * `connect-src` origin without re-authoring the rest of the policy.\n * - `'replace-baseline'` — authored `directives` map REPLACES the\n * baseline entirely. Use when the baseline is fundamentally wrong\n * for the surface (e.g., a tighter or fundamentally different\n * posture). Escape hatch — the merge default is the right answer\n * in 95% of cases.\n */\nexport enum CspMergeStrategy {\n EXTEND_BASELINE = 'extend-baseline',\n REPLACE_BASELINE = 'replace-baseline',\n}\n\n/**\n * Author-side directive overrides — partial map keyed by the closed\n * directive-name set above. Each value is a source list of strings\n * (joined with single spaces by the serializer).\n *\n * Authoring `directives: { 'connect-src': ['https://api.example.com'] }`\n * with the default `'extend-baseline'` strategy APPENDS that origin to\n * the baseline `connect-src` source list (which already contains\n * `'self'` for every baseline) — it does NOT replace the baseline's\n * `connect-src`. Use `mergeStrategy: 'replace-baseline'` to opt out of\n * additive merging.\n */\nexport const CspDirectivesOverrideSchema = z.strictObject(\n Object.fromEntries(\n CSP_DIRECTIVE_NAMES.map((name) => [\n name,\n z.array(z.string().min(1)).optional(),\n ]),\n ) as Record<CspDirectiveName, z.ZodOptional<z.ZodArray<z.ZodString>>>,\n);\nexport type CspDirectivesOverride = z.infer<typeof CspDirectivesOverrideSchema>;\n\n/**\n * @wildo_source:part:start saas.config.content-security-policy facet:layer:shared facet:audience:app-developer\n *\n * Declaring a Content-Security-Policy for one of the application's frontends.\n *\n * ⚠️ **Every browser surface ships a policy; what differs is what happens when you author none.** On\n * the application (`services.<key>.csp`) an omitted block resolves at sync to `enabled: true,\n * reportOnly: true` — a policy that reports violations and blocks nothing. A website or technical-doc\n * config with no block is refused at sync, naming the file. A policy that resolves DISABLED is refused\n * on every surface, so `enabled: false` cannot switch the header off.\n *\n * ## The generated file is the only one read\n *\n * Author the static posture here, add per-environment entries under `csp.<serviceKey>` in that\n * environment's infrastructure configuration, then run `wildo dev sync-csp --env <env>` (starting\n * development runs it for you). Each surface reads ONLY the generated artifact — hand-editing a\n * surface's own policy file changes nothing and is overwritten on the next sync.\n *\n * ## `reportOnly` is a posture, not a formality\n *\n * `reportOnly: true` emits the report-only header: the browser reports violations and BLOCKS\n * NOTHING. Flipping it is one field. Note also that a `report-uri` is supported by the schema and the\n * emitter and no baseline ships a collector, so with nothing authored there the reports a browser\n * generates have nowhere to go — report-only plus no collector is a policy that neither blocks nor\n * tells you anything.\n *\n * Nonces and hashes are not generated per request or at build time. A source list may name one by\n * hand, but there is no generation, which is why a baseline that must admit inline script still does.\n *\n * Per-frontend CSP block. Authored on each service-definition's `csp?`\n * field. All three surfaces carry it: `wildo.tech-doc.config.ts.csp?`,\n * `wildo.website.config.ts.csp?`, and `services.<key>.csp` on the\n * `SAAS_APP` service definition.\n *\n * An AUTHORED block that omits `enabled` parses as `enabled: false`, which the resolver turns into no\n * policy and the sync then refuses — so author `enabled: true` explicitly whenever you write a block.\n *\n * `z.strictObject` (Zod 4) is intentional — typos like `enable: true`\n * (no `d`) or `directive: { … }` (no plural) MUST surface as parse\n * errors, not silently strip to `enabled: false` (i.e. CSP off, the\n * worst possible default). Same framework-mindset enforcement as\n * `WildoAuthConfigSchema`.\n */\nexport const WildoCspConfigSchema = z.strictObject({\n /**\n * `true` => baseline (+ overrides) emitted on both channels per `reportOnly`.\n * `false` — also the parse default for an authored block — makes the resolver return `null`, and\n * `wildo dev sync-csp` refuses that for every CSP-capable surface. It is not a way to turn the\n * header off.\n */\n enabled: z.boolean().default(false),\n /**\n * `true` => header name flips to `Content-Security-Policy-Report-Only`\n * AND the `<meta http-equiv>` channel goes silent (browsers reject the\n * report-only header via meta — W3C CSP3 §4.2.1). Use during the\n * pilot to triage console-surfaced violations without breaking real\n * traffic. Flip to `false` once the directive overrides settle.\n *\n * Default: `false` (enforcing). Authors opting into CSP for the first\n * time SHOULD set `reportOnly: true` for the first PR; the schema\n * default is intentionally enforcing so the steady state (post-pilot)\n * doesn't require a per-app authored `reportOnly: false`.\n */\n reportOnly: z.boolean().default(false),\n /**\n * Merge strategy for authored `directives` over the baseline. Default:\n * `'extend-baseline'` (per-directive additive merge — see\n * `CspMergeStrategy`).\n */\n mergeStrategy: z\n .enum(CspMergeStrategy)\n .default(CspMergeStrategy.EXTEND_BASELINE),\n /**\n * Per-directive overrides, keyed by directive name. Default: empty\n * map (baseline emitted verbatim).\n */\n directives: CspDirectivesOverrideSchema.default({}),\n /**\n * Optional `report-uri` directive value (header-only — meta tag\n * ignores it; the resolver feeds it to the nginx channel only).\n * No `report-to` field today — `report-to` requires the parallel\n * Reporting API endpoint config which the platform doesn't ship; add\n * when the violation-collector lands (`auth-hardening.md` \"Cheap\n * Bonuses — CSP violation monitoring endpoint\").\n */\n reportUri: z.string().min(1).optional(),\n});\n/** @wildo_source:part:end saas.config.content-security-policy */\nexport type WildoCspConfig = z.infer<typeof WildoCspConfigSchema>;\nexport type WildoCspConfigInput = z.input<typeof WildoCspConfigSchema>;\n\n/**\n * Env-specific overrides — authored under\n * `wildo.infra.<env>.config.ts.csp?[serviceKey]`. The loader merges\n * these on top of the app-static layer (which itself is on top of the\n * baseline).\n *\n * `WildoInfraEnvConfigSchema` declares `csp` as a record of these,\n * keyed by service key, and the resolver in `csp-emit.ts` consumes it.\n *\n * `extraDirectives` is ADDITIVE only — env-layer entries are APPENDED\n * to whatever the app-static layer produced for that directive. There\n * is no `'replace-baseline'`-equivalent at the env layer because env\n * config exists to LOOSEN policies for specific deployments (Sentry\n * origin in staging, dev hot-reload `'unsafe-eval'`), not to replace\n * an app's chosen posture. If an env genuinely needs a different\n * posture the right answer is to fix the app-static layer.\n */\nexport const EnvCspOverrideSchema = z.strictObject({\n /**\n * Per-directive ADDITIVE merge. Each entry's source list is\n * APPENDED to the app-static layer's source list for that directive\n * (de-duplicated, app order preserved, env sources appended in\n * author order). No replace semantics at this layer.\n */\n extraDirectives: CspDirectivesOverrideSchema.default({}),\n /**\n * Vite dev-mode CSP loosening: adds BOTH `'unsafe-inline'` and\n * `'unsafe-eval'` to `script-src`. Vite's dev server injects an\n * inline `<script>` for the HMR client bootstrap AND uses `eval()`\n * for lazy module / sourcemap transforms — both block under a strict\n * `script-src 'self'` policy and produce ~120+ CSP violations per\n * page load. Production Vite builds emit `<script type=\"module\">`\n * only and use no `eval()`, so this loosening is dev-only by design.\n *\n * AUTO-DEFAULT: `true` when the resolved env id is `'local'` AND the\n * frontend type is `SAAS_APP` (the only Vite-bundled frontend kind in\n * the framework). The framework applies the loosening automatically so\n * every Wildo app gets a clean dev console without per-app\n * configuration; opting in app-by-app would scatter the same\n * framework-shipped Vite knowledge across N infrastructure files.\n *\n * EXPLICIT OPT-OUT: set to `false` to keep tight `script-src` in\n * local dev. Useful only when actively debugging a real CSP issue\n * and willing to accept Vite-induced noise. Production envs ignore\n * this flag's auto-default and require explicit opt-in (extremely\n * unusual — a production app that needs `'unsafe-inline'` /\n * `'unsafe-eval'` is almost always a sign of a misconfigured asset\n * pipeline).\n */\n viteDevLoosening: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportOnly` flag. When\n * present (not `undefined`), takes precedence over the app-static\n * value. Common shape: app-static ships `reportOnly: false`\n * (enforcing in prod), env-layer flips to `reportOnly: true` for\n * staging while the violation collector ramps up.\n */\n reportOnly: z.boolean().optional(),\n /**\n * Env-layer override of the app-static `reportUri` (e.g., per-env\n * collector endpoint).\n */\n reportUri: z.string().min(1).optional(),\n});\nexport type EnvCspOverride = z.infer<typeof EnvCspOverrideSchema>;\nexport type EnvCspOverrideInput = z.input<typeof EnvCspOverrideSchema>;\n"]}
|