@prisma/composer 0.36.0 → 0.37.0-dev.1

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 (119) hide show
  1. package/dist/{app-config-DNnd7Zu--BQ1vHaMK.d.mts → app-config-Bf_y5R7o-BEZAnKqM.d.mts} +46 -6
  2. package/dist/app-config-Bf_y5R7o-BEZAnKqM.d.mts.map +1 -0
  3. package/dist/app-configuration-file-CeJvBAti-D3uDlheX.mjs +221 -0
  4. package/dist/app-configuration-file-CeJvBAti-D3uDlheX.mjs.map +1 -0
  5. package/dist/arktype.d.mts +20 -6
  6. package/dist/arktype.d.mts.map +1 -1
  7. package/dist/arktype.mjs +45 -6
  8. package/dist/arktype.mjs.map +1 -1
  9. package/dist/config-CDkq5Ayl.d.mts +1 -0
  10. package/dist/config-adapters-DG-uhGfv-Bt1M9f8b.mjs +47 -0
  11. package/dist/config-adapters-DG-uhGfv-Bt1M9f8b.mjs.map +1 -0
  12. package/dist/config.d.mts +16 -3
  13. package/dist/config.d.mts.map +1 -0
  14. package/dist/config.mjs +2 -1
  15. package/dist/control.d.mts +6 -174
  16. package/dist/control.d.mts.map +1 -1
  17. package/dist/control.mjs +4 -4
  18. package/dist/control.mjs.map +1 -1
  19. package/dist/deploy-CmiYExQA.mjs +373 -0
  20. package/dist/deploy-CmiYExQA.mjs.map +1 -0
  21. package/dist/deploy-DQyaIoNe.d.mts +2 -0
  22. package/dist/deploy.d.mts +4 -3
  23. package/dist/deploy.mjs +3 -364
  24. package/dist/{deployment-summary-CDHdLtnO-DrE7GsHq.mjs → deployment-summary-BiBkPWlB-CyC2pudN.mjs} +10 -23
  25. package/dist/deployment-summary-BiBkPWlB-CyC2pudN.mjs.map +1 -0
  26. package/dist/{deployment-summary-p88NV5m5-SaPCCX2C.d.mts → deployment-summary-p88NV5m5-BJOosgmI.d.mts} +3 -3
  27. package/dist/{deployment-summary-p88NV5m5-SaPCCX2C.d.mts.map → deployment-summary-p88NV5m5-BJOosgmI.d.mts.map} +1 -1
  28. package/dist/{secret-DoWGmN7m-DO5Brq1Y.mjs → describe-kind-Cpm_euxo-CkhlGJUL.mjs} +29 -2
  29. package/dist/describe-kind-Cpm_euxo-CkhlGJUL.mjs.map +1 -0
  30. package/dist/{dev-current-Brb4qugP-CG0_96FZ.mjs → dev-current-D0Kn6Mf4-DDWYu-3j.mjs} +5 -5
  31. package/dist/{dev-current-Brb4qugP-CG0_96FZ.mjs.map → dev-current-D0Kn6Mf4-DDWYu-3j.mjs.map} +1 -1
  32. package/dist/{dev-environment-name-6eEr5PW8-CGk1ijP7.mjs → dev-environment-name-6eEr5PW8-BwusWVKi.mjs} +3 -3
  33. package/dist/{dev-environment-name-6eEr5PW8-CGk1ijP7.mjs.map → dev-environment-name-6eEr5PW8-BwusWVKi.mjs.map} +1 -1
  34. package/dist/{dist-DiYPSVUE.mjs → dist-BtzrklYG.mjs} +2 -2
  35. package/dist/{dist-DiYPSVUE.mjs.map → dist-BtzrklYG.mjs.map} +1 -1
  36. package/dist/{dist-CZ_yEZ7F.mjs → dist-C7SnNTD3.mjs} +11 -4
  37. package/dist/dist-C7SnNTD3.mjs.map +1 -0
  38. package/dist/errors-0e8IVwzi.mjs.map +1 -1
  39. package/dist/{execute-deploy-destroy-CNt-xpE7-CYaa3sYk.mjs → execute-deploy-destroy-Dh1CQ9X6-DY4c9egd.mjs} +60 -29
  40. package/dist/execute-deploy-destroy-Dh1CQ9X6-DY4c9egd.mjs.map +1 -0
  41. package/dist/{execute-dev-BUk-XWBJ-ZHX5A8cR.mjs → execute-dev-Bl-5Q-Av-DILne6iY.mjs} +99 -44
  42. package/dist/execute-dev-Bl-5Q-Av-DILne6iY.mjs.map +1 -0
  43. package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs → execute-dev-current-D3USgHJ4-CNQe5ADb.mjs} +6 -6
  44. package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs.map → execute-dev-current-D3USgHJ4-CNQe5ADb.mjs.map} +1 -1
  45. package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs → execute-log-Dm3DkQQP-BSjoy6Wd.mjs} +6 -6
  46. package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs.map → execute-log-Dm3DkQQP-BSjoy6Wd.mjs.map} +1 -1
  47. package/dist/{graph-MGOZJdDt-CyI8-9r7.mjs → graph-Bqr7PSGl-BM-M-TlO.mjs} +637 -199
  48. package/dist/graph-Bqr7PSGl-BM-M-TlO.mjs.map +1 -0
  49. package/dist/{graph-BzTSXnoQ-BvGVq0bm.d.mts → graph-DI1v3WKX-3g1lTRbh.d.mts} +8 -4
  50. package/dist/graph-DI1v3WKX-3g1lTRbh.d.mts.map +1 -0
  51. package/dist/{graph-types-DfsG9Rkg-D_ARjMo7.d.mts → graph-types-DRe9UUOp-C85Yr-sJ.d.mts} +253 -120
  52. package/dist/graph-types-DRe9UUOp-C85Yr-sJ.d.mts.map +1 -0
  53. package/dist/http.d.mts +2 -2
  54. package/dist/http.mjs +2 -2
  55. package/dist/{index-D89ftK2z.d.mts → index-DWQ6BSgm.d.mts} +3 -3
  56. package/dist/index-DWQ6BSgm.d.mts.map +1 -0
  57. package/dist/index.d.mts +5 -5
  58. package/dist/index.mjs +4 -4
  59. package/dist/internal-app-configuration-file.d.mts +19 -0
  60. package/dist/internal-app-configuration-file.d.mts.map +1 -0
  61. package/dist/internal-app-configuration-file.mjs +2 -0
  62. package/dist/{local-target-DySKw61w.mjs → local-target-Dd8FJEb5.mjs} +5 -3
  63. package/dist/{local-target-DySKw61w.mjs.map → local-target-Dd8FJEb5.mjs.map} +1 -1
  64. package/dist/local-target.d.mts +2 -2
  65. package/dist/local-target.d.mts.map +1 -1
  66. package/dist/local-target.mjs +1 -1
  67. package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts → nextjs-DLyeRR7M-RtoHcY1c.d.mts} +3 -3
  68. package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts.map → nextjs-DLyeRR7M-RtoHcY1c.d.mts.map} +1 -1
  69. package/dist/nextjs-control.d.mts +4 -4
  70. package/dist/nextjs-control.mjs +2 -2
  71. package/dist/nextjs.d.mts +1 -1
  72. package/dist/node-control.d.mts +3 -3
  73. package/dist/node-control.mjs +2 -2
  74. package/dist/node.d.mts +2 -2
  75. package/dist/pointer-CyQZZugO-D7k3vibs.d.mts +42 -0
  76. package/dist/pointer-CyQZZugO-D7k3vibs.d.mts.map +1 -0
  77. package/dist/redaction-Bf8FvTFH-BTsKD9B5.d.mts +183 -0
  78. package/dist/redaction-Bf8FvTFH-BTsKD9B5.d.mts.map +1 -0
  79. package/dist/redaction-HnbkSFrK-BXRZ3B33.mjs +295 -0
  80. package/dist/redaction-HnbkSFrK-BXRZ3B33.mjs.map +1 -0
  81. package/dist/report.d.mts +3 -3
  82. package/dist/report.mjs +1 -1
  83. package/dist/report.mjs.map +1 -1
  84. package/dist/{run-alchemy-Dl_MWw4g-BZaLckHp.mjs → run-alchemy-OS_ix5g0-DCvUYZ7T.mjs} +30 -12
  85. package/dist/run-alchemy-OS_ix5g0-DCvUYZ7T.mjs.map +1 -0
  86. package/dist/{run-report-CmBz2-xc-S50d4g5V.mjs → run-report-CmBz2-xc-Cc8rV1CX.mjs} +2 -2
  87. package/dist/{run-report-CmBz2-xc-S50d4g5V.mjs.map → run-report-CmBz2-xc-Cc8rV1CX.mjs.map} +1 -1
  88. package/dist/service-rpc.d.mts +2 -2
  89. package/dist/service-rpc.mjs +2 -2
  90. package/dist/testing.d.mts +2 -2
  91. package/dist/testing.d.mts.map +1 -1
  92. package/dist/{validate-environment-CEhUSEg2-DmAtiQhe.mjs → validate-environment-D_dECxgO-B-gqpVEf.mjs} +113 -13
  93. package/dist/validate-environment-D_dECxgO-B-gqpVEf.mjs.map +1 -0
  94. package/dist/zod.d.mts +30 -0
  95. package/dist/zod.d.mts.map +1 -0
  96. package/dist/zod.mjs +39 -0
  97. package/dist/zod.mjs.map +1 -0
  98. package/package.json +31 -18
  99. package/skills/prisma-composer-core-concepts/SKILL.md +49 -23
  100. package/src/exports/config.ts +1 -0
  101. package/src/exports/internal-app-configuration-file.ts +1 -0
  102. package/src/exports/zod.ts +1 -0
  103. package/dist/app-config-DNnd7Zu--BQ1vHaMK.d.mts.map +0 -1
  104. package/dist/config-RKyUvtGC.d.mts +0 -1
  105. package/dist/deploy-RKyUvtGC.d.mts +0 -1
  106. package/dist/deploy.mjs.map +0 -1
  107. package/dist/deployment-summary-CDHdLtnO-DrE7GsHq.mjs.map +0 -1
  108. package/dist/dist-CZ_yEZ7F.mjs.map +0 -1
  109. package/dist/execute-deploy-destroy-CNt-xpE7-CYaa3sYk.mjs.map +0 -1
  110. package/dist/execute-dev-BUk-XWBJ-ZHX5A8cR.mjs.map +0 -1
  111. package/dist/graph-BzTSXnoQ-BvGVq0bm.d.mts.map +0 -1
  112. package/dist/graph-MGOZJdDt-CyI8-9r7.mjs.map +0 -1
  113. package/dist/graph-types-DfsG9Rkg-D_ARjMo7.d.mts.map +0 -1
  114. package/dist/index-D89ftK2z.d.mts.map +0 -1
  115. package/dist/run-alchemy-Dl_MWw4g-BZaLckHp.mjs.map +0 -1
  116. package/dist/secret-CHOw4LBU-C8yXoC9N.d.mts +0 -25
  117. package/dist/secret-CHOw4LBU-C8yXoC9N.d.mts.map +0 -1
  118. package/dist/secret-DoWGmN7m-DO5Brq1Y.mjs.map +0 -1
  119. package/dist/validate-environment-CEhUSEg2-DmAtiQhe.mjs.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
2
+ import { i as POINTER, o as isSecretPointer, r as isSecretString, t as describeKind } from "./describe-kind-Cpm_euxo-CkhlGJUL.mjs";
2
3
  import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
3
4
  import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
4
- //#region ../../0-framework/1-core/core/dist/graph-MGOZJdDt.mjs
5
+ //#region ../../0-framework/1-core/core/dist/graph-Bqr7PSGl.mjs
5
6
  /** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
6
7
  const RESOURCE_OUT_PORT = "$out";
7
8
  /**
@@ -24,17 +25,21 @@ const VALUE = blindCast(Symbol.for("prisma:value"));
24
25
  const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
25
26
  /**
26
27
  * A value computed from other values. `fn` receives the dependencies' real
27
- * values as one tuple, in order, and returns plain data. Load runs it after
28
- * every module body, with `provision` disabled (ADR-0062). `fn` must be a pure
29
- * function of its dependencies: a deploy runs it in two processes.
28
+ * values as one tuple, in order, and returns plain data. Each dependency must
29
+ * be a deploy-time value: listing a runtime value or a field wrapped with
30
+ * `field()` fails to compile, and Load refuses a dependency whose real value
31
+ * holds a pointer. Load runs `fn` after every module body, with `provision`
32
+ * disabled (ADR-0062). `fn` must be a pure function of its dependencies: a
33
+ * deploy runs it in two processes.
30
34
  */
31
35
  function resolve(dependencies, fn) {
32
36
  if (!Array.isArray(dependencies)) throw new Error("resolve() requires a tuple of values as its first argument.");
33
- dependencies.forEach((dependency, index) => {
37
+ const checked = dependencies.map((dependency, index) => {
34
38
  if (!isValue(dependency)) throw new Error(`resolve() dependency at index ${index} is not a value — list environment.name or another resolve() result.`);
39
+ return dependency;
35
40
  });
36
41
  if (typeof fn !== "function") throw new Error("resolve() requires a function as its second argument.");
37
- const frozenDependencies = Object.freeze([...dependencies]);
42
+ const frozenDependencies = Object.freeze(checked);
38
43
  const compute = blindCast(fn);
39
44
  return Object.freeze({
40
45
  [VALUE]: true,
@@ -45,7 +50,7 @@ function resolve(dependencies, fn) {
45
50
  })
46
51
  });
47
52
  }
48
- /** True if `value` is a `Value` (checks the brand only, never a prototype). */
53
+ /** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
49
54
  function isValue(value) {
50
55
  return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
51
56
  }
@@ -67,28 +72,117 @@ const environmentFacts = Object.freeze({ name: Object.freeze({
67
72
  fact: "name"
68
73
  })
69
74
  }) });
75
+ const INSPECT = Symbol.for("nodejs.util.inspect.custom");
76
+ /** `input` or `input.a.b`: how an error names an input field. */
77
+ function inputFieldLabel(origin) {
78
+ return origin.path.length === 0 ? "input" : `input.${origin.path.join(".")}`;
79
+ }
80
+ function misuse(origin, what) {
81
+ if (origin.path.length === 0) return new LoadError(`input of module "${origin.module}" is a dictionary of values, not data, and ${what}. A module body can only pass the fields of its input on, by name: into a provision() binding or, for a plain field, as a resolve() dependency.`);
82
+ const field = inputFieldLabel(origin);
83
+ return new LoadError(`${field} of module "${origin.module}" is a value, not its real value, and ${what}. A module body can only pass an input field on: into a provision() binding or as a resolve() dependency. To compute with it, it must be a plain field, not a wrapped or secret one; list it: resolve([${field}], ([v]) => …).`);
84
+ }
85
+ /** What a coercion with `hint` did to a value, worded for a misuse error. */
86
+ function primitiveMisuse(hint) {
87
+ switch (hint) {
88
+ case "string": return "it was turned into text (a template literal or String())";
89
+ case "number": return "it was turned into a number (arithmetic, or a comparison such as <)";
90
+ default: return "it was combined with + or compared with ==";
91
+ }
92
+ }
93
+ /**
94
+ * Builds the `input` a module body receives. Every property access returns a
95
+ * value recording its key path, and the same path always returns the same
96
+ * object, so Load's identity-keyed maps see one value per field. Any way of
97
+ * reading the real value throws a LoadError naming the field. At run time the
98
+ * whole input still answers the value brand, at path `[]`, so Load can find
99
+ * and refuse it wherever it is passed on.
100
+ */
101
+ function buildModuleInput(moduleAddress) {
102
+ const byPath = /* @__PURE__ */ new Map();
103
+ const valueAt = (path) => {
104
+ const key = JSON.stringify(path);
105
+ const existing = byPath.get(key);
106
+ if (existing !== void 0) return existing;
107
+ const origin = Object.freeze({
108
+ kind: "input",
109
+ module: moduleAddress,
110
+ path: Object.freeze([...path])
111
+ });
112
+ const thrower = (what) => () => {
113
+ throw misuse(origin, what);
114
+ };
115
+ const handler = {
116
+ get(_target, property) {
117
+ if (property === VALUE) return true;
118
+ if (property === VALUE_ORIGIN) return origin;
119
+ if (property === Symbol.toPrimitive) return (hint) => {
120
+ throw misuse(origin, primitiveMisuse(hint));
121
+ };
122
+ if (property === "toString") return thrower("its toString() was called");
123
+ if (property === "valueOf") return thrower("its valueOf() was called");
124
+ if (property === "toJSON") return thrower("it was serialized with JSON.stringify");
125
+ if (property === Symbol.iterator || property === Symbol.asyncIterator) return thrower("it was iterated (array spread, for…of or array destructuring)");
126
+ if (typeof property === "symbol") return void 0;
127
+ return valueAt([...path, property]);
128
+ },
129
+ has(_target, property) {
130
+ if (property === VALUE || property === VALUE_ORIGIN) return true;
131
+ if (typeof property === "symbol") return false;
132
+ throw misuse(origin, `it was checked with the in operator ("${property}" in …)`);
133
+ },
134
+ ownKeys() {
135
+ throw misuse(origin, "its keys were listed (Object.keys, object spread, for…in or Object.entries)");
136
+ },
137
+ getOwnPropertyDescriptor() {
138
+ throw misuse(origin, "its properties were inspected");
139
+ },
140
+ set(_target, property) {
141
+ throw misuse(origin, `its field "${String(property)}" was assigned to`);
142
+ },
143
+ defineProperty(_target, property) {
144
+ throw misuse(origin, `its field "${String(property)}" was assigned to`);
145
+ },
146
+ deleteProperty() {
147
+ throw misuse(origin, "a property was deleted from it");
148
+ },
149
+ setPrototypeOf() {
150
+ throw misuse(origin, "its prototype was changed");
151
+ },
152
+ preventExtensions() {
153
+ throw misuse(origin, "it was frozen or sealed");
154
+ }
155
+ };
156
+ const target = Object.create(null);
157
+ Object.defineProperty(target, INSPECT, {
158
+ value: () => `[${inputFieldLabel(origin)} of module "${origin.module}"]`,
159
+ configurable: true
160
+ });
161
+ const proxy = new Proxy(target, handler);
162
+ byPath.set(key, proxy);
163
+ return proxy;
164
+ };
165
+ return blindCast(valueAt([]));
166
+ }
70
167
  /**
71
168
  * Core model: node types and the factories that construct them, plain frozen
72
169
  * data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).
73
170
  */
74
171
  const NODE = Symbol.for("prisma:node");
75
- const SECRET_NEED = blindCast(Symbol.for("prisma:secret-need"));
76
172
  const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
77
- /** Declares a secret NEED. Nameless — the platform name is bound at the root via `envSecret`. */
78
- function secret() {
79
- return Object.freeze({
80
- [SECRET_NEED]: true,
81
- kind: "secret"
82
- });
83
- }
84
- /** Builds an opaque secret source from a target-defined payload — the SPI a deploy target's own source constructor (e.g. `envSecret`) calls. Core forwards the source and never inspects the payload. */
85
- function secretSource(payload) {
86
- return Object.freeze({
87
- [SECRET_SOURCE]: true,
88
- payload
89
- });
173
+ /** Builds a secret source from a target-defined payload: the SPI a deploy target's own constructor (e.g. `envSecret`) calls. The source is a value whose real value at deploy is itself, a pointer. Core forwards it and never inspects the payload. */
174
+ function secretSource(payload, options) {
175
+ const label = sourceLabel("secretSource", options?.label, "a secret source");
176
+ const secretsKey = options?.secretsKey;
177
+ if (secretsKey !== void 0 && (typeof secretsKey !== "string" || secretsKey.length === 0)) throw new Error("secretSource() secretsKey must be a non-empty string.");
178
+ return blindCast(buildSource(SECRET_SOURCE, payload, {
179
+ kind: "source",
180
+ sourceKind: "secret",
181
+ label,
182
+ secretsKey
183
+ }, "secret"));
90
184
  }
91
- /** True if `value` is a secret source (an `envSecret` result or a forwarded ctx.secrets ref). */
185
+ /** True if `value` is a secret source, such as an `envSecret()` result. */
92
186
  function isSecretSource(value) {
93
187
  return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
94
188
  }
@@ -106,25 +200,71 @@ function isProvisionNeed(value) {
106
200
  return typeof value === "object" && value !== null && blindCast(value)[PROVISION_NEED] === true;
107
201
  }
108
202
  const PARAM_SOURCE = blindCast(Symbol.for("prisma:param-source"));
109
- const PARAM_NEED = blindCast(Symbol.for("prisma:param-need"));
110
- /** Builds an opaque param source from a target-defined payload — the SPI a deploy target's own source constructor (e.g. `envParam`) calls. Core forwards the source and never inspects the payload. */
111
- function paramSource(payload) {
112
- return Object.freeze({
113
- [PARAM_SOURCE]: true,
203
+ /** Builds a param source from a target-defined payload: the SPI a deploy target's own constructor (e.g. `envParam`) calls. Core forwards it and never inspects the payload. */
204
+ function paramSource(payload, options) {
205
+ const label = sourceLabel("paramSource", options?.label, "a param source");
206
+ const configurationKey = options?.configurationKey;
207
+ if (configurationKey !== void 0 && (typeof configurationKey !== "string" || configurationKey.length === 0)) throw new Error("paramSource() configurationKey must be a non-empty string.");
208
+ const redacted = options?.redacted === true;
209
+ if (configurationKey !== void 0 && redacted) throw new Error("paramSource() takes configurationKey, for a value known at deploy, or redacted, for a secret known only at boot, not both.");
210
+ return blindCast(buildSource(PARAM_SOURCE, payload, {
211
+ kind: "source",
212
+ sourceKind: "param",
213
+ label,
214
+ configurationKey
215
+ }, configurationKey !== void 0 ? void 0 : redacted ? "secret" : "plain"));
216
+ }
217
+ function sourceLabel(factory, label, fallback) {
218
+ if (label === void 0) return fallback;
219
+ if (typeof label !== "string" || label.length === 0) throw new Error(`${factory}() label must be a non-empty string.`);
220
+ return label;
221
+ }
222
+ function buildSource(brand, payload, origin, kind) {
223
+ const source = {
224
+ [VALUE]: true,
225
+ [VALUE_ORIGIN]: origin,
226
+ [brand]: true,
227
+ ...kind === void 0 ? {} : { [POINTER]: kind },
114
228
  payload
115
- });
229
+ };
230
+ Object.defineProperty(origin, "source", { value: source });
231
+ Object.defineProperties(source, coercions(origin));
232
+ Object.freeze(origin);
233
+ return Object.freeze(source);
234
+ }
235
+ function coercions(origin) {
236
+ const thrower = (what) => () => {
237
+ throw sourceMisuse(origin, what);
238
+ };
239
+ return {
240
+ toString: { value: thrower("its toString() was called") },
241
+ valueOf: { value: thrower("its valueOf() was called") },
242
+ [Symbol.toPrimitive]: { value: (hint) => {
243
+ throw sourceMisuse(origin, primitiveMisuse(hint));
244
+ } }
245
+ };
246
+ }
247
+ const sourceMisuses = /* @__PURE__ */ new WeakSet();
248
+ function sourceMisuse(origin, what) {
249
+ const { label } = origin;
250
+ const error = new LoadError(origin.sourceKind === "secret" || origin.configurationKey === void 0 ? `${label} is known only at boot: the deploy holds a pointer to it, never its value, and ${what}. A module body can only pass it on, into a provision() binding; to compute with the value, do it in the service that reads it.` : `${label} is a value, not its real value, and ${what}. A module body can only pass it on: into a provision() binding or as a resolve() dependency. To compute with it, list it: resolve([${label}], ([v]) => …).`);
251
+ sourceMisuses.add(error);
252
+ return error;
253
+ }
254
+ /** True for the error a source throws when code turns it into text or a number. Internal to core. */
255
+ function isSourceMisuse(error) {
256
+ return error instanceof LoadError && sourceMisuses.has(error);
116
257
  }
117
- /** True if `value` is a param source (an `envParam` result or a forwarded ctx.params ref). */
258
+ /** A source's origin; `undefined` for a source another installed copy of core built without one. Internal to core. */
259
+ function sourceOriginOf(source) {
260
+ if (!isValue(source)) return void 0;
261
+ const origin = originOf(source);
262
+ return origin.kind === "source" ? origin : void 0;
263
+ }
264
+ /** True if `value` is a param source, such as an `envParam()` result. */
118
265
  function isParamSource(value) {
119
266
  return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
120
267
  }
121
- /** Declares a module param-forwarding NEED. Nameless — bound to a `ParamSource` by an enclosing scope and forwarded into a child's real param. */
122
- function paramNeed() {
123
- return Object.freeze({
124
- [PARAM_NEED]: true,
125
- kind: "param"
126
- });
127
- }
128
268
  function requireType(type, factory) {
129
269
  if (typeof type !== "string" || type.length === 0) throw new Error(`${factory}() requires a non-empty node type.`);
130
270
  }
@@ -304,14 +444,18 @@ function module(name, boundaryOrBody, maybeBody) {
304
444
  requireName(name, "module");
305
445
  const closedRoot = typeof boundaryOrBody === "function";
306
446
  const boundary = closedRoot ? {} : boundaryOrBody;
447
+ if (Object.hasOwn(boundary, "params")) throw new Error(`module("${name}") declares \`params\`, which a module no longer takes. Declare each value as a field of the module's \`input\` schema, and bind it with provision(module, { input: { … } }) (ADR-0061).`);
448
+ if (Object.hasOwn(boundary, "secrets")) throw new Error(`module("${name}") declares \`secrets\`, which a module no longer takes. Declare each secret as a secretString() field of the module's \`input\` schema, and bind it with provision(module, { input: { … } }) (ADR-0061).`);
307
449
  requireNotReservedPortNames(Object.keys(boundary.deps ?? {}), "module");
308
450
  requireNotReservedPortNames(Object.keys(boundary.expose ?? {}), "module");
451
+ if (boundary.input !== void 0 && typeof boundary.input["~standard"]?.validate !== "function") throw new Error("module() `input` must be a Standard Schema (an object with a \"~standard\".validate function) — see https://standardschema.dev (ADR-0061).");
309
452
  const deps = frozenShallowCopy(boundary.deps ?? {});
310
- const secretSlots = frozenShallowCopy(boundary.secrets ?? {});
311
- const paramSlots = frozenShallowCopy(boundary.params ?? {});
312
453
  const expose = frozenShallowCopy(boundary.expose ?? {});
313
454
  const body = closedRoot ? (ctx) => {
314
- boundaryOrBody(ctx);
455
+ boundaryOrBody({
456
+ ...ctx,
457
+ input: void 0
458
+ });
315
459
  return {};
316
460
  } : maybeBody;
317
461
  return Object.freeze({
@@ -319,8 +463,7 @@ function module(name, boundaryOrBody, maybeBody) {
319
463
  kind: "module",
320
464
  name,
321
465
  deps,
322
- secretSlots,
323
- paramSlots,
466
+ inputSchema: boundary.input,
324
467
  expose,
325
468
  body
326
469
  });
@@ -464,7 +607,12 @@ function loadService(root, rootId) {
464
607
  ports: boundaryPortsOf(rootId, root),
465
608
  authoredEdges: [],
466
609
  inputBindings: [],
467
- params: []
610
+ params: [],
611
+ secretSources: [],
612
+ appConfigurationRead: {
613
+ rootInput: [],
614
+ configurationKeyText: {}
615
+ }
468
616
  };
469
617
  }
470
618
  function joinPath(path, key) {
@@ -472,12 +620,22 @@ function joinPath(path, key) {
472
620
  }
473
621
  function describeSite(site) {
474
622
  switch (site.kind) {
475
- case "input": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
623
+ case "serviceInput": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
624
+ case "moduleInput": return site.path === "" ? `the input binding of module "${site.address}"` : `input key "${site.path}" of module "${site.address}"`;
476
625
  case "param": return `param "${site.path}" of service "${site.address}"`;
477
626
  case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
478
627
  }
479
628
  }
480
- function collect(value, site, found, seen) {
629
+ function collect(value, site, found, seen, recordSecret) {
630
+ if (isSecretSource(value) || isParamSource(value)) {
631
+ if (isSecretSource(value) && site.kind !== "props") recordSecret(value, site);
632
+ if (site.kind === "serviceInput" || site.kind === "param" || !isValue(value)) return;
633
+ found.push({
634
+ value,
635
+ site
636
+ });
637
+ return;
638
+ }
481
639
  if (isValue(value)) {
482
640
  found.push({
483
641
  value,
@@ -485,7 +643,6 @@ function collect(value, site, found, seen) {
485
643
  });
486
644
  return;
487
645
  }
488
- if (isSecretSource(value) || isParamSource(value)) return;
489
646
  if (!Array.isArray(value) && !isPlainObject(value)) return;
490
647
  if (seen.has(value)) return;
491
648
  seen.add(value);
@@ -495,7 +652,7 @@ function collect(value, site, found, seen) {
495
652
  collect(member, {
496
653
  ...site,
497
654
  path
498
- }, found, seen);
655
+ }, found, seen, recordSecret);
499
656
  }
500
657
  }
501
658
  function describeNotPlain(value) {
@@ -508,17 +665,69 @@ function describeNotPlain(value) {
508
665
  default: return;
509
666
  }
510
667
  }
668
+ /** How `value` would not survive `JSON.stringify` and `JSON.parse` unchanged, or `undefined` when it would. A key whose value is `undefined` is dropped, which a body cannot tell from absent. */
669
+ function jsonInexactKind(value) {
670
+ if (value === null || typeof value === "string" || typeof value === "boolean") return void 0;
671
+ if (typeof value === "number") return Number.isFinite(value) ? void 0 : "a non-finite number";
672
+ if (Array.isArray(value)) {
673
+ for (const member of value) {
674
+ if (member === void 0) return "an array with a missing member";
675
+ const kind = jsonInexactKind(member);
676
+ if (kind !== void 0) return kind;
677
+ }
678
+ return;
679
+ }
680
+ if (isPlainObject(value)) {
681
+ for (const member of Object.values(value)) {
682
+ if (member === void 0) continue;
683
+ const kind = jsonInexactKind(member);
684
+ if (kind !== void 0) return kind;
685
+ }
686
+ return;
687
+ }
688
+ return describeNotPlain(value) ?? describeKind(value);
689
+ }
690
+ const SAME_GRAPH_ADVICE = "A module body must build the same graph every time; one that reads the process environment, a file or the clock can build a different one.";
511
691
  function isThenable(value) {
692
+ if (isValue(value)) return false;
512
693
  return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
513
694
  }
695
+ function canonicalSecret(source) {
696
+ const original = sourceOriginOf(source)?.source;
697
+ return isSecretSource(original) ? original : source;
698
+ }
699
+ function nodeKindOf(site) {
700
+ switch (site.kind) {
701
+ case "serviceInput":
702
+ case "param": return "service";
703
+ case "moduleInput": return "module";
704
+ case "props": return "resource";
705
+ }
706
+ }
707
+ function pointersIn(values) {
708
+ const pointers = /* @__PURE__ */ new Set();
709
+ const seen = /* @__PURE__ */ new WeakSet();
710
+ const walk = (value) => {
711
+ if (isSecretSource(value) || isParamSource(value)) {
712
+ pointers.add(value);
713
+ return;
714
+ }
715
+ if (!Array.isArray(value) && !isPlainObject(value)) return;
716
+ if (seen.has(value)) return;
717
+ seen.add(value);
718
+ for (const member of Array.isArray(value) ? value : Object.values(value)) walk(member);
719
+ };
720
+ walk(values);
721
+ return pointers;
722
+ }
514
723
  function checkResult(result, fnLabel) {
515
724
  if (isThenable(result)) throw new LoadError(`${fnLabel} returned a Promise. resolve() runs synchronously at Load.`);
516
725
  const seen = /* @__PURE__ */ new WeakSet();
517
726
  const walk = (value, path) => {
518
727
  const atPath = path === "" ? "" : ` at "${path}"`;
519
728
  if (value === void 0) throw new LoadError(`${fnLabel} returned undefined${atPath}. Return a result for every environment; Composer never picks a default.`);
729
+ if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a source${atPath}, such as envSecret() or envParam() called inside the function. resolve() returns plain data; bind a source directly.`);
520
730
  if (isValue(value)) throw new LoadError(`${fnLabel} returned a value${atPath}, not a real value. List that value as a dependency; fn receives its real value.`);
521
- if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a secret or param source${atPath}. Bind envSecret() or envParam() directly; resolve() returns plain data.`);
522
731
  const notPlain = describeNotPlain(value);
523
732
  if (notPlain !== void 0) throw new LoadError(`${fnLabel} returned ${notPlain}${atPath}. resolve() returns plain data: strings, finite numbers, booleans, null, arrays and plain objects.`);
524
733
  if (typeof value !== "object" || value === null || seen.has(value)) return;
@@ -528,13 +737,42 @@ function checkResult(result, fnLabel) {
528
737
  };
529
738
  walk(result, "");
530
739
  }
531
- function substitute(value, results, inProgress) {
740
+ /** The first pointer in `value`, at any depth through arrays and plain objects, with its key path; `undefined` when there is none. */
741
+ function firstPointer(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
742
+ if (isSecretSource(value) || isParamSource(value)) return {
743
+ pointer: value,
744
+ path
745
+ };
746
+ if (!Array.isArray(value) && !isPlainObject(value)) return void 0;
747
+ if (seen.has(value)) return void 0;
748
+ seen.add(value);
749
+ const entries = Array.isArray(value) ? value.map((member, index) => [String(index), member]) : Object.entries(value);
750
+ for (const [key, member] of entries) {
751
+ const found = firstPointer(member, [...path, key], seen);
752
+ if (found !== void 0) return found;
753
+ }
754
+ }
755
+ /** Refuses a resolve() dependency whose real value is a pointer or holds one at any depth: `fn` computes with deploy-time data only. */
756
+ function refusePointerDependency(fnLabel, dependency, real) {
757
+ const found = firstPointer(real);
758
+ if (found === void 0) return;
759
+ const label = sourceOriginOf(found.pointer)?.label ?? "a value known only at boot";
760
+ const origin = originOf(dependency);
761
+ if (origin.kind !== "input") throw new LoadError(`${fnLabel} lists ${label}, which is known only at boot. A resolve() dependency must be a deploy-time value. Bind ${label} directly into the input of the service that reads it.`);
762
+ const listed = `${inputFieldLabel(origin)} of module "${origin.module}"`;
763
+ const field = inputFieldLabel({
764
+ ...origin,
765
+ path: [...origin.path, ...found.path]
766
+ });
767
+ throw new LoadError(`${fnLabel} lists ${listed}, ${found.path.length === 0 ? `whose real value is ${label}` : `which holds ${label} at ${field}`}, a value known only at boot. A resolve() dependency must be a deploy-time value. ${isSecretPointer(found.pointer) ? `A secret has no deploy-time value: pass ${field} on into a binding, and read it in the service.` : `To compute with ${field}, declare it plain, without field(), and bind it to deploy-time data.`}`);
768
+ }
769
+ function substitute(value, results, inProgress, sources) {
770
+ if (isSecretSource(value) || isParamSource(value)) return sources === "keep" || !isValue(value) ? value : results.get(value);
532
771
  if (isValue(value)) return results.get(value);
533
- if (isSecretSource(value) || isParamSource(value)) return value;
534
772
  if (Array.isArray(value)) {
535
773
  if (inProgress.has(value)) return value;
536
774
  inProgress.add(value);
537
- const rebuilt = value.map((member) => substitute(member, results, inProgress));
775
+ const rebuilt = value.map((member) => substitute(member, results, inProgress, sources));
538
776
  inProgress.delete(value);
539
777
  return rebuilt.every((member, index) => member === value[index]) ? value : rebuilt;
540
778
  }
@@ -544,39 +782,181 @@ function substitute(value, results, inProgress) {
544
782
  const rebuilt = {};
545
783
  let changed = false;
546
784
  for (const [key, member] of Object.entries(value)) {
547
- rebuilt[key] = substitute(member, results, inProgress);
548
- if (rebuilt[key] !== member) changed = true;
785
+ const real = substitute(member, results, inProgress, sources);
786
+ if (real === void 0 && isValue(member)) {
787
+ changed = true;
788
+ continue;
789
+ }
790
+ rebuilt[key] = real;
791
+ if (real !== member) changed = true;
549
792
  }
550
793
  inProgress.delete(value);
551
794
  return changed ? rebuilt : value;
552
795
  }
553
796
  return value;
554
797
  }
798
+ function describeData(value) {
799
+ if (Array.isArray(value)) return "an array";
800
+ if (typeof value === "object") return "an object that is not plain data";
801
+ return `a ${typeof value}`;
802
+ }
803
+ /** The data at `origin`'s path inside a validated input; `undefined` where a key or a parent is absent. */
804
+ function readPath(data, origin) {
805
+ let current = data;
806
+ for (const [index, key] of origin.path.entries()) {
807
+ if (current === void 0 || current === null) return void 0;
808
+ const missing = `${inputFieldLabel(origin)} of module "${origin.module}" does not exist`;
809
+ const parent = inputFieldLabel({
810
+ ...origin,
811
+ path: origin.path.slice(0, index)
812
+ });
813
+ const schemaAdvice = `The module's input schema must output a plain object for its body to read fields.`;
814
+ if (isSecretSource(current) || isParamSource(current)) throw new LoadError(`${missing}: ${parent} stands for a value only the platform has at boot, so it has no fields` + (index === 0 ? `. ${schemaAdvice}` : " and can only be passed on unchanged."));
815
+ if (!isPlainObject(current)) {
816
+ const advice = index === 0 ? schemaAdvice : `To compute with it, it must be a plain field, not a wrapped or secret one; list it: resolve([${parent}], ([v]) => …).`;
817
+ throw new LoadError(`${missing}: ${parent} is ${describeData(current)}, not a plain object, so it has no fields. ${advice}`);
818
+ }
819
+ if (!Object.hasOwn(current, key)) return void 0;
820
+ current = current[key];
821
+ }
822
+ return current;
823
+ }
824
+ function refuseSecretBoxes(address, value, path) {
825
+ if (isSecretSource(value) || isParamSource(value)) return;
826
+ if (isSecretString(value)) throw new LoadError(`${describeSite({
827
+ address,
828
+ kind: "moduleInput",
829
+ path
830
+ })} is bound to a SecretString. A secret's value never appears in the code; bind envSecret('NAME'), or pass on an input field typed secretString().`);
831
+ if (Array.isArray(value)) {
832
+ for (const [index, member] of value.entries()) refuseSecretBoxes(address, member, joinPath(path, index));
833
+ return;
834
+ }
835
+ if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) refuseSecretBoxes(address, member, joinPath(path, key));
836
+ }
837
+ /** The original source each runtime value in `value` names, by its path. */
838
+ function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map()) {
839
+ if (isSecretSource(value) || isParamSource(value)) found.set(path, sourceOriginOf(value)?.source ?? value);
840
+ else if (Array.isArray(value)) for (const [index, member] of value.entries()) sourcesByPath(member, joinPath(path, index), found);
841
+ else if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) sourcesByPath(member, joinPath(path, key), found);
842
+ return found;
843
+ }
844
+ function validateModuleInput(entry, resolved, environment) {
845
+ const address = entry.moduleAddress;
846
+ refuseSecretBoxes(address, resolved, "");
847
+ const result = entry.schema["~standard"].validate(resolved);
848
+ if (result instanceof Promise) throw new LoadError(`The input schema of module "${address}" returned a Promise from validate(). A module's input is validated synchronously at Load; use a schema with no asynchronous checks.`);
849
+ if (result.issues !== void 0) {
850
+ const messages = result.issues.map((issue) => issue.message).join("; ");
851
+ if (entry.isRoot) throw new LoadError(`The input of root module "${address}" does not match its input schema: ${messages}. A root's input is the values the \`config\` adapters in prisma.config.ts return${environment === void 0 ? "" : ` for the environment "${environment.name}"`}.`);
852
+ throw new LoadError(`The input binding of module "${address}" does not match the module's input schema: ${messages}`);
853
+ }
854
+ const bound = sourcesByPath(resolved);
855
+ const onlyChecked = "Its value is known only at boot, so a module's schema may check the field but never replace or move it.";
856
+ const restore = (value, path) => {
857
+ const expected = bound.get(path);
858
+ if (isSecretSource(value) || isParamSource(value)) {
859
+ const source = sourceOriginOf(value)?.source ?? value;
860
+ if (source !== expected) throw new LoadError(`The input schema of module "${address}" moved ${sourceOriginOf(source)?.label} to input key "${path}". ${onlyChecked}`);
861
+ return source;
862
+ }
863
+ if (expected !== void 0 && value !== void 0) throw new LoadError(`The input schema of module "${address}" replaced input key "${path}", which is bound to ${sourceOriginOf(expected)?.label}. ${onlyChecked}`);
864
+ if (isSecretString(value)) {
865
+ const atPath = path === "" ? "" : ` at "${path}"`;
866
+ throw new LoadError(`The input schema of module "${address}" produced a SecretString${atPath} that its binding did not supply. A module's schema may check a secret field, never create one.`);
867
+ }
868
+ if (Array.isArray(value)) return value.map((member, index) => restore(member, joinPath(path, index)));
869
+ if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, restore(member, joinPath(path, key))]));
870
+ return value;
871
+ };
872
+ return restore(result.value, "");
873
+ }
874
+ function refusePointersInProps(address, props) {
875
+ const seen = /* @__PURE__ */ new WeakSet();
876
+ const walk = (value, path) => {
877
+ if (isSecretSource(value) || isParamSource(value)) {
878
+ const label = sourceOriginOf(value)?.label ?? (isSecretSource(value) ? "a secret source" : "a param source");
879
+ throw new LoadError(`${describeSite({
880
+ address,
881
+ kind: "props",
882
+ path
883
+ })} is bound to ${label}, which is known only at boot. A resource's props are read at deploy; bind a value known at deploy.`);
884
+ }
885
+ if (!Array.isArray(value) && !isPlainObject(value)) return;
886
+ if (seen.has(value)) return;
887
+ seen.add(value);
888
+ const entries = Array.isArray(value) ? value.map((member, index) => [index, member]) : Object.entries(value);
889
+ for (const [key, member] of entries) walk(member, joinPath(path, key));
890
+ };
891
+ walk(props, "");
892
+ }
555
893
  /**
556
894
  * Resolves every value the graph binds, dependency-first, once each, and
557
895
  * returns each binding with its values replaced by their real values.
558
896
  */
559
897
  function resolveValues(input) {
560
898
  const { environment } = input;
899
+ const rootFields = /* @__PURE__ */ new Map();
900
+ const keysRead = /* @__PURE__ */ new Map();
901
+ /** The text the app configuration holds for `key`, recorded; `undefined` when it holds none or `''`. */
902
+ const configurationText = (key, label, site) => {
903
+ let raw;
904
+ if (input.appConfigurationRead !== void 0) raw = input.appConfigurationRead.configurationKeyText[key];
905
+ else if (input.configuration !== void 0) raw = input.configuration[key];
906
+ else throw new LoadError(`${describeSite(site)} depends on ${label}, but Load was given no app configuration to read "${key}" from. Pass { configuration } to Load; the deploy and dev commands pass the values the \`config\` adapters return.`);
907
+ if (raw !== void 0 && raw !== "" && typeof raw !== "string") throw new LoadError(`${describeSite(site)} depends on ${label}, which reads "${key}" from the values the \`config\` adapters return, but they return ${describeKind(raw)} for it, not text. ${label} reads text; to pass other data, declare it in the root module's input.`);
908
+ const text = raw === void 0 || raw === "" ? void 0 : raw;
909
+ keysRead.set(key, {
910
+ label,
911
+ text
912
+ });
913
+ return text;
914
+ };
915
+ const secretUses = /* @__PURE__ */ new Map();
916
+ const recordSecret = (source, site) => {
917
+ const canonical = canonicalSecret(source);
918
+ if (secretUses.has(canonical)) return;
919
+ secretUses.set(canonical, {
920
+ source: canonical,
921
+ address: site.address,
922
+ nodeKind: nodeKindOf(site)
923
+ });
924
+ };
925
+ const secretSourcesReceivedBy = (inputBindings, params) => {
926
+ for (const { serviceAddress, binding } of [...inputBindings, ...params]) for (const pointer of pointersIn(binding)) {
927
+ if (!isSecretSource(pointer)) continue;
928
+ const canonical = canonicalSecret(pointer);
929
+ if (secretUses.get(canonical)?.nodeKind === "service") continue;
930
+ secretUses.set(canonical, {
931
+ source: canonical,
932
+ address: serviceAddress,
933
+ nodeKind: "service"
934
+ });
935
+ }
936
+ return [...secretUses.values()];
937
+ };
561
938
  const found = [];
562
939
  for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
563
940
  address: serviceAddress,
564
- kind: "input",
941
+ kind: "serviceInput",
565
942
  path: ""
566
- }, found, /* @__PURE__ */ new WeakSet());
943
+ }, found, /* @__PURE__ */ new WeakSet(), recordSecret);
567
944
  for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
568
945
  address: serviceAddress,
569
946
  kind: "param",
570
947
  path: slot
571
- }, found, /* @__PURE__ */ new WeakSet());
948
+ }, found, /* @__PURE__ */ new WeakSet(), recordSecret);
572
949
  for (const [address, resource] of input.resources) {
573
950
  const site = {
574
951
  address,
575
952
  kind: "props",
576
953
  path: ""
577
954
  };
578
- collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
955
+ collect(resource.props, site, found, /* @__PURE__ */ new WeakSet(), recordSecret);
579
956
  }
957
+ const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
958
+ const validatedInputs = /* @__PURE__ */ new Map();
959
+ const validating = /* @__PURE__ */ new Set();
580
960
  const results = /* @__PURE__ */ new Map();
581
961
  const visiting = [];
582
962
  const fnLabelFor = (site) => visiting.length === 1 ? `The resolve() function for ${describeSite(site)}` : `A resolve() function that ${describeSite(site)} depends on`;
@@ -591,52 +971,168 @@ function resolveValues(input) {
591
971
  if (environment === void 0) throw new LoadError(`${describeSite(site)} depends on environment.name, but Load was given no environment. Pass { environment: { name } } to Load; the deploy and dev commands do.`);
592
972
  result = environment[origin.fact];
593
973
  break;
974
+ case "source":
975
+ if (isSecretSource(origin.source)) recordSecret(origin.source, site);
976
+ if (origin.sourceKind === "secret" || origin.configurationKey === void 0) result = origin.source;
977
+ else result = configurationText(origin.configurationKey, origin.label, site);
978
+ break;
594
979
  case "computed": {
595
- const args = origin.dependencies.map((dependency) => resolveOne(dependency, site));
980
+ const args = origin.dependencies.map((dependency) => {
981
+ const real = resolveOne(dependency, site);
982
+ const source = originOf(dependency);
983
+ if (real === void 0 && source.kind === "source" && source.sourceKind === "param") throw new LoadError(`${fnLabelFor(site)} lists ${source.label}, but "${source.configurationKey}" is unset or empty, so it has no real value. Set "${source.configurationKey}", or bind ${source.label} directly into an input binding, where an absent value leaves the key out and the schema decides.`);
984
+ refusePointerDependency(fnLabelFor(site), dependency, real);
985
+ return real;
986
+ });
596
987
  try {
597
988
  result = origin.compute(args);
598
989
  } catch (thrown) {
599
- if (thrown instanceof LoadError) throw thrown;
990
+ if (thrown instanceof LoadError && !isSourceMisuse(thrown)) throw thrown;
600
991
  const message = thrown instanceof Error ? thrown.message : String(thrown);
601
992
  throw new LoadError(`${fnLabelFor(site)} threw: ${message}`, { cause: thrown });
602
993
  }
603
994
  checkResult(result, fnLabelFor(site));
604
995
  break;
605
996
  }
997
+ case "input": {
998
+ const entry = moduleInputByAddress.get(origin.module);
999
+ if (entry === void 0) throw new LoadError(`${describeSite(site)} depends on ${inputFieldLabel(origin)} of module "${origin.module}", which this Load does not provision. An input field can be passed on only inside the body of the module that received it.`);
1000
+ if (origin.path.length === 0) {
1001
+ const everyVariable = entry.isRoot ? " The root's input is every value the `config` adapters return, which by default is every variable of the process environment, secrets included." : "";
1002
+ throw new LoadError(`${describeSite(site)} depends on the whole input of module "${origin.module}". A module body's input is a dictionary of values, not a value, so it cannot be passed on whole.${everyVariable} Pass its fields on by name, such as input.from.`);
1003
+ }
1004
+ if (entry.checked !== void 0) {
1005
+ const field = entry.checked.find((candidate) => candidate.path.join("\0") === origin.path.join("\0"));
1006
+ if (field === void 0) throw new LoadError(`${inputFieldLabel(origin)} of root module "${origin.module}" is not in the app configuration file. The first process's root body did not pass it on, so the deploy's two processes built different graphs. ${SAME_GRAPH_ADVICE}`);
1007
+ result = field.value;
1008
+ } else {
1009
+ result = readPath(validatedInputOf(entry), origin);
1010
+ if (entry.isRoot) rootFields.set(origin.path.join("\0"), result === void 0 ? { path: origin.path } : {
1011
+ path: origin.path,
1012
+ value: result
1013
+ });
1014
+ }
1015
+ break;
1016
+ }
606
1017
  }
607
1018
  visiting.pop();
608
1019
  results.set(value, result);
609
1020
  return result;
610
1021
  };
1022
+ const validatedInputOf = (entry) => {
1023
+ if (entry.checked !== void 0) return void 0;
1024
+ if (validatedInputs.has(entry.moduleAddress)) return validatedInputs.get(entry.moduleAddress);
1025
+ if (validating.has(entry.moduleAddress)) throw new LoadError(`The input binding of module "${entry.moduleAddress}" depends on that module's own input. Remove the cycle.`);
1026
+ validating.add(entry.moduleAddress);
1027
+ const site = {
1028
+ address: entry.moduleAddress,
1029
+ kind: "moduleInput",
1030
+ path: ""
1031
+ };
1032
+ const values = [];
1033
+ collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet(), recordSecret);
1034
+ for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
1035
+ const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet(), "resolve"), environment);
1036
+ validating.delete(entry.moduleAddress);
1037
+ validatedInputs.set(entry.moduleAddress, validated);
1038
+ return validated;
1039
+ };
1040
+ const rootModuleAddress = () => input.moduleInputs.find((entry) => entry.isRoot)?.moduleAddress ?? "";
1041
+ const appConfigurationReadOf = (inputBindings, params, secretSources) => {
1042
+ if (input.configuration !== void 0 || input.appConfigurationRead !== void 0) {
1043
+ const kept = [...inputBindings.map(({ serviceAddress, binding }) => ({
1044
+ binding,
1045
+ site: {
1046
+ address: serviceAddress,
1047
+ kind: "serviceInput",
1048
+ path: ""
1049
+ }
1050
+ })), ...params.map(({ serviceAddress, slot, binding }) => ({
1051
+ binding,
1052
+ site: {
1053
+ address: serviceAddress,
1054
+ kind: "param",
1055
+ path: slot
1056
+ }
1057
+ }))];
1058
+ for (const { binding, site } of kept) for (const pointer of pointersIn(binding)) {
1059
+ if (!isParamSource(pointer)) continue;
1060
+ const origin = sourceOriginOf(pointer);
1061
+ if (origin?.sourceKind === "param" && origin.configurationKey !== void 0) configurationText(origin.configurationKey, origin.label, site);
1062
+ }
1063
+ }
1064
+ for (const use of secretSources) {
1065
+ const origin = sourceOriginOf(use.source);
1066
+ if (origin?.sourceKind !== "secret") continue;
1067
+ const key = origin.secretsKey;
1068
+ const read = key === void 0 ? void 0 : keysRead.get(key);
1069
+ if (key !== void 0 && read !== void 0) throw new LoadError(`${read.label} reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: Composer hands the deploy's second process every plain value it reads, in a file, and never writes a secret to a file. Give the plain value and the secret different names.`);
1070
+ const field = [...rootFields.values()].find((candidate) => candidate.path[0] === key);
1071
+ if (key !== void 0 && field !== void 0) throw new LoadError(`${inputFieldLabel({
1072
+ kind: "input",
1073
+ module: rootModuleAddress(),
1074
+ path: field.path
1075
+ })} of root module "${rootModuleAddress()}" reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: Composer hands the deploy's second process every root input field the root's body passes on, in a file, and never writes a secret to a file. Read the secret with ${origin.label} only, or give the plain value a different name.`);
1076
+ }
1077
+ for (const field of rootFields.values()) {
1078
+ const kind = "value" in field ? jsonInexactKind(field.value) : void 0;
1079
+ if (kind !== void 0) throw new LoadError(`${inputFieldLabel({
1080
+ kind: "input",
1081
+ module: rootModuleAddress(),
1082
+ path: field.path
1083
+ })} of root module "${rootModuleAddress()}" holds ${kind}, which JSON cannot hold exactly. The deploy hands the root's input to its second process in a JSON file, so a field the root's body passes on must hold text, a finite number, a boolean, null, or arrays and plain objects of these.`);
1084
+ }
1085
+ const configurationKeyText = {};
1086
+ for (const [key, { text }] of keysRead) if (text !== void 0) configurationKeyText[key] = text;
1087
+ return {
1088
+ rootInput: [...rootFields.values()],
1089
+ configurationKeyText
1090
+ };
1091
+ };
1092
+ for (const entry of input.moduleInputs) validatedInputOf(entry);
611
1093
  for (const { value, site } of found) resolveOne(value, site);
612
1094
  const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
613
- if (found.length === 0) return {
614
- inputBindings: input.inputBindings,
615
- params: input.params,
616
- resourceProps: authoredProps
617
- };
1095
+ if (found.length === 0) {
1096
+ for (const [address, props] of authoredProps) refusePointersInProps(address, props);
1097
+ const secretSources = secretSourcesReceivedBy(input.inputBindings, input.params);
1098
+ return {
1099
+ inputBindings: input.inputBindings,
1100
+ params: input.params,
1101
+ resourceProps: authoredProps,
1102
+ secretSources,
1103
+ appConfigurationRead: appConfigurationReadOf(input.inputBindings, input.params, secretSources)
1104
+ };
1105
+ }
618
1106
  const inProgress = /* @__PURE__ */ new WeakSet();
619
1107
  const resourceProps = /* @__PURE__ */ new Map();
620
1108
  for (const [address, props] of authoredProps) {
621
- const substituted = substitute(props, results, inProgress);
622
- resourceProps.set(address, substituted === props ? props : blindCast(substituted));
1109
+ const substituted = substitute(props, results, inProgress, "resolve");
1110
+ refusePointersInProps(address, substituted);
1111
+ const resolvedProps = substituted === props ? props : blindCast(substituted);
1112
+ resourceProps.set(address, resolvedProps);
623
1113
  }
1114
+ const inputBindings = input.inputBindings.map((entry) => {
1115
+ const binding = substitute(entry.binding, results, inProgress, "keep");
1116
+ return binding === entry.binding ? entry : {
1117
+ serviceAddress: entry.serviceAddress,
1118
+ binding: blindCast(binding)
1119
+ };
1120
+ });
1121
+ const params = input.params.flatMap((entry) => {
1122
+ const binding = substitute(entry.binding, results, inProgress, "keep");
1123
+ if (binding === void 0 && isValue(entry.binding)) return [];
1124
+ return [binding === entry.binding ? entry : {
1125
+ ...entry,
1126
+ binding
1127
+ }];
1128
+ });
1129
+ const secretSources = secretSourcesReceivedBy(inputBindings, params);
624
1130
  return {
625
1131
  resourceProps,
626
- inputBindings: input.inputBindings.map((entry) => {
627
- const binding = substitute(entry.binding, results, inProgress);
628
- return binding === entry.binding ? entry : {
629
- serviceAddress: entry.serviceAddress,
630
- binding: blindCast(binding)
631
- };
632
- }),
633
- params: input.params.map((entry) => {
634
- const binding = substitute(entry.binding, results, inProgress);
635
- return binding === entry.binding ? entry : {
636
- ...entry,
637
- binding
638
- };
639
- })
1132
+ inputBindings,
1133
+ params,
1134
+ secretSources,
1135
+ appConfigurationRead: appConfigurationReadOf(inputBindings, params, secretSources)
640
1136
  };
641
1137
  }
642
1138
  /**
@@ -710,10 +1206,6 @@ function producerIdOf(ref) {
710
1206
  * identity the branding copy creates, never on reading this back.
711
1207
  */
712
1208
  const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
713
- /** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.secrets` forwarding channel. */
714
- const MODULE_SECRET_KEY = Symbol("prisma:module-secret-key");
715
- /** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.params` forwarding channel. */
716
- const MODULE_PARAM_KEY = Symbol("prisma:module-param-key");
717
1209
  /** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
718
1210
  function satisfiesRequired(ref, required) {
719
1211
  return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
@@ -747,25 +1239,6 @@ function validateWiring(pending, byId) {
747
1239
  if (value.kind === "dependency") throw new LoadError(`Dependency "${input}" of provisioned ${targetKind} "${targetId}" is not wired to a producer (module "${enclosingModuleName}").`);
748
1240
  }
749
1241
  }
750
- /**
751
- * Flattens a value into itself plus every nested object/array member value —
752
- * identity fodder for the ctx.secrets/ctx.params usage marking, which must
753
- * see a forwarded source wherever it sits inside an input binding (ADR-0042).
754
- * A secret/param source is an opaque leaf: it is pushed (a forwarded ref IS
755
- * such a source, so identity-matching still needs it) but never descended
756
- * into, so a ref buried in an unrelated source's payload is not falsely seen
757
- * as used. `seen` guards object cycles so a self-referential binding cannot
758
- * recurse forever.
759
- */
760
- function deepValues(value, out, seen = /* @__PURE__ */ new WeakSet()) {
761
- out.push(value);
762
- if (typeof value !== "object" || value === null) return;
763
- if (isSecretSource(value) || isParamSource(value)) return;
764
- if (seen.has(value)) return;
765
- seen.add(value);
766
- const members = Array.isArray(value) ? value : Object.values(value);
767
- for (const member of members) deepValues(member, out, seen);
768
- }
769
1242
  /** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */
770
1243
  function wiringEdges(wiring, targetId) {
771
1244
  return Object.entries(wiring).map(([input, ref]) => ({
@@ -776,48 +1249,15 @@ function wiringEdges(wiring, targetId) {
776
1249
  }));
777
1250
  }
778
1251
  /**
779
- * Checks the secrets wired into one provisioned child MODULE: every declared
780
- * forwarding slot is bound to a real secret source (an `envSecret` or a
781
- * forwarded ctx.secrets ref), and no wired key names a slot the module
782
- * doesn't declare — the secret analog of `validateWiring`'s per-input checks,
783
- * but resolved inline (a source carries its own name, so no whole-graph pass
784
- * is needed).
785
- */
786
- function validateSecretBinding(child, id, address, secretWiring, enclosingModuleName) {
787
- const { kind } = child;
788
- for (const slot of Object.keys(child.secretSlots)) {
789
- const bound = secretWiring[slot];
790
- if (bound === void 0) throw new LoadError(`Secret slot "${slot}" of provisioned ${kind} "${id}" is not bound (module "${enclosingModuleName}") — bind it with envSecret('NAME') or forward ctx.secrets.`);
791
- if (isValue(bound)) throw new LoadError(`The secrets for "${address}" bind "${slot}" to a value. A value is not a secret source; bind envSecret('NAME') or a forwarded ctx.secrets ref.`);
792
- if (!isSecretSource(bound)) throw new LoadError(`Secret slot "${slot}" of "${id}" (module "${enclosingModuleName}") was wired with a non-secret value — use envSecret('NAME') or a forwarded ctx.secrets ref.`);
793
- }
794
- for (const slot of Object.keys(secretWiring)) if (!Object.hasOwn(child.secretSlots, slot)) throw new LoadError(`The secrets for "${id}" name "${slot}", which is not a secret slot of that ${kind} (module "${enclosingModuleName}").`);
795
- }
796
- /**
797
- * Checks the params wired into a provisioned SERVICE: unlike a secret slot, a
798
- * declared param is never required to be bound here — it may fall back to its
799
- * own `default` (checked later, at `buildConfig`) — so this only rejects a
800
- * wired key that names something other than a real declared param.
1252
+ * Checks the params wired into a provisioned SERVICE: a declared param is never
1253
+ * required to be bound here — it may fall back to its own `default` (checked
1254
+ * later, at `buildConfig`) — so this only rejects a wired key that names
1255
+ * something other than a real declared param.
801
1256
  */
802
1257
  function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName) {
803
1258
  for (const slot of Object.keys(paramWiring)) if (!Object.hasOwn(child.params, slot)) throw new LoadError(`The params for "${id}" name "${slot}", which is not a param of that service (module "${enclosingModuleName}").`);
804
1259
  }
805
1260
  /**
806
- * Checks the params wired into a provisioned MODULE: every declared
807
- * param-forwarding slot must be bound to a real `ParamSource` — a slot has no
808
- * schema of its own, so (unlike a service param) it cannot fall back to a
809
- * literal or a default; the param analog of `validateSecretBinding`.
810
- */
811
- function validateParamNeedBinding(child, id, address, paramWiring, enclosingModuleName) {
812
- for (const slot of Object.keys(child.paramSlots)) {
813
- const bound = paramWiring[slot];
814
- if (bound === void 0) throw new LoadError(`Param slot "${slot}" of provisioned module "${id}" is not bound (module "${enclosingModuleName}") — bind it with a param source (e.g. envParam('NAME')) or forward ctx.params.`);
815
- if (isValue(bound)) throw new LoadError(`The params for "${address}" bind "${slot}" to a value. A module param slot takes a param source; bind envParam('NAME') or a forwarded ctx.params ref.`);
816
- if (!isParamSource(bound)) throw new LoadError(`Param slot "${slot}" of "${id}" (module "${enclosingModuleName}") was wired with a non-source value — a module param-forwarding slot carries no schema to validate a literal against; use envParam('NAME') or a forwarded ctx.params ref.`);
817
- }
818
- for (const slot of Object.keys(paramWiring)) if (!Object.hasOwn(child.paramSlots, slot)) throw new LoadError(`The params for "${id}" name "${slot}", which is not a param slot of that module (module "${enclosingModuleName}").`);
819
- }
820
- /**
821
1261
  * Recursively flattens one module's body into the shared graph state and
822
1262
  * returns its resolved ModuleOutputs (one ref-port per expose key) for the
823
1263
  * caller (the enclosing provision() call, or Load itself for the root) to
@@ -835,12 +1275,10 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
835
1275
  * children carry it as their `parent`, and this module's own boundary ports
836
1276
  * (and the authored edges touching them) are recorded against it.
837
1277
  */
838
- function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading) {
1278
+ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
839
1279
  ports.push(...boundaryPortsOf(selfId, moduleNode));
840
1280
  const localIds = /* @__PURE__ */ new Set();
841
1281
  const used = /* @__PURE__ */ new Set();
842
- const usedSecrets = /* @__PURE__ */ new Set();
843
- const usedParams = /* @__PURE__ */ new Set();
844
1282
  const ctxInputs = {};
845
1283
  for (const key of Object.keys(moduleNode.deps)) {
846
1284
  const wired = wiring[key];
@@ -879,28 +1317,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
879
1317
  });
880
1318
  }
881
1319
  };
882
- const ctxSecrets = {};
883
- for (const key of Object.keys(moduleNode.secretSlots)) {
884
- const bound = secretWiring[key];
885
- ctxSecrets[key] = typeof bound === "object" && bound !== null ? {
886
- ...bound,
887
- [MODULE_SECRET_KEY]: key
888
- } : bound;
889
- }
890
- const markSecretsUsed = (values) => {
891
- for (const value of values) for (const key of Object.keys(ctxSecrets)) if (value === ctxSecrets[key]) usedSecrets.add(key);
892
- };
893
- const ctxParams = {};
894
- for (const key of Object.keys(moduleNode.paramSlots)) {
895
- const bound = paramWiring[key];
896
- ctxParams[key] = typeof bound === "object" && bound !== null ? {
897
- ...bound,
898
- [MODULE_PARAM_KEY]: key
899
- } : bound;
900
- }
901
- const markParamsUsed = (values) => {
902
- for (const value of values) for (const key of Object.keys(ctxParams)) if (value === ctxParams[key]) usedParams.add(key);
903
- };
904
1320
  const provision = (child, opts) => {
905
1321
  if (loading.sealed) throw new LoadError(`provision() was called after module "${moduleNode.name}" was loaded, from inside a resolve() function. resolve() computes values, never structure: the graph is the same whatever inputs Composer is given (ADR-0062). Provision the node in the module body and pass the value into it.`);
906
1322
  const id = opts?.id ?? child.name;
@@ -954,24 +1370,15 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
954
1370
  for (const [input, ref] of Object.entries(provisionWiring ?? {})) if (isValue(ref)) throw new LoadError(`The deps for "${fullAddress}.${input}" are bound to a value. A value can configure a node, never decide its edges: the graph is the same whatever inputs Composer is given (ADR-0062).`);
955
1371
  const localWiring = { ...provisionWiring ?? {} };
956
1372
  markUsed(Object.values(localWiring));
957
- const localSecrets = { ...provisionSecrets ?? {} };
958
- markSecretsUsed(Object.values(localSecrets));
959
1373
  const localParams = { ...provisionParams ?? {} };
960
- markParamsUsed(Object.values(localParams));
961
1374
  if (child.kind === "service") {
962
1375
  if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a service — a service takes its secrets as envSecret(...) leaves of its \`input\` binding (ADR-0042), not a secrets map.`);
963
1376
  if (child.inputSchema !== void 0 && provisionInput === void 0) throw new LoadError(`Input of provisioned service "${id}" is not bound (module "${moduleNode.name}") — the service declares an input schema; bind it with \`input: { … }\` on its provision() call.`);
964
1377
  if (child.inputSchema === void 0 && provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding, but the service declares no input schema (module "${moduleNode.name}").`);
965
- if (provisionInput !== void 0) {
966
- const leaves = [];
967
- deepValues(provisionInput, leaves);
968
- markSecretsUsed(leaves);
969
- markParamsUsed(leaves);
970
- inputBindings.push({
971
- serviceAddress: fullAddress,
972
- binding: blindCast(provisionInput)
973
- });
974
- }
1378
+ if (provisionInput !== void 0) inputBindings.push({
1379
+ serviceAddress: fullAddress,
1380
+ binding: provisionInput
1381
+ });
975
1382
  validateServiceParamBinding(child, id, localParams, moduleNode.name);
976
1383
  for (const [slot, binding] of Object.entries(localParams)) paramBindings.push({
977
1384
  serviceAddress: fullAddress,
@@ -997,9 +1404,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
997
1404
  byId.set(fullAddress, child);
998
1405
  return refFor(fullAddress, child);
999
1406
  }
1000
- if (provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding for a module — a module has no input schema; bind the input on the service that declares it.`);
1001
- validateSecretBinding(child, id, fullAddress, localSecrets, moduleNode.name);
1002
- validateParamNeedBinding(child, id, fullAddress, localParams, moduleNode.name);
1407
+ if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a module, which a module no longer takes. A module takes a secret as a secretString() field of its \`input\` binding (ADR-0061), not a secrets map.`);
1408
+ if (provisionParams !== void 0) throw new LoadError(`provision("${id}") received params for a module, which a module no longer takes. A module takes its values as fields of its \`input\` binding (ADR-0061), not a params map.`);
1409
+ const childInputSchema = child.inputSchema;
1410
+ if (childInputSchema === void 0 && provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding, but the module declares no input schema (module "${moduleNode.name}").`);
1411
+ if (childInputSchema !== void 0 && provisionInput === void 0) throw new LoadError(`Input of provisioned module "${id}" is not bound (module "${moduleNode.name}") — the module declares an input schema; bind it with \`input: { … }\` on its provision() call.`);
1412
+ if (childInputSchema !== void 0) moduleInputs.push({
1413
+ moduleAddress: fullAddress,
1414
+ schema: childInputSchema,
1415
+ binding: provisionInput,
1416
+ isRoot: false
1417
+ });
1003
1418
  edges.push(...wiringEdges(localWiring, fullAddress));
1004
1419
  recordAuthoredWiring(fullAddress, localWiring);
1005
1420
  pending.push({
@@ -1009,7 +1424,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
1009
1424
  targetKind: "module",
1010
1425
  enclosingModuleName: moduleNode.name
1011
1426
  });
1012
- const childOutputs = flatten(child, fullAddress, localWiring, localSecrets, localParams, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading);
1427
+ const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
1013
1428
  nodes.push({
1014
1429
  id: fullAddress,
1015
1430
  parent: selfId,
@@ -1031,19 +1446,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
1031
1446
  };
1032
1447
  const ctx = blindCast({
1033
1448
  deps: ctxInputs,
1034
- secrets: ctxSecrets,
1035
- params: ctxParams,
1449
+ input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
1036
1450
  environment: environmentFacts,
1037
1451
  provision: blindCast(provision)
1038
1452
  });
1039
1453
  const outputs = blindCast(moduleNode.body(ctx) ?? {});
1040
1454
  markUsed(Object.values(outputs));
1041
1455
  for (const key of Object.keys(moduleNode.deps)) if (!used.has(key)) throw new LoadError(`Module "${moduleNode.name}" declares dependency "${key}" but never forwards it into a provision nor returns it as an exposed interface.`);
1042
- for (const key of Object.keys(moduleNode.secretSlots)) if (!usedSecrets.has(key)) throw new LoadError(`Module "${moduleNode.name}" declares secret "${key}" but never forwards it into a provision.`);
1043
- for (const key of Object.keys(moduleNode.paramSlots)) if (!usedParams.has(key)) throw new LoadError(`Module "${moduleNode.name}" declares param "${key}" but never forwards it into a provision.`);
1044
1456
  for (const [key, contract] of Object.entries(moduleNode.expose)) {
1045
1457
  const port = outputs[key];
1046
1458
  if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
1459
+ if (isValue(port)) throw new LoadError(`Module "${moduleNode.name}" returned a value for expose "${key}". A value can configure a node, never decide its edges: return a port of a node the body provisions.`);
1047
1460
  if (!satisfiesRequired(port, contract)) throw new LoadError(`Module "${moduleNode.name}"'s returned port for expose "${key}" does not satisfy its declared contract.`);
1048
1461
  const from = authoredSourceOf(port);
1049
1462
  if (from !== void 0) authoredEdges.push({
@@ -1064,16 +1477,22 @@ function loadModule(root, opts) {
1064
1477
  const names = rootDepKeys.map((k) => `"${k}"`).join(", ");
1065
1478
  throw new LoadError(`Module "${root.name}" declares ${rootDepKeys.length > 1 ? "dependencies" : "dependency"} ${names} but is being deployed as the root — a root has no enclosing scope to wire them; compose "${root.name}" from another module that provisions and wires it instead.`);
1066
1479
  }
1067
- const rootSecretKeys = Object.keys(root.secretSlots);
1068
- if (rootSecretKeys.length > 0) {
1069
- const names = rootSecretKeys.map((k) => `"${k}"`).join(", ");
1070
- throw new LoadError(`Module "${root.name}" declares secret${rootSecretKeys.length > 1 ? "s" : ""} ${names} but is being deployed as the root — a root has no enclosing scope to bind them; the root binds secrets with envSecret('NAME'), it does not declare secret slots of its own.`);
1071
- }
1072
- const rootParamKeys = Object.keys(root.paramSlots);
1073
- if (rootParamKeys.length > 0) {
1074
- const names = rootParamKeys.map((k) => `"${k}"`).join(", ");
1075
- throw new LoadError(`Module "${root.name}" declares param${rootParamKeys.length > 1 ? "s" : ""} ${names} but is being deployed as the root — a root has no enclosing scope to bind them; the root binds params directly on each provision() call, it does not declare param-forwarding slots of its own.`);
1076
- }
1480
+ if (opts?.configuration !== void 0 && opts.appConfigurationRead !== void 0) throw new LoadError("Load takes configuration, in the first process, or appConfigurationRead, in the second, not both.");
1481
+ const moduleInputs = [];
1482
+ if (root.inputSchema !== void 0) if (opts?.appConfigurationRead !== void 0) moduleInputs.push({
1483
+ moduleAddress: rootId,
1484
+ schema: root.inputSchema,
1485
+ binding: void 0,
1486
+ isRoot: true,
1487
+ checked: opts.appConfigurationRead.rootInput
1488
+ });
1489
+ else if (opts?.configuration !== void 0) moduleInputs.push({
1490
+ moduleAddress: rootId,
1491
+ schema: root.inputSchema,
1492
+ binding: opts.configuration,
1493
+ isRoot: true
1494
+ });
1495
+ else throw new LoadError(`Module "${root.name}" declares input and is being deployed as the root, but Load was given no app configuration to fill it from. Pass { configuration } to Load; prisma deploy and prisma dev pass the values the \`config\` adapters return.`);
1077
1496
  const nodes = [];
1078
1497
  const edges = [];
1079
1498
  const pending = [];
@@ -1084,7 +1503,7 @@ function loadModule(root, opts) {
1084
1503
  const authoredEdges = [];
1085
1504
  const loading = { sealed: false };
1086
1505
  try {
1087
- flatten(root, rootId, {}, {}, {}, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading);
1506
+ flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
1088
1507
  for (const entry of pending) validateWiring(entry, byId);
1089
1508
  assertDependencyDag(edges);
1090
1509
  } finally {
@@ -1094,8 +1513,11 @@ function loadModule(root, opts) {
1094
1513
  for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
1095
1514
  const resolved = resolveValues({
1096
1515
  environment: opts?.environment,
1516
+ configuration: opts?.configuration,
1517
+ appConfigurationRead: opts?.appConfigurationRead,
1097
1518
  inputBindings,
1098
1519
  params: paramBindings,
1520
+ moduleInputs,
1099
1521
  resources
1100
1522
  });
1101
1523
  const resolvedNodes = nodes.map((entry) => {
@@ -1118,7 +1540,9 @@ function loadModule(root, opts) {
1118
1540
  ports,
1119
1541
  authoredEdges,
1120
1542
  inputBindings: resolved.inputBindings,
1121
- params: resolved.params
1543
+ params: resolved.params,
1544
+ secretSources: resolved.secretSources,
1545
+ appConfigurationRead: resolved.appConfigurationRead
1122
1546
  };
1123
1547
  }
1124
1548
  /**
@@ -1190,7 +1614,21 @@ function Load(root, opts) {
1190
1614
  if (root.kind === "service") return loadService(root, opts?.id ?? "root");
1191
1615
  throw new LoadError("Load expects a service or module root (received another node kind).");
1192
1616
  }
1617
+ /** The app secrets key of every secret source the graph names, once each, in the order Load met them. A source built without a `secretsKey` is left out. */
1618
+ function secretsKeys(graph) {
1619
+ const keys = /* @__PURE__ */ new Set();
1620
+ for (const { source } of graph.secretSources) {
1621
+ const origin = sourceOriginOf(source);
1622
+ const key = origin?.sourceKind === "secret" ? origin.secretsKey : void 0;
1623
+ if (key !== void 0) keys.add(key);
1624
+ }
1625
+ return [...keys];
1626
+ }
1627
+ /** The address of every node in the graph, sorted. Two Loads of the same graph give the same list. */
1628
+ function nodeAddresses(graph) {
1629
+ return graph.nodes.map(({ id }) => id).sort();
1630
+ }
1193
1631
  //#endregion
1194
- export { slotsOf as S, resolve as _, assertAppName as a, secretSource as b, isNode as c, isSecretSource as d, isValue as f, provisionNeed as g, paramSource as h, ResourceNodeBase as i, isParamSource as l, paramNeed as m, LoadError as n, dependency as o, module as p, RESOURCE_OUT_PORT as r, freezeNode as s, Load as t, isProvisionNeed as u, resource as v, service as x, secret as y };
1632
+ export { slotsOf as S, resolve as _, assertAppName as a, secretsKeys as b, isNode as c, isSecretSource as d, isValue as f, provisionNeed as g, paramSource as h, ResourceNodeBase as i, isParamSource as l, nodeAddresses as m, LoadError as n, dependency as o, module as p, RESOURCE_OUT_PORT as r, freezeNode as s, Load as t, isProvisionNeed as u, resource as v, service as x, secretSource as y };
1195
1633
 
1196
- //# sourceMappingURL=graph-MGOZJdDt-CyI8-9r7.mjs.map
1634
+ //# sourceMappingURL=graph-Bqr7PSGl-BM-M-TlO.mjs.map