@prisma-next/migration-tools 0.11.0-dev.4 → 0.11.0-dev.41

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 (109) hide show
  1. package/README.md +4 -4
  2. package/dist/{errors-DGYwcwXs.mjs → errors-CoEN114u.mjs} +14 -2
  3. package/dist/errors-CoEN114u.mjs.map +1 -0
  4. package/dist/exports/aggregate.d.mts +4 -4
  5. package/dist/exports/aggregate.d.mts.map +1 -1
  6. package/dist/exports/aggregate.mjs +5 -4
  7. package/dist/exports/aggregate.mjs.map +1 -1
  8. package/dist/exports/enumerate-migration-spaces.d.mts +53 -0
  9. package/dist/exports/enumerate-migration-spaces.d.mts.map +1 -0
  10. package/dist/exports/enumerate-migration-spaces.mjs +107 -0
  11. package/dist/exports/enumerate-migration-spaces.mjs.map +1 -0
  12. package/dist/exports/errors.d.mts +2 -2
  13. package/dist/exports/errors.d.mts.map +1 -1
  14. package/dist/exports/errors.mjs +1 -1
  15. package/dist/exports/graph.d.mts +1 -1
  16. package/dist/exports/hash.d.mts +8 -9
  17. package/dist/exports/hash.d.mts.map +1 -1
  18. package/dist/exports/hash.mjs +1 -1
  19. package/dist/exports/invariants.d.mts +1 -1
  20. package/dist/exports/invariants.d.mts.map +1 -1
  21. package/dist/exports/invariants.mjs +1 -1
  22. package/dist/exports/io.d.mts +1 -1
  23. package/dist/exports/io.d.mts.map +1 -1
  24. package/dist/exports/io.mjs +1 -1
  25. package/dist/exports/metadata.d.mts +2 -2
  26. package/dist/exports/migration-graph.d.mts +9 -2
  27. package/dist/exports/migration-graph.d.mts.map +1 -0
  28. package/dist/exports/migration-graph.mjs +16 -2
  29. package/dist/exports/migration-graph.mjs.map +1 -0
  30. package/dist/exports/migration-list-types.d.mts +2 -0
  31. package/dist/exports/migration-list-types.mjs +1 -0
  32. package/dist/exports/migration-ts.d.mts.map +1 -1
  33. package/dist/exports/migration-ts.mjs.map +1 -1
  34. package/dist/exports/migration.d.mts +5 -6
  35. package/dist/exports/migration.d.mts.map +1 -1
  36. package/dist/exports/migration.mjs +14 -32
  37. package/dist/exports/migration.mjs.map +1 -1
  38. package/dist/exports/package.d.mts +1 -1
  39. package/dist/exports/ref-resolution.d.mts +2 -2
  40. package/dist/exports/ref-resolution.d.mts.map +1 -1
  41. package/dist/exports/ref-resolution.mjs +1 -1
  42. package/dist/exports/ref-resolution.mjs.map +1 -1
  43. package/dist/exports/refs.d.mts +15 -2
  44. package/dist/exports/refs.d.mts.map +1 -0
  45. package/dist/exports/refs.mjs +137 -2
  46. package/dist/exports/refs.mjs.map +1 -0
  47. package/dist/exports/spaces.d.mts +27 -2
  48. package/dist/exports/spaces.d.mts.map +1 -1
  49. package/dist/exports/spaces.mjs +9 -7
  50. package/dist/exports/spaces.mjs.map +1 -1
  51. package/dist/{graph-BrLXqoUc.d.mts → graph-ZAIvH6p4.d.mts} +1 -2
  52. package/dist/graph-ZAIvH6p4.d.mts.map +1 -0
  53. package/dist/{hash-Cr4WIr4Z.mjs → hash--Y7vCpN3.mjs} +8 -9
  54. package/dist/hash--Y7vCpN3.mjs.map +1 -0
  55. package/dist/{invariants-0daYEzyo.mjs → invariants-lbJddL-S.mjs} +2 -2
  56. package/dist/{invariants-0daYEzyo.mjs.map → invariants-lbJddL-S.mjs.map} +1 -1
  57. package/dist/{io-BPLfzvZe.mjs → io-Dc64lvaL.mjs} +4 -10
  58. package/dist/io-Dc64lvaL.mjs.map +1 -0
  59. package/dist/metadata-BCH1rNsk.d.mts +2 -0
  60. package/dist/{migration-graph-nlS4TRpn.mjs → migration-graph-D5JeadSE.mjs} +5 -21
  61. package/dist/migration-graph-D5JeadSE.mjs.map +1 -0
  62. package/dist/{migration-graph-De0dUZoC.d.mts → migration-graph-D97XMWVH.d.mts} +6 -6
  63. package/dist/migration-graph-D97XMWVH.d.mts.map +1 -0
  64. package/dist/migration-list-types-B-qimPet.d.mts +23 -0
  65. package/dist/migration-list-types-B-qimPet.d.mts.map +1 -0
  66. package/dist/op-schema-D5qkXfEf.mjs.map +1 -1
  67. package/dist/{package-DZj8YvD0.d.mts → package-DIttKL7X.d.mts} +1 -1
  68. package/dist/package-DIttKL7X.d.mts.map +1 -0
  69. package/dist/read-contract-space-contract-_EvvV5Gl.mjs +82 -0
  70. package/dist/read-contract-space-contract-_EvvV5Gl.mjs.map +1 -0
  71. package/dist/{refs-CDaNerhT.d.mts → refs-BaygQaFD.d.mts} +1 -1
  72. package/dist/refs-BaygQaFD.d.mts.map +1 -0
  73. package/dist/{refs-BDHo5l_g.mjs → refs-HhOkD8BT.mjs} +3 -3
  74. package/dist/refs-HhOkD8BT.mjs.map +1 -0
  75. package/dist/{read-contract-space-contract-DRueB4Aa.mjs → verify-contract-spaces-DIdQLGo7.mjs} +32 -80
  76. package/dist/verify-contract-spaces-DIdQLGo7.mjs.map +1 -0
  77. package/package.json +14 -6
  78. package/src/emit-contract-space-artefacts.ts +4 -3
  79. package/src/enumerate-migration-spaces.ts +127 -0
  80. package/src/errors.ts +17 -2
  81. package/src/exports/enumerate-migration-spaces.ts +4 -0
  82. package/src/exports/metadata.ts +1 -1
  83. package/src/exports/migration-graph.ts +1 -0
  84. package/src/exports/migration-list-types.ts +5 -0
  85. package/src/exports/refs.ts +8 -0
  86. package/src/exports/spaces.ts +3 -0
  87. package/src/graph-membership.ts +17 -0
  88. package/src/graph.ts +0 -1
  89. package/src/hash.ts +7 -8
  90. package/src/io.ts +0 -8
  91. package/src/metadata.ts +1 -1
  92. package/src/migration-base.ts +10 -30
  93. package/src/migration-graph.ts +4 -18
  94. package/src/migration-list-types.ts +21 -0
  95. package/src/read-contract-space-head-ref.ts +5 -2
  96. package/src/refs/snapshot.ts +197 -0
  97. package/src/refs.ts +3 -1
  98. package/src/space-layout.ts +30 -0
  99. package/dist/errors-DGYwcwXs.mjs.map +0 -1
  100. package/dist/graph-BrLXqoUc.d.mts.map +0 -1
  101. package/dist/hash-Cr4WIr4Z.mjs.map +0 -1
  102. package/dist/io-BPLfzvZe.mjs.map +0 -1
  103. package/dist/metadata-BFX0xdz8.d.mts +0 -2
  104. package/dist/migration-graph-De0dUZoC.d.mts.map +0 -1
  105. package/dist/migration-graph-nlS4TRpn.mjs.map +0 -1
  106. package/dist/package-DZj8YvD0.d.mts.map +0 -1
  107. package/dist/read-contract-space-contract-DRueB4Aa.mjs.map +0 -1
  108. package/dist/refs-BDHo5l_g.mjs.map +0 -1
  109. package/dist/refs-CDaNerhT.d.mts.map +0 -1
@@ -0,0 +1,107 @@
1
+ import { s as readMigrationsDir } from "../io-Dc64lvaL.mjs";
2
+ import { r as readRefs } from "../refs-HhOkD8BT.mjs";
3
+ import { c as spaceMigrationDirectory, i as RESERVED_SPACE_SUBDIR_NAMES, l as spaceRefsDirectory, r as APP_SPACE_ID, s as isValidSpaceId, t as listContractSpaceDirectories } from "../verify-contract-spaces-DIdQLGo7.mjs";
4
+ //#region src/enumerate-migration-spaces.ts
5
+ /**
6
+ * Index `migrations/<space>/refs/*.json` by the contract hash each ref
7
+ * points at, so callers can attach `(ref names)` decorations to every
8
+ * row whose destination contract hash matches.
9
+ *
10
+ * Each bucket is sorted lex-asc to keep rendered output deterministic
11
+ * (adjacent rows pointing at the same hash render their ref decorations
12
+ * in the same order).
13
+ *
14
+ * Refs whose hash matches no migration on disk are still indexed; the
15
+ * caller decides whether to surface them. Migration rows only carry
16
+ * `(refs)` decorations when a matching destination contract hash exists
17
+ * on disk — orphan refs are not rendered on any row.
18
+ *
19
+ * Returns an empty map when the refs directory does not exist
20
+ * ({@link readRefs} treats `ENOENT` as "no refs").
21
+ */
22
+ async function resolveRefsByContractHash(refsDir) {
23
+ const refs = await readRefs(refsDir);
24
+ const byHash = /* @__PURE__ */ new Map();
25
+ for (const [name, entry] of Object.entries(refs)) {
26
+ const bucket = byHash.get(entry.hash);
27
+ if (bucket) bucket.push(name);
28
+ else byHash.set(entry.hash, [name]);
29
+ }
30
+ for (const bucket of byHash.values()) bucket.sort();
31
+ return byHash;
32
+ }
33
+ /**
34
+ * Compare two contract-space IDs for the inter-space ordering rule:
35
+ * {@link APP_SPACE_ID} first if present, then lex-asc on the rest.
36
+ */
37
+ function compareSpaceIds(a, b) {
38
+ if (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;
39
+ if (b === APP_SPACE_ID) return 1;
40
+ if (a < b) return -1;
41
+ if (a > b) return 1;
42
+ return 0;
43
+ }
44
+ /**
45
+ * Sort `dirName` descending so the rendered output reads latest-first,
46
+ * matching the `git log` latest-first convention.
47
+ */
48
+ function compareDirNamesDescending(a, b) {
49
+ if (a.dirName < b.dirName) return 1;
50
+ if (a.dirName > b.dirName) return -1;
51
+ return 0;
52
+ }
53
+ /**
54
+ * Enumerate every contract space's on-disk migrations under
55
+ * `<projectMigrationsDir>/`. For each valid space directory:
56
+ *
57
+ * - Loads on-disk packages via {@link readMigrationsDir}.
58
+ * - Attaches ref decorations: each migration's `refs[]` lists every ref
59
+ * name from `migrations/<spaceId>/refs/*.json` whose hash equals the
60
+ * migration's destination contract hash.
61
+ * - Sorts migrations within the space by `dirName` descending
62
+ * (reverse-filename, latest first).
63
+ *
64
+ * Contract spaces are returned with {@link APP_SPACE_ID} first when
65
+ * present, then the remaining ids lex-asc. A contract-space directory
66
+ * that contains no migrations becomes `{ spaceId, migrations: [] }` so
67
+ * the renderer's empty-state path can surface it.
68
+ *
69
+ * Directory entries that are not valid {@link isValidSpaceId} names are
70
+ * skipped (a stray non-space directory under `migrations/` does not
71
+ * spawn a phantom space entry). Entries whose name appears in
72
+ * {@link RESERVED_SPACE_SUBDIR_NAMES} are also skipped — the per-space
73
+ * `refs/` subdirectory name shape would otherwise satisfy
74
+ * {@link isValidSpaceId} and surface as a phantom contract space.
75
+ *
76
+ * Returns `[]` when `<projectMigrationsDir>` does not exist — a fresh
77
+ * project that has not authored any migration yet.
78
+ */
79
+ async function enumerateMigrationSpaces(args) {
80
+ const { projectMigrationsDir } = args;
81
+ const spaceIds = (await listContractSpaceDirectories(projectMigrationsDir)).filter((name) => !RESERVED_SPACE_SUBDIR_NAMES.has(name)).filter(isValidSpaceId).sort(compareSpaceIds);
82
+ const spaces = [];
83
+ for (const spaceId of spaceIds) {
84
+ const spaceDir = spaceMigrationDirectory(projectMigrationsDir, spaceId);
85
+ const packages = await readMigrationsDir(spaceDir);
86
+ const refsByHash = await resolveRefsByContractHash(spaceRefsDirectory(spaceDir));
87
+ const migrations = packages.map((pkg) => ({
88
+ dirName: pkg.dirName,
89
+ from: pkg.metadata.from,
90
+ to: pkg.metadata.to,
91
+ migrationHash: pkg.metadata.migrationHash,
92
+ operationCount: pkg.ops.length,
93
+ createdAt: pkg.metadata.createdAt,
94
+ refs: refsByHash.get(pkg.metadata.to) ?? [],
95
+ providedInvariants: pkg.metadata.providedInvariants
96
+ })).sort(compareDirNamesDescending);
97
+ spaces.push({
98
+ spaceId,
99
+ migrations
100
+ });
101
+ }
102
+ return spaces;
103
+ }
104
+ //#endregion
105
+ export { enumerateMigrationSpaces, resolveRefsByContractHash };
106
+
107
+ //# sourceMappingURL=enumerate-migration-spaces.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumerate-migration-spaces.mjs","names":[],"sources":["../../src/enumerate-migration-spaces.ts"],"sourcesContent":["import { readMigrationsDir } from './io';\nimport type { MigrationListEntry, MigrationSpaceListEntry } from './migration-list-types';\nimport { readRefs } from './refs';\nimport {\n APP_SPACE_ID,\n isValidSpaceId,\n RESERVED_SPACE_SUBDIR_NAMES,\n spaceMigrationDirectory,\n spaceRefsDirectory,\n} from './space-layout';\nimport { listContractSpaceDirectories } from './verify-contract-spaces';\n\n/**\n * Index `migrations/<space>/refs/*.json` by the contract hash each ref\n * points at, so callers can attach `(ref names)` decorations to every\n * row whose destination contract hash matches.\n *\n * Each bucket is sorted lex-asc to keep rendered output deterministic\n * (adjacent rows pointing at the same hash render their ref decorations\n * in the same order).\n *\n * Refs whose hash matches no migration on disk are still indexed; the\n * caller decides whether to surface them. Migration rows only carry\n * `(refs)` decorations when a matching destination contract hash exists\n * on disk — orphan refs are not rendered on any row.\n *\n * Returns an empty map when the refs directory does not exist\n * ({@link readRefs} treats `ENOENT` as \"no refs\").\n */\nexport async function resolveRefsByContractHash(\n refsDir: string,\n): Promise<ReadonlyMap<string, readonly string[]>> {\n const refs = await readRefs(refsDir);\n const byHash = new Map<string, string[]>();\n for (const [name, entry] of Object.entries(refs)) {\n const bucket = byHash.get(entry.hash);\n if (bucket) bucket.push(name);\n else byHash.set(entry.hash, [name]);\n }\n for (const bucket of byHash.values()) {\n bucket.sort();\n }\n return byHash;\n}\n\n/**\n * Compare two contract-space IDs for the inter-space ordering rule:\n * {@link APP_SPACE_ID} first if present, then lex-asc on the rest.\n */\nfunction compareSpaceIds(a: string, b: string): number {\n if (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;\n if (b === APP_SPACE_ID) return 1;\n if (a < b) return -1;\n if (a > b) return 1;\n return 0;\n}\n\n/**\n * Sort `dirName` descending so the rendered output reads latest-first,\n * matching the `git log` latest-first convention.\n */\nfunction compareDirNamesDescending(a: MigrationListEntry, b: MigrationListEntry): number {\n if (a.dirName < b.dirName) return 1;\n if (a.dirName > b.dirName) return -1;\n return 0;\n}\n\n/**\n * Enumerate every contract space's on-disk migrations under\n * `<projectMigrationsDir>/`. For each valid space directory:\n *\n * - Loads on-disk packages via {@link readMigrationsDir}.\n * - Attaches ref decorations: each migration's `refs[]` lists every ref\n * name from `migrations/<spaceId>/refs/*.json` whose hash equals the\n * migration's destination contract hash.\n * - Sorts migrations within the space by `dirName` descending\n * (reverse-filename, latest first).\n *\n * Contract spaces are returned with {@link APP_SPACE_ID} first when\n * present, then the remaining ids lex-asc. A contract-space directory\n * that contains no migrations becomes `{ spaceId, migrations: [] }` so\n * the renderer's empty-state path can surface it.\n *\n * Directory entries that are not valid {@link isValidSpaceId} names are\n * skipped (a stray non-space directory under `migrations/` does not\n * spawn a phantom space entry). Entries whose name appears in\n * {@link RESERVED_SPACE_SUBDIR_NAMES} are also skipped — the per-space\n * `refs/` subdirectory name shape would otherwise satisfy\n * {@link isValidSpaceId} and surface as a phantom contract space.\n *\n * Returns `[]` when `<projectMigrationsDir>` does not exist — a fresh\n * project that has not authored any migration yet.\n */\nexport async function enumerateMigrationSpaces(args: {\n readonly projectMigrationsDir: string;\n}): Promise<readonly MigrationSpaceListEntry[]> {\n const { projectMigrationsDir } = args;\n const candidateDirs = await listContractSpaceDirectories(projectMigrationsDir);\n const spaceIds = candidateDirs\n .filter((name) => !RESERVED_SPACE_SUBDIR_NAMES.has(name))\n .filter(isValidSpaceId)\n .sort(compareSpaceIds);\n\n const spaces: MigrationSpaceListEntry[] = [];\n for (const spaceId of spaceIds) {\n const spaceDir = spaceMigrationDirectory(projectMigrationsDir, spaceId);\n const packages = await readMigrationsDir(spaceDir);\n const refsByHash = await resolveRefsByContractHash(spaceRefsDirectory(spaceDir));\n\n const migrations: MigrationListEntry[] = packages\n .map((pkg) => ({\n dirName: pkg.dirName,\n from: pkg.metadata.from,\n to: pkg.metadata.to,\n migrationHash: pkg.metadata.migrationHash,\n operationCount: pkg.ops.length,\n createdAt: pkg.metadata.createdAt,\n refs: refsByHash.get(pkg.metadata.to) ?? [],\n providedInvariants: pkg.metadata.providedInvariants,\n }))\n .sort(compareDirNamesDescending);\n\n spaces.push({ spaceId, migrations });\n }\n\n return spaces;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,0BACpB,SACiD;CACjD,MAAM,OAAO,MAAM,SAAS,OAAO;CACnC,MAAM,yBAAS,IAAI,IAAsB;CACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,IAAI,GAAG;EAChD,MAAM,SAAS,OAAO,IAAI,MAAM,IAAI;EACpC,IAAI,QAAQ,OAAO,KAAK,IAAI;OACvB,OAAO,IAAI,MAAM,MAAM,CAAC,IAAI,CAAC;CACpC;CACA,KAAK,MAAM,UAAU,OAAO,OAAO,GACjC,OAAO,KAAK;CAEd,OAAO;AACT;;;;;AAMA,SAAS,gBAAgB,GAAW,GAAmB;CACrD,IAAI,MAAM,cAAc,OAAO,MAAM,eAAe,IAAI;CACxD,IAAI,MAAM,cAAc,OAAO;CAC/B,IAAI,IAAI,GAAG,OAAO;CAClB,IAAI,IAAI,GAAG,OAAO;CAClB,OAAO;AACT;;;;;AAMA,SAAS,0BAA0B,GAAuB,GAA+B;CACvF,IAAI,EAAE,UAAU,EAAE,SAAS,OAAO;CAClC,IAAI,EAAE,UAAU,EAAE,SAAS,OAAO;CAClC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,yBAAyB,MAEC;CAC9C,MAAM,EAAE,yBAAyB;CAEjC,MAAM,YAAW,MADW,6BAA6B,oBAAoB,GAE1E,QAAQ,SAAS,CAAC,4BAA4B,IAAI,IAAI,CAAC,EACvD,OAAO,cAAc,EACrB,KAAK,eAAe;CAEvB,MAAM,SAAoC,CAAC;CAC3C,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,WAAW,wBAAwB,sBAAsB,OAAO;EACtE,MAAM,WAAW,MAAM,kBAAkB,QAAQ;EACjD,MAAM,aAAa,MAAM,0BAA0B,mBAAmB,QAAQ,CAAC;EAE/E,MAAM,aAAmC,SACtC,KAAK,SAAS;GACb,SAAS,IAAI;GACb,MAAM,IAAI,SAAS;GACnB,IAAI,IAAI,SAAS;GACjB,eAAe,IAAI,SAAS;GAC5B,gBAAgB,IAAI,IAAI;GACxB,WAAW,IAAI,SAAS;GACxB,MAAM,WAAW,IAAI,IAAI,SAAS,EAAE,KAAK,CAAC;GAC1C,oBAAoB,IAAI,SAAS;EACnC,EAAE,EACD,KAAK,yBAAyB;EAEjC,OAAO,KAAK;GAAE;GAAS;EAAW,CAAC;CACrC;CAEA,OAAO;AACT"}
@@ -37,8 +37,8 @@ declare function errorDescriptorHeadHashMismatch(args: {
37
37
  /**
38
38
  * Wire-shape edge surfaced through the JSON envelope's
39
39
  * `meta.structuralPath` of `MIGRATION.NO_INVARIANT_PATH`. Slim by design —
40
- * authoring metadata (`createdAt`, `labels`) lives on `MigrationEdge` but
41
- * is intentionally dropped here so the envelope stays stable across
40
+ * authoring metadata (`createdAt`) lives on `MigrationEdge` but is
41
+ * intentionally dropped here so the envelope stays stable across
42
42
  * graph-internal refactors.
43
43
  *
44
44
  * Stability: any field added here is part of the public CLI JSON contract.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/errors.ts"],"mappings":";;AAmCA;;;;;;;;;;;;;;;cAAa,mBAAA,SAA4B,KAAA;EAAA,SAC9B,IAAA;EAAA,SACA,QAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,OAAA,EAAS,MAAA;cAGhB,IAAA,UACA,OAAA,UACA,OAAA;IAAA,SACW,GAAA;IAAA,SACA,GAAA;IAAA,SACA,OAAA,GAAU,MAAA;EAAA;EAAA,OAWhB,EAAA,CAAG,KAAA,YAAiB,KAAA,IAAS,mBAAA;AAAA;AAAA,iBA0BtB,gBAAA,CAAiB,QAAA,UAAkB,UAAA,WAAqB,mBAAA;AAAA,iBAwDxD,+BAAA,CAAgC,IAAA;EAAA,SACrC,WAAA;EAAA,SACA,cAAA;EAAA,SACA,WAAA;AAAA,IACP,mBAAA;;;;;;;;;;;AA0NJ;UAlCiB,6BAAA;EAAA,SACN,OAAA;EAAA,SACA,aAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,UAAA;AAAA;AAAA,iBAGK,oBAAA,CAAqB,IAAA;EAAA,SAC1B,OAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,cAAA,WAAyB,6BAAA;AAAA,IAChC,mBAAA;AAAA,iBAqBY,qBAAA,CAAsB,IAAA;EAAA,SAC3B,OAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA,IACP,mBAAA"}
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/errors.ts"],"mappings":";AAoCA;;;;;;;;;;;;;;;;AAAA,cAAa,mBAAA,SAA4B,KAAA;EAAA,SAC9B,IAAA;EAAA,SACA,QAAA;EAAA,SACA,GAAA;EAAA,SACA,GAAA;EAAA,SACA,OAAA,EAAS,MAAA;cAGhB,IAAA,UACA,OAAA,UACA,OAAA;IAAA,SACW,GAAA;IAAA,SACA,GAAA;IAAA,SACA,OAAA,GAAU,MAAA;EAAA;EAAA,OAWhB,EAAA,CAAG,KAAA,YAAiB,KAAA,IAAS,mBAAA;AAAA;AAAA,iBA0BtB,gBAAA,CAAiB,QAAA,UAAkB,UAAA,WAAqB,mBAAmB;AAAA,iBAwD3E,+BAAA,CAAgC,IAAA;EAAA,SACrC,WAAA;EAAA,SACA,cAAA;EAAA,SACA,WAAA;AAAA,IACP,mBAAmB;;;;;;;;;AAqMA;AAqBvB;;UAlCiB,6BAAA;EAAA,SACN,OAAA;EAAA,SACA,aAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,UAAA;AAAA;AAAA,iBAGK,oBAAA,CAAqB,IAAA;EAAA,SAC1B,OAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,cAAA,WAAyB,6BAAA;AAAA,IAChC,mBAAmB;AAAA,iBAqBP,qBAAA,CAAsB,IAAA;EAAA,SAC3B,OAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;AAAA,IACP,mBAAmB"}
@@ -1,2 +1,2 @@
1
- import { T as errorUnknownInvariant, r as errorDescriptorHeadHashMismatch, t as MigrationToolsError, u as errorInvalidJson, x as errorNoInvariantPath } from "../errors-DGYwcwXs.mjs";
1
+ import { E as errorUnknownInvariant, S as errorNoInvariantPath, d as errorInvalidJson, r as errorDescriptorHeadHashMismatch, t as MigrationToolsError } from "../errors-CoEN114u.mjs";
2
2
  export { MigrationToolsError, errorDescriptorHeadHashMismatch, errorInvalidJson, errorNoInvariantPath, errorUnknownInvariant };
@@ -1,2 +1,2 @@
1
- import { n as MigrationGraph, t as MigrationEdge } from "../graph-BrLXqoUc.mjs";
1
+ import { n as MigrationGraph, t as MigrationEdge } from "../graph-ZAIvH6p4.mjs";
2
2
  export { type MigrationEdge, type MigrationGraph };
@@ -1,5 +1,5 @@
1
- import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-DZj8YvD0.mjs";
2
- import { n as MigrationMetadata } from "../metadata-BFX0xdz8.mjs";
1
+ import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-DIttKL7X.mjs";
2
+ import { t as MigrationMetadata } from "../metadata-BCH1rNsk.mjs";
3
3
 
4
4
  //#region src/hash.d.ts
5
5
  interface VerifyResult {
@@ -9,13 +9,12 @@ interface VerifyResult {
9
9
  readonly computedHash: string;
10
10
  }
11
11
  /**
12
- * Content-addressed migration hash over (metadata envelope sans hints,
13
- * ops). See ADR 199 — Storage-only migration identity for the
14
- * rationale: the storage-hash bookends (`from`, `to`) inside the
15
- * envelope anchor the contract identity by hash, and planner hints are
16
- * advisory and must not affect identity. The full contract IRs are not
17
- * part of the manifest they live in sibling `*-contract.json` files
18
- * authored alongside the migration, never inlined here.
12
+ * Content-addressed migration hash over (metadata envelope, ops). See
13
+ * ADR 199 — Storage-only migration identity for the rationale: the
14
+ * storage-hash bookends (`from`, `to`) inside the envelope anchor the
15
+ * contract identity by hash. The full contract IRs are not part of the
16
+ * manifest they live in sibling `*-contract.json` files authored
17
+ * alongside the migration, never inlined here.
19
18
  *
20
19
  * The integrity check is purely structural, not semantic. The function
21
20
  * canonicalizes its inputs via `sortKeys` (recursive) + `JSON.stringify`
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.mts","names":[],"sources":["../../src/hash.ts"],"mappings":";;;;UAKiB,YAAA;EAAA,SACN,EAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;AAAA;;;;;;;AAmCX;;;;;;;;;;;;;;;;AAwBA;;;;;;iBAxBgB,oBAAA,CACd,QAAA,EAAU,IAAA,CAAK,iBAAA;EAAA,SAAiD,aAAA;AAAA,GAChE,GAAA,EAAK,YAAA;;;;;;;;;;iBAsBS,mBAAA,CAAoB,GAAA,EAAK,sBAAA,GAAyB,YAAA"}
1
+ {"version":3,"file":"hash.d.mts","names":[],"sources":["../../src/hash.ts"],"mappings":";;;;UAKiB,YAAA;EAAA,SACN,EAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;AAAA;;;;;;AAAY;AAkCvB;;;;;;;;;;;;;;;AAEmB;AAsBnB;;;;;iBAxBgB,oBAAA,CACd,QAAA,EAAU,IAAA,CAAK,iBAAA;EAAA,SAAiD,aAAA;AAAA,GAChE,GAAA,EAAK,YAAA;AAsBuE;;;;;;;;;AAAA,iBAA9D,mBAAA,CAAoB,GAAA,EAAK,sBAAA,GAAyB,YAAY"}
@@ -1,2 +1,2 @@
1
- import { n as verifyMigrationHash, t as computeMigrationHash } from "../hash-Cr4WIr4Z.mjs";
1
+ import { n as verifyMigrationHash, t as computeMigrationHash } from "../hash--Y7vCpN3.mjs";
2
2
  export { computeMigrationHash, verifyMigrationHash };
@@ -1,4 +1,4 @@
1
- import { t as MigrationOps } from "../package-DZj8YvD0.mjs";
1
+ import { t as MigrationOps } from "../package-DIttKL7X.mjs";
2
2
 
3
3
  //#region src/invariants.d.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"invariants.d.mts","names":[],"sources":["../../src/invariants.ts"],"mappings":";;;;;AAUA;;;;iBAAgB,mBAAA,CAAoB,WAAA;AA8BpC;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBAAgB,wBAAA,CAAyB,GAAA,EAAK,YAAA"}
1
+ {"version":3,"file":"invariants.d.mts","names":[],"sources":["../../src/invariants.ts"],"mappings":";;;;;AAUA;;;;iBAAgB,mBAAA,CAAoB,WAAmB;AA8BvD;;;;AAA0D;;;;;;;;;;;;;;;;;;;;;AAA1D,iBAAgB,wBAAA,CAAyB,GAAiB,EAAZ,YAAY"}
@@ -1,2 +1,2 @@
1
- import { n as validateInvariantId, t as deriveProvidedInvariants } from "../invariants-0daYEzyo.mjs";
1
+ import { n as validateInvariantId, t as deriveProvidedInvariants } from "../invariants-lbJddL-S.mjs";
2
2
  export { deriveProvidedInvariants, validateInvariantId };
@@ -1,4 +1,4 @@
1
- import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-DZj8YvD0.mjs";
1
+ import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-DIttKL7X.mjs";
2
2
  import { MigrationMetadata, MigrationPackage } from "@prisma-next/framework-components/control";
3
3
 
4
4
  //#region src/io.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"io.d.mts","names":[],"sources":["../../src/io.ts"],"mappings":";;;;iBA+CsB,qBAAA,CACpB,GAAA,UACA,QAAA,EAAU,iBAAA,EACV,GAAA,EAAK,YAAA,GACJ,OAAA;AAJH;;;;;;;;;;;;;;;;AAoDA;;;;;;;;;;AA8BA;;;;AAlFA,iBAoDsB,2BAAA,CACpB,SAAA,UACA,GAAA,EAAK,gBAAA,GACJ,OAAA;;;;;;;AA2DH;;;;;;;;;;;AAaA;;;;iBA7CsB,6CAAA,CACpB,SAAA,UACA,GAAA,EAAK,gBAAA,GACJ,OAAA;EAAA,SAAmB,OAAA;AAAA;;;;AAiDtB;;;;;;;;iBApBsB,mBAAA,CACpB,OAAA,UACA,KAAA;EAAA,SAA2B,UAAA;EAAA,SAA6B,QAAA;AAAA,MACvD,OAAA;AAAA,iBAUmB,sBAAA,CACpB,GAAA,UACA,QAAA,EAAU,iBAAA,GACT,OAAA;AAAA,iBAImB,iBAAA,CAAkB,GAAA,UAAa,GAAA,EAAK,YAAA,GAAe,OAAA;AAAA,iBAInD,oBAAA,CAAqB,GAAA,WAAc,OAAA,CAAQ,sBAAA;AAAA,iBAiG3C,iBAAA,CACpB,cAAA,WACC,OAAA,UAAiB,sBAAA;AAAA,iBA+BJ,sBAAA,CAAuB,SAAA,EAAW,IAAA,EAAM,IAAA"}
1
+ {"version":3,"file":"io.d.mts","names":[],"sources":["../../src/io.ts"],"mappings":";;;;iBAuCsB,qBAAA,CACpB,GAAA,UACA,QAAA,EAAU,iBAAA,EACV,GAAA,EAAK,YAAA,GACJ,OAAA;AAJH;;;;;;;;;;;;;;;AAIU;AAgDV;;;;;;;;;AAGU;AA2BV;;;;AAlFA,iBAoDsB,2BAAA,CACpB,SAAA,UACA,GAAA,EAAK,gBAAA,GACJ,OAAO;;;;;;AA8BmB;AA6B7B;;;;;;;;;;AAGU;AAUV;;;;iBA7CsB,6CAAA,CACpB,SAAA,UACA,GAAA,EAAK,gBAAA,GACJ,OAAO;EAAA,SAAY,OAAA;AAAA;;;AA6CZ;AAIV;;;;;;;;iBApBsB,mBAAA,CACpB,OAAA,UACA,KAAA;EAAA,SAA2B,UAAA;EAAA,SAA6B,QAAA;AAAA,MACvD,OAAO;AAAA,iBAUY,sBAAA,CACpB,GAAA,UACA,QAAA,EAAU,iBAAA,GACT,OAAO;AAAA,iBAIY,iBAAA,CAAkB,GAAA,UAAa,GAAA,EAAK,YAAA,GAAe,OAAO;AAAA,iBAI1D,oBAAA,CAAqB,GAAA,WAAc,OAAO,CAAC,sBAAA;AAAA,iBAiG3C,iBAAA,CACpB,cAAA,WACC,OAAO,UAAU,sBAAA;AAAA,iBA+BJ,sBAAA,CAAuB,SAAA,EAAW,IAAI,EAAE,IAAA"}
@@ -1,2 +1,2 @@
1
- import { a as materialiseMigrationPackage, c as writeMigrationMetadata, i as materialiseExtensionMigrationPackageIfMissing, l as writeMigrationOps, n as copyFilesWithRename, o as readMigrationPackage, r as formatMigrationDirName, s as readMigrationsDir, u as writeMigrationPackage } from "../io-BPLfzvZe.mjs";
1
+ import { a as materialiseMigrationPackage, c as writeMigrationMetadata, i as materialiseExtensionMigrationPackageIfMissing, l as writeMigrationOps, n as copyFilesWithRename, o as readMigrationPackage, r as formatMigrationDirName, s as readMigrationsDir, u as writeMigrationPackage } from "../io-Dc64lvaL.mjs";
2
2
  export { copyFilesWithRename, formatMigrationDirName, materialiseExtensionMigrationPackageIfMissing, materialiseMigrationPackage, readMigrationPackage, readMigrationsDir, writeMigrationMetadata, writeMigrationOps, writeMigrationPackage };
@@ -1,2 +1,2 @@
1
- import { n as MigrationMetadata, t as MigrationHints } from "../metadata-BFX0xdz8.mjs";
2
- export { type MigrationHints, type MigrationMetadata };
1
+ import { t as MigrationMetadata } from "../metadata-BCH1rNsk.mjs";
2
+ export { type MigrationMetadata };
@@ -1,2 +1,9 @@
1
- import { a as findLeaf, c as findPathWithInvariants, i as findLatestMigration, l as findReachableLeaves, n as detectCycles, o as findPath, r as detectOrphans, s as findPathWithDecision, t as PathDecision, u as reconstructGraph } from "../migration-graph-De0dUZoC.mjs";
2
- export { type PathDecision, detectCycles, detectOrphans, findLatestMigration, findLeaf, findPath, findPathWithDecision, findPathWithInvariants, findReachableLeaves, reconstructGraph };
1
+ import { n as MigrationGraph } from "../graph-ZAIvH6p4.mjs";
2
+ import { a as findLeaf, c as findPathWithInvariants, i as findLatestMigration, l as findReachableLeaves, n as detectCycles, o as findPath, r as detectOrphans, s as findPathWithDecision, t as PathDecision, u as reconstructGraph } from "../migration-graph-D97XMWVH.mjs";
3
+
4
+ //#region src/graph-membership.d.ts
5
+ declare function isGraphNode(hash: string, graph: MigrationGraph): boolean;
6
+ declare function assertHashIsGraphNode(hash: string, graph: MigrationGraph): asserts hash is string;
7
+ //#endregion
8
+ export { type PathDecision, assertHashIsGraphNode, detectCycles, detectOrphans, findLatestMigration, findLeaf, findPath, findPathWithDecision, findPathWithInvariants, findReachableLeaves, isGraphNode, reconstructGraph };
9
+ //# sourceMappingURL=migration-graph.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-graph.d.mts","names":[],"sources":["../../src/graph-membership.ts"],"mappings":";;;;iBAIgB,WAAA,CAAY,IAAA,UAAc,KAAA,EAAO,cAAc;AAAA,iBAO/C,qBAAA,CAAsB,IAAA,UAAc,KAAA,EAAO,cAAc,WAAW,IAAA"}
@@ -1,2 +1,16 @@
1
- import { a as findPath, c as findReachableLeaves, i as findLeaf, l as reconstructGraph, n as detectOrphans, o as findPathWithDecision, r as findLatestMigration, s as findPathWithInvariants, t as detectCycles } from "../migration-graph-nlS4TRpn.mjs";
2
- export { detectCycles, detectOrphans, findLatestMigration, findLeaf, findPath, findPathWithDecision, findPathWithInvariants, findReachableLeaves, reconstructGraph };
1
+ import { c as errorHashNotInGraph } from "../errors-CoEN114u.mjs";
2
+ import "../constants-DWV9_o2Z.mjs";
3
+ import { a as findPath, c as findReachableLeaves, i as findLeaf, l as reconstructGraph, n as detectOrphans, o as findPathWithDecision, r as findLatestMigration, s as findPathWithInvariants, t as detectCycles } from "../migration-graph-D5JeadSE.mjs";
4
+ //#region src/graph-membership.ts
5
+ function isGraphNode(hash, graph) {
6
+ if (hash === "sha256:empty") return true;
7
+ return graph.nodes.has(hash);
8
+ }
9
+ function assertHashIsGraphNode(hash, graph) {
10
+ if (isGraphNode(hash, graph)) return;
11
+ throw errorHashNotInGraph(hash, graph);
12
+ }
13
+ //#endregion
14
+ export { assertHashIsGraphNode, detectCycles, detectOrphans, findLatestMigration, findLeaf, findPath, findPathWithDecision, findPathWithInvariants, findReachableLeaves, isGraphNode, reconstructGraph };
15
+
16
+ //# sourceMappingURL=migration-graph.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-graph.mjs","names":[],"sources":["../../src/graph-membership.ts"],"sourcesContent":["import { EMPTY_CONTRACT_HASH } from './constants';\nimport { errorHashNotInGraph } from './errors';\nimport type { MigrationGraph } from './graph';\n\nexport function isGraphNode(hash: string, graph: MigrationGraph): boolean {\n if (hash === EMPTY_CONTRACT_HASH) {\n return true;\n }\n return graph.nodes.has(hash);\n}\n\nexport function assertHashIsGraphNode(hash: string, graph: MigrationGraph): asserts hash is string {\n if (isGraphNode(hash, graph)) {\n return;\n }\n throw errorHashNotInGraph(hash, graph);\n}\n"],"mappings":";;;;AAIA,SAAgB,YAAY,MAAc,OAAgC;CACxE,IAAI,SAAA,gBACF,OAAO;CAET,OAAO,MAAM,MAAM,IAAI,IAAI;AAC7B;AAEA,SAAgB,sBAAsB,MAAc,OAA+C;CACjG,IAAI,YAAY,MAAM,KAAK,GACzB;CAEF,MAAM,oBAAoB,MAAM,KAAK;AACvC"}
@@ -0,0 +1,2 @@
1
+ import { n as MigrationListResult, r as MigrationSpaceListEntry, t as MigrationListEntry } from "../migration-list-types-B-qimPet.mjs";
2
+ export { type MigrationListEntry, type MigrationListResult, type MigrationSpaceListEntry };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"migration-ts.d.mts","names":[],"sources":["../../src/migration-ts.ts","../../src/runtime-detection.ts"],"mappings":";;AA8BA;;;;;;;;;AAsBA;;;;;;;;ACpDA;;;;;iBD8BsB,gBAAA,CAAiB,UAAA,UAAoB,OAAA,WAAkB,OAAA;;;;iBAsBvD,cAAA,CAAe,UAAA,WAAqB,OAAA;;;KCpD9C,eAAA;AAAA,iBAEI,qBAAA,CAAA,GAAyB,eAAA;AAAA,iBAMzB,cAAA,CAAe,OAAA,EAAS,eAAA"}
1
+ {"version":3,"file":"migration-ts.d.mts","names":[],"sources":["../../src/migration-ts.ts","../../src/runtime-detection.ts"],"mappings":";;AA8BA;;;;;;;;AAAoF;AAsBpF;;;;AAAiE;;;;ACpDjE;;;;AAA2B;iBD8BL,gBAAA,CAAiB,UAAA,UAAoB,OAAA,WAAkB,OAAO;;;;iBAsB9D,cAAA,CAAe,UAAA,WAAqB,OAAO;;;KCpDrD,eAAA;AAAA,iBAEI,qBAAA,CAAA,GAAyB,eAAe;AAAA,iBAMxC,cAAA,CAAe,OAAwB,EAAf,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"migration-ts.mjs","names":[],"sources":["../../src/migration-ts.ts","../../src/runtime-detection.ts"],"sourcesContent":["/**\n * Utilities for reading/writing `migration.ts` files.\n *\n * Rendering migration.ts source is the target's responsibility — the CLI\n * obtains source strings from a planner's `plan.renderTypeScript()`. The\n * helper here is limited to file I/O: writing the returned source with the\n * right executable bit and probing for existence.\n */\n\nimport { stat, writeFile } from 'node:fs/promises';\nimport { join } from 'pathe';\nimport { format } from 'prettier';\n\nconst MIGRATION_TS_FILE = 'migration.ts';\n\n/**\n * Writes a pre-rendered `migration.ts` source string to the given package\n * directory. If the source begins with a shebang, the file is written with\n * executable permissions (0o755) so it can be run directly via\n * `./migration.ts` — the rendered scaffold ends with\n * `MigrationCLI.run(import.meta.url, M)` from\n * `@prisma-next/cli/migration-cli` (re-exported by the postgres facade),\n * which guards on the entrypoint and serializes when the file is the main\n * module.\n *\n * The source is run through prettier before writing so migration renderers\n * can produce structurally-correct but loosely-indented source and rely on\n * a single canonical format on disk. Matches what `@prisma-next/emitter`\n * already does for generated `contract.d.ts`.\n */\nexport async function writeMigrationTs(packageDir: string, content: string): Promise<void> {\n const formatted = await formatMigrationTsSource(content);\n const isExecutable = formatted.startsWith('#!');\n await writeFile(\n join(packageDir, MIGRATION_TS_FILE),\n formatted,\n isExecutable ? { mode: 0o755 } : undefined,\n );\n}\n\nasync function formatMigrationTsSource(source: string): Promise<string> {\n return format(source, {\n parser: 'typescript',\n singleQuote: true,\n semi: true,\n printWidth: 100,\n });\n}\n\n/**\n * Checks whether a migration.ts file exists in the package directory.\n */\nexport async function hasMigrationTs(packageDir: string): Promise<boolean> {\n try {\n const s = await stat(join(packageDir, MIGRATION_TS_FILE));\n return s.isFile();\n } catch {\n return false;\n }\n}\n","export type ScaffoldRuntime = 'node' | 'bun' | 'deno';\n\nexport function detectScaffoldRuntime(): ScaffoldRuntime {\n if (typeof (globalThis as { Bun?: unknown }).Bun !== 'undefined') return 'bun';\n if (typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined') return 'deno';\n return 'node';\n}\n\nexport function shebangLineFor(runtime: ScaffoldRuntime): string {\n switch (runtime) {\n case 'bun':\n return '#!/usr/bin/env -S bun';\n case 'deno':\n return '#!/usr/bin/env -S deno run -A';\n case 'node':\n return '#!/usr/bin/env -S node';\n }\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,oBAAoB;;;;;;;;;;;;;;;;AAiB1B,eAAsB,iBAAiB,YAAoB,SAAgC;CACzF,MAAM,YAAY,MAAM,wBAAwB,QAAQ;CACxD,MAAM,eAAe,UAAU,WAAW,KAAK;CAC/C,MAAM,UACJ,KAAK,YAAY,kBAAkB,EACnC,WACA,eAAe,EAAE,MAAM,KAAO,GAAG,KAAA,EAClC;;AAGH,eAAe,wBAAwB,QAAiC;CACtE,OAAO,OAAO,QAAQ;EACpB,QAAQ;EACR,aAAa;EACb,MAAM;EACN,YAAY;EACb,CAAC;;;;;AAMJ,eAAsB,eAAe,YAAsC;CACzE,IAAI;EAEF,QAAO,MADS,KAAK,KAAK,YAAY,kBAAkB,CAAC,EAChD,QAAQ;SACX;EACN,OAAO;;;;;ACvDX,SAAgB,wBAAyC;CACvD,IAAI,OAAQ,WAAiC,QAAQ,aAAa,OAAO;CACzE,IAAI,OAAQ,WAAkC,SAAS,aAAa,OAAO;CAC3E,OAAO;;AAGT,SAAgB,eAAe,SAAkC;CAC/D,QAAQ,SAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO"}
1
+ {"version":3,"file":"migration-ts.mjs","names":[],"sources":["../../src/migration-ts.ts","../../src/runtime-detection.ts"],"sourcesContent":["/**\n * Utilities for reading/writing `migration.ts` files.\n *\n * Rendering migration.ts source is the target's responsibility — the CLI\n * obtains source strings from a planner's `plan.renderTypeScript()`. The\n * helper here is limited to file I/O: writing the returned source with the\n * right executable bit and probing for existence.\n */\n\nimport { stat, writeFile } from 'node:fs/promises';\nimport { join } from 'pathe';\nimport { format } from 'prettier';\n\nconst MIGRATION_TS_FILE = 'migration.ts';\n\n/**\n * Writes a pre-rendered `migration.ts` source string to the given package\n * directory. If the source begins with a shebang, the file is written with\n * executable permissions (0o755) so it can be run directly via\n * `./migration.ts` — the rendered scaffold ends with\n * `MigrationCLI.run(import.meta.url, M)` from\n * `@prisma-next/cli/migration-cli` (re-exported by the postgres facade),\n * which guards on the entrypoint and serializes when the file is the main\n * module.\n *\n * The source is run through prettier before writing so migration renderers\n * can produce structurally-correct but loosely-indented source and rely on\n * a single canonical format on disk. Matches what `@prisma-next/emitter`\n * already does for generated `contract.d.ts`.\n */\nexport async function writeMigrationTs(packageDir: string, content: string): Promise<void> {\n const formatted = await formatMigrationTsSource(content);\n const isExecutable = formatted.startsWith('#!');\n await writeFile(\n join(packageDir, MIGRATION_TS_FILE),\n formatted,\n isExecutable ? { mode: 0o755 } : undefined,\n );\n}\n\nasync function formatMigrationTsSource(source: string): Promise<string> {\n return format(source, {\n parser: 'typescript',\n singleQuote: true,\n semi: true,\n printWidth: 100,\n });\n}\n\n/**\n * Checks whether a migration.ts file exists in the package directory.\n */\nexport async function hasMigrationTs(packageDir: string): Promise<boolean> {\n try {\n const s = await stat(join(packageDir, MIGRATION_TS_FILE));\n return s.isFile();\n } catch {\n return false;\n }\n}\n","export type ScaffoldRuntime = 'node' | 'bun' | 'deno';\n\nexport function detectScaffoldRuntime(): ScaffoldRuntime {\n if (typeof (globalThis as { Bun?: unknown }).Bun !== 'undefined') return 'bun';\n if (typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined') return 'deno';\n return 'node';\n}\n\nexport function shebangLineFor(runtime: ScaffoldRuntime): string {\n switch (runtime) {\n case 'bun':\n return '#!/usr/bin/env -S bun';\n case 'deno':\n return '#!/usr/bin/env -S deno run -A';\n case 'node':\n return '#!/usr/bin/env -S node';\n }\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,oBAAoB;;;;;;;;;;;;;;;;AAiB1B,eAAsB,iBAAiB,YAAoB,SAAgC;CACzF,MAAM,YAAY,MAAM,wBAAwB,OAAO;CACvD,MAAM,eAAe,UAAU,WAAW,IAAI;CAC9C,MAAM,UACJ,KAAK,YAAY,iBAAiB,GAClC,WACA,eAAe,EAAE,MAAM,IAAM,IAAI,KAAA,CACnC;AACF;AAEA,eAAe,wBAAwB,QAAiC;CACtE,OAAO,OAAO,QAAQ;EACpB,QAAQ;EACR,aAAa;EACb,MAAM;EACN,YAAY;CACd,CAAC;AACH;;;;AAKA,eAAsB,eAAe,YAAsC;CACzE,IAAI;EAEF,QAAO,MADS,KAAK,KAAK,YAAY,iBAAiB,CAAC,GAC/C,OAAO;CAClB,QAAQ;EACN,OAAO;CACT;AACF;;;ACzDA,SAAgB,wBAAyC;CACvD,IAAI,OAAQ,WAAiC,QAAQ,aAAa,OAAO;CACzE,IAAI,OAAQ,WAAkC,SAAS,aAAa,OAAO;CAC3E,OAAO;AACT;AAEA,SAAgB,eAAe,SAAkC;CAC/D,QAAQ,SAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,QACH,OAAO;CACX;AACF"}
@@ -1,11 +1,10 @@
1
- import { n as MigrationMetadata$1 } from "../metadata-BFX0xdz8.mjs";
1
+ import { t as MigrationMetadata$1 } from "../metadata-BCH1rNsk.mjs";
2
2
  import { ControlStack, MigrationPlan, MigrationPlanOperation } from "@prisma-next/framework-components/control";
3
3
 
4
4
  //#region src/migration-base.d.ts
5
5
  interface MigrationMeta {
6
6
  readonly from: string | null;
7
7
  readonly to: string;
8
- readonly labels?: readonly string[];
9
8
  }
10
9
  /**
11
10
  * Base class for migrations.
@@ -77,10 +76,10 @@ interface MigrationArtifacts {
77
76
  * Pure conversion from a `Migration` instance (plus the previously
78
77
  * scaffolded metadata, when one exists on disk) to the in-memory
79
78
  * artifacts that downstream tooling persists. Owns metadata validation,
80
- * metadata synthesis/preservation, hint normalization, and the
81
- * content-addressed `migrationHash` computation, but performs no file I/O
82
- * — callers handle reads (to source `existing`) and writes (to persist
83
- * `opsJson` / `metadataJson`).
79
+ * metadata synthesis/preservation, and the content-addressed
80
+ * `migrationHash` computation, but performs no file I/O — callers handle
81
+ * reads (to source `existing`) and writes (to persist `opsJson` /
82
+ * `metadataJson`).
84
83
  */
85
84
  declare function buildMigrationArtifacts(instance: Migration, existing: Partial<MigrationMetadata$1> | null): MigrationArtifacts;
86
85
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.mts","names":[],"sources":["../../src/migration-base.ts"],"mappings":";;;;UAeiB,aAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAA;EAAA,SACA,MAAA;AAAA;;;;;;;AAuBX;;;uBAAsB,SAAA,oBACD,sBAAA,GAAyB,sBAAA,mFAGjC,aAAA;EAAA,kBAEO,QAAA;EAWqB;;;;;;;;;EAAA,mBAApB,KAAA,EAAO,YAAA,CAAa,SAAA,EAAW,SAAA;cAEtC,KAAA,GAAQ,YAAA,CAAa,SAAA,EAAW,SAAA;EAlB5C;;;;;;EAAA,aA4Ba,UAAA,CAAA,YAAuB,UAAA;EAZjB;;;;;EAAA,SAmBV,QAAA,CAAA,GAAY,aAAA;EAAA,IAEjB,MAAA,CAAA;IAAA,SAAqB,WAAA;EAAA;EAAA,IAKrB,WAAA,CAAA;IAAA,SAA0B,WAAA;EAAA;AAAA;;;;;;;AAYhC;iBAAgB,kBAAA,CAAmB,aAAA;;;;AAsBnC;;;;;;;;UAAiB,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,QAAA,EAAU,mBAAA;EAAA,SACV,YAAA;AAAA;;;;;;;;;;iBA8DK,uBAAA,CACd,QAAA,EAAU,SAAA,EACV,QAAA,EAAU,OAAA,CAAQ,mBAAA,WACjB,kBAAA"}
1
+ {"version":3,"file":"migration.d.mts","names":[],"sources":["../../src/migration-base.ts"],"mappings":";;;;UAeiB,aAAA;EAAA,SACN,IAAA;EAAA,SACA,EAAE;AAAA;;;AAAA;AAsBb;;;;;;uBAAsB,SAAA,oBACD,sBAAA,GAAyB,sBAAA,mFAGjC,aAAA;EAAA,kBAEO,QAAA;EAae;;;;;;;;;EAAA,mBAFd,KAAA,EAAO,YAAA,CAAa,SAAA,EAAW,SAAA;cAEtC,KAAA,GAAQ,YAAA,CAAa,SAAA,EAAW,SAAA;EAjB5C;;;;;;EAAA,aA2Ba,UAAA,CAAA,YAAuB,UAAA;EAZc;;;;;EAAA,SAmBzC,QAAA,CAAA,GAAY,aAAA;EAAA,IAEjB,MAAA,CAAA;IAAA,SAAqB,WAAA;EAAA;EAAA,IAKrB,WAAA,CAAA;IAAA,SAA0B,WAAA;EAAA;AAAA;;;AAAW;AAY3C;;;;iBAAgB,kBAAA,CAAmB,aAAqB;AAsBxD;;;;;;;;;AAGuB;AA4CvB;AA/CA,UAAiB,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,QAAA,EAAU,mBAAiB;EAAA,SAC3B,YAAA;AAAA;;;;;;;;;;iBA4CK,uBAAA,CACd,QAAA,EAAU,SAAA,EACV,QAAA,EAAU,OAAA,CAAQ,mBAAA,WACjB,kBAAA"}
@@ -1,6 +1,6 @@
1
- import { f as errorInvalidOperationEntry } from "../errors-DGYwcwXs.mjs";
2
- import { t as computeMigrationHash } from "../hash-Cr4WIr4Z.mjs";
3
- import { t as deriveProvidedInvariants } from "../invariants-0daYEzyo.mjs";
1
+ import { p as errorInvalidOperationEntry } from "../errors-CoEN114u.mjs";
2
+ import { t as computeMigrationHash } from "../hash--Y7vCpN3.mjs";
3
+ import { t as deriveProvidedInvariants } from "../invariants-lbJddL-S.mjs";
4
4
  import { t as MigrationOpSchema } from "../op-schema-D5qkXfEf.mjs";
5
5
  import { type } from "arktype";
6
6
  import { realpathSync } from "node:fs";
@@ -8,8 +8,7 @@ import { fileURLToPath } from "node:url";
8
8
  //#region src/migration-base.ts
9
9
  const MigrationMetaSchema = type({
10
10
  from: "string > 0 | null",
11
- to: "string",
12
- "labels?": type("string").array()
11
+ to: "string"
13
12
  });
14
13
  /**
15
14
  * Base class for migrations.
@@ -64,12 +63,11 @@ function isDirectEntrypoint(importMetaUrl) {
64
63
  * operations list, and the previously-scaffolded metadata (if any).
65
64
  *
66
65
  * When a `migration.json` already exists for this package (the common
67
- * case: it was scaffolded by `migration plan`), preserve the contract
68
- * bookends, hints, labels, and `createdAt` set there those fields are
69
- * owned by the CLI scaffolder, not the authored class. Only the
70
- * `describe()`-derived fields (`from`, `to`) and the operations
71
- * change as the author iterates. When no metadata exists yet (a bare
72
- * `migration.ts` run from scratch), synthesize a minimal but
66
+ * case: it was scaffolded by `migration plan`), preserve `createdAt`
67
+ * set there that field is owned by the CLI scaffolder, not the authored
68
+ * class. Only the `describe()`-derived fields (`from`, `to`) and the
69
+ * operations change as the author iterates. When no metadata exists yet
70
+ * (a bare `migration.ts` run from scratch), synthesize a minimal but
73
71
  * schema-conformant record so the resulting package can still be read,
74
72
  * verified, and applied.
75
73
  *
@@ -80,10 +78,8 @@ function buildAttestedMetadata(meta, ops, existing) {
80
78
  const baseMetadata = {
81
79
  from: meta.from,
82
80
  to: meta.to,
83
- labels: meta.labels ?? existing?.labels ?? [],
84
81
  providedInvariants: deriveProvidedInvariants(ops),
85
- createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
86
- hints: normalizeHints(existing?.hints)
82
+ createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
87
83
  };
88
84
  const migrationHash = computeMigrationHash(baseMetadata, ops);
89
85
  return {
@@ -92,27 +88,13 @@ function buildAttestedMetadata(meta, ops, existing) {
92
88
  };
93
89
  }
94
90
  /**
95
- * Project `existing.hints` down to the known `MigrationHints` shape, dropping
96
- * any legacy keys that may linger in metadata scaffolded by older CLI
97
- * versions (e.g. `planningStrategy`). Picking fields explicitly instead of
98
- * spreading keeps refreshed `migration.json` files schema-clean regardless
99
- * of what was on disk before.
100
- */
101
- function normalizeHints(existing) {
102
- return {
103
- used: existing?.used ?? [],
104
- applied: existing?.applied ?? [],
105
- plannerVersion: existing?.plannerVersion ?? "2.0.0"
106
- };
107
- }
108
- /**
109
91
  * Pure conversion from a `Migration` instance (plus the previously
110
92
  * scaffolded metadata, when one exists on disk) to the in-memory
111
93
  * artifacts that downstream tooling persists. Owns metadata validation,
112
- * metadata synthesis/preservation, hint normalization, and the
113
- * content-addressed `migrationHash` computation, but performs no file I/O
114
- * — callers handle reads (to source `existing`) and writes (to persist
115
- * `opsJson` / `metadataJson`).
94
+ * metadata synthesis/preservation, and the content-addressed
95
+ * `migrationHash` computation, but performs no file I/O — callers handle
96
+ * reads (to source `existing`) and writes (to persist `opsJson` /
97
+ * `metadataJson`).
116
98
  */
117
99
  function buildMigrationArtifacts(instance, existing) {
118
100
  const ops = instance.operations;
@@ -1 +1 @@
1
- {"version":3,"file":"migration.mjs","names":[],"sources":["../../src/migration-base.ts"],"sourcesContent":["import { realpathSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type {\n ControlStack,\n MigrationPlan,\n MigrationPlanOperation,\n} from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\nimport { errorInvalidOperationEntry } from './errors';\nimport { computeMigrationHash } from './hash';\nimport { deriveProvidedInvariants } from './invariants';\nimport type { MigrationHints, MigrationMetadata } from './metadata';\nimport { MigrationOpSchema } from './op-schema';\nimport type { MigrationOps } from './package';\n\nexport interface MigrationMeta {\n readonly from: string | null;\n readonly to: string;\n readonly labels?: readonly string[];\n}\n\n// `from` rejects empty strings to mirror `MigrationMetadataSchema` in\n// `./io.ts`. Without this match, an authored migration could `describe()` with\n// `from: ''` and pass `buildMigrationArtifacts`'s validation, only to have\n// `readMigrationPackage` reject the resulting `migration.json` later — the\n// two validators must agree on the legal value space.\nconst MigrationMetaSchema = type({\n from: 'string > 0 | null',\n to: 'string',\n 'labels?': type('string').array(),\n});\n\n/**\n * Base class for migrations.\n *\n * A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n * runner can consume it directly via `targetId`, `operations`, `origin`, and\n * `destination`. The metadata-shaped inputs come from `describe()`, which\n * every migration must implement — `migration.json` is required for a\n * migration to be valid.\n */\nexport abstract class Migration<\n TOperation extends MigrationPlanOperation = MigrationPlanOperation,\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> implements MigrationPlan\n{\n abstract readonly targetId: string;\n\n /**\n * Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n *\n * Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n * adapter once per instance. Optional at the abstract level so unit tests can\n * construct `Migration` instances purely for `operations` / `describe`\n * assertions without needing a real stack; concrete subclasses that need the\n * stack at runtime should narrow the parameter to required.\n */\n protected readonly stack: ControlStack<TFamilyId, TTargetId> | undefined;\n\n constructor(stack?: ControlStack<TFamilyId, TTargetId>) {\n this.stack = stack;\n }\n\n /**\n * Ordered list of operations this migration performs.\n *\n * Implemented as a getter so that subclasses can either precompute the list\n * in their constructor or build it lazily per access.\n */\n abstract get operations(): readonly TOperation[];\n\n /**\n * Metadata inputs used to build `migration.json` and to derive the plan's\n * origin/destination identities. Every migration must provide this —\n * omitting it would produce an invalid on-disk migration package.\n */\n abstract describe(): MigrationMeta;\n\n get origin(): { readonly storageHash: string } | null {\n const from = this.describe().from;\n return from === null ? null : { storageHash: from };\n }\n\n get destination(): { readonly storageHash: string } {\n return { storageHash: this.describe().to };\n }\n}\n\n/**\n * Returns true when `import.meta.url` resolves to the same file that was\n * invoked as the node entrypoint (`process.argv[1]`). Used by\n * `MigrationCLI.run` (in `@prisma-next/cli/migration-cli`) to no-op when\n * the migration module is being imported (e.g. by another script) rather\n * than executed directly.\n */\nexport function isDirectEntrypoint(importMetaUrl: string): boolean {\n const metaFilename = fileURLToPath(importMetaUrl);\n const argv1 = process.argv[1];\n if (!argv1) return false;\n try {\n return realpathSync(metaFilename) === realpathSync(argv1);\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory artifacts produced from a `Migration` instance: the\n * serialized `ops.json` body, the `migration.json` metadata object, and\n * its serialized form. Returned by `buildMigrationArtifacts` so callers\n * (today: `MigrationCLI.run` in `@prisma-next/cli/migration-cli`) can\n * decide how to persist them — write to disk, print in dry-run, ship\n * over the wire — without coupling artifact construction to file I/O.\n *\n * `metadataJson` is `JSON.stringify(metadata, null, 2)` — the canonical\n * on-disk shape that the arktype loader-schema in `./io` validates.\n */\nexport interface MigrationArtifacts {\n readonly opsJson: string;\n readonly metadata: MigrationMetadata;\n readonly metadataJson: string;\n}\n\n/**\n * Build the attested metadata from `describe()`-derived metadata, the\n * operations list, and the previously-scaffolded metadata (if any).\n *\n * When a `migration.json` already exists for this package (the common\n * case: it was scaffolded by `migration plan`), preserve the contract\n * bookends, hints, labels, and `createdAt` set there — those fields are\n * owned by the CLI scaffolder, not the authored class. Only the\n * `describe()`-derived fields (`from`, `to`) and the operations\n * change as the author iterates. When no metadata exists yet (a bare\n * `migration.ts` run from scratch), synthesize a minimal but\n * schema-conformant record so the resulting package can still be read,\n * verified, and applied.\n *\n * The `migrationHash` is recomputed against the current metadata + ops so\n * the on-disk artifacts are always fully attested.\n */\nfunction buildAttestedMetadata(\n meta: MigrationMeta,\n ops: MigrationOps,\n existing: Partial<MigrationMetadata> | null,\n): MigrationMetadata {\n const baseMetadata: Omit<MigrationMetadata, 'migrationHash'> = {\n from: meta.from,\n to: meta.to,\n labels: meta.labels ?? existing?.labels ?? [],\n providedInvariants: deriveProvidedInvariants(ops),\n createdAt: existing?.createdAt ?? new Date().toISOString(),\n hints: normalizeHints(existing?.hints),\n };\n\n const migrationHash = computeMigrationHash(baseMetadata, ops);\n return { ...baseMetadata, migrationHash };\n}\n\n/**\n * Project `existing.hints` down to the known `MigrationHints` shape, dropping\n * any legacy keys that may linger in metadata scaffolded by older CLI\n * versions (e.g. `planningStrategy`). Picking fields explicitly instead of\n * spreading keeps refreshed `migration.json` files schema-clean regardless\n * of what was on disk before.\n */\nfunction normalizeHints(existing: MigrationHints | undefined): MigrationHints {\n return {\n used: existing?.used ?? [],\n applied: existing?.applied ?? [],\n plannerVersion: existing?.plannerVersion ?? '2.0.0',\n };\n}\n\n/**\n * Pure conversion from a `Migration` instance (plus the previously\n * scaffolded metadata, when one exists on disk) to the in-memory\n * artifacts that downstream tooling persists. Owns metadata validation,\n * metadata synthesis/preservation, hint normalization, and the\n * content-addressed `migrationHash` computation, but performs no file I/O\n * — callers handle reads (to source `existing`) and writes (to persist\n * `opsJson` / `metadataJson`).\n */\nexport function buildMigrationArtifacts(\n instance: Migration,\n existing: Partial<MigrationMetadata> | null,\n): MigrationArtifacts {\n const ops = instance.operations;\n if (!Array.isArray(ops)) {\n throw new Error('operations must be an array');\n }\n\n for (let index = 0; index < ops.length; index++) {\n const result = MigrationOpSchema(ops[index]);\n if (result instanceof type.errors) {\n throw errorInvalidOperationEntry(index, result.summary);\n }\n }\n\n const rawMeta: unknown = instance.describe();\n const parsed = MigrationMetaSchema(rawMeta);\n if (parsed instanceof type.errors) {\n throw new Error(`describe() returned invalid metadata: ${parsed.summary}`);\n }\n\n const metadata = buildAttestedMetadata(parsed, ops, existing);\n\n return {\n opsJson: JSON.stringify(ops, null, 2),\n metadata,\n metadataJson: JSON.stringify(metadata, null, 2),\n };\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,sBAAsB,KAAK;CAC/B,MAAM;CACN,IAAI;CACJ,WAAW,KAAK,SAAS,CAAC,OAAO;CAClC,CAAC;;;;;;;;;;AAWF,IAAsB,YAAtB,MAKA;;;;;;;;;;CAYE;CAEA,YAAY,OAA4C;EACtD,KAAK,QAAQ;;CAkBf,IAAI,SAAkD;EACpD,MAAM,OAAO,KAAK,UAAU,CAAC;EAC7B,OAAO,SAAS,OAAO,OAAO,EAAE,aAAa,MAAM;;CAGrD,IAAI,cAAgD;EAClD,OAAO,EAAE,aAAa,KAAK,UAAU,CAAC,IAAI;;;;;;;;;;AAW9C,SAAgB,mBAAmB,eAAgC;CACjE,MAAM,eAAe,cAAc,cAAc;CACjD,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI;EACF,OAAO,aAAa,aAAa,KAAK,aAAa,MAAM;SACnD;EACN,OAAO;;;;;;;;;;;;;;;;;;;;AAsCX,SAAS,sBACP,MACA,KACA,UACmB;CACnB,MAAM,eAAyD;EAC7D,MAAM,KAAK;EACX,IAAI,KAAK;EACT,QAAQ,KAAK,UAAU,UAAU,UAAU,EAAE;EAC7C,oBAAoB,yBAAyB,IAAI;EACjD,WAAW,UAAU,8BAAa,IAAI,MAAM,EAAC,aAAa;EAC1D,OAAO,eAAe,UAAU,MAAM;EACvC;CAED,MAAM,gBAAgB,qBAAqB,cAAc,IAAI;CAC7D,OAAO;EAAE,GAAG;EAAc;EAAe;;;;;;;;;AAU3C,SAAS,eAAe,UAAsD;CAC5E,OAAO;EACL,MAAM,UAAU,QAAQ,EAAE;EAC1B,SAAS,UAAU,WAAW,EAAE;EAChC,gBAAgB,UAAU,kBAAkB;EAC7C;;;;;;;;;;;AAYH,SAAgB,wBACd,UACA,UACoB;CACpB,MAAM,MAAM,SAAS;CACrB,IAAI,CAAC,MAAM,QAAQ,IAAI,EACrB,MAAM,IAAI,MAAM,8BAA8B;CAGhD,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAC/C,MAAM,SAAS,kBAAkB,IAAI,OAAO;EAC5C,IAAI,kBAAkB,KAAK,QACzB,MAAM,2BAA2B,OAAO,OAAO,QAAQ;;CAK3D,MAAM,SAAS,oBADU,SAAS,UACQ,CAAC;CAC3C,IAAI,kBAAkB,KAAK,QACzB,MAAM,IAAI,MAAM,yCAAyC,OAAO,UAAU;CAG5E,MAAM,WAAW,sBAAsB,QAAQ,KAAK,SAAS;CAE7D,OAAO;EACL,SAAS,KAAK,UAAU,KAAK,MAAM,EAAE;EACrC;EACA,cAAc,KAAK,UAAU,UAAU,MAAM,EAAE;EAChD"}
1
+ {"version":3,"file":"migration.mjs","names":[],"sources":["../../src/migration-base.ts"],"sourcesContent":["import { realpathSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport type {\n ControlStack,\n MigrationPlan,\n MigrationPlanOperation,\n} from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\nimport { errorInvalidOperationEntry } from './errors';\nimport { computeMigrationHash } from './hash';\nimport { deriveProvidedInvariants } from './invariants';\nimport type { MigrationMetadata } from './metadata';\nimport { MigrationOpSchema } from './op-schema';\nimport type { MigrationOps } from './package';\n\nexport interface MigrationMeta {\n readonly from: string | null;\n readonly to: string;\n}\n\n// `from` rejects empty strings to mirror `MigrationMetadataSchema` in\n// `./io.ts`. Without this match, an authored migration could `describe()` with\n// `from: ''` and pass `buildMigrationArtifacts`'s validation, only to have\n// `readMigrationPackage` reject the resulting `migration.json` later — the\n// two validators must agree on the legal value space.\nconst MigrationMetaSchema = type({\n from: 'string > 0 | null',\n to: 'string',\n});\n\n/**\n * Base class for migrations.\n *\n * A `Migration` subclass is itself a `MigrationPlan`: CLI commands and the\n * runner can consume it directly via `targetId`, `operations`, `origin`, and\n * `destination`. The metadata-shaped inputs come from `describe()`, which\n * every migration must implement — `migration.json` is required for a\n * migration to be valid.\n */\nexport abstract class Migration<\n TOperation extends MigrationPlanOperation = MigrationPlanOperation,\n TFamilyId extends string = string,\n TTargetId extends string = string,\n> implements MigrationPlan\n{\n abstract readonly targetId: string;\n\n /**\n * Assembled `ControlStack` injected by the orchestrator (`runMigration`).\n *\n * Subclasses (e.g. `PostgresMigration`) read the stack to materialize their\n * adapter once per instance. Optional at the abstract level so unit tests can\n * construct `Migration` instances purely for `operations` / `describe`\n * assertions without needing a real stack; concrete subclasses that need the\n * stack at runtime should narrow the parameter to required.\n */\n protected readonly stack: ControlStack<TFamilyId, TTargetId> | undefined;\n\n constructor(stack?: ControlStack<TFamilyId, TTargetId>) {\n this.stack = stack;\n }\n\n /**\n * Ordered list of operations this migration performs.\n *\n * Implemented as a getter so that subclasses can either precompute the list\n * in their constructor or build it lazily per access.\n */\n abstract get operations(): readonly TOperation[];\n\n /**\n * Metadata inputs used to build `migration.json` and to derive the plan's\n * origin/destination identities. Every migration must provide this —\n * omitting it would produce an invalid on-disk migration package.\n */\n abstract describe(): MigrationMeta;\n\n get origin(): { readonly storageHash: string } | null {\n const from = this.describe().from;\n return from === null ? null : { storageHash: from };\n }\n\n get destination(): { readonly storageHash: string } {\n return { storageHash: this.describe().to };\n }\n}\n\n/**\n * Returns true when `import.meta.url` resolves to the same file that was\n * invoked as the node entrypoint (`process.argv[1]`). Used by\n * `MigrationCLI.run` (in `@prisma-next/cli/migration-cli`) to no-op when\n * the migration module is being imported (e.g. by another script) rather\n * than executed directly.\n */\nexport function isDirectEntrypoint(importMetaUrl: string): boolean {\n const metaFilename = fileURLToPath(importMetaUrl);\n const argv1 = process.argv[1];\n if (!argv1) return false;\n try {\n return realpathSync(metaFilename) === realpathSync(argv1);\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory artifacts produced from a `Migration` instance: the\n * serialized `ops.json` body, the `migration.json` metadata object, and\n * its serialized form. Returned by `buildMigrationArtifacts` so callers\n * (today: `MigrationCLI.run` in `@prisma-next/cli/migration-cli`) can\n * decide how to persist them — write to disk, print in dry-run, ship\n * over the wire — without coupling artifact construction to file I/O.\n *\n * `metadataJson` is `JSON.stringify(metadata, null, 2)` — the canonical\n * on-disk shape that the arktype loader-schema in `./io` validates.\n */\nexport interface MigrationArtifacts {\n readonly opsJson: string;\n readonly metadata: MigrationMetadata;\n readonly metadataJson: string;\n}\n\n/**\n * Build the attested metadata from `describe()`-derived metadata, the\n * operations list, and the previously-scaffolded metadata (if any).\n *\n * When a `migration.json` already exists for this package (the common\n * case: it was scaffolded by `migration plan`), preserve `createdAt`\n * set there — that field is owned by the CLI scaffolder, not the authored\n * class. Only the `describe()`-derived fields (`from`, `to`) and the\n * operations change as the author iterates. When no metadata exists yet\n * (a bare `migration.ts` run from scratch), synthesize a minimal but\n * schema-conformant record so the resulting package can still be read,\n * verified, and applied.\n *\n * The `migrationHash` is recomputed against the current metadata + ops so\n * the on-disk artifacts are always fully attested.\n */\nfunction buildAttestedMetadata(\n meta: MigrationMeta,\n ops: MigrationOps,\n existing: Partial<MigrationMetadata> | null,\n): MigrationMetadata {\n const baseMetadata: Omit<MigrationMetadata, 'migrationHash'> = {\n from: meta.from,\n to: meta.to,\n providedInvariants: deriveProvidedInvariants(ops),\n createdAt: existing?.createdAt ?? new Date().toISOString(),\n };\n\n const migrationHash = computeMigrationHash(baseMetadata, ops);\n return { ...baseMetadata, migrationHash };\n}\n\n/**\n * Pure conversion from a `Migration` instance (plus the previously\n * scaffolded metadata, when one exists on disk) to the in-memory\n * artifacts that downstream tooling persists. Owns metadata validation,\n * metadata synthesis/preservation, and the content-addressed\n * `migrationHash` computation, but performs no file I/O — callers handle\n * reads (to source `existing`) and writes (to persist `opsJson` /\n * `metadataJson`).\n */\nexport function buildMigrationArtifacts(\n instance: Migration,\n existing: Partial<MigrationMetadata> | null,\n): MigrationArtifacts {\n const ops = instance.operations;\n if (!Array.isArray(ops)) {\n throw new Error('operations must be an array');\n }\n\n for (let index = 0; index < ops.length; index++) {\n const result = MigrationOpSchema(ops[index]);\n if (result instanceof type.errors) {\n throw errorInvalidOperationEntry(index, result.summary);\n }\n }\n\n const rawMeta: unknown = instance.describe();\n const parsed = MigrationMetaSchema(rawMeta);\n if (parsed instanceof type.errors) {\n throw new Error(`describe() returned invalid metadata: ${parsed.summary}`);\n }\n\n const metadata = buildAttestedMetadata(parsed, ops, existing);\n\n return {\n opsJson: JSON.stringify(ops, null, 2),\n metadata,\n metadataJson: JSON.stringify(metadata, null, 2),\n };\n}\n"],"mappings":";;;;;;;;AAyBA,MAAM,sBAAsB,KAAK;CAC/B,MAAM;CACN,IAAI;AACN,CAAC;;;;;;;;;;AAWD,IAAsB,YAAtB,MAKA;;;;;;;;;;CAYE;CAEA,YAAY,OAA4C;EACtD,KAAK,QAAQ;CACf;CAiBA,IAAI,SAAkD;EACpD,MAAM,OAAO,KAAK,SAAS,EAAE;EAC7B,OAAO,SAAS,OAAO,OAAO,EAAE,aAAa,KAAK;CACpD;CAEA,IAAI,cAAgD;EAClD,OAAO,EAAE,aAAa,KAAK,SAAS,EAAE,GAAG;CAC3C;AACF;;;;;;;;AASA,SAAgB,mBAAmB,eAAgC;CACjE,MAAM,eAAe,cAAc,aAAa;CAChD,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI;EACF,OAAO,aAAa,YAAY,MAAM,aAAa,KAAK;CAC1D,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;AAmCA,SAAS,sBACP,MACA,KACA,UACmB;CACnB,MAAM,eAAyD;EAC7D,MAAM,KAAK;EACX,IAAI,KAAK;EACT,oBAAoB,yBAAyB,GAAG;EAChD,WAAW,UAAU,8BAAa,IAAI,KAAK,GAAE,YAAY;CAC3D;CAEA,MAAM,gBAAgB,qBAAqB,cAAc,GAAG;CAC5D,OAAO;EAAE,GAAG;EAAc;CAAc;AAC1C;;;;;;;;;;AAWA,SAAgB,wBACd,UACA,UACoB;CACpB,MAAM,MAAM,SAAS;CACrB,IAAI,CAAC,MAAM,QAAQ,GAAG,GACpB,MAAM,IAAI,MAAM,6BAA6B;CAG/C,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAC/C,MAAM,SAAS,kBAAkB,IAAI,MAAM;EAC3C,IAAI,kBAAkB,KAAK,QACzB,MAAM,2BAA2B,OAAO,OAAO,OAAO;CAE1D;CAGA,MAAM,SAAS,oBADU,SAAS,SACO,CAAC;CAC1C,IAAI,kBAAkB,KAAK,QACzB,MAAM,IAAI,MAAM,yCAAyC,OAAO,SAAS;CAG3E,MAAM,WAAW,sBAAsB,QAAQ,KAAK,QAAQ;CAE5D,OAAO;EACL,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC;EACpC;EACA,cAAc,KAAK,UAAU,UAAU,MAAM,CAAC;CAChD;AACF"}
@@ -1,3 +1,3 @@
1
- import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-DZj8YvD0.mjs";
1
+ import { n as OnDiskMigrationPackage, t as MigrationOps } from "../package-DIttKL7X.mjs";
2
2
  import { MigrationPackage } from "@prisma-next/framework-components/control";
3
3
  export { type MigrationOps, type MigrationPackage, type OnDiskMigrationPackage };
@@ -1,5 +1,5 @@
1
- import { n as MigrationGraph, t as MigrationEdge } from "../graph-BrLXqoUc.mjs";
2
- import { n as Refs } from "../refs-CDaNerhT.mjs";
1
+ import { n as MigrationGraph, t as MigrationEdge } from "../graph-ZAIvH6p4.mjs";
2
+ import { n as Refs } from "../refs-BaygQaFD.mjs";
3
3
  import { Result } from "@prisma-next/utils/result";
4
4
 
5
5
  //#region src/refs/types.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"ref-resolution.d.mts","names":[],"sources":["../../src/refs/types.ts","../../src/refs/contract-ref.ts","../../src/refs/migration-ref.ts"],"mappings":";;;;;;UAIiB,oBAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,IAAA,EAAM,IAAA;AAAA;AAAA,KAGL,qBAAA;EAAA,SACG,IAAA;EAAA,SAAuB,KAAA;AAAA;EAAA,SACvB,IAAA;EAAA,SAAsB,OAAA;AAAA;EAAA,SACtB,IAAA;EAAA,SAA+B,OAAA;AAAA;EAAA,SAC/B,IAAA;EAAA,SAAiC,OAAA;AAAA;;UAG/B,WAAA;EAAA,SACN,IAAA;EAAA,SACA,UAAA,EAAY,qBAAA;AAAA;AAAA,KAGX,sBAAA;EAAA,SACG,IAAA;EAAA,SAA2B,OAAA;AAAA;EAAA,SAC3B,IAAA;EAAA,SAAuB,KAAA;AAAA;;UAGrB,YAAA;EAAA,SACN,OAAA;EAAA,SACA,aAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,UAAA,EAAY,sBAAA;AAAA;AAAA,UAGN,qBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,yBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,eAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;AAAA;AAAA,UAGM,0BAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;AAAA,KAGC,kBAAA,GACR,qBAAA,GACA,sBAAA,GACA,yBAAA,GACA,0BAAA;AAAA,iBAiBY,iBAAA,CACd,KAAA,EAAO,cAAA,EACP,OAAA,WACC,aAAA;;;;;;AAjFH;;;;;;;;iBCkBgB,gBAAA,CACd,KAAA,UACA,GAAA,EAAK,oBAAA,GACJ,MAAA,CAAO,WAAA,EAAa,kBAAA;;;;;;ADrBvB;;;;;;;;;iBEcgB,iBAAA,CACd,KAAA,UACA,GAAA,EAAK,oBAAA,GACJ,MAAA,CAAO,YAAA,EAAc,kBAAA"}
1
+ {"version":3,"file":"ref-resolution.d.mts","names":[],"sources":["../../src/refs/types.ts","../../src/refs/contract-ref.ts","../../src/refs/migration-ref.ts"],"mappings":";;;;;;UAIiB,oBAAA;EAAA,SACN,KAAA,EAAO,cAAA;EAAA,SACP,IAAA,EAAM,IAAI;AAAA;AAAA,KAGT,qBAAA;EAAA,SACG,IAAA;EAAA,SAAuB,KAAA;AAAA;EAAA,SACvB,IAAA;EAAA,SAAsB,OAAA;AAAA;EAAA,SACtB,IAAA;EAAA,SAA+B,OAAA;AAAA;EAAA,SAC/B,IAAA;EAAA,SAAiC,OAAA;AAAA;;UAG/B,WAAA;EAAA,SACN,IAAA;EAAA,SACA,UAAA,EAAY,qBAAqB;AAAA;AAAA,KAGhC,sBAAA;EAAA,SACG,IAAA;EAAA,SAA2B,OAAA;AAAA;EAAA,SAC3B,IAAA;EAAA,SAAuB,KAAA;AAAA;;UAGrB,YAAA;EAAA,SACN,OAAA;EAAA,SACA,aAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,UAAA,EAAY,sBAAsB;AAAA;AAAA,UAG5B,qBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,sBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,yBAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,eAAA;EAAA,SACA,OAAA;EAAA,SACA,GAAA;AAAA;AAAA,UAGM,0BAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;AAAA;AAAA,KAGC,kBAAA,GACR,qBAAA,GACA,sBAAA,GACA,yBAAA,GACA,0BAAA;AAAA,iBAiBY,iBAAA,CACd,KAAA,EAAO,cAAA,EACP,OAAA,WACC,aAAa;;;;;;AAjFhB;;;;;;;;iBCkBgB,gBAAA,CACd,KAAA,UACA,GAAA,EAAK,oBAAA,GACJ,MAAA,CAAO,WAAA,EAAa,kBAAA;;;;;;ADrBvB;;;;;;;;;iBEcgB,iBAAA,CACd,KAAA,UACA,GAAA,EAAK,oBAAA,GACJ,MAAA,CAAO,YAAA,EAAc,kBAAA"}
@@ -1,4 +1,4 @@
1
- import { a as validateRefName } from "../refs-BDHo5l_g.mjs";
1
+ import { a as validateRefName } from "../refs-HhOkD8BT.mjs";
2
2
  import { notOk, ok } from "@prisma-next/utils/result";
3
3
  //#region src/refs/types.ts
4
4
  const FULL_HASH_PATTERN = /^sha256:([0-9a-f]{64}|empty)$/;
@@ -1 +1 @@
1
- {"version":3,"file":"ref-resolution.mjs","names":[],"sources":["../../src/refs/types.ts","../../src/refs/contract-ref.ts","../../src/refs/migration-ref.ts"],"sourcesContent":["import type { MigrationEdge, MigrationGraph } from '../graph';\nimport type { Refs } from '../refs';\n\n/** Context required to resolve a contract or migration reference. */\nexport interface RefResolutionContext {\n readonly graph: MigrationGraph;\n readonly refs: Refs;\n}\n\nexport type ContractRefProvenance =\n | { readonly kind: 'hash'; readonly input: string }\n | { readonly kind: 'ref'; readonly refName: string }\n | { readonly kind: 'migration-to'; readonly dirName: string }\n | { readonly kind: 'migration-from'; readonly dirName: string };\n\n/** A resolved contract reference: the target hash and how it was derived. */\nexport interface ContractRef {\n readonly hash: string;\n readonly provenance: ContractRefProvenance;\n}\n\nexport type MigrationRefProvenance =\n | { readonly kind: 'dir-name'; readonly dirName: string }\n | { readonly kind: 'hash'; readonly input: string };\n\n/** A resolved migration reference. */\nexport interface MigrationRef {\n readonly dirName: string;\n readonly migrationHash: string;\n readonly from: string;\n readonly to: string;\n readonly provenance: MigrationRefProvenance;\n}\n\nexport interface RefResolutionNotFound {\n readonly kind: 'not-found';\n readonly input: string;\n readonly grammar: 'contract' | 'migration';\n}\n\nexport interface RefResolutionAmbiguous {\n readonly kind: 'ambiguous';\n readonly input: string;\n readonly candidates: readonly string[];\n readonly grammar: 'contract' | 'migration';\n}\n\nexport interface RefResolutionWrongGrammar {\n readonly kind: 'wrong-grammar';\n readonly input: string;\n readonly expectedGrammar: 'contract' | 'migration';\n readonly message: string;\n readonly fix: string;\n}\n\nexport interface RefResolutionInvalidFormat {\n readonly kind: 'invalid-format';\n readonly input: string;\n readonly reason: string;\n}\n\nexport type RefResolutionError =\n | RefResolutionNotFound\n | RefResolutionAmbiguous\n | RefResolutionWrongGrammar\n | RefResolutionInvalidFormat;\n\nconst FULL_HASH_PATTERN = /^sha256:([0-9a-f]{64}|empty)$/;\nconst HEX_PREFIX_PATTERN = /^(sha256:)?[0-9a-f]{6,}$/;\n\nexport function isFullHash(input: string): boolean {\n return FULL_HASH_PATTERN.test(input);\n}\n\nexport function isHexPrefix(input: string): boolean {\n return HEX_PREFIX_PATTERN.test(input);\n}\n\nexport function normalizeHashPrefix(input: string): string {\n return input.startsWith('sha256:') ? input : `sha256:${input}`;\n}\n\nexport function findEdgeByDirName(\n graph: MigrationGraph,\n dirName: string,\n): MigrationEdge | undefined {\n for (const edges of graph.forwardChain.values()) {\n for (const edge of edges) {\n if (edge.dirName === dirName) return edge;\n }\n }\n return undefined;\n}\n","import type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { validateRefName } from '../refs';\nimport type {\n ContractRef,\n ContractRefProvenance,\n RefResolutionContext,\n RefResolutionError,\n} from './types';\nimport { findEdgeByDirName, isFullHash, isHexPrefix, normalizeHashPrefix } from './types';\n\n/**\n * Resolve a user-supplied string to a contract hash using the unified\n * contract-reference grammar.\n *\n * Accepted forms:\n * - Full storage hash (`sha256:<64 hex>` or `sha256: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 */\nexport function parseContractRef(\n input: string,\n ctx: RefResolutionContext,\n): Result<ContractRef, RefResolutionError> {\n if (!input) {\n return notOk({ kind: 'invalid-format', input, reason: 'Reference cannot be empty' });\n }\n\n if (isFullHash(input)) {\n if (ctx.graph.nodes.has(input)) {\n return ok({ hash: input, provenance: { kind: 'hash', input } });\n }\n return notOk({ kind: 'not-found', input, grammar: 'contract' });\n }\n\n if (input.endsWith('^')) {\n const dirName = input.slice(0, -1);\n if (!dirName) {\n return notOk({ kind: 'invalid-format', input, reason: 'Missing directory name before ^' });\n }\n const edge = findEdgeByDirName(ctx.graph, dirName);\n if (edge) {\n return ok({ hash: edge.from, provenance: { kind: 'migration-from', dirName } });\n }\n return notOk({ kind: 'not-found', input, grammar: 'contract' });\n }\n\n type Candidate = { hash: string; provenance: ContractRefProvenance; label: string };\n const candidates: Candidate[] = [];\n\n if (validateRefName(input) && Object.hasOwn(ctx.refs, input)) {\n const ref = ctx.refs[input];\n if (ref) {\n candidates.push({\n hash: ref.hash,\n provenance: { kind: 'ref', refName: input },\n label: `ref \"${input}\"`,\n });\n }\n }\n\n const edge = findEdgeByDirName(ctx.graph, input);\n if (edge) {\n candidates.push({\n hash: edge.to,\n provenance: { kind: 'migration-to', dirName: input },\n label: `migration directory \"${input}\"`,\n });\n }\n\n if (isHexPrefix(input)) {\n const prefix = normalizeHashPrefix(input);\n const matches = [...ctx.graph.nodes].filter((n) => n.startsWith(prefix));\n const [firstMatch] = matches;\n if (matches.length === 1 && firstMatch !== undefined) {\n candidates.push({\n hash: firstMatch,\n provenance: { kind: 'hash', input },\n label: `hash prefix \"${input}\"`,\n });\n } else if (matches.length > 1) {\n return notOk({ kind: 'ambiguous', input, candidates: matches, grammar: 'contract' });\n }\n }\n\n const [firstCandidate] = candidates;\n if (candidates.length === 1 && firstCandidate !== undefined) {\n return ok({ hash: firstCandidate.hash, provenance: firstCandidate.provenance });\n }\n\n if (candidates.length > 1) {\n return notOk({\n kind: 'ambiguous',\n input,\n candidates: candidates.map((c) => c.label),\n grammar: 'contract',\n });\n }\n\n return notOk({ kind: 'not-found', input, grammar: 'contract' });\n}\n","import type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { validateRefName } from '../refs';\nimport type { MigrationRef, RefResolutionContext, RefResolutionError } from './types';\nimport { findEdgeByDirName, isFullHash, isHexPrefix, normalizeHashPrefix } from './types';\n\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 */\nexport function parseMigrationRef(\n input: string,\n ctx: RefResolutionContext,\n): Result<MigrationRef, RefResolutionError> {\n if (!input) {\n return notOk({ kind: 'invalid-format', input, reason: 'Reference cannot be empty' });\n }\n\n if (input.endsWith('^')) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: '`^` syntax addresses contracts, not migrations',\n fix: 'Pass the migration directory name without `^`, or use a contract-accepting flag like `--to` or `--from`.',\n });\n }\n\n if (validateRefName(input) && Object.hasOwn(ctx.refs, input)) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: `\"${input}\" is a ref name, not a migration`,\n fix: 'Refs point at contracts, not migrations. Use a migration directory name or migration hash.',\n });\n }\n\n const edge = findEdgeByDirName(ctx.graph, input);\n if (edge) {\n return ok({\n dirName: edge.dirName,\n migrationHash: edge.migrationHash,\n from: edge.from,\n to: edge.to,\n provenance: { kind: 'dir-name', dirName: input },\n });\n }\n\n if (isFullHash(input)) {\n const migEdge = ctx.graph.migrationByHash.get(input);\n if (migEdge) {\n return ok({\n dirName: migEdge.dirName,\n migrationHash: migEdge.migrationHash,\n from: migEdge.from,\n to: migEdge.to,\n provenance: { kind: 'hash', input },\n });\n }\n if (ctx.graph.nodes.has(input)) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: 'Hash matched a contract but not a migration',\n fix: 'Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.',\n });\n }\n return notOk({ kind: 'not-found', input, grammar: 'migration' });\n }\n\n if (isHexPrefix(input)) {\n const prefix = normalizeHashPrefix(input);\n const migMatches = [...ctx.graph.migrationByHash.entries()].filter(([hash]) =>\n hash.startsWith(prefix),\n );\n\n const [firstMigMatch] = migMatches;\n if (migMatches.length === 1 && firstMigMatch !== undefined) {\n const [, matchedEdge] = firstMigMatch;\n return ok({\n dirName: matchedEdge.dirName,\n migrationHash: matchedEdge.migrationHash,\n from: matchedEdge.from,\n to: matchedEdge.to,\n provenance: { kind: 'hash', input },\n });\n }\n\n if (migMatches.length > 1) {\n return notOk({\n kind: 'ambiguous',\n input,\n candidates: migMatches.map(([hash]) => hash),\n grammar: 'migration',\n });\n }\n\n const contractMatches = [...ctx.graph.nodes].filter((n) => n.startsWith(prefix));\n if (contractMatches.length > 0) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: 'Hash matched a contract but not a migration',\n fix: 'Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.',\n });\n }\n }\n\n return notOk({ kind: 'not-found', input, grammar: 'migration' });\n}\n"],"mappings":";;;AAmEA,MAAM,oBAAoB;AAC1B,MAAM,qBAAq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ACtB,OAAO,MAAM;GACX,MAAM;GACN;GACA,YAAY,WAAW,KAAK,CAAC,UAAU,KAAK;GAC5C,SAAS;GACV,CAAC;EAIJ,IADwB,CAAC,GAAG,IAAI,MAAM,MAAM,CAAC,QAAQ,MAAM,EAAE,WAAW,OAAO,CAC5D,CAAC,SAAS,GAC3B,OAAO,MAAM;GACX,MAAM;GACN;GACA,iBAAiB;GACjB,SAAS;GACT,KAAK;GACN,CAAC;;CAIN,OAAO,MAAM;EAAE,MAAM;EAAa;EAAO,SAAS;EAAa,CAAC"}
1
+ {"version":3,"file":"ref-resolution.mjs","names":[],"sources":["../../src/refs/types.ts","../../src/refs/contract-ref.ts","../../src/refs/migration-ref.ts"],"sourcesContent":["import type { MigrationEdge, MigrationGraph } from '../graph';\nimport type { Refs } from '../refs';\n\n/** Context required to resolve a contract or migration reference. */\nexport interface RefResolutionContext {\n readonly graph: MigrationGraph;\n readonly refs: Refs;\n}\n\nexport type ContractRefProvenance =\n | { readonly kind: 'hash'; readonly input: string }\n | { readonly kind: 'ref'; readonly refName: string }\n | { readonly kind: 'migration-to'; readonly dirName: string }\n | { readonly kind: 'migration-from'; readonly dirName: string };\n\n/** A resolved contract reference: the target hash and how it was derived. */\nexport interface ContractRef {\n readonly hash: string;\n readonly provenance: ContractRefProvenance;\n}\n\nexport type MigrationRefProvenance =\n | { readonly kind: 'dir-name'; readonly dirName: string }\n | { readonly kind: 'hash'; readonly input: string };\n\n/** A resolved migration reference. */\nexport interface MigrationRef {\n readonly dirName: string;\n readonly migrationHash: string;\n readonly from: string;\n readonly to: string;\n readonly provenance: MigrationRefProvenance;\n}\n\nexport interface RefResolutionNotFound {\n readonly kind: 'not-found';\n readonly input: string;\n readonly grammar: 'contract' | 'migration';\n}\n\nexport interface RefResolutionAmbiguous {\n readonly kind: 'ambiguous';\n readonly input: string;\n readonly candidates: readonly string[];\n readonly grammar: 'contract' | 'migration';\n}\n\nexport interface RefResolutionWrongGrammar {\n readonly kind: 'wrong-grammar';\n readonly input: string;\n readonly expectedGrammar: 'contract' | 'migration';\n readonly message: string;\n readonly fix: string;\n}\n\nexport interface RefResolutionInvalidFormat {\n readonly kind: 'invalid-format';\n readonly input: string;\n readonly reason: string;\n}\n\nexport type RefResolutionError =\n | RefResolutionNotFound\n | RefResolutionAmbiguous\n | RefResolutionWrongGrammar\n | RefResolutionInvalidFormat;\n\nconst FULL_HASH_PATTERN = /^sha256:([0-9a-f]{64}|empty)$/;\nconst HEX_PREFIX_PATTERN = /^(sha256:)?[0-9a-f]{6,}$/;\n\nexport function isFullHash(input: string): boolean {\n return FULL_HASH_PATTERN.test(input);\n}\n\nexport function isHexPrefix(input: string): boolean {\n return HEX_PREFIX_PATTERN.test(input);\n}\n\nexport function normalizeHashPrefix(input: string): string {\n return input.startsWith('sha256:') ? input : `sha256:${input}`;\n}\n\nexport function findEdgeByDirName(\n graph: MigrationGraph,\n dirName: string,\n): MigrationEdge | undefined {\n for (const edges of graph.forwardChain.values()) {\n for (const edge of edges) {\n if (edge.dirName === dirName) return edge;\n }\n }\n return undefined;\n}\n","import type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { validateRefName } from '../refs';\nimport type {\n ContractRef,\n ContractRefProvenance,\n RefResolutionContext,\n RefResolutionError,\n} from './types';\nimport { findEdgeByDirName, isFullHash, isHexPrefix, normalizeHashPrefix } from './types';\n\n/**\n * Resolve a user-supplied string to a contract hash using the unified\n * contract-reference grammar.\n *\n * Accepted forms:\n * - Full storage hash (`sha256:<64 hex>` or `sha256: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 */\nexport function parseContractRef(\n input: string,\n ctx: RefResolutionContext,\n): Result<ContractRef, RefResolutionError> {\n if (!input) {\n return notOk({ kind: 'invalid-format', input, reason: 'Reference cannot be empty' });\n }\n\n if (isFullHash(input)) {\n if (ctx.graph.nodes.has(input)) {\n return ok({ hash: input, provenance: { kind: 'hash', input } });\n }\n return notOk({ kind: 'not-found', input, grammar: 'contract' });\n }\n\n if (input.endsWith('^')) {\n const dirName = input.slice(0, -1);\n if (!dirName) {\n return notOk({ kind: 'invalid-format', input, reason: 'Missing directory name before ^' });\n }\n const edge = findEdgeByDirName(ctx.graph, dirName);\n if (edge) {\n return ok({ hash: edge.from, provenance: { kind: 'migration-from', dirName } });\n }\n return notOk({ kind: 'not-found', input, grammar: 'contract' });\n }\n\n type Candidate = { hash: string; provenance: ContractRefProvenance; label: string };\n const candidates: Candidate[] = [];\n\n if (validateRefName(input) && Object.hasOwn(ctx.refs, input)) {\n const ref = ctx.refs[input];\n if (ref) {\n candidates.push({\n hash: ref.hash,\n provenance: { kind: 'ref', refName: input },\n label: `ref \"${input}\"`,\n });\n }\n }\n\n const edge = findEdgeByDirName(ctx.graph, input);\n if (edge) {\n candidates.push({\n hash: edge.to,\n provenance: { kind: 'migration-to', dirName: input },\n label: `migration directory \"${input}\"`,\n });\n }\n\n if (isHexPrefix(input)) {\n const prefix = normalizeHashPrefix(input);\n const matches = [...ctx.graph.nodes].filter((n) => n.startsWith(prefix));\n const [firstMatch] = matches;\n if (matches.length === 1 && firstMatch !== undefined) {\n candidates.push({\n hash: firstMatch,\n provenance: { kind: 'hash', input },\n label: `hash prefix \"${input}\"`,\n });\n } else if (matches.length > 1) {\n return notOk({ kind: 'ambiguous', input, candidates: matches, grammar: 'contract' });\n }\n }\n\n const [firstCandidate] = candidates;\n if (candidates.length === 1 && firstCandidate !== undefined) {\n return ok({ hash: firstCandidate.hash, provenance: firstCandidate.provenance });\n }\n\n if (candidates.length > 1) {\n return notOk({\n kind: 'ambiguous',\n input,\n candidates: candidates.map((c) => c.label),\n grammar: 'contract',\n });\n }\n\n return notOk({ kind: 'not-found', input, grammar: 'contract' });\n}\n","import type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { validateRefName } from '../refs';\nimport type { MigrationRef, RefResolutionContext, RefResolutionError } from './types';\nimport { findEdgeByDirName, isFullHash, isHexPrefix, normalizeHashPrefix } from './types';\n\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 */\nexport function parseMigrationRef(\n input: string,\n ctx: RefResolutionContext,\n): Result<MigrationRef, RefResolutionError> {\n if (!input) {\n return notOk({ kind: 'invalid-format', input, reason: 'Reference cannot be empty' });\n }\n\n if (input.endsWith('^')) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: '`^` syntax addresses contracts, not migrations',\n fix: 'Pass the migration directory name without `^`, or use a contract-accepting flag like `--to` or `--from`.',\n });\n }\n\n if (validateRefName(input) && Object.hasOwn(ctx.refs, input)) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: `\"${input}\" is a ref name, not a migration`,\n fix: 'Refs point at contracts, not migrations. Use a migration directory name or migration hash.',\n });\n }\n\n const edge = findEdgeByDirName(ctx.graph, input);\n if (edge) {\n return ok({\n dirName: edge.dirName,\n migrationHash: edge.migrationHash,\n from: edge.from,\n to: edge.to,\n provenance: { kind: 'dir-name', dirName: input },\n });\n }\n\n if (isFullHash(input)) {\n const migEdge = ctx.graph.migrationByHash.get(input);\n if (migEdge) {\n return ok({\n dirName: migEdge.dirName,\n migrationHash: migEdge.migrationHash,\n from: migEdge.from,\n to: migEdge.to,\n provenance: { kind: 'hash', input },\n });\n }\n if (ctx.graph.nodes.has(input)) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: 'Hash matched a contract but not a migration',\n fix: 'Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.',\n });\n }\n return notOk({ kind: 'not-found', input, grammar: 'migration' });\n }\n\n if (isHexPrefix(input)) {\n const prefix = normalizeHashPrefix(input);\n const migMatches = [...ctx.graph.migrationByHash.entries()].filter(([hash]) =>\n hash.startsWith(prefix),\n );\n\n const [firstMigMatch] = migMatches;\n if (migMatches.length === 1 && firstMigMatch !== undefined) {\n const [, matchedEdge] = firstMigMatch;\n return ok({\n dirName: matchedEdge.dirName,\n migrationHash: matchedEdge.migrationHash,\n from: matchedEdge.from,\n to: matchedEdge.to,\n provenance: { kind: 'hash', input },\n });\n }\n\n if (migMatches.length > 1) {\n return notOk({\n kind: 'ambiguous',\n input,\n candidates: migMatches.map(([hash]) => hash),\n grammar: 'migration',\n });\n }\n\n const contractMatches = [...ctx.graph.nodes].filter((n) => n.startsWith(prefix));\n if (contractMatches.length > 0) {\n return notOk({\n kind: 'wrong-grammar',\n input,\n expectedGrammar: 'migration',\n message: 'Hash matched a contract but not a migration',\n fix: 'Use a contract-accepting flag like `--to` or `--from` to reference contracts by hash. Pass `migration show <dir>` for a specific migration.',\n });\n }\n }\n\n return notOk({ kind: 'not-found', input, grammar: 'migration' });\n}\n"],"mappings":";;;AAmEA,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAE3B,SAAgB,WAAW,OAAwB;CACjD,OAAO,kBAAkB,KAAK,KAAK;AACrC;AAEA,SAAgB,YAAY,OAAwB;CAClD,OAAO,mBAAmB,KAAK,KAAK;AACtC;AAEA,SAAgB,oBAAoB,OAAuB;CACzD,OAAO,MAAM,WAAW,SAAS,IAAI,QAAQ,UAAU;AACzD;AAEA,SAAgB,kBACd,OACA,SAC2B;CAC3B,KAAK,MAAM,SAAS,MAAM,aAAa,OAAO,GAC5C,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,YAAY,SAAS,OAAO;AAI3C;;;;;;;;;;;;;;ACtEA,SAAgB,iBACd,OACA,KACyC;CACzC,IAAI,CAAC,OACH,OAAO,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