@prisma/orm-toolchain 8.0.0-rc.1-dev.21 → 8.0.0-rc.1-dev.23
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/bin__prisma-next.mjs +23 -23
- package/dist/bin__prisma-next.mjs.map +1 -1
- package/dist/{caught-errors-D7Qznyrm-BzYooF6H.mjs → caught-errors-D7Qznyrm-DaZubR00.mjs} +2 -2
- package/dist/{caught-errors-D7Qznyrm-BzYooF6H.mjs.map → caught-errors-D7Qznyrm-DaZubR00.mjs.map} +1 -1
- package/dist/{cli-errors-CDr3WcJP-NFry5GHb.d.mts → cli-errors-BKPhkBSf-Ca-ymb6S.d.mts} +3 -3
- package/dist/{cli-errors-CDr3WcJP-NFry5GHb.d.mts.map → cli-errors-BKPhkBSf-Ca-ymb6S.d.mts.map} +1 -1
- package/dist/cli-telemetry.mjs +6 -5
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__commands__contract-emit.mjs +1 -1
- package/dist/cli__commands__contract-infer.mjs +1 -1
- package/dist/cli__commands__db-init.mjs +1 -1
- package/dist/cli__commands__db-schema.mjs +1 -1
- package/dist/cli__commands__db-sign.mjs +1 -1
- package/dist/cli__commands__db-update.mjs +1 -1
- package/dist/cli__commands__db-verify.mjs +1 -1
- package/dist/cli__commands__migrate.d.mts +2 -2
- package/dist/cli__commands__migrate.mjs +1 -1
- package/dist/cli__commands__migration-check.mjs +1 -1
- package/dist/cli__commands__migration-graph.d.mts +1 -1
- package/dist/cli__commands__migration-graph.mjs +1 -1
- package/dist/cli__commands__migration-list.d.mts +1 -1
- package/dist/cli__commands__migration-list.mjs +1 -1
- package/dist/cli__commands__migration-log.d.mts +1 -1
- package/dist/cli__commands__migration-log.mjs +1 -1
- package/dist/cli__commands__migration-new.mjs +1 -1
- package/dist/cli__commands__migration-plan.d.mts +1 -1
- package/dist/cli__commands__migration-plan.mjs +1 -1
- package/dist/cli__commands__migration-show.mjs +1 -1
- package/dist/cli__commands__migration-status.d.mts +1 -1
- package/dist/cli__commands__migration-status.mjs +1 -1
- package/dist/cli__commands__ref.mjs +1 -1
- package/dist/cli__commands__telemetry.mjs +1 -1
- package/dist/cli__control-api.d.mts +5 -5
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +15 -15
- package/dist/cli__control-api__testing.d.mts +66 -0
- package/dist/cli__control-api__testing.d.mts.map +1 -0
- package/dist/cli__control-api__testing.mjs +255 -0
- package/dist/cli__control-api__testing.mjs.map +1 -0
- package/dist/cli__migration-cli.mjs +13 -4
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/{client-Y6qbDk7X-BzKLmBZo.mjs → client-BNAEJZ76-ld7eOxpZ.mjs} +5 -5
- package/dist/{client-Y6qbDk7X-BzKLmBZo.mjs.map → client-BNAEJZ76-ld7eOxpZ.mjs.map} +1 -1
- package/dist/{command-helpers-C4WpR-QE-DE494TSG.mjs → command-helpers-C4WpR-QE-DNllqff1.mjs} +3 -3
- package/dist/{command-helpers-C4WpR-QE-DE494TSG.mjs.map → command-helpers-C4WpR-QE-DNllqff1.mjs.map} +1 -1
- package/dist/config-loader.d.mts +2 -2
- package/dist/config-loader.mjs +2 -2
- package/dist/{contract-at-errors-Dv1mxKYO-C29YB4RC.mjs → contract-at-errors-Dv1mxKYO-D4xfRBW5.mjs} +2 -2
- package/dist/{contract-at-errors-Dv1mxKYO-C29YB4RC.mjs.map → contract-at-errors-Dv1mxKYO-D4xfRBW5.mjs.map} +1 -1
- package/dist/{contract-emit-D8IXP9Qp-Df6NwXn8.mjs → contract-emit-DFu7h-Zl-7DBgYNv7.mjs} +9 -13
- package/dist/contract-emit-DFu7h-Zl-7DBgYNv7.mjs.map +1 -0
- package/dist/{contract-emit-CTm2zfuG-7PV9SBY6.mjs → contract-emit-DT0JKUZT-BYE7WZPc.mjs} +17 -9
- package/dist/contract-emit-DT0JKUZT-BYE7WZPc.mjs.map +1 -0
- package/dist/{contract-infer-BwT7ngoo-Dx6aAwIN.mjs → contract-infer-C_b7E71m-D2UO-X-k.mjs} +4 -4
- package/dist/{contract-infer-BwT7ngoo-Dx6aAwIN.mjs.map → contract-infer-C_b7E71m-D2UO-X-k.mjs.map} +1 -1
- package/dist/{contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs → contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs} +3 -3
- package/dist/{contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs.map → contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs → contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs} +2 -2
- package/dist/{contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs.map → contract-space-aggregate-loader-C5r12INu-DfE0nmtZ.mjs.map} +1 -1
- package/dist/{db-init-CBj_EWg3.mjs → db-init-Cqjw5Flp.mjs} +3 -3
- package/dist/{db-init-CBj_EWg3.mjs.map → db-init-Cqjw5Flp.mjs.map} +1 -1
- package/dist/{db-schema-BWpeh0Q_.mjs → db-schema-CRGCFKlH.mjs} +4 -4
- package/dist/{db-schema-BWpeh0Q_.mjs.map → db-schema-CRGCFKlH.mjs.map} +1 -1
- package/dist/{db-sign-DCb_DKtv.mjs → db-sign-BPQduGHb.mjs} +18 -7
- package/dist/db-sign-BPQduGHb.mjs.map +1 -0
- package/dist/{db-update-WX0KitcX.mjs → db-update-DuEk-ra5.mjs} +4 -4
- package/dist/{db-update-WX0KitcX.mjs.map → db-update-DuEk-ra5.mjs.map} +1 -1
- package/dist/{db-verify-B8ax2Y_x-Bp4s5Ra6.mjs → db-verify-DPH4lonK-pteoYVnK.mjs} +26 -11
- package/dist/db-verify-DPH4lonK-pteoYVnK.mjs.map +1 -0
- package/dist/exports-BN0vFTxG.mjs.map +1 -1
- package/dist/{exports-BnihzVhw.mjs → exports-DAA3XD4a.mjs} +15 -3
- package/dist/exports-DAA3XD4a.mjs.map +1 -0
- package/dist/exports-DVoyX2LM.mjs +173 -0
- package/dist/exports-DVoyX2LM.mjs.map +1 -0
- package/dist/{format-Bw3LVJ1v-BJ6lVFMA.mjs → format-DyVeO1z5-D1lnTJaz.mjs} +7 -11
- package/dist/format-DyVeO1z5-D1lnTJaz.mjs.map +1 -0
- package/dist/{framework-components-3DdB31mk-BHyX-OlJ.mjs → framework-components-ioeTnj2Z-yyQtaVWk.mjs} +7 -5
- package/dist/framework-components-ioeTnj2Z-yyQtaVWk.mjs.map +1 -0
- package/dist/index-Deu3DQZI.d.mts +47 -0
- package/dist/index-Deu3DQZI.d.mts.map +1 -0
- package/dist/{init-CPB89WK2-DPZRZ9Ee.mjs → init-BwYYd10C-CJq9i42m.mjs} +4 -4
- package/dist/{init-CPB89WK2-DPZRZ9Ee.mjs.map → init-BwYYd10C-CJq9i42m.mjs.map} +1 -1
- package/dist/{inspect-live-schema-Da76TWOs-CAFqkhGb.mjs → inspect-live-schema-CXH4ZGHT-BfUdyZme.mjs} +15 -12
- package/dist/inspect-live-schema-CXH4ZGHT-BfUdyZme.mjs.map +1 -0
- package/dist/{invariants-BzYfO9IL-BXTvx0z9.mjs → invariants-BzYfO9IL-BPDPDIr0.mjs} +2 -2
- package/dist/{invariants-BzYfO9IL-BXTvx0z9.mjs.map → invariants-BzYfO9IL-BPDPDIr0.mjs.map} +1 -1
- package/dist/{legend-5iwwlLU2-CB8bdQKJ.mjs → legend-5iwwlLU2-Bit8enjF.mjs} +2 -2
- package/dist/{legend-5iwwlLU2-CB8bdQKJ.mjs.map → legend-5iwwlLU2-Bit8enjF.mjs.map} +1 -1
- package/dist/{migrate-B-NAuO90.mjs → migrate-Bfsw18KQ.mjs} +23 -12
- package/dist/migrate-Bfsw18KQ.mjs.map +1 -0
- package/dist/{migrate-show-B2LkXkoB-D1ZNl84C.mjs → migrate-show-CO5OiR3J-DE4NIjvW.mjs} +18 -7
- package/dist/migrate-show-CO5OiR3J-DE4NIjvW.mjs.map +1 -0
- package/dist/{migrate-show-60NNqVia-oGqMaVA9.d.mts → migrate-show-Cu3k9mZm-B-nCgvK1.d.mts} +3 -3
- package/dist/{migrate-show-60NNqVia-oGqMaVA9.d.mts.map → migrate-show-Cu3k9mZm-B-nCgvK1.d.mts.map} +1 -1
- package/dist/{migration-check-BDjtAn7x-B0nEBR0k.mjs → migration-check-BfOnfgyY-DII6Ty5m.mjs} +19 -7
- package/dist/migration-check-BfOnfgyY-DII6Ty5m.mjs.map +1 -0
- package/dist/{migration-check-DONPyXff-CGTUpLv-.mjs → migration-check-DONPyXff-KpD0q3Zh.mjs} +4 -4
- package/dist/{migration-check-DONPyXff-CGTUpLv-.mjs.map → migration-check-DONPyXff-KpD0q3Zh.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs → migration-command-scaffold-CGcbYM2B-C3B8S3c-.mjs} +24 -7
- package/dist/migration-command-scaffold-CGcbYM2B-C3B8S3c-.mjs.map +1 -0
- package/dist/{migration-graph-Dn469b0l.mjs → migration-graph-BHiSuhBR.mjs} +17 -8
- package/dist/migration-graph-BHiSuhBR.mjs.map +1 -0
- package/dist/{migration-graph-HKch1Xk4-DyWhXtjZ.mjs → migration-graph-HKch1Xk4-DD-3zdSg.mjs} +2 -2
- package/dist/{migration-graph-HKch1Xk4-DyWhXtjZ.mjs.map → migration-graph-HKch1Xk4-DD-3zdSg.mjs.map} +1 -1
- package/dist/{migration-list-jk4iCtmO.mjs → migration-list-BkTNEeOK.mjs} +16 -7
- package/dist/migration-list-BkTNEeOK.mjs.map +1 -0
- package/dist/{migration-list-C9OPCMt--C28yBgVr.mjs → migration-list-C9OPCMt--BBm2c7tN.mjs} +2 -2
- package/dist/{migration-list-C9OPCMt--C28yBgVr.mjs.map → migration-list-C9OPCMt--BBm2c7tN.mjs.map} +1 -1
- package/dist/{migration-log-DQzUBrm8-D3m9wcuf.mjs → migration-log-CqrwQXER-cqf2INDN.mjs} +17 -7
- package/dist/migration-log-CqrwQXER-cqf2INDN.mjs.map +1 -0
- package/dist/{migration-new-g98oB3nC-BcrkxAAt.mjs → migration-new-Cjhe_MIE-CIovsuXK.mjs} +17 -8
- package/dist/migration-new-Cjhe_MIE-CIovsuXK.mjs.map +1 -0
- package/dist/{migration-new-BkSY6m0t.mjs → migration-new-NuMfcbH8.mjs} +3 -3
- package/dist/{migration-new-BkSY6m0t.mjs.map → migration-new-NuMfcbH8.mjs.map} +1 -1
- package/dist/{migration-path-target-BPYp3LNc-DsDdLU0J.mjs → migration-path-target-BPYp3LNc-DjdEIQsZ.mjs} +2 -2
- package/dist/{migration-path-target-BPYp3LNc-DsDdLU0J.mjs.map → migration-path-target-BPYp3LNc-DjdEIQsZ.mjs.map} +1 -1
- package/dist/{migration-plan-CjIYMJZy.mjs → migration-plan-D81XmVwy.mjs} +3 -3
- package/dist/{migration-plan-CjIYMJZy.mjs.map → migration-plan-D81XmVwy.mjs.map} +1 -1
- package/dist/{migration-plan-CwuZLXVE-DAJ-JUQT.mjs → migration-plan-DE7-vtqT-jgtSH4Lw.mjs} +18 -9
- package/dist/migration-plan-DE7-vtqT-jgtSH4Lw.mjs.map +1 -0
- package/dist/{migration-plan-BsOYRogP-CC1UFAbu.d.mts → migration-plan-DvBJhxXg-B5aHAOtu.d.mts} +3 -3
- package/dist/{migration-plan-BsOYRogP-CC1UFAbu.d.mts.map → migration-plan-DvBJhxXg-B5aHAOtu.d.mts.map} +1 -1
- package/dist/{migration-show-CW6EKtfw.mjs → migration-show-DEsLJ6-a.mjs} +18 -8
- package/dist/migration-show-DEsLJ6-a.mjs.map +1 -0
- package/dist/{migration-status-DSQcBhiN.mjs → migration-status-DfLM3VqL.mjs} +21 -10
- package/dist/migration-status-DfLM3VqL.mjs.map +1 -0
- package/dist/{project-import-root-C_bd0ooL-WkbJLnAA.mjs → project-import-root-C_bd0ooL-CusfluWF.mjs} +2 -2
- package/dist/{project-import-root-C_bd0ooL-WkbJLnAA.mjs.map → project-import-root-C_bd0ooL-CusfluWF.mjs.map} +1 -1
- package/dist/{ref-DSAZime8.mjs → ref-D6JzE8nq.mjs} +3 -3
- package/dist/{ref-DSAZime8.mjs.map → ref-D6JzE8nq.mjs.map} +1 -1
- package/dist/{ref-eJjxzYTh-CNiyDL4p.mjs → ref-DrAvdDhN-q1ccuI03.mjs} +21 -10
- package/dist/ref-DrAvdDhN-q1ccuI03.mjs.map +1 -0
- package/dist/{ref-resolution-_S4xTT2L-BE5zgO2W.mjs → ref-resolution-_S4xTT2L-JfNjZU9d.mjs} +2 -2
- package/dist/{ref-resolution-_S4xTT2L-BE5zgO2W.mjs.map → ref-resolution-_S4xTT2L-JfNjZU9d.mjs.map} +1 -1
- package/dist/{telemetry-DVBHDQd6-Ckn5oClN.mjs → telemetry-DVBHDQd6-CWNTFnMO.mjs} +2 -2
- package/dist/{telemetry-DVBHDQd6-Ckn5oClN.mjs.map → telemetry-DVBHDQd6-CWNTFnMO.mjs.map} +1 -1
- package/dist/{verify-C6L_hiJU-B4V3bqvG.mjs → verify-C6L_hiJU-MX67LFfI.mjs} +2 -2
- package/dist/{verify-C6L_hiJU-B4V3bqvG.mjs.map → verify-C6L_hiJU-MX67LFfI.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +5 -3
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +13 -12
- package/dist/contract-emit-CTm2zfuG-7PV9SBY6.mjs.map +0 -1
- package/dist/contract-emit-D8IXP9Qp-Df6NwXn8.mjs.map +0 -1
- package/dist/db-sign-DCb_DKtv.mjs.map +0 -1
- package/dist/db-verify-B8ax2Y_x-Bp4s5Ra6.mjs.map +0 -1
- package/dist/exports-BnihzVhw.mjs.map +0 -1
- package/dist/exports-CDX9kZuw.mjs +0 -119
- package/dist/exports-CDX9kZuw.mjs.map +0 -1
- package/dist/format-Bw3LVJ1v-BJ6lVFMA.mjs.map +0 -1
- package/dist/framework-components-3DdB31mk-BHyX-OlJ.mjs.map +0 -1
- package/dist/index-Df9igRvP.d.mts +0 -18
- package/dist/index-Df9igRvP.d.mts.map +0 -1
- package/dist/inspect-live-schema-Da76TWOs-CAFqkhGb.mjs.map +0 -1
- package/dist/migrate-B-NAuO90.mjs.map +0 -1
- package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs.map +0 -1
- package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs.map +0 -1
- package/dist/migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs.map +0 -1
- package/dist/migration-graph-Dn469b0l.mjs.map +0 -1
- package/dist/migration-list-jk4iCtmO.mjs.map +0 -1
- package/dist/migration-log-DQzUBrm8-D3m9wcuf.mjs.map +0 -1
- package/dist/migration-new-g98oB3nC-BcrkxAAt.mjs.map +0 -1
- package/dist/migration-plan-CwuZLXVE-DAJ-JUQT.mjs.map +0 -1
- package/dist/migration-show-CW6EKtfw.mjs.map +0 -1
- package/dist/migration-status-DSQcBhiN.mjs.map +0 -1
- package/dist/ref-eJjxzYTh-CNiyDL4p.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { N as errorUnexpected, Q as maskConnectionUrl, W as formatStyledHeader, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, f as errorDatabaseConnectionRequired, h as errorFileNotFound, it as resolveMigrationPaths, m as errorDriverRequired, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, rt as resolveContractPath, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-
|
|
2
|
-
import {
|
|
1
|
+
import { N as errorUnexpected, Q as maskConnectionUrl, W as formatStyledHeader, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, f as errorDatabaseConnectionRequired, h as errorFileNotFound, it as resolveMigrationPaths, m as errorDriverRequired, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, rt as resolveContractPath, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
|
|
2
|
+
import { a as loadConfigForSections } from "./exports-DVoyX2LM.mjs";
|
|
3
3
|
import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
|
|
4
|
-
import { t as createControlClient } from "./client-
|
|
5
|
-
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-SATuw0JW-
|
|
6
|
-
import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-C6L_hiJU-
|
|
4
|
+
import { t as createControlClient } from "./client-BNAEJZ76-ld7eOxpZ.mjs";
|
|
5
|
+
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs";
|
|
6
|
+
import { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from "./verify-C6L_hiJU-MX67LFfI.mjs";
|
|
7
7
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
8
8
|
import { relative, resolve } from "pathe";
|
|
9
9
|
import { readFile } from "node:fs/promises";
|
|
@@ -16,7 +16,18 @@ import { Command } from "commander";
|
|
|
16
16
|
* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)
|
|
17
17
|
*/
|
|
18
18
|
async function executeDbSignCommand(contractArg, options, flags, ui) {
|
|
19
|
-
const
|
|
19
|
+
const configResult = await loadConfigForSections(options.config, [
|
|
20
|
+
"family",
|
|
21
|
+
"target",
|
|
22
|
+
"adapter",
|
|
23
|
+
"driver",
|
|
24
|
+
"extensions",
|
|
25
|
+
"db",
|
|
26
|
+
"migrations",
|
|
27
|
+
"contract"
|
|
28
|
+
]);
|
|
29
|
+
if (!configResult.ok) return configResult;
|
|
30
|
+
const config = configResult.value;
|
|
20
31
|
const configPath = options.config ? relative(process.cwd(), resolve(options.config)) : "prisma-next.config.ts";
|
|
21
32
|
const contractPathAbsolute = resolveContractPath(config);
|
|
22
33
|
const contractPath = relative(process.cwd(), contractPathAbsolute);
|
|
@@ -156,4 +167,4 @@ function createDbSignCommand() {
|
|
|
156
167
|
//#endregion
|
|
157
168
|
export { createDbSignCommand as t };
|
|
158
169
|
|
|
159
|
-
//# sourceMappingURL=db-sign-
|
|
170
|
+
//# sourceMappingURL=db-sign-BPQduGHb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-sign-BPQduGHb.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-sign.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, F as CliStructuredError, U as errorDriverRequired, V as errorDatabaseConnectionRequired, W as errorFileNotFound, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, o as resolveContractPath, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { t as createProgressAdapter } from \"../progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"../client-BNAEJZ76.mjs\";\nimport { a as formatSignJson, i as formatSchemaVerifyOutput, o as formatSignOutput, r as formatSchemaVerifyJson } from \"../verify-C6L_hiJU.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"../contract-snapshot-resolution-SATuw0JW.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-sign.ts\n/**\n* Executes the db sign command and returns a structured Result.\n* Success: SignDatabaseResult (sign happened)\n* Failure: CliStructuredError (infra error) or VerifyDatabaseSchemaResult (schema mismatch)\n*/\nasync function executeDbSignCommand(contractArg, options, flags, ui) {\n\tconst configResult = await loadConfigForSections(options.config, [\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"driver\",\n\t\t\"extensions\",\n\t\t\"db\",\n\t\t\"migrations\",\n\t\t\"contract\"\n\t]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\tconst contractPath = relative(process.cwd(), contractPathAbsolute);\n\tconst effectiveContractArg = contractArg ?? options.contract;\n\tif (!flags.json && !flags.quiet) {\n\t\tconst details = [{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: configPath\n\t\t}, {\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: effectiveContractArg ?? contractPath\n\t\t}];\n\t\tif (options.db) details.push({\n\t\t\tlabel: \"database\",\n\t\t\tvalue: maskConnectionUrl(options.db)\n\t\t});\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"db sign\",\n\t\t\tdescription: \"Sign the database with your contract so you can safely run queries\",\n\t\t\turl: \"https://pris.ly/db-sign\",\n\t\t\tdetails,\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tlet contractJson;\n\tif (effectiveContractArg) try {\n\t\tconst { migrationsDir } = resolveMigrationPaths(options.config, config);\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: effectiveContractArg,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: true\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to resolve contract reference: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\telse {\n\t\tlet contractJsonContent;\n\t\ttry {\n\t\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t\t}));\n\t\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t\t}\n\t\ttry {\n\t\t\tcontractJson = JSON.parse(contractJsonContent);\n\t\t} catch (error) {\n\t\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t\t}\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (!dbConnection) return notOk(errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for db sign (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"db sign\"\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: \"Config.driver is required for db sign\" }));\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\tdriver: config.driver,\n\t\textensions: config.extensions ?? []\n\t});\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst schemaVerifyResult = await client.schemaVerify({\n\t\t\tcontract: contractJson,\n\t\t\tstrict: false,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!schemaVerifyResult.ok) return notOk(schemaVerifyResult);\n\t\treturn ok(await client.sign({\n\t\t\tcontract: contractJson,\n\t\t\tcontractPath,\n\t\t\tconfigPath,\n\t\t\tonProgress\n\t\t}));\n\t} catch (error) {\n\t\tif (error instanceof CliStructuredError) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during db sign: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbSignCommand() {\n\tconst command = new Command(\"sign\");\n\tsetCommandDescriptions(command, \"Sign the database with your contract so you can safely run queries\", \"Verifies that your database schema satisfies the emitted contract, and if so, writes or\\nupdates the database signature. This command is idempotent and safe to run\\nin CI/deployment pipelines. The signature records that this database instance is aligned\\nwith a specific contract version.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db sign --db $DATABASE_URL\",\n\t\t\"prisma-next db sign production --db $DATABASE_URL\",\n\t\t\"prisma-next db sign --contract production --db $DATABASE_URL\"\n\t]);\n\taddGlobalOptions(command).argument(\"[contract]\", \"Contract reference (hash, prefix, ref name, or migration dir name)\").option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--contract <contract>\", \"Contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\").action(async (positionalContract, options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tif (positionalContract && options.contract) {\n\t\t\tprocess.stderr.write(\"Cannot specify both a positional contract argument and --contract flag.\\n\");\n\t\t\tprocess.exit(2);\n\t\t\treturn;\n\t\t}\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst result = await executeDbSignCommand(positionalContract, options, flags, ui);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatSignJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatSignOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tconst failure = result.failure;\n\t\tif (failure instanceof CliStructuredError) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(failure));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(failure, flags);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbSignCommand };\n\n//# sourceMappingURL=db-sign.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,eAAe,qBAAqB,aAAa,SAAS,OAAO,IAAI;CACpE,MAAM,eAAe,MAAM,sBAAsB,QAAQ,QAAQ;EAChE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CAAC;CACD,IAAI,CAAC,aAAa,IAAI,OAAO;CAC7B,MAAM,SAAS,aAAa;CAC5B,MAAM,aAAa,QAAQ,SAAS,SAAS,QAAQ,IAAI,GAAG,QAAQ,QAAQ,MAAM,CAAC,IAAI;CACvF,MAAM,uBAAuB,oBAAoB,MAAM;CACvD,MAAM,eAAe,SAAS,QAAQ,IAAI,GAAG,oBAAoB;CACjE,MAAM,uBAAuB,eAAe,QAAQ;CACpD,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,UAAU,CAAC;GAChB,OAAO;GACP,OAAO;EACR,GAAG;GACF,OAAO;GACP,OAAO,wBAAwB;EAChC,CAAC;EACD,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC5B,OAAO;GACP,OAAO,kBAAkB,QAAQ,EAAE;EACpC,CAAC;EACD,MAAM,SAAS,mBAAmB;GACjC,SAAS;GACT,aAAa;GACb,KAAK;GACL;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;CACjB;CACA,IAAI;CACJ,IAAI,sBAAsB,IAAI;EAC7B,MAAM,EAAE,kBAAkB,sBAAsB,QAAQ,QAAQ,MAAM;EACtE,MAAM,WAAW,MAAM,6BAA6B;GACnD;GACA;GACA,UAAU;GACV;GACA,mBAAmB;EACpB,CAAC;EACD,IAAI,CAAC,SAAS,IAAI,OAAO,MAAM,SAAS,OAAO;EAC/C,eAAe,S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IAAI;GACd,IAAI,MAAM,MAAM,GAAG,OAAO,eAAe,OAAO,KAAK,CAAC;QACjD;IACJ,MAAM,SAAS,iBAAiB,OAAO,OAAO,KAAK;IACnD,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;GACA,QAAQ,KAAK,CAAC;EACf;EACA,MAAM,UAAU,OAAO;EACvB,IAAI,mBAAmBA,sBAAoB;GAC1C,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE;GAC/C,QAAQ,KAAK,QAAQ;EACtB;EACA,IAAI,MAAM,MAAM,GAAG,OAAO,uBAAuB,OAAO,CAAC;OACpD;GACJ,MAAM,SAAS,yBAAyB,SAAS,KAAK;GACtD,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B;EACA,QAAQ,KAAK,CAAC;CACf,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as formatMigrationJson, D as errorRunnerFailed, N as errorUnexpected, V as formatMigrationPlanOutput, at as sanitizeErrorMessage, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, n as ERROR_CODE_DESTRUCTIVE_CHANGES, o as createTerminalUI, ot as setCommandDescriptions, p as errorDestructiveChanges, q as handleResult, st as setCommandExamples, t as CliStructuredError$1, x as errorMigrationPlanningFailed, z as formatMigrationApplyOutput } from "./command-helpers-C4WpR-QE-
|
|
1
|
+
import { B as formatMigrationJson, D as errorRunnerFailed, N as errorUnexpected, V as formatMigrationPlanOutput, at as sanitizeErrorMessage, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, n as ERROR_CODE_DESTRUCTIVE_CHANGES, o as createTerminalUI, ot as setCommandDescriptions, p as errorDestructiveChanges, q as handleResult, st as setCommandExamples, t as CliStructuredError$1, x as errorMigrationPlanningFailed, z as formatMigrationApplyOutput } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
|
|
2
2
|
import { o as resolveRefAdvancementFields } from "./ref-advancement-DaZBzm7m-BZQtedYC.mjs";
|
|
3
|
-
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-
|
|
4
|
-
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-SATuw0JW-
|
|
3
|
+
import { n as prepareMigrationContext, t as addMigrationCommandOptions } from "./migration-command-scaffold-CGcbYM2B-C3B8S3c-.mjs";
|
|
4
|
+
import { t as resolveContractRefToSnapshot } from "./contract-snapshot-resolution-SATuw0JW-DpTZJd1x.mjs";
|
|
5
5
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
6
6
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
7
7
|
import { assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
@@ -157,4 +157,4 @@ function createDbUpdateCommand() {
|
|
|
157
157
|
//#endregion
|
|
158
158
|
export { createDbUpdateCommand as t };
|
|
159
159
|
|
|
160
|
-
//# sourceMappingURL=db-update-
|
|
160
|
+
//# sourceMappingURL=db-update-DuEk-ra5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-update-WX0KitcX.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-update.mjs"],"sourcesContent":["import { B as errorContractValidationFailed, C as formatMigrationApplyOutput, F as CliStructuredError, H as errorDestructiveChanges, I as ERROR_CODE_DESTRUCTIVE_CHANGES, T as formatMigrationPlanOutput, X as errorMigrationPlanningFailed, _ as createTerminalUI, c as sanitizeErrorMessage, ct as errorUnexpected, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, nt as errorRunnerFailed, s as resolveMigrationPaths, u as setCommandExamples, w as formatMigrationJson, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { o as resolveRefAdvancementFields } from \"../ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"../migration-command-scaffold-BPqXPCFV.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"../contract-snapshot-resolution-SATuw0JW.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-update.ts\n/**\n* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbUpdateFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.\" : \"Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\tmeta: {\n\t\t\t\t...failure.meta,\n\t\t\t\t...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}\n\t\t\t},\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tif (failure.code === \"DESTRUCTIVE_CHANGES\") return errorDestructiveChanges(failure.summary, {\n\t\t...ifDefined(\"why\", failure.why),\n\t\tfix: \"Re-run with `-y` to apply destructive changes, or use `--dry-run` to preview first\",\n\t\t...ifDefined(\"meta\", failure.meta)\n\t});\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db update command and returns a structured Result.\n*/\nasync function executeDbUpdateCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db update\",\n\t\tdescription: \"Update your database schema to match your contract\",\n\t\turl: \"https://pris.ly/db-update\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tlet { contractJson } = ctxResult.value;\n\tlet contractJsonPathForSnapshot = contractPathAbsolute;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\tif (options.to) {\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: options.to,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: false,\n\t\t\tmissingBundleFlag: \"--to\"\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t\tcontractJsonPathForSnapshot = resolved.value.contractJsonPath;\n\t}\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbUpdate({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\t...flags.yes ? { acceptDataLoss: true } : {},\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbUpdateFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractJsonPathForSnapshot,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...ifDefined(\"execution\", result.value.execution ? {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"marker\", result.value.marker ? {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\t...ifDefined(\"warnings\", result.value.warnings),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbUpdateCommand() {\n\tconst command = new Command(\"update\");\n\tsetCommandDescriptions(command, \"Update your database schema to match your contract\", \"Compares your database schema to the emitted contract and applies the necessary\\nchanges. Works on any database, whether or not it has been initialized with `db init`.\\nDestructive operations prompt for confirmation in interactive mode. Use -y to\\nauto-accept or --dry-run to preview first.\");\n\tsetCommandExamples(command, [\"prisma-next db update --db $DATABASE_URL\", \"prisma-next db update --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\");\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet result = await executeDbUpdateCommand(options, flags, ui, startTime);\n\t\tif (!result.ok && result.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES && flags.interactive && !flags.json && !flags.yes) {\n\t\t\tconst destructiveOps = result.failure.meta?.destructiveOperations ?? [];\n\t\t\tif (destructiveOps.length > 0) ui.warn(`${destructiveOps.length} destructive operation(s) that may cause data loss:\\n${destructiveOps.map((op) => ` ${ui.yellow(\"▸\")} ${op.label}`).join(\"\\n\")}`);\n\t\t\tif (await ui.confirm(\"Apply destructive changes? This cannot be undone.\")) result = await executeDbUpdateCommand(options, {\n\t\t\t\t...flags,\n\t\t\t\tyes: true\n\t\t\t}, ui, Date.now());\n\t\t}\n\t\tconst exitCode = handleResult(result, flags, ui, (dbUpdateResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbUpdateResult));\n\t\t\telse {\n\t\t\t\tconst output = dbUpdateResult.mode === \"plan\" ? formatMigrationPlanOutput(dbUpdateResult, flags) : formatMigrationApplyOutput(dbUpdateResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbUpdateCommand };\n\n//# sourceMappingURL=db-update.mjs.map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,MAAM,uBAAuB,SAAS,OAAO,IAAI,SAAS;EACvE,IAAI,CAAC,OAAO,MAAM,OAAO,QAAQ,SAAS,kCAAkC,MAAM,eAAe,CAAC,MAAM,QAAQ,CAAC,MAAM,KAAK;GAC3H,MAAM,iBAAiB,OAAO,QAAQ,MAAM,yBAAyB,CAAC;GACtE,IAAI,eAAe,SAAS,GAAG,GAAG,KAAK,GAAG,eAAe,OAAO,uDAAuD,eAAe,KAAK,OAAO,KAAK,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG;GACjM,IAAI,MAAM,GAAG,QAAQ,mDAAmD,GAAG,SAAS,MAAM,uBAAuB,SAAS;IACzH,GAAG;IACH,KAAK;GACN,GAAG,IAAI,KAAK,IAAI,CAAC;EAClB;EACA,MAAM,WAAW,aAAa,QAAQ,OAAO,KAAK,mBAAmB;GACpE,IAAI,MAAM,MAAM,GAAG,OAAO,oBAAoB,cAAc,CAAC;QACxD;IACJ,MAAM,SAAS,eAAe,SAAS,SAAS,0BAA0B,gBAAgB,KAAK,IAAI,2BAA2B,gBAAgB,KAAK;IACnJ,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"db-update-DuEk-ra5.mjs","names":["CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/db-update.mjs"],"sourcesContent":["import { B as errorContractValidationFailed, C as formatMigrationApplyOutput, F as CliStructuredError, H as errorDestructiveChanges, I as ERROR_CODE_DESTRUCTIVE_CHANGES, T as formatMigrationPlanOutput, X as errorMigrationPlanningFailed, _ as createTerminalUI, c as sanitizeErrorMessage, ct as errorUnexpected, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, nt as errorRunnerFailed, s as resolveMigrationPaths, u as setCommandExamples, w as formatMigrationJson, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { o as resolveRefAdvancementFields } from \"../ref-advancement-DaZBzm7m.mjs\";\nimport { n as prepareMigrationContext, t as addMigrationCommandOptions } from \"../migration-command-scaffold-CGcbYM2B.mjs\";\nimport { t as resolveContractRefToSnapshot } from \"../contract-snapshot-resolution-SATuw0JW.mjs\";\nimport { Command } from \"commander\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { assertNever } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/commands/db-update.ts\n/**\n* Maps a DbUpdateFailure to a CliStructuredError for consistent error handling.\n*/\nfunction mapDbUpdateFailure(failure) {\n\tif (failure.code === \"PLANNING_FAILED\") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });\n\tif (failure.code === \"RUNNER_FAILED\") {\n\t\tconst fix = (typeof failure.meta?.[\"runnerErrorCode\"] === \"string\" ? failure.meta[\"runnerErrorCode\"] : void 0) === \"MIGRATION.LEGACY_MARKER_SHAPE\" ? \"Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `prisma-next db init` to recreate it with the current per-space schema.\" : \"Inspect the reported conflict, reconcile schema drift if needed, then re-run `prisma-next db update`\";\n\t\treturn errorRunnerFailed(failure.summary, {\n\t\t\twhy: failure.why ?? \"Migration runner failed\",\n\t\t\tfix,\n\t\t\tmeta: {\n\t\t\t\t...failure.meta,\n\t\t\t\t...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}\n\t\t\t},\n\t\t\t...ifDefined(\"cause\", failure.cause)\n\t\t});\n\t}\n\tif (failure.code === \"DESTRUCTIVE_CHANGES\") return errorDestructiveChanges(failure.summary, {\n\t\t...ifDefined(\"why\", failure.why),\n\t\tfix: \"Re-run with `-y` to apply destructive changes, or use `--dry-run` to preview first\",\n\t\t...ifDefined(\"meta\", failure.meta)\n\t});\n\tconst exhaustive = failure.code;\n\treturn assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);\n}\n/**\n* Executes the db update command and returns a structured Result.\n*/\nasync function executeDbUpdateCommand(options, flags, ui, startTime) {\n\tconst ctxResult = await prepareMigrationContext(options, flags, ui, {\n\t\tcommandName: \"db update\",\n\t\tdescription: \"Update your database schema to match your contract\",\n\t\turl: \"https://pris.ly/db-update\"\n\t});\n\tif (!ctxResult.ok) return ctxResult;\n\tconst { client, config, dbConnection, onProgress, contractPathAbsolute } = ctxResult.value;\n\tlet { contractJson } = ctxResult.value;\n\tlet contractJsonPathForSnapshot = contractPathAbsolute;\n\tconst { migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);\n\tif (options.to) {\n\t\tconst resolved = await resolveContractRefToSnapshot({\n\t\t\tconfig,\n\t\t\tmigrationsDir,\n\t\t\trefInput: options.to,\n\t\t\tcontractPathAbsolute,\n\t\t\tfallbackToEmitted: false,\n\t\t\tmissingBundleFlag: \"--to\"\n\t\t});\n\t\tif (!resolved.ok) return notOk(resolved.failure);\n\t\tcontractJson = resolved.value.contractJson;\n\t\tcontractJsonPathForSnapshot = resolved.value.contractJsonPath;\n\t}\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst result = await client.dbUpdate({\n\t\t\tcontract: contractJson,\n\t\t\tmode: options.dryRun ? \"plan\" : \"apply\",\n\t\t\tmigrationsDir,\n\t\t\t...flags.yes ? { acceptDataLoss: true } : {},\n\t\t\tonProgress\n\t\t});\n\t\tif (!result.ok) return notOk(mapDbUpdateFailure(result.failure));\n\t\tconst advancementHash = result.value.mode === \"apply\" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;\n\t\tconst advancement = await resolveRefAdvancementFields({\n\t\t\t...ifDefined(\"advanceRef\", options.advanceRef),\n\t\t\t...ifDefined(\"db\", options.db),\n\t\t\trefsDir,\n\t\t\tmigrationsDir,\n\t\t\tcontractJson,\n\t\t\tcontractJsonPath: contractJsonPathForSnapshot,\n\t\t\tmode: result.value.mode,\n\t\t\thash: advancementHash\n\t\t});\n\t\tif (!advancement.ok) return notOk(advancement.failure);\n\t\tconst refAdvancementFields = advancement.value;\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: result.value.mode,\n\t\t\tplan: {\n\t\t\t\ttargetId: ctxResult.value.config.target.targetId,\n\t\t\t\tdestination: {\n\t\t\t\t\tstorageHash: result.value.destination.storageHash,\n\t\t\t\t\t...ifDefined(\"profileHash\", result.value.destination.profileHash)\n\t\t\t\t},\n\t\t\t\toperations: result.value.plan.operations.map((op) => ({\n\t\t\t\t\tid: op.id,\n\t\t\t\t\tlabel: op.label,\n\t\t\t\t\toperationClass: op.operationClass\n\t\t\t\t})),\n\t\t\t\t...ifDefined(\"preview\", result.value.plan.preview)\n\t\t\t},\n\t\t\t...ifDefined(\"execution\", result.value.execution ? {\n\t\t\t\toperationsPlanned: result.value.execution.operationsPlanned,\n\t\t\t\toperationsExecuted: result.value.execution.operationsExecuted\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"marker\", result.value.marker ? {\n\t\t\t\tstorageHash: result.value.marker.storageHash,\n\t\t\t\t...ifDefined(\"profileHash\", result.value.marker.profileHash)\n\t\t\t} : void 0),\n\t\t\t...ifDefined(\"perSpace\", result.value.perSpace),\n\t\t\t...ifDefined(\"warnings\", result.value.warnings),\n\t\t\tadvancedRef: refAdvancementFields.advancedRef,\n\t\t\tplannedAdvanceRef: refAdvancementFields.plannedAdvanceRef,\n\t\t\tsummary: result.value.summary,\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\tif (CliStructuredError.is(error)) return notOk(error);\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\tconst safeMessage = sanitizeErrorMessage(error instanceof Error ? error.message : String(error), typeof dbConnection === \"string\" ? dbConnection : void 0);\n\t\treturn notOk(errorUnexpected(safeMessage, { why: `Unexpected error during db update: ${safeMessage}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbUpdateCommand() {\n\tconst command = new Command(\"update\");\n\tsetCommandDescriptions(command, \"Update your database schema to match your contract\", \"Compares your database schema to the emitted contract and applies the necessary\\nchanges. Works on any database, whether or not it has been initialized with `db init`.\\nDestructive operations prompt for confirmation in interactive mode. Use -y to\\nauto-accept or --dry-run to preview first.\");\n\tsetCommandExamples(command, [\"prisma-next db update --db $DATABASE_URL\", \"prisma-next db update --db $DATABASE_URL --dry-run\"]);\n\taddMigrationCommandOptions(command);\n\tcommand.option(\"--to <contract>\", \"Target contract reference (hash, prefix, ref name, migration dir name, <dir>^, or ./path)\");\n\tcommand.option(\"--advance-ref <name>\", \"Ref to advance to the post-command contract hash\");\n\tcommand.action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst startTime = Date.now();\n\t\tconst ui = createTerminalUI(flags);\n\t\tlet result = await executeDbUpdateCommand(options, flags, ui, startTime);\n\t\tif (!result.ok && result.failure.code === ERROR_CODE_DESTRUCTIVE_CHANGES && flags.interactive && !flags.json && !flags.yes) {\n\t\t\tconst destructiveOps = result.failure.meta?.destructiveOperations ?? [];\n\t\t\tif (destructiveOps.length > 0) ui.warn(`${destructiveOps.length} destructive operation(s) that may cause data loss:\\n${destructiveOps.map((op) => ` ${ui.yellow(\"▸\")} ${op.label}`).join(\"\\n\")}`);\n\t\t\tif (await ui.confirm(\"Apply destructive changes? This cannot be undone.\")) result = await executeDbUpdateCommand(options, {\n\t\t\t\t...flags,\n\t\t\t\tyes: true\n\t\t\t}, ui, Date.now());\n\t\t}\n\t\tconst exitCode = handleResult(result, flags, ui, (dbUpdateResult) => {\n\t\t\tif (flags.json) ui.output(formatMigrationJson(dbUpdateResult));\n\t\t\telse {\n\t\t\t\tconst output = dbUpdateResult.mode === \"plan\" ? formatMigrationPlanOutput(dbUpdateResult, flags) : formatMigrationApplyOutput(dbUpdateResult, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbUpdateCommand };\n\n//# sourceMappingURL=db-update.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,mBAAmB,SAAS;CACpC,IAAI,QAAQ,SAAS,mBAAmB,OAAO,6BAA6B,EAAE,WAAW,QAAQ,aAAa,CAAC,EAAE,CAAC;CAClH,IAAI,QAAQ,SAAS,iBAAiB;EACrC,MAAM,OAAO,OAAO,QAAQ,OAAO,uBAAuB,WAAW,QAAQ,KAAK,qBAAqB,KAAK,OAAO,kCAAkC,iMAAiM;EACtV,OAAO,kBAAkB,QAAQ,SAAS;GACzC,KAAK,QAAQ,OAAO;GACpB;GACA,MAAM;IACL,GAAG,QAAQ;IACX,GAAG,QAAQ,YAAY,QAAQ,SAAS,SAAS,IAAI,EAAE,iBAAiB,QAAQ,SAAS,IAAI,CAAC;GAC/F;GACA,GAAG,UAAU,SAAS,QAAQ,KAAK;EACpC,CAAC;CACF;CACA,IAAI,QAAQ,SAAS,uBAAuB,OAAO,wBAAwB,QAAQ,SAAS;EAC3F,GAAG,UAAU,OAAO,QAAQ,GAAG;EAC/B,KAAK;EACL,GAAG,UAAU,QAAQ,QAAQ,IAAI;CAClC,CAAC;CACD,MAAM,aAAa,QAAQ;CAC3B,OAAO,YAAY,YAAY,mCAAmC,OAAO,UAAU,GAAG;AACvF;;;;AAIA,eAAe,uBAAuB,SAAS,OAAO,IAAI,WAAW;CACpE,MAAM,YAAY,MAAM,wBAAwB,SAAS,OAAO,IAAI;EACnE,aAAa;EACb,aAAa;EACb,KAAK;CACN,CAAC;CACD,IAAI,CAAC,UAAU,IAAI,OAAO;CAC1B,MAAM,EAAE,QAAQ,QAAQ,cAAc,YAAY,yBAAyB,UAAU;CACrF,IAAI,EAAE,iBAAiB,UAAU;CACjC,IAAI,8BAA8B;CAClC,MAAM,EAAE,e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B,kDAAkD;CACzF,QAAQ,OAAO,OAAO,YAAY;EACjC,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,YAAY,KAAK,IAAI;EAC3B,MAAM,KAAK,iBAAiB,KAAK;EACjC,IAAI,SAAS,MAAM,uBAAuB,SAAS,OAAO,IAAI,SAAS;EACvE,IAAI,CAAC,OAAO,MAAM,OAAO,QAAQ,SAAS,kCAAkC,MAAM,eAAe,CAAC,MAAM,QAAQ,CAAC,MAAM,KAAK;GAC3H,MAAM,iBAAiB,OAAO,QAAQ,MAAM,yBAAyB,CAAC;GACtE,IAAI,eAAe,SAAS,GAAG,GAAG,KAAK,GAAG,eAAe,OAAO,uDAAuD,eAAe,KAAK,OAAO,KAAK,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG;GACjM,IAAI,MAAM,GAAG,QAAQ,mDAAmD,GAAG,SAAS,MAAM,uBAAuB,SAAS;IACzH,GAAG;IACH,KAAK;GACN,GAAG,IAAI,KAAK,IAAI,CAAC;EAClB;EACA,MAAM,WAAW,aAAa,QAAQ,OAAO,KAAK,mBAAmB;GACpE,IAAI,MAAM,MAAM,GAAG,OAAO,oBAAoB,cAAc,CAAC;QACxD;IACJ,MAAM,SAAS,eAAe,SAAS,SAAS,0BAA0B,gBAAgB,KAAK,IAAI,2BAA2B,gBAAgB,KAAK;IACnJ,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { M as errorTargetMismatch, N as errorUnexpected, O as errorRuntime$1, Q as maskConnectionUrl, W as formatStyledHeader, b as errorMarkerMissing, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, f as errorDatabaseConnectionRequired, g as errorHashMismatch, h as errorFileNotFound, it as resolveMigrationPaths, m as errorDriverRequired, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, rt as resolveContractPath, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-
|
|
2
|
-
import {
|
|
1
|
+
import { M as errorTargetMismatch, N as errorUnexpected, O as errorRuntime$1, Q as maskConnectionUrl, W as formatStyledHeader, b as errorMarkerMissing, d as errorContractValidationFailed, et as parseGlobalFlagsOrExit, f as errorDatabaseConnectionRequired, g as errorHashMismatch, h as errorFileNotFound, it as resolveMigrationPaths, m as errorDriverRequired, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, rt as resolveContractPath, st as setCommandExamples, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DNllqff1.mjs";
|
|
2
|
+
import { a as loadConfigForSections } from "./exports-DVoyX2LM.mjs";
|
|
3
3
|
import { t as createProgressAdapter } from "./progress-adapter-CjAeTxY_-BXYSd1eY.mjs";
|
|
4
|
-
import { t as createControlClient } from "./client-
|
|
5
|
-
import { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from "./verify-C6L_hiJU-
|
|
4
|
+
import { t as createControlClient } from "./client-BNAEJZ76-ld7eOxpZ.mjs";
|
|
5
|
+
import { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from "./verify-C6L_hiJU-MX67LFfI.mjs";
|
|
6
6
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
7
7
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
8
8
|
import { relative, resolve } from "pathe";
|
|
@@ -11,7 +11,7 @@ import { VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARG
|
|
|
11
11
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
12
12
|
import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
13
13
|
import { Command } from "commander";
|
|
14
|
-
//#region ../../../1-framework/3-tooling/cli/dist/db-verify-
|
|
14
|
+
//#region ../../../1-framework/3-tooling/cli/dist/db-verify-DPH4lonK.mjs
|
|
15
15
|
/**
|
|
16
16
|
* Collapse the aggregate verifier's per-space contract-satisfaction results
|
|
17
17
|
* into a single {@link VerifyDatabaseSchemaResult} for the CLI display
|
|
@@ -167,15 +167,26 @@ function renderVerifyHeader(paths, options, mode, flags, ui) {
|
|
|
167
167
|
}));
|
|
168
168
|
}
|
|
169
169
|
async function resolveVerifyPaths(options) {
|
|
170
|
-
const
|
|
170
|
+
const configResult = await loadConfigForSections(options.config, [
|
|
171
|
+
"family",
|
|
172
|
+
"target",
|
|
173
|
+
"adapter",
|
|
174
|
+
"driver",
|
|
175
|
+
"extensions",
|
|
176
|
+
"db",
|
|
177
|
+
"migrations",
|
|
178
|
+
"contract"
|
|
179
|
+
]);
|
|
180
|
+
if (!configResult.ok) return configResult;
|
|
181
|
+
const config = configResult.value;
|
|
171
182
|
const configPath = options.config ? relative(process.cwd(), resolve(options.config)) : "prisma-next.config.ts";
|
|
172
183
|
const contractPathAbsolute = resolveContractPath(config);
|
|
173
|
-
return {
|
|
184
|
+
return ok({
|
|
174
185
|
config,
|
|
175
186
|
configPath,
|
|
176
187
|
contractPathAbsolute,
|
|
177
188
|
contractPath: relative(process.cwd(), contractPathAbsolute)
|
|
178
|
-
};
|
|
189
|
+
});
|
|
179
190
|
}
|
|
180
191
|
async function resolveVerifySetup(paths, options, mode) {
|
|
181
192
|
const { config, configPath, contractPathAbsolute, contractPath } = paths;
|
|
@@ -230,7 +241,9 @@ function wrapVerifyError(error, contractPathAbsolute, modeLabel) {
|
|
|
230
241
|
*/
|
|
231
242
|
async function executeDbVerifyCommand(options, flags, ui, mode) {
|
|
232
243
|
const startTime = Date.now();
|
|
233
|
-
const
|
|
244
|
+
const pathsResult = await resolveVerifyPaths(options);
|
|
245
|
+
if (!pathsResult.ok) return pathsResult;
|
|
246
|
+
const paths = pathsResult.value;
|
|
234
247
|
renderVerifyHeader(paths, options, mode, flags, ui);
|
|
235
248
|
const setupResult = await resolveVerifySetup(paths, options, mode);
|
|
236
249
|
if (!setupResult.ok) return setupResult;
|
|
@@ -303,7 +316,9 @@ async function executeDbVerifyCommand(options, flags, ui, mode) {
|
|
|
303
316
|
}
|
|
304
317
|
}
|
|
305
318
|
async function executeDbSchemaOnlyVerifyCommand(options, flags, ui) {
|
|
306
|
-
const
|
|
319
|
+
const pathsResult = await resolveVerifyPaths(options);
|
|
320
|
+
if (!pathsResult.ok) return pathsResult;
|
|
321
|
+
const paths = pathsResult.value;
|
|
307
322
|
renderVerifyHeader(paths, options, "schema-only", flags, ui);
|
|
308
323
|
const setupResult = await resolveVerifySetup(paths, options, "schema-only");
|
|
309
324
|
if (!setupResult.ok) return setupResult;
|
|
@@ -396,4 +411,4 @@ function createDbVerifyCommand() {
|
|
|
396
411
|
//#endregion
|
|
397
412
|
export { createDbVerifyCommand as t };
|
|
398
413
|
|
|
399
|
-
//# sourceMappingURL=db-verify-
|
|
414
|
+
//# sourceMappingURL=db-verify-DPH4lonK-pteoYVnK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-verify-DPH4lonK-pteoYVnK.mjs","names":["errorRuntime","CliStructuredError"],"sources":["../../../../1-framework/3-tooling/cli/dist/db-verify-DPH4lonK.mjs"],"sourcesContent":["import { A as formatStyledHeader, B as errorContractValidationFailed, F as CliStructuredError, G as errorHashMismatch, U as errorDriverRequired, V as errorDatabaseConnectionRequired, W as errorFileNotFound, Y as errorMarkerMissing, _ as createTerminalUI, ct as errorUnexpected, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, o as resolveContractPath, rt as errorRuntime, s as resolveMigrationPaths, st as errorTargetMismatch, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as createProgressAdapter } from \"./progress-adapter-CjAeTxY_.mjs\";\nimport { t as createControlClient } from \"./client-BNAEJZ76.mjs\";\nimport { c as formatVerifyOutput, i as formatSchemaVerifyOutput, r as formatSchemaVerifyJson, s as formatVerifyJson } from \"./verify-C6L_hiJU.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfigForSections } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { relative, resolve } from \"pathe\";\nimport { readFile } from \"node:fs/promises\";\nimport { VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, createControlStack } from \"@internal/framework-components/control\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\n//#region src/utils/combine-verify-results.ts\n/**\n* Collapse the aggregate verifier's per-space contract-satisfaction results\n* into a single {@link VerifyDatabaseSchemaResult} for the CLI display\n* surface, and carry the deduplicated unclaimed-elements list alongside it.\n* Concatenates the issue lists across spaces; uses the app space's result as\n* the structural envelope (storage hash, target). Extras are already\n* stripped from each per-space result, so nothing here duplicates an\n* unclaimed element per space.\n*\n* **Unclaimed disposition.** In strict mode a non-empty `unclaimed` list fails\n* the combined verdict (`ok: false`); in lenient mode it is carried for\n* informational rendering only. The list itself is returned unchanged for the\n* renderer.\n*\n* **Summary policy.** Preserve the per-family phrasing whenever the\n* combined `ok` flag agrees with the app space's `ok` flag — this is\n* the common case (single-family deployments, single-app deployments)\n* and the family's \"satisfies / does not satisfy contract\" phrasing\n* stays user-visible. When the app passes but an extension fails (or\n* vice versa) the app's summary contradicts the envelope, so fall back\n* to the first failing space's summary. This keeps family phrasing\n* intact and the envelope internally consistent (`ok: false` ↔ failure\n* summary).\n*/\nfunction combineVerifyResults(perSpace, appSpaceId, strict, unclaimed) {\n\tconst appResult = perSpace.get(appSpaceId) ?? perSpace.values().next().value;\n\tif (appResult === void 0) throw new InternalError(\"Aggregate verifier returned no per-space verify results — this is a wiring bug.\");\n\tlet okAll = true;\n\tlet firstFailure;\n\tlet issues = [];\n\tlet warningIssues = [];\n\tfor (const [, result] of perSpace) {\n\t\tif (!result.ok) {\n\t\t\tokAll = false;\n\t\t\tif (firstFailure === void 0) firstFailure = result;\n\t\t}\n\t\tissues = [...issues, ...result.schema.issues];\n\t\twarningIssues = [...warningIssues, ...result.schema.warnings?.issues ?? []];\n\t}\n\tconst unclaimedFails = strict && unclaimed.length > 0;\n\tconst ok = okAll && !unclaimedFails;\n\tconst summary = okAll ? unclaimedFails ? `Database schema has ${unclaimed.length} unclaimed element${unclaimed.length === 1 ? \"\" : \"s\"} (not in any contract)` : appResult.summary : appResult.ok ? firstFailure?.summary ?? appResult.summary : appResult.summary;\n\treturn {\n\t\tresult: {\n\t\t\tok,\n\t\t\t...ok ? {} : { code: appResult.code ?? \"CONTRACT.MARKER_REQUIRED\" },\n\t\t\tsummary,\n\t\t\tcontract: appResult.contract,\n\t\t\ttarget: appResult.target,\n\t\t\tschema: {\n\t\t\t\tissues,\n\t\t\t\twarnings: { issues: warningIssues }\n\t\t\t},\n\t\t\tmeta: { strict },\n\t\t\ttimings: { total: 0 }\n\t\t},\n\t\tunclaimed\n\t};\n}\n//#endregion\n//#region src/commands/db-verify.ts\n/**\n* Maps a VerifyDatabaseResult failure to a CliStructuredError.\n*/\nfunction mapVerifyFailure(verifyResult) {\n\tif (!verifyResult.ok && verifyResult.code) {\n\t\tif (verifyResult.code === VERIFY_CODE_MARKER_MISSING) return errorMarkerMissing();\n\t\tif (verifyResult.code === VERIFY_CODE_HASH_MISMATCH) {\n\t\t\tconst storageMatch = verifyResult.marker?.storageHash === verifyResult.contract.storageHash;\n\t\t\tconst profileMatch = !verifyResult.contract.profileHash || verifyResult.marker?.profileHash === verifyResult.contract.profileHash;\n\t\t\tif (!storageMatch) return errorHashMismatch({\n\t\t\t\twhy: \"Contract storageHash does not match database marker\",\n\t\t\t\texpected: verifyResult.contract.storageHash,\n\t\t\t\t...ifDefined(\"actual\", verifyResult.marker?.storageHash)\n\t\t\t});\n\t\t\treturn errorHashMismatch({\n\t\t\t\twhy: profileMatch ? \"Contract hash does not match database marker\" : \"Contract profileHash does not match database marker\",\n\t\t\t\t...ifDefined(\"expected\", verifyResult.contract.profileHash),\n\t\t\t\t...ifDefined(\"actual\", verifyResult.marker?.profileHash)\n\t\t\t});\n\t\t}\n\t\tif (verifyResult.code === VERIFY_CODE_TARGET_MISMATCH) return errorTargetMismatch(verifyResult.target.expected, verifyResult.target.actual ?? \"unknown\");\n\t}\n\treturn errorRuntime(\"CONTRACT.VERIFY_FAILED\", verifyResult.summary, {\n\t\twhy: \"Verification failed\",\n\t\tfix: \"Check contract and database state\"\n\t});\n}\nfunction errorInvalidVerifyMode(options) {\n\treturn new CliStructuredError(\"CLI.INVALID_VERIFY_MODE\", \"Invalid verify mode\", {\n\t\twhy: options.why,\n\t\tfix: options.fix,\n\t\tdocsUrl: \"https://pris.ly/db-verify\"\n\t});\n}\nfunction resolveDbVerifyMode(options) {\n\tif (options.markerOnly && options.schemaOnly) return notOk(errorInvalidVerifyMode({\n\t\twhy: \"`--marker-only` and `--schema-only` cannot be used together\",\n\t\tfix: \"Choose one mode: omit both to check the marker and schema, use `--marker-only` to check only the marker, or use `--schema-only` to check only the live schema.\"\n\t}));\n\tif (options.markerOnly && options.strict) return notOk(errorInvalidVerifyMode({\n\t\twhy: \"`--strict` requires schema verification, but `--marker-only` skips it\",\n\t\tfix: \"Remove `--strict`, or use `db verify` / `db verify --schema-only` when you want to check the live schema in strict mode.\"\n\t}));\n\tif (options.schemaOnly) return ok(\"schema-only\");\n\tif (options.markerOnly) return ok(\"marker-only\");\n\treturn ok(\"full\");\n}\nfunction formatDbVerifyModeLabel(mode, strict) {\n\tif (mode === \"marker-only\") return \"marker only\";\n\tif (mode === \"schema-only\") return `schema only (${strict ? \"strict\" : \"tolerant\"})`;\n\treturn `full (marker + schema, ${strict ? \"strict\" : \"tolerant\"})`;\n}\nfunction formatDbVerifyInvocation(mode, strict) {\n\tconst args = [\"db verify\"];\n\tif (mode === \"marker-only\") args.push(\"--marker-only\");\n\tif (mode === \"schema-only\") args.push(\"--schema-only\");\n\tif (strict) args.push(\"--strict\");\n\treturn args.join(\" \");\n}\nfunction createDbVerifyConnectionRequiredError(options) {\n\tconst invocation = formatDbVerifyInvocation(options.mode, options.strict);\n\treturn errorDatabaseConnectionRequired({\n\t\twhy: `Database connection is required for ${invocation} (set db.connection in ${options.configPath}, or pass --db <url>)`,\n\t\tretryCommand: `prisma-next ${invocation} --db <url>`\n\t});\n}\nfunction renderVerifyHeader(paths, options, mode, flags, ui) {\n\tif (flags.json || flags.quiet) return;\n\tconst description = mode === \"schema-only\" ? \"Check whether the live database schema matches your contract\" : mode === \"marker-only\" ? \"Check whether the database marker matches your contract\" : \"Check whether the database marker and live schema match your contract\";\n\tconst details = [\n\t\t{\n\t\t\tlabel: \"config\",\n\t\t\tvalue: paths.configPath\n\t\t},\n\t\t{\n\t\t\tlabel: \"contract\",\n\t\t\tvalue: paths.contractPath\n\t\t},\n\t\t{\n\t\t\tlabel: \"mode\",\n\t\t\tvalue: formatDbVerifyModeLabel(mode, options.strict ?? false)\n\t\t}\n\t];\n\tif (options.db) details.push({\n\t\tlabel: \"database\",\n\t\tvalue: maskConnectionUrl(options.db)\n\t});\n\tui.stderr(formatStyledHeader({\n\t\tcommand: \"db verify\",\n\t\tdescription,\n\t\turl: \"https://pris.ly/db-verify\",\n\t\tdetails,\n\t\tflags\n\t}));\n}\nasync function resolveVerifyPaths(options) {\n\tconst configResult = await loadConfigForSections(options.config, [\n\t\t\"family\",\n\t\t\"target\",\n\t\t\"adapter\",\n\t\t\"driver\",\n\t\t\"extensions\",\n\t\t\"db\",\n\t\t\"migrations\",\n\t\t\"contract\"\n\t]);\n\tif (!configResult.ok) return configResult;\n\tconst config = configResult.value;\n\tconst configPath = options.config ? relative(process.cwd(), resolve(options.config)) : \"prisma-next.config.ts\";\n\tconst contractPathAbsolute = resolveContractPath(config);\n\treturn ok({\n\t\tconfig,\n\t\tconfigPath,\n\t\tcontractPathAbsolute,\n\t\tcontractPath: relative(process.cwd(), contractPathAbsolute)\n\t});\n}\nasync function resolveVerifySetup(paths, options, mode) {\n\tconst { config, configPath, contractPathAbsolute, contractPath } = paths;\n\tlet contractJsonContent;\n\ttry {\n\t\tcontractJsonContent = await readFile(contractPathAbsolute, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return notOk(errorFileNotFound(contractPathAbsolute, {\n\t\t\twhy: `Contract file not found at ${contractPathAbsolute}`,\n\t\t\tfix: `Run \\`prisma-next contract emit\\` to generate ${contractPath}, or update \\`config.contract.output\\` in ${configPath}`\n\t\t}));\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read contract file: ${error instanceof Error ? error.message : String(error)}` }));\n\t}\n\tconst stack = createControlStack(config);\n\tconst familyInstance = config.family.create(stack);\n\tlet contractJson;\n\ttry {\n\t\tcontractJson = familyInstance.deserializeContract(JSON.parse(contractJsonContent));\n\t} catch (error) {\n\t\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\t\treturn notOk(errorContractValidationFailed(`Contract JSON is invalid: ${error instanceof Error ? error.message : String(error)}`, { where: { path: contractPathAbsolute } }));\n\t}\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tif (typeof dbConnection !== \"string\" || dbConnection.length === 0) return notOk(createDbVerifyConnectionRequiredError({\n\t\tconfigPath,\n\t\tmode,\n\t\tstrict: options.strict ?? false\n\t}));\n\tif (!config.driver) return notOk(errorDriverRequired({ why: `Config.driver is required for ${formatDbVerifyInvocation(mode, options.strict ?? false)}` }));\n\treturn ok({\n\t\t...paths,\n\t\tcontractJson,\n\t\tdbConnection\n\t});\n}\nfunction createVerifyClient(setup) {\n\treturn createControlClient({\n\t\tfamily: setup.config.family,\n\t\ttarget: setup.config.target,\n\t\tadapter: setup.config.adapter,\n\t\tdriver: setup.config.driver,\n\t\textensions: setup.config.extensions ?? []\n\t});\n}\nfunction wrapVerifyError(error, contractPathAbsolute, modeLabel) {\n\tif (CliStructuredError.is(error)) return notOk(error);\n\tif (isStructuredError(error) && error.code === \"CONTRACT.VALIDATION_FAILED\") return notOk(errorContractValidationFailed(`Contract validation failed: ${error.message}`, { where: { path: contractPathAbsolute } }));\n\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Unexpected error during ${modeLabel}: ${error instanceof Error ? error.message : String(error)}` }));\n}\n/**\n* Executes the db verify command and returns a structured Result.\n*/\nasync function executeDbVerifyCommand(options, flags, ui, mode) {\n\tconst startTime = Date.now();\n\tconst pathsResult = await resolveVerifyPaths(options);\n\tif (!pathsResult.ok) return pathsResult;\n\tconst paths = pathsResult.value;\n\trenderVerifyHeader(paths, options, mode, flags, ui);\n\tconst setupResult = await resolveVerifySetup(paths, options, mode);\n\tif (!setupResult.ok) return setupResult;\n\tconst { contractJson, dbConnection, contractPathAbsolute } = setupResult.value;\n\tconst { migrationsDir } = resolveMigrationPaths(options.config, setupResult.value.config);\n\tconst client = createVerifyClient(setupResult.value);\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tconst verifyResult = await client.verify({\n\t\t\tcontract: contractJson,\n\t\t\tconnection: dbConnection,\n\t\t\tonProgress\n\t\t});\n\t\tif (!verifyResult.ok) return notOk(mapVerifyFailure(verifyResult));\n\t\tconst aggregateResult = await client.dbVerify({\n\t\t\tcontract: contractJson,\n\t\t\tmigrationsDir,\n\t\t\tstrict: options.strict ?? false,\n\t\t\tskipSchema: mode === \"marker-only\",\n\t\t\tskipMarker: false,\n\t\t\tonProgress\n\t\t});\n\t\tif (!aggregateResult.ok) return notOk(aggregateResult.failure);\n\t\tif (mode === \"marker-only\") return ok({\n\t\t\tok: true,\n\t\t\tmode: \"marker-only\",\n\t\t\tsummary: \"Database marker matches contract\",\n\t\t\tcontract: verifyResult.contract,\n\t\t\tmarker: verifyResult.marker,\n\t\t\ttarget: verifyResult.target,\n\t\t\t...ifDefined(\"missingCodecs\", verifyResult.missingCodecs),\n\t\t\t...ifDefined(\"codecCoverageSkipped\", verifyResult.codecCoverageSkipped),\n\t\t\twarning: \"Schema verification skipped because --marker-only was provided\",\n\t\t\tmeta: {\n\t\t\t\t...verifyResult.meta ?? {},\n\t\t\t\tschemaVerification: \"skipped\"\n\t\t\t},\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t\tconst combined = combineVerifyResults(aggregateResult.value.schemaResults, aggregateResult.value.appSpaceId, options.strict ?? false, aggregateResult.value.unclaimed);\n\t\tif (!combined.result.ok) return notOk(combined);\n\t\treturn ok({\n\t\t\tok: true,\n\t\t\tmode: \"full\",\n\t\t\tsummary: \"Database marker and schema match contract\",\n\t\t\tcontract: verifyResult.contract,\n\t\t\tmarker: verifyResult.marker,\n\t\t\ttarget: verifyResult.target,\n\t\t\t...ifDefined(\"missingCodecs\", verifyResult.missingCodecs),\n\t\t\t...ifDefined(\"codecCoverageSkipped\", verifyResult.codecCoverageSkipped),\n\t\t\tschema: {\n\t\t\t\tsummary: combined.result.summary,\n\t\t\t\tstrict: combined.result.meta?.strict ?? false,\n\t\t\t\twarnings: (combined.result.schema.warnings?.issues ?? []).map((issue) => issue.path.join(\"/\"))\n\t\t\t},\n\t\t\tunclaimed: combined.unclaimed,\n\t\t\tmeta: {\n\t\t\t\t...verifyResult.meta ?? {},\n\t\t\t\tschemaVerification: \"performed\"\n\t\t\t},\n\t\t\ttimings: { total: Date.now() - startTime }\n\t\t});\n\t} catch (error) {\n\t\treturn wrapVerifyError(error, contractPathAbsolute, \"db verify\");\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nasync function executeDbSchemaOnlyVerifyCommand(options, flags, ui) {\n\tconst pathsResult = await resolveVerifyPaths(options);\n\tif (!pathsResult.ok) return pathsResult;\n\tconst paths = pathsResult.value;\n\trenderVerifyHeader(paths, options, \"schema-only\", flags, ui);\n\tconst setupResult = await resolveVerifySetup(paths, options, \"schema-only\");\n\tif (!setupResult.ok) return setupResult;\n\tconst { contractJson, dbConnection, contractPathAbsolute } = setupResult.value;\n\tconst { migrationsDir } = resolveMigrationPaths(options.config, setupResult.value.config);\n\tconst client = createVerifyClient(setupResult.value);\n\tconst onProgress = createProgressAdapter({\n\t\tui,\n\t\tflags\n\t});\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\tconst aggregateResult = await client.dbVerify({\n\t\t\tcontract: contractJson,\n\t\t\tmigrationsDir,\n\t\t\tstrict: options.strict ?? false,\n\t\t\tskipSchema: false,\n\t\t\tskipMarker: true,\n\t\t\tonProgress\n\t\t});\n\t\tif (!aggregateResult.ok) return notOk(aggregateResult.failure);\n\t\treturn ok(combineVerifyResults(aggregateResult.value.schemaResults, aggregateResult.value.appSpaceId, options.strict ?? false, aggregateResult.value.unclaimed));\n\t} catch (error) {\n\t\treturn wrapVerifyError(error, contractPathAbsolute, \"db verify --schema-only\");\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createDbVerifyCommand() {\n\tconst command = new Command(\"verify\");\n\tsetCommandDescriptions(command, \"Check whether the database marker and live schema match your contract\", \"Verifies the database marker first, then checks the database schema matches your contract.\\nUse `--marker-only` for marker-only verification, `--schema-only` to skip marker checks and\\ninspect only the live schema, and `--strict` to fail if the database includes elements\\nnot present in the contract.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next db verify --db $DATABASE_URL\",\n\t\t\"prisma-next db verify --db $DATABASE_URL --strict\",\n\t\t\"prisma-next db verify --db $DATABASE_URL --schema-only\",\n\t\t\"prisma-next db verify --db $DATABASE_URL --schema-only --strict\",\n\t\t\"prisma-next db verify --db $DATABASE_URL --marker-only\",\n\t\t\"prisma-next db verify --db $DATABASE_URL --json\"\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--marker-only\", \"Skip schema verification and only check the database marker\").option(\"--schema-only\", \"Skip marker verification and only check whether the live schema satisfies the contract\").option(\"--strict\", \"Strict mode: schema elements not present in the contract are considered an error\", false).action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst modeResult = resolveDbVerifyMode(options);\n\t\tif (!modeResult.ok) {\n\t\t\tconst exitCode = handleResult(modeResult, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tconst mode = modeResult.value;\n\t\tif (mode === \"schema-only\") {\n\t\t\tconst result = await executeDbSchemaOnlyVerifyCommand(options, flags, ui);\n\t\t\tconst exitCode = handleResult(result, flags, ui, (combined) => {\n\t\t\t\tif (flags.json) ui.output(formatSchemaVerifyJson(combined.result, combined.unclaimed));\n\t\t\t\telse {\n\t\t\t\t\tconst renderFlags = combined.result.ok ? flags : {\n\t\t\t\t\t\t...flags,\n\t\t\t\t\t\tquiet: false\n\t\t\t\t\t};\n\t\t\t\t\tconst output = formatSchemaVerifyOutput(combined.result, renderFlags, combined.unclaimed);\n\t\t\t\t\tif (output) ui.log(output);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (result.ok && !result.value.result.ok) process.exit(1);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tconst result = await executeDbVerifyCommand(options, flags, ui, mode);\n\t\tif (result.ok) {\n\t\t\tif (flags.json) ui.output(formatVerifyJson(result.value));\n\t\t\telse {\n\t\t\t\tconst output = formatVerifyOutput(result.value, flags);\n\t\t\t\tif (output) ui.log(output);\n\t\t\t}\n\t\t\tprocess.exit(0);\n\t\t}\n\t\tif (CliStructuredError.is(result.failure)) {\n\t\t\tconst exitCode = handleResult(result, flags, ui);\n\t\t\tprocess.exit(exitCode);\n\t\t}\n\t\tif (flags.json) ui.output(formatSchemaVerifyJson(result.failure.result, result.failure.unclaimed));\n\t\telse {\n\t\t\tconst output = formatSchemaVerifyOutput(result.failure.result, {\n\t\t\t\t...flags,\n\t\t\t\tquiet: false\n\t\t\t}, result.failure.unclaimed);\n\t\t\tif (output) ui.log(output);\n\t\t}\n\t\tprocess.exit(1);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createDbVerifyCommand as t };\n\n//# sourceMappingURL=db-verify-DPH4lonK.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAS,qBAAqB,UAAU,YAAY,QAAQ,WAAW;CACtE,MAAM,YAAY,SAAS,IAAI,UAAU,KAAK,SAAS,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC;CACvE,IAAI,cAAc,KAAK,GAAG,MAAM,IAAI,cAAc,iFAAiF;CACnI,IAAI,QAAQ;CACZ,IAAI;CACJ,IAAI,SAAS,CAAC;CACd,IAAI,gBAAgB,CAAC;CACrB,KAAK,MAAM,GAAG,WAAW,UAAU;EAClC,IAAI,CAAC,OAAO,IAAI;GACf,QAAQ;GACR,IAAI,iBAAiB,KAAK,GAAG,eAAe;EAC7C;EACA,SAAS,CAAC,GAAG,QAAQ,GAAG,OAAO,OAAO,MAAM;EAC5C,gBAAgB,CAAC,GAAG,eAAe,GAAG,OAAO,OAAO,UAAU,UAAU,CAAC,CAAC;CAC3E;CACA,MAAM,iBAAiB,UAAU,UAAU,SAAS;CACpD,MAAM,KAAK,SAAS,CAAC;CACrB,MAAM,UAAU,QAAQ,iBAAiB,uBAAuB,UAAU,OAAO,oBAAoB,UAAU,WAAW,IAAI,KAAK,IAAI,0BAA0B,UAAU,UAAU,UAAU,KAAK,cAAc,WAAW,UAAU,UAAU,UAAU;CAC3P,OAAO;EACN,QAAQ;GACP;GACA,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,UAAU,QAAQ,2BAA2B;GAClE;GACA,UAAU,UAAU;GACpB,QAAQ,UAAU;GAClB,QAAQ;IACP;IACA,UAAU,EAAE,QAAQ,cAAc;GACnC;GACA,MAAM,EAAE,OAAO;GACf,SAAS,EAAE,OAAO,EAAE;EACrB;EACA;CACD;AACD;;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AAI;GACd,IAAI,MAAM,MAAM,GAAG,OAAO,iBAAiB,OAAO,KAAK,CAAC;QACnD;IACJ,MAAM,SAAS,mBAAmB,OAAO,OAAO,KAAK;IACrD,IAAI,QAAQ,GAAG,IAAI,MAAM;GAC1B;GACA,QAAQ,KAAK,CAAC;EACf;EACA,IAAIA,qBAAmB,GAAG,OAAO,OAAO,GAAG;GAC1C,MAAM,WAAW,aAAa,QAAQ,OAAO,EAAE;GAC/C,QAAQ,KAAK,QAAQ;EACtB;EACA,IAAI,MAAM,MAAM,GAAG,OAAO,uBAAuB,OAAO,QAAQ,QAAQ,OAAO,QAAQ,SAAS,CAAC;OAC5F;GACJ,MAAM,SAAS,yBAAyB,OAAO,QAAQ,QAAQ;IAC9D,GAAG;IACH,OAAO;GACR,GAAG,OAAO,QAAQ,SAAS;GAC3B,IAAI,QAAQ,GAAG,IAAI,MAAM;EAC1B;EACA,QAAQ,KAAK,CAAC;CACf,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports-BN0vFTxG.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.mjs"],"sourcesContent":["import { n as loadProjectConfig } from \"../enrich-CtoCke3N.mjs\";\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"pathe\";\nimport { fork } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { randomUUID } from \"node:crypto\";\nimport { homedir } from \"node:os\";\n//#region src/endpoint.ts\n/**\n* Production endpoint pinned to the deployed Prisma Compute backend.\n* Compiled as a build-time constant; not user-configurable.\n*/\nconst TELEMETRY_BACKEND_URL = \"https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.prisma.build\";\n/**\n* Path within the backend that accepts telemetry POSTs.\n*/\nconst TELEMETRY_ENDPOINT_PATH = \"/events\";\n/**\n* Resolve the full POST URL the sender targets. The\n* `PRISMA_NEXT_TELEMETRY_ENDPOINT` env var is an integration-testing\n* affordance only — it lets the test suite spin up a mock HTTP server\n* on an ephemeral port and point the spawned sender at it. The override\n* is intentionally undocumented in user-facing material.\n*\n* Fail-open: a malformed override (typo in a dev shell, bad CI config)\n* silently falls back to the production backend rather than throwing,\n* matching the telemetry layer's broader silent-on-failure contract.\n*/\nfunction resolveTelemetryEndpoint(env = process.env) {\n\tconst override = env[\"PRISMA_NEXT_TELEMETRY_ENDPOINT\"];\n\tconst base = override !== void 0 && override.length > 0 ? override : TELEMETRY_BACKEND_URL;\n\ttry {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, base).toString();\n\t} catch {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, TELEMETRY_BACKEND_URL).toString();\n\t}\n}\n//#endregion\n//#region src/gating.ts\n/**\n* A `PRISMA_NEXT_DISABLE_TELEMETRY` value counts as an opt-out only if\n* it parses as a truthy string. The set-but-falsy spellings (`''`,\n* `'0'`, `'false'`) are intentionally treated as not-set so a parent\n* shell that exports the variable to a benign value doesn't accidentally\n* disable telemetry for child processes.\n*/\nfunction isTruthyOptOut(raw) {\n\tif (raw === void 0) return false;\n\tconst normalised = raw.trim().toLowerCase();\n\tif (normalised === \"\") return false;\n\tif (normalised === \"0\") return false;\n\tif (normalised === \"false\") return false;\n\treturn true;\n}\n/**\n* Pure-function resolution of the gating decision. Same input → same\n* output; no I/O. The caller is responsible for reading the env and the\n* user config.\n*\n* Decision order:\n* 1. Env-var override (`PRISMA_NEXT_DISABLE_TELEMETRY` truthy, or\n* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an\n* opt-out env var wins over any stored or unset preference.\n* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).\n* 3. Stored `enableTelemetry === true` → enabled.\n* 4. Stored `enableTelemetry === undefined` (file missing, or field\n* not set) → ENABLED. This is the opt-out default: absence of an\n* explicit choice means telemetry is on. This is the load-bearing,\n* counter-intuitive branch — do not \"fix\" it to default-off.\n*\n* Telemetry is disabled only when an env override is active or\n* `enableTelemetry` is explicitly `false`.\n*/\nfunction resolveGating(inputs) {\n\tif (isTruthyOptOut(inputs.env[\"PRISMA_NEXT_DISABLE_TELEMETRY\"]) || inputs.env[\"DO_NOT_TRACK\"] === \"1\") return {\n\t\tenabled: false,\n\t\treason: \"env-override\"\n\t};\n\tif (inputs.config.enableTelemetry === false) return {\n\t\tenabled: false,\n\t\treason: \"stored-opt-out\"\n\t};\n\treturn { enabled: true };\n}\n//#endregion\n//#region src/sanitize.ts\nfunction flagNameFromLongName(longName) {\n\tif (longName === null || !longName.startsWith(\"--\")) return null;\n\tconst withoutPrefix = longName.slice(2);\n\treturn withoutPrefix.length > 0 ? withoutPrefix : null;\n}\n/**\n* Project commander's parsed result into the wire-shape command and\n* flag-name list. Pure; the only allowed inputs are the fields of\n* `CommanderResultShape`.\n*\n* Sanitiser contract — no flag values, no positionals, no raw argv:\n* - Drop the root program name (`commandPath[0]`); the wire ships\n* `migration new`, not `prisma-next migration new`.\n* - Emit only options whose Commander source is `cli`.\n* - Emit the long user-facing flag spelling without the `--` prefix;\n* never emit Commander's camelCase attribute names.\n* - `positionalArgs` is accepted but never consumed; the field exists\n* in the input type to make it obvious at the call site that\n* positionals were deliberately excluded.\n*/\nfunction sanitizeCommanderResult(input) {\n\treturn {\n\t\tcommand: input.commandPath.slice(1).join(\" \"),\n\t\tflags: input.options.flatMap((option) => {\n\t\t\tif (option.source !== \"cli\") return [];\n\t\t\tconst flagName = flagNameFromLongName(option.longName);\n\t\t\treturn flagName === null ? [] : [flagName];\n\t\t})\n\t};\n}\n//#endregion\n//#region src/user-config.ts\nconst APP_DIR = \"prisma-next\";\nconst FILE_NAME = \"config.json\";\n/**\n* Resolves the user-level config directory:\n* - Windows: `%APPDATA%\\prisma-next\\` (fallback: `%USERPROFILE%\\AppData\\Roaming\\prisma-next\\`).\n* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-next/` if set, else\n* `$HOME/.config/prisma-next/` per the XDG Base Directory Specification.\n*\n* The spec deliberately picks XDG over the macOS-native\n* `~/Library/Preferences/` convention so the path resolution is\n* test-overridable via `XDG_CONFIG_HOME` and matches the documented\n* behaviour on all *nix platforms. We intentionally do not use\n* `env-paths`: its macOS choice of `~/Library/Preferences` is for\n* OS-managed plist preferences, not arbitrary JSON files. Apple documents\n* that apps access that directory through system APIs such as\n* `NSUserDefaults`, while cross-platform CLI and developer tools conventionally\n* use `~/.config` on macOS too:\n* https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html\n*/\nfunction configDir() {\n\tif (process.platform === \"win32\") {\n\t\tconst appData = process.env[\"APPDATA\"];\n\t\tif (appData !== void 0 && appData.length > 0) return join(appData, APP_DIR);\n\t\treturn join(homedir(), \"AppData\", \"Roaming\", APP_DIR);\n\t}\n\tconst xdg = process.env[\"XDG_CONFIG_HOME\"];\n\tif (xdg !== void 0 && xdg.length > 0) return join(xdg, APP_DIR);\n\treturn join(homedir(), \".config\", APP_DIR);\n}\n/**\n* Path to the user-level config file. Resolved per call so test\n* harnesses can mutate `$XDG_CONFIG_HOME` between cases.\n*/\nfunction userConfigPath() {\n\treturn join(configDir(), FILE_NAME);\n}\n/**\n* Reads the user-level config. File-missing, unreadable, or malformed →\n* `{}` (the absence of consent is the same answer in every error mode).\n* Unknown fields from a future client are passed through verbatim.\n*/\nfunction readUserConfig() {\n\tconst path = userConfigPath();\n\tif (!existsSync(path)) return {};\n\ttry {\n\t\tconst raw = readFileSync(path, \"utf-8\");\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)) return parsed;\n\t\treturn {};\n\t} catch {\n\t\treturn {};\n\t}\n}\n/**\n* Merges `partial` into the current config and writes the result\n* atomically (temp file + rename) so a crash mid-write never leaves a\n* half-baked file readable on disk. Unknown fields already on disk are\n* preserved.\n*\n* When `partial.enableTelemetry === true` and no `installationId` is\n* stored yet, generates a v4 random UUID and persists both fields in\n* the same write. An existing `installationId` is never rotated. This is\n* the *explicit-consent* mint path: a `false` answer\n* (`writeUserConfig({ enableTelemetry: false })`) writes no id, and a bare\n* `writeUserConfig({ installationId })` mints nothing extra. The default-on\n* first-send path mints its id separately via {@link ensureInstallationId},\n* which records no consent answer.\n*/\nfunction writeUserConfig(partial) {\n\tconst merged = {\n\t\t...readUserConfig(),\n\t\t...partial\n\t};\n\tif (partial.enableTelemetry === true && merged[\"installationId\"] === void 0) merged[\"installationId\"] = randomUUID();\n\tconst path = userConfigPath();\n\tconst dir = dirname(path);\n\tif (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n\tconst tmpPath = `${path}.${process.pid}.tmp`;\n\twriteFileSync(tmpPath, `${JSON.stringify(merged, null, 2)}\\n`, \"utf-8\");\n\trenameSync(tmpPath, path);\n}\n/**\n* Returns the stored `installationId`, minting and persisting a fresh v4\n* UUID when none exists yet. Crucially, this persists *only* the id —\n* `enableTelemetry` is left untouched (stays `undefined` on a default-on\n* first run), so the interactive `init` consent prompt is not wrongly\n* suppressed and no explicit consent the user never gave is recorded.\n*\n* Used by the default-on first-run fire path: the gate has already\n* resolved enabled, so this only ever runs when telemetry is on.\n*/\nfunction ensureInstallationId() {\n\tconst existing = readUserConfig().installationId;\n\tif (typeof existing === \"string\" && existing.length > 0) return existing;\n\tconst installationId = randomUUID();\n\twriteUserConfig({ installationId });\n\treturn installationId;\n}\n//#endregion\n//#region src/spawn.ts\nfunction runTelemetry(inputs) {\n\tconst env = inputs.env ?? process.env;\n\tif (inputs.isCI) return {\n\t\tspawned: false,\n\t\treason: \"ci\"\n\t};\n\tconst config = inputs.userConfig ?? readUserConfig();\n\tif (!resolveGating({\n\t\tenv,\n\t\tconfig\n\t}).enabled) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst sanitised = sanitizeCommanderResult(inputs.command);\n\tif (typeof config.installationId !== \"string\" || config.installationId.length === 0) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst payload = {\n\t\tinstallationId: config.installationId,\n\t\tversion: inputs.version,\n\t\tcommand: sanitised.command,\n\t\tflags: sanitised.flags,\n\t\tprojectRoot: inputs.projectRoot,\n\t\tendpoint: resolveTelemetryEndpoint(env),\n\t\t...ifDefined(\"databaseTarget\", inputs.databaseTarget)\n\t};\n\ttry {\n\t\tconst child = fork(inputs.senderPath, [], {\n\t\t\tdetached: true,\n\t\t\tstdio: [\n\t\t\t\t\"pipe\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ipc\"\n\t\t\t]\n\t\t});\n\t\tchild.send(payload, (err) => {\n\t\t\tif (err !== null && process.env[\"PRISMA_NEXT_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent send error: ${String(err)}\\n`);\n\t\t});\n\t\tchild.disconnect();\n\t\tchild.unref();\n\t\treturn { spawned: true };\n\t} catch (err) {\n\t\tif (process.env[\"PRISMA_NEXT_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent fork failed: ${String(err)}\\n`);\n\t\treturn {\n\t\t\tspawned: false,\n\t\t\treason: \"fork-failed\"\n\t\t};\n\t}\n}\n/**\n* Resolve the path to the compiled sender entry relative to a consumer\n* that has captured its own `import.meta.url`. The CLI's\n* `tsdown`-emitted entry sits at `<package>/dist/sender.mjs`; the\n* consumer asks `senderModuleUrl()` and forwards the result to\n* `runTelemetry({ senderPath })`.\n*/\nfunction senderModuleUrl(importMetaUrl) {\n\treturn fileURLToPath(new URL(\"./sender.mjs\", importMetaUrl));\n}\n//#endregion\nexport { TELEMETRY_BACKEND_URL, TELEMETRY_ENDPOINT_PATH, ensureInstallationId, loadProjectConfig, readUserConfig, resolveGating, resolveTelemetryEndpoint, runTelemetry, sanitizeCommanderResult, senderModuleUrl, userConfigPath, writeUserConfig };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;AAaA,M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AK;EACb,IAAI,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,OAAO,MAAM,uCAAuC,OAAO,GAAG,EAAE,GAAG;EACzH,OAAO;GACN,SAAS;GACT,QAAQ;EACT;CACD;AACD;;;;;;;;AAQA,SAAS,gBAAgB,eAAe;CACvC,OAAO,cAAc,IAAI,IAAI,gBAAgB,aAAa,CAAC;AAC5D"}
|
|
1
|
+
{"version":3,"file":"exports-BN0vFTxG.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.mjs"],"sourcesContent":["import { n as loadProjectConfig } from \"../enrich-BKPD0fEi.mjs\";\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"pathe\";\nimport { fork } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { randomUUID } from \"node:crypto\";\nimport { homedir } from \"node:os\";\n//#region src/endpoint.ts\n/**\n* Production endpoint pinned to the deployed Prisma Compute backend.\n* Compiled as a build-time constant; not user-configurable.\n*/\nconst TELEMETRY_BACKEND_URL = \"https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.prisma.build\";\n/**\n* Path within the backend that accepts telemetry POSTs.\n*/\nconst TELEMETRY_ENDPOINT_PATH = \"/events\";\n/**\n* Resolve the full POST URL the sender targets. The\n* `PRISMA_NEXT_TELEMETRY_ENDPOINT` env var is an integration-testing\n* affordance only — it lets the test suite spin up a mock HTTP server\n* on an ephemeral port and point the spawned sender at it. The override\n* is intentionally undocumented in user-facing material.\n*\n* Fail-open: a malformed override (typo in a dev shell, bad CI config)\n* silently falls back to the production backend rather than throwing,\n* matching the telemetry layer's broader silent-on-failure contract.\n*/\nfunction resolveTelemetryEndpoint(env = process.env) {\n\tconst override = env[\"PRISMA_NEXT_TELEMETRY_ENDPOINT\"];\n\tconst base = override !== void 0 && override.length > 0 ? override : TELEMETRY_BACKEND_URL;\n\ttry {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, base).toString();\n\t} catch {\n\t\treturn new URL(TELEMETRY_ENDPOINT_PATH, TELEMETRY_BACKEND_URL).toString();\n\t}\n}\n//#endregion\n//#region src/gating.ts\n/**\n* A `PRISMA_NEXT_DISABLE_TELEMETRY` value counts as an opt-out only if\n* it parses as a truthy string. The set-but-falsy spellings (`''`,\n* `'0'`, `'false'`) are intentionally treated as not-set so a parent\n* shell that exports the variable to a benign value doesn't accidentally\n* disable telemetry for child processes.\n*/\nfunction isTruthyOptOut(raw) {\n\tif (raw === void 0) return false;\n\tconst normalised = raw.trim().toLowerCase();\n\tif (normalised === \"\") return false;\n\tif (normalised === \"0\") return false;\n\tif (normalised === \"false\") return false;\n\treturn true;\n}\n/**\n* Pure-function resolution of the gating decision. Same input → same\n* output; no I/O. The caller is responsible for reading the env and the\n* user config.\n*\n* Decision order:\n* 1. Env-var override (`PRISMA_NEXT_DISABLE_TELEMETRY` truthy, or\n* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an\n* opt-out env var wins over any stored or unset preference.\n* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).\n* 3. Stored `enableTelemetry === true` → enabled.\n* 4. Stored `enableTelemetry === undefined` (file missing, or field\n* not set) → ENABLED. This is the opt-out default: absence of an\n* explicit choice means telemetry is on. This is the load-bearing,\n* counter-intuitive branch — do not \"fix\" it to default-off.\n*\n* Telemetry is disabled only when an env override is active or\n* `enableTelemetry` is explicitly `false`.\n*/\nfunction resolveGating(inputs) {\n\tif (isTruthyOptOut(inputs.env[\"PRISMA_NEXT_DISABLE_TELEMETRY\"]) || inputs.env[\"DO_NOT_TRACK\"] === \"1\") return {\n\t\tenabled: false,\n\t\treason: \"env-override\"\n\t};\n\tif (inputs.config.enableTelemetry === false) return {\n\t\tenabled: false,\n\t\treason: \"stored-opt-out\"\n\t};\n\treturn { enabled: true };\n}\n//#endregion\n//#region src/sanitize.ts\nfunction flagNameFromLongName(longName) {\n\tif (longName === null || !longName.startsWith(\"--\")) return null;\n\tconst withoutPrefix = longName.slice(2);\n\treturn withoutPrefix.length > 0 ? withoutPrefix : null;\n}\n/**\n* Project commander's parsed result into the wire-shape command and\n* flag-name list. Pure; the only allowed inputs are the fields of\n* `CommanderResultShape`.\n*\n* Sanitiser contract — no flag values, no positionals, no raw argv:\n* - Drop the root program name (`commandPath[0]`); the wire ships\n* `migration new`, not `prisma-next migration new`.\n* - Emit only options whose Commander source is `cli`.\n* - Emit the long user-facing flag spelling without the `--` prefix;\n* never emit Commander's camelCase attribute names.\n* - `positionalArgs` is accepted but never consumed; the field exists\n* in the input type to make it obvious at the call site that\n* positionals were deliberately excluded.\n*/\nfunction sanitizeCommanderResult(input) {\n\treturn {\n\t\tcommand: input.commandPath.slice(1).join(\" \"),\n\t\tflags: input.options.flatMap((option) => {\n\t\t\tif (option.source !== \"cli\") return [];\n\t\t\tconst flagName = flagNameFromLongName(option.longName);\n\t\t\treturn flagName === null ? [] : [flagName];\n\t\t})\n\t};\n}\n//#endregion\n//#region src/user-config.ts\nconst APP_DIR = \"prisma-next\";\nconst FILE_NAME = \"config.json\";\n/**\n* Resolves the user-level config directory:\n* - Windows: `%APPDATA%\\prisma-next\\` (fallback: `%USERPROFILE%\\AppData\\Roaming\\prisma-next\\`).\n* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-next/` if set, else\n* `$HOME/.config/prisma-next/` per the XDG Base Directory Specification.\n*\n* The spec deliberately picks XDG over the macOS-native\n* `~/Library/Preferences/` convention so the path resolution is\n* test-overridable via `XDG_CONFIG_HOME` and matches the documented\n* behaviour on all *nix platforms. We intentionally do not use\n* `env-paths`: its macOS choice of `~/Library/Preferences` is for\n* OS-managed plist preferences, not arbitrary JSON files. Apple documents\n* that apps access that directory through system APIs such as\n* `NSUserDefaults`, while cross-platform CLI and developer tools conventionally\n* use `~/.config` on macOS too:\n* https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html\n*/\nfunction configDir() {\n\tif (process.platform === \"win32\") {\n\t\tconst appData = process.env[\"APPDATA\"];\n\t\tif (appData !== void 0 && appData.length > 0) return join(appData, APP_DIR);\n\t\treturn join(homedir(), \"AppData\", \"Roaming\", APP_DIR);\n\t}\n\tconst xdg = process.env[\"XDG_CONFIG_HOME\"];\n\tif (xdg !== void 0 && xdg.length > 0) return join(xdg, APP_DIR);\n\treturn join(homedir(), \".config\", APP_DIR);\n}\n/**\n* Path to the user-level config file. Resolved per call so test\n* harnesses can mutate `$XDG_CONFIG_HOME` between cases.\n*/\nfunction userConfigPath() {\n\treturn join(configDir(), FILE_NAME);\n}\n/**\n* Reads the user-level config. File-missing, unreadable, or malformed →\n* `{}` (the absence of consent is the same answer in every error mode).\n* Unknown fields from a future client are passed through verbatim.\n*/\nfunction readUserConfig() {\n\tconst path = userConfigPath();\n\tif (!existsSync(path)) return {};\n\ttry {\n\t\tconst raw = readFileSync(path, \"utf-8\");\n\t\tconst parsed = JSON.parse(raw);\n\t\tif (parsed !== null && typeof parsed === \"object\" && !Array.isArray(parsed)) return parsed;\n\t\treturn {};\n\t} catch {\n\t\treturn {};\n\t}\n}\n/**\n* Merges `partial` into the current config and writes the result\n* atomically (temp file + rename) so a crash mid-write never leaves a\n* half-baked file readable on disk. Unknown fields already on disk are\n* preserved.\n*\n* When `partial.enableTelemetry === true` and no `installationId` is\n* stored yet, generates a v4 random UUID and persists both fields in\n* the same write. An existing `installationId` is never rotated. This is\n* the *explicit-consent* mint path: a `false` answer\n* (`writeUserConfig({ enableTelemetry: false })`) writes no id, and a bare\n* `writeUserConfig({ installationId })` mints nothing extra. The default-on\n* first-send path mints its id separately via {@link ensureInstallationId},\n* which records no consent answer.\n*/\nfunction writeUserConfig(partial) {\n\tconst merged = {\n\t\t...readUserConfig(),\n\t\t...partial\n\t};\n\tif (partial.enableTelemetry === true && merged[\"installationId\"] === void 0) merged[\"installationId\"] = randomUUID();\n\tconst path = userConfigPath();\n\tconst dir = dirname(path);\n\tif (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n\tconst tmpPath = `${path}.${process.pid}.tmp`;\n\twriteFileSync(tmpPath, `${JSON.stringify(merged, null, 2)}\\n`, \"utf-8\");\n\trenameSync(tmpPath, path);\n}\n/**\n* Returns the stored `installationId`, minting and persisting a fresh v4\n* UUID when none exists yet. Crucially, this persists *only* the id —\n* `enableTelemetry` is left untouched (stays `undefined` on a default-on\n* first run), so the interactive `init` consent prompt is not wrongly\n* suppressed and no explicit consent the user never gave is recorded.\n*\n* Used by the default-on first-run fire path: the gate has already\n* resolved enabled, so this only ever runs when telemetry is on.\n*/\nfunction ensureInstallationId() {\n\tconst existing = readUserConfig().installationId;\n\tif (typeof existing === \"string\" && existing.length > 0) return existing;\n\tconst installationId = randomUUID();\n\twriteUserConfig({ installationId });\n\treturn installationId;\n}\n//#endregion\n//#region src/spawn.ts\nfunction runTelemetry(inputs) {\n\tconst env = inputs.env ?? process.env;\n\tif (inputs.isCI) return {\n\t\tspawned: false,\n\t\treason: \"ci\"\n\t};\n\tconst config = inputs.userConfig ?? readUserConfig();\n\tif (!resolveGating({\n\t\tenv,\n\t\tconfig\n\t}).enabled) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst sanitised = sanitizeCommanderResult(inputs.command);\n\tif (typeof config.installationId !== \"string\" || config.installationId.length === 0) return {\n\t\tspawned: false,\n\t\treason: \"gated-off\"\n\t};\n\tconst payload = {\n\t\tinstallationId: config.installationId,\n\t\tversion: inputs.version,\n\t\tcommand: sanitised.command,\n\t\tflags: sanitised.flags,\n\t\tprojectRoot: inputs.projectRoot,\n\t\tendpoint: resolveTelemetryEndpoint(env),\n\t\t...ifDefined(\"databaseTarget\", inputs.databaseTarget)\n\t};\n\ttry {\n\t\tconst child = fork(inputs.senderPath, [], {\n\t\t\tdetached: true,\n\t\t\tstdio: [\n\t\t\t\t\"pipe\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ignore\",\n\t\t\t\t\"ipc\"\n\t\t\t]\n\t\t});\n\t\tchild.send(payload, (err) => {\n\t\t\tif (err !== null && process.env[\"PRISMA_NEXT_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent send error: ${String(err)}\\n`);\n\t\t});\n\t\tchild.disconnect();\n\t\tchild.unref();\n\t\treturn { spawned: true };\n\t} catch (err) {\n\t\tif (process.env[\"PRISMA_NEXT_DEBUG\"] === \"1\") process.stderr.write(`[cli-telemetry] parent fork failed: ${String(err)}\\n`);\n\t\treturn {\n\t\t\tspawned: false,\n\t\t\treason: \"fork-failed\"\n\t\t};\n\t}\n}\n/**\n* Resolve the path to the compiled sender entry relative to a consumer\n* that has captured its own `import.meta.url`. The CLI's\n* `tsdown`-emitted entry sits at `<package>/dist/sender.mjs`; the\n* consumer asks `senderModuleUrl()` and forwards the result to\n* `runTelemetry({ senderPath })`.\n*/\nfunction senderModuleUrl(importMetaUrl) {\n\treturn fileURLToPath(new URL(\"./sender.mjs\", importMetaUrl));\n}\n//#endregion\nexport { TELEMETRY_BACKEND_URL, TELEMETRY_ENDPOINT_PATH, ensureInstallationId, loadProjectConfig, readUserConfig, resolveGating, resolveTelemetryEndpoint, runTelemetry, sanitizeCommanderResult, senderModuleUrl, userConfigPath, writeUserConfig };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;AAaA,MAAM,wBAAwB;;;;AAI9B,MAAM,0BAA0B;;;;;;;;;;;;AAYhC,SAAS,yBAAyB,MAAM,QAAQ,KAAK;CACpD,MAAM,WAAW,IAAI;CACrB,MAAM,OAAO,aAAa,KAAK,KAAK,SAAS,SAAS,IAAI,WAAW;CACrE,IAAI;EACH,OAAO,IAAI,IAAI,yBAAyB,IAAI,CAAC,CAAC,SAAS;CACxD,QAAQ;EACP,OAAO,IAAI,IAAI,yBAAyB,qBAAqB,CAAC,CAAC,SAAS;CACzE;AACD;;;;;;;;AAUA,SAAS,eAAe,KAAK;CAC5B,IAAI,QAAQ,KAAK,GAAG,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OAAO,MAAM,OAAO;EACvB,SAAS;EACT,QAAQ;CACT;CACA,MAAM,SAAS,OAAO,cAAc,eAAe;CACnD,IAAI,CAAC,cAAc;EAClB;EACA;CACD,CAAC,CAAC,CAAC,SAAS,OAAO;EAClB,SAAS;EACT,QAAQ;CACT;CACA,MAAM,YAAY,wBAAwB,OAAO,OAAO;CACxD,IAAI,OAAO,OAAO,mBAAmB,YAAY,OAAO,eAAe,WAAW,GAAG,OAAO;EAC3F,SAAS;EACT,QAAQ;CACT;CACA,MAAM,UAAU;EACf,gBAAgB,OAAO;EACvB,SAAS,OAAO;EAChB,SAAS,UAAU;EACnB,OAAO,UAAU;EACjB,aAAa,OAAO;EACpB,UAAU,yBAAyB,GAAG;EACtC,GAAG,UAAU,kBAAkB,OAAO,cAAc;CACrD;CACA,IAAI;EACH,MAAM,QAAQ,KAAK,OAAO,YAAY,CAAC,GAAG;GACzC,UAAU;GACV,OAAO;IACN;IACA;IACA;IACA;GACD;EACD,CAAC;EACD,MAAM,KAAK,UAAU,QAAQ;GAC5B,IAAI,QAAQ,QAAQ,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,OAAO,MAAM,sCAAsC,OAAO,GAAG,EAAE,GAAG;EACzI,CAAC;EACD,MAAM,WAAW;EACjB,MAAM,MAAM;EACZ,OAAO,EAAE,SAAS,KAAK;CACxB,SAAS,KAAK;EACb,IAAI,QAAQ,IAAI,yBAAyB,KAAK,QAAQ,OAAO,MAAM,uCAAuC,OAAO,GAAG,EAAE,GAAG;EACzH,OAAO;GACN,SAAS;GACT,QAAQ;EACT;CACD;AACD;;;;;;;;AAQA,SAAS,gBAAgB,eAAe;CACvC,OAAO,cAAc,IAAI,IAAI,gBAAgB,aAAa,CAAC;AAC5D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as findNearestConfigPathForFile, r as loadConfig } from "./exports-
|
|
1
|
+
import { n as findNearestConfigPathForFile, o as requireConfigSections, r as loadConfig } from "./exports-DVoyX2LM.mjs";
|
|
2
2
|
import { CliStructuredError } from "@prisma/orm-framework/errors/control";
|
|
3
3
|
import { join } from "pathe";
|
|
4
4
|
import { createControlStack } from "@prisma/orm-framework/components/control";
|
|
@@ -484,13 +484,25 @@ const emptyPipelineInputs = {
|
|
|
484
484
|
pslBlockDescriptors: {}
|
|
485
485
|
};
|
|
486
486
|
async function resolveConfigInputs(configPath) {
|
|
487
|
-
const
|
|
487
|
+
const loaded = await loadConfig(configPath);
|
|
488
|
+
if (!loaded.ok) throw loaded.failure;
|
|
489
|
+
const projectSections = requireConfigSections(loaded.value, ["contract", "formatter"]);
|
|
490
|
+
if (!projectSections.ok) throw projectSections.failure;
|
|
491
|
+
const config = projectSections.value;
|
|
488
492
|
const inputs = resolveSchemaInputs(config);
|
|
489
493
|
if (!hasPslInputs(config)) return {
|
|
490
494
|
inputs,
|
|
491
495
|
controlStack: emptyPipelineInputs,
|
|
492
496
|
...config.formatter === void 0 ? {} : { formatter: config.formatter }
|
|
493
497
|
};
|
|
498
|
+
const controlSections = requireConfigSections(loaded.value, [
|
|
499
|
+
"family",
|
|
500
|
+
"target",
|
|
501
|
+
"adapter",
|
|
502
|
+
"driver",
|
|
503
|
+
"extensions"
|
|
504
|
+
]);
|
|
505
|
+
if (!controlSections.ok) throw controlSections.failure;
|
|
494
506
|
const stack = createControlStack(config);
|
|
495
507
|
const interpretation = resolveInterpretation(config, stack, inputs);
|
|
496
508
|
return {
|
|
@@ -1433,4 +1445,4 @@ function startServer() {
|
|
|
1433
1445
|
//#endregion
|
|
1434
1446
|
export { startServer };
|
|
1435
1447
|
|
|
1436
|
-
//# sourceMappingURL=exports-
|
|
1448
|
+
//# sourceMappingURL=exports-DAA3XD4a.mjs.map
|