@prisma/composer 0.36.0 → 0.37.0-dev.2

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-lMqqcFA1-DacpRpC4.d.mts} +48 -8
  2. package/dist/app-config-lMqqcFA1-DacpRpC4.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-Bpbj7Riz.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-DergV8De.mjs +375 -0
  20. package/dist/deploy-DergV8De.mjs.map +1 -0
  21. package/dist/deploy-Dh_I6YLS.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-Bqd0Uf4H.d.mts} +3 -3
  27. package/dist/{deployment-summary-p88NV5m5-SaPCCX2C.d.mts.map → deployment-summary-p88NV5m5-Bqd0Uf4H.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-D-Qb6Yem-Cvy2dWhe.mjs} +5 -5
  31. package/dist/{dev-current-Brb4qugP-CG0_96FZ.mjs.map → dev-current-D-Qb6Yem-Cvy2dWhe.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-NyTyCEnG.mjs} +11 -4
  37. package/dist/dist-NyTyCEnG.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-C6EsdmLz-BO5xEJsJ.mjs} +60 -29
  40. package/dist/execute-deploy-destroy-C6EsdmLz-BO5xEJsJ.mjs.map +1 -0
  41. package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs → execute-dev-current-tBKmDAjV-0LnPjGGi.mjs} +6 -6
  42. package/dist/{execute-dev-current-BdEqeKAB-BLUs2eQv.mjs.map → execute-dev-current-tBKmDAjV-0LnPjGGi.mjs.map} +1 -1
  43. package/dist/{execute-dev-BUk-XWBJ-ZHX5A8cR.mjs → execute-dev-gjIKYybU-BMpgGLtS.mjs} +99 -44
  44. package/dist/execute-dev-gjIKYybU-BMpgGLtS.mjs.map +1 -0
  45. package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs → execute-log-c0_dL_Bv-Dq1glmTO.mjs} +6 -6
  46. package/dist/{execute-log-aiHhujIh-C_aXmb6j.mjs.map → execute-log-c0_dL_Bv-Dq1glmTO.mjs.map} +1 -1
  47. package/dist/{graph-MGOZJdDt-CyI8-9r7.mjs → graph-CBt9CRBT-yMupsISb.mjs} +681 -214
  48. package/dist/graph-CBt9CRBT-yMupsISb.mjs.map +1 -0
  49. package/dist/{graph-BzTSXnoQ-BvGVq0bm.d.mts → graph-D1zpgcLm-YlrEdzUB.d.mts} +9 -5
  50. package/dist/graph-D1zpgcLm-YlrEdzUB.d.mts.map +1 -0
  51. package/dist/{graph-types-DfsG9Rkg-D_ARjMo7.d.mts → graph-types-BiFZrE06-D6vaGxXz.d.mts} +287 -122
  52. package/dist/graph-types-BiFZrE06-D6vaGxXz.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-CMklpG87.d.mts} +3 -3
  56. package/dist/index-CMklpG87.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-RqgYxqhI.d.mts} +3 -3
  68. package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts.map → nextjs-DLyeRR7M-RqgYxqhI.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-pjMN5nIB.d.mts +183 -0
  78. package/dist/redaction-Bf8FvTFH-pjMN5nIB.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-CpQLC3CA-COmDdusV.mjs} +124 -21
  93. package/dist/validate-environment-CpQLC3CA-COmDdusV.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 +54 -29
  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-CBt9CRBT.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
- });
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"));
83
184
  }
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
- });
90
- }
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);
116
234
  }
117
- /** True if `value` is a param source (an `envParam` result or a forwarded ctx.params ref). */
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);
257
+ }
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
  }
@@ -162,7 +302,7 @@ function requireConfigKeySegmentNames(names, kind, factory) {
162
302
  function freezeParams(params) {
163
303
  const frozen = {};
164
304
  for (const [name, param] of Object.entries(params)) frozen[name] = Object.freeze({ ...param });
165
- return Object.freeze(frozen);
305
+ return blindCast(Object.freeze(frozen));
166
306
  }
167
307
  /** A frozen shallow copy that keeps the caller's declared type. */
168
308
  function frozenShallowCopy(obj) {
@@ -292,7 +432,7 @@ function dependency(def) {
292
432
  kind: "dependency",
293
433
  name: def.name !== void 0 && def.name.length > 0 ? def.name : def.type,
294
434
  type: def.type,
295
- connection,
435
+ connection: blindCast(connection),
296
436
  required: def.required
297
437
  });
298
438
  }
@@ -302,27 +442,58 @@ function dependency(def) {
302
442
  */
303
443
  function module(name, boundaryOrBody, maybeBody) {
304
444
  requireName(name, "module");
305
- const closedRoot = typeof boundaryOrBody === "function";
306
- const boundary = closedRoot ? {} : boundaryOrBody;
445
+ if (typeof boundaryOrBody === "function") return buildModuleNode(false, name, {}, (ctx) => {
446
+ boundaryOrBody({
447
+ ...ctx,
448
+ input: void 0
449
+ });
450
+ return {};
451
+ });
452
+ return buildModuleNode(false, name, boundaryOrBody, requireBody("module", name, maybeBody));
453
+ }
454
+ function appRoot(name, optionsOrBody, maybeBody) {
455
+ requireName(name, "appRoot");
456
+ if (typeof optionsOrBody === "function") return buildModuleNode(true, name, {}, ({ environment, provision }) => {
457
+ optionsOrBody({
458
+ input: void 0,
459
+ environment,
460
+ provision
461
+ });
462
+ return {};
463
+ });
464
+ const body = requireBody("appRoot", name, maybeBody);
465
+ if (Object.hasOwn(optionsOrBody, "deps")) throw new Error(`appRoot("${name}") declares \`deps\`, which an app root cannot have: nothing provisions the root, so nothing can wire a dependency into it. Provision the resource inside the root's body instead.`);
466
+ if (Object.hasOwn(optionsOrBody, "expose")) throw new Error(`appRoot("${name}") declares \`expose\`, which an app root cannot have: nothing provisions the root, so nothing can consume what it exposes.`);
467
+ return buildModuleNode(true, name, optionsOrBody, ({ input, environment, provision }) => {
468
+ body({
469
+ input,
470
+ environment,
471
+ provision
472
+ });
473
+ return {};
474
+ });
475
+ }
476
+ function requireBody(factory, name, body) {
477
+ if (typeof body !== "function") throw new Error(`${factory}("${name}") requires a body function.`);
478
+ return body;
479
+ }
480
+ /** Constructs a branded, frozen module node for `module()` and `appRoot()`. Construction is inert: the body is wiring, and runs only when the module is Loaded. */
481
+ function buildModuleNode(root, name, boundary, body) {
482
+ const factory = root ? "appRoot" : "module";
483
+ if (Object.hasOwn(boundary, "params")) throw new Error(`${factory}("${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).`);
484
+ if (Object.hasOwn(boundary, "secrets")) throw new Error(`${factory}("${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
485
  requireNotReservedPortNames(Object.keys(boundary.deps ?? {}), "module");
308
486
  requireNotReservedPortNames(Object.keys(boundary.expose ?? {}), "module");
309
- const deps = frozenShallowCopy(boundary.deps ?? {});
310
- const secretSlots = frozenShallowCopy(boundary.secrets ?? {});
311
- const paramSlots = frozenShallowCopy(boundary.params ?? {});
312
- const expose = frozenShallowCopy(boundary.expose ?? {});
313
- const body = closedRoot ? (ctx) => {
314
- boundaryOrBody(ctx);
315
- return {};
316
- } : maybeBody;
487
+ if (boundary.input !== void 0 && typeof boundary.input["~standard"]?.validate !== "function") throw new Error(`${factory}() \`input\` must be a Standard Schema (an object with a "~standard".validate function) — see https://standardschema.dev (ADR-0061).`);
317
488
  return Object.freeze({
318
489
  [NODE]: true,
319
490
  kind: "module",
320
491
  name,
321
- deps,
322
- secretSlots,
323
- paramSlots,
324
- expose,
325
- body
492
+ deps: frozenShallowCopy(boundary.deps ?? {}),
493
+ inputSchema: boundary.input,
494
+ expose: frozenShallowCopy(boundary.expose ?? {}),
495
+ body,
496
+ isRoot: () => root
326
497
  });
327
498
  }
328
499
  /**
@@ -331,7 +502,7 @@ function module(name, boundaryOrBody, maybeBody) {
331
502
  * installed copy of core (dual-package hazard).
332
503
  */
333
504
  function isNode(value) {
334
- return typeof value === "object" && value !== null && value[NODE] === true;
505
+ return typeof value === "object" && value !== null && blindCast(value)[NODE] === true;
335
506
  }
336
507
  /** A node's dependency slots. A resource node built by another installed copy of core may have no `inputs`; that means none. */
337
508
  function slotsOf(node) {
@@ -464,7 +635,12 @@ function loadService(root, rootId) {
464
635
  ports: boundaryPortsOf(rootId, root),
465
636
  authoredEdges: [],
466
637
  inputBindings: [],
467
- params: []
638
+ params: [],
639
+ secretSources: [],
640
+ appConfigurationRead: {
641
+ rootInput: [],
642
+ configurationKeyText: {}
643
+ }
468
644
  };
469
645
  }
470
646
  function joinPath(path, key) {
@@ -472,12 +648,22 @@ function joinPath(path, key) {
472
648
  }
473
649
  function describeSite(site) {
474
650
  switch (site.kind) {
475
- case "input": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
651
+ case "serviceInput": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
652
+ case "moduleInput": return site.path === "" ? `the input binding of module "${site.address}"` : `input key "${site.path}" of module "${site.address}"`;
476
653
  case "param": return `param "${site.path}" of service "${site.address}"`;
477
654
  case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
478
655
  }
479
656
  }
480
- function collect(value, site, found, seen) {
657
+ function collect(value, site, found, seen, recordSecret) {
658
+ if (isSecretSource(value) || isParamSource(value)) {
659
+ if (isSecretSource(value) && site.kind !== "props") recordSecret(value, site);
660
+ if (site.kind === "serviceInput" || site.kind === "param" || !isValue(value)) return;
661
+ found.push({
662
+ value,
663
+ site
664
+ });
665
+ return;
666
+ }
481
667
  if (isValue(value)) {
482
668
  found.push({
483
669
  value,
@@ -485,7 +671,6 @@ function collect(value, site, found, seen) {
485
671
  });
486
672
  return;
487
673
  }
488
- if (isSecretSource(value) || isParamSource(value)) return;
489
674
  if (!Array.isArray(value) && !isPlainObject(value)) return;
490
675
  if (seen.has(value)) return;
491
676
  seen.add(value);
@@ -495,7 +680,7 @@ function collect(value, site, found, seen) {
495
680
  collect(member, {
496
681
  ...site,
497
682
  path
498
- }, found, seen);
683
+ }, found, seen, recordSecret);
499
684
  }
500
685
  }
501
686
  function describeNotPlain(value) {
@@ -508,17 +693,69 @@ function describeNotPlain(value) {
508
693
  default: return;
509
694
  }
510
695
  }
696
+ /** 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. */
697
+ function jsonInexactKind(value) {
698
+ if (value === null || typeof value === "string" || typeof value === "boolean") return void 0;
699
+ if (typeof value === "number") return Number.isFinite(value) ? void 0 : "a non-finite number";
700
+ if (Array.isArray(value)) {
701
+ for (const member of value) {
702
+ if (member === void 0) return "an array with a missing member";
703
+ const kind = jsonInexactKind(member);
704
+ if (kind !== void 0) return kind;
705
+ }
706
+ return;
707
+ }
708
+ if (isPlainObject(value)) {
709
+ for (const member of Object.values(value)) {
710
+ if (member === void 0) continue;
711
+ const kind = jsonInexactKind(member);
712
+ if (kind !== void 0) return kind;
713
+ }
714
+ return;
715
+ }
716
+ return describeNotPlain(value) ?? describeKind(value);
717
+ }
718
+ 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
719
  function isThenable(value) {
720
+ if (isValue(value)) return false;
512
721
  return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
513
722
  }
723
+ function canonicalSecret(source) {
724
+ const original = sourceOriginOf(source)?.source;
725
+ return isSecretSource(original) ? original : source;
726
+ }
727
+ function nodeKindOf(site) {
728
+ switch (site.kind) {
729
+ case "serviceInput":
730
+ case "param": return "service";
731
+ case "moduleInput": return "module";
732
+ case "props": return "resource";
733
+ }
734
+ }
735
+ function pointersIn(values) {
736
+ const pointers = /* @__PURE__ */ new Set();
737
+ const seen = /* @__PURE__ */ new WeakSet();
738
+ const walk = (value) => {
739
+ if (isSecretSource(value) || isParamSource(value)) {
740
+ pointers.add(value);
741
+ return;
742
+ }
743
+ if (!Array.isArray(value) && !isPlainObject(value)) return;
744
+ if (seen.has(value)) return;
745
+ seen.add(value);
746
+ for (const member of Array.isArray(value) ? value : Object.values(value)) walk(member);
747
+ };
748
+ walk(values);
749
+ return pointers;
750
+ }
514
751
  function checkResult(result, fnLabel) {
515
752
  if (isThenable(result)) throw new LoadError(`${fnLabel} returned a Promise. resolve() runs synchronously at Load.`);
516
753
  const seen = /* @__PURE__ */ new WeakSet();
517
754
  const walk = (value, path) => {
518
755
  const atPath = path === "" ? "" : ` at "${path}"`;
519
756
  if (value === void 0) throw new LoadError(`${fnLabel} returned undefined${atPath}. Return a result for every environment; Composer never picks a default.`);
757
+ 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
758
  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
759
  const notPlain = describeNotPlain(value);
523
760
  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
761
  if (typeof value !== "object" || value === null || seen.has(value)) return;
@@ -528,13 +765,42 @@ function checkResult(result, fnLabel) {
528
765
  };
529
766
  walk(result, "");
530
767
  }
531
- function substitute(value, results, inProgress) {
768
+ /** The first pointer in `value`, at any depth through arrays and plain objects, with its key path; `undefined` when there is none. */
769
+ function firstPointer(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
770
+ if (isSecretSource(value) || isParamSource(value)) return {
771
+ pointer: value,
772
+ path
773
+ };
774
+ if (!Array.isArray(value) && !isPlainObject(value)) return void 0;
775
+ if (seen.has(value)) return void 0;
776
+ seen.add(value);
777
+ const entries = Array.isArray(value) ? value.map((member, index) => [String(index), member]) : Object.entries(value);
778
+ for (const [key, member] of entries) {
779
+ const found = firstPointer(member, [...path, key], seen);
780
+ if (found !== void 0) return found;
781
+ }
782
+ }
783
+ /** Refuses a resolve() dependency whose real value is a pointer or holds one at any depth: `fn` computes with deploy-time data only. */
784
+ function refusePointerDependency(fnLabel, dependency, real) {
785
+ const found = firstPointer(real);
786
+ if (found === void 0) return;
787
+ const label = sourceOriginOf(found.pointer)?.label ?? "a value known only at boot";
788
+ const origin = originOf(dependency);
789
+ 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.`);
790
+ const listed = `${inputFieldLabel(origin)} of module "${origin.module}"`;
791
+ const field = inputFieldLabel({
792
+ ...origin,
793
+ path: [...origin.path, ...found.path]
794
+ });
795
+ 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.`}`);
796
+ }
797
+ function substitute(value, results, inProgress, sources) {
798
+ if (isSecretSource(value) || isParamSource(value)) return sources === "keep" || !isValue(value) ? value : results.get(value);
532
799
  if (isValue(value)) return results.get(value);
533
- if (isSecretSource(value) || isParamSource(value)) return value;
534
800
  if (Array.isArray(value)) {
535
801
  if (inProgress.has(value)) return value;
536
802
  inProgress.add(value);
537
- const rebuilt = value.map((member) => substitute(member, results, inProgress));
803
+ const rebuilt = value.map((member) => substitute(member, results, inProgress, sources));
538
804
  inProgress.delete(value);
539
805
  return rebuilt.every((member, index) => member === value[index]) ? value : rebuilt;
540
806
  }
@@ -544,39 +810,181 @@ function substitute(value, results, inProgress) {
544
810
  const rebuilt = {};
545
811
  let changed = false;
546
812
  for (const [key, member] of Object.entries(value)) {
547
- rebuilt[key] = substitute(member, results, inProgress);
548
- if (rebuilt[key] !== member) changed = true;
813
+ const real = substitute(member, results, inProgress, sources);
814
+ if (real === void 0 && isValue(member)) {
815
+ changed = true;
816
+ continue;
817
+ }
818
+ rebuilt[key] = real;
819
+ if (real !== member) changed = true;
549
820
  }
550
821
  inProgress.delete(value);
551
822
  return changed ? rebuilt : value;
552
823
  }
553
824
  return value;
554
825
  }
826
+ function describeData(value) {
827
+ if (Array.isArray(value)) return "an array";
828
+ if (typeof value === "object") return "an object that is not plain data";
829
+ return `a ${typeof value}`;
830
+ }
831
+ /** The data at `origin`'s path inside a validated input; `undefined` where a key or a parent is absent. */
832
+ function readPath(data, origin) {
833
+ let current = data;
834
+ for (const [index, key] of origin.path.entries()) {
835
+ if (current === void 0 || current === null) return void 0;
836
+ const missing = `${inputFieldLabel(origin)} of module "${origin.module}" does not exist`;
837
+ const parent = inputFieldLabel({
838
+ ...origin,
839
+ path: origin.path.slice(0, index)
840
+ });
841
+ const schemaAdvice = `The module's input schema must output a plain object for its body to read fields.`;
842
+ 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."));
843
+ if (!isPlainObject(current)) {
844
+ 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]) => …).`;
845
+ throw new LoadError(`${missing}: ${parent} is ${describeData(current)}, not a plain object, so it has no fields. ${advice}`);
846
+ }
847
+ if (!Object.hasOwn(current, key)) return void 0;
848
+ current = current[key];
849
+ }
850
+ return current;
851
+ }
852
+ function refuseSecretBoxes(address, value, path) {
853
+ if (isSecretSource(value) || isParamSource(value)) return;
854
+ if (isSecretString(value)) throw new LoadError(`${describeSite({
855
+ address,
856
+ kind: "moduleInput",
857
+ path
858
+ })} 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().`);
859
+ if (Array.isArray(value)) {
860
+ for (const [index, member] of value.entries()) refuseSecretBoxes(address, member, joinPath(path, index));
861
+ return;
862
+ }
863
+ if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) refuseSecretBoxes(address, member, joinPath(path, key));
864
+ }
865
+ /** The original source each runtime value in `value` names, by its path. */
866
+ function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map()) {
867
+ if (isSecretSource(value) || isParamSource(value)) found.set(path, sourceOriginOf(value)?.source ?? value);
868
+ else if (Array.isArray(value)) for (const [index, member] of value.entries()) sourcesByPath(member, joinPath(path, index), found);
869
+ else if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) sourcesByPath(member, joinPath(path, key), found);
870
+ return found;
871
+ }
872
+ function validateModuleInput(entry, resolved, environment) {
873
+ const address = entry.moduleAddress;
874
+ refuseSecretBoxes(address, resolved, "");
875
+ const result = entry.schema["~standard"].validate(resolved);
876
+ 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.`);
877
+ if (result.issues !== void 0) {
878
+ const messages = result.issues.map((issue) => issue.message).join("; ");
879
+ if (entry.isLoadRoot) 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}"`}.`);
880
+ throw new LoadError(`The input binding of module "${address}" does not match the module's input schema: ${messages}`);
881
+ }
882
+ const bound = sourcesByPath(resolved);
883
+ const onlyChecked = "Its value is known only at boot, so a module's schema may check the field but never replace or move it.";
884
+ const restore = (value, path) => {
885
+ const expected = bound.get(path);
886
+ if (isSecretSource(value) || isParamSource(value)) {
887
+ const source = sourceOriginOf(value)?.source ?? value;
888
+ if (source !== expected) throw new LoadError(`The input schema of module "${address}" moved ${sourceOriginOf(source)?.label} to input key "${path}". ${onlyChecked}`);
889
+ return source;
890
+ }
891
+ 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}`);
892
+ if (isSecretString(value)) {
893
+ const atPath = path === "" ? "" : ` at "${path}"`;
894
+ 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.`);
895
+ }
896
+ if (Array.isArray(value)) return value.map((member, index) => restore(member, joinPath(path, index)));
897
+ if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, restore(member, joinPath(path, key))]));
898
+ return value;
899
+ };
900
+ return restore(result.value, "");
901
+ }
902
+ function refusePointersInProps(address, props) {
903
+ const seen = /* @__PURE__ */ new WeakSet();
904
+ const walk = (value, path) => {
905
+ if (isSecretSource(value) || isParamSource(value)) {
906
+ const label = sourceOriginOf(value)?.label ?? (isSecretSource(value) ? "a secret source" : "a param source");
907
+ throw new LoadError(`${describeSite({
908
+ address,
909
+ kind: "props",
910
+ path
911
+ })} is bound to ${label}, which is known only at boot. A resource's props are read at deploy; bind a value known at deploy.`);
912
+ }
913
+ if (!Array.isArray(value) && !isPlainObject(value)) return;
914
+ if (seen.has(value)) return;
915
+ seen.add(value);
916
+ const entries = Array.isArray(value) ? value.map((member, index) => [index, member]) : Object.entries(value);
917
+ for (const [key, member] of entries) walk(member, joinPath(path, key));
918
+ };
919
+ walk(props, "");
920
+ }
555
921
  /**
556
922
  * Resolves every value the graph binds, dependency-first, once each, and
557
923
  * returns each binding with its values replaced by their real values.
558
924
  */
559
925
  function resolveValues(input) {
560
926
  const { environment } = input;
927
+ const rootFields = /* @__PURE__ */ new Map();
928
+ const keysRead = /* @__PURE__ */ new Map();
929
+ /** The text the app configuration holds for `key`, recorded; `undefined` when it holds none or `''`. */
930
+ const configurationText = (key, label, site) => {
931
+ let raw;
932
+ if (input.appConfigurationRead !== void 0) raw = input.appConfigurationRead.configurationKeyText[key];
933
+ else if (input.configuration !== void 0) raw = input.configuration[key];
934
+ 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.`);
935
+ 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.`);
936
+ const text = raw === void 0 || raw === "" ? void 0 : raw;
937
+ keysRead.set(key, {
938
+ label,
939
+ text
940
+ });
941
+ return text;
942
+ };
943
+ const secretUses = /* @__PURE__ */ new Map();
944
+ const recordSecret = (source, site) => {
945
+ const canonical = canonicalSecret(source);
946
+ if (secretUses.has(canonical)) return;
947
+ secretUses.set(canonical, {
948
+ source: canonical,
949
+ address: site.address,
950
+ nodeKind: nodeKindOf(site)
951
+ });
952
+ };
953
+ const secretSourcesReceivedBy = (inputBindings, params) => {
954
+ for (const { serviceAddress, binding } of [...inputBindings, ...params]) for (const pointer of pointersIn(binding)) {
955
+ if (!isSecretSource(pointer)) continue;
956
+ const canonical = canonicalSecret(pointer);
957
+ if (secretUses.get(canonical)?.nodeKind === "service") continue;
958
+ secretUses.set(canonical, {
959
+ source: canonical,
960
+ address: serviceAddress,
961
+ nodeKind: "service"
962
+ });
963
+ }
964
+ return [...secretUses.values()];
965
+ };
561
966
  const found = [];
562
967
  for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
563
968
  address: serviceAddress,
564
- kind: "input",
969
+ kind: "serviceInput",
565
970
  path: ""
566
- }, found, /* @__PURE__ */ new WeakSet());
971
+ }, found, /* @__PURE__ */ new WeakSet(), recordSecret);
567
972
  for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
568
973
  address: serviceAddress,
569
974
  kind: "param",
570
975
  path: slot
571
- }, found, /* @__PURE__ */ new WeakSet());
976
+ }, found, /* @__PURE__ */ new WeakSet(), recordSecret);
572
977
  for (const [address, resource] of input.resources) {
573
978
  const site = {
574
979
  address,
575
980
  kind: "props",
576
981
  path: ""
577
982
  };
578
- collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
983
+ collect(resource.props, site, found, /* @__PURE__ */ new WeakSet(), recordSecret);
579
984
  }
985
+ const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
986
+ const validatedInputs = /* @__PURE__ */ new Map();
987
+ const validating = /* @__PURE__ */ new Set();
580
988
  const results = /* @__PURE__ */ new Map();
581
989
  const visiting = [];
582
990
  const fnLabelFor = (site) => visiting.length === 1 ? `The resolve() function for ${describeSite(site)}` : `A resolve() function that ${describeSite(site)} depends on`;
@@ -591,52 +999,168 @@ function resolveValues(input) {
591
999
  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
1000
  result = environment[origin.fact];
593
1001
  break;
1002
+ case "source":
1003
+ if (isSecretSource(origin.source)) recordSecret(origin.source, site);
1004
+ if (origin.sourceKind === "secret" || origin.configurationKey === void 0) result = origin.source;
1005
+ else result = configurationText(origin.configurationKey, origin.label, site);
1006
+ break;
594
1007
  case "computed": {
595
- const args = origin.dependencies.map((dependency) => resolveOne(dependency, site));
1008
+ const args = origin.dependencies.map((dependency) => {
1009
+ const real = resolveOne(dependency, site);
1010
+ const source = originOf(dependency);
1011
+ 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.`);
1012
+ refusePointerDependency(fnLabelFor(site), dependency, real);
1013
+ return real;
1014
+ });
596
1015
  try {
597
1016
  result = origin.compute(args);
598
1017
  } catch (thrown) {
599
- if (thrown instanceof LoadError) throw thrown;
1018
+ if (thrown instanceof LoadError && !isSourceMisuse(thrown)) throw thrown;
600
1019
  const message = thrown instanceof Error ? thrown.message : String(thrown);
601
1020
  throw new LoadError(`${fnLabelFor(site)} threw: ${message}`, { cause: thrown });
602
1021
  }
603
1022
  checkResult(result, fnLabelFor(site));
604
1023
  break;
605
1024
  }
1025
+ case "input": {
1026
+ const entry = moduleInputByAddress.get(origin.module);
1027
+ 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.`);
1028
+ if (origin.path.length === 0) {
1029
+ const everyVariable = entry.isLoadRoot ? " The root's input is every value the `config` adapters return, which by default is every variable of the process environment, secrets included." : "";
1030
+ 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.`);
1031
+ }
1032
+ if (entry.checked !== void 0) {
1033
+ const field = entry.checked.find((candidate) => candidate.path.join("\0") === origin.path.join("\0"));
1034
+ 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}`);
1035
+ result = field.value;
1036
+ } else {
1037
+ result = readPath(validatedInputOf(entry), origin);
1038
+ if (entry.isLoadRoot) rootFields.set(origin.path.join("\0"), result === void 0 ? { path: origin.path } : {
1039
+ path: origin.path,
1040
+ value: result
1041
+ });
1042
+ }
1043
+ break;
1044
+ }
606
1045
  }
607
1046
  visiting.pop();
608
1047
  results.set(value, result);
609
1048
  return result;
610
1049
  };
1050
+ const validatedInputOf = (entry) => {
1051
+ if (entry.checked !== void 0) return void 0;
1052
+ if (validatedInputs.has(entry.moduleAddress)) return validatedInputs.get(entry.moduleAddress);
1053
+ 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.`);
1054
+ validating.add(entry.moduleAddress);
1055
+ const site = {
1056
+ address: entry.moduleAddress,
1057
+ kind: "moduleInput",
1058
+ path: ""
1059
+ };
1060
+ const values = [];
1061
+ collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet(), recordSecret);
1062
+ for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
1063
+ const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet(), "resolve"), environment);
1064
+ validating.delete(entry.moduleAddress);
1065
+ validatedInputs.set(entry.moduleAddress, validated);
1066
+ return validated;
1067
+ };
1068
+ const rootModuleAddress = () => input.moduleInputs.find((entry) => entry.isLoadRoot)?.moduleAddress ?? "";
1069
+ const appConfigurationReadOf = (inputBindings, params, secretSources) => {
1070
+ if (input.configuration !== void 0 || input.appConfigurationRead !== void 0) {
1071
+ const kept = [...inputBindings.map(({ serviceAddress, binding }) => ({
1072
+ binding,
1073
+ site: {
1074
+ address: serviceAddress,
1075
+ kind: "serviceInput",
1076
+ path: ""
1077
+ }
1078
+ })), ...params.map(({ serviceAddress, slot, binding }) => ({
1079
+ binding,
1080
+ site: {
1081
+ address: serviceAddress,
1082
+ kind: "param",
1083
+ path: slot
1084
+ }
1085
+ }))];
1086
+ for (const { binding, site } of kept) for (const pointer of pointersIn(binding)) {
1087
+ if (!isParamSource(pointer)) continue;
1088
+ const origin = sourceOriginOf(pointer);
1089
+ if (origin?.sourceKind === "param" && origin.configurationKey !== void 0) configurationText(origin.configurationKey, origin.label, site);
1090
+ }
1091
+ }
1092
+ for (const use of secretSources) {
1093
+ const origin = sourceOriginOf(use.source);
1094
+ if (origin?.sourceKind !== "secret") continue;
1095
+ const key = origin.secretsKey;
1096
+ const read = key === void 0 ? void 0 : keysRead.get(key);
1097
+ 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.`);
1098
+ const field = [...rootFields.values()].find((candidate) => candidate.path[0] === key);
1099
+ if (key !== void 0 && field !== void 0) throw new LoadError(`${inputFieldLabel({
1100
+ kind: "input",
1101
+ module: rootModuleAddress(),
1102
+ path: field.path
1103
+ })} 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.`);
1104
+ }
1105
+ for (const field of rootFields.values()) {
1106
+ const kind = "value" in field ? jsonInexactKind(field.value) : void 0;
1107
+ if (kind !== void 0) throw new LoadError(`${inputFieldLabel({
1108
+ kind: "input",
1109
+ module: rootModuleAddress(),
1110
+ path: field.path
1111
+ })} 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.`);
1112
+ }
1113
+ const configurationKeyText = {};
1114
+ for (const [key, { text }] of keysRead) if (text !== void 0) configurationKeyText[key] = text;
1115
+ return {
1116
+ rootInput: [...rootFields.values()],
1117
+ configurationKeyText
1118
+ };
1119
+ };
1120
+ for (const entry of input.moduleInputs) validatedInputOf(entry);
611
1121
  for (const { value, site } of found) resolveOne(value, site);
612
1122
  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
- };
1123
+ if (found.length === 0) {
1124
+ for (const [address, props] of authoredProps) refusePointersInProps(address, props);
1125
+ const secretSources = secretSourcesReceivedBy(input.inputBindings, input.params);
1126
+ return {
1127
+ inputBindings: input.inputBindings,
1128
+ params: input.params,
1129
+ resourceProps: authoredProps,
1130
+ secretSources,
1131
+ appConfigurationRead: appConfigurationReadOf(input.inputBindings, input.params, secretSources)
1132
+ };
1133
+ }
618
1134
  const inProgress = /* @__PURE__ */ new WeakSet();
619
1135
  const resourceProps = /* @__PURE__ */ new Map();
620
1136
  for (const [address, props] of authoredProps) {
621
- const substituted = substitute(props, results, inProgress);
622
- resourceProps.set(address, substituted === props ? props : blindCast(substituted));
1137
+ const substituted = substitute(props, results, inProgress, "resolve");
1138
+ refusePointersInProps(address, substituted);
1139
+ const resolvedProps = substituted === props ? props : blindCast(substituted);
1140
+ resourceProps.set(address, resolvedProps);
623
1141
  }
1142
+ const inputBindings = input.inputBindings.map((entry) => {
1143
+ const binding = substitute(entry.binding, results, inProgress, "keep");
1144
+ return binding === entry.binding ? entry : {
1145
+ serviceAddress: entry.serviceAddress,
1146
+ binding: blindCast(binding)
1147
+ };
1148
+ });
1149
+ const params = input.params.flatMap((entry) => {
1150
+ const binding = substitute(entry.binding, results, inProgress, "keep");
1151
+ if (binding === void 0 && isValue(entry.binding)) return [];
1152
+ return [binding === entry.binding ? entry : {
1153
+ ...entry,
1154
+ binding
1155
+ }];
1156
+ });
1157
+ const secretSources = secretSourcesReceivedBy(inputBindings, params);
624
1158
  return {
625
1159
  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
- })
1160
+ inputBindings,
1161
+ params,
1162
+ secretSources,
1163
+ appConfigurationRead: appConfigurationReadOf(inputBindings, params, secretSources)
640
1164
  };
641
1165
  }
642
1166
  /**
@@ -710,10 +1234,6 @@ function producerIdOf(ref) {
710
1234
  * identity the branding copy creates, never on reading this back.
711
1235
  */
712
1236
  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
1237
  /** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
718
1238
  function satisfiesRequired(ref, required) {
719
1239
  return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
@@ -747,25 +1267,6 @@ function validateWiring(pending, byId) {
747
1267
  if (value.kind === "dependency") throw new LoadError(`Dependency "${input}" of provisioned ${targetKind} "${targetId}" is not wired to a producer (module "${enclosingModuleName}").`);
748
1268
  }
749
1269
  }
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
1270
  /** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */
770
1271
  function wiringEdges(wiring, targetId) {
771
1272
  return Object.entries(wiring).map(([input, ref]) => ({
@@ -776,48 +1277,15 @@ function wiringEdges(wiring, targetId) {
776
1277
  }));
777
1278
  }
778
1279
  /**
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.
1280
+ * Checks the params wired into a provisioned SERVICE: a declared param is never
1281
+ * required to be bound here — it may fall back to its own `default` (checked
1282
+ * later, at `buildConfig`) — so this only rejects a wired key that names
1283
+ * something other than a real declared param.
801
1284
  */
802
1285
  function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName) {
803
1286
  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
1287
  }
805
1288
  /**
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
1289
  * Recursively flattens one module's body into the shared graph state and
822
1290
  * returns its resolved ModuleOutputs (one ref-port per expose key) for the
823
1291
  * caller (the enclosing provision() call, or Load itself for the root) to
@@ -835,12 +1303,10 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
835
1303
  * children carry it as their `parent`, and this module's own boundary ports
836
1304
  * (and the authored edges touching them) are recorded against it.
837
1305
  */
838
- function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading) {
1306
+ function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
839
1307
  ports.push(...boundaryPortsOf(selfId, moduleNode));
840
1308
  const localIds = /* @__PURE__ */ new Set();
841
1309
  const used = /* @__PURE__ */ new Set();
842
- const usedSecrets = /* @__PURE__ */ new Set();
843
- const usedParams = /* @__PURE__ */ new Set();
844
1310
  const ctxInputs = {};
845
1311
  for (const key of Object.keys(moduleNode.deps)) {
846
1312
  const wired = wiring[key];
@@ -879,28 +1345,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
879
1345
  });
880
1346
  }
881
1347
  };
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
1348
  const provision = (child, opts) => {
905
1349
  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
1350
  const id = opts?.id ?? child.name;
@@ -914,6 +1358,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
914
1358
  if (localIds.has(id)) throw new LoadError(`Duplicate provision id "${id}" in module "${moduleNode.name}".`);
915
1359
  const untrusted = child;
916
1360
  if (!isNode(untrusted) || untrusted.kind !== "service" && untrusted.kind !== "resource" && untrusted.kind !== "module") throw new LoadError(`provision("${id}") expects a branded service, resource, or module node (construct it with the service()/resource()/module() factories or a pack's own).`);
1361
+ if (untrusted.kind === "module" && typeof untrusted.isRoot === "function" && untrusted.isRoot()) throw new LoadError(`Module "${selfId}" provisions the app root "${untrusted.name}". An app root is the deploy's entry and cannot be provisioned. Build the module with module() instead.`);
917
1362
  localIds.add(id);
918
1363
  const fullAddress = `${selfId}.${id}`;
919
1364
  if (child.kind === "resource") {
@@ -954,24 +1399,15 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
954
1399
  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
1400
  const localWiring = { ...provisionWiring ?? {} };
956
1401
  markUsed(Object.values(localWiring));
957
- const localSecrets = { ...provisionSecrets ?? {} };
958
- markSecretsUsed(Object.values(localSecrets));
959
1402
  const localParams = { ...provisionParams ?? {} };
960
- markParamsUsed(Object.values(localParams));
961
1403
  if (child.kind === "service") {
962
1404
  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
1405
  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
1406
  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
- }
1407
+ if (provisionInput !== void 0) inputBindings.push({
1408
+ serviceAddress: fullAddress,
1409
+ binding: provisionInput
1410
+ });
975
1411
  validateServiceParamBinding(child, id, localParams, moduleNode.name);
976
1412
  for (const [slot, binding] of Object.entries(localParams)) paramBindings.push({
977
1413
  serviceAddress: fullAddress,
@@ -997,9 +1433,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
997
1433
  byId.set(fullAddress, child);
998
1434
  return refFor(fullAddress, child);
999
1435
  }
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);
1436
+ 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.`);
1437
+ 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.`);
1438
+ const childInputSchema = child.inputSchema;
1439
+ 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}").`);
1440
+ 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.`);
1441
+ if (childInputSchema !== void 0) moduleInputs.push({
1442
+ moduleAddress: fullAddress,
1443
+ schema: childInputSchema,
1444
+ binding: provisionInput,
1445
+ isLoadRoot: false
1446
+ });
1003
1447
  edges.push(...wiringEdges(localWiring, fullAddress));
1004
1448
  recordAuthoredWiring(fullAddress, localWiring);
1005
1449
  pending.push({
@@ -1009,7 +1453,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
1009
1453
  targetKind: "module",
1010
1454
  enclosingModuleName: moduleNode.name
1011
1455
  });
1012
- const childOutputs = flatten(child, fullAddress, localWiring, localSecrets, localParams, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading);
1456
+ const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
1013
1457
  nodes.push({
1014
1458
  id: fullAddress,
1015
1459
  parent: selfId,
@@ -1031,19 +1475,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
1031
1475
  };
1032
1476
  const ctx = blindCast({
1033
1477
  deps: ctxInputs,
1034
- secrets: ctxSecrets,
1035
- params: ctxParams,
1478
+ input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
1036
1479
  environment: environmentFacts,
1037
1480
  provision: blindCast(provision)
1038
1481
  });
1039
1482
  const outputs = blindCast(moduleNode.body(ctx) ?? {});
1040
1483
  markUsed(Object.values(outputs));
1041
1484
  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
1485
  for (const [key, contract] of Object.entries(moduleNode.expose)) {
1045
1486
  const port = outputs[key];
1046
1487
  if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
1488
+ 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
1489
  if (!satisfiesRequired(port, contract)) throw new LoadError(`Module "${moduleNode.name}"'s returned port for expose "${key}" does not satisfy its declared contract.`);
1048
1490
  const from = authoredSourceOf(port);
1049
1491
  if (from !== void 0) authoredEdges.push({
@@ -1064,16 +1506,22 @@ function loadModule(root, opts) {
1064
1506
  const names = rootDepKeys.map((k) => `"${k}"`).join(", ");
1065
1507
  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
1508
  }
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
- }
1509
+ 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.");
1510
+ const moduleInputs = [];
1511
+ if (root.inputSchema !== void 0) if (opts?.appConfigurationRead !== void 0) moduleInputs.push({
1512
+ moduleAddress: rootId,
1513
+ schema: root.inputSchema,
1514
+ binding: void 0,
1515
+ isLoadRoot: true,
1516
+ checked: opts.appConfigurationRead.rootInput
1517
+ });
1518
+ else if (opts?.configuration !== void 0) moduleInputs.push({
1519
+ moduleAddress: rootId,
1520
+ schema: root.inputSchema,
1521
+ binding: opts.configuration,
1522
+ isLoadRoot: true
1523
+ });
1524
+ 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
1525
  const nodes = [];
1078
1526
  const edges = [];
1079
1527
  const pending = [];
@@ -1084,7 +1532,7 @@ function loadModule(root, opts) {
1084
1532
  const authoredEdges = [];
1085
1533
  const loading = { sealed: false };
1086
1534
  try {
1087
- flatten(root, rootId, {}, {}, {}, nodes, edges, pending, inputBindings, paramBindings, byId, ports, authoredEdges, loading);
1535
+ flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
1088
1536
  for (const entry of pending) validateWiring(entry, byId);
1089
1537
  assertDependencyDag(edges);
1090
1538
  } finally {
@@ -1094,8 +1542,11 @@ function loadModule(root, opts) {
1094
1542
  for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
1095
1543
  const resolved = resolveValues({
1096
1544
  environment: opts?.environment,
1545
+ configuration: opts?.configuration,
1546
+ appConfigurationRead: opts?.appConfigurationRead,
1097
1547
  inputBindings,
1098
1548
  params: paramBindings,
1549
+ moduleInputs,
1099
1550
  resources
1100
1551
  });
1101
1552
  const resolvedNodes = nodes.map((entry) => {
@@ -1118,7 +1569,9 @@ function loadModule(root, opts) {
1118
1569
  ports,
1119
1570
  authoredEdges,
1120
1571
  inputBindings: resolved.inputBindings,
1121
- params: resolved.params
1572
+ params: resolved.params,
1573
+ secretSources: resolved.secretSources,
1574
+ appConfigurationRead: resolved.appConfigurationRead
1122
1575
  };
1123
1576
  }
1124
1577
  /**
@@ -1182,15 +1635,29 @@ function assertAppName(name) {
1182
1635
  * functions.
1183
1636
  */
1184
1637
  function Load(root, opts) {
1185
- if (!isNode(root)) throw new LoadError("Load expects a branded service or module node (construct it with the service()/module() factories).");
1638
+ if (!isNode(root)) throw new LoadError("Load expects a branded service, module or app root node (construct it with the service(), module() or appRoot() factories).");
1186
1639
  if (root.kind === "module") {
1187
1640
  assertAppName(opts?.id ?? root.name);
1188
1641
  return loadModule(root, opts);
1189
1642
  }
1190
1643
  if (root.kind === "service") return loadService(root, opts?.id ?? "root");
1191
- throw new LoadError("Load expects a service or module root (received another node kind).");
1644
+ throw new LoadError("Load expects a service, module or app root (received another node kind).");
1645
+ }
1646
+ /** 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. */
1647
+ function secretsKeys(graph) {
1648
+ const keys = /* @__PURE__ */ new Set();
1649
+ for (const { source } of graph.secretSources) {
1650
+ const origin = sourceOriginOf(source);
1651
+ const key = origin?.sourceKind === "secret" ? origin.secretsKey : void 0;
1652
+ if (key !== void 0) keys.add(key);
1653
+ }
1654
+ return [...keys];
1655
+ }
1656
+ /** The address of every node in the graph, sorted. Two Loads of the same graph give the same list. */
1657
+ function nodeAddresses(graph) {
1658
+ return graph.nodes.map(({ id }) => id).sort();
1192
1659
  }
1193
1660
  //#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 };
1661
+ export { slotsOf as C, service as S, provisionNeed as _, appRoot as a, secretSource as b, freezeNode as c, isProvisionNeed as d, isSecretSource as f, paramSource as g, nodeAddresses as h, ResourceNodeBase as i, isNode as l, module as m, LoadError as n, assertAppName as o, isValue as p, RESOURCE_OUT_PORT as r, dependency as s, Load as t, isParamSource as u, resolve as v, secretsKeys as x, resource as y };
1195
1662
 
1196
- //# sourceMappingURL=graph-MGOZJdDt-CyI8-9r7.mjs.map
1663
+ //# sourceMappingURL=graph-CBt9CRBT-yMupsISb.mjs.map