@prisma/composer 0.6.0-dev.9 → 0.7.0
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-CFsSXEVj-B242oUnm.d.mts → app-config-BinBcpPf-1akTl5h4.d.mts} +128 -15
- package/dist/app-config-BinBcpPf-1akTl5h4.d.mts.map +1 -0
- package/dist/config-647Wkm51.d.mts +1 -0
- package/dist/config.d.mts +3 -3
- package/dist/control.d.mts +79 -35
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +34 -33
- package/dist/control.mjs.map +1 -1
- package/dist/deploy-647Wkm51.d.mts +1 -0
- package/dist/deploy.d.mts +2 -2
- package/dist/{deployment-summary-r47O6kFr-CcMYVOn5.mjs → deployment-summary-DswOl_9E-B9MhYYDt.mjs} +5 -5
- package/dist/deployment-summary-DswOl_9E-B9MhYYDt.mjs.map +1 -0
- package/dist/dist-CVk7Pk4B.mjs +42 -0
- package/dist/dist-CVk7Pk4B.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs → execute-deploy-destroy-DRl6Tfg9-B8LE2Lh5.mjs} +171 -31
- package/dist/execute-deploy-destroy-DRl6Tfg9-B8LE2Lh5.mjs.map +1 -0
- package/dist/{execute-dev-DLYyduEM-88uyvrbj.mjs → execute-dev-BMTFWfFc-7MifQgpp.mjs} +53 -48
- package/dist/execute-dev-BMTFWfFc-7MifQgpp.mjs.map +1 -0
- package/dist/{execute-log-VIOL4DBz-DBPH8By4.mjs → execute-log-Cay9hlKW-BcvKPOW1.mjs} +10 -7
- package/dist/execute-log-Cay9hlKW-BcvKPOW1.mjs.map +1 -0
- package/dist/local-target.d.mts +1 -1
- package/dist/nextjs-control.d.mts +3 -3
- package/dist/nextjs-control.mjs +138 -34
- package/dist/nextjs-control.mjs.map +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node-control.mjs +21814 -55
- package/dist/node-control.mjs.map +1 -1
- package/dist/{pipeline-D3QoVzAB-Ci2aJ2mE.mjs → pipeline-AoW8zq4I-Dg8xQ7nC.mjs} +170 -49
- package/dist/pipeline-AoW8zq4I-Dg8xQ7nC.mjs.map +1 -0
- package/dist/report.d.mts +2 -2
- package/dist/report.mjs +1 -1
- package/dist/report.mjs.map +1 -1
- package/dist/{result-CzGChwbZ.mjs → result-D95kAAek.mjs} +36 -20
- package/dist/result-D95kAAek.mjs.map +1 -0
- package/dist/run-alchemy-D44OZlyB-Cw5CVbUQ.mjs +93 -0
- package/dist/run-alchemy-D44OZlyB-Cw5CVbUQ.mjs.map +1 -0
- package/dist/run-report-C2o98uD--AX8kpz4Q.mjs +60 -0
- package/dist/run-report-C2o98uD--AX8kpz4Q.mjs.map +1 -0
- package/package.json +14 -19
- package/src/exports/testing.ts +5 -0
- package/dist/app-config-CFsSXEVj-B242oUnm.d.mts.map +0 -1
- package/dist/bin.mjs +0 -19
- package/dist/bin.mjs.map +0 -1
- package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs +0 -401
- package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs.map +0 -1
- package/dist/config-ku5b_2YD.d.mts +0 -1
- package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs +0 -75
- package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs.map +0 -1
- package/dist/deploy-ku5b_2YD.d.mts +0 -1
- package/dist/deployment-summary-r47O6kFr-CcMYVOn5.mjs.map +0 -1
- package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs +0 -306
- package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs.map +0 -1
- package/dist/execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs.map +0 -1
- package/dist/execute-dev-DLYyduEM-88uyvrbj.mjs.map +0 -1
- package/dist/execute-dev-DLYyduEM-BuUGTm0g.mjs +0 -2006
- package/dist/execute-dev-DLYyduEM-BuUGTm0g.mjs.map +0 -1
- package/dist/execute-log-VIOL4DBz-DBPH8By4.mjs.map +0 -1
- package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs +0 -155
- package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs.map +0 -1
- package/dist/local-target-DuSyWeYc.mjs +0 -68
- package/dist/local-target-DuSyWeYc.mjs.map +0 -1
- package/dist/pipeline-D3QoVzAB-Ci2aJ2mE.mjs.map +0 -1
- package/dist/pipeline-D3QoVzAB-D_ufjg3N.mjs +0 -857
- package/dist/pipeline-D3QoVzAB-D_ufjg3N.mjs.map +0 -1
- package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs +0 -30
- package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs.map +0 -1
- package/dist/result-CFqJKiqg.mjs +0 -106
- package/dist/result-CFqJKiqg.mjs.map +0 -1
- package/dist/result-CzGChwbZ.mjs.map +0 -1
- package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs +0 -48
- package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs.map +0 -1
- package/dist/shared-CCaR42wo-BvegvmA_.mjs +0 -265
- package/dist/shared-CCaR42wo-BvegvmA_.mjs.map +0 -1
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
//#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
|
|
5
|
-
/**
|
|
6
|
-
* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
|
|
7
|
-
*
|
|
8
|
-
* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes
|
|
9
|
-
* unnecessary**: tighten an input type, add a runtime check that narrows via a type
|
|
10
|
-
* predicate, restructure a generic so the compiler can see the relationship you're
|
|
11
|
-
* asserting, or use {@link castAs} when the value already satisfies the target type.
|
|
12
|
-
* Only when no rewrite is feasible does `blindCast` become the right answer — and at
|
|
13
|
-
* that point, the `Reason` literal you supply must articulate the compromise in
|
|
14
|
-
* language a reviewer can evaluate.
|
|
15
|
-
*
|
|
16
|
-
* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,
|
|
17
|
-
* that is not a signal to soften the reason; it is a signal to go back and solve the
|
|
18
|
-
* underlying type-system problem properly. An unconvincing justification is rework,
|
|
19
|
-
* not a free pass.
|
|
20
|
-
*
|
|
21
|
-
* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses
|
|
22
|
-
* the compiler's checks (the input type is `unknown`, the output type is whatever the
|
|
23
|
-
* caller asks for), but it forces the unsafety to be named at the call site instead of
|
|
24
|
-
* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile
|
|
25
|
-
* time — it is not present in the emitted JavaScript — but it is grep-able and
|
|
26
|
-
* visible to future readers.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const stringValue = blindCast<
|
|
31
|
-
* string,
|
|
32
|
-
* "JSON.parse returns `unknown`; this field is documented to be a string in the API contract"
|
|
33
|
-
* >(parsed[key]);
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @typeParam TargetType - The type the caller is asserting the input has.
|
|
37
|
-
* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.
|
|
38
|
-
* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.
|
|
39
|
-
*/
|
|
40
|
-
function blindCast(input) {
|
|
41
|
-
return input;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region ../../0-framework/0-foundation/foundation/dist/errors.mjs
|
|
45
|
-
/**
|
|
46
|
-
* Returns an object with the key/value if value is defined, otherwise an empty object.
|
|
47
|
-
*
|
|
48
|
-
* Use with spread to conditionally include optional properties while satisfying
|
|
49
|
-
* exactOptionalPropertyTypes. This is explicit about which properties are optional
|
|
50
|
-
* and won't inadvertently strip other undefined values.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* // Instead of:
|
|
55
|
-
* const obj = {
|
|
56
|
-
* required: 'value',
|
|
57
|
-
* ...(optional ? { optional } : {}),
|
|
58
|
-
* };
|
|
59
|
-
*
|
|
60
|
-
* // Use:
|
|
61
|
-
* const obj = {
|
|
62
|
-
* required: 'value',
|
|
63
|
-
* ...ifDefined('optional', optional),
|
|
64
|
-
* };
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
function ifDefined(key, value) {
|
|
68
|
-
return value !== void 0 ? blindCast({ [key]: value }) : {};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Structured CLI error that contains all information needed for error envelopes.
|
|
72
|
-
* Call sites throw these errors with full context.
|
|
73
|
-
*
|
|
74
|
-
* A `CliStructuredError` is a `StructuredError` (see
|
|
75
|
-
* `./structured-error.ts`): `code` is a dotted
|
|
76
|
-
* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's
|
|
77
|
-
* category — there is no separate `domain` field. See ADR 239 in
|
|
78
|
-
* prisma/prisma and composer's ADR-0044 for the namespace taxonomy.
|
|
79
|
-
*/
|
|
80
|
-
var CliStructuredError = class extends Error {
|
|
81
|
-
code;
|
|
82
|
-
severity;
|
|
83
|
-
constructor(code, summary, options) {
|
|
84
|
-
super(summary, options?.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
85
|
-
this.name = "CliStructuredError";
|
|
86
|
-
this.code = code;
|
|
87
|
-
this.severity = options?.severity ?? "error";
|
|
88
|
-
const fix = options?.fix === options?.why ? void 0 : options?.fix;
|
|
89
|
-
const where = options?.where ? {
|
|
90
|
-
...ifDefined("path", options.where.path),
|
|
91
|
-
...ifDefined("line", options.where.line)
|
|
92
|
-
} : void 0;
|
|
93
|
-
Object.assign(this, {
|
|
94
|
-
...ifDefined("why", options?.why),
|
|
95
|
-
...ifDefined("fix", fix),
|
|
96
|
-
...ifDefined("where", where),
|
|
97
|
-
...ifDefined("meta", options?.meta),
|
|
98
|
-
...ifDefined("docsUrl", options?.docsUrl)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Converts this error to a CLI error envelope for output formatting.
|
|
103
|
-
*/
|
|
104
|
-
toEnvelope() {
|
|
105
|
-
return {
|
|
106
|
-
ok: false,
|
|
107
|
-
code: this.code,
|
|
108
|
-
severity: this.severity,
|
|
109
|
-
summary: this.message,
|
|
110
|
-
...ifDefined("why", this.why),
|
|
111
|
-
...ifDefined("fix", this.fix),
|
|
112
|
-
...ifDefined("where", this.where),
|
|
113
|
-
...ifDefined("meta", this.meta),
|
|
114
|
-
...ifDefined("docsUrl", this.docsUrl)
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Type guard to check if an error is a CliStructuredError.
|
|
119
|
-
* Uses duck-typing to work across module boundaries where instanceof may fail.
|
|
120
|
-
*/
|
|
121
|
-
static is(error) {
|
|
122
|
-
if (!(error instanceof Error)) return false;
|
|
123
|
-
const candidate = blindCast(error);
|
|
124
|
-
return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && typeof candidate.toEnvelope === "function";
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region ../../0-framework/3-tooling/cli/dist/shared-CCaR42wo.mjs
|
|
129
|
-
/**
|
|
130
|
-
* Deploy preflight (TML-3158): verify that alchemy resolves the exact `effect`
|
|
131
|
-
* version @prisma/composer pins. Package managers cannot be made to enforce
|
|
132
|
-
* this — alchemy's own peer range accepts newer effect betas, and npm resolves
|
|
133
|
-
* transitive peer conflicts with a warning, not a failure — so a floating
|
|
134
|
-
* `@effect/*` range anywhere in the consumer's tree can hoist a newer effect
|
|
135
|
-
* to the root, where alchemy picks it up and crashes mid-deploy
|
|
136
|
-
* (`TypeError: Schedule.either is not a function`). This check turns that
|
|
137
|
-
* silent break into a start-up error naming the fix.
|
|
138
|
-
*/
|
|
139
|
-
/** Walks up from `startDir` looking for `node_modules/alchemy` (mirrors resolveAlchemyBin). Undefined when absent — the check skips rather than second-guessing later, clearer failures. */
|
|
140
|
-
function findAlchemyPackageDir(startDir) {
|
|
141
|
-
let dir = startDir;
|
|
142
|
-
while (true) {
|
|
143
|
-
const candidate = path.join(dir, "node_modules", "alchemy");
|
|
144
|
-
if (fs.existsSync(path.join(candidate, "package.json"))) return candidate;
|
|
145
|
-
const parent = path.dirname(dir);
|
|
146
|
-
if (parent === dir) return void 0;
|
|
147
|
-
dir = parent;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* The `effect` version Node gives `packageDir`'s code, resolved exactly as
|
|
152
|
-
* Node would: from the package's real path (so pnpm symlink layouts resolve
|
|
153
|
-
* from the package's own store position, like at runtime). Undefined when
|
|
154
|
-
* `effect` is not resolvable from there.
|
|
155
|
-
*/
|
|
156
|
-
function resolveEffectVersionFrom(packageDir) {
|
|
157
|
-
let entry;
|
|
158
|
-
try {
|
|
159
|
-
entry = createRequire(path.join(fs.realpathSync(packageDir), "noop.js")).resolve("effect");
|
|
160
|
-
} catch {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
let dir = path.dirname(entry);
|
|
164
|
-
while (!fs.existsSync(path.join(dir, "package.json"))) {
|
|
165
|
-
const parent = path.dirname(dir);
|
|
166
|
-
if (parent === dir) return void 0;
|
|
167
|
-
dir = parent;
|
|
168
|
-
}
|
|
169
|
-
const version = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf-8")).version;
|
|
170
|
-
return typeof version === "string" ? version : void 0;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* The `effect` version @prisma/composer pins, read from its own installed
|
|
174
|
-
* package.json — the single source of truth; never hardcoded here. Undefined
|
|
175
|
-
* when @prisma/composer is not resolvable from `startDir` (e.g. the CLI is
|
|
176
|
-
* driven some other way), in which case the check skips.
|
|
177
|
-
*
|
|
178
|
-
* Assumes the pin is an exact version — effectMismatchError compares with
|
|
179
|
-
* `===`, which scripts/check-npm-effect-resolution.mjs enforces in CI;
|
|
180
|
-
* relaxing the pin to a range means revisiting that comparison.
|
|
181
|
-
*/
|
|
182
|
-
function requiredEffectVersion(startDir) {
|
|
183
|
-
let manifestPath;
|
|
184
|
-
try {
|
|
185
|
-
manifestPath = createRequire(path.join(startDir, "noop.js")).resolve("@prisma/composer/package.json");
|
|
186
|
-
} catch {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
190
|
-
if (typeof manifest !== "object" || manifest === null || !("dependencies" in manifest)) return;
|
|
191
|
-
const dependencies = manifest.dependencies;
|
|
192
|
-
if (typeof dependencies !== "object" || dependencies === null || !("effect" in dependencies)) return;
|
|
193
|
-
const version = dependencies.effect;
|
|
194
|
-
return typeof version === "string" ? version : void 0;
|
|
195
|
-
}
|
|
196
|
-
/** Pure comparison + parts rendering, separated so tests cover the rule without a filesystem. Returns the structured error parts, or undefined when the tree is healthy or either side is unknown. */
|
|
197
|
-
function effectMismatchError(found, required) {
|
|
198
|
-
if (found === void 0 || required === void 0 || found === required) return void 0;
|
|
199
|
-
return {
|
|
200
|
-
summary: `Dependency conflict: alchemy resolves effect@${found}, but @prisma/composer requires effect@${required}.`,
|
|
201
|
-
why: "Your package manager installed a second effect that alchemy picks up; deploying with it would crash inside alchemy.",
|
|
202
|
-
fix: `Add this to your app's package.json, then reinstall:
|
|
203
|
-
|
|
204
|
-
"overrides": { "effect": "${required}" }\n\n(npm uses "overrides"; yarn calls it "resolutions", pnpm "pnpm.overrides".)`,
|
|
205
|
-
meta: {
|
|
206
|
-
found,
|
|
207
|
-
required
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
/** Runs the preflight from the app's directory; throws DEPS.EFFECT_VERSION_CONFLICT on a mismatched tree, no-op otherwise. */
|
|
212
|
-
function checkEffectResolution(cwd) {
|
|
213
|
-
const alchemyDir = findAlchemyPackageDir(cwd);
|
|
214
|
-
if (alchemyDir === void 0) return;
|
|
215
|
-
const parts = effectMismatchError(resolveEffectVersionFrom(alchemyDir), requiredEffectVersion(cwd));
|
|
216
|
-
if (parts !== void 0) throw new CliStructuredError("DEPS.EFFECT_VERSION_CONFLICT", parts.summary, {
|
|
217
|
-
why: parts.why,
|
|
218
|
-
fix: parts.fix,
|
|
219
|
-
meta: parts.meta
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Reads the execution diagnostics an engine-failure error carries in
|
|
224
|
-
* `meta.diagnostics`; undefined for every other failure.
|
|
225
|
-
*/
|
|
226
|
-
function executionDiagnostics(f) {
|
|
227
|
-
const diagnostics = f.meta?.["diagnostics"];
|
|
228
|
-
if (typeof diagnostics !== "object" || diagnostics === null) return void 0;
|
|
229
|
-
const candidate = blindCast(diagnostics);
|
|
230
|
-
if (candidate["exitCode"] !== void 0 && typeof candidate["exitCode"] !== "number" || typeof candidate["stackFilePath"] !== "string" || typeof candidate["reproduceCommand"] !== "string" || typeof candidate["cwd"] !== "string") return;
|
|
231
|
-
return blindCast(diagnostics);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Site-specific wrap for foreign extension/environment causes — passthrough
|
|
235
|
-
* when already structured; never a boundary fallback (base-type rule 6(ii)).
|
|
236
|
-
*/
|
|
237
|
-
function toStructured(code, error) {
|
|
238
|
-
return CliStructuredError.is(error) ? error : new CliStructuredError(code, error instanceof Error ? error.message : String(error), { cause: error });
|
|
239
|
-
}
|
|
240
|
-
/** Diagnoses a failed executor import: when the app's tree resolves a
|
|
241
|
-
* mismatched `effect` (the known way that import breaks), the failure is the
|
|
242
|
-
* fix-naming DEPS.EFFECT_VERSION_CONFLICT from checkEffectResolution with the
|
|
243
|
-
* import error riding as cause; otherwise DEPS.EXECUTOR_UNLOADABLE — an
|
|
244
|
-
* environmental failure of the consumer's installed tree, not a bug here. */
|
|
245
|
-
function executorLoadFailure(operation, error, cwd) {
|
|
246
|
-
try {
|
|
247
|
-
checkEffectResolution(cwd);
|
|
248
|
-
} catch (diagnostic) {
|
|
249
|
-
if (CliStructuredError.is(diagnostic)) return new CliStructuredError(diagnostic.code, diagnostic.message, {
|
|
250
|
-
...diagnostic.why !== void 0 ? { why: diagnostic.why } : {},
|
|
251
|
-
...diagnostic.fix !== void 0 ? { fix: diagnostic.fix } : {},
|
|
252
|
-
...diagnostic.meta !== void 0 ? { meta: diagnostic.meta } : {},
|
|
253
|
-
cause: error
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return new CliStructuredError("DEPS.EXECUTOR_UNLOADABLE", `Could not load the ${operation} executor: ${error instanceof Error ? error.message : String(error)}`, {
|
|
257
|
-
why: `The ${operation} operation's executor imports the deploy engine's provider tree from your app's installed dependencies, and that import failed.`,
|
|
258
|
-
fix: "Reinstall your dependencies, and check that `alchemy` is installed and loadable from your app.",
|
|
259
|
-
cause: error
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
export { CliStructuredError as a, toStructured as i, executionDiagnostics as n, blindCast as o, executorLoadFailure as r, checkEffectResolution as t };
|
|
264
|
-
|
|
265
|
-
//# sourceMappingURL=shared-CCaR42wo-BvegvmA_.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-CCaR42wo-BvegvmA_.mjs","names":[],"sources":["../../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs","../../../0-framework/0-foundation/foundation/dist/errors.mjs","../../../0-framework/3-tooling/cli/dist/shared-CCaR42wo.mjs"],"sourcesContent":["//#region src/casts.ts\n/**\n* **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**\n*\n* Before reaching for `blindCast`, **rewrite the surrounding code so the cast becomes\n* unnecessary**: tighten an input type, add a runtime check that narrows via a type\n* predicate, restructure a generic so the compiler can see the relationship you're\n* asserting, or use {@link castAs} when the value already satisfies the target type.\n* Only when no rewrite is feasible does `blindCast` become the right answer — and at\n* that point, the `Reason` literal you supply must articulate the compromise in\n* language a reviewer can evaluate.\n*\n* The reviewer **will** validate the `Reason`. If it doesn't hold up under scrutiny,\n* that is not a signal to soften the reason; it is a signal to go back and solve the\n* underlying type-system problem properly. An unconvincing justification is rework,\n* not a free pass.\n*\n* `blindCast` is the auditable form of `as Foo` / `as unknown as Foo`: it bypasses\n* the compiler's checks (the input type is `unknown`, the output type is whatever the\n* caller asks for), but it forces the unsafety to be named at the call site instead of\n* smuggled in via a bare `as`. The `Reason` type parameter exists only at compile\n* time — it is not present in the emitted JavaScript — but it is grep-able and\n* visible to future readers.\n*\n* @example\n* ```typescript\n* const stringValue = blindCast<\n* string,\n* \"JSON.parse returns `unknown`; this field is documented to be a string in the API contract\"\n* >(parsed[key]);\n* ```\n*\n* @typeParam TargetType - The type the caller is asserting the input has.\n* @typeParam _Reason - A string literal describing why bypassing the type system is necessary here.\n* Only meaningful at compile time. The reviewer evaluates whether it justifies the unsafety.\n*/\nfunction blindCast(input) {\n\treturn input;\n}\n/**\n* Type-checked, runtime pass-through alternative to a bare `as Type` cast.\n*\n* Use `castAs` when the value already satisfies the target type but you want to make\n* the type assertion explicit at the call site — for example, when an inferred type is\n* wider than the type you want to publish, or when a literal object should be tagged\n* with its nominal interface. Unlike {@link blindCast}, the compiler still checks that\n* the value is assignable to the target type, so this helper cannot smuggle in an\n* unsafe assertion.\n*\n* `castAs` exists alongside `blindCast` so authors pick the right name at the call\n* site: a `castAs` is type-checked and benign; a `blindCast` is the unsafe escape\n* hatch. The split makes review faster — readers know which casts to scrutinize and\n* which are pure annotations.\n*\n* @example\n* ```typescript\n* interface FancyObject {\n* key: string;\n* keyTwo: {\n* subKey: string;\n* subKeyTwo: number;\n* };\n* }\n*\n* const typedObject = castAs<FancyObject>({\n* key: 'Chookede',\n* keyTwo: {\n* subKey: 'Choookeeeee',\n* subKeyTwo: 2,\n* },\n* });\n* ```\n*\n* @typeParam Type - The type to constrain and tag the value with. The value must be assignable to `Type`.\n*/\nfunction castAs(value) {\n\treturn value;\n}\n//#endregion\nexport { castAs as n, blindCast as t };\n\n//# sourceMappingURL=casts-DpaahrlC.mjs.map","import { t as blindCast } from \"./casts-DpaahrlC.mjs\";\nimport { n as assertNever, r as isInternalError, t as InternalError } from \"./internal-error-BIc-ehme.mjs\";\n//#region src/defined.ts\n/**\n* Returns an object with the key/value if value is defined, otherwise an empty object.\n*\n* Use with spread to conditionally include optional properties while satisfying\n* exactOptionalPropertyTypes. This is explicit about which properties are optional\n* and won't inadvertently strip other undefined values.\n*\n* @example\n* ```typescript\n* // Instead of:\n* const obj = {\n* required: 'value',\n* ...(optional ? { optional } : {}),\n* };\n*\n* // Use:\n* const obj = {\n* required: 'value',\n* ...ifDefined('optional', optional),\n* };\n* ```\n*/\nfunction ifDefined(key, value) {\n\treturn value !== void 0 ? blindCast({ [key]: value }) : {};\n}\n//#endregion\n//#region src/cli-structured-error.ts\n/**\n* Structured CLI error that contains all information needed for error envelopes.\n* Call sites throw these errors with full context.\n*\n* A `CliStructuredError` is a `StructuredError` (see\n* `./structured-error.ts`): `code` is a dotted\n* `NAMESPACE.SUBCODE` string, and the namespace prefix is the error's\n* category — there is no separate `domain` field. See ADR 239 in\n* prisma/prisma and composer's ADR-0044 for the namespace taxonomy.\n*/\nvar CliStructuredError = class extends Error {\n\tcode;\n\tseverity;\n\tconstructor(code, summary, options) {\n\t\tsuper(summary, options?.cause !== void 0 ? { cause: options.cause } : void 0);\n\t\tthis.name = \"CliStructuredError\";\n\t\tthis.code = code;\n\t\tthis.severity = options?.severity ?? \"error\";\n\t\tconst fix = options?.fix === options?.why ? void 0 : options?.fix;\n\t\tconst where = options?.where ? {\n\t\t\t...ifDefined(\"path\", options.where.path),\n\t\t\t...ifDefined(\"line\", options.where.line)\n\t\t} : void 0;\n\t\tObject.assign(this, {\n\t\t\t...ifDefined(\"why\", options?.why),\n\t\t\t...ifDefined(\"fix\", fix),\n\t\t\t...ifDefined(\"where\", where),\n\t\t\t...ifDefined(\"meta\", options?.meta),\n\t\t\t...ifDefined(\"docsUrl\", options?.docsUrl)\n\t\t});\n\t}\n\t/**\n\t* Converts this error to a CLI error envelope for output formatting.\n\t*/\n\ttoEnvelope() {\n\t\treturn {\n\t\t\tok: false,\n\t\t\tcode: this.code,\n\t\t\tseverity: this.severity,\n\t\t\tsummary: this.message,\n\t\t\t...ifDefined(\"why\", this.why),\n\t\t\t...ifDefined(\"fix\", this.fix),\n\t\t\t...ifDefined(\"where\", this.where),\n\t\t\t...ifDefined(\"meta\", this.meta),\n\t\t\t...ifDefined(\"docsUrl\", this.docsUrl)\n\t\t};\n\t}\n\t/**\n\t* Type guard to check if an error is a CliStructuredError.\n\t* Uses duck-typing to work across module boundaries where instanceof may fail.\n\t*/\n\tstatic is(error) {\n\t\tif (!(error instanceof Error)) return false;\n\t\tconst candidate = blindCast(error);\n\t\treturn candidate.name === \"CliStructuredError\" && typeof candidate.code === \"string\" && typeof candidate.toEnvelope === \"function\";\n\t}\n};\n//#endregion\n//#region src/structured-error.ts\nconst STRUCTURED_CODE_RE = /^[A-Z][A-Z0-9]*\\.[A-Z][A-Z0-9_]*$/;\nfunction isStructuredError(e) {\n\treturn typeof e === \"object\" && e !== null && \"code\" in e && typeof e.code === \"string\" && STRUCTURED_CODE_RE.test(e.code) && \"message\" in e && typeof e.message === \"string\";\n}\nfunction structuredError(code, message, options) {\n\tconst error = options?.cause !== void 0 ? new Error(message, { cause: options.cause }) : new Error(message);\n\tObject.defineProperty(error, \"name\", {\n\t\tvalue: \"StructuredError\",\n\t\tconfigurable: true\n\t});\n\treturn Object.assign(error, {\n\t\tcode,\n\t\t...ifDefined(\"why\", options?.why),\n\t\t...ifDefined(\"fix\", options?.fix),\n\t\t...ifDefined(\"where\", options?.where),\n\t\t...ifDefined(\"severity\", options?.severity),\n\t\t...ifDefined(\"meta\", options?.meta),\n\t\t...ifDefined(\"docsUrl\", options?.docsUrl)\n\t});\n}\nconst DOCS_BASE = `https://docs.prisma.io/docs/orm/next/reference/error-reference`;\nfunction docsUrlFor(code) {\n\treturn `${DOCS_BASE}#${code}`;\n}\n//#endregion\nexport { CliStructuredError, DOCS_BASE, InternalError, assertNever, docsUrlFor, isInternalError, isStructuredError, structuredError };\n\n//# sourceMappingURL=errors.mjs.map","import { createRequire } from \"node:module\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { blindCast } from \"@internal/foundation/casts\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n//#region src/check-effect-resolution.ts\n/**\n* Deploy preflight (TML-3158): verify that alchemy resolves the exact `effect`\n* version @prisma/composer pins. Package managers cannot be made to enforce\n* this — alchemy's own peer range accepts newer effect betas, and npm resolves\n* transitive peer conflicts with a warning, not a failure — so a floating\n* `@effect/*` range anywhere in the consumer's tree can hoist a newer effect\n* to the root, where alchemy picks it up and crashes mid-deploy\n* (`TypeError: Schedule.either is not a function`). This check turns that\n* silent break into a start-up error naming the fix.\n*/\n/** Walks up from `startDir` looking for `node_modules/alchemy` (mirrors resolveAlchemyBin). Undefined when absent — the check skips rather than second-guessing later, clearer failures. */\nfunction findAlchemyPackageDir(startDir) {\n\tlet dir = startDir;\n\twhile (true) {\n\t\tconst candidate = path.join(dir, \"node_modules\", \"alchemy\");\n\t\tif (fs.existsSync(path.join(candidate, \"package.json\"))) return candidate;\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) return void 0;\n\t\tdir = parent;\n\t}\n}\n/**\n* The `effect` version Node gives `packageDir`'s code, resolved exactly as\n* Node would: from the package's real path (so pnpm symlink layouts resolve\n* from the package's own store position, like at runtime). Undefined when\n* `effect` is not resolvable from there.\n*/\nfunction resolveEffectVersionFrom(packageDir) {\n\tlet entry;\n\ttry {\n\t\tentry = createRequire(path.join(fs.realpathSync(packageDir), \"noop.js\")).resolve(\"effect\");\n\t} catch {\n\t\treturn;\n\t}\n\tlet dir = path.dirname(entry);\n\twhile (!fs.existsSync(path.join(dir, \"package.json\"))) {\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) return void 0;\n\t\tdir = parent;\n\t}\n\tconst version = JSON.parse(fs.readFileSync(path.join(dir, \"package.json\"), \"utf-8\")).version;\n\treturn typeof version === \"string\" ? version : void 0;\n}\n/**\n* The `effect` version @prisma/composer pins, read from its own installed\n* package.json — the single source of truth; never hardcoded here. Undefined\n* when @prisma/composer is not resolvable from `startDir` (e.g. the CLI is\n* driven some other way), in which case the check skips.\n*\n* Assumes the pin is an exact version — effectMismatchError compares with\n* `===`, which scripts/check-npm-effect-resolution.mjs enforces in CI;\n* relaxing the pin to a range means revisiting that comparison.\n*/\nfunction requiredEffectVersion(startDir) {\n\tlet manifestPath;\n\ttry {\n\t\tmanifestPath = createRequire(path.join(startDir, \"noop.js\")).resolve(\"@prisma/composer/package.json\");\n\t} catch {\n\t\treturn;\n\t}\n\tconst manifest = JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n\tif (typeof manifest !== \"object\" || manifest === null || !(\"dependencies\" in manifest)) return;\n\tconst dependencies = manifest.dependencies;\n\tif (typeof dependencies !== \"object\" || dependencies === null || !(\"effect\" in dependencies)) return;\n\tconst version = dependencies.effect;\n\treturn typeof version === \"string\" ? version : void 0;\n}\n/** Pure comparison + parts rendering, separated so tests cover the rule without a filesystem. Returns the structured error parts, or undefined when the tree is healthy or either side is unknown. */\nfunction effectMismatchError(found, required) {\n\tif (found === void 0 || required === void 0 || found === required) return void 0;\n\treturn {\n\t\tsummary: `Dependency conflict: alchemy resolves effect@${found}, but @prisma/composer requires effect@${required}.`,\n\t\twhy: \"Your package manager installed a second effect that alchemy picks up; deploying with it would crash inside alchemy.\",\n\t\tfix: `Add this to your app's package.json, then reinstall:\n\n \"overrides\": { \"effect\": \"${required}\" }\\n\\n(npm uses \"overrides\"; yarn calls it \"resolutions\", pnpm \"pnpm.overrides\".)`,\n\t\tmeta: {\n\t\t\tfound,\n\t\t\trequired\n\t\t}\n\t};\n}\n/** Runs the preflight from the app's directory; throws DEPS.EFFECT_VERSION_CONFLICT on a mismatched tree, no-op otherwise. */\nfunction checkEffectResolution(cwd) {\n\tconst alchemyDir = findAlchemyPackageDir(cwd);\n\tif (alchemyDir === void 0) return;\n\tconst parts = effectMismatchError(resolveEffectVersionFrom(alchemyDir), requiredEffectVersion(cwd));\n\tif (parts !== void 0) throw new CliStructuredError(\"DEPS.EFFECT_VERSION_CONFLICT\", parts.summary, {\n\t\twhy: parts.why,\n\t\tfix: parts.fix,\n\t\tmeta: parts.meta\n\t});\n}\n//#endregion\n//#region src/operations/shared.ts\n/**\n* Reads the execution diagnostics an engine-failure error carries in\n* `meta.diagnostics`; undefined for every other failure.\n*/\nfunction executionDiagnostics(f) {\n\tconst diagnostics = f.meta?.[\"diagnostics\"];\n\tif (typeof diagnostics !== \"object\" || diagnostics === null) return void 0;\n\tconst candidate = blindCast(diagnostics);\n\tif (candidate[\"exitCode\"] !== void 0 && typeof candidate[\"exitCode\"] !== \"number\" || typeof candidate[\"stackFilePath\"] !== \"string\" || typeof candidate[\"reproduceCommand\"] !== \"string\" || typeof candidate[\"cwd\"] !== \"string\") return;\n\treturn blindCast(diagnostics);\n}\n/**\n* Site-specific wrap for foreign extension/environment causes — passthrough\n* when already structured; never a boundary fallback (base-type rule 6(ii)).\n*/\nfunction toStructured(code, error) {\n\treturn CliStructuredError.is(error) ? error : new CliStructuredError(code, error instanceof Error ? error.message : String(error), { cause: error });\n}\n/** Diagnoses a failed executor import: when the app's tree resolves a\n* mismatched `effect` (the known way that import breaks), the failure is the\n* fix-naming DEPS.EFFECT_VERSION_CONFLICT from checkEffectResolution with the\n* import error riding as cause; otherwise DEPS.EXECUTOR_UNLOADABLE — an\n* environmental failure of the consumer's installed tree, not a bug here. */\nfunction executorLoadFailure(operation, error, cwd) {\n\ttry {\n\t\tcheckEffectResolution(cwd);\n\t} catch (diagnostic) {\n\t\tif (CliStructuredError.is(diagnostic)) return new CliStructuredError(diagnostic.code, diagnostic.message, {\n\t\t\t...diagnostic.why !== void 0 ? { why: diagnostic.why } : {},\n\t\t\t...diagnostic.fix !== void 0 ? { fix: diagnostic.fix } : {},\n\t\t\t...diagnostic.meta !== void 0 ? { meta: diagnostic.meta } : {},\n\t\t\tcause: error\n\t\t});\n\t}\n\treturn new CliStructuredError(\"DEPS.EXECUTOR_UNLOADABLE\", `Could not load the ${operation} executor: ${error instanceof Error ? error.message : String(error)}`, {\n\t\twhy: `The ${operation} operation's executor imports the deploy engine's provider tree from your app's installed dependencies, and that import failed.`,\n\t\tfix: \"Reinstall your dependencies, and check that `alchemy` is installed and loadable from your app.\",\n\t\tcause: error\n\t});\n}\n//#endregion\nexport { checkEffectResolution as i, executorLoadFailure as n, toStructured as r, executionDiagnostics as t };\n\n//# sourceMappingURL=shared-CCaR42wo.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,UAAU,OAAO;CACzB,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;;;;;ACbA,SAAS,UAAU,KAAK,OAAO;CAC9B,OAAO,UAAU,KAAK,IAAI,UAAU,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;AAC1D;;;;;;;;;;;AAaA,IAAI,qBAAqB,cAAc,MAAM;CAC5C;CACA;CACA,YAAY,MAAM,SAAS,SAAS;EACnC,MAAM,SAAS,SAAS,UAAU,KAAK,IAAI,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAK,CAAC;EAC5E,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW,SAAS,YAAY;EACrC,MAAM,MAAM,SAAS,QAAQ,SAAS,MAAM,KAAK,IAAI,SAAS;EAC9D,MAAM,QAAQ,SAAS,QAAQ;GAC9B,GAAG,UAAU,QAAQ,QAAQ,MAAM,IAAI;GACvC,GAAG,UAAU,QAAQ,QAAQ,MAAM,IAAI;EACxC,IAAI,KAAK;EACT,OAAO,OAAO,MAAM;GACnB,GAAG,UAAU,OAAO,SAAS,GAAG;GAChC,GAAG,UAAU,OAAO,GAAG;GACvB,GAAG,UAAU,SAAS,KAAK;GA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