@prisma/composer 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/{app-config-CWm3wlNA-BVGreP8x.d.mts → app-config-BvxeTt2h-CcVmwsq6.d.mts} +44 -6
- package/dist/app-config-BvxeTt2h-CcVmwsq6.d.mts.map +1 -0
- package/dist/arktype.d.mts +20 -6
- package/dist/arktype.d.mts.map +1 -1
- package/dist/arktype.mjs +46 -6
- package/dist/arktype.mjs.map +1 -1
- package/dist/config-Cn9vjklJ.d.mts +1 -0
- package/dist/config-adapters-BA_IeiX0-BiE51GeB.mjs +84 -0
- package/dist/config-adapters-BA_IeiX0-BiE51GeB.mjs.map +1 -0
- package/dist/config-pools-DiYw7wMu-DzeWrJdm.mjs +63 -0
- package/dist/config-pools-DiYw7wMu-DzeWrJdm.mjs.map +1 -0
- package/dist/config.d.mts +18 -3
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +2 -1
- package/dist/control.d.mts +11 -7
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +3 -3
- package/dist/control.mjs.map +1 -1
- package/dist/deploy-Cn9vjklJ.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/deploy.mjs +3 -2
- package/dist/deploy.mjs.map +1 -1
- package/dist/{deployment-summary-p88NV5m5-C2gLUQ8l.d.mts → deployment-summary-Cm4lN6w9-Dc69sCgo.d.mts} +5 -4
- package/dist/deployment-summary-Cm4lN6w9-Dc69sCgo.d.mts.map +1 -0
- package/dist/{deployment-summary-CDHdLtnO-DrE7GsHq.mjs → deployment-summary-QkZexVIS-DqL4znd4.mjs} +35 -11
- package/dist/deployment-summary-QkZexVIS-DqL4znd4.mjs.map +1 -0
- package/dist/describe-kind-Cpm_euxo-JFh8ejof.mjs +14 -0
- package/dist/describe-kind-Cpm_euxo-JFh8ejof.mjs.map +1 -0
- package/dist/{dev-current-BNoPkDRU-CtQMfn60.mjs → dev-current-BurA9uhA-C7E-BpRH.mjs} +5 -5
- package/dist/{dev-current-BNoPkDRU-CtQMfn60.mjs.map → dev-current-BurA9uhA-C7E-BpRH.mjs.map} +1 -1
- package/dist/{dev-environment-name-6eEr5PW8-CGk1ijP7.mjs → dev-environment-name-6eEr5PW8-BbNUVxlS.mjs} +2 -2
- package/dist/{dev-environment-name-6eEr5PW8-CGk1ijP7.mjs.map → dev-environment-name-6eEr5PW8-BbNUVxlS.mjs.map} +1 -1
- package/dist/{dist-CZ_yEZ7F.mjs → dist-0Iux8Khv.mjs} +11 -4
- package/dist/dist-0Iux8Khv.mjs.map +1 -0
- package/dist/errors-0e8IVwzi.mjs.map +1 -1
- package/dist/{execute-deploy-destroy-BIqwt1RF-CP2mVGW_.mjs → execute-deploy-destroy-Cww6zOSC-CIPx-m4I.mjs} +14 -7
- package/dist/execute-deploy-destroy-Cww6zOSC-CIPx-m4I.mjs.map +1 -0
- package/dist/{execute-dev-DIEyloWn-C0jgWe-M.mjs → execute-dev-4KYkqSMh-BP9S193k.mjs} +36 -16
- package/dist/execute-dev-4KYkqSMh-BP9S193k.mjs.map +1 -0
- package/dist/{execute-dev-current-CeKI-tiC-DVTy30tU.mjs → execute-dev-current-Cd4YEUZk-C6bs4ONa.mjs} +6 -6
- package/dist/{execute-dev-current-CeKI-tiC-DVTy30tU.mjs.map → execute-dev-current-Cd4YEUZk-C6bs4ONa.mjs.map} +1 -1
- package/dist/{execute-log-DA5AAQAA-ByUrxpMJ.mjs → execute-log-BC5o35wQ-C8QWELlP.mjs} +6 -6
- package/dist/{execute-log-DA5AAQAA-ByUrxpMJ.mjs.map → execute-log-BC5o35wQ-C8QWELlP.mjs.map} +1 -1
- package/dist/{graph-BzTSXnoQ-BvGVq0bm.d.mts → graph-CN8VuVZN-Ck2y98XZ.d.mts} +3 -3
- package/dist/graph-CN8VuVZN-Ck2y98XZ.d.mts.map +1 -0
- package/dist/{graph-MGOZJdDt-CyI8-9r7.mjs → graph-gE31_ToO-BouKBfIS.mjs} +498 -199
- package/dist/graph-gE31_ToO-BouKBfIS.mjs.map +1 -0
- package/dist/{graph-types-DfsG9Rkg-D_ARjMo7.d.mts → graph-types-R38xjBnN-cDTIX_rZ.d.mts} +153 -91
- package/dist/graph-types-R38xjBnN-cDTIX_rZ.d.mts.map +1 -0
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-D89ftK2z.d.mts → index-BHdm4Q39.d.mts} +3 -3
- package/dist/index-BHdm4Q39.d.mts.map +1 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -4
- package/dist/internal-pools.d.mts +18 -0
- package/dist/internal-pools.d.mts.map +1 -0
- package/dist/internal-pools.mjs +2 -0
- package/dist/{local-target-DySKw61w.mjs → local-target-zSdLvLyy.mjs} +4 -3
- package/dist/{local-target-DySKw61w.mjs.map → local-target-zSdLvLyy.mjs.map} +1 -1
- package/dist/local-target.d.mts +2 -2
- package/dist/local-target.d.mts.map +1 -1
- package/dist/local-target.mjs +1 -1
- package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts → nextjs-DLyeRR7M-CuGngjU4.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-BeiYsLuZ.d.mts.map → nextjs-DLyeRR7M-CuGngjU4.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/pointer-CyQZZugO-D7k3vibs.d.mts +42 -0
- package/dist/pointer-CyQZZugO-D7k3vibs.d.mts.map +1 -0
- package/dist/report.d.mts +3 -3
- package/dist/report.mjs +1 -1
- package/dist/report.mjs.map +1 -1
- package/dist/{run-alchemy-Dl_MWw4g-BZaLckHp.mjs → run-alchemy-B-Z6i3cD-C30mHT0u.mjs} +6 -5
- package/dist/run-alchemy-B-Z6i3cD-C30mHT0u.mjs.map +1 -0
- package/dist/{secret-DoWGmN7m-DO5Brq1Y.mjs → secret-DoWGmN7m-CI5Yrldp.mjs} +18 -2
- package/dist/secret-DoWGmN7m-CI5Yrldp.mjs.map +1 -0
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.d.mts.map +1 -1
- package/dist/{validate-environment-CEhUSEg2-DmAtiQhe.mjs → validate-environment-BNZC6W46-B0ESzFBn.mjs} +49 -12
- package/dist/validate-environment-BNZC6W46-B0ESzFBn.mjs.map +1 -0
- package/dist/zod.d.mts +30 -0
- package/dist/zod.d.mts.map +1 -0
- package/dist/zod.mjs +40 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +29 -13
- package/skills/prisma-composer-core-concepts/SKILL.md +38 -18
- package/src/exports/config.ts +1 -0
- package/src/exports/internal-pools.ts +1 -0
- package/src/exports/zod.ts +1 -0
- package/dist/app-config-CWm3wlNA-BVGreP8x.d.mts.map +0 -1
- package/dist/config-BSdGEsYV.d.mts +0 -1
- package/dist/deploy-BSdGEsYV.d.mts +0 -1
- package/dist/deployment-summary-CDHdLtnO-DrE7GsHq.mjs.map +0 -1
- package/dist/deployment-summary-p88NV5m5-C2gLUQ8l.d.mts.map +0 -1
- package/dist/dist-CZ_yEZ7F.mjs.map +0 -1
- package/dist/execute-deploy-destroy-BIqwt1RF-CP2mVGW_.mjs.map +0 -1
- package/dist/execute-dev-DIEyloWn-C0jgWe-M.mjs.map +0 -1
- package/dist/graph-BzTSXnoQ-BvGVq0bm.d.mts.map +0 -1
- package/dist/graph-MGOZJdDt-CyI8-9r7.mjs.map +0 -1
- package/dist/graph-types-DfsG9Rkg-D_ARjMo7.d.mts.map +0 -1
- package/dist/index-D89ftK2z.d.mts.map +0 -1
- package/dist/run-alchemy-Dl_MWw4g-BZaLckHp.mjs.map +0 -1
- package/dist/secret-CHOw4LBU-C8yXoC9N.d.mts +0 -25
- package/dist/secret-CHOw4LBU-C8yXoC9N.d.mts.map +0 -1
- package/dist/secret-DoWGmN7m-DO5Brq1Y.mjs.map +0 -1
- package/dist/validate-environment-CEhUSEg2-DmAtiQhe.mjs.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
+
import { a as isSecretPointer, n as isSecretString, r as POINTER } from "./secret-DoWGmN7m-CI5Yrldp.mjs";
|
|
3
|
+
import { t as describeKind } from "./describe-kind-Cpm_euxo-JFh8ejof.mjs";
|
|
2
4
|
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
3
5
|
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
4
|
-
//#region ../../0-framework/1-core/core/dist/graph-
|
|
6
|
+
//#region ../../0-framework/1-core/core/dist/graph-gE31_ToO.mjs
|
|
5
7
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
6
8
|
const RESOURCE_OUT_PORT = "$out";
|
|
7
9
|
/**
|
|
@@ -24,17 +26,21 @@ const VALUE = blindCast(Symbol.for("prisma:value"));
|
|
|
24
26
|
const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
|
|
25
27
|
/**
|
|
26
28
|
* A value computed from other values. `fn` receives the dependencies' real
|
|
27
|
-
* values as one tuple, in order, and returns plain data.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* values as one tuple, in order, and returns plain data. Each dependency must
|
|
30
|
+
* be a deploy-time value: listing a runtime value or a field wrapped with
|
|
31
|
+
* `field()` fails to compile, and Load refuses a dependency whose real value
|
|
32
|
+
* holds a pointer. Load runs `fn` after every module body, with `provision`
|
|
33
|
+
* disabled (ADR-0062). `fn` must be a pure function of its dependencies: a
|
|
34
|
+
* deploy runs it in two processes.
|
|
30
35
|
*/
|
|
31
36
|
function resolve(dependencies, fn) {
|
|
32
37
|
if (!Array.isArray(dependencies)) throw new Error("resolve() requires a tuple of values as its first argument.");
|
|
33
|
-
dependencies.
|
|
38
|
+
const checked = dependencies.map((dependency, index) => {
|
|
34
39
|
if (!isValue(dependency)) throw new Error(`resolve() dependency at index ${index} is not a value — list environment.name or another resolve() result.`);
|
|
40
|
+
return dependency;
|
|
35
41
|
});
|
|
36
42
|
if (typeof fn !== "function") throw new Error("resolve() requires a function as its second argument.");
|
|
37
|
-
const frozenDependencies = Object.freeze(
|
|
43
|
+
const frozenDependencies = Object.freeze(checked);
|
|
38
44
|
const compute = blindCast(fn);
|
|
39
45
|
return Object.freeze({
|
|
40
46
|
[VALUE]: true,
|
|
@@ -45,7 +51,7 @@ function resolve(dependencies, fn) {
|
|
|
45
51
|
})
|
|
46
52
|
});
|
|
47
53
|
}
|
|
48
|
-
/** True if `value` is a `Value
|
|
54
|
+
/** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
|
|
49
55
|
function isValue(value) {
|
|
50
56
|
return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
|
|
51
57
|
}
|
|
@@ -67,28 +73,111 @@ const environmentFacts = Object.freeze({ name: Object.freeze({
|
|
|
67
73
|
fact: "name"
|
|
68
74
|
})
|
|
69
75
|
}) });
|
|
76
|
+
const INSPECT = Symbol.for("nodejs.util.inspect.custom");
|
|
77
|
+
/** `input` or `input.a.b`: how an error names an input field. */
|
|
78
|
+
function inputFieldLabel(origin) {
|
|
79
|
+
return origin.path.length === 0 ? "input" : `input.${origin.path.join(".")}`;
|
|
80
|
+
}
|
|
81
|
+
function misuse(origin, what) {
|
|
82
|
+
const field = inputFieldLabel(origin);
|
|
83
|
+
return new LoadError(`${field} of module "${origin.module}" is a value, not its real value, and ${what}. A module body can only pass an input field on: into a provision() binding or as a resolve() dependency. To compute with it, it must be a plain field, not a wrapped or secret one; list it: resolve([${field}], ([v]) => …).`);
|
|
84
|
+
}
|
|
85
|
+
/** What a coercion with `hint` did to a value, worded for a misuse error. */
|
|
86
|
+
function primitiveMisuse(hint) {
|
|
87
|
+
switch (hint) {
|
|
88
|
+
case "string": return "it was turned into text (a template literal or String())";
|
|
89
|
+
case "number": return "it was turned into a number (arithmetic, or a comparison such as <)";
|
|
90
|
+
default: return "it was combined with + or compared with ==";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Builds the `input` a module body receives. Every property access returns a
|
|
95
|
+
* value recording its key path, and the same path always returns the same
|
|
96
|
+
* object, so Load's identity-keyed maps see one value per field. Any way of
|
|
97
|
+
* reading the real value throws a LoadError naming the field.
|
|
98
|
+
*/
|
|
99
|
+
function buildModuleInput(moduleAddress) {
|
|
100
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
101
|
+
const valueAt = (path) => {
|
|
102
|
+
const key = JSON.stringify(path);
|
|
103
|
+
const existing = byPath.get(key);
|
|
104
|
+
if (existing !== void 0) return existing;
|
|
105
|
+
const origin = Object.freeze({
|
|
106
|
+
kind: "input",
|
|
107
|
+
module: moduleAddress,
|
|
108
|
+
path: Object.freeze([...path])
|
|
109
|
+
});
|
|
110
|
+
const thrower = (what) => () => {
|
|
111
|
+
throw misuse(origin, what);
|
|
112
|
+
};
|
|
113
|
+
const handler = {
|
|
114
|
+
get(_target, property) {
|
|
115
|
+
if (property === VALUE) return true;
|
|
116
|
+
if (property === VALUE_ORIGIN) return origin;
|
|
117
|
+
if (property === Symbol.toPrimitive) return (hint) => {
|
|
118
|
+
throw misuse(origin, primitiveMisuse(hint));
|
|
119
|
+
};
|
|
120
|
+
if (property === "toString") return thrower("its toString() was called");
|
|
121
|
+
if (property === "valueOf") return thrower("its valueOf() was called");
|
|
122
|
+
if (property === "toJSON") return thrower("it was serialized with JSON.stringify");
|
|
123
|
+
if (property === Symbol.iterator || property === Symbol.asyncIterator) return thrower("it was iterated (array spread, for…of or array destructuring)");
|
|
124
|
+
if (typeof property === "symbol") return void 0;
|
|
125
|
+
return valueAt([...path, property]);
|
|
126
|
+
},
|
|
127
|
+
has(_target, property) {
|
|
128
|
+
if (property === VALUE || property === VALUE_ORIGIN) return true;
|
|
129
|
+
if (typeof property === "symbol") return false;
|
|
130
|
+
throw misuse(origin, `it was checked with the in operator ("${property}" in …)`);
|
|
131
|
+
},
|
|
132
|
+
ownKeys() {
|
|
133
|
+
throw misuse(origin, "its keys were listed (Object.keys, object spread, for…in or Object.entries)");
|
|
134
|
+
},
|
|
135
|
+
getOwnPropertyDescriptor() {
|
|
136
|
+
throw misuse(origin, "its properties were inspected");
|
|
137
|
+
},
|
|
138
|
+
set(_target, property) {
|
|
139
|
+
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
140
|
+
},
|
|
141
|
+
defineProperty(_target, property) {
|
|
142
|
+
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
143
|
+
},
|
|
144
|
+
deleteProperty() {
|
|
145
|
+
throw misuse(origin, "a property was deleted from it");
|
|
146
|
+
},
|
|
147
|
+
setPrototypeOf() {
|
|
148
|
+
throw misuse(origin, "its prototype was changed");
|
|
149
|
+
},
|
|
150
|
+
preventExtensions() {
|
|
151
|
+
throw misuse(origin, "it was frozen or sealed");
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const target = Object.create(null);
|
|
155
|
+
Object.defineProperty(target, INSPECT, {
|
|
156
|
+
value: () => `[${inputFieldLabel(origin)} of module "${origin.module}"]`,
|
|
157
|
+
configurable: true
|
|
158
|
+
});
|
|
159
|
+
const proxy = new Proxy(target, handler);
|
|
160
|
+
byPath.set(key, proxy);
|
|
161
|
+
return proxy;
|
|
162
|
+
};
|
|
163
|
+
return blindCast(valueAt([]));
|
|
164
|
+
}
|
|
70
165
|
/**
|
|
71
166
|
* Core model: node types and the factories that construct them, plain frozen
|
|
72
167
|
* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).
|
|
73
168
|
*/
|
|
74
169
|
const NODE = Symbol.for("prisma:node");
|
|
75
|
-
const SECRET_NEED = blindCast(Symbol.for("prisma:secret-need"));
|
|
76
170
|
const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
|
|
77
|
-
/**
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
kind: "
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
function secretSource(payload) {
|
|
86
|
-
return Object.freeze({
|
|
87
|
-
[SECRET_SOURCE]: true,
|
|
88
|
-
payload
|
|
89
|
-
});
|
|
171
|
+
/** Builds a secret source from a target-defined payload: the SPI a deploy target's own constructor (e.g. `envSecret`) calls. The source is a value whose real value at deploy is itself, a pointer. Core forwards it and never inspects the payload. */
|
|
172
|
+
function secretSource(payload, options) {
|
|
173
|
+
const label = sourceLabel("secretSource", options?.label, "a secret source");
|
|
174
|
+
return blindCast(buildSource(SECRET_SOURCE, payload, {
|
|
175
|
+
kind: "source",
|
|
176
|
+
label,
|
|
177
|
+
poolKey: void 0
|
|
178
|
+
}, "secret"));
|
|
90
179
|
}
|
|
91
|
-
/** True if `value` is a secret source
|
|
180
|
+
/** True if `value` is a secret source, such as an `envSecret()` result. */
|
|
92
181
|
function isSecretSource(value) {
|
|
93
182
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
|
|
94
183
|
}
|
|
@@ -106,25 +195,70 @@ function isProvisionNeed(value) {
|
|
|
106
195
|
return typeof value === "object" && value !== null && blindCast(value)[PROVISION_NEED] === true;
|
|
107
196
|
}
|
|
108
197
|
const PARAM_SOURCE = blindCast(Symbol.for("prisma:param-source"));
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
198
|
+
/** Builds a param source from a target-defined payload: the SPI a deploy target's own constructor (e.g. `envParam`) calls. Core forwards it and never inspects the payload. */
|
|
199
|
+
function paramSource(payload, options) {
|
|
200
|
+
const label = sourceLabel("paramSource", options?.label, "a param source");
|
|
201
|
+
const poolKey = options?.poolKey;
|
|
202
|
+
if (poolKey !== void 0 && (typeof poolKey !== "string" || poolKey.length === 0)) throw new Error("paramSource() poolKey must be a non-empty string.");
|
|
203
|
+
const redacted = options?.redacted === true;
|
|
204
|
+
if (poolKey !== void 0 && redacted) throw new Error("paramSource() takes poolKey, for a value known at deploy, or redacted, for a secret known only at boot, not both.");
|
|
205
|
+
return blindCast(buildSource(PARAM_SOURCE, payload, {
|
|
206
|
+
kind: "source",
|
|
207
|
+
label,
|
|
208
|
+
poolKey
|
|
209
|
+
}, poolKey !== void 0 ? void 0 : redacted ? "secret" : "plain"));
|
|
210
|
+
}
|
|
211
|
+
function sourceLabel(factory, label, fallback) {
|
|
212
|
+
if (label === void 0) return fallback;
|
|
213
|
+
if (typeof label !== "string" || label.length === 0) throw new Error(`${factory}() label must be a non-empty string.`);
|
|
214
|
+
return label;
|
|
215
|
+
}
|
|
216
|
+
function buildSource(brand, payload, origin, kind) {
|
|
217
|
+
const source = {
|
|
218
|
+
[VALUE]: true,
|
|
219
|
+
[VALUE_ORIGIN]: origin,
|
|
220
|
+
[brand]: true,
|
|
221
|
+
...kind === void 0 ? {} : { [POINTER]: kind },
|
|
114
222
|
payload
|
|
115
|
-
}
|
|
223
|
+
};
|
|
224
|
+
Object.defineProperty(origin, "source", { value: source });
|
|
225
|
+
Object.defineProperties(source, coercions(origin));
|
|
226
|
+
Object.freeze(origin);
|
|
227
|
+
return Object.freeze(source);
|
|
116
228
|
}
|
|
117
|
-
|
|
229
|
+
function coercions(origin) {
|
|
230
|
+
const thrower = (what) => () => {
|
|
231
|
+
throw sourceMisuse(origin, what);
|
|
232
|
+
};
|
|
233
|
+
return {
|
|
234
|
+
toString: { value: thrower("its toString() was called") },
|
|
235
|
+
valueOf: { value: thrower("its valueOf() was called") },
|
|
236
|
+
[Symbol.toPrimitive]: { value: (hint) => {
|
|
237
|
+
throw sourceMisuse(origin, primitiveMisuse(hint));
|
|
238
|
+
} }
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const sourceMisuses = /* @__PURE__ */ new WeakSet();
|
|
242
|
+
function sourceMisuse(origin, what) {
|
|
243
|
+
const { label } = origin;
|
|
244
|
+
const error = new LoadError(origin.poolKey === void 0 ? `${label} is known only at boot: the deploy holds a pointer to it, never its value, and ${what}. A module body can only pass it on, into a provision() binding; to compute with the value, do it in the service that reads it.` : `${label} is a value, not its real value, and ${what}. A module body can only pass it on: into a provision() binding or as a resolve() dependency. To compute with it, list it: resolve([${label}], ([v]) => …).`);
|
|
245
|
+
sourceMisuses.add(error);
|
|
246
|
+
return error;
|
|
247
|
+
}
|
|
248
|
+
/** True for the error a source throws when code turns it into text or a number. Internal to core. */
|
|
249
|
+
function isSourceMisuse(error) {
|
|
250
|
+
return error instanceof LoadError && sourceMisuses.has(error);
|
|
251
|
+
}
|
|
252
|
+
/** A source's origin; `undefined` for a source another installed copy of core built without one. Internal to core. */
|
|
253
|
+
function sourceOriginOf(source) {
|
|
254
|
+
if (!isValue(source)) return void 0;
|
|
255
|
+
const origin = originOf(source);
|
|
256
|
+
return origin.kind === "source" ? origin : void 0;
|
|
257
|
+
}
|
|
258
|
+
/** True if `value` is a param source, such as an `envParam()` result. */
|
|
118
259
|
function isParamSource(value) {
|
|
119
260
|
return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
|
|
120
261
|
}
|
|
121
|
-
/** Declares a module param-forwarding NEED. Nameless — bound to a `ParamSource` by an enclosing scope and forwarded into a child's real param. */
|
|
122
|
-
function paramNeed() {
|
|
123
|
-
return Object.freeze({
|
|
124
|
-
[PARAM_NEED]: true,
|
|
125
|
-
kind: "param"
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
262
|
function requireType(type, factory) {
|
|
129
263
|
if (typeof type !== "string" || type.length === 0) throw new Error(`${factory}() requires a non-empty node type.`);
|
|
130
264
|
}
|
|
@@ -304,14 +438,18 @@ function module(name, boundaryOrBody, maybeBody) {
|
|
|
304
438
|
requireName(name, "module");
|
|
305
439
|
const closedRoot = typeof boundaryOrBody === "function";
|
|
306
440
|
const boundary = closedRoot ? {} : boundaryOrBody;
|
|
441
|
+
if (Object.hasOwn(boundary, "params")) throw new Error(`module("${name}") declares \`params\`, which a module no longer takes. Declare each value as a field of the module's \`input\` schema, and bind it with provision(module, { input: { … } }) (ADR-0061).`);
|
|
442
|
+
if (Object.hasOwn(boundary, "secrets")) throw new Error(`module("${name}") declares \`secrets\`, which a module no longer takes. Declare each secret as a secretString() field of the module's \`input\` schema, and bind it with provision(module, { input: { … } }) (ADR-0061).`);
|
|
307
443
|
requireNotReservedPortNames(Object.keys(boundary.deps ?? {}), "module");
|
|
308
444
|
requireNotReservedPortNames(Object.keys(boundary.expose ?? {}), "module");
|
|
445
|
+
if (boundary.input !== void 0 && typeof boundary.input["~standard"]?.validate !== "function") throw new Error("module() `input` must be a Standard Schema (an object with a \"~standard\".validate function) — see https://standardschema.dev (ADR-0061).");
|
|
309
446
|
const deps = frozenShallowCopy(boundary.deps ?? {});
|
|
310
|
-
const secretSlots = frozenShallowCopy(boundary.secrets ?? {});
|
|
311
|
-
const paramSlots = frozenShallowCopy(boundary.params ?? {});
|
|
312
447
|
const expose = frozenShallowCopy(boundary.expose ?? {});
|
|
313
448
|
const body = closedRoot ? (ctx) => {
|
|
314
|
-
boundaryOrBody(
|
|
449
|
+
boundaryOrBody({
|
|
450
|
+
...ctx,
|
|
451
|
+
input: void 0
|
|
452
|
+
});
|
|
315
453
|
return {};
|
|
316
454
|
} : maybeBody;
|
|
317
455
|
return Object.freeze({
|
|
@@ -319,8 +457,7 @@ function module(name, boundaryOrBody, maybeBody) {
|
|
|
319
457
|
kind: "module",
|
|
320
458
|
name,
|
|
321
459
|
deps,
|
|
322
|
-
|
|
323
|
-
paramSlots,
|
|
460
|
+
inputSchema: boundary.input,
|
|
324
461
|
expose,
|
|
325
462
|
body
|
|
326
463
|
});
|
|
@@ -464,7 +601,8 @@ function loadService(root, rootId) {
|
|
|
464
601
|
ports: boundaryPortsOf(rootId, root),
|
|
465
602
|
authoredEdges: [],
|
|
466
603
|
inputBindings: [],
|
|
467
|
-
params: []
|
|
604
|
+
params: [],
|
|
605
|
+
secretSources: []
|
|
468
606
|
};
|
|
469
607
|
}
|
|
470
608
|
function joinPath(path, key) {
|
|
@@ -472,12 +610,22 @@ function joinPath(path, key) {
|
|
|
472
610
|
}
|
|
473
611
|
function describeSite(site) {
|
|
474
612
|
switch (site.kind) {
|
|
475
|
-
case "
|
|
613
|
+
case "serviceInput": return site.path === "" ? `the input binding of service "${site.address}"` : `input key "${site.path}" of service "${site.address}"`;
|
|
614
|
+
case "moduleInput": return site.path === "" ? `the input binding of module "${site.address}"` : `input key "${site.path}" of module "${site.address}"`;
|
|
476
615
|
case "param": return `param "${site.path}" of service "${site.address}"`;
|
|
477
616
|
case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
|
|
478
617
|
}
|
|
479
618
|
}
|
|
480
|
-
function collect(value, site, found, seen) {
|
|
619
|
+
function collect(value, site, found, seen, recordSecret) {
|
|
620
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
621
|
+
if (isSecretSource(value) && site.kind !== "props") recordSecret(value, site);
|
|
622
|
+
if (site.kind === "serviceInput" || site.kind === "param" || !isValue(value)) return;
|
|
623
|
+
found.push({
|
|
624
|
+
value,
|
|
625
|
+
site
|
|
626
|
+
});
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
481
629
|
if (isValue(value)) {
|
|
482
630
|
found.push({
|
|
483
631
|
value,
|
|
@@ -485,7 +633,6 @@ function collect(value, site, found, seen) {
|
|
|
485
633
|
});
|
|
486
634
|
return;
|
|
487
635
|
}
|
|
488
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
489
636
|
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
490
637
|
if (seen.has(value)) return;
|
|
491
638
|
seen.add(value);
|
|
@@ -495,7 +642,7 @@ function collect(value, site, found, seen) {
|
|
|
495
642
|
collect(member, {
|
|
496
643
|
...site,
|
|
497
644
|
path
|
|
498
|
-
}, found, seen);
|
|
645
|
+
}, found, seen, recordSecret);
|
|
499
646
|
}
|
|
500
647
|
}
|
|
501
648
|
function describeNotPlain(value) {
|
|
@@ -509,16 +656,45 @@ function describeNotPlain(value) {
|
|
|
509
656
|
}
|
|
510
657
|
}
|
|
511
658
|
function isThenable(value) {
|
|
659
|
+
if (isValue(value)) return false;
|
|
512
660
|
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
513
661
|
}
|
|
662
|
+
function canonicalSecret(source) {
|
|
663
|
+
const original = sourceOriginOf(source)?.source;
|
|
664
|
+
return isSecretSource(original) ? original : source;
|
|
665
|
+
}
|
|
666
|
+
function nodeKindOf(site) {
|
|
667
|
+
switch (site.kind) {
|
|
668
|
+
case "serviceInput":
|
|
669
|
+
case "param": return "service";
|
|
670
|
+
case "moduleInput": return "module";
|
|
671
|
+
case "props": return "resource";
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function pointersIn(values) {
|
|
675
|
+
const pointers = /* @__PURE__ */ new Set();
|
|
676
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
677
|
+
const walk = (value) => {
|
|
678
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
679
|
+
pointers.add(value);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
683
|
+
if (seen.has(value)) return;
|
|
684
|
+
seen.add(value);
|
|
685
|
+
for (const member of Array.isArray(value) ? value : Object.values(value)) walk(member);
|
|
686
|
+
};
|
|
687
|
+
walk(values);
|
|
688
|
+
return pointers;
|
|
689
|
+
}
|
|
514
690
|
function checkResult(result, fnLabel) {
|
|
515
691
|
if (isThenable(result)) throw new LoadError(`${fnLabel} returned a Promise. resolve() runs synchronously at Load.`);
|
|
516
692
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
517
693
|
const walk = (value, path) => {
|
|
518
694
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
519
695
|
if (value === void 0) throw new LoadError(`${fnLabel} returned undefined${atPath}. Return a result for every environment; Composer never picks a default.`);
|
|
696
|
+
if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a source${atPath}, such as envSecret() or envParam() called inside the function. resolve() returns plain data; bind a source directly.`);
|
|
520
697
|
if (isValue(value)) throw new LoadError(`${fnLabel} returned a value${atPath}, not a real value. List that value as a dependency; fn receives its real value.`);
|
|
521
|
-
if (isSecretSource(value) || isParamSource(value)) throw new LoadError(`${fnLabel} returned a secret or param source${atPath}. Bind envSecret() or envParam() directly; resolve() returns plain data.`);
|
|
522
698
|
const notPlain = describeNotPlain(value);
|
|
523
699
|
if (notPlain !== void 0) throw new LoadError(`${fnLabel} returned ${notPlain}${atPath}. resolve() returns plain data: strings, finite numbers, booleans, null, arrays and plain objects.`);
|
|
524
700
|
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
@@ -528,13 +704,42 @@ function checkResult(result, fnLabel) {
|
|
|
528
704
|
};
|
|
529
705
|
walk(result, "");
|
|
530
706
|
}
|
|
531
|
-
|
|
707
|
+
/** The first pointer in `value`, at any depth through arrays and plain objects, with its key path; `undefined` when there is none. */
|
|
708
|
+
function firstPointer(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
|
|
709
|
+
if (isSecretSource(value) || isParamSource(value)) return {
|
|
710
|
+
pointer: value,
|
|
711
|
+
path
|
|
712
|
+
};
|
|
713
|
+
if (!Array.isArray(value) && !isPlainObject(value)) return void 0;
|
|
714
|
+
if (seen.has(value)) return void 0;
|
|
715
|
+
seen.add(value);
|
|
716
|
+
const entries = Array.isArray(value) ? value.map((member, index) => [String(index), member]) : Object.entries(value);
|
|
717
|
+
for (const [key, member] of entries) {
|
|
718
|
+
const found = firstPointer(member, [...path, key], seen);
|
|
719
|
+
if (found !== void 0) return found;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
/** Refuses a resolve() dependency whose real value is a pointer or holds one at any depth: `fn` computes with deploy-time data only. */
|
|
723
|
+
function refusePointerDependency(fnLabel, dependency, real) {
|
|
724
|
+
const found = firstPointer(real);
|
|
725
|
+
if (found === void 0) return;
|
|
726
|
+
const label = sourceOriginOf(found.pointer)?.label ?? "a value known only at boot";
|
|
727
|
+
const origin = originOf(dependency);
|
|
728
|
+
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.`);
|
|
729
|
+
const listed = `${inputFieldLabel(origin)} of module "${origin.module}"`;
|
|
730
|
+
const field = inputFieldLabel({
|
|
731
|
+
...origin,
|
|
732
|
+
path: [...origin.path, ...found.path]
|
|
733
|
+
});
|
|
734
|
+
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.`}`);
|
|
735
|
+
}
|
|
736
|
+
function substitute(value, results, inProgress, sources) {
|
|
737
|
+
if (isSecretSource(value) || isParamSource(value)) return sources === "keep" || !isValue(value) ? value : results.get(value);
|
|
532
738
|
if (isValue(value)) return results.get(value);
|
|
533
|
-
if (isSecretSource(value) || isParamSource(value)) return value;
|
|
534
739
|
if (Array.isArray(value)) {
|
|
535
740
|
if (inProgress.has(value)) return value;
|
|
536
741
|
inProgress.add(value);
|
|
537
|
-
const rebuilt = value.map((member) => substitute(member, results, inProgress));
|
|
742
|
+
const rebuilt = value.map((member) => substitute(member, results, inProgress, sources));
|
|
538
743
|
inProgress.delete(value);
|
|
539
744
|
return rebuilt.every((member, index) => member === value[index]) ? value : rebuilt;
|
|
540
745
|
}
|
|
@@ -544,39 +749,161 @@ function substitute(value, results, inProgress) {
|
|
|
544
749
|
const rebuilt = {};
|
|
545
750
|
let changed = false;
|
|
546
751
|
for (const [key, member] of Object.entries(value)) {
|
|
547
|
-
|
|
548
|
-
if (
|
|
752
|
+
const real = substitute(member, results, inProgress, sources);
|
|
753
|
+
if (real === void 0 && isValue(member)) {
|
|
754
|
+
changed = true;
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
rebuilt[key] = real;
|
|
758
|
+
if (real !== member) changed = true;
|
|
549
759
|
}
|
|
550
760
|
inProgress.delete(value);
|
|
551
761
|
return changed ? rebuilt : value;
|
|
552
762
|
}
|
|
553
763
|
return value;
|
|
554
764
|
}
|
|
765
|
+
function describeData(value) {
|
|
766
|
+
if (Array.isArray(value)) return "an array";
|
|
767
|
+
if (typeof value === "object") return "an object that is not plain data";
|
|
768
|
+
return `a ${typeof value}`;
|
|
769
|
+
}
|
|
770
|
+
/** The data at `origin`'s path inside a validated input; `undefined` where a key or a parent is absent. */
|
|
771
|
+
function readPath(data, origin) {
|
|
772
|
+
let current = data;
|
|
773
|
+
for (const [index, key] of origin.path.entries()) {
|
|
774
|
+
if (current === void 0 || current === null) return void 0;
|
|
775
|
+
const missing = `${inputFieldLabel(origin)} of module "${origin.module}" does not exist`;
|
|
776
|
+
const parent = inputFieldLabel({
|
|
777
|
+
...origin,
|
|
778
|
+
path: origin.path.slice(0, index)
|
|
779
|
+
});
|
|
780
|
+
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.`);
|
|
781
|
+
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]) => …).`);
|
|
782
|
+
if (!Object.hasOwn(current, key)) return void 0;
|
|
783
|
+
current = current[key];
|
|
784
|
+
}
|
|
785
|
+
return current;
|
|
786
|
+
}
|
|
787
|
+
function refuseSecretBoxes(address, value, path) {
|
|
788
|
+
if (isSecretSource(value) || isParamSource(value)) return;
|
|
789
|
+
if (isSecretString(value)) throw new LoadError(`${describeSite({
|
|
790
|
+
address,
|
|
791
|
+
kind: "moduleInput",
|
|
792
|
+
path
|
|
793
|
+
})} 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().`);
|
|
794
|
+
if (Array.isArray(value)) {
|
|
795
|
+
for (const [index, member] of value.entries()) refuseSecretBoxes(address, member, joinPath(path, index));
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) refuseSecretBoxes(address, member, joinPath(path, key));
|
|
799
|
+
}
|
|
800
|
+
/** The original source each runtime value in `value` names, by its path. */
|
|
801
|
+
function sourcesByPath(value, path = "", found = /* @__PURE__ */ new Map()) {
|
|
802
|
+
if (isSecretSource(value) || isParamSource(value)) found.set(path, sourceOriginOf(value)?.source ?? value);
|
|
803
|
+
else if (Array.isArray(value)) for (const [index, member] of value.entries()) sourcesByPath(member, joinPath(path, index), found);
|
|
804
|
+
else if (isPlainObject(value)) for (const [key, member] of Object.entries(value)) sourcesByPath(member, joinPath(path, key), found);
|
|
805
|
+
return found;
|
|
806
|
+
}
|
|
807
|
+
function validateModuleInput(entry, resolved, environment) {
|
|
808
|
+
const address = entry.moduleAddress;
|
|
809
|
+
refuseSecretBoxes(address, resolved, "");
|
|
810
|
+
const result = entry.schema["~standard"].validate(resolved);
|
|
811
|
+
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.`);
|
|
812
|
+
if (result.issues !== void 0) {
|
|
813
|
+
const messages = result.issues.map((issue) => issue.message).join("; ");
|
|
814
|
+
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}"`}.`);
|
|
815
|
+
throw new LoadError(`The input binding of module "${address}" does not match the module's input schema: ${messages}`);
|
|
816
|
+
}
|
|
817
|
+
const bound = sourcesByPath(resolved);
|
|
818
|
+
const onlyChecked = "Its value is known only at boot, so a module's schema may check the field but never replace or move it.";
|
|
819
|
+
const restore = (value, path) => {
|
|
820
|
+
const expected = bound.get(path);
|
|
821
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
822
|
+
const source = sourceOriginOf(value)?.source ?? value;
|
|
823
|
+
if (source !== expected) throw new LoadError(`The input schema of module "${address}" moved ${sourceOriginOf(source)?.label} to input key "${path}". ${onlyChecked}`);
|
|
824
|
+
return source;
|
|
825
|
+
}
|
|
826
|
+
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}`);
|
|
827
|
+
if (isSecretString(value)) {
|
|
828
|
+
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
829
|
+
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.`);
|
|
830
|
+
}
|
|
831
|
+
if (Array.isArray(value)) return value.map((member, index) => restore(member, joinPath(path, index)));
|
|
832
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, restore(member, joinPath(path, key))]));
|
|
833
|
+
return value;
|
|
834
|
+
};
|
|
835
|
+
return restore(result.value, "");
|
|
836
|
+
}
|
|
837
|
+
function refusePointersInProps(address, props) {
|
|
838
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
839
|
+
const walk = (value, path) => {
|
|
840
|
+
if (isSecretSource(value) || isParamSource(value)) {
|
|
841
|
+
const label = sourceOriginOf(value)?.label ?? (isSecretSource(value) ? "a secret source" : "a param source");
|
|
842
|
+
throw new LoadError(`${describeSite({
|
|
843
|
+
address,
|
|
844
|
+
kind: "props",
|
|
845
|
+
path
|
|
846
|
+
})} is bound to ${label}, which is known only at boot. A resource's props are read at deploy; bind a value known at deploy.`);
|
|
847
|
+
}
|
|
848
|
+
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
849
|
+
if (seen.has(value)) return;
|
|
850
|
+
seen.add(value);
|
|
851
|
+
const entries = Array.isArray(value) ? value.map((member, index) => [index, member]) : Object.entries(value);
|
|
852
|
+
for (const [key, member] of entries) walk(member, joinPath(path, key));
|
|
853
|
+
};
|
|
854
|
+
walk(props, "");
|
|
855
|
+
}
|
|
555
856
|
/**
|
|
556
857
|
* Resolves every value the graph binds, dependency-first, once each, and
|
|
557
858
|
* returns each binding with its values replaced by their real values.
|
|
558
859
|
*/
|
|
559
860
|
function resolveValues(input) {
|
|
560
|
-
const { environment } = input;
|
|
861
|
+
const { environment, configPool } = input;
|
|
862
|
+
const secretUses = /* @__PURE__ */ new Map();
|
|
863
|
+
const recordSecret = (source, site) => {
|
|
864
|
+
const canonical = canonicalSecret(source);
|
|
865
|
+
if (secretUses.has(canonical)) return;
|
|
866
|
+
secretUses.set(canonical, {
|
|
867
|
+
source: canonical,
|
|
868
|
+
address: site.address,
|
|
869
|
+
nodeKind: nodeKindOf(site)
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
const secretSourcesReceivedBy = (inputBindings, params) => {
|
|
873
|
+
for (const { serviceAddress, binding } of [...inputBindings, ...params]) for (const pointer of pointersIn(binding)) {
|
|
874
|
+
if (!isSecretSource(pointer)) continue;
|
|
875
|
+
const canonical = canonicalSecret(pointer);
|
|
876
|
+
if (secretUses.get(canonical)?.nodeKind === "service") continue;
|
|
877
|
+
secretUses.set(canonical, {
|
|
878
|
+
source: canonical,
|
|
879
|
+
address: serviceAddress,
|
|
880
|
+
nodeKind: "service"
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
return [...secretUses.values()];
|
|
884
|
+
};
|
|
561
885
|
const found = [];
|
|
562
886
|
for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
|
|
563
887
|
address: serviceAddress,
|
|
564
|
-
kind: "
|
|
888
|
+
kind: "serviceInput",
|
|
565
889
|
path: ""
|
|
566
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
890
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
567
891
|
for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
|
|
568
892
|
address: serviceAddress,
|
|
569
893
|
kind: "param",
|
|
570
894
|
path: slot
|
|
571
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
895
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
572
896
|
for (const [address, resource] of input.resources) {
|
|
573
897
|
const site = {
|
|
574
898
|
address,
|
|
575
899
|
kind: "props",
|
|
576
900
|
path: ""
|
|
577
901
|
};
|
|
578
|
-
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
|
|
902
|
+
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
579
903
|
}
|
|
904
|
+
const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
|
|
905
|
+
const validatedInputs = /* @__PURE__ */ new Map();
|
|
906
|
+
const validating = /* @__PURE__ */ new Set();
|
|
580
907
|
const results = /* @__PURE__ */ new Map();
|
|
581
908
|
const visiting = [];
|
|
582
909
|
const fnLabelFor = (site) => visiting.length === 1 ? `The resolve() function for ${describeSite(site)}` : `A resolve() function that ${describeSite(site)} depends on`;
|
|
@@ -591,52 +918,104 @@ function resolveValues(input) {
|
|
|
591
918
|
if (environment === void 0) throw new LoadError(`${describeSite(site)} depends on environment.name, but Load was given no environment. Pass { environment: { name } } to Load; the deploy and dev commands do.`);
|
|
592
919
|
result = environment[origin.fact];
|
|
593
920
|
break;
|
|
921
|
+
case "source":
|
|
922
|
+
if (isSecretSource(origin.source)) recordSecret(origin.source, site);
|
|
923
|
+
if (origin.poolKey === void 0) result = origin.source;
|
|
924
|
+
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.`);
|
|
925
|
+
else {
|
|
926
|
+
const raw = configPool[origin.poolKey];
|
|
927
|
+
if (raw === void 0 || raw === "") result = void 0;
|
|
928
|
+
else if (typeof raw === "string") result = raw;
|
|
929
|
+
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.`);
|
|
930
|
+
}
|
|
931
|
+
break;
|
|
594
932
|
case "computed": {
|
|
595
|
-
const args = origin.dependencies.map((dependency) =>
|
|
933
|
+
const args = origin.dependencies.map((dependency) => {
|
|
934
|
+
const real = resolveOne(dependency, site);
|
|
935
|
+
const source = originOf(dependency);
|
|
936
|
+
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.`);
|
|
937
|
+
refusePointerDependency(fnLabelFor(site), dependency, real);
|
|
938
|
+
return real;
|
|
939
|
+
});
|
|
596
940
|
try {
|
|
597
941
|
result = origin.compute(args);
|
|
598
942
|
} catch (thrown) {
|
|
599
|
-
if (thrown instanceof LoadError) throw thrown;
|
|
943
|
+
if (thrown instanceof LoadError && !isSourceMisuse(thrown)) throw thrown;
|
|
600
944
|
const message = thrown instanceof Error ? thrown.message : String(thrown);
|
|
601
945
|
throw new LoadError(`${fnLabelFor(site)} threw: ${message}`, { cause: thrown });
|
|
602
946
|
}
|
|
603
947
|
checkResult(result, fnLabelFor(site));
|
|
604
948
|
break;
|
|
605
949
|
}
|
|
950
|
+
case "input": {
|
|
951
|
+
const entry = moduleInputByAddress.get(origin.module);
|
|
952
|
+
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.`);
|
|
953
|
+
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.`);
|
|
954
|
+
result = readPath(validatedInputOf(entry), origin);
|
|
955
|
+
break;
|
|
956
|
+
}
|
|
606
957
|
}
|
|
607
958
|
visiting.pop();
|
|
608
959
|
results.set(value, result);
|
|
609
960
|
return result;
|
|
610
961
|
};
|
|
962
|
+
const validatedInputOf = (entry) => {
|
|
963
|
+
if (validatedInputs.has(entry.moduleAddress)) return validatedInputs.get(entry.moduleAddress);
|
|
964
|
+
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.`);
|
|
965
|
+
validating.add(entry.moduleAddress);
|
|
966
|
+
const site = {
|
|
967
|
+
address: entry.moduleAddress,
|
|
968
|
+
kind: "moduleInput",
|
|
969
|
+
path: ""
|
|
970
|
+
};
|
|
971
|
+
const values = [];
|
|
972
|
+
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
973
|
+
for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
|
|
974
|
+
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet(), "resolve"), environment);
|
|
975
|
+
validating.delete(entry.moduleAddress);
|
|
976
|
+
validatedInputs.set(entry.moduleAddress, validated);
|
|
977
|
+
return validated;
|
|
978
|
+
};
|
|
979
|
+
for (const entry of input.moduleInputs) validatedInputOf(entry);
|
|
611
980
|
for (const { value, site } of found) resolveOne(value, site);
|
|
612
981
|
const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
|
|
613
|
-
if (found.length === 0)
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
982
|
+
if (found.length === 0) {
|
|
983
|
+
for (const [address, props] of authoredProps) refusePointersInProps(address, props);
|
|
984
|
+
return {
|
|
985
|
+
inputBindings: input.inputBindings,
|
|
986
|
+
params: input.params,
|
|
987
|
+
resourceProps: authoredProps,
|
|
988
|
+
secretSources: secretSourcesReceivedBy(input.inputBindings, input.params)
|
|
989
|
+
};
|
|
990
|
+
}
|
|
618
991
|
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
619
992
|
const resourceProps = /* @__PURE__ */ new Map();
|
|
620
993
|
for (const [address, props] of authoredProps) {
|
|
621
|
-
const substituted = substitute(props, results, inProgress);
|
|
622
|
-
|
|
994
|
+
const substituted = substitute(props, results, inProgress, "resolve");
|
|
995
|
+
refusePointersInProps(address, substituted);
|
|
996
|
+
const resolvedProps = substituted === props ? props : blindCast(substituted);
|
|
997
|
+
resourceProps.set(address, resolvedProps);
|
|
623
998
|
}
|
|
999
|
+
const inputBindings = input.inputBindings.map((entry) => {
|
|
1000
|
+
const binding = substitute(entry.binding, results, inProgress, "keep");
|
|
1001
|
+
return binding === entry.binding ? entry : {
|
|
1002
|
+
serviceAddress: entry.serviceAddress,
|
|
1003
|
+
binding: blindCast(binding)
|
|
1004
|
+
};
|
|
1005
|
+
});
|
|
1006
|
+
const params = input.params.flatMap((entry) => {
|
|
1007
|
+
const binding = substitute(entry.binding, results, inProgress, "keep");
|
|
1008
|
+
if (binding === void 0 && isValue(entry.binding)) return [];
|
|
1009
|
+
return [binding === entry.binding ? entry : {
|
|
1010
|
+
...entry,
|
|
1011
|
+
binding
|
|
1012
|
+
}];
|
|
1013
|
+
});
|
|
624
1014
|
return {
|
|
625
1015
|
resourceProps,
|
|
626
|
-
inputBindings
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
serviceAddress: entry.serviceAddress,
|
|
630
|
-
binding: blindCast(binding)
|
|
631
|
-
};
|
|
632
|
-
}),
|
|
633
|
-
params: input.params.map((entry) => {
|
|
634
|
-
const binding = substitute(entry.binding, results, inProgress);
|
|
635
|
-
return binding === entry.binding ? entry : {
|
|
636
|
-
...entry,
|
|
637
|
-
binding
|
|
638
|
-
};
|
|
639
|
-
})
|
|
1016
|
+
inputBindings,
|
|
1017
|
+
params,
|
|
1018
|
+
secretSources: secretSourcesReceivedBy(inputBindings, params)
|
|
640
1019
|
};
|
|
641
1020
|
}
|
|
642
1021
|
/**
|
|
@@ -710,10 +1089,6 @@ function producerIdOf(ref) {
|
|
|
710
1089
|
* identity the branding copy creates, never on reading this back.
|
|
711
1090
|
*/
|
|
712
1091
|
const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
|
|
713
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.secrets` forwarding channel. */
|
|
714
|
-
const MODULE_SECRET_KEY = Symbol("prisma:module-secret-key");
|
|
715
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.params` forwarding channel. */
|
|
716
|
-
const MODULE_PARAM_KEY = Symbol("prisma:module-param-key");
|
|
717
1092
|
/** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
|
|
718
1093
|
function satisfiesRequired(ref, required) {
|
|
719
1094
|
return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
|
|
@@ -747,25 +1122,6 @@ function validateWiring(pending, byId) {
|
|
|
747
1122
|
if (value.kind === "dependency") throw new LoadError(`Dependency "${input}" of provisioned ${targetKind} "${targetId}" is not wired to a producer (module "${enclosingModuleName}").`);
|
|
748
1123
|
}
|
|
749
1124
|
}
|
|
750
|
-
/**
|
|
751
|
-
* Flattens a value into itself plus every nested object/array member value —
|
|
752
|
-
* identity fodder for the ctx.secrets/ctx.params usage marking, which must
|
|
753
|
-
* see a forwarded source wherever it sits inside an input binding (ADR-0042).
|
|
754
|
-
* A secret/param source is an opaque leaf: it is pushed (a forwarded ref IS
|
|
755
|
-
* such a source, so identity-matching still needs it) but never descended
|
|
756
|
-
* into, so a ref buried in an unrelated source's payload is not falsely seen
|
|
757
|
-
* as used. `seen` guards object cycles so a self-referential binding cannot
|
|
758
|
-
* recurse forever.
|
|
759
|
-
*/
|
|
760
|
-
function deepValues(value, out, seen = /* @__PURE__ */ new WeakSet()) {
|
|
761
|
-
out.push(value);
|
|
762
|
-
if (typeof value !== "object" || value === null) return;
|
|
763
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
764
|
-
if (seen.has(value)) return;
|
|
765
|
-
seen.add(value);
|
|
766
|
-
const members = Array.isArray(value) ? value : Object.values(value);
|
|
767
|
-
for (const member of members) deepValues(member, out, seen);
|
|
768
|
-
}
|
|
769
1125
|
/** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */
|
|
770
1126
|
function wiringEdges(wiring, targetId) {
|
|
771
1127
|
return Object.entries(wiring).map(([input, ref]) => ({
|
|
@@ -776,48 +1132,15 @@ function wiringEdges(wiring, targetId) {
|
|
|
776
1132
|
}));
|
|
777
1133
|
}
|
|
778
1134
|
/**
|
|
779
|
-
* Checks the
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
* but resolved inline (a source carries its own name, so no whole-graph pass
|
|
784
|
-
* is needed).
|
|
785
|
-
*/
|
|
786
|
-
function validateSecretBinding(child, id, address, secretWiring, enclosingModuleName) {
|
|
787
|
-
const { kind } = child;
|
|
788
|
-
for (const slot of Object.keys(child.secretSlots)) {
|
|
789
|
-
const bound = secretWiring[slot];
|
|
790
|
-
if (bound === void 0) throw new LoadError(`Secret slot "${slot}" of provisioned ${kind} "${id}" is not bound (module "${enclosingModuleName}") — bind it with envSecret('NAME') or forward ctx.secrets.`);
|
|
791
|
-
if (isValue(bound)) throw new LoadError(`The secrets for "${address}" bind "${slot}" to a value. A value is not a secret source; bind envSecret('NAME') or a forwarded ctx.secrets ref.`);
|
|
792
|
-
if (!isSecretSource(bound)) throw new LoadError(`Secret slot "${slot}" of "${id}" (module "${enclosingModuleName}") was wired with a non-secret value — use envSecret('NAME') or a forwarded ctx.secrets ref.`);
|
|
793
|
-
}
|
|
794
|
-
for (const slot of Object.keys(secretWiring)) if (!Object.hasOwn(child.secretSlots, slot)) throw new LoadError(`The secrets for "${id}" name "${slot}", which is not a secret slot of that ${kind} (module "${enclosingModuleName}").`);
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Checks the params wired into a provisioned SERVICE: unlike a secret slot, a
|
|
798
|
-
* declared param is never required to be bound here — it may fall back to its
|
|
799
|
-
* own `default` (checked later, at `buildConfig`) — so this only rejects a
|
|
800
|
-
* wired key that names something other than a real declared param.
|
|
1135
|
+
* Checks the params wired into a provisioned SERVICE: a declared param is never
|
|
1136
|
+
* required to be bound here — it may fall back to its own `default` (checked
|
|
1137
|
+
* later, at `buildConfig`) — so this only rejects a wired key that names
|
|
1138
|
+
* something other than a real declared param.
|
|
801
1139
|
*/
|
|
802
1140
|
function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName) {
|
|
803
1141
|
for (const slot of Object.keys(paramWiring)) if (!Object.hasOwn(child.params, slot)) throw new LoadError(`The params for "${id}" name "${slot}", which is not a param of that service (module "${enclosingModuleName}").`);
|
|
804
1142
|
}
|
|
805
1143
|
/**
|
|
806
|
-
* Checks the params wired into a provisioned MODULE: every declared
|
|
807
|
-
* param-forwarding slot must be bound to a real `ParamSource` — a slot has no
|
|
808
|
-
* schema of its own, so (unlike a service param) it cannot fall back to a
|
|
809
|
-
* literal or a default; the param analog of `validateSecretBinding`.
|
|
810
|
-
*/
|
|
811
|
-
function validateParamNeedBinding(child, id, address, paramWiring, enclosingModuleName) {
|
|
812
|
-
for (const slot of Object.keys(child.paramSlots)) {
|
|
813
|
-
const bound = paramWiring[slot];
|
|
814
|
-
if (bound === void 0) throw new LoadError(`Param slot "${slot}" of provisioned module "${id}" is not bound (module "${enclosingModuleName}") — bind it with a param source (e.g. envParam('NAME')) or forward ctx.params.`);
|
|
815
|
-
if (isValue(bound)) throw new LoadError(`The params for "${address}" bind "${slot}" to a value. A module param slot takes a param source; bind envParam('NAME') or a forwarded ctx.params ref.`);
|
|
816
|
-
if (!isParamSource(bound)) throw new LoadError(`Param slot "${slot}" of "${id}" (module "${enclosingModuleName}") was wired with a non-source value — a module param-forwarding slot carries no schema to validate a literal against; use envParam('NAME') or a forwarded ctx.params ref.`);
|
|
817
|
-
}
|
|
818
|
-
for (const slot of Object.keys(paramWiring)) if (!Object.hasOwn(child.paramSlots, slot)) throw new LoadError(`The params for "${id}" name "${slot}", which is not a param slot of that module (module "${enclosingModuleName}").`);
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
1144
|
* Recursively flattens one module's body into the shared graph state and
|
|
822
1145
|
* returns its resolved ModuleOutputs (one ref-port per expose key) for the
|
|
823
1146
|
* caller (the enclosing provision() call, or Load itself for the root) to
|
|
@@ -835,12 +1158,10 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
|
|
|
835
1158
|
* children carry it as their `parent`, and this module's own boundary ports
|
|
836
1159
|
* (and the authored edges touching them) are recorded against it.
|
|
837
1160
|
*/
|
|
838
|
-
function flatten(moduleNode, selfId, wiring,
|
|
1161
|
+
function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
|
|
839
1162
|
ports.push(...boundaryPortsOf(selfId, moduleNode));
|
|
840
1163
|
const localIds = /* @__PURE__ */ new Set();
|
|
841
1164
|
const used = /* @__PURE__ */ new Set();
|
|
842
|
-
const usedSecrets = /* @__PURE__ */ new Set();
|
|
843
|
-
const usedParams = /* @__PURE__ */ new Set();
|
|
844
1165
|
const ctxInputs = {};
|
|
845
1166
|
for (const key of Object.keys(moduleNode.deps)) {
|
|
846
1167
|
const wired = wiring[key];
|
|
@@ -879,28 +1200,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
879
1200
|
});
|
|
880
1201
|
}
|
|
881
1202
|
};
|
|
882
|
-
const ctxSecrets = {};
|
|
883
|
-
for (const key of Object.keys(moduleNode.secretSlots)) {
|
|
884
|
-
const bound = secretWiring[key];
|
|
885
|
-
ctxSecrets[key] = typeof bound === "object" && bound !== null ? {
|
|
886
|
-
...bound,
|
|
887
|
-
[MODULE_SECRET_KEY]: key
|
|
888
|
-
} : bound;
|
|
889
|
-
}
|
|
890
|
-
const markSecretsUsed = (values) => {
|
|
891
|
-
for (const value of values) for (const key of Object.keys(ctxSecrets)) if (value === ctxSecrets[key]) usedSecrets.add(key);
|
|
892
|
-
};
|
|
893
|
-
const ctxParams = {};
|
|
894
|
-
for (const key of Object.keys(moduleNode.paramSlots)) {
|
|
895
|
-
const bound = paramWiring[key];
|
|
896
|
-
ctxParams[key] = typeof bound === "object" && bound !== null ? {
|
|
897
|
-
...bound,
|
|
898
|
-
[MODULE_PARAM_KEY]: key
|
|
899
|
-
} : bound;
|
|
900
|
-
}
|
|
901
|
-
const markParamsUsed = (values) => {
|
|
902
|
-
for (const value of values) for (const key of Object.keys(ctxParams)) if (value === ctxParams[key]) usedParams.add(key);
|
|
903
|
-
};
|
|
904
1203
|
const provision = (child, opts) => {
|
|
905
1204
|
if (loading.sealed) throw new LoadError(`provision() was called after module "${moduleNode.name}" was loaded, from inside a resolve() function. resolve() computes values, never structure: the graph is the same whatever inputs Composer is given (ADR-0062). Provision the node in the module body and pass the value into it.`);
|
|
906
1205
|
const id = opts?.id ?? child.name;
|
|
@@ -954,24 +1253,15 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
954
1253
|
for (const [input, ref] of Object.entries(provisionWiring ?? {})) if (isValue(ref)) throw new LoadError(`The deps for "${fullAddress}.${input}" are bound to a value. A value can configure a node, never decide its edges: the graph is the same whatever inputs Composer is given (ADR-0062).`);
|
|
955
1254
|
const localWiring = { ...provisionWiring ?? {} };
|
|
956
1255
|
markUsed(Object.values(localWiring));
|
|
957
|
-
const localSecrets = { ...provisionSecrets ?? {} };
|
|
958
|
-
markSecretsUsed(Object.values(localSecrets));
|
|
959
1256
|
const localParams = { ...provisionParams ?? {} };
|
|
960
|
-
markParamsUsed(Object.values(localParams));
|
|
961
1257
|
if (child.kind === "service") {
|
|
962
1258
|
if (provisionSecrets !== void 0) throw new LoadError(`provision("${id}") received secrets for a service — a service takes its secrets as envSecret(...) leaves of its \`input\` binding (ADR-0042), not a secrets map.`);
|
|
963
1259
|
if (child.inputSchema !== void 0 && provisionInput === void 0) throw new LoadError(`Input of provisioned service "${id}" is not bound (module "${moduleNode.name}") — the service declares an input schema; bind it with \`input: { … }\` on its provision() call.`);
|
|
964
1260
|
if (child.inputSchema === void 0 && provisionInput !== void 0) throw new LoadError(`provision("${id}") received an input binding, but the service declares no input schema (module "${moduleNode.name}").`);
|
|
965
|
-
if (provisionInput !== void 0) {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
markParamsUsed(leaves);
|
|
970
|
-
inputBindings.push({
|
|
971
|
-
serviceAddress: fullAddress,
|
|
972
|
-
binding: blindCast(provisionInput)
|
|
973
|
-
});
|
|
974
|
-
}
|
|
1261
|
+
if (provisionInput !== void 0) inputBindings.push({
|
|
1262
|
+
serviceAddress: fullAddress,
|
|
1263
|
+
binding: blindCast(provisionInput)
|
|
1264
|
+
});
|
|
975
1265
|
validateServiceParamBinding(child, id, localParams, moduleNode.name);
|
|
976
1266
|
for (const [slot, binding] of Object.entries(localParams)) paramBindings.push({
|
|
977
1267
|
serviceAddress: fullAddress,
|
|
@@ -997,9 +1287,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
997
1287
|
byId.set(fullAddress, child);
|
|
998
1288
|
return refFor(fullAddress, child);
|
|
999
1289
|
}
|
|
1000
|
-
if (
|
|
1001
|
-
|
|
1002
|
-
|
|
1290
|
+
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.`);
|
|
1291
|
+
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.`);
|
|
1292
|
+
const childInputSchema = child.inputSchema;
|
|
1293
|
+
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}").`);
|
|
1294
|
+
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.`);
|
|
1295
|
+
if (childInputSchema !== void 0) moduleInputs.push({
|
|
1296
|
+
moduleAddress: fullAddress,
|
|
1297
|
+
schema: childInputSchema,
|
|
1298
|
+
binding: provisionInput,
|
|
1299
|
+
fromConfigPool: false
|
|
1300
|
+
});
|
|
1003
1301
|
edges.push(...wiringEdges(localWiring, fullAddress));
|
|
1004
1302
|
recordAuthoredWiring(fullAddress, localWiring);
|
|
1005
1303
|
pending.push({
|
|
@@ -1009,7 +1307,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1009
1307
|
targetKind: "module",
|
|
1010
1308
|
enclosingModuleName: moduleNode.name
|
|
1011
1309
|
});
|
|
1012
|
-
const childOutputs = flatten(child, fullAddress, localWiring,
|
|
1310
|
+
const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1013
1311
|
nodes.push({
|
|
1014
1312
|
id: fullAddress,
|
|
1015
1313
|
parent: selfId,
|
|
@@ -1031,19 +1329,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1031
1329
|
};
|
|
1032
1330
|
const ctx = blindCast({
|
|
1033
1331
|
deps: ctxInputs,
|
|
1034
|
-
|
|
1035
|
-
params: ctxParams,
|
|
1332
|
+
input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
|
|
1036
1333
|
environment: environmentFacts,
|
|
1037
1334
|
provision: blindCast(provision)
|
|
1038
1335
|
});
|
|
1039
1336
|
const outputs = blindCast(moduleNode.body(ctx) ?? {});
|
|
1040
1337
|
markUsed(Object.values(outputs));
|
|
1041
1338
|
for (const key of Object.keys(moduleNode.deps)) if (!used.has(key)) throw new LoadError(`Module "${moduleNode.name}" declares dependency "${key}" but never forwards it into a provision nor returns it as an exposed interface.`);
|
|
1042
|
-
for (const key of Object.keys(moduleNode.secretSlots)) if (!usedSecrets.has(key)) throw new LoadError(`Module "${moduleNode.name}" declares secret "${key}" but never forwards it into a provision.`);
|
|
1043
|
-
for (const key of Object.keys(moduleNode.paramSlots)) if (!usedParams.has(key)) throw new LoadError(`Module "${moduleNode.name}" declares param "${key}" but never forwards it into a provision.`);
|
|
1044
1339
|
for (const [key, contract] of Object.entries(moduleNode.expose)) {
|
|
1045
1340
|
const port = outputs[key];
|
|
1046
1341
|
if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
|
|
1342
|
+
if (isValue(port)) throw new LoadError(`Module "${moduleNode.name}" returned a value for expose "${key}". A value can configure a node, never decide its edges: return a port of a node the body provisions.`);
|
|
1047
1343
|
if (!satisfiesRequired(port, contract)) throw new LoadError(`Module "${moduleNode.name}"'s returned port for expose "${key}" does not satisfy its declared contract.`);
|
|
1048
1344
|
const from = authoredSourceOf(port);
|
|
1049
1345
|
if (from !== void 0) authoredEdges.push({
|
|
@@ -1064,15 +1360,15 @@ function loadModule(root, opts) {
|
|
|
1064
1360
|
const names = rootDepKeys.map((k) => `"${k}"`).join(", ");
|
|
1065
1361
|
throw new LoadError(`Module "${root.name}" declares ${rootDepKeys.length > 1 ? "dependencies" : "dependency"} ${names} but is being deployed as the root — a root has no enclosing scope to wire them; compose "${root.name}" from another module that provisions and wires it instead.`);
|
|
1066
1362
|
}
|
|
1067
|
-
const
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1363
|
+
const moduleInputs = [];
|
|
1364
|
+
if (root.inputSchema !== void 0) {
|
|
1365
|
+
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.`);
|
|
1366
|
+
moduleInputs.push({
|
|
1367
|
+
moduleAddress: rootId,
|
|
1368
|
+
schema: root.inputSchema,
|
|
1369
|
+
binding: opts.configPool,
|
|
1370
|
+
fromConfigPool: true
|
|
1371
|
+
});
|
|
1076
1372
|
}
|
|
1077
1373
|
const nodes = [];
|
|
1078
1374
|
const edges = [];
|
|
@@ -1084,7 +1380,7 @@ function loadModule(root, opts) {
|
|
|
1084
1380
|
const authoredEdges = [];
|
|
1085
1381
|
const loading = { sealed: false };
|
|
1086
1382
|
try {
|
|
1087
|
-
flatten(root, rootId, {},
|
|
1383
|
+
flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1088
1384
|
for (const entry of pending) validateWiring(entry, byId);
|
|
1089
1385
|
assertDependencyDag(edges);
|
|
1090
1386
|
} finally {
|
|
@@ -1094,8 +1390,10 @@ function loadModule(root, opts) {
|
|
|
1094
1390
|
for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
|
|
1095
1391
|
const resolved = resolveValues({
|
|
1096
1392
|
environment: opts?.environment,
|
|
1393
|
+
configPool: opts?.configPool,
|
|
1097
1394
|
inputBindings,
|
|
1098
1395
|
params: paramBindings,
|
|
1396
|
+
moduleInputs,
|
|
1099
1397
|
resources
|
|
1100
1398
|
});
|
|
1101
1399
|
const resolvedNodes = nodes.map((entry) => {
|
|
@@ -1118,7 +1416,8 @@ function loadModule(root, opts) {
|
|
|
1118
1416
|
ports,
|
|
1119
1417
|
authoredEdges,
|
|
1120
1418
|
inputBindings: resolved.inputBindings,
|
|
1121
|
-
params: resolved.params
|
|
1419
|
+
params: resolved.params,
|
|
1420
|
+
secretSources: resolved.secretSources
|
|
1122
1421
|
};
|
|
1123
1422
|
}
|
|
1124
1423
|
/**
|
|
@@ -1191,6 +1490,6 @@ function Load(root, opts) {
|
|
|
1191
1490
|
throw new LoadError("Load expects a service or module root (received another node kind).");
|
|
1192
1491
|
}
|
|
1193
1492
|
//#endregion
|
|
1194
|
-
export {
|
|
1493
|
+
export { resource as _, assertAppName as a, slotsOf as b, isNode as c, isSecretSource as d, isValue as f, resolve as g, provisionNeed as h, ResourceNodeBase as i, isParamSource as l, paramSource as m, LoadError as n, dependency as o, module as p, RESOURCE_OUT_PORT as r, freezeNode as s, Load as t, isProvisionNeed as u, secretSource as v, service as y };
|
|
1195
1494
|
|
|
1196
|
-
//# sourceMappingURL=graph-
|
|
1495
|
+
//# sourceMappingURL=graph-gE31_ToO-BouKBfIS.mjs.map
|