@prisma/composer-prisma-cloud 0.3.0-dev.6 → 0.3.0-dev.8
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/control.d.mts +1 -1
- package/dist/control.mjs +28 -17
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.d.mts +33 -26
- package/dist/cron/index.d.mts.map +1 -1
- package/dist/cron/index.mjs +202 -77
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +133 -114
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +200 -76
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/email/email-entrypoint.mjs +162 -126
- package/dist/email/email-entrypoint.mjs.map +1 -1
- package/dist/email/email-service.mjs +230 -79
- package/dist/email/email-service.mjs.map +1 -1
- package/dist/email/index.d.mts +33 -29
- package/dist/email/index.d.mts.map +1 -1
- package/dist/email/index.mjs +236 -84
- package/dist/email/index.mjs.map +1 -1
- package/dist/email/testing.mjs +112 -89
- package/dist/email/testing.mjs.map +1 -1
- package/dist/index.d.mts +51 -43
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +47 -51
- package/dist/index.mjs.map +1 -1
- package/dist/local-target.mjs +1 -1
- package/dist/local-target.mjs.map +1 -1
- package/dist/{preflight-names-BPL-qsZF-BfoRgbgb.mjs → preflight-names-CpJUd9ZA-BCU-W3cT.mjs} +30 -14
- package/dist/{preflight-names-BPL-qsZF-BfoRgbgb.mjs.map → preflight-names-CpJUd9ZA-BCU-W3cT.mjs.map} +1 -1
- package/dist/{provisioned-edges-C1wSO3cx-YC5C19f9.mjs → provisioned-edges-Cxy18aoh-CUnaY96r.mjs} +3 -3
- package/dist/{provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map → provisioned-edges-Cxy18aoh-CUnaY96r.mjs.map} +1 -1
- package/dist/{param-BTzY0ne5-CW6ojZ3E.mjs → secret-BVGxqHxY-DYDfiULl.mjs} +45 -4
- package/dist/secret-BVGxqHxY-DYDfiULl.mjs.map +1 -0
- package/dist/{serializer-Cx5slrV4-xJfH6EWS.d.mts → serializer-BD_6nkr4-DWn5NNTC.d.mts} +2 -2
- package/dist/serializer-BD_6nkr4-DWn5NNTC.d.mts.map +1 -0
- package/dist/serializer-sVE4UAmg-CikRngbR.mjs +475 -0
- package/dist/serializer-sVE4UAmg-CikRngbR.mjs.map +1 -0
- package/dist/storage/index.d.mts +31 -26
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +215 -89
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +147 -122
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +212 -87
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/streams/index.d.mts +29 -22
- package/dist/streams/index.d.mts.map +1 -1
- package/dist/streams/index.mjs +213 -88
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +139 -118
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +212 -87
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/testing.d.mts +19 -5
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +11 -3
- package/dist/testing.mjs.map +1 -1
- package/package.json +17 -17
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +0 -1
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +0 -47
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +0 -1
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs +0 -251
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +0 -1
- package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisioned-edges-
|
|
1
|
+
{"version":3,"file":"provisioned-edges-Cxy18aoh-CUnaY96r.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-Cxy18aoh.mjs"],"sourcesContent":["import { n as configKey, t as ORIGIN_KEY_NAME } from \"./serializer-sVE4UAmg.mjs\";\nimport { provisionNeed } from \"@internal/core\";\nimport { type } from \"arktype\";\nimport { RPC_PEER_KEY } from \"@internal/service-rpc\";\n//#region src/origin-key.ts\n/**\n* The service's own origin as a reserved provider param (ADR-0031): the ONE\n* brand and the ONE entry — shared by control.ts (which registers the\n* deploy-side value function that resolves the provisioned service's\n* `endpointDomain` — see its `selfOriginValue`) and compute.ts (which\n* validates and stashes the row at boot through the generic\n* `stashProviderParams` loop), so writer and reader cannot drift.\n*\n* Unlike the key-minting brands (`service-keys.ts`, `streams-keys.ts`) this\n* brand has no provisioner and no consumer edges: the value derives from the\n* service's OWN provisioned attributes, so control.ts registers it as a\n* service-derived provider param (`descriptors/shared.ts`'s\n* `ServiceProviderParam`) and the descriptor writes it for EVERY compute\n* service, exposing or not.\n*\n* This module is reachable from the RUNTIME/authoring side — it must never\n* import `@internal/lowering` or `effect`, or those tokens leak into a user\n* service's bundle (the deploy-side value function lives in control.ts, the\n* control-plane-only entry).\n*/\n/** ADR-0031's brand for the service's own origin — control.ts registers the deploy-side value function under this. */\nconst SELF_ORIGIN = Symbol.for(\"prisma:self-origin\");\n/**\n* The reserved provider param for the origin row: the var name is `ORIGIN`,\n* derived through `configKey` at both ends (`configKey(address, …)` at\n* deploy, `configKey('', …)` — `COMPOSER_ORIGIN` — at boot, where\n* `readOrigin` reads it back). `brand` is `SELF_ORIGIN` — control.ts looks\n* its deploy-side value function up by this field.\n*/\nconst ORIGIN_PARAM = {\n\tname: ORIGIN_KEY_NAME,\n\tschema: type(\"string\"),\n\tbrand: SELF_ORIGIN\n};\n//#endregion\n//#region src/service-keys.ts\n/**\n* RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —\n* name + schema + brand — for the accepted-keys set a provider stores, shared\n* by `control.ts` (which registers the deploy-side `value(refs)` that mints\n* and aggregates it — see its `rpcAcceptedKeysValue`) and `compute.ts` (which\n* validates and stashes it at boot), so writer and reader cannot drift.\n* Finding the edges themselves is `provisioned-edges.ts`'s generic,\n* brand-blind scan — RPC is not special-cased anywhere in this target.\n*\n* This module is reachable from the RUNTIME/authoring side — it must never\n* import `@internal/lowering` or `effect`, or those tokens leak into a user\n* service's bundle (the deploy-side `value(refs)` lives in control.ts, the\n* control-plane-only entry).\n*/\n/**\n* The reserved provider param for RPC's accepted-keys set: the var name is\n* `RPC_ACCEPTED_KEYS`, derived through `configKey` at both ends\n* (`configKey(address, …)` at deploy, `configKey('', …)` at boot — the\n* address-free form is `@internal/service-rpc`'s `RPC_ACCEPTED_KEYS_ENV`). `brand` is\n* `RPC_PEER_KEY`, the same brand `perBindingToken()`'s need carries — control.ts\n* looks its `value(refs)` up by this field.\n*/\nconst RPC_ACCEPTED_KEYS_PARAM = {\n\tname: \"RPC_ACCEPTED_KEYS\",\n\tschema: type(\"string[]\"),\n\tbrand: RPC_PEER_KEY\n};\n//#endregion\n//#region src/streams-keys.ts\n/** ADR-0031's need brand for the streams module's bearer key — control.ts registers the provisioner under this. */\nconst STREAMS_API_KEY = Symbol.for(\"prisma:streams/api-key\");\n/**\n* The provisioning need `durableStreams()`'s `apiKey` param declares: an\n* unguessable value the target mints ONCE PER PROVIDER (not per edge) —\n* `@prisma/streams-server` authenticates a single `API_KEY`, so every\n* consumer of one streams module must present the same value. Per-provider\n* cardinality is provisioner policy (ADR-0031), invisible to core.\n*/\nconst streamsApiKeyNeed = () => provisionNeed(STREAMS_API_KEY);\n/**\n* The reserved provider param for the streams bearer key: the var name is\n* `STREAMS_API_KEY`. `brand` is `STREAMS_API_KEY` itself (the same symbol\n* `streamsApiKeyNeed()`'s need carries) — control.ts looks its `value(refs)`\n* up by this field.\n*/\nconst STREAMS_API_KEY_PARAM = {\n\tname: \"STREAMS_API_KEY\",\n\tschema: type(\"string\"),\n\tbrand: STREAMS_API_KEY\n};\n/** The address-free name compute.ts re-stashes to and the streams entrypoint reads. */\nconst STREAMS_API_KEY_ENV = configKey(\"\", {\n\towner: \"service\",\n\tname: STREAMS_API_KEY_PARAM.name\n});\n//#endregion\n//#region src/provider-params.ts\n/**\n* The list of provider-side reserved params the boot path validates and\n* stashes (ADR-0031): every brand's `{name, schema, brand}` declaration,\n* collected from that brand's own module (`service-keys.ts`,\n* `streams-keys.ts`, `origin-key.ts`) so `compute.ts` names no brand itself.\n*\n* This list exists separately from `control.ts`'s deploy-side registry\n* (`PROVIDER_PARAMS`) because `control.ts` is deploy-only code — it imports\n* `@internal/lowering` and `effect` to mint values — and a booted service\n* must never import it. This module is reachable from a user service's\n* bundle through `compute.ts`, so it must never import `@internal/lowering`,\n* `effect`, `alchemy`, or `control.ts`.\n*\n* This is the single source of which reserved provider params exist:\n* control.ts builds `PROVIDER_PARAMS` by mapping over this list and looking\n* up each entry's deploy-side value function (edge-derived `value(refs)` or\n* service-derived `valueForService(provisioned, address)`) by its `brand`,\n* throwing at module load if one is missing. Adding a brand means adding its\n* entry here, plus its deploy-side value function in control.ts — a brand\n* registered for deploy but absent here is no longer expressible, because\n* deploy no longer names its own param set independently.\n*/\nconst RESERVED_PROVIDER_PARAMS = [\n\tRPC_ACCEPTED_KEYS_PARAM,\n\tSTREAMS_API_KEY_PARAM,\n\tORIGIN_PARAM\n];\n//#endregion\n//#region src/provisioned-edges.ts\n/**\n* Every provisioned edge in the graph. Core resolves and mints these (one\n* value per edge, keyed by `edgeId`); this scan is how the target finds them\n* again when it gathers a provider's inbound values.\n*/\nfunction provisionedEdges(graph) {\n\tconst edges = [];\n\tfor (const edge of graph.edges) {\n\t\tif (edge.kind !== \"dependency\") continue;\n\t\tconst consumer = graph.nodes.find((n) => n.id === edge.to)?.node;\n\t\tif (consumer === void 0 || consumer.kind !== \"service\") continue;\n\t\tconst slot = consumer.inputs[edge.input];\n\t\tif (slot === void 0) continue;\n\t\tfor (const param of Object.values(slot.connection.params)) {\n\t\t\tconst brand = param.provision?.brand;\n\t\t\tif (brand === void 0) continue;\n\t\t\tedges.push({\n\t\t\t\tedgeId: `${edge.to}.${edge.input}`,\n\t\t\t\tconsumerAddress: edge.to,\n\t\t\t\tinput: edge.input,\n\t\t\t\tproviderAddress: edge.from,\n\t\t\t\tbrand\n\t\t\t});\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn edges;\n}\n//#endregion\nexport { streamsApiKeyNeed as a, STREAMS_API_KEY_ENV as i, RESERVED_PROVIDER_PARAMS as n, SELF_ORIGIN as o, STREAMS_API_KEY as r, provisionedEdges as t };\n\n//# sourceMappingURL=provisioned-edges-Cxy18aoh.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,cAAc,OAAO,IAAI,oBAAoB;;;;;;;;AAQnD,MAAM,eAAe;CACpB,MAAM;CACN,QAAQ,KAAK,QAAQ;CACrB,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,0BAA0B;CAC/B,MAAM;CACN,QAAQ,KAAK,UAAU;CACvB,OAAO;AACR;;AAIA,MAAM,kBAAkB,OAAO,IAAI,wBAAwB;;;;;;;;AAQ3D,MAAM,0BAA0B,cAAc,eAAe;;;;;;;AAO7D,MAAM,wBAAwB;CAC7B,MAAM;CACN,QAAQ,KAAK,QAAQ;CACrB,OAAO;AACR;;AAEA,MAAM,sBAAsB,UAAU,IAAI;CACzC,OAAO;CACP,MAAM,sBAAsB;AAC7B,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAyBD,MAAM,2BAA2B;CAChC;CACA;CACA;AACD;;;;;;AAQA,SAAS,iBAAiB,OAAO;CAChC,MAAM,QAAQ,CAAC;CACf,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC/B,IAAI,KAAK,SAAS,cAAc;EAChC,MAAM,WAAW,MAAM,MAAM,MAAM,MAAM,EAAE,OAAO,KAAK,EAAE,CAAC,EAAE;EAC5D,IAAI,aAAa,KAAK,KAAK,SAAS,SAAS,WAAW;EACxD,MAAM,OAAO,SAAS,OAAO,KAAK;EAClC,IAAI,SAAS,KAAK,GAAG;EACrB,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,WAAW,MAAM,GAAG;GAC1D,MAAM,QAAQ,MAAM,WAAW;GAC/B,IAAI,UAAU,KAAK,GAAG;GACtB,MAAM,KAAK;IACV,QAAQ,GAAG,KAAK,GAAG,GAAG,KAAK;IAC3B,iBAAiB,KAAK;IACtB,OAAO,KAAK;IACZ,iBAAiB,KAAK;IACtB;GACD,CAAC;GACD;EACD;CACD;CACA,OAAO;AACR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isParamSource, paramSource } from "@prisma/composer";
|
|
1
|
+
import { isParamSource, paramSource, secretSource } from "@prisma/composer";
|
|
2
2
|
import { blindCast } from "@prisma/composer/casts";
|
|
3
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/
|
|
3
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/secret-BVGxqHxY.mjs
|
|
4
4
|
/**
|
|
5
5
|
* Brands the payload `envParam` builds. Core's `paramSource()` is a public
|
|
6
6
|
* SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;
|
|
@@ -60,7 +60,48 @@ function paramBindingFor(bindings, serviceAddress, slot) {
|
|
|
60
60
|
if (binding === void 0) throw new Error(`param slot "${slot}" of "${serviceAddress}" resolved to a source but has no bound entry in the manifest — Load should have recorded it.`);
|
|
61
61
|
return binding;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Brands the payload `envSecret` builds. Core's `secretSource()` is a public
|
|
65
|
+
* SPI, so a user could bypass `envSecret` and bind a raw `secretSource('x')`;
|
|
66
|
+
* the brand lets `secretName` reject such a source (or another target's) with a
|
|
67
|
+
* clear error instead of reading an absent `.name`.
|
|
68
|
+
*/
|
|
69
|
+
const PRISMA_CLOUD_SECRET_SOURCE = blindCast(Symbol.for("prisma:prisma-cloud-secret-source"));
|
|
70
|
+
const RESERVED_SECRET_PREFIX = "COMPOSER_";
|
|
71
|
+
const POISONED_SECRET_NAMES = /* @__PURE__ */ new Set(["DATABASE_URL", "DATABASE_URL_POOLED"]);
|
|
72
|
+
/**
|
|
73
|
+
* Binds a secret slot to a named Prisma Cloud platform env var (ADR-0029). The
|
|
74
|
+
* value is provisioned out-of-band; only the name is carried. The name may not
|
|
75
|
+
* use the framework's reserved `COMPOSER_` prefix or the poisoned
|
|
76
|
+
* `DATABASE_URL(_POOLED)` keys.
|
|
77
|
+
*/
|
|
78
|
+
function envSecret(name) {
|
|
79
|
+
if (typeof name !== "string" || name.length === 0) throw new Error("envSecret() requires a non-empty platform env-var name, e.g. envSecret('STRIPE_SECRET_KEY').");
|
|
80
|
+
if (name.startsWith(RESERVED_SECRET_PREFIX)) throw new Error(`envSecret name "${name}" may not start with "${RESERVED_SECRET_PREFIX}" — that prefix is reserved for the framework's own generated config keys.`);
|
|
81
|
+
if (POISONED_SECRET_NAMES.has(name)) throw new Error(`envSecret name "${name}" is reserved — ${[...POISONED_SECRET_NAMES].join(" and ")} are poisoned at project provision and cannot back a secret.`);
|
|
82
|
+
return secretSource({
|
|
83
|
+
[PRISMA_CLOUD_SECRET_SOURCE]: true,
|
|
84
|
+
name
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** True only for a payload that `envSecret` built — i.e. one carrying the brand. */
|
|
88
|
+
function isEnvSecretPayload(payload) {
|
|
89
|
+
return typeof payload === "object" && payload !== null && blindCast(payload)[PRISMA_CLOUD_SECRET_SOURCE] === true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Reads the Prisma Cloud env-var name back out of an opaque secret source —
|
|
93
|
+
* an `envSecret` leaf of an input binding (ADR-0042). A source not built by
|
|
94
|
+
* `envSecret` (a raw `secretSource(...)` or another target's source) carries
|
|
95
|
+
* no name — reject it here, with `where` naming the leaf's position, so a
|
|
96
|
+
* foreign source fails early and clearly rather than producing a broken
|
|
97
|
+
* deploy with an undefined name.
|
|
98
|
+
*/
|
|
99
|
+
function secretName(source, where) {
|
|
100
|
+
const payload = source.payload;
|
|
101
|
+
if (!isEnvSecretPayload(payload)) throw new Error(`${where} is bound to a secret source not created by envSecret() — bind secrets with envSecret('NAME') from @prisma/composer-prisma-cloud.`);
|
|
102
|
+
return payload.name;
|
|
103
|
+
}
|
|
63
104
|
//#endregion
|
|
64
|
-
export { paramName as i,
|
|
105
|
+
export { paramName as a, paramBindingFor as i, envSecret as n, secretName as o, isEnvParamSource as r, envParam as t };
|
|
65
106
|
|
|
66
|
-
//# sourceMappingURL=
|
|
107
|
+
//# sourceMappingURL=secret-BVGxqHxY-DYDfiULl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-BVGxqHxY-DYDfiULl.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/secret-BVGxqHxY.mjs"],"sourcesContent":["import { isParamSource, paramSource, secretSource } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/param.ts\n/**\n* Brands the payload `envParam` builds. Core's `paramSource()` is a public\n* SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;\n* the brand lets `paramName` reject such a source (or another target's) with\n* a clear error instead of reading an absent `.name`.\n*/\nconst PRISMA_CLOUD_PARAM_SOURCE = blindCast(Symbol.for(\"prisma:prisma-cloud-param-source\"));\nconst RESERVED_PARAM_PREFIX = \"COMPOSER_\";\nconst POISONED_PARAM_NAMES = /* @__PURE__ */ new Set([\"DATABASE_URL\", \"DATABASE_URL_POOLED\"]);\n/**\n* Binds a param slot to a named Prisma Cloud platform env var — the non-secret\n* sibling of `envSecret` (spec: env-sourced config params). The platform\n* injects the value into the running instance per stage; the param's own\n* schema validates it at boot, unredacted. The name may not use the\n* framework's reserved `COMPOSER_` prefix or the poisoned\n* `DATABASE_URL(_POOLED)` keys — same parity as `envSecret`.\n*/\nfunction envParam(name) {\n\tif (typeof name !== \"string\" || name.length === 0) throw new Error(\"envParam() requires a non-empty platform env-var name, e.g. envParam('APP_ORIGIN').\");\n\tif (name.startsWith(RESERVED_PARAM_PREFIX)) throw new Error(`envParam name \"${name}\" may not start with \"${RESERVED_PARAM_PREFIX}\" — that prefix is reserved for the framework's own generated config keys.`);\n\tif (POISONED_PARAM_NAMES.has(name)) throw new Error(`envParam name \"${name}\" is reserved — ${[...POISONED_PARAM_NAMES].join(\" and \")} are poisoned at project provision and cannot back a param.`);\n\treturn paramSource({\n\t\t[PRISMA_CLOUD_PARAM_SOURCE]: true,\n\t\tname\n\t});\n}\n/** True only for a payload that `envParam` built — i.e. one carrying the brand. */\nfunction isEnvParamPayload(payload) {\n\treturn typeof payload === \"object\" && payload !== null && blindCast(payload)[PRISMA_CLOUD_PARAM_SOURCE] === true;\n}\n/** True iff a resolved param value is an env-sourced pointer this target built (as opposed to a literal, or a foreign/raw `ParamSource`). */\nfunction isEnvParamSource(value) {\n\treturn isParamSource(value) && isEnvParamPayload(value.payload);\n}\n/**\n* Reads the Prisma Cloud env-var name back out of a param binding's opaque\n* source. A source not built by `envParam` (a raw `paramSource(...)` or\n* another target's source) carries no name — reject it here. `paramName` runs\n* in preflight and at serialize before any value ever crosses the wire, so a\n* foreign source fails early and clearly rather than producing a broken\n* deploy with an undefined name.\n*/\nfunction paramName(binding) {\n\tconst { binding: bound } = binding;\n\tif (!isEnvParamSource(bound)) throw new Error(`param slot \"${binding.slot}\" of service \"${binding.serviceAddress}\" is bound to a source not created by envParam() — bind env-sourced params with envParam('NAME') from @prisma/composer-prisma-cloud.`);\n\treturn bound.payload.name;\n}\n/**\n* Finds the manifest entry for one service param slot. `serialize` calls this\n* only after confirming `buildConfig` resolved the slot to a `ParamSource`\n* (`isParamSource(value)`), so a miss here means `graph.params` and the\n* resolved `Config` have drifted — a Load invariant violation, surfaced\n* loudly rather than producing a pointer row with an undefined name.\n*/\nfunction paramBindingFor(bindings, serviceAddress, slot) {\n\tconst binding = bindings.find((b) => b.serviceAddress === serviceAddress && b.slot === slot);\n\tif (binding === void 0) throw new Error(`param slot \"${slot}\" of \"${serviceAddress}\" resolved to a source but has no bound entry in the manifest — Load should have recorded it.`);\n\treturn binding;\n}\n//#endregion\n//#region src/secret.ts\n/**\n* Brands the payload `envSecret` builds. Core's `secretSource()` is a public\n* SPI, so a user could bypass `envSecret` and bind a raw `secretSource('x')`;\n* the brand lets `secretName` reject such a source (or another target's) with a\n* clear error instead of reading an absent `.name`.\n*/\nconst PRISMA_CLOUD_SECRET_SOURCE = blindCast(Symbol.for(\"prisma:prisma-cloud-secret-source\"));\nconst RESERVED_SECRET_PREFIX = \"COMPOSER_\";\nconst POISONED_SECRET_NAMES = /* @__PURE__ */ new Set([\"DATABASE_URL\", \"DATABASE_URL_POOLED\"]);\n/**\n* Binds a secret slot to a named Prisma Cloud platform env var (ADR-0029). The\n* value is provisioned out-of-band; only the name is carried. The name may not\n* use the framework's reserved `COMPOSER_` prefix or the poisoned\n* `DATABASE_URL(_POOLED)` keys.\n*/\nfunction envSecret(name) {\n\tif (typeof name !== \"string\" || name.length === 0) throw new Error(\"envSecret() requires a non-empty platform env-var name, e.g. envSecret('STRIPE_SECRET_KEY').\");\n\tif (name.startsWith(RESERVED_SECRET_PREFIX)) throw new Error(`envSecret name \"${name}\" may not start with \"${RESERVED_SECRET_PREFIX}\" — that prefix is reserved for the framework's own generated config keys.`);\n\tif (POISONED_SECRET_NAMES.has(name)) throw new Error(`envSecret name \"${name}\" is reserved — ${[...POISONED_SECRET_NAMES].join(\" and \")} are poisoned at project provision and cannot back a secret.`);\n\treturn secretSource({\n\t\t[PRISMA_CLOUD_SECRET_SOURCE]: true,\n\t\tname\n\t});\n}\n/** True only for a payload that `envSecret` built — i.e. one carrying the brand. */\nfunction isEnvSecretPayload(payload) {\n\treturn typeof payload === \"object\" && payload !== null && blindCast(payload)[PRISMA_CLOUD_SECRET_SOURCE] === true;\n}\n/**\n* Reads the Prisma Cloud env-var name back out of an opaque secret source —\n* an `envSecret` leaf of an input binding (ADR-0042). A source not built by\n* `envSecret` (a raw `secretSource(...)` or another target's source) carries\n* no name — reject it here, with `where` naming the leaf's position, so a\n* foreign source fails early and clearly rather than producing a broken\n* deploy with an undefined name.\n*/\nfunction secretName(source, where) {\n\tconst payload = source.payload;\n\tif (!isEnvSecretPayload(payload)) throw new Error(`${where} is bound to a secret source not created by envSecret() — bind secrets with envSecret('NAME') from @prisma/composer-prisma-cloud.`);\n\treturn payload.name;\n}\n//#endregion\nexport { paramBindingFor as a, isEnvParamSource as i, secretName as n, paramName as o, envParam as r, envSecret as t };\n\n//# sourceMappingURL=secret-BVGxqHxY.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,4BAA4B,UAAU,OAAO,IAAI,kCAAkC,CAAC;AAC1F,MAAM,wBAAwB;AAC9B,MAAM,uCAAuC,IAAI,IAAI,CAAC,gBAAgB,qBAAqB,CAAC;;;;;;;;;AAS5F,SAAS,SAAS,MAAM;CACvB,IAAI,OAAO,SAAS,YAAY,KAAK,WAAW,GAAG,MAAM,IAAI,MAAM,qFAAqF;CACxJ,IAAI,KAAK,WAAW,qBAAqB,GAAG,MAAM,IAAI,MAAM,kBAAkB,KAAK,wBAAwB,sBAAsB,2EAA2E;CAC5M,IAAI,qBAAqB,IAAI,IAAI,GAAG,MAAM,IAAI,MAAM,kBAAkB,KAAK,kBAAkB,CAAC,GAAG,oBAAoB,CAAC,CAAC,KAAK,OAAO,EAAE,4DAA4D;CACjM,OAAO,YAAY;GACjB,4BAA4B;EAC7B;CACD,CAAC;AACF;;AAEA,SAAS,kBAAkB,SAAS;CACnC,OAAO,OAAO,YAAY,YAAY,YAAY,QAAQ,UAAU,OAAO,CAAC,CAAC,+BAA+B;AAC7G;;AAEA,SAAS,iBAAiB,OAAO;CAChC,OAAO,cAAc,KAAK,KAAK,kBAAkB,MAAM,OAAO;AAC/D;;;;;;;;;AASA,SAAS,UAAU,SAAS;CAC3B,MAAM,EAAE,SAAS,UAAU;CAC3B,IAAI,CAAC,iBAAiB,KAAK,GAAG,MAAM,IAAI,MAAM,eAAe,QAAQ,KAAK,gBAAgB,QAAQ,eAAe,qIAAqI;CACtP,OAAO,MAAM,QAAQ;AACtB;;;;;;;;AAQA,SAAS,gBAAgB,UAAU,gBAAgB,MAAM;CACxD,MAAM,UAAU,SAAS,MAAM,MAAM,EAAE,mBAAmB,kBAAkB,EAAE,SAAS,IAAI;CAC3F,IAAI,YAAY,KAAK,GAAG,MAAM,IAAI,MAAM,eAAe,KAAK,QAAQ,eAAe,8FAA8F;CACjL,OAAO;AACR;;;;;;;AASA,MAAM,6BAA6B,UAAU,OAAO,IAAI,mCAAmC,CAAC;AAC5F,MAAM,yBAAyB;AAC/B,MAAM,wCAAwC,IAAI,IAAI,CAAC,gBAAgB,qBAAqB,CAAC;;;;;;;AAO7F,SAAS,UAAU,MAAM;CACxB,IAAI,OAAO,SAAS,YAAY,KAAK,WAAW,GAAG,MAAM,IAAI,MAAM,8FAA8F;CACjK,IAAI,KAAK,WAAW,sBAAsB,GAAG,MAAM,IAAI,MAAM,mBAAmB,KAAK,wBAAwB,uBAAuB,2EAA2E;CAC/M,IAAI,sBAAsB,IAAI,IAAI,GAAG,MAAM,IAAI,MAAM,mBAAmB,KAAK,kBAAkB,CAAC,GAAG,qBAAqB,CAAC,CAAC,KAAK,OAAO,EAAE,6DAA6D;CACrM,OAAO,aAAa;GAClB,6BAA6B;EAC9B;CACD,CAAC;AACF;;AAEA,SAAS,mBAAmB,SAAS;CACpC,OAAO,OAAO,YAAY,YAAY,YAAY,QAAQ,UAAU,OAAO,CAAC,CAAC,gCAAgC;AAC9G;;;;;;;;;AASA,SAAS,WAAW,QAAQ,OAAO;CAClC,MAAM,UAAU,OAAO;CACvB,IAAI,CAAC,mBAAmB,OAAO,GAAG,MAAM,IAAI,MAAM,GAAG,MAAM,kIAAkI;CAC7L,OAAO,QAAQ;AAChB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigParam } from "@prisma/composer";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-
|
|
3
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-BD_6nkr4.d.mts
|
|
4
4
|
//#region src/serializer.d.ts
|
|
5
5
|
/** One declared param, paired with its owner and the raw ConfigParam (functions included). */
|
|
6
6
|
interface ParamEntry {
|
|
@@ -33,4 +33,4 @@ interface ProviderParamEntry {
|
|
|
33
33
|
}
|
|
34
34
|
//#endregion
|
|
35
35
|
export { configKey as n, ProviderParamEntry as t };
|
|
36
|
-
//# sourceMappingURL=serializer-
|
|
36
|
+
//# sourceMappingURL=serializer-BD_6nkr4-DWn5NNTC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer-BD_6nkr4-DWn5NNTC.d.mts","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/serializer-BD_6nkr4.d.mts"],"mappings":";;;;;UAKU;WACC;aACE;;WAEF;WACA,OAAO;;cAEJ,YAAY,iBAAiB;EACzC,OAAO;EACP;;;;;;;;;;;;;;UAcQ;WACC;WACA,QAAQ;WACR"}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { o as secretName, r as isEnvParamSource } from "./secret-BVGxqHxY-DYDfiULl.mjs";
|
|
2
|
+
import { isParamSource, isSecretSource } from "@prisma/composer";
|
|
3
|
+
import { blindCast } from "@prisma/composer/casts";
|
|
4
|
+
import { type } from "arktype";
|
|
5
|
+
//#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
|
|
6
|
+
/**
|
|
7
|
+
* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
|
|
8
|
+
*
|
|
9
|
+
* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes
|
|
10
|
+
* unnecessary**: tighten an input type, add a runtime check that narrows via a type
|
|
11
|
+
* predicate, restructure a generic so the compiler can see the relationship you're
|
|
12
|
+
* asserting, or use {@link castAs} when the value already satisfies the target type.
|
|
13
|
+
* Only when no rewrite is feasible does `blindCast` become the right answer — and at
|
|
14
|
+
* that point, the `Reason` literal you supply must articulate the compromise in
|
|
15
|
+
* language a reviewer can evaluate.
|
|
16
|
+
*
|
|
17
|
+
* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,
|
|
18
|
+
* that is not a signal to soften the reason; it is a signal to go back and solve the
|
|
19
|
+
* underlying type-system problem properly. An unconvincing justification is rework,
|
|
20
|
+
* not a free pass.
|
|
21
|
+
*
|
|
22
|
+
* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses
|
|
23
|
+
* the compiler's checks (the input type is `unknown`, the output type is whatever the
|
|
24
|
+
* caller asks for), but it forces the unsafety to be named at the call site instead of
|
|
25
|
+
* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile
|
|
26
|
+
* time — it is not present in the emitted JavaScript — but it is grep-able and
|
|
27
|
+
* visible to future readers.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const stringValue = blindCast<
|
|
32
|
+
* string,
|
|
33
|
+
* "JSON.parse returns `unknown`; this field is documented to be a string in the API contract"
|
|
34
|
+
* >(parsed[key]);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @typeParam TargetType - The type the caller is asserting the input has.
|
|
38
|
+
* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.
|
|
39
|
+
* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.
|
|
40
|
+
*/
|
|
41
|
+
function blindCast$1(input) {
|
|
42
|
+
return input;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
|
|
46
|
+
/**
|
|
47
|
+
* A value wrapper that redacts everywhere except the one explicit reader,
|
|
48
|
+
* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
|
|
49
|
+
* sink must remember to check: `String(box)`, template interpolation,
|
|
50
|
+
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
51
|
+
* a secret can't leak through an accidental log or serialization.
|
|
52
|
+
*
|
|
53
|
+
* Every box carries a brand property keyed by the registered symbol
|
|
54
|
+
* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
|
|
55
|
+
* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
|
|
56
|
+
* public shape still matches the platform's own `secrecy` type
|
|
57
|
+
* (pdp-control-plane).
|
|
58
|
+
*/
|
|
59
|
+
const REDACTED = "[REDACTED]";
|
|
60
|
+
const SECRET_BOX = blindCast$1(Symbol.for("prisma:secret-box"));
|
|
61
|
+
var SecretBox = class {
|
|
62
|
+
[SECRET_BOX] = true;
|
|
63
|
+
#value;
|
|
64
|
+
constructor(value) {
|
|
65
|
+
this.#value = value;
|
|
66
|
+
}
|
|
67
|
+
/** The sole explicit door to the wrapped value. */
|
|
68
|
+
expose() {
|
|
69
|
+
return this.#value;
|
|
70
|
+
}
|
|
71
|
+
toString() {
|
|
72
|
+
return REDACTED;
|
|
73
|
+
}
|
|
74
|
+
toJSON() {
|
|
75
|
+
return REDACTED;
|
|
76
|
+
}
|
|
77
|
+
valueOf() {
|
|
78
|
+
return REDACTED;
|
|
79
|
+
}
|
|
80
|
+
[Symbol.toPrimitive]() {
|
|
81
|
+
return REDACTED;
|
|
82
|
+
}
|
|
83
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
84
|
+
return REDACTED;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-sVE4UAmg.mjs
|
|
89
|
+
/**
|
|
90
|
+
* Walks a node's own params, then each dependency input's connection params —
|
|
91
|
+
* the same enumeration order `configOf` uses, but carrying the raw
|
|
92
|
+
* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
|
|
93
|
+
* projection.
|
|
94
|
+
*/
|
|
95
|
+
function paramEntries(node) {
|
|
96
|
+
const entries = [];
|
|
97
|
+
for (const [input, value] of Object.entries(node.inputs)) {
|
|
98
|
+
if (typeof value !== "object" || value === null) continue;
|
|
99
|
+
const params = blindCast(value).connection.params;
|
|
100
|
+
for (const [name, param] of Object.entries(params)) entries.push({
|
|
101
|
+
owner: { input },
|
|
102
|
+
name,
|
|
103
|
+
param
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
for (const [name, param] of Object.entries(node.params)) entries.push({
|
|
107
|
+
owner: "service",
|
|
108
|
+
name,
|
|
109
|
+
param
|
|
110
|
+
});
|
|
111
|
+
return entries;
|
|
112
|
+
}
|
|
113
|
+
const configKey = (address, d) => {
|
|
114
|
+
const segments = address.split(".").filter((s) => s.length > 0);
|
|
115
|
+
const owner = d.owner === "service" ? [] : [d.owner.input];
|
|
116
|
+
return [
|
|
117
|
+
"COMPOSER",
|
|
118
|
+
...segments,
|
|
119
|
+
...owner,
|
|
120
|
+
d.name
|
|
121
|
+
].join("_").toUpperCase();
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Typed value → its stored string. Service-own literals are JSON-encoded; a
|
|
125
|
+
* dependency-input value is a provisioning ref at deploy (and a resolved
|
|
126
|
+
* string at boot) and passes through untouched — LANDMINE: JSON-encoding it
|
|
127
|
+
* would break the ordering edge Alchemy resolves through it.
|
|
128
|
+
*/
|
|
129
|
+
function encode(owner, value) {
|
|
130
|
+
return owner === "service" ? JSON.stringify(value) : blindCast(value);
|
|
131
|
+
}
|
|
132
|
+
/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
|
|
133
|
+
function decode(owner, raw) {
|
|
134
|
+
return owner === "service" ? JSON.parse(raw) : raw;
|
|
135
|
+
}
|
|
136
|
+
const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
|
|
137
|
+
/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
|
|
138
|
+
const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
|
|
139
|
+
/** Builds a param pointer row's stored value from the platform var NAME it points to. */
|
|
140
|
+
const encodeParamPointer = (name) => `${PARAM_POINTER_PREFIX}${name}`;
|
|
141
|
+
/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
|
|
142
|
+
const decodeParamPointer = (raw) => raw.slice(24);
|
|
143
|
+
function coerce(raw, d, key) {
|
|
144
|
+
if (!(raw !== void 0 && raw !== "")) {
|
|
145
|
+
if (d.param.default !== void 0) return d.param.default;
|
|
146
|
+
if (d.param.optional === true) return void 0;
|
|
147
|
+
throw new Error(`missing required config param "${d.name}" (env ${key})`);
|
|
148
|
+
}
|
|
149
|
+
if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
|
|
150
|
+
try {
|
|
151
|
+
return standardValidateSync(d.param.schema, decode(d.owner, raw));
|
|
152
|
+
} catch (cause) {
|
|
153
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
154
|
+
throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Boot resolution for an env-sourced param: double-lookup (pointer → platform
|
|
159
|
+
* var), then the param's own schema on the raw string — no JSON decode, and
|
|
160
|
+
* no redaction (it's config, not a secret). An UNSET platform var is a loud
|
|
161
|
+
* boot failure naming both the param and the platform var; an EMPTY string is
|
|
162
|
+
* not special-cased here — it reaches the schema like any other value, so it
|
|
163
|
+
* passes iff the schema accepts it (deliberately unlike a literal param's own
|
|
164
|
+
* ""-means-absent rule, and unlike a secret's non-empty requirement).
|
|
165
|
+
*/
|
|
166
|
+
function coerceEnvSourcedParam(raw, d, key) {
|
|
167
|
+
const platformVar = decodeParamPointer(raw);
|
|
168
|
+
const value = process.env[platformVar];
|
|
169
|
+
if (value === void 0) throw new Error(`env-sourced config param "${d.name}" (env ${key} → ${platformVar}) is unset: the platform variable "${platformVar}" was not injected — the deploy did not provision it.`);
|
|
170
|
+
try {
|
|
171
|
+
return standardValidateSync(d.param.schema, value);
|
|
172
|
+
} catch (cause) {
|
|
173
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
174
|
+
throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Boot: read each declared param from env by its key, reverse the param's own
|
|
179
|
+
* serialization (missing/invalid fails loudly), assemble the typed Config.
|
|
180
|
+
* The input document rides its own channel (readInput), not this one.
|
|
181
|
+
*/
|
|
182
|
+
const deserialize = (node, address) => {
|
|
183
|
+
const service = {};
|
|
184
|
+
const inputs = {};
|
|
185
|
+
for (const d of paramEntries(node)) {
|
|
186
|
+
const key = configKey(address, d);
|
|
187
|
+
const value = coerce(process.env[key], d, key);
|
|
188
|
+
if (d.owner === "service") service[d.name] = value;
|
|
189
|
+
else {
|
|
190
|
+
let bucket = inputs[d.owner.input];
|
|
191
|
+
if (bucket === void 0) {
|
|
192
|
+
bucket = {};
|
|
193
|
+
inputs[d.owner.input] = bucket;
|
|
194
|
+
}
|
|
195
|
+
bucket[d.name] = value;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
service,
|
|
200
|
+
inputs
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* run()'s setup step: write the resolved config to the environment under
|
|
205
|
+
* address-free keys (configKey("", d) + each serialize suffix), which load()
|
|
206
|
+
* reads back with no address. Uses env, not a module variable, because a
|
|
207
|
+
* framework may fork worker processes that inherit env but not memory.
|
|
208
|
+
* Writes only these keys; nothing else is touched.
|
|
209
|
+
*/
|
|
210
|
+
const stash = (node, config) => {
|
|
211
|
+
for (const d of paramEntries(node)) {
|
|
212
|
+
const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
|
|
213
|
+
if (value === void 0) continue;
|
|
214
|
+
process.env[configKey("", d)] = encode(d.owner, value);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
/** The input document's own row name; its full key is COMPOSER_<addr>_INPUT. */
|
|
218
|
+
const INPUT_KEY_NAME = "INPUT";
|
|
219
|
+
/** The input document row's key for a service address. */
|
|
220
|
+
const inputKey = (address) => configKey(address, {
|
|
221
|
+
owner: "service",
|
|
222
|
+
name: INPUT_KEY_NAME
|
|
223
|
+
});
|
|
224
|
+
const SECRET_MARKER = "$secret";
|
|
225
|
+
const ESCAPABLE_KEY = /^\$+secret$/;
|
|
226
|
+
const ESCAPED_KEY = /^\$\$+secret$/;
|
|
227
|
+
/** True for the framework's secret pointer: `{ "$secret": "<PLATFORM_VAR>" }` and nothing else. */
|
|
228
|
+
function isSecretPointer(value) {
|
|
229
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && SECRET_MARKER in value && typeof value[SECRET_MARKER] === "string";
|
|
230
|
+
}
|
|
231
|
+
/** A plain data object (not an array, not a class instance) — the only object shape a binding/document may nest. */
|
|
232
|
+
function isPlainObject(value) {
|
|
233
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
234
|
+
const proto = Object.getPrototypeOf(value);
|
|
235
|
+
return proto === Object.prototype || proto === null;
|
|
236
|
+
}
|
|
237
|
+
const ABSENT = Symbol("composer-input-absent");
|
|
238
|
+
/**
|
|
239
|
+
* Deploy: recursive descent over the provision-time binding (plain data).
|
|
240
|
+
* `envSecret` leaves become empty sentinel `SecretBox`es (the value never
|
|
241
|
+
* enters the deploy); `envParam` leaves read the deploy shell — unset or
|
|
242
|
+
* empty means the enclosing object key is OMITTED, and the schema arbitrates
|
|
243
|
+
* whether that absence is legal (ADR-0042). Everything non-plain (a class
|
|
244
|
+
* instance, a function, a raw SecretBox holding a value) is rejected loudly.
|
|
245
|
+
*/
|
|
246
|
+
function resolveInputBinding(binding, env) {
|
|
247
|
+
const sentinels = /* @__PURE__ */ new Map();
|
|
248
|
+
const absent = [];
|
|
249
|
+
const walk = (value, path) => {
|
|
250
|
+
if (isSecretSource(value)) {
|
|
251
|
+
const name = secretName(value, path === "" ? "the input binding root" : `input key "${path}"`);
|
|
252
|
+
const sentinel = new SecretBox("");
|
|
253
|
+
sentinels.set(sentinel, name);
|
|
254
|
+
return sentinel;
|
|
255
|
+
}
|
|
256
|
+
if (isParamSource(value)) {
|
|
257
|
+
if (!isEnvParamSource(value)) throw new Error(`input binding${path === "" ? "" : ` key "${path}"`} is bound to a param source not created by envParam() — bind env-sourced input values with envParam('NAME') from @prisma/composer-prisma-cloud.`);
|
|
258
|
+
const raw = env[value.payload.name];
|
|
259
|
+
if (raw === void 0 || raw === "") {
|
|
260
|
+
absent.push(path === "" ? `(root) → ${value.payload.name}` : `${path} → ${value.payload.name}`);
|
|
261
|
+
return ABSENT;
|
|
262
|
+
}
|
|
263
|
+
return raw;
|
|
264
|
+
}
|
|
265
|
+
if (Array.isArray(value)) return value.map((member, index) => {
|
|
266
|
+
const resolvedMember = walk(member, path === "" ? String(index) : `${path}.${index}`);
|
|
267
|
+
if (resolvedMember === ABSENT) throw new Error(`input binding key "${path}[${index}]" is an env-bound array element whose variable is unset — an array position cannot be omitted; bind a literal or provision the variable.`);
|
|
268
|
+
return resolvedMember;
|
|
269
|
+
});
|
|
270
|
+
if (isPlainObject(value)) {
|
|
271
|
+
const out = {};
|
|
272
|
+
for (const [key, member] of Object.entries(value)) {
|
|
273
|
+
const resolvedMember = walk(member, path === "" ? key : `${path}.${key}`);
|
|
274
|
+
if (resolvedMember === ABSENT) continue;
|
|
275
|
+
out[key] = resolvedMember;
|
|
276
|
+
}
|
|
277
|
+
return out;
|
|
278
|
+
}
|
|
279
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
280
|
+
throw new Error(`input binding${path === "" ? "" : ` key "${path}"`} holds a value that is not plain data (${typeof value === "object" ? "a non-plain object" : `a ${typeof value}`}) — a binding's leaves are literals, envParam(...), or envSecret(...) (ADR-0042). A secret VALUE (e.g. a SecretBox) never belongs in a binding — bind envSecret('NAME') instead.`);
|
|
281
|
+
};
|
|
282
|
+
const resolved = walk(binding, "");
|
|
283
|
+
return {
|
|
284
|
+
resolved: resolved === ABSENT ? void 0 : resolved,
|
|
285
|
+
sentinels,
|
|
286
|
+
absent
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Deploy: resolve the binding, judge it with the service's own schema
|
|
291
|
+
* (secrets as opaque sentinel boxes), and serialize the defaults-applied
|
|
292
|
+
* VALIDATED output — pointers substituted back where the sentinels sit — into
|
|
293
|
+
* one JSON row. Returns `undefined` for a service with no input schema.
|
|
294
|
+
* A validation failure that mentions a secret leaf means either a
|
|
295
|
+
* misclassified binding (a literal where the schema wants a `SecretString`,
|
|
296
|
+
* or vice versa) or a schema refining on secret CONTENT — deploy-time
|
|
297
|
+
* validation sees only empty boxes, and the ADR forbids content refinements.
|
|
298
|
+
*/
|
|
299
|
+
function serializeInput(node, address, binding, env = process.env) {
|
|
300
|
+
const schema = node.inputSchema;
|
|
301
|
+
if (schema === void 0) {
|
|
302
|
+
if (binding !== void 0) throw new Error(`service "${address}" has an input binding but declares no input schema — Load should have rejected it (ADR-0042).`);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (binding === void 0) throw new Error(`service "${address}" declares an input schema but has no recorded input binding — Load should have required it (ADR-0042).`);
|
|
306
|
+
const { resolved, sentinels, absent } = resolveInputBinding(binding, env);
|
|
307
|
+
let validated;
|
|
308
|
+
try {
|
|
309
|
+
validated = standardValidateSync(schema, resolved);
|
|
310
|
+
} catch (cause) {
|
|
311
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
312
|
+
throw new Error(`invalid input for service "${address}": ${message}\n(Deploy-time validation sees each envSecret leaf as an opaque, empty SecretString box. A failure naming a secret field means the binding and schema disagree about its secretness, or the schema refines on secret content — which ADR-0042 forbids.)`);
|
|
313
|
+
}
|
|
314
|
+
const document = substituteSecretPointers(validated, sentinels, address);
|
|
315
|
+
return {
|
|
316
|
+
key: inputKey(address),
|
|
317
|
+
value: JSON.stringify(document),
|
|
318
|
+
absent
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Walks the VALIDATED output, mapping each sentinel box (by identity) back to
|
|
323
|
+
* its `{ "$secret": name }` pointer and escaping any user key that matches
|
|
324
|
+
* the reserved marker. A `SecretString` the walk does not recognize came from
|
|
325
|
+
* the schema itself (a default or transform minting a box) — there is no
|
|
326
|
+
* platform var behind it, so it is rejected rather than serialized.
|
|
327
|
+
*/
|
|
328
|
+
function substituteSecretPointers(value, sentinels, address) {
|
|
329
|
+
const walk = (v, path) => {
|
|
330
|
+
if (v instanceof SecretBox) {
|
|
331
|
+
const name = sentinels.get(v);
|
|
332
|
+
if (name === void 0) throw new Error(`input key "${path}" of service "${address}" validated to a SecretString the binding did not supply — a schema must not mint secret boxes (a default/transform cannot name a platform variable); bind the field with envSecret('NAME') instead.`);
|
|
333
|
+
return { [SECRET_MARKER]: name };
|
|
334
|
+
}
|
|
335
|
+
if (Array.isArray(v)) return v.map((m, i) => walk(m, `${path}[${i}]`));
|
|
336
|
+
if (isPlainObject(v)) {
|
|
337
|
+
const out = {};
|
|
338
|
+
for (const [key, member] of Object.entries(v)) {
|
|
339
|
+
if (member === void 0) continue;
|
|
340
|
+
const written = ESCAPABLE_KEY.test(key) ? `$${key}` : key;
|
|
341
|
+
out[written] = walk(member, path === "" ? key : `${path}.${key}`);
|
|
342
|
+
}
|
|
343
|
+
return out;
|
|
344
|
+
}
|
|
345
|
+
if (v === null || v === void 0 || typeof v === "string" || typeof v === "number" || typeof v === "boolean") return v;
|
|
346
|
+
throw new Error(`input key "${path}" of service "${address}" validated to a value that cannot be serialized (a ${typeof v === "object" ? "non-plain object" : typeof v}) — the input document is plain JSON (ADR-0042).`);
|
|
347
|
+
};
|
|
348
|
+
return walk(value, "");
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Boot: read the one input document row (address-free after run()'s
|
|
352
|
+
* re-stash), swap each `$secret` pointer for a redacting box over the named
|
|
353
|
+
* platform var, unescape reserved keys, validate with the service's own
|
|
354
|
+
* schema, and return the typed object. A missing row is a loud failure naming
|
|
355
|
+
* the env var — a deployed environment always writes it; a local harness must
|
|
356
|
+
* supply it (set the row to the serialized input document).
|
|
357
|
+
*/
|
|
358
|
+
function readInput(node, address) {
|
|
359
|
+
const schema = node.inputSchema;
|
|
360
|
+
if (schema === void 0) throw new Error(`input() called on service "${node.name}", which declares no input schema — declare \`input: <schema>\` on compute() to use it (ADR-0042).`);
|
|
361
|
+
const key = inputKey(address);
|
|
362
|
+
const raw = process.env[key];
|
|
363
|
+
if (raw === void 0 || raw === "") throw new Error(`this service's input is not available (env ${key} is unset) — a deployed environment writes it automatically; a local harness must supply it like any other config value (set ${key} to the serialized input document).`);
|
|
364
|
+
let parsed;
|
|
365
|
+
try {
|
|
366
|
+
parsed = JSON.parse(raw);
|
|
367
|
+
} catch (cause) {
|
|
368
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
369
|
+
throw new Error(`this service's input document is not valid JSON (env ${key}): ${message} — a deployed environment writes it automatically; a local harness must supply the serialized input document (set ${key} to it).`);
|
|
370
|
+
}
|
|
371
|
+
const hydrated = hydrateInputDocument(parsed, key);
|
|
372
|
+
try {
|
|
373
|
+
return standardValidateSync(schema, hydrated);
|
|
374
|
+
} catch (cause) {
|
|
375
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
376
|
+
throw new Error(`invalid input document (env ${key}): ${message}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/** Reverses the document encoding: `$secret` pointers become redacting boxes over the named platform vars; escaped reserved keys drop one "$". */
|
|
380
|
+
function hydrateInputDocument(value, key) {
|
|
381
|
+
if (isSecretPointer(value)) {
|
|
382
|
+
const name = value[SECRET_MARKER];
|
|
383
|
+
const secret = process.env[name];
|
|
384
|
+
if (secret === void 0 || secret === "") throw new Error(`secret input is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
|
|
385
|
+
return new SecretBox(secret);
|
|
386
|
+
}
|
|
387
|
+
if (Array.isArray(value)) return value.map((member) => hydrateInputDocument(member, key));
|
|
388
|
+
if (isPlainObject(value)) {
|
|
389
|
+
const out = {};
|
|
390
|
+
for (const [k, member] of Object.entries(value)) {
|
|
391
|
+
const read = ESCAPED_KEY.test(k) ? k.slice(1) : k;
|
|
392
|
+
out[read] = hydrateInputDocument(member, key);
|
|
393
|
+
}
|
|
394
|
+
return out;
|
|
395
|
+
}
|
|
396
|
+
return value;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* run()'s setup step for the input document: re-emit the row under its
|
|
400
|
+
* address-free key, so the address-free `readInput` reads identically. The
|
|
401
|
+
* document carries pointers, never values — the values stay only in their
|
|
402
|
+
* platform vars.
|
|
403
|
+
*/
|
|
404
|
+
const stashInput = (node, address) => {
|
|
405
|
+
if (node.inputSchema === void 0) return;
|
|
406
|
+
const raw = process.env[inputKey(address)];
|
|
407
|
+
if (raw === void 0) return;
|
|
408
|
+
process.env[inputKey("")] = raw;
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Boot: for each reserved provider param, read its address-scoped row through
|
|
412
|
+
* the same `coerce` a declared param uses (JSON-decode, schema-validate), and
|
|
413
|
+
* re-emit it address-free — `stash`'s counterpart for this separate
|
|
414
|
+
* declaration space. A param is declared optional here unconditionally: an
|
|
415
|
+
* absent row means "never provisioned" (local dev, tests, a provider with no
|
|
416
|
+
* registered value for this deploy), never a boot failure, so nothing is
|
|
417
|
+
* stashed and the runtime reader that owns this slot falls back to its own
|
|
418
|
+
* pass-through behavior.
|
|
419
|
+
*/
|
|
420
|
+
function stashProviderParams(entries, address) {
|
|
421
|
+
for (const entry of entries) {
|
|
422
|
+
const d = {
|
|
423
|
+
owner: "service",
|
|
424
|
+
name: entry.name,
|
|
425
|
+
param: {
|
|
426
|
+
schema: entry.schema,
|
|
427
|
+
optional: true
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const key = configKey(address, d);
|
|
431
|
+
const value = coerce(process.env[key], d, key);
|
|
432
|
+
if (value === void 0) continue;
|
|
433
|
+
process.env[configKey("", d)] = encode("service", value);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/** The framework-resolved origin row: COMPOSER_<addr>_ORIGIN. Written per
|
|
437
|
+
* compute service at serialize — the service's own provisioned endpoint URL,
|
|
438
|
+
* riding the reserved-provider-param machinery (`origin-key.ts`'s
|
|
439
|
+
* `ORIGIN_PARAM`); never a declared param, never in config(). A harness with
|
|
440
|
+
* no deploy behind it supplies it by setting `COMPOSER_ORIGIN` to the
|
|
441
|
+
* JSON-encoded origin URL — exactly how the existing entrypoint tests supply
|
|
442
|
+
* their other `COMPOSER_*` rows. */
|
|
443
|
+
const ORIGIN_KEY_NAME = "ORIGIN";
|
|
444
|
+
/**
|
|
445
|
+
* Reads this service's origin back out of the address-free stash
|
|
446
|
+
* `stashProviderParams` wrote for the ORIGIN entry. `COMPOSER_ORIGIN` unset is
|
|
447
|
+
* a loud failure — a deployed environment always writes it, so an unset row
|
|
448
|
+
* means either a local harness that hasn't supplied it or a boot() called
|
|
449
|
+
* before run().
|
|
450
|
+
*/
|
|
451
|
+
function readOrigin() {
|
|
452
|
+
const d = {
|
|
453
|
+
owner: "service",
|
|
454
|
+
name: ORIGIN_KEY_NAME,
|
|
455
|
+
param: {
|
|
456
|
+
schema: type("string"),
|
|
457
|
+
optional: true
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
const key = configKey("", d);
|
|
461
|
+
const value = coerce(process.env[key], d, key);
|
|
462
|
+
if (value === void 0) throw new Error("this service's origin is not available (env COMPOSER_ORIGIN is unset) — a deployed environment writes it automatically; a local harness must supply it like any other config value (set COMPOSER_ORIGIN to the JSON-encoded origin URL).");
|
|
463
|
+
return blindCast(value);
|
|
464
|
+
}
|
|
465
|
+
/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
|
|
466
|
+
function standardValidateSync(schema, value) {
|
|
467
|
+
const result = schema["~standard"].validate(value);
|
|
468
|
+
if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
|
|
469
|
+
if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
470
|
+
return result.value;
|
|
471
|
+
}
|
|
472
|
+
//#endregion
|
|
473
|
+
export { encodeParamPointer as a, readOrigin as c, stashInput as d, stashProviderParams as f, encode as i, serializeInput as l, configKey as n, paramEntries as o, deserialize as r, readInput as s, ORIGIN_KEY_NAME as t, stash as u };
|
|
474
|
+
|
|
475
|
+
//# sourceMappingURL=serializer-sVE4UAmg-CikRngbR.mjs.map
|