@prisma/composer-prisma-cloud 0.1.0

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.
@@ -0,0 +1,207 @@
1
+ import { secretSource } from "@prisma/composer";
2
+ import { blindCast } from "@prisma/composer/casts";
3
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-C2CsA7xm.mjs
4
+ /**
5
+ * Brands the payload `envSecret` builds. Core's `secretSource()` is a public
6
+ * SPI, so a user could bypass `envSecret` and bind a raw `secretSource('x')`;
7
+ * the brand lets `secretName` reject such a source (or another target's) with a
8
+ * clear error instead of reading an absent `.name`.
9
+ */
10
+ const PRISMA_CLOUD_SECRET_SOURCE = blindCast(Symbol.for("prisma:prisma-cloud-secret-source"));
11
+ const RESERVED_SECRET_PREFIX = "COMPOSE_";
12
+ const POISONED_SECRET_NAMES = /* @__PURE__ */ new Set(["DATABASE_URL", "DATABASE_URL_POOLED"]);
13
+ /**
14
+ * Binds a secret slot to a named Prisma Cloud platform env var (ADR-0029). The
15
+ * value is provisioned out-of-band; only the name is carried. The name may not
16
+ * use the framework's reserved `COMPOSE_` prefix or the poisoned
17
+ * `DATABASE_URL(_POOLED)` keys.
18
+ */
19
+ function envSecret(name) {
20
+ 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').");
21
+ 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.`);
22
+ 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.`);
23
+ return secretSource({
24
+ [PRISMA_CLOUD_SECRET_SOURCE]: true,
25
+ name
26
+ });
27
+ }
28
+ /** True only for a payload that `envSecret` built — i.e. one carrying the brand. */
29
+ function isEnvSecretPayload(payload) {
30
+ return typeof payload === "object" && payload !== null && blindCast(payload)[PRISMA_CLOUD_SECRET_SOURCE] === true;
31
+ }
32
+ /**
33
+ * Reads the Prisma Cloud env-var name back out of a secret binding's opaque
34
+ * source. A source not built by `envSecret` (a raw `secretSource(...)` or
35
+ * another target's source) carries no name — reject it here. `secretName` runs
36
+ * in preflight before any provisioning, so a foreign source fails early and
37
+ * clearly rather than producing a broken deploy with an undefined name.
38
+ */
39
+ function secretName(binding) {
40
+ const payload = binding.source.payload;
41
+ if (!isEnvSecretPayload(payload)) throw new Error(`secret slot "${binding.slot}" of service "${binding.serviceAddress}" is bound to a source not created by envSecret() — bind secrets with envSecret('NAME') from @prisma/composer-prisma-cloud.`);
42
+ return payload.name;
43
+ }
44
+ /**
45
+ * Walks a node's own params, then each dependency input's connection params —
46
+ * the same enumeration order `configOf` uses, but carrying the raw
47
+ * `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
48
+ * projection.
49
+ */
50
+ function paramEntries(node) {
51
+ const entries = [];
52
+ for (const [input, value] of Object.entries(node.inputs)) {
53
+ if (typeof value !== "object" || value === null) continue;
54
+ const params = blindCast(value).connection.params;
55
+ for (const [name, param] of Object.entries(params)) entries.push({
56
+ owner: { input },
57
+ name,
58
+ param
59
+ });
60
+ }
61
+ for (const [name, param] of Object.entries(node.params)) entries.push({
62
+ owner: "service",
63
+ name,
64
+ param
65
+ });
66
+ return entries;
67
+ }
68
+ const configKey = (address, d) => {
69
+ const segments = address.split(".").filter((s) => s.length > 0);
70
+ const owner = d.owner === "service" ? [] : [d.owner.input];
71
+ return [
72
+ "COMPOSE",
73
+ ...segments,
74
+ ...owner,
75
+ d.name
76
+ ].join("_").toUpperCase();
77
+ };
78
+ /**
79
+ * Typed value → its stored string. Service-own literals are JSON-encoded; a
80
+ * dependency-input value is a provisioning ref at deploy (and a resolved
81
+ * string at boot) and passes through untouched — LANDMINE: JSON-encoding it
82
+ * would break the ordering edge Alchemy resolves through it.
83
+ */
84
+ function encode(owner, value) {
85
+ return owner === "service" ? JSON.stringify(value) : blindCast(value);
86
+ }
87
+ /** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
88
+ function decode(owner, raw) {
89
+ return owner === "service" ? JSON.parse(raw) : raw;
90
+ }
91
+ function coerce(raw, d, key) {
92
+ if (!(raw !== void 0 && raw !== "")) {
93
+ if (d.param.default !== void 0) return d.param.default;
94
+ if (d.param.optional === true) return void 0;
95
+ throw new Error(`missing required config param "${d.name}" (env ${key})`);
96
+ }
97
+ try {
98
+ return standardValidateSync(d.param.schema, decode(d.owner, raw));
99
+ } catch (cause) {
100
+ const message = cause instanceof Error ? cause.message : String(cause);
101
+ throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
102
+ }
103
+ }
104
+ /**
105
+ * Boot: read each declared param from env by its key, reverse the param's own
106
+ * serialization (missing/invalid fails loudly), assemble the typed Config.
107
+ * Secrets ride a separate channel (deserializeSecrets), not this one.
108
+ */
109
+ const deserialize = (node, address) => {
110
+ const service = {};
111
+ const inputs = {};
112
+ for (const d of paramEntries(node)) {
113
+ const key = configKey(address, d);
114
+ const value = coerce(process.env[key], d, key);
115
+ if (d.owner === "service") service[d.name] = value;
116
+ else {
117
+ let bucket = inputs[d.owner.input];
118
+ if (bucket === void 0) {
119
+ bucket = {};
120
+ inputs[d.owner.input] = bucket;
121
+ }
122
+ bucket[d.name] = value;
123
+ }
124
+ }
125
+ return {
126
+ service,
127
+ inputs
128
+ };
129
+ };
130
+ /**
131
+ * run()'s setup step: write the resolved config to the environment under
132
+ * address-free keys (configKey("", d) + each serialize suffix), which load()
133
+ * reads back with no address. Uses env, not a module variable, because a
134
+ * framework may fork worker processes that inherit env but not memory.
135
+ * Writes only these keys; nothing else is touched.
136
+ */
137
+ const stash = (node, config) => {
138
+ for (const d of paramEntries(node)) {
139
+ const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
140
+ if (value === void 0) continue;
141
+ process.env[configKey("", d)] = encode(d.owner, value);
142
+ }
143
+ };
144
+ /** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */
145
+ const secretKey = (address, slot) => configKey(address, {
146
+ owner: "service",
147
+ name: slot
148
+ });
149
+ /**
150
+ * Deploy: the pointer rows for a node's secret slots — each slot's key mapped to
151
+ * the platform NAME the root bound it to (looked up in `graph.secrets`). Never a
152
+ * value. A declared slot with no binding is a Load-invariant violation (Load
153
+ * binds every slot), surfaced loudly here rather than written as a blank row.
154
+ */
155
+ function secretPointerRows(node, address, bindings) {
156
+ const rows = [];
157
+ for (const slot of Object.keys(node.secretSlots)) {
158
+ const binding = bindings.find((b) => b.serviceAddress === address && b.slot === slot);
159
+ if (binding === void 0) throw new Error(`secret slot "${slot}" of "${address}" has no bound platform name — Load should have bound it (ADR-0029).`);
160
+ rows.push({
161
+ key: secretKey(address, slot),
162
+ name: secretName(binding)
163
+ });
164
+ }
165
+ return rows;
166
+ }
167
+ /**
168
+ * Boot: resolve every secret slot to its value by double-lookup — read the
169
+ * pointer key (the platform NAME), then read that platform var. A missing
170
+ * pointer or a missing/empty platform value is a loud failure naming both keys.
171
+ * Returns a plain Record for core's `hydrateSecrets` to box.
172
+ */
173
+ const deserializeSecrets = (node, address) => {
174
+ const values = {};
175
+ for (const slot of Object.keys(node.secretSlots)) {
176
+ const key = secretKey(address, slot);
177
+ const name = process.env[key];
178
+ if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
179
+ const value = process.env[name];
180
+ if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
181
+ values[slot] = value;
182
+ }
183
+ return values;
184
+ };
185
+ /**
186
+ * run()'s setup step for secrets: re-emit each slot's pointer NAME under its
187
+ * address-free key, so the address-free `deserializeSecrets` double-looks-up
188
+ * identically. Never the value — the value stays only in the platform var.
189
+ */
190
+ const stashSecrets = (node, address) => {
191
+ for (const slot of Object.keys(node.secretSlots)) {
192
+ const name = process.env[secretKey(address, slot)];
193
+ if (name === void 0) continue;
194
+ process.env[secretKey("", slot)] = name;
195
+ }
196
+ };
197
+ /** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
198
+ function standardValidateSync(schema, value) {
199
+ const result = schema["~standard"].validate(value);
200
+ if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
201
+ if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
202
+ return result.value;
203
+ }
204
+ //#endregion
205
+ export { envSecret as a, secretPointerRows as c, encode as i, stash as l, deserialize as n, paramEntries as o, deserializeSecrets as r, secretName as s, configKey as t, stashSecrets as u };
206
+
207
+ //# sourceMappingURL=serializer-C2CsA7xm-29Eg2Tjl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer-C2CsA7xm-29Eg2Tjl.mjs","names":[],"sources":["../../../1-prisma-cloud/1-extensions/target/dist/serializer-C2CsA7xm.mjs"],"sourcesContent":["import { secretSource } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\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 = \"COMPOSE_\";\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 `COMPOSE_` 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 a secret binding's opaque\n* source. A source not built by `envSecret` (a raw `secretSource(...)` or\n* another target's source) carries no name — reject it here. `secretName` runs\n* in preflight before any provisioning, so a foreign source fails early and\n* clearly rather than producing a broken deploy with an undefined name.\n*/\nfunction secretName(binding) {\n\tconst payload = binding.source.payload;\n\tif (!isEnvSecretPayload(payload)) throw new Error(`secret slot \"${binding.slot}\" of service \"${binding.serviceAddress}\" is bound to a source not created by envSecret() — bind secrets with envSecret('NAME') from @prisma/composer-prisma-cloud.`);\n\treturn payload.name;\n}\n//#endregion\n//#region src/serializer.ts\n/**\n* Walks a node's own params, then each dependency input's connection params —\n* the same enumeration order `configOf` uses, but carrying the raw\n* `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data\n* projection.\n*/\nfunction paramEntries(node) {\n\tconst entries = [];\n\tfor (const [input, value] of Object.entries(node.inputs)) {\n\t\tif (typeof value !== \"object\" || value === null) continue;\n\t\tconst params = blindCast(value).connection.params;\n\t\tfor (const [name, param] of Object.entries(params)) entries.push({\n\t\t\towner: { input },\n\t\t\tname,\n\t\t\tparam\n\t\t});\n\t}\n\tfor (const [name, param] of Object.entries(node.params)) entries.push({\n\t\towner: \"service\",\n\t\tname,\n\t\tparam\n\t});\n\treturn entries;\n}\nconst configKey = (address, d) => {\n\tconst segments = address.split(\".\").filter((s) => s.length > 0);\n\tconst owner = d.owner === \"service\" ? [] : [d.owner.input];\n\treturn [\n\t\t\"COMPOSE\",\n\t\t...segments,\n\t\t...owner,\n\t\td.name\n\t].join(\"_\").toUpperCase();\n};\n/**\n* Typed value → its stored string. Service-own literals are JSON-encoded; a\n* dependency-input value is a provisioning ref at deploy (and a resolved\n* string at boot) and passes through untouched — LANDMINE: JSON-encoding it\n* would break the ordering edge Alchemy resolves through it.\n*/\nfunction encode(owner, value) {\n\treturn owner === \"service\" ? JSON.stringify(value) : blindCast(value);\n}\n/** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */\nfunction decode(owner, raw) {\n\treturn owner === \"service\" ? JSON.parse(raw) : raw;\n}\nfunction coerce(raw, d, key) {\n\tif (!(raw !== void 0 && raw !== \"\")) {\n\t\tif (d.param.default !== void 0) return d.param.default;\n\t\tif (d.param.optional === true) return void 0;\n\t\tthrow new Error(`missing required config param \"${d.name}\" (env ${key})`);\n\t}\n\ttry {\n\t\treturn standardValidateSync(d.param.schema, decode(d.owner, raw));\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`invalid value for config param \"${d.name}\" (env ${key}): ${message}`);\n\t}\n}\n/**\n* Boot: read each declared param from env by its key, reverse the param's own\n* serialization (missing/invalid fails loudly), assemble the typed Config.\n* Secrets ride a separate channel (deserializeSecrets), not this one.\n*/\nconst deserialize = (node, address) => {\n\tconst service = {};\n\tconst inputs = {};\n\tfor (const d of paramEntries(node)) {\n\t\tconst key = configKey(address, d);\n\t\tconst value = coerce(process.env[key], d, key);\n\t\tif (d.owner === \"service\") service[d.name] = value;\n\t\telse {\n\t\t\tlet bucket = inputs[d.owner.input];\n\t\t\tif (bucket === void 0) {\n\t\t\t\tbucket = {};\n\t\t\t\tinputs[d.owner.input] = bucket;\n\t\t\t}\n\t\t\tbucket[d.name] = value;\n\t\t}\n\t}\n\treturn {\n\t\tservice,\n\t\tinputs\n\t};\n};\n/**\n* run()'s setup step: write the resolved config to the environment under\n* address-free keys (configKey(\"\", d) + each serialize suffix), which load()\n* reads back with no address. Uses env, not a module variable, because a\n* framework may fork worker processes that inherit env but not memory.\n* Writes only these keys; nothing else is touched.\n*/\nconst stash = (node, config) => {\n\tfor (const d of paramEntries(node)) {\n\t\tconst value = d.owner === \"service\" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];\n\t\tif (value === void 0) continue;\n\t\tprocess.env[configKey(\"\", d)] = encode(d.owner, value);\n\t}\n};\n/** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */\nconst secretKey = (address, slot) => configKey(address, {\n\towner: \"service\",\n\tname: slot\n});\n/**\n* Deploy: the pointer rows for a node's secret slots — each slot's key mapped to\n* the platform NAME the root bound it to (looked up in `graph.secrets`). Never a\n* value. A declared slot with no binding is a Load-invariant violation (Load\n* binds every slot), surfaced loudly here rather than written as a blank row.\n*/\nfunction secretPointerRows(node, address, bindings) {\n\tconst rows = [];\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst binding = bindings.find((b) => b.serviceAddress === address && b.slot === slot);\n\t\tif (binding === void 0) throw new Error(`secret slot \"${slot}\" of \"${address}\" has no bound platform name — Load should have bound it (ADR-0029).`);\n\t\trows.push({\n\t\t\tkey: secretKey(address, slot),\n\t\t\tname: secretName(binding)\n\t\t});\n\t}\n\treturn rows;\n}\n/**\n* Boot: resolve every secret slot to its value by double-lookup — read the\n* pointer key (the platform NAME), then read that platform var. A missing\n* pointer or a missing/empty platform value is a loud failure naming both keys.\n* Returns a plain Record for core's `hydrateSecrets` to box.\n*/\nconst deserializeSecrets = (node, address) => {\n\tconst values = {};\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst key = secretKey(address, slot);\n\t\tconst name = process.env[key];\n\t\tif (name === void 0 || name === \"\") throw new Error(`missing secret pointer for slot \"${slot}\" (env ${key}) — the deploy did not write it.`);\n\t\tconst value = process.env[name];\n\t\tif (value === void 0 || value === \"\") throw new Error(`secret \"${slot}\" is not provisioned (env ${key} → ${name}): the platform var \"${name}\" is unset or empty.`);\n\t\tvalues[slot] = value;\n\t}\n\treturn values;\n};\n/**\n* run()'s setup step for secrets: re-emit each slot's pointer NAME under its\n* address-free key, so the address-free `deserializeSecrets` double-looks-up\n* identically. Never the value — the value stays only in the platform var.\n*/\nconst stashSecrets = (node, address) => {\n\tfor (const slot of Object.keys(node.secretSlots)) {\n\t\tconst name = process.env[secretKey(address, slot)];\n\t\tif (name === void 0) continue;\n\t\tprocess.env[secretKey(\"\", slot)] = name;\n\t}\n};\n/** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */\nfunction standardValidateSync(schema, value) {\n\tconst result = schema[\"~standard\"].validate(value);\n\tif (result instanceof Promise) throw new Error(\"config param schema validation must be synchronous — async Standard Schema validators are not supported for config params\");\n\tif (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join(\"; \")}`);\n\treturn result.value;\n}\n//#endregion\nexport { paramEntries as a, stashSecrets as c, encode as i, envSecret as l, deserialize as n, secretPointerRows as o, deserializeSecrets as r, stash as s, configKey as t, secretName as u };\n\n//# sourceMappingURL=serializer-C2CsA7xm.mjs.map"],"mappings":";;;;;;;;;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,2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Y;CACvC,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,WAAW,GAAG;EACjD,MAAM,OAAO,QAAQ,IAAI,UAAU,SAAS,IAAI;EAChD,IAAI,SAAS,KAAK,GAAG;EACrB,QAAQ,IAAI,UAAU,IAAI,IAAI,KAAK;CACpC;AACD;;AAEA,SAAS,qBAAqB,QAAQ,OAAO;CAC5C,MAAM,SAAS,OAAO,YAAY,CAAC,SAAS,KAAK;CACjD,IAAI,kBAAkB,SAAS,MAAM,IAAI,MAAM,2HAA2H;CAC1K,IAAI,OAAO,WAAW,KAAK,GAAG,MAAM,IAAI,MAAM,mCAAmC,OAAO,OAAO,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG;CACzI,OAAO,OAAO;AACf"}
@@ -0,0 +1,67 @@
1
+ import { Contract, DependencyEnd, ModuleNode } from "@prisma/composer";
2
+
3
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/index.d.mts
4
+ //#endregion
5
+ //#region src/postgres.d.ts
6
+ interface PostgresConfig {
7
+ readonly url: string;
8
+ }
9
+ /**
10
+ * The contract a Postgres provides — and the contract its consumers require.
11
+ * `satisfies` compares KIND, not identity: an extension module can be duplicated
12
+ * across a workspace (same rationale as the Symbol.for node brand), and every
13
+ * duplicate's contract must still satisfy. `__cmp` is the connection config a
14
+ * postgres offers; core never inspects it.
15
+ */
16
+ //#endregion
17
+ //#region src/s3-credentials.d.ts
18
+ interface CredentialsConfig {
19
+ readonly accessKeyId: string;
20
+ readonly secretAccessKey: string;
21
+ }
22
+ /**
23
+ * The contract the `s3-credentials` resource provides — a minted SigV4 key
24
+ * pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is
25
+ * the config the resource offers, which core never inspects.
26
+ */
27
+ //#endregion
28
+ //#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-Dl8holZ2.d.mts
29
+ //#region src/contract.d.ts
30
+ interface S3Config {
31
+ readonly url: string;
32
+ readonly bucket: string;
33
+ readonly accessKeyId: string;
34
+ readonly secretAccessKey: string;
35
+ }
36
+ declare const s3Contract: Contract<'s3', S3Config>;
37
+ type S3Contract = typeof s3Contract;
38
+ /**
39
+ * A consumer's dependency on an S3-compatible store. No `region` in the
40
+ * binding — the server accepts whatever region string the client signed.
41
+ */
42
+ declare function s3(): DependencyEnd<S3Config, typeof s3Contract>; //#endregion
43
+ //#region src/storage-service.d.ts
44
+ declare function storageService(opts: {
45
+ bucket: string;
46
+ }): import("@prisma/composer").RunnableServiceNode<{
47
+ db: import("@prisma/composer").DependencyEnd<PostgresConfig, import("@prisma/composer").Contract<"postgres", PostgresConfig>>;
48
+ credentials: import("@prisma/composer").DependencyEnd<CredentialsConfig, import("@prisma/composer").Contract<"credentials", CredentialsConfig>>;
49
+ }, {
50
+ bucket: import("@prisma/composer").ConfigParam<import("@standard-schema/spec").StandardSchemaV1<string, string>>;
51
+ } & {
52
+ readonly port: import("@prisma/composer").ConfigParam<import("@standard-schema/spec").StandardSchemaV1<number, number>>;
53
+ }, {
54
+ store: import("@prisma/composer").Contract<"s3", S3Config>;
55
+ }, Record<never, never>>;
56
+ //#endregion
57
+ //#region ../../1-prisma-cloud/2-shared-modules/storage/dist/index.d.mts
58
+ //#region src/storage-module.d.ts
59
+ declare function storage(opts?: {
60
+ name?: string;
61
+ bucket?: string;
62
+ }): ModuleNode<Record<never, never>, {
63
+ store: typeof s3Contract;
64
+ }, Record<never, never>>; //#endregion
65
+ //#endregion
66
+ export { type S3Config, type S3Contract, s3, s3Contract, storage, storageService };
67
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1,374 @@
1
+ import { dependency, hydrateSecrets, hydrateSync, module, number, resource, service, string } from "@prisma/composer";
2
+ import { blindCast } from "@prisma/composer/casts";
3
+ import node from "@prisma/composer/node";
4
+ blindCast(Symbol.for("prisma:prisma-cloud-secret-source"));
5
+ /**
6
+ * Walks a node's own params, then each dependency input's connection params —
7
+ * the same enumeration order `configOf` uses, but carrying the raw
8
+ * `ConfigParam` (with its `serialize`/`deserialize`) instead of a pure-data
9
+ * projection.
10
+ */
11
+ function paramEntries(node) {
12
+ const entries = [];
13
+ for (const [input, value] of Object.entries(node.inputs)) {
14
+ if (typeof value !== "object" || value === null) continue;
15
+ const params = blindCast(value).connection.params;
16
+ for (const [name, param] of Object.entries(params)) entries.push({
17
+ owner: { input },
18
+ name,
19
+ param
20
+ });
21
+ }
22
+ for (const [name, param] of Object.entries(node.params)) entries.push({
23
+ owner: "service",
24
+ name,
25
+ param
26
+ });
27
+ return entries;
28
+ }
29
+ const configKey = (address, d) => {
30
+ const segments = address.split(".").filter((s) => s.length > 0);
31
+ const owner = d.owner === "service" ? [] : [d.owner.input];
32
+ return [
33
+ "COMPOSE",
34
+ ...segments,
35
+ ...owner,
36
+ d.name
37
+ ].join("_").toUpperCase();
38
+ };
39
+ /**
40
+ * Typed value → its stored string. Service-own literals are JSON-encoded; a
41
+ * dependency-input value is a provisioning ref at deploy (and a resolved
42
+ * string at boot) and passes through untouched — LANDMINE: JSON-encoding it
43
+ * would break the ordering edge Alchemy resolves through it.
44
+ */
45
+ function encode(owner, value) {
46
+ return owner === "service" ? JSON.stringify(value) : blindCast(value);
47
+ }
48
+ /** Reverses `encode`: JSON-parse a service-own value, take a dependency-input value raw. */
49
+ function decode(owner, raw) {
50
+ return owner === "service" ? JSON.parse(raw) : raw;
51
+ }
52
+ function coerce(raw, d, key) {
53
+ if (!(raw !== void 0 && raw !== "")) {
54
+ if (d.param.default !== void 0) return d.param.default;
55
+ if (d.param.optional === true) return void 0;
56
+ throw new Error(`missing required config param "${d.name}" (env ${key})`);
57
+ }
58
+ try {
59
+ return standardValidateSync(d.param.schema, decode(d.owner, raw));
60
+ } catch (cause) {
61
+ const message = cause instanceof Error ? cause.message : String(cause);
62
+ throw new Error(`invalid value for config param "${d.name}" (env ${key}): ${message}`);
63
+ }
64
+ }
65
+ /**
66
+ * Boot: read each declared param from env by its key, reverse the param's own
67
+ * serialization (missing/invalid fails loudly), assemble the typed Config.
68
+ * Secrets ride a separate channel (deserializeSecrets), not this one.
69
+ */
70
+ const deserialize = (node, address) => {
71
+ const service = {};
72
+ const inputs = {};
73
+ for (const d of paramEntries(node)) {
74
+ const key = configKey(address, d);
75
+ const value = coerce(process.env[key], d, key);
76
+ if (d.owner === "service") service[d.name] = value;
77
+ else {
78
+ let bucket = inputs[d.owner.input];
79
+ if (bucket === void 0) {
80
+ bucket = {};
81
+ inputs[d.owner.input] = bucket;
82
+ }
83
+ bucket[d.name] = value;
84
+ }
85
+ }
86
+ return {
87
+ service,
88
+ inputs
89
+ };
90
+ };
91
+ /**
92
+ * run()'s setup step: write the resolved config to the environment under
93
+ * address-free keys (configKey("", d) + each serialize suffix), which load()
94
+ * reads back with no address. Uses env, not a module variable, because a
95
+ * framework may fork worker processes that inherit env but not memory.
96
+ * Writes only these keys; nothing else is touched.
97
+ */
98
+ const stash = (node, config) => {
99
+ for (const d of paramEntries(node)) {
100
+ const value = d.owner === "service" ? config.service[d.name] : config.inputs[d.owner.input]?.[d.name];
101
+ if (value === void 0) continue;
102
+ process.env[configKey("", d)] = encode(d.owner, value);
103
+ }
104
+ };
105
+ /** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */
106
+ const secretKey = (address, slot) => configKey(address, {
107
+ owner: "service",
108
+ name: slot
109
+ });
110
+ /**
111
+ * Boot: resolve every secret slot to its value by double-lookup — read the
112
+ * pointer key (the platform NAME), then read that platform var. A missing
113
+ * pointer or a missing/empty platform value is a loud failure naming both keys.
114
+ * Returns a plain Record for core's `hydrateSecrets` to box.
115
+ */
116
+ const deserializeSecrets = (node, address) => {
117
+ const values = {};
118
+ for (const slot of Object.keys(node.secretSlots)) {
119
+ const key = secretKey(address, slot);
120
+ const name = process.env[key];
121
+ if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
122
+ const value = process.env[name];
123
+ if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
124
+ values[slot] = value;
125
+ }
126
+ return values;
127
+ };
128
+ /**
129
+ * run()'s setup step for secrets: re-emit each slot's pointer NAME under its
130
+ * address-free key, so the address-free `deserializeSecrets` double-looks-up
131
+ * identically. Never the value — the value stays only in the platform var.
132
+ */
133
+ const stashSecrets = (node, address) => {
134
+ for (const slot of Object.keys(node.secretSlots)) {
135
+ const name = process.env[secretKey(address, slot)];
136
+ if (name === void 0) continue;
137
+ process.env[secretKey("", slot)] = name;
138
+ }
139
+ };
140
+ /** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
141
+ function standardValidateSync(schema, value) {
142
+ const result = schema["~standard"].validate(value);
143
+ if (result instanceof Promise) throw new Error("config param schema validation must be synchronous — async Standard Schema validators are not supported for config params");
144
+ if (result.issues !== void 0) throw new Error(`config param validation failed: ${result.issues.map((issue) => issue.message).join("; ")}`);
145
+ return result.value;
146
+ }
147
+ //#endregion
148
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/index.mjs
149
+ const reservedParams = { port: number({ default: 3e3 }) };
150
+ /**
151
+ * A Prisma Compute service — declarations only (deps + params + build + the
152
+ * ports it exposes), no descriptor. `params` merges with the reserved
153
+ * `ReservedParams` (`port`); a user param whose name collides with a reserved
154
+ * one fails at authoring, the same way a colliding dependency name does.
155
+ * Returns the extension's runnable/loadable node:
156
+ * · run(address, boot) — the process controller: deserialize the platform
157
+ * environment (keyed off `address`, the extension's ONE env read) into a
158
+ * typed Config, re-emit it under address-free process-local stash keys,
159
+ * then call boot() to start the app's entry.
160
+ * · load() / config() — called from inside the app's entry: read the stash;
161
+ * load() hydrates + memoizes the deps, config() returns the typed params.
162
+ * Separate accessors so a dep and a param never share a namespace (ADR-0021).
163
+ *
164
+ * `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
165
+ * the control-plane registry key `prisma-composer deploy` resolves through the
166
+ * app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
167
+ * deploy time; nodes are pure data.
168
+ */
169
+ const compute = (def) => {
170
+ const userParams = def.params ?? blindCast({});
171
+ for (const reserved of Object.keys(reservedParams)) {
172
+ if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
173
+ if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
174
+ }
175
+ const params = blindCast({
176
+ ...userParams,
177
+ ...reservedParams
178
+ });
179
+ const node = service({
180
+ name: def.name,
181
+ extension: "@prisma/composer-prisma-cloud",
182
+ type: "compute",
183
+ inputs: def.deps,
184
+ params,
185
+ ...def.secrets !== void 0 ? { secrets: def.secrets } : {},
186
+ build: def.build,
187
+ ...def.expose !== void 0 ? { expose: def.expose } : {}
188
+ });
189
+ let resolved;
190
+ let loadedDeps;
191
+ let loadedParams;
192
+ let loadedSecrets;
193
+ function processConfig() {
194
+ if (resolved === void 0) resolved = deserialize(node, "");
195
+ return resolved;
196
+ }
197
+ const runnable = {
198
+ ...node,
199
+ async run(address, boot) {
200
+ const config = deserialize(node, address);
201
+ stash(node, config);
202
+ stashSecrets(node, address);
203
+ const port = config.service["port"];
204
+ if (typeof port === "number") process.env["PORT"] = String(port);
205
+ return boot();
206
+ },
207
+ load() {
208
+ if (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));
209
+ return loadedDeps;
210
+ },
211
+ config() {
212
+ if (loadedParams === void 0) loadedParams = blindCast(processConfig().service);
213
+ return loadedParams;
214
+ },
215
+ secrets() {
216
+ if (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, "")));
217
+ return loadedSecrets;
218
+ }
219
+ };
220
+ return Object.freeze(blindCast(runnable));
221
+ };
222
+ /**
223
+ * The contract a Postgres provides — and the contract its consumers require.
224
+ * `satisfies` compares KIND, not identity: an extension module can be duplicated
225
+ * across a workspace (same rationale as the Symbol.for node brand), and every
226
+ * duplicate's contract must still satisfy. `__cmp` is the connection config a
227
+ * postgres offers; core never inspects it.
228
+ */
229
+ const postgresContract = Object.freeze({
230
+ kind: "postgres",
231
+ __cmp: { url: "" },
232
+ satisfies: (required) => required.kind === "postgres"
233
+ });
234
+ function postgres(opts) {
235
+ if (opts?.name !== void 0) return resource({
236
+ name: opts.name,
237
+ extension: "@prisma/composer-prisma-cloud",
238
+ provides: postgresContract
239
+ });
240
+ return dependency({
241
+ type: "postgres",
242
+ connection: {
243
+ params: { url: string() },
244
+ hydrate: (v) => v
245
+ },
246
+ required: postgresContract
247
+ });
248
+ }
249
+ /**
250
+ * The contract the `s3-credentials` resource provides — a minted SigV4 key
251
+ * pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is
252
+ * the config the resource offers, which core never inspects.
253
+ */
254
+ const credentialsContract = Object.freeze({
255
+ kind: "credentials",
256
+ __cmp: {
257
+ accessKeyId: "",
258
+ secretAccessKey: ""
259
+ },
260
+ satisfies: (required) => required.kind === "credentials"
261
+ });
262
+ function s3Credentials(opts) {
263
+ if (opts?.name !== void 0) return resource({
264
+ name: opts.name,
265
+ extension: "@prisma/composer-prisma-cloud",
266
+ provides: credentialsContract
267
+ });
268
+ return dependency({
269
+ type: "credentials",
270
+ connection: {
271
+ params: {
272
+ accessKeyId: string(),
273
+ secretAccessKey: string()
274
+ },
275
+ hydrate: (v) => v
276
+ },
277
+ required: credentialsContract
278
+ });
279
+ }
280
+ /**
281
+ * The storage service authoring factory — a `compute` service routed to the
282
+ * `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s
283
+ * runnable (run/load/config, deps, params, build, expose) with the routing
284
+ * `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the
285
+ * serializer keys off the deployment address and each param's owner/name, and
286
+ * `load`/`config` off deps/params), so only the deploy-time descriptor lookup
287
+ * sees the override and routes to the extended-output lowering (§ 5). The
288
+ * return type is compute's exactly (including the reserved `port` param). The
289
+ * storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
290
+ * param, and `expose: { store: s3Contract }`.
291
+ */
292
+ function s3StoreService(def) {
293
+ const node = compute(def);
294
+ return Object.freeze(blindCast({
295
+ ...node,
296
+ type: "s3-store"
297
+ }));
298
+ }
299
+ //#endregion
300
+ //#region ../../1-prisma-cloud/2-shared-modules/storage/dist/storage-service-DSaZsAC4.mjs
301
+ const s3Contract = Object.freeze({
302
+ kind: "s3",
303
+ __cmp: {
304
+ url: "",
305
+ bucket: "",
306
+ accessKeyId: "",
307
+ secretAccessKey: ""
308
+ },
309
+ satisfies: (required) => required.kind === "s3"
310
+ });
311
+ /**
312
+ * A consumer's dependency on an S3-compatible store. No `region` in the
313
+ * binding — the server accepts whatever region string the client signed.
314
+ */
315
+ function s3() {
316
+ return dependency({
317
+ type: "s3",
318
+ connection: {
319
+ params: {
320
+ url: string(),
321
+ bucket: string(),
322
+ accessKeyId: string(),
323
+ secretAccessKey: string()
324
+ },
325
+ hydrate: (v) => v
326
+ },
327
+ required: s3Contract
328
+ });
329
+ }
330
+ /**
331
+ * The storage service node (like cron's `scheduler.ts` + `scheduler-service.ts`
332
+ * combined): `storageService` builds the `s3-store` service — a Postgres `db`
333
+ * dependency, a minted `credentials` dependency, a `bucket` param, and the
334
+ * `store` port exposing `s3Contract`. The deploy bootstrap runs the
335
+ * default-exported bare node (`main.run(address, boot)`); the real bucket comes
336
+ * from serialized config at runtime, so the default's `bucket` is only a
337
+ * placeholder — exactly like `scheduler-service.ts` default-exports
338
+ * `cronScheduler({ jobs: [] })`.
339
+ */
340
+ function storageService(opts) {
341
+ return s3StoreService({
342
+ name: "storage",
343
+ deps: {
344
+ db: postgres(),
345
+ credentials: s3Credentials()
346
+ },
347
+ params: { bucket: string({ default: opts.bucket }) },
348
+ build: node({
349
+ module: new URL("./storage-service.mjs", import.meta.url).href,
350
+ entry: "./storage-entrypoint.mjs"
351
+ }),
352
+ expose: { store: s3Contract }
353
+ });
354
+ }
355
+ storageService({ bucket: "storage" });
356
+ //#endregion
357
+ //#region ../../1-prisma-cloud/2-shared-modules/storage/dist/index.mjs
358
+ function storage(opts) {
359
+ return module(opts?.name ?? "storage", { expose: { store: s3Contract } }, ({ provision }) => {
360
+ const db = provision(postgres({ name: "db" }), { id: "db" });
361
+ const credentials = provision(s3Credentials({ name: "credentials" }), { id: "credentials" });
362
+ return { store: provision(storageService({ bucket: opts?.bucket ?? "storage" }), {
363
+ id: "service",
364
+ deps: {
365
+ db,
366
+ credentials
367
+ }
368
+ }).store };
369
+ });
370
+ }
371
+ //#endregion
372
+ export { s3, s3Contract, storage, storageService };
373
+
374
+ //# sourceMappingURL=index.mjs.map