@prisma/composer-prisma-cloud 0.3.0-dev.6 → 0.3.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +17 -17
  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,34 +1,38 @@
1
- import { BuildAdapter, Deps, Expose, HydratedDeps, ModuleNode, NODE, Params, RunnableServiceNode, SecretValues, Secrets, ServiceNode, Values } from "@prisma/composer";
2
- import "@standard-schema/spec";
1
+ import { BuildAdapter, Deps, Expose, HydratedDeps, InputValueOf, ModuleNode, NODE, Params, RunnableServiceNode, ServiceNode } from "@prisma/composer";
2
+ import { StandardSchemaV1 } from "@standard-schema/spec";
3
3
  //#region ../../1-prisma-cloud/1-extensions/target/dist/index.d.mts
4
4
  //#endregion
5
5
  //#region src/compute.d.ts
6
6
  declare const reservedParams: {
7
- readonly port: import("@prisma/composer").ConfigParam<import("@standard-schema/spec").StandardSchemaV1<number, number>>;
7
+ readonly port: import("@prisma/composer").ConfigParam<StandardSchemaV1<number, number>>;
8
8
  };
9
9
  type ReservedParams = typeof reservedParams;
10
10
  /**
11
- * A Prisma Compute service — declarations only (deps + params + build + the
12
- * ports it exposes), no descriptor. `params` merges with the reserved
13
- * `ReservedParams` (`port`); a user param whose name collides with a reserved
14
- * one fails at authoring, the same way a colliding dependency name does.
11
+ * A Prisma Compute service — declarations only (deps + one input schema +
12
+ * build + the ports it exposes), no descriptor. The reserved `port` param
13
+ * rides its own channel (ADR-0042 leaves it untouched); a dependency named
14
+ * like it fails at authoring.
15
15
  *
16
16
  * · run(address, boot) — the process controller: deserialize the platform
17
17
  * environment (keyed off `address`, the extension's ONE env read) into a
18
- * typed Config, re-emit it under address-free process-local stash keys,
19
- * then call boot() to start the app's entry.
20
- * · load() / config() — called from inside the app's entry: read the stash;
21
- * load() hydrates + memoizes the deps, config() returns the typed params.
22
- * Separate accessors so a dep and a param never share a namespace (ADR-0021).
18
+ * typed Config, re-emit it (and the input document row) under address-free
19
+ * process-local stash keys, then call boot() to start the app's entry.
20
+ * · load() / input() — called from inside the app's entry: read the stash;
21
+ * load() hydrates + memoizes the deps, input() parses the input document,
22
+ * replaces each `$secret` pointer with a redacting box over the named
23
+ * platform var, validates with the declared schema, and memoizes (ADR-0042).
23
24
  * · origin() — this service's platform-assigned public origin, read from the
24
25
  * stash `run()` populates; memoized per process.
26
+ * · port() — this service's resolved reserved port (the value `run()` routes
27
+ * to and exports as PORT), read from that same stash via #processConfig();
28
+ * defaults to 3000 when the platform binds none.
25
29
  *
26
30
  * The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
27
31
  * the control-plane registry key `prisma-composer deploy` resolves through the
28
32
  * app's `prisma-composer.config.ts` (ADR-0017). This module loads nothing at
29
33
  * deploy time; nodes are pure data until run() or load() is called.
30
34
  */
31
- declare class ComputeService<D extends Deps, P extends Params, E extends Expose, S extends Secrets> implements RunnableServiceNode<D, P & ReservedParams, E, S> {
35
+ declare class ComputeService<D extends Deps, I extends StandardSchemaV1 | undefined, E extends Expose> implements RunnableServiceNode<D, ReservedParams, E, I> {
32
36
  #private;
33
37
  readonly [NODE]: true;
34
38
  readonly kind: 'service';
@@ -36,19 +40,22 @@ declare class ComputeService<D extends Deps, P extends Params, E extends Expose,
36
40
  readonly extension: string;
37
41
  readonly type: string;
38
42
  readonly inputs: D;
39
- readonly params: P & ReservedParams;
40
- readonly secretSlots: S;
43
+ readonly params: ReservedParams;
44
+ readonly inputSchema: I;
41
45
  readonly build: BuildAdapter;
42
46
  readonly expose: E | undefined;
43
- constructor(node: ServiceNode<D, P & ReservedParams, E, S>);
47
+ constructor(node: ServiceNode<D, ReservedParams, E, I>);
44
48
  run(address: string, boot: () => Promise<unknown>): Promise<unknown>;
45
49
  load(): HydratedDeps<D>;
46
- config(): Values<P & ReservedParams>;
47
- secrets(): SecretValues<S>;
50
+ input(): InputValueOf<I>;
48
51
  /** This service's platform-assigned public origin — read from the stash
49
52
  * run() populates and memoized per process. Throws if called before run()
50
53
  * has stashed it (readOrigin's pinned message). */
51
54
  origin(): string;
55
+ /** This service's resolved reserved port — the value run() routes to and
56
+ * exports as PORT — read the same way load() reads the stash. Defaults to
57
+ * 3000 when the platform binds none. */
58
+ port(): number;
52
59
  }
53
60
  //#endregion
54
61
  //#region ../../1-prisma-cloud/2-shared-modules/cron/dist/index.d.mts
@@ -100,11 +107,11 @@ declare function cron<RD extends Deps, RP extends Params, Ids extends string>(op
100
107
  //#endregion
101
108
  //#region src/scheduler.d.ts
102
109
  /**
103
- * The always-on scheduler service. `schedule` sets only the `jobs` param's
104
- * default the value the deploy serializes into config; the scheduler
105
- * itself is job-agnostic.
110
+ * The always-on scheduler service. Job-agnostic: the schedule arrives as the
111
+ * `jobs` key of the input binding `cron()` supplies at provision, and the
112
+ * entrypoint reads it back through `input()`.
106
113
  */
107
- declare function cronScheduler<Ids extends string>(schedule: Schedule<Ids>): ComputeService<{
114
+ declare function cronScheduler(): ComputeService<{
108
115
  trigger: import("@prisma/composer").DependencyEnd<{
109
116
  trigger: (input: {
110
117
  jobId: string;
@@ -118,12 +125,12 @@ declare function cronScheduler<Ids extends string>(schedule: Schedule<Ids>): Com
118
125
  ok: boolean;
119
126
  }>;
120
127
  }>>;
121
- }, {
122
- jobs: import("@prisma/composer").ConfigParam<import("arktype/internal/variants/array.ts").ArrayType<{
128
+ }, import("arktype/internal/variants/object.ts").ObjectType<{
129
+ jobs: {
123
130
  jobId: string;
124
131
  every: string;
125
- }[], {}>>;
126
- }, Record<never, never>, Record<never, never>>;
132
+ }[];
133
+ }, {}>, Record<never, never>>;
127
134
  /**
128
135
  * Fires `call(jobId)` on each job's `every` interval. A rejected `call` is
129
136
  * logged, never thrown — a missed tick is healed by an idempotent target, not
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../1-prisma-cloud/1-extensions/target/dist/index.d.mts","../../../../1-prisma-cloud/2-shared-modules/cron/dist/index.d.mts"],"mappings":";;;;;cA0Cc;WACH,+BAA+B,4CAA4C;;KAEjF,wBAAwB;;;;;;;;;;;;;;;;;;;;;;cAsBf,eAAe,UAAU,MAAM,UAAU,QAAQ,UAAU,QAAQ,UAAU,oBAAoB,oBAAoB,GAAG,IAAI,gBAAgB,GAAG;;YAEjJ;WACD;WACA;WACA;WACA;WACA,QAAQ;WACR,QAAQ,IAAI;WACZ,aAAa;WACb,OAAO;WACP,QAAQ;EACjB,YAAY,MAAM,YAAY,GAAG,IAAI,gBAAgB,GAAG;EACxD,IAAI,iBAAiB,YAAY,mBAAmB;EACpD,QAAQ,aAAa;EACrB,UAAU,OAAO,IAAI;EACrB,WAAW,aAAa;;;;EAIxB;;;;;cCrFY,0CAA0C;EACtD,UAAU;IACR;QACI;IACJ;;;KAGC,yBAAyB;;;;;;;;UAQpB,SAAS;WACR,MAAM;aACJ,OAAO;aACP;;;;;;;;iBAQI,qBAAqB,UAAU,wBAAwB,MAAM,IAAI,eAAe;;;;;;;;;;;iBAWhF,KAAK,WAAW,MAAM,WAAW,QAAQ,oBAAoB;EAC5E,UAAU,SAAS;EACnB,QAAQ,YAAY,IAAI;IACtB,SAAS;;EAEX;IACE,WAAW,IAAI;;;;;;;;iBAQF,cAAc,oBAAoB,UAAU,SAAS,OAmB7C;EAlBvB,kCAAkC;IAChC,UAAU;MACR;UACI;MACJ;;8BAEwB;IAC1B,UAAU;MACR;UACI;MACJ;;;;EAIJ,+BAA+B,yDAAyD;IACtF;IACA;;GAED,sBAAsB;;;;;;;iBAOR,aAAa;EAC5B,MAAM;IACJ;IACA;;EAEF,OAAO,kBAAkB;EACzB,YAAY,gBAAgB;;;;KAIzB,gBAAgB,MAAM,MAAM,MAAM;iBACtB,cAAc,UAAU,MAAM,UAAU,QAAQ,oBAAoB,SAAS,oBAAoB,GAAG;EACnH,SAAS;IACP,WAAW,SAAS,MAAM,aAAa,MAAM,MAAM,gBAAgB,aAAa,UAAU,KAAK,YAAY,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../1-prisma-cloud/1-extensions/target/dist/index.d.mts","../../../../1-prisma-cloud/2-shared-modules/cron/dist/index.d.mts"],"mappings":";;;;;cA2Cc;WACH,+BAA+B,YAAY;;KAEjD,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;cA0Bf,eAAe,UAAU,MAAM,UAAU,8BAA8B,UAAU,mBAAmB,oBAAoB,GAAG,gBAAgB,GAAG;;YAEhJ;WACD;WACA;WACA;WACA;WACA,QAAQ;WACR,QAAQ;WACR,aAAa;WACb,OAAO;WACP,QAAQ;EACjB,YAAY,MAAM,YAAY,GAAG,gBAAgB,GAAG;EACpD,IAAI,iBAAiB,YAAY,mBAAmB;EACpD,QAAQ,aAAa;EACrB,SAAS,aAAa;;;;EAItB;;;;EAIA;;;;;cC7FY,0CAA0C;EACtD,UAAU;IACR;QACI;IACJ;;;KAGC,yBAAyB;;;;;;;;UAQpB,SAAS;WACR,MAAM;aACJ,OAAO;aACP;;;;;;;;iBAQI,qBAAqB,UAAU,wBAAwB,MAAM,IAAI,eAAe;;;;;;;;;;;iBAWhF,KAAK,WAAW,MAAM,WAAW,QAAQ,oBAAoB;EAC5E,UAAU,SAAS;EACnB,QAAQ,YAAY,IAAI;IACtB,SAAS;;EAEX;IACE,WAAW,IAAI;;;;;;;;iBAQF,iBAmBT;EAlBN,kCAAkC;IAChC,UAAU;MACR;UACI;MACJ;;8BAEwB;IAC1B,UAAU;MACR;UACI;MACJ;;;iDAG2C;EAC/C;IACE;IACA;;QAEI;;;;;;;iBAOS,aAAa;EAC5B,MAAM;IACJ;IACA;;EAEF,OAAO,kBAAkB;EACzB,YAAY,gBAAgB;;;;KAIzB,gBAAgB,MAAM,MAAM,MAAM;iBACtB,cAAc,UAAU,MAAM,UAAU,QAAQ,oBAAoB,SAAS,oBAAoB,GAAG;EACnH,SAAS;IACP,WAAW,SAAS,MAAM,aAAa,MAAM,MAAM,gBAAgB,aAAa,UAAU,KAAK,YAAY,QAAQ"}
@@ -1,9 +1,92 @@
1
1
  import { RPC_PEER_KEY, contract, rpc, serve } from "@prisma/composer/service-rpc";
2
2
  import { type } from "arktype";
3
- import { hydrateSecrets, hydrateSync, module, number, param, service } from "@prisma/composer";
4
3
  import node from "@prisma/composer/node";
4
+ import { hydrateSync, module, number, service } from "@prisma/composer";
5
5
  import { blindCast } from "@prisma/composer/casts";
6
- //#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-CJiOhF2d.mjs
6
+ //#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
7
+ /**
8
+ * **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
9
+ *
10
+ * Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes
11
+ * unnecessary**: tighten an input type, add a runtime check that narrows via a type
12
+ * predicate, restructure a generic so the compiler can see the relationship you're
13
+ * asserting, or use {@link castAs} when the value already satisfies the target type.
14
+ * Only when no rewrite is feasible does `blindCast` become the right answer — and at
15
+ * that point, the `Reason` literal you supply must articulate the compromise in
16
+ * language a reviewer can evaluate.
17
+ *
18
+ * The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,
19
+ * that is not a signal to soften the reason; it is a signal to go back and solve the
20
+ * underlying type-system problem properly. An unconvincing justification is rework,
21
+ * not a free pass.
22
+ *
23
+ * `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses
24
+ * the compiler's checks (the input type is `unknown`, the output type is whatever the
25
+ * caller asks for), but it forces the unsafety to be named at the call site instead of
26
+ * smuggled in via a bare `as`. The `Reason` type parameter exists only at compile
27
+ * time — it is not present in the emitted JavaScript — but it is grep-able and
28
+ * visible to future readers.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const stringValue = blindCast<
33
+ * string,
34
+ * "JSON.parse returns `unknown`; this field is documented to be a string in the API contract"
35
+ * >(parsed[key]);
36
+ * ```
37
+ *
38
+ * @typeParam TargetType - The type the caller is asserting the input has.
39
+ * @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.
40
+ * Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.
41
+ */
42
+ function blindCast$1(input) {
43
+ return input;
44
+ }
45
+ //#endregion
46
+ //#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
47
+ /**
48
+ * A value wrapper that redacts everywhere except the one explicit reader,
49
+ * `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
50
+ * sink must remember to check: `String(box)`, template interpolation,
51
+ * `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
52
+ * a secret can't leak through an accidental log or serialization.
53
+ *
54
+ * Every box carries a brand property keyed by the registered symbol
55
+ * `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
56
+ * symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
57
+ * public shape still matches the platform's own `secrecy` type
58
+ * (pdp-control-plane).
59
+ */
60
+ const REDACTED = "[REDACTED]";
61
+ const SECRET_BOX = blindCast$1(Symbol.for("prisma:secret-box"));
62
+ var SecretBox = class {
63
+ [SECRET_BOX] = true;
64
+ #value;
65
+ constructor(value) {
66
+ this.#value = value;
67
+ }
68
+ /** The sole explicit door to the wrapped value. */
69
+ expose() {
70
+ return this.#value;
71
+ }
72
+ toString() {
73
+ return REDACTED;
74
+ }
75
+ toJSON() {
76
+ return REDACTED;
77
+ }
78
+ valueOf() {
79
+ return REDACTED;
80
+ }
81
+ [Symbol.toPrimitive]() {
82
+ return REDACTED;
83
+ }
84
+ [Symbol.for("nodejs.util.inspect.custom")]() {
85
+ return REDACTED;
86
+ }
87
+ };
88
+ //#endregion
89
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/serializer-sVE4UAmg.mjs
7
90
  /**
8
91
  * Walks a node's own params, then each dependency input's connection params —
9
92
  * the same enumeration order `configOf` uses, but carrying the raw
@@ -93,7 +176,7 @@ function coerceEnvSourcedParam(raw, d, key) {
93
176
  /**
94
177
  * Boot: read each declared param from env by its key, reverse the param's own
95
178
  * serialization (missing/invalid fails loudly), assemble the typed Config.
96
- * Secrets ride a separate channel (deserializeSecrets), not this one.
179
+ * The input document rides its own channel (readInput), not this one.
97
180
  */
98
181
  const deserialize = (node, address) => {
99
182
  const service = {};
@@ -130,40 +213,84 @@ const stash = (node, config) => {
130
213
  process.env[configKey("", d)] = encode(d.owner, value);
131
214
  }
132
215
  };
133
- /** The pointer-row key for a secret slot: COMPOSER_<addr>_<slot> (secrets are service-level). */
134
- const secretKey = (address, slot) => configKey(address, {
216
+ /** The input document's own row name; its full key is COMPOSER_<addr>_INPUT. */
217
+ const INPUT_KEY_NAME = "INPUT";
218
+ /** The input document row's key for a service address. */
219
+ const inputKey = (address) => configKey(address, {
135
220
  owner: "service",
136
- name: slot
221
+ name: INPUT_KEY_NAME
137
222
  });
223
+ const SECRET_MARKER = "$secret";
224
+ const ESCAPED_KEY = /^\$\$+secret$/;
225
+ /** True for the framework's secret pointer: `{ "$secret": "<PLATFORM_VAR>" }` and nothing else. */
226
+ function isSecretPointer(value) {
227
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && SECRET_MARKER in value && typeof value[SECRET_MARKER] === "string";
228
+ }
229
+ /** A plain data object (not an array, not a class instance) — the only object shape a binding/document may nest. */
230
+ function isPlainObject(value) {
231
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
232
+ const proto = Object.getPrototypeOf(value);
233
+ return proto === Object.prototype || proto === null;
234
+ }
138
235
  /**
139
- * Boot: resolve every secret slot to its value by double-lookup read the
140
- * pointer key (the platform NAME), then read that platform var. A missing
141
- * pointer or a missing/empty platform value is a loud failure naming both keys.
142
- * Returns a plain Record for core's `hydrateSecrets` to box.
236
+ * Boot: read the one input document row (address-free after run()'s
237
+ * re-stash), swap each `$secret` pointer for a redacting box over the named
238
+ * platform var, unescape reserved keys, validate with the service's own
239
+ * schema, and return the typed object. A missing row is a loud failure naming
240
+ * the env var — a deployed environment always writes it; a local harness must
241
+ * supply it (set the row to the serialized input document).
143
242
  */
144
- const deserializeSecrets = (node, address) => {
145
- const values = {};
146
- for (const slot of Object.keys(node.secretSlots)) {
147
- const key = secretKey(address, slot);
148
- const name = process.env[key];
149
- if (name === void 0 || name === "") throw new Error(`missing secret pointer for slot "${slot}" (env ${key}) — the deploy did not write it.`);
150
- const value = process.env[name];
151
- if (value === void 0 || value === "") throw new Error(`secret "${slot}" is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
152
- values[slot] = value;
243
+ function readInput(node, address) {
244
+ const schema = node.inputSchema;
245
+ 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).`);
246
+ const key = inputKey(address);
247
+ const raw = process.env[key];
248
+ 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).`);
249
+ let parsed;
250
+ try {
251
+ parsed = JSON.parse(raw);
252
+ } catch (cause) {
253
+ const message = cause instanceof Error ? cause.message : String(cause);
254
+ 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).`);
153
255
  }
154
- return values;
155
- };
256
+ const hydrated = hydrateInputDocument(parsed, key);
257
+ try {
258
+ return standardValidateSync(schema, hydrated);
259
+ } catch (cause) {
260
+ const message = cause instanceof Error ? cause.message : String(cause);
261
+ throw new Error(`invalid input document (env ${key}): ${message}`);
262
+ }
263
+ }
264
+ /** Reverses the document encoding: `$secret` pointers become redacting boxes over the named platform vars; escaped reserved keys drop one "$". */
265
+ function hydrateInputDocument(value, key) {
266
+ if (isSecretPointer(value)) {
267
+ const name = value[SECRET_MARKER];
268
+ const secret = process.env[name];
269
+ if (secret === void 0 || secret === "") throw new Error(`secret input is not provisioned (env ${key} → ${name}): the platform var "${name}" is unset or empty.`);
270
+ return new SecretBox(secret);
271
+ }
272
+ if (Array.isArray(value)) return value.map((member) => hydrateInputDocument(member, key));
273
+ if (isPlainObject(value)) {
274
+ const out = {};
275
+ for (const [k, member] of Object.entries(value)) {
276
+ const read = ESCAPED_KEY.test(k) ? k.slice(1) : k;
277
+ out[read] = hydrateInputDocument(member, key);
278
+ }
279
+ return out;
280
+ }
281
+ return value;
282
+ }
156
283
  /**
157
- * run()'s setup step for secrets: re-emit each slot's pointer NAME under its
158
- * address-free key, so the address-free `deserializeSecrets` double-looks-up
159
- * identically. Never the value — the value stays only in the platform var.
284
+ * run()'s setup step for the input document: re-emit the row under its
285
+ * address-free key, so the address-free `readInput` reads identically. The
286
+ * document carries pointers, never values — the values stay only in their
287
+ * platform vars.
160
288
  */
161
- const stashSecrets = (node, address) => {
162
- for (const slot of Object.keys(node.secretSlots)) {
163
- const name = process.env[secretKey(address, slot)];
164
- if (name === void 0) continue;
165
- process.env[secretKey("", slot)] = name;
166
- }
289
+ const stashInput = (node, address) => {
290
+ if (node.inputSchema === void 0) return;
291
+ const raw = process.env[inputKey(address)];
292
+ if (raw === void 0) return;
293
+ process.env[inputKey("")] = raw;
167
294
  };
168
295
  /**
169
296
  * Boot: for each reserved provider param, read its address-scoped row through
@@ -228,7 +355,7 @@ function standardValidateSync(schema, value) {
228
355
  return result.value;
229
356
  }
230
357
  //#endregion
231
- //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-C1wSO3cx.mjs
358
+ //#region ../../1-prisma-cloud/1-extensions/target/dist/provisioned-edges-Cxy18aoh.mjs
232
359
  /**
233
360
  * The service's own origin as a reserved provider param (ADR-0031): the ONE
234
361
  * brand and the ONE entry — shared by control.ts (which registers the
@@ -346,20 +473,24 @@ Object.freeze({
346
473
  });
347
474
  const reservedParams = { port: number({ default: 3e3 }) };
348
475
  /**
349
- * A Prisma Compute service — declarations only (deps + params + build + the
350
- * ports it exposes), no descriptor. `params` merges with the reserved
351
- * `ReservedParams` (`port`); a user param whose name collides with a reserved
352
- * one fails at authoring, the same way a colliding dependency name does.
476
+ * A Prisma Compute service — declarations only (deps + one input schema +
477
+ * build + the ports it exposes), no descriptor. The reserved `port` param
478
+ * rides its own channel (ADR-0042 leaves it untouched); a dependency named
479
+ * like it fails at authoring.
353
480
  *
354
481
  * · run(address, boot) — the process controller: deserialize the platform
355
482
  * environment (keyed off `address`, the extension's ONE env read) into a
356
- * typed Config, re-emit it under address-free process-local stash keys,
357
- * then call boot() to start the app's entry.
358
- * · load() / config() — called from inside the app's entry: read the stash;
359
- * load() hydrates + memoizes the deps, config() returns the typed params.
360
- * Separate accessors so a dep and a param never share a namespace (ADR-0021).
483
+ * typed Config, re-emit it (and the input document row) under address-free
484
+ * process-local stash keys, then call boot() to start the app's entry.
485
+ * · load() / input() — called from inside the app's entry: read the stash;
486
+ * load() hydrates + memoizes the deps, input() parses the input document,
487
+ * replaces each `$secret` pointer with a redacting box over the named
488
+ * platform var, validates with the declared schema, and memoizes (ADR-0042).
361
489
  * · origin() — this service's platform-assigned public origin, read from the
362
490
  * stash `run()` populates; memoized per process.
491
+ * · port() — this service's resolved reserved port (the value `run()` routes
492
+ * to and exports as PORT), read from that same stash via #processConfig();
493
+ * defaults to 3000 when the platform binds none.
363
494
  *
364
495
  * The underlying node carries `extension: '@prisma/composer-prisma-cloud'` —
365
496
  * the control-plane registry key `prisma-composer deploy` resolves through the
@@ -369,8 +500,7 @@ const reservedParams = { port: number({ default: 3e3 }) };
369
500
  var ComputeService = class {
370
501
  #resolved;
371
502
  #loadedDeps;
372
- #loadedParams;
373
- #loadedSecrets;
503
+ #loadedInput;
374
504
  #origin;
375
505
  constructor(node) {
376
506
  Object.assign(this, node);
@@ -383,7 +513,7 @@ var ComputeService = class {
383
513
  const config = deserialize(this, address);
384
514
  stash(this, config);
385
515
  stashProviderParams(RESERVED_PROVIDER_PARAMS, address);
386
- stashSecrets(this, address);
516
+ stashInput(this, address);
387
517
  const port = config.service["port"];
388
518
  if (typeof port === "number") process.env["PORT"] = String(port);
389
519
  return boot();
@@ -392,13 +522,9 @@ var ComputeService = class {
392
522
  if (this.#loadedDeps === void 0) this.#loadedDeps = blindCast(hydrateSync(this, this.#processConfig()));
393
523
  return this.#loadedDeps;
394
524
  }
395
- config() {
396
- if (this.#loadedParams === void 0) this.#loadedParams = blindCast(this.#processConfig().service);
397
- return this.#loadedParams;
398
- }
399
- secrets() {
400
- if (this.#loadedSecrets === void 0) this.#loadedSecrets = blindCast(hydrateSecrets(this, deserializeSecrets(this, "")));
401
- return this.#loadedSecrets;
525
+ input() {
526
+ if (this.#loadedInput === void 0) this.#loadedInput = blindCast(readInput(this, ""));
527
+ return this.#loadedInput;
402
528
  }
403
529
  /** This service's platform-assigned public origin — read from the stash
404
530
  * run() populates and memoized per process. Throws if called before run()
@@ -407,26 +533,24 @@ var ComputeService = class {
407
533
  this.#origin ??= readOrigin();
408
534
  return this.#origin;
409
535
  }
536
+ /** This service's resolved reserved port — the value run() routes to and
537
+ * exports as PORT — read the same way load() reads the stash. Defaults to
538
+ * 3000 when the platform binds none. */
539
+ port() {
540
+ const port = this.#processConfig().service["port"];
541
+ 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.`);
542
+ return port;
543
+ }
410
544
  };
411
545
  const compute = (def) => {
412
- const userParams = def.params ?? blindCast({});
413
- for (const reserved of Object.keys(reservedParams)) {
414
- if (reserved in def.deps) throw new Error(`compute(): dependency "${reserved}" collides with the reserved service param of the same name — rename the dependency.`);
415
- if (reserved in userParams) throw new Error(`compute(): param "${reserved}" collides with the reserved service param of the same name — rename the param.`);
416
- }
417
- 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.`);
418
- 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.`);
419
- const params = blindCast({
420
- ...userParams,
421
- ...reservedParams
422
- });
546
+ 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.`);
423
547
  const instance = new ComputeService(service({
424
548
  name: def.name,
425
549
  extension: "@prisma/composer-prisma-cloud",
426
550
  type: "compute",
427
551
  inputs: def.deps,
428
- params,
429
- ...def.secrets !== void 0 ? { secrets: def.secrets } : {},
552
+ params: reservedParams,
553
+ ...def.input !== void 0 ? { input: def.input } : {},
430
554
  build: def.build,
431
555
  ...def.expose !== void 0 ? { expose: def.expose } : {}
432
556
  }));
@@ -447,7 +571,7 @@ Object.freeze({
447
571
  satisfies: (required) => required.kind === "credentials"
448
572
  });
449
573
  //#endregion
450
- //#region ../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-DhziPSWE.mjs
574
+ //#region ../../1-prisma-cloud/2-shared-modules/cron/dist/scheduler-QQTyhZzT.mjs
451
575
  /**
452
576
  * The one call edge between the scheduler and the app's runner: `trigger(jobId)`.
453
577
  * The scheduler depends on it (`rpc(triggerContract)`); the runner exposes it
@@ -490,25 +614,25 @@ function parseEvery(s) {
490
614
  }
491
615
  /**
492
616
  * The reusable scheduler node and its firing logic. `cronScheduler` builds a
493
- * `compute()` whose `jobs` param default is the app's schedule and whose only
494
- * dependency is `trigger(jobId)`; nothing else about it varies per app.
495
- * `runScheduler` is the pure, injectable firing loop the entrypoint (and its
496
- * tests) drive.
617
+ * `compute()` whose one input is the `jobs` schedule (bound at provision by
618
+ * `cron()`, ADR-0042) and whose only dependency is `trigger(jobId)`; nothing
619
+ * else about it varies per app. `runScheduler` is the pure, injectable firing
620
+ * loop the entrypoint (and its tests) drive.
497
621
  */
498
- const scheduleSchema = type({
622
+ const cronInputSchema = type({ jobs: type({
499
623
  jobId: "string",
500
624
  every: "string"
501
- }).array();
625
+ }).array() });
502
626
  /**
503
- * The always-on scheduler service. `schedule` sets only the `jobs` param's
504
- * default the value the deploy serializes into config; the scheduler
505
- * itself is job-agnostic.
627
+ * The always-on scheduler service. Job-agnostic: the schedule arrives as the
628
+ * `jobs` key of the input binding `cron()` supplies at provision, and the
629
+ * entrypoint reads it back through `input()`.
506
630
  */
507
- function cronScheduler(schedule) {
631
+ function cronScheduler() {
508
632
  return compute({
509
633
  name: "scheduler",
510
634
  deps: { trigger: rpc(triggerContract) },
511
- params: { jobs: param(scheduleSchema, { default: [...schedule.jobs] }) },
635
+ input: cronInputSchema,
512
636
  build: node({
513
637
  module: new URL("./scheduler-service.mjs", import.meta.url).href,
514
638
  entry: "./scheduler-entrypoint.mjs"
@@ -545,9 +669,10 @@ function cron(opts) {
545
669
  id: "runner",
546
670
  deps: inputs
547
671
  });
548
- provision(cronScheduler(opts.schedule), {
672
+ provision(cronScheduler(), {
549
673
  id: "scheduler",
550
- deps: { trigger: runner.trigger }
674
+ deps: { trigger: runner.trigger },
675
+ input: { jobs: [...opts.schedule.jobs] }
551
676
  });
552
677
  return {};
553
678
  });