@prisma/composer 0.36.0-dev.3 → 0.36.0-dev.5
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-8nfo_ECP-DngN6Z3i.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-BZ4RWg1k.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-qQ5hObmB.mjs → dev-current-BurA9uhA-C7E-BpRH.mjs} +5 -5
- package/dist/{dev-current-BNoPkDRU-qQ5hObmB.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-CQVqb52E.mjs → dist-0Iux8Khv.mjs} +11 -3
- package/dist/dist-0Iux8Khv.mjs.map +1 -0
- package/dist/errors-0e8IVwzi.mjs.map +1 -1
- package/dist/{execute-deploy-destroy-BIqwt1RF-B83XdRmn.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-L5AXbxEF.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-BMAsygzx.mjs → execute-dev-current-Cd4YEUZk-C6bs4ONa.mjs} +6 -6
- package/dist/{execute-dev-current-CeKI-tiC-BMAsygzx.mjs.map → execute-dev-current-Cd4YEUZk-C6bs4ONa.mjs.map} +1 -1
- package/dist/{execute-log-DA5AAQAA-CBNrz-1p.mjs → execute-log-BC5o35wQ-C8QWELlP.mjs} +6 -6
- package/dist/{execute-log-DA5AAQAA-CBNrz-1p.mjs.map → execute-log-BC5o35wQ-C8QWELlP.mjs.map} +1 -1
- package/dist/{graph-Dahnws6W-yKmoqSdc.d.mts → graph-CN8VuVZN-Ck2y98XZ.d.mts} +3 -3
- package/dist/graph-CN8VuVZN-Ck2y98XZ.d.mts.map +1 -0
- package/dist/{graph-KEuXGBfJ-BfR6EMoN.mjs → graph-gE31_ToO-BouKBfIS.mjs} +424 -334
- package/dist/graph-gE31_ToO-BouKBfIS.mjs.map +1 -0
- package/dist/{graph-types-Bn3tSF4x-BuHwUsq4.d.mts → graph-types-R38xjBnN-cDTIX_rZ.d.mts} +106 -82
- 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-Ba2dpziF.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-CNdHQRgH.d.mts → nextjs-DLyeRR7M-CuGngjU4.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-CNdHQRgH.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-D3vECWQz.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 +31 -18
- package/skills/prisma-composer-core-concepts/SKILL.md +37 -24
- 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-8nfo_ECP-DngN6Z3i.d.mts.map +0 -1
- package/dist/config-cJwLd_Uj.d.mts +0 -1
- package/dist/deploy-cJwLd_Uj.d.mts +0 -1
- package/dist/deployment-summary-CDHdLtnO-DrE7GsHq.mjs.map +0 -1
- package/dist/deployment-summary-p88NV5m5-BZ4RWg1k.d.mts.map +0 -1
- package/dist/dist-CQVqb52E.mjs.map +0 -1
- package/dist/execute-deploy-destroy-BIqwt1RF-B83XdRmn.mjs.map +0 -1
- package/dist/execute-dev-DIEyloWn-L5AXbxEF.mjs.map +0 -1
- package/dist/graph-Dahnws6W-yKmoqSdc.d.mts.map +0 -1
- package/dist/graph-KEuXGBfJ-BfR6EMoN.mjs.map +0 -1
- package/dist/graph-types-Bn3tSF4x-BuHwUsq4.d.mts.map +0 -1
- package/dist/index-Ba2dpziF.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-D3vECWQz.mjs.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
-
import { n as isSecretString,
|
|
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";
|
|
3
4
|
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
4
5
|
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
5
|
-
//#region ../../0-framework/1-core/core/dist/graph-
|
|
6
|
+
//#region ../../0-framework/1-core/core/dist/graph-gE31_ToO.mjs
|
|
6
7
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
7
8
|
const RESOURCE_OUT_PORT = "$out";
|
|
8
9
|
/**
|
|
@@ -25,17 +26,21 @@ const VALUE = blindCast(Symbol.for("prisma:value"));
|
|
|
25
26
|
const VALUE_ORIGIN = blindCast(Symbol.for("prisma:value-origin"));
|
|
26
27
|
/**
|
|
27
28
|
* A value computed from other values. `fn` receives the dependencies' real
|
|
28
|
-
* values as one tuple, in order, and returns plain data.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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.
|
|
31
35
|
*/
|
|
32
36
|
function resolve(dependencies, fn) {
|
|
33
37
|
if (!Array.isArray(dependencies)) throw new Error("resolve() requires a tuple of values as its first argument.");
|
|
34
|
-
dependencies.
|
|
38
|
+
const checked = dependencies.map((dependency, index) => {
|
|
35
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;
|
|
36
41
|
});
|
|
37
42
|
if (typeof fn !== "function") throw new Error("resolve() requires a function as its second argument.");
|
|
38
|
-
const frozenDependencies = Object.freeze(
|
|
43
|
+
const frozenDependencies = Object.freeze(checked);
|
|
39
44
|
const compute = blindCast(fn);
|
|
40
45
|
return Object.freeze({
|
|
41
46
|
[VALUE]: true,
|
|
@@ -46,7 +51,7 @@ function resolve(dependencies, fn) {
|
|
|
46
51
|
})
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
|
-
/** True if `value` is a `Value
|
|
54
|
+
/** True if `value` is a `Value`, a source included (checks the brand only, never a prototype). */
|
|
50
55
|
function isValue(value) {
|
|
51
56
|
return typeof value === "object" && value !== null && blindCast(value)[VALUE] === true;
|
|
52
57
|
}
|
|
@@ -68,28 +73,111 @@ const environmentFacts = Object.freeze({ name: Object.freeze({
|
|
|
68
73
|
fact: "name"
|
|
69
74
|
})
|
|
70
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
|
+
}
|
|
71
165
|
/**
|
|
72
166
|
* Core model: node types and the factories that construct them, plain frozen
|
|
73
167
|
* data objects. A node's `extension` + `type` form its deploy-time registry key (ADR-0017).
|
|
74
168
|
*/
|
|
75
169
|
const NODE = Symbol.for("prisma:node");
|
|
76
|
-
const SECRET_NEED = blindCast(Symbol.for("prisma:secret-need"));
|
|
77
170
|
const SECRET_SOURCE = blindCast(Symbol.for("prisma:secret-source"));
|
|
78
|
-
/**
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
kind: "
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
[SECRET_SOURCE]: true,
|
|
89
|
-
payload
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/** True if `value` is a secret source (an `envSecret` result or a forwarded ctx.secrets ref). */
|
|
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"));
|
|
179
|
+
}
|
|
180
|
+
/** True if `value` is a secret source, such as an `envSecret()` result. */
|
|
93
181
|
function isSecretSource(value) {
|
|
94
182
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_SOURCE] === true;
|
|
95
183
|
}
|
|
@@ -107,25 +195,70 @@ function isProvisionNeed(value) {
|
|
|
107
195
|
return typeof value === "object" && value !== null && blindCast(value)[PROVISION_NEED] === true;
|
|
108
196
|
}
|
|
109
197
|
const PARAM_SOURCE = blindCast(Symbol.for("prisma:param-source"));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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 },
|
|
115
222
|
payload
|
|
116
|
-
}
|
|
223
|
+
};
|
|
224
|
+
Object.defineProperty(origin, "source", { value: source });
|
|
225
|
+
Object.defineProperties(source, coercions(origin));
|
|
226
|
+
Object.freeze(origin);
|
|
227
|
+
return Object.freeze(source);
|
|
228
|
+
}
|
|
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
|
+
};
|
|
117
240
|
}
|
|
118
|
-
|
|
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. */
|
|
119
259
|
function isParamSource(value) {
|
|
120
260
|
return typeof value === "object" && value !== null && blindCast(value)[PARAM_SOURCE] === true;
|
|
121
261
|
}
|
|
122
|
-
/** Declares a module param-forwarding NEED. Nameless — bound to a `ParamSource` by an enclosing scope and forwarded into a child's real param. */
|
|
123
|
-
function paramNeed() {
|
|
124
|
-
return Object.freeze({
|
|
125
|
-
[PARAM_NEED]: true,
|
|
126
|
-
kind: "param"
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
262
|
function requireType(type, factory) {
|
|
130
263
|
if (typeof type !== "string" || type.length === 0) throw new Error(`${factory}() requires a non-empty node type.`);
|
|
131
264
|
}
|
|
@@ -305,12 +438,12 @@ function module(name, boundaryOrBody, maybeBody) {
|
|
|
305
438
|
requireName(name, "module");
|
|
306
439
|
const closedRoot = typeof boundaryOrBody === "function";
|
|
307
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).`);
|
|
308
443
|
requireNotReservedPortNames(Object.keys(boundary.deps ?? {}), "module");
|
|
309
444
|
requireNotReservedPortNames(Object.keys(boundary.expose ?? {}), "module");
|
|
310
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).");
|
|
311
446
|
const deps = frozenShallowCopy(boundary.deps ?? {});
|
|
312
|
-
const secretSlots = frozenShallowCopy(boundary.secrets ?? {});
|
|
313
|
-
const paramSlots = frozenShallowCopy(boundary.params ?? {});
|
|
314
447
|
const expose = frozenShallowCopy(boundary.expose ?? {});
|
|
315
448
|
const body = closedRoot ? (ctx) => {
|
|
316
449
|
boundaryOrBody({
|
|
@@ -324,8 +457,6 @@ function module(name, boundaryOrBody, maybeBody) {
|
|
|
324
457
|
kind: "module",
|
|
325
458
|
name,
|
|
326
459
|
deps,
|
|
327
|
-
secretSlots,
|
|
328
|
-
paramSlots,
|
|
329
460
|
inputSchema: boundary.input,
|
|
330
461
|
expose,
|
|
331
462
|
body
|
|
@@ -470,98 +601,10 @@ function loadService(root, rootId) {
|
|
|
470
601
|
ports: boundaryPortsOf(rootId, root),
|
|
471
602
|
authoredEdges: [],
|
|
472
603
|
inputBindings: [],
|
|
473
|
-
params: []
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
const INSPECT = Symbol.for("nodejs.util.inspect.custom");
|
|
477
|
-
/** `input` or `input.a.b`: how an error names an input field. */
|
|
478
|
-
function inputFieldLabel(origin) {
|
|
479
|
-
return origin.path.length === 0 ? "input" : `input.${origin.path.join(".")}`;
|
|
480
|
-
}
|
|
481
|
-
function misuse(origin, what) {
|
|
482
|
-
const field = inputFieldLabel(origin);
|
|
483
|
-
return new LoadError(`${field} of module "${origin.module}" is a value, not its real value, and ${what}. A module body can only pass an input field on: into a provision() binding or as a resolve() dependency. To compute with it, list it: resolve([${field}], ([v]) => …).`);
|
|
484
|
-
}
|
|
485
|
-
function primitiveMisuse(hint) {
|
|
486
|
-
switch (hint) {
|
|
487
|
-
case "string": return "it was turned into text (a template literal or String())";
|
|
488
|
-
case "number": return "it was turned into a number (arithmetic, or a comparison such as <)";
|
|
489
|
-
default: return "it was combined with + or compared with ==";
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Builds the `input` a module body receives. Every property access returns a
|
|
494
|
-
* value recording its key path, and the same path always returns the same
|
|
495
|
-
* object, so Load's identity-keyed maps see one value per field. Any way of
|
|
496
|
-
* reading the real value throws a LoadError naming the field.
|
|
497
|
-
*/
|
|
498
|
-
function buildModuleInput(moduleAddress) {
|
|
499
|
-
const byPath = /* @__PURE__ */ new Map();
|
|
500
|
-
const valueAt = (path) => {
|
|
501
|
-
const key = JSON.stringify(path);
|
|
502
|
-
const existing = byPath.get(key);
|
|
503
|
-
if (existing !== void 0) return existing;
|
|
504
|
-
const origin = Object.freeze({
|
|
505
|
-
kind: "input",
|
|
506
|
-
module: moduleAddress,
|
|
507
|
-
path: Object.freeze([...path])
|
|
508
|
-
});
|
|
509
|
-
const thrower = (what) => () => {
|
|
510
|
-
throw misuse(origin, what);
|
|
511
|
-
};
|
|
512
|
-
const handler = {
|
|
513
|
-
get(_target, property) {
|
|
514
|
-
if (property === VALUE) return true;
|
|
515
|
-
if (property === VALUE_ORIGIN) return origin;
|
|
516
|
-
if (property === Symbol.toPrimitive) return (hint) => {
|
|
517
|
-
throw misuse(origin, primitiveMisuse(hint));
|
|
518
|
-
};
|
|
519
|
-
if (property === "toString") return thrower("its toString() was called");
|
|
520
|
-
if (property === "valueOf") return thrower("its valueOf() was called");
|
|
521
|
-
if (property === "toJSON") return thrower("it was serialized with JSON.stringify");
|
|
522
|
-
if (property === Symbol.iterator || property === Symbol.asyncIterator) return thrower("it was iterated (array spread, for…of or array destructuring)");
|
|
523
|
-
if (typeof property === "symbol") return void 0;
|
|
524
|
-
return valueAt([...path, property]);
|
|
525
|
-
},
|
|
526
|
-
has(_target, property) {
|
|
527
|
-
if (property === VALUE || property === VALUE_ORIGIN) return true;
|
|
528
|
-
if (typeof property === "symbol") return false;
|
|
529
|
-
throw misuse(origin, `it was checked with the in operator ("${property}" in …)`);
|
|
530
|
-
},
|
|
531
|
-
ownKeys() {
|
|
532
|
-
throw misuse(origin, "its keys were listed (Object.keys, object spread, for…in or Object.entries)");
|
|
533
|
-
},
|
|
534
|
-
getOwnPropertyDescriptor() {
|
|
535
|
-
throw misuse(origin, "its properties were inspected");
|
|
536
|
-
},
|
|
537
|
-
set(_target, property) {
|
|
538
|
-
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
539
|
-
},
|
|
540
|
-
defineProperty(_target, property) {
|
|
541
|
-
throw misuse(origin, `its field "${String(property)}" was assigned to`);
|
|
542
|
-
},
|
|
543
|
-
deleteProperty() {
|
|
544
|
-
throw misuse(origin, "a property was deleted from it");
|
|
545
|
-
},
|
|
546
|
-
setPrototypeOf() {
|
|
547
|
-
throw misuse(origin, "its prototype was changed");
|
|
548
|
-
},
|
|
549
|
-
preventExtensions() {
|
|
550
|
-
throw misuse(origin, "it was frozen or sealed");
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
const target = Object.create(null);
|
|
554
|
-
Object.defineProperty(target, INSPECT, {
|
|
555
|
-
value: () => `[${inputFieldLabel(origin)} of module "${origin.module}"]`,
|
|
556
|
-
configurable: true
|
|
557
|
-
});
|
|
558
|
-
const proxy = new Proxy(target, handler);
|
|
559
|
-
byPath.set(key, proxy);
|
|
560
|
-
return proxy;
|
|
604
|
+
params: [],
|
|
605
|
+
secretSources: []
|
|
561
606
|
};
|
|
562
|
-
return blindCast(valueAt([]));
|
|
563
607
|
}
|
|
564
|
-
const SENTINEL_SOURCE = Symbol("prisma:module-input-sentinel");
|
|
565
608
|
function joinPath(path, key) {
|
|
566
609
|
return path === "" ? String(key) : `${path}.${key}`;
|
|
567
610
|
}
|
|
@@ -573,7 +616,16 @@ function describeSite(site) {
|
|
|
573
616
|
case "props": return site.path === "" ? `the props of resource "${site.address}"` : `prop "${site.path}" of resource "${site.address}"`;
|
|
574
617
|
}
|
|
575
618
|
}
|
|
576
|
-
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
|
+
}
|
|
577
629
|
if (isValue(value)) {
|
|
578
630
|
found.push({
|
|
579
631
|
value,
|
|
@@ -581,7 +633,6 @@ function collect(value, site, found, seen) {
|
|
|
581
633
|
});
|
|
582
634
|
return;
|
|
583
635
|
}
|
|
584
|
-
if (isSecretSource(value) || isParamSource(value)) return;
|
|
585
636
|
if (!Array.isArray(value) && !isPlainObject(value)) return;
|
|
586
637
|
if (seen.has(value)) return;
|
|
587
638
|
seen.add(value);
|
|
@@ -591,7 +642,7 @@ function collect(value, site, found, seen) {
|
|
|
591
642
|
collect(member, {
|
|
592
643
|
...site,
|
|
593
644
|
path
|
|
594
|
-
}, found, seen);
|
|
645
|
+
}, found, seen, recordSecret);
|
|
595
646
|
}
|
|
596
647
|
}
|
|
597
648
|
function describeNotPlain(value) {
|
|
@@ -608,14 +659,42 @@ function isThenable(value) {
|
|
|
608
659
|
if (isValue(value)) return false;
|
|
609
660
|
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
610
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
|
+
}
|
|
611
690
|
function checkResult(result, fnLabel) {
|
|
612
691
|
if (isThenable(result)) throw new LoadError(`${fnLabel} returned a Promise. resolve() runs synchronously at Load.`);
|
|
613
692
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
614
693
|
const walk = (value, path) => {
|
|
615
694
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
616
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.`);
|
|
617
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.`);
|
|
618
|
-
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.`);
|
|
619
698
|
const notPlain = describeNotPlain(value);
|
|
620
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.`);
|
|
621
700
|
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
@@ -625,13 +704,42 @@ function checkResult(result, fnLabel) {
|
|
|
625
704
|
};
|
|
626
705
|
walk(result, "");
|
|
627
706
|
}
|
|
628
|
-
|
|
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);
|
|
629
738
|
if (isValue(value)) return results.get(value);
|
|
630
|
-
if (isSecretSource(value) || isParamSource(value)) return value;
|
|
631
739
|
if (Array.isArray(value)) {
|
|
632
740
|
if (inProgress.has(value)) return value;
|
|
633
741
|
inProgress.add(value);
|
|
634
|
-
const rebuilt = value.map((member) => substitute(member, results, inProgress));
|
|
742
|
+
const rebuilt = value.map((member) => substitute(member, results, inProgress, sources));
|
|
635
743
|
inProgress.delete(value);
|
|
636
744
|
return rebuilt.every((member, index) => member === value[index]) ? value : rebuilt;
|
|
637
745
|
}
|
|
@@ -641,7 +749,7 @@ function substitute(value, results, inProgress) {
|
|
|
641
749
|
const rebuilt = {};
|
|
642
750
|
let changed = false;
|
|
643
751
|
for (const [key, member] of Object.entries(value)) {
|
|
644
|
-
const real = substitute(member, results, inProgress);
|
|
752
|
+
const real = substitute(member, results, inProgress, sources);
|
|
645
753
|
if (real === void 0 && isValue(member)) {
|
|
646
754
|
changed = true;
|
|
647
755
|
continue;
|
|
@@ -656,7 +764,6 @@ function substitute(value, results, inProgress) {
|
|
|
656
764
|
}
|
|
657
765
|
function describeData(value) {
|
|
658
766
|
if (Array.isArray(value)) return "an array";
|
|
659
|
-
if (isSecretSource(value)) return "a secret";
|
|
660
767
|
if (typeof value === "object") return "an object that is not plain data";
|
|
661
768
|
return `a ${typeof value}`;
|
|
662
769
|
}
|
|
@@ -665,47 +772,59 @@ function readPath(data, origin) {
|
|
|
665
772
|
let current = data;
|
|
666
773
|
for (const [index, key] of origin.path.entries()) {
|
|
667
774
|
if (current === void 0 || current === null) return void 0;
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
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]) => …).`);
|
|
675
782
|
if (!Object.hasOwn(current, key)) return void 0;
|
|
676
783
|
current = current[key];
|
|
677
784
|
}
|
|
678
785
|
return current;
|
|
679
786
|
}
|
|
680
|
-
function
|
|
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) {
|
|
681
808
|
const address = entry.moduleAddress;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
const sentinel = new SecretBox("");
|
|
685
|
-
Object.defineProperty(sentinel, SENTINEL_SOURCE, { value });
|
|
686
|
-
return sentinel;
|
|
687
|
-
}
|
|
688
|
-
if (isParamSource(value)) throw new LoadError(`${describeSite({
|
|
689
|
-
address,
|
|
690
|
-
kind: "moduleInput",
|
|
691
|
-
path
|
|
692
|
-
})} is bound to a param source, such as envParam(). A module's input does not take a param source yet; bind it on the service's input inside the module, or forward it through the module's params slot.`);
|
|
693
|
-
if (isSecretString(value)) throw new LoadError(`${describeSite({
|
|
694
|
-
address,
|
|
695
|
-
kind: "moduleInput",
|
|
696
|
-
path
|
|
697
|
-
})} 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().`);
|
|
698
|
-
if (Array.isArray(value)) return value.map((member, index) => withSentinels(member, joinPath(path, index)));
|
|
699
|
-
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, withSentinels(member, joinPath(path, key))]));
|
|
700
|
-
return value;
|
|
701
|
-
};
|
|
702
|
-
const result = entry.schema["~standard"].validate(withSentinels(resolved, ""));
|
|
809
|
+
refuseSecretBoxes(address, resolved, "");
|
|
810
|
+
const result = entry.schema["~standard"].validate(resolved);
|
|
703
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.`);
|
|
704
|
-
if (result.issues !== void 0)
|
|
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.";
|
|
705
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}`);
|
|
706
827
|
if (isSecretString(value)) {
|
|
707
|
-
const source = blindCast(value)[SENTINEL_SOURCE];
|
|
708
|
-
if (isSecretSource(source)) return source;
|
|
709
828
|
const atPath = path === "" ? "" : ` at "${path}"`;
|
|
710
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.`);
|
|
711
830
|
}
|
|
@@ -715,30 +834,72 @@ function validateModuleInput(entry, resolved) {
|
|
|
715
834
|
};
|
|
716
835
|
return restore(result.value, "");
|
|
717
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
|
+
}
|
|
718
856
|
/**
|
|
719
857
|
* Resolves every value the graph binds, dependency-first, once each, and
|
|
720
858
|
* returns each binding with its values replaced by their real values.
|
|
721
859
|
*/
|
|
722
860
|
function resolveValues(input) {
|
|
723
|
-
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
|
+
};
|
|
724
885
|
const found = [];
|
|
725
886
|
for (const { serviceAddress, binding } of input.inputBindings) collect(binding, {
|
|
726
887
|
address: serviceAddress,
|
|
727
888
|
kind: "serviceInput",
|
|
728
889
|
path: ""
|
|
729
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
890
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
730
891
|
for (const { serviceAddress, slot, binding } of input.params) collect(binding, {
|
|
731
892
|
address: serviceAddress,
|
|
732
893
|
kind: "param",
|
|
733
894
|
path: slot
|
|
734
|
-
}, found, /* @__PURE__ */ new WeakSet());
|
|
895
|
+
}, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
735
896
|
for (const [address, resource] of input.resources) {
|
|
736
897
|
const site = {
|
|
737
898
|
address,
|
|
738
899
|
kind: "props",
|
|
739
900
|
path: ""
|
|
740
901
|
};
|
|
741
|
-
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet());
|
|
902
|
+
collect(resource.props, site, found, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
742
903
|
}
|
|
743
904
|
const moduleInputByAddress = new Map(input.moduleInputs.map((entry) => [entry.moduleAddress, entry]));
|
|
744
905
|
const validatedInputs = /* @__PURE__ */ new Map();
|
|
@@ -757,12 +918,29 @@ function resolveValues(input) {
|
|
|
757
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.`);
|
|
758
919
|
result = environment[origin.fact];
|
|
759
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;
|
|
760
932
|
case "computed": {
|
|
761
|
-
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
|
+
});
|
|
762
940
|
try {
|
|
763
941
|
result = origin.compute(args);
|
|
764
942
|
} catch (thrown) {
|
|
765
|
-
if (thrown instanceof LoadError) throw thrown;
|
|
943
|
+
if (thrown instanceof LoadError && !isSourceMisuse(thrown)) throw thrown;
|
|
766
944
|
const message = thrown instanceof Error ? thrown.message : String(thrown);
|
|
767
945
|
throw new LoadError(`${fnLabelFor(site)} threw: ${message}`, { cause: thrown });
|
|
768
946
|
}
|
|
@@ -772,6 +950,7 @@ function resolveValues(input) {
|
|
|
772
950
|
case "input": {
|
|
773
951
|
const entry = moduleInputByAddress.get(origin.module);
|
|
774
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.`);
|
|
775
954
|
result = readPath(validatedInputOf(entry), origin);
|
|
776
955
|
break;
|
|
777
956
|
}
|
|
@@ -790,9 +969,9 @@ function resolveValues(input) {
|
|
|
790
969
|
path: ""
|
|
791
970
|
};
|
|
792
971
|
const values = [];
|
|
793
|
-
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet());
|
|
972
|
+
collect(entry.binding, site, values, /* @__PURE__ */ new WeakSet(), recordSecret);
|
|
794
973
|
for (const { value, site: valueSite } of values) resolveOne(value, valueSite);
|
|
795
|
-
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet()));
|
|
974
|
+
const validated = validateModuleInput(entry, substitute(entry.binding, results, /* @__PURE__ */ new WeakSet(), "resolve"), environment);
|
|
796
975
|
validating.delete(entry.moduleAddress);
|
|
797
976
|
validatedInputs.set(entry.moduleAddress, validated);
|
|
798
977
|
return validated;
|
|
@@ -800,34 +979,43 @@ function resolveValues(input) {
|
|
|
800
979
|
for (const entry of input.moduleInputs) validatedInputOf(entry);
|
|
801
980
|
for (const { value, site } of found) resolveOne(value, site);
|
|
802
981
|
const authoredProps = new Map([...input.resources].map(([address, resource]) => [address, resource.props]));
|
|
803
|
-
if (found.length === 0)
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
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
|
+
}
|
|
808
991
|
const inProgress = /* @__PURE__ */ new WeakSet();
|
|
809
992
|
const resourceProps = /* @__PURE__ */ new Map();
|
|
810
993
|
for (const [address, props] of authoredProps) {
|
|
811
|
-
const substituted = substitute(props, results, inProgress);
|
|
812
|
-
|
|
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);
|
|
813
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
|
+
});
|
|
814
1014
|
return {
|
|
815
1015
|
resourceProps,
|
|
816
|
-
inputBindings
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
serviceAddress: entry.serviceAddress,
|
|
820
|
-
binding: blindCast(binding)
|
|
821
|
-
};
|
|
822
|
-
}),
|
|
823
|
-
params: input.params.flatMap((entry) => {
|
|
824
|
-
const binding = substitute(entry.binding, results, inProgress);
|
|
825
|
-
if (binding === void 0 && isValue(entry.binding)) return [];
|
|
826
|
-
return [binding === entry.binding ? entry : {
|
|
827
|
-
...entry,
|
|
828
|
-
binding
|
|
829
|
-
}];
|
|
830
|
-
})
|
|
1016
|
+
inputBindings,
|
|
1017
|
+
params,
|
|
1018
|
+
secretSources: secretSourcesReceivedBy(inputBindings, params)
|
|
831
1019
|
};
|
|
832
1020
|
}
|
|
833
1021
|
/**
|
|
@@ -901,10 +1089,6 @@ function producerIdOf(ref) {
|
|
|
901
1089
|
* identity the branding copy creates, never on reading this back.
|
|
902
1090
|
*/
|
|
903
1091
|
const MODULE_INPUT_KEY = Symbol("prisma:module-input-key");
|
|
904
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.secrets` forwarding channel. */
|
|
905
|
-
const MODULE_SECRET_KEY = Symbol("prisma:module-secret-key");
|
|
906
|
-
/** Same per-key identity trick as MODULE_INPUT_KEY, for the parallel `ctx.params` forwarding channel. */
|
|
907
|
-
const MODULE_PARAM_KEY = Symbol("prisma:module-param-key");
|
|
908
1092
|
/** Whether `ref` carries a callable `satisfies` that accepts `required` truthily. */
|
|
909
1093
|
function satisfiesRequired(ref, required) {
|
|
910
1094
|
return typeof ref === "object" && ref !== null && "satisfies" in ref && typeof ref.satisfies === "function" && ref.satisfies(required);
|
|
@@ -938,25 +1122,6 @@ function validateWiring(pending, byId) {
|
|
|
938
1122
|
if (value.kind === "dependency") throw new LoadError(`Dependency "${input}" of provisioned ${targetKind} "${targetId}" is not wired to a producer (module "${enclosingModuleName}").`);
|
|
939
1123
|
}
|
|
940
1124
|
}
|
|
941
|
-
/**
|
|
942
|
-
* Flattens a value into itself plus every nested object/array member value —
|
|
943
|
-
* identity fodder for the ctx.secrets/ctx.params usage marking, which must
|
|
944
|
-
* see a forwarded source wherever it sits inside an input binding (ADR-0042).
|
|
945
|
-
* A value or a secret/param source is an opaque leaf: it is pushed (a
|
|
946
|
-
* forwarded ref IS such a source, so identity-matching still needs it) but
|
|
947
|
-
* never descended into, so a ref buried in an unrelated source's payload is
|
|
948
|
-
* not falsely seen as used. `seen` guards object cycles so a self-referential binding cannot
|
|
949
|
-
* recurse forever.
|
|
950
|
-
*/
|
|
951
|
-
function deepValues(value, out, seen = /* @__PURE__ */ new WeakSet()) {
|
|
952
|
-
out.push(value);
|
|
953
|
-
if (typeof value !== "object" || value === null) return;
|
|
954
|
-
if (isValue(value) || isSecretSource(value) || isParamSource(value)) return;
|
|
955
|
-
if (seen.has(value)) return;
|
|
956
|
-
seen.add(value);
|
|
957
|
-
const members = Array.isArray(value) ? value : Object.values(value);
|
|
958
|
-
for (const member of members) deepValues(member, out, seen);
|
|
959
|
-
}
|
|
960
1125
|
/** The (unvalidated) edges a `wiring` object implies — one dependency edge per entry; `validateWiring` does the real checking. */
|
|
961
1126
|
function wiringEdges(wiring, targetId) {
|
|
962
1127
|
return Object.entries(wiring).map(([input, ref]) => ({
|
|
@@ -967,48 +1132,15 @@ function wiringEdges(wiring, targetId) {
|
|
|
967
1132
|
}));
|
|
968
1133
|
}
|
|
969
1134
|
/**
|
|
970
|
-
* Checks the
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
* but resolved inline (a source carries its own name, so no whole-graph pass
|
|
975
|
-
* is needed).
|
|
976
|
-
*/
|
|
977
|
-
function validateSecretBinding(child, id, address, secretWiring, enclosingModuleName) {
|
|
978
|
-
const { kind } = child;
|
|
979
|
-
for (const slot of Object.keys(child.secretSlots)) {
|
|
980
|
-
const bound = secretWiring[slot];
|
|
981
|
-
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.`);
|
|
982
|
-
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.`);
|
|
983
|
-
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.`);
|
|
984
|
-
}
|
|
985
|
-
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}").`);
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* Checks the params wired into a provisioned SERVICE: unlike a secret slot, a
|
|
989
|
-
* declared param is never required to be bound here — it may fall back to its
|
|
990
|
-
* own `default` (checked later, at `buildConfig`) — so this only rejects a
|
|
991
|
-
* 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.
|
|
992
1139
|
*/
|
|
993
1140
|
function validateServiceParamBinding(child, id, paramWiring, enclosingModuleName) {
|
|
994
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}").`);
|
|
995
1142
|
}
|
|
996
1143
|
/**
|
|
997
|
-
* Checks the params wired into a provisioned MODULE: every declared
|
|
998
|
-
* param-forwarding slot must be bound to a real `ParamSource` — a slot has no
|
|
999
|
-
* schema of its own, so (unlike a service param) it cannot fall back to a
|
|
1000
|
-
* literal or a default; the param analog of `validateSecretBinding`.
|
|
1001
|
-
*/
|
|
1002
|
-
function validateParamNeedBinding(child, id, address, paramWiring, enclosingModuleName) {
|
|
1003
|
-
for (const slot of Object.keys(child.paramSlots)) {
|
|
1004
|
-
const bound = paramWiring[slot];
|
|
1005
|
-
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.`);
|
|
1006
|
-
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.`);
|
|
1007
|
-
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.`);
|
|
1008
|
-
}
|
|
1009
|
-
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}").`);
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
1144
|
* Recursively flattens one module's body into the shared graph state and
|
|
1013
1145
|
* returns its resolved ModuleOutputs (one ref-port per expose key) for the
|
|
1014
1146
|
* caller (the enclosing provision() call, or Load itself for the root) to
|
|
@@ -1026,12 +1158,10 @@ function validateParamNeedBinding(child, id, address, paramWiring, enclosingModu
|
|
|
1026
1158
|
* children carry it as their `parent`, and this module's own boundary ports
|
|
1027
1159
|
* (and the authored edges touching them) are recorded against it.
|
|
1028
1160
|
*/
|
|
1029
|
-
function flatten(moduleNode, selfId, wiring,
|
|
1161
|
+
function flatten(moduleNode, selfId, wiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading) {
|
|
1030
1162
|
ports.push(...boundaryPortsOf(selfId, moduleNode));
|
|
1031
1163
|
const localIds = /* @__PURE__ */ new Set();
|
|
1032
1164
|
const used = /* @__PURE__ */ new Set();
|
|
1033
|
-
const usedSecrets = /* @__PURE__ */ new Set();
|
|
1034
|
-
const usedParams = /* @__PURE__ */ new Set();
|
|
1035
1165
|
const ctxInputs = {};
|
|
1036
1166
|
for (const key of Object.keys(moduleNode.deps)) {
|
|
1037
1167
|
const wired = wiring[key];
|
|
@@ -1070,28 +1200,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1070
1200
|
});
|
|
1071
1201
|
}
|
|
1072
1202
|
};
|
|
1073
|
-
const ctxSecrets = {};
|
|
1074
|
-
for (const key of Object.keys(moduleNode.secretSlots)) {
|
|
1075
|
-
const bound = secretWiring[key];
|
|
1076
|
-
ctxSecrets[key] = typeof bound === "object" && bound !== null ? {
|
|
1077
|
-
...bound,
|
|
1078
|
-
[MODULE_SECRET_KEY]: key
|
|
1079
|
-
} : bound;
|
|
1080
|
-
}
|
|
1081
|
-
const markSecretsUsed = (values) => {
|
|
1082
|
-
for (const value of values) for (const key of Object.keys(ctxSecrets)) if (value === ctxSecrets[key]) usedSecrets.add(key);
|
|
1083
|
-
};
|
|
1084
|
-
const ctxParams = {};
|
|
1085
|
-
for (const key of Object.keys(moduleNode.paramSlots)) {
|
|
1086
|
-
const bound = paramWiring[key];
|
|
1087
|
-
ctxParams[key] = typeof bound === "object" && bound !== null ? {
|
|
1088
|
-
...bound,
|
|
1089
|
-
[MODULE_PARAM_KEY]: key
|
|
1090
|
-
} : bound;
|
|
1091
|
-
}
|
|
1092
|
-
const markParamsUsed = (values) => {
|
|
1093
|
-
for (const value of values) for (const key of Object.keys(ctxParams)) if (value === ctxParams[key]) usedParams.add(key);
|
|
1094
|
-
};
|
|
1095
1203
|
const provision = (child, opts) => {
|
|
1096
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.`);
|
|
1097
1205
|
const id = opts?.id ?? child.name;
|
|
@@ -1145,24 +1253,15 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1145
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).`);
|
|
1146
1254
|
const localWiring = { ...provisionWiring ?? {} };
|
|
1147
1255
|
markUsed(Object.values(localWiring));
|
|
1148
|
-
const localSecrets = { ...provisionSecrets ?? {} };
|
|
1149
|
-
markSecretsUsed(Object.values(localSecrets));
|
|
1150
1256
|
const localParams = { ...provisionParams ?? {} };
|
|
1151
|
-
markParamsUsed(Object.values(localParams));
|
|
1152
1257
|
if (child.kind === "service") {
|
|
1153
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.`);
|
|
1154
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.`);
|
|
1155
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}").`);
|
|
1156
|
-
if (provisionInput !== void 0) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
markParamsUsed(leaves);
|
|
1161
|
-
inputBindings.push({
|
|
1162
|
-
serviceAddress: fullAddress,
|
|
1163
|
-
binding: blindCast(provisionInput)
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1261
|
+
if (provisionInput !== void 0) inputBindings.push({
|
|
1262
|
+
serviceAddress: fullAddress,
|
|
1263
|
+
binding: blindCast(provisionInput)
|
|
1264
|
+
});
|
|
1166
1265
|
validateServiceParamBinding(child, id, localParams, moduleNode.name);
|
|
1167
1266
|
for (const [slot, binding] of Object.entries(localParams)) paramBindings.push({
|
|
1168
1267
|
serviceAddress: fullAddress,
|
|
@@ -1188,22 +1287,17 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1188
1287
|
byId.set(fullAddress, child);
|
|
1189
1288
|
return refFor(fullAddress, child);
|
|
1190
1289
|
}
|
|
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.`);
|
|
1191
1292
|
const childInputSchema = child.inputSchema;
|
|
1192
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}").`);
|
|
1193
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.`);
|
|
1194
|
-
if (childInputSchema !== void 0) {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
moduleAddress: fullAddress,
|
|
1201
|
-
schema: childInputSchema,
|
|
1202
|
-
binding: provisionInput
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
validateSecretBinding(child, id, fullAddress, localSecrets, moduleNode.name);
|
|
1206
|
-
validateParamNeedBinding(child, id, fullAddress, localParams, moduleNode.name);
|
|
1295
|
+
if (childInputSchema !== void 0) moduleInputs.push({
|
|
1296
|
+
moduleAddress: fullAddress,
|
|
1297
|
+
schema: childInputSchema,
|
|
1298
|
+
binding: provisionInput,
|
|
1299
|
+
fromConfigPool: false
|
|
1300
|
+
});
|
|
1207
1301
|
edges.push(...wiringEdges(localWiring, fullAddress));
|
|
1208
1302
|
recordAuthoredWiring(fullAddress, localWiring);
|
|
1209
1303
|
pending.push({
|
|
@@ -1213,7 +1307,7 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1213
1307
|
targetKind: "module",
|
|
1214
1308
|
enclosingModuleName: moduleNode.name
|
|
1215
1309
|
});
|
|
1216
|
-
const childOutputs = flatten(child, fullAddress, localWiring,
|
|
1310
|
+
const childOutputs = flatten(child, fullAddress, localWiring, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1217
1311
|
nodes.push({
|
|
1218
1312
|
id: fullAddress,
|
|
1219
1313
|
parent: selfId,
|
|
@@ -1235,8 +1329,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1235
1329
|
};
|
|
1236
1330
|
const ctx = blindCast({
|
|
1237
1331
|
deps: ctxInputs,
|
|
1238
|
-
secrets: ctxSecrets,
|
|
1239
|
-
params: ctxParams,
|
|
1240
1332
|
input: moduleNode.inputSchema === void 0 ? void 0 : buildModuleInput(selfId),
|
|
1241
1333
|
environment: environmentFacts,
|
|
1242
1334
|
provision: blindCast(provision)
|
|
@@ -1244,8 +1336,6 @@ function flatten(moduleNode, selfId, wiring, secretWiring, paramWiring, nodes, e
|
|
|
1244
1336
|
const outputs = blindCast(moduleNode.body(ctx) ?? {});
|
|
1245
1337
|
markUsed(Object.values(outputs));
|
|
1246
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.`);
|
|
1247
|
-
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.`);
|
|
1248
|
-
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.`);
|
|
1249
1339
|
for (const [key, contract] of Object.entries(moduleNode.expose)) {
|
|
1250
1340
|
const port = outputs[key];
|
|
1251
1341
|
if (port === void 0) throw new LoadError(`Module "${moduleNode.name}" declares expose "${key}" but its body did not return a port for it.`);
|
|
@@ -1270,29 +1360,27 @@ function loadModule(root, opts) {
|
|
|
1270
1360
|
const names = rootDepKeys.map((k) => `"${k}"`).join(", ");
|
|
1271
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.`);
|
|
1272
1362
|
}
|
|
1273
|
-
const
|
|
1274
|
-
if (
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
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
|
+
});
|
|
1282
1372
|
}
|
|
1283
|
-
if (root.inputSchema !== void 0) throw new LoadError(`Module "${root.name}" declares input but is being deployed as the root. Composer cannot fill a root's input yet; provision "${root.name}" from another module and bind its input there.`);
|
|
1284
1373
|
const nodes = [];
|
|
1285
1374
|
const edges = [];
|
|
1286
1375
|
const pending = [];
|
|
1287
1376
|
const inputBindings = [];
|
|
1288
1377
|
const paramBindings = [];
|
|
1289
|
-
const moduleInputs = [];
|
|
1290
1378
|
const byId = /* @__PURE__ */ new Map();
|
|
1291
1379
|
const ports = [];
|
|
1292
1380
|
const authoredEdges = [];
|
|
1293
1381
|
const loading = { sealed: false };
|
|
1294
1382
|
try {
|
|
1295
|
-
flatten(root, rootId, {},
|
|
1383
|
+
flatten(root, rootId, {}, nodes, edges, pending, inputBindings, paramBindings, moduleInputs, byId, ports, authoredEdges, loading);
|
|
1296
1384
|
for (const entry of pending) validateWiring(entry, byId);
|
|
1297
1385
|
assertDependencyDag(edges);
|
|
1298
1386
|
} finally {
|
|
@@ -1302,6 +1390,7 @@ function loadModule(root, opts) {
|
|
|
1302
1390
|
for (const [address, node] of byId) if (node.kind === "resource") resources.set(address, node);
|
|
1303
1391
|
const resolved = resolveValues({
|
|
1304
1392
|
environment: opts?.environment,
|
|
1393
|
+
configPool: opts?.configPool,
|
|
1305
1394
|
inputBindings,
|
|
1306
1395
|
params: paramBindings,
|
|
1307
1396
|
moduleInputs,
|
|
@@ -1327,7 +1416,8 @@ function loadModule(root, opts) {
|
|
|
1327
1416
|
ports,
|
|
1328
1417
|
authoredEdges,
|
|
1329
1418
|
inputBindings: resolved.inputBindings,
|
|
1330
|
-
params: resolved.params
|
|
1419
|
+
params: resolved.params,
|
|
1420
|
+
secretSources: resolved.secretSources
|
|
1331
1421
|
};
|
|
1332
1422
|
}
|
|
1333
1423
|
/**
|
|
@@ -1400,6 +1490,6 @@ function Load(root, opts) {
|
|
|
1400
1490
|
throw new LoadError("Load expects a service or module root (received another node kind).");
|
|
1401
1491
|
}
|
|
1402
1492
|
//#endregion
|
|
1403
|
-
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 };
|
|
1404
1494
|
|
|
1405
|
-
//# sourceMappingURL=graph-
|
|
1495
|
+
//# sourceMappingURL=graph-gE31_ToO-BouKBfIS.mjs.map
|