@prisma/composer-prisma-cloud 0.1.0 → 0.2.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.
Files changed (47) hide show
  1. package/dist/control.d.mts +52 -38
  2. package/dist/control.mjs +1050 -326
  3. package/dist/control.mjs.map +1 -1
  4. package/dist/cron/index.d.mts +9 -6
  5. package/dist/cron/index.mjs +114 -5
  6. package/dist/cron/index.mjs.map +1 -1
  7. package/dist/cron/scheduler-entrypoint.mjs +281 -111
  8. package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
  9. package/dist/cron/scheduler-service.mjs +114 -5
  10. package/dist/cron/scheduler-service.mjs.map +1 -1
  11. package/dist/index.d.mts +118 -23
  12. package/dist/index.mjs +44 -2
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/{prisma-next-COrwlg3N.mjs → prisma-next-DlU01kXJ-2sP5mQb6.mjs} +3 -3
  15. package/dist/prisma-next-DlU01kXJ-2sP5mQb6.mjs.map +1 -0
  16. package/dist/prisma-next.d.mts +1 -2
  17. package/dist/prisma-next.mjs +1 -1
  18. package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs +151 -0
  19. package/dist/provisioned-edges-DIQAR4q4-Bn9op-JG.mjs.map +1 -0
  20. package/dist/{serializer-C2CsA7xm-29Eg2Tjl.mjs → serializer-CX4VYdf_-KKGoAxfx.mjs} +61 -7
  21. package/dist/serializer-CX4VYdf_-KKGoAxfx.mjs.map +1 -0
  22. package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts +36 -0
  23. package/dist/storage/index.d.mts +5 -16
  24. package/dist/storage/index.mjs +114 -3
  25. package/dist/storage/index.mjs.map +1 -1
  26. package/dist/storage/storage-entrypoint.mjs +7242 -12
  27. package/dist/storage/storage-entrypoint.mjs.map +1 -1
  28. package/dist/storage/storage-service.mjs +114 -3
  29. package/dist/storage/storage-service.mjs.map +1 -1
  30. package/dist/storage/testing.d.mts +7 -4
  31. package/dist/storage/testing.mjs.map +1 -1
  32. package/dist/streams/index.d.mts +250 -0
  33. package/dist/streams/index.mjs +4058 -0
  34. package/dist/streams/index.mjs.map +1 -0
  35. package/dist/streams/streams-entrypoint.mjs +48095 -0
  36. package/dist/streams/streams-entrypoint.mjs.map +1 -0
  37. package/dist/streams/streams-service.mjs +811 -0
  38. package/dist/streams/streams-service.mjs.map +1 -0
  39. package/dist/streams/testing.d.mts +33 -0
  40. package/dist/streams/testing.mjs +31335 -0
  41. package/dist/streams/testing.mjs.map +1 -0
  42. package/dist/testing.d.mts +1 -2
  43. package/dist/testing.mjs +1 -1
  44. package/dist/testing.mjs.map +1 -1
  45. package/package.json +27 -22
  46. package/dist/prisma-next-COrwlg3N.mjs.map +0 -1
  47. package/dist/serializer-C2CsA7xm-29Eg2Tjl.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { contract, rpc } from "@prisma/composer/rpc";
1
+ import { RPC_PEER_KEY, contract, rpc } from "@prisma/composer/service-rpc";
2
2
  import { type } from "arktype";
3
3
  import { hydrateSecrets, hydrateSync, number, param, service } from "@prisma/composer";
4
4
  import node from "@prisma/composer/node";
@@ -32,7 +32,7 @@ const configKey = (address, d) => {
32
32
  const segments = address.split(".").filter((s) => s.length > 0);
33
33
  const owner = d.owner === "service" ? [] : [d.owner.input];
34
34
  return [
35
- "COMPOSE",
35
+ "COMPOSER",
36
36
  ...segments,
37
37
  ...owner,
38
38
  d.name
@@ -51,12 +51,18 @@ function encode(owner, value) {
51
51
  function decode(owner, raw) {
52
52
  return owner === "service" ? JSON.parse(raw) : raw;
53
53
  }
54
+ const PARAM_POINTER_PREFIX = "@composer-param-pointer:";
55
+ /** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */
56
+ const isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);
57
+ /** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */
58
+ const decodeParamPointer = (raw) => raw.slice(24);
54
59
  function coerce(raw, d, key) {
55
60
  if (!(raw !== void 0 && raw !== "")) {
56
61
  if (d.param.default !== void 0) return d.param.default;
57
62
  if (d.param.optional === true) return void 0;
58
63
  throw new Error(`missing required config param "${d.name}" (env ${key})`);
59
64
  }
65
+ if (d.owner === "service" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);
60
66
  try {
61
67
  return standardValidateSync(d.param.schema, decode(d.owner, raw));
62
68
  } catch (cause) {
@@ -65,6 +71,26 @@ function coerce(raw, d, key) {
65
71
  }
66
72
  }
67
73
  /**
74
+ * Boot resolution for an env-sourced param: double-lookup (pointer → platform
75
+ * var), then the param's own schema on the raw string — no JSON decode, and
76
+ * no redaction (it's config, not a secret). An UNSET platform var is a loud
77
+ * boot failure naming both the param and the platform var; an EMPTY string is
78
+ * not special-cased here — it reaches the schema like any other value, so it
79
+ * passes iff the schema accepts it (deliberately unlike a literal param's own
80
+ * ""-means-absent rule, and unlike a secret's non-empty requirement).
81
+ */
82
+ function coerceEnvSourcedParam(raw, d, key) {
83
+ const platformVar = decodeParamPointer(raw);
84
+ const value = process.env[platformVar];
85
+ 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.`);
86
+ try {
87
+ return standardValidateSync(d.param.schema, value);
88
+ } catch (cause) {
89
+ const message = cause instanceof Error ? cause.message : String(cause);
90
+ throw new Error(`invalid value for env-sourced config param "${d.name}" (env ${key} → ${platformVar}): ${message}`);
91
+ }
92
+ }
93
+ /**
68
94
  * Boot: read each declared param from env by its key, reverse the param's own
69
95
  * serialization (missing/invalid fails loudly), assemble the typed Config.
70
96
  * Secrets ride a separate channel (deserializeSecrets), not this one.
@@ -104,7 +130,7 @@ const stash = (node, config) => {
104
130
  process.env[configKey("", d)] = encode(d.owner, value);
105
131
  }
106
132
  };
107
- /** The pointer-row key for a secret slot: COMPOSE_<addr>_<slot> (secrets are service-level). */
133
+ /** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
108
134
  const secretKey = (address, slot) => configKey(address, {
109
135
  owner: "service",
110
136
  name: slot
@@ -139,6 +165,32 @@ const stashSecrets = (node, address) => {
139
165
  process.env[secretKey("", slot)] = name;
140
166
  }
141
167
  };
168
+ /**
169
+ * Boot: for each reserved provider param, read its address-scoped row through
170
+ * the same `coerce` a declared param uses (JSON-decode, schema-validate), and
171
+ * re-emit it address-free — `stash`'s counterpart for this separate
172
+ * declaration space. A param is declared optional here unconditionally: an
173
+ * absent row means "never provisioned" (local dev, tests, a provider with no
174
+ * registered value for this deploy), never a boot failure, so nothing is
175
+ * stashed and the runtime reader that owns this slot falls back to its own
176
+ * pass-through behavior.
177
+ */
178
+ function stashProviderParams(entries, address) {
179
+ for (const entry of entries) {
180
+ const d = {
181
+ owner: "service",
182
+ name: entry.name,
183
+ param: {
184
+ schema: entry.schema,
185
+ optional: true
186
+ }
187
+ };
188
+ const key = configKey(address, d);
189
+ const value = coerce(process.env[key], d, key);
190
+ if (value === void 0) continue;
191
+ process.env[configKey("", d)] = encode("service", value);
192
+ }
193
+ }
142
194
  /** Synchronous Standard Schema validation — see the matching note in core's `config.ts`. */
143
195
  function standardValidateSync(schema, value) {
144
196
  const result = schema["~standard"].validate(value);
@@ -147,7 +199,63 @@ function standardValidateSync(schema, value) {
147
199
  return result.value;
148
200
  }
149
201
  //#endregion
150
- //#region ../../1-prisma-cloud/1-extensions/target/dist/index.mjs
202
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-DIQAR4q4.mjs
203
+ /**
204
+ * RPC's reserved provider param (ADR-0030/ADR-0031): the declaration —
205
+ * name + schema + brand — for the accepted-keys set a provider stores, shared
206
+ * by `control.ts` (which registers the deploy-side `value(refs)` that mints
207
+ * and aggregates it — see its `rpcAcceptedKeysValue`) and `compute.ts` (which
208
+ * validates and stashes it at boot), so writer and reader cannot drift.
209
+ * Finding the edges themselves is `provisioned-edges.ts`'s generic,
210
+ * brand-blind scan — RPC is not special-cased anywhere in this target.
211
+ *
212
+ * This module is reachable from the RUNTIME/authoring side — it must never
213
+ * import `@internal/lowering` or `effect`, or those tokens leak into a user
214
+ * service's bundle (the deploy-side `value(refs)` lives in control.ts, the
215
+ * control-plane-only entry).
216
+ */
217
+ /**
218
+ * The reserved provider param for RPC's accepted-keys set: the var name is
219
+ * `RPC_ACCEPTED_KEYS`, derived through `configKey` at both ends
220
+ * (`configKey(address, …)` at deploy, `configKey('', …)` at boot — the
221
+ * address-free form is `@internal/service-rpc`'s `RPC_ACCEPTED_KEYS_ENV`). `brand` is
222
+ * `RPC_PEER_KEY`, the same brand `perBindingToken()`'s need carries — control.ts
223
+ * looks its `value(refs)` up by this field.
224
+ */
225
+ const RPC_ACCEPTED_KEYS_PARAM = {
226
+ name: "RPC_ACCEPTED_KEYS",
227
+ schema: type("string[]"),
228
+ brand: RPC_PEER_KEY
229
+ };
230
+ /** ADR-0031's need brand for the streams module's bearer key — control.ts registers the provisioner under this. */
231
+ const STREAMS_API_KEY = Symbol.for("prisma:streams/api-key");
232
+ /**
233
+ * The reserved provider param for the streams bearer key: the var name is
234
+ * `STREAMS_API_KEY`. `brand` is `STREAMS_API_KEY` itself (the same symbol
235
+ * `streamsApiKeyNeed()`'s need carries) — control.ts looks its `value(refs)`
236
+ * up by this field.
237
+ */
238
+ const STREAMS_API_KEY_PARAM = {
239
+ name: "STREAMS_API_KEY",
240
+ schema: type("string"),
241
+ brand: STREAMS_API_KEY
242
+ };
243
+ configKey("", {
244
+ owner: "service",
245
+ name: STREAMS_API_KEY_PARAM.name
246
+ });
247
+ const RESERVED_PROVIDER_PARAMS = [RPC_ACCEPTED_KEYS_PARAM, STREAMS_API_KEY_PARAM];
248
+ blindCast(Symbol.for("prisma:prisma-cloud-param-source"));
249
+ Object.freeze({
250
+ kind: "s3",
251
+ __cmp: {
252
+ url: "",
253
+ bucket: "",
254
+ accessKeyId: "",
255
+ secretAccessKey: ""
256
+ },
257
+ satisfies: (required) => required.kind === "s3"
258
+ });
151
259
  const reservedParams = { port: number({ default: 3e3 }) };
152
260
  /**
153
261
  * A Prisma Compute service — declarations only (deps + params + build + the
@@ -201,6 +309,7 @@ const compute = (def) => {
201
309
  async run(address, boot) {
202
310
  const config = deserialize(node, address);
203
311
  stash(node, config);
312
+ stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
204
313
  stashSecrets(node, address);
205
314
  const port = config.service["port"];
206
315
  if (typeof port === "number") process.env["PORT"] = String(port);
@@ -235,7 +344,7 @@ Object.freeze({
235
344
  satisfies: (required) => required.kind === "credentials"
236
345
  });
237
346
  //#endregion
238
- //#region ../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-iL9rl3YY.mjs
347
+ //#region ../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-DhziPSWE.mjs
239
348
  /**
240
349
  * The one call edge between the scheduler and the app's runner: `trigger(jobId)`.
241
350
  * The scheduler depends on it (`rpc(triggerContract)`); the runner exposes it
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler-service.mjs","names":[],"sources":["../../../../1-prisma-cloud/1-extensions/target/dist/serializer-C2CsA7xm.mjs","../../../../1-prisma-cloud/1-extensions/target/dist/index.mjs","../../../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-iL9rl3YY.mjs","../../../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-service.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","import { c as stashSecrets, l as envSecret, n as deserialize, r as deserializeSecrets, s as stash, t as configKey, u as secretName } from \"./serializer-C2CsA7xm.mjs\";\nimport { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/compute.ts\nconst reservedParams = { port: number({ default: 3e3 }) };\n/**\n* A Prisma Compute service — declarations only (deps + params + build + the\n* ports it exposes), no descriptor. `params` merges with the reserved\n* `ReservedParams` (`port`); a user param whose name collides with a reserved\n* one fails at authoring, the same way a colliding dependency name does.\n* Returns the extension's runnable/loadable node:\n* · run(address, boot) — the process controller: deserialize the platform\n* environment (keyed off `address`, the extension's ONE env read) into a\n* typed Config, re-emit it under address-free process-local stash keys,\n* then call boot() to start the app's entry.\n* · load() / config() — called from inside the app's entry: read the stash;\n* load() hydrates + memoizes the deps, config() returns the typed params.\n* Separate accessors so a dep and a param never share a namespace (ADR-0021).\n*\n* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —\n* the control-plane registry key `prisma-composer deploy` resolves through the\n* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at\n* deploy time; nodes are pure data.\n*/\nconst compute = (def) => {\n\tconst userParams = def.params ?? blindCast({});\n\tfor (const reserved of Object.keys(reservedParams)) {\n\t\tif (reserved in def.deps) throw new Error(`compute(): dependency \"${reserved}\" collides with the reserved service param of the same name — rename the dependency.`);\n\t\tif (reserved in userParams) throw new Error(`compute(): param \"${reserved}\" collides with the reserved service param of the same name — rename the param.`);\n\t}\n\tconst params = blindCast({\n\t\t...userParams,\n\t\t...reservedParams\n\t});\n\tconst node = service({\n\t\tname: def.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\ttype: \"compute\",\n\t\tinputs: def.deps,\n\t\tparams,\n\t\t...def.secrets !== void 0 ? { secrets: def.secrets } : {},\n\t\tbuild: def.build,\n\t\t...def.expose !== void 0 ? { expose: def.expose } : {}\n\t});\n\tlet resolved;\n\tlet loadedDeps;\n\tlet loadedParams;\n\tlet loadedSecrets;\n\tfunction processConfig() {\n\t\tif (resolved === void 0) resolved = deserialize(node, \"\");\n\t\treturn resolved;\n\t}\n\tconst runnable = {\n\t\t...node,\n\t\tasync run(address, boot) {\n\t\t\tconst config = deserialize(node, address);\n\t\t\tstash(node, config);\n\t\t\tstashSecrets(node, address);\n\t\t\tconst port = config.service[\"port\"];\n\t\t\tif (typeof port === \"number\") process.env[\"PORT\"] = String(port);\n\t\t\treturn boot();\n\t\t},\n\t\tload() {\n\t\t\tif (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));\n\t\t\treturn loadedDeps;\n\t\t},\n\t\tconfig() {\n\t\t\tif (loadedParams === void 0) loadedParams = blindCast(processConfig().service);\n\t\t\treturn loadedParams;\n\t\t},\n\t\tsecrets() {\n\t\t\tif (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, \"\")));\n\t\t\treturn loadedSecrets;\n\t\t}\n\t};\n\treturn Object.freeze(blindCast(runnable));\n};\n//#endregion\n//#region src/http.ts\nconst defaultHttpClient = (cfg) => ({\n\turl: cfg.url,\n\tfetch: (path, init) => fetch(new URL(path, cfg.url), init)\n});\n/**\n* A service-to-service dependency. Its binding (what `load()` returns) is a\n* derived HttpClient — a thin URL-anchored fetch wrapper (fetch is standard\n* across runtimes — no driver, no runtime coupling). http() is a\n* protocol-owned kind: the framework owns the transport, so the client is\n* kind-canonical and derived from the contract, with no user client in the\n* declaration (ADR-0015). The typed generated client arrives with the\n* interface primitive (a later extension point).\n*/\nconst http = (opts) => dependency({\n\tname: opts.name,\n\ttype: \"http\",\n\tconnection: {\n\t\tparams: { url: string() },\n\t\thydrate: (v) => defaultHttpClient({ url: v.url })\n\t}\n});\n//#endregion\n//#region src/postgres.ts\n/**\n* The contract a Postgres provides — and the contract its consumers require.\n* `satisfies` compares KIND, not identity: an extension module can be duplicated\n* across a workspace (same rationale as the Symbol.for node brand), and every\n* duplicate's contract must still satisfy. `__cmp` is the connection config a\n* postgres offers; core never inspects it.\n*/\nconst postgresContract = Object.freeze({\n\tkind: \"postgres\",\n\t__cmp: { url: \"\" },\n\tsatisfies: (required) => required.kind === \"postgres\"\n});\nfunction postgres(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: postgresContract\n\t});\n\treturn dependency({\n\t\ttype: \"postgres\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: postgresContract\n\t});\n}\n//#endregion\n//#region src/s3-credentials.ts\n/**\n* The contract the `s3-credentials` resource provides — a minted SigV4 key\n* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is\n* the config the resource offers, which core never inspects.\n*/\nconst credentialsContract = Object.freeze({\n\tkind: \"credentials\",\n\t__cmp: {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"credentials\"\n});\nfunction s3Credentials(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: credentialsContract\n\t});\n\treturn dependency({\n\t\ttype: \"credentials\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: credentialsContract\n\t});\n}\n//#endregion\n//#region src/s3-store.ts\n/**\n* The storage service authoring factory — a `compute` service routed to the\n* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s\n* runnable (run/load/config, deps, params, build, expose) with the routing\n* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the\n* serializer keys off the deployment address and each param's owner/name, and\n* `load`/`config` off deps/params), so only the deploy-time descriptor lookup\n* sees the override and routes to the extended-output lowering (§ 5). The\n* return type is compute's exactly (including the reserved `port` param). The\n* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`\n* param, and `expose: { store: s3Contract }`.\n*/\nfunction s3StoreService(def) {\n\tconst node = compute(def);\n\treturn Object.freeze(blindCast({\n\t\t...node,\n\t\ttype: \"s3-store\"\n\t}));\n}\n//#endregion\nexport { compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };\n\n//# sourceMappingURL=index.mjs.map","import { contract, rpc } from \"@internal/rpc\";\nimport { type } from \"arktype\";\nimport { param } from \"@internal/core\";\nimport node from \"@internal/node\";\nimport { compute } from \"@internal/prisma-cloud\";\n//#region src/contract.ts\n/**\n* The one call edge between the scheduler and the app's runner: `trigger(jobId)`.\n* The scheduler depends on it (`rpc(triggerContract)`); the runner exposes it\n* (`expose: { trigger: triggerContract }`). `jobId` travels as data through this\n* single method — adding a job never adds a method, service, or port.\n*/\nconst triggerContract = contract({ trigger: rpc({\n\tinput: type({ jobId: \"string\" }),\n\toutput: type({ ok: \"boolean\" })\n}) });\n//#endregion\n//#region src/schedule.ts\n/**\n* `defineSchedule({ tick: '60s', mrr: '24h' })` →\n* `{ jobs: [{ jobId: 'tick', every: '60s' }, { jobId: 'mrr', every: '24h' }] }`,\n* preserving key order.\n*/\nfunction defineSchedule(spec) {\n\treturn { jobs: Object.entries(spec).map(([jobId, every]) => ({\n\t\tjobId,\n\t\tevery\n\t})) };\n}\n/**\n* Parses the `every` grammar `<integer><unit>`, unit one of `s`/`m`/`h`/`d`\n* (e.g. `30s`, `24h`), returning milliseconds. Throws on a malformed value —\n* empty, missing/unknown unit, non-integer, or non-positive.\n*/\nfunction parseEvery(s) {\n\tconst match = /^(\\d+)([smhd])$/.exec(s);\n\tif (match === null) throw new Error(`parseEvery(): \"${s}\" is not a valid interval — expected \"<integer><unit>\" with unit one of s/m/h/d (e.g. \"30s\", \"24h\").`);\n\tconst [, digits = \"\", unit = \"\"] = match;\n\tconst value = Number(digits);\n\tif (!Number.isInteger(value) || value <= 0) throw new Error(`parseEvery(): \"${s}\" must have a positive integer value.`);\n\tswitch (unit) {\n\t\tcase \"s\": return value * 1e3;\n\t\tcase \"m\": return value * 6e4;\n\t\tcase \"h\": return value * 36e5;\n\t\tcase \"d\": return value * 864e5;\n\t\tdefault: throw new Error(`parseEvery(): \"${s}\" has an unknown unit \"${unit}\" — expected one of s/m/h/d.`);\n\t}\n}\n//#endregion\n//#region src/scheduler.ts\n/**\n* The reusable scheduler node and its firing logic. `cronScheduler` builds a\n* `compute()` whose `jobs` param default is the app's schedule and whose only\n* dependency is `trigger(jobId)`; nothing else about it varies per app.\n* `runScheduler` is the pure, injectable firing loop the entrypoint (and its\n* tests) drive.\n*/\nconst scheduleSchema = type({\n\tjobId: \"string\",\n\tevery: \"string\"\n}).array();\n/**\n* The always-on scheduler service. `schedule` sets only the `jobs` param's\n* default — the value the deploy serializes into config; the scheduler\n* itself is job-agnostic.\n*/\nfunction cronScheduler(schedule) {\n\treturn compute({\n\t\tname: \"scheduler\",\n\t\tdeps: { trigger: rpc(triggerContract) },\n\t\tparams: { jobs: param(scheduleSchema, { default: [...schedule.jobs] }) },\n\t\tbuild: node({\n\t\t\tmodule: new URL(\"./scheduler-service.mjs\", import.meta.url).href,\n\t\t\tentry: \"./scheduler-entrypoint.mjs\"\n\t\t})\n\t});\n}\n/**\n* Fires `call(jobId)` on each job's `every` interval. A rejected `call` is\n* logged, never thrown — a missed tick is healed by an idempotent target, not\n* by scheduler state. `setTimer` defaults to `setInterval`; tests inject a\n* fake to drive time.\n*/\nfunction runScheduler(opts) {\n\tconst setTimer = opts.setTimer ?? ((fn, ms) => setInterval(fn, ms));\n\tfor (const job of opts.jobs) setTimer(() => {\n\t\topts.call(job.jobId).catch((err) => {\n\t\t\tconsole.error(`cron: job \"${job.jobId}\" failed`, err);\n\t\t});\n\t}, parseEvery(job.every));\n}\n//#endregion\nexport { triggerContract as i, runScheduler as n, defineSchedule as r, cronScheduler as t };\n\n//# sourceMappingURL=scheduler-iL9rl3YY.mjs.map","import { t as cronScheduler } from \"./scheduler-iL9rl3YY.mjs\";\n//#region src/scheduler-service.ts\nvar scheduler_service_default = cronScheduler({ jobs: [] });\n//#endregion\nexport { scheduler_service_default as default };\n\n//# sourceMappingURL=scheduler-service.mjs.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AO;EACN,aAAa;EACb,iBAAiB;CAClB;CACA,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;;;;;;;;;ACnID,MAAM,kBAAkB,SAAS,EAAE,SAAS,IAAI;CAC/C,OAAO,KAAK,EAAE,OAAO,SAAS,CAAC;CAC/B,QAAQ,KAAK,EAAE,IAAI,UAAU,CAAC;AAC/B,CAAC,EAAE,CAAC;;;;;;;;AA0CJ,MAAM,iBAAiB,KAAK;CAC3B,OAAO;CACP,OAAO;AACR,CAAC,CAAC,CAAC,MAAM;;;;;;AAMT,SAAS,cAAc,UAAU;CAChC,OAAO,QAAQ;EACd,MAAM;EACN,MAAM,EAAE,SAAS,IAAI,eAAe,EAAE;EACtC,QAAQ,EAAE,MAAM,MAAM,gBAAgB,EAAE,SAAS,CAAC,GAAG,SAAS,IAAI,EAAE,CAAC,EAAE;EACvE,OAAO,KAAK;GACX,QAAQ,IAAI,IAAI,2BAA2B,OAAO,KAAK,GAAG,CAAC,CAAC;GAC5D,OAAO;EACR,CAAC;CACF,CAAC;AACF;;;AC1EA,IAAI,4BAA4B,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"scheduler-service.mjs","names":[],"sources":["../../../../1-prisma-cloud/1-extensions/target/dist/serializer-CX4VYdf_.mjs","../../../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-DIQAR4q4.mjs","../../../../1-prisma-cloud/1-extensions/target/dist/index.mjs","../../../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-DhziPSWE.mjs","../../../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-service.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 = \"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 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\"COMPOSER\",\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}\nconst PARAM_POINTER_PREFIX = \"@composer-param-pointer:\";\n/** True iff `raw` is a param pointer row (as opposed to a JSON-encoded literal). */\nconst isParamPointerRow = (raw) => raw.startsWith(PARAM_POINTER_PREFIX);\n/** Builds a param pointer row's stored value from the platform var NAME it points to. */\nconst encodeParamPointer = (name) => `${PARAM_POINTER_PREFIX}${name}`;\n/** Reverses `encodeParamPointer`: the platform var NAME a pointer row points to. */\nconst decodeParamPointer = (raw) => raw.slice(24);\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\tif (d.owner === \"service\" && isParamPointerRow(raw)) return coerceEnvSourcedParam(raw, d, key);\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 resolution for an env-sourced param: double-lookup (pointer → platform\n* var), then the param's own schema on the raw string — no JSON decode, and\n* no redaction (it's config, not a secret). An UNSET platform var is a loud\n* boot failure naming both the param and the platform var; an EMPTY string is\n* not special-cased here — it reaches the schema like any other value, so it\n* passes iff the schema accepts it (deliberately unlike a literal param's own\n* \"\"-means-absent rule, and unlike a secret's non-empty requirement).\n*/\nfunction coerceEnvSourcedParam(raw, d, key) {\n\tconst platformVar = decodeParamPointer(raw);\n\tconst value = process.env[platformVar];\n\tif (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.`);\n\ttry {\n\t\treturn standardValidateSync(d.param.schema, value);\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`invalid value for env-sourced config param \"${d.name}\" (env ${key} → ${platformVar}): ${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: COMPOSER_<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/**\n* Boot: for each reserved provider param, read its address-scoped row through\n* the same `coerce` a declared param uses (JSON-decode, schema-validate), and\n* re-emit it address-free — `stash`'s counterpart for this separate\n* declaration space. A param is declared optional here unconditionally: an\n* absent row means \"never provisioned\" (local dev, tests, a provider with no\n* registered value for this deploy), never a boot failure, so nothing is\n* stashed and the runtime reader that owns this slot falls back to its own\n* pass-through behavior.\n*/\nfunction stashProviderParams(entries, address) {\n\tfor (const entry of entries) {\n\t\tconst d = {\n\t\t\towner: \"service\",\n\t\t\tname: entry.name,\n\t\t\tparam: {\n\t\t\t\tschema: entry.schema,\n\t\t\t\toptional: true\n\t\t\t}\n\t\t};\n\t\tconst key = configKey(address, d);\n\t\tconst value = coerce(process.env[key], d, key);\n\t\tif (value === void 0) continue;\n\t\tprocess.env[configKey(\"\", d)] = encode(\"service\", value);\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 { encodeParamPointer as a, stash as c, envSecret as d, secretName as f, encode as i, stashProviderParams as l, deserialize as n, paramEntries as o, deserializeSecrets as r, secretPointerRows as s, configKey as t, stashSecrets as u };\n\n//# sourceMappingURL=serializer-CX4VYdf_.mjs.map","import { t as configKey } from \"./serializer-CX4VYdf_.mjs\";\nimport { isParamSource, paramSource, provisionNeed } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport { RPC_PEER_KEY } from \"@internal/service-rpc\";\nimport { type } from \"arktype\";\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\nconst RESERVED_PROVIDER_PARAMS = [RPC_ACCEPTED_KEYS_PARAM, STREAMS_API_KEY_PARAM];\n//#endregion\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/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 { paramName as a, STREAMS_API_KEY_ENV as c, paramBindingFor as i, streamsApiKeyNeed as l, envParam as n, RESERVED_PROVIDER_PARAMS as o, isEnvParamSource as r, STREAMS_API_KEY as s, provisionedEdges as t };\n\n//# sourceMappingURL=provisioned-edges-DIQAR4q4.mjs.map","import { a as paramName, c as STREAMS_API_KEY_ENV, l as streamsApiKeyNeed, n as envParam, o as RESERVED_PROVIDER_PARAMS, s as STREAMS_API_KEY, t as provisionedEdges } from \"./provisioned-edges-DIQAR4q4.mjs\";\nimport { c as stash, d as envSecret, f as secretName, l as stashProviderParams, n as deserialize, r as deserializeSecrets, t as configKey, u as stashSecrets } from \"./serializer-CX4VYdf_.mjs\";\nimport { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from \"@internal/core\";\nimport { blindCast } from \"@internal/foundation/casts\";\n//#region src/bucket.ts\n/**\n* The contract a provisioned Bucket provides — deliberately kind-equal to the\n* storage module's `s3Contract` (`kind: 's3'`). `satisfies` compares KIND,\n* not identity (mirrors `postgresContract`): a real bucket and the emulator\n* are interchangeable at every `s3()` dependency slot. Cross-layer import of\n* the storage module's contract is not allowed (layering: 2-shared-modules\n* depends on 1-extensions, not the reverse), which is exactly the design\n* rationale for kind-equality — the two contracts cooperate through their\n* shared kind string, not through object identity.\n*/\nconst bucketContract = Object.freeze({\n\tkind: \"s3\",\n\t__cmp: {\n\t\turl: \"\",\n\t\tbucket: \"\",\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"s3\"\n});\nfunction bucket(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: bucketContract\n\t});\n\treturn dependency({\n\t\ttype: \"s3\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\turl: string(),\n\t\t\t\tbucket: string(),\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: bucketContract\n\t});\n}\n//#endregion\n//#region src/compute.ts\nconst reservedParams = { port: number({ default: 3e3 }) };\n/**\n* A Prisma Compute service — declarations only (deps + params + build + the\n* ports it exposes), no descriptor. `params` merges with the reserved\n* `ReservedParams` (`port`); a user param whose name collides with a reserved\n* one fails at authoring, the same way a colliding dependency name does.\n* Returns the extension's runnable/loadable node:\n* · run(address, boot) — the process controller: deserialize the platform\n* environment (keyed off `address`, the extension's ONE env read) into a\n* typed Config, re-emit it under address-free process-local stash keys,\n* then call boot() to start the app's entry.\n* · load() / config() — called from inside the app's entry: read the stash;\n* load() hydrates + memoizes the deps, config() returns the typed params.\n* Separate accessors so a dep and a param never share a namespace (ADR-0021).\n*\n* `service()`'s underlying node carries `extension: '@prisma/composer-prisma-cloud'` —\n* the control-plane registry key `prisma-composer deploy` resolves through the\n* app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at\n* deploy time; nodes are pure data.\n*/\nconst compute = (def) => {\n\tconst userParams = def.params ?? blindCast({});\n\tfor (const reserved of Object.keys(reservedParams)) {\n\t\tif (reserved in def.deps) throw new Error(`compute(): dependency \"${reserved}\" collides with the reserved service param of the same name — rename the dependency.`);\n\t\tif (reserved in userParams) throw new Error(`compute(): param \"${reserved}\" collides with the reserved service param of the same name — rename the param.`);\n\t}\n\tconst params = blindCast({\n\t\t...userParams,\n\t\t...reservedParams\n\t});\n\tconst node = service({\n\t\tname: def.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\ttype: \"compute\",\n\t\tinputs: def.deps,\n\t\tparams,\n\t\t...def.secrets !== void 0 ? { secrets: def.secrets } : {},\n\t\tbuild: def.build,\n\t\t...def.expose !== void 0 ? { expose: def.expose } : {}\n\t});\n\tlet resolved;\n\tlet loadedDeps;\n\tlet loadedParams;\n\tlet loadedSecrets;\n\tfunction processConfig() {\n\t\tif (resolved === void 0) resolved = deserialize(node, \"\");\n\t\treturn resolved;\n\t}\n\tconst runnable = {\n\t\t...node,\n\t\tasync run(address, boot) {\n\t\t\tconst config = deserialize(node, address);\n\t\t\tstash(node, config);\n\t\t\tstashProviderParams(RESERVED_PROVIDER_PARAMS, address);\n\t\t\tstashSecrets(node, address);\n\t\t\tconst port = config.service[\"port\"];\n\t\t\tif (typeof port === \"number\") process.env[\"PORT\"] = String(port);\n\t\t\treturn boot();\n\t\t},\n\t\tload() {\n\t\t\tif (loadedDeps === void 0) loadedDeps = blindCast(hydrateSync(node, processConfig()));\n\t\t\treturn loadedDeps;\n\t\t},\n\t\tconfig() {\n\t\t\tif (loadedParams === void 0) loadedParams = blindCast(processConfig().service);\n\t\t\treturn loadedParams;\n\t\t},\n\t\tsecrets() {\n\t\t\tif (loadedSecrets === void 0) loadedSecrets = blindCast(hydrateSecrets(node, deserializeSecrets(node, \"\")));\n\t\t\treturn loadedSecrets;\n\t\t}\n\t};\n\treturn Object.freeze(blindCast(runnable));\n};\n//#endregion\n//#region src/http.ts\nconst defaultHttpClient = (cfg) => ({\n\turl: cfg.url,\n\tfetch: (path, init) => fetch(new URL(path, cfg.url), init)\n});\n/**\n* A service-to-service dependency. Its binding (what `load()` returns) is a\n* derived HttpClient — a thin URL-anchored fetch wrapper (fetch is standard\n* across runtimes — no driver, no runtime coupling). http() is a\n* protocol-owned kind: the framework owns the transport, so the client is\n* kind-canonical and derived from the contract, with no user client in the\n* declaration (ADR-0015). The typed generated client arrives with the\n* interface primitive (a later extension point).\n*/\nconst http = (opts) => dependency({\n\tname: opts.name,\n\ttype: \"http\",\n\tconnection: {\n\t\tparams: { url: string() },\n\t\thydrate: (v) => defaultHttpClient({ url: v.url })\n\t}\n});\n//#endregion\n//#region src/postgres.ts\n/**\n* The contract a Postgres provides — and the contract its consumers require.\n* `satisfies` compares KIND, not identity: an extension module can be duplicated\n* across a workspace (same rationale as the Symbol.for node brand), and every\n* duplicate's contract must still satisfy. `__cmp` is the connection config a\n* postgres offers; core never inspects it.\n*/\nconst postgresContract = Object.freeze({\n\tkind: \"postgres\",\n\t__cmp: { url: \"\" },\n\tsatisfies: (required) => required.kind === \"postgres\"\n});\nfunction postgres(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: postgresContract\n\t});\n\treturn dependency({\n\t\ttype: \"postgres\",\n\t\tconnection: {\n\t\t\tparams: { url: string() },\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: postgresContract\n\t});\n}\n//#endregion\n//#region src/s3-credentials.ts\n/**\n* The contract the `s3-credentials` resource provides — a minted SigV4 key\n* pair. `satisfies` compares KIND only (mirrors `postgresContract`); `__cmp` is\n* the config the resource offers, which core never inspects.\n*/\nconst credentialsContract = Object.freeze({\n\tkind: \"credentials\",\n\t__cmp: {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\"\n\t},\n\tsatisfies: (required) => required.kind === \"credentials\"\n});\nfunction s3Credentials(opts) {\n\tif (opts?.name !== void 0) return resource({\n\t\tname: opts.name,\n\t\textension: \"@prisma/composer-prisma-cloud\",\n\t\tprovides: credentialsContract\n\t});\n\treturn dependency({\n\t\ttype: \"credentials\",\n\t\tconnection: {\n\t\t\tparams: {\n\t\t\t\taccessKeyId: string(),\n\t\t\t\tsecretAccessKey: string()\n\t\t\t},\n\t\t\thydrate: (v) => v\n\t\t},\n\t\trequired: credentialsContract\n\t});\n}\n//#endregion\n//#region src/s3-store.ts\n/**\n* The storage service authoring factory — a `compute` service routed to the\n* `s3-store` lowering instead of `compute`'s. It is exactly `compute`'s\n* runnable (run/load/config, deps, params, build, expose) with the routing\n* `type` overridden to `'s3-store'`: nothing at runtime keys off `type` (the\n* serializer keys off the deployment address and each param's owner/name, and\n* `load`/`config` off deps/params), so only the deploy-time descriptor lookup\n* sees the override and routes to the extended-output lowering (§ 5). The\n* return type is compute's exactly (including the reserved `port` param). The\n* storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`\n* param, and `expose: { store: s3Contract }`.\n*/\nfunction s3StoreService(def) {\n\tconst node = compute(def);\n\treturn Object.freeze(blindCast({\n\t\t...node,\n\t\ttype: \"s3-store\"\n\t}));\n}\n//#endregion\nexport { STREAMS_API_KEY, STREAMS_API_KEY_ENV, bucket, bucketContract, compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, provisionedEdges, s3Credentials, s3StoreService, secretName, streamsApiKeyNeed };\n\n//# sourceMappingURL=index.mjs.map","import { contract, rpc } from \"@internal/service-rpc\";\nimport { type } from \"arktype\";\nimport { param } from \"@internal/core\";\nimport node from \"@internal/node\";\nimport { compute } from \"@internal/prisma-cloud\";\n//#region src/contract.ts\n/**\n* The one call edge between the scheduler and the app's runner: `trigger(jobId)`.\n* The scheduler depends on it (`rpc(triggerContract)`); the runner exposes it\n* (`expose: { trigger: triggerContract }`). `jobId` travels as data through this\n* single method — adding a job never adds a method, service, or port.\n*/\nconst triggerContract = contract({ trigger: rpc({\n\tinput: type({ jobId: \"string\" }),\n\toutput: type({ ok: \"boolean\" })\n}) });\n//#endregion\n//#region src/schedule.ts\n/**\n* `defineSchedule({ tick: '60s', mrr: '24h' })` →\n* `{ jobs: [{ jobId: 'tick', every: '60s' }, { jobId: 'mrr', every: '24h' }] }`,\n* preserving key order.\n*/\nfunction defineSchedule(spec) {\n\treturn { jobs: Object.entries(spec).map(([jobId, every]) => ({\n\t\tjobId,\n\t\tevery\n\t})) };\n}\n/**\n* Parses the `every` grammar `<integer><unit>`, unit one of `s`/`m`/`h`/`d`\n* (e.g. `30s`, `24h`), returning milliseconds. Throws on a malformed value —\n* empty, missing/unknown unit, non-integer, or non-positive.\n*/\nfunction parseEvery(s) {\n\tconst match = /^(\\d+)([smhd])$/.exec(s);\n\tif (match === null) throw new Error(`parseEvery(): \"${s}\" is not a valid interval — expected \"<integer><unit>\" with unit one of s/m/h/d (e.g. \"30s\", \"24h\").`);\n\tconst [, digits = \"\", unit = \"\"] = match;\n\tconst value = Number(digits);\n\tif (!Number.isInteger(value) || value <= 0) throw new Error(`parseEvery(): \"${s}\" must have a positive integer value.`);\n\tswitch (unit) {\n\t\tcase \"s\": return value * 1e3;\n\t\tcase \"m\": return value * 6e4;\n\t\tcase \"h\": return value * 36e5;\n\t\tcase \"d\": return value * 864e5;\n\t\tdefault: throw new Error(`parseEvery(): \"${s}\" has an unknown unit \"${unit}\" — expected one of s/m/h/d.`);\n\t}\n}\n//#endregion\n//#region src/scheduler.ts\n/**\n* The reusable scheduler node and its firing logic. `cronScheduler` builds a\n* `compute()` whose `jobs` param default is the app's schedule and whose only\n* dependency is `trigger(jobId)`; nothing else about it varies per app.\n* `runScheduler` is the pure, injectable firing loop the entrypoint (and its\n* tests) drive.\n*/\nconst scheduleSchema = type({\n\tjobId: \"string\",\n\tevery: \"string\"\n}).array();\n/**\n* The always-on scheduler service. `schedule` sets only the `jobs` param's\n* default — the value the deploy serializes into config; the scheduler\n* itself is job-agnostic.\n*/\nfunction cronScheduler(schedule) {\n\treturn compute({\n\t\tname: \"scheduler\",\n\t\tdeps: { trigger: rpc(triggerContract) },\n\t\tparams: { jobs: param(scheduleSchema, { default: [...schedule.jobs] }) },\n\t\tbuild: node({\n\t\t\tmodule: new URL(\"./scheduler-service.mjs\", import.meta.url).href,\n\t\t\tentry: \"./scheduler-entrypoint.mjs\"\n\t\t})\n\t});\n}\n/**\n* Fires `call(jobId)` on each job's `every` interval. A rejected `call` is\n* logged, never thrown — a missed tick is healed by an idempotent target, not\n* by scheduler state. `setTimer` defaults to `setInterval`; tests inject a\n* fake to drive time.\n*/\nfunction runScheduler(opts) {\n\tconst setTimer = opts.setTimer ?? ((fn, ms) => setInterval(fn, ms));\n\tfor (const job of opts.jobs) setTimer(() => {\n\t\topts.call(job.jobId).catch((err) => {\n\t\t\tconsole.error(`cron: job \"${job.jobId}\" failed`, err);\n\t\t});\n\t}, parseEvery(job.every));\n}\n//#endregion\nexport { triggerContract as i, runScheduler as n, defineSchedule as r, cronScheduler as t };\n\n//# sourceMappingURL=scheduler-DhziPSWE.mjs.map","import { t as cronScheduler } from \"./scheduler-DhziPSWE.mjs\";\n//#region src/execution/scheduler-service.ts\nvar scheduler_service_default = cronScheduler({ jobs: [] });\n//#endregion\nexport { scheduler_service_default as default };\n\n//# sourceMappingURL=scheduler-service.mjs.map"],"mappings":";;;;;AASmC,UAAU,OAAO,IAAI,mCAAmC,CAAC;;;;;;;AA0C5F,SAAS,aAAa,MAAM;CAC3B,MAAM,UAAU,CAAC;CACjB,KAAK,MAAM,CAAC,OAAO,UAAU,OA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AAO,OAAO,OAAO,UAAU,QAAQ,CAAC;AACzC;AAiCyB,OAAO,OAAO;CACtC,MAAM;CACN,OAAO,EAAE,KAAK,GAAG;CACjB,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;AAuB2B,OAAO,OAAO;CACzC,MAAM;CACN,OAAO;EACN,aAAa;EACb,iBAAiB;CAClB;CACA,YAAY,aAAa,SAAS,SAAS;AAC5C,CAAC;;;;;;;;;AC/KD,MAAM,kBAAkB,SAAS,EAAE,SAAS,IAAI;CAC/C,OAAO,KAAK,EAAE,OAAO,SAAS,CAAC;CAC/B,QAAQ,KAAK,EAAE,IAAI,UAAU,CAAC;AAC/B,CAAC,EAAE,CAAC;;;;;;;;AA0CJ,MAAM,iBAAiB,KAAK;CAC3B,OAAO;CACP,OAAO;AACR,CAAC,CAAC,CAAC,MAAM;;;;;;AAMT,SAAS,cAAc,UAAU;CAChC,OAAO,QAAQ;EACd,MAAM;EACN,MAAM,EAAE,SAAS,IAAI,eAAe,EAAE;EACtC,QAAQ,EAAE,MAAM,MAAM,gBAAgB,EAAE,SAAS,CAAC,GAAG,SAAS,IAAI,EAAE,CAAC,EAAE;EACvE,OAAO,KAAK;GACX,QAAQ,IAAI,IAAI,2BAA2B,OAAO,KAAK,GAAG,CAAC,CAAC;GAC5D,OAAO;EACR,CAAC;CACF,CAAC;AACF;;;AC1EA,IAAI,4BAA4B,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC"}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,45 @@
1
- import { BuildAdapter, ConfigParam, Contract, DependencyEnd, Deps, Expose, Params, ResourceNode, RunnableServiceNode, SecretBinding, SecretSource, Secrets } from "@prisma/composer";
2
-
1
+ import { n as configKey } from "./serializer-Cx5slrV4-xJfH6EWS.mjs";
2
+ import { BuildAdapter, Contract, DependencyEnd, Deps, Expose, Graph, ParamBinding, ParamSource, Params, ProvisionNeed, ResourceNode, RunnableServiceNode, SecretBinding, SecretSource, Secrets } from "@prisma/composer";
3
3
  //#region ../../1-prisma-cloud/1-extensions/target/dist/index.d.mts
4
+ //#region src/bucket.d.ts
5
+ interface BucketConfig {
6
+ readonly url: string;
7
+ readonly bucket: string;
8
+ readonly accessKeyId: string;
9
+ readonly secretAccessKey: string;
10
+ }
11
+ /**
12
+ * The contract a provisioned Bucket provides — deliberately kind-equal to the
13
+ * storage module's `s3Contract` (`kind: 's3'`). `satisfies` compares KIND,
14
+ * not identity (mirrors `postgresContract`): a real bucket and the emulator
15
+ * are interchangeable at every `s3()` dependency slot. Cross-layer import of
16
+ * the storage module's contract is not allowed (layering: 2-shared-modules
17
+ * depends on 1-extensions, not the reverse), which is exactly the design
18
+ * rationale for kind-equality — the two contracts cooperate through their
19
+ * shared kind string, not through object identity.
20
+ */
21
+ declare const bucketContract: Contract<'s3', BucketConfig>;
22
+ /**
23
+ * The one Bucket factory; the argument shape picks the role.
24
+ *
25
+ * `{ name }` — the resource identity a module provisions: the ONE place the
26
+ * bucket exists, providing `bucketContract`. Return type declared explicitly
27
+ * so nothing widens.
28
+ */
29
+ declare function bucket(opts: {
30
+ name: string;
31
+ }): ResourceNode<typeof bucketContract>;
32
+ /**
33
+ * `bucket()` — a service's dependency on a real bucket. Its binding (what
34
+ * `load()` returns) is the typed connection config `BucketConfig` itself —
35
+ * `{ url, bucket, accessKeyId, secretAccessKey }`. The app constructs its own
36
+ * S3 client from that config (ADR-0015). The kind `'s3'` makes this slot
37
+ * interchangeable with the storage emulator's `s3()` dependency: any provider
38
+ * whose contract has `kind === 's3'` — whether a real bucket or the emulator
39
+ * — will wire here.
40
+ */
41
+ declare function bucket(): DependencyEnd<BucketConfig, typeof bucketContract>;
42
+ //#endregion
4
43
  //#region src/compute.d.ts
5
44
  declare const reservedParams: {
6
45
  readonly port: import("@prisma/composer").ConfigParam<import("@standard-schema/spec").StandardSchemaV1<number, number>>;
@@ -32,7 +71,8 @@ declare const compute: <D extends Deps, P extends Params = Record<never, never>,
32
71
  secrets?: S;
33
72
  build: BuildAdapter;
34
73
  expose?: E;
35
- }) => RunnableServiceNode<D, P & ReservedParams, E, S>; //#endregion
74
+ }) => RunnableServiceNode<D, P & ReservedParams, E, S>;
75
+ //#endregion
36
76
  //#region src/http.d.ts
37
77
  /** A service-to-service dependency's client: a thin URL-anchored fetch wrapper. */
38
78
  interface HttpClient {
@@ -50,7 +90,40 @@ interface HttpClient {
50
90
  */
51
91
  declare const http: (opts: {
52
92
  name: string;
53
- }) => DependencyEnd<HttpClient>; //#endregion
93
+ }) => DependencyEnd<HttpClient>;
94
+ //#endregion
95
+ //#region src/param.d.ts
96
+ /**
97
+ * Brands the payload `envParam` builds. Core's `paramSource()` is a public
98
+ * SPI, so a user could bypass `envParam` and bind a raw `paramSource('x')`;
99
+ * the brand lets `paramName` reject such a source (or another target's) with
100
+ * a clear error instead of reading an absent `.name`.
101
+ */
102
+ declare const PRISMA_CLOUD_PARAM_SOURCE: unique symbol;
103
+ /** The Prisma Cloud param source payload: the platform env-var name the slot resolves to, under a brand only `envParam` sets. */
104
+ interface EnvParamPayload {
105
+ readonly [PRISMA_CLOUD_PARAM_SOURCE]: true;
106
+ readonly name: string;
107
+ }
108
+ /**
109
+ * Binds a param slot to a named Prisma Cloud platform env var — the non-secret
110
+ * sibling of `envSecret` (spec: env-sourced config params). The platform
111
+ * injects the value into the running instance per stage; the param's own
112
+ * schema validates it at boot, unredacted. The name may not use the
113
+ * framework's reserved `COMPOSER_` prefix or the poisoned
114
+ * `DATABASE_URL(_POOLED)` keys — same parity as `envSecret`.
115
+ */
116
+ declare function envParam(name: string): ParamSource<EnvParamPayload>;
117
+ /**
118
+ * Reads the Prisma Cloud env-var name back out of a param binding's opaque
119
+ * source. A source not built by `envParam` (a raw `paramSource(...)` or
120
+ * another target's source) carries no name — reject it here. `paramName` runs
121
+ * in preflight and at serialize before any value ever crosses the wire, so a
122
+ * foreign source fails early and clearly rather than producing a broken
123
+ * deploy with an undefined name.
124
+ */
125
+ declare function paramName(binding: ParamBinding): string;
126
+ //#endregion
54
127
  //#region src/postgres.d.ts
55
128
  interface PostgresConfig {
56
129
  readonly url: string;
@@ -81,7 +154,26 @@ declare function postgres(opts: {
81
154
  * `const sql = new SQL({ url: db.url })`. No driver choice lives in the
82
155
  * declaration.
83
156
  */
84
- declare function postgres(): DependencyEnd<PostgresConfig, typeof postgresContract>; //#endregion
157
+ declare function postgres(): DependencyEnd<PostgresConfig, typeof postgresContract>;
158
+ //#endregion
159
+ //#region src/provisioned-edges.d.ts
160
+ /** One faceted dependency edge: a consumer input whose param carries a provisioning need. */
161
+ interface ProvisionedEdge {
162
+ /** `${consumerAddress}.${input}` — `ctx.provisioned`'s key. */
163
+ readonly edgeId: string;
164
+ readonly consumerAddress: string;
165
+ readonly input: string;
166
+ readonly providerAddress: string;
167
+ /** The need's brand — opaque here; the target's registry gives it meaning. */
168
+ readonly brand: symbol;
169
+ }
170
+ /**
171
+ * Every provisioned edge in the graph. Core resolves and mints these (one
172
+ * value per edge, keyed by `edgeId`); this scan is how the target finds them
173
+ * again when it gathers a provider's inbound values.
174
+ */
175
+ declare function provisionedEdges(graph: Graph): readonly ProvisionedEdge[];
176
+ //#endregion
85
177
  //#region src/s3-credentials.d.ts
86
178
  interface CredentialsConfig {
87
179
  readonly accessKeyId: string;
@@ -107,7 +199,8 @@ declare function s3Credentials(opts: {
107
199
  * the typed `CredentialsConfig`. The storage service reads the pair through this
108
200
  * dependency binding (invariant 4 — no bespoke env reads).
109
201
  */
110
- declare function s3Credentials(): DependencyEnd<CredentialsConfig, typeof credentialsContract>; //#endregion
202
+ declare function s3Credentials(): DependencyEnd<CredentialsConfig, typeof credentialsContract>;
203
+ //#endregion
111
204
  //#region src/s3-store.d.ts
112
205
  /**
113
206
  * The storage service authoring factory — a `compute` service routed to the
@@ -121,7 +214,8 @@ declare function s3Credentials(): DependencyEnd<CredentialsConfig, typeof creden
121
214
  * storage module (D4b) calls this with its `db`/`credentials` deps, a `bucket`
122
215
  * param, and `expose: { store: s3Contract }`.
123
216
  */
124
- declare function s3StoreService<D extends Deps, P extends Params = Record<never, never>, E extends Expose = Record<never, never>>(def: Parameters<typeof compute<D, P, E>>[0]): ReturnType<typeof compute<D, P, E>>; //#endregion
217
+ declare function s3StoreService<D extends Deps, P extends Params = Record<never, never>, E extends Expose = Record<never, never>>(def: Parameters<typeof compute<D, P, E>>[0]): ReturnType<typeof compute<D, P, E>>;
218
+ //#endregion
125
219
  //#region src/secret.d.ts
126
220
  /**
127
221
  * Brands the payload `envSecret` builds. Core's `secretSource()` is a public
@@ -138,7 +232,7 @@ interface EnvSecretPayload {
138
232
  /**
139
233
  * Binds a secret slot to a named Prisma Cloud platform env var (ADR-0029). The
140
234
  * value is provisioned out-of-band; only the name is carried. The name may not
141
- * use the framework's reserved `COMPOSE_` prefix or the poisoned
235
+ * use the framework's reserved `COMPOSER_` prefix or the poisoned
142
236
  * `DATABASE_URL(_POOLED)` keys.
143
237
  */
144
238
  declare function envSecret(name: string): SecretSource<EnvSecretPayload>;
@@ -149,20 +243,21 @@ declare function envSecret(name: string): SecretSource<EnvSecretPayload>;
149
243
  * in preflight before any provisioning, so a foreign source fails early and
150
244
  * clearly rather than producing a broken deploy with an undefined name.
151
245
  */
152
- declare function secretName(binding: SecretBinding): string; //#endregion
153
- //#region src/serializer.d.ts
154
- /** One declared param, paired with its owner and the raw ConfigParam (functions included). */
155
- interface ParamEntry {
156
- readonly owner: 'service' | {
157
- readonly input: string;
158
- };
159
- readonly name: string;
160
- readonly param: ConfigParam;
161
- }
162
- declare const configKey: (address: string, d: {
163
- owner: ParamEntry["owner"];
164
- name: string;
165
- }) => string; //#endregion
246
+ declare function secretName(binding: SecretBinding): string;
247
+ //#endregion
248
+ //#region src/streams-keys.d.ts
249
+ /** ADR-0031's need brand for the streams module's bearer key — control.ts registers the provisioner under this. */
250
+ declare const STREAMS_API_KEY: unique symbol;
251
+ /**
252
+ * The provisioning need `durableStreams()`'s `apiKey` param declares: an
253
+ * unguessable value the target mints ONCE PER PROVIDER (not per edge) —
254
+ * `@prisma/streams-server` authenticates a single `API_KEY`, so every
255
+ * consumer of one streams module must present the same value. Per-provider
256
+ * cardinality is provisioner policy (ADR-0031), invisible to core.
257
+ */
258
+ declare const streamsApiKeyNeed: () => ProvisionNeed;
259
+ /** The address-free name compute.ts re-stashes to and the streams entrypoint reads. */
260
+ declare const STREAMS_API_KEY_ENV: string;
166
261
  //#endregion
167
- export { type CredentialsConfig, type CredentialsContract, type HttpClient, type PostgresConfig, compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };
262
+ export { type BucketConfig, type CredentialsConfig, type CredentialsContract, type HttpClient, type PostgresConfig, type ProvisionedEdge, STREAMS_API_KEY, STREAMS_API_KEY_ENV, bucket, bucketContract, compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, provisionedEdges, s3Credentials, s3StoreService, secretName, streamsApiKeyNeed };
168
263
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,7 +1,48 @@
1
- import { a as envSecret, l as stash, n as deserialize, r as deserializeSecrets, s as secretName, t as configKey, u as stashSecrets } from "./serializer-C2CsA7xm-29Eg2Tjl.mjs";
1
+ import { c as secretName, d as stashProviderParams, f as stashSecrets, n as deserialize, o as envSecret, r as deserializeSecrets, t as configKey, u as stash } from "./serializer-CX4VYdf_-KKGoAxfx.mjs";
2
+ import { c as provisionedEdges, i as envParam, l as streamsApiKeyNeed, n as STREAMS_API_KEY, r as STREAMS_API_KEY_ENV, s as paramName, t as RESERVED_PROVIDER_PARAMS } from "./provisioned-edges-DIQAR4q4-Bn9op-JG.mjs";
2
3
  import { dependency, hydrateSecrets, hydrateSync, number, resource, service, string } from "@prisma/composer";
3
4
  import { blindCast } from "@prisma/composer/casts";
4
5
  //#region ../../1-prisma-cloud/1-extensions/target/dist/index.mjs
6
+ /**
7
+ * The contract a provisioned Bucket provides — deliberately kind-equal to the
8
+ * storage module's `s3Contract` (`kind: 's3'`). `satisfies` compares KIND,
9
+ * not identity (mirrors `postgresContract`): a real bucket and the emulator
10
+ * are interchangeable at every `s3()` dependency slot. Cross-layer import of
11
+ * the storage module's contract is not allowed (layering: 2-shared-modules
12
+ * depends on 1-extensions, not the reverse), which is exactly the design
13
+ * rationale for kind-equality — the two contracts cooperate through their
14
+ * shared kind string, not through object identity.
15
+ */
16
+ const bucketContract = Object.freeze({
17
+ kind: "s3",
18
+ __cmp: {
19
+ url: "",
20
+ bucket: "",
21
+ accessKeyId: "",
22
+ secretAccessKey: ""
23
+ },
24
+ satisfies: (required) => required.kind === "s3"
25
+ });
26
+ function bucket(opts) {
27
+ if (opts?.name !== void 0) return resource({
28
+ name: opts.name,
29
+ extension: "@prisma/composer-prisma-cloud",
30
+ provides: bucketContract
31
+ });
32
+ return dependency({
33
+ type: "s3",
34
+ connection: {
35
+ params: {
36
+ url: string(),
37
+ bucket: string(),
38
+ accessKeyId: string(),
39
+ secretAccessKey: string()
40
+ },
41
+ hydrate: (v) => v
42
+ },
43
+ required: bucketContract
44
+ });
45
+ }
5
46
  const reservedParams = { port: number({ default: 3e3 }) };
6
47
  /**
7
48
  * A Prisma Compute service — declarations only (deps + params + build + the
@@ -55,6 +96,7 @@ const compute = (def) => {
55
96
  async run(address, boot) {
56
97
  const config = deserialize(node, address);
57
98
  stash(node, config);
99
+ stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
58
100
  stashSecrets(node, address);
59
101
  const port = config.service["port"];
60
102
  if (typeof port === "number") process.env["PORT"] = String(port);
@@ -174,6 +216,6 @@ function s3StoreService(def) {
174
216
  }));
175
217
  }
176
218
  //#endregion
177
- export { compute, configKey, credentialsContract, envSecret, http, postgres, postgresContract, s3Credentials, s3StoreService, secretName };
219
+ export { STREAMS_API_KEY, STREAMS_API_KEY_ENV, bucket, bucketContract, compute, configKey, credentialsContract, envParam, envSecret, http, paramName, postgres, postgresContract, provisionedEdges, s3Credentials, s3StoreService, secretName, streamsApiKeyNeed };
178
220
 
179
221
  //# sourceMappingURL=index.mjs.map