@prisma/orm-toolchain 8.0.0-rc.2-dev.2 → 8.0.0-rc.20
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/README.md +1 -5
- package/dist/{aggregate-DLUJLq5Y.d.mts → aggregate-BpcQdygS.d.mts} +83 -36
- package/dist/aggregate-BpcQdygS.d.mts.map +1 -0
- package/dist/{aggregate-CPZB020V.mjs → aggregate-T_HG6gq6.mjs} +118 -57
- package/dist/aggregate-T_HG6gq6.mjs.map +1 -0
- package/dist/caught-errors-Bmbi1dBu-DKO5X2tN.mjs +1026 -0
- package/dist/caught-errors-Bmbi1dBu-DKO5X2tN.mjs.map +1 -0
- package/dist/cli-telemetry.d.mts +9 -8
- package/dist/cli-telemetry.d.mts.map +1 -1
- package/dist/cli-telemetry.mjs +30 -27
- package/dist/cli-telemetry.mjs.map +1 -1
- package/dist/cli.d.mts +7 -14
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +3832 -1562
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +233 -93
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +3 -2
- package/dist/cli__control-api__testing.d.mts +5 -4
- package/dist/cli__control-api__testing.d.mts.map +1 -1
- package/dist/cli__control-api__testing.mjs +21 -16
- package/dist/cli__control-api__testing.mjs.map +1 -1
- package/dist/cli__init-output.d.mts +11 -1
- package/dist/cli__init-output.d.mts.map +1 -1
- package/dist/cli__init-output.mjs +1 -1
- package/dist/cli__migration-cli.d.mts +1 -1
- package/dist/cli__migration-cli.mjs +65 -19
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +2 -2
- package/dist/config-loader.mjs +2 -2
- package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs} +44 -16
- package/dist/contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs.map +1 -0
- package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts +59 -0
- package/dist/contract-snapshot-store-Bok5nQYi-D3g_P7im.d.mts.map +1 -0
- package/dist/contract-snapshot-store-DrIwu5pn.d.mts +2 -0
- package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-sign-gvrl0kFE-D-nTGx88.d.mts} +330 -230
- package/dist/db-sign-gvrl0kFE-D-nTGx88.d.mts.map +1 -0
- package/dist/{domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs → domain-type-generation-B4m774CV-WAjyhZHw.mjs} +144 -154
- package/dist/domain-type-generation-B4m774CV-WAjyhZHw.mjs.map +1 -0
- package/dist/domain-type-generation-DZjtzrbE-BpOOD3YV.d.mts +78 -0
- package/dist/domain-type-generation-DZjtzrbE-BpOOD3YV.d.mts.map +1 -0
- package/dist/emitter.d.mts +3 -3
- package/dist/emitter.mjs +3 -3
- package/dist/emitter__domain-type-generation.d.mts +2 -2
- package/dist/emitter__domain-type-generation.mjs +2 -2
- package/dist/{errors-D59OCpoI.d.mts → errors-CLwhWJiz.d.mts} +14 -3
- package/dist/errors-CLwhWJiz.d.mts.map +1 -0
- package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-DXha_4l--relAaiI4.mjs} +37 -42
- package/dist/errors-DXha_4l--relAaiI4.mjs.map +1 -0
- package/dist/exports-BCIlMjIW-DkUBVDzl.mjs +421 -0
- package/dist/exports-BCIlMjIW-DkUBVDzl.mjs.map +1 -0
- package/dist/exports-BlYTE3-J.mjs +539 -0
- package/dist/exports-BlYTE3-J.mjs.map +1 -0
- package/dist/exports-CKgwcXbp.mjs +3973 -0
- package/dist/exports-CKgwcXbp.mjs.map +1 -0
- package/dist/graph-membership-DxpNgxfZ-BfqA-H7V.mjs +19 -0
- package/dist/graph-membership-DxpNgxfZ-BfqA-H7V.mjs.map +1 -0
- package/dist/{hash-DH8hl5Rq-BpM2t3Nu.mjs → hash-BAZVWU4a-BQovI7hF.mjs} +24 -3
- package/dist/hash-BAZVWU4a-BQovI7hF.mjs.map +1 -0
- package/dist/hash-CwWGlFWV.d.mts +1 -0
- package/dist/{hash-XZYYKJ-i.d.mts → hash-DclMqd7S-WBvXJ_4C.d.mts} +17 -4
- package/dist/hash-DclMqd7S-WBvXJ_4C.d.mts.map +1 -0
- package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
- package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
- package/dist/{import-roots-CNFBPAT1.mjs → import-roots-BPn2s_fq.mjs} +6 -6
- package/dist/import-roots-BPn2s_fq.mjs.map +1 -0
- package/dist/index-CWPFeYyi.d.mts +204 -0
- package/dist/index-CWPFeYyi.d.mts.map +1 -0
- package/dist/{index-Dgwl8Tzs.d.mts → index-tAySVPvZ.d.mts} +16 -4
- package/dist/index-tAySVPvZ.d.mts.map +1 -0
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-DrF9p5Gd-BF70vGl1.mjs} +3 -3
- package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-DrF9p5Gd-BF70vGl1.mjs.map} +1 -1
- package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-BNxFm3eg-DYD82QeZ.mjs} +8 -8
- package/dist/io-BNxFm3eg-DYD82QeZ.mjs.map +1 -0
- package/dist/io-D8Epu7iY.d.mts +1 -0
- package/dist/{io-sr4CO9_t-C3eV_kn-.d.mts → io-DZfMV51z-BKlH5Dhb.d.mts} +9 -2
- package/dist/io-DZfMV51z-BKlH5Dhb.d.mts.map +1 -0
- package/dist/{migration-B2ljMJim.d.mts → migration-Bjz05034.d.mts} +12 -5
- package/dist/migration-Bjz05034.d.mts.map +1 -0
- package/dist/{migration-hspPIEeV.mjs → migration-CWyjX9vz.mjs} +18 -6
- package/dist/migration-CWyjX9vz.mjs.map +1 -0
- package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-BoiiZAaU-DLht12k7.mjs} +6 -89
- package/dist/migration-graph-BoiiZAaU-DLht12k7.mjs.map +1 -0
- package/dist/{migration-graph-tarTxJ99-BrGBANeE.d.mts → migration-graph-D8IuOkZb-pSI7-k4_.d.mts} +7 -29
- package/dist/migration-graph-D8IuOkZb-pSI7-k4_.d.mts.map +1 -0
- package/dist/migration-graph-Dra4CcyN.d.mts +14 -0
- package/dist/migration-graph-Dra4CcyN.d.mts.map +1 -0
- package/dist/migration-tools.d.mts +17 -15
- package/dist/migration-tools.mjs +15 -15
- package/dist/migration-tools__aggregate.d.mts +2 -2
- package/dist/migration-tools__aggregate.mjs +2 -2
- package/dist/migration-tools__contract-snapshot-store.d.mts +4 -2
- package/dist/migration-tools__contract-snapshot-store.mjs +2 -2
- package/dist/migration-tools__errors.d.mts +2 -2
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__hash.d.mts +2 -1
- package/dist/migration-tools__hash.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.d.mts +2 -2
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.d.mts +3 -3
- package/dist/migration-tools__migration-graph.mjs +3 -3
- package/dist/migration-tools__migration-ts.d.mts +2 -2
- package/dist/migration-tools__migration-ts.mjs +2 -2
- package/dist/migration-tools__migration.d.mts +1 -1
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.d.mts +2 -2
- package/dist/migration-tools__ref-resolution.mjs +2 -2
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.d.mts +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{migration-ts-DdVm0rws.mjs → migration-ts-DDgjsR1O.mjs} +6 -5
- package/dist/migration-ts-DDgjsR1O.mjs.map +1 -0
- package/dist/{migration-ts-CNaAtK8C.d.mts → migration-ts-SGer0PXq.d.mts} +4 -2
- package/dist/migration-ts-SGer0PXq.d.mts.map +1 -0
- package/dist/op-schema-3tXg0LTS-DqpOKDEa.mjs +23 -0
- package/dist/op-schema-3tXg0LTS-DqpOKDEa.mjs.map +1 -0
- package/dist/output-BcC8eB0h-C5bRd-aC.mjs +129 -0
- package/dist/output-BcC8eB0h-C5bRd-aC.mjs.map +1 -0
- package/dist/publish-surface.d.mts +1 -1
- package/dist/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.d.mts +1 -1
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/quick-reference-mongo.md +12 -12
- package/dist/quick-reference-postgres.md +10 -10
- package/dist/quick-reference-prisma7.md +80 -0
- package/dist/readme-mongo.md +6 -6
- package/dist/readme-postgres.md +6 -6
- package/dist/ref-DEiY2Cbd-1ZImpUEN.mjs +6663 -0
- package/dist/ref-DEiY2Cbd-1ZImpUEN.mjs.map +1 -0
- package/dist/{ref-resolution-COGOSL57.d.mts → ref-resolution-BPhR-kta.d.mts} +29 -11
- package/dist/ref-resolution-BPhR-kta.d.mts.map +1 -0
- package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-Eo0QHp4f.mjs} +30 -6
- package/dist/ref-resolution-Eo0QHp4f.mjs.map +1 -0
- package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-DM3q3IZC-BC6H6P0X.mjs} +9 -9
- package/dist/refs-DM3q3IZC-BC6H6P0X.mjs.map +1 -0
- package/dist/{shells-C4HbRAr5.mjs → shells-w_yEDhe8.mjs} +98 -31
- package/dist/shells-w_yEDhe8.mjs.map +1 -0
- package/dist/{spaces-Dj65JrwZ.d.mts → spaces-BWULKO54.d.mts} +3 -3
- package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-BWULKO54.d.mts.map} +1 -1
- package/dist/{spaces-4qMOAYE9.mjs → spaces-c9xdiXW8.mjs} +14 -13
- package/dist/spaces-c9xdiXW8.mjs.map +1 -0
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-YzEHF9zj-DGZgox_3.mjs} +7 -7
- package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-YzEHF9zj-DGZgox_3.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.d.mts +1 -1
- package/dist/vite-plugin-contract-emit.mjs +10 -10
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +16 -15
- package/dist/aggregate-CPZB020V.mjs.map +0 -1
- package/dist/aggregate-DLUJLq5Y.d.mts.map +0 -1
- package/dist/contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map +0 -1
- package/dist/contract-snapshot-store-CbqynbtE.d.mts +0 -28
- package/dist/contract-snapshot-store-CbqynbtE.d.mts.map +0 -1
- package/dist/db-verify-BwgNK50T-DGvKgFCK.d.mts.map +0 -1
- package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts +0 -63
- package/dist/domain-type-generation-PkAb39ob-Ct8AGqow.d.mts.map +0 -1
- package/dist/domain-type-generation-bpSO3Y0L-jo2C7LlH.mjs.map +0 -1
- package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
- package/dist/errors-D59OCpoI.d.mts.map +0 -1
- package/dist/exports-8ZUN43ve.mjs +0 -1734
- package/dist/exports-8ZUN43ve.mjs.map +0 -1
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs +0 -160
- package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
- package/dist/exports-BZaG8_w_.mjs +0 -243
- package/dist/exports-BZaG8_w_.mjs.map +0 -1
- package/dist/graph-membership-BViWUMpP-C4lYYJdU.mjs +0 -14
- package/dist/graph-membership-BViWUMpP-C4lYYJdU.mjs.map +0 -1
- package/dist/hash-DH8hl5Rq-BpM2t3Nu.mjs.map +0 -1
- package/dist/hash-XZYYKJ-i.d.mts.map +0 -1
- package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
- package/dist/index-DRs7L6N0.d.mts +0 -57
- package/dist/index-DRs7L6N0.d.mts.map +0 -1
- package/dist/index-Dgwl8Tzs.d.mts.map +0 -1
- package/dist/io-635GlNx1-D3zrw2qu.mjs.map +0 -1
- package/dist/io-DYfeLJxR.d.mts +0 -1
- package/dist/io-sr4CO9_t-C3eV_kn-.d.mts.map +0 -1
- package/dist/migration-B2ljMJim.d.mts.map +0 -1
- package/dist/migration-graph-Dqndu0i5.d.mts +0 -9
- package/dist/migration-graph-Dqndu0i5.d.mts.map +0 -1
- package/dist/migration-graph-_SJImD5V-BURyY1KM.mjs.map +0 -1
- package/dist/migration-graph-tarTxJ99-BrGBANeE.d.mts.map +0 -1
- package/dist/migration-hspPIEeV.mjs.map +0 -1
- package/dist/migration-ts-CNaAtK8C.d.mts.map +0 -1
- package/dist/migration-ts-DdVm0rws.mjs.map +0 -1
- package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs +0 -13
- package/dist/op-schema-BSVHzEQN-DIWt28D8.mjs.map +0 -1
- package/dist/output-CovTDY14-CUoAqLML.mjs +0 -77
- package/dist/output-CovTDY14-CUoAqLML.mjs.map +0 -1
- package/dist/ref-h6InR6dO-rGfl18Jv.mjs +0 -4686
- package/dist/ref-h6InR6dO-rGfl18Jv.mjs.map +0 -1
- package/dist/ref-resolution-COGOSL57.d.mts.map +0 -1
- package/dist/ref-resolution-HeNBXW53.mjs.map +0 -1
- package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
- package/dist/shells-C4HbRAr5.mjs.map +0 -1
- package/dist/spaces-4qMOAYE9.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caught-errors-Bmbi1dBu-DKO5X2tN.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/caught-errors-Bmbi1dBu.mjs"],"sourcesContent":["import { ifDefined } from \"@internal/utils/defined\";\nimport { CliStructuredError as CliStructuredError$1, errorConfigValidation, errorContractConfigMissing, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorMigrationPlanningFailed, errorTargetMigrationNotSupported, errorUnexpected } from \"@internal/errors/control\";\nimport { APP_SPACE_ID, hasMigrations } from \"@internal/framework-components/control\";\nimport { InternalError, isInternalError } from \"@internal/utils/internal-error\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\nimport { relative, resolve } from \"pathe\";\nimport { errorHashMismatch, errorMarkerMissing, errorRuntime, errorTargetMismatch } from \"@internal/errors/execution\";\nimport \"@internal/errors/migration\";\nimport { readFile } from \"node:fs/promises\";\nimport { APP_SPACE_ID as APP_SPACE_ID$1, spaceMigrationDirectory } from \"@internal/migration-tools/spaces\";\n//#region src/control-api/statements/statement-flag.ts\nconst SHELL_SAFE = /^[A-Za-z0-9_.:/@%+,-]+$/;\n/** The value as a shell passes it through unchanged, single-quoted when needed. */\nfunction shellQuoted(value) {\n\treturn SHELL_SAFE.test(value) ? value : `'${value.replaceAll(\"'\", `'\\\\''`)}'`;\n}\n/**\n* A statement written as a flag a shell passes through unchanged: the value is single-quoted when\n* it has a character a shell would read, and joined with `=` when it starts with `-`, which a\n* parser would otherwise read as a flag.\n*/\nfunction statementFlag(statement) {\n\tconst value = shellQuoted(statement.text);\n\treturn statement.text.startsWith(\"-\") ? `--${statement.verb}=${value}` : `--${statement.verb} ${value}`;\n}\n//#endregion\n//#region src/utils/next-actions.ts\n/**\n* The typed remediation the CLI attaches to its own errors and findings.\n* Constructors live here rather than in any library the CLI calls: naming a\n* runnable invocation is something only the CLI can do.\n*/\nfunction runCommandAction(label, command) {\n\treturn {\n\t\tkind: \"run-command\",\n\t\tlabel,\n\t\tcommand\n\t};\n}\n/** Advice the user carries out or decides on themselves, such as changing data in the database or choosing between plans; it has no command to run and edits no file. */\nfunction chooseAction(label) {\n\treturn {\n\t\tkind: \"user-choice\",\n\t\tlabel\n\t};\n}\n/** Advice that changes a file before anything runs again. */\nfunction editFileAction(label) {\n\treturn {\n\t\tkind: \"edit-file\",\n\t\tlabel\n\t};\n}\n//#endregion\n//#region src/utils/printed-command.ts\n/** The invocation of a command run with `ctx`, given `--db` when `db` is defined. */\nfunction cliInvocation(ctx, db) {\n\treturn {\n\t\tcwd: ctx.cwd,\n\t\tconfigPath: ctx.configPath,\n\t\tdbGiven: db !== void 0\n\t};\n}\n/** The commands that connect to a database: those whose flags include `dbFlag`, which a test checks. */\nconst COMMANDS_TAKING_DB = /* @__PURE__ */ new Set([\n\t\"contract infer\",\n\t\"db init\",\n\t\"db migrate\",\n\t\"db schema\",\n\t\"db sign\",\n\t\"db update\",\n\t\"db verify\",\n\t\"migration log\",\n\t\"migration status\"\n]);\nfunction configWords(configPath) {\n\treturn configPath === void 0 ? [] : [\"--config\", shellQuoted(configPath)];\n}\n/**\n* A CLI command as advice prints it: `{bin}`, the command and its arguments, the `--config` the CLI\n* was given, and, for a command that connects to a database, `--db <url>` when the CLI was given\n* `--db`, so it runs as printed from the directory the CLI ran in, against the same database. The\n* URL stays a placeholder because it can hold credentials.\n*/\nfunction cliCommand(invocation, command, args = []) {\n\treturn [\n\t\t\"{bin}\",\n\t\tcommand,\n\t\t...args,\n\t\t...configWords(invocation?.configPath),\n\t\t...invocation?.dbGiven === true && COMMANDS_TAKING_DB.has(command) ? [\"--db\", \"<url>\"] : []\n\t].join(\" \");\n}\n/**\n* The `migration plan` command advice prints: it starts from `from`, the contract the database is\n* at, whenever that is known, because `migration plan` cannot find its origin without it once\n* migrations exist and no `db` ref names one.\n*/\nfunction printedPlanCommand(invocation, from, flags) {\n\treturn cliCommand(invocation, \"migration plan\", [...from === void 0 ? [] : [\"--from\", from], ...flags]);\n}\n/**\n* The command that runs a `migration.ts`, named relative to the directory the CLI ran in, with the\n* `--config` the CLI was given, so it loads the same config.\n*/\nfunction selfEmitCommand(invocation, migrationTs) {\n\treturn [\n\t\t\"node\",\n\t\tshellQuoted(printedPath(invocation, migrationTs)),\n\t\t...configWords(invocation.configPath)\n\t].join(\" \");\n}\n/** A path as advice prints it: relative to the directory the CLI ran in. */\nfunction printedPath(invocation, path) {\n\treturn relative(invocation.cwd, path);\n}\n//#endregion\n//#region src/utils/cli-errors.ts\n/**\n* A CLI-raised error that carries the typed remediation as well as the prose.\n* Only the CLI knows which invocation fixes a failure, so only errors raised\n* here spell one; the foundation classes every library also raises keep\n* carrying `code`, `why` and `fix` alone.\n*\n* Both fields are required: the `fix` prose is what the commander shell still\n* renders, and the handler boundary drops it in favour of `nextActions` when it\n* settles the engine's envelope.\n*/\nvar ActionableCliError = class extends CliStructuredError$1 {\n\tnextActions;\n\tconstructor(code, summary, options) {\n\t\tsuper(code, summary, options);\n\t\tthis.nextActions = options.nextActions;\n\t}\n};\n/**\n* A command that accepts a contract reference both as a positional and as a\n* flag was given both. Structured rather than a bare stderr line, so a script\n* sees the same envelope every other invocation failure produces.\n*/\nfunction errorContractArgConflict(options) {\n\tconst fix = \"Pass the contract reference once — either as the positional argument or as --contract.\";\n\treturn new ActionableCliError(\"CLI.CONTRACT_ARG_CONFLICT\", \"Cannot specify both a positional contract argument and --contract\", {\n\t\twhy: `The positional argument names \"${options.positional}\" and --contract names \"${options.flag}\"; there is no rule for which wins.`,\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: {\n\t\t\tpositional: options.positional,\n\t\t\tflag: options.flag\n\t\t}\n\t});\n}\n/**\n* A command was told both which ref to advance and not to advance any ref.\n* Same envelope as the positional/flag contract conflict, so a script sees\n* every invocation conflict in one shape.\n*/\nfunction errorAdvanceRefArgConflict(options) {\n\tconst fix = \"Pass either --advance-ref <name> or --no-advance-ref, not both.\";\n\treturn new ActionableCliError(\"CLI.ADVANCE_REF_ARG_CONFLICT\", \"Cannot specify both --advance-ref and --no-advance-ref\", {\n\t\twhy: `--advance-ref names \"${options.advanceRef}\" while --no-advance-ref asks for no ref to be written; there is no rule for which wins.`,\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: { advanceRef: options.advanceRef }\n\t});\n}\nfunction quotedSpaces(spaces) {\n\treturn spaces.map((space) => `\"${space}\"`).join(\", \");\n}\nfunction notSignedSentence(spaces, because, becausePlural) {\n\tif (spaces.length === 0) return \"\";\n\treturn spaces.length === 1 ? ` Space ${quotedSpaces(spaces)} was not signed, because ${because}.` : ` Spaces ${quotedSpaces(spaces)} were not signed, because ${becausePlural}.`;\n}\n/**\n* `db sign` wrote the markers, then failed to write one or more refs or their snapshots. The database is signed; running the command again writes the refs. The error also names the spaces it did not sign: those whose schema failed verification, and those whose marker changed while it ran.\n*/\nfunction errorSignRefsNotWritten(options) {\n\tconst { signedSpaces, failedSpaces, conflictSpaces, unwrittenRefs, rerunCommand } = options;\n\tconst markers = signedSpaces.length === 1 ? `the marker of space ${quotedSpaces(signedSpaces)} holds its contract` : `the markers of spaces ${quotedSpaces(signedSpaces)} hold their contracts`;\n\tconst notSigned = notSignedSentence(failedSpaces, \"its schema does not satisfy its contract\", \"their schemas do not satisfy their contracts\") + notSignedSentence(conflictSpaces, \"its marker changed while db sign ran\", \"their markers changed while db sign ran\");\n\tconst refs = unwrittenRefs.map((ref) => `ref \"${ref.name}\" of space \"${ref.space}\" (${ref.reason})`).join(\"; \");\n\tconst count = unwrittenRefs.length;\n\treturn new ActionableCliError(\"MIGRATION.SIGN_REFS_NOT_WRITTEN\", `Database signed, but ${count} ${count === 1 ? \"ref was\" : \"refs were\"} not written`, {\n\t\twhy: `The database was signed: ${markers}.${notSigned} These refs were not written: ${refs}.`,\n\t\tfix: `Fix what stopped the write, then run \\`${rerunCommand}\\` again: the markers already hold the contracts, so it writes only the refs.`,\n\t\tnextActions: [runCommandAction(\"Sign again to write the refs that were not written\", rerunCommand)],\n\t\tmeta: {\n\t\t\tsignedSpaces,\n\t\t\tfailedSpaces,\n\t\t\tconflictSpaces,\n\t\t\tunwrittenRefs,\n\t\t\tadvancedRefs: options.advancedRefs\n\t\t},\n\t\tcause: options.cause\n\t});\n}\nfunction errorRefSetHashNotInGraph(resolvedHash, reachableHashes) {\n\tconst reachableList = reachableHashes.length > 0 ? reachableHashes.join(\", \") : \"(none — migration graph is empty)\";\n\tconst fix = reachableHashes.length > 0 ? \"Set the ref to the `to` hash of an on-disk migration; `{bin} migration list` shows them.\" : \"Run `{bin} migration plan` first.\";\n\tconst nextActions = reachableHashes.length > 0 ? [runCommandAction(\"List the migrations and their destination hashes\", \"{bin} migration list\"), chooseAction(\"Set the ref to the `to` hash of one of them\")] : [runCommandAction(\"Plan the first migration\", \"{bin} migration plan\")];\n\treturn new ActionableCliError(\"MIGRATION.HASH_NOT_IN_GRAPH\", `Resolved contract hash is not in the migration graph: ${resolvedHash}`, {\n\t\twhy: reachableHashes.length > 0 ? `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.` : \"The migration graph is empty — no hashes reachable.\",\n\t\tfix,\n\t\tnextActions,\n\t\tmeta: {\n\t\t\tresolvedHash,\n\t\t\treachableHashes: [...reachableHashes]\n\t\t}\n\t});\n}\nfunction errorRefSetEmptySentinel(hash) {\n\treturn new ActionableCliError(\"MIGRATION.REF_SET_EMPTY_SENTINEL\", `Cannot set ref to the empty-database sentinel: ${hash}`, {\n\t\twhy: \"The empty-database sentinel is a planner internal; it is not a valid ref target.\",\n\t\tfix: \"Set the ref to a contract hash from the migration graph, or use another ref name.\",\n\t\tnextActions: [chooseAction(\"Set the ref to a contract hash from the migration graph\"), chooseAction(\"Or use another ref name\")],\n\t\tmeta: { hash }\n\t});\n}\n/**\n* `--legend` was combined with a machine-readable or silent output flag.\n* The legend is human-only decoration on stderr.\n*/\nfunction errorLegendHumanOnly(conflictingFlag) {\n\treturn new ActionableCliError(\"MIGRATION.LEGEND_HUMAN_ONLY\", \"`--legend` is only available for human-readable output\", {\n\t\twhy: `\\`--legend\\` prints a glyph key to stderr and cannot be combined with ${conflictingFlag}.`,\n\t\tfix: `Omit ${conflictingFlag} to print the legend alongside the tree, or omit --legend when using ${conflictingFlag}.`,\n\t\tnextActions: [chooseAction(`Omit ${conflictingFlag} to print the legend alongside the tree`), chooseAction(`Or omit --legend when using ${conflictingFlag}`)],\n\t\tmeta: { conflictingFlag }\n\t});\n}\n/**\n* `--space <id>` was given a value that doesn't satisfy the contract-space\n* naming rule (`[a-z][a-z0-9_-]{0,63}` per `isValidSpaceId`). Fires before\n* any fs work — the input is syntactically rejected the same way an on-disk\n* directory with that name would be skipped by the enumerator.\n*/\nfunction errorInvalidSpaceId(spaceId) {\n\treturn new ActionableCliError(\"MIGRATION.INVALID_SPACE_ID\", `Invalid contract space id: ${spaceId}`, {\n\t\twhy: \"Contract space ids must match [a-z][a-z0-9_-]{0,63} (lowercase, starts with a letter, max 64 characters — the rule applied to every on-disk space directory).\",\n\t\tfix: \"Pass a space id that matches the directory naming rule, or omit --space to list every space.\",\n\t\tnextActions: [chooseAction(\"Pass a space id matching [a-z][a-z0-9_-]{0,63}\"), runCommandAction(\"Or list every space\", \"{bin} migration list\")],\n\t\tmeta: { spaceId }\n\t});\n}\n/**\n* `migration list --space <id>` was given a contract-space id that has no\n* directory under `migrations/`. Distinct from \"the space exists but is\n* empty\" — that path renders the empty-state line and exits 0 per the\n* slice spec § Empty-state. This error fires only when `<projectMigrationsDir>/<spaceId>`\n* does not exist on disk.\n*\n* `availableSpaces` lists the contract-space directory names actually\n* present, sorted lex-asc, so the diagnostic can suggest a near match\n* without making the user reach for `ls`.\n*/\nfunction errorSpaceNotFound(spaceId, availableSpaces) {\n\tconst availableList = availableSpaces.length > 0 ? availableSpaces.join(\", \") : \"(none — no contract spaces on disk yet)\";\n\tconst fix = availableSpaces.length > 0 ? `Pick one of: ${availableList}. Run \\`{bin} migration list\\` (no --space) to see every space's migrations.` : \"Author a migration with `{bin} migration new` to create the first contract-space directory.\";\n\tconst nextActions = availableSpaces.length > 0 ? [chooseAction(`Pick one of: ${availableList}`), runCommandAction(\"See every space's migrations\", \"{bin} migration list\")] : [runCommandAction(\"Author the first migration, which creates the contract-space directory\", \"{bin} migration new\")];\n\treturn new ActionableCliError(\"MIGRATION.SPACE_NOT_FOUND\", `Unknown contract space: ${spaceId}`, {\n\t\twhy: `No directory named \"${spaceId}\" exists under the migrations root.`,\n\t\tfix,\n\t\tnextActions,\n\t\tmeta: {\n\t\t\tspaceId,\n\t\t\tavailableSpaces: [...availableSpaces]\n\t\t}\n\t});\n}\n/**\n* A `migration show` target resolved to a directory or a graph node, but no\n* on-disk package was loaded for it.\n*/\nfunction errorMigrationPackageNotFound(why) {\n\treturn new ActionableCliError(\"MIGRATION.PACKAGE_NOT_FOUND\", \"Migration package not found\", {\n\t\twhy,\n\t\tfix: \"Pass a directory name, hash prefix, or path to an on-disk app-space migration package.\",\n\t\tnextActions: [chooseAction(\"Pass a directory name, hash prefix, or path to an on-disk app-space migration package\"), runCommandAction(\"List what is on disk\", \"{bin} migration list\")]\n\t});\n}\n/** The app space has no migration packages at all, so no target can resolve. */\nfunction errorNoMigrations(appMigrationsRelative) {\n\treturn new ActionableCliError(\"MIGRATION.NO_MIGRATIONS\", \"No migrations found\", {\n\t\twhy: `No migration packages found in ${appMigrationsRelative}`,\n\t\tfix: \"Run `{bin} migration plan` to create a migration first.\",\n\t\tnextActions: [runCommandAction(\"Create the first migration\", \"{bin} migration plan\")]\n\t});\n}\nfunction errorRefSetBundleNotFound(hash) {\n\treturn new ActionableCliError(\"MIGRATION.REF_SET_BUNDLE_NOT_FOUND\", `No migration bundle matches graph-node hash ${hash}`, {\n\t\twhy: `The hash is a graph node but no on-disk bundle has metadata.to = ${hash}.`,\n\t\tfix: \"Run `pnpm fixtures:check`, or re-emit the migration that produces this hash so its bundle is restored.\",\n\t\tnextActions: [runCommandAction(\"Restore the checked-in fixtures\", \"pnpm fixtures:check\"), chooseAction(\"Or re-emit the migration that produces this hash\")],\n\t\tmeta: { hash }\n\t});\n}\nfunction errorPlanForgotTheFlag(resolvedHash, reachableRefs, options) {\n\tconst reachableList = reachableRefs.length > 0 ? reachableRefs.map((r) => `${r.name} (${r.hash})`).join(\", \") : \"(none)\";\n\tconst refFix = reachableRefs.length > 0 ? `Run migration plan with ${reachableRefs.map((r) => `--from ${r.name}`).join(\" or \")}.` : \"Pass --from <contract> naming the `to` hash of an on-disk migration (`{bin} migration list` shows them), or point the db ref at one with `{bin} migration ref set db <contract>`.\";\n\tconst nextActions = reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) : [runCommandAction(\"Plan from an explicit origin\", \"{bin} migration plan --from <contract>\"), runCommandAction(\"Point the db ref at a graph node\", \"{bin} migration ref set db <contract>\")];\n\treturn new ActionableCliError(\"MIGRATION.HASH_NOT_IN_GRAPH\", `Resolved from-hash is not in the migration graph: ${resolvedHash}`, {\n\t\twhy: `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.`,\n\t\tfix: refFix,\n\t\tnextActions,\n\t\tmeta: {\n\t\t\tresolvedHash,\n\t\t\treachableRefs: reachableRefs.map((r) => r.name)\n\t\t},\n\t\t...ifDefined(\"cause\", options?.cause)\n\t});\n}\n/**\n* `viaRef: true` (the default) mirrors migration-tools' `errorRefNotResolvable`:\n* a ref name with no pointer file, where the fallback hash isn't a graph\n* node either — there's nothing to materialize a contract from.\n* `viaRef: false` is a distinct, ref-independent case: an explicit `--from\n* <hash>` that doesn't name a ref, on an empty migration graph, so there is\n* no graph node and no ref to resolve a contract through.\n*/\nfunction errorSnapshotMissing(identifier, options) {\n\tconst viaRef = options?.viaRef !== false;\n\tconst fix = viaRef ? `Create the ref with \"{bin} migration ref set ${identifier} <hash>\" (or advance it via \"{bin} db update --advance-ref ${identifier}\"), or pass a hash that is a node in the migration graph.` : `No contract source exists for hash \"${identifier}\" on an empty migration graph. Use --from with a ref name (its contract resolves through the snapshot store), or run db update first.`;\n\tconst nextActions = viaRef ? [\n\t\trunCommandAction(`Create the ref \"${identifier}\"`, `{bin} migration ref set ${identifier} <hash>`),\n\t\trunCommandAction(\"Or advance it from the database\", `{bin} db update --advance-ref ${identifier}`),\n\t\tchooseAction(\"Or pass a hash that is a node in the migration graph\")\n\t] : [chooseAction(\"Pass --from a ref name, whose contract resolves through the snapshot store\"), runCommandAction(\"Or populate the graph first\", \"{bin} db update\")];\n\treturn new ActionableCliError(\"MIGRATION.SNAPSHOT_MISSING\", viaRef ? `Ref \"${identifier}\" is not resolvable` : `No contract source for from-hash \"${identifier}\"`, {\n\t\twhy: viaRef ? `Ref \"${identifier}\" has no pointer file, and the hash being resolved is not a node in the migration graph either.` : `Hash \"${identifier}\" is not a node in the migration graph (the graph is empty), and it does not name a ref either.`,\n\t\tfix,\n\t\tnextActions,\n\t\tmeta: {\n\t\t\tidentifier,\n\t\t\tviaRef\n\t\t},\n\t\t...ifDefined(\"cause\", options?.cause)\n\t});\n}\n/**\n* Default origin resolution for `migration plan` found nothing (no `--from`,\n* no `db` ref) while migrations already exist on disk. Planning would silently\n* produce an empty-origin migration that ignores the existing history — almost\n* always a mistake — so the command refuses and names the three exits.\n*/\nfunction errorPlanOriginUnknown(reachableRefs) {\n\tconst fromSuggestion = reachableRefs.length > 0 ? reachableRefs.map((r) => `--from ${r.name}`).join(\" or \") : \"--from <contract>\";\n\tconst refSetCommand = \"{bin} migration ref set db <contract>\";\n\treturn new ActionableCliError(\"MIGRATION.PLAN_ORIGIN_UNKNOWN\", \"Cannot determine the plan origin: migrations exist but no origin is named\", {\n\t\twhy: \"Migrations exist on disk, but there is no `db` ref and no --from was given, so the plan origin would silently fall back to an empty database and the resulting migration would recreate everything the existing migrations already create.\",\n\t\tfix: [\n\t\t\t`Set the \\`db\\` ref to the contract your dev database is at (\\`${refSetCommand}\\`), or advance it via \\`{bin} db update\\`.`,\n\t\t\t`Or pass the origin explicitly: \\`{bin} migration plan ${fromSuggestion}\\`.`,\n\t\t\t\"Or pass --from @empty to deliberately plan from an empty database.\"\n\t\t].join(\"\\n\"),\n\t\tnextActions: [\n\t\t\trunCommandAction(\"Point the db ref at the origin contract\", refSetCommand),\n\t\t\t...reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) : [runCommandAction(\"Plan from an explicit origin\", `{bin} migration plan ${fromSuggestion}`)],\n\t\t\trunCommandAction(\"Plan from an empty database deliberately\", \"{bin} migration plan --from @empty\")\n\t\t],\n\t\tmeta: { reachableRefs: reachableRefs.map((r) => r.name) }\n\t});\n}\nfunction errorStatementInvalid(statement, why, fix) {\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_INVALID\", `Invalid statement \"--${statement.verb} ${statement.text}\"`, {\n\t\twhy,\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: {\n\t\t\tstatement: statement.text,\n\t\t\tverb: statement.verb\n\t\t}\n\t});\n}\n/**\n* A statement is well formed, but its names do not resolve in the\n* origin and destination contracts the way a rename requires.\n*/\nfunction errorStatementUnresolved(statement, why, fix) {\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_UNRESOLVED\", `Cannot resolve statement \"--${statement.verb} ${statement.text}\"`, {\n\t\twhy,\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: {\n\t\t\tstatement: statement.text,\n\t\t\tverb: statement.verb\n\t\t}\n\t});\n}\n/**\n* A rename or convert typed in answer to a data-loss question was planned, and the plan still loses\n* the subject's data: the statement does not account for the operation the question was about.\n*/\nfunction errorStatementDidNotResolveLoss(statement, subject) {\n\tconst fix = `Answer the question about \"${subject}\" with ${statementFlag({\n\t\tverb: \"delete\",\n\t\ttext: subject\n\t})} if its data may be lost, or give a ${statement.verb} statement that keeps that data.`;\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_DID_NOT_RESOLVE_LOSS\", `\"--${statement.verb} ${statement.text}\" does not keep the data of \"${subject}\"`, {\n\t\twhy: `The plan was made again with the statement, and it still loses the data of \"${subject}\".`,\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: {\n\t\t\tstatement: statement.text,\n\t\t\tverb: statement.verb,\n\t\t\tsubject\n\t\t}\n\t});\n}\n/** `--convert` and `--delete` name the same field, and each answers its type change differently. */\nfunction errorConvertAndDelete(field) {\n\tconst fix = `Give one of them: ${statementFlag({\n\t\tverb: \"convert\",\n\t\ttext: field\n\t})}, or ${statementFlag({\n\t\tverb: \"delete\",\n\t\ttext: field\n\t})}.`;\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_INVALID\", `\"--convert ${field}\" and \"--delete ${field}\" conflict`, {\n\t\twhy: `Both answer the type change of \"${field}\": --convert converts each value with code you write in migration.ts, and --delete lets the database cast each value, losing those it cannot keep.`,\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: {\n\t\t\tstatement: field,\n\t\t\tverb: \"convert\"\n\t\t}\n\t});\n}\nconst MIGRATION_PLAN_VERBS = [\n\t\"rename\",\n\t\"delete\",\n\t\"convert\",\n\t\"backfill\"\n];\n/**\n* `--convert` or `--backfill` statements were given to `db update`, which applies its plan\n* directly and so has no migration file whose slot the user could fill. `statements` are every\n* statement the user gave, in the order given: the `migration plan` command the error suggests\n* carries each one that command accepts, and starts from `databaseStorageHash`, the contract the\n* database is at, when it is known. Its commands repeat the `--config` of `invocation`.\n*/\nfunction errorStatementNeedsMigrationFile(statements, invocation, databaseStorageHash) {\n\tconst refused = statements.filter(({ verb }) => verb === \"convert\" || verb === \"backfill\");\n\tconst written = refused.map(({ verb, text }) => `\"--${verb} ${text}\"`);\n\tconst listed = written.length === 1 ? written[0] : `${written.slice(0, -1).join(\", \")} and ${written.at(-1)}`;\n\tconst plan = printedPlanCommand(invocation, databaseStorageHash, statements.filter(({ verb }) => MIGRATION_PLAN_VERBS.includes(verb)).map(statementFlag));\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_NEEDS_MIGRATION_FILE\", `db update cannot carry out ${listed}`, {\n\t\twhy: \"--convert and --backfill ask for a migration file with a slot for the code that converts or fills in the values, and db update has no migration file to fill: it applies its plan directly.\",\n\t\tfix: `Plan the change with ${plan}, fill in the migration.ts it writes, run that migration.ts with the \\`node\\` command \\`migration plan\\` prints, and apply it with ${cliCommand(invocation, \"db migrate\")}. Or leave out these statements: db update then asks before it loses any data.`,\n\t\tnextActions: [runCommandAction(\"Plan the change into a migration file to fill in\", plan), chooseAction(\"Or run db update without these statements\")],\n\t\tmeta: { statements: refused.map(({ verb, text }) => ({\n\t\t\tverb,\n\t\t\ttext\n\t\t})) }\n\t});\n}\nfunction unusedConsentSentence({ verb, text, alreadyAnsweredBy: answeredBy }) {\n\tif (answeredBy === void 0) return `--${verb} ${text} was given but nothing in this run asked about ${text}.`;\n\tif (answeredBy.kind === \"namespace\") return `--${verb} ${text} was given, but every question about namespace \"${answeredBy.namespace}\" was already answered by another flag.`;\n\treturn `--${verb} ${text} was given, but the question about ${answeredBy.subject} was already answered by --${answeredBy.flag.verb} ${answeredBy.flag.text}.`;\n}\nfunction errorConsentUnused(unused, asked) {\n\tconst actions = [...unused.some(({ alreadyAnsweredBy }) => alreadyAnsweredBy === void 0) ? [\"Remove the flag, or spell the subject the way the command names it.\"] : [], ...unused.some(({ alreadyAnsweredBy }) => alreadyAnsweredBy !== void 0) ? [\"Give one flag per question.\"] : []];\n\treturn new CliStructuredError$1(\"CLI.CONSENT_UNUSED\", unused.map(unusedConsentSentence).join(\" \"), {\n\t\t...ifDefined(\"why\", asked.length === 0 ? void 0 : `The run asked about ${asked.join(\", \")}.`),\n\t\tnextActions: actions.map((label) => ({\n\t\t\tkind: \"user-choice\",\n\t\t\tlabel\n\t\t})),\n\t\tmeta: {\n\t\t\tunused: unused.map(({ verb, text }) => ({\n\t\t\t\tverb,\n\t\t\t\tvalues: [text]\n\t\t\t})),\n\t\t\t...asked.length === 0 ? {} : { asked }\n\t\t}\n\t});\n}\n/**\n* `delete` or `allow` statements given to a programmatic call match no question the plan asks,\n* so they consent to nothing.\n*/\nfunction errorStatementAnswersNoQuestion(statements, subjects) {\n\tconst written = statements.map(({ verb, text }) => `\"--${verb} ${text}\"`);\n\tconst listed = written.length === 1 ? `Statement ${written[0]} answers` : `Statements ${written.slice(0, -1).join(\", \")} and ${written.at(-1)} answer`;\n\tconst fix = subjects.length === 0 ? \"Leave the statements out: the plan asks no question.\" : `Leave them out, or name a subject the plan asks about: ${subjects.join(\", \")}.`;\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_ANSWERS_NO_QUESTION\", `${listed} no question of the plan`, {\n\t\twhy: \"A delete or allow statement consents to an operation the plan asks about, and these name no subject the plan would lose data from or change access to.\",\n\t\tfix,\n\t\tnextActions: [chooseAction(fix)],\n\t\tmeta: {\n\t\t\tstatements: statements.map(({ verb, text }) => ({\n\t\t\t\tverb,\n\t\t\t\ttext\n\t\t\t})),\n\t\t\tsubjects\n\t\t}\n\t});\n}\n/**\n* Without statements, `db update` drops a renamed table or column and creates it again under the\n* new name, so any advice to run without them says so.\n*/\nconst WITHOUT_STATEMENTS_DROPS = \"A plan made without statements drops the storage of each renamed model or field with its data and creates it again under the new name, and asks for consent before it does.\";\n/** How to store the snapshot of the contract the database is at, so statements can resolve. */\nconst STORE_ORIGIN_SNAPSHOT_STEPS = [\n\t\"1. Put the contract source back to the version the database is at, and run `{bin} contract emit`.\",\n\t\"2. Run `{bin} db update --advance-ref <name> --dry-run`, with the same `--db` as this command if it has one, and check that it plans no operations. Then run it again without `--dry-run`: the database matches that contract, so this changes nothing in it, and it stores the contract snapshot. If the dry run plans operations, the database has drifted from that contract; settle that before you go on.\",\n\t\"3. Put the new contract source back, run `{bin} contract emit`, and run this command again with `--advance-ref <name>`.\"\n];\n/**\n* Statements were given, but there is no origin contract to resolve their old\n* names against.\n*/\nfunction errorStatementOriginUnknown(origin) {\n\tif (origin.hash === null) return new ActionableCliError(\"MIGRATION.STATEMENT_ORIGIN_UNKNOWN\", \"Cannot resolve statements: the database has no marker\", {\n\t\twhy: \"The database has no marker: Prisma has never initialised or updated it, so there is no earlier contract whose names a statement could rename.\",\n\t\tfix: `Leave out the statements. If the database already holds data under the old names, preview the plan with --dry-run first. ${WITHOUT_STATEMENTS_DROPS}`,\n\t\tnextActions: [chooseAction(`Leave out the statements, and preview the plan with --dry-run first. ${WITHOUT_STATEMENTS_DROPS}`)],\n\t\tmeta: {\n\t\t\thash: null,\n\t\t\tsnapshotDirectory: origin.snapshotDirectory\n\t\t}\n\t});\n\tconst meta = {\n\t\thash: origin.hash,\n\t\tsnapshotDirectory: origin.snapshotDirectory,\n\t\t...ifDefined(\"unreadable\", origin.unreadable)\n\t};\n\tif (origin.unreadable !== void 0) return new ActionableCliError(\"MIGRATION.STATEMENT_ORIGIN_UNKNOWN\", \"Cannot resolve statements: the origin contract snapshot cannot be read\", {\n\t\twhy: `The contract snapshot for hash \"${origin.hash}\" in ${origin.snapshotDirectory} could not be read: ${origin.unreadable}`,\n\t\tfix: [\"Restore migrations/snapshots/ from version control. If no good copy exists, store the snapshot again:\", ...STORE_ORIGIN_SNAPSHOT_STEPS].join(\"\\n\"),\n\t\tnextActions: [chooseAction(\"Restore migrations/snapshots/ from version control\"), chooseAction(\"Or store the snapshot again from the contract the database is at\")],\n\t\tmeta\n\t});\n\treturn new ActionableCliError(\"MIGRATION.STATEMENT_ORIGIN_UNKNOWN\", \"Cannot resolve statements: the origin contract is unknown\", {\n\t\twhy: `No contract snapshot for hash \"${origin.hash}\" was found in ${origin.snapshotDirectory}. Statements name things in the contract the database is at, so the command needs that contract. \\`db update\\` stores the snapshot of the contract it applies only when it advances a ref: the \\`db\\` ref by default, or with \\`--db <url>\\` only the ref named by \\`--advance-ref <name>\\`. Most likely the run that brought the database to this contract advanced no ref.`,\n\t\tfix: [\n\t\t\t\"Store the snapshot of the contract the database is at, then run the rename:\",\n\t\t\t...STORE_ORIGIN_SNAPSHOT_STEPS,\n\t\t\t\"Adding --advance-ref to this command alone does not help: it would store the new contract, not the one the database is at. `migration plan --from` does not apply to `db update`.\"\n\t\t].join(\"\\n\"),\n\t\tnextActions: [\n\t\t\tchooseAction(\"Put the contract source back to the version the database is at, and emit it\"),\n\t\t\trunCommandAction(\"Check that it plans no operations (with the same --db as this command, if any)\", \"{bin} db update --advance-ref <name> --dry-run\"),\n\t\t\trunCommandAction(\"Then store its snapshot, which changes nothing in the database\", \"{bin} db update --advance-ref <name>\"),\n\t\t\tchooseAction(\"Put the new contract source back, emit it, and run this command again with --advance-ref <name>\")\n\t\t],\n\t\tmeta\n\t});\n}\nconst REPORT_MISSED_CHANGE = \"If you expected the database to change, migration plan missed it: report it with the output of `prisma migration plan --json`.\";\nfunction noOperationsConflict(origin, destination) {\n\tswitch (origin.kind) {\n\t\tcase \"empty\": return {\n\t\t\tkind: \"nothingToCreate\",\n\t\t\tsummary: \"This contract describes nothing migration plan can create, so there is no first migration to plan.\",\n\t\t\twhy: destination.isEmitted ? \"If the database needs something the contract does not describe, run `prisma migration new`, add its operations to the new `migration.ts`, then run that `migration.ts` with `node` to write `ops.json`.\" : \"`prisma migration new` writes a migration only to the emitted contract. If the database needs something this contract does not describe, emit it, run `prisma migration new`, add its operations to the new `migration.ts`, then run that `migration.ts` with `node` to write `ops.json`.\"\n\t\t};\n\t\tcase \"baseline\": return {\n\t\t\tkind: \"nothingToBaseline\",\n\t\t\tsummary: `The migrations directory is empty, so migration plan starts the migration history with a baseline migration to the contract the db ref points at, ${origin.hash}. That contract describes nothing migration plan can create, so there is no baseline to plan.`,\n\t\t\twhy: \"No command writes a baseline migration with no operations. If you manage the database with `prisma db init` or `prisma db update`, keep using `prisma db update`. No command can start a migration history from this database yet; report it with the output of `prisma migration plan --json`.\"\n\t\t};\n\t\tcase \"contract\": return {\n\t\t\tkind: \"noDatabaseChange\",\n\t\t\tsummary: \"The contract changed, but migration plan found nothing to change in the database. That is expected after a Prisma upgrade that changes how contract.json records values, after you switch a field to another codec of the same type, or after you change a control policy.\",\n\t\t\twhy: destination.isEmitted ? `If you deploy with migrations, run \\`prisma migration new --from ${origin.hash}\\` to write a migration with no operations, then \\`prisma db migrate\\`. If you manage the database with \\`prisma db init\\` or \\`prisma db update\\`, run \\`prisma db sign\\` on each database instead. ${REPORT_MISSED_CHANGE}` : `\\`prisma migration new\\` writes a migration only to the emitted contract; to write one to this target, emit it first. If you manage the database with \\`prisma db init\\` or \\`prisma db update\\`, run \\`prisma db sign ${destination.hash}\\` on each database. ${REPORT_MISSED_CHANGE}`\n\t\t};\n\t}\n}\n/** `migration plan` refuses a leg whose planner produced no operations, and says how to proceed from where it planned. */\nfunction errorPlanProducedNoOperations(origin, destination) {\n\treturn errorMigrationPlanningFailed({ conflicts: [noOperationsConflict(origin, destination)] });\n}\nfunction errorMarkerMismatch(markerHash, reachableHashes) {\n\treturn new ActionableCliError(\"MIGRATION.MARKER_MISMATCH\", \"Database marker is not reachable in the on-disk migration graph\", {\n\t\twhy: `DB marker is ${markerHash}, but the on-disk migration graph reaches: ${reachableHashes.length > 0 ? reachableHashes.join(\", \") : \"(none — migration graph is empty)\"}.`,\n\t\tfix: [\n\t\t\t\"Run `{bin} db sign` to overwrite the marker if the database already matches the contract.\",\n\t\t\t\"Run `{bin} migration plan --from <contract>`, naming the graph node the database was migrated from, if the live marker is canonical and the on-disk graph needs catching up.\",\n\t\t\t`Run \\`{bin} migration ref set db ${markerHash}\\` if the on-disk graph is canonical and the local \\`db\\` ref drifted.`,\n\t\t\t\"Investigate whether the database was migrated by an out-of-band process.\"\n\t\t].join(\"\\n\"),\n\t\tnextActions: [\n\t\t\trunCommandAction(\"Overwrite the marker if the database already matches the contract\", \"{bin} db sign\"),\n\t\t\trunCommandAction(\"Catch the on-disk graph up to the live marker\", \"{bin} migration plan --from <contract>\"),\n\t\t\trunCommandAction(\"Point the local db ref at the live marker\", `{bin} migration ref set db ${markerHash}`),\n\t\t\tchooseAction(\"Investigate whether the database was migrated by an out-of-band process\")\n\t\t],\n\t\tmeta: {\n\t\t\tmarkerHash,\n\t\t\treachableHashes: [...reachableHashes]\n\t\t}\n\t});\n}\nconst ROLLBACK_IS_DESTRUCTIVE = \"A rollback (reverse) plan is expected to contain destructive (DROP) operations — review them before applying\";\nconst RENAMES_AND_DATA_NEED_MORE = \"Plan a rename with --rename old:new; re-adding a required field without a safe default, or a type change that needs data, may need you to fill in the planned migration.ts\";\nfunction planThenApply(meta) {\n\tconst planCommand = meta.kind === \"neverPlanned\" ? \"{bin} migration plan --name <slug>\" : meta.fromHash === EMPTY_CONTRACT_HASH ? `{bin} migration plan --to ${meta.targetHash} --name <slug>` : `{bin} migration plan --from ${meta.fromHash} --to ${meta.targetHash} --name <slug>`;\n\tconst applyCommand = meta.kind === \"neverPlanned\" ? \"{bin} db migrate\" : `{bin} db migrate --to ${meta.targetHash}`;\n\treturn {\n\t\tfix: [\n\t\t\t\"Plan the missing edge, then apply it:\",\n\t\t\t` 1. ${planCommand}`,\n\t\t\t` 2. ${applyCommand}`,\n\t\t\t`${ROLLBACK_IS_DESTRUCTIVE}.`,\n\t\t\t`${RENAMES_AND_DATA_NEED_MORE}.`,\n\t\t\t\"Inspect the on-disk graph with `{bin} migration list`, or `{bin} migration show <bundle>` for any bundle in the path you expected.\"\n\t\t].join(\"\\n\"),\n\t\tnextActions: [\n\t\t\trunCommandAction(\"Plan the missing edge\", planCommand),\n\t\t\trunCommandAction(\"Apply it\", applyCommand),\n\t\t\tchooseAction(ROLLBACK_IS_DESTRUCTIVE),\n\t\t\tchooseAction(RENAMES_AND_DATA_NEED_MORE),\n\t\t\trunCommandAction(\"Inspect the on-disk graph\", \"{bin} migration list\"),\n\t\t\trunCommandAction(\"Inspect a bundle in the path you expected\", \"{bin} migration show <bundle>\")\n\t\t]\n\t};\n}\n/** `MIGRATION.PATH_UNREACHABLE`, advising to plan the missing edge and apply it unless `advice` says otherwise. */\nfunction errorPathUnreachable(failure, advice = planThenApply(failure.meta)) {\n\treturn new ActionableCliError(\"MIGRATION.PATH_UNREACHABLE\", failure.summary, {\n\t\twhy: failure.why,\n\t\tfix: advice.fix,\n\t\tnextActions: advice.nextActions,\n\t\tmeta: failure.meta\n\t});\n}\n/**\n* Shared \"needs a live database\" precondition for read verbs that consult the\n* marker/ledger (`migration log`, `migration status`). A command needs both a\n* connection string and a control-plane driver; either missing yields the same\n* `CONFIG.DB_CONNECTION_REQUIRED` envelope with `meta.missingFlags` (canonical long-form flags\n* per CLI Style Guide §Errors) so callers can react programmatically. Returns\n* `null` when both are present.\n*/\nfunction requireLiveDatabase(args) {\n\tif (args.dbConnection && args.hasDriver) return null;\n\tconst missingFlags = args.dbConnection ? [] : [\"--db\"];\n\treturn errorDatabaseConnectionRequired({\n\t\twhy: args.why,\n\t\tmissingFlags,\n\t\t...ifDefined(\"commandName\", args.commandName),\n\t\t...ifDefined(\"retryCommand\", args.retryCommand)\n\t});\n}\n/**\n* Maps a `RefResolutionError` from the contract/migration reference\n* resolver into a CLI structured error envelope.\n*/\n/**\n* A migration ref (dirName or hash-prefix) resolves in more than one contract\n* space. The user must qualify with `--space <id>` to disambiguate.\n*/\nfunction errorAmbiguousMigrationRef(ref, spaceIds) {\n\tconst spaceList = spaceIds.join(\", \");\n\treturn new ActionableCliError(\"MIGRATION.AMBIGUOUS_MIGRATION_REF\", `Ambiguous migration reference: \"${ref}\" resolves in multiple spaces — qualify with --space <id>`, {\n\t\twhy: `\"${ref}\" matches migrations in spaces: ${spaceList}.`,\n\t\tfix: `Qualify with --space <id> to select one space. Available matching spaces: ${spaceList}.`,\n\t\tnextActions: [chooseAction(`Qualify with --space <id>, one of: ${spaceList}`)],\n\t\tmeta: {\n\t\t\tref,\n\t\t\tspaceIds: [...spaceIds]\n\t\t}\n\t});\n}\nfunction mapRefResolutionError(error) {\n\tswitch (error.kind) {\n\t\tcase \"not-found\": {\n\t\t\tconst fix = error.grammar === \"contract\" ? \"Provide a valid contract hash, ref name, or migration directory name.\" : \"Provide a valid migration directory name or migration hash.\";\n\t\t\treturn new ActionableCliError(\"MIGRATION.REF_NOT_FOUND\", `Not a known ${error.grammar} reference: \"${error.input}\"`, {\n\t\t\t\twhy: `No ${error.grammar} matching \"${error.input}\" exists in the migration graph or refs index.`,\n\t\t\t\tfix,\n\t\t\t\tnextActions: [chooseAction(fix)],\n\t\t\t\tmeta: {\n\t\t\t\t\tinput: error.input,\n\t\t\t\t\tgrammar: error.grammar\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tcase \"ambiguous\": return new ActionableCliError(\"MIGRATION.REF_AMBIGUOUS\", `Ambiguous ${error.grammar} reference: \"${error.input}\"`, {\n\t\t\twhy: `\"${error.input}\" matches multiple ${error.grammar}s: ${error.candidates.join(\", \")}`,\n\t\t\tfix: \"Provide a longer prefix or use the full hash to disambiguate.\",\n\t\t\tnextActions: [chooseAction(\"Provide a longer prefix or use the full hash to disambiguate\")],\n\t\t\tmeta: {\n\t\t\t\tinput: error.input,\n\t\t\t\tcandidates: error.candidates,\n\t\t\t\tgrammar: error.grammar\n\t\t\t}\n\t\t});\n\t\tcase \"wrong-grammar\": return new ActionableCliError(\"MIGRATION.REF_WRONG_GRAMMAR\", error.message, {\n\t\t\twhy: error.message,\n\t\t\tfix: error.fix,\n\t\t\tnextActions: [chooseAction(error.fix)],\n\t\t\tmeta: {\n\t\t\t\tinput: error.input,\n\t\t\t\texpectedGrammar: error.expectedGrammar\n\t\t\t}\n\t\t});\n\t\tcase \"invalid-format\": return new ActionableCliError(\"MIGRATION.REF_INVALID_FORMAT\", `Invalid reference format: \"${error.input}\"`, {\n\t\t\twhy: error.reason,\n\t\t\tfix: \"Provide a valid contract hash, ref name, or migration directory name.\",\n\t\t\tnextActions: [chooseAction(\"Provide a valid contract hash, ref name, or migration directory name\")],\n\t\t\tmeta: { input: error.input }\n\t\t});\n\t}\n}\n//#endregion\n//#region src/orm/migration/paths.ts\n/**\n* The directory of the config file that wrote the section, recorded when the\n* engine validated it. Every command runs behind that validation, so its\n* absence here is a bug.\n*/\nfunction baseDirFor(config) {\n\tif (config.baseDir === void 0) throw new InternalError(\"the orm config section reached a command without baseDir\");\n\treturn config.baseDir;\n}\n/**\n* Where a config keeps its migrations: `migrations.dir`, default `migrations`, resolved against the config's `baseDir`. `base` stands in for `baseDir` when a config built in memory carries none.\n*/\nfunction migrationsDirFor(config, base) {\n\treturn resolve(config.baseDir ?? base ?? baseDirFor(config), config.migrations?.dir ?? \"migrations\");\n}\n/** The app subspace under {@link migrationsDirFor}. */\nfunction appMigrationsDirFor(config) {\n\treturn spaceMigrationDirectory(migrationsDirFor(config), APP_SPACE_ID);\n}\n/**\n* Where refs live. The framework keeps them under the app subspace rather than\n* at the migrations root.\n*/\nfunction appRefsDirFor(config) {\n\treturn resolve(appMigrationsDirFor(config), \"refs\");\n}\n/** The emitted contract; the validated config carries `contract.output` absolute. */\nfunction contractPathFor(config) {\n\treturn config.contract?.output;\n}\n/**\n* The header's rendering of a path: relative to where the user invoked the\n* CLI, as the commander shell rendered it against the config file.\n*/\nfunction displayPath(path, cwd) {\n\treturn relative(cwd, path);\n}\n//#endregion\n//#region src/utils/url-credentials.ts\nconst MASK = \"****\";\nconst URL_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\//;\nconst LEADING_URL_USERINFO = /^[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\/([^/?#\\s]+)@/;\nconst URL_USERINFO = /([a-zA-Z][a-zA-Z0-9+.-]*:\\/\\/)([^/?#\\s]+)@/g;\nconst PASSWORD_QUERY_PARAMETER = /([?&][^=&#\\s]*password[^=&#\\s]*=)([^&#\\s]*)/gi;\nfunction hasUrlScheme(text) {\n\treturn URL_SCHEME.test(text);\n}\n/**\n* Reads the userinfo of a URL without parsing its hosts, so it works for URLs `new URL` rejects,\n* such as a seed list of several `host:port` pairs. The userinfo ends at the last `@` before the\n* first `/`, `?` or `#`.\n*/\nfunction urlUserinfo(url) {\n\treturn splitUserinfo(url.match(LEADING_URL_USERINFO)?.[1] ?? \"\");\n}\n/**\n* Reads the values of the query parameters whose key contains `password`, the same ones\n* `redactUrlCredentials` masks, without parsing hosts.\n*/\nfunction passwordQueryValues(url) {\n\treturn [...url.matchAll(PASSWORD_QUERY_PARAMETER)].map((match) => match[2] ?? \"\");\n}\n/**\n* Masks the userinfo and any password query parameter of every URL in `text`, without parsing\n* hosts. The masked form matches what `new URL` gives when its username and password are set to\n* `****`.\n*/\nfunction redactUrlCredentials(text) {\n\treturn text.replace(URL_USERINFO, (_match, scheme, userinfo) => `${scheme}${maskUserinfo(splitUserinfo(userinfo))}@`).replace(PASSWORD_QUERY_PARAMETER, `$1${MASK}`);\n}\nfunction splitUserinfo(userinfo) {\n\tconst colon = userinfo.indexOf(\":\");\n\tif (colon === -1) return {\n\t\tusername: userinfo,\n\t\tpassword: \"\"\n\t};\n\treturn {\n\t\tusername: userinfo.slice(0, colon),\n\t\tpassword: userinfo.slice(colon + 1)\n\t};\n}\nfunction maskUserinfo({ username, password }) {\n\treturn `${username ? MASK : \"\"}${password ? `:${MASK}` : \"\"}`;\n}\n//#endregion\n//#region src/utils/command-helpers.ts\nconst PASSWORD_QUERY_KEY = /password/i;\n/**\n* Resolves the absolute path to contract.json from the config.\n*/\nfunction resolveContractPath(config) {\n\tif (config.contract?.output === void 0) throw errorRuntime(\"CONFIG.VALIDATION_FAILED\", \"config.contract.output is required to resolve the contract path\", {\n\t\twhy: \"CLI commands read the emitted contract from config.contract.output; the config has no value to read.\",\n\t\tfix: \"Ensure your prisma.config.ts goes through `defineConfig()`, which normalises a default output when the provider supplies an input path, or set `contract.output` explicitly.\"\n\t});\n\treturn resolve(config.contract.output);\n}\n/**\n* Resolves the migrations directory and config path from CLI options.\n* Shared by migrate, migration-plan, and migration-status.\n*\n* - `migrationsDir` is the project's top-level `migrations/` directory\n* (the root that the aggregate loader walks for every contract space).\n* - `appMigrationsDir` is the app subspace directory under it\n* (`<migrationsDir>/<APP_SPACE_ID>/`). Every per-app reader / writer\n* (`migration new`, `migration plan`, `migrate`,\n* `migration status`, `migration show`, `migration ref`) operates on\n* this directory. Extensions own their own `migrations/<spaceId>/`.\n* - `refsDir` is the app's refs directory (`<appMigrationsDir>/refs/`).\n* The framework does not maintain refs at the migrations root.\n*\n* `cwd` is the directory the command was invoked from; every relative path in\n* the result is computed against it.\n*/\nfunction resolveMigrationPaths(config, cwd) {\n\tconst configPath = \"prisma.config.ts\";\n\tconst migrationsDir = migrationsDirFor(config, cwd);\n\tconst migrationsRelative = relative(cwd, migrationsDir);\n\tconst appMigrationsDir = spaceMigrationDirectory(migrationsDir, APP_SPACE_ID$1);\n\treturn {\n\t\tconfigPath,\n\t\tmigrationsDir,\n\t\tmigrationsRelative,\n\t\tappMigrationsDir,\n\t\tappMigrationsRelative: relative(cwd, appMigrationsDir),\n\t\trefsDir: resolve(appMigrationsDir, \"refs\")\n\t};\n}\nfunction collectDeclaredInvariants(graph) {\n\tconst declared = /* @__PURE__ */ new Set();\n\tfor (const edges of graph.forwardChain.values()) for (const edge of edges) for (const inv of edge.invariants) declared.add(inv);\n\treturn declared;\n}\n/**\n* Maps a `MigrationEdge` to the structural-edge shape used in the\n* `MIGRATION.NO_INVARIANT_PATH` error envelope. Shared between\n* `migrate` and `migration status` so both commands surface\n* the same JSON wire shape when an invariant-aware route is unsatisfiable.\n*/\nfunction toStructuralEdge(edge) {\n\treturn {\n\t\tdirName: edge.dirName,\n\t\tmigrationHash: edge.migrationHash,\n\t\tfrom: edge.from,\n\t\tto: edge.to,\n\t\tinvariants: edge.invariants\n\t};\n}\nfunction targetSupportsMigrations(target) {\n\treturn hasMigrations(target);\n}\n/**\n* Hangs up without letting the hang-up decide the command's result. A rejection out of a\n* `finally` replaces the value the `try`/`catch` already returned, so an unguarded close turns a\n* mapped connection error into an unmapped one — and that is the case it hits most, because a\n* `connect()` that failed leaves nothing to close.\n*/\nasync function closeQuietly(client) {\n\ttry {\n\t\tawait client.close();\n\t} catch {}\n}\nfunction getTargetMigrations(target) {\n\treturn hasMigrations(target) ? target.migrations : void 0;\n}\n/**\n* Reads and parses contract.json, validating the framework-level envelope\n* fields (storageHash, schemaVersion, target, targetFamily).\n*\n* Family-specific validation (storage structure, codec mappings, etc.)\n* happens downstream in the control client via the family instance.\n*/\nasync function readContractEnvelope(config) {\n\tconst contractPath = resolveContractPath(config);\n\tconst content = await readFile(contractPath, \"utf-8\");\n\tconst json = JSON.parse(content);\n\tconst { schemaVersion, target, targetFamily, profileHash } = json;\n\tconst storageHash = json[\"storage\"]?.[\"storageHash\"];\n\tif (typeof storageHash !== \"string\") throw new CliStructuredError$1(\"CONTRACT.VALIDATION_FAILED\", `Contract at ${relative(process.cwd(), contractPath)} is missing a valid storage.storageHash. Run \\`{bin} contract emit\\` to regenerate.`, { where: { path: contractPath } });\n\tif (typeof schemaVersion !== \"string\") throw new CliStructuredError$1(\"CONTRACT.VALIDATION_FAILED\", `Contract at ${relative(process.cwd(), contractPath)} is missing schemaVersion.`, { where: { path: contractPath } });\n\tif (typeof target !== \"string\") throw new CliStructuredError$1(\"CONTRACT.VALIDATION_FAILED\", `Contract at ${relative(process.cwd(), contractPath)} is missing target.`, { where: { path: contractPath } });\n\tif (typeof targetFamily !== \"string\") throw new CliStructuredError$1(\"CONTRACT.VALIDATION_FAILED\", `Contract at ${relative(process.cwd(), contractPath)} is missing targetFamily.`, { where: { path: contractPath } });\n\treturn {\n\t\t...json,\n\t\tstorageHash,\n\t\tschemaVersion,\n\t\ttarget,\n\t\ttargetFamily,\n\t\t...typeof profileHash === \"string\" ? { profileHash } : {}\n\t};\n}\n/**\n* Masks credentials in a database connection URL.\n* Handles standard URLs (username + password + query params), URLs `new URL` rejects (such as\n* multi-host URLs), and libpq-style key=value strings.\n*/\nfunction maskConnectionUrl(url) {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\tif (parsed.username) parsed.username = \"****\";\n\t\tif (parsed.password) parsed.password = \"****\";\n\t\tfor (const key of [...parsed.searchParams.keys()]) if (PASSWORD_QUERY_KEY.test(key)) parsed.searchParams.set(key, \"****\");\n\t\treturn parsed.toString();\n\t} catch {\n\t\treturn hasUrlScheme(url) ? redactUrlCredentials(url) : maskKeyValueCredentials(url);\n\t}\n}\n/**\n* Strips raw connection URL fragments from an error message to prevent credential leakage.\n* Call this before surfacing driver errors to the user.\n*/\nfunction sanitizeErrorMessage(message, connectionUrl) {\n\tif (!connectionUrl) return message;\n\tconst secrets = connectionUrlSecrets(connectionUrl);\n\tif (secrets === void 0) return maskKeyValueCredentials(message);\n\tlet sanitized = message.replaceAll(connectionUrl, maskConnectionUrl(connectionUrl));\n\tfor (const secret of secrets.filter(Boolean).sort(longestFirst)) sanitized = sanitized.replaceAll(secret, \"****\");\n\treturn sanitized;\n}\n/** A next action with the connection string removed from each of its strings. */\nfunction nextActionWithoutConnectionString(action, connectionUrl) {\n\tconst clean = (text) => sanitizeErrorMessage(text, connectionUrl);\n\treturn {\n\t\tkind: action.kind,\n\t\tlabel: clean(action.label),\n\t\t...ifDefined(\"command\", action.command === void 0 ? void 0 : clean(action.command)),\n\t\t...ifDefined(\"commands\", action.commands?.map(clean)),\n\t\t...ifDefined(\"url\", action.url === void 0 ? void 0 : clean(action.url)),\n\t\t...ifDefined(\"reason\", action.reason === void 0 ? void 0 : clean(action.reason))\n\t};\n}\n/** `meta` with the connection string removed from every string it holds, however deeply nested. */\nfunction metaWithoutConnectionString(meta, connectionUrl) {\n\tconst clean = (value) => {\n\t\tif (typeof value === \"string\") return sanitizeErrorMessage(value, connectionUrl);\n\t\tif (Array.isArray(value)) return value.map(clean);\n\t\tif (typeof value === \"object\" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, clean(entry)]));\n\t\treturn value;\n\t};\n\treturn Object.fromEntries(Object.entries(meta).map(([key, value]) => [key, clean(value)]));\n}\nfunction connectionUrlSecrets(connectionUrl) {\n\ttry {\n\t\tconst { username, password, searchParams } = new URL(connectionUrl);\n\t\treturn [\n\t\t\tusername,\n\t\t\tpassword,\n\t\t\t...[...searchParams].filter(([key]) => PASSWORD_QUERY_KEY.test(key)).map(([, value]) => value)\n\t\t];\n\t} catch {\n\t\tif (!hasUrlScheme(connectionUrl)) return;\n\t\tconst { username, password } = urlUserinfo(connectionUrl);\n\t\treturn [\n\t\t\tusername,\n\t\t\tpassword,\n\t\t\t...passwordQueryValues(connectionUrl)\n\t\t];\n\t}\n}\nfunction longestFirst(a, b) {\n\treturn b.length - a.length;\n}\nfunction maskKeyValueCredentials(text) {\n\treturn text.replace(/password\\s*=\\s*\\S+/gi, \"password=****\").replace(/user\\s*=\\s*\\S+/gi, \"user=****\");\n}\n//#endregion\n//#region src/control-api/operations/caught-errors.ts\n/**\n* The error a command reports for one it caught. A CLI error is reported as it is, and so is any other error a library raised with a structured code, such as `CONTRACT.DEFAULT_INVALID` for a stale contract's default or `CONTRACT.TYPE_PARAMS_INVALID` for its type parameters: the code says what went wrong better than the command can. An `InternalError` is thrown again, so the command boundary, `defineOrmCommand`, lets the engine report it as a bug. Anything else is reported as `CLI.UNEXPECTED` with the `why` the command gives for the error's message, and a `code` it carries that is not a structured one, such as a driver's `ECONNREFUSED` or a SQLSTATE, in `meta.code`.\n*\n* A command that holds a database connection passes its connection string, which is then removed from every string the reported error carries, whichever of those it is.\n*/\nfunction errorFromCaught(error, why, options = {}) {\n\tconst reported = reportedError(error, why);\n\treturn options.connection === void 0 ? reported : withoutConnectionString(reported, options.connection);\n}\n/** A structured error a library raised, reported under its own code, message and fields. */\nfunction cliErrorFromStructured(error) {\n\tif (CliStructuredError$1.is(error)) return error;\n\treturn new CliStructuredError$1(error.code, error.message, {\n\t\t...ifDefined(\"severity\", error.severity),\n\t\t...ifDefined(\"why\", error.why),\n\t\t...ifDefined(\"fix\", error.fix),\n\t\t...ifDefined(\"nextActions\", error.nextActions),\n\t\t...ifDefined(\"where\", error.where),\n\t\t...ifDefined(\"meta\", error.meta),\n\t\t...ifDefined(\"docsUrl\", error.docsUrl),\n\t\tcause: error\n\t});\n}\nfunction reportedError(error, why) {\n\tif (isInternalError(error)) throw error;\n\tif (CliStructuredError$1.is(error)) return error;\n\tif (isStructuredError(error)) return cliErrorFromStructured(error);\n\tconst message = error instanceof Error ? error.message : String(error);\n\tconst driverCode = error instanceof Error ? Reflect.get(error, \"code\") : void 0;\n\treturn errorUnexpected(message, {\n\t\twhy: why(message),\n\t\t...ifDefined(\"meta\", typeof driverCode === \"string\" ? { code: driverCode } : void 0),\n\t\tcause: error\n\t});\n}\nfunction withoutConnectionString(error, connection) {\n\tconst clean = (text) => sanitizeErrorMessage(text, connection);\n\treturn new CliStructuredError$1(error.code, clean(error.message), {\n\t\tseverity: error.severity,\n\t\t...ifDefined(\"why\", error.why === void 0 ? void 0 : clean(error.why)),\n\t\t...ifDefined(\"fix\", error.fix === void 0 ? void 0 : clean(error.fix)),\n\t\t...ifDefined(\"nextActions\", error.nextActions?.map((action) => nextActionWithoutConnectionString(action, connection))),\n\t\t...ifDefined(\"diagnostics\", error.diagnostics?.map((diagnostic) => diagnosticWithoutConnectionString(diagnostic, connection))),\n\t\t...ifDefined(\"where\", error.where),\n\t\t...ifDefined(\"meta\", error.meta === void 0 ? void 0 : metaWithoutConnectionString(error.meta, connection)),\n\t\t...ifDefined(\"docsUrl\", error.docsUrl),\n\t\tcause: error.cause\n\t});\n}\nfunction diagnosticWithoutConnectionString(diagnostic, connection) {\n\tconst clean = (text) => sanitizeErrorMessage(text, connection);\n\treturn {\n\t\t...diagnostic,\n\t\tsummary: clean(diagnostic.summary),\n\t\t...ifDefined(\"why\", diagnostic.why === void 0 ? void 0 : clean(diagnostic.why)),\n\t\tnextActions: diagnostic.nextActions.map((action) => nextActionWithoutConnectionString(action, connection)),\n\t\t...ifDefined(\"meta\", diagnostic.meta === void 0 ? void 0 : metaWithoutConnectionString(diagnostic.meta, connection))\n\t};\n}\n//#endregion\nexport { errorStatementDidNotResolveLoss as $, errorDatabaseConnectionRequired as A, errorNoMigrations as B, errorAmbiguousMigrationRef as C, errorContractConfigMissing as D, errorContractArgConflict as E, errorLegendHumanOnly as F, errorRefSetBundleNotFound as G, errorPlanForgotTheFlag as H, errorMarkerMismatch as I, errorRuntime as J, errorRefSetEmptySentinel as K, errorMarkerMissing as L, errorFileNotFound as M, errorHashMismatch as N, errorContractValidationFailed as O, errorInvalidSpaceId as P, errorStatementAnswersNoQuestion as Q, errorMigrationPackageNotFound as R, errorAdvanceRefArgConflict as S, errorConsentUnused as T, errorPlanOriginUnknown as U, errorPathUnreachable as V, errorPlanProducedNoOperations as W, errorSnapshotMissing as X, errorSignRefsNotWritten as Y, errorSpaceNotFound as Z, displayPath as _, shellQuoted as _t, getTargetMigrations as a, errorTargetMismatch as at, CliStructuredError$1 as b, resolveContractPath as c, requireLiveDatabase as ct, toStructuralEdge as d, printedPath as dt, errorStatementInvalid as et, redactUrlCredentials as f, printedPlanCommand as ft, contractPathFor as g, runCommandAction as gt, baseDirFor as h, editFileAction as ht, collectDeclaredInvariants as i, errorTargetMigrationNotSupported as it, errorDriverRequired as j, errorConvertAndDelete as k, resolveMigrationPaths as l, cliCommand as lt, appRefsDirFor as m, chooseAction as mt, errorFromCaught as n, errorStatementOriginUnknown as nt, maskConnectionUrl as o, errorUnexpected as ot, appMigrationsDirFor as p, selfEmitCommand as pt, errorRefSetHashNotInGraph as q, closeQuietly as r, errorStatementUnresolved as rt, readContractEnvelope as s, mapRefResolutionError as st, cliErrorFromStructured as t, errorStatementNeedsMigrationFile as tt, targetSupportsMigrations as u, cliInvocation as ut, migrationsDirFor as v, statementFlag as vt, errorConfigValidation as w, STORE_ORIGIN_SNAPSHOT_STEPS as x, ActionableCliError as y, errorMigrationPlanningFailed as z };\n\n//# sourceMappingURL=caught-errors-Bmbi1dBu.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,aAAa;;AAEnB,SAAS,YAAY,OAAO;CAC3B,OAAO,WAAW,KAAK,KAAK,IAAI,QAAQ,IAAI,MAAM,WAAW,KAAK,OAAO,EAAE;AAC5E;;;;;;AAMA,SAAS,cAAc,WAAW;CACjC,MAAM,QAAQ,YAAY,UAAU,IAAI;CACxC,OAAO,UAAU,KAAK,WAAW,GAAG,IAAI,KAAK,UAAU,KAAK,GAAG,UAAU,KAAK,UAAU,KAAK,GAAG;AACjG;;;;;;AAQA,SAAS,iBAAiB,OAAO,SAAS;CACzC,OAAO;EACN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AAO;EACrC,OAAO,MAAM;CACd,CAAC;AACF;AACA,SAAS,kCAAkC,YAAY,YAAY;CAClE,MAAM,SAAS,SAAS,qBAAqB,MAAM,UAAU;CAC7D,OAAO;EACN,GAAG;EACH,SAAS,MAAM,WAAW,OAAO;EACjC,GAAG,UAAU,OAAO,WAAW,QAAQ,KAAK,IAAI,KAAK,IAAI,MAAM,WAAW,GAAG,CAAC;EAC9E,aAAa,WAAW,YAAY,KAAK,WAAW,kCAAkC,QAAQ,UAAU,CAAC;EACzG,GAAG,UAAU,QAAQ,WAAW,SAAS,KAAK,IAAI,KAAK,IAAI,4BAA4B,WAAW,MAAM,UAAU,CAAC;CACpH;AACD"}
|
package/dist/cli-telemetry.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ declare const TELEMETRY_BACKEND_URL = "https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.pri
|
|
|
11
11
|
declare const TELEMETRY_ENDPOINT_PATH = "/events";
|
|
12
12
|
/**
|
|
13
13
|
* Resolve the full POST URL the sender targets. The
|
|
14
|
-
* `
|
|
14
|
+
* `PRISMA_TELEMETRY_ENDPOINT` env var is an integration-testing
|
|
15
15
|
* affordance only — it lets the test suite spin up a mock HTTP server
|
|
16
16
|
* on an ephemeral port and point the spawned sender at it. The override
|
|
17
17
|
* is intentionally undocumented in user-facing material.
|
|
@@ -122,12 +122,12 @@ interface ProjectConfigFields {
|
|
|
122
122
|
* Best-effort load of `prisma.config.*` from `projectRoot`,
|
|
123
123
|
* validated against the canonical `@internal/config` schema.
|
|
124
124
|
* Returns `{ databaseTarget: null, extensions: [] }` on any failure
|
|
125
|
-
* mode — missing config file (e.g. before `prisma
|
|
125
|
+
* mode — missing config file (e.g. before `prisma orm init`), c12
|
|
126
126
|
* throws while evaluating user TS, validator rejects a malformed
|
|
127
127
|
* shape, etc. Telemetry is non-blocking and best-effort; an empty
|
|
128
128
|
* result is the only downside of an unloadable or invalid config.
|
|
129
129
|
*
|
|
130
|
-
* Both `c12` and
|
|
130
|
+
* Both `c12` and the config loader are imported
|
|
131
131
|
* lazily so the detached sender's cold-start cost is paid only when
|
|
132
132
|
* telemetry actually fires, not on every fork even when gates
|
|
133
133
|
* short-circuit before reaching this code path.
|
|
@@ -206,7 +206,7 @@ interface GatingInputs {
|
|
|
206
206
|
/**
|
|
207
207
|
* Environment-variable lookups the resolver consults. Tests pass a
|
|
208
208
|
* literal record; production passes `process.env`. The two opt-out
|
|
209
|
-
* signals are `
|
|
209
|
+
* signals are `PRISMA_DISABLE_TELEMETRY` (Prisma-specific) and
|
|
210
210
|
* `DO_NOT_TRACK` (community convention).
|
|
211
211
|
*/
|
|
212
212
|
readonly env: Readonly<Record<string, string | undefined>>;
|
|
@@ -219,7 +219,8 @@ interface GatingInputs {
|
|
|
219
219
|
* user config.
|
|
220
220
|
*
|
|
221
221
|
* Decision order:
|
|
222
|
-
* 1. Env-var override (`
|
|
222
|
+
* 1. Env-var override (`PRISMA_DISABLE_TELEMETRY` truthy, its
|
|
223
|
+
* `PRISMA_NEXT_DISABLE_TELEMETRY` spelling from earlier releases, or
|
|
223
224
|
* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an
|
|
224
225
|
* opt-out env var wins over any stored or unset preference.
|
|
225
226
|
* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).
|
|
@@ -253,7 +254,7 @@ interface CommanderResultShape {
|
|
|
253
254
|
/**
|
|
254
255
|
* The full command path from the root program to the leaf, including
|
|
255
256
|
* the root program name as the first element (the sanitiser drops it).
|
|
256
|
-
* Example: `['prisma
|
|
257
|
+
* Example: `['prisma', 'migration', 'new']`.
|
|
257
258
|
*/
|
|
258
259
|
readonly commandPath: readonly string[];
|
|
259
260
|
/**
|
|
@@ -287,7 +288,7 @@ interface SanitisedCommand {
|
|
|
287
288
|
*
|
|
288
289
|
* Sanitiser contract — no flag values, no positionals, no raw argv:
|
|
289
290
|
* - Drop the root program name (`commandPath[0]`); the wire ships
|
|
290
|
-
* `migration new`, not `prisma
|
|
291
|
+
* `migration new`, not `prisma migration new`.
|
|
291
292
|
* - Emit only options whose Commander source is `cli`.
|
|
292
293
|
* - Emit the long user-facing flag spelling without the `--` prefix;
|
|
293
294
|
* never emit Commander's camelCase attribute names.
|
|
@@ -355,7 +356,7 @@ interface RunTelemetryInputs {
|
|
|
355
356
|
* the fork runs in the background and never blocks the parent. Every
|
|
356
357
|
* failure mode is swallowed; the parent's stdout/stderr is untouched in
|
|
357
358
|
* normal operation, the only escape valve being
|
|
358
|
-
* `
|
|
359
|
+
* `PRISMA_DEBUG=1` which routes diagnostics to stderr.
|
|
359
360
|
*
|
|
360
361
|
* Returns the spawn outcome so debug-mode logging and the test-harness
|
|
361
362
|
* probe (which verifies test runs short-circuit the fork) can inspect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-telemetry.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.d.mts"],"mappings":";;;;;;cAKc;;;;cAIA;;;;;;;;;;;;iBAYG,yBAAyB,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgC/C;WACC;WACA;WACA;WACA;;;;;;;WAOA;;WAEA;;;;;;;;;;;WAWA;;;;;;;;WAQA;;;;;;UAMD;WACC;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;;UAUD;WACC;WACA;;;;;;;;;;;;;;;;iBAgBM,kBAAkB,sBAAsB,QAAQ;;;;;;;;;;;;;;UAcvD;WACC;WACA;YACC;;;;;;iBAMK;;;;;;iBAMA,kBAAkB;;;;;;;;;;;;;;;;iBAgBlB,gBAAgB,SAAS,QAAQ;;;;;;;;;;;iBAWjC;;;;;;;KAOZ;KACA;WACM;;WAEA;WACA,QAAQ;;UAET;;;;;;;WAOC,KAAK,SAAS;;WAEd,QAAQ
|
|
1
|
+
{"version":3,"file":"cli-telemetry.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.d.mts"],"mappings":";;;;;;cAKc;;;;cAIA;;;;;;;;;;;;iBAYG,yBAAyB,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAgC/C;WACC;WACA;WACA;WACA;;;;;;;WAOA;;WAEA;;;;;;;;;;;WAWA;;;;;;;;WAQA;;;;;;UAMD;WACC;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;;;;;;UAUD;WACC;WACA;;;;;;;;;;;;;;;;iBAgBM,kBAAkB,sBAAsB,QAAQ;;;;;;;;;;;;;;UAcvD;WACC;WACA;YACC;;;;;;iBAMK;;;;;;iBAMA,kBAAkB;;;;;;;;;;;;;;;;iBAgBlB,gBAAgB,SAAS,QAAQ;;;;;;;;;;;iBAWjC;;;;;;;KAOZ;KACA;WACM;;WAEA;WACA,QAAQ;;UAET;;;;;;;WAOC,KAAK,SAAS;;WAEd,QAAQ;;;;;;;;;;;;;;;;;;;;;;iBAsBF,cAAc,QAAQ,eAAe;;;UAG5C;;WAEC;;WAEA;;WAEA;;;;;;;;UAQD;;;;;;WAMC;;;;;;;WAOA;;;;;;;WAOA,kBAAkB;;;;;;;UAOnB;WACC;WACA;;;;;;;;;;;;;;;;;iBAiBM,wBAAwB,OAAO,uBAAuB;;;;;;;;;;;;;;;;;;;UAmB7D;;WAEC,SAAS;;WAET;;WAEA;;;;;;WAMA;;;;;WAKA;;;;;;;WAOA;;;;;;WAMA;;WAEA,MAAM,SAAS;;WAEf,aAAa;;;;;;;;;;;;;KAanB;WACM;;WAEA;WACA;;iBAEM,aAAa,QAAQ,qBAAqB;;;;;;;;iBAQ1C,gBAAgB"}
|
package/dist/cli-telemetry.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
2
|
-
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
3
2
|
import { dirname, join } from "pathe";
|
|
4
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
8
|
import { fork } from "node:child_process";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
9
|
import "@vercel/detect-agent";
|
|
10
|
-
//#region ../../../1-framework/3-tooling/cli-telemetry/dist/enrich-
|
|
10
|
+
//#region ../../../1-framework/3-tooling/cli-telemetry/dist/enrich-CJ5LlTek.mjs
|
|
11
11
|
const EMPTY_PROJECT_CONFIG = {
|
|
12
12
|
databaseTarget: null,
|
|
13
13
|
extensions: []
|
|
@@ -16,12 +16,12 @@ const EMPTY_PROJECT_CONFIG = {
|
|
|
16
16
|
* Best-effort load of `prisma.config.*` from `projectRoot`,
|
|
17
17
|
* validated against the canonical `@internal/config` schema.
|
|
18
18
|
* Returns `{ databaseTarget: null, extensions: [] }` on any failure
|
|
19
|
-
* mode — missing config file (e.g. before `prisma
|
|
19
|
+
* mode — missing config file (e.g. before `prisma orm init`), c12
|
|
20
20
|
* throws while evaluating user TS, validator rejects a malformed
|
|
21
21
|
* shape, etc. Telemetry is non-blocking and best-effort; an empty
|
|
22
22
|
* result is the only downside of an unloadable or invalid config.
|
|
23
23
|
*
|
|
24
|
-
* Both `c12` and
|
|
24
|
+
* Both `c12` and the config loader are imported
|
|
25
25
|
* lazily so the detached sender's cold-start cost is paid only when
|
|
26
26
|
* telemetry actually fires, not on every fork even when gates
|
|
27
27
|
* short-circuit before reaching this code path.
|
|
@@ -36,17 +36,19 @@ async function loadProjectConfig(projectRoot) {
|
|
|
36
36
|
rcFile: false,
|
|
37
37
|
globalRc: false
|
|
38
38
|
});
|
|
39
|
-
let
|
|
40
|
-
if (!result.config || Object.keys(result.config).length === 0) result = await load("prisma-next");
|
|
41
|
-
let config = result.config ?? null;
|
|
39
|
+
let config = (await load("prisma")).config ?? null;
|
|
42
40
|
if (config === null || Object.keys(config).length === 0) return EMPTY_PROJECT_CONFIG;
|
|
43
|
-
if (config["$prismaConfig"]
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
if (config["$prismaConfig"] === void 0) return EMPTY_PROJECT_CONFIG;
|
|
42
|
+
const orm = config["orm"];
|
|
43
|
+
if (orm === null || typeof orm !== "object" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;
|
|
44
|
+
config = blindCast(orm);
|
|
45
|
+
const { validateOrmSection } = await import("./exports-BlYTE3-J.mjs").then((n) => n.o);
|
|
46
|
+
const validation = validateOrmSection(config, {
|
|
47
|
+
files: [],
|
|
48
|
+
keys: {}
|
|
49
|
+
});
|
|
50
|
+
if (!validation.ok) return EMPTY_PROJECT_CONFIG;
|
|
51
|
+
const validConfig = validation.value;
|
|
50
52
|
return {
|
|
51
53
|
databaseTarget: validConfig.target.targetId,
|
|
52
54
|
extensions: (validConfig.extensions ?? []).map((pack) => pack.id)
|
|
@@ -68,7 +70,7 @@ const TELEMETRY_BACKEND_URL = "https://cmpbfbsdp09hr3jf7pojjs5qs.ewr.prisma.buil
|
|
|
68
70
|
const TELEMETRY_ENDPOINT_PATH = "/events";
|
|
69
71
|
/**
|
|
70
72
|
* Resolve the full POST URL the sender targets. The
|
|
71
|
-
* `
|
|
73
|
+
* `PRISMA_TELEMETRY_ENDPOINT` env var is an integration-testing
|
|
72
74
|
* affordance only — it lets the test suite spin up a mock HTTP server
|
|
73
75
|
* on an ephemeral port and point the spawned sender at it. The override
|
|
74
76
|
* is intentionally undocumented in user-facing material.
|
|
@@ -78,7 +80,7 @@ const TELEMETRY_ENDPOINT_PATH = "/events";
|
|
|
78
80
|
* matching the telemetry layer's broader silent-on-failure contract.
|
|
79
81
|
*/
|
|
80
82
|
function resolveTelemetryEndpoint(env = process.env) {
|
|
81
|
-
const override = env["
|
|
83
|
+
const override = env["PRISMA_TELEMETRY_ENDPOINT"];
|
|
82
84
|
const base = override !== void 0 && override.length > 0 ? override : TELEMETRY_BACKEND_URL;
|
|
83
85
|
try {
|
|
84
86
|
return new URL(TELEMETRY_ENDPOINT_PATH, base).toString();
|
|
@@ -87,7 +89,7 @@ function resolveTelemetryEndpoint(env = process.env) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
90
|
-
* A `
|
|
92
|
+
* A `PRISMA_DISABLE_TELEMETRY` value counts as an opt-out only if
|
|
91
93
|
* it parses as a truthy string. The set-but-falsy spellings (`''`,
|
|
92
94
|
* `'0'`, `'false'`) are intentionally treated as not-set so a parent
|
|
93
95
|
* shell that exports the variable to a benign value doesn't accidentally
|
|
@@ -107,7 +109,8 @@ function isTruthyOptOut(raw) {
|
|
|
107
109
|
* user config.
|
|
108
110
|
*
|
|
109
111
|
* Decision order:
|
|
110
|
-
* 1. Env-var override (`
|
|
112
|
+
* 1. Env-var override (`PRISMA_DISABLE_TELEMETRY` truthy, its
|
|
113
|
+
* `PRISMA_NEXT_DISABLE_TELEMETRY` spelling from earlier releases, or
|
|
111
114
|
* `DO_NOT_TRACK=1`) → disabled. The env check runs first, so an
|
|
112
115
|
* opt-out env var wins over any stored or unset preference.
|
|
113
116
|
* 2. Stored `enableTelemetry === false` → disabled (`stored-opt-out`).
|
|
@@ -121,7 +124,7 @@ function isTruthyOptOut(raw) {
|
|
|
121
124
|
* `enableTelemetry` is explicitly `false`.
|
|
122
125
|
*/
|
|
123
126
|
function resolveGating(inputs) {
|
|
124
|
-
if (isTruthyOptOut(inputs.env["PRISMA_NEXT_DISABLE_TELEMETRY"]) || inputs.env["DO_NOT_TRACK"] === "1") return {
|
|
127
|
+
if (isTruthyOptOut(inputs.env["PRISMA_DISABLE_TELEMETRY"]) || isTruthyOptOut(inputs.env["PRISMA_NEXT_DISABLE_TELEMETRY"]) || inputs.env["DO_NOT_TRACK"] === "1") return {
|
|
125
128
|
enabled: false,
|
|
126
129
|
reason: "env-override"
|
|
127
130
|
};
|
|
@@ -143,7 +146,7 @@ function flagNameFromLongName(longName) {
|
|
|
143
146
|
*
|
|
144
147
|
* Sanitiser contract — no flag values, no positionals, no raw argv:
|
|
145
148
|
* - Drop the root program name (`commandPath[0]`); the wire ships
|
|
146
|
-
* `migration new`, not `prisma
|
|
149
|
+
* `migration new`, not `prisma migration new`.
|
|
147
150
|
* - Emit only options whose Commander source is `cli`.
|
|
148
151
|
* - Emit the long user-facing flag spelling without the `--` prefix;
|
|
149
152
|
* never emit Commander's camelCase attribute names.
|
|
@@ -161,13 +164,13 @@ function sanitizeCommanderResult(input) {
|
|
|
161
164
|
})
|
|
162
165
|
};
|
|
163
166
|
}
|
|
164
|
-
const APP_DIR = "prisma-
|
|
167
|
+
const APP_DIR = "prisma-8";
|
|
165
168
|
const FILE_NAME = "config.json";
|
|
166
169
|
/**
|
|
167
170
|
* Resolves the user-level config directory:
|
|
168
|
-
* - Windows: `%APPDATA%\prisma-
|
|
169
|
-
* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-
|
|
170
|
-
* `$HOME/.config/prisma-
|
|
171
|
+
* - Windows: `%APPDATA%\prisma-8\` (fallback: `%USERPROFILE%\AppData\Roaming\prisma-8\`).
|
|
172
|
+
* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-8/` if set, else
|
|
173
|
+
* `$HOME/.config/prisma-8/` per the XDG Base Directory Specification.
|
|
171
174
|
*
|
|
172
175
|
* The spec deliberately picks XDG over the macOS-native
|
|
173
176
|
* `~/Library/Preferences/` convention so the path resolution is
|
|
@@ -299,13 +302,13 @@ function runTelemetry(inputs) {
|
|
|
299
302
|
]
|
|
300
303
|
});
|
|
301
304
|
child.send(payload, (err) => {
|
|
302
|
-
if (err !== null && process.env["
|
|
305
|
+
if (err !== null && process.env["PRISMA_DEBUG"] === "1") process.stderr.write(`[cli-telemetry] parent send error: ${String(err)}\n`);
|
|
303
306
|
});
|
|
304
307
|
child.disconnect();
|
|
305
308
|
child.unref();
|
|
306
309
|
return { spawned: true };
|
|
307
310
|
} catch (err) {
|
|
308
|
-
if (process.env["
|
|
311
|
+
if (process.env["PRISMA_DEBUG"] === "1") process.stderr.write(`[cli-telemetry] parent fork failed: ${String(err)}\n`);
|
|
309
312
|
return {
|
|
310
313
|
spawned: false,
|
|
311
314
|
reason: "fork-failed"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-telemetry.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/enrich-IkV4Zai4.mjs","../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.mjs"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { determineAgent } from \"@vercel/detect-agent\";\nimport { join } from \"pathe\";\n//#region src/enrich.ts\nconst EMPTY_PROJECT_CONFIG = {\n\tdatabaseTarget: null,\n\textensions: []\n};\n/**\n* Best-effort load of `prisma.config.*` from `projectRoot`,\n* validated against the canonical `@internal/config` schema.\n* Returns `{ databaseTarget: null, extensions: [] }` on any failure\n* mode — missing config file (e.g. before `prisma-next init`), c12\n* throws while evaluating user TS, validator rejects a malformed\n* shape, etc. Telemetry is non-blocking and best-effort; an empty\n* result is the only downside of an unloadable or invalid config.\n*\n* Both `c12` and `@internal/config/config-validation` are imported\n* lazily so the detached sender's cold-start cost is paid only when\n* telemetry actually fires, not on every fork even when gates\n* short-circuit before reaching this code path.\n*/\nasync function loadProjectConfig(projectRoot) {\n\ttry {\n\t\tconst { loadConfig } = await import(\"c12\");\n\t\tconst load = (name) => loadConfig({\n\t\t\tname,\n\t\t\tcwd: projectRoot,\n\t\t\tdotenv: false,\n\t\t\trcFile: false,\n\t\t\tglobalRc: false\n\t\t});\n\t\tlet result = await load(\"prisma\");\n\t\tif (!result.config || Object.keys(result.config).length === 0) result = await load(\"prisma-next\");\n\t\tlet config = result.config ?? null;\n\t\tif (config === null || Object.keys(config).length === 0) return EMPTY_PROJECT_CONFIG;\n\t\tif (config[\"$prismaConfig\"] !== void 0) {\n\t\t\tconst orm = config[\"orm\"];\n\t\t\tif (orm === null || typeof orm !== \"object\" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;\n\t\t\tconfig = blindCast(orm);\n\t\t}\n\t\tif ((await import(\"@internal/config/config-validation\")).collectConfigIssues(config).length > 0) return EMPTY_PROJECT_CONFIG;\n\t\tconst validConfig = blindCast(config);\n\t\treturn {\n\t\t\tdatabaseTarget: validConfig.target.targetId,\n\t\t\textensions: (validConfig.extensions ?? []).map((pack) => pack.id)\n\t\t};\n\t} catch {\n\t\treturn EMPTY_PROJECT_CONFIG;\n\t}\n}\n/**\n* Identify the runtime the sender is running in. Same-runtime as the\n* parent is a correctness requirement: the parent forked us via\n* `child_process.fork`, which inherits the parent's runtime. Detection\n* keys on the runtime-specific version field rather than env vars so a\n* spoofed env can't lie about the actual interpreter.\n*/\nfunction resolveRuntime(versions) {\n\tif (versions.bun !== void 0) return {\n\t\tname: \"bun\",\n\t\tversion: versions.bun\n\t};\n\tif (versions.deno !== void 0) return {\n\t\tname: \"deno\",\n\t\tversion: versions.deno\n\t};\n\treturn {\n\t\tname: \"node\",\n\t\tversion: versions.node\n\t};\n}\n/**\n* Parse `npm_config_user_agent` into a `<pm>/<version>` token. The\n* value, when present, looks like\n* `\"pnpm/10.27.0 npm/? node/v24.13.0 darwin arm64\"` — we take the first\n* whitespace-separated token. Any failure → `null`.\n*/\nfunction parsePackageManager(userAgent) {\n\tif (userAgent === void 0) return null;\n\tconst first = userAgent.split(/\\s+/)[0];\n\tif (first === void 0 || first.length === 0) return null;\n\tif (!first.includes(\"/\")) return null;\n\treturn first;\n}\n/**\n* Read the user's project `package.json` and resolve a TypeScript\n* version from `devDependencies.typescript` (preferred) or\n* `dependencies.typescript`. Strips a leading `^` or `~` semver\n* prefix. Returns `null` on any failure mode — file missing,\n* unreadable, malformed JSON, key absent, not a string.\n*/\nfunction readTsVersionFromPackageJson(raw) {\n\tif (raw === null) return null;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n\tconst candidate = pickStringDep(parsed[\"devDependencies\"]) ?? pickStringDep(parsed[\"dependencies\"]);\n\tif (candidate === null) return null;\n\treturn candidate.replace(/^[\\^~]/, \"\");\n}\nfunction pickStringDep(deps) {\n\tif (deps === null || typeof deps !== \"object\" || Array.isArray(deps)) return null;\n\tconst value = deps[\"typescript\"];\n\treturn typeof value === \"string\" ? value : null;\n}\n/**\n* Build the full backend event from the parent's payload, the\n* c12-loaded project-config slice, and the child's per-process\n* snapshot. Pure given a `projectConfig` + `EnrichEnvironment`.\n*/\nfunction buildTelemetryEvent(payload, projectConfig, env) {\n\tconst runtime = resolveRuntime(env.versions);\n\treturn {\n\t\tinstallationId: payload.installationId,\n\t\tversion: payload.version,\n\t\tcommand: payload.command,\n\t\tflags: payload.flags,\n\t\truntimeName: runtime.name,\n\t\truntimeVersion: runtime.version,\n\t\tos: env.platform,\n\t\tarch: env.arch,\n\t\tpackageManager: parsePackageManager(env.env[\"npm_config_user_agent\"]),\n\t\tdatabaseTarget: projectConfig.databaseTarget,\n\t\ttsVersion: readTsVersionFromPackageJson(env.readProjectPackageJson()),\n\t\tagent: env.agent,\n\t\textensions: projectConfig.extensions,\n\t\texitCode: payload.exitCode ?? null\n\t};\n}\n/**\n* Resolve the agent label for the telemetry event via\n* `@vercel/detect-agent`, collapsing its discriminated result to the\n* event's `string | null` shape. Any detection failure counts as\n* \"no agent\" — telemetry is best-effort and non-blocking.\n*/\nasync function resolveAgentLabel() {\n\ttry {\n\t\tconst result = await determineAgent();\n\t\treturn result.isAgent ? result.agent.name : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Convenience for the sender entry: build the event from the live\n* `process` plus a c12 load of `prisma.config.*` from\n* `payload.projectRoot` plus a real project-package.json reader,\n* swallowing any I/O errors in the file read.\n*\n* The parent's `payload.databaseTarget` (when present) wins over the\n* c12-derived value. The parent sets this for the first-`init` run,\n* where the config file does not exist on disk yet but the user has\n* just declared a target via the consent prompt; every other\n* invocation leaves it unset and the c12 load supplies the value.\n*/\nasync function buildTelemetryEventFromProcess(payload) {\n\tconst loadedConfig = await loadProjectConfig(payload.projectRoot);\n\treturn buildTelemetryEvent(payload, {\n\t\tdatabaseTarget: payload.databaseTarget ?? loadedConfig.databaseTarget,\n\t\textensions: loadedConfig.extensions\n\t}, {\n\t\tplatform: process.platform,\n\t\tarch: process.arch,\n\t\tversions: process.versions,\n\t\tenv: process.env,\n\t\tagent: await resolveAgentLabel(),\n\t\treadProjectPackageJson: () => {\n\t\t\ttry {\n\t\t\t\treturn readFileSync(join(payload.projectRoot, \"package.json\"), \"utf-8\");\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t});\n}\n//#endregion\nexport { loadProjectConfig as n, buildTelemetryEventFromProcess as t };\n\n//# sourceMappingURL=enrich-IkV4Zai4.mjs.map","import { n as loadProjectConfig } from \"../enrich-IkV4Zai4.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\t...ifDefined(\"exitCode\", inputs.exitCode)\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":";;;;;;;;;;AAKA,MAAM,uBAAuB;CAC5B,gBAAgB;CAChB,YAAY,CAAC;AACd;;;;;;;;;;;;;;;AAeA,e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AI,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;EACpD,GAAG,UAAU,YAAY,OAAO,QAAQ;CACzC;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
|
+
{"version":3,"file":"cli-telemetry.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli-telemetry/dist/enrich-CJ5LlTek.mjs","../../../../1-framework/3-tooling/cli-telemetry/dist/exports/index.mjs"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { determineAgent } from \"@vercel/detect-agent\";\nimport { join } from \"pathe\";\n//#region src/enrich.ts\nconst EMPTY_PROJECT_CONFIG = {\n\tdatabaseTarget: null,\n\textensions: []\n};\n/**\n* Best-effort load of `prisma.config.*` from `projectRoot`,\n* validated against the canonical `@internal/config` schema.\n* Returns `{ databaseTarget: null, extensions: [] }` on any failure\n* mode — missing config file (e.g. before `prisma orm init`), c12\n* throws while evaluating user TS, validator rejects a malformed\n* shape, etc. Telemetry is non-blocking and best-effort; an empty\n* result is the only downside of an unloadable or invalid config.\n*\n* Both `c12` and the config loader are imported\n* lazily so the detached sender's cold-start cost is paid only when\n* telemetry actually fires, not on every fork even when gates\n* short-circuit before reaching this code path.\n*/\nasync function loadProjectConfig(projectRoot) {\n\ttry {\n\t\tconst { loadConfig } = await import(\"c12\");\n\t\tconst load = (name) => loadConfig({\n\t\t\tname,\n\t\t\tcwd: projectRoot,\n\t\t\tdotenv: false,\n\t\t\trcFile: false,\n\t\t\tglobalRc: false\n\t\t});\n\t\tlet config = (await load(\"prisma\")).config ?? null;\n\t\tif (config === null || Object.keys(config).length === 0) return EMPTY_PROJECT_CONFIG;\n\t\tif (config[\"$prismaConfig\"] === void 0) return EMPTY_PROJECT_CONFIG;\n\t\tconst orm = config[\"orm\"];\n\t\tif (orm === null || typeof orm !== \"object\" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;\n\t\tconfig = blindCast(orm);\n\t\tconst { validateOrmSection } = await import(\"@internal/config-loader\");\n\t\tconst validation = validateOrmSection(config, {\n\t\t\tfiles: [],\n\t\t\tkeys: {}\n\t\t});\n\t\tif (!validation.ok) return EMPTY_PROJECT_CONFIG;\n\t\tconst validConfig = validation.value;\n\t\treturn {\n\t\t\tdatabaseTarget: validConfig.target.targetId,\n\t\t\textensions: (validConfig.extensions ?? []).map((pack) => pack.id)\n\t\t};\n\t} catch {\n\t\treturn EMPTY_PROJECT_CONFIG;\n\t}\n}\n/**\n* Identify the runtime the sender is running in. Same-runtime as the\n* parent is a correctness requirement: the parent forked us via\n* `child_process.fork`, which inherits the parent's runtime. Detection\n* keys on the runtime-specific version field rather than env vars so a\n* spoofed env can't lie about the actual interpreter.\n*/\nfunction resolveRuntime(versions) {\n\tif (versions.bun !== void 0) return {\n\t\tname: \"bun\",\n\t\tversion: versions.bun\n\t};\n\tif (versions.deno !== void 0) return {\n\t\tname: \"deno\",\n\t\tversion: versions.deno\n\t};\n\treturn {\n\t\tname: \"node\",\n\t\tversion: versions.node\n\t};\n}\n/**\n* Parse `npm_config_user_agent` into a `<pm>/<version>` token. The\n* value, when present, looks like\n* `\"pnpm/10.27.0 npm/? node/v24.13.0 darwin arm64\"` — we take the first\n* whitespace-separated token. Any failure → `null`.\n*/\nfunction parsePackageManager(userAgent) {\n\tif (userAgent === void 0) return null;\n\tconst first = userAgent.split(/\\s+/)[0];\n\tif (first === void 0 || first.length === 0) return null;\n\tif (!first.includes(\"/\")) return null;\n\treturn first;\n}\n/**\n* Read the user's project `package.json` and resolve a TypeScript\n* version from `devDependencies.typescript` (preferred) or\n* `dependencies.typescript`. Strips a leading `^` or `~` semver\n* prefix. Returns `null` on any failure mode — file missing,\n* unreadable, malformed JSON, key absent, not a string.\n*/\nfunction readTsVersionFromPackageJson(raw) {\n\tif (raw === null) return null;\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n\tconst candidate = pickStringDep(parsed[\"devDependencies\"]) ?? pickStringDep(parsed[\"dependencies\"]);\n\tif (candidate === null) return null;\n\treturn candidate.replace(/^[\\^~]/, \"\");\n}\nfunction pickStringDep(deps) {\n\tif (deps === null || typeof deps !== \"object\" || Array.isArray(deps)) return null;\n\tconst value = deps[\"typescript\"];\n\treturn typeof value === \"string\" ? value : null;\n}\n/**\n* Build the full backend event from the parent's payload, the\n* c12-loaded project-config slice, and the child's per-process\n* snapshot. Pure given a `projectConfig` + `EnrichEnvironment`.\n*/\nfunction buildTelemetryEvent(payload, projectConfig, env) {\n\tconst runtime = resolveRuntime(env.versions);\n\treturn {\n\t\tinstallationId: payload.installationId,\n\t\tversion: payload.version,\n\t\tcommand: payload.command,\n\t\tflags: payload.flags,\n\t\truntimeName: runtime.name,\n\t\truntimeVersion: runtime.version,\n\t\tos: env.platform,\n\t\tarch: env.arch,\n\t\tpackageManager: parsePackageManager(env.env[\"npm_config_user_agent\"]),\n\t\tdatabaseTarget: projectConfig.databaseTarget,\n\t\ttsVersion: readTsVersionFromPackageJson(env.readProjectPackageJson()),\n\t\tagent: env.agent,\n\t\textensions: projectConfig.extensions,\n\t\texitCode: payload.exitCode ?? null\n\t};\n}\n/**\n* Resolve the agent label for the telemetry event via\n* `@vercel/detect-agent`, collapsing its discriminated result to the\n* event's `string | null` shape. Any detection failure counts as\n* \"no agent\" — telemetry is best-effort and non-blocking.\n*/\nasync function resolveAgentLabel() {\n\ttry {\n\t\tconst result = await determineAgent();\n\t\treturn result.isAgent ? result.agent.name : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n/**\n* Convenience for the sender entry: build the event from the live\n* `process` plus a c12 load of `prisma.config.*` from\n* `payload.projectRoot` plus a real project-package.json reader,\n* swallowing any I/O errors in the file read.\n*\n* The parent's `payload.databaseTarget` (when present) wins over the\n* c12-derived value. The parent sets this for the first-`init` run,\n* where the config file does not exist on disk yet but the user has\n* just declared a target via the consent prompt; every other\n* invocation leaves it unset and the c12 load supplies the value.\n*/\nasync function buildTelemetryEventFromProcess(payload) {\n\tconst loadedConfig = await loadProjectConfig(payload.projectRoot);\n\treturn buildTelemetryEvent(payload, {\n\t\tdatabaseTarget: payload.databaseTarget ?? loadedConfig.databaseTarget,\n\t\textensions: loadedConfig.extensions\n\t}, {\n\t\tplatform: process.platform,\n\t\tarch: process.arch,\n\t\tversions: process.versions,\n\t\tenv: process.env,\n\t\tagent: await resolveAgentLabel(),\n\t\treadProjectPackageJson: () => {\n\t\t\ttry {\n\t\t\t\treturn readFileSync(join(payload.projectRoot, \"package.json\"), \"utf-8\");\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t});\n}\n//#endregion\nexport { loadProjectConfig as n, buildTelemetryEventFromProcess as t };\n\n//# sourceMappingURL=enrich-CJ5LlTek.mjs.map","import { n as loadProjectConfig } from \"../enrich-CJ5LlTek.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_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_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_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_DISABLE_TELEMETRY` truthy, its\n* `PRISMA_NEXT_DISABLE_TELEMETRY` spelling from earlier releases, 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_DISABLE_TELEMETRY\"]) || 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 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-8\";\nconst FILE_NAME = \"config.json\";\n/**\n* Resolves the user-level config directory:\n* - Windows: `%APPDATA%\\prisma-8\\` (fallback: `%USERPROFILE%\\AppData\\Roaming\\prisma-8\\`).\n* - Unix (incl. macOS): `$XDG_CONFIG_HOME/prisma-8/` if set, else\n* `$HOME/.config/prisma-8/` 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\t...ifDefined(\"exitCode\", inputs.exitCode)\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_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_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":";;;;;;;;;;AAKA,MAAM,uBAAuB;CAC5B,gBAAgB;CAChB,YAAY,CAAC;AACd;;;;;;;;;;;;;;;AAeA,eAAe,kBAAkB,aAAa;CAC7C,IAAI;EACH,MAAM,EAAE,eAAe,MAAM,OAAO;EACpC,MAAM,QAAQ,SAAS,WAAW;GACjC;GACA,KAAK;GACL,QAAQ;GACR,QAAQ;GACR,UAAU;EACX,CAAC;EACD,IAAI,UAAU,MAAM,KAAK,QAAQ,EAAA,CAAG,UAAU;EAC9C,IAAI,WAAW,QAAQ,OAAO,KAAK,MAAM,CAAC,CAAC,WAAW,GAAG,OAAO;EAChE,IAAI,OAAO,qBAAqB,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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;EACpD,GAAG,UAAU,YAAY,OAAO,QAAQ;CACzC;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,oBAAoB,KAAK,QAAQ,OAAO,MAAM,sCAAsC,OAAO,GAAG,EAAE,GAAG;EACpI,CAAC;EACD,MAAM,WAAW;EACjB,MAAM,MAAM;EACZ,OAAO,EAAE,SAAS,KAAK;CACxB,SAAS,KAAK;EACb,IAAI,QAAQ,IAAI,oBAAoB,KAAK,QAAQ,OAAO,MAAM,uCAAuC,OAAO,GAAG,EAAE,GAAG;EACpH,OAAO;GACN,SAAS;GACT,QAAQ;EACT;CACD;AACD;;;;;;;;AAQA,SAAS,gBAAgB,eAAe;CACvC,OAAO,cAAc,IAAI,IAAI,gBAAgB,aAAa,CAAC;AAC5D"}
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { y as ormConfigSection } from "./index-CWPFeYyi.mjs";
|
|
1
2
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
2
3
|
import { LoadedConfig } from "@prisma/cli-engine";
|
|
3
|
-
import { PrismaNextConfig } from "@prisma/orm-framework/config/config-types";
|
|
4
4
|
//#region ../../../1-framework/3-tooling/cli/dist/exports/index.d.mts
|
|
5
5
|
//#region src/load-ts-contract.d.ts
|
|
6
6
|
interface LoadTsContractOptions {
|
|
@@ -24,9 +24,6 @@ interface LoadTsContractOptions {
|
|
|
24
24
|
*/
|
|
25
25
|
declare function loadContractFromTs(entryPath: string, options?: LoadTsContractOptions): Promise<Contract>;
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region src/orm/config-section.d.ts
|
|
28
|
-
declare const ormConfigSection: import("@prisma/cli-engine").ConfigSection<PrismaNextConfig<string, string, unknown>>;
|
|
29
|
-
//#endregion
|
|
30
27
|
//#region src/orm/family.d.ts
|
|
31
28
|
/**
|
|
32
29
|
* The unit the ORM contributes to a CLI: its config section, its commands by
|
|
@@ -41,23 +38,19 @@ interface LoadOrmConfigOptions {
|
|
|
41
38
|
readonly cwd: string;
|
|
42
39
|
/** A non-default config file, resolved against `cwd` when relative. */
|
|
43
40
|
readonly configPath?: string;
|
|
44
|
-
/** Receives one message per deprecated spelling the loader accepted. */
|
|
45
|
-
readonly warn?: (message: string) => void;
|
|
46
41
|
}
|
|
47
42
|
/**
|
|
48
43
|
* Builds the engine's `Runtime.config` from `prisma.config.ts`.
|
|
49
44
|
*
|
|
50
|
-
* The engine ships its own
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* deprecated `prisma-next.config.ts` filename and flat shape, surfacing each
|
|
56
|
-
* through `warn`.
|
|
45
|
+
* The engine ships its own loader, but the bin owns the load: the ORM's c12
|
|
46
|
+
* loader evaluates the module asynchronously and follows `extends`. It hands
|
|
47
|
+
* the engine each file on the chain with its sections as written; the engine
|
|
48
|
+
* validates the `orm` section against its schema with that provenance,
|
|
49
|
+
* resolving every path against the file that declared it.
|
|
57
50
|
*
|
|
58
51
|
* Only failures that prevent evaluation entirely are diagnostics here, and
|
|
59
52
|
* they carry `section: null` so they fail exactly the commands that read
|
|
60
|
-
* config. Structural verdicts belong to the section
|
|
53
|
+
* config. Structural verdicts belong to the section schema.
|
|
61
54
|
*/
|
|
62
55
|
declare function loadOrmConfig(options: LoadOrmConfigOptions): Promise<LoadedConfig>;
|
|
63
56
|
//#endregion
|
package/dist/cli.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/exports/index.d.mts"],"mappings":";;;;;UAIU;WACC,YAAY;;;;;;;;;;;;;;;;;;iBAkBN,mBAAmB,mBAAmB,UAAU,wBAAwB,QAAQ
|
|
1
|
+
{"version":3,"file":"cli.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/exports/index.d.mts"],"mappings":";;;;;UAIU;WACC,YAAY;;;;;;;;;;;;;;;;;;iBAkBN,mBAAmB,mBAAmB,UAAU,wBAAwB,QAAQ;;;;;;;;cAQnF,+CAA+C;;;UAGnD;;WAEC;;WAEA;;;;;;;;;;;;;;;iBAeM,cAAc,SAAS,uBAAuB,QAAQ"}
|