@prisma/composer 0.39.0-dev.7 → 0.39.0-dev.8
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-DmCj4luV-BC36-MeB.d.mts → app-config-DriAu5RU-C8hYpR38.d.mts} +17 -15
- package/dist/app-config-DriAu5RU-C8hYpR38.d.mts.map +1 -0
- package/dist/{app-configuration-file-Bbfq5PR3-D4DUNKUM.mjs → app-configuration-file-D0rB5g65-CdMrjkCc.mjs} +10 -40
- package/dist/app-configuration-file-D0rB5g65-CdMrjkCc.mjs.map +1 -0
- package/dist/app-converge-CVlo9uw2-B-fdr0nr.mjs +88 -0
- package/dist/app-converge-CVlo9uw2-B-fdr0nr.mjs.map +1 -0
- package/dist/config-Bpi8QVLB.d.mts +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/control.d.mts +8 -23
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +4 -4
- package/dist/control.mjs.map +1 -1
- package/dist/{converge-in-process-BBBeood8-BCIPOG8X.d.mts → converge-in-process-CTomEXaD-BnDylZP8.d.mts} +5 -5
- package/dist/{converge-in-process-BBBeood8-BCIPOG8X.d.mts.map → converge-in-process-CTomEXaD-BnDylZP8.d.mts.map} +1 -1
- package/dist/converge-in-process-x89zb2MF-Dvj-J8xo.mjs +258 -0
- package/dist/converge-in-process-x89zb2MF-Dvj-J8xo.mjs.map +1 -0
- package/dist/{deploy-B2kxaH5E.mjs → deploy-CSU0kr4j.mjs} +65 -5
- package/dist/{deploy-B2kxaH5E.mjs.map → deploy-CSU0kr4j.mjs.map} +1 -1
- package/dist/deploy-DHgEJDpg.d.mts +32 -0
- package/dist/deploy-DHgEJDpg.d.mts.map +1 -0
- package/dist/deploy.d.mts +4 -4
- package/dist/deploy.mjs +3 -3
- package/dist/{deployment-summary-6LgQDUuu-Dp8kwMs_.d.mts → deployment-summary-6LgQDUuu-Cu_6UNhc.d.mts} +4 -4
- package/dist/{deployment-summary-6LgQDUuu-Dp8kwMs_.d.mts.map → deployment-summary-6LgQDUuu-Cu_6UNhc.d.mts.map} +1 -1
- package/dist/{deployment-summary-YP7eMPJI-CQsj7BHh.mjs → deployment-summary-CVJZn2v0-Dz-gX1rp.mjs} +3 -3
- package/dist/{deployment-summary-YP7eMPJI-CQsj7BHh.mjs.map → deployment-summary-CVJZn2v0-Dz-gX1rp.mjs.map} +1 -1
- package/dist/dev-converge-messages-DML4rTz7-C_EAB5M_.mjs +165 -0
- package/dist/dev-converge-messages-DML4rTz7-C_EAB5M_.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +142 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-gQnmjB4V-BaNhcGpK.mjs → dev-current-ByY2RrbK-DbU6y3PF.mjs} +11 -7
- package/dist/dev-current-ByY2RrbK-DbU6y3PF.mjs.map +1 -0
- package/dist/{dev-environment-name-6eEr5PW8-6sPgQZG3.mjs → dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs} +3 -3
- package/dist/{dev-environment-name-6eEr5PW8-6sPgQZG3.mjs.map → dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs.map} +1 -1
- package/dist/{dist-CyrEbDx6.mjs → dist-Cf_mZHaH.mjs} +2 -2
- package/dist/{dist-CyrEbDx6.mjs.map → dist-Cf_mZHaH.mjs.map} +1 -1
- package/dist/{emulator-retry-CV8rl69G-BgUzkxc-.mjs → emulator-retry-CV8rl69G-scQ105wk.mjs} +2 -2
- package/dist/{emulator-retry-CV8rl69G-BgUzkxc-.mjs.map → emulator-retry-CV8rl69G-scQ105wk.mjs.map} +1 -1
- package/dist/{errors-0e8IVwzi.mjs → errors-DI3TBXE-.mjs} +7 -2
- package/dist/{errors-0e8IVwzi.mjs.map → errors-DI3TBXE-.mjs.map} +1 -1
- package/dist/{execute-deploy-destroy-DKbsBkqK-BWXh0zXQ.mjs → execute-deploy-destroy-D1jnaYqU-RAlTx-NX.mjs} +246 -193
- package/dist/execute-deploy-destroy-D1jnaYqU-RAlTx-NX.mjs.map +1 -0
- package/dist/{execute-dev-DVCWURmI-Cp3i7Hrp.mjs → execute-dev-BP0Shlpd-BNFvs2LF.mjs} +434 -261
- package/dist/execute-dev-BP0Shlpd-BNFvs2LF.mjs.map +1 -0
- package/dist/{execute-dev-current-Dt_9srY2-COEgQ9h4.mjs → execute-dev-current-B792f_1m-BYJ-Rl8m.mjs} +7 -7
- package/dist/{execute-dev-current-Dt_9srY2-COEgQ9h4.mjs.map → execute-dev-current-B792f_1m-BYJ-Rl8m.mjs.map} +1 -1
- package/dist/{execute-log-B34AeU97-CkJiGdIc.mjs → execute-log-BiRHQq6Q-BkQk0Kvo.mjs} +8 -8
- package/dist/{execute-log-B34AeU97-CkJiGdIc.mjs.map → execute-log-BiRHQq6Q-BkQk0Kvo.mjs.map} +1 -1
- package/dist/{graph-1ILOBl8O-DBaUZL2D.d.mts → graph-CUYXjK8S-BzL-mhjq.d.mts} +3 -3
- package/dist/graph-CUYXjK8S-BzL-mhjq.d.mts.map +1 -0
- package/dist/{graph-C6Fqe2gn-qJQBxs_C.mjs → graph-D2WMLL43-CeiC5wdy.mjs} +18 -9
- package/dist/graph-D2WMLL43-CeiC5wdy.mjs.map +1 -0
- package/dist/{graph-types-CaH3flhT-DgrCdRA3.d.mts → graph-types-D4PrtP-l-B0uuchTl.d.mts} +13 -11
- package/dist/{graph-types-CaH3flhT-DgrCdRA3.d.mts.map → graph-types-D4PrtP-l-B0uuchTl.d.mts.map} +1 -1
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-Cnbf_d0q.d.mts → index-D8chHe55.d.mts} +3 -3
- package/dist/{index-Cnbf_d0q.d.mts.map → index-D8chHe55.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/internal-app-configuration-file.d.mts +5 -9
- package/dist/internal-app-configuration-file.d.mts.map +1 -1
- package/dist/internal-app-configuration-file.mjs +2 -2
- package/dist/internal-converge-contract.d.mts +6 -4
- package/dist/internal-converge-contract.d.mts.map +1 -1
- package/dist/internal-converge-contract.mjs +7 -5
- package/dist/internal-converge-contract.mjs.map +1 -1
- package/dist/internal-converge.d.mts +5 -4
- package/dist/internal-converge.mjs +4 -228
- package/dist/load-entry-CEoVBdMj-CHOz7jKf.mjs +527 -0
- package/dist/load-entry-CEoVBdMj-CHOz7jKf.mjs.map +1 -0
- package/dist/local-target-7KRsLMDO.d.mts +31 -0
- package/dist/local-target-7KRsLMDO.d.mts.map +1 -0
- package/dist/{local-target-COdS1iNs.mjs → local-target-DhU1vaxd.mjs} +6 -6
- package/dist/{local-target-COdS1iNs.mjs.map → local-target-DhU1vaxd.mjs.map} +1 -1
- package/dist/local-target.d.mts +3 -31
- package/dist/local-target.mjs +1 -1
- package/dist/{nextjs-DLyeRR7M-CSKy5tFv.d.mts → nextjs-DLyeRR7M-CzUbvPaJ.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-CSKy5tFv.d.mts.map → nextjs-DLyeRR7M-CzUbvPaJ.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/{preflight-transport-C7_3abXW-Bza_hn9G.mjs → preflight-transport-2d6iIchu-B-v7Di6I.mjs} +5 -4
- package/dist/preflight-transport-2d6iIchu-B-v7Di6I.mjs.map +1 -0
- package/dist/{redaction-CjMYXtGp-CEQ5z1PK.mjs → redaction-DY6eDC12-W-FzW7_r.mjs} +16 -4
- package/dist/{redaction-CjMYXtGp-CEQ5z1PK.mjs.map → redaction-DY6eDC12-W-FzW7_r.mjs.map} +1 -1
- package/dist/{redaction-CIaE4m9U-DyJoGPRw.d.mts → redaction-Dn7BRdaP-BcLSPhLV.d.mts} +58 -17
- package/dist/redaction-Dn7BRdaP-BcLSPhLV.d.mts.map +1 -0
- package/dist/report.d.mts +3 -3
- package/dist/report.mjs +2 -2
- package/dist/report.mjs.map +1 -1
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/steps-BZXNqW6U-C_ME2VLd.mjs +112 -0
- package/dist/steps-BZXNqW6U-C_ME2VLd.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/validate-environment-DCZiNSlR-C7lv0cH1.mjs +344 -0
- package/dist/validate-environment-DCZiNSlR-C7lv0cH1.mjs.map +1 -0
- package/package.json +11 -11
- package/skills/prisma-composer-core-concepts/SKILL.md +8 -8
- package/src/exports/dev-converge-worker.ts +2 -0
- package/dist/app-config-DmCj4luV-BC36-MeB.d.mts.map +0 -1
- package/dist/app-configuration-file-Bbfq5PR3-D4DUNKUM.mjs.map +0 -1
- package/dist/config-vv8LBErH.d.mts +0 -1
- package/dist/deploy-w-BcRS8b.d.mts +0 -12
- package/dist/deploy-w-BcRS8b.d.mts.map +0 -1
- package/dist/dev-current-gQnmjB4V-BaNhcGpK.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DKbsBkqK-BWXh0zXQ.mjs.map +0 -1
- package/dist/execute-dev-DVCWURmI-Cp3i7Hrp.mjs.map +0 -1
- package/dist/graph-1ILOBl8O-DBaUZL2D.d.mts.map +0 -1
- package/dist/graph-C6Fqe2gn-qJQBxs_C.mjs.map +0 -1
- package/dist/internal-converge.mjs.map +0 -1
- package/dist/local-target.d.mts.map +0 -1
- package/dist/preflight-transport-C7_3abXW-Bza_hn9G.mjs.map +0 -1
- package/dist/redaction-CIaE4m9U-DyJoGPRw.d.mts.map +0 -1
- package/dist/run-alchemy-BlYyc4Oh-mIzYC4lq.mjs +0 -236
- package/dist/run-alchemy-BlYyc4Oh-mIzYC4lq.mjs.map +0 -1
- package/dist/validate-environment-XwVDifWN-D14WhSH0.mjs +0 -739
- package/dist/validate-environment-XwVDifWN-D14WhSH0.mjs.map +0 -1
|
@@ -1,739 +0,0 @@
|
|
|
1
|
-
import { t as blindCast } from "./casts-DpaahrlC-C5XMnP9S.mjs";
|
|
2
|
-
import { t as describeKind } from "./describe-kind-Cpm_euxo-DsSPENQa.mjs";
|
|
3
|
-
import { C as secretsKeys, n as Load, s as assertAppName, t as GraphCheckError, u as isNode } from "./graph-C6Fqe2gn-qJQBxs_C.mjs";
|
|
4
|
-
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
5
|
-
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
6
|
-
import "./dist-CyrEbDx6.mjs";
|
|
7
|
-
import { n as environmentVariables } from "./config-adapters-DG-uhGfv-Bt1M9f8b.mjs";
|
|
8
|
-
import "./deploy-B2kxaH5E.mjs";
|
|
9
|
-
import { r as credentialLookingValues, t as SecretRedaction, u as valuesUnderSecretsKeys } from "./redaction-CjMYXtGp-CEQ5z1PK.mjs";
|
|
10
|
-
import * as mod from "node:module";
|
|
11
|
-
import * as path$1 from "node:path";
|
|
12
|
-
import * as fs$1 from "node:fs";
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
14
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
-
import { spawnSync } from "node:child_process";
|
|
16
|
-
//#region ../../0-framework/3-tooling/cli/dist/composer-config-QKdY85G-.mjs
|
|
17
|
-
/**
|
|
18
|
-
* What makes a `composer` section valid, shared by the CLI's section validator and the programmatic operations.
|
|
19
|
-
* It imports nothing from the CLI engine, because `@prisma/composer` must not depend on it.
|
|
20
|
-
*/
|
|
21
|
-
const SECTION_FIX = "Write `composer: composer({ entry: './module.ts', extensions: [...], state: ... })` in prisma.config.ts, with `import { defineConfig as composer } from '@prisma/composer/config'`.";
|
|
22
|
-
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.`;
|
|
23
|
-
const SECTION_IS_THE_ONLY_SOURCE = "Composer reads its configuration only from the `composer` section of prisma.config.ts.";
|
|
24
|
-
const DESCRIPTOR_FIX = "Use the descriptor the extension factory returns, unchanged, instead of building one by hand.";
|
|
25
|
-
const RETIRED_FILE_NAMES = [
|
|
26
|
-
"ts",
|
|
27
|
-
"mts",
|
|
28
|
-
"mjs",
|
|
29
|
-
"js"
|
|
30
|
-
].map((extension) => `prisma-composer.config.${extension}`);
|
|
31
|
-
/** What the generated stack file throws when the file it imports has no `composer` export. */
|
|
32
|
-
function noComposerExportMessage(configFile) {
|
|
33
|
-
return `${configFile} declares no \`composer\` section. Pass the prisma.config.ts that declares it.`;
|
|
34
|
-
}
|
|
35
|
-
function configFileMissing(file) {
|
|
36
|
-
return {
|
|
37
|
-
code: "CONFIG.FILE_MISSING",
|
|
38
|
-
summary: `${file} does not exist.`,
|
|
39
|
-
fix: "Pass the path of the prisma.config.ts that declares the `composer` section.",
|
|
40
|
-
where: file
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/** A prisma-composer.config.* beside the declaring file would otherwise be silently ignored. */
|
|
44
|
-
/** The path with symlinks resolved; the path itself when it cannot be resolved, so the check never throws. */
|
|
45
|
-
function realPath(file) {
|
|
46
|
-
try {
|
|
47
|
-
return fs$1.realpathSync(file);
|
|
48
|
-
} catch {
|
|
49
|
-
return file;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function retiredFileFinding(configFile) {
|
|
53
|
-
const directory = path$1.dirname(realPath(configFile));
|
|
54
|
-
const found = RETIRED_FILE_NAMES.map((name) => path$1.join(directory, name)).find((file) => fs$1.existsSync(file));
|
|
55
|
-
if (found === void 0) return void 0;
|
|
56
|
-
return {
|
|
57
|
-
code: "CONFIG.FILE_RETIRED",
|
|
58
|
-
summary: `${found} is no longer read.`,
|
|
59
|
-
why: SECTION_IS_THE_ONLY_SOURCE,
|
|
60
|
-
fix: MOVE_TO_SECTION_FIX,
|
|
61
|
-
where: found
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function isObject(value) {
|
|
65
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
66
|
-
}
|
|
67
|
-
function isExtensionDescriptor(value) {
|
|
68
|
-
return isObject(value) && typeof value["id"] === "string" && value["id"].length > 0 && isObject(value["nodes"]);
|
|
69
|
-
}
|
|
70
|
-
function isStateDescriptor(value) {
|
|
71
|
-
return isObject(value) && typeof value["extension"] === "string" && typeof value["create"] === "function";
|
|
72
|
-
}
|
|
73
|
-
const stateInvalid = {
|
|
74
|
-
code: "CONFIG.FIELD_INVALID",
|
|
75
|
-
summary: "`composer.state` must be a state descriptor with a string `extension` and a `create` function.",
|
|
76
|
-
fix: "Set `state` to the state descriptor an extension provides, e.g. `state: prismaState()`.",
|
|
77
|
-
field: "state"
|
|
78
|
-
};
|
|
79
|
-
const SECTION_FIELDS = /* @__PURE__ */ new Set([
|
|
80
|
-
"entry",
|
|
81
|
-
"extensions",
|
|
82
|
-
"state",
|
|
83
|
-
"config",
|
|
84
|
-
"secrets"
|
|
85
|
-
]);
|
|
86
|
-
const entryInvalid = {
|
|
87
|
-
code: "CONFIG.FIELD_INVALID",
|
|
88
|
-
summary: "`composer.entry` must be a non-empty string: the path to the module whose default export is the app.",
|
|
89
|
-
fix: "Set `entry` to that module's path, relative to prisma.config.ts, e.g. `entry: './module.ts'`.",
|
|
90
|
-
field: "entry"
|
|
91
|
-
};
|
|
92
|
-
/** Neither the section's `entry` nor an override names the module whose default export is the app. */
|
|
93
|
-
const entryMissing = {
|
|
94
|
-
code: "CONFIG.ENTRY_MISSING",
|
|
95
|
-
summary: "No entry module is set, so there is no app to load.",
|
|
96
|
-
why: "The entry is the module whose default export is the app root, built with appRoot(...).",
|
|
97
|
-
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).",
|
|
98
|
-
field: "entry"
|
|
99
|
-
};
|
|
100
|
-
function unknownField(key) {
|
|
101
|
-
return {
|
|
102
|
-
code: "CONFIG.FIELD_UNKNOWN",
|
|
103
|
-
summary: `The \`composer\` section has no field \`${key}\`.`,
|
|
104
|
-
fix: key === "composer" ? "Pass the `composer` property of the prisma.config.ts export, not the whole export. The section takes only `entry`, `extensions`, `state`, `config` and `secrets`." : `Remove \`${key}\`. The section takes only \`entry\`, \`extensions\`, \`state\`, \`config\` and \`secrets\`.`,
|
|
105
|
-
field: key
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function checkExtensions(value) {
|
|
109
|
-
if (!Array.isArray(value)) return {
|
|
110
|
-
extensions: [],
|
|
111
|
-
findings: [{
|
|
112
|
-
code: "CONFIG.FIELD_INVALID",
|
|
113
|
-
summary: "`composer.extensions` must be an array of extension descriptors.",
|
|
114
|
-
fix: "Set `extensions` to the descriptors your extensions provide, e.g. `extensions: [nodeBuild()]`.",
|
|
115
|
-
field: "extensions"
|
|
116
|
-
}]
|
|
117
|
-
};
|
|
118
|
-
const findings = [];
|
|
119
|
-
const extensions = [];
|
|
120
|
-
const seen = /* @__PURE__ */ new Set();
|
|
121
|
-
for (const [index, entry] of value.entries()) {
|
|
122
|
-
const field = `extensions[${index}]`;
|
|
123
|
-
if (!isObject(entry)) {
|
|
124
|
-
findings.push({
|
|
125
|
-
code: "CONFIG.FIELD_INVALID",
|
|
126
|
-
summary: `\`composer.${field}\` must be an extension descriptor object.`,
|
|
127
|
-
fix: "Put the descriptor an extension factory returns here, e.g. `nodeBuild()`, not the factory itself.",
|
|
128
|
-
field
|
|
129
|
-
});
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const id = entry["id"];
|
|
133
|
-
if (typeof id !== "string" || id.length === 0) findings.push({
|
|
134
|
-
code: "CONFIG.FIELD_INVALID",
|
|
135
|
-
summary: `\`composer.${field}.id\` must be a non-empty string (the extension package name).`,
|
|
136
|
-
fix: DESCRIPTOR_FIX,
|
|
137
|
-
field: `${field}.id`
|
|
138
|
-
});
|
|
139
|
-
else if (seen.has(id)) findings.push({
|
|
140
|
-
code: "CONFIG.EXTENSION_DUPLICATE",
|
|
141
|
-
summary: `Extension "${id}" is listed more than once in \`composer.extensions\`.`,
|
|
142
|
-
fix: `Remove the repeated "${id}" entry from \`extensions\`.`,
|
|
143
|
-
field: `${field}.id`
|
|
144
|
-
});
|
|
145
|
-
else seen.add(id);
|
|
146
|
-
if (!isObject(entry["nodes"])) findings.push({
|
|
147
|
-
code: "CONFIG.FIELD_INVALID",
|
|
148
|
-
summary: `\`composer.${field}.nodes\` must be an object (the node-ID → control registry).`,
|
|
149
|
-
fix: DESCRIPTOR_FIX,
|
|
150
|
-
field: `${field}.nodes`
|
|
151
|
-
});
|
|
152
|
-
if (isExtensionDescriptor(entry)) extensions.push(entry);
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
findings,
|
|
156
|
-
extensions
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function isAdapterList(value) {
|
|
160
|
-
return Array.isArray(value) && value.every((entry) => typeof entry === "function");
|
|
161
|
-
}
|
|
162
|
-
function checkAdapters(list, value) {
|
|
163
|
-
if (value === void 0) return [];
|
|
164
|
-
if (!Array.isArray(value)) return [{
|
|
165
|
-
code: "CONFIG.FIELD_INVALID",
|
|
166
|
-
summary: `\`composer.${list}\` must be an array of adapters.`,
|
|
167
|
-
fix: `Set \`${list}\` to a list of adapters, e.g. \`${list}: [dotenv(), environmentVariables()]\`, imported from '@prisma/composer/config'.`,
|
|
168
|
-
field: list
|
|
169
|
-
}];
|
|
170
|
-
return value.flatMap((entry, index) => typeof entry === "function" ? [] : [{
|
|
171
|
-
code: "CONFIG.FIELD_INVALID",
|
|
172
|
-
summary: `\`composer.${list}[${index}]\` must be an adapter: a function that receives the environment and returns its values.`,
|
|
173
|
-
fix: "Put an adapter here, e.g. `dotenv()`.",
|
|
174
|
-
field: `${list}[${index}]`
|
|
175
|
-
}]);
|
|
176
|
-
}
|
|
177
|
-
function checkFields(section) {
|
|
178
|
-
if (Object.hasOwn(section, "configPath")) return {
|
|
179
|
-
ok: false,
|
|
180
|
-
findings: [{
|
|
181
|
-
code: "CONFIG.FIELD_RETIRED",
|
|
182
|
-
summary: "`composer.configPath` is no longer supported: prisma-composer.config.ts is no longer read.",
|
|
183
|
-
why: SECTION_IS_THE_ONLY_SOURCE,
|
|
184
|
-
fix: `Replace \`configPath\` with the section itself. ${MOVE_TO_SECTION_FIX}`,
|
|
185
|
-
field: "configPath"
|
|
186
|
-
}]
|
|
187
|
-
};
|
|
188
|
-
if (Object.hasOwn(section, "composer")) return {
|
|
189
|
-
ok: false,
|
|
190
|
-
findings: [unknownField("composer")]
|
|
191
|
-
};
|
|
192
|
-
const findings = Object.keys(section).filter((key) => !SECTION_FIELDS.has(key)).map(unknownField);
|
|
193
|
-
const checked = checkExtensions(section["extensions"]);
|
|
194
|
-
findings.push(...checked.findings);
|
|
195
|
-
const state = section["state"];
|
|
196
|
-
if (!isStateDescriptor(state)) findings.push(stateInvalid);
|
|
197
|
-
const entry = section["entry"];
|
|
198
|
-
const entryValid = entry === void 0 || typeof entry === "string" && entry.length > 0;
|
|
199
|
-
if (!entryValid) findings.push(entryInvalid);
|
|
200
|
-
const config = section["config"];
|
|
201
|
-
const secrets = section["secrets"];
|
|
202
|
-
findings.push(...checkAdapters("config", config), ...checkAdapters("secrets", secrets));
|
|
203
|
-
const [first, ...rest] = findings;
|
|
204
|
-
if (first === void 0 && isStateDescriptor(state) && entryValid && (config === void 0 || isAdapterList(config)) && (secrets === void 0 || isAdapterList(secrets))) return {
|
|
205
|
-
ok: true,
|
|
206
|
-
value: {
|
|
207
|
-
extensions: checked.extensions,
|
|
208
|
-
state,
|
|
209
|
-
...entry === void 0 ? {} : { entry },
|
|
210
|
-
...config === void 0 ? {} : { config },
|
|
211
|
-
...secrets === void 0 ? {} : { secrets }
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
return {
|
|
215
|
-
ok: false,
|
|
216
|
-
findings: [first ?? stateInvalid, ...rest]
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Checks the fields that identify each descriptor and returns the descriptors as the config file's own objects.
|
|
221
|
-
* Never throws: a section's values are user code, and a throwing getter or Proxy trap becomes a finding.
|
|
222
|
-
*/
|
|
223
|
-
function checkComposerSection(raw) {
|
|
224
|
-
if (!isObject(raw)) return {
|
|
225
|
-
ok: false,
|
|
226
|
-
findings: [{
|
|
227
|
-
code: "CONFIG.FIELD_INVALID",
|
|
228
|
-
summary: "The `composer` section of prisma.config.ts must be an object.",
|
|
229
|
-
fix: SECTION_FIX
|
|
230
|
-
}]
|
|
231
|
-
};
|
|
232
|
-
try {
|
|
233
|
-
return checkFields({ ...raw });
|
|
234
|
-
} catch (cause) {
|
|
235
|
-
return {
|
|
236
|
-
ok: false,
|
|
237
|
-
findings: [{
|
|
238
|
-
code: "CONFIG.FIELD_INVALID",
|
|
239
|
-
summary: "The `composer` section of prisma.config.ts could not be read.",
|
|
240
|
-
why: `Reading it threw: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
241
|
-
fix: SECTION_FIX
|
|
242
|
-
}]
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* 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.
|
|
248
|
-
*/
|
|
249
|
-
function checkComposerConfig(raw, configFile) {
|
|
250
|
-
const retired = retiredFileFinding(configFile);
|
|
251
|
-
const checked = checkComposerSection(raw);
|
|
252
|
-
if (retired === void 0) return checked;
|
|
253
|
-
return {
|
|
254
|
-
ok: false,
|
|
255
|
-
findings: checked.ok ? [retired] : [retired, ...checked.findings]
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region ../../0-framework/3-tooling/assemble/dist/index.mjs
|
|
260
|
-
/**
|
|
261
|
-
* A user-facing assembly failure, structured at origin (base-type rule 6):
|
|
262
|
-
* a `CliStructuredError` whose code names which way assembly went wrong.
|
|
263
|
-
* This package's second consumer is the programmatic deploy API, not just
|
|
264
|
-
* the CLI — hosts branch on `error.code`, the CLI renders the envelope.
|
|
265
|
-
*/
|
|
266
|
-
var AssembleError = class extends CliStructuredError {
|
|
267
|
-
constructor(code, summary, options) {
|
|
268
|
-
super(code, summary, options);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* The registry route for one service's build: extension by
|
|
273
|
-
* `build.extension`, node descriptor by `build.type`, kind must be "build".
|
|
274
|
-
* The CLI's coverage validation reports the same misses earlier with the
|
|
275
|
-
* config fix; these errors are the backstop for programmatic callers.
|
|
276
|
-
*/
|
|
277
|
-
function buildDescriptorAssemble(config, node, address, cwd, report) {
|
|
278
|
-
const { extension, type } = node.build;
|
|
279
|
-
const extensionDescriptor = config.extensions.find((candidate) => candidate.id === extension);
|
|
280
|
-
if (extensionDescriptor === void 0) throw new AssembleError("ASSEMBLE.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by service "${node.name}"'s build).`, { fix: "Add it to `extensions` in the `composer` section of prisma.config.ts." });
|
|
281
|
-
const nodeDescriptor = extensionDescriptor.nodes[type];
|
|
282
|
-
if (nodeDescriptor === void 0) throw new AssembleError("ASSEMBLE.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for build type "${type}".`, { why: `Known types: ${Object.keys(extensionDescriptor.nodes).join(", ")}.` });
|
|
283
|
-
if (nodeDescriptor.kind !== "build") throw new AssembleError("ASSEMBLE.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for type "${type}" is a "${nodeDescriptor.kind}" descriptor.`, { why: "Assembling a service build needs a \"build\" descriptor." });
|
|
284
|
-
return nodeDescriptor.assemble({
|
|
285
|
-
build: node.build,
|
|
286
|
-
address,
|
|
287
|
-
cwd,
|
|
288
|
-
report
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* The dev server a service's build descriptor declares, or `undefined` when it
|
|
293
|
-
* declares none — including when the registry route misses, which the
|
|
294
|
-
* assemble that follows reports with its own pinned error.
|
|
295
|
-
*/
|
|
296
|
-
async function buildDescriptorServe(config, node, address) {
|
|
297
|
-
const { extension, type } = node.build;
|
|
298
|
-
const nodeDescriptor = config.extensions.find((candidate) => candidate.id === extension)?.nodes[type];
|
|
299
|
-
if (nodeDescriptor?.kind !== "build" || nodeDescriptor.serve === void 0) return void 0;
|
|
300
|
-
try {
|
|
301
|
-
return await nodeDescriptor.serve({
|
|
302
|
-
build: node.build,
|
|
303
|
-
address
|
|
304
|
-
});
|
|
305
|
-
} catch (error) {
|
|
306
|
-
if (CliStructuredError.is(error)) throw error;
|
|
307
|
-
throw new CliStructuredError("DEV.DEV_SERVER_UNAVAILABLE", `service "${address}" cannot run its dev server: ${error instanceof Error ? error.message : String(error)}`, {
|
|
308
|
-
meta: { address },
|
|
309
|
-
cause: error
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async function assembleServices(graph, config, cwd, run, onEvent, options = {}) {
|
|
314
|
-
const runAssembler = run ?? ((node, address, nodeCwd, report) => buildDescriptorAssemble(config, node, address, nodeCwd, report));
|
|
315
|
-
const serviceNodes = graph.nodes.filter((n) => n.node.kind === "service");
|
|
316
|
-
if (serviceNodes.length === 0) throw new AssembleError("ASSEMBLE.SERVICE_MISSING", "The loaded graph has no service to assemble.");
|
|
317
|
-
const bundles = {};
|
|
318
|
-
const devServers = {};
|
|
319
|
-
for (const { id, node } of serviceNodes) {
|
|
320
|
-
if (options.devServers === true) {
|
|
321
|
-
const server = await buildDescriptorServe(config, node, id);
|
|
322
|
-
if (server !== void 0) {
|
|
323
|
-
devServers[id] = server;
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
onEvent?.({
|
|
328
|
-
kind: "service-started",
|
|
329
|
-
address: id
|
|
330
|
-
});
|
|
331
|
-
const data = {};
|
|
332
|
-
let artifact;
|
|
333
|
-
try {
|
|
334
|
-
artifact = await runAssembler(node, id, cwd, (reported) => Object.assign(data, reported));
|
|
335
|
-
} catch (error) {
|
|
336
|
-
if (CliStructuredError.is(error)) throw error;
|
|
337
|
-
throw new AssembleError("ASSEMBLE.BUILD_FAILED", error instanceof Error ? error.message : String(error), {
|
|
338
|
-
meta: { address: id },
|
|
339
|
-
cause: error
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
bundles[id] = artifact;
|
|
343
|
-
onEvent?.({
|
|
344
|
-
kind: "service-assembled",
|
|
345
|
-
address: id,
|
|
346
|
-
data
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
return {
|
|
350
|
-
bundles,
|
|
351
|
-
devServers
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region ../../0-framework/3-tooling/cli/dist/validate-environment-XwVDifWN.mjs
|
|
356
|
-
function adapterInvalid(list, index, input, summary, fix) {
|
|
357
|
-
return new CliStructuredError("CONFIG.ADAPTER_INVALID", summary, {
|
|
358
|
-
fix,
|
|
359
|
-
where: { path: input.configFile },
|
|
360
|
-
meta: { field: `${list}[${index}]` }
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
function isValues(value) {
|
|
364
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
365
|
-
}
|
|
366
|
-
function isText(values) {
|
|
367
|
-
return Object.values(values).every((value) => typeof value === "string");
|
|
368
|
-
}
|
|
369
|
-
async function readAdapters(list, adapters, input) {
|
|
370
|
-
const adapterInput = Object.freeze({
|
|
371
|
-
environment: input.environment,
|
|
372
|
-
configDirectory: path$1.dirname(input.configFile)
|
|
373
|
-
});
|
|
374
|
-
const merged = Object.create(null);
|
|
375
|
-
for (const [index, adapter] of adapters.entries()) {
|
|
376
|
-
const field = `composer.${list}[${index}]`;
|
|
377
|
-
let values;
|
|
378
|
-
try {
|
|
379
|
-
values = await adapter(adapterInput);
|
|
380
|
-
} catch (thrown) {
|
|
381
|
-
throw new CliStructuredError("CONFIG.ADAPTER_FAILED", `\`${field}\` failed to read the values for the environment "${input.environment}".`, {
|
|
382
|
-
why: `It threw: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
383
|
-
fix: `Fix the adapter, or remove it from \`composer.${list}\` in prisma.config.ts.`,
|
|
384
|
-
where: { path: input.configFile },
|
|
385
|
-
meta: { field: `${list}[${index}]` },
|
|
386
|
-
cause: thrown
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
if (typeof values === "function") throw adapterInvalid(list, index, input, `\`${field}\` returned a function, not an object of values.`, "An adapter factory was put in the list instead of the adapter it makes: write `dotenv()`, not `dotenv`.");
|
|
390
|
-
if (!isValues(values)) throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(values)}, not an object of values.`, "Return an object whose keys are the names of the values, e.g. `{ EMAIL_FROM: 'shop@example.com' }`.");
|
|
391
|
-
for (const [key, value] of Object.entries(values)) {
|
|
392
|
-
if (value === void 0) continue;
|
|
393
|
-
if (list === "secrets" && typeof value !== "string") throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(value)} for "${key}", but a secret is text.`, "Return the secret as a string. A platform variable holds text.");
|
|
394
|
-
merged[key] = value;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return Object.freeze(merged);
|
|
398
|
-
}
|
|
399
|
-
/** Calls the section's `config` adapters (default `[environmentVariables()]`) and merges what they return: the app configuration. */
|
|
400
|
-
function readAppConfiguration(section, input) {
|
|
401
|
-
return readAdapters("config", section.config ?? [environmentVariables()], input);
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* Calls the section's `secrets` adapters (default `[environmentVariables()]`) and merges what they
|
|
405
|
-
* return: the app secrets. Every value must be text. A value is a known secret only once the graph
|
|
406
|
-
* names it, so this adds none.
|
|
407
|
-
*/
|
|
408
|
-
async function readAppSecrets(section, input) {
|
|
409
|
-
const merged = await readAdapters("secrets", section.secrets ?? [environmentVariables()], input);
|
|
410
|
-
if (!isText(merged)) throw new InternalError("readAdapters admitted a secret that is not text");
|
|
411
|
-
return merged;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Synchronous Node resolve hook so that entry modules may import relative
|
|
415
|
-
* files using the specifier forms TypeScript accepts by default —
|
|
416
|
-
* extensionless `./service` and `./service.js` for a `.ts` source file —
|
|
417
|
-
* without requiring `allowImportingTsExtensions` in every consumer's tsconfig.
|
|
418
|
-
*
|
|
419
|
-
* Resolution only; uses TypeScript's own documented mapping: for a specifier
|
|
420
|
-
* Node could not resolve, strip any JS-family extension and probe the
|
|
421
|
-
* corresponding TypeScript source; first candidate that exists on disk wins.
|
|
422
|
-
* Format-specific rules: `.mjs` → `.mts`; `.cjs` → `.cts`; `.js` and
|
|
423
|
-
* extensionless → `.ts`, `.mts`, `.tsx`, then `./index.ts`. Bare and package
|
|
424
|
-
* specifiers are never touched. Existing `./x.ts` imports keep working —
|
|
425
|
-
* Node resolves them before the hook fires (ADR-0005: no transform, no
|
|
426
|
-
* guessing, deterministic TypeScript rule).
|
|
427
|
-
*
|
|
428
|
-
* Bun resolves `./x.js` and `./x` to `x.ts` natively, so the hook is a
|
|
429
|
-
* no-op under Bun. Nothing is registered there.
|
|
430
|
-
*/
|
|
431
|
-
let registered = false;
|
|
432
|
-
/**
|
|
433
|
-
* Registers the resolve hook once (idempotent). Call at the start of
|
|
434
|
-
* `loadEntry` so every module in the entry graph benefits, including those
|
|
435
|
-
* imported lazily after the entry itself loads.
|
|
436
|
-
*/
|
|
437
|
-
function registerEntryResolution() {
|
|
438
|
-
if (registered || typeof process.versions.bun === "string") return;
|
|
439
|
-
if (typeof mod.registerHooks !== "function") return;
|
|
440
|
-
registered = true;
|
|
441
|
-
mod.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
442
|
-
try {
|
|
443
|
-
return nextResolve(specifier, context);
|
|
444
|
-
} catch (error) {
|
|
445
|
-
if (!isRelativeSpecifier(specifier) || context.parentURL === void 0 || !isModuleNotFoundError(error)) throw error;
|
|
446
|
-
for (const candidate of sourceCandidates(new URL(specifier, context.parentURL))) if (existsSync(fileURLToPath(candidate))) return nextResolve(candidate.href, context);
|
|
447
|
-
throw error;
|
|
448
|
-
}
|
|
449
|
-
} });
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* TypeScript's extension mapping: for a JS-family or extensionless URL,
|
|
453
|
-
* produce the source candidates to probe. Format-specific: `.mjs` maps only
|
|
454
|
-
* to `.mts`; `.cjs` maps only to `.cts`; `.js` and extensionless probe
|
|
455
|
-
* `.ts`, `.mts`, `.tsx` (keeping `.tsx` so the JSX diagnostic fires), then
|
|
456
|
-
* `./index.ts`.
|
|
457
|
-
*/
|
|
458
|
-
function sourceCandidates(resolved) {
|
|
459
|
-
const href = resolved.href;
|
|
460
|
-
if (href.endsWith(".mjs")) {
|
|
461
|
-
const base = href.slice(0, -4);
|
|
462
|
-
return [new URL(`${base}.mts`)];
|
|
463
|
-
}
|
|
464
|
-
if (href.endsWith(".cjs")) {
|
|
465
|
-
const base = href.slice(0, -4);
|
|
466
|
-
return [new URL(`${base}.cts`)];
|
|
467
|
-
}
|
|
468
|
-
const base = href.endsWith(".js") ? href.slice(0, -3) : href;
|
|
469
|
-
return [
|
|
470
|
-
new URL(`${base}.ts`),
|
|
471
|
-
new URL(`${base}.mts`),
|
|
472
|
-
new URL(`${base}.tsx`),
|
|
473
|
-
new URL(`${base}/index.ts`)
|
|
474
|
-
];
|
|
475
|
-
}
|
|
476
|
-
function isRelativeSpecifier(specifier) {
|
|
477
|
-
return specifier.startsWith("./") || specifier.startsWith("../");
|
|
478
|
-
}
|
|
479
|
-
function isModuleNotFoundError(error) {
|
|
480
|
-
if (!(error instanceof Error)) return false;
|
|
481
|
-
if (!("code" in error)) return false;
|
|
482
|
-
return error.code === "ERR_MODULE_NOT_FOUND";
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* `loadEntry` imports a user's topology with the host runtime's own module
|
|
486
|
-
* loader — under node (the CLI's shebang runtime), that loader strips
|
|
487
|
-
* TypeScript types but has no JSX transform (ADR-0005: the framework
|
|
488
|
-
* doesn't bundle or transform the app's code; deploy loading is no
|
|
489
|
-
* exception). A `.tsx`/`.jsx` file anywhere in the topology's import graph
|
|
490
|
-
* dies with node's raw `ERR_UNKNOWN_FILE_EXTENSION`, which names the file
|
|
491
|
-
* but not the cause or the fix. This turns that one case into structured
|
|
492
|
-
* error parts (summary/why/fix) that do — every other load failure (syntax
|
|
493
|
-
* errors, missing files, non-JSX unknown extensions) is untouched.
|
|
494
|
-
*/
|
|
495
|
-
const UNKNOWN_EXTENSION_CODE = "ERR_UNKNOWN_FILE_EXTENSION";
|
|
496
|
-
const JSX_EXTENSIONS = [".tsx", ".jsx"];
|
|
497
|
-
function errorCode(error) {
|
|
498
|
-
return "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
499
|
-
}
|
|
500
|
-
function unknownExtensionPath(error) {
|
|
501
|
-
if (!(error instanceof Error)) return void 0;
|
|
502
|
-
if (errorCode(error) !== UNKNOWN_EXTENSION_CODE) return void 0;
|
|
503
|
-
return /Unknown file extension "\.\w+" for (.+)$/.exec(error.message)?.[1];
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Returns structured error parts when `error` is node's
|
|
507
|
-
* `ERR_UNKNOWN_FILE_EXTENSION` for a `.tsx`/`.jsx` file — `undefined` for
|
|
508
|
-
* every other error (including unknown-extension failures for some other
|
|
509
|
-
* extension), so the caller can fall through to its normal rethrow.
|
|
510
|
-
*/
|
|
511
|
-
function explainJsxLoadError(error, entryPath) {
|
|
512
|
-
const offendingPath = unknownExtensionPath(error);
|
|
513
|
-
if (offendingPath === void 0) return void 0;
|
|
514
|
-
if (!JSX_EXTENSIONS.some((ext) => offendingPath.endsWith(ext))) return void 0;
|
|
515
|
-
return {
|
|
516
|
-
summary: `"${offendingPath}" can't be loaded.`,
|
|
517
|
-
why: `deploy loads "${entryPath}"'s topology with node's own module loader, which strips TypeScript types but has no JSX transform — so a .tsx/.jsx file can't sit anywhere in that import graph.`,
|
|
518
|
-
fix: "Precompile that file in your own build (transform the JSX away, keep the real npm packages external) and import the compiled output instead of the raw .tsx/.jsx — see examples/email/scripts/build.ts in the prisma/composer repo for a worked example."
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Pipeline step 2 (deploy-cli.md § The pipeline): import the entry module
|
|
523
|
-
* (resolved against cwd) and require its default export to be the app's root:
|
|
524
|
-
* an app root built with `appRoot()`, or a module built with `module()`
|
|
525
|
-
* (ADR-0003).
|
|
526
|
-
*/
|
|
527
|
-
/** `unloadableFix`, when given, says where the path came from, so a wrong path names its source. */
|
|
528
|
-
async function loadEntry(entryArg, cwd, unloadableFix) {
|
|
529
|
-
registerEntryResolution();
|
|
530
|
-
const resolvedPath = path$1.resolve(cwd, entryArg);
|
|
531
|
-
let mod;
|
|
532
|
-
try {
|
|
533
|
-
mod = await import(pathToFileURL(resolvedPath).href);
|
|
534
|
-
} catch (error) {
|
|
535
|
-
const explained = explainJsxLoadError(error, resolvedPath);
|
|
536
|
-
if (explained !== void 0) throw new CliStructuredError("COMPOSE.ENTRY_UNLOADABLE", explained.summary, {
|
|
537
|
-
why: explained.why,
|
|
538
|
-
fix: explained.fix,
|
|
539
|
-
where: { path: resolvedPath },
|
|
540
|
-
cause: error
|
|
541
|
-
});
|
|
542
|
-
throw new CliStructuredError("COMPOSE.ENTRY_UNLOADABLE", `Failed to import entry module "${resolvedPath}": ${error instanceof Error ? error.message : String(error)}`, {
|
|
543
|
-
...unloadableFix === void 0 ? {} : { fix: unloadableFix },
|
|
544
|
-
where: { path: resolvedPath },
|
|
545
|
-
cause: error
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
const root = blindCast(mod).default;
|
|
549
|
-
if (isNode(root) && root.kind === "service") throw new CliStructuredError("COMPOSE.ROOT_NOT_MODULE", `The entry "${resolvedPath}" default-exports a service. The app's root must be a module, built with appRoot().`, {
|
|
550
|
-
fix: "Provision the service inside a root, e.g. export default appRoot('name', ({ provision }) => { provision(service); }).",
|
|
551
|
-
where: { path: resolvedPath }
|
|
552
|
-
});
|
|
553
|
-
if (!isNode(root) || root.kind !== "module") throw new CliStructuredError("COMPOSE.ENTRY_EXPORT_INVALID", `Entry module "${resolvedPath}" must default-export the app's root.`, {
|
|
554
|
-
fix: "Build it with appRoot() from @prisma/composer.",
|
|
555
|
-
where: { path: resolvedPath }
|
|
556
|
-
});
|
|
557
|
-
return {
|
|
558
|
-
path: resolvedPath,
|
|
559
|
-
root
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
function lookup(extensions, extension, type, expectedKind, what) {
|
|
563
|
-
const ext = extensions.get(extension);
|
|
564
|
-
if (ext === void 0) throw new CliStructuredError("CONFIG.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by ${what}).`, {
|
|
565
|
-
fix: "Add it to `extensions` in the `composer` section of prisma.config.ts (import its /control entry and list its descriptor).",
|
|
566
|
-
meta: {
|
|
567
|
-
extension,
|
|
568
|
-
type
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
|
-
const descriptor = ext.nodes[type];
|
|
572
|
-
if (descriptor === void 0) throw new CliStructuredError("CONFIG.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for node type "${type}" (needed by ${what}).`, {
|
|
573
|
-
why: `Known types: ${Object.keys(ext.nodes).join(", ")}.`,
|
|
574
|
-
meta: {
|
|
575
|
-
extension,
|
|
576
|
-
type
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
if (descriptor.kind !== expectedKind) throw new CliStructuredError("CONFIG.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for node type "${type}" is a "${descriptor.kind}" descriptor — ${what} needs a "${expectedKind}" descriptor.`, { meta: {
|
|
580
|
-
extension,
|
|
581
|
-
type,
|
|
582
|
-
kind: descriptor.kind
|
|
583
|
-
} });
|
|
584
|
-
}
|
|
585
|
-
/** Throws a structured CONFIG.* error on the first uncovered `(extension, type)`; silent when the config covers the whole graph. */
|
|
586
|
-
function validateRegistryCoverage(graph, config) {
|
|
587
|
-
const extensions = new Map(config.extensions.map((descriptor) => [descriptor.id, descriptor]));
|
|
588
|
-
for (const { id, node } of graph.nodes) {
|
|
589
|
-
if (node.kind === "resource") {
|
|
590
|
-
lookup(extensions, node.extension, node.type, "resource", `resource node "${id}"`);
|
|
591
|
-
continue;
|
|
592
|
-
}
|
|
593
|
-
if (node.kind !== "service") continue;
|
|
594
|
-
lookup(extensions, node.extension, node.type, "service", `service node "${id}"`);
|
|
595
|
-
lookup(extensions, node.build.extension, node.build.type, "build", `service node "${id}"'s build descriptor`);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* The shared prefix of `deploy`/`destroy`/`dev` (deploy-cli.md § The
|
|
600
|
-
* pipeline; local-dev spec § 6): entry load, Load,
|
|
601
|
-
* registry coverage validation, name resolution, assemble. Deploy and dev
|
|
602
|
-
* diverge after this — deploy resolves containers/preflight/stack file
|
|
603
|
-
* against the hosted providers, dev against the local ones — so everything
|
|
604
|
-
* up to and including assemble lives here once, consumed verbatim by both
|
|
605
|
-
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
606
|
-
* cannot drift.
|
|
607
|
-
*/
|
|
608
|
-
const NO_SECRETS = Object.freeze({});
|
|
609
|
-
function configError(findings, file) {
|
|
610
|
-
const [first] = findings;
|
|
611
|
-
return new CliStructuredError(first.code, first.summary, {
|
|
612
|
-
...first.why === void 0 ? {} : { why: first.why },
|
|
613
|
-
fix: first.fix,
|
|
614
|
-
where: { path: first.where ?? file },
|
|
615
|
-
meta: {
|
|
616
|
-
...first.field === void 0 ? {} : { field: first.field },
|
|
617
|
-
findings
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Refuses a caller's config with the same findings, in the same order, as the CLI's section validator.
|
|
623
|
-
* The error is the first finding and carries all of them in `meta.findings`. Returns the config with `file` resolved against `cwd`.
|
|
624
|
-
*/
|
|
625
|
-
function checkConfigSource(source, cwd) {
|
|
626
|
-
const file = path$1.resolve(cwd, source.file);
|
|
627
|
-
if (!fs$1.existsSync(file)) throw configError([configFileMissing(file)], file);
|
|
628
|
-
const checked = checkComposerConfig(source.value, file);
|
|
629
|
-
if (!checked.ok) throw configError(checked.findings, file);
|
|
630
|
-
return {
|
|
631
|
-
value: checked.value,
|
|
632
|
-
file
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Resolves the entry module. An override (`--entry`, or an operation's `entry` input) resolves
|
|
637
|
-
* against `cwd`; the section's `entry` resolves against the directory of the file that declares it,
|
|
638
|
-
* as the CLI engine resolves path fields in prisma.config.ts.
|
|
639
|
-
*/
|
|
640
|
-
function resolveEntryPath(override, source, cwd) {
|
|
641
|
-
if (override !== void 0) return {
|
|
642
|
-
path: path$1.resolve(cwd, override),
|
|
643
|
-
fix: `Check the \`--entry\` path (the \`entry\` input when calling @prisma/composer/control) "${override}". It is relative to the current directory, ${cwd}.`
|
|
644
|
-
};
|
|
645
|
-
const configured = source.value.entry;
|
|
646
|
-
if (configured === void 0) throw configError([entryMissing], source.file);
|
|
647
|
-
return {
|
|
648
|
-
path: path$1.resolve(path$1.dirname(source.file), configured),
|
|
649
|
-
fix: `Check \`entry: "${configured}"\` in ${source.file}. It is relative to that file's directory.`
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* The pipeline's front — entry load and name resolution —
|
|
654
|
-
* WITHOUT Load, coverage, or assemble. `log` needs only who the app is (its
|
|
655
|
-
* config and resolved name) to reach the already-running local instance; it
|
|
656
|
-
* neither builds nor provisions, so it must not require the user's built
|
|
657
|
-
* output the way the full pipeline does.
|
|
658
|
-
*/
|
|
659
|
-
async function resolveAppIdentity(entry, overrideName, cwd, config) {
|
|
660
|
-
const checked = checkConfigSource(config, cwd);
|
|
661
|
-
const { value } = checked;
|
|
662
|
-
const resolved = resolveEntryPath(entry, checked, cwd);
|
|
663
|
-
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
664
|
-
const name = overrideName ?? entryModule.root.name;
|
|
665
|
-
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
666
|
-
assertAppName(name);
|
|
667
|
-
return {
|
|
668
|
-
config: value,
|
|
669
|
-
name
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Runs entry load, name resolution, Load, registry coverage, and assemble — steps 1–5 of `run()`. `onAssembleError`, when
|
|
674
|
-
* given, lets a caller decorate an assemble failure with command-specific
|
|
675
|
-
* guidance (destroy's "build first" hint) without this shared step knowing
|
|
676
|
-
* about any one command.
|
|
677
|
-
*/
|
|
678
|
-
async function runPipeline(entry, overrideName, environment, cwd, source, deps = {}, onAssembleError) {
|
|
679
|
-
const configSource = checkConfigSource(source, cwd);
|
|
680
|
-
const config = configSource.value;
|
|
681
|
-
const resolved = resolveEntryPath(entry, configSource, cwd);
|
|
682
|
-
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
683
|
-
const name = overrideName ?? entryModule.root.name;
|
|
684
|
-
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
685
|
-
const redaction = deps.redaction ?? new SecretRedaction(process.env);
|
|
686
|
-
const adapterInput = {
|
|
687
|
-
environment,
|
|
688
|
-
configFile: configSource.file
|
|
689
|
-
};
|
|
690
|
-
const secrets = deps.readSecrets === true ? await readAppSecrets(config, adapterInput) : NO_SECRETS;
|
|
691
|
-
const configuration = await readAppConfiguration(config, adapterInput);
|
|
692
|
-
redaction.addCredentialLookingValues(credentialLookingValues(configuration));
|
|
693
|
-
const graph = Load(entryModule.root, {
|
|
694
|
-
id: name,
|
|
695
|
-
environment: { name: environment },
|
|
696
|
-
configuration
|
|
697
|
-
});
|
|
698
|
-
redaction.addKnownSecrets(valuesUnderSecretsKeys(configuration, secrets, secretsKeys(graph)));
|
|
699
|
-
checkGraph(graph, config.extensions);
|
|
700
|
-
validateRegistryCoverage(graph, config);
|
|
701
|
-
deps.onEvent?.({ kind: "loaded" });
|
|
702
|
-
let assembled;
|
|
703
|
-
try {
|
|
704
|
-
assembled = await assembleServices(graph, config, cwd, deps.runAssembler, deps.onEvent, { devServers: deps.devServers === true });
|
|
705
|
-
} catch (error) {
|
|
706
|
-
if (onAssembleError !== void 0 && error instanceof Error) throw onAssembleError(error);
|
|
707
|
-
throw error;
|
|
708
|
-
}
|
|
709
|
-
return {
|
|
710
|
-
configSource,
|
|
711
|
-
entryModule,
|
|
712
|
-
graph,
|
|
713
|
-
name,
|
|
714
|
-
assembled,
|
|
715
|
-
configuration,
|
|
716
|
-
secrets
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
function checkGraph(graph, extensions) {
|
|
720
|
-
for (const extension of extensions) try {
|
|
721
|
-
extension.checkGraph?.(graph);
|
|
722
|
-
} catch (error) {
|
|
723
|
-
if (error instanceof GraphCheckError) throw new GraphCheckError(error.message, { extension: extension.id });
|
|
724
|
-
throw error;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
/** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
|
|
728
|
-
const PLAIN_ENVIRONMENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
729
|
-
/** An environment name must be a valid git ref (deploy-cli.md) — checked via `git check-ref-format`, never silently normalized. Runs before anything platform-specific. */
|
|
730
|
-
function validateEnvironmentName(environment, spawn = spawnSync) {
|
|
731
|
-
if (PLAIN_ENVIRONMENT_NAME.test(environment)) return;
|
|
732
|
-
const result = spawn("git", ["check-ref-format", `refs/heads/${environment}`], { stdio: "ignore" });
|
|
733
|
-
if (result.error) throw new CliStructuredError("DEPLOY.ENVIRONMENT_UNVALIDATABLE", `git is required to validate --environment "${environment}" (git check-ref-format): ${result.error.message}.`, { cause: result.error });
|
|
734
|
-
if (result.status !== 0) throw new CliStructuredError("DEPLOY.ENVIRONMENT_INVALID", `Invalid --environment "${environment}": must be a valid git ref name (git check-ref-format rejected "refs/heads/${environment}").`);
|
|
735
|
-
}
|
|
736
|
-
//#endregion
|
|
737
|
-
export { noComposerExportMessage as a, validateEnvironmentName as i, resolveAppIdentity as n, runPipeline as r, checkConfigSource as t };
|
|
738
|
-
|
|
739
|
-
//# sourceMappingURL=validate-environment-XwVDifWN-D14WhSH0.mjs.map
|