@prisma/composer-cli 0.34.0-dev.5 → 0.34.0-dev.6

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.
Files changed (39) hide show
  1. package/dist/{dev-current-hGle--BH-DHFSz_ur.mjs → dev-current-BB02pfSh-vMKS1rYi.mjs} +6 -6
  2. package/dist/{dev-current-hGle--BH-DHFSz_ur.mjs.map → dev-current-BB02pfSh-vMKS1rYi.mjs.map} +1 -1
  3. package/dist/{dist-D1c-3NFX.mjs → dist-B9-nLeho.mjs} +2 -2
  4. package/dist/{dist-D1c-3NFX.mjs.map → dist-B9-nLeho.mjs.map} +1 -1
  5. package/dist/{execute-deploy-destroy-iO4yn-3Q-5rmMfeg8.mjs → execute-deploy-destroy-DwcoZIks-CiW-dlB1.mjs} +7 -13
  6. package/dist/execute-deploy-destroy-DwcoZIks-CiW-dlB1.mjs.map +1 -0
  7. package/dist/{execute-dev-DQMSVQn9-DL5eWfNL.mjs → execute-dev-BHRWoEnd-DrGMSTD3.mjs} +7 -7
  8. package/dist/{execute-dev-DQMSVQn9-DL5eWfNL.mjs.map → execute-dev-BHRWoEnd-DrGMSTD3.mjs.map} +1 -1
  9. package/dist/{execute-dev-current-C8e554e4-CR_Z_5cs.mjs → execute-dev-current-D4RkOtPA-BFoZ0cXm.mjs} +6 -6
  10. package/dist/{execute-dev-current-C8e554e4-CR_Z_5cs.mjs.map → execute-dev-current-D4RkOtPA-BFoZ0cXm.mjs.map} +1 -1
  11. package/dist/{family-CsvN_3rK-CxpRZHs6.d.mts → family-xJ6y4fXc-CFBu6q4b.d.mts} +29 -28
  12. package/dist/family-xJ6y4fXc-CFBu6q4b.d.mts.map +1 -0
  13. package/dist/family.d.mts +35 -4
  14. package/dist/family.d.mts.map +1 -1
  15. package/dist/family.mjs +86 -6
  16. package/dist/family.mjs.map +1 -1
  17. package/dist/{generate-dev-stack-CfneNj97-YWn8z26x.mjs → generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs} +2 -2
  18. package/dist/{generate-dev-stack-CfneNj97-YWn8z26x.mjs.map → generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs.map} +1 -1
  19. package/dist/list-deployed-DJM8V6Ri.mjs +354 -0
  20. package/dist/list-deployed-DJM8V6Ri.mjs.map +1 -0
  21. package/dist/{local-target-Pro_jmzo.mjs → local-target-CK8gvYV4.mjs} +2 -2
  22. package/dist/{local-target-Pro_jmzo.mjs.map → local-target-CK8gvYV4.mjs.map} +1 -1
  23. package/dist/{pipeline-C06OEvKd-B_vvzzSY.mjs → pipeline-BmWt-Nhb-Bos4TFXR.mjs} +24 -4
  24. package/dist/{pipeline-C06OEvKd-B_vvzzSY.mjs.map → pipeline-BmWt-Nhb-Bos4TFXR.mjs.map} +1 -1
  25. package/dist/{composer-config-ehUUVHtU-Db7akNFy.mjs → run-alchemy-Dl_MWw4g-DaWV9tkH.mjs} +318 -318
  26. package/dist/run-alchemy-Dl_MWw4g-DaWV9tkH.mjs.map +1 -0
  27. package/dist/testing.d.mts +1 -1
  28. package/dist/testing.mjs +2 -2
  29. package/dist/testing.mjs.map +1 -1
  30. package/dist/validate-stage-DxRW3MwT-DOWCXHa_.mjs +13 -0
  31. package/dist/validate-stage-DxRW3MwT-DOWCXHa_.mjs.map +1 -0
  32. package/package.json +9 -7
  33. package/src/exports/family.ts +8 -1
  34. package/src/family/deploy-list.ts +96 -0
  35. package/src/family/deployed-nodes.ts +55 -0
  36. package/src/family/list-deployed.ts +64 -0
  37. package/dist/composer-config-ehUUVHtU-Db7akNFy.mjs.map +0 -1
  38. package/dist/execute-deploy-destroy-iO4yn-3Q-5rmMfeg8.mjs.map +0 -1
  39. package/dist/family-CsvN_3rK-CxpRZHs6.d.mts.map +0 -1
@@ -2,6 +2,230 @@ import { createRequire } from "node:module";
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import spawn from "cross-spawn";
5
+ //#region ../../0-framework/3-tooling/cli/dist/composer-config-ehUUVHtU.mjs
6
+ /**
7
+ * What makes a `composer` section valid, shared by the CLI's section validator and the programmatic operations.
8
+ * It imports nothing from the CLI engine, because `@prisma/composer` must not depend on it.
9
+ */
10
+ const SECTION_FIX = "Write `composer: composer({ entry: './module.ts', extensions: [...], state: ... })` in prisma.config.ts, with `import { defineConfig as composer } from '@prisma/composer/config'`.";
11
+ const MOVE_TO_SECTION_FIX = `${SECTION_FIX} If the project has a prisma-composer.config.ts, move its extensions and state into that section and delete the file.`;
12
+ const SECTION_IS_THE_ONLY_SOURCE = "Composer reads its configuration only from the `composer` section of prisma.config.ts.";
13
+ const DESCRIPTOR_FIX = "Use the descriptor the extension factory returns, unchanged, instead of building one by hand.";
14
+ const RETIRED_FILE_NAMES = [
15
+ "ts",
16
+ "mts",
17
+ "mjs",
18
+ "js"
19
+ ].map((extension) => `prisma-composer.config.${extension}`);
20
+ const sectionMissing = {
21
+ code: "CONFIG.SECTION_MISSING",
22
+ summary: "No loaded prisma.config.ts declares a `composer` section.",
23
+ why: `${SECTION_IS_THE_ONLY_SOURCE} A prisma-composer.config.ts file is no longer read.`,
24
+ fix: MOVE_TO_SECTION_FIX
25
+ };
26
+ /** What the generated stack file throws when the file it imports has no `composer` export. */
27
+ function noComposerExportMessage(configFile) {
28
+ return `${configFile} declares no \`composer\` section. Pass the prisma.config.ts that declares it.`;
29
+ }
30
+ function configFileMissing(file) {
31
+ return {
32
+ code: "CONFIG.FILE_MISSING",
33
+ summary: `${file} does not exist.`,
34
+ fix: "Pass the path of the prisma.config.ts that declares the `composer` section.",
35
+ where: file
36
+ };
37
+ }
38
+ /** A prisma-composer.config.* beside the declaring file would otherwise be silently ignored. */
39
+ /** The path with symlinks resolved; the path itself when it cannot be resolved, so the check never throws. */
40
+ function realPath(file) {
41
+ try {
42
+ return fs.realpathSync(file);
43
+ } catch {
44
+ return file;
45
+ }
46
+ }
47
+ function retiredFileFinding(configFile) {
48
+ const directory = path.dirname(realPath(configFile));
49
+ const found = RETIRED_FILE_NAMES.map((name) => path.join(directory, name)).find((file) => fs.existsSync(file));
50
+ if (found === void 0) return void 0;
51
+ return {
52
+ code: "CONFIG.FILE_RETIRED",
53
+ summary: `${found} is no longer read.`,
54
+ why: SECTION_IS_THE_ONLY_SOURCE,
55
+ fix: MOVE_TO_SECTION_FIX,
56
+ where: found
57
+ };
58
+ }
59
+ function isObject(value) {
60
+ return typeof value === "object" && value !== null && !Array.isArray(value);
61
+ }
62
+ function isExtensionDescriptor(value) {
63
+ return isObject(value) && typeof value["id"] === "string" && value["id"].length > 0 && isObject(value["nodes"]);
64
+ }
65
+ function isStateDescriptor(value) {
66
+ return isObject(value) && typeof value["extension"] === "string" && typeof value["create"] === "function";
67
+ }
68
+ const stateInvalid = {
69
+ code: "CONFIG.FIELD_INVALID",
70
+ summary: "`composer.state` must be a state descriptor with a string `extension` and a `create` function.",
71
+ fix: "Set `state` to the state descriptor an extension provides, e.g. `state: prismaState()`.",
72
+ field: "state"
73
+ };
74
+ const SECTION_FIELDS = /* @__PURE__ */ new Set([
75
+ "entry",
76
+ "extensions",
77
+ "state"
78
+ ]);
79
+ const entryInvalid = {
80
+ code: "CONFIG.FIELD_INVALID",
81
+ summary: "`composer.entry` must be a non-empty string: the path to the module whose default export is the app.",
82
+ fix: "Set `entry` to that module's path, relative to prisma.config.ts, e.g. `entry: './module.ts'`.",
83
+ field: "entry"
84
+ };
85
+ /** Neither the section's `entry` nor an override names the module whose default export is the app. */
86
+ const entryMissing = {
87
+ code: "CONFIG.ENTRY_MISSING",
88
+ summary: "No entry module is set, so there is no app to load.",
89
+ why: "The entry is the module whose default export is the app root, built with module(...).",
90
+ fix: "Set `entry: './module.ts'` in the `composer` section of prisma.config.ts, or pass `--entry <path>` (the `entry` input when calling @prisma/composer/control).",
91
+ field: "entry"
92
+ };
93
+ function unknownField(key) {
94
+ return {
95
+ code: "CONFIG.FIELD_UNKNOWN",
96
+ summary: `The \`composer\` section has no field \`${key}\`.`,
97
+ fix: key === "composer" ? "Pass the `composer` property of the prisma.config.ts export, not the whole export. The section takes only `entry`, `extensions` and `state`." : `Remove \`${key}\`. The section takes only \`entry\`, \`extensions\` and \`state\`.`,
98
+ field: key
99
+ };
100
+ }
101
+ function checkExtensions(value) {
102
+ if (!Array.isArray(value)) return {
103
+ extensions: [],
104
+ findings: [{
105
+ code: "CONFIG.FIELD_INVALID",
106
+ summary: "`composer.extensions` must be an array of extension descriptors.",
107
+ fix: "Set `extensions` to the descriptors your extensions provide, e.g. `extensions: [nodeBuild()]`.",
108
+ field: "extensions"
109
+ }]
110
+ };
111
+ const findings = [];
112
+ const extensions = [];
113
+ const seen = /* @__PURE__ */ new Set();
114
+ for (const [index, entry] of value.entries()) {
115
+ const field = `extensions[${index}]`;
116
+ if (!isObject(entry)) {
117
+ findings.push({
118
+ code: "CONFIG.FIELD_INVALID",
119
+ summary: `\`composer.${field}\` must be an extension descriptor object.`,
120
+ fix: "Put the descriptor an extension factory returns here, e.g. `nodeBuild()`, not the factory itself.",
121
+ field
122
+ });
123
+ continue;
124
+ }
125
+ const id = entry["id"];
126
+ if (typeof id !== "string" || id.length === 0) findings.push({
127
+ code: "CONFIG.FIELD_INVALID",
128
+ summary: `\`composer.${field}.id\` must be a non-empty string (the extension package name).`,
129
+ fix: DESCRIPTOR_FIX,
130
+ field: `${field}.id`
131
+ });
132
+ else if (seen.has(id)) findings.push({
133
+ code: "CONFIG.EXTENSION_DUPLICATE",
134
+ summary: `Extension "${id}" is listed more than once in \`composer.extensions\`.`,
135
+ fix: `Remove the repeated "${id}" entry from \`extensions\`.`,
136
+ field: `${field}.id`
137
+ });
138
+ else seen.add(id);
139
+ if (!isObject(entry["nodes"])) findings.push({
140
+ code: "CONFIG.FIELD_INVALID",
141
+ summary: `\`composer.${field}.nodes\` must be an object (the node-ID → control registry).`,
142
+ fix: DESCRIPTOR_FIX,
143
+ field: `${field}.nodes`
144
+ });
145
+ if (isExtensionDescriptor(entry)) extensions.push(entry);
146
+ }
147
+ return {
148
+ findings,
149
+ extensions
150
+ };
151
+ }
152
+ function checkFields(section) {
153
+ if (Object.hasOwn(section, "configPath")) return {
154
+ ok: false,
155
+ findings: [{
156
+ code: "CONFIG.FIELD_RETIRED",
157
+ summary: "`composer.configPath` is no longer supported: prisma-composer.config.ts is no longer read.",
158
+ why: SECTION_IS_THE_ONLY_SOURCE,
159
+ fix: `Replace \`configPath\` with the section itself. ${MOVE_TO_SECTION_FIX}`,
160
+ field: "configPath"
161
+ }]
162
+ };
163
+ if (Object.hasOwn(section, "composer")) return {
164
+ ok: false,
165
+ findings: [unknownField("composer")]
166
+ };
167
+ const findings = Object.keys(section).filter((key) => !SECTION_FIELDS.has(key)).map(unknownField);
168
+ const checked = checkExtensions(section["extensions"]);
169
+ findings.push(...checked.findings);
170
+ const state = section["state"];
171
+ if (!isStateDescriptor(state)) findings.push(stateInvalid);
172
+ const entry = section["entry"];
173
+ const entryValid = entry === void 0 || typeof entry === "string" && entry.length > 0;
174
+ if (!entryValid) findings.push(entryInvalid);
175
+ const [first, ...rest] = findings;
176
+ if (first === void 0 && isStateDescriptor(state) && entryValid) return {
177
+ ok: true,
178
+ value: {
179
+ extensions: checked.extensions,
180
+ state,
181
+ ...entry === void 0 ? {} : { entry }
182
+ }
183
+ };
184
+ return {
185
+ ok: false,
186
+ findings: [first ?? stateInvalid, ...rest]
187
+ };
188
+ }
189
+ /**
190
+ * Checks the fields that identify each descriptor and returns the descriptors as the config file's own objects.
191
+ * Never throws: a section's values are user code, and a throwing getter or Proxy trap becomes a finding.
192
+ */
193
+ function checkComposerSection(raw) {
194
+ if (!isObject(raw)) return {
195
+ ok: false,
196
+ findings: [{
197
+ code: "CONFIG.FIELD_INVALID",
198
+ summary: "The `composer` section of prisma.config.ts must be an object.",
199
+ fix: SECTION_FIX
200
+ }]
201
+ };
202
+ try {
203
+ return checkFields({ ...raw });
204
+ } catch (cause) {
205
+ return {
206
+ ok: false,
207
+ findings: [{
208
+ code: "CONFIG.FIELD_INVALID",
209
+ summary: "The `composer` section of prisma.config.ts could not be read.",
210
+ why: `Reading it threw: ${cause instanceof Error ? cause.message : String(cause)}`,
211
+ fix: SECTION_FIX
212
+ }]
213
+ };
214
+ }
215
+ }
216
+ /**
217
+ * The whole check, shared by the section validator and the programmatic operations so both report the same findings in the same order: the retired file beside the declaring `configFile` (resolved through symlinks), then every field finding.
218
+ */
219
+ function checkComposerConfig(raw, configFile) {
220
+ const retired = retiredFileFinding(configFile);
221
+ const checked = checkComposerSection(raw);
222
+ if (retired === void 0) return checked;
223
+ return {
224
+ ok: false,
225
+ findings: checked.ok ? [retired] : [retired, ...checked.findings]
226
+ };
227
+ }
228
+ //#endregion
5
229
  //#region ../../0-framework/0-foundation/foundation/dist/casts-DpaahrlC.mjs
6
230
  /**
7
231
  * **Last-resort escape hatch for unsafe type assertions. Not a sanctioned tool to reach for.**
@@ -57,93 +281,6 @@ var InternalError = class extends Error {
57
281
  }
58
282
  };
59
283
  //#endregion
60
- //#region ../../0-framework/0-foundation/foundation/dist/result.mjs
61
- /**
62
- * Generic Result type for representing success or failure outcomes.
63
- *
64
- * This is the standard way to return "expected failures" as values rather than
65
- * throwing exceptions. See docs/Error Handling.md for the full taxonomy.
66
- *
67
- * Naming rationale:
68
- * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator
69
- * - `NotOk` avoids collision with domain types like "Failure" or "Error"
70
- * - `failure` property distinguishes from JS Error semantics
71
- */
72
- /**
73
- * Result class that implements both Ok and NotOk variants.
74
- */
75
- var ResultImpl = class ResultImpl {
76
- ok;
77
- _value;
78
- _failure;
79
- constructor(ok, valueOrFailure) {
80
- this.ok = ok;
81
- if (ok) this._value = blindCast(valueOrFailure);
82
- else this._failure = blindCast(valueOrFailure);
83
- Object.freeze(this);
84
- }
85
- get value() {
86
- if (!this.ok) throw new InternalError("Cannot access value on NotOk result");
87
- return this._value;
88
- }
89
- get failure() {
90
- if (this.ok) throw new InternalError("Cannot access failure on Ok result");
91
- return this._failure;
92
- }
93
- /**
94
- * Creates a successful result.
95
- */
96
- static ok(value) {
97
- return blindCast(new ResultImpl(true, value));
98
- }
99
- /**
100
- * Creates an unsuccessful result.
101
- */
102
- static notOk(failure) {
103
- return blindCast(new ResultImpl(false, failure));
104
- }
105
- /**
106
- * Asserts that this result is Ok and returns the value.
107
- * Throws if the result is NotOk.
108
- */
109
- assertOk() {
110
- if (!this.ok) throw new InternalError("Expected Ok result but got NotOk");
111
- return this.value;
112
- }
113
- /**
114
- * Asserts that this result is NotOk and returns the failure.
115
- * Throws if the result is Ok.
116
- */
117
- assertNotOk() {
118
- if (this.ok) throw new InternalError("Expected NotOk result but got Ok");
119
- return this.failure;
120
- }
121
- };
122
- /**
123
- * Creates a successful result.
124
- */
125
- function ok(value) {
126
- return ResultImpl.ok(value);
127
- }
128
- /**
129
- * Creates an unsuccessful result.
130
- */
131
- function notOk(failure) {
132
- return ResultImpl.notOk(failure);
133
- }
134
- /**
135
- * Singleton for void success results.
136
- * Use this for validation checks that don't produce a value.
137
- */
138
- const OK_VOID = ResultImpl.ok(void 0);
139
- /**
140
- * Returns a successful void result.
141
- * Use this for validation checks that don't produce a value.
142
- */
143
- function okVoid() {
144
- return OK_VOID;
145
- }
146
- //#endregion
147
284
  //#region ../../0-framework/0-foundation/foundation/dist/errors.mjs
148
285
  /**
149
286
  * Returns an object with the key/value if value is defined, otherwise an empty object.
@@ -221,14 +358,101 @@ var CliStructuredError = class extends Error {
221
358
  * Type guard to check if an error is a CliStructuredError.
222
359
  * Uses duck-typing to work across module boundaries where instanceof may fail.
223
360
  */
224
- static is(error) {
225
- if (!(error instanceof Error)) return false;
226
- const candidate = blindCast(error);
227
- return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && typeof candidate.toEnvelope === "function";
361
+ static is(error) {
362
+ if (!(error instanceof Error)) return false;
363
+ const candidate = blindCast(error);
364
+ return candidate.name === "CliStructuredError" && typeof candidate.code === "string" && typeof candidate.toEnvelope === "function";
365
+ }
366
+ };
367
+ //#endregion
368
+ //#region ../../0-framework/0-foundation/foundation/dist/result.mjs
369
+ /**
370
+ * Generic Result type for representing success or failure outcomes.
371
+ *
372
+ * This is the standard way to return "expected failures" as values rather than
373
+ * throwing exceptions. See docs/Error Handling.md for the full taxonomy.
374
+ *
375
+ * Naming rationale:
376
+ * - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator
377
+ * - `NotOk` avoids collision with domain types like "Failure" or "Error"
378
+ * - `failure` property distinguishes from JS Error semantics
379
+ */
380
+ /**
381
+ * Result class that implements both Ok and NotOk variants.
382
+ */
383
+ var ResultImpl = class ResultImpl {
384
+ ok;
385
+ _value;
386
+ _failure;
387
+ constructor(ok, valueOrFailure) {
388
+ this.ok = ok;
389
+ if (ok) this._value = blindCast(valueOrFailure);
390
+ else this._failure = blindCast(valueOrFailure);
391
+ Object.freeze(this);
392
+ }
393
+ get value() {
394
+ if (!this.ok) throw new InternalError("Cannot access value on NotOk result");
395
+ return this._value;
396
+ }
397
+ get failure() {
398
+ if (this.ok) throw new InternalError("Cannot access failure on Ok result");
399
+ return this._failure;
400
+ }
401
+ /**
402
+ * Creates a successful result.
403
+ */
404
+ static ok(value) {
405
+ return blindCast(new ResultImpl(true, value));
406
+ }
407
+ /**
408
+ * Creates an unsuccessful result.
409
+ */
410
+ static notOk(failure) {
411
+ return blindCast(new ResultImpl(false, failure));
412
+ }
413
+ /**
414
+ * Asserts that this result is Ok and returns the value.
415
+ * Throws if the result is NotOk.
416
+ */
417
+ assertOk() {
418
+ if (!this.ok) throw new InternalError("Expected Ok result but got NotOk");
419
+ return this.value;
420
+ }
421
+ /**
422
+ * Asserts that this result is NotOk and returns the failure.
423
+ * Throws if the result is Ok.
424
+ */
425
+ assertNotOk() {
426
+ if (this.ok) throw new InternalError("Expected NotOk result but got Ok");
427
+ return this.failure;
228
428
  }
229
429
  };
430
+ /**
431
+ * Creates a successful result.
432
+ */
433
+ function ok(value) {
434
+ return ResultImpl.ok(value);
435
+ }
436
+ /**
437
+ * Creates an unsuccessful result.
438
+ */
439
+ function notOk(failure) {
440
+ return ResultImpl.notOk(failure);
441
+ }
442
+ /**
443
+ * Singleton for void success results.
444
+ * Use this for validation checks that don't produce a value.
445
+ */
446
+ const OK_VOID = ResultImpl.ok(void 0);
447
+ /**
448
+ * Returns a successful void result.
449
+ * Use this for validation checks that don't produce a value.
450
+ */
451
+ function okVoid() {
452
+ return OK_VOID;
453
+ }
230
454
  //#endregion
231
- //#region ../../0-framework/3-tooling/cli/dist/run-alchemy-BqHpStQn.mjs
455
+ //#region ../../0-framework/3-tooling/cli/dist/run-alchemy-Dl_MWw4g.mjs
232
456
  /**
233
457
  * Which Alchemy CLI runs a generated stack file: the `alchemy` that
234
458
  * `@prisma/composer` depends on, found from the app the way the stack file's
@@ -438,230 +662,6 @@ function spawnCommandLine(line) {
438
662
  });
439
663
  }
440
664
  //#endregion
441
- //#region ../../0-framework/3-tooling/cli/dist/composer-config-ehUUVHtU.mjs
442
- /**
443
- * What makes a `composer` section valid, shared by the CLI's section validator and the programmatic operations.
444
- * It imports nothing from the CLI engine, because `@prisma/composer` must not depend on it.
445
- */
446
- const SECTION_FIX = "Write `composer: composer({ entry: './module.ts', extensions: [...], state: ... })` in prisma.config.ts, with `import { defineConfig as composer } from '@prisma/composer/config'`.";
447
- const MOVE_TO_SECTION_FIX = `${SECTION_FIX} If the project has a prisma-composer.config.ts, move its extensions and state into that section and delete the file.`;
448
- const SECTION_IS_THE_ONLY_SOURCE = "Composer reads its configuration only from the `composer` section of prisma.config.ts.";
449
- const DESCRIPTOR_FIX = "Use the descriptor the extension factory returns, unchanged, instead of building one by hand.";
450
- const RETIRED_FILE_NAMES = [
451
- "ts",
452
- "mts",
453
- "mjs",
454
- "js"
455
- ].map((extension) => `prisma-composer.config.${extension}`);
456
- const sectionMissing = {
457
- code: "CONFIG.SECTION_MISSING",
458
- summary: "No loaded prisma.config.ts declares a `composer` section.",
459
- why: `${SECTION_IS_THE_ONLY_SOURCE} A prisma-composer.config.ts file is no longer read.`,
460
- fix: MOVE_TO_SECTION_FIX
461
- };
462
- /** What the generated stack file throws when the file it imports has no `composer` export. */
463
- function noComposerExportMessage(configFile) {
464
- return `${configFile} declares no \`composer\` section. Pass the prisma.config.ts that declares it.`;
465
- }
466
- function configFileMissing(file) {
467
- return {
468
- code: "CONFIG.FILE_MISSING",
469
- summary: `${file} does not exist.`,
470
- fix: "Pass the path of the prisma.config.ts that declares the `composer` section.",
471
- where: file
472
- };
473
- }
474
- /** A prisma-composer.config.* beside the declaring file would otherwise be silently ignored. */
475
- /** The path with symlinks resolved; the path itself when it cannot be resolved, so the check never throws. */
476
- function realPath(file) {
477
- try {
478
- return fs.realpathSync(file);
479
- } catch {
480
- return file;
481
- }
482
- }
483
- function retiredFileFinding(configFile) {
484
- const directory = path.dirname(realPath(configFile));
485
- const found = RETIRED_FILE_NAMES.map((name) => path.join(directory, name)).find((file) => fs.existsSync(file));
486
- if (found === void 0) return void 0;
487
- return {
488
- code: "CONFIG.FILE_RETIRED",
489
- summary: `${found} is no longer read.`,
490
- why: SECTION_IS_THE_ONLY_SOURCE,
491
- fix: MOVE_TO_SECTION_FIX,
492
- where: found
493
- };
494
- }
495
- function isObject(value) {
496
- return typeof value === "object" && value !== null && !Array.isArray(value);
497
- }
498
- function isExtensionDescriptor(value) {
499
- return isObject(value) && typeof value["id"] === "string" && value["id"].length > 0 && isObject(value["nodes"]);
500
- }
501
- function isStateDescriptor(value) {
502
- return isObject(value) && typeof value["extension"] === "string" && typeof value["create"] === "function";
503
- }
504
- const stateInvalid = {
505
- code: "CONFIG.FIELD_INVALID",
506
- summary: "`composer.state` must be a state descriptor with a string `extension` and a `create` function.",
507
- fix: "Set `state` to the state descriptor an extension provides, e.g. `state: prismaState()`.",
508
- field: "state"
509
- };
510
- const SECTION_FIELDS = /* @__PURE__ */ new Set([
511
- "entry",
512
- "extensions",
513
- "state"
514
- ]);
515
- const entryInvalid = {
516
- code: "CONFIG.FIELD_INVALID",
517
- summary: "`composer.entry` must be a non-empty string: the path to the module whose default export is the app.",
518
- fix: "Set `entry` to that module's path, relative to prisma.config.ts, e.g. `entry: './module.ts'`.",
519
- field: "entry"
520
- };
521
- /** Neither the section's `entry` nor an override names the module whose default export is the app. */
522
- const entryMissing = {
523
- code: "CONFIG.ENTRY_MISSING",
524
- summary: "No entry module is set, so there is no app to load.",
525
- why: "The entry is the module whose default export is the app root, built with module(...).",
526
- fix: "Set `entry: './module.ts'` in the `composer` section of prisma.config.ts, or pass `--entry <path>` (the `entry` input when calling @prisma/composer/control).",
527
- field: "entry"
528
- };
529
- function unknownField(key) {
530
- return {
531
- code: "CONFIG.FIELD_UNKNOWN",
532
- summary: `The \`composer\` section has no field \`${key}\`.`,
533
- fix: key === "composer" ? "Pass the `composer` property of the prisma.config.ts export, not the whole export. The section takes only `entry`, `extensions` and `state`." : `Remove \`${key}\`. The section takes only \`entry\`, \`extensions\` and \`state\`.`,
534
- field: key
535
- };
536
- }
537
- function checkExtensions(value) {
538
- if (!Array.isArray(value)) return {
539
- extensions: [],
540
- findings: [{
541
- code: "CONFIG.FIELD_INVALID",
542
- summary: "`composer.extensions` must be an array of extension descriptors.",
543
- fix: "Set `extensions` to the descriptors your extensions provide, e.g. `extensions: [nodeBuild()]`.",
544
- field: "extensions"
545
- }]
546
- };
547
- const findings = [];
548
- const extensions = [];
549
- const seen = /* @__PURE__ */ new Set();
550
- for (const [index, entry] of value.entries()) {
551
- const field = `extensions[${index}]`;
552
- if (!isObject(entry)) {
553
- findings.push({
554
- code: "CONFIG.FIELD_INVALID",
555
- summary: `\`composer.${field}\` must be an extension descriptor object.`,
556
- fix: "Put the descriptor an extension factory returns here, e.g. `nodeBuild()`, not the factory itself.",
557
- field
558
- });
559
- continue;
560
- }
561
- const id = entry["id"];
562
- if (typeof id !== "string" || id.length === 0) findings.push({
563
- code: "CONFIG.FIELD_INVALID",
564
- summary: `\`composer.${field}.id\` must be a non-empty string (the extension package name).`,
565
- fix: DESCRIPTOR_FIX,
566
- field: `${field}.id`
567
- });
568
- else if (seen.has(id)) findings.push({
569
- code: "CONFIG.EXTENSION_DUPLICATE",
570
- summary: `Extension "${id}" is listed more than once in \`composer.extensions\`.`,
571
- fix: `Remove the repeated "${id}" entry from \`extensions\`.`,
572
- field: `${field}.id`
573
- });
574
- else seen.add(id);
575
- if (!isObject(entry["nodes"])) findings.push({
576
- code: "CONFIG.FIELD_INVALID",
577
- summary: `\`composer.${field}.nodes\` must be an object (the node-ID → control registry).`,
578
- fix: DESCRIPTOR_FIX,
579
- field: `${field}.nodes`
580
- });
581
- if (isExtensionDescriptor(entry)) extensions.push(entry);
582
- }
583
- return {
584
- findings,
585
- extensions
586
- };
587
- }
588
- function checkFields(section) {
589
- if (Object.hasOwn(section, "configPath")) return {
590
- ok: false,
591
- findings: [{
592
- code: "CONFIG.FIELD_RETIRED",
593
- summary: "`composer.configPath` is no longer supported: prisma-composer.config.ts is no longer read.",
594
- why: SECTION_IS_THE_ONLY_SOURCE,
595
- fix: `Replace \`configPath\` with the section itself. ${MOVE_TO_SECTION_FIX}`,
596
- field: "configPath"
597
- }]
598
- };
599
- if (Object.hasOwn(section, "composer")) return {
600
- ok: false,
601
- findings: [unknownField("composer")]
602
- };
603
- const findings = Object.keys(section).filter((key) => !SECTION_FIELDS.has(key)).map(unknownField);
604
- const checked = checkExtensions(section["extensions"]);
605
- findings.push(...checked.findings);
606
- const state = section["state"];
607
- if (!isStateDescriptor(state)) findings.push(stateInvalid);
608
- const entry = section["entry"];
609
- const entryValid = entry === void 0 || typeof entry === "string" && entry.length > 0;
610
- if (!entryValid) findings.push(entryInvalid);
611
- const [first, ...rest] = findings;
612
- if (first === void 0 && isStateDescriptor(state) && entryValid) return {
613
- ok: true,
614
- value: {
615
- extensions: checked.extensions,
616
- state,
617
- ...entry === void 0 ? {} : { entry }
618
- }
619
- };
620
- return {
621
- ok: false,
622
- findings: [first ?? stateInvalid, ...rest]
623
- };
624
- }
625
- /**
626
- * Checks the fields that identify each descriptor and returns the descriptors as the config file's own objects.
627
- * Never throws: a section's values are user code, and a throwing getter or Proxy trap becomes a finding.
628
- */
629
- function checkComposerSection(raw) {
630
- if (!isObject(raw)) return {
631
- ok: false,
632
- findings: [{
633
- code: "CONFIG.FIELD_INVALID",
634
- summary: "The `composer` section of prisma.config.ts must be an object.",
635
- fix: SECTION_FIX
636
- }]
637
- };
638
- try {
639
- return checkFields({ ...raw });
640
- } catch (cause) {
641
- return {
642
- ok: false,
643
- findings: [{
644
- code: "CONFIG.FIELD_INVALID",
645
- summary: "The `composer` section of prisma.config.ts could not be read.",
646
- why: `Reading it threw: ${cause instanceof Error ? cause.message : String(cause)}`,
647
- fix: SECTION_FIX
648
- }]
649
- };
650
- }
651
- }
652
- /**
653
- * The whole check, shared by the section validator and the programmatic operations so both report the same findings in the same order: the retired file beside the declaring `configFile` (resolved through symlinks), then every field finding.
654
- */
655
- function checkComposerConfig(raw, configFile) {
656
- const retired = retiredFileFinding(configFile);
657
- const checked = checkComposerSection(raw);
658
- if (retired === void 0) return checked;
659
- return {
660
- ok: false,
661
- findings: checked.ok ? [retired] : [retired, ...checked.findings]
662
- };
663
- }
664
- //#endregion
665
- export { sectionMissing as a, reproduceCommand as c, notOk as d, ok as f, blindCast as h, noComposerExportMessage as i, spawnAlchemy as l, InternalError as m, configFileMissing as n, alchemyCommandLine as o, okVoid as p, entryMissing as r, alchemyInvocation as s, checkComposerConfig as t, CliStructuredError as u };
665
+ export { notOk as a, CliStructuredError as c, checkComposerConfig as d, configFileMissing as f, sectionMissing as h, spawnAlchemy as i, InternalError as l, noComposerExportMessage as m, alchemyInvocation as n, ok as o, entryMissing as p, reproduceCommand as r, okVoid as s, alchemyCommandLine as t, blindCast as u };
666
666
 
667
- //# sourceMappingURL=composer-config-ehUUVHtU-Db7akNFy.mjs.map
667
+ //# sourceMappingURL=run-alchemy-Dl_MWw4g-DaWV9tkH.mjs.map