@prisma/composer-prisma-cloud 0.3.0-dev.5 → 0.3.0-dev.7

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 (64) hide show
  1. package/dist/control.d.mts +1 -1
  2. package/dist/control.mjs +28 -17
  3. package/dist/control.mjs.map +1 -1
  4. package/dist/cron/index.d.mts +33 -26
  5. package/dist/cron/index.d.mts.map +1 -1
  6. package/dist/cron/index.mjs +202 -77
  7. package/dist/cron/index.mjs.map +1 -1
  8. package/dist/cron/scheduler-entrypoint.mjs +133 -114
  9. package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
  10. package/dist/cron/scheduler-service.mjs +200 -76
  11. package/dist/cron/scheduler-service.mjs.map +1 -1
  12. package/dist/email/email-entrypoint.mjs +162 -126
  13. package/dist/email/email-entrypoint.mjs.map +1 -1
  14. package/dist/email/email-service.mjs +230 -79
  15. package/dist/email/email-service.mjs.map +1 -1
  16. package/dist/email/index.d.mts +33 -29
  17. package/dist/email/index.d.mts.map +1 -1
  18. package/dist/email/index.mjs +236 -84
  19. package/dist/email/index.mjs.map +1 -1
  20. package/dist/email/testing.mjs +112 -89
  21. package/dist/email/testing.mjs.map +1 -1
  22. package/dist/index.d.mts +51 -43
  23. package/dist/index.d.mts.map +1 -1
  24. package/dist/index.mjs +47 -51
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/local-target.mjs +1 -1
  27. package/dist/local-target.mjs.map +1 -1
  28. package/dist/{preflight-names-BPL-qsZF-BfoRgbgb.mjs → preflight-names-CpJUd9ZA-BCU-W3cT.mjs} +30 -14
  29. package/dist/{preflight-names-BPL-qsZF-BfoRgbgb.mjs.map → preflight-names-CpJUd9ZA-BCU-W3cT.mjs.map} +1 -1
  30. package/dist/{provisioned-edges-C1wSO3cx-YC5C19f9.mjs → provisioned-edges-Cxy18aoh-CUnaY96r.mjs} +3 -3
  31. package/dist/{provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map → provisioned-edges-Cxy18aoh-CUnaY96r.mjs.map} +1 -1
  32. package/dist/{param-BTzY0ne5-CW6ojZ3E.mjs → secret-BVGxqHxY-DYDfiULl.mjs} +45 -4
  33. package/dist/secret-BVGxqHxY-DYDfiULl.mjs.map +1 -0
  34. package/dist/{serializer-Cx5slrV4-xJfH6EWS.d.mts → serializer-BD_6nkr4-DWn5NNTC.d.mts} +2 -2
  35. package/dist/serializer-BD_6nkr4-DWn5NNTC.d.mts.map +1 -0
  36. package/dist/serializer-sVE4UAmg-CikRngbR.mjs +475 -0
  37. package/dist/serializer-sVE4UAmg-CikRngbR.mjs.map +1 -0
  38. package/dist/storage/index.d.mts +31 -26
  39. package/dist/storage/index.d.mts.map +1 -1
  40. package/dist/storage/index.mjs +215 -89
  41. package/dist/storage/index.mjs.map +1 -1
  42. package/dist/storage/storage-entrypoint.mjs +147 -122
  43. package/dist/storage/storage-entrypoint.mjs.map +1 -1
  44. package/dist/storage/storage-service.mjs +212 -87
  45. package/dist/storage/storage-service.mjs.map +1 -1
  46. package/dist/streams/index.d.mts +29 -22
  47. package/dist/streams/index.d.mts.map +1 -1
  48. package/dist/streams/index.mjs +213 -88
  49. package/dist/streams/index.mjs.map +1 -1
  50. package/dist/streams/streams-entrypoint.mjs +139 -118
  51. package/dist/streams/streams-entrypoint.mjs.map +1 -1
  52. package/dist/streams/streams-service.mjs +212 -87
  53. package/dist/streams/streams-service.mjs.map +1 -1
  54. package/dist/testing.d.mts +19 -5
  55. package/dist/testing.d.mts.map +1 -1
  56. package/dist/testing.mjs +11 -3
  57. package/dist/testing.mjs.map +1 -1
  58. package/package.json +18 -18
  59. package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +0 -1
  60. package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +0 -47
  61. package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +0 -1
  62. package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs +0 -251
  63. package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +0 -1
  64. package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +0 -1
@@ -1,10 +1,101 @@
1
- import { dependency, hydrateSecrets, hydrateSync, module, number, param, paramNeed, resource, secret, service, string } from "@prisma/composer";
1
+ import { dependency, hydrateSync, module, number, paramNeed, resource, secret, service, string } from "@prisma/composer";
2
2
  import { assertDefined } from "@prisma/composer/assertions";
3
3
  import { blindCast } from "@prisma/composer/casts";
4
4
  import { RPC_PEER_KEY, contract, makeClient, perBindingToken, rpc } from "@prisma/composer/service-rpc";
5
5
  import { type } from "arktype";
6
6
  import node from "@prisma/composer/node";
7
- //#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-CJiOhF2d.mjs
7
+ //#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
8
+ /**
9
+ * **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
10
+ *
11
+ * Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes
12
+ * unnecessary**: tighten an input type, add a runtime check that narrows via a type
13
+ * predicate, restructure a generic so the compiler can see the relationship you're
14
+ * asserting, or use {@link castAs} when the value already satisfies the target type.
15
+ * Only when no rewrite is feasible does `blindCast` become the right answer — and at
16
+ * that point, the `Reason` literal you supply must articulate the compromise in
17
+ * language a reviewer can evaluate.
18
+ *
19
+ * The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,
20
+ * that is not a signal to soften the reason; it is a signal to go back and solve the
21
+ * underlying type-system problem properly. An unconvincing justification is rework,
22
+ * not a free pass.
23
+ *
24
+ * `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses
25
+ * the compiler's checks (the input type is `unknown`, the output type is whatever the
26
+ * caller asks for), but it forces the unsafety to be named at the call site instead of
27
+ * smuggled in via a bare `as`. The `Reason` type parameter exists only at compile
28
+ * time — it is not present in the emitted JavaScript — but it is grep-able and
29
+ * visible to future readers.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const stringValue = blindCast<
34
+ * string,
35
+ * "JSON.parse returns `unknown`; this field is documented to be a string in the API contract"
36
+ * >(parsed[key]);
37
+ * ```
38
+ *
39
+ * @typeParam TargetType - The type the caller is asserting the input has.
40
+ * @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.
41
+ * Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.
42
+ */
43
+ function blindCast$1(input) {
44
+ return input;
45
+ }
46
+ //#endregion
47
+ //#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
48
+ /**
49
+ * A value wrapper that redacts everywhere except the one explicit reader,
50
+ * `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
51
+ * sink must remember to check: `String(box)`, template interpolation,
52
+ * `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
53
+ * a secret can't leak through an accidental log or serialization.
54
+ *
55
+ * Every box carries a brand property keyed by the registered symbol
56
+ * `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
57
+ * symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
58
+ * public shape still matches the platform's own `secrecy` type
59
+ * (pdp-control-plane).
60
+ */
61
+ const REDACTED = "[REDACTED]";
62
+ const SECRET_BOX = blindCast$1(Symbol.for("prisma:secret-box"));
63
+ var SecretBox = class {
64
+ [SECRET_BOX] = true;
65
+ #value;
66
+ constructor(value) {
67
+ this.#value = value;
68
+ }
69
+ /** The sole explicit door to the wrapped value. */
70
+ expose() {
71
+ return this.#value;
72
+ }
73
+ toString() {
74
+ return REDACTED;
75
+ }
76
+ toJSON() {
77
+ return REDACTED;
78
+ }
79
+ valueOf() {
80
+ return REDACTED;
81
+ }
82
+ [Symbol.toPrimitive]() {
83
+ return REDACTED;
84
+ }
85
+ [Symbol.for("nodejs.util.inspect.custom")]() {
86
+ return REDACTED;
87
+ }
88
+ };
89
+ /**
90
+ * True for a redacting secret box — what a schema's secret leaf checks
91
+ * (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
92
+ * duplicated module copy in a bundle counts and a look-alike does not.
93
+ */
94
+ function isSecretString(value) {
95
+ return typeof value === "object" && value !== null && blindCast$1(value)[SECRET_BOX] === true;
96
+ }
97
+ //#endregion
98
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-sVE4UAmg.mjs
8
99
  /**
9
100
  * Walks a node's own params, then each dependency input's connection params —
10
101
  * the same enumeration order `configOf` uses, but carrying the raw
@@ -94,7 +185,7 @@ function coerceEnvSourcedParam(raw, d, key) {
94
185
  /**
95
186
  * Boot: read each declared param from env by its key, reverse the param's own
96
187
  * serialization (missing/invalid fails loudly), assemble the typed Config.
97
- * Secrets ride a separate channel (deserializeSecrets), not this one.
188
+ * The input document rides its own channel (readInput), not this one.
98
189
  */
99
190
  const deserialize = (node, address) => {
100
191
  const service = {};
@@ -131,40 +222,84 @@ const stash = (node, config) => {
131
222
  process.env[configKey("", d)] = encode(d.owner, value);
132
223
  }
133
224
  };
134
- /** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
135
- const secretKey = (address, slot) => configKey(address, {
225
+ /** The input document's own row name; its full key is COMPOSER_<addr>_INPUT. */
226
+ const INPUT_KEY_NAME = "INPUT";
227
+ /** The input document row's key for a service address. */
228
+ const inputKey = (address) => configKey(address, {
136
229
  owner: "service",
137
- name: slot
230
+ name: INPUT_KEY_NAME
138
231
  });
232
+ const SECRET_MARKER = "$secret";
233
+ const ESCAPED_KEY = /^\$\$+secret$/;
234
+ /** True for the framework's secret pointer: `{ "$secret": "<PLATFORM_VAR>" }` and nothing else. */
235
+ function isSecretPointer(value) {
236
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && SECRET_MARKER in value && typeof value[SECRET_MARKER] === "string";
237
+ }
238
+ /** A plain data object (not an array, not a class instance) — the only object shape a binding/document may nest. */
239
+ function isPlainObject(value) {
240
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
241
+ const proto = Object.getPrototypeOf(value);
242
+ return proto === Object.prototype || proto === null;
243
+ }
139
244
  /**
140
- * Boot: resolve every secret slot to its value by double-lookup read the
141
- * pointer key (the platform NAME), then read that platform var. A missing
142
- * pointer or a missing/empty platform value is a loud failure naming both keys.
143
- * Returns a plain Record for core's `hydrateSecrets` to box.
245
+ * Boot: read the one input document row (address-free after run()'s
246
+ * re-stash), swap each `$secret` pointer for a redacting box over the named
247
+ * platform var, unescape reserved keys, validate with the service's own
248
+ * schema, and return the typed object. A missing row is a loud failure naming
249
+ * the env var — a deployed environment always writes it; a local harness must
250
+ * supply it (set the row to the serialized input document).
144
251
  */
145
- const deserializeSecrets = (node, address) => {
146
- const values = {};
147
- for (const slot of Object.keys(node.secretSlots)) {
148
- const key = secretKey(address, slot);
149
- const name = process.env[key];
150
- if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
151
- const value = process.env[name];
152
- if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
153
- values[slot] = value;
252
+ function readInput(node, address) {
253
+ const schema = node.inputSchema;
254
+ if (schema === void 0) throw new Error(`input() called on service "${node.name}", which declares no input schema — declare \`input: <schema>\` on compute() to use it (ADR-0042).`);
255
+ const key = inputKey(address);
256
+ const raw = process.env[key];
257
+ if (raw === void 0 || raw === "") throw new Error(`this service's input is not available (env ${key} is unset) — a deployed environment writes it automatically; a local harness must supply it like any other config value (set ${key} to the serialized input document).`);
258
+ let parsed;
259
+ try {
260
+ parsed = JSON.parse(raw);
261
+ } catch (cause) {
262
+ const message = cause instanceof Error ? cause.message : String(cause);
263
+ throw new Error(`this service's input document is not valid JSON (env ${key}): ${message} — a deployed environment writes it automatically; a local harness must supply the serialized input document (set ${key} to it).`);
154
264
  }
155
- return values;
156
- };
265
+ const hydrated = hydrateInputDocument(parsed, key);
266
+ try {
267
+ return standardValidateSync(schema, hydrated);
268
+ } catch (cause) {
269
+ const message = cause instanceof Error ? cause.message : String(cause);
270
+ throw new Error(`invalid input document (env ${key}): ${message}`);
271
+ }
272
+ }
273
+ /** Reverses the document encoding: `$secret` pointers become redacting boxes over the named platform vars; escaped reserved keys drop one "$". */
274
+ function hydrateInputDocument(value, key) {
275
+ if (isSecretPointer(value)) {
276
+ const name = value[SECRET_MARKER];
277
+ const secret = process.env[name];
278
+ if (secret === void 0 || secret === "") throw new Error(`secret input is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
279
+ return new SecretBox(secret);
280
+ }
281
+ if (Array.isArray(value)) return value.map((member) => hydrateInputDocument(member, key));
282
+ if (isPlainObject(value)) {
283
+ const out = {};
284
+ for (const [k, member] of Object.entries(value)) {
285
+ const read = ESCAPED_KEY.test(k) ? k.slice(1) : k;
286
+ out[read] = hydrateInputDocument(member, key);
287
+ }
288
+ return out;
289
+ }
290
+ return value;
291
+ }
157
292
  /**
158
- * run()'s setup step for secrets: re-emit each slot's pointer NAME under its
159
- * address-free key, so the address-free `deserializeSecrets` double-looks-up
160
- * identically. Never the value — the value stays only in the platform var.
293
+ * run()'s setup step for the input document: re-emit the row under its
294
+ * address-free key, so the address-free `readInput` reads identically. The
295
+ * document carries pointers, never values — the values stay only in their
296
+ * platform vars.
161
297
  */
162
- const stashSecrets = (node, address) => {
163
- for (const slot of Object.keys(node.secretSlots)) {
164
- const name = process.env[secretKey(address, slot)];
165
- if (name === void 0) continue;
166
- process.env[secretKey("", slot)] = name;
167
- }
298
+ const stashInput = (node, address) => {
299
+ if (node.inputSchema === void 0) return;
300
+ const raw = process.env[inputKey(address)];
301
+ if (raw === void 0) return;
302
+ process.env[inputKey("")] = raw;
168
303
  };
169
304
  /**
170
305
  * Boot: for each reserved provider param, read its address-scoped row through
@@ -229,7 +364,7 @@ function standardValidateSync(schema, value) {
229
364
  return result.value;
230
365
  }
231
366
  //#endregion
232
- //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-C1wSO3cx.mjs
367
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-Cxy18aoh.mjs
233
368
  /**
234
369
  * The service's own origin as a reserved provider param (ADR-0031): the ONE
235
370
  * brand and the ONE entry — shared by control.ts (which registers the
@@ -347,20 +482,24 @@ Object.freeze({
347
482
  });
348
483
  const reservedParams = { port: number({ default: 3e3 }) };
349
484
  /**
350
- * A Prisma Compute service — declarations only (deps + params + build + the
351
- * ports it exposes), no descriptor. `params` merges with the reserved
352
- * `ReservedParams` (`port`); a user param whose name collides with a reserved
353
- * one fails at authoring, the same way a colliding dependency name does.
485
+ * A Prisma Compute service — declarations only (deps + one input schema +
486
+ * build + the ports it exposes), no descriptor. The reserved `port` param
487
+ * rides its own channel (ADR-0042 leaves it untouched); a dependency named
488
+ * like it fails at authoring.
354
489
  *
355
490
  * · run(address, boot) — the process controller: deserialize the platform
356
491
  * environment (keyed off `address`, the extension's ONE env read) into a
357
- * typed Config, re-emit it under address-free process-local stash keys,
358
- * then call boot() to start the app's entry.
359
- * · load() / config() — called from inside the app's entry: read the stash;
360
- * load() hydrates + memoizes the deps, config() returns the typed params.
361
- * Separate accessors so a dep and a param never share a namespace (ADR-0021).
492
+ * typed Config, re-emit it (and the input document row) under address-free
493
+ * process-local stash keys, then call boot() to start the app's entry.
494
+ * · load() / input() — called from inside the app's entry: read the stash;
495
+ * load() hydrates + memoizes the deps, input() parses the input document,
496
+ * replaces each `$secret` pointer with a redacting box over the named
497
+ * platform var, validates with the declared schema, and memoizes (ADR-0042).
362
498
  * · origin() — this service's platform-assigned public origin, read from the
363
499
  * stash `run()` populates; memoized per process.
500
+ * · port() — this service's resolved reserved port (the value `run()` routes
501
+ * to and exports as PORT), read from that same stash via #processConfig();
502
+ * defaults to 3000 when the platform binds none.
364
503
  *
365
504
  * The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
366
505
  * the control-plane registry key `prisma-composer deploy` resolves through the
@@ -370,8 +509,7 @@ const reservedParams = { port: number({ default: 3e3 }) };
370
509
  var ComputeService = class {
371
510
  #resolved;
372
511
  #loadedDeps;
373
- #loadedParams;
374
- #loadedSecrets;
512
+ #loadedInput;
375
513
  #origin;
376
514
  constructor(node) {
377
515
  Object.assign(this, node);
@@ -384,7 +522,7 @@ var ComputeService = class {
384
522
  const config = deserialize(this, address);
385
523
  stash(this, config);
386
524
  stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
387
- stashSecrets(this, address);
525
+ stashInput(this, address);
388
526
  const port = config.service["port"];
389
527
  if (typeof port === "number") process.env["PORT"] = String(port);
390
528
  return boot();
@@ -393,13 +531,9 @@ var ComputeService = class {
393
531
  if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
394
532
  return this.#loadedDeps;
395
533
  }
396
- config() {
397
- if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
398
- return this.#loadedParams;
399
- }
400
- secrets() {
401
- if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
402
- return this.#loadedSecrets;
534
+ input() {
535
+ if (this.#loadedInput === void 0) this.#loadedInput = blindCast(readInput(this, ""));
536
+ return this.#loadedInput;
403
537
  }
404
538
  /** This service's platform-assigned public origin — read from the stash
405
539
  * run() populates and memoized per process. Throws if called before run()
@@ -408,26 +542,24 @@ var ComputeService = class {
408
542
  this.#origin ??= readOrigin();
409
543
  return this.#origin;
410
544
  }
545
+ /** This service's resolved reserved port — the value run() routes to and
546
+ * exports as PORT — read the same way load() reads the stash. Defaults to
547
+ * 3000 when the platform binds none. */
548
+ port() {
549
+ const port = this.#processConfig().service["port"];
550
+ if (typeof port !== "number") throw new Error(`service "${this.name}" resolved a non-numeric port — the reserved port param is number({ default: 3000 }), so a stashed config always carries a number here.`);
551
+ return port;
552
+ }
411
553
  };
412
554
  const compute = (def) => {
413
- const userParams = def.params ?? blindCast({});
414
- for (const reserved of Object.keys(reservedParams)) {
415
- if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
416
- if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
417
- }
418
- for (const name of Object.keys(userParams)) if (name.toUpperCase() === "ORIGIN") throw new Error(`compute(): param "${name}" collides with the framework-written origin row — rename the param.`);
419
- for (const name of Object.keys(def.secrets ?? {})) if (name.toUpperCase() === "ORIGIN") throw new Error(`compute(): secret "${name}" collides with the framework-written origin row — rename the secret.`);
420
- const params = blindCast({
421
- ...userParams,
422
- ...reservedParams
423
- });
555
+ for (const reserved of Object.keys(reservedParams)) if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
424
556
  const instance = new ComputeService(service({
425
557
  name: def.name,
426
558
  extension: "@prisma/composer-prisma-cloud",
427
559
  type: "compute",
428
560
  inputs: def.deps,
429
- params,
430
- ...def.secrets !== void 0 ? { secrets: def.secrets } : {},
561
+ params: reservedParams,
562
+ ...def.input !== void 0 ? { input: def.input } : {},
431
563
  build: def.build,
432
564
  ...def.expose !== void 0 ? { expose: def.expose } : {}
433
565
  }));
@@ -470,7 +602,24 @@ Object.freeze({
470
602
  satisfies: (required) => required.kind === "credentials"
471
603
  });
472
604
  //#endregion
473
- //#region ../../1-prisma-cloud/2-shared-modules/email/dist/email-service-DD1VF_64.mjs
605
+ //#region ../../0-framework/0-foundation/foundation/dist/arktype.mjs
606
+ /**
607
+ * ArkType spellings of the framework's schema leaves. Opt-in: the framework
608
+ * accepts any Standard Schema library (ADR-0042) and nothing outside this
609
+ * module imports arktype, so an app that uses Zod never loads it.
610
+ */
611
+ /**
612
+ * A schema leaf that accepts only a redacting `SecretString` box, so
613
+ * `input().<field>.expose()` type-checks and binding a plain literal there
614
+ * fails the deploy (ADR-0042).
615
+ *
616
+ * ```ts
617
+ * input: type({ signingKey: secretString() })
618
+ * ```
619
+ */
620
+ const secretString = () => type("unknown").narrow((value, ctx) => isSecretString(value) || ctx.mustBe("a SecretString box — bind this field to a secret"));
621
+ //#endregion
622
+ //#region ../../1-prisma-cloud/2-shared-modules/email/dist/email-service-CTqLUEQV.mjs
474
623
  /**
475
624
  * Identity helper that infers `T` with literal keys and each entry's own
476
625
  * data type — the `defineSchedule` pattern
@@ -586,25 +735,27 @@ function emailSender(templates) {
586
735
  }
587
736
  /**
588
737
  * The email compute service (spec §"Service definition"): a Postgres `db`
589
- * dependency, the `deliveryMode`/`deliveryUrl`/`from` params, the
590
- * `deliveryCredential` secret, and the two exposed ports (`send`, `outbox`).
591
- * Build/entry mechanics copied from storage's service file
592
- * (`storage/src/storage-service.ts`), not re-derived: `build.module` points
593
- * at this file's own built output so the deploy bootstrap can re-import it
594
- * as `main` and call `main.run(address, boot)`; `entry` resolves the
595
- * sibling entrypoint pass in the same dist directory.
738
+ * dependency, ONE input schema — `deliveryMode`/`deliveryUrl`/`from` plus the
739
+ * `deliveryCredential` secret leaf (a `SecretString`-typed field, ADR-0042)
740
+ * and the two exposed ports (`send`, `outbox`). The module (`email-module.ts`)
741
+ * binds the input at provision: forwarded boundary params/secret as leaves,
742
+ * `deliveryUrl` as a literal. Build/entry mechanics copied from storage's
743
+ * service file (`storage/src/storage-service.ts`), not re-derived:
744
+ * `build.module` points at this file's own built output so the deploy
745
+ * bootstrap can re-import it as `main` and call `main.run(address, boot)`;
746
+ * `entry` resolves the sibling entrypoint pass in the same dist directory.
596
747
  */
597
- const deliveryModeSchema = type("'resend'|'smtp'|'none'");
598
- function emailService(opts) {
748
+ const emailInputSchema = type({
749
+ deliveryMode: "'resend'|'smtp'|'none'",
750
+ deliveryUrl: "string",
751
+ from: "string",
752
+ deliveryCredential: secretString()
753
+ });
754
+ function emailService() {
599
755
  return compute({
600
756
  name: "email",
601
757
  deps: { db: postgres() },
602
- params: {
603
- deliveryMode: param(deliveryModeSchema),
604
- deliveryUrl: string({ default: opts?.deliveryUrl ?? "https://api.resend.com" }),
605
- from: string()
606
- },
607
- secrets: { deliveryCredential: secret() },
758
+ input: emailInputSchema,
608
759
  expose: {
609
760
  send: emailSendContract,
610
761
  outbox: emailOutboxContract
@@ -631,14 +782,15 @@ function email(opts) {
631
782
  }
632
783
  }, ({ params, secrets, provision }) => {
633
784
  const db = provision(postgres({ name: "db" }), { id: "db" });
634
- const service = provision(emailService(opts?.deliveryUrl !== void 0 ? { deliveryUrl: opts.deliveryUrl } : {}), {
785
+ const service = provision(emailService(), {
635
786
  id: "service",
636
787
  deps: { db },
637
- params: {
788
+ input: {
638
789
  deliveryMode: params.deliveryMode,
639
- from: params.from
640
- },
641
- secrets: { deliveryCredential: secrets.deliveryCredential }
790
+ deliveryUrl: opts?.deliveryUrl ?? "https://api.resend.com",
791
+ from: params.from,
792
+ deliveryCredential: secrets.deliveryCredential
793
+ }
642
794
  });
643
795
  return {
644
796
  send: service.send,