@prisma/orm-toolchain 8.0.0-rc.3-dev.7 → 8.0.0-rc.3-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/{aggregate-CPZB020V.mjs → aggregate-BOlLu7k7.mjs} +8 -8
  2. package/dist/{aggregate-CPZB020V.mjs.map → aggregate-BOlLu7k7.mjs.map} +1 -1
  3. package/dist/cli-telemetry.d.mts +2 -2
  4. package/dist/cli-telemetry.mjs +9 -12
  5. package/dist/cli-telemetry.mjs.map +1 -1
  6. package/dist/cli.d.mts +1 -5
  7. package/dist/cli.d.mts.map +1 -1
  8. package/dist/cli.mjs +117 -58
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/cli__control-api.d.mts +3 -3
  11. package/dist/cli__control-api.d.mts.map +1 -1
  12. package/dist/cli__control-api.mjs +1 -1
  13. package/dist/cli__control-api__testing.d.mts +1 -1
  14. package/dist/cli__migration-cli.mjs +5 -5
  15. package/dist/cli__migration-cli.mjs.map +1 -1
  16. package/dist/config-loader.d.mts +1 -1
  17. package/dist/config-loader.mjs +1 -1
  18. package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs → contract-snapshot-store-BAmQkHe5-BJFpuIQQ.mjs} +3 -3
  19. package/dist/{contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs.map → contract-snapshot-store-BAmQkHe5-BJFpuIQQ.mjs.map} +1 -1
  20. package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts → db-verify-BRDzImLV-3eI346zy.d.mts} +3 -3
  21. package/dist/{db-verify-BwgNK50T-DGvKgFCK.d.mts.map → db-verify-BRDzImLV-3eI346zy.d.mts.map} +1 -1
  22. package/dist/emitter.mjs +1 -1
  23. package/dist/{errors-CXbGUWGu-CstQHPh6.mjs → errors-CcEpbfnE-CsSXrttT.mjs} +6 -6
  24. package/dist/errors-CcEpbfnE-CsSXrttT.mjs.map +1 -0
  25. package/dist/{exports-DLDFkjNv.mjs → exports-CN1Qe98l.mjs} +3 -3
  26. package/dist/{exports-DLDFkjNv.mjs.map → exports-CN1Qe98l.mjs.map} +1 -1
  27. package/dist/{exports-UjssmDwy.mjs → exports-Cv8nMmBT.mjs} +15 -51
  28. package/dist/exports-Cv8nMmBT.mjs.map +1 -0
  29. package/dist/{exports-BCLg4CiV-05kuwcb0.mjs → exports-Dw2WIX63-CQgI2e_L.mjs} +6 -6
  30. package/dist/exports-Dw2WIX63-CQgI2e_L.mjs.map +1 -0
  31. package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs → graph-membership-BoITerZB-C2-x1Qp6.mjs} +3 -3
  32. package/dist/{graph-membership-BViWUMpP-C4lYYJdU.mjs.map → graph-membership-BoITerZB-C2-x1Qp6.mjs.map} +1 -1
  33. package/dist/{import-roots-CfoYgejL.d.mts → import-roots-ARK1wjzc.d.mts} +3 -3
  34. package/dist/{import-roots-CfoYgejL.d.mts.map → import-roots-ARK1wjzc.d.mts.map} +1 -1
  35. package/dist/{import-roots-CNFBPAT1.mjs → import-roots-D0H8HuRw.mjs} +3 -3
  36. package/dist/import-roots-D0H8HuRw.mjs.map +1 -0
  37. package/dist/{index-BRjNSwL-.d.mts → index-u5RdrumF.d.mts} +2 -10
  38. package/dist/index-u5RdrumF.d.mts.map +1 -0
  39. package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs → invariants-DcFfhJMZ-BHDWZP9k.mjs} +3 -3
  40. package/dist/{invariants-CTHy88OP-CYI2a8IO.mjs.map → invariants-DcFfhJMZ-BHDWZP9k.mjs.map} +1 -1
  41. package/dist/{io-635GlNx1-D3zrw2qu.mjs → io-DsViRB_O-Ci1kJGBg.mjs} +5 -5
  42. package/dist/{io-635GlNx1-D3zrw2qu.mjs.map → io-DsViRB_O-Ci1kJGBg.mjs.map} +1 -1
  43. package/dist/{migration-BB4LDjuS.mjs → migration-CWSj4pMr.mjs} +3 -3
  44. package/dist/{migration-BB4LDjuS.mjs.map → migration-CWSj4pMr.mjs.map} +1 -1
  45. package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs → migration-graph-DwXAHP6T-NgmP2DNz.mjs} +3 -3
  46. package/dist/{migration-graph-_SJImD5V-BURyY1KM.mjs.map → migration-graph-DwXAHP6T-NgmP2DNz.mjs.map} +1 -1
  47. package/dist/migration-tools.d.mts +1 -1
  48. package/dist/migration-tools.mjs +12 -12
  49. package/dist/migration-tools__aggregate.mjs +1 -1
  50. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  51. package/dist/migration-tools__errors.mjs +1 -1
  52. package/dist/migration-tools__invariants.mjs +1 -1
  53. package/dist/migration-tools__io.mjs +1 -1
  54. package/dist/migration-tools__migration-graph.mjs +2 -2
  55. package/dist/migration-tools__migration.mjs +1 -1
  56. package/dist/migration-tools__ref-resolution.mjs +1 -1
  57. package/dist/migration-tools__refs.mjs +1 -1
  58. package/dist/migration-tools__spaces.d.mts +1 -1
  59. package/dist/migration-tools__spaces.mjs +2 -2
  60. package/dist/publish-surface.d.mts +1 -1
  61. package/dist/publish-surface.mjs +1 -1
  62. package/dist/publish-surface__import-roots.d.mts +1 -1
  63. package/dist/publish-surface__import-roots.mjs +1 -1
  64. package/dist/quick-reference-postgres.md +1 -1
  65. package/dist/{ref-BSRf-7Uh-JmET-ptm.mjs → ref-dWFulULw-TMeX1ZM1.mjs} +16 -16
  66. package/dist/ref-dWFulULw-TMeX1ZM1.mjs.map +1 -0
  67. package/dist/{ref-resolution-HeNBXW53.mjs → ref-resolution-Cbdejrwt.mjs} +2 -2
  68. package/dist/{ref-resolution-HeNBXW53.mjs.map → ref-resolution-Cbdejrwt.mjs.map} +1 -1
  69. package/dist/{refs-WK86uYYp-gM8tvWQP.mjs → refs-KVVlm3lE-BcqdpdYD.mjs} +6 -6
  70. package/dist/refs-KVVlm3lE-BcqdpdYD.mjs.map +1 -0
  71. package/dist/{spaces-Dj65JrwZ.d.mts → spaces-B20bgxF9.d.mts} +2 -2
  72. package/dist/{spaces-Dj65JrwZ.d.mts.map → spaces-B20bgxF9.d.mts.map} +1 -1
  73. package/dist/{spaces-4qMOAYE9.mjs → spaces-CHrjWRoZ.mjs} +7 -7
  74. package/dist/spaces-CHrjWRoZ.mjs.map +1 -0
  75. package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs → verify-contract-spaces-DomK5uP5-CyI3hD3Q.mjs} +7 -7
  76. package/dist/{verify-contract-spaces-DhJTb0zM-B62maCfE.mjs.map → verify-contract-spaces-DomK5uP5-CyI3hD3Q.mjs.map} +1 -1
  77. package/dist/vite-plugin-contract-emit.mjs +3 -3
  78. package/package.json +12 -12
  79. package/dist/errors-CXbGUWGu-CstQHPh6.mjs.map +0 -1
  80. package/dist/exports-BCLg4CiV-05kuwcb0.mjs.map +0 -1
  81. package/dist/exports-UjssmDwy.mjs.map +0 -1
  82. package/dist/import-roots-CNFBPAT1.mjs.map +0 -1
  83. package/dist/index-BRjNSwL-.d.mts.map +0 -1
  84. package/dist/ref-BSRf-7Uh-JmET-ptm.mjs.map +0 -1
  85. package/dist/refs-WK86uYYp-gM8tvWQP.mjs.map +0 -1
  86. package/dist/spaces-4qMOAYE9.mjs.map +0 -1
@@ -1,11 +1,11 @@
1
- import { M as errorRefNotResolvable, N as errorSpaceHeadRefMissing, i as errorContractDeserializationFailed, p as errorHashNotInGraph, r as errorBundleNotFoundForGraphNode, t as MigrationToolsError } from "./errors-CXbGUWGu-CstQHPh6.mjs";
2
- import { n as readContractSnapshotDts, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-B0G1Fw_F-CHc4QfKb.mjs";
3
- import { s as readMigrationsDir } from "./io-635GlNx1-D3zrw2qu.mjs";
1
+ import { M as errorRefNotResolvable, N as errorSpaceHeadRefMissing, i as errorContractDeserializationFailed, p as errorHashNotInGraph, r as errorBundleNotFoundForGraphNode, t as MigrationToolsError } from "./errors-CcEpbfnE-CsSXrttT.mjs";
2
+ import { n as readContractSnapshotDts, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-BAmQkHe5-BJFpuIQQ.mjs";
3
+ import { s as readMigrationsDir } from "./io-DsViRB_O-Ci1kJGBg.mjs";
4
4
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
5
- import { n as isGraphNode } from "./graph-membership-BViWUMpP-C4lYYJdU.mjs";
6
- import { l as reconstructGraph, o as findPathWithDecision } from "./migration-graph-_SJImD5V-BURyY1KM.mjs";
7
- import { a as readRefsTolerant, r as readRef, t as HEAD_REF_NAME } from "./refs-WK86uYYp-gM8tvWQP.mjs";
8
- import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-DhJTb0zM-B62maCfE.mjs";
5
+ import { n as isGraphNode } from "./graph-membership-BoITerZB-C2-x1Qp6.mjs";
6
+ import { l as reconstructGraph, o as findPathWithDecision } from "./migration-graph-DwXAHP6T-NgmP2DNz.mjs";
7
+ import { a as readRefsTolerant, r as readRef, t as HEAD_REF_NAME } from "./refs-KVVlm3lE-BcqdpdYD.mjs";
8
+ import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-DomK5uP5-CyI3hD3Q.mjs";
9
9
  import { blindCast } from "@prisma/orm-framework/utils/casts";
10
10
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
11
11
  import { issueOutcome } from "@prisma/orm-framework/components/control";
@@ -1009,4 +1009,4 @@ function runVerifyMigration(input) {
1009
1009
  //#endregion
1010
1010
  export { createAggregateContractSpace as a, loadProblemToViolation as c, resolveRecordedPath as d, verifyMigration as f, computeIntegrityViolations as i, planMigration as l, buildFabricatedMigrationEdge as n, createContractSpaceAggregate as o, collectAggregateNamespaces as r, loadContractSpaceAggregate as s, allStorageElementsExternal as t, requireHeadRef as u };
1011
1011
 
1012
- //# sourceMappingURL=aggregate-CPZB020V.mjs.map
1012
+ //# sourceMappingURL=aggregate-BOlLu7k7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-CPZB020V.mjs","names":["APP_SPACE_ID"],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/aggregate.mjs"],"sourcesContent":["import { M as errorRefNotResolvable, N as errorSpaceHeadRefMissing, i as errorContractDeserializationFailed, p as errorHashNotInGraph, r as errorBundleNotFoundForGraphNode, t as MigrationToolsError } from \"../errors-CXbGUWGu.mjs\";\nimport { n as readContractSnapshotDts, r as readContractSnapshotJson, t as contractSnapshotDir } from \"../contract-snapshot-store-B0G1Fw_F.mjs\";\nimport { s as readMigrationsDir } from \"../io-635GlNx1.mjs\";\nimport { t as EMPTY_CONTRACT_HASH } from \"../constants-CM-w38DQ.mjs\";\nimport { n as isGraphNode } from \"../graph-membership-BViWUMpP.mjs\";\nimport { l as reconstructGraph, o as findPathWithDecision } from \"../migration-graph-_SJImD5V.mjs\";\nimport { a as readRefsTolerant, r as readRef, t as HEAD_REF_NAME } from \"../refs-WK86uYYp.mjs\";\nimport { c as isValidSpaceId, i as APP_SPACE_ID, l as spaceMigrationDirectory, r as readContractSpaceHeadRef, t as listContractSpaceDirectories, u as spaceRefsDirectory } from \"../verify-contract-spaces-DhJTb0zM.mjs\";\nimport { join } from \"pathe\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { UNBOUND_NAMESPACE_ID, coordinateKey, elementCoordinates, entityAt } from \"@internal/framework-components/ir\";\nimport { effectiveControlPolicy } from \"@internal/contract/types\";\n//#region src/aggregate/aggregate.ts\nfunction contractAtMemoKey(hash, refName) {\n\treturn `${hash}\\0${refName ?? \"\"}`;\n}\nfunction deserializeContractAtPath(filePath, contractJson, deserializeContract) {\n\ttry {\n\t\treturn deserializeContract(contractJson);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) throw error;\n\t\tthrow errorContractDeserializationFailed(filePath, error instanceof Error ? error.message : String(error));\n\t}\n}\nasync function readContractSnapshotEntry(migrationsDir, hash, deserializeContract) {\n\tconst contractJson = await readContractSnapshotJson(migrationsDir, hash);\n\treturn {\n\t\tcontractJson,\n\t\tcontractDts: await readContractSnapshotDts(migrationsDir, hash),\n\t\tcontract: deserializeContractAtPath(join(contractSnapshotDir(migrationsDir, hash), \"contract.json\"), contractJson, deserializeContract)\n\t};\n}\nasync function resolveContractAt(args) {\n\tconst { hash, opts, refsDir, migrationsDir, packages, graph, deserializeContract } = args;\n\tconst refName = opts?.refName;\n\tif (refName !== void 0) {\n\t\tlet refEntry;\n\t\ttry {\n\t\t\trefEntry = await readRef(refsDir, refName);\n\t\t} catch (error) {\n\t\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.UNKNOWN_REF\") refEntry = void 0;\n\t\t\telse throw error;\n\t\t}\n\t\tif (refEntry) {\n\t\t\tconst { contractJson, contractDts, contract } = await readContractSnapshotEntry(migrationsDir, refEntry.hash, deserializeContract);\n\t\t\treturn {\n\t\t\t\thash: refEntry.hash,\n\t\t\t\tcontractJson,\n\t\t\t\tcontractDts,\n\t\t\t\tcontract,\n\t\t\t\tprovenance: \"ref\"\n\t\t\t};\n\t\t}\n\t\tif (isGraphNode(hash, graph)) return resolveGraphNodeContractAt({\n\t\t\thash,\n\t\t\tmigrationsDir,\n\t\t\tpackages,\n\t\t\tdeserializeContract,\n\t\t\texplicitLabel: refName\n\t\t});\n\t\tthrow errorRefNotResolvable(refName);\n\t}\n\tif (isGraphNode(hash, graph)) return resolveGraphNodeContractAt({\n\t\thash,\n\t\tmigrationsDir,\n\t\tpackages,\n\t\tdeserializeContract\n\t});\n\tthrow errorHashNotInGraph(hash, graph);\n}\nasync function resolveGraphNodeContractAt(args) {\n\tconst { hash, migrationsDir, packages, deserializeContract, explicitLabel } = args;\n\tif (!packages.find((pkg) => pkg.metadata.to === hash)) throw errorBundleNotFoundForGraphNode(hash, explicitLabel);\n\tconst { contractJson, contractDts, contract } = await readContractSnapshotEntry(migrationsDir, hash, deserializeContract);\n\treturn {\n\t\thash,\n\t\tcontractJson,\n\t\tcontractDts,\n\t\tcontract,\n\t\tprovenance: \"graph-node\"\n\t};\n}\n/**\n* Resolve a contract space's head ref, asserting it is present. The apply/verify\n* engine only runs after `checkIntegrity` has refused on `headRefMissing`,\n* so a space reaching the planner / verifier without a head ref is a\n* programming error (the integrity gate was skipped), not a user-facing\n* state. The app space's head ref is always synthesised, so this only\n* ever guards an ungated extension space.\n*/\nfunction requireHeadRef(space) {\n\tif (space.headRef === null) throw new InternalError(`Contract space \"${space.spaceId}\" has no head ref; the integrity gate must refuse a missing head ref before planning or verifying.`);\n\treturn space.headRef;\n}\n/**\n* Build a {@link AggregateContractSpace} with lazily-memoised `graph()`,\n* `contract()`, and `contractAt()` facets.\n*\n* `graph()` reconstructs the migration graph from `packages` on first\n* call and caches it. `contract()` calls `resolveContract` on first call\n* and caches the result; a throwing `resolveContract` (e.g. a missing or\n* undeserializable on-disk contract) re-throws on each call rather than\n* caching a value — `checkIntegrity` surfaces that as `contractUnreadable`.\n* `contractAt()` materializes the contract at an arbitrary graph node with\n* the same resolution order as plan-time ref resolution: the ref's pointer\n* plus the store entry keyed by the pointer's hash first (when\n* `opts.refName` is set), else the contract snapshot store entry keyed by\n* the matching package's `to` hash.\n*/\nfunction createAggregateContractSpace(args) {\n\tconst { spaceId, packages, refs, headRef, refsDir, migrationsDir, resolveContract, deserializeContract } = args;\n\tlet graphMemo;\n\tlet contractMemo;\n\tconst contractAtMemo = /* @__PURE__ */ new Map();\n\tfunction spaceGraph() {\n\t\tgraphMemo ??= reconstructGraph(packages);\n\t\treturn graphMemo;\n\t}\n\treturn {\n\t\tspaceId,\n\t\tpackages,\n\t\trefs,\n\t\theadRef,\n\t\tgraph: spaceGraph,\n\t\tcontract() {\n\t\t\tcontractMemo ??= resolveContract();\n\t\t\treturn contractMemo;\n\t\t},\n\t\tasync contractAt(hash, opts) {\n\t\t\tconst key = contractAtMemoKey(hash, opts?.refName);\n\t\t\tconst cached = contractAtMemo.get(key);\n\t\t\tif (cached) return cached;\n\t\t\tconst result = await resolveContractAt({\n\t\t\t\thash,\n\t\t\t\topts,\n\t\t\t\trefsDir,\n\t\t\t\tmigrationsDir,\n\t\t\t\tpackages,\n\t\t\t\tgraph: spaceGraph(),\n\t\t\t\tdeserializeContract\n\t\t\t});\n\t\t\tcontractAtMemo.set(key, result);\n\t\t\treturn result;\n\t\t}\n\t};\n}\n/**\n* Collect the union of every namespace declared across all contract spaces of an\n* aggregate (app + extensions) and return a minimal object with the shape\n* `{ storage: { namespaces } }` suitable for passing to\n* `familyInstance.introspect`.\n*\n* Callers invoke this after the integrity gate (`buildContractSpaceAggregate`\n* with `checkContracts: true`), so every `space.contract()` call is safe —\n* no try/catch is needed here.\n*/\nfunction collectAggregateNamespaces(aggregate) {\n\tconst merged = {};\n\tfor (const space of aggregate.spaces()) for (const [key, ns] of Object.entries(space.contract().storage.namespaces)) {\n\t\tconst existing = merged[key];\n\t\tmerged[key] = existing === void 0 ? ns : mergeNamespaceEntries(existing, ns);\n\t}\n\treturn { storage: { namespaces: merged } };\n}\n/**\n* Union two contract spaces' declarations for the same namespace id, per\n* entity kind. Two spaces may legitimately share a namespace (e.g. both\n* declaring tables in `public`); element-level disjointness is enforced by\n* `checkIntegrity`, so the kind maps never collide on a name — replacing the\n* whole namespace would silently drop the earlier space's entities.\n*/\nfunction mergeNamespaceEntries(a, b) {\n\tconst entries = { ...a.entries };\n\tfor (const [entityKind, kindMap] of Object.entries(b.entries)) entries[entityKind] = {\n\t\t...entries[entityKind],\n\t\t...kindMap\n\t};\n\treturn {\n\t\t...a,\n\t\tentries\n\t};\n}\n/**\n* Assemble a {@link ContractSpaceAggregate} value from its contract spaces and a\n* `checkIntegrity` implementation. The query methods (`listSpaces` /\n* `hasSpace` / `space` / `spaces`) are derived here so every aggregate —\n* loader-built or test-built — shares one query surface: `app` first,\n* then `extensions` in the order supplied (the loader sorts them\n* lex-ascending by `spaceId`).\n*/\nfunction createContractSpaceAggregate(args) {\n\tconst { targetId, app, extensions, checkIntegrity } = args;\n\tconst ordered = [app, ...extensions];\n\tconst byId = new Map(ordered.map((m) => [m.spaceId, m]));\n\tconst spaceDeclares = (space, coordinate) => {\n\t\tconst key = coordinateKey(coordinate);\n\t\tfor (const coord of elementCoordinates(space.contract().storage)) if (coordinateKey(coord) === key) return true;\n\t\treturn false;\n\t};\n\treturn {\n\t\ttargetId,\n\t\tapp,\n\t\textensions,\n\t\tlistSpaces: () => ordered.map((m) => m.spaceId),\n\t\thasSpace: (id) => byId.has(id),\n\t\tspace: (id) => byId.get(id),\n\t\tspaces: () => ordered,\n\t\tdeclaresEntity: (coordinate) => ordered.some((space) => spaceDeclares(space, coordinate)),\n\t\tdeclaringSpaces: (coordinate) => ordered.filter((space) => spaceDeclares(space, coordinate)).map((s) => s.spaceId),\n\t\tcheckIntegrity\n\t};\n}\n//#endregion\n//#region src/aggregate/all-external.ts\nfunction isControlPolicy(value) {\n\treturn value === \"managed\" || value === \"tolerated\" || value === \"external\" || value === \"observed\";\n}\n/**\n* True when every storage element the contract declares resolves to the\n* `external` control policy (ADR 224) — element-level `control` first, the\n* contract's `defaultControlPolicy` otherwise. A contract with no storage\n* elements is vacuously all-external.\n*\n* This is the precondition for advancing a contract space's marker without\n* any migrations (the declared-state resolution the db-init aggregate\n* planner and `migrate` share): only when nothing in the space is\n* Prisma-Next-managed can the storage structure be correct without a\n* migration having produced it. Any space that declares a managed element\n* but ships no migration graph is an authoring bug and must fail loudly.\n*/\nfunction allStorageElementsExternal(contract) {\n\tfor (const coordinate of elementCoordinates(contract.storage)) {\n\t\tconst entity = entityAt(contract.storage, coordinate);\n\t\tconst declared = entity !== null && typeof entity === \"object\" ? blindCast(entity).control : void 0;\n\t\tif (effectiveControlPolicy(isControlPolicy(declared) ? declared : void 0, contract.defaultControlPolicy) !== \"external\") return false;\n\t}\n\treturn true;\n}\n//#endregion\n//#region src/aggregate/check-integrity.ts\n/**\n* Walk the loaded model and return **every** integrity violation — never\n* bailing at the first. Structurally-derivable violations (load-time\n* problems, self-edges, missing / unreachable head refs) are always\n* produced; layout-drift checks require `declaredExtensions`, and\n* contract / target / disjointness checks require `checkContracts`.\n*/\nfunction computeIntegrityViolations(input, opts) {\n\tconst violations = [];\n\tfor (const { space, problems, refProblems, headRefProblem, isApp } of input.spaces) {\n\t\tconst { spaceId } = space;\n\t\tfor (const problem of problems) violations.push(loadProblemToViolation(spaceId, problem));\n\t\tfor (const refProblem of refProblems) violations.push({\n\t\t\tkind: \"refUnreadable\",\n\t\t\tspaceId,\n\t\t\trefName: refProblem.refName,\n\t\t\tdetail: refProblem.detail\n\t\t});\n\t\tif (headRefProblem !== null) violations.push({\n\t\t\tkind: \"refUnreadable\",\n\t\t\tspaceId,\n\t\t\trefName: headRefProblem.refName,\n\t\t\tdetail: headRefProblem.detail\n\t\t});\n\t\tfor (const pkg of space.packages) {\n\t\t\tconst from = pkg.metadata.from ?? \"empty\";\n\t\t\tconst isSelfEdge = from === pkg.metadata.to;\n\t\t\tconst hasDataOp = pkg.ops.some((op) => op.operationClass === \"data\");\n\t\t\tif (isSelfEdge && !hasDataOp) violations.push({\n\t\t\t\tkind: \"sameSourceAndTarget\",\n\t\t\t\tspaceId,\n\t\t\t\tdirName: pkg.dirName,\n\t\t\t\thash: from\n\t\t\t});\n\t\t}\n\t\tviolations.push(...duplicateMigrationHashViolations(spaceId, space.packages));\n\t\tif (!isApp && headRefProblem === null) {\n\t\t\tif (space.headRef === null) violations.push({\n\t\t\t\tkind: \"headRefMissing\",\n\t\t\t\tspaceId\n\t\t\t});\n\t\t\telse if (space.packages.length > 0 && !headRefPresentInGraph(space, space.headRef.hash)) violations.push({\n\t\t\t\tkind: \"headRefNotInGraph\",\n\t\t\t\tspaceId,\n\t\t\t\thash: space.headRef.hash\n\t\t\t});\n\t\t}\n\t}\n\tif (opts?.declaredExtensions !== void 0) violations.push(...layoutViolations(input.spaces, opts.declaredExtensions));\n\tif (opts?.checkContracts === true) violations.push(...contractViolations(input));\n\treturn violations;\n}\nfunction loadProblemToViolation(spaceId, problem) {\n\tswitch (problem.kind) {\n\t\tcase \"hashMismatch\": return {\n\t\t\tkind: \"hashMismatch\",\n\t\t\tspaceId,\n\t\t\tdirName: problem.dirName,\n\t\t\tstored: problem.stored,\n\t\t\tcomputed: problem.computed\n\t\t};\n\t\tcase \"providedInvariantsMismatch\": return {\n\t\t\tkind: \"providedInvariantsMismatch\",\n\t\t\tspaceId,\n\t\t\tdirName: problem.dirName\n\t\t};\n\t\tcase \"packageUnloadable\": return {\n\t\t\tkind: \"packageUnloadable\",\n\t\t\tspaceId,\n\t\t\tdirName: problem.dirName,\n\t\t\tdetail: problem.detail\n\t\t};\n\t}\n}\nfunction duplicateMigrationHashViolations(spaceId, packages) {\n\tconst dirNamesByHash = /* @__PURE__ */ new Map();\n\tfor (const pkg of packages) {\n\t\tconst hash = pkg.metadata.migrationHash;\n\t\tconst dirNames = dirNamesByHash.get(hash);\n\t\tif (dirNames) dirNames.push(pkg.dirName);\n\t\telse dirNamesByHash.set(hash, [pkg.dirName]);\n\t}\n\tconst out = [];\n\tfor (const [migrationHash, dirNames] of dirNamesByHash) if (dirNames.length > 1) out.push({\n\t\tkind: \"duplicateMigrationHash\",\n\t\tspaceId,\n\t\tmigrationHash,\n\t\tdirNames: [...dirNames].sort()\n\t});\n\treturn out;\n}\n/**\n* Whether a space's head-ref hash is present in its reconstructed graph.\n* An empty graph is reachable only by the empty-contract sentinel.\n*/\nfunction headRefPresentInGraph(space, headHash) {\n\tconst graph = space.graph();\n\tif (graph.nodes.size === 0) return headHash === EMPTY_CONTRACT_HASH;\n\treturn graph.nodes.has(headHash);\n}\nfunction layoutViolations(spaces, declaredExtensions) {\n\tconst out = [];\n\tconst extensionSpaceIds = new Set(spaces.filter((s) => !s.isApp).map((s) => s.space.spaceId));\n\tconst declaredIds = new Set(declaredExtensions.map((d) => d.id));\n\tfor (const id of [...extensionSpaceIds].sort()) if (!declaredIds.has(id)) out.push({\n\t\tkind: \"orphanSpaceDir\",\n\t\tspaceId: id\n\t});\n\tfor (const id of [...declaredIds].sort()) if (!extensionSpaceIds.has(id)) out.push({\n\t\tkind: \"declaredButUnmigrated\",\n\t\tspaceId: id\n\t});\n\treturn out;\n}\nfunction contractViolations(input) {\n\tconst out = [];\n\tconst elementClaimedBy = /* @__PURE__ */ new Map();\n\tconst elementLabel = /* @__PURE__ */ new Map();\n\tfor (const { space } of input.spaces) {\n\t\tlet contract;\n\t\ttry {\n\t\t\tcontract = space.contract();\n\t\t} catch (error) {\n\t\t\tout.push({\n\t\t\t\tkind: \"contractUnreadable\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\tdetail: detailOf$1(error)\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (contract.target !== input.targetId) out.push({\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId: space.spaceId,\n\t\t\texpected: input.targetId,\n\t\t\tactual: contract.target\n\t\t});\n\t\tfor (const coordinate of elementCoordinates(contract.storage)) {\n\t\t\tconst key = coordinateKey(coordinate);\n\t\t\tconst claimers = elementClaimedBy.get(key);\n\t\t\tif (claimers) claimers.push(space.spaceId);\n\t\t\telse {\n\t\t\t\telementClaimedBy.set(key, [space.spaceId]);\n\t\t\t\telementLabel.set(key, `${coordinate.namespaceId}.${coordinate.entityName}`);\n\t\t\t}\n\t\t}\n\t}\n\tconst disjointness = [];\n\tfor (const [key, claimedBy] of elementClaimedBy) if (claimedBy.length > 1) {\n\t\tconst element = elementLabel.get(key) ?? key;\n\t\tdisjointness.push({\n\t\t\tkind: \"disjointness\",\n\t\t\telement,\n\t\t\tclaimedBy: [...claimedBy].sort()\n\t\t});\n\t}\n\tdisjointness.sort((a, b) => a.kind === \"disjointness\" && b.kind === \"disjointness\" ? a.element.localeCompare(b.element) : 0);\n\tout.push(...disjointness);\n\treturn out;\n}\nfunction detailOf$1(error) {\n\tif (MigrationToolsError.is(error)) return error.why;\n\tif (error instanceof Error) return error.message;\n\treturn String(error);\n}\n//#endregion\n//#region src/aggregate/fabricated-migration-edge.ts\nfunction buildFabricatedMigrationEdge(args) {\n\treturn {\n\t\tdirName: \"\",\n\t\tmigrationHash: args.destinationStorageHash,\n\t\tfrom: args.currentMarkerStorageHash ?? \"\",\n\t\tto: args.destinationStorageHash,\n\t\toperationCount: args.operationCount,\n\t\t...args.destinationContractJson !== void 0 ? { destinationContractJson: args.destinationContractJson } : {}\n\t};\n}\n//#endregion\n//#region src/aggregate/loader.ts\n/**\n* Build a tolerant, queryable {@link ContractSpaceAggregate} from on-disk\n* migration state plus the caller's live app contract.\n*\n* Building **never throws on disk content**: a hash- or\n* invariants-mismatched package is retained, an unparseable package is\n* omitted, a missing extension head ref leaves `headRef: null`, and an\n* unreadable on-disk contract defers its failure to `space.contract()`.\n* Every such problem is judged by {@link ContractSpaceAggregate.checkIntegrity}\n* rather than aborting the load. The only rejections are catastrophic I/O\n* (a `migrations/` that exists but is unreadable for reasons other than\n* absence).\n*\n* The app space's head ref is synthesised from the live contract's\n* storage hash (the app contract is authored independently of the\n* migration graph), and `app.contract()` returns the supplied contract.\n* Extension spaces read their contract, refs, and head ref from disk.\n*/\nasync function loadContractSpaceAggregate(input) {\n\tconst { migrationsDir, deserializeContract, appContract } = input;\n\tconst targetId = appContract.target;\n\tconst appState = await loadAppSpace(migrationsDir, appContract, deserializeContract);\n\tconst extensionStates = await loadExtensionSpaces(migrationsDir, deserializeContract);\n\tconst spaces = [appState, ...extensionStates];\n\treturn createContractSpaceAggregate({\n\t\ttargetId,\n\t\tapp: appState.space,\n\t\textensions: extensionStates.map((state) => state.space),\n\t\tcheckIntegrity: (opts) => computeIntegrityViolations({\n\t\t\ttargetId,\n\t\t\tspaces\n\t\t}, opts)\n\t});\n}\nasync function loadAppSpace(migrationsDir, appContract, deserializeContract) {\n\tconst spaceDir = spaceMigrationDirectory(migrationsDir, APP_SPACE_ID);\n\tconst { packages, problems } = await readMigrationsDir(spaceDir, { migrationsDir });\n\tconst { refs, problems: refProblems } = await readRefsTolerant(spaceRefsDirectory(spaceDir));\n\treturn {\n\t\tspace: createAggregateContractSpace({\n\t\t\tspaceId: APP_SPACE_ID,\n\t\t\tpackages,\n\t\t\trefs,\n\t\t\theadRef: {\n\t\t\t\thash: appContract.storage.storageHash,\n\t\t\t\tinvariants: []\n\t\t\t},\n\t\t\trefsDir: spaceRefsDirectory(spaceDir),\n\t\t\tmigrationsDir,\n\t\t\tresolveContract: () => appContract,\n\t\t\tdeserializeContract\n\t\t}),\n\t\tproblems,\n\t\trefProblems,\n\t\theadRefProblem: null,\n\t\tisApp: true\n\t};\n}\nasync function loadExtensionSpaces(migrationsDir, deserializeContract) {\n\tconst extensionIds = (await listContractSpaceDirectories(migrationsDir)).filter((name) => name !== APP_SPACE_ID).filter(isValidSpaceId).sort();\n\tconst states = [];\n\tfor (const spaceId of extensionIds) states.push(await loadExtensionSpace(migrationsDir, spaceId, deserializeContract));\n\treturn states;\n}\nasync function loadExtensionSpace(migrationsDir, spaceId, deserializeContract) {\n\tconst spaceDir = spaceMigrationDirectory(migrationsDir, spaceId);\n\tconst { packages, problems } = await readMigrationsDir(spaceDir, { migrationsDir });\n\tconst { refs, problems: refProblems } = await readRefsTolerant(spaceRefsDirectory(spaceDir));\n\tconst { headRef, problem: headRefProblem } = await readHeadRefTolerant(migrationsDir, spaceId);\n\tconst rawContract = await readRawContractDeferred(migrationsDir, spaceId, headRef);\n\treturn {\n\t\tspace: createAggregateContractSpace({\n\t\t\tspaceId,\n\t\t\tpackages,\n\t\t\trefs,\n\t\t\theadRef,\n\t\t\trefsDir: spaceRefsDirectory(spaceDir),\n\t\t\tmigrationsDir,\n\t\t\tresolveContract: () => deserializeContract(rawContract()),\n\t\t\tdeserializeContract\n\t\t}),\n\t\tproblems,\n\t\trefProblems,\n\t\theadRefProblem,\n\t\tisApp: false\n\t};\n}\n/**\n* Read an extension's head ref, distinguishing a *genuinely absent*\n* `head.json` (`headRef: null`, no problem — judged `headRefMissing`)\n* from one that *exists but cannot be parsed* (`headRef: null` plus a\n* problem — judged `refUnreadable`, not `headRefMissing`).\n* `readContractSpaceHeadRef` already returns `null` only for ENOENT and\n* throws for unparseable / schema-invalid content, so the throw is the\n* corruption signal. Construction never throws on disk content.\n*/\nfunction isToleratedRefHeadReadError(error) {\n\tif (MigrationToolsError.is(error)) return true;\n\tif (!(error instanceof Error)) return false;\n\tconst code = error.code;\n\treturn code === \"ENOENT\" || code === \"EISDIR\";\n}\nasync function readHeadRefTolerant(migrationsDir, spaceId) {\n\ttry {\n\t\treturn {\n\t\t\theadRef: await readContractSpaceHeadRef(migrationsDir, spaceId),\n\t\t\tproblem: null\n\t\t};\n\t} catch (error) {\n\t\tif (!isToleratedRefHeadReadError(error)) throw error;\n\t\treturn {\n\t\t\theadRef: null,\n\t\t\tproblem: {\n\t\t\t\trefName: HEAD_REF_NAME,\n\t\t\t\tdetail: detailOf(error)\n\t\t\t}\n\t\t};\n\t}\n}\nfunction detailOf(error) {\n\treturn error instanceof Error ? error.message : String(error);\n}\n/**\n* Read the raw contract snapshot-store entry eagerly (cheap I/O) but defer\n* its (throwing) failure to call time, so a missing or unparseable store\n* entry becomes a `contract()` throw — surfaced as `contractUnreadable` —\n* rather than a construction failure. When `headRef` is absent there is no\n* hash to resolve against the store, so the deferred call always throws;\n* `checkIntegrity` already reports that case as `headRefMissing`, and a\n* `checkContracts` pass surfaces the same space as `contractUnreadable`.\n*/\nasync function readRawContractDeferred(migrationsDir, spaceId, headRef) {\n\tif (headRef === null) return () => {\n\t\tthrow errorSpaceHeadRefMissing(spaceId);\n\t};\n\ttry {\n\t\tconst raw = await readContractSnapshotJson(migrationsDir, headRef.hash);\n\t\treturn () => raw;\n\t} catch (error) {\n\t\treturn () => {\n\t\t\tthrow error;\n\t\t};\n\t}\n}\n//#endregion\n//#region src/aggregate/strategies/plan-from-diff.ts\n/**\n* Plan a migration for a single contract space from a diff against the full\n* live schema, delegating to the family's `createPlanner(...).plan(...)`.\n*\n* The planner diffs the whole introspected schema, so it sees other contract\n* spaces' tables as \"extras\"; the orchestration hands the planner the\n* aggregate as an ownership oracle so it can ask, per extra, whether any\n* space owns it — a sibling-owned table is left untouched, so the planner\n* never emits a destructive drop for it, and this strategy holds no ownership\n* logic of its own. The schema is never pruned before planning: cross-space\n* foreign keys need every sibling table visible to the diff.\n*\n* The produced plan's `targetId` is set from `aggregateTargetId`\n* (the aggregate's ambient target). The family's planner does not\n* stamp `targetId` on the produced plan; the aggregate planner is\n* the single point that knows the target.\n*\n* Used by:\n*\n* - The app space by default (CLI policy\n* `ignoreGraphFor: { app.spaceId }`).\n* - Any extension space whose `headRef.invariants` is empty and whose\n* graph is non-empty (the all-external, zero-migration-package case is\n* handled directly by the aggregate planner without calling this).\n*/\nasync function planFromDiff(input) {\n\tconst plannerResult = await input.migrations.createPlanner(input.adapter).plan({\n\t\tcontract: input.space.contract(),\n\t\tschema: input.schemaIntrospection,\n\t\tpolicy: input.operationPolicy,\n\t\tfromContract: null,\n\t\tframeworkComponents: input.frameworkComponents,\n\t\tspaceId: input.space.spaceId,\n\t\townership: input.ownership,\n\t\tsnapshotsImportPath: \"\"\n\t});\n\tif (plannerResult.kind === \"failure\") return {\n\t\tkind: \"failure\",\n\t\tconflicts: plannerResult.conflicts\n\t};\n\tconst producedPlan = plannerResult.plan;\n\tconst plan = new Proxy(producedPlan, {\n\t\tget(target, prop) {\n\t\t\tif (prop === \"targetId\") return input.aggregateTargetId;\n\t\t\treturn Reflect.get(target, prop, target);\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (prop === \"targetId\") return true;\n\t\t\treturn Reflect.has(target, prop);\n\t\t}\n\t});\n\tconst destinationStorageHash = producedPlan.destination.storageHash;\n\tconst producedOps = await Promise.all(producedPlan.operations);\n\tconst destinationContract = input.space.contract();\n\treturn {\n\t\tkind: \"ok\",\n\t\tresult: {\n\t\t\tplan,\n\t\t\tdisplayOps: producedOps,\n\t\t\tdestinationContract,\n\t\t\tstrategy: \"plan-from-diff\",\n\t\t\t...plannerResult.warnings && plannerResult.warnings.length > 0 ? { warnings: plannerResult.warnings } : {},\n\t\t\tmigrationEdges: [buildFabricatedMigrationEdge({\n\t\t\t\tcurrentMarkerStorageHash: input.currentMarker?.storageHash,\n\t\t\t\tdestinationStorageHash,\n\t\t\t\toperationCount: producedOps.length,\n\t\t\t\tdestinationContractJson: destinationContract\n\t\t\t})]\n\t\t}\n\t};\n}\n//#endregion\n//#region src/aggregate/strategies/resolve-recorded-path.ts\n/**\n* Resolve a contract space's hydrated migration graph to the path from the\n* live marker to `space.headRef.hash`, covering every required invariant.\n*\n* Pure synchronous function — no I/O. The aggregate's loader has\n* already integrity-checked every package and reconstructed the graph;\n* this resolves the path by looking up ops by `migrationHash` and\n* assembles a `MigrationPlan` with `targetId` set from the aggregate (no\n* placeholder cast).\n*\n* Required invariants are computed as `headRef.invariants \\ marker.invariants`\n* — the marker already declares some invariants satisfied; the path\n* only needs to provide the remainder. Mirrors today's\n* `computeExtensionSpaceApplyPath` semantics.\n*/\nfunction resolveRecordedPath(input) {\n\tconst { aggregateTargetId, space, currentMarker, refName } = input;\n\tconst headRef = requireHeadRef(space);\n\tconst graph = space.graph();\n\tconst packagesByMigrationHash = new Map(space.packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));\n\tconst fromHash = currentMarker?.storageHash ?? \"empty\";\n\tconst markerInvariants = new Set(currentMarker?.invariants ?? []);\n\tconst required = new Set(headRef.invariants.filter((id) => !markerInvariants.has(id)));\n\tconst outcome = findPathWithDecision(graph, fromHash, headRef.hash, {\n\t\trequired,\n\t\t...refName !== void 0 ? { refName } : {}\n\t});\n\tif (outcome.kind === \"unreachable\") return { kind: \"unreachable\" };\n\tif (outcome.kind === \"unsatisfiable\") return {\n\t\tkind: \"unsatisfiable\",\n\t\tmissing: outcome.missing\n\t};\n\tconst pathOps = [];\n\tconst providedInvariantsSet = /* @__PURE__ */ new Set();\n\tconst edgeRefs = [];\n\tfor (const edge of outcome.decision.selectedPath) {\n\t\tconst pkg = packagesByMigrationHash.get(edge.migrationHash);\n\t\tif (!pkg) throw new InternalError(`Migration package missing for edge ${edge.migrationHash} in space \"${space.spaceId}\". The hydrated migration graph and packagesByMigrationHash map are out of sync — this should be unreachable; report.`);\n\t\tfor (const op of pkg.ops) pathOps.push(op);\n\t\tfor (const invariant of pkg.metadata.providedInvariants) providedInvariantsSet.add(invariant);\n\t\tedgeRefs.push({\n\t\t\tmigrationHash: edge.migrationHash,\n\t\t\tdirName: edge.dirName,\n\t\t\tfrom: edge.from,\n\t\t\tto: edge.to,\n\t\t\toperationCount: pkg.ops.length,\n\t\t\t...pkg.endContractJson !== void 0 ? { destinationContractJson: pkg.endContractJson } : {}\n\t\t});\n\t}\n\treturn {\n\t\tkind: \"ok\",\n\t\tresult: {\n\t\t\tplan: {\n\t\t\t\ttargetId: aggregateTargetId,\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\torigin: currentMarker === null ? null : { storageHash: currentMarker.storageHash },\n\t\t\t\tdestination: { storageHash: headRef.hash },\n\t\t\t\toperations: pathOps,\n\t\t\t\tprovidedInvariants: [...providedInvariantsSet].sort()\n\t\t\t},\n\t\t\tdisplayOps: pathOps,\n\t\t\tdestinationContract: space.contract(),\n\t\t\tstrategy: \"resolve-recorded-path\",\n\t\t\tmigrationEdges: edgeRefs,\n\t\t\tpathDecision: outcome.decision\n\t\t}\n\t};\n}\n//#endregion\n//#region src/aggregate/planner.ts\n/**\n* Plan a migration across every contract space of a {@link ContractSpaceAggregate}.\n*\n* Per-space operation selection, in order; first match wins:\n*\n* 1. If `callerPolicy.ignoreGraphFor.has(space.spaceId)`:\n* - If `space.headRef.invariants` is empty → `planFromDiff`.\n* - Else → `policyConflict` (a diff-fabricated plan cannot satisfy\n* authored invariants).\n* 2. Else if `space.graph()` is non-empty AND `resolveRecordedPath`\n* succeeds → its result.\n* 3. Else if `space.graph()` is non-empty but unresolvable →\n* `extensionPathUnreachable` / `extensionPathUnsatisfiable`.\n* 4. Else (empty graph — the space ships no migration packages at all,\n* e.g. an all-external extension space like Supabase's `auth`/`storage`)\n* if `space.headRef.invariants` is empty → declare the no-op state\n* directly (zero ops, destination = head ref) without invoking the\n* family planner.\n* 5. Else → `extensionPathUnsatisfiable` (an empty graph cannot satisfy\n* non-empty invariants).\n*\n* Output `applyOrder` is `[...aggregate.extensions.map(spaceId), aggregate.app.spaceId]`\n* — extensions alphabetical, then app — matching today's\n* `concatenateSpaceApplyInputs` ordering. This preserves\n* `MigrationRunnerFailure.failingSpace` attribution byte-for-byte.\n*\n* Every emitted `MigrationPlan` has `targetId = aggregate.targetId`.\n* No placeholder cast; no patch step.\n*/\nasync function planMigration(input) {\n\tconst { aggregate, currentDBState, callerPolicy } = input;\n\tconst perSpace = /* @__PURE__ */ new Map();\n\tconst orderedSpaces = [...aggregate.extensions, aggregate.app];\n\tfor (const space of orderedSpaces) {\n\t\tconst currentMarker = currentDBState.markersBySpaceId.get(space.spaceId) ?? null;\n\t\tconst headRef = requireHeadRef(space);\n\t\tconst ignoreGraph = callerPolicy.ignoreGraphFor.has(space.spaceId);\n\t\tconst invariantsRequired = headRef.invariants.length > 0;\n\t\tif (ignoreGraph && invariantsRequired) return notOk({\n\t\t\tkind: \"policyConflict\",\n\t\t\tspaceId: space.spaceId,\n\t\t\tdetail: `\\`callerPolicy.ignoreGraphFor\\` requested for space \"${space.spaceId}\", but the contract space declares non-empty head-ref invariants (${headRef.invariants.join(\", \")}). A plan built directly from the contract IR cannot satisfy authored invariants — the graph must be walked. Either remove \"${space.spaceId}\" from \\`ignoreGraphFor\\` or amend the on-disk head ref to declare zero invariants.`\n\t\t});\n\t\tif (ignoreGraph) {\n\t\t\tconst diffOutcome = await planFromDiff({\n\t\t\t\taggregateTargetId: aggregate.targetId,\n\t\t\t\tcurrentMarker,\n\t\t\t\tspace,\n\t\t\t\townership: aggregate,\n\t\t\t\tschemaIntrospection: currentDBState.schemaIntrospection,\n\t\t\t\tadapter: input.adapter,\n\t\t\t\tmigrations: input.migrations,\n\t\t\t\tframeworkComponents: input.frameworkComponents,\n\t\t\t\toperationPolicy: input.operationPolicy\n\t\t\t});\n\t\t\tif (diffOutcome.kind === \"failure\") return notOk({\n\t\t\t\tkind: \"planFromDiffFailed\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\tconflicts: diffOutcome.conflicts\n\t\t\t});\n\t\t\tperSpace.set(space.spaceId, diffOutcome.result);\n\t\t\tcontinue;\n\t\t}\n\t\tif (space.graph().nodes.size > 0) {\n\t\t\tconst resolved = resolveRecordedPath({\n\t\t\t\taggregateTargetId: aggregate.targetId,\n\t\t\t\tspace,\n\t\t\t\tcurrentMarker\n\t\t\t});\n\t\t\tif (resolved.kind === \"ok\") {\n\t\t\t\tperSpace.set(space.spaceId, resolved.result);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (resolved.kind === \"unreachable\") return notOk({\n\t\t\t\tkind: \"extensionPathUnreachable\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\ttarget: headRef.hash\n\t\t\t});\n\t\t\treturn notOk({\n\t\t\t\tkind: \"extensionPathUnsatisfiable\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\tmissingInvariants: resolved.missing\n\t\t\t});\n\t\t}\n\t\tif (invariantsRequired) return notOk({\n\t\t\tkind: \"extensionPathUnsatisfiable\",\n\t\t\tspaceId: space.spaceId,\n\t\t\tmissingInvariants: [...headRef.invariants].sort()\n\t\t});\n\t\tif (!allStorageElementsExternal(space.contract())) return notOk({\n\t\t\tkind: \"extensionPathUnreachable\",\n\t\t\tspaceId: space.spaceId,\n\t\t\ttarget: headRef.hash\n\t\t});\n\t\tperSpace.set(space.spaceId, {\n\t\t\tplan: {\n\t\t\t\ttargetId: aggregate.targetId,\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\torigin: currentMarker === null ? null : { storageHash: currentMarker.storageHash },\n\t\t\t\tdestination: { storageHash: headRef.hash },\n\t\t\t\toperations: []\n\t\t\t},\n\t\t\tdisplayOps: [],\n\t\t\tdestinationContract: space.contract(),\n\t\t\tstrategy: \"declared-state\",\n\t\t\tmigrationEdges: [buildFabricatedMigrationEdge({\n\t\t\t\tcurrentMarkerStorageHash: currentMarker?.storageHash,\n\t\t\t\tdestinationStorageHash: headRef.hash,\n\t\t\t\toperationCount: 0\n\t\t\t})]\n\t\t});\n\t}\n\treturn ok({\n\t\tperSpace,\n\t\tapplyOrder: [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId]\n\t});\n}\nfunction pathIsUnder(path, prefix) {\n\tif (path.length < prefix.length) return false;\n\treturn prefix.every((segment, i) => path[i] === segment);\n}\n/**\n* Whether an issue's subject is a WHOLE top-level entity — as opposed to\n* something nested under one (e.g. a field, an index, or a policy). Calls\n* the injected `classify` capability, which resolves this from the issue's\n* node `nodeKind` (this aggregate never reaches into the node itself).\n* Absent `classify` (or a `classify` that returns nothing for this issue —\n* a family that doesn't classify) falls back to path shape: a\n* top-level entity's path is exactly its own name (one segment), so\n* anything deeper is nested.\n*/\nfunction isWholeEntityIssue(issue, classify) {\n\tconst granularity = classify?.(issue);\n\tif (granularity !== void 0) return granularity === \"entity\";\n\treturn issue.path.length === 1;\n}\n/**\n* A contract space's contract-satisfaction view. Strips the top-level entity\n* extras — the `not-expected` findings on whole-entity nodes (plus the\n* findings the differ's total descent reported under those entities). Those\n* belong to the standalone unclaimed-elements list\n* ({@link collectExtraElementCoordinates}), never a space's own verdict.\n*\n* Nested `not-expected` findings (an extra field on the space's own\n* declared entity…) and structural findings (an undeclared policy) are\n* the space's **own drift** and stay.\n*\n* The verdict recomputes from the surviving list: the per-space result is\n* issue-based (`ok` ⇔ the list is empty), so a space whose only failures\n* were top-level extras passes after the strip.\n*/\nfunction stripExtraFindings(result, classify) {\n\tconst droppedTablePaths = result.schema.issues.filter((issue) => issueOutcome(issue) === \"not-expected\" && isWholeEntityIssue(issue, classify)).map((issue) => issue.path);\n\tconst issues = result.schema.issues.filter((issue) => {\n\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\tif (classify?.(issue) === \"structural\") return true;\n\t\treturn !droppedTablePaths.some((prefix) => pathIsUnder(issue.path, prefix));\n\t});\n\tif (issues.length === result.schema.issues.length) return result;\n\tconst ok = issues.length === 0;\n\tconst { code: staleCode, ...envelope } = result;\n\treturn {\n\t\t...envelope,\n\t\tok,\n\t\t...ok ? {} : { code: result.code ?? \"CONTRACT.MARKER_REQUIRED\" },\n\t\tsummary: ok ? \"Database schema satisfies contract\" : result.summary,\n\t\tschema: {\n\t\t\tissues,\n\t\t\t...result.schema.warnings !== void 0 ? { warnings: result.schema.warnings } : {}\n\t\t}\n\t};\n}\n/**\n* The schema-IR entity coordinate a `not-expected` `SchemaDiffIssue`\n* addresses, when its subject is a whole top-level entity. A nested leaf\n* (a field, an index, a policy on an undeclared entity) has no entity of\n* its own to report here.\n*\n* The whole-entity's name is the last path segment: the differ builds each\n* path from its nodes' ids, so at a whole-entity finding the last segment is\n* exactly the entity name — for every family, whether or not it stamps a\n* granularity. The namespace segment only exists for namespace-qualified\n* paths (`['database', namespaceId, entityName]`); single-namespace families\n* (a flat `['database', entityName]`, or a bare `[entityName]`) have no\n* separate segment, so every entity they declare implicitly shares one\n* namespace — the same sentinel the aggregate's own coordinate walk uses\n* for those families.\n*\n* `entityKind` is asked from the injected `classifyEntityKind` capability —\n* this module never names a family entity kind itself. Absent a classifier\n* (the classifier-absent path-shape fallback, e.g. a document family) the\n* coordinate carries {@link UNCLASSIFIED_ENTITY_KIND}: no ownership\n* consumer queries `declaresEntity` for a family in that state today, so\n* nothing reads the value as true.\n*/\nfunction schemaDiffIssueCoordinate(issue, classify, classifyEntityKind) {\n\tif (!isWholeEntityIssue(issue, classify)) return void 0;\n\tconst entityName = issue.path[issue.path.length - 1];\n\tif (entityName === void 0) return void 0;\n\treturn {\n\t\tnamespaceId: issue.path.length === 3 ? issue.path[1] ?? UNBOUND_NAMESPACE_ID : UNBOUND_NAMESPACE_ID,\n\t\tentityKind: classifyEntityKind?.(issue) ?? \"unclassified-entity\",\n\t\tentityName\n\t};\n}\n/**\n* The schema-IR entity coordinates of every live element this contract\n* space's diff reports as `not-expected`, deduplicated. The verifier gathers\n* these across all spaces and keeps only the coordinates no contract space\n* declares — the standalone unclaimed-elements list, reported once for the\n* whole database.\n*/\nfunction collectExtraElementCoordinates(result, classify, classifyEntityKind) {\n\tconst seen = /* @__PURE__ */ new Map();\n\tfor (const issue of result.schema.issues) {\n\t\tif (issueOutcome(issue) !== \"not-expected\") continue;\n\t\tconst coordinate = schemaDiffIssueCoordinate(issue, classify, classifyEntityKind);\n\t\tif (coordinate === void 0) continue;\n\t\tseen.set(coordinateKey(coordinate), coordinate);\n\t}\n\treturn [...seen.values()];\n}\n//#endregion\n//#region src/aggregate/verifier.ts\n/**\n* Verify a {@link ContractSpaceAggregate} against the live database\n* state. Bundles two checks:\n*\n* - `markerCheck` per contract space: compare the live marker row against the\n* space's `headRef.hash` + `headRef.invariants`. Absence is a\n* distinct kind, not an error (callers — `db verify` strict vs\n* `db init` precondition — choose how to interpret it).\n* - `schemaCheck`: two distinct outputs from the per-space diffs.\n* `perSpace` — each space verified against the **full**\n* introspected schema, then its extras stripped, leaving the space's\n* declared nodes (its contract-satisfaction view; verdict is\n* missing/mismatch only). `unclaimed` — the extras gathered\n* across every space, deduplicated, and filtered to the names no contract\n* space declares (via the passive aggregate's ownership query); reported\n* once for the database. No schema is pruned before verifying.\n*\n* `markerCheck.orphanMarkers` lists every marker row whose `space` is\n* not a contract space of the aggregate. `db verify` callers reject orphans;\n* future tooling may not.\n*\n* Pure synchronous function; no I/O. The caller (CLI) gathers\n* `markersBySpaceId` and `schemaIntrospection` ahead of the call.\n*/\nfunction verifyMigration(input) {\n\ttry {\n\t\treturn runVerifyMigration(input);\n\t} catch (error) {\n\t\treturn notOk({\n\t\t\tkind: \"introspectionFailure\",\n\t\t\tdetail: error instanceof Error ? error.message : String(error)\n\t\t});\n\t}\n}\nfunction runVerifyMigration(input) {\n\tconst { aggregate, markersBySpaceId, schemaIntrospection, mode, verifySchemaForSpace, classifySubjectGranularity, classifyEntityKind } = input;\n\tconst allSpaces = [aggregate.app, ...aggregate.extensions];\n\tconst aggregateSpaceIds = new Set(allSpaces.map((m) => m.spaceId));\n\tconst markerPerSpace = /* @__PURE__ */ new Map();\n\tfor (const space of allSpaces) {\n\t\tconst marker = markersBySpaceId.get(space.spaceId) ?? null;\n\t\tif (marker === null) {\n\t\t\tmarkerPerSpace.set(space.spaceId, { kind: \"absent\" });\n\t\t\tcontinue;\n\t\t}\n\t\tconst headRef = requireHeadRef(space);\n\t\tif (marker.storageHash !== headRef.hash) {\n\t\t\tmarkerPerSpace.set(space.spaceId, {\n\t\t\t\tkind: \"hashMismatch\",\n\t\t\t\tmarkerHash: marker.storageHash,\n\t\t\t\texpected: headRef.hash\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst markerInvariants = new Set(marker.invariants);\n\t\tconst missing = headRef.invariants.filter((id) => !markerInvariants.has(id));\n\t\tif (missing.length > 0) {\n\t\t\tmarkerPerSpace.set(space.spaceId, {\n\t\t\t\tkind: \"missingInvariants\",\n\t\t\t\tmissing: [...missing].sort()\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tmarkerPerSpace.set(space.spaceId, { kind: \"ok\" });\n\t}\n\tconst orphanMarkers = [];\n\tfor (const [spaceId, row] of markersBySpaceId) if (row !== null && !aggregateSpaceIds.has(spaceId)) orphanMarkers.push({\n\t\tspaceId,\n\t\trow\n\t});\n\torphanMarkers.sort((a, b) => a.spaceId.localeCompare(b.spaceId));\n\tconst schemaPerSpace = /* @__PURE__ */ new Map();\n\tconst extraCoordinates = /* @__PURE__ */ new Map();\n\tfor (const space of allSpaces) {\n\t\tconst result = verifySchemaForSpace(schemaIntrospection, space, mode);\n\t\tschemaPerSpace.set(space.spaceId, stripExtraFindings(result, classifySubjectGranularity));\n\t\tfor (const coordinate of collectExtraElementCoordinates(result, classifySubjectGranularity, classifyEntityKind)) extraCoordinates.set(coordinateKey(coordinate), coordinate);\n\t}\n\tconst unclaimed = [...new Set([...extraCoordinates.values()].filter((coordinate) => !aggregate.declaresEntity(coordinate)).map((coordinate) => coordinate.entityName))].sort((a, b) => a.localeCompare(b));\n\treturn ok({\n\t\tmarkerCheck: {\n\t\t\tperSpace: markerPerSpace,\n\t\t\torphanMarkers\n\t\t},\n\t\tschemaCheck: {\n\t\t\tperSpace: schemaPerSpace,\n\t\t\tunclaimed\n\t\t}\n\t});\n}\n//#endregion\nexport { allStorageElementsExternal, buildFabricatedMigrationEdge, collectAggregateNamespaces, computeIntegrityViolations, createAggregateContractSpace, createContractSpaceAggregate, loadContractSpaceAggregate, loadProblemToViolation, planMigration, requireHeadRef, resolveRecordedPath, verifyMigration };\n\n//# sourceMappingURL=aggregate.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,kBAAkB,MAAM,SAAS;CACzC,OAAO,GAAG,KAAK,IAAI,WAAW;AAC/B;AACA,SAAS,0BAA0B,UAAU,cAAc,qBAAqB;CAC/E,IAAI;EACH,OAAO,oBAAoB,YAAY;CACxC,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,MAAM;EACzC,MAAM,mCAAmC,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CAC1G;AACD;AACA,eAAe,0BAA0B,eAAe,MAAM,qBAAqB;CAClF,MAAM,eAAe,MAAM,yBAAyB,eAAe,IAAI;CACvE,OAAO;EACN;EACA,aAAa,MAAM,wBAAwB,eAAe,IAAI;EAC9D,UAAU,0BAA0B,KAAK,oBAAoB,eAAe,IAAI,GAAG,eAAe,GAAG,cAAc,mBAAmB;CACvI;AACD;AACA,eAAe,kBAAkB,MAAM;CACtC,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,cAAc,CAAC,CAAC;CACzM,OAAO,GAAG;EACT,aAAa;GACZ,UAAU;GACV;EACD;EACA,aAAa;GACZ,UAAU;GACV;EACD;CACD,CAAC;AACF"}
1
+ {"version":3,"file":"aggregate-BOlLu7k7.mjs","names":["APP_SPACE_ID"],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/aggregate.mjs"],"sourcesContent":["import { M as errorRefNotResolvable, N as errorSpaceHeadRefMissing, i as errorContractDeserializationFailed, p as errorHashNotInGraph, r as errorBundleNotFoundForGraphNode, t as MigrationToolsError } from \"../errors-CcEpbfnE.mjs\";\nimport { n as readContractSnapshotDts, r as readContractSnapshotJson, t as contractSnapshotDir } from \"../contract-snapshot-store-BAmQkHe5.mjs\";\nimport { s as readMigrationsDir } from \"../io-DsViRB_O.mjs\";\nimport { t as EMPTY_CONTRACT_HASH } from \"../constants-CM-w38DQ.mjs\";\nimport { n as isGraphNode } from \"../graph-membership-BoITerZB.mjs\";\nimport { l as reconstructGraph, o as findPathWithDecision } from \"../migration-graph-DwXAHP6T.mjs\";\nimport { a as readRefsTolerant, r as readRef, t as HEAD_REF_NAME } from \"../refs-KVVlm3lE.mjs\";\nimport { c as isValidSpaceId, i as APP_SPACE_ID, l as spaceMigrationDirectory, r as readContractSpaceHeadRef, t as listContractSpaceDirectories, u as spaceRefsDirectory } from \"../verify-contract-spaces-DomK5uP5.mjs\";\nimport { join } from \"pathe\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { UNBOUND_NAMESPACE_ID, coordinateKey, elementCoordinates, entityAt } from \"@internal/framework-components/ir\";\nimport { effectiveControlPolicy } from \"@internal/contract/types\";\n//#region src/aggregate/aggregate.ts\nfunction contractAtMemoKey(hash, refName) {\n\treturn `${hash}\\0${refName ?? \"\"}`;\n}\nfunction deserializeContractAtPath(filePath, contractJson, deserializeContract) {\n\ttry {\n\t\treturn deserializeContract(contractJson);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error)) throw error;\n\t\tthrow errorContractDeserializationFailed(filePath, error instanceof Error ? error.message : String(error));\n\t}\n}\nasync function readContractSnapshotEntry(migrationsDir, hash, deserializeContract) {\n\tconst contractJson = await readContractSnapshotJson(migrationsDir, hash);\n\treturn {\n\t\tcontractJson,\n\t\tcontractDts: await readContractSnapshotDts(migrationsDir, hash),\n\t\tcontract: deserializeContractAtPath(join(contractSnapshotDir(migrationsDir, hash), \"contract.json\"), contractJson, deserializeContract)\n\t};\n}\nasync function resolveContractAt(args) {\n\tconst { hash, opts, refsDir, migrationsDir, packages, graph, deserializeContract } = args;\n\tconst refName = opts?.refName;\n\tif (refName !== void 0) {\n\t\tlet refEntry;\n\t\ttry {\n\t\t\trefEntry = await readRef(refsDir, refName);\n\t\t} catch (error) {\n\t\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.UNKNOWN_REF\") refEntry = void 0;\n\t\t\telse throw error;\n\t\t}\n\t\tif (refEntry) {\n\t\t\tconst { contractJson, contractDts, contract } = await readContractSnapshotEntry(migrationsDir, refEntry.hash, deserializeContract);\n\t\t\treturn {\n\t\t\t\thash: refEntry.hash,\n\t\t\t\tcontractJson,\n\t\t\t\tcontractDts,\n\t\t\t\tcontract,\n\t\t\t\tprovenance: \"ref\"\n\t\t\t};\n\t\t}\n\t\tif (isGraphNode(hash, graph)) return resolveGraphNodeContractAt({\n\t\t\thash,\n\t\t\tmigrationsDir,\n\t\t\tpackages,\n\t\t\tdeserializeContract,\n\t\t\texplicitLabel: refName\n\t\t});\n\t\tthrow errorRefNotResolvable(refName);\n\t}\n\tif (isGraphNode(hash, graph)) return resolveGraphNodeContractAt({\n\t\thash,\n\t\tmigrationsDir,\n\t\tpackages,\n\t\tdeserializeContract\n\t});\n\tthrow errorHashNotInGraph(hash, graph);\n}\nasync function resolveGraphNodeContractAt(args) {\n\tconst { hash, migrationsDir, packages, deserializeContract, explicitLabel } = args;\n\tif (!packages.find((pkg) => pkg.metadata.to === hash)) throw errorBundleNotFoundForGraphNode(hash, explicitLabel);\n\tconst { contractJson, contractDts, contract } = await readContractSnapshotEntry(migrationsDir, hash, deserializeContract);\n\treturn {\n\t\thash,\n\t\tcontractJson,\n\t\tcontractDts,\n\t\tcontract,\n\t\tprovenance: \"graph-node\"\n\t};\n}\n/**\n* Resolve a contract space's head ref, asserting it is present. The apply/verify\n* engine only runs after `checkIntegrity` has refused on `headRefMissing`,\n* so a space reaching the planner / verifier without a head ref is a\n* programming error (the integrity gate was skipped), not a user-facing\n* state. The app space's head ref is always synthesised, so this only\n* ever guards an ungated extension space.\n*/\nfunction requireHeadRef(space) {\n\tif (space.headRef === null) throw new InternalError(`Contract space \"${space.spaceId}\" has no head ref; the integrity gate must refuse a missing head ref before planning or verifying.`);\n\treturn space.headRef;\n}\n/**\n* Build a {@link AggregateContractSpace} with lazily-memoised `graph()`,\n* `contract()`, and `contractAt()` facets.\n*\n* `graph()` reconstructs the migration graph from `packages` on first\n* call and caches it. `contract()` calls `resolveContract` on first call\n* and caches the result; a throwing `resolveContract` (e.g. a missing or\n* undeserializable on-disk contract) re-throws on each call rather than\n* caching a value — `checkIntegrity` surfaces that as `contractUnreadable`.\n* `contractAt()` materializes the contract at an arbitrary graph node with\n* the same resolution order as plan-time ref resolution: the ref's pointer\n* plus the store entry keyed by the pointer's hash first (when\n* `opts.refName` is set), else the contract snapshot store entry keyed by\n* the matching package's `to` hash.\n*/\nfunction createAggregateContractSpace(args) {\n\tconst { spaceId, packages, refs, headRef, refsDir, migrationsDir, resolveContract, deserializeContract } = args;\n\tlet graphMemo;\n\tlet contractMemo;\n\tconst contractAtMemo = /* @__PURE__ */ new Map();\n\tfunction spaceGraph() {\n\t\tgraphMemo ??= reconstructGraph(packages);\n\t\treturn graphMemo;\n\t}\n\treturn {\n\t\tspaceId,\n\t\tpackages,\n\t\trefs,\n\t\theadRef,\n\t\tgraph: spaceGraph,\n\t\tcontract() {\n\t\t\tcontractMemo ??= resolveContract();\n\t\t\treturn contractMemo;\n\t\t},\n\t\tasync contractAt(hash, opts) {\n\t\t\tconst key = contractAtMemoKey(hash, opts?.refName);\n\t\t\tconst cached = contractAtMemo.get(key);\n\t\t\tif (cached) return cached;\n\t\t\tconst result = await resolveContractAt({\n\t\t\t\thash,\n\t\t\t\topts,\n\t\t\t\trefsDir,\n\t\t\t\tmigrationsDir,\n\t\t\t\tpackages,\n\t\t\t\tgraph: spaceGraph(),\n\t\t\t\tdeserializeContract\n\t\t\t});\n\t\t\tcontractAtMemo.set(key, result);\n\t\t\treturn result;\n\t\t}\n\t};\n}\n/**\n* Collect the union of every namespace declared across all contract spaces of an\n* aggregate (app + extensions) and return a minimal object with the shape\n* `{ storage: { namespaces } }` suitable for passing to\n* `familyInstance.introspect`.\n*\n* Callers invoke this after the integrity gate (`buildContractSpaceAggregate`\n* with `checkContracts: true`), so every `space.contract()` call is safe —\n* no try/catch is needed here.\n*/\nfunction collectAggregateNamespaces(aggregate) {\n\tconst merged = {};\n\tfor (const space of aggregate.spaces()) for (const [key, ns] of Object.entries(space.contract().storage.namespaces)) {\n\t\tconst existing = merged[key];\n\t\tmerged[key] = existing === void 0 ? ns : mergeNamespaceEntries(existing, ns);\n\t}\n\treturn { storage: { namespaces: merged } };\n}\n/**\n* Union two contract spaces' declarations for the same namespace id, per\n* entity kind. Two spaces may legitimately share a namespace (e.g. both\n* declaring tables in `public`); element-level disjointness is enforced by\n* `checkIntegrity`, so the kind maps never collide on a name — replacing the\n* whole namespace would silently drop the earlier space's entities.\n*/\nfunction mergeNamespaceEntries(a, b) {\n\tconst entries = { ...a.entries };\n\tfor (const [entityKind, kindMap] of Object.entries(b.entries)) entries[entityKind] = {\n\t\t...entries[entityKind],\n\t\t...kindMap\n\t};\n\treturn {\n\t\t...a,\n\t\tentries\n\t};\n}\n/**\n* Assemble a {@link ContractSpaceAggregate} value from its contract spaces and a\n* `checkIntegrity` implementation. The query methods (`listSpaces` /\n* `hasSpace` / `space` / `spaces`) are derived here so every aggregate —\n* loader-built or test-built — shares one query surface: `app` first,\n* then `extensions` in the order supplied (the loader sorts them\n* lex-ascending by `spaceId`).\n*/\nfunction createContractSpaceAggregate(args) {\n\tconst { targetId, app, extensions, checkIntegrity } = args;\n\tconst ordered = [app, ...extensions];\n\tconst byId = new Map(ordered.map((m) => [m.spaceId, m]));\n\tconst spaceDeclares = (space, coordinate) => {\n\t\tconst key = coordinateKey(coordinate);\n\t\tfor (const coord of elementCoordinates(space.contract().storage)) if (coordinateKey(coord) === key) return true;\n\t\treturn false;\n\t};\n\treturn {\n\t\ttargetId,\n\t\tapp,\n\t\textensions,\n\t\tlistSpaces: () => ordered.map((m) => m.spaceId),\n\t\thasSpace: (id) => byId.has(id),\n\t\tspace: (id) => byId.get(id),\n\t\tspaces: () => ordered,\n\t\tdeclaresEntity: (coordinate) => ordered.some((space) => spaceDeclares(space, coordinate)),\n\t\tdeclaringSpaces: (coordinate) => ordered.filter((space) => spaceDeclares(space, coordinate)).map((s) => s.spaceId),\n\t\tcheckIntegrity\n\t};\n}\n//#endregion\n//#region src/aggregate/all-external.ts\nfunction isControlPolicy(value) {\n\treturn value === \"managed\" || value === \"tolerated\" || value === \"external\" || value === \"observed\";\n}\n/**\n* True when every storage element the contract declares resolves to the\n* `external` control policy (ADR 224) — element-level `control` first, the\n* contract's `defaultControlPolicy` otherwise. A contract with no storage\n* elements is vacuously all-external.\n*\n* This is the precondition for advancing a contract space's marker without\n* any migrations (the declared-state resolution the db-init aggregate\n* planner and `migrate` share): only when nothing in the space is\n* Prisma-Next-managed can the storage structure be correct without a\n* migration having produced it. Any space that declares a managed element\n* but ships no migration graph is an authoring bug and must fail loudly.\n*/\nfunction allStorageElementsExternal(contract) {\n\tfor (const coordinate of elementCoordinates(contract.storage)) {\n\t\tconst entity = entityAt(contract.storage, coordinate);\n\t\tconst declared = entity !== null && typeof entity === \"object\" ? blindCast(entity).control : void 0;\n\t\tif (effectiveControlPolicy(isControlPolicy(declared) ? declared : void 0, contract.defaultControlPolicy) !== \"external\") return false;\n\t}\n\treturn true;\n}\n//#endregion\n//#region src/aggregate/check-integrity.ts\n/**\n* Walk the loaded model and return **every** integrity violation — never\n* bailing at the first. Structurally-derivable violations (load-time\n* problems, self-edges, missing / unreachable head refs) are always\n* produced; layout-drift checks require `declaredExtensions`, and\n* contract / target / disjointness checks require `checkContracts`.\n*/\nfunction computeIntegrityViolations(input, opts) {\n\tconst violations = [];\n\tfor (const { space, problems, refProblems, headRefProblem, isApp } of input.spaces) {\n\t\tconst { spaceId } = space;\n\t\tfor (const problem of problems) violations.push(loadProblemToViolation(spaceId, problem));\n\t\tfor (const refProblem of refProblems) violations.push({\n\t\t\tkind: \"refUnreadable\",\n\t\t\tspaceId,\n\t\t\trefName: refProblem.refName,\n\t\t\tdetail: refProblem.detail\n\t\t});\n\t\tif (headRefProblem !== null) violations.push({\n\t\t\tkind: \"refUnreadable\",\n\t\t\tspaceId,\n\t\t\trefName: headRefProblem.refName,\n\t\t\tdetail: headRefProblem.detail\n\t\t});\n\t\tfor (const pkg of space.packages) {\n\t\t\tconst from = pkg.metadata.from ?? \"empty\";\n\t\t\tconst isSelfEdge = from === pkg.metadata.to;\n\t\t\tconst hasDataOp = pkg.ops.some((op) => op.operationClass === \"data\");\n\t\t\tif (isSelfEdge && !hasDataOp) violations.push({\n\t\t\t\tkind: \"sameSourceAndTarget\",\n\t\t\t\tspaceId,\n\t\t\t\tdirName: pkg.dirName,\n\t\t\t\thash: from\n\t\t\t});\n\t\t}\n\t\tviolations.push(...duplicateMigrationHashViolations(spaceId, space.packages));\n\t\tif (!isApp && headRefProblem === null) {\n\t\t\tif (space.headRef === null) violations.push({\n\t\t\t\tkind: \"headRefMissing\",\n\t\t\t\tspaceId\n\t\t\t});\n\t\t\telse if (space.packages.length > 0 && !headRefPresentInGraph(space, space.headRef.hash)) violations.push({\n\t\t\t\tkind: \"headRefNotInGraph\",\n\t\t\t\tspaceId,\n\t\t\t\thash: space.headRef.hash\n\t\t\t});\n\t\t}\n\t}\n\tif (opts?.declaredExtensions !== void 0) violations.push(...layoutViolations(input.spaces, opts.declaredExtensions));\n\tif (opts?.checkContracts === true) violations.push(...contractViolations(input));\n\treturn violations;\n}\nfunction loadProblemToViolation(spaceId, problem) {\n\tswitch (problem.kind) {\n\t\tcase \"hashMismatch\": return {\n\t\t\tkind: \"hashMismatch\",\n\t\t\tspaceId,\n\t\t\tdirName: problem.dirName,\n\t\t\tstored: problem.stored,\n\t\t\tcomputed: problem.computed\n\t\t};\n\t\tcase \"providedInvariantsMismatch\": return {\n\t\t\tkind: \"providedInvariantsMismatch\",\n\t\t\tspaceId,\n\t\t\tdirName: problem.dirName\n\t\t};\n\t\tcase \"packageUnloadable\": return {\n\t\t\tkind: \"packageUnloadable\",\n\t\t\tspaceId,\n\t\t\tdirName: problem.dirName,\n\t\t\tdetail: problem.detail\n\t\t};\n\t}\n}\nfunction duplicateMigrationHashViolations(spaceId, packages) {\n\tconst dirNamesByHash = /* @__PURE__ */ new Map();\n\tfor (const pkg of packages) {\n\t\tconst hash = pkg.metadata.migrationHash;\n\t\tconst dirNames = dirNamesByHash.get(hash);\n\t\tif (dirNames) dirNames.push(pkg.dirName);\n\t\telse dirNamesByHash.set(hash, [pkg.dirName]);\n\t}\n\tconst out = [];\n\tfor (const [migrationHash, dirNames] of dirNamesByHash) if (dirNames.length > 1) out.push({\n\t\tkind: \"duplicateMigrationHash\",\n\t\tspaceId,\n\t\tmigrationHash,\n\t\tdirNames: [...dirNames].sort()\n\t});\n\treturn out;\n}\n/**\n* Whether a space's head-ref hash is present in its reconstructed graph.\n* An empty graph is reachable only by the empty-contract sentinel.\n*/\nfunction headRefPresentInGraph(space, headHash) {\n\tconst graph = space.graph();\n\tif (graph.nodes.size === 0) return headHash === EMPTY_CONTRACT_HASH;\n\treturn graph.nodes.has(headHash);\n}\nfunction layoutViolations(spaces, declaredExtensions) {\n\tconst out = [];\n\tconst extensionSpaceIds = new Set(spaces.filter((s) => !s.isApp).map((s) => s.space.spaceId));\n\tconst declaredIds = new Set(declaredExtensions.map((d) => d.id));\n\tfor (const id of [...extensionSpaceIds].sort()) if (!declaredIds.has(id)) out.push({\n\t\tkind: \"orphanSpaceDir\",\n\t\tspaceId: id\n\t});\n\tfor (const id of [...declaredIds].sort()) if (!extensionSpaceIds.has(id)) out.push({\n\t\tkind: \"declaredButUnmigrated\",\n\t\tspaceId: id\n\t});\n\treturn out;\n}\nfunction contractViolations(input) {\n\tconst out = [];\n\tconst elementClaimedBy = /* @__PURE__ */ new Map();\n\tconst elementLabel = /* @__PURE__ */ new Map();\n\tfor (const { space } of input.spaces) {\n\t\tlet contract;\n\t\ttry {\n\t\t\tcontract = space.contract();\n\t\t} catch (error) {\n\t\t\tout.push({\n\t\t\t\tkind: \"contractUnreadable\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\tdetail: detailOf$1(error)\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (contract.target !== input.targetId) out.push({\n\t\t\tkind: \"targetMismatch\",\n\t\t\tspaceId: space.spaceId,\n\t\t\texpected: input.targetId,\n\t\t\tactual: contract.target\n\t\t});\n\t\tfor (const coordinate of elementCoordinates(contract.storage)) {\n\t\t\tconst key = coordinateKey(coordinate);\n\t\t\tconst claimers = elementClaimedBy.get(key);\n\t\t\tif (claimers) claimers.push(space.spaceId);\n\t\t\telse {\n\t\t\t\telementClaimedBy.set(key, [space.spaceId]);\n\t\t\t\telementLabel.set(key, `${coordinate.namespaceId}.${coordinate.entityName}`);\n\t\t\t}\n\t\t}\n\t}\n\tconst disjointness = [];\n\tfor (const [key, claimedBy] of elementClaimedBy) if (claimedBy.length > 1) {\n\t\tconst element = elementLabel.get(key) ?? key;\n\t\tdisjointness.push({\n\t\t\tkind: \"disjointness\",\n\t\t\telement,\n\t\t\tclaimedBy: [...claimedBy].sort()\n\t\t});\n\t}\n\tdisjointness.sort((a, b) => a.kind === \"disjointness\" && b.kind === \"disjointness\" ? a.element.localeCompare(b.element) : 0);\n\tout.push(...disjointness);\n\treturn out;\n}\nfunction detailOf$1(error) {\n\tif (MigrationToolsError.is(error)) return error.why;\n\tif (error instanceof Error) return error.message;\n\treturn String(error);\n}\n//#endregion\n//#region src/aggregate/fabricated-migration-edge.ts\nfunction buildFabricatedMigrationEdge(args) {\n\treturn {\n\t\tdirName: \"\",\n\t\tmigrationHash: args.destinationStorageHash,\n\t\tfrom: args.currentMarkerStorageHash ?? \"\",\n\t\tto: args.destinationStorageHash,\n\t\toperationCount: args.operationCount,\n\t\t...args.destinationContractJson !== void 0 ? { destinationContractJson: args.destinationContractJson } : {}\n\t};\n}\n//#endregion\n//#region src/aggregate/loader.ts\n/**\n* Build a tolerant, queryable {@link ContractSpaceAggregate} from on-disk\n* migration state plus the caller's live app contract.\n*\n* Building **never throws on disk content**: a hash- or\n* invariants-mismatched package is retained, an unparseable package is\n* omitted, a missing extension head ref leaves `headRef: null`, and an\n* unreadable on-disk contract defers its failure to `space.contract()`.\n* Every such problem is judged by {@link ContractSpaceAggregate.checkIntegrity}\n* rather than aborting the load. The only rejections are catastrophic I/O\n* (a `migrations/` that exists but is unreadable for reasons other than\n* absence).\n*\n* The app space's head ref is synthesised from the live contract's\n* storage hash (the app contract is authored independently of the\n* migration graph), and `app.contract()` returns the supplied contract.\n* Extension spaces read their contract, refs, and head ref from disk.\n*/\nasync function loadContractSpaceAggregate(input) {\n\tconst { migrationsDir, deserializeContract, appContract } = input;\n\tconst targetId = appContract.target;\n\tconst appState = await loadAppSpace(migrationsDir, appContract, deserializeContract);\n\tconst extensionStates = await loadExtensionSpaces(migrationsDir, deserializeContract);\n\tconst spaces = [appState, ...extensionStates];\n\treturn createContractSpaceAggregate({\n\t\ttargetId,\n\t\tapp: appState.space,\n\t\textensions: extensionStates.map((state) => state.space),\n\t\tcheckIntegrity: (opts) => computeIntegrityViolations({\n\t\t\ttargetId,\n\t\t\tspaces\n\t\t}, opts)\n\t});\n}\nasync function loadAppSpace(migrationsDir, appContract, deserializeContract) {\n\tconst spaceDir = spaceMigrationDirectory(migrationsDir, APP_SPACE_ID);\n\tconst { packages, problems } = await readMigrationsDir(spaceDir, { migrationsDir });\n\tconst { refs, problems: refProblems } = await readRefsTolerant(spaceRefsDirectory(spaceDir));\n\treturn {\n\t\tspace: createAggregateContractSpace({\n\t\t\tspaceId: APP_SPACE_ID,\n\t\t\tpackages,\n\t\t\trefs,\n\t\t\theadRef: {\n\t\t\t\thash: appContract.storage.storageHash,\n\t\t\t\tinvariants: []\n\t\t\t},\n\t\t\trefsDir: spaceRefsDirectory(spaceDir),\n\t\t\tmigrationsDir,\n\t\t\tresolveContract: () => appContract,\n\t\t\tdeserializeContract\n\t\t}),\n\t\tproblems,\n\t\trefProblems,\n\t\theadRefProblem: null,\n\t\tisApp: true\n\t};\n}\nasync function loadExtensionSpaces(migrationsDir, deserializeContract) {\n\tconst extensionIds = (await listContractSpaceDirectories(migrationsDir)).filter((name) => name !== APP_SPACE_ID).filter(isValidSpaceId).sort();\n\tconst states = [];\n\tfor (const spaceId of extensionIds) states.push(await loadExtensionSpace(migrationsDir, spaceId, deserializeContract));\n\treturn states;\n}\nasync function loadExtensionSpace(migrationsDir, spaceId, deserializeContract) {\n\tconst spaceDir = spaceMigrationDirectory(migrationsDir, spaceId);\n\tconst { packages, problems } = await readMigrationsDir(spaceDir, { migrationsDir });\n\tconst { refs, problems: refProblems } = await readRefsTolerant(spaceRefsDirectory(spaceDir));\n\tconst { headRef, problem: headRefProblem } = await readHeadRefTolerant(migrationsDir, spaceId);\n\tconst rawContract = await readRawContractDeferred(migrationsDir, spaceId, headRef);\n\treturn {\n\t\tspace: createAggregateContractSpace({\n\t\t\tspaceId,\n\t\t\tpackages,\n\t\t\trefs,\n\t\t\theadRef,\n\t\t\trefsDir: spaceRefsDirectory(spaceDir),\n\t\t\tmigrationsDir,\n\t\t\tresolveContract: () => deserializeContract(rawContract()),\n\t\t\tdeserializeContract\n\t\t}),\n\t\tproblems,\n\t\trefProblems,\n\t\theadRefProblem,\n\t\tisApp: false\n\t};\n}\n/**\n* Read an extension's head ref, distinguishing a *genuinely absent*\n* `head.json` (`headRef: null`, no problem — judged `headRefMissing`)\n* from one that *exists but cannot be parsed* (`headRef: null` plus a\n* problem — judged `refUnreadable`, not `headRefMissing`).\n* `readContractSpaceHeadRef` already returns `null` only for ENOENT and\n* throws for unparseable / schema-invalid content, so the throw is the\n* corruption signal. Construction never throws on disk content.\n*/\nfunction isToleratedRefHeadReadError(error) {\n\tif (MigrationToolsError.is(error)) return true;\n\tif (!(error instanceof Error)) return false;\n\tconst code = error.code;\n\treturn code === \"ENOENT\" || code === \"EISDIR\";\n}\nasync function readHeadRefTolerant(migrationsDir, spaceId) {\n\ttry {\n\t\treturn {\n\t\t\theadRef: await readContractSpaceHeadRef(migrationsDir, spaceId),\n\t\t\tproblem: null\n\t\t};\n\t} catch (error) {\n\t\tif (!isToleratedRefHeadReadError(error)) throw error;\n\t\treturn {\n\t\t\theadRef: null,\n\t\t\tproblem: {\n\t\t\t\trefName: HEAD_REF_NAME,\n\t\t\t\tdetail: detailOf(error)\n\t\t\t}\n\t\t};\n\t}\n}\nfunction detailOf(error) {\n\treturn error instanceof Error ? error.message : String(error);\n}\n/**\n* Read the raw contract snapshot-store entry eagerly (cheap I/O) but defer\n* its (throwing) failure to call time, so a missing or unparseable store\n* entry becomes a `contract()` throw — surfaced as `contractUnreadable` —\n* rather than a construction failure. When `headRef` is absent there is no\n* hash to resolve against the store, so the deferred call always throws;\n* `checkIntegrity` already reports that case as `headRefMissing`, and a\n* `checkContracts` pass surfaces the same space as `contractUnreadable`.\n*/\nasync function readRawContractDeferred(migrationsDir, spaceId, headRef) {\n\tif (headRef === null) return () => {\n\t\tthrow errorSpaceHeadRefMissing(spaceId);\n\t};\n\ttry {\n\t\tconst raw = await readContractSnapshotJson(migrationsDir, headRef.hash);\n\t\treturn () => raw;\n\t} catch (error) {\n\t\treturn () => {\n\t\t\tthrow error;\n\t\t};\n\t}\n}\n//#endregion\n//#region src/aggregate/strategies/plan-from-diff.ts\n/**\n* Plan a migration for a single contract space from a diff against the full\n* live schema, delegating to the family's `createPlanner(...).plan(...)`.\n*\n* The planner diffs the whole introspected schema, so it sees other contract\n* spaces' tables as \"extras\"; the orchestration hands the planner the\n* aggregate as an ownership oracle so it can ask, per extra, whether any\n* space owns it — a sibling-owned table is left untouched, so the planner\n* never emits a destructive drop for it, and this strategy holds no ownership\n* logic of its own. The schema is never pruned before planning: cross-space\n* foreign keys need every sibling table visible to the diff.\n*\n* The produced plan's `targetId` is set from `aggregateTargetId`\n* (the aggregate's ambient target). The family's planner does not\n* stamp `targetId` on the produced plan; the aggregate planner is\n* the single point that knows the target.\n*\n* Used by:\n*\n* - The app space by default (CLI policy\n* `ignoreGraphFor: { app.spaceId }`).\n* - Any extension space whose `headRef.invariants` is empty and whose\n* graph is non-empty (the all-external, zero-migration-package case is\n* handled directly by the aggregate planner without calling this).\n*/\nasync function planFromDiff(input) {\n\tconst plannerResult = await input.migrations.createPlanner(input.adapter).plan({\n\t\tcontract: input.space.contract(),\n\t\tschema: input.schemaIntrospection,\n\t\tpolicy: input.operationPolicy,\n\t\tfromContract: null,\n\t\tframeworkComponents: input.frameworkComponents,\n\t\tspaceId: input.space.spaceId,\n\t\townership: input.ownership,\n\t\tsnapshotsImportPath: \"\"\n\t});\n\tif (plannerResult.kind === \"failure\") return {\n\t\tkind: \"failure\",\n\t\tconflicts: plannerResult.conflicts\n\t};\n\tconst producedPlan = plannerResult.plan;\n\tconst plan = new Proxy(producedPlan, {\n\t\tget(target, prop) {\n\t\t\tif (prop === \"targetId\") return input.aggregateTargetId;\n\t\t\treturn Reflect.get(target, prop, target);\n\t\t},\n\t\thas(target, prop) {\n\t\t\tif (prop === \"targetId\") return true;\n\t\t\treturn Reflect.has(target, prop);\n\t\t}\n\t});\n\tconst destinationStorageHash = producedPlan.destination.storageHash;\n\tconst producedOps = await Promise.all(producedPlan.operations);\n\tconst destinationContract = input.space.contract();\n\treturn {\n\t\tkind: \"ok\",\n\t\tresult: {\n\t\t\tplan,\n\t\t\tdisplayOps: producedOps,\n\t\t\tdestinationContract,\n\t\t\tstrategy: \"plan-from-diff\",\n\t\t\t...plannerResult.warnings && plannerResult.warnings.length > 0 ? { warnings: plannerResult.warnings } : {},\n\t\t\tmigrationEdges: [buildFabricatedMigrationEdge({\n\t\t\t\tcurrentMarkerStorageHash: input.currentMarker?.storageHash,\n\t\t\t\tdestinationStorageHash,\n\t\t\t\toperationCount: producedOps.length,\n\t\t\t\tdestinationContractJson: destinationContract\n\t\t\t})]\n\t\t}\n\t};\n}\n//#endregion\n//#region src/aggregate/strategies/resolve-recorded-path.ts\n/**\n* Resolve a contract space's hydrated migration graph to the path from the\n* live marker to `space.headRef.hash`, covering every required invariant.\n*\n* Pure synchronous function — no I/O. The aggregate's loader has\n* already integrity-checked every package and reconstructed the graph;\n* this resolves the path by looking up ops by `migrationHash` and\n* assembles a `MigrationPlan` with `targetId` set from the aggregate (no\n* placeholder cast).\n*\n* Required invariants are computed as `headRef.invariants \\ marker.invariants`\n* — the marker already declares some invariants satisfied; the path\n* only needs to provide the remainder. Mirrors today's\n* `computeExtensionSpaceApplyPath` semantics.\n*/\nfunction resolveRecordedPath(input) {\n\tconst { aggregateTargetId, space, currentMarker, refName } = input;\n\tconst headRef = requireHeadRef(space);\n\tconst graph = space.graph();\n\tconst packagesByMigrationHash = new Map(space.packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));\n\tconst fromHash = currentMarker?.storageHash ?? \"empty\";\n\tconst markerInvariants = new Set(currentMarker?.invariants ?? []);\n\tconst required = new Set(headRef.invariants.filter((id) => !markerInvariants.has(id)));\n\tconst outcome = findPathWithDecision(graph, fromHash, headRef.hash, {\n\t\trequired,\n\t\t...refName !== void 0 ? { refName } : {}\n\t});\n\tif (outcome.kind === \"unreachable\") return { kind: \"unreachable\" };\n\tif (outcome.kind === \"unsatisfiable\") return {\n\t\tkind: \"unsatisfiable\",\n\t\tmissing: outcome.missing\n\t};\n\tconst pathOps = [];\n\tconst providedInvariantsSet = /* @__PURE__ */ new Set();\n\tconst edgeRefs = [];\n\tfor (const edge of outcome.decision.selectedPath) {\n\t\tconst pkg = packagesByMigrationHash.get(edge.migrationHash);\n\t\tif (!pkg) throw new InternalError(`Migration package missing for edge ${edge.migrationHash} in space \"${space.spaceId}\". The hydrated migration graph and packagesByMigrationHash map are out of sync — this should be unreachable; report.`);\n\t\tfor (const op of pkg.ops) pathOps.push(op);\n\t\tfor (const invariant of pkg.metadata.providedInvariants) providedInvariantsSet.add(invariant);\n\t\tedgeRefs.push({\n\t\t\tmigrationHash: edge.migrationHash,\n\t\t\tdirName: edge.dirName,\n\t\t\tfrom: edge.from,\n\t\t\tto: edge.to,\n\t\t\toperationCount: pkg.ops.length,\n\t\t\t...pkg.endContractJson !== void 0 ? { destinationContractJson: pkg.endContractJson } : {}\n\t\t});\n\t}\n\treturn {\n\t\tkind: \"ok\",\n\t\tresult: {\n\t\t\tplan: {\n\t\t\t\ttargetId: aggregateTargetId,\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\torigin: currentMarker === null ? null : { storageHash: currentMarker.storageHash },\n\t\t\t\tdestination: { storageHash: headRef.hash },\n\t\t\t\toperations: pathOps,\n\t\t\t\tprovidedInvariants: [...providedInvariantsSet].sort()\n\t\t\t},\n\t\t\tdisplayOps: pathOps,\n\t\t\tdestinationContract: space.contract(),\n\t\t\tstrategy: \"resolve-recorded-path\",\n\t\t\tmigrationEdges: edgeRefs,\n\t\t\tpathDecision: outcome.decision\n\t\t}\n\t};\n}\n//#endregion\n//#region src/aggregate/planner.ts\n/**\n* Plan a migration across every contract space of a {@link ContractSpaceAggregate}.\n*\n* Per-space operation selection, in order; first match wins:\n*\n* 1. If `callerPolicy.ignoreGraphFor.has(space.spaceId)`:\n* - If `space.headRef.invariants` is empty → `planFromDiff`.\n* - Else → `policyConflict` (a diff-fabricated plan cannot satisfy\n* authored invariants).\n* 2. Else if `space.graph()` is non-empty AND `resolveRecordedPath`\n* succeeds → its result.\n* 3. Else if `space.graph()` is non-empty but unresolvable →\n* `extensionPathUnreachable` / `extensionPathUnsatisfiable`.\n* 4. Else (empty graph — the space ships no migration packages at all,\n* e.g. an all-external extension space like Supabase's `auth`/`storage`)\n* if `space.headRef.invariants` is empty → declare the no-op state\n* directly (zero ops, destination = head ref) without invoking the\n* family planner.\n* 5. Else → `extensionPathUnsatisfiable` (an empty graph cannot satisfy\n* non-empty invariants).\n*\n* Output `applyOrder` is `[...aggregate.extensions.map(spaceId), aggregate.app.spaceId]`\n* — extensions alphabetical, then app — matching today's\n* `concatenateSpaceApplyInputs` ordering. This preserves\n* `MigrationRunnerFailure.failingSpace` attribution byte-for-byte.\n*\n* Every emitted `MigrationPlan` has `targetId = aggregate.targetId`.\n* No placeholder cast; no patch step.\n*/\nasync function planMigration(input) {\n\tconst { aggregate, currentDBState, callerPolicy } = input;\n\tconst perSpace = /* @__PURE__ */ new Map();\n\tconst orderedSpaces = [...aggregate.extensions, aggregate.app];\n\tfor (const space of orderedSpaces) {\n\t\tconst currentMarker = currentDBState.markersBySpaceId.get(space.spaceId) ?? null;\n\t\tconst headRef = requireHeadRef(space);\n\t\tconst ignoreGraph = callerPolicy.ignoreGraphFor.has(space.spaceId);\n\t\tconst invariantsRequired = headRef.invariants.length > 0;\n\t\tif (ignoreGraph && invariantsRequired) return notOk({\n\t\t\tkind: \"policyConflict\",\n\t\t\tspaceId: space.spaceId,\n\t\t\tdetail: `\\`callerPolicy.ignoreGraphFor\\` requested for space \"${space.spaceId}\", but the contract space declares non-empty head-ref invariants (${headRef.invariants.join(\", \")}). A plan built directly from the contract IR cannot satisfy authored invariants — the graph must be walked. Either remove \"${space.spaceId}\" from \\`ignoreGraphFor\\` or amend the on-disk head ref to declare zero invariants.`\n\t\t});\n\t\tif (ignoreGraph) {\n\t\t\tconst diffOutcome = await planFromDiff({\n\t\t\t\taggregateTargetId: aggregate.targetId,\n\t\t\t\tcurrentMarker,\n\t\t\t\tspace,\n\t\t\t\townership: aggregate,\n\t\t\t\tschemaIntrospection: currentDBState.schemaIntrospection,\n\t\t\t\tadapter: input.adapter,\n\t\t\t\tmigrations: input.migrations,\n\t\t\t\tframeworkComponents: input.frameworkComponents,\n\t\t\t\toperationPolicy: input.operationPolicy\n\t\t\t});\n\t\t\tif (diffOutcome.kind === \"failure\") return notOk({\n\t\t\t\tkind: \"planFromDiffFailed\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\tconflicts: diffOutcome.conflicts\n\t\t\t});\n\t\t\tperSpace.set(space.spaceId, diffOutcome.result);\n\t\t\tcontinue;\n\t\t}\n\t\tif (space.graph().nodes.size > 0) {\n\t\t\tconst resolved = resolveRecordedPath({\n\t\t\t\taggregateTargetId: aggregate.targetId,\n\t\t\t\tspace,\n\t\t\t\tcurrentMarker\n\t\t\t});\n\t\t\tif (resolved.kind === \"ok\") {\n\t\t\t\tperSpace.set(space.spaceId, resolved.result);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (resolved.kind === \"unreachable\") return notOk({\n\t\t\t\tkind: \"extensionPathUnreachable\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\ttarget: headRef.hash\n\t\t\t});\n\t\t\treturn notOk({\n\t\t\t\tkind: \"extensionPathUnsatisfiable\",\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\tmissingInvariants: resolved.missing\n\t\t\t});\n\t\t}\n\t\tif (invariantsRequired) return notOk({\n\t\t\tkind: \"extensionPathUnsatisfiable\",\n\t\t\tspaceId: space.spaceId,\n\t\t\tmissingInvariants: [...headRef.invariants].sort()\n\t\t});\n\t\tif (!allStorageElementsExternal(space.contract())) return notOk({\n\t\t\tkind: \"extensionPathUnreachable\",\n\t\t\tspaceId: space.spaceId,\n\t\t\ttarget: headRef.hash\n\t\t});\n\t\tperSpace.set(space.spaceId, {\n\t\t\tplan: {\n\t\t\t\ttargetId: aggregate.targetId,\n\t\t\t\tspaceId: space.spaceId,\n\t\t\t\torigin: currentMarker === null ? null : { storageHash: currentMarker.storageHash },\n\t\t\t\tdestination: { storageHash: headRef.hash },\n\t\t\t\toperations: []\n\t\t\t},\n\t\t\tdisplayOps: [],\n\t\t\tdestinationContract: space.contract(),\n\t\t\tstrategy: \"declared-state\",\n\t\t\tmigrationEdges: [buildFabricatedMigrationEdge({\n\t\t\t\tcurrentMarkerStorageHash: currentMarker?.storageHash,\n\t\t\t\tdestinationStorageHash: headRef.hash,\n\t\t\t\toperationCount: 0\n\t\t\t})]\n\t\t});\n\t}\n\treturn ok({\n\t\tperSpace,\n\t\tapplyOrder: [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId]\n\t});\n}\nfunction pathIsUnder(path, prefix) {\n\tif (path.length < prefix.length) return false;\n\treturn prefix.every((segment, i) => path[i] === segment);\n}\n/**\n* Whether an issue's subject is a WHOLE top-level entity — as opposed to\n* something nested under one (e.g. a field, an index, or a policy). Calls\n* the injected `classify` capability, which resolves this from the issue's\n* node `nodeKind` (this aggregate never reaches into the node itself).\n* Absent `classify` (or a `classify` that returns nothing for this issue —\n* a family that doesn't classify) falls back to path shape: a\n* top-level entity's path is exactly its own name (one segment), so\n* anything deeper is nested.\n*/\nfunction isWholeEntityIssue(issue, classify) {\n\tconst granularity = classify?.(issue);\n\tif (granularity !== void 0) return granularity === \"entity\";\n\treturn issue.path.length === 1;\n}\n/**\n* A contract space's contract-satisfaction view. Strips the top-level entity\n* extras — the `not-expected` findings on whole-entity nodes (plus the\n* findings the differ's total descent reported under those entities). Those\n* belong to the standalone unclaimed-elements list\n* ({@link collectExtraElementCoordinates}), never a space's own verdict.\n*\n* Nested `not-expected` findings (an extra field on the space's own\n* declared entity…) and structural findings (an undeclared policy) are\n* the space's **own drift** and stay.\n*\n* The verdict recomputes from the surviving list: the per-space result is\n* issue-based (`ok` ⇔ the list is empty), so a space whose only failures\n* were top-level extras passes after the strip.\n*/\nfunction stripExtraFindings(result, classify) {\n\tconst droppedTablePaths = result.schema.issues.filter((issue) => issueOutcome(issue) === \"not-expected\" && isWholeEntityIssue(issue, classify)).map((issue) => issue.path);\n\tconst issues = result.schema.issues.filter((issue) => {\n\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\tif (classify?.(issue) === \"structural\") return true;\n\t\treturn !droppedTablePaths.some((prefix) => pathIsUnder(issue.path, prefix));\n\t});\n\tif (issues.length === result.schema.issues.length) return result;\n\tconst ok = issues.length === 0;\n\tconst { code: staleCode, ...envelope } = result;\n\treturn {\n\t\t...envelope,\n\t\tok,\n\t\t...ok ? {} : { code: result.code ?? \"CONTRACT.MARKER_REQUIRED\" },\n\t\tsummary: ok ? \"Database schema satisfies contract\" : result.summary,\n\t\tschema: {\n\t\t\tissues,\n\t\t\t...result.schema.warnings !== void 0 ? { warnings: result.schema.warnings } : {}\n\t\t}\n\t};\n}\n/**\n* The schema-IR entity coordinate a `not-expected` `SchemaDiffIssue`\n* addresses, when its subject is a whole top-level entity. A nested leaf\n* (a field, an index, a policy on an undeclared entity) has no entity of\n* its own to report here.\n*\n* The whole-entity's name is the last path segment: the differ builds each\n* path from its nodes' ids, so at a whole-entity finding the last segment is\n* exactly the entity name — for every family, whether or not it stamps a\n* granularity. The namespace segment only exists for namespace-qualified\n* paths (`['database', namespaceId, entityName]`); single-namespace families\n* (a flat `['database', entityName]`, or a bare `[entityName]`) have no\n* separate segment, so every entity they declare implicitly shares one\n* namespace — the same sentinel the aggregate's own coordinate walk uses\n* for those families.\n*\n* `entityKind` is asked from the injected `classifyEntityKind` capability —\n* this module never names a family entity kind itself. Absent a classifier\n* (the classifier-absent path-shape fallback, e.g. a document family) the\n* coordinate carries {@link UNCLASSIFIED_ENTITY_KIND}: no ownership\n* consumer queries `declaresEntity` for a family in that state today, so\n* nothing reads the value as true.\n*/\nfunction schemaDiffIssueCoordinate(issue, classify, classifyEntityKind) {\n\tif (!isWholeEntityIssue(issue, classify)) return void 0;\n\tconst entityName = issue.path[issue.path.length - 1];\n\tif (entityName === void 0) return void 0;\n\treturn {\n\t\tnamespaceId: issue.path.length === 3 ? issue.path[1] ?? UNBOUND_NAMESPACE_ID : UNBOUND_NAMESPACE_ID,\n\t\tentityKind: classifyEntityKind?.(issue) ?? \"unclassified-entity\",\n\t\tentityName\n\t};\n}\n/**\n* The schema-IR entity coordinates of every live element this contract\n* space's diff reports as `not-expected`, deduplicated. The verifier gathers\n* these across all spaces and keeps only the coordinates no contract space\n* declares — the standalone unclaimed-elements list, reported once for the\n* whole database.\n*/\nfunction collectExtraElementCoordinates(result, classify, classifyEntityKind) {\n\tconst seen = /* @__PURE__ */ new Map();\n\tfor (const issue of result.schema.issues) {\n\t\tif (issueOutcome(issue) !== \"not-expected\") continue;\n\t\tconst coordinate = schemaDiffIssueCoordinate(issue, classify, classifyEntityKind);\n\t\tif (coordinate === void 0) continue;\n\t\tseen.set(coordinateKey(coordinate), coordinate);\n\t}\n\treturn [...seen.values()];\n}\n//#endregion\n//#region src/aggregate/verifier.ts\n/**\n* Verify a {@link ContractSpaceAggregate} against the live database\n* state. Bundles two checks:\n*\n* - `markerCheck` per contract space: compare the live marker row against the\n* space's `headRef.hash` + `headRef.invariants`. Absence is a\n* distinct kind, not an error (callers — `db verify` strict vs\n* `db init` precondition — choose how to interpret it).\n* - `schemaCheck`: two distinct outputs from the per-space diffs.\n* `perSpace` — each space verified against the **full**\n* introspected schema, then its extras stripped, leaving the space's\n* declared nodes (its contract-satisfaction view; verdict is\n* missing/mismatch only). `unclaimed` — the extras gathered\n* across every space, deduplicated, and filtered to the names no contract\n* space declares (via the passive aggregate's ownership query); reported\n* once for the database. No schema is pruned before verifying.\n*\n* `markerCheck.orphanMarkers` lists every marker row whose `space` is\n* not a contract space of the aggregate. `db verify` callers reject orphans;\n* future tooling may not.\n*\n* Pure synchronous function; no I/O. The caller (CLI) gathers\n* `markersBySpaceId` and `schemaIntrospection` ahead of the call.\n*/\nfunction verifyMigration(input) {\n\ttry {\n\t\treturn runVerifyMigration(input);\n\t} catch (error) {\n\t\treturn notOk({\n\t\t\tkind: \"introspectionFailure\",\n\t\t\tdetail: error instanceof Error ? error.message : String(error)\n\t\t});\n\t}\n}\nfunction runVerifyMigration(input) {\n\tconst { aggregate, markersBySpaceId, schemaIntrospection, mode, verifySchemaForSpace, classifySubjectGranularity, classifyEntityKind } = input;\n\tconst allSpaces = [aggregate.app, ...aggregate.extensions];\n\tconst aggregateSpaceIds = new Set(allSpaces.map((m) => m.spaceId));\n\tconst markerPerSpace = /* @__PURE__ */ new Map();\n\tfor (const space of allSpaces) {\n\t\tconst marker = markersBySpaceId.get(space.spaceId) ?? null;\n\t\tif (marker === null) {\n\t\t\tmarkerPerSpace.set(space.spaceId, { kind: \"absent\" });\n\t\t\tcontinue;\n\t\t}\n\t\tconst headRef = requireHeadRef(space);\n\t\tif (marker.storageHash !== headRef.hash) {\n\t\t\tmarkerPerSpace.set(space.spaceId, {\n\t\t\t\tkind: \"hashMismatch\",\n\t\t\t\tmarkerHash: marker.storageHash,\n\t\t\t\texpected: headRef.hash\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst markerInvariants = new Set(marker.invariants);\n\t\tconst missing = headRef.invariants.filter((id) => !markerInvariants.has(id));\n\t\tif (missing.length > 0) {\n\t\t\tmarkerPerSpace.set(space.spaceId, {\n\t\t\t\tkind: \"missingInvariants\",\n\t\t\t\tmissing: [...missing].sort()\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tmarkerPerSpace.set(space.spaceId, { kind: \"ok\" });\n\t}\n\tconst orphanMarkers = [];\n\tfor (const [spaceId, row] of markersBySpaceId) if (row !== null && !aggregateSpaceIds.has(spaceId)) orphanMarkers.push({\n\t\tspaceId,\n\t\trow\n\t});\n\torphanMarkers.sort((a, b) => a.spaceId.localeCompare(b.spaceId));\n\tconst schemaPerSpace = /* @__PURE__ */ new Map();\n\tconst extraCoordinates = /* @__PURE__ */ new Map();\n\tfor (const space of allSpaces) {\n\t\tconst result = verifySchemaForSpace(schemaIntrospection, space, mode);\n\t\tschemaPerSpace.set(space.spaceId, stripExtraFindings(result, classifySubjectGranularity));\n\t\tfor (const coordinate of collectExtraElementCoordinates(result, classifySubjectGranularity, classifyEntityKind)) extraCoordinates.set(coordinateKey(coordinate), coordinate);\n\t}\n\tconst unclaimed = [...new Set([...extraCoordinates.values()].filter((coordinate) => !aggregate.declaresEntity(coordinate)).map((coordinate) => coordinate.entityName))].sort((a, b) => a.localeCompare(b));\n\treturn ok({\n\t\tmarkerCheck: {\n\t\t\tperSpace: markerPerSpace,\n\t\t\torphanMarkers\n\t\t},\n\t\tschemaCheck: {\n\t\t\tperSpace: schemaPerSpace,\n\t\t\tunclaimed\n\t\t}\n\t});\n}\n//#endregion\nexport { allStorageElementsExternal, buildFabricatedMigrationEdge, collectAggregateNamespaces, computeIntegrityViolations, createAggregateContractSpace, createContractSpaceAggregate, loadContractSpaceAggregate, loadProblemToViolation, planMigration, requireHeadRef, resolveRecordedPath, verifyMigration };\n\n//# sourceMappingURL=aggregate.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,kBAAkB,MAAM,SAAS;CACzC,OAAO,GAAG,KAAK,IAAI,WAAW;AAC/B;AACA,SAAS,0BAA0B,UAAU,cAAc,qBAAqB;CAC/E,IAAI;EACH,OAAO,oBAAoB,YAAY;CACxC,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,GAAG,MAAM;EACzC,MAAM,mCAAmC,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CAC1G;AACD;AACA,eAAe,0BAA0B,eAAe,MAAM,qBAAqB;CAClF,MAAM,eAAe,MAAM,yBAAyB,eAAe,IAAI;CACvE,OAAO;EACN;EACA,aAAa,MAAM,wBAAwB,eAAe,IAAI;EAC9D,UAAU,0BAA0B,KAAK,oBAAoB,eAAe,IAAI,GAAG,eAAe,GAAG,cAAc,mBAAmB;CACvI;AACD;AACA,eAAe,kBAAkB,MAAM;CACtC,MAAM,E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CAAC,CAAC;CACzM,OAAO,GAAG;EACT,aAAa;GACZ,UAAU;GACV;EACD;EACA,aAAa;GACZ,UAAU;GACV;EACD;CACD,CAAC;AACF"}
@@ -122,7 +122,7 @@ 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-next init`), c12
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.
@@ -287,7 +287,7 @@ interface SanitisedCommand {
287
287
  *
288
288
  * Sanitiser contract — no flag values, no positionals, no raw argv:
289
289
  * - Drop the root program name (`commandPath[0]`); the wire ships
290
- * `migration new`, not `prisma-next migration new`.
290
+ * `migration new`, not `prisma migration new`.
291
291
  * - Emit only options whose Commander source is `cli`.
292
292
  * - Emit the long user-facing flag spelling without the `--` prefix;
293
293
  * never emit Commander's camelCase attribute names.
@@ -3,11 +3,11 @@ import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import { blindCast } from "@prisma/orm-framework/utils/casts";
4
4
  import { dirname, join } from "pathe";
5
5
  import { randomUUID } from "node:crypto";
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-IkV4Zai4.mjs
10
+ //#region ../../../1-framework/3-tooling/cli-telemetry/dist/enrich-rd5g3THY.mjs
11
11
  const EMPTY_PROJECT_CONFIG = {
12
12
  databaseTarget: null,
13
13
  extensions: []
@@ -16,7 +16,7 @@ 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-next init`), c12
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.
@@ -36,15 +36,12 @@ async function loadProjectConfig(projectRoot) {
36
36
  rcFile: false,
37
37
  globalRc: false
38
38
  });
39
- let result = await load("prisma");
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"] !== void 0) {
44
- const orm = config["orm"];
45
- if (orm === null || typeof orm !== "object" || Array.isArray(orm)) return EMPTY_PROJECT_CONFIG;
46
- config = blindCast(orm);
47
- }
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);
48
45
  if ((await import("@prisma/orm-framework/config/config-validation")).collectConfigIssues(config).length > 0) return EMPTY_PROJECT_CONFIG;
49
46
  const validConfig = blindCast(config);
50
47
  return {
@@ -143,7 +140,7 @@ function flagNameFromLongName(longName) {
143
140
  *
144
141
  * Sanitiser contract — no flag values, no positionals, no raw argv:
145
142
  * - Drop the root program name (`commandPath[0]`); the wire ships
146
- * `migration new`, not `prisma-next migration new`.
143
+ * `migration new`, not `prisma migration new`.
147
144
  * - Emit only options whose Commander source is `cli`.
148
145
  * - Emit the long user-facing flag spelling without the `--` prefix;
149
146
  * never emit Commander's camelCase attribute names.
@@ -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,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,SAAS,MAAM,KAAK,QAAQ;EAChC,IAAI,CAAC,OAAO,UAAU,OAAO,KAAK,OAAO,MAAM,CAAC,CAAC,WAAW,GAAG,SAAS,MAAM,KAAK,aAAa;EAChG,IAAI,SAAS,OAAO,UAAU;EAC9B,IAAI,WAAW,QAAQ,OAA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B,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-rd5g3THY.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 `@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 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\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-rd5g3THY.mjs.map","import { n as loadProjectConfig } from \"../enrich-rd5g3THY.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 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,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,KAAK,GAAG,OAAO;EAC/C,MAAM,MAAM,OAAO;EACnB,IAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAAG,OAAO;EAC1E,SAAS,UAAU,GAAG;EACtB,KAAK,MAAM,OAAO,kDAAA,CAAuC,oBAAoB,MAAM,CAAC,CAAC,SAAS,GAAG,OAAO;EACxG,MAAM,cAAc,UAAU,MAAM;EACpC,OAAO;GACN,gBAAgB,YAAY,OAAO;GACnC,aAAa,YAAY,cAAc,CAAC,EAAA,CAAG,KAAK,SAAS,KAAK,EAAE;EACjE;CACD,QAAQ;EACP,OAAO;CACR;AACD;;;;;;;ACnCA,MAAM,wBAAwB;;;;AAI9B,MAAM,0BAA0B;;;;;;;;;;;;AAYhC,SAAS,yBAAyB,MAAM,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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"}
package/dist/cli.d.mts CHANGED
@@ -41,8 +41,6 @@ interface LoadOrmConfigOptions {
41
41
  readonly cwd: string;
42
42
  /** A non-default config file, resolved against `cwd` when relative. */
43
43
  readonly configPath?: string;
44
- /** Receives one message per deprecated spelling the loader accepted. */
45
- readonly warn?: (message: string) => void;
46
44
  }
47
45
  /**
48
46
  * Builds the engine's `Runtime.config` from `prisma.config.ts`.
@@ -51,9 +49,7 @@ interface LoadOrmConfigOptions {
51
49
  * ORM's c12 loader evaluates the module asynchronously and finalizes paths
52
50
  * against the config file's own directory. It reads the same shape the engine
53
51
  * does — defineConfig from `@prisma/cli-engine` with the whole Prisma Next
54
- * configuration nested as the single `orm` section — and keeps reading the
55
- * deprecated `prisma-next.config.ts` filename and flat shape, surfacing each
56
- * through `warn`.
52
+ * configuration nested as the single `orm` section.
57
53
  *
58
54
  * Only failures that prevent evaluation entirely are diagnostics here, and
59
55
  * they carry `section: null` so they fail exactly the commands that read
@@ -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;;;cAGnF,+CAA+C,cAAc;;;;;;;;cAQ7D,+CAA+C;;;UAGnD;;WAEC;;WAEA;;WAEA,QAAQ;;;;;;;;;;;;;;;;;iBAiBF,cAAc,SAAS,uBAAuB,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;;;cAGnF,+CAA+C,cAAc;;;;;;;;cAQ7D,+CAA+C;;;UAGnD;;WAEC;;WAEA;;;;;;;;;;;;;;;iBAeM,cAAc,SAAS,uBAAuB,QAAQ"}