@prisma/composer-prisma-cloud 0.3.0-dev.8 → 0.3.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 (66) hide show
  1. package/dist/compute-main.mjs +4 -20
  2. package/dist/compute-main.mjs.map +1 -1
  3. package/dist/control.d.mts +1 -1
  4. package/dist/control.mjs +17 -28
  5. package/dist/control.mjs.map +1 -1
  6. package/dist/cron/index.d.mts +26 -33
  7. package/dist/cron/index.d.mts.map +1 -1
  8. package/dist/cron/index.mjs +77 -202
  9. package/dist/cron/index.mjs.map +1 -1
  10. package/dist/cron/scheduler-entrypoint.mjs +114 -133
  11. package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
  12. package/dist/cron/scheduler-service.mjs +76 -200
  13. package/dist/cron/scheduler-service.mjs.map +1 -1
  14. package/dist/email/email-entrypoint.mjs +126 -162
  15. package/dist/email/email-entrypoint.mjs.map +1 -1
  16. package/dist/email/email-service.mjs +79 -230
  17. package/dist/email/email-service.mjs.map +1 -1
  18. package/dist/email/index.d.mts +29 -33
  19. package/dist/email/index.d.mts.map +1 -1
  20. package/dist/email/index.mjs +84 -236
  21. package/dist/email/index.mjs.map +1 -1
  22. package/dist/email/testing.mjs +89 -112
  23. package/dist/email/testing.mjs.map +1 -1
  24. package/dist/index.d.mts +43 -51
  25. package/dist/index.d.mts.map +1 -1
  26. package/dist/index.mjs +51 -47
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/local-target.mjs +1 -1
  29. package/dist/local-target.mjs.map +1 -1
  30. package/dist/{secret-BVGxqHxY-DYDfiULl.mjs → param-BTzY0ne5-CW6ojZ3E.mjs} +4 -45
  31. package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +1 -0
  32. package/dist/{preflight-names-CpJUd9ZA-BCU-W3cT.mjs → preflight-names-BPL-qsZF-BfoRgbgb.mjs} +14 -30
  33. package/dist/{preflight-names-CpJUd9ZA-BCU-W3cT.mjs.map → preflight-names-BPL-qsZF-BfoRgbgb.mjs.map} +1 -1
  34. package/dist/{provisioned-edges-Cxy18aoh-CUnaY96r.mjs → provisioned-edges-C1wSO3cx-YC5C19f9.mjs} +3 -3
  35. package/dist/{provisioned-edges-Cxy18aoh-CUnaY96r.mjs.map → provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map} +1 -1
  36. package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +47 -0
  37. package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +1 -0
  38. package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs +251 -0
  39. package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +1 -0
  40. package/dist/{serializer-BD_6nkr4-DWn5NNTC.d.mts → serializer-Cx5slrV4-xJfH6EWS.d.mts} +2 -2
  41. package/dist/serializer-Cx5slrV4-xJfH6EWS.d.mts.map +1 -0
  42. package/dist/storage/index.d.mts +26 -31
  43. package/dist/storage/index.d.mts.map +1 -1
  44. package/dist/storage/index.mjs +89 -215
  45. package/dist/storage/index.mjs.map +1 -1
  46. package/dist/storage/storage-entrypoint.mjs +122 -147
  47. package/dist/storage/storage-entrypoint.mjs.map +1 -1
  48. package/dist/storage/storage-service.mjs +87 -212
  49. package/dist/storage/storage-service.mjs.map +1 -1
  50. package/dist/streams/index.d.mts +22 -29
  51. package/dist/streams/index.d.mts.map +1 -1
  52. package/dist/streams/index.mjs +88 -213
  53. package/dist/streams/index.mjs.map +1 -1
  54. package/dist/streams/streams-entrypoint.mjs +118 -139
  55. package/dist/streams/streams-entrypoint.mjs.map +1 -1
  56. package/dist/streams/streams-service.mjs +87 -212
  57. package/dist/streams/streams-service.mjs.map +1 -1
  58. package/dist/testing.d.mts +5 -19
  59. package/dist/testing.d.mts.map +1 -1
  60. package/dist/testing.mjs +3 -11
  61. package/dist/testing.mjs.map +1 -1
  62. package/package.json +18 -18
  63. package/dist/secret-BVGxqHxY-DYDfiULl.mjs.map +0 -1
  64. package/dist/serializer-BD_6nkr4-DWn5NNTC.d.mts.map +0 -1
  65. package/dist/serializer-sVE4UAmg-CikRngbR.mjs +0 -475
  66. package/dist/serializer-sVE4UAmg-CikRngbR.mjs.map +0 -1
@@ -1,101 +1,10 @@
1
- import { dependency, hydrateSync, module, number, paramNeed, resource, secret, service, string } from "@prisma/composer";
1
+ import { dependency, hydrateSecrets, hydrateSync, module, number, param, 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 ../../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
7
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-CJiOhF2d.mjs
99
8
  /**
100
9
  * Walks a node's own params, then each dependency input's connection params —
101
10
  * the same enumeration order `configOf` uses, but carrying the raw
@@ -185,7 +94,7 @@ function coerceEnvSourcedParam(raw, d, key) {
185
94
  /**
186
95
  * Boot: read each declared param from env by its key, reverse the param's own
187
96
  * serialization (missing/invalid fails loudly), assemble the typed Config.
188
- * The input document rides its own channel (readInput), not this one.
97
+ * Secrets ride a separate channel (deserializeSecrets), not this one.
189
98
  */
190
99
  const deserialize = (node, address) => {
191
100
  const service = {};
@@ -222,84 +131,40 @@ const stash = (node, config) => {
222
131
  process.env[configKey("", d)] = encode(d.owner, value);
223
132
  }
224
133
  };
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, {
134
+ /** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
135
+ const secretKey = (address, slot) => configKey(address, {
229
136
  owner: "service",
230
- name: INPUT_KEY_NAME
137
+ name: slot
231
138
  });
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
- }
244
139
  /**
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).
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.
251
144
  */
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).`);
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;
264
154
  }
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
- }
155
+ return values;
156
+ };
292
157
  /**
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.
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.
297
161
  */
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;
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
+ }
303
168
  };
304
169
  /**
305
170
  * Boot: for each reserved provider param, read its address-scoped row through
@@ -364,7 +229,7 @@ function standardValidateSync(schema, value) {
364
229
  return result.value;
365
230
  }
366
231
  //#endregion
367
- //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-Cxy18aoh.mjs
232
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-C1wSO3cx.mjs
368
233
  /**
369
234
  * The service's own origin as a reserved provider param (ADR-0031): the ONE
370
235
  * brand and the ONE entry — shared by control.ts (which registers the
@@ -482,24 +347,20 @@ Object.freeze({
482
347
  });
483
348
  const reservedParams = { port: number({ default: 3e3 }) };
484
349
  /**
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.
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.
489
354
  *
490
355
  * · run(address, boot) — the process controller: deserialize the platform
491
356
  * environment (keyed off `address`, the extension's ONE env read) into a
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).
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).
498
362
  * · origin() — this service's platform-assigned public origin, read from the
499
363
  * 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.
503
364
  *
504
365
  * The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
505
366
  * the control-plane registry key `prisma-composer deploy` resolves through the
@@ -509,7 +370,8 @@ const reservedParams = { port: number({ default: 3e3 }) };
509
370
  var ComputeService = class {
510
371
  #resolved;
511
372
  #loadedDeps;
512
- #loadedInput;
373
+ #loadedParams;
374
+ #loadedSecrets;
513
375
  #origin;
514
376
  constructor(node) {
515
377
  Object.assign(this, node);
@@ -522,7 +384,7 @@ var ComputeService = class {
522
384
  const config = deserialize(this, address);
523
385
  stash(this, config);
524
386
  stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
525
- stashInput(this, address);
387
+ stashSecrets(this, address);
526
388
  const port = config.service["port"];
527
389
  if (typeof port === "number") process.env["PORT"] = String(port);
528
390
  return boot();
@@ -531,9 +393,13 @@ var ComputeService = class {
531
393
  if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
532
394
  return this.#loadedDeps;
533
395
  }
534
- input() {
535
- if (this.#loadedInput === void 0) this.#loadedInput = blindCast(readInput(this, ""));
536
- return this.#loadedInput;
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;
537
403
  }
538
404
  /** This service's platform-assigned public origin — read from the stash
539
405
  * run() populates and memoized per process. Throws if called before run()
@@ -542,24 +408,26 @@ var ComputeService = class {
542
408
  this.#origin ??= readOrigin();
543
409
  return this.#origin;
544
410
  }
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
- }
553
411
  };
554
412
  const compute = (def) => {
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.`);
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
+ });
556
424
  const instance = new ComputeService(service({
557
425
  name: def.name,
558
426
  extension: "@prisma/composer-prisma-cloud",
559
427
  type: "compute",
560
428
  inputs: def.deps,
561
- params: reservedParams,
562
- ...def.input !== void 0 ? { input: def.input } : {},
429
+ params,
430
+ ...def.secrets !== void 0 ? { secrets: def.secrets } : {},
563
431
  build: def.build,
564
432
  ...def.expose !== void 0 ? { expose: def.expose } : {}
565
433
  }));
@@ -602,24 +470,7 @@ Object.freeze({
602
470
  satisfies: (required) => required.kind === "credentials"
603
471
  });
604
472
  //#endregion
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
473
+ //#region ../../1-prisma-cloud/2-shared-modules/email/dist/email-service-DD1VF_64.mjs
623
474
  /**
624
475
  * Identity helper that infers `T` with literal keys and each entry's own
625
476
  * data type — the `defineSchedule` pattern
@@ -735,27 +586,25 @@ function emailSender(templates) {
735
586
  }
736
587
  /**
737
588
  * The email compute service (spec §"Service definition"): a Postgres `db`
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.
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.
747
596
  */
748
- const emailInputSchema = type({
749
- deliveryMode: "'resend'|'smtp'|'none'",
750
- deliveryUrl: "string",
751
- from: "string",
752
- deliveryCredential: secretString()
753
- });
754
- function emailService() {
597
+ const deliveryModeSchema = type("'resend'|'smtp'|'none'");
598
+ function emailService(opts) {
755
599
  return compute({
756
600
  name: "email",
757
601
  deps: { db: postgres() },
758
- input: emailInputSchema,
602
+ params: {
603
+ deliveryMode: param(deliveryModeSchema),
604
+ deliveryUrl: string({ default: opts?.deliveryUrl ?? "https://api.resend.com" }),
605
+ from: string()
606
+ },
607
+ secrets: { deliveryCredential: secret() },
759
608
  expose: {
760
609
  send: emailSendContract,
761
610
  outbox: emailOutboxContract
@@ -782,15 +631,14 @@ function email(opts) {
782
631
  }
783
632
  }, ({ params, secrets, provision }) => {
784
633
  const db = provision(postgres({ name: "db" }), { id: "db" });
785
- const service = provision(emailService(), {
634
+ const service = provision(emailService(opts?.deliveryUrl !== void 0 ? { deliveryUrl: opts.deliveryUrl } : {}), {
786
635
  id: "service",
787
636
  deps: { db },
788
- input: {
637
+ params: {
789
638
  deliveryMode: params.deliveryMode,
790
- deliveryUrl: opts?.deliveryUrl ?? "https://api.resend.com",
791
- from: params.from,
792
- deliveryCredential: secrets.deliveryCredential
793
- }
639
+ from: params.from
640
+ },
641
+ secrets: { deliveryCredential: secrets.deliveryCredential }
794
642
  });
795
643
  return {
796
644
  send: service.send,