@prisma/orm-toolchain 8.0.0-rc.24-dev.23 → 8.0.0-rc.24-dev.24

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 (74) hide show
  1. package/dist/{aggregate-BmhAhXYL.d.mts → aggregate-C6PGBKyb.d.mts} +7 -3
  2. package/dist/aggregate-C6PGBKyb.d.mts.map +1 -0
  3. package/dist/{aggregate-BIjV2dM9.mjs → aggregate-CRIdmKmq.mjs} +12 -8
  4. package/dist/aggregate-CRIdmKmq.mjs.map +1 -0
  5. package/dist/{caught-errors-Cll-zcA1-MXR0HE1V.mjs → caught-errors-I1l50iPc-D_-F2M3t.mjs} +21 -5
  6. package/dist/caught-errors-I1l50iPc-D_-F2M3t.mjs.map +1 -0
  7. package/dist/cli.d.mts +1 -1
  8. package/dist/cli.mjs +187 -67
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/cli__control-api.d.mts +17 -5
  11. package/dist/cli__control-api.d.mts.map +1 -1
  12. package/dist/cli__control-api.mjs +2 -2
  13. package/dist/cli__control-api__testing.d.mts +1 -1
  14. package/dist/cli__migration-cli.mjs +3 -3
  15. package/dist/cli__migration-cli.mjs.map +1 -1
  16. package/dist/{contract-snapshot-store-nWnsWPPQ-rJ94UCcE.mjs → contract-snapshot-store-B0fRbVHB-BN2g8BKh.mjs} +3 -3
  17. package/dist/{contract-snapshot-store-nWnsWPPQ-rJ94UCcE.mjs.map → contract-snapshot-store-B0fRbVHB-BN2g8BKh.mjs.map} +1 -1
  18. package/dist/{db-sign-DGSaPRQ--B_9CmDng.d.mts → db-sign-Bv-FZMAD-uQhMNCC7.d.mts} +42 -26
  19. package/dist/db-sign-Bv-FZMAD-uQhMNCC7.d.mts.map +1 -0
  20. package/dist/{errors-DXha_4l--relAaiI4.mjs → errors-BMq40nYH-Cg8PBect.mjs} +33 -4
  21. package/dist/errors-BMq40nYH-Cg8PBect.mjs.map +1 -0
  22. package/dist/{errors-CLwhWJiz.d.mts → errors-oP9FaWWm.d.mts} +5 -2
  23. package/dist/errors-oP9FaWWm.d.mts.map +1 -0
  24. package/dist/{graph-membership-DxpNgxfZ-BfqA-H7V.mjs → graph-membership-D7m41lWA-B68g1CRS.mjs} +3 -3
  25. package/dist/{graph-membership-DxpNgxfZ-BfqA-H7V.mjs.map → graph-membership-D7m41lWA-B68g1CRS.mjs.map} +1 -1
  26. package/dist/{invariants-DrF9p5Gd-BF70vGl1.mjs → invariants-DxCj82g2-DhGkStla.mjs} +3 -3
  27. package/dist/{invariants-DrF9p5Gd-BF70vGl1.mjs.map → invariants-DxCj82g2-DhGkStla.mjs.map} +1 -1
  28. package/dist/{io-4O31S6Ei-DvsFKW_Y.mjs → io-B39zsxMm-D5Wcf6cf.mjs} +5 -5
  29. package/dist/{io-4O31S6Ei-DvsFKW_Y.mjs.map → io-B39zsxMm-D5Wcf6cf.mjs.map} +1 -1
  30. package/dist/{migration-CWyjX9vz.mjs → migration-DTmtOJ0n.mjs} +3 -3
  31. package/dist/{migration-CWyjX9vz.mjs.map → migration-DTmtOJ0n.mjs.map} +1 -1
  32. package/dist/migration-tools.d.mts +6 -5
  33. package/dist/migration-tools.mjs +12 -12
  34. package/dist/migration-tools__aggregate.d.mts +1 -1
  35. package/dist/migration-tools__aggregate.mjs +1 -1
  36. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  37. package/dist/migration-tools__errors.d.mts +2 -2
  38. package/dist/migration-tools__errors.mjs +2 -2
  39. package/dist/migration-tools__invariants.mjs +1 -1
  40. package/dist/migration-tools__io.mjs +1 -1
  41. package/dist/migration-tools__migration-graph.mjs +1 -1
  42. package/dist/migration-tools__migration.mjs +1 -1
  43. package/dist/migration-tools__ref-resolution.d.mts +1 -1
  44. package/dist/migration-tools__ref-resolution.mjs +1 -1
  45. package/dist/migration-tools__refs.d.mts +3 -2
  46. package/dist/migration-tools__refs.mjs +2 -2
  47. package/dist/migration-tools__spaces.mjs +2 -2
  48. package/dist/{ref-D4GWEHQU-BOqb4i_E.mjs → ref-DfuqRCA7-CPPoVHY9.mjs} +459 -101
  49. package/dist/ref-DfuqRCA7-CPPoVHY9.mjs.map +1 -0
  50. package/dist/{ref-resolution-Eo0QHp4f.mjs → ref-resolution-C9j2SSb6.mjs} +2 -2
  51. package/dist/{ref-resolution-Eo0QHp4f.mjs.map → ref-resolution-C9j2SSb6.mjs.map} +1 -1
  52. package/dist/{ref-resolution-BPhR-kta.d.mts → ref-resolution-UwnXbc9M.d.mts} +2 -2
  53. package/dist/{ref-resolution-BPhR-kta.d.mts.map → ref-resolution-UwnXbc9M.d.mts.map} +1 -1
  54. package/dist/refs-B5N_vHH7.d.mts +1 -0
  55. package/dist/{refs-BNCUu58Y-BIso5Jfg.d.mts → refs-CkGjbosE-CLkrSkQ4.d.mts} +18 -3
  56. package/dist/refs-CkGjbosE-CLkrSkQ4.d.mts.map +1 -0
  57. package/dist/{refs-DM3q3IZC-BC6H6P0X.mjs → refs-t_JbIjGo-CRpBRRkq.mjs} +79 -20
  58. package/dist/refs-t_JbIjGo-CRpBRRkq.mjs.map +1 -0
  59. package/dist/{spaces-BIABdklg.mjs → spaces-OVZ0QzWJ.mjs} +5 -5
  60. package/dist/{spaces-BIABdklg.mjs.map → spaces-OVZ0QzWJ.mjs.map} +1 -1
  61. package/dist/{verify-contract-spaces-BmnQiKDj-JwT2fAPh.mjs → verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs} +11 -7
  62. package/dist/verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs.map +1 -0
  63. package/dist/vite-plugin-contract-emit.mjs +1 -1
  64. package/package.json +12 -12
  65. package/dist/aggregate-BIjV2dM9.mjs.map +0 -1
  66. package/dist/aggregate-BmhAhXYL.d.mts.map +0 -1
  67. package/dist/caught-errors-Cll-zcA1-MXR0HE1V.mjs.map +0 -1
  68. package/dist/db-sign-DGSaPRQ--B_9CmDng.d.mts.map +0 -1
  69. package/dist/errors-CLwhWJiz.d.mts.map +0 -1
  70. package/dist/errors-DXha_4l--relAaiI4.mjs.map +0 -1
  71. package/dist/ref-D4GWEHQU-BOqb4i_E.mjs.map +0 -1
  72. package/dist/refs-BNCUu58Y-BIso5Jfg.d.mts.map +0 -1
  73. package/dist/refs-DM3q3IZC-BC6H6P0X.mjs.map +0 -1
  74. package/dist/verify-contract-spaces-BmnQiKDj-JwT2fAPh.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
2
- import { l as validateRefName } from "./refs-DM3q3IZC-BC6H6P0X.mjs";
2
+ import { u as validateRefName } from "./refs-t_JbIjGo-CRpBRRkq.mjs";
3
3
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
4
4
  //#region ../../../1-framework/3-tooling/migration/dist/exports/ref-resolution.mjs
5
5
  const FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;
@@ -271,4 +271,4 @@ function parseMigrationRef(input, ctx) {
271
271
  //#endregion
272
272
  export { findEdgeByDirName as a, parseContractRef as c, WORKING_CONTRACT_REF as i, parseMigrationRef as l, LIVE_MARKER_REF as n, isLiveMarkerRef as o, RESERVED_CONTRACT_REFS as r, isReservedContractRef as s, EMPTY_CONTRACT_REF as t };
273
273
 
274
- //# sourceMappingURL=ref-resolution-Eo0QHp4f.mjs.map
274
+ //# sourceMappingURL=ref-resolution-C9j2SSb6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ref-resolution-Eo0QHp4f.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/ref-resolution.mjs"],"sourcesContent":["import { t as EMPTY_CONTRACT_HASH } from \"../constants-CM-w38DQ.mjs\";\nimport { l as validateRefName } from \"../refs-DM3q3IZC.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\n//#region src/refs/types.ts\nconst FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;\nconst HEX_PREFIX_PATTERN = /^[0-9a-f]{6,}$/;\nfunction isFullHash(input) {\n\treturn FULL_HASH_PATTERN.test(input);\n}\nfunction isHexPrefix(input) {\n\treturn HEX_PREFIX_PATTERN.test(input);\n}\nfunction findEdgeByDirName(graph, dirName) {\n\tfor (const edges of graph.forwardChain.values()) for (const edge of edges) if (edge.dirName === dirName) return edge;\n}\n//#endregion\n//#region src/refs/contract-ref.ts\nconst WORKING_CONTRACT_REF = \"@contract\";\nconst LIVE_MARKER_REF = \"@db\";\nconst EMPTY_CONTRACT_REF = \"@empty\";\n/** The reserved references, in a fixed order: `@contract`, `@db`, `@empty`. */\nconst RESERVED_CONTRACT_REFS = [\n\tWORKING_CONTRACT_REF,\n\t\"@db\",\n\tEMPTY_CONTRACT_REF\n];\n/** True for a reserved reference, which resolves from contract.json, the database, or the empty contract rather than from a contract recorded in the migrations directory. */\nfunction isReservedContractRef(input) {\n\treturn RESERVED_CONTRACT_REFS.includes(input);\n}\n/** True for `@db`, the only reserved reference that needs a database read to resolve. */\nfunction isLiveMarkerRef(input) {\n\treturn input === \"@db\";\n}\n/**\n* Resolve a user-supplied string to a contract hash using the unified\n* contract-reference grammar.\n*\n* Accepted forms:\n* - `@contract` — the on-disk working contract hash (offline; requires\n* `ctx.contractHash` to be set)\n* - `@db` — the live database marker. Callers that accept `@db` test\n* `isLiveMarkerRef(input)` before parsing and resolve it from the marker;\n* the `reserved-db` result carries a placeholder hash that must not be used\n* - `@empty` — the empty contract (offline; resolves to\n* `EMPTY_CONTRACT_HASH`, the origin with no prior storage state)\n* - Full storage hash (64 hex chars or `empty`)\n* - Hex prefix (6+ hex chars, must uniquely identify one contract)\n* - Ref name (looked up in the refs index)\n* - Migration directory name (resolves to the migration's `to`-contract)\n* - `<dir>^` (resolves to the migration's `from`-contract)\n*/\nfunction parseContractRef(input, ctx) {\n\tif (!input) return notOk({\n\t\tkind: \"invalid-format\",\n\t\tinput,\n\t\treason: \"Reference cannot be empty\"\n\t});\n\tif (input === \"@contract\") {\n\t\tif (ctx.contractHash === void 0) return notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t\treturn ok({\n\t\t\thash: ctx.contractHash,\n\t\t\tprovenance: { kind: \"reserved-contract\" }\n\t\t});\n\t}\n\tif (input === \"@db\") return ok({\n\t\thash: \"\",\n\t\tprovenance: { kind: \"reserved-db\" }\n\t});\n\tif (input === \"@empty\") return ok({\n\t\thash: EMPTY_CONTRACT_HASH,\n\t\tprovenance: { kind: \"reserved-empty\" }\n\t});\n\tif (isFullHash(input)) {\n\t\tif (ctx.graph.nodes.has(input)) return ok({\n\t\t\thash: input,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"hash\",\n\t\t\t\tinput\n\t\t\t}\n\t\t});\n\t\treturn notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t}\n\tif (input.endsWith(\"^\")) {\n\t\tconst dirName = input.slice(0, -1);\n\t\tif (!dirName) return notOk({\n\t\t\tkind: \"invalid-format\",\n\t\t\tinput,\n\t\t\treason: \"Missing directory name before ^\"\n\t\t});\n\t\tconst edge = findEdgeByDirName(ctx.graph, dirName);\n\t\tif (edge) return ok({\n\t\t\thash: edge.from,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"migration-from\",\n\t\t\t\tdirName\n\t\t\t}\n\t\t});\n\t\treturn notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t}\n\tconst candidates = [];\n\tif (validateRefName(input) && Object.hasOwn(ctx.refs, input)) {\n\t\tconst ref = ctx.refs[input];\n\t\tif (ref) candidates.push({\n\t\t\thash: ref.hash,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"ref\",\n\t\t\t\trefName: input\n\t\t\t},\n\t\t\tlabel: `ref \"${input}\"`\n\t\t});\n\t}\n\tconst edge = findEdgeByDirName(ctx.graph, input);\n\tif (edge) candidates.push({\n\t\thash: edge.to,\n\t\tprovenance: {\n\t\t\tkind: \"migration-to\",\n\t\t\tdirName: input\n\t\t},\n\t\tlabel: `migration directory \"${input}\"`\n\t});\n\tif (isHexPrefix(input)) {\n\t\tconst matches = [...ctx.graph.nodes].filter((n) => n.startsWith(input));\n\t\tconst [firstMatch] = matches;\n\t\tif (matches.length === 1 && firstMatch !== void 0) candidates.push({\n\t\t\thash: firstMatch,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"hash\",\n\t\t\t\tinput\n\t\t\t},\n\t\t\tlabel: `hash prefix \"${input}\"`\n\t\t});\n\t\telse if (matches.length > 1) return notOk({\n\t\t\tkind: \"ambiguous\",\n\t\t\tinput,\n\t\t\tcandidates: matches,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t}\n\tconst [firstCandidate] = candidates;\n\tif (candidates.length === 1 && firstCandidate !== void 0) return ok({\n\t\thash: firstCandidate.hash,\n\t\tprovenance: firstCandidate.provenance\n\t});\n\tif (candidates.length > 1) return notOk({\n\t\tkind: \"ambiguous\",\n\t\tinput,\n\t\tcandidates: candidates.map((c) => c.label),\n\t\tgrammar: \"contract\"\n\t});\n\treturn notOk({\n\t\tkind: \"not-found\",\n\t\tinput,\n\t\tgrammar: \"contract\"\n\t});\n}\n//#endregion\n//#region src/refs/migration-ref.ts\n/**\n* Resolve a user-supplied string to a migration using the migration-reference\n* grammar.\n*\n* Accepted forms:\n* - Migration directory name (e.g. `20260101-add-users`)\n* - Migration hash (full or 6+ hex prefix)\n*\n* Wrong-grammar diagnostics are produced when the input matches a\n* contract-grammar form (ref name, `<dir>^`, contract-only hash) so the\n* user gets a targeted hint rather than a generic \"not found\".\n*/\nfunction parseMigrationRef(input, ctx) {\n\tif (!input) return notOk({\n\t\tkind: \"invalid-format\",\n\t\tinput,\n\t\treason: \"Reference cannot be empty\"\n\t});\n\tif (input.endsWith(\"^\")) return notOk({\n\t\tkind: \"wrong-grammar\",\n\t\tinput,\n\t\texpectedGrammar: \"migration\",\n\t\tmessage: \"`^` syntax addresses contracts, not migrations\",\n\t\tfix: \"Pass the migration directory name without `^`, or use a contract-accepting flag like `--to` or `--from`.\"\n\t});\n\tif (validateRefName(input) && Object.hasOwn(ctx.refs, input)) return notOk({\n\t\tkind: \"wrong-grammar\",\n\t\tinput,\n\t\texpectedGrammar: \"migration\",\n\t\tmessage: `\"${input}\" is a ref name, not a migration`,\n\t\tfix: \"Refs point at contracts, not migrations. Use a migration directory name or migration hash.\"\n\t});\n\tconst edge = findEdgeByDirName(ctx.graph, input);\n\tif (edge) return ok({\n\t\tdirName: edge.dirName,\n\t\tmigrationHash: edge.migrationHash,\n\t\tfrom: edge.from,\n\t\tto: edge.to,\n\t\tprovenance: {\n\t\t\tkind: \"dir-name\",\n\t\t\tdirName: input\n\t\t}\n\t});\n\tif (isFullHash(input)) {\n\t\tconst migEdge = ctx.graph.migrationByHash.get(input);\n\t\tif (migEdge) return ok({\n\t\t\tdirName: migEdge.dirName,\n\t\t\tmigrationHash: migEdge.migrationHash,\n\t\t\tfrom: migEdge.from,\n\t\t\tto: migEdge.to,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"hash\",\n\t\t\t\tinput\n\t\t\t}\n\t\t});\n\t\tif (ctx.graph.nodes.has(input)) return notOk({\n\t\t\tkind: \"wrong-grammar\",\n\t\t\tinput,\n\t\t\texpectedGrammar: \"migration\",\n\t\t\tmessage: \"Hash matched a contract but not a migration\",\n\t\t\tfix: \"Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.\"\n\t\t});\n\t\treturn notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"migration\"\n\t\t});\n\t}\n\tif (isHexPrefix(input)) {\n\t\tconst migMatches = [...ctx.graph.migrationByHash.entries()].filter(([hash]) => hash.startsWith(input));\n\t\tconst [firstMigMatch] = migMatches;\n\t\tif (migMatches.length === 1 && firstMigMatch !== void 0) {\n\t\t\tconst [, matchedEdge] = firstMigMatch;\n\t\t\treturn ok({\n\t\t\t\tdirName: matchedEdge.dirName,\n\t\t\t\tmigrationHash: matchedEdge.migrationHash,\n\t\t\t\tfrom: matchedEdge.from,\n\t\t\t\tto: matchedEdge.to,\n\t\t\t\tprovenance: {\n\t\t\t\t\tkind: \"hash\",\n\t\t\t\t\tinput\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (migMatches.length > 1) return notOk({\n\t\t\tkind: \"ambiguous\",\n\t\t\tinput,\n\t\t\tcandidates: migMatches.map(([hash]) => hash),\n\t\t\tgrammar: \"migration\"\n\t\t});\n\t\tif ([...ctx.graph.nodes].filter((n) => n.startsWith(input)).length > 0) return notOk({\n\t\t\tkind: \"wrong-grammar\",\n\t\t\tinput,\n\t\t\texpectedGrammar: \"migration\",\n\t\t\tmessage: \"Hash matched a contract but not a migration\",\n\t\t\tfix: \"Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.\"\n\t\t});\n\t}\n\treturn notOk({\n\t\tkind: \"not-found\",\n\t\tinput,\n\t\tgrammar: \"migration\"\n\t});\n}\n//#endregion\nexport { EMPTY_CONTRACT_REF, LIVE_MARKER_REF, RESERVED_CONTRACT_REFS, WORKING_CONTRACT_REF, findEdgeByDirName, isLiveMarkerRef, isReservedContractRef, parseContractRef, parseMigrationRef };\n\n//# sourceMappingURL=ref-resolution.mjs.map"],"mappings":";;;;AAIA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,SAAS,WAAW,OAAO;CAC1B,OAAO,kBAAkB,KAAK,KAAK;AACpC;AACA,SAAS,YAAY,OAAO;CAC3B,OAAO,mBAAmB,KAAK,KAAK;AACrC;AACA,SAAS,kBAAkB,OAAO,SAAS;CAC1C,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,GAAG,KAAK,MAAM,QAAQ,OAAO,IAAI,KAAK,YAAY,SAAS,OAAO;AACjH;AAGA,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;;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ACX,MAAM;KACN;IACD;GACD,CAAC;EACF;EACA,IAAI,WAAW,SAAS,GAAG,OAAO,MAAM;GACvC,MAAM;GACN;GACA,YAAY,WAAW,KAAK,CAAC,UAAU,IAAI;GAC3C,SAAS;EACV,CAAC;EACD,IAAI,CAAC,GAAG,IAAI,MAAM,KAAK,CAAC,CAAC,QAAQ,MAAM,EAAE,WAAW,KAAK,CAAC,CAAC,CAAC,SAAS,GAAG,OAAO,MAAM;GACpF,MAAM;GACN;GACA,iBAAiB;GACjB,SAAS;GACT,KAAK;EACN,CAAC;CACF;CACA,OAAO,MAAM;EACZ,MAAM;EACN;EACA,SAAS;CACV,CAAC;AACF"}
1
+ {"version":3,"file":"ref-resolution-C9j2SSb6.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/ref-resolution.mjs"],"sourcesContent":["import { t as EMPTY_CONTRACT_HASH } from \"../constants-CM-w38DQ.mjs\";\nimport { u as validateRefName } from \"../refs-t_JbIjGo.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\n//#region src/refs/types.ts\nconst FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;\nconst HEX_PREFIX_PATTERN = /^[0-9a-f]{6,}$/;\nfunction isFullHash(input) {\n\treturn FULL_HASH_PATTERN.test(input);\n}\nfunction isHexPrefix(input) {\n\treturn HEX_PREFIX_PATTERN.test(input);\n}\nfunction findEdgeByDirName(graph, dirName) {\n\tfor (const edges of graph.forwardChain.values()) for (const edge of edges) if (edge.dirName === dirName) return edge;\n}\n//#endregion\n//#region src/refs/contract-ref.ts\nconst WORKING_CONTRACT_REF = \"@contract\";\nconst LIVE_MARKER_REF = \"@db\";\nconst EMPTY_CONTRACT_REF = \"@empty\";\n/** The reserved references, in a fixed order: `@contract`, `@db`, `@empty`. */\nconst RESERVED_CONTRACT_REFS = [\n\tWORKING_CONTRACT_REF,\n\t\"@db\",\n\tEMPTY_CONTRACT_REF\n];\n/** True for a reserved reference, which resolves from contract.json, the database, or the empty contract rather than from a contract recorded in the migrations directory. */\nfunction isReservedContractRef(input) {\n\treturn RESERVED_CONTRACT_REFS.includes(input);\n}\n/** True for `@db`, the only reserved reference that needs a database read to resolve. */\nfunction isLiveMarkerRef(input) {\n\treturn input === \"@db\";\n}\n/**\n* Resolve a user-supplied string to a contract hash using the unified\n* contract-reference grammar.\n*\n* Accepted forms:\n* - `@contract` — the on-disk working contract hash (offline; requires\n* `ctx.contractHash` to be set)\n* - `@db` — the live database marker. Callers that accept `@db` test\n* `isLiveMarkerRef(input)` before parsing and resolve it from the marker;\n* the `reserved-db` result carries a placeholder hash that must not be used\n* - `@empty` — the empty contract (offline; resolves to\n* `EMPTY_CONTRACT_HASH`, the origin with no prior storage state)\n* - Full storage hash (64 hex chars or `empty`)\n* - Hex prefix (6+ hex chars, must uniquely identify one contract)\n* - Ref name (looked up in the refs index)\n* - Migration directory name (resolves to the migration's `to`-contract)\n* - `<dir>^` (resolves to the migration's `from`-contract)\n*/\nfunction parseContractRef(input, ctx) {\n\tif (!input) return notOk({\n\t\tkind: \"invalid-format\",\n\t\tinput,\n\t\treason: \"Reference cannot be empty\"\n\t});\n\tif (input === \"@contract\") {\n\t\tif (ctx.contractHash === void 0) return notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t\treturn ok({\n\t\t\thash: ctx.contractHash,\n\t\t\tprovenance: { kind: \"reserved-contract\" }\n\t\t});\n\t}\n\tif (input === \"@db\") return ok({\n\t\thash: \"\",\n\t\tprovenance: { kind: \"reserved-db\" }\n\t});\n\tif (input === \"@empty\") return ok({\n\t\thash: EMPTY_CONTRACT_HASH,\n\t\tprovenance: { kind: \"reserved-empty\" }\n\t});\n\tif (isFullHash(input)) {\n\t\tif (ctx.graph.nodes.has(input)) return ok({\n\t\t\thash: input,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"hash\",\n\t\t\t\tinput\n\t\t\t}\n\t\t});\n\t\treturn notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t}\n\tif (input.endsWith(\"^\")) {\n\t\tconst dirName = input.slice(0, -1);\n\t\tif (!dirName) return notOk({\n\t\t\tkind: \"invalid-format\",\n\t\t\tinput,\n\t\t\treason: \"Missing directory name before ^\"\n\t\t});\n\t\tconst edge = findEdgeByDirName(ctx.graph, dirName);\n\t\tif (edge) return ok({\n\t\t\thash: edge.from,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"migration-from\",\n\t\t\t\tdirName\n\t\t\t}\n\t\t});\n\t\treturn notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t}\n\tconst candidates = [];\n\tif (validateRefName(input) && Object.hasOwn(ctx.refs, input)) {\n\t\tconst ref = ctx.refs[input];\n\t\tif (ref) candidates.push({\n\t\t\thash: ref.hash,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"ref\",\n\t\t\t\trefName: input\n\t\t\t},\n\t\t\tlabel: `ref \"${input}\"`\n\t\t});\n\t}\n\tconst edge = findEdgeByDirName(ctx.graph, input);\n\tif (edge) candidates.push({\n\t\thash: edge.to,\n\t\tprovenance: {\n\t\t\tkind: \"migration-to\",\n\t\t\tdirName: input\n\t\t},\n\t\tlabel: `migration directory \"${input}\"`\n\t});\n\tif (isHexPrefix(input)) {\n\t\tconst matches = [...ctx.graph.nodes].filter((n) => n.startsWith(input));\n\t\tconst [firstMatch] = matches;\n\t\tif (matches.length === 1 && firstMatch !== void 0) candidates.push({\n\t\t\thash: firstMatch,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"hash\",\n\t\t\t\tinput\n\t\t\t},\n\t\t\tlabel: `hash prefix \"${input}\"`\n\t\t});\n\t\telse if (matches.length > 1) return notOk({\n\t\t\tkind: \"ambiguous\",\n\t\t\tinput,\n\t\t\tcandidates: matches,\n\t\t\tgrammar: \"contract\"\n\t\t});\n\t}\n\tconst [firstCandidate] = candidates;\n\tif (candidates.length === 1 && firstCandidate !== void 0) return ok({\n\t\thash: firstCandidate.hash,\n\t\tprovenance: firstCandidate.provenance\n\t});\n\tif (candidates.length > 1) return notOk({\n\t\tkind: \"ambiguous\",\n\t\tinput,\n\t\tcandidates: candidates.map((c) => c.label),\n\t\tgrammar: \"contract\"\n\t});\n\treturn notOk({\n\t\tkind: \"not-found\",\n\t\tinput,\n\t\tgrammar: \"contract\"\n\t});\n}\n//#endregion\n//#region src/refs/migration-ref.ts\n/**\n* Resolve a user-supplied string to a migration using the migration-reference\n* grammar.\n*\n* Accepted forms:\n* - Migration directory name (e.g. `20260101-add-users`)\n* - Migration hash (full or 6+ hex prefix)\n*\n* Wrong-grammar diagnostics are produced when the input matches a\n* contract-grammar form (ref name, `<dir>^`, contract-only hash) so the\n* user gets a targeted hint rather than a generic \"not found\".\n*/\nfunction parseMigrationRef(input, ctx) {\n\tif (!input) return notOk({\n\t\tkind: \"invalid-format\",\n\t\tinput,\n\t\treason: \"Reference cannot be empty\"\n\t});\n\tif (input.endsWith(\"^\")) return notOk({\n\t\tkind: \"wrong-grammar\",\n\t\tinput,\n\t\texpectedGrammar: \"migration\",\n\t\tmessage: \"`^` syntax addresses contracts, not migrations\",\n\t\tfix: \"Pass the migration directory name without `^`, or use a contract-accepting flag like `--to` or `--from`.\"\n\t});\n\tif (validateRefName(input) && Object.hasOwn(ctx.refs, input)) return notOk({\n\t\tkind: \"wrong-grammar\",\n\t\tinput,\n\t\texpectedGrammar: \"migration\",\n\t\tmessage: `\"${input}\" is a ref name, not a migration`,\n\t\tfix: \"Refs point at contracts, not migrations. Use a migration directory name or migration hash.\"\n\t});\n\tconst edge = findEdgeByDirName(ctx.graph, input);\n\tif (edge) return ok({\n\t\tdirName: edge.dirName,\n\t\tmigrationHash: edge.migrationHash,\n\t\tfrom: edge.from,\n\t\tto: edge.to,\n\t\tprovenance: {\n\t\t\tkind: \"dir-name\",\n\t\t\tdirName: input\n\t\t}\n\t});\n\tif (isFullHash(input)) {\n\t\tconst migEdge = ctx.graph.migrationByHash.get(input);\n\t\tif (migEdge) return ok({\n\t\t\tdirName: migEdge.dirName,\n\t\t\tmigrationHash: migEdge.migrationHash,\n\t\t\tfrom: migEdge.from,\n\t\t\tto: migEdge.to,\n\t\t\tprovenance: {\n\t\t\t\tkind: \"hash\",\n\t\t\t\tinput\n\t\t\t}\n\t\t});\n\t\tif (ctx.graph.nodes.has(input)) return notOk({\n\t\t\tkind: \"wrong-grammar\",\n\t\t\tinput,\n\t\t\texpectedGrammar: \"migration\",\n\t\t\tmessage: \"Hash matched a contract but not a migration\",\n\t\t\tfix: \"Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.\"\n\t\t});\n\t\treturn notOk({\n\t\t\tkind: \"not-found\",\n\t\t\tinput,\n\t\t\tgrammar: \"migration\"\n\t\t});\n\t}\n\tif (isHexPrefix(input)) {\n\t\tconst migMatches = [...ctx.graph.migrationByHash.entries()].filter(([hash]) => hash.startsWith(input));\n\t\tconst [firstMigMatch] = migMatches;\n\t\tif (migMatches.length === 1 && firstMigMatch !== void 0) {\n\t\t\tconst [, matchedEdge] = firstMigMatch;\n\t\t\treturn ok({\n\t\t\t\tdirName: matchedEdge.dirName,\n\t\t\t\tmigrationHash: matchedEdge.migrationHash,\n\t\t\t\tfrom: matchedEdge.from,\n\t\t\t\tto: matchedEdge.to,\n\t\t\t\tprovenance: {\n\t\t\t\t\tkind: \"hash\",\n\t\t\t\t\tinput\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (migMatches.length > 1) return notOk({\n\t\t\tkind: \"ambiguous\",\n\t\t\tinput,\n\t\t\tcandidates: migMatches.map(([hash]) => hash),\n\t\t\tgrammar: \"migration\"\n\t\t});\n\t\tif ([...ctx.graph.nodes].filter((n) => n.startsWith(input)).length > 0) return notOk({\n\t\t\tkind: \"wrong-grammar\",\n\t\t\tinput,\n\t\t\texpectedGrammar: \"migration\",\n\t\t\tmessage: \"Hash matched a contract but not a migration\",\n\t\t\tfix: \"Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.\"\n\t\t});\n\t}\n\treturn notOk({\n\t\tkind: \"not-found\",\n\t\tinput,\n\t\tgrammar: \"migration\"\n\t});\n}\n//#endregion\nexport { EMPTY_CONTRACT_REF, LIVE_MARKER_REF, RESERVED_CONTRACT_REFS, WORKING_CONTRACT_REF, findEdgeByDirName, isLiveMarkerRef, isReservedContractRef, parseContractRef, parseMigrationRef };\n\n//# sourceMappingURL=ref-resolution.mjs.map"],"mappings":";;;;AAIA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,SAAS,WAAW,OAAO;CAC1B,OAAO,kBAAkB,KAAK,KAAK;AACpC;AACA,SAAS,YAAY,OAAO;CAC3B,OAAO,mBAAmB,KAAK,KAAK;AACrC;AACA,SAAS,kBAAkB,OAAO,SAAS;CAC1C,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,GAAG,KAAK,MAAM,QAAQ,OAAO,IAAI,KAAK,YAAY,SAAS,OAAO;AACjH;AAGA,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;;AAE3B,MAAM,yBAAyB;CAC9B;CACA;CACA;AACD;;AAEA,SAAS,sBAAsB,OAAO;CACrC,OAAO,uBAAuB,SAAS,KAAK;AAC7C;;AAEA,SAAS,gBAAgB,OAAO;CAC/B,OAAO,UAAU;AAClB;;;;;;;;;;;;;;;;;;;AAmBA,SAAS,iBAAiB,OAAO,KAAK;CACrC,IAAI,CAAC,OAAO,OAAO,MAAM;EACxB,MAAM;EACN;EACA,QAAQ;CACT,CAAC;CACD,IAAI,UAAU,aAAa;EAC1B,IAAI,IAAI,iBAAiB,KAAK,GAAG,OAAO,MAAM;GAC7C,MAAM;GACN;GACA,SAAS;EACV,CAAC;EACD,OAAO,GAAG;GACT,MAAM,IAAI;GACV,YAAY,EAAE,MAAM,oBAAoB;EACzC,CA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1
+ import { a as Refs } from "./refs-CkGjbosE-CLkrSkQ4.mjs";
2
2
  import { n as MigrationGraph, t as MigrationEdge } from "./graph-bDjJ4GL9-BhFevsJS.mjs";
3
3
  import { Result } from "@prisma/orm-framework/utils/result";
4
4
  //#region ../../../1-framework/3-tooling/migration/dist/exports/ref-resolution.d.mts
@@ -142,4 +142,4 @@ declare function parseContractRef(input: string, ctx: RefResolutionContext): Res
142
142
  declare function parseMigrationRef(input: string, ctx: RefResolutionContext): Result<MigrationRef, RefResolutionError>;
143
143
  //#endregion
144
144
  export { isReservedContractRef as _, MigrationRef as a, RefResolutionAmbiguous as c, RefResolutionInvalidFormat as d, RefResolutionNotFound as f, isLiveMarkerRef as g, findEdgeByDirName as h, LIVE_MARKER_REF as i, RefResolutionContext as l, WORKING_CONTRACT_REF as m, ContractRefProvenance as n, MigrationRefProvenance as o, RefResolutionWrongGrammar as p, EMPTY_CONTRACT_REF as r, RESERVED_CONTRACT_REFS as s, ContractRef as t, RefResolutionError as u, parseContractRef as v, parseMigrationRef as y };
145
- //# sourceMappingURL=ref-resolution-BPhR-kta.d.mts.map
145
+ //# sourceMappingURL=ref-resolution-UwnXbc9M.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ref-resolution-BPhR-kta.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/ref-resolution.d.mts"],"mappings":";;;;;;UAKU;WACC,OAAO;WACP,MAAM;;;;;;WAMN;;KAEN;WACM;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;WACA;;;;;;;WAOA;;;;;;;;WAQA;;;;;;;;WAQA;;;UAGD;WACC;WACA,YAAY;;KAElB;WACM;WACA;;WAEA;WACA;;;UAGD;WACC;WACA;WACA;WACA;WACA,YAAY;;UAEb;WACC;WACA;WACA;;UAED;WACC;WACA;WACA;WACA;;UAED;WACC;WACA;WACA;WACA;WACA;;UAED;WACC;WACA;WACA;;KAEN,qBAAqB,wBAAwB,yBAAyB,4BAA4B;iBACtF,kBAAkB,OAAO,gBAAgB,kBAAkB;;;cAG9D;cACA;cACA;;cAEA;;iBAEG,sBAAsB;;iBAEtB,gBAAgB;;;;;;;;;;;;;;;;;;;iBAmBhB,iBAAiB,eAAe,KAAK,uBAAuB,OAAO,aAAa;;;;;;;;;;;;;;;iBAehF,kBAAkB,eAAe,KAAK,uBAAuB,OAAO,cAAc"}
1
+ {"version":3,"file":"ref-resolution-UwnXbc9M.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/ref-resolution.d.mts"],"mappings":";;;;;;UAKU;WACC,OAAO;WACP,MAAM;;;;;;WAMN;;KAEN;WACM;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;WACA;;;;;;;WAOA;;;;;;;;WAQA;;;;;;;;WAQA;;;UAGD;WACC;WACA,YAAY;;KAElB;WACM;WACA;;WAEA;WACA;;;UAGD;WACC;WACA;WACA;WACA;WACA,YAAY;;UAEb;WACC;WACA;WACA;;UAED;WACC;WACA;WACA;WACA;;UAED;WACC;WACA;WACA;WACA;WACA;;UAED;WACC;WACA;WACA;;KAEN,qBAAqB,wBAAwB,yBAAyB,4BAA4B;iBACtF,kBAAkB,OAAO,gBAAgB,kBAAkB;;;cAG9D;cACA;cACA;;cAEA;;iBAEG,sBAAsB;;iBAEtB,gBAAgB;;;;;;;;;;;;;;;;;;;iBAmBhB,iBAAiB,eAAe,KAAK,uBAAuB,OAAO,aAAa;;;;;;;;;;;;;;;iBAehF,kBAAkB,eAAe,KAAK,uBAAuB,OAAO,cAAc"}
@@ -0,0 +1 @@
1
+ import "./refs-CkGjbosE-CLkrSkQ4.mjs";
@@ -1,9 +1,15 @@
1
- //#region ../../../1-framework/3-tooling/migration/dist/refs-BNCUu58Y.d.mts
1
+ import { DeclaredDatabasePolicies, DeclaredDatabasePoliciesIssue } from "@prisma/orm-framework/components/control";
2
+ //#region ../../../1-framework/3-tooling/migration/dist/refs-CkGjbosE.d.mts
2
3
  //#region src/refs.d.ts
3
4
  interface RefEntry {
4
5
  readonly hash: string;
5
6
  readonly invariants: readonly string[];
7
+ readonly policies?: DeclaredDatabasePolicies;
6
8
  }
9
+ /** A ref with its name: what a `--to` naming a ref resolves to. */
10
+ type NamedRef = {
11
+ readonly name: string;
12
+ } & RefEntry;
7
13
  type Refs = Readonly<Record<string, RefEntry>>;
8
14
  /**
9
15
  * The system head ref lives at `refs/head.json`. It is read (and its
@@ -19,13 +25,22 @@ declare const HEAD_REF_NAME = "head";
19
25
  */
20
26
  interface RefLoadProblem {
21
27
  readonly refName: string;
28
+ /** The ref file that could not be read. */
29
+ readonly path: string;
22
30
  readonly detail: string;
31
+ /** The invalid keys of the ref's `policies`, when they are what is wrong. */
32
+ readonly policyIssues?: readonly DeclaredDatabasePoliciesIssue[];
23
33
  }
24
34
  declare function validateRefName(name: string): boolean;
25
35
  declare function validateRefValue(value: string): boolean;
26
36
  declare function readRef(refsDir: string, name: string): Promise<RefEntry>;
27
37
  declare function readRefs(refsDir: string): Promise<Refs>;
28
38
  declare function writeRef(refsDir: string, name: string, entry: RefEntry): Promise<void>;
39
+ /**
40
+ * Points ref `name` at `hash`, keeping everything else the ref declares. A ref that does not exist
41
+ * yet is written with no invariants. Returns the entry as written.
42
+ */
43
+ declare function advanceRef(refsDir: string, name: string, hash: string): Promise<RefEntry>;
29
44
  declare function deleteRef(refsDir: string, name: string): Promise<void>;
30
45
  /**
31
46
  * Index user-authored refs by the contract hash each ref points at.
@@ -39,5 +54,5 @@ declare function refsByContractHash(refs: Refs): ReadonlyMap<string, readonly st
39
54
  declare function resolveRefsByContractHash(refsDir: string): Promise<ReadonlyMap<string, readonly string[]>>;
40
55
  declare function resolveRef(refs: Refs, name: string): RefEntry;
41
56
  //#endregion
42
- export { deleteRef as a, refsByContractHash as c, validateRefName as d, validateRefValue as f, Refs as i, resolveRef as l, RefEntry as n, readRef as o, writeRef as p, RefLoadProblem as r, readRefs as s, HEAD_REF_NAME as t, resolveRefsByContractHash as u };
43
- //# sourceMappingURL=refs-BNCUu58Y-BIso5Jfg.d.mts.map
57
+ export { Refs as a, readRef as c, resolveRef as d, resolveRefsByContractHash as f, writeRef as h, RefLoadProblem as i, readRefs as l, validateRefValue as m, NamedRef as n, advanceRef as o, validateRefName as p, RefEntry as r, deleteRef as s, HEAD_REF_NAME as t, refsByContractHash as u };
58
+ //# sourceMappingURL=refs-CkGjbosE-CLkrSkQ4.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs-CkGjbosE-CLkrSkQ4.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/refs-CkGjbosE.d.mts"],"mappings":";;;UAEU;WACC;WACA;WACA,WAAW;;;KAGjB;WACM;IACP;KACC,OAAO,SAAS,eAAe;;;;;;cAMtB;;;;;;;UAOJ;WACC;;WAEA;WACA;;WAEA,wBAAwB;;iBAElB,gBAAgB;iBAChB,iBAAiB;iBACjB,QAAQ,iBAAiB,eAAe,QAAQ;iBAChD,SAAS,kBAAkB,QAAQ;iBACnC,SAAS,iBAAiB,cAAc,OAAO,WAAW;;;;;iBAK1D,WAAW,iBAAiB,cAAc,eAAe,QAAQ;iBACjE,UAAU,iBAAiB,eAAe;;;;;iBAK1C,mBAAmB,MAAM,OAAO;;;;;iBAKhC,0BAA0B,kBAAkB,QAAQ;iBACpD,WAAW,MAAM,MAAM,eAAe"}
@@ -1,8 +1,11 @@
1
- import { b as errorInvalidRefName, t as MigrationToolsError, x as errorInvalidRefValue, y as errorInvalidRefFile } from "./errors-DXha_4l--relAaiI4.mjs";
1
+ import { b as errorInvalidRefName, t as MigrationToolsError, x as errorInvalidRefValue, y as errorInvalidRefFile } from "./errors-BMq40nYH-Cg8PBect.mjs";
2
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
+ import { parseDeclaredDatabasePolicies } from "@prisma/orm-framework/components/control";
2
4
  import { dirname, join, relative } from "pathe";
3
5
  import { mkdir, readFile, readdir, rename, rmdir, unlink, writeFile } from "node:fs/promises";
4
6
  import { type } from "arktype";
5
- //#region ../../../1-framework/3-tooling/migration/dist/refs-DM3q3IZC.mjs
7
+ import { notOk, ok } from "@prisma/orm-framework/utils/result";
8
+ //#region ../../../1-framework/3-tooling/migration/dist/refs-t_JbIjGo.mjs
6
9
  /**
7
10
  * The system head ref lives at `refs/head.json`. It is read (and its
8
11
  * corruption judged) through `readContractSpaceHeadRef`, not as a
@@ -21,13 +24,40 @@ function validateRefName(name) {
21
24
  function validateRefValue(value) {
22
25
  return REF_VALUE_PATTERN.test(value);
23
26
  }
24
- const RefEntrySchema = type({
27
+ const RefEntryFileSchema = type({
25
28
  hash: "string",
26
- invariants: "string[]"
29
+ invariants: "string[]",
30
+ "policies?": "unknown"
27
31
  }).narrow((entry, ctx) => {
28
32
  if (!validateRefValue(entry.hash)) return ctx.mustBe(`a valid contract hash (got "${entry.hash}")`);
29
33
  return true;
30
34
  });
35
+ function policiesIssueText({ path, problem }) {
36
+ return path === "" ? `policies ${problem}` : `policies.${path} ${problem}`;
37
+ }
38
+ /** The ref entry a ref file's parsed JSON holds, or why it holds none: each invalid field, by its path. */
39
+ function refEntryOf(parsed) {
40
+ const entry = RefEntryFileSchema(parsed);
41
+ if (entry instanceof type.errors) return notOk({
42
+ detail: entry.summary,
43
+ policyIssues: []
44
+ });
45
+ const { hash, invariants, policies } = entry;
46
+ if (policies === void 0) return ok({
47
+ hash,
48
+ invariants
49
+ });
50
+ const declared = parseDeclaredDatabasePolicies(policies);
51
+ if (!declared.ok) return notOk({
52
+ detail: declared.failure.map(policiesIssueText).join("\n"),
53
+ policyIssues: declared.failure
54
+ });
55
+ return ok({
56
+ hash,
57
+ invariants,
58
+ policies: declared.value
59
+ });
60
+ }
31
61
  function refFilePath(refsDir, name) {
32
62
  return join(refsDir, `${name}.json`);
33
63
  }
@@ -62,9 +92,9 @@ async function readRef(refsDir, name) {
62
92
  } catch {
63
93
  throw errorInvalidRefFile(filePath, "Failed to parse as JSON");
64
94
  }
65
- const result = RefEntrySchema(parsed);
66
- if (result instanceof type.errors) throw errorInvalidRefFile(filePath, result.summary);
67
- return result;
95
+ const result = refEntryOf(parsed);
96
+ if (!result.ok) throw errorInvalidRefFile(filePath, result.failure.detail, result.failure.policyIssues);
97
+ return result.value;
68
98
  }
69
99
  async function readRefs(refsDir) {
70
100
  let entries;
@@ -96,16 +126,16 @@ async function readRefs(refsDir) {
96
126
  } catch {
97
127
  throw errorInvalidRefFile(filePath, "Failed to parse as JSON");
98
128
  }
99
- const result = RefEntrySchema(parsed);
100
- if (result instanceof type.errors) throw errorInvalidRefFile(filePath, result.summary);
101
- refs[name] = result;
129
+ const result = refEntryOf(parsed);
130
+ if (!result.ok) throw errorInvalidRefFile(filePath, result.failure.detail, result.failure.policyIssues);
131
+ refs[name] = result.value;
102
132
  }
103
133
  return refs;
104
134
  }
105
135
  /**
106
136
  * Read a space's user-authored refs without ever throwing on disk
107
137
  * content. A ref whose JSON is unparseable or whose shape fails
108
- * {@link RefEntrySchema} is omitted from `refs` and reported as a
138
+ * {@link refEntryOf} is omitted from `refs` and reported as a
109
139
  * {@link RefLoadProblem}; the remaining well-formed refs are still
110
140
  * returned. A missing `refs/` directory yields no refs and no problems.
111
141
  *
@@ -149,19 +179,22 @@ async function readRefsTolerant(refsDir) {
149
179
  } catch (e) {
150
180
  problems.push({
151
181
  refName: name,
182
+ path: filePath,
152
183
  detail: e instanceof Error ? e.message : String(e)
153
184
  });
154
185
  continue;
155
186
  }
156
- const result = RefEntrySchema(parsed);
157
- if (result instanceof type.errors) {
187
+ const result = refEntryOf(parsed);
188
+ if (!result.ok) {
158
189
  problems.push({
159
190
  refName: name,
160
- detail: result.summary
191
+ path: filePath,
192
+ detail: result.failure.detail,
193
+ policyIssues: result.failure.policyIssues
161
194
  });
162
195
  continue;
163
196
  }
164
- refs[name] = result;
197
+ refs[name] = result.value;
165
198
  }
166
199
  return {
167
200
  refs,
@@ -175,12 +208,38 @@ async function writeRef(refsDir, name, entry) {
175
208
  const dir = dirname(filePath);
176
209
  await mkdir(dir, { recursive: true });
177
210
  const tmpPath = join(dir, `.${name.split("/").pop()}.json.${Date.now()}.tmp`);
178
- await writeFile(tmpPath, `${JSON.stringify({
211
+ const content = {
179
212
  hash: entry.hash,
180
- invariants: [...entry.invariants]
181
- }, null, 2)}\n`);
213
+ invariants: [...entry.invariants],
214
+ ...ifDefined("policies", entry.policies)
215
+ };
216
+ await writeFile(tmpPath, `${JSON.stringify(content, null, 2)}\n`);
182
217
  await rename(tmpPath, filePath);
183
218
  }
219
+ /**
220
+ * Points ref `name` at `hash`, keeping everything else the ref declares. A ref that does not exist
221
+ * yet is written with no invariants. Returns the entry as written.
222
+ */
223
+ async function advanceRef(refsDir, name, hash) {
224
+ const existing = await readExistingRef(refsDir, name);
225
+ const entry = existing === void 0 ? {
226
+ hash,
227
+ invariants: []
228
+ } : {
229
+ ...existing,
230
+ hash
231
+ };
232
+ await writeRef(refsDir, name, entry);
233
+ return entry;
234
+ }
235
+ async function readExistingRef(refsDir, name) {
236
+ try {
237
+ return await readRef(refsDir, name);
238
+ } catch (error) {
239
+ if (MigrationToolsError.is(error) && error.code === "MIGRATION.UNKNOWN_REF") return void 0;
240
+ throw error;
241
+ }
242
+ }
184
243
  async function deleteRef(refsDir, name) {
185
244
  if (!validateRefName(name)) throw errorInvalidRefName(name);
186
245
  const filePath = refFilePath(refsDir, name);
@@ -252,6 +311,6 @@ function resolveRef(refs, name) {
252
311
  return refs[name];
253
312
  }
254
313
  //#endregion
255
- export { readRefsTolerant as a, resolveRefsByContractHash as c, writeRef as d, readRefs as i, validateRefName as l, deleteRef as n, refsByContractHash as o, readRef as r, resolveRef as s, HEAD_REF_NAME as t, validateRefValue as u };
314
+ export { readRefs as a, resolveRef as c, validateRefValue as d, writeRef as f, readRef as i, resolveRefsByContractHash as l, advanceRef as n, readRefsTolerant as o, deleteRef as r, refsByContractHash as s, HEAD_REF_NAME as t, validateRefName as u };
256
315
 
257
- //# sourceMappingURL=refs-DM3q3IZC-BC6H6P0X.mjs.map
316
+ //# sourceMappingURL=refs-t_JbIjGo-CRpBRRkq.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs-t_JbIjGo-CRpBRRkq.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/refs-t_JbIjGo.mjs"],"sourcesContent":["import { b as errorInvalidRefName, t as MigrationToolsError, x as errorInvalidRefValue, y as errorInvalidRefFile } from \"./errors-BMq40nYH.mjs\";\nimport { parseDeclaredDatabasePolicies } from \"@internal/framework-components/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { dirname, join, relative } from \"pathe\";\nimport { mkdir, readFile, readdir, rename, rmdir, unlink, writeFile } from \"node:fs/promises\";\nimport { type } from \"arktype\";\nimport { notOk, ok } from \"@internal/utils/result\";\n//#region src/refs.ts\n/**\n* The system head ref lives at `refs/head.json`. It is read (and its\n* corruption judged) through `readContractSpaceHeadRef`, not as a\n* user-authored ref, so {@link readRefsTolerant} excludes it.\n*/\nconst HEAD_REF_NAME = \"head\";\nconst REF_NAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\/[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/;\nconst REF_VALUE_PATTERN = /^(empty|[0-9a-f]{64})$/;\nfunction validateRefName(name) {\n\tif (name.length === 0) return false;\n\tif (name.includes(\"..\")) return false;\n\tif (name.includes(\"//\")) return false;\n\tif (name.startsWith(\".\")) return false;\n\treturn REF_NAME_PATTERN.test(name);\n}\nfunction validateRefValue(value) {\n\treturn REF_VALUE_PATTERN.test(value);\n}\nconst RefEntryFileSchema = type({\n\thash: \"string\",\n\tinvariants: \"string[]\",\n\t\"policies?\": \"unknown\"\n}).narrow((entry, ctx) => {\n\tif (!validateRefValue(entry.hash)) return ctx.mustBe(`a valid contract hash (got \"${entry.hash}\")`);\n\treturn true;\n});\nfunction policiesIssueText({ path, problem }) {\n\treturn path === \"\" ? `policies ${problem}` : `policies.${path} ${problem}`;\n}\n/** The ref entry a ref file's parsed JSON holds, or why it holds none: each invalid field, by its path. */\nfunction refEntryOf(parsed) {\n\tconst entry = RefEntryFileSchema(parsed);\n\tif (entry instanceof type.errors) return notOk({\n\t\tdetail: entry.summary,\n\t\tpolicyIssues: []\n\t});\n\tconst { hash, invariants, policies } = entry;\n\tif (policies === void 0) return ok({\n\t\thash,\n\t\tinvariants\n\t});\n\tconst declared = parseDeclaredDatabasePolicies(policies);\n\tif (!declared.ok) return notOk({\n\t\tdetail: declared.failure.map(policiesIssueText).join(\"\\n\"),\n\t\tpolicyIssues: declared.failure\n\t});\n\treturn ok({\n\t\thash,\n\t\tinvariants,\n\t\tpolicies: declared.value\n\t});\n}\nfunction refFilePath(refsDir, name) {\n\treturn join(refsDir, `${name}.json`);\n}\nfunction refNameFromPath(refsDir, filePath) {\n\treturn relative(refsDir, filePath).replace(/\\.json$/, \"\");\n}\nasync function readRef(refsDir, name) {\n\tif (!validateRefName(name)) throw errorInvalidRefName(name);\n\tconst filePath = refFilePath(refsDir, name);\n\tlet raw;\n\ttry {\n\t\traw = await readFile(filePath, \"utf-8\");\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") throw new MigrationToolsError(\"MIGRATION.UNKNOWN_REF\", `Unknown ref \"${name}\"`, {\n\t\t\twhy: `No ref file found at \"${filePath}\".`,\n\t\t\tfix: `Create the ref with: {bin} migration ref set ${name} <hash>`,\n\t\t\tnextActions: [{\n\t\t\t\tkind: \"run-command\",\n\t\t\t\tlabel: `Create the ref \"${name}\"`,\n\t\t\t\tcommand: `{bin} migration ref set ${name} <hash>`\n\t\t\t}],\n\t\t\tmeta: {\n\t\t\t\trefName: name,\n\t\t\t\tfilePath\n\t\t\t}\n\t\t});\n\t\tthrow error;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\tthrow errorInvalidRefFile(filePath, \"Failed to parse as JSON\");\n\t}\n\tconst result = refEntryOf(parsed);\n\tif (!result.ok) throw errorInvalidRefFile(filePath, result.failure.detail, result.failure.policyIssues);\n\treturn result.value;\n}\nasync function readRefs(refsDir) {\n\tlet entries;\n\ttry {\n\t\tentries = await readdir(refsDir, {\n\t\t\trecursive: true,\n\t\t\tencoding: \"utf-8\"\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return {};\n\t\tthrow error;\n\t}\n\tconst jsonFiles = entries.filter((entry) => entry.endsWith(\".json\") && !entry.endsWith(\".contract.json\"));\n\tconst refs = {};\n\tfor (const jsonFile of jsonFiles) {\n\t\tconst filePath = join(refsDir, jsonFile);\n\t\tconst name = refNameFromPath(refsDir, filePath);\n\t\tlet raw;\n\t\ttry {\n\t\t\traw = await readFile(filePath, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tconst code = error instanceof Error ? error.code : void 0;\n\t\t\tif (code === \"ENOENT\" || code === \"EISDIR\") continue;\n\t\t\tthrow error;\n\t\t}\n\t\tlet parsed;\n\t\ttry {\n\t\t\tparsed = JSON.parse(raw);\n\t\t} catch {\n\t\t\tthrow errorInvalidRefFile(filePath, \"Failed to parse as JSON\");\n\t\t}\n\t\tconst result = refEntryOf(parsed);\n\t\tif (!result.ok) throw errorInvalidRefFile(filePath, result.failure.detail, result.failure.policyIssues);\n\t\trefs[name] = result.value;\n\t}\n\treturn refs;\n}\n/**\n* Read a space's user-authored refs without ever throwing on disk\n* content. A ref whose JSON is unparseable or whose shape fails\n* {@link refEntryOf} is omitted from `refs` and reported as a\n* {@link RefLoadProblem}; the remaining well-formed refs are still\n* returned. A missing `refs/` directory yields no refs and no problems.\n*\n* `refs/head.json` is deliberately skipped here: the system head ref is\n* read through `readContractSpaceHeadRef` (which validates head-ref\n* shape, distinct from the strict user-ref hash grammar), so it is judged\n* there and never doubles as a user ref. Genuine I/O faults (EACCES, EIO,\n* …) still propagate — only parse / schema problems are made tolerant.\n*/\nasync function readRefsTolerant(refsDir) {\n\tlet entries;\n\ttry {\n\t\tentries = await readdir(refsDir, {\n\t\t\trecursive: true,\n\t\t\tencoding: \"utf-8\"\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") return {\n\t\t\trefs: {},\n\t\t\tproblems: []\n\t\t};\n\t\tthrow error;\n\t}\n\tconst jsonFiles = entries.filter((entry) => entry.endsWith(\".json\") && !entry.endsWith(\".contract.json\") && entry !== `head.json`);\n\tconst refs = {};\n\tconst problems = [];\n\tfor (const jsonFile of jsonFiles) {\n\t\tconst filePath = join(refsDir, jsonFile);\n\t\tconst name = refNameFromPath(refsDir, filePath);\n\t\tlet raw;\n\t\ttry {\n\t\t\traw = await readFile(filePath, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tconst code = error instanceof Error ? error.code : void 0;\n\t\t\tif (code === \"ENOENT\" || code === \"EISDIR\") continue;\n\t\t\tthrow error;\n\t\t}\n\t\tlet parsed;\n\t\ttry {\n\t\t\tparsed = JSON.parse(raw);\n\t\t} catch (e) {\n\t\t\tproblems.push({\n\t\t\t\trefName: name,\n\t\t\t\tpath: filePath,\n\t\t\t\tdetail: e instanceof Error ? e.message : String(e)\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst result = refEntryOf(parsed);\n\t\tif (!result.ok) {\n\t\t\tproblems.push({\n\t\t\t\trefName: name,\n\t\t\t\tpath: filePath,\n\t\t\t\tdetail: result.failure.detail,\n\t\t\t\tpolicyIssues: result.failure.policyIssues\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\trefs[name] = result.value;\n\t}\n\treturn {\n\t\trefs,\n\t\tproblems\n\t};\n}\nasync function writeRef(refsDir, name, entry) {\n\tif (!validateRefName(name)) throw errorInvalidRefName(name);\n\tif (!validateRefValue(entry.hash)) throw errorInvalidRefValue(entry.hash);\n\tconst filePath = refFilePath(refsDir, name);\n\tconst dir = dirname(filePath);\n\tawait mkdir(dir, { recursive: true });\n\tconst tmpPath = join(dir, `.${name.split(\"/\").pop()}.json.${Date.now()}.tmp`);\n\tconst content = {\n\t\thash: entry.hash,\n\t\tinvariants: [...entry.invariants],\n\t\t...ifDefined(\"policies\", entry.policies)\n\t};\n\tawait writeFile(tmpPath, `${JSON.stringify(content, null, 2)}\\n`);\n\tawait rename(tmpPath, filePath);\n}\n/**\n* Points ref `name` at `hash`, keeping everything else the ref declares. A ref that does not exist\n* yet is written with no invariants. Returns the entry as written.\n*/\nasync function advanceRef(refsDir, name, hash) {\n\tconst existing = await readExistingRef(refsDir, name);\n\tconst entry = existing === void 0 ? {\n\t\thash,\n\t\tinvariants: []\n\t} : {\n\t\t...existing,\n\t\thash\n\t};\n\tawait writeRef(refsDir, name, entry);\n\treturn entry;\n}\nasync function readExistingRef(refsDir, name) {\n\ttry {\n\t\treturn await readRef(refsDir, name);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.UNKNOWN_REF\") return void 0;\n\t\tthrow error;\n\t}\n}\nasync function deleteRef(refsDir, name) {\n\tif (!validateRefName(name)) throw errorInvalidRefName(name);\n\tconst filePath = refFilePath(refsDir, name);\n\ttry {\n\t\tawait unlink(filePath);\n\t} catch (error) {\n\t\tif (error instanceof Error && error.code === \"ENOENT\") throw new MigrationToolsError(\"MIGRATION.UNKNOWN_REF\", `Unknown ref \"${name}\"`, {\n\t\t\twhy: `No ref file found at \"${filePath}\".`,\n\t\t\tfix: \"Run `{bin} migration ref list` to see available refs.\",\n\t\t\tnextActions: [{\n\t\t\t\tkind: \"run-command\",\n\t\t\t\tlabel: \"List the available refs\",\n\t\t\t\tcommand: \"{bin} migration ref list\"\n\t\t\t}],\n\t\t\tmeta: {\n\t\t\t\trefName: name,\n\t\t\t\tfilePath\n\t\t\t}\n\t\t});\n\t\tthrow error;\n\t}\n\tlet dir = dirname(filePath);\n\twhile (dir !== refsDir && dir.startsWith(refsDir)) try {\n\t\tawait rmdir(dir);\n\t\tdir = dirname(dir);\n\t} catch (error) {\n\t\tconst code = error instanceof Error ? error.code : void 0;\n\t\tif (code === \"ENOTEMPTY\" || code === \"EEXIST\" || code === \"ENOENT\") break;\n\t\tthrow error;\n\t}\n}\n/**\n* Index user-authored refs by the contract hash each ref points at.\n* Each bucket is sorted lex-asc for deterministic output.\n*/\nfunction refsByContractHash(refs) {\n\tconst byHash = /* @__PURE__ */ new Map();\n\tfor (const [name, entry] of Object.entries(refs)) {\n\t\tconst bucket = byHash.get(entry.hash);\n\t\tif (bucket) bucket.push(name);\n\t\telse byHash.set(entry.hash, [name]);\n\t}\n\tfor (const bucket of byHash.values()) bucket.sort();\n\treturn byHash;\n}\n/**\n* Read `migrations/<space>/refs/*.json` and index by destination hash.\n* Returns an empty map when the refs directory does not exist.\n*/\nasync function resolveRefsByContractHash(refsDir) {\n\treturn refsByContractHash(await readRefs(refsDir));\n}\nfunction resolveRef(refs, name) {\n\tif (!validateRefName(name)) throw errorInvalidRefName(name);\n\tif (!Object.hasOwn(refs, name)) throw new MigrationToolsError(\"MIGRATION.UNKNOWN_REF\", `Unknown ref \"${name}\"`, {\n\t\twhy: `No ref named \"${name}\" exists.`,\n\t\tfix: `Available refs: ${Object.keys(refs).join(\", \") || \"(none)\"}. Create a ref with: {bin} migration ref set ${name} <hash>`,\n\t\tnextActions: [{\n\t\t\tkind: \"run-command\",\n\t\t\tlabel: `Create the ref \"${name}\"`,\n\t\t\tcommand: `{bin} migration ref set ${name} <hash>`,\n\t\t\treason: `Available refs: ${Object.keys(refs).join(\", \") || \"(none)\"}.`\n\t\t}],\n\t\tmeta: {\n\t\t\trefName: name,\n\t\t\tavailableRefs: Object.keys(refs)\n\t\t}\n\t});\n\treturn refs[name];\n}\n//#endregion\nexport { readRefs as a, resolveRef as c, validateRefValue as d, writeRef as f, readRef as i, resolveRefsByContractHash as l, advanceRef as n, readRefsTolerant as o, deleteRef as r, refsByContractHash as s, HEAD_REF_NAME as t, validateRefName as u };\n\n//# sourceMappingURL=refs-t_JbIjGo.mjs.map"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,SAAS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SAAS,WAAW,MAAM,MAAM;CAC/B,IAAI,CAAC,gBAAgB,IAAI,GAAG,MAAM,oBAAoB,IAAI;CAC1D,IAAI,CAAC,OAAO,OAAO,MAAM,IAAI,GAAG,MAAM,IAAI,oBAAoB,yBAAyB,gBAAgB,KAAK,IAAI;EAC/G,KAAK,iBAAiB,KAAK;EAC3B,KAAK,mBAAmB,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,SAAS,+CAA+C,KAAK;EACrH,aAAa,CAAC;GACb,MAAM;GACN,OAAO,mBAAmB,KAAK;GAC/B,SAAS,2BAA2B,KAAK;GACzC,QAAQ,mBAAmB,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,SAAS;EACrE,CAAC;EACD,MAAM;GACL,SAAS;GACT,eAAe,OAAO,KAAK,IAAI;EAChC;CACD,CAAC;CACD,OAAO,KAAK;AACb"}
@@ -1,9 +1,9 @@
1
- import { f as errorDuplicateSpaceId, l as errorDescriptorHeadHashMismatch } from "./errors-DXha_4l--relAaiI4.mjs";
1
+ import { f as errorDuplicateSpaceId, l as errorDescriptorHeadHashMismatch } from "./errors-BMq40nYH-Cg8PBect.mjs";
2
2
  import { n as recomputePublishedStorageHash } from "./hash-BAZVWU4a-BQovI7hF.mjs";
3
- import { c as writeContractSnapshot } from "./contract-snapshot-store-nWnsWPPQ-rJ94UCcE.mjs";
4
- import { s as readMigrationsDir } from "./io-4O31S6Ei-DvsFKW_Y.mjs";
3
+ import { c as writeContractSnapshot } from "./contract-snapshot-store-B0fRbVHB-BN2g8BKh.mjs";
4
+ import { s as readMigrationsDir } from "./io-B39zsxMm-D5Wcf6cf.mjs";
5
5
  import { i as findPathWithDecision, o as reconstructGraph } from "./migration-graph-BoiiZAaU-DLht12k7.mjs";
6
- import { c as spaceMigrationDirectory, i as assertValidSpaceId, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID } from "./verify-contract-spaces-BmnQiKDj-JwT2fAPh.mjs";
6
+ import { c as readContractSpaceHeadRef, i as assertValidSpaceId, l as spaceMigrationDirectory, s as listContractSpaceDirectories, t as APP_SPACE_ID, u as spaceRefsDirectory } from "./verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs";
7
7
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
8
8
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
9
9
  import { join } from "pathe";
@@ -285,4 +285,4 @@ function planAllSpaces(inputs, planSpace) {
285
285
  //#endregion
286
286
  export { gatherDiskContractSpaceState as a, emitContractSpaceArtifacts as i, computeExtensionSpaceApplyPath as n, planAllSpaces as o, contractSpaceFromJson as r, assertDescriptorSelfConsistency as t };
287
287
 
288
- //# sourceMappingURL=spaces-BIABdklg.mjs.map
288
+ //# sourceMappingURL=spaces-OVZ0QzWJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"spaces-BIABdklg.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/spaces.mjs"],"sourcesContent":["import { f as errorDuplicateSpaceId, l as errorDescriptorHeadHashMismatch } from \"../errors-DXha_4l-.mjs\";\nimport { n as recomputePublishedStorageHash } from \"../hash-BAZVWU4a.mjs\";\nimport { c as writeContractSnapshot } from \"../contract-snapshot-store-nWnsWPPQ.mjs\";\nimport { s as readMigrationsDir } from \"../io-4O31S6Ei.mjs\";\nimport \"../constants-CM-w38DQ.mjs\";\nimport { i as findPathWithDecision, o as reconstructGraph } from \"../migration-graph-BoiiZAaU.mjs\";\nimport { a as RESERVED_SPACE_SUBDIR_NAMES, c as isValidSpaceId, i as APP_SPACE_ID, l as spaceMigrationDirectory, n as verifyContractSpaces, o as SPACE_REFS_DIRNAME, r as readContractSpaceHeadRef, s as assertValidSpaceId, t as listContractSpaceDirectories, u as spaceRefsDirectory } from \"../verify-contract-spaces-BmnQiKDj.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { join } from \"pathe\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/assert-descriptor-self-consistency.ts\n/**\n* Assert that an extension descriptor is self-consistent: the\n* `headRef.hash` it publishes must match the canonical hash recomputed\n* from its `contractSpace.contractJson`.\n*\n* Recomputes via {@link computeStorageHash} — the same canonical-JSON\n* pipeline the descriptor's own emit pipeline produced the hash with —\n* over `(target, targetFamily, storage)`. Mismatch indicates the\n* extension author bumped `contractJson` without rerunning emit, leaving\n* the descriptor's `headRef.hash` stale; the consumer-side helpers\n* (drift detection, on-disk artefact emission, runner marker writes) all\n* trust `headRef.hash` as the canonical identity, so a stale value would\n* silently corrupt every downstream boundary.\n*\n* Synchronous, pure, no I/O. Throws\n* `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH` on failure with both the\n* recomputed and published hashes in `meta` so callers can surface a\n* clear remediation hint without re-deriving them.\n*/\nfunction assertDescriptorSelfConsistency(inputs) {\n\tconst recomputed = recomputePublishedStorageHash({\n\t\ttarget: inputs.target,\n\t\ttargetFamily: inputs.targetFamily,\n\t\tstorage: inputs.storage,\n\t\thooks: {\n\t\t\t...ifDefined(\"shouldPreserveEmpty\", inputs.shouldPreserveEmpty),\n\t\t\t...ifDefined(\"sortStorage\", inputs.sortStorage)\n\t\t}\n\t});\n\tif (recomputed !== inputs.headRefHash) throw errorDescriptorHeadHashMismatch({\n\t\textensionId: inputs.extensionId,\n\t\trecomputedHash: recomputed,\n\t\theadRefHash: inputs.headRefHash\n\t});\n}\n//#endregion\n//#region src/compute-extension-space-apply-path.ts\n/**\n* Compute the apply path for an extension contract space — the shortest\n* sequence of on-disk migration packages that walks the live marker\n* forward to the on-disk head ref hash, covering every required\n* invariant.\n*\n* Reads only on-disk artifacts (`migrations/<spaceId>/refs/head.json`\n* and the per-space migration packages). **Does not import any\n* extension descriptor module** — `db init` / `db update` must remain\n* runnable without the descriptor source on disk.\n*\n* Behaviour:\n* - Returns `{ kind: 'ok', pathOps: [], … }` when the marker is already\n* at the recorded head and no required invariants are missing.\n* - Returns `{ kind: 'unreachable' }` when the marker hash is not\n* structurally connected to the recorded head in the graph.\n* - Returns `{ kind: 'unsatisfiable', missing, … }` when the marker is\n* reachable but no path covers the required invariants.\n* - Returns `{ kind: 'contractSpaceHeadRefMissing' }` when the per-space\n* `refs/head.json` is absent — the precheck verifier should already\n* have rejected this case, but the helper is defensive so callers can\n* surface a coherent error rather than throw.\n*/\nasync function computeExtensionSpaceApplyPath(inputs) {\n\tconst { projectMigrationsDir, spaceId, currentMarkerHash, currentMarkerInvariants } = inputs;\n\tconst contractSpaceHeadRef = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n\tif (contractSpaceHeadRef === null) return { kind: \"contractSpaceHeadRefMissing\" };\n\tconst { packages } = await readMigrationsDir(spaceMigrationDirectory(projectMigrationsDir, spaceId), { migrationsDir: projectMigrationsDir });\n\tconst graph = reconstructGraph(packages);\n\tconst fromHash = currentMarkerHash ?? \"empty\";\n\tconst required = new Set(contractSpaceHeadRef.invariants.filter((id) => !currentMarkerInvariants.includes(id)));\n\tconst outcome = findPathWithDecision(graph, fromHash, contractSpaceHeadRef.hash, { required });\n\tif (outcome.kind === \"unreachable\") return {\n\t\tkind: \"unreachable\",\n\t\tcontractSpaceHeadRef\n\t};\n\tif (outcome.kind === \"unsatisfiable\") return {\n\t\tkind: \"unsatisfiable\",\n\t\tcontractSpaceHeadRef,\n\t\tmissing: outcome.missing,\n\t\tstructuralPath: outcome.structuralPath.map(({ dirName, to }) => ({\n\t\t\tdirName,\n\t\t\tto\n\t\t}))\n\t};\n\tconst packagesByHash = new Map(packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));\n\tconst pathOps = [];\n\tconst walkedMigrationDirs = [];\n\tconst providedInvariantsSet = /* @__PURE__ */ new Set();\n\tfor (const edge of outcome.decision.selectedPath) {\n\t\tconst pkg = packagesByHash.get(edge.migrationHash);\n\t\tif (!pkg) throw new InternalError(`Migration package missing for edge ${edge.migrationHash} in space \"${spaceId}\"`);\n\t\twalkedMigrationDirs.push(pkg.dirName);\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}\n\treturn {\n\t\tkind: \"ok\",\n\t\tcontractSpaceHeadRef,\n\t\tprovidedInvariants: [...providedInvariantsSet].sort(),\n\t\tpathOps,\n\t\twalkedMigrationDirs\n\t};\n}\n//#endregion\n//#region src/contract-space-from-json.ts\n/**\n* Materialise a typed {@link ContractSpace} from the JSON artefacts a\n* contract-space extension package emits to disk.\n*\n* Extension descriptors wire `contract.json`, per-migration\n* `migration.json` / `ops.json`, and `refs/head.json` to the framework's\n* typed surfaces. TypeScript widens JSON imports to a structural record\n* that does not preserve readonly modifiers or branded scalars (e.g.\n* `StorageHashBase<'abc123...'>`), so authoring the descriptor inline\n* forces every wiring site to cast through `unknown`. This helper\n* encapsulates the single narrowing point: descriptor sources stay\n* cast-free, and the (necessary) coercion is colocated with the\n* documentation explaining why it is safe.\n*\n* Safety: the JSON files passed here are produced by the framework's own\n* emit pipeline (`prisma contract emit` and `MigrationCLI.run`)\n* and re-validated downstream by the runner / verifier. The descriptor\n* is a pass-through wiring layer — no descriptor consumer treats the\n* narrowed types as a stronger guarantee than \"these came from the\n* canonical emit pipeline\".\n*\n* The helper does not introspect or schema-validate the inputs; runtime\n* validation is the responsibility of `family.deserializeContract`\n* (codec-aware, invoked at control-stack construction) and the\n* per-migration `readMigrationPackage` reader used when loading\n* from disk. JSON-imported packages flow through the descriptor without\n* a disk read, so the equivalent runtime guarantee comes from the emit\n* pipeline that produced the JSON in the first place.\n*/\nfunction contractSpaceFromJson(inputs) {\n\tconst migrations = inputs.migrations.map((m) => ({\n\t\tdirName: m.dirName,\n\t\tmetadata: m.metadata,\n\t\tops: m.ops\n\t}));\n\treturn {\n\t\tcontractJson: inputs.contractJson,\n\t\tmigrations,\n\t\theadRef: inputs.headRef\n\t};\n}\n//#endregion\n//#region src/emit-contract-space-artifacts.ts\n/**\n* Emit the per-space artifacts — the head contract snapshot (written into\n* the migrations-root-wide `snapshots/` store, keyed by `headRef.hash`) and\n* `refs/head.json` — under `<projectMigrationsDir>/<spaceId>/`.\n*\n* The head contract snapshot is write-if-absent (see\n* {@link writeContractSnapshot}): a changed extension contract has a new\n* hash, so it lands as a new store entry; an unchanged hash means identical\n* canonical content already sits there. `refs/head.json` is\n* rewritten whenever the head it holds differs; a file that already holds the\n* same head, however it is formatted, is left alone.\n*\n* Path layout matches the convention in\n* [`spaceMigrationDirectory`](./space-layout.ts). The space id is\n* validated against `[a-z][a-z0-9_-]{0,63}` via\n* {@link assertValidSpaceId} for filesystem-safety reasons; the helper\n* accepts every space uniformly (including the app space, default\n* `'app'`).\n*\n* The migrations directory and space subdirectory are created if they\n* do not yet exist (`mkdir { recursive: true }`).\n*\n* Returns the snapshot directory and the head ref path when this call wrote them.\n*/\nasync function emitContractSpaceArtifacts(projectMigrationsDir, spaceId, inputs) {\n\tassertValidSpaceId(spaceId);\n\tconst refsDir = spaceRefsDirectory(join(projectMigrationsDir, spaceId));\n\tawait mkdir(refsDir, { recursive: true });\n\tconst writtenPaths = [];\n\tconst snapshot = await writeContractSnapshot(projectMigrationsDir, inputs.headRef.hash, {\n\t\tcontractJson: inputs.contract,\n\t\tcontractDts: inputs.contractDts\n\t});\n\tif (snapshot.written) writtenPaths.push(snapshot.dir);\n\tconst sortedInvariants = [...inputs.headRef.invariants].sort();\n\tconst headJson = canonicalizeJson({\n\t\thash: inputs.headRef.hash,\n\t\tinvariants: sortedInvariants\n\t});\n\tconst headPath = join(refsDir, \"head.json\");\n\tif (await canonicalHeadOnDisk(headPath) !== headJson) {\n\t\tawait writeFile(headPath, `${headJson}\\n`);\n\t\twrittenPaths.push(headPath);\n\t}\n\treturn { writtenPaths };\n}\nasync function canonicalHeadOnDisk(headPath) {\n\ttry {\n\t\tconst onDisk = JSON.parse(await readFile(headPath, \"utf-8\"));\n\t\tif (!Array.isArray(onDisk.invariants)) return void 0;\n\t\treturn canonicalizeJson({\n\t\t\thash: onDisk.hash,\n\t\t\tinvariants: [...onDisk.invariants].sort()\n\t\t});\n\t} catch {\n\t\treturn;\n\t}\n}\n//#endregion\n//#region src/gather-disk-contract-space-state.ts\n/**\n* Read the on-disk state the per-space verifier needs:\n*\n* - The list of contract-space directories under\n* `<projectMigrationsDir>/` (via\n* {@link import('./verify-contract-spaces').listContractSpaceDirectories}).\n* - The on-disk head ref `(hash, invariants)` for each declared extension space\n* (via {@link readContractSpaceHeadRef}; missing on-disk artefacts are simply\n* omitted — the verifier reports them as `declaredButUnmigrated`).\n*\n* Synchronous in spirit but async due to filesystem reads. Reads only\n* the user's repo. **Does not import any extension descriptor module.**\n*\n* Composition convention: pure target-agnostic primitive in\n* `1-framework`; the SQL family (and any future target family) wires\n* it into its `dbInit` / `verify` flows alongside its own marker-row\n* read before invoking `verifyContractSpaces`.\n*/\nasync function gatherDiskContractSpaceState(args) {\n\tconst { projectMigrationsDir, loadedSpaceIds } = args;\n\tconst spaceDirsOnDisk = await listContractSpaceDirectories(projectMigrationsDir);\n\tconst headRefsBySpace = /* @__PURE__ */ new Map();\n\tfor (const spaceId of loadedSpaceIds) {\n\t\tif (spaceId === APP_SPACE_ID) continue;\n\t\tconst head = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n\t\tif (head !== null) headRefsBySpace.set(spaceId, head);\n\t}\n\treturn {\n\t\tspaceDirsOnDisk,\n\t\theadRefsBySpace\n\t};\n}\n//#endregion\n//#region src/plan-all-spaces.ts\n/**\n* Iterate the per-space planner across a set of loaded contract spaces\n* and return a deterministic shape regardless of declaration order.\n*\n* Behaviour:\n*\n* - The output is sorted alphabetically by `spaceId`. Two callers\n* passing the same set of inputs in different orders observe\n* byte-identical outputs.\n* - The per-space planner (`planSpace`) is called exactly once per\n* input, in alphabetical-by-spaceId order. Its return value is\n* attached to the corresponding output entry verbatim.\n* - Duplicate `spaceId`s in the input array throw\n* `MIGRATION.DUPLICATE_SPACE_ID` before any `planSpace` call runs,\n* keeping the planner pure when the input is malformed.\n*\n* The signature is generic over `TContract` and `TPackage` because the\n* shape is framework-neutral (SQL family today, Mongo family\n* eventually). Callers wire in whatever contract value and migration\n* package shape their family already speaks.\n*\n* Synchronous: the underlying per-space planner (target's\n* `MigrationPlanner.plan(...)`) is synchronous; callers that need to\n* resolve async I/O (e.g. reading on-disk `contract.json` from disk)\n* resolve it before calling `planAllSpaces` and pass the materialised\n* inputs through.\n*/\nfunction planAllSpaces(inputs, planSpace) {\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (const input of inputs) {\n\t\tif (seen.has(input.spaceId)) throw errorDuplicateSpaceId(input.spaceId);\n\t\tseen.add(input.spaceId);\n\t}\n\treturn [...inputs].sort((a, b) => {\n\t\tif (a.spaceId < b.spaceId) return -1;\n\t\tif (a.spaceId > b.spaceId) return 1;\n\t\treturn 0;\n\t}).map((input) => ({\n\t\tspaceId: input.spaceId,\n\t\tmigrationPackages: planSpace(input)\n\t}));\n}\n//#endregion\nexport { APP_SPACE_ID, RESERVED_SPACE_SUBDIR_NAMES, SPACE_REFS_DIRNAME, assertDescriptorSelfConsistency, assertValidSpaceId, computeExtensionSpaceApplyPath, contractSpaceFromJson, emitContractSpaceArtifacts, gatherDiskContractSpaceState, isValidSpaceId, listContractSpaceDirectories, planAllSpaces, readContractSpaceHeadRef, spaceMigrationDirectory, spaceRefsDirectory, verifyContractSpaces };\n\n//# sourceMappingURL=spaces.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,gCAAgC,QAAQ;CAChD,MAAM,aAAa,8BAA8B;EAChD,QAAQ,OAAO;EACf,cAAc,OAAO;EACrB,SAAS,OAAO;EAChB,OAAO;GACN,GAAG,UAAU,uBAAuB,OAAO,mBAAmB;GAC9D,GAAG,UAAU,eAAe,OAAO,WAAW;EAC/C;CACD,CAAC;CACD,IAAI,eAAe,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AU,OAAO,CAAC;EAC3D,IAAI,CAAC,MAAM,QAAQ,OAAO,UAAU,GAAG,OAAO,KAAK;EACnD,OAAO,iBAAiB;GACvB,MAAM,OAAO;GACb,YAAY,CAAC,GAAG,OAAO,UAAU,CAAC,CAAC,KAAK;EACzC,CAAC;CACF,QAAQ;EACP;CACD;AACD;;;;;;;;;;;;;;;;;;;AAqBA,eAAe,6BAA6B,MAAM;CACjD,MAAM,EAAE,sBAAsB,mBAAmB;CACjD,MAAM,kBAAkB,MAAM,6BAA6B,oBAAoB;CAC/E,MAAM,kCAAkC,IAAI,IAAI;CAChD,KAAK,MAAM,WAAW,gBAAgB;EACrC,IAAI,YAAY,cAAc;EAC9B,MAAM,OAAO,MAAM,yBAAyB,sBAAsB,OAAO;EACzE,IAAI,SAAS,MAAM,gBAAgB,IAAI,SAAS,IAAI;CACrD;CACA,OAAO;EACN;EACA;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,cAAc,QAAQ,WAAW;CACzC,MAAM,uBAAuB,IAAI,IAAI;CACrC,KAAK,MAAM,SAAS,QAAQ;EAC3B,IAAI,KAAK,IAAI,MAAM,OAAO,GAAG,MAAM,sBAAsB,MAAM,OAAO;EACtE,KAAK,IAAI,MAAM,OAAO;CACvB;CACA,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM;EACjC,IAAI,EAAE,UAAU,EAAE,SAAS,OAAO;EAClC,IAAI,EAAE,UAAU,EAAE,SAAS,OAAO;EAClC,OAAO;CACR,CAAC,CAAC,CAAC,KAAK,WAAW;EAClB,SAAS,MAAM;EACf,mBAAmB,UAAU,KAAK;CACnC,EAAE;AACH"}
1
+ {"version":3,"file":"spaces-OVZ0QzWJ.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/exports/spaces.mjs"],"sourcesContent":["import { f as errorDuplicateSpaceId, l as errorDescriptorHeadHashMismatch } from \"../errors-BMq40nYH.mjs\";\nimport { n as recomputePublishedStorageHash } from \"../hash-BAZVWU4a.mjs\";\nimport { c as writeContractSnapshot } from \"../contract-snapshot-store-B0fRbVHB.mjs\";\nimport { s as readMigrationsDir } from \"../io-B39zsxMm.mjs\";\nimport \"../constants-CM-w38DQ.mjs\";\nimport { i as findPathWithDecision, o as reconstructGraph } from \"../migration-graph-BoiiZAaU.mjs\";\nimport { a as APP_SPACE_ID, c as assertValidSpaceId, d as spaceRefsDirectory, i as readContractSpaceHeadRef, l as isValidSpaceId, n as verifyContractSpaces, o as RESERVED_SPACE_SUBDIR_NAMES, s as SPACE_REFS_DIRNAME, t as listContractSpaceDirectories, u as spaceMigrationDirectory } from \"../verify-contract-spaces-BOnqhfQs.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { join } from \"pathe\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/assert-descriptor-self-consistency.ts\n/**\n* Assert that an extension descriptor is self-consistent: the\n* `headRef.hash` it publishes must match the canonical hash recomputed\n* from its `contractSpace.contractJson`.\n*\n* Recomputes via {@link computeStorageHash} — the same canonical-JSON\n* pipeline the descriptor's own emit pipeline produced the hash with —\n* over `(target, targetFamily, storage)`. Mismatch indicates the\n* extension author bumped `contractJson` without rerunning emit, leaving\n* the descriptor's `headRef.hash` stale; the consumer-side helpers\n* (drift detection, on-disk artefact emission, runner marker writes) all\n* trust `headRef.hash` as the canonical identity, so a stale value would\n* silently corrupt every downstream boundary.\n*\n* Synchronous, pure, no I/O. Throws\n* `MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH` on failure with both the\n* recomputed and published hashes in `meta` so callers can surface a\n* clear remediation hint without re-deriving them.\n*/\nfunction assertDescriptorSelfConsistency(inputs) {\n\tconst recomputed = recomputePublishedStorageHash({\n\t\ttarget: inputs.target,\n\t\ttargetFamily: inputs.targetFamily,\n\t\tstorage: inputs.storage,\n\t\thooks: {\n\t\t\t...ifDefined(\"shouldPreserveEmpty\", inputs.shouldPreserveEmpty),\n\t\t\t...ifDefined(\"sortStorage\", inputs.sortStorage)\n\t\t}\n\t});\n\tif (recomputed !== inputs.headRefHash) throw errorDescriptorHeadHashMismatch({\n\t\textensionId: inputs.extensionId,\n\t\trecomputedHash: recomputed,\n\t\theadRefHash: inputs.headRefHash\n\t});\n}\n//#endregion\n//#region src/compute-extension-space-apply-path.ts\n/**\n* Compute the apply path for an extension contract space — the shortest\n* sequence of on-disk migration packages that walks the live marker\n* forward to the on-disk head ref hash, covering every required\n* invariant.\n*\n* Reads only on-disk artifacts (`migrations/<spaceId>/refs/head.json`\n* and the per-space migration packages). **Does not import any\n* extension descriptor module** — `db init` / `db update` must remain\n* runnable without the descriptor source on disk.\n*\n* Behaviour:\n* - Returns `{ kind: 'ok', pathOps: [], … }` when the marker is already\n* at the recorded head and no required invariants are missing.\n* - Returns `{ kind: 'unreachable' }` when the marker hash is not\n* structurally connected to the recorded head in the graph.\n* - Returns `{ kind: 'unsatisfiable', missing, … }` when the marker is\n* reachable but no path covers the required invariants.\n* - Returns `{ kind: 'contractSpaceHeadRefMissing' }` when the per-space\n* `refs/head.json` is absent — the precheck verifier should already\n* have rejected this case, but the helper is defensive so callers can\n* surface a coherent error rather than throw.\n*/\nasync function computeExtensionSpaceApplyPath(inputs) {\n\tconst { projectMigrationsDir, spaceId, currentMarkerHash, currentMarkerInvariants } = inputs;\n\tconst contractSpaceHeadRef = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n\tif (contractSpaceHeadRef === null) return { kind: \"contractSpaceHeadRefMissing\" };\n\tconst { packages } = await readMigrationsDir(spaceMigrationDirectory(projectMigrationsDir, spaceId), { migrationsDir: projectMigrationsDir });\n\tconst graph = reconstructGraph(packages);\n\tconst fromHash = currentMarkerHash ?? \"empty\";\n\tconst required = new Set(contractSpaceHeadRef.invariants.filter((id) => !currentMarkerInvariants.includes(id)));\n\tconst outcome = findPathWithDecision(graph, fromHash, contractSpaceHeadRef.hash, { required });\n\tif (outcome.kind === \"unreachable\") return {\n\t\tkind: \"unreachable\",\n\t\tcontractSpaceHeadRef\n\t};\n\tif (outcome.kind === \"unsatisfiable\") return {\n\t\tkind: \"unsatisfiable\",\n\t\tcontractSpaceHeadRef,\n\t\tmissing: outcome.missing,\n\t\tstructuralPath: outcome.structuralPath.map(({ dirName, to }) => ({\n\t\t\tdirName,\n\t\t\tto\n\t\t}))\n\t};\n\tconst packagesByHash = new Map(packages.map((pkg) => [pkg.metadata.migrationHash, pkg]));\n\tconst pathOps = [];\n\tconst walkedMigrationDirs = [];\n\tconst providedInvariantsSet = /* @__PURE__ */ new Set();\n\tfor (const edge of outcome.decision.selectedPath) {\n\t\tconst pkg = packagesByHash.get(edge.migrationHash);\n\t\tif (!pkg) throw new InternalError(`Migration package missing for edge ${edge.migrationHash} in space \"${spaceId}\"`);\n\t\twalkedMigrationDirs.push(pkg.dirName);\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}\n\treturn {\n\t\tkind: \"ok\",\n\t\tcontractSpaceHeadRef,\n\t\tprovidedInvariants: [...providedInvariantsSet].sort(),\n\t\tpathOps,\n\t\twalkedMigrationDirs\n\t};\n}\n//#endregion\n//#region src/contract-space-from-json.ts\n/**\n* Materialise a typed {@link ContractSpace} from the JSON artefacts a\n* contract-space extension package emits to disk.\n*\n* Extension descriptors wire `contract.json`, per-migration\n* `migration.json` / `ops.json`, and `refs/head.json` to the framework's\n* typed surfaces. TypeScript widens JSON imports to a structural record\n* that does not preserve readonly modifiers or branded scalars (e.g.\n* `StorageHashBase<'abc123...'>`), so authoring the descriptor inline\n* forces every wiring site to cast through `unknown`. This helper\n* encapsulates the single narrowing point: descriptor sources stay\n* cast-free, and the (necessary) coercion is colocated with the\n* documentation explaining why it is safe.\n*\n* Safety: the JSON files passed here are produced by the framework's own\n* emit pipeline (`prisma contract emit` and `MigrationCLI.run`)\n* and re-validated downstream by the runner / verifier. The descriptor\n* is a pass-through wiring layer — no descriptor consumer treats the\n* narrowed types as a stronger guarantee than \"these came from the\n* canonical emit pipeline\".\n*\n* The helper does not introspect or schema-validate the inputs; runtime\n* validation is the responsibility of `family.deserializeContract`\n* (codec-aware, invoked at control-stack construction) and the\n* per-migration `readMigrationPackage` reader used when loading\n* from disk. JSON-imported packages flow through the descriptor without\n* a disk read, so the equivalent runtime guarantee comes from the emit\n* pipeline that produced the JSON in the first place.\n*/\nfunction contractSpaceFromJson(inputs) {\n\tconst migrations = inputs.migrations.map((m) => ({\n\t\tdirName: m.dirName,\n\t\tmetadata: m.metadata,\n\t\tops: m.ops\n\t}));\n\treturn {\n\t\tcontractJson: inputs.contractJson,\n\t\tmigrations,\n\t\theadRef: inputs.headRef\n\t};\n}\n//#endregion\n//#region src/emit-contract-space-artifacts.ts\n/**\n* Emit the per-space artifacts — the head contract snapshot (written into\n* the migrations-root-wide `snapshots/` store, keyed by `headRef.hash`) and\n* `refs/head.json` — under `<projectMigrationsDir>/<spaceId>/`.\n*\n* The head contract snapshot is write-if-absent (see\n* {@link writeContractSnapshot}): a changed extension contract has a new\n* hash, so it lands as a new store entry; an unchanged hash means identical\n* canonical content already sits there. `refs/head.json` is\n* rewritten whenever the head it holds differs; a file that already holds the\n* same head, however it is formatted, is left alone.\n*\n* Path layout matches the convention in\n* [`spaceMigrationDirectory`](./space-layout.ts). The space id is\n* validated against `[a-z][a-z0-9_-]{0,63}` via\n* {@link assertValidSpaceId} for filesystem-safety reasons; the helper\n* accepts every space uniformly (including the app space, default\n* `'app'`).\n*\n* The migrations directory and space subdirectory are created if they\n* do not yet exist (`mkdir { recursive: true }`).\n*\n* Returns the snapshot directory and the head ref path when this call wrote them.\n*/\nasync function emitContractSpaceArtifacts(projectMigrationsDir, spaceId, inputs) {\n\tassertValidSpaceId(spaceId);\n\tconst refsDir = spaceRefsDirectory(join(projectMigrationsDir, spaceId));\n\tawait mkdir(refsDir, { recursive: true });\n\tconst writtenPaths = [];\n\tconst snapshot = await writeContractSnapshot(projectMigrationsDir, inputs.headRef.hash, {\n\t\tcontractJson: inputs.contract,\n\t\tcontractDts: inputs.contractDts\n\t});\n\tif (snapshot.written) writtenPaths.push(snapshot.dir);\n\tconst sortedInvariants = [...inputs.headRef.invariants].sort();\n\tconst headJson = canonicalizeJson({\n\t\thash: inputs.headRef.hash,\n\t\tinvariants: sortedInvariants\n\t});\n\tconst headPath = join(refsDir, \"head.json\");\n\tif (await canonicalHeadOnDisk(headPath) !== headJson) {\n\t\tawait writeFile(headPath, `${headJson}\\n`);\n\t\twrittenPaths.push(headPath);\n\t}\n\treturn { writtenPaths };\n}\nasync function canonicalHeadOnDisk(headPath) {\n\ttry {\n\t\tconst onDisk = JSON.parse(await readFile(headPath, \"utf-8\"));\n\t\tif (!Array.isArray(onDisk.invariants)) return void 0;\n\t\treturn canonicalizeJson({\n\t\t\thash: onDisk.hash,\n\t\t\tinvariants: [...onDisk.invariants].sort()\n\t\t});\n\t} catch {\n\t\treturn;\n\t}\n}\n//#endregion\n//#region src/gather-disk-contract-space-state.ts\n/**\n* Read the on-disk state the per-space verifier needs:\n*\n* - The list of contract-space directories under\n* `<projectMigrationsDir>/` (via\n* {@link import('./verify-contract-spaces').listContractSpaceDirectories}).\n* - The on-disk head ref `(hash, invariants)` for each declared extension space\n* (via {@link readContractSpaceHeadRef}; missing on-disk artefacts are simply\n* omitted — the verifier reports them as `declaredButUnmigrated`).\n*\n* Synchronous in spirit but async due to filesystem reads. Reads only\n* the user's repo. **Does not import any extension descriptor module.**\n*\n* Composition convention: pure target-agnostic primitive in\n* `1-framework`; the SQL family (and any future target family) wires\n* it into its `dbInit` / `verify` flows alongside its own marker-row\n* read before invoking `verifyContractSpaces`.\n*/\nasync function gatherDiskContractSpaceState(args) {\n\tconst { projectMigrationsDir, loadedSpaceIds } = args;\n\tconst spaceDirsOnDisk = await listContractSpaceDirectories(projectMigrationsDir);\n\tconst headRefsBySpace = /* @__PURE__ */ new Map();\n\tfor (const spaceId of loadedSpaceIds) {\n\t\tif (spaceId === APP_SPACE_ID) continue;\n\t\tconst head = await readContractSpaceHeadRef(projectMigrationsDir, spaceId);\n\t\tif (head !== null) headRefsBySpace.set(spaceId, head);\n\t}\n\treturn {\n\t\tspaceDirsOnDisk,\n\t\theadRefsBySpace\n\t};\n}\n//#endregion\n//#region src/plan-all-spaces.ts\n/**\n* Iterate the per-space planner across a set of loaded contract spaces\n* and return a deterministic shape regardless of declaration order.\n*\n* Behaviour:\n*\n* - The output is sorted alphabetically by `spaceId`. Two callers\n* passing the same set of inputs in different orders observe\n* byte-identical outputs.\n* - The per-space planner (`planSpace`) is called exactly once per\n* input, in alphabetical-by-spaceId order. Its return value is\n* attached to the corresponding output entry verbatim.\n* - Duplicate `spaceId`s in the input array throw\n* `MIGRATION.DUPLICATE_SPACE_ID` before any `planSpace` call runs,\n* keeping the planner pure when the input is malformed.\n*\n* The signature is generic over `TContract` and `TPackage` because the\n* shape is framework-neutral (SQL family today, Mongo family\n* eventually). Callers wire in whatever contract value and migration\n* package shape their family already speaks.\n*\n* Synchronous: the underlying per-space planner (target's\n* `MigrationPlanner.plan(...)`) is synchronous; callers that need to\n* resolve async I/O (e.g. reading on-disk `contract.json` from disk)\n* resolve it before calling `planAllSpaces` and pass the materialised\n* inputs through.\n*/\nfunction planAllSpaces(inputs, planSpace) {\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (const input of inputs) {\n\t\tif (seen.has(input.spaceId)) throw errorDuplicateSpaceId(input.spaceId);\n\t\tseen.add(input.spaceId);\n\t}\n\treturn [...inputs].sort((a, b) => {\n\t\tif (a.spaceId < b.spaceId) return -1;\n\t\tif (a.spaceId > b.spaceId) return 1;\n\t\treturn 0;\n\t}).map((input) => ({\n\t\tspaceId: input.spaceId,\n\t\tmigrationPackages: planSpace(input)\n\t}));\n}\n//#endregion\nexport { APP_SPACE_ID, RESERVED_SPACE_SUBDIR_NAMES, SPACE_REFS_DIRNAME, assertDescriptorSelfConsistency, assertValidSpaceId, computeExtensionSpaceApplyPath, contractSpaceFromJson, emitContractSpaceArtifacts, gatherDiskContractSpaceState, isValidSpaceId, listContractSpaceDirectories, planAllSpaces, readContractSpaceHeadRef, spaceMigrationDirectory, spaceRefsDirectory, verifyContractSpaces };\n\n//# sourceMappingURL=spaces.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAS,gCAAgC,QAAQ;CAChD,MAAM,aAAa,8BAA8B;EAChD,QAAQ,OAAO;EACf,cAAc,OAAO;EACrB,SAAS,OAAO;EAChB,OAAO;GACN,GAAG,UAAU,uBAAuB,OAAO,mBAAmB;GAC9D,GAAG,UAAU,eAAe,OAAO,WAAW;EAC/C;CACD,CAAC;CACD,IAAI,eAAe,OAAO,aAAa,MAAM,gCAAgC;EAC5E,aAAa,OAAO;EACpB,gBAAgB;EAChB,aAAa,OAAO;CACrB,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,eAAe,+BAA+B,QAAQ;CACrD,MAAM,EAAE,sBAAsB,SAAS,mBAAmB,4BAA4B;CACtF,MAAM,uBAAuB,MAAM,yBAAyB,sBAAsB,OAAO;CACzF,IAAI,yBAAyB,MAAM,OAAO,EAAE,MAAM,8BAA8B;CAChF,MAAM,EAAE,aAAa,MAAM,kBAAkB,wBAAwB,sBAAsB,OAAO,GAAG,EAAE,eAAe,qBAAqB,CAAC;CAC5I,MAAM,QAAQ,iBAAiB,QAAQ;CACvC,MAAM,WAAW,qBAAqB;CACtC,MAAM,WAAW,IAAI,IAAI,qBAAqB,WAAW,QAAQ,OAAO,CAAC,wBAAwB,SAAS,EAAE,CAAC,CAAC;CAC9G,MAAM,UAAU,qBAAqB,OAAO,UAAU,qBAAqB,MAAM,EAAE,SAAS,CAAC;CAC7F,IAAI,QAAQ,SAAS,eAAe,OAAO;EAC1C,MAAM;EACN;CACD;CACA,IAAI,QAAQ,SAAS,iBAAiB,OAAO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GAAG,MAAM,sBAAsB,MAAM,OAAO;EACtE,KAAK,IAAI,MAAM,OAAO;CACvB;CACA,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,GAAG,MAAM;EACjC,IAAI,EAAE,UAAU,EAAE,SAAS,OAAO;EAClC,IAAI,EAAE,UAAU,EAAE,SAAS,OAAO;EAClC,OAAO;CACR,CAAC,CAAC,CAAC,KAAK,WAAW;EAClB,SAAS,MAAM;EACf,mBAAmB,UAAU,KAAK;CACnC,EAAE;AACH"}
@@ -1,9 +1,9 @@
1
- import { C as errorInvalidSpaceId, g as errorInvalidJson, y as errorInvalidRefFile } from "./errors-DXha_4l--relAaiI4.mjs";
2
- import { t as MANIFEST_FILE } from "./io-4O31S6Ei-DvsFKW_Y.mjs";
1
+ import { C as errorInvalidSpaceId, g as errorInvalidJson, y as errorInvalidRefFile } from "./errors-BMq40nYH-Cg8PBect.mjs";
2
+ import { t as MANIFEST_FILE } from "./io-B39zsxMm-D5Wcf6cf.mjs";
3
3
  import { APP_SPACE_ID as APP_SPACE_ID$1, CONTRACT_SNAPSHOTS_DIRNAME } from "@prisma/orm-framework/components/control";
4
4
  import { join } from "pathe";
5
5
  import { readFile, readdir, stat } from "node:fs/promises";
6
- //#region ../../../1-framework/3-tooling/migration/dist/verify-contract-spaces-BmnQiKDj.mjs
6
+ //#region ../../../1-framework/3-tooling/migration/dist/verify-contract-spaces-BOnqhfQs.mjs
7
7
  /**
8
8
  * Pattern a contract-space identifier must match. The constraint is
9
9
  * filesystem-friendly: lowercase letters / digits / hyphen / underscore,
@@ -61,6 +61,11 @@ function spaceRefsDirectory(spaceMigrationsDir) {
61
61
  function hasErrnoCode$1(error, code) {
62
62
  return error instanceof Error && error.code === code;
63
63
  }
64
+ /** The file that holds the head ref of contract space `spaceId`. */
65
+ function contractSpaceHeadRefPath(projectMigrationsDir, spaceId) {
66
+ assertValidSpaceId(spaceId);
67
+ return join(spaceRefsDirectory(spaceMigrationDirectory(projectMigrationsDir, spaceId)), "head.json");
68
+ }
64
69
  /**
65
70
  * Read the head ref (`hash` + `invariants`) for a contract space from
66
71
  * `<projectMigrationsDir>/<spaceId>/refs/head.json`.
@@ -75,8 +80,7 @@ function hasErrnoCode$1(error, code) {
75
80
  * helper is uniform across the app and extension spaces.
76
81
  */
77
82
  async function readContractSpaceHeadRef(projectMigrationsDir, spaceId) {
78
- assertValidSpaceId(spaceId);
79
- const filePath = join(spaceRefsDirectory(spaceMigrationDirectory(projectMigrationsDir, spaceId)), "head.json");
83
+ const filePath = contractSpaceHeadRefPath(projectMigrationsDir, spaceId);
80
84
  let raw;
81
85
  try {
82
86
  raw = await readFile(filePath, "utf-8");
@@ -247,6 +251,6 @@ function verifyContractSpaces(inputs) {
247
251
  };
248
252
  }
249
253
  //#endregion
250
- export { isValidSpaceId as a, spaceMigrationDirectory as c, assertValidSpaceId as i, spaceRefsDirectory as l, RESERVED_SPACE_SUBDIR_NAMES as n, listContractSpaceDirectories as o, SPACE_REFS_DIRNAME as r, readContractSpaceHeadRef as s, APP_SPACE_ID$1 as t, verifyContractSpaces as u };
254
+ export { contractSpaceHeadRefPath as a, readContractSpaceHeadRef as c, verifyContractSpaces as d, assertValidSpaceId as i, spaceMigrationDirectory as l, RESERVED_SPACE_SUBDIR_NAMES as n, isValidSpaceId as o, SPACE_REFS_DIRNAME as r, listContractSpaceDirectories as s, APP_SPACE_ID$1 as t, spaceRefsDirectory as u };
251
255
 
252
- //# sourceMappingURL=verify-contract-spaces-BmnQiKDj-JwT2fAPh.mjs.map
256
+ //# sourceMappingURL=verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-contract-spaces-BOnqhfQs-BBq5YOKo.mjs","names":["APP_SPACE_ID"],"sources":["../../../../1-framework/3-tooling/migration/dist/verify-contract-spaces-BOnqhfQs.mjs"],"sourcesContent":["import { C as errorInvalidSpaceId, g as errorInvalidJson, y as errorInvalidRefFile } from \"./errors-BMq40nYH.mjs\";\nimport { t as MANIFEST_FILE } from \"./io-B39zsxMm.mjs\";\nimport { APP_SPACE_ID, CONTRACT_SNAPSHOTS_DIRNAME } from \"@internal/framework-components/control\";\nimport { join } from \"pathe\";\nimport { readFile, readdir, stat } from \"node:fs/promises\";\n//#region src/space-layout.ts\n/**\n* Pattern a contract-space identifier must match. The constraint is\n* filesystem-friendly: lowercase letters / digits / hyphen / underscore,\n* starts with a letter, max 64 characters.\n*/\nconst SPACE_ID_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;\nfunction isValidSpaceId(spaceId) {\n\treturn SPACE_ID_PATTERN.test(spaceId);\n}\nfunction assertValidSpaceId(spaceId) {\n\tif (!isValidSpaceId(spaceId)) throw errorInvalidSpaceId(spaceId);\n}\n/**\n* Resolve the migrations subdirectory for a given contract space.\n*\n* Every contract space — including the app space (default `'app'`) —\n* lands under `<projectMigrationsDir>/<spaceId>/`. The space id is\n* validated against {@link SPACE_ID_PATTERN} because it becomes a\n* filesystem directory name verbatim.\n*\n* `projectMigrationsDir` is the project's top-level `migrations/`\n* directory; the helper does not assume anything about its absolute /\n* relative shape and is symmetric with `pathe.join`.\n*/\nfunction spaceMigrationDirectory(projectMigrationsDir, spaceId) {\n\tassertValidSpaceId(spaceId);\n\treturn join(projectMigrationsDir, spaceId);\n}\n/**\n* Per-space subdirectory name reserved for the ref store\n* (`migrations/<space>/<SPACE_REFS_DIRNAME>/*.json`). Single source of\n* truth: every helper that composes a per-space refs path imports this\n* constant, and the enumerator uses it (via\n* {@link RESERVED_SPACE_SUBDIR_NAMES}) to exclude reserved names from\n* the contract-space candidate list.\n*/\nconst SPACE_REFS_DIRNAME = \"refs\";\n/**\n* Names reserved under `migrations/` that must never be enumerated as a\n* phantom contract space: `SPACE_REFS_DIRNAME` (e.g. a top-level\n* `migrations/refs/` left in the wrong place) and\n* `CONTRACT_SNAPSHOTS_DIRNAME` (the migrations-root-wide contract\n* snapshot store, `migrations/snapshots/`).\n*/\nconst RESERVED_SPACE_SUBDIR_NAMES = /* @__PURE__ */ new Set([SPACE_REFS_DIRNAME, CONTRACT_SNAPSHOTS_DIRNAME]);\n/**\n* Resolve the per-space refs directory for `spaceMigrationsDir`\n* (typically the value returned by {@link spaceMigrationDirectory}).\n* Composes the canonical {@link SPACE_REFS_DIRNAME} so callers do not\n* hard-code the literal.\n*/\nfunction spaceRefsDirectory(spaceMigrationsDir) {\n\treturn join(spaceMigrationsDir, SPACE_REFS_DIRNAME);\n}\n//#endregion\n//#region src/read-contract-space-head-ref.ts\nfunction hasErrnoCode$1(error, code) {\n\treturn error instanceof Error && error.code === code;\n}\n/** The file that holds the head ref of contract space `spaceId`. */\nfunction contractSpaceHeadRefPath(projectMigrationsDir, spaceId) {\n\tassertValidSpaceId(spaceId);\n\treturn join(spaceRefsDirectory(spaceMigrationDirectory(projectMigrationsDir, spaceId)), \"head.json\");\n}\n/**\n* Read the head ref (`hash` + `invariants`) for a contract space from\n* `<projectMigrationsDir>/<spaceId>/refs/head.json`.\n*\n* Returns `null` when the file does not exist (first emit). Surfaces\n* `MIGRATION.INVALID_JSON` / `MIGRATION.INVALID_REF_FILE` on a corrupt\n* `refs/head.json` so callers can distinguish \"no head ref on disk\"\n* (returns `null`) from \"head ref present but unreadable\" (throws).\n*\n* Validates the space id against `[a-z][a-z0-9_-]{0,63}` for the same\n* filesystem-safety reasons as the rest of the per-space helpers. The\n* helper is uniform across the app and extension spaces.\n*/\nasync function readContractSpaceHeadRef(projectMigrationsDir, spaceId) {\n\tconst filePath = contractSpaceHeadRefPath(projectMigrationsDir, spaceId);\n\tlet raw;\n\ttry {\n\t\traw = await readFile(filePath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode$1(error, \"ENOENT\")) return null;\n\t\tthrow error;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(filePath, e instanceof Error ? e.message : String(e));\n\t}\n\tif (typeof parsed !== \"object\" || parsed === null) throw errorInvalidRefFile(filePath, \"expected an object\");\n\tconst obj = parsed;\n\tif (typeof obj.hash !== \"string\") throw errorInvalidRefFile(filePath, \"expected an object with a string `hash` field\");\n\tif (!Array.isArray(obj.invariants) || obj.invariants.some((value) => typeof value !== \"string\")) throw errorInvalidRefFile(filePath, \"expected an object with an `invariants` array of strings\");\n\treturn {\n\t\thash: obj.hash,\n\t\tinvariants: obj.invariants\n\t};\n}\n//#endregion\n//#region src/verify-contract-spaces.ts\nfunction hasErrnoCode(error, code) {\n\treturn error instanceof Error && error.code === code;\n}\n/**\n* List the per-space subdirectories under\n* `<projectRoot>/migrations/`. Returns space-id directory names (sorted\n* alphabetically) — i.e. any non-dot-prefixed, non-reserved\n* ({@link RESERVED_SPACE_SUBDIR_NAMES}) subdirectory whose root does\n* **not** contain a `migration.json` manifest. The manifest is the\n* structural marker of a user-authored migration directory (see\n* `readMigrationsDir` in `./io`); directory names themselves belong to\n* the user and are not part of the contract. The reserved-name filter\n* keeps `migrations/snapshots/` (the contract snapshot store) from ever\n* being enumerated as a phantom contract space.\n*\n* Returns `[]` if the migrations directory does not exist (greenfield\n* project).\n*\n* Reads only the user's repo. **No descriptor import.** The caller\n* (verifier) feeds the result into {@link verifyContractSpaces} alongside\n* the loaded-space set and the marker rows.\n*/\nasync function listContractSpaceDirectories(projectMigrationsDir) {\n\tlet entries;\n\ttry {\n\t\tentries = (await readdir(projectMigrationsDir, { withFileTypes: true })).map((d) => ({\n\t\t\tname: d.name,\n\t\t\tisDirectory: d.isDirectory()\n\t\t}));\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return [];\n\t\tthrow error;\n\t}\n\tconst namedCandidates = entries.filter((e) => e.isDirectory).map((e) => e.name).filter((name) => !name.startsWith(\".\")).filter((name) => !RESERVED_SPACE_SUBDIR_NAMES.has(name)).sort();\n\treturn (await Promise.all(namedCandidates.map(async (name) => {\n\t\ttry {\n\t\t\tawait stat(join(projectMigrationsDir, name, MANIFEST_FILE));\n\t\t\treturn {\n\t\t\t\tname,\n\t\t\t\tisMigrationDir: true\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (hasErrnoCode(error, \"ENOENT\")) return {\n\t\t\t\tname,\n\t\t\t\tisMigrationDir: false\n\t\t\t};\n\t\t\tthrow error;\n\t\t}\n\t}))).filter((c) => !c.isMigrationDir).map((c) => c.name);\n}\n/**\n* Pure structural verifier for the per-space mechanism. Aggregates the\n* three orphan / missing checks plus per-space hash and invariant\n* comparison.\n*\n* Algorithm:\n*\n* - For every extension space declared in `loadedSpaces` (`'app'`\n* excluded — the per-space verifier is scoped to extension spaces;\n* the app is verified through the aggregate path):\n* - If no contract-space dir on disk → `declaredButUnmigrated`.\n* - Else if `markerRowsBySpace` lacks an entry → no violation here;\n* the live-DB compare done outside this helper is where the\n* absence shows up.\n* - Else compare marker hash / invariants vs. on-disk head hash /\n* invariants → `hashMismatch` / `invariantsMismatch` on drift.\n* - For every contract-space dir on disk that is not in `loadedSpaces` →\n* `orphanSpaceDir`.\n* - For every marker row whose `space` is not in `loadedSpaces` →\n* `orphanMarker`. The app-space marker is always loaded (`'app'` is\n* in `loadedSpaces` by definition).\n*\n* Output is deterministic: violations are sorted first by `kind`\n* (`declaredButUnmigrated` → `orphanMarker` → `orphanSpaceDir` →\n* `hashMismatch` → `invariantsMismatch`) then by `spaceId`. Two callers\n* passing equivalent inputs see byte-identical violation lists.\n*\n* Synchronous, pure, no I/O. **Does not import the extension descriptor**\n* (the inputs are pre-resolved by the caller); the verifier reads only\n* the user repo, not `node_modules`.\n*/\nfunction verifyContractSpaces(inputs) {\n\tconst violations = [];\n\tfor (const spaceId of [...inputs.loadedSpaces].sort()) {\n\t\tif (spaceId === APP_SPACE_ID) continue;\n\t\tif (!inputs.spaceDirsOnDisk.includes(spaceId)) {\n\t\t\tviolations.push({\n\t\t\t\tkind: \"declaredButUnmigrated\",\n\t\t\t\tspaceId,\n\t\t\t\tremediation: `Extension '${spaceId}' is declared in extensions but has not been emitted; run \\`{bin} db migrate\\`.`\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst head = inputs.headRefsBySpace.get(spaceId);\n\t\tconst marker = inputs.markerRowsBySpace.get(spaceId);\n\t\tif (!head || !marker) continue;\n\t\tif (head.hash !== marker.hash) {\n\t\t\tviolations.push({\n\t\t\t\tkind: \"hashMismatch\",\n\t\t\t\tspaceId,\n\t\t\t\tpriorHeadHash: head.hash,\n\t\t\t\tmarkerHash: marker.hash,\n\t\t\t\tremediation: `Marker row for space '${spaceId}' is keyed at ${marker.hash}, but the on-disk ${join(\"migrations\", spaceId, \"contract.json\")} resolves to ${head.hash}. Run \\`{bin} db update\\` to advance the database, or \\`{bin} db migrate\\` if the descriptor was bumped without re-emitting.`\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst onDiskInvariants = [...head.invariants].sort();\n\t\tconst markerInvariants = new Set(marker.invariants);\n\t\tconst missing = onDiskInvariants.filter((id) => !markerInvariants.has(id));\n\t\tif (missing.length > 0) violations.push({\n\t\t\tkind: \"invariantsMismatch\",\n\t\t\tspaceId,\n\t\t\tonDiskInvariants,\n\t\t\tmarkerInvariants: [...marker.invariants].sort(),\n\t\t\tremediation: `Marker row for space '${spaceId}' is missing invariants [${missing.map((s) => JSON.stringify(s)).join(\", \")}]. Run \\`{bin} db update\\` to apply the corresponding data-transform migrations.`\n\t\t});\n\t}\n\tfor (const dir of [...inputs.spaceDirsOnDisk].sort()) if (!inputs.loadedSpaces.has(dir)) violations.push({\n\t\tkind: \"orphanSpaceDir\",\n\t\tspaceId: dir,\n\t\tremediation: `Orphan contract-space directory \\`${join(\"migrations\", dir)}/\\` for an extension not in extensions; remove the directory or re-add the extension.`\n\t});\n\tfor (const space of [...inputs.markerRowsBySpace.keys()].sort()) if (!inputs.loadedSpaces.has(space)) violations.push({\n\t\tkind: \"orphanMarker\",\n\t\tspaceId: space,\n\t\tremediation: `Orphan marker row for space '${space}' (no longer in extensions); remediation: manually delete the row from \\`${inputs.markerLocation}\\`.`\n\t});\n\tif (violations.length === 0) return { ok: true };\n\tconst kindOrder = {\n\t\tdeclaredButUnmigrated: 0,\n\t\torphanMarker: 1,\n\t\torphanSpaceDir: 2,\n\t\thashMismatch: 3,\n\t\tinvariantsMismatch: 4\n\t};\n\tviolations.sort((a, b) => {\n\t\tconst k = kindOrder[a.kind] - kindOrder[b.kind];\n\t\tif (k !== 0) return k;\n\t\tif (a.spaceId < b.spaceId) return -1;\n\t\tif (a.spaceId > b.spaceId) return 1;\n\t\treturn 0;\n\t});\n\treturn {\n\t\tok: false,\n\t\tviolations\n\t};\n}\n//#endregion\nexport { APP_SPACE_ID as a, assertValidSpaceId as c, spaceRefsDirectory as d, readContractSpaceHeadRef as i, isValidSpaceId as l, verifyContractSpaces as n, RESERVED_SPACE_SUBDIR_NAMES as o, contractSpaceHeadRefPath as r, SPACE_REFS_DIRNAME as s, listContractSpaceDirectories as t, spaceMigrationDirectory as u };\n\n//# sourceMappingURL=verify-contract-spaces-BOnqhfQs.mjs.map"],"mappings":";;;;;;;;;;;AAWA,MAAM,mBAAmB;AACzB,SAAS,eAAe,SAAS;CAChC,OAAO,iBAAiB,KAAK,OAAO;AACrC;AACA,SAAS,mBAAmB,SAAS;CACpC,IAAI,CAAC,eAAe,OAAO,GAAG,MAAM,oBAAoB,OAAO;AAChE;;;;;;;;;;;;;AAaA,SAAS,wBAAwB,sBAAsB,SAAS;CAC/D,mBAAmB,OAAO;CAC1B,OAAO,KAAK,sBAAsB,OAAO;AAC1C;;;;;;;;;AASA,MAAM,qBAAqB;;;;;;;;AAQ3B,MAAM,8CAA8C,IAAI,IAAI,CAAC,oBAAoB,0BAA0B,CAAC;;;;;;;AAO5G,SAAS,mBAAmB,oBAAoB;CAC/C,OAAO,KAAK,oBAAoB,kBAAkB;AACnD;AAGA,SAAS,eAAe,OAAO,MAAM;CACpC,OAAO,iBAAiB,SAAS,MAAM,SAAS;AACjD;;AAEA,SAAS,yBAAyB,sBAAsB,SAAS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-1,6 +1,6 @@
1
1
  import { a as expandContractInputs, p as loadConfigForSections } from "./exports-CSVHjfwG.mjs";
2
2
  import { r as getEmittedArtifactPaths } from "./exports-CVgs3YWV-BF4rqnxF.mjs";
3
- import { v as disposeEmitQueue, x as executeContractEmit } from "./ref-D4GWEHQU-BOqb4i_E.mjs";
3
+ import { b as disposeEmitQueue, w as executeContractEmit } from "./ref-DfuqRCA7-CPPoVHY9.mjs";
4
4
  import { dirname, extname, resolve } from "pathe";
5
5
  //#region ../../../1-framework/3-tooling/vite-plugin-contract-emit/dist/index.mjs
6
6
  const PLUGIN_NAME = "prisma-vite-plugin-contract-emit";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-toolchain",
3
- "version": "8.0.0-rc.24-dev.23",
3
+ "version": "8.0.0-rc.24-dev.24",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,7 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@prisma/orm-framework": "8.0.0-rc.24-dev.23",
12
+ "@prisma/orm-framework": "8.0.0-rc.24-dev.24",
13
13
  "@vercel/detect-agent": "^1.2.4",
14
14
  "arktype": "^2.2.2",
15
15
  "c12": "^3.3.4",
@@ -30,16 +30,16 @@
30
30
  "wrap-ansi": "^10.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@internal/cli": "8.0.0-rc.24-dev.23",
34
- "@internal/cli-telemetry": "8.0.0-rc.24-dev.23",
35
- "@internal/config-loader": "8.0.0-rc.24-dev.23",
36
- "@internal/emitter": "8.0.0-rc.24-dev.23",
37
- "@internal/language-server": "8.0.0-rc.24-dev.23",
38
- "@internal/migration-tools": "8.0.0-rc.24-dev.23",
39
- "@internal/publish-surface": "8.0.0-rc.24-dev.23",
40
- "@repo/tsconfig": "8.0.0-rc.24-dev.23",
41
- "@repo/tsdown": "8.0.0-rc.24-dev.23",
42
- "@internal/vite-plugin-contract-emit": "8.0.0-rc.24-dev.23",
33
+ "@internal/cli": "8.0.0-rc.24-dev.24",
34
+ "@internal/cli-telemetry": "8.0.0-rc.24-dev.24",
35
+ "@internal/config-loader": "8.0.0-rc.24-dev.24",
36
+ "@internal/emitter": "8.0.0-rc.24-dev.24",
37
+ "@internal/language-server": "8.0.0-rc.24-dev.24",
38
+ "@internal/migration-tools": "8.0.0-rc.24-dev.24",
39
+ "@internal/publish-surface": "8.0.0-rc.24-dev.24",
40
+ "@repo/tsconfig": "8.0.0-rc.24-dev.24",
41
+ "@repo/tsdown": "8.0.0-rc.24-dev.24",
42
+ "@internal/vite-plugin-contract-emit": "8.0.0-rc.24-dev.24",
43
43
  "tsdown": "0.22.14",
44
44
  "typescript": "5.9.3"
45
45
  },