@prisma/composer-cli 0.36.0-dev.3 → 0.36.0-dev.4
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.
- package/dist/config-adapters-BA_IeiX0-CiRnz7z8.mjs +590 -0
- package/dist/config-adapters-BA_IeiX0-CiRnz7z8.mjs.map +1 -0
- package/dist/{dev-current-BNoPkDRU-DGd_7FDS.mjs → dev-current-BurA9uhA-BWYAftn9.mjs} +6 -6
- package/dist/{dev-current-BNoPkDRU-DGd_7FDS.mjs.map → dev-current-BurA9uhA-BWYAftn9.mjs.map} +1 -1
- package/dist/{dev-environment-name-6eEr5PW8-lIZmJjfr.mjs → dev-environment-name-6eEr5PW8-YyPDRApO.mjs} +2 -2
- package/dist/dev-environment-name-6eEr5PW8-YyPDRApO.mjs.map +1 -0
- package/dist/{dist-B9-nLeho.mjs → dist-BsONwZNR.mjs} +3 -6
- package/dist/{dist-B9-nLeho.mjs.map → dist-BsONwZNR.mjs.map} +1 -1
- package/dist/{execute-deploy-destroy-BIqwt1RF-D3F6yxLV.mjs → execute-deploy-destroy-Cww6zOSC-CmOmzLiB.mjs} +50 -11
- package/dist/execute-deploy-destroy-Cww6zOSC-CmOmzLiB.mjs.map +1 -0
- package/dist/{execute-dev-DIEyloWn-CjtRM3-x.mjs → execute-dev-4KYkqSMh-uh7gnPyS.mjs} +33 -17
- package/dist/{execute-dev-DIEyloWn-CjtRM3-x.mjs.map → execute-dev-4KYkqSMh-uh7gnPyS.mjs.map} +1 -1
- package/dist/{execute-dev-current-CeKI-tiC-fd62IW2Y.mjs → execute-dev-current-Cd4YEUZk-b2L-LwbT.mjs} +6 -6
- package/dist/{execute-dev-current-CeKI-tiC-fd62IW2Y.mjs.map → execute-dev-current-Cd4YEUZk-b2L-LwbT.mjs.map} +1 -1
- package/dist/{family-Dy3ZQOxG-CcELNRXg.d.mts → family-DACJfaA5-CBuEC2B3.d.mts} +103 -61
- package/dist/family-DACJfaA5-CBuEC2B3.d.mts.map +1 -0
- package/dist/family.d.mts +1 -1
- package/dist/family.mjs +12 -4
- package/dist/family.mjs.map +1 -1
- package/dist/{generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs → generate-dev-stack-DS6U_JHX-wDTViqdg.mjs} +9 -4
- package/dist/generate-dev-stack-DS6U_JHX-wDTViqdg.mjs.map +1 -0
- package/dist/{list-deployed-2Xs64YAh.mjs → list-deployed-CH3SMsQ4.mjs} +4 -4
- package/dist/{list-deployed-2Xs64YAh.mjs.map → list-deployed-CH3SMsQ4.mjs.map} +1 -1
- package/dist/result-sR7PBi61.mjs +229 -0
- package/dist/result-sR7PBi61.mjs.map +1 -0
- package/dist/run-alchemy-B-Z6i3cD-f0MXFCG8.mjs +219 -0
- package/dist/run-alchemy-B-Z6i3cD-f0MXFCG8.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +3 -2
- package/dist/testing.mjs.map +1 -1
- package/dist/{validate-environment-CEhUSEg2-BohWFcgr.mjs → validate-environment-BNZC6W46-DY_7cPQJ.mjs} +449 -342
- package/dist/validate-environment-BNZC6W46-DY_7cPQJ.mjs.map +1 -0
- package/package.json +7 -7
- package/dist/dev-environment-name-6eEr5PW8-lIZmJjfr.mjs.map +0 -1
- package/dist/execute-deploy-destroy-BIqwt1RF-D3F6yxLV.mjs.map +0 -1
- package/dist/family-Dy3ZQOxG-CcELNRXg.d.mts.map +0 -1
- package/dist/generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs.map +0 -1
- package/dist/run-alchemy-Dl_MWw4g-DaWV9tkH.mjs +0 -667
- package/dist/run-alchemy-Dl_MWw4g-DaWV9tkH.mjs.map +0 -1
- package/dist/validate-environment-CEhUSEg2-BohWFcgr.mjs.map +0 -1
|
@@ -1,10 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as entryMissing, i as configFileMissing, n as environmentVariables, r as checkComposerConfig } from "./config-adapters-BA_IeiX0-CiRnz7z8.mjs";
|
|
2
|
+
import { a as InternalError, i as CliStructuredError, o as blindCast } from "./result-sR7PBi61.mjs";
|
|
2
3
|
import * as mod from "node:module";
|
|
3
4
|
import * as fs from "node:fs";
|
|
4
5
|
import { existsSync } from "node:fs";
|
|
5
6
|
import * as path from "node:path";
|
|
6
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
8
|
import { spawnSync } from "node:child_process";
|
|
9
|
+
//#region ../../0-framework/0-foundation/foundation/dist/describe-kind-Cpm_euxo.mjs
|
|
10
|
+
/** How an error names the kind of a value it did not expect, without printing the value. */
|
|
11
|
+
function describeKind(value) {
|
|
12
|
+
if (value === void 0) return "nothing";
|
|
13
|
+
if (value === null) return "null";
|
|
14
|
+
if (Array.isArray(value)) return "an array";
|
|
15
|
+
if (typeof value === "function") return "a function";
|
|
16
|
+
if (typeof value === "object") return "an object";
|
|
17
|
+
return `a ${typeof value}`;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region ../../0-framework/3-tooling/cli/dist/config-pools-DiYw7wMu.mjs
|
|
21
|
+
function adapterInvalid(list, index, input, summary, fix) {
|
|
22
|
+
return new CliStructuredError("CONFIG.ADAPTER_INVALID", summary, {
|
|
23
|
+
fix,
|
|
24
|
+
where: { path: input.configFile },
|
|
25
|
+
meta: { field: `${list}[${index}]` }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function isValues(value) {
|
|
29
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
function isText(pool) {
|
|
32
|
+
return Object.values(pool).every((value) => typeof value === "string");
|
|
33
|
+
}
|
|
34
|
+
async function readPool(list, adapters, input) {
|
|
35
|
+
const adapterInput = Object.freeze({
|
|
36
|
+
environment: input.environment,
|
|
37
|
+
configDirectory: path.dirname(input.configFile)
|
|
38
|
+
});
|
|
39
|
+
const pool = Object.create(null);
|
|
40
|
+
for (const [index, adapter] of adapters.entries()) {
|
|
41
|
+
const field = `composer.${list}[${index}]`;
|
|
42
|
+
let values;
|
|
43
|
+
try {
|
|
44
|
+
values = await adapter(adapterInput);
|
|
45
|
+
} catch (thrown) {
|
|
46
|
+
throw new CliStructuredError("CONFIG.ADAPTER_FAILED", `\`${field}\` failed to read the values for the environment "${input.environment}".`, {
|
|
47
|
+
why: `It threw: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
48
|
+
fix: `Fix the adapter, or remove it from \`composer.${list}\` in prisma.config.ts.`,
|
|
49
|
+
where: { path: input.configFile },
|
|
50
|
+
meta: { field: `${list}[${index}]` },
|
|
51
|
+
cause: thrown
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (typeof values === "function") throw adapterInvalid(list, index, input, `\`${field}\` returned a function, not an object of values.`, "An adapter factory was put in the list instead of the adapter it makes: write `dotenv()`, not `dotenv`.");
|
|
55
|
+
if (!isValues(values)) throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(values)}, not an object of values.`, "Return an object whose keys are the names of the values, e.g. `{ EMAIL_FROM: 'shop@example.com' }`.");
|
|
56
|
+
for (const [key, value] of Object.entries(values)) {
|
|
57
|
+
if (value === void 0) continue;
|
|
58
|
+
if (list === "secrets" && typeof value !== "string") throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(value)} for "${key}", but a secret is text.`, "Return the secret as a string. A platform variable holds text.");
|
|
59
|
+
pool[key] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return Object.freeze(pool);
|
|
63
|
+
}
|
|
64
|
+
/** Calls the section's `config` adapters (default `[environmentVariables()]`) and merges what they return: the config pool. */
|
|
65
|
+
function readConfigPool(section, input) {
|
|
66
|
+
return readPool("config", section.config ?? [environmentVariables()], input);
|
|
67
|
+
}
|
|
68
|
+
/** Calls the section's `secrets` adapters (default `[environmentVariables()]`) and merges what they return: the secrets pool. Every value must be text. */
|
|
69
|
+
async function readSecretsPool(section, input) {
|
|
70
|
+
const pool = await readPool("secrets", section.secrets ?? [environmentVariables()], input);
|
|
71
|
+
if (!isText(pool)) throw new InternalError("readPool admitted a secret that is not text");
|
|
72
|
+
return pool;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
8
75
|
//#region ../../0-framework/3-tooling/assemble/dist/index.mjs
|
|
9
76
|
/**
|
|
10
77
|
* A user-facing assembly failure, structured at origin (base-type rule 6):
|
|
@@ -101,48 +168,20 @@ async function assembleServices(graph, config, cwd, run, onEvent, options = {})
|
|
|
101
168
|
};
|
|
102
169
|
}
|
|
103
170
|
//#endregion
|
|
171
|
+
//#region ../../0-framework/0-foundation/foundation/dist/pointer-Cw3E-nrh.mjs
|
|
172
|
+
/** A pointer: what a value known only at boot holds at deploy. It names the platform variable the service reads at boot, and records whether that variable holds a secret. */
|
|
173
|
+
const POINTER = blindCast(Symbol.for("prisma:pointer"));
|
|
174
|
+
function kindOf(value) {
|
|
175
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
176
|
+
return Reflect.get(value, POINTER);
|
|
177
|
+
}
|
|
178
|
+
/** True for a secret pointer: a value known only at boot whose variable holds a secret. */
|
|
179
|
+
function isSecretPointer(value) {
|
|
180
|
+
return kindOf(value) === "secret";
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
104
183
|
//#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
|
|
105
|
-
/**
|
|
106
|
-
* A value wrapper that redacts everywhere except the one explicit reader,
|
|
107
|
-
* `expose()`. Sensitivity is carried by the TYPE (`SecretBox<T>`), not a flag a
|
|
108
|
-
* sink must remember to check: `String(box)`, template interpolation,
|
|
109
|
-
* `JSON.stringify`, and `console.log`/`util.inspect` all print `[REDACTED]`, so
|
|
110
|
-
* a secret can't leak through an accidental log or serialization.
|
|
111
|
-
*
|
|
112
|
-
* Every box carries a brand property keyed by the registered symbol
|
|
113
|
-
* `Symbol.for('prisma:secret-box')`, which is what `isSecretString` checks. A
|
|
114
|
-
* symbol key is invisible to `JSON.stringify` and `Object.keys`, so the box's
|
|
115
|
-
* public shape still matches the platform's own `secrecy` type
|
|
116
|
-
* (pdp-control-plane).
|
|
117
|
-
*/
|
|
118
|
-
const REDACTED = "[REDACTED]";
|
|
119
184
|
const SECRET_BOX = blindCast(Symbol.for("prisma:secret-box"));
|
|
120
|
-
var SecretBox = class {
|
|
121
|
-
[SECRET_BOX] = true;
|
|
122
|
-
#value;
|
|
123
|
-
constructor(value) {
|
|
124
|
-
this.#value = value;
|
|
125
|
-
}
|
|
126
|
-
/** The sole explicit door to the wrapped value. */
|
|
127
|
-
expose() {
|
|
128
|
-
return this.#value;
|
|
129
|
-
}
|
|
130
|
-
toString() {
|
|
131
|
-
return REDACTED;
|
|
132
|
-
}
|
|
133
|
-
toJSON() {
|
|
134
|
-
return REDACTED;
|
|
135
|
-
}
|
|
136
|
-
valueOf() {
|
|
137
|
-
return REDACTED;
|
|
138
|
-
}
|
|
139
|
-
[Symbol.toPrimitive]() {
|
|
140
|
-
return REDACTED;
|
|
141
|
-
}
|
|
142
|
-
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
143
|
-
return REDACTED;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
185
|
/**
|
|
147
186
|
* True for a redacting secret box — what a schema's secret leaf checks
|
|
148
187
|
* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
|
|
@@ -152,7 +191,7 @@ function isSecretString(value) {
|
|
|
152
191
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_BOX] === true;
|
|
153
192
|
}
|
|
154
193
|
//#endregion
|
|
155
|
-
//#region ../../0-framework/1-core/core/dist/graph-
|
|
194
|
+
//#region ../../0-framework/1-core/core/dist/graph-gE31_ToO.mjs
|
|
156
195
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
157
196
|
const RESOURCE_OUT_PORT = "$out";
|
|
158
197
|
/**
|
|
@@ -173,7 +212,7 @@ function contractStyleOf(contract) {
|
|
|
173
212
|
}
|
|
174
213
|
const VALUE = blindCast(Symbol.for("prisma:value"));
|
|
175
214
|
const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
|
|
176
|
-
/** True if `value` is a `Value
|
|
215
|
+
/** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
|
|
177
216
|
function isValue(value) {
|
|
178
217
|
return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
|
|
179
218
|
}
|
|
@@ -195,21 +234,119 @@ const environmentFacts = Object.freeze({ name: Object.freeze({
|
|
|
195
234
|
fact: "name"
|
|
196
235
|
})
|
|
197
236
|
}) });
|
|
237
|
+
const INSPECT = Symbol.for("nodejs.util.inspect.custom");
|
|
238
|
+
/** `input` or `input.a.b`: how an error names an input field. */
|
|
239
|
+
function inputFieldLabel(origin) {
|
|
240
|
+
return origin.path.length === 0 ? "input" : `input.${origin.path.join(".")}`;
|
|
241
|
+
}
|
|
242
|
+
function misuse(origin, what) {
|
|
243
|
+
const field = inputFieldLabel(origin);
|
|
244
|
+
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]) => …).`);
|
|
245
|
+
}
|
|
246
|
+
/** What a coercion with `hint` did to a value, worded for a misuse error. */
|
|
247
|
+
function primitiveMisuse(hint) {
|
|
248
|
+
switch (hint) {
|
|
249
|
+
case "string": return "it was turned into text (a template literal or String())";
|
|
250
|
+
case "number": return "it was turned into a number (arithmetic, or a comparison such as <)";
|
|
251
|
+
default: return "it was combined with + or compared with ==";
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Builds the `input` a module body receives. Every property access returns a
|
|
256
|
+
* value recording its key path, and the same path always returns the same
|
|
257
|
+
* object, so Load's identity-keyed maps see one value per field. Any way of
|
|
258
|
+
* reading the real value throws a LoadError naming the field.
|
|
259
|
+
*/
|
|
260
|
+
function buildModuleInput(moduleAddress) {
|
|
261
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
262
|
+
const valueAt = (path) => {
|
|
263
|
+
const key = JSON.stringify(path);
|
|
264
|
+
const existing = byPath.get(key);
|
|
265
|
+
if (existing !== void 0) return existing;
|
|
266
|
+
const origin = Object.freeze({
|
|
267
|
+
kind: "input",
|
|
268
|
+
module: moduleAddress,
|
|
269
|
+
path: Object.freeze([...path])
|
|
270
|
+
});
|
|
271
|
+
const thrower = (what) => () => {
|
|
272
|
+
throw misuse(origin, what);
|
|
273
|
+
};
|
|
274
|
+
const handler = {
|
|
275
|
+
get(_target, property) {
|
|
276
|
+
if (property === VALUE) return true;
|
|
277
|
+
if (property === VALUE_ORIGIN) return origin;
|
|
278
|
+
if (property === Symbol.toPrimitive) return (hint) => {
|
|
279
|
+
throw misuse(origin, primitiveMisuse(hint));
|
|
280
|
+
};
|
|
281
|
+
if (property === "toString") return thrower("its toString() was called");
|
|
282
|
+
if (property === "valueOf") return thrower("its valueOf() was called");
|
|
283
|
+
if (property === "toJSON") return thrower("it was serialized with JSON.stringify");
|
|
284
|
+
if (property === Symbol.iterator || property === Symbol.asyncIterator) return thrower("it was iterated (array spread, for…of or array destructuring)");
|
|
285
|
+
if (typeof property === "symbol") return void 0;
|
|
286
|
+
return valueAt([...path, property]);
|
|
287
|
+
},
|
|
288
|
+
has(_target, property) {
|
|
289
|
+
if (property === VALUE || property === VALUE_ORIGIN) return true;
|
|
290
|
+
if (typeof property === "symbol") return false;
|
|
291
|
+
throw misuse(origin, `it was checked with the in operator ("${property}" in …)`);
|
|
292
|
+
},
|
|
293
|
+
ownKeys() {
|
|
294
|
+
throw misuse(origin, "its keys were listed (Object.keys, object spread, for…in or Object.entries)");
|
|
295
|
+
},
|
|
296
|
+
getOwnPropertyDescriptor() {
|
|
297
|
+
throw misuse(origin, "its properties were inspected");
|
|
298
|
+
},
|
|
299
|
+
set(_target, property) {
|
|
300
|
+
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
301
|
+
},
|
|
302
|
+
defineProperty(_target, property) {
|
|
303
|
+
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
304
|
+
},
|
|
305
|
+
deleteProperty() {
|
|
306
|
+
throw misuse(origin, "a property was deleted from it");
|
|
307
|
+
},
|
|
308
|
+
setPrototypeOf() {
|
|
309
|
+
throw misuse(origin, "its prototype was changed");
|
|
310
|
+
},
|
|
311
|
+
preventExtensions() {
|
|
312
|
+
throw misuse(origin, "it was frozen or sealed");
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const target = Object.create(null);
|
|
316
|
+
Object.defineProperty(target, INSPECT, {
|
|
317
|
+
value: () => `[${inputFieldLabel(origin)} of module "${origin.module}"]`,
|
|
318
|
+
configurable: true
|
|
319
|
+
});
|
|
320
|
+
const proxy = new Proxy(target, handler);
|
|
321
|
+
byPath.set(key, proxy);
|
|
322
|
+
return proxy;
|
|
323
|
+
};
|
|
324
|
+
return blindCast(valueAt([]));
|
|
325
|
+
}
|
|
198
326
|
/**
|
|
199
327
|
* Core model: node types and the factories that construct them, plain frozen
|
|
200
328
|
* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).
|
|
201
329
|
*/
|
|
202
330
|
const NODE = Symbol.for("prisma:node");
|
|
203
|
-
blindCast(Symbol.for("prisma:secret-need"));
|
|
204
331
|
const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
|
|
205
|
-
/** True if `value` is a secret source
|
|
332
|
+
/** True if `value` is a secret source, such as an `envSecret()` result. */
|
|
206
333
|
function isSecretSource(value) {
|
|
207
334
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
|
|
208
335
|
}
|
|
209
336
|
blindCast(Symbol.for("prisma:provision-need"));
|
|
210
337
|
const PARAM_SOURCE = blindCast(Symbol.for("prisma:param-source"));
|
|
211
|
-
|
|
212
|
-
/** True
|
|
338
|
+
const sourceMisuses = /* @__PURE__ */ new WeakSet();
|
|
339
|
+
/** True for the error a source throws when code turns it into text or a number. Internal to core. */
|
|
340
|
+
function isSourceMisuse(error) {
|
|
341
|
+
return error instanceof LoadError && sourceMisuses.has(error);
|
|
342
|
+
}
|
|
343
|
+
/** A source's origin; `undefined` for a source another installed copy of core built without one. Internal to core. */
|
|
344
|
+
function sourceOriginOf(source) {
|
|
345
|
+
if (!isValue(source)) return void 0;
|
|
346
|
+
const origin = originOf(source);
|
|
347
|
+
return origin.kind === "source" ? origin : void 0;
|
|
348
|
+
}
|
|
349
|
+
/** True if `value` is a param source, such as an `envParam()` result. */
|
|
213
350
|
function isParamSource(value) {
|
|
214
351
|
return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
|
|
215
352
|
}
|
|
@@ -361,98 +498,10 @@ function loadService(root, rootId) {
|
|
|
361
498
|
ports: boundaryPortsOf(rootId, root),
|
|
362
499
|
authoredEdges: [],
|
|
363
500
|
inputBindings: [],
|
|
364
|
-
params: []
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
const INSPECT = Symbol.for("nodejs.util.inspect.custom");
|
|
368
|
-
/** `input` or `input.a.b`: how an error names an input field. */
|
|
369
|
-
function inputFieldLabel(origin) {
|
|
370
|
-
return origin.path.length === 0 ? "input" : `input.${origin.path.join(".")}`;
|
|
371
|
-
}
|
|
372
|
-
function misuse(origin, what) {
|
|
373
|
-
const field = inputFieldLabel(origin);
|
|
374
|
-
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, list it: resolve([${field}], ([v]) => …).`);
|
|
375
|
-
}
|
|
376
|
-
function primitiveMisuse(hint) {
|
|
377
|
-
switch (hint) {
|
|
378
|
-
case "string": return "it was turned into text (a template literal or String())";
|
|
379
|
-
case "number": return "it was turned into a number (arithmetic, or a comparison such as <)";
|
|
380
|
-
default: return "it was combined with + or compared with ==";
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Builds the `input` a module body receives. Every property access returns a
|
|
385
|
-
* value recording its key path, and the same path always returns the same
|
|
386
|
-
* object, so Load's identity-keyed maps see one value per field. Any way of
|
|
387
|
-
* reading the real value throws a LoadError naming the field.
|
|
388
|
-
*/
|
|
389
|
-
function buildModuleInput(moduleAddress) {
|
|
390
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
391
|
-
const valueAt = (path) => {
|
|
392
|
-
const key = JSON.stringify(path);
|
|
393
|
-
const existing = byPath.get(key);
|
|
394
|
-
if (existing !== void 0) return existing;
|
|
395
|
-
const origin = Object.freeze({
|
|
396
|
-
kind: "input",
|
|
397
|
-
module: moduleAddress,
|
|
398
|
-
path: Object.freeze([...path])
|
|
399
|
-
});
|
|
400
|
-
const thrower = (what) => () => {
|
|
401
|
-
throw misuse(origin, what);
|
|
402
|
-
};
|
|
403
|
-
const handler = {
|
|
404
|
-
get(_target, property) {
|
|
405
|
-
if (property === VALUE) return true;
|
|
406
|
-
if (property === VALUE_ORIGIN) return origin;
|
|
407
|
-
if (property === Symbol.toPrimitive) return (hint) => {
|
|
408
|
-
throw misuse(origin, primitiveMisuse(hint));
|
|
409
|
-
};
|
|
410
|
-
if (property === "toString") return thrower("its toString() was called");
|
|
411
|
-
if (property === "valueOf") return thrower("its valueOf() was called");
|
|
412
|
-
if (property === "toJSON") return thrower("it was serialized with JSON.stringify");
|
|
413
|
-
if (property === Symbol.iterator || property === Symbol.asyncIterator) return thrower("it was iterated (array spread, for…of or array destructuring)");
|
|
414
|
-
if (typeof property === "symbol") return void 0;
|
|
415
|
-
return valueAt([...path, property]);
|
|
416
|
-
},
|
|
417
|
-
has(_target, property) {
|
|
418
|
-
if (property === VALUE || property === VALUE_ORIGIN) return true;
|
|
419
|
-
if (typeof property === "symbol") return false;
|
|
420
|
-
throw misuse(origin, `it was checked with the in operator ("${property}" in …)`);
|
|
421
|
-
},
|
|
422
|
-
ownKeys() {
|
|
423
|
-
throw misuse(origin, "its keys were listed (Object.keys, object spread, for…in or Object.entries)");
|
|
424
|
-
},
|
|
425
|
-
getOwnPropertyDescriptor() {
|
|
426
|
-
throw misuse(origin, "its properties were inspected");
|
|
427
|
-
},
|
|
428
|
-
set(_target, property) {
|
|
429
|
-
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
430
|
-
},
|
|
431
|
-
defineProperty(_target, property) {
|
|
432
|
-
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
433
|
-
},
|
|
434
|
-
deleteProperty() {
|
|
435
|
-
throw misuse(origin, "a property was deleted from it");
|
|
436
|
-
},
|
|
437
|
-
setPrototypeOf() {
|
|
438
|
-
throw misuse(origin, "its prototype was changed");
|
|
439
|
-
},
|
|
440
|
-
preventExtensions() {
|
|
441
|
-
throw misuse(origin, "it was frozen or sealed");
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
const target = Object.create(null);
|
|
445
|
-
Object.defineProperty(target, INSPECT, {
|
|
446
|
-
value: () => `[${inputFieldLabel(origin)} of module "${origin.module}"]`,
|
|
447
|
-
configurable: true
|
|
448
|
-
});
|
|
449
|
-
const proxy = new Proxy(target, handler);
|
|
450
|
-
byPath.set(key, proxy);
|
|
451
|
-
return proxy;
|
|
501
|
+
params: [],
|
|
502
|
+
secretSources: []
|
|
452
503
|
};
|
|
453
|
-
return blindCast(valueAt([]));
|
|
454
504
|
}
|
|
455
|
-
const SENTINEL_SOURCE = Symbol("prisma:module-input-sentinel");
|
|
456
505
|
function joinPath(path, key) {
|
|
457
506
|
return path === "" ? String(key) : `${path}.${key}`;
|
|
458
507
|
}
|
|
@@ -464,7 +513,16 @@ function describeSite(site) {
|
|
|
464
513
|
case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
|
|
465
514
|
}
|
|
466
515
|
}
|
|
467
|
-
function collect(value, site, found, seen) {
|
|
516
|
+
function collect(value, site, found, seen, recordSecret) {
|
|
517
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
518
|
+
if (isSecretSource(value) && site.kind !== "props") recordSecret(value, site);
|
|
519
|
+
if (site.kind === "serviceInput" || site.kind === "param" || !isValue(value)) return;
|
|
520
|
+
found.push({
|
|
521
|
+
value,
|
|
522
|
+
site
|
|
523
|
+
});
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
468
526
|
if (isValue(value)) {
|
|
469
527
|
found.push({
|
|
470
528
|
value,
|
|
@@ -472,7 +530,6 @@ function collect(value, site, found, seen) {
|
|
|
472
530
|
});
|
|
473
531
|
return;
|
|
474
532
|
}
|
|
475
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
476
533
|
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
477
534
|
if (seen.has(value)) return;
|
|
478
535
|
seen.add(value);
|
|
@@ -482,7 +539,7 @@ function collect(value, site, found, seen) {
|
|
|
482
539
|
collect(member, {
|
|
483
540
|
...site,
|
|
484
541
|
path
|
|
485
|
-
}, found, seen);
|
|
542
|
+
}, found, seen, recordSecret);
|
|
486
543
|
}
|
|
487
544
|
}
|
|
488
545
|
function describeNotPlain(value) {
|
|
@@ -499,14 +556,42 @@ function isThenable(value) {
|
|
|
499
556
|
if (isValue(value)) return false;
|
|
500
557
|
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
501
558
|
}
|
|
559
|
+
function canonicalSecret(source) {
|
|
560
|
+
const original = sourceOriginOf(source)?.source;
|
|
561
|
+
return isSecretSource(original) ? original : source;
|
|
562
|
+
}
|
|
563
|
+
function nodeKindOf(site) {
|
|
564
|
+
switch (site.kind) {
|
|
565
|
+
case "serviceInput":
|
|
566
|
+
case "param": return "service";
|
|
567
|
+
case "moduleInput": return "module";
|
|
568
|
+
case "props": return "resource";
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
function pointersIn(values) {
|
|
572
|
+
const pointers = /* @__PURE__ */ new Set();
|
|
573
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
574
|
+
const walk = (value) => {
|
|
575
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
576
|
+
pointers.add(value);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
580
|
+
if (seen.has(value)) return;
|
|
581
|
+
seen.add(value);
|
|
582
|
+
for (const member of Array.isArray(value) ? value : Object.values(value)) walk(member);
|
|
583
|
+
};
|
|
584
|
+
walk(values);
|
|
585
|
+
return pointers;
|
|
586
|
+
}
|
|
502
587
|
function checkResult(result, fnLabel) {
|
|
503
588
|
if (isThenable(result)) throw new LoadError(`${fnLabel} returned a Promise. resolve() runs synchronously at Load.`);
|
|
504
589
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
505
590
|
const walk = (value, path) => {
|
|
506
591
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
507
592
|
if (value === void 0) throw new LoadError(`${fnLabel} returned undefined${atPath}. Return a result for every environment; Composer never picks a default.`);
|
|
593
|
+
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.`);
|
|
508
594
|
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.`);
|
|
509
|
-
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.`);
|
|
510
595
|
const notPlain = describeNotPlain(value);
|
|
511
596
|
if (notPlain !== void 0) throw new LoadError(`${fnLabel} returned ${notPlain}${atPath}. resolve() returns plain data: strings, finite numbers, booleans, null, arrays and plain objects.`);
|
|
512
597
|
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
@@ -516,13 +601,42 @@ function checkResult(result, fnLabel) {
|
|
|
516
601
|
};
|
|
517
602
|
walk(result, "");
|
|
518
603
|
}
|
|
519
|
-
|
|
604
|
+
/** The first pointer in `value`, at any depth through arrays and plain objects, with its key path; `undefined` when there is none. */
|
|
605
|
+
function firstPointer(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
|
|
606
|
+
if (isSecretSource(value) || isParamSource(value)) return {
|
|
607
|
+
pointer: value,
|
|
608
|
+
path
|
|
609
|
+
};
|
|
610
|
+
if (!Array.isArray(value) && !isPlainObject(value)) return void 0;
|
|
611
|
+
if (seen.has(value)) return void 0;
|
|
612
|
+
seen.add(value);
|
|
613
|
+
const entries = Array.isArray(value) ? value.map((member, index) => [String(index), member]) : Object.entries(value);
|
|
614
|
+
for (const [key, member] of entries) {
|
|
615
|
+
const found = firstPointer(member, [...path, key], seen);
|
|
616
|
+
if (found !== void 0) return found;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/** Refuses a resolve() dependency whose real value is a pointer or holds one at any depth: `fn` computes with deploy-time data only. */
|
|
620
|
+
function refusePointerDependency(fnLabel, dependency, real) {
|
|
621
|
+
const found = firstPointer(real);
|
|
622
|
+
if (found === void 0) return;
|
|
623
|
+
const label = sourceOriginOf(found.pointer)?.label ?? "a value known only at boot";
|
|
624
|
+
const origin = originOf(dependency);
|
|
625
|
+
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.`);
|
|
626
|
+
const listed = `${inputFieldLabel(origin)} of module "${origin.module}"`;
|
|
627
|
+
const field = inputFieldLabel({
|
|
628
|
+
...origin,
|
|
629
|
+
path: [...origin.path, ...found.path]
|
|
630
|
+
});
|
|
631
|
+
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.`}`);
|
|
632
|
+
}
|
|
633
|
+
function substitute(value, results, inProgress, sources) {
|
|
634
|
+
if (isSecretSource(value) || isParamSource(value)) return sources === "keep" || !isValue(value) ? value : results.get(value);
|
|
520
635
|
if (isValue(value)) return results.get(value);
|
|
521
|
-
if (isSecretSource(value) || isParamSource(value)) return value;
|
|
522
636
|
if (Array.isArray(value)) {
|
|
523
637
|
if (inProgress.has(value)) return value;
|
|
524
638
|
inProgress.add(value);
|
|
525
|
-
const rebuilt = value.map((member) => substitute(member, results, inProgress));
|
|
639
|
+
const rebuilt = value.map((member) => substitute(member, results, inProgress, sources));
|
|
526
640
|
inProgress.delete(value);
|
|
527
641
|
return rebuilt.every((member, index) => member === value[index]) ? value : rebuilt;
|
|
528
642
|
}
|
|
@@ -532,7 +646,7 @@ function substitute(value, results, inProgress) {
|
|
|
532
646
|
const rebuilt = {};
|
|
533
647
|
let changed = false;
|
|
534
648
|
for (const [key, member] of Object.entries(value)) {
|
|
535
|
-
const real = substitute(member, results, inProgress);
|
|
649
|
+
const real = substitute(member, results, inProgress, sources);
|
|
536
650
|
if (real === void 0 && isValue(member)) {
|
|
537
651
|
changed = true;
|
|
538
652
|
continue;
|
|
@@ -547,7 +661,6 @@ function substitute(value, results, inProgress) {
|
|
|
547
661
|
}
|
|
548
662
|
function describeData(value) {
|
|
549
663
|
if (Array.isArray(value)) return "an array";
|
|
550
|
-
if (isSecretSource(value)) return "a secret";
|
|
551
664
|
if (typeof value === "object") return "an object that is not plain data";
|
|
552
665
|
return `a ${typeof value}`;
|
|
553
666
|
}
|
|
@@ -556,47 +669,59 @@ function readPath(data, origin) {
|
|
|
556
669
|
let current = data;
|
|
557
670
|
for (const [index, key] of origin.path.entries()) {
|
|
558
671
|
if (current === void 0 || current === null) return void 0;
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
}
|
|
672
|
+
const missing = `${inputFieldLabel(origin)} of module "${origin.module}" does not exist`;
|
|
673
|
+
const parent = inputFieldLabel({
|
|
674
|
+
...origin,
|
|
675
|
+
path: origin.path.slice(0, index)
|
|
676
|
+
});
|
|
677
|
+
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 and can only be passed on unchanged.`);
|
|
678
|
+
if (!isPlainObject(current)) throw new LoadError(`${missing}: ${parent} is ${describeData(current)}, not a plain object, so it has no fields. To compute with it, it must be a plain field, not a wrapped or secret one; list it: resolve([${parent}], ([v]) => …).`);
|
|
566
679
|
if (!Object.hasOwn(current, key)) return void 0;
|
|
567
680
|
current = current[key];
|
|
568
681
|
}
|
|
569
682
|
return current;
|
|
570
683
|
}
|
|
571
|
-
function
|
|
684
|
+
function refuseSecretBoxes(address, value, path) {
|
|
685
|
+
if (isSecretSource(value) || isParamSource(value)) return;
|
|
686
|
+
if (isSecretString(value)) throw new LoadError(`${describeSite({
|
|
687
|
+
address,
|
|
688
|
+
kind: "moduleInput",
|
|
689
|
+
path
|
|
690
|
+
})} 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().`);
|
|
691
|
+
if (Array.isArray(value)) {
|
|
692
|
+
for (const [index, member] of value.entries()) refuseSecretBoxes(address, member, joinPath(path, index));
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) refuseSecretBoxes(address, member, joinPath(path, key));
|
|
696
|
+
}
|
|
697
|
+
/** The original source each runtime value in `value` names, by its path. */
|
|
698
|
+
function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map()) {
|
|
699
|
+
if (isSecretSource(value) || isParamSource(value)) found.set(path, sourceOriginOf(value)?.source ?? value);
|
|
700
|
+
else if (Array.isArray(value)) for (const [index, member] of value.entries()) sourcesByPath(member, joinPath(path, index), found);
|
|
701
|
+
else if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) sourcesByPath(member, joinPath(path, key), found);
|
|
702
|
+
return found;
|
|
703
|
+
}
|
|
704
|
+
function validateModuleInput(entry, resolved, environment) {
|
|
572
705
|
const address = entry.moduleAddress;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
const sentinel = new SecretBox("");
|
|
576
|
-
Object.defineProperty(sentinel, SENTINEL_SOURCE, { value });
|
|
577
|
-
return sentinel;
|
|
578
|
-
}
|
|
579
|
-
if (isParamSource(value)) throw new LoadError(`${describeSite({
|
|
580
|
-
address,
|
|
581
|
-
kind: "moduleInput",
|
|
582
|
-
path
|
|
583
|
-
})} is bound to a param source, such as envParam(). A module's input does not take a param source yet; bind it on the service's input inside the module, or forward it through the module's params slot.`);
|
|
584
|
-
if (isSecretString(value)) throw new LoadError(`${describeSite({
|
|
585
|
-
address,
|
|
586
|
-
kind: "moduleInput",
|
|
587
|
-
path
|
|
588
|
-
})} 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().`);
|
|
589
|
-
if (Array.isArray(value)) return value.map((member, index) => withSentinels(member, joinPath(path, index)));
|
|
590
|
-
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, withSentinels(member, joinPath(path, key))]));
|
|
591
|
-
return value;
|
|
592
|
-
};
|
|
593
|
-
const result = entry.schema["~standard"].validate(withSentinels(resolved, ""));
|
|
706
|
+
refuseSecretBoxes(address, resolved, "");
|
|
707
|
+
const result = entry.schema["~standard"].validate(resolved);
|
|
594
708
|
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.`);
|
|
595
|
-
if (result.issues !== void 0)
|
|
709
|
+
if (result.issues !== void 0) {
|
|
710
|
+
const messages = result.issues.map((issue) => issue.message).join("; ");
|
|
711
|
+
if (entry.fromConfigPool) 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}"`}.`);
|
|
712
|
+
throw new LoadError(`The input binding of module "${address}" does not match the module's input schema: ${messages}`);
|
|
713
|
+
}
|
|
714
|
+
const bound = sourcesByPath(resolved);
|
|
715
|
+
const onlyChecked = "Its value is known only at boot, so a module's schema may check the field but never replace or move it.";
|
|
596
716
|
const restore = (value, path) => {
|
|
717
|
+
const expected = bound.get(path);
|
|
718
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
719
|
+
const source = sourceOriginOf(value)?.source ?? value;
|
|
720
|
+
if (source !== expected) throw new LoadError(`The input schema of module "${address}" moved ${sourceOriginOf(source)?.label} to input key "${path}". ${onlyChecked}`);
|
|
721
|
+
return source;
|
|
722
|
+
}
|
|
723
|
+
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}`);
|
|
597
724
|
if (isSecretString(value)) {
|
|
598
|
-
const source = blindCast(value)[SENTINEL_SOURCE];
|
|
599
|
-
if (isSecretSource(source)) return source;
|
|
600
725
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
601
726
|
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.`);
|
|
602
727
|
}
|
|
@@ -606,30 +731,72 @@ function validateModuleInput(entry, resolved) {
|
|
|
606
731
|
};
|
|
607
732
|
return restore(result.value, "");
|
|
608
733
|
}
|
|
734
|
+
function refusePointersInProps(address, props) {
|
|
735
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
736
|
+
const walk = (value, path) => {
|
|
737
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
738
|
+
const label = sourceOriginOf(value)?.label ?? (isSecretSource(value) ? "a secret source" : "a param source");
|
|
739
|
+
throw new LoadError(`${describeSite({
|
|
740
|
+
address,
|
|
741
|
+
kind: "props",
|
|
742
|
+
path
|
|
743
|
+
})} is bound to ${label}, which is known only at boot. A resource's props are read at deploy; bind a value known at deploy.`);
|
|
744
|
+
}
|
|
745
|
+
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
746
|
+
if (seen.has(value)) return;
|
|
747
|
+
seen.add(value);
|
|
748
|
+
const entries = Array.isArray(value) ? value.map((member, index) => [index, member]) : Object.entries(value);
|
|
749
|
+
for (const [key, member] of entries) walk(member, joinPath(path, key));
|
|
750
|
+
};
|
|
751
|
+
walk(props, "");
|
|
752
|
+
}
|
|
609
753
|
/**
|
|
610
754
|
* Resolves every value the graph binds, dependency-first, once each, and
|
|
611
755
|
* returns each binding with its values replaced by their real values.
|
|
612
756
|
*/
|
|
613
757
|
function resolveValues(input) {
|
|
614
|
-
const { environment } = input;
|
|
758
|
+
const { environment, configPool } = input;
|
|
759
|
+
const secretUses = /* @__PURE__ */ new Map();
|
|
760
|
+
const recordSecret = (source, site) => {
|
|
761
|
+
const canonical = canonicalSecret(source);
|
|
762
|
+
if (secretUses.has(canonical)) return;
|
|
763
|
+
secretUses.set(canonical, {
|
|
764
|
+
source: canonical,
|
|
765
|
+
address: site.address,
|
|
766
|
+
nodeKind: nodeKindOf(site)
|
|
767
|
+
});
|
|
768
|
+
};
|
|
769
|
+
const secretSourcesReceivedBy = (inputBindings, params) => {
|
|
770
|
+
for (const { serviceAddress, binding } of [...inputBindings, ...params]) for (const pointer of pointersIn(binding)) {
|
|
771
|
+
if (!isSecretSource(pointer)) continue;
|
|
772
|
+
const canonical = canonicalSecret(pointer);
|
|
773
|
+
if (secretUses.get(canonical)?.nodeKind === "service") continue;
|
|
774
|
+
secretUses.set(canonical, {
|
|
775
|
+
source: canonical,
|
|
776
|
+
address: serviceAddress,
|
|
777
|
+
nodeKind: "service"
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
return [...secretUses.values()];
|
|
781
|
+
};
|
|
615
782
|
const found = [];
|
|
616
783
|
for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
|
|
617
784
|
address: serviceAddress,
|
|
618
785
|
kind: "serviceInput",
|
|
619
786
|
path: ""
|
|
620
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
787
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
621
788
|
for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
|
|
622
789
|
address: serviceAddress,
|
|
623
790
|
kind: "param",
|
|
624
791
|
path: slot
|
|
625
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
792
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
626
793
|
for (const [address, resource] of input.resources) {
|
|
627
794
|
const site = {
|
|
628
795
|
address,
|
|
629
796
|
kind: "props",
|
|
630
797
|
path: ""
|
|
631
798
|
};
|
|
632
|
-
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
|
|
799
|
+
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
633
800
|
}
|
|
634
801
|
const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
|
|
635
802
|
const validatedInputs = /* @__PURE__ */ new Map();
|
|
@@ -648,12 +815,29 @@ function resolveValues(input) {
|
|
|
648
815
|
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.`);
|
|
649
816
|
result = environment[origin.fact];
|
|
650
817
|
break;
|
|
818
|
+
case "source":
|
|
819
|
+
if (isSecretSource(origin.source)) recordSecret(origin.source, site);
|
|
820
|
+
if (origin.poolKey === void 0) result = origin.source;
|
|
821
|
+
else if (configPool === void 0) throw new LoadError(`${describeSite(site)} depends on ${origin.label}, but Load was given no values from the \`config\` adapters to read "${origin.poolKey}" from. Pass { configPool } to Load; the deploy and dev commands pass the values the \`config\` adapters return.`);
|
|
822
|
+
else {
|
|
823
|
+
const raw = configPool[origin.poolKey];
|
|
824
|
+
if (raw === void 0 || raw === "") result = void 0;
|
|
825
|
+
else if (typeof raw === "string") result = raw;
|
|
826
|
+
else throw new LoadError(`${describeSite(site)} depends on ${origin.label}, which reads "${origin.poolKey}" from the values the \`config\` adapters return, but they return ${describeKind(raw)} for it, not text. ${origin.label} reads text; to pass other data, declare it in the root module's input.`);
|
|
827
|
+
}
|
|
828
|
+
break;
|
|
651
829
|
case "computed": {
|
|
652
|
-
const args = origin.dependencies.map((dependency) =>
|
|
830
|
+
const args = origin.dependencies.map((dependency) => {
|
|
831
|
+
const real = resolveOne(dependency, site);
|
|
832
|
+
const source = originOf(dependency);
|
|
833
|
+
if (real === void 0 && source.kind === "source") throw new LoadError(`${fnLabelFor(site)} lists ${source.label}, but "${source.poolKey}" is unset or empty, so it has no real value. Set "${source.poolKey}", or bind ${source.label} directly into an input binding, where an absent value leaves the key out and the schema decides.`);
|
|
834
|
+
refusePointerDependency(fnLabelFor(site), dependency, real);
|
|
835
|
+
return real;
|
|
836
|
+
});
|
|
653
837
|
try {
|
|
654
838
|
result = origin.compute(args);
|
|
655
839
|
} catch (thrown) {
|
|
656
|
-
if (thrown instanceof LoadError) throw thrown;
|
|
840
|
+
if (thrown instanceof LoadError && !isSourceMisuse(thrown)) throw thrown;
|
|
657
841
|
const message = thrown instanceof Error ? thrown.message : String(thrown);
|
|
658
842
|
throw new LoadError(`${fnLabelFor(site)} threw: ${message}`, { cause: thrown });
|
|
659
843
|
}
|
|
@@ -663,6 +847,7 @@ function resolveValues(input) {
|
|
|
663
847
|
case "input": {
|
|
664
848
|
const entry = moduleInputByAddress.get(origin.module);
|
|
665
849
|
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.`);
|
|
850
|
+
if (entry.fromConfigPool && origin.path.length === 0) throw new LoadError(`${describeSite(site)} depends on the whole input of root module "${origin.module}". The root's input is every value the \`config\` adapters return, which by default is every variable of the process environment, secrets included. Pass on the fields the root declares one by one, such as input.EMAIL_FROM.`);
|
|
666
851
|
result = readPath(validatedInputOf(entry), origin);
|
|
667
852
|
break;
|
|
668
853
|
}
|
|
@@ -681,9 +866,9 @@ function resolveValues(input) {
|
|
|
681
866
|
path: ""
|
|
682
867
|
};
|
|
683
868
|
const values = [];
|
|
684
|
-
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet());
|
|
869
|
+
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
685
870
|
for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
|
|
686
|
-
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet()));
|
|
871
|
+
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet(), "resolve"), environment);
|
|
687
872
|
validating.delete(entry.moduleAddress);
|
|
688
873
|
validatedInputs.set(entry.moduleAddress, validated);
|
|
689
874
|
return validated;
|
|
@@ -691,34 +876,43 @@ function resolveValues(input) {
|
|
|
691
876
|
for (const entry of input.moduleInputs) validatedInputOf(entry);
|
|
692
877
|
for (const { value, site } of found) resolveOne(value, site);
|
|
693
878
|
const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
|
|
694
|
-
if (found.length === 0)
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
879
|
+
if (found.length === 0) {
|
|
880
|
+
for (const [address, props] of authoredProps) refusePointersInProps(address, props);
|
|
881
|
+
return {
|
|
882
|
+
inputBindings: input.inputBindings,
|
|
883
|
+
params: input.params,
|
|
884
|
+
resourceProps: authoredProps,
|
|
885
|
+
secretSources: secretSourcesReceivedBy(input.inputBindings, input.params)
|
|
886
|
+
};
|
|
887
|
+
}
|
|
699
888
|
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
700
889
|
const resourceProps = /* @__PURE__ */ new Map();
|
|
701
890
|
for (const [address, props] of authoredProps) {
|
|
702
|
-
const substituted = substitute(props, results, inProgress);
|
|
703
|
-
|
|
891
|
+
const substituted = substitute(props, results, inProgress, "resolve");
|
|
892
|
+
refusePointersInProps(address, substituted);
|
|
893
|
+
const resolvedProps = substituted === props ? props : blindCast(substituted);
|
|
894
|
+
resourceProps.set(address, resolvedProps);
|
|
704
895
|
}
|
|
896
|
+
const inputBindings = input.inputBindings.map((entry) => {
|
|
897
|
+
const binding = substitute(entry.binding, results, inProgress, "keep");
|
|
898
|
+
return binding === entry.binding ? entry : {
|
|
899
|
+
serviceAddress: entry.serviceAddress,
|
|
900
|
+
binding: blindCast(binding)
|
|
901
|
+
};
|
|
902
|
+
});
|
|
903
|
+
const params = input.params.flatMap((entry) => {
|
|
904
|
+
const binding = substitute(entry.binding, results, inProgress, "keep");
|
|
905
|
+
if (binding === void 0 && isValue(entry.binding)) return [];
|
|
906
|
+
return [binding === entry.binding ? entry : {
|
|
907
|
+
...entry,
|
|
908
|
+
binding
|
|
909
|
+
}];
|
|
910
|
+
});
|
|
705
911
|
return {
|
|
706
912
|
resourceProps,
|
|
707
|
-
inputBindings
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
serviceAddress: entry.serviceAddress,
|
|
711
|
-
binding: blindCast(binding)
|
|
712
|
-
};
|
|
713
|
-
}),
|
|
714
|
-
params: input.params.flatMap((entry) => {
|
|
715
|
-
const binding = substitute(entry.binding, results, inProgress);
|
|
716
|
-
if (binding === void 0 && isValue(entry.binding)) return [];
|
|
717
|
-
return [binding === entry.binding ? entry : {
|
|
718
|
-
...entry,
|
|
719
|
-
binding
|
|
720
|
-
}];
|
|
721
|
-
})
|
|
913
|
+
inputBindings,
|
|
914
|
+
params,
|
|
915
|
+
secretSources: secretSourcesReceivedBy(inputBindings, params)
|
|
722
916
|
};
|
|
723
917
|
}
|
|
724
918
|
/**
|
|
@@ -792,10 +986,6 @@ function producerIdOf(ref) {
|
|
|
792
986
|
* identity the branding copy creates, never on reading this back.
|
|
793
987
|
*/
|
|
794
988
|
const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
|
|
795
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.secrets` forwarding channel. */
|
|
796
|
-
const MODULE_SECRET_KEY = Symbol("prisma:module-secret-key");
|
|
797
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.params` forwarding channel. */
|
|
798
|
-
const MODULE_PARAM_KEY = Symbol("prisma:module-param-key");
|
|
799
989
|
/** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
|
|
800
990
|
function satisfiesRequired(ref, required) {
|
|
801
991
|
return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
|
|
@@ -829,25 +1019,6 @@ function validateWiring(pending, byId) {
|
|
|
829
1019
|
if (value.kind === "dependency") throw new LoadError(`Dependency "${input}" of provisioned ${targetKind} "${targetId}" is not wired to a producer (module "${enclosingModuleName}").`);
|
|
830
1020
|
}
|
|
831
1021
|
}
|
|
832
|
-
/**
|
|
833
|
-
* Flattens a value into itself plus every nested object/array member value —
|
|
834
|
-
* identity fodder for the ctx.secrets/ctx.params usage marking, which must
|
|
835
|
-
* see a forwarded source wherever it sits inside an input binding (ADR-0042).
|
|
836
|
-
* A value or a secret/param source is an opaque leaf: it is pushed (a
|
|
837
|
-
* forwarded ref IS such a source, so identity-matching still needs it) but
|
|
838
|
-
* never descended into, so a ref buried in an unrelated source's payload is
|
|
839
|
-
* not falsely seen as used. `seen` guards object cycles so a self-referential binding cannot
|
|
840
|
-
* recurse forever.
|
|
841
|
-
*/
|
|
842
|
-
function deepValues(value, out, seen = /* @__PURE__ */ new WeakSet()) {
|
|
843
|
-
out.push(value);
|
|
844
|
-
if (typeof value !== "object" || value === null) return;
|
|
845
|
-
if (isValue(value) || isSecretSource(value) || isParamSource(value)) return;
|
|
846
|
-
if (seen.has(value)) return;
|
|
847
|
-
seen.add(value);
|
|
848
|
-
const members = Array.isArray(value) ? value : Object.values(value);
|
|
849
|
-
for (const member of members) deepValues(member, out, seen);
|
|
850
|
-
}
|
|
851
1022
|
/** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */
|
|
852
1023
|
function wiringEdges(wiring, targetId) {
|
|
853
1024
|
return Object.entries(wiring).map(([input, ref]) => ({
|
|
@@ -858,48 +1029,15 @@ function wiringEdges(wiring, targetId) {
|
|
|
858
1029
|
}));
|
|
859
1030
|
}
|
|
860
1031
|
/**
|
|
861
|
-
* Checks the
|
|
862
|
-
*
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
* but resolved inline (a source carries its own name, so no whole-graph pass
|
|
866
|
-
* is needed).
|
|
867
|
-
*/
|
|
868
|
-
function validateSecretBinding(child, id, address, secretWiring, enclosingModuleName) {
|
|
869
|
-
const { kind } = child;
|
|
870
|
-
for (const slot of Object.keys(child.secretSlots)) {
|
|
871
|
-
const bound = secretWiring[slot];
|
|
872
|
-
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.`);
|
|
873
|
-
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.`);
|
|
874
|
-
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.`);
|
|
875
|
-
}
|
|
876
|
-
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}").`);
|
|
877
|
-
}
|
|
878
|
-
/**
|
|
879
|
-
* Checks the params wired into a provisioned SERVICE: unlike a secret slot, a
|
|
880
|
-
* declared param is never required to be bound here — it may fall back to its
|
|
881
|
-
* own `default` (checked later, at `buildConfig`) — so this only rejects a
|
|
882
|
-
* wired key that names something other than a real declared param.
|
|
1032
|
+
* Checks the params wired into a provisioned SERVICE: a declared param is never
|
|
1033
|
+
* required to be bound here — it may fall back to its own `default` (checked
|
|
1034
|
+
* later, at `buildConfig`) — so this only rejects a wired key that names
|
|
1035
|
+
* something other than a real declared param.
|
|
883
1036
|
*/
|
|
884
1037
|
function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName) {
|
|
885
1038
|
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}").`);
|
|
886
1039
|
}
|
|
887
1040
|
/**
|
|
888
|
-
* Checks the params wired into a provisioned MODULE: every declared
|
|
889
|
-
* param-forwarding slot must be bound to a real `ParamSource` — a slot has no
|
|
890
|
-
* schema of its own, so (unlike a service param) it cannot fall back to a
|
|
891
|
-
* literal or a default; the param analog of `validateSecretBinding`.
|
|
892
|
-
*/
|
|
893
|
-
function validateParamNeedBinding(child, id, address, paramWiring, enclosingModuleName) {
|
|
894
|
-
for (const slot of Object.keys(child.paramSlots)) {
|
|
895
|
-
const bound = paramWiring[slot];
|
|
896
|
-
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.`);
|
|
897
|
-
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.`);
|
|
898
|
-
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.`);
|
|
899
|
-
}
|
|
900
|
-
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}").`);
|
|
901
|
-
}
|
|
902
|
-
/**
|
|
903
1041
|
* Recursively flattens one module's body into the shared graph state and
|
|
904
1042
|
* returns its resolved ModuleOutputs (one ref-port per expose key) for the
|
|
905
1043
|
* caller (the enclosing provision() call, or Load itself for the root) to
|
|
@@ -917,12 +1055,10 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
|
|
|
917
1055
|
* children carry it as their `parent`, and this module's own boundary ports
|
|
918
1056
|
* (and the authored edges touching them) are recorded against it.
|
|
919
1057
|
*/
|
|
920
|
-
function flatten(moduleNode, selfId, wiring,
|
|
1058
|
+
function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
|
|
921
1059
|
ports.push(...boundaryPortsOf(selfId, moduleNode));
|
|
922
1060
|
const localIds = /* @__PURE__ */ new Set();
|
|
923
1061
|
const used = /* @__PURE__ */ new Set();
|
|
924
|
-
const usedSecrets = /* @__PURE__ */ new Set();
|
|
925
|
-
const usedParams = /* @__PURE__ */ new Set();
|
|
926
1062
|
const ctxInputs = {};
|
|
927
1063
|
for (const key of Object.keys(moduleNode.deps)) {
|
|
928
1064
|
const wired = wiring[key];
|
|
@@ -961,28 +1097,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
961
1097
|
});
|
|
962
1098
|
}
|
|
963
1099
|
};
|
|
964
|
-
const ctxSecrets = {};
|
|
965
|
-
for (const key of Object.keys(moduleNode.secretSlots)) {
|
|
966
|
-
const bound = secretWiring[key];
|
|
967
|
-
ctxSecrets[key] = typeof bound === "object" && bound !== null ? {
|
|
968
|
-
...bound,
|
|
969
|
-
[MODULE_SECRET_KEY]: key
|
|
970
|
-
} : bound;
|
|
971
|
-
}
|
|
972
|
-
const markSecretsUsed = (values) => {
|
|
973
|
-
for (const value of values) for (const key of Object.keys(ctxSecrets)) if (value === ctxSecrets[key]) usedSecrets.add(key);
|
|
974
|
-
};
|
|
975
|
-
const ctxParams = {};
|
|
976
|
-
for (const key of Object.keys(moduleNode.paramSlots)) {
|
|
977
|
-
const bound = paramWiring[key];
|
|
978
|
-
ctxParams[key] = typeof bound === "object" && bound !== null ? {
|
|
979
|
-
...bound,
|
|
980
|
-
[MODULE_PARAM_KEY]: key
|
|
981
|
-
} : bound;
|
|
982
|
-
}
|
|
983
|
-
const markParamsUsed = (values) => {
|
|
984
|
-
for (const value of values) for (const key of Object.keys(ctxParams)) if (value === ctxParams[key]) usedParams.add(key);
|
|
985
|
-
};
|
|
986
1100
|
const provision = (child, opts) => {
|
|
987
1101
|
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.`);
|
|
988
1102
|
const id = opts?.id ?? child.name;
|
|
@@ -1036,24 +1150,15 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1036
1150
|
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).`);
|
|
1037
1151
|
const localWiring = { ...provisionWiring ?? {} };
|
|
1038
1152
|
markUsed(Object.values(localWiring));
|
|
1039
|
-
const localSecrets = { ...provisionSecrets ?? {} };
|
|
1040
|
-
markSecretsUsed(Object.values(localSecrets));
|
|
1041
1153
|
const localParams = { ...provisionParams ?? {} };
|
|
1042
|
-
markParamsUsed(Object.values(localParams));
|
|
1043
1154
|
if (child.kind === "service") {
|
|
1044
1155
|
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.`);
|
|
1045
1156
|
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.`);
|
|
1046
1157
|
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}").`);
|
|
1047
|
-
if (provisionInput !== void 0) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
markParamsUsed(leaves);
|
|
1052
|
-
inputBindings.push({
|
|
1053
|
-
serviceAddress: fullAddress,
|
|
1054
|
-
binding: blindCast(provisionInput)
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1158
|
+
if (provisionInput !== void 0) inputBindings.push({
|
|
1159
|
+
serviceAddress: fullAddress,
|
|
1160
|
+
binding: blindCast(provisionInput)
|
|
1161
|
+
});
|
|
1057
1162
|
validateServiceParamBinding(child, id, localParams, moduleNode.name);
|
|
1058
1163
|
for (const [slot, binding] of Object.entries(localParams)) paramBindings.push({
|
|
1059
1164
|
serviceAddress: fullAddress,
|
|
@@ -1079,22 +1184,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1079
1184
|
byId.set(fullAddress, child);
|
|
1080
1185
|
return refFor(fullAddress, child);
|
|
1081
1186
|
}
|
|
1187
|
+
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.`);
|
|
1188
|
+
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.`);
|
|
1082
1189
|
const childInputSchema = child.inputSchema;
|
|
1083
1190
|
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}").`);
|
|
1084
1191
|
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.`);
|
|
1085
|
-
if (childInputSchema !== void 0) {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
moduleAddress: fullAddress,
|
|
1092
|
-
schema: childInputSchema,
|
|
1093
|
-
binding: provisionInput
|
|
1094
|
-
});
|
|
1095
|
-
}
|
|
1096
|
-
validateSecretBinding(child, id, fullAddress, localSecrets, moduleNode.name);
|
|
1097
|
-
validateParamNeedBinding(child, id, fullAddress, localParams, moduleNode.name);
|
|
1192
|
+
if (childInputSchema !== void 0) moduleInputs.push({
|
|
1193
|
+
moduleAddress: fullAddress,
|
|
1194
|
+
schema: childInputSchema,
|
|
1195
|
+
binding: provisionInput,
|
|
1196
|
+
fromConfigPool: false
|
|
1197
|
+
});
|
|
1098
1198
|
edges.push(...wiringEdges(localWiring, fullAddress));
|
|
1099
1199
|
recordAuthoredWiring(fullAddress, localWiring);
|
|
1100
1200
|
pending.push({
|
|
@@ -1104,7 +1204,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1104
1204
|
targetKind: "module",
|
|
1105
1205
|
enclosingModuleName: moduleNode.name
|
|
1106
1206
|
});
|
|
1107
|
-
const childOutputs = flatten(child, fullAddress, localWiring,
|
|
1207
|
+
const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1108
1208
|
nodes.push({
|
|
1109
1209
|
id: fullAddress,
|
|
1110
1210
|
parent: selfId,
|
|
@@ -1126,8 +1226,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1126
1226
|
};
|
|
1127
1227
|
const ctx = blindCast({
|
|
1128
1228
|
deps: ctxInputs,
|
|
1129
|
-
secrets: ctxSecrets,
|
|
1130
|
-
params: ctxParams,
|
|
1131
1229
|
input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
|
|
1132
1230
|
environment: environmentFacts,
|
|
1133
1231
|
provision: blindCast(provision)
|
|
@@ -1135,8 +1233,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1135
1233
|
const outputs = blindCast(moduleNode.body(ctx) ?? {});
|
|
1136
1234
|
markUsed(Object.values(outputs));
|
|
1137
1235
|
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.`);
|
|
1138
|
-
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.`);
|
|
1139
|
-
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.`);
|
|
1140
1236
|
for (const [key, contract] of Object.entries(moduleNode.expose)) {
|
|
1141
1237
|
const port = outputs[key];
|
|
1142
1238
|
if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
|
|
@@ -1161,29 +1257,27 @@ function loadModule(root, opts) {
|
|
|
1161
1257
|
const names = rootDepKeys.map((k) => `"${k}"`).join(", ");
|
|
1162
1258
|
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.`);
|
|
1163
1259
|
}
|
|
1164
|
-
const
|
|
1165
|
-
if (
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1260
|
+
const moduleInputs = [];
|
|
1261
|
+
if (root.inputSchema !== void 0) {
|
|
1262
|
+
if (opts?.configPool === void 0) throw new LoadError(`Module "${root.name}" declares input and is being deployed as the root, but Load was given no values from the \`config\` adapters to fill it from. Pass { configPool } to Load; prisma deploy and prisma dev pass the values the \`config\` adapters return.`);
|
|
1263
|
+
moduleInputs.push({
|
|
1264
|
+
moduleAddress: rootId,
|
|
1265
|
+
schema: root.inputSchema,
|
|
1266
|
+
binding: opts.configPool,
|
|
1267
|
+
fromConfigPool: true
|
|
1268
|
+
});
|
|
1173
1269
|
}
|
|
1174
|
-
if (root.inputSchema !== void 0) throw new LoadError(`Module "${root.name}" declares input but is being deployed as the root. Composer cannot fill a root's input yet; provision "${root.name}" from another module and bind its input there.`);
|
|
1175
1270
|
const nodes = [];
|
|
1176
1271
|
const edges = [];
|
|
1177
1272
|
const pending = [];
|
|
1178
1273
|
const inputBindings = [];
|
|
1179
1274
|
const paramBindings = [];
|
|
1180
|
-
const moduleInputs = [];
|
|
1181
1275
|
const byId = /* @__PURE__ */ new Map();
|
|
1182
1276
|
const ports = [];
|
|
1183
1277
|
const authoredEdges = [];
|
|
1184
1278
|
const loading = { sealed: false };
|
|
1185
1279
|
try {
|
|
1186
|
-
flatten(root, rootId, {},
|
|
1280
|
+
flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1187
1281
|
for (const entry of pending) validateWiring(entry, byId);
|
|
1188
1282
|
assertDependencyDag(edges);
|
|
1189
1283
|
} finally {
|
|
@@ -1193,6 +1287,7 @@ function loadModule(root, opts) {
|
|
|
1193
1287
|
for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
|
|
1194
1288
|
const resolved = resolveValues({
|
|
1195
1289
|
environment: opts?.environment,
|
|
1290
|
+
configPool: opts?.configPool,
|
|
1196
1291
|
inputBindings,
|
|
1197
1292
|
params: paramBindings,
|
|
1198
1293
|
moduleInputs,
|
|
@@ -1218,7 +1313,8 @@ function loadModule(root, opts) {
|
|
|
1218
1313
|
ports,
|
|
1219
1314
|
authoredEdges,
|
|
1220
1315
|
inputBindings: resolved.inputBindings,
|
|
1221
|
-
params: resolved.params
|
|
1316
|
+
params: resolved.params,
|
|
1317
|
+
secretSources: resolved.secretSources
|
|
1222
1318
|
};
|
|
1223
1319
|
}
|
|
1224
1320
|
/**
|
|
@@ -1291,7 +1387,7 @@ function Load(root, opts) {
|
|
|
1291
1387
|
throw new LoadError("Load expects a service or module root (received another node kind).");
|
|
1292
1388
|
}
|
|
1293
1389
|
//#endregion
|
|
1294
|
-
//#region ../../0-framework/3-tooling/cli/dist/validate-environment-
|
|
1390
|
+
//#region ../../0-framework/3-tooling/cli/dist/validate-environment-BNZC6W46.mjs
|
|
1295
1391
|
/**
|
|
1296
1392
|
* Synchronous Node resolve hook so that entry modules may import relative
|
|
1297
1393
|
* files using the specifier forms TypeScript accepts by default —
|
|
@@ -1401,7 +1497,7 @@ function explainJsxLoadError(error, entryPath) {
|
|
|
1401
1497
|
};
|
|
1402
1498
|
}
|
|
1403
1499
|
/**
|
|
1404
|
-
* Pipeline step
|
|
1500
|
+
* Pipeline step 2 (deploy-cli.md § The pipeline): import the entry module
|
|
1405
1501
|
* (resolved against cwd) and require its default export to be a node — a
|
|
1406
1502
|
* service or module, branded by core's factories. Whatever this module exports
|
|
1407
1503
|
* IS the application; nothing else marks a root (ADR-0003).
|
|
@@ -1483,6 +1579,7 @@ function validateRegistryCoverage(graph, config) {
|
|
|
1483
1579
|
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
1484
1580
|
* cannot drift.
|
|
1485
1581
|
*/
|
|
1582
|
+
const NO_SECRETS = Object.freeze({});
|
|
1486
1583
|
function configError(findings, file) {
|
|
1487
1584
|
const [first] = findings;
|
|
1488
1585
|
return new CliStructuredError(first.code, first.summary, {
|
|
@@ -1559,9 +1656,18 @@ async function runPipeline(entry, overrideName, environment, cwd, source, deps =
|
|
|
1559
1656
|
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
1560
1657
|
const name = overrideName ?? entryModule.root.name;
|
|
1561
1658
|
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
1659
|
+
const poolInput = {
|
|
1660
|
+
environment,
|
|
1661
|
+
configFile: configSource.file
|
|
1662
|
+
};
|
|
1663
|
+
const pools = {
|
|
1664
|
+
config: await readConfigPool(config, poolInput),
|
|
1665
|
+
secrets: deps.readSecrets === true ? await readSecretsPool(config, poolInput) : NO_SECRETS
|
|
1666
|
+
};
|
|
1562
1667
|
const graph = Load(entryModule.root, {
|
|
1563
1668
|
id: name,
|
|
1564
|
-
environment: { name: environment }
|
|
1669
|
+
environment: { name: environment },
|
|
1670
|
+
configPool: pools.config
|
|
1565
1671
|
});
|
|
1566
1672
|
if (graph.root.node.kind !== "module") throw new CliStructuredError("COMPOSE.ROOT_NOT_MODULE", "The deploy root must be a module.", { fix: "Wrap your service, e.g. export default module('name', ({ provision }) => { provision(service); })." });
|
|
1567
1673
|
validateRegistryCoverage(graph, config);
|
|
@@ -1578,7 +1684,8 @@ async function runPipeline(entry, overrideName, environment, cwd, source, deps =
|
|
|
1578
1684
|
entryModule,
|
|
1579
1685
|
graph,
|
|
1580
1686
|
name,
|
|
1581
|
-
assembled
|
|
1687
|
+
assembled,
|
|
1688
|
+
pools
|
|
1582
1689
|
};
|
|
1583
1690
|
}
|
|
1584
1691
|
/** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
|
|
@@ -1593,4 +1700,4 @@ function validateEnvironmentName(environment, spawn = spawnSync) {
|
|
|
1593
1700
|
//#endregion
|
|
1594
1701
|
export { validateEnvironmentName as i, resolveAppIdentity as n, runPipeline as r, checkConfigSource as t };
|
|
1595
1702
|
|
|
1596
|
-
//# sourceMappingURL=validate-environment-
|
|
1703
|
+
//# sourceMappingURL=validate-environment-BNZC6W46-DY_7cPQJ.mjs.map
|