@prisma/composer-cli 0.36.0-dev.2 → 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-D_UIh9Ne.mjs → dev-current-BurA9uhA-BWYAftn9.mjs} +6 -6
- package/dist/{dev-current-BNoPkDRU-D_UIh9Ne.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-DiqyXoh9.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-CBl6TlQ0.mjs → execute-dev-4KYkqSMh-uh7gnPyS.mjs} +33 -17
- package/dist/{execute-dev-DIEyloWn-CBl6TlQ0.mjs.map → execute-dev-4KYkqSMh-uh7gnPyS.mjs.map} +1 -1
- package/dist/{execute-dev-current-CeKI-tiC-BVg5a-5b.mjs → execute-dev-current-Cd4YEUZk-b2L-LwbT.mjs} +6 -6
- package/dist/{execute-dev-current-CeKI-tiC-BVg5a-5b.mjs.map → execute-dev-current-Cd4YEUZk-b2L-LwbT.mjs.map} +1 -1
- package/dist/{family-Dy3ZQOxG-BGwHvqM_.d.mts → family-DACJfaA5-CBuEC2B3.d.mts} +166 -71
- 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-s0gjqC-r.mjs → list-deployed-CH3SMsQ4.mjs} +4 -4
- package/dist/{list-deployed-s0gjqC-r.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-ExABehBM.mjs → validate-environment-BNZC6W46-DY_7cPQJ.mjs} +529 -169
- 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-DiqyXoh9.mjs.map +0 -1
- package/dist/family-Dy3ZQOxG-BGwHvqM_.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-ExABehBM.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,7 +168,30 @@ async function assembleServices(graph, config, cwd, run, onEvent, options = {})
|
|
|
101
168
|
};
|
|
102
169
|
}
|
|
103
170
|
//#endregion
|
|
104
|
-
//#region ../../0-framework/
|
|
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
|
|
183
|
+
//#region ../../0-framework/0-foundation/foundation/dist/secret-DoWGmN7m.mjs
|
|
184
|
+
const SECRET_BOX = blindCast(Symbol.for("prisma:secret-box"));
|
|
185
|
+
/**
|
|
186
|
+
* True for a redacting secret box — what a schema's secret leaf checks
|
|
187
|
+
* (ADR-0042). Reads the brand rather than `instanceof`, so a box from a
|
|
188
|
+
* duplicated module copy in a bundle counts and a look-alike does not.
|
|
189
|
+
*/
|
|
190
|
+
function isSecretString(value) {
|
|
191
|
+
return typeof value === "object" && value !== null && blindCast(value)[SECRET_BOX] === true;
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region ../../0-framework/1-core/core/dist/graph-gE31_ToO.mjs
|
|
105
195
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
106
196
|
const RESOURCE_OUT_PORT = "$out";
|
|
107
197
|
/**
|
|
@@ -122,7 +212,7 @@ function contractStyleOf(contract) {
|
|
|
122
212
|
}
|
|
123
213
|
const VALUE = blindCast(Symbol.for("prisma:value"));
|
|
124
214
|
const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
|
|
125
|
-
/** True if `value` is a `Value
|
|
215
|
+
/** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
|
|
126
216
|
function isValue(value) {
|
|
127
217
|
return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
|
|
128
218
|
}
|
|
@@ -144,21 +234,119 @@ const environmentFacts = Object.freeze({ name: Object.freeze({
|
|
|
144
234
|
fact: "name"
|
|
145
235
|
})
|
|
146
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
|
+
}
|
|
147
326
|
/**
|
|
148
327
|
* Core model: node types and the factories that construct them, plain frozen
|
|
149
328
|
* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).
|
|
150
329
|
*/
|
|
151
330
|
const NODE = Symbol.for("prisma:node");
|
|
152
|
-
blindCast(Symbol.for("prisma:secret-need"));
|
|
153
331
|
const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
|
|
154
|
-
/** True if `value` is a secret source
|
|
332
|
+
/** True if `value` is a secret source, such as an `envSecret()` result. */
|
|
155
333
|
function isSecretSource(value) {
|
|
156
334
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
|
|
157
335
|
}
|
|
158
336
|
blindCast(Symbol.for("prisma:provision-need"));
|
|
159
337
|
const PARAM_SOURCE = blindCast(Symbol.for("prisma:param-source"));
|
|
160
|
-
|
|
161
|
-
/** 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. */
|
|
162
350
|
function isParamSource(value) {
|
|
163
351
|
return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
|
|
164
352
|
}
|
|
@@ -310,7 +498,8 @@ function loadService(root, rootId) {
|
|
|
310
498
|
ports: boundaryPortsOf(rootId, root),
|
|
311
499
|
authoredEdges: [],
|
|
312
500
|
inputBindings: [],
|
|
313
|
-
params: []
|
|
501
|
+
params: [],
|
|
502
|
+
secretSources: []
|
|
314
503
|
};
|
|
315
504
|
}
|
|
316
505
|
function joinPath(path, key) {
|
|
@@ -318,12 +507,22 @@ function joinPath(path, key) {
|
|
|
318
507
|
}
|
|
319
508
|
function describeSite(site) {
|
|
320
509
|
switch (site.kind) {
|
|
321
|
-
case "
|
|
510
|
+
case "serviceInput": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
|
|
511
|
+
case "moduleInput": return site.path === "" ? `the input binding of module "${site.address}"` : `input key "${site.path}" of module "${site.address}"`;
|
|
322
512
|
case "param": return `param "${site.path}" of service "${site.address}"`;
|
|
323
513
|
case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
|
|
324
514
|
}
|
|
325
515
|
}
|
|
326
|
-
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
|
+
}
|
|
327
526
|
if (isValue(value)) {
|
|
328
527
|
found.push({
|
|
329
528
|
value,
|
|
@@ -331,7 +530,6 @@ function collect(value, site, found, seen) {
|
|
|
331
530
|
});
|
|
332
531
|
return;
|
|
333
532
|
}
|
|
334
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
335
533
|
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
336
534
|
if (seen.has(value)) return;
|
|
337
535
|
seen.add(value);
|
|
@@ -341,7 +539,7 @@ function collect(value, site, found, seen) {
|
|
|
341
539
|
collect(member, {
|
|
342
540
|
...site,
|
|
343
541
|
path
|
|
344
|
-
}, found, seen);
|
|
542
|
+
}, found, seen, recordSecret);
|
|
345
543
|
}
|
|
346
544
|
}
|
|
347
545
|
function describeNotPlain(value) {
|
|
@@ -355,16 +553,45 @@ function describeNotPlain(value) {
|
|
|
355
553
|
}
|
|
356
554
|
}
|
|
357
555
|
function isThenable(value) {
|
|
556
|
+
if (isValue(value)) return false;
|
|
358
557
|
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
359
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
|
+
}
|
|
360
587
|
function checkResult(result, fnLabel) {
|
|
361
588
|
if (isThenable(result)) throw new LoadError(`${fnLabel} returned a Promise. resolve() runs synchronously at Load.`);
|
|
362
589
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
363
590
|
const walk = (value, path) => {
|
|
364
591
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
365
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.`);
|
|
366
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.`);
|
|
367
|
-
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.`);
|
|
368
595
|
const notPlain = describeNotPlain(value);
|
|
369
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.`);
|
|
370
597
|
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
@@ -374,13 +601,42 @@ function checkResult(result, fnLabel) {
|
|
|
374
601
|
};
|
|
375
602
|
walk(result, "");
|
|
376
603
|
}
|
|
377
|
-
|
|
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);
|
|
378
635
|
if (isValue(value)) return results.get(value);
|
|
379
|
-
if (isSecretSource(value) || isParamSource(value)) return value;
|
|
380
636
|
if (Array.isArray(value)) {
|
|
381
637
|
if (inProgress.has(value)) return value;
|
|
382
638
|
inProgress.add(value);
|
|
383
|
-
const rebuilt = value.map((member) => substitute(member, results, inProgress));
|
|
639
|
+
const rebuilt = value.map((member) => substitute(member, results, inProgress, sources));
|
|
384
640
|
inProgress.delete(value);
|
|
385
641
|
return rebuilt.every((member, index) => member === value[index]) ? value : rebuilt;
|
|
386
642
|
}
|
|
@@ -390,39 +646,161 @@ function substitute(value, results, inProgress) {
|
|
|
390
646
|
const rebuilt = {};
|
|
391
647
|
let changed = false;
|
|
392
648
|
for (const [key, member] of Object.entries(value)) {
|
|
393
|
-
|
|
394
|
-
if (
|
|
649
|
+
const real = substitute(member, results, inProgress, sources);
|
|
650
|
+
if (real === void 0 && isValue(member)) {
|
|
651
|
+
changed = true;
|
|
652
|
+
continue;
|
|
653
|
+
}
|
|
654
|
+
rebuilt[key] = real;
|
|
655
|
+
if (real !== member) changed = true;
|
|
395
656
|
}
|
|
396
657
|
inProgress.delete(value);
|
|
397
658
|
return changed ? rebuilt : value;
|
|
398
659
|
}
|
|
399
660
|
return value;
|
|
400
661
|
}
|
|
662
|
+
function describeData(value) {
|
|
663
|
+
if (Array.isArray(value)) return "an array";
|
|
664
|
+
if (typeof value === "object") return "an object that is not plain data";
|
|
665
|
+
return `a ${typeof value}`;
|
|
666
|
+
}
|
|
667
|
+
/** The data at `origin`'s path inside a validated input; `undefined` where a key or a parent is absent. */
|
|
668
|
+
function readPath(data, origin) {
|
|
669
|
+
let current = data;
|
|
670
|
+
for (const [index, key] of origin.path.entries()) {
|
|
671
|
+
if (current === void 0 || current === null) return void 0;
|
|
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]) => …).`);
|
|
679
|
+
if (!Object.hasOwn(current, key)) return void 0;
|
|
680
|
+
current = current[key];
|
|
681
|
+
}
|
|
682
|
+
return current;
|
|
683
|
+
}
|
|
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) {
|
|
705
|
+
const address = entry.moduleAddress;
|
|
706
|
+
refuseSecretBoxes(address, resolved, "");
|
|
707
|
+
const result = entry.schema["~standard"].validate(resolved);
|
|
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.`);
|
|
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.";
|
|
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}`);
|
|
724
|
+
if (isSecretString(value)) {
|
|
725
|
+
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
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.`);
|
|
727
|
+
}
|
|
728
|
+
if (Array.isArray(value)) return value.map((member, index) => restore(member, joinPath(path, index)));
|
|
729
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, restore(member, joinPath(path, key))]));
|
|
730
|
+
return value;
|
|
731
|
+
};
|
|
732
|
+
return restore(result.value, "");
|
|
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
|
+
}
|
|
401
753
|
/**
|
|
402
754
|
* Resolves every value the graph binds, dependency-first, once each, and
|
|
403
755
|
* returns each binding with its values replaced by their real values.
|
|
404
756
|
*/
|
|
405
757
|
function resolveValues(input) {
|
|
406
|
-
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
|
+
};
|
|
407
782
|
const found = [];
|
|
408
783
|
for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
|
|
409
784
|
address: serviceAddress,
|
|
410
|
-
kind: "
|
|
785
|
+
kind: "serviceInput",
|
|
411
786
|
path: ""
|
|
412
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
787
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
413
788
|
for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
|
|
414
789
|
address: serviceAddress,
|
|
415
790
|
kind: "param",
|
|
416
791
|
path: slot
|
|
417
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
792
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
418
793
|
for (const [address, resource] of input.resources) {
|
|
419
794
|
const site = {
|
|
420
795
|
address,
|
|
421
796
|
kind: "props",
|
|
422
797
|
path: ""
|
|
423
798
|
};
|
|
424
|
-
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
|
|
799
|
+
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
425
800
|
}
|
|
801
|
+
const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
|
|
802
|
+
const validatedInputs = /* @__PURE__ */ new Map();
|
|
803
|
+
const validating = /* @__PURE__ */ new Set();
|
|
426
804
|
const results = /* @__PURE__ */ new Map();
|
|
427
805
|
const visiting = [];
|
|
428
806
|
const fnLabelFor = (site) => visiting.length === 1 ? `The resolve() function for ${describeSite(site)}` : `A resolve() function that ${describeSite(site)} depends on`;
|
|
@@ -437,52 +815,104 @@ function resolveValues(input) {
|
|
|
437
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.`);
|
|
438
816
|
result = environment[origin.fact];
|
|
439
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;
|
|
440
829
|
case "computed": {
|
|
441
|
-
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
|
+
});
|
|
442
837
|
try {
|
|
443
838
|
result = origin.compute(args);
|
|
444
839
|
} catch (thrown) {
|
|
445
|
-
if (thrown instanceof LoadError) throw thrown;
|
|
840
|
+
if (thrown instanceof LoadError && !isSourceMisuse(thrown)) throw thrown;
|
|
446
841
|
const message = thrown instanceof Error ? thrown.message : String(thrown);
|
|
447
842
|
throw new LoadError(`${fnLabelFor(site)} threw: ${message}`, { cause: thrown });
|
|
448
843
|
}
|
|
449
844
|
checkResult(result, fnLabelFor(site));
|
|
450
845
|
break;
|
|
451
846
|
}
|
|
847
|
+
case "input": {
|
|
848
|
+
const entry = moduleInputByAddress.get(origin.module);
|
|
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.`);
|
|
851
|
+
result = readPath(validatedInputOf(entry), origin);
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
452
854
|
}
|
|
453
855
|
visiting.pop();
|
|
454
856
|
results.set(value, result);
|
|
455
857
|
return result;
|
|
456
858
|
};
|
|
859
|
+
const validatedInputOf = (entry) => {
|
|
860
|
+
if (validatedInputs.has(entry.moduleAddress)) return validatedInputs.get(entry.moduleAddress);
|
|
861
|
+
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.`);
|
|
862
|
+
validating.add(entry.moduleAddress);
|
|
863
|
+
const site = {
|
|
864
|
+
address: entry.moduleAddress,
|
|
865
|
+
kind: "moduleInput",
|
|
866
|
+
path: ""
|
|
867
|
+
};
|
|
868
|
+
const values = [];
|
|
869
|
+
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
870
|
+
for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
|
|
871
|
+
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet(), "resolve"), environment);
|
|
872
|
+
validating.delete(entry.moduleAddress);
|
|
873
|
+
validatedInputs.set(entry.moduleAddress, validated);
|
|
874
|
+
return validated;
|
|
875
|
+
};
|
|
876
|
+
for (const entry of input.moduleInputs) validatedInputOf(entry);
|
|
457
877
|
for (const { value, site } of found) resolveOne(value, site);
|
|
458
878
|
const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
|
|
459
|
-
if (found.length === 0)
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
+
}
|
|
464
888
|
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
465
889
|
const resourceProps = /* @__PURE__ */ new Map();
|
|
466
890
|
for (const [address, props] of authoredProps) {
|
|
467
|
-
const substituted = substitute(props, results, inProgress);
|
|
468
|
-
|
|
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);
|
|
469
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
|
+
});
|
|
470
911
|
return {
|
|
471
912
|
resourceProps,
|
|
472
|
-
inputBindings
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
serviceAddress: entry.serviceAddress,
|
|
476
|
-
binding: blindCast(binding)
|
|
477
|
-
};
|
|
478
|
-
}),
|
|
479
|
-
params: input.params.map((entry) => {
|
|
480
|
-
const binding = substitute(entry.binding, results, inProgress);
|
|
481
|
-
return binding === entry.binding ? entry : {
|
|
482
|
-
...entry,
|
|
483
|
-
binding
|
|
484
|
-
};
|
|
485
|
-
})
|
|
913
|
+
inputBindings,
|
|
914
|
+
params,
|
|
915
|
+
secretSources: secretSourcesReceivedBy(inputBindings, params)
|
|
486
916
|
};
|
|
487
917
|
}
|
|
488
918
|
/**
|
|
@@ -556,10 +986,6 @@ function producerIdOf(ref) {
|
|
|
556
986
|
* identity the branding copy creates, never on reading this back.
|
|
557
987
|
*/
|
|
558
988
|
const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
|
|
559
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.secrets` forwarding channel. */
|
|
560
|
-
const MODULE_SECRET_KEY = Symbol("prisma:module-secret-key");
|
|
561
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.params` forwarding channel. */
|
|
562
|
-
const MODULE_PARAM_KEY = Symbol("prisma:module-param-key");
|
|
563
989
|
/** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
|
|
564
990
|
function satisfiesRequired(ref, required) {
|
|
565
991
|
return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
|
|
@@ -593,25 +1019,6 @@ function validateWiring(pending, byId) {
|
|
|
593
1019
|
if (value.kind === "dependency") throw new LoadError(`Dependency "${input}" of provisioned ${targetKind} "${targetId}" is not wired to a producer (module "${enclosingModuleName}").`);
|
|
594
1020
|
}
|
|
595
1021
|
}
|
|
596
|
-
/**
|
|
597
|
-
* Flattens a value into itself plus every nested object/array member value —
|
|
598
|
-
* identity fodder for the ctx.secrets/ctx.params usage marking, which must
|
|
599
|
-
* see a forwarded source wherever it sits inside an input binding (ADR-0042).
|
|
600
|
-
* A secret/param source is an opaque leaf: it is pushed (a forwarded ref IS
|
|
601
|
-
* such a source, so identity-matching still needs it) but never descended
|
|
602
|
-
* into, so a ref buried in an unrelated source's payload is not falsely seen
|
|
603
|
-
* as used. `seen` guards object cycles so a self-referential binding cannot
|
|
604
|
-
* recurse forever.
|
|
605
|
-
*/
|
|
606
|
-
function deepValues(value, out, seen = /* @__PURE__ */ new WeakSet()) {
|
|
607
|
-
out.push(value);
|
|
608
|
-
if (typeof value !== "object" || value === null) return;
|
|
609
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
610
|
-
if (seen.has(value)) return;
|
|
611
|
-
seen.add(value);
|
|
612
|
-
const members = Array.isArray(value) ? value : Object.values(value);
|
|
613
|
-
for (const member of members) deepValues(member, out, seen);
|
|
614
|
-
}
|
|
615
1022
|
/** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */
|
|
616
1023
|
function wiringEdges(wiring, targetId) {
|
|
617
1024
|
return Object.entries(wiring).map(([input, ref]) => ({
|
|
@@ -622,48 +1029,15 @@ function wiringEdges(wiring, targetId) {
|
|
|
622
1029
|
}));
|
|
623
1030
|
}
|
|
624
1031
|
/**
|
|
625
|
-
* Checks the
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
* but resolved inline (a source carries its own name, so no whole-graph pass
|
|
630
|
-
* is needed).
|
|
631
|
-
*/
|
|
632
|
-
function validateSecretBinding(child, id, address, secretWiring, enclosingModuleName) {
|
|
633
|
-
const { kind } = child;
|
|
634
|
-
for (const slot of Object.keys(child.secretSlots)) {
|
|
635
|
-
const bound = secretWiring[slot];
|
|
636
|
-
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.`);
|
|
637
|
-
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.`);
|
|
638
|
-
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.`);
|
|
639
|
-
}
|
|
640
|
-
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}").`);
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Checks the params wired into a provisioned SERVICE: unlike a secret slot, a
|
|
644
|
-
* declared param is never required to be bound here — it may fall back to its
|
|
645
|
-
* own `default` (checked later, at `buildConfig`) — so this only rejects a
|
|
646
|
-
* 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.
|
|
647
1036
|
*/
|
|
648
1037
|
function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName) {
|
|
649
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}").`);
|
|
650
1039
|
}
|
|
651
1040
|
/**
|
|
652
|
-
* Checks the params wired into a provisioned MODULE: every declared
|
|
653
|
-
* param-forwarding slot must be bound to a real `ParamSource` — a slot has no
|
|
654
|
-
* schema of its own, so (unlike a service param) it cannot fall back to a
|
|
655
|
-
* literal or a default; the param analog of `validateSecretBinding`.
|
|
656
|
-
*/
|
|
657
|
-
function validateParamNeedBinding(child, id, address, paramWiring, enclosingModuleName) {
|
|
658
|
-
for (const slot of Object.keys(child.paramSlots)) {
|
|
659
|
-
const bound = paramWiring[slot];
|
|
660
|
-
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.`);
|
|
661
|
-
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.`);
|
|
662
|
-
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.`);
|
|
663
|
-
}
|
|
664
|
-
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}").`);
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
1041
|
* Recursively flattens one module's body into the shared graph state and
|
|
668
1042
|
* returns its resolved ModuleOutputs (one ref-port per expose key) for the
|
|
669
1043
|
* caller (the enclosing provision() call, or Load itself for the root) to
|
|
@@ -681,12 +1055,10 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
|
|
|
681
1055
|
* children carry it as their `parent`, and this module's own boundary ports
|
|
682
1056
|
* (and the authored edges touching them) are recorded against it.
|
|
683
1057
|
*/
|
|
684
|
-
function flatten(moduleNode, selfId, wiring,
|
|
1058
|
+
function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
|
|
685
1059
|
ports.push(...boundaryPortsOf(selfId, moduleNode));
|
|
686
1060
|
const localIds = /* @__PURE__ */ new Set();
|
|
687
1061
|
const used = /* @__PURE__ */ new Set();
|
|
688
|
-
const usedSecrets = /* @__PURE__ */ new Set();
|
|
689
|
-
const usedParams = /* @__PURE__ */ new Set();
|
|
690
1062
|
const ctxInputs = {};
|
|
691
1063
|
for (const key of Object.keys(moduleNode.deps)) {
|
|
692
1064
|
const wired = wiring[key];
|
|
@@ -725,28 +1097,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
725
1097
|
});
|
|
726
1098
|
}
|
|
727
1099
|
};
|
|
728
|
-
const ctxSecrets = {};
|
|
729
|
-
for (const key of Object.keys(moduleNode.secretSlots)) {
|
|
730
|
-
const bound = secretWiring[key];
|
|
731
|
-
ctxSecrets[key] = typeof bound === "object" && bound !== null ? {
|
|
732
|
-
...bound,
|
|
733
|
-
[MODULE_SECRET_KEY]: key
|
|
734
|
-
} : bound;
|
|
735
|
-
}
|
|
736
|
-
const markSecretsUsed = (values) => {
|
|
737
|
-
for (const value of values) for (const key of Object.keys(ctxSecrets)) if (value === ctxSecrets[key]) usedSecrets.add(key);
|
|
738
|
-
};
|
|
739
|
-
const ctxParams = {};
|
|
740
|
-
for (const key of Object.keys(moduleNode.paramSlots)) {
|
|
741
|
-
const bound = paramWiring[key];
|
|
742
|
-
ctxParams[key] = typeof bound === "object" && bound !== null ? {
|
|
743
|
-
...bound,
|
|
744
|
-
[MODULE_PARAM_KEY]: key
|
|
745
|
-
} : bound;
|
|
746
|
-
}
|
|
747
|
-
const markParamsUsed = (values) => {
|
|
748
|
-
for (const value of values) for (const key of Object.keys(ctxParams)) if (value === ctxParams[key]) usedParams.add(key);
|
|
749
|
-
};
|
|
750
1100
|
const provision = (child, opts) => {
|
|
751
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.`);
|
|
752
1102
|
const id = opts?.id ?? child.name;
|
|
@@ -800,24 +1150,15 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
800
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).`);
|
|
801
1151
|
const localWiring = { ...provisionWiring ?? {} };
|
|
802
1152
|
markUsed(Object.values(localWiring));
|
|
803
|
-
const localSecrets = { ...provisionSecrets ?? {} };
|
|
804
|
-
markSecretsUsed(Object.values(localSecrets));
|
|
805
1153
|
const localParams = { ...provisionParams ?? {} };
|
|
806
|
-
markParamsUsed(Object.values(localParams));
|
|
807
1154
|
if (child.kind === "service") {
|
|
808
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.`);
|
|
809
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.`);
|
|
810
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}").`);
|
|
811
|
-
if (provisionInput !== void 0) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
markParamsUsed(leaves);
|
|
816
|
-
inputBindings.push({
|
|
817
|
-
serviceAddress: fullAddress,
|
|
818
|
-
binding: blindCast(provisionInput)
|
|
819
|
-
});
|
|
820
|
-
}
|
|
1158
|
+
if (provisionInput !== void 0) inputBindings.push({
|
|
1159
|
+
serviceAddress: fullAddress,
|
|
1160
|
+
binding: blindCast(provisionInput)
|
|
1161
|
+
});
|
|
821
1162
|
validateServiceParamBinding(child, id, localParams, moduleNode.name);
|
|
822
1163
|
for (const [slot, binding] of Object.entries(localParams)) paramBindings.push({
|
|
823
1164
|
serviceAddress: fullAddress,
|
|
@@ -843,9 +1184,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
843
1184
|
byId.set(fullAddress, child);
|
|
844
1185
|
return refFor(fullAddress, child);
|
|
845
1186
|
}
|
|
846
|
-
if (
|
|
847
|
-
|
|
848
|
-
|
|
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.`);
|
|
1189
|
+
const childInputSchema = child.inputSchema;
|
|
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}").`);
|
|
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.`);
|
|
1192
|
+
if (childInputSchema !== void 0) moduleInputs.push({
|
|
1193
|
+
moduleAddress: fullAddress,
|
|
1194
|
+
schema: childInputSchema,
|
|
1195
|
+
binding: provisionInput,
|
|
1196
|
+
fromConfigPool: false
|
|
1197
|
+
});
|
|
849
1198
|
edges.push(...wiringEdges(localWiring, fullAddress));
|
|
850
1199
|
recordAuthoredWiring(fullAddress, localWiring);
|
|
851
1200
|
pending.push({
|
|
@@ -855,7 +1204,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
855
1204
|
targetKind: "module",
|
|
856
1205
|
enclosingModuleName: moduleNode.name
|
|
857
1206
|
});
|
|
858
|
-
const childOutputs = flatten(child, fullAddress, localWiring,
|
|
1207
|
+
const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
859
1208
|
nodes.push({
|
|
860
1209
|
id: fullAddress,
|
|
861
1210
|
parent: selfId,
|
|
@@ -877,19 +1226,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
877
1226
|
};
|
|
878
1227
|
const ctx = blindCast({
|
|
879
1228
|
deps: ctxInputs,
|
|
880
|
-
|
|
881
|
-
params: ctxParams,
|
|
1229
|
+
input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
|
|
882
1230
|
environment: environmentFacts,
|
|
883
1231
|
provision: blindCast(provision)
|
|
884
1232
|
});
|
|
885
1233
|
const outputs = blindCast(moduleNode.body(ctx) ?? {});
|
|
886
1234
|
markUsed(Object.values(outputs));
|
|
887
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.`);
|
|
888
|
-
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.`);
|
|
889
|
-
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.`);
|
|
890
1236
|
for (const [key, contract] of Object.entries(moduleNode.expose)) {
|
|
891
1237
|
const port = outputs[key];
|
|
892
1238
|
if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
|
|
1239
|
+
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.`);
|
|
893
1240
|
if (!satisfiesRequired(port, contract)) throw new LoadError(`Module "${moduleNode.name}"'s returned port for expose "${key}" does not satisfy its declared contract.`);
|
|
894
1241
|
const from = authoredSourceOf(port);
|
|
895
1242
|
if (from !== void 0) authoredEdges.push({
|
|
@@ -910,15 +1257,15 @@ function loadModule(root, opts) {
|
|
|
910
1257
|
const names = rootDepKeys.map((k) => `"${k}"`).join(", ");
|
|
911
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.`);
|
|
912
1259
|
}
|
|
913
|
-
const
|
|
914
|
-
if (
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
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
|
+
});
|
|
922
1269
|
}
|
|
923
1270
|
const nodes = [];
|
|
924
1271
|
const edges = [];
|
|
@@ -930,7 +1277,7 @@ function loadModule(root, opts) {
|
|
|
930
1277
|
const authoredEdges = [];
|
|
931
1278
|
const loading = { sealed: false };
|
|
932
1279
|
try {
|
|
933
|
-
flatten(root, rootId, {},
|
|
1280
|
+
flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
934
1281
|
for (const entry of pending) validateWiring(entry, byId);
|
|
935
1282
|
assertDependencyDag(edges);
|
|
936
1283
|
} finally {
|
|
@@ -940,8 +1287,10 @@ function loadModule(root, opts) {
|
|
|
940
1287
|
for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
|
|
941
1288
|
const resolved = resolveValues({
|
|
942
1289
|
environment: opts?.environment,
|
|
1290
|
+
configPool: opts?.configPool,
|
|
943
1291
|
inputBindings,
|
|
944
1292
|
params: paramBindings,
|
|
1293
|
+
moduleInputs,
|
|
945
1294
|
resources
|
|
946
1295
|
});
|
|
947
1296
|
const resolvedNodes = nodes.map((entry) => {
|
|
@@ -964,7 +1313,8 @@ function loadModule(root, opts) {
|
|
|
964
1313
|
ports,
|
|
965
1314
|
authoredEdges,
|
|
966
1315
|
inputBindings: resolved.inputBindings,
|
|
967
|
-
params: resolved.params
|
|
1316
|
+
params: resolved.params,
|
|
1317
|
+
secretSources: resolved.secretSources
|
|
968
1318
|
};
|
|
969
1319
|
}
|
|
970
1320
|
/**
|
|
@@ -1036,9 +1386,8 @@ function Load(root, opts) {
|
|
|
1036
1386
|
if (root.kind === "service") return loadService(root, opts?.id ?? "root");
|
|
1037
1387
|
throw new LoadError("Load expects a service or module root (received another node kind).");
|
|
1038
1388
|
}
|
|
1039
|
-
blindCast(Symbol.for("prisma:secret-box"));
|
|
1040
1389
|
//#endregion
|
|
1041
|
-
//#region ../../0-framework/3-tooling/cli/dist/validate-environment-
|
|
1390
|
+
//#region ../../0-framework/3-tooling/cli/dist/validate-environment-BNZC6W46.mjs
|
|
1042
1391
|
/**
|
|
1043
1392
|
* Synchronous Node resolve hook so that entry modules may import relative
|
|
1044
1393
|
* files using the specifier forms TypeScript accepts by default —
|
|
@@ -1148,7 +1497,7 @@ function explainJsxLoadError(error, entryPath) {
|
|
|
1148
1497
|
};
|
|
1149
1498
|
}
|
|
1150
1499
|
/**
|
|
1151
|
-
* Pipeline step
|
|
1500
|
+
* Pipeline step 2 (deploy-cli.md § The pipeline): import the entry module
|
|
1152
1501
|
* (resolved against cwd) and require its default export to be a node — a
|
|
1153
1502
|
* service or module, branded by core's factories. Whatever this module exports
|
|
1154
1503
|
* IS the application; nothing else marks a root (ADR-0003).
|
|
@@ -1230,6 +1579,7 @@ function validateRegistryCoverage(graph, config) {
|
|
|
1230
1579
|
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
1231
1580
|
* cannot drift.
|
|
1232
1581
|
*/
|
|
1582
|
+
const NO_SECRETS = Object.freeze({});
|
|
1233
1583
|
function configError(findings, file) {
|
|
1234
1584
|
const [first] = findings;
|
|
1235
1585
|
return new CliStructuredError(first.code, first.summary, {
|
|
@@ -1306,9 +1656,18 @@ async function runPipeline(entry, overrideName, environment, cwd, source, deps =
|
|
|
1306
1656
|
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
1307
1657
|
const name = overrideName ?? entryModule.root.name;
|
|
1308
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
|
+
};
|
|
1309
1667
|
const graph = Load(entryModule.root, {
|
|
1310
1668
|
id: name,
|
|
1311
|
-
environment: { name: environment }
|
|
1669
|
+
environment: { name: environment },
|
|
1670
|
+
configPool: pools.config
|
|
1312
1671
|
});
|
|
1313
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); })." });
|
|
1314
1673
|
validateRegistryCoverage(graph, config);
|
|
@@ -1325,7 +1684,8 @@ async function runPipeline(entry, overrideName, environment, cwd, source, deps =
|
|
|
1325
1684
|
entryModule,
|
|
1326
1685
|
graph,
|
|
1327
1686
|
name,
|
|
1328
|
-
assembled
|
|
1687
|
+
assembled,
|
|
1688
|
+
pools
|
|
1329
1689
|
};
|
|
1330
1690
|
}
|
|
1331
1691
|
/** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
|
|
@@ -1340,4 +1700,4 @@ function validateEnvironmentName(environment, spawn = spawnSync) {
|
|
|
1340
1700
|
//#endregion
|
|
1341
1701
|
export { validateEnvironmentName as i, resolveAppIdentity as n, runPipeline as r, checkConfigSource as t };
|
|
1342
1702
|
|
|
1343
|
-
//# sourceMappingURL=validate-environment-
|
|
1703
|
+
//# sourceMappingURL=validate-environment-BNZC6W46-DY_7cPQJ.mjs.map
|