@prisma-next/migration-tools 0.5.0-dev.3 → 0.5.0-dev.31

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 (92) hide show
  1. package/README.md +34 -22
  2. package/dist/{constants-BRi0X7B_.mjs → constants-BQEHsaEx.mjs} +1 -1
  3. package/dist/{constants-BRi0X7B_.mjs.map → constants-BQEHsaEx.mjs.map} +1 -1
  4. package/dist/errors-Bl3cKiM8.mjs +244 -0
  5. package/dist/errors-Bl3cKiM8.mjs.map +1 -0
  6. package/dist/exports/constants.mjs +1 -1
  7. package/dist/exports/{types.d.mts → errors.d.mts} +7 -8
  8. package/dist/exports/errors.d.mts.map +1 -0
  9. package/dist/exports/errors.mjs +3 -0
  10. package/dist/exports/graph.d.mts +2 -0
  11. package/dist/exports/graph.mjs +1 -0
  12. package/dist/exports/hash.d.mts +52 -0
  13. package/dist/exports/hash.d.mts.map +1 -0
  14. package/dist/exports/hash.mjs +3 -0
  15. package/dist/exports/invariants.d.mts +24 -0
  16. package/dist/exports/invariants.d.mts.map +1 -0
  17. package/dist/exports/invariants.mjs +4 -0
  18. package/dist/exports/io.d.mts +7 -6
  19. package/dist/exports/io.d.mts.map +1 -1
  20. package/dist/exports/io.mjs +162 -2
  21. package/dist/exports/io.mjs.map +1 -0
  22. package/dist/exports/metadata.d.mts +2 -0
  23. package/dist/exports/metadata.mjs +1 -0
  24. package/dist/exports/{dag.d.mts → migration-graph.d.mts} +31 -10
  25. package/dist/exports/migration-graph.d.mts.map +1 -0
  26. package/dist/exports/{dag.mjs → migration-graph.mjs} +143 -63
  27. package/dist/exports/migration-graph.mjs.map +1 -0
  28. package/dist/exports/migration-ts.mjs +1 -1
  29. package/dist/exports/migration.d.mts +15 -14
  30. package/dist/exports/migration.d.mts.map +1 -1
  31. package/dist/exports/migration.mjs +68 -40
  32. package/dist/exports/migration.mjs.map +1 -1
  33. package/dist/exports/package.d.mts +2 -0
  34. package/dist/exports/package.mjs +1 -0
  35. package/dist/exports/refs.d.mts +11 -5
  36. package/dist/exports/refs.d.mts.map +1 -1
  37. package/dist/exports/refs.mjs +106 -30
  38. package/dist/exports/refs.mjs.map +1 -1
  39. package/dist/graph-BHPv-9Gl.d.mts +28 -0
  40. package/dist/graph-BHPv-9Gl.d.mts.map +1 -0
  41. package/dist/hash-BARZdVgW.mjs +76 -0
  42. package/dist/hash-BARZdVgW.mjs.map +1 -0
  43. package/dist/invariants-BmrTBQ0A.mjs +42 -0
  44. package/dist/invariants-BmrTBQ0A.mjs.map +1 -0
  45. package/dist/metadata-BP1cmU7Z.d.mts +50 -0
  46. package/dist/metadata-BP1cmU7Z.d.mts.map +1 -0
  47. package/dist/op-schema-DZKFua46.mjs +14 -0
  48. package/dist/op-schema-DZKFua46.mjs.map +1 -0
  49. package/dist/package-5HCCg0z-.d.mts +21 -0
  50. package/dist/package-5HCCg0z-.d.mts.map +1 -0
  51. package/package.json +32 -16
  52. package/src/errors.ts +139 -15
  53. package/src/exports/errors.ts +1 -0
  54. package/src/exports/graph.ts +1 -0
  55. package/src/exports/hash.ts +2 -0
  56. package/src/exports/invariants.ts +1 -0
  57. package/src/exports/io.ts +1 -1
  58. package/src/exports/metadata.ts +1 -0
  59. package/src/exports/{dag.ts → migration-graph.ts} +3 -2
  60. package/src/exports/migration.ts +0 -1
  61. package/src/exports/package.ts +1 -0
  62. package/src/exports/refs.ts +10 -2
  63. package/src/graph-ops.ts +57 -30
  64. package/src/graph.ts +25 -0
  65. package/src/hash.ts +91 -0
  66. package/src/invariants.ts +45 -0
  67. package/src/io.ts +57 -31
  68. package/src/metadata.ts +41 -0
  69. package/src/migration-base.ts +97 -56
  70. package/src/{dag.ts → migration-graph.ts} +156 -54
  71. package/src/op-schema.ts +11 -0
  72. package/src/package.ts +18 -0
  73. package/src/refs.ts +148 -37
  74. package/dist/attestation-DtF8tEOM.mjs +0 -65
  75. package/dist/attestation-DtF8tEOM.mjs.map +0 -1
  76. package/dist/errors-BKbRGCJM.mjs +0 -160
  77. package/dist/errors-BKbRGCJM.mjs.map +0 -1
  78. package/dist/exports/attestation.d.mts +0 -37
  79. package/dist/exports/attestation.d.mts.map +0 -1
  80. package/dist/exports/attestation.mjs +0 -4
  81. package/dist/exports/dag.d.mts.map +0 -1
  82. package/dist/exports/dag.mjs.map +0 -1
  83. package/dist/exports/types.d.mts.map +0 -1
  84. package/dist/exports/types.mjs +0 -3
  85. package/dist/io-CCnYsUHU.mjs +0 -153
  86. package/dist/io-CCnYsUHU.mjs.map +0 -1
  87. package/dist/types-DyGXcWWp.d.mts +0 -71
  88. package/dist/types-DyGXcWWp.d.mts.map +0 -1
  89. package/src/attestation.ts +0 -81
  90. package/src/exports/attestation.ts +0 -2
  91. package/src/exports/types.ts +0 -10
  92. package/src/types.ts +0 -66
package/src/refs.ts CHANGED
@@ -1,14 +1,19 @@
1
- import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
1
+ import { mkdir, readdir, readFile, rename, rmdir, unlink, writeFile } from 'node:fs/promises';
2
2
  import { type } from 'arktype';
3
- import { dirname, join } from 'pathe';
3
+ import { dirname, join, relative } from 'pathe';
4
4
  import {
5
+ errorInvalidRefFile,
5
6
  errorInvalidRefName,
6
- errorInvalidRefs,
7
7
  errorInvalidRefValue,
8
8
  MigrationToolsError,
9
9
  } from './errors';
10
10
 
11
- export type Refs = Readonly<Record<string, string>>;
11
+ export interface RefEntry {
12
+ readonly hash: string;
13
+ readonly invariants: readonly string[];
14
+ }
15
+
16
+ export type Refs = Readonly<Record<string, RefEntry>>;
12
17
 
13
18
  const REF_NAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\/[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/;
14
19
  const REF_VALUE_PATTERN = /^sha256:(empty|[0-9a-f]{64})$/;
@@ -25,22 +30,40 @@ export function validateRefValue(value: string): boolean {
25
30
  return REF_VALUE_PATTERN.test(value);
26
31
  }
27
32
 
28
- const RefsSchema = type('Record<string, string>').narrow((refs, ctx) => {
29
- for (const [key, value] of Object.entries(refs)) {
30
- if (!validateRefName(key)) return ctx.mustBe(`valid ref names (invalid: "${key}")`);
31
- if (!validateRefValue(value))
32
- return ctx.mustBe(`valid contract hashes (invalid value for "${key}": "${value}")`);
33
- }
33
+ const RefEntrySchema = type({
34
+ hash: 'string',
35
+ invariants: 'string[]',
36
+ }).narrow((entry, ctx) => {
37
+ if (!validateRefValue(entry.hash))
38
+ return ctx.mustBe(`a valid contract hash (got "${entry.hash}")`);
34
39
  return true;
35
40
  });
36
41
 
37
- export async function readRefs(refsPath: string): Promise<Refs> {
42
+ function refFilePath(refsDir: string, name: string): string {
43
+ return join(refsDir, `${name}.json`);
44
+ }
45
+
46
+ function refNameFromPath(refsDir: string, filePath: string): string {
47
+ const rel = relative(refsDir, filePath);
48
+ return rel.replace(/\.json$/, '');
49
+ }
50
+
51
+ export async function readRef(refsDir: string, name: string): Promise<RefEntry> {
52
+ if (!validateRefName(name)) {
53
+ throw errorInvalidRefName(name);
54
+ }
55
+
56
+ const filePath = refFilePath(refsDir, name);
38
57
  let raw: string;
39
58
  try {
40
- raw = await readFile(refsPath, 'utf-8');
59
+ raw = await readFile(filePath, 'utf-8');
41
60
  } catch (error) {
42
61
  if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {
43
- return {};
62
+ throw new MigrationToolsError('MIGRATION.UNKNOWN_REF', `Unknown ref "${name}"`, {
63
+ why: `No ref file found at "${filePath}".`,
64
+ fix: `Create the ref with: prisma-next migration ref set ${name} <hash>`,
65
+ details: { refName: name, filePath },
66
+ });
44
67
  }
45
68
  throw error;
46
69
  }
@@ -49,54 +72,142 @@ export async function readRefs(refsPath: string): Promise<Refs> {
49
72
  try {
50
73
  parsed = JSON.parse(raw);
51
74
  } catch {
52
- throw errorInvalidRefs(refsPath, 'Failed to parse as JSON');
75
+ throw errorInvalidRefFile(filePath, 'Failed to parse as JSON');
53
76
  }
54
77
 
55
- const result = RefsSchema(parsed);
78
+ const result = RefEntrySchema(parsed);
56
79
  if (result instanceof type.errors) {
57
- throw errorInvalidRefs(refsPath, result.summary);
80
+ throw errorInvalidRefFile(filePath, result.summary);
58
81
  }
59
82
 
60
83
  return result;
61
84
  }
62
85
 
63
- export async function writeRefs(refsPath: string, refs: Refs): Promise<void> {
64
- for (const [key, value] of Object.entries(refs)) {
65
- if (!validateRefName(key)) {
66
- throw errorInvalidRefName(key);
86
+ export async function readRefs(refsDir: string): Promise<Refs> {
87
+ let entries: string[];
88
+ try {
89
+ entries = await readdir(refsDir, { recursive: true, encoding: 'utf-8' });
90
+ } catch (error) {
91
+ if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {
92
+ return {};
93
+ }
94
+ throw error;
95
+ }
96
+
97
+ const jsonFiles = entries.filter((entry) => entry.endsWith('.json'));
98
+ const refs: Record<string, RefEntry> = {};
99
+
100
+ for (const jsonFile of jsonFiles) {
101
+ const filePath = join(refsDir, jsonFile);
102
+ const name = refNameFromPath(refsDir, filePath);
103
+
104
+ let raw: string;
105
+ try {
106
+ raw = await readFile(filePath, 'utf-8');
107
+ } catch (error) {
108
+ // Tolerate the TOCTOU race between `readdir` and `readFile` (ENOENT) and
109
+ // benign EISDIR if a directory happens to end in `.json`. Anything else
110
+ // (EACCES, EIO, EMFILE, …) is a real failure and propagates so the CLI
111
+ // surfaces it rather than silently dropping the ref.
112
+ const code = error instanceof Error ? (error as { code?: string }).code : undefined;
113
+ if (code === 'ENOENT' || code === 'EISDIR') {
114
+ continue;
115
+ }
116
+ throw error;
117
+ }
118
+
119
+ let parsed: unknown;
120
+ try {
121
+ parsed = JSON.parse(raw);
122
+ } catch {
123
+ throw errorInvalidRefFile(filePath, 'Failed to parse as JSON');
67
124
  }
68
- if (!validateRefValue(value)) {
69
- throw errorInvalidRefValue(value);
125
+
126
+ const result = RefEntrySchema(parsed);
127
+ if (result instanceof type.errors) {
128
+ throw errorInvalidRefFile(filePath, result.summary);
70
129
  }
130
+
131
+ refs[name] = result;
71
132
  }
72
133
 
73
- const sorted = Object.fromEntries(Object.entries(refs).sort(([a], [b]) => a.localeCompare(b)));
134
+ return refs;
135
+ }
136
+
137
+ export async function writeRef(refsDir: string, name: string, entry: RefEntry): Promise<void> {
138
+ if (!validateRefName(name)) {
139
+ throw errorInvalidRefName(name);
140
+ }
141
+ if (!validateRefValue(entry.hash)) {
142
+ throw errorInvalidRefValue(entry.hash);
143
+ }
74
144
 
75
- const dir = dirname(refsPath);
145
+ const filePath = refFilePath(refsDir, name);
146
+ const dir = dirname(filePath);
76
147
  await mkdir(dir, { recursive: true });
77
148
 
78
- const tmpPath = join(dir, `.refs.json.${Date.now()}.tmp`);
79
- await writeFile(tmpPath, `${JSON.stringify(sorted, null, 2)}\n`);
80
- await rename(tmpPath, refsPath);
149
+ const tmpPath = join(dir, `.${name.split('/').pop()}.json.${Date.now()}.tmp`);
150
+ await writeFile(
151
+ tmpPath,
152
+ `${JSON.stringify({ hash: entry.hash, invariants: [...entry.invariants] }, null, 2)}\n`,
153
+ );
154
+ await rename(tmpPath, filePath);
81
155
  }
82
156
 
83
- export function resolveRef(refs: Refs, name: string): string {
157
+ export async function deleteRef(refsDir: string, name: string): Promise<void> {
84
158
  if (!validateRefName(name)) {
85
159
  throw errorInvalidRefName(name);
86
160
  }
87
161
 
88
- const hash = refs[name];
89
- if (hash === undefined) {
162
+ const filePath = refFilePath(refsDir, name);
163
+ try {
164
+ await unlink(filePath);
165
+ } catch (error) {
166
+ if (error instanceof Error && (error as { code?: string }).code === 'ENOENT') {
167
+ throw new MigrationToolsError('MIGRATION.UNKNOWN_REF', `Unknown ref "${name}"`, {
168
+ why: `No ref file found at "${filePath}".`,
169
+ fix: 'Run `prisma-next migration ref list` to see available refs.',
170
+ details: { refName: name, filePath },
171
+ });
172
+ }
173
+ throw error;
174
+ }
175
+
176
+ // Clean empty parent directories up to refsDir. Stop walking on the expected
177
+ // "directory has siblings" signal (ENOTEMPTY on Linux, EEXIST on some BSDs)
178
+ // and on ENOENT (concurrent removal). Anything else (EACCES, EIO, …) is a
179
+ // real failure and propagates.
180
+ let dir = dirname(filePath);
181
+ while (dir !== refsDir && dir.startsWith(refsDir)) {
182
+ try {
183
+ await rmdir(dir);
184
+ dir = dirname(dir);
185
+ } catch (error) {
186
+ const code = error instanceof Error ? (error as { code?: string }).code : undefined;
187
+ if (code === 'ENOTEMPTY' || code === 'EEXIST' || code === 'ENOENT') {
188
+ break;
189
+ }
190
+ throw error;
191
+ }
192
+ }
193
+ }
194
+
195
+ export function resolveRef(refs: Refs, name: string): RefEntry {
196
+ if (!validateRefName(name)) {
197
+ throw errorInvalidRefName(name);
198
+ }
199
+
200
+ // Object.hasOwn gate: plain-object `refs` would otherwise let
201
+ // `refs['constructor']` return Object.prototype.constructor and bypass the
202
+ // UNKNOWN_REF throw. validateRefName accepts `"constructor"` as a name shape.
203
+ if (!Object.hasOwn(refs, name)) {
90
204
  throw new MigrationToolsError('MIGRATION.UNKNOWN_REF', `Unknown ref "${name}"`, {
91
- why: `No ref named "${name}" exists in refs.json.`,
92
- fix: `Available refs: ${Object.keys(refs).join(', ') || '(none)'}. Create a ref with: set the "${name}" key in migrations/refs.json.`,
205
+ why: `No ref named "${name}" exists.`,
206
+ fix: `Available refs: ${Object.keys(refs).join(', ') || '(none)'}. Create a ref with: prisma-next migration ref set ${name} <hash>`,
93
207
  details: { refName: name, availableRefs: Object.keys(refs) },
94
208
  });
95
209
  }
96
210
 
97
- if (!validateRefValue(hash)) {
98
- throw errorInvalidRefValue(hash);
99
- }
100
-
101
- return hash;
211
+ // biome-ignore lint/style/noNonNullAssertion: Object.hasOwn gate above guarantees this is defined
212
+ return refs[name]!;
102
213
  }
@@ -1,65 +0,0 @@
1
- import { r as readMigrationPackage } from "./io-CCnYsUHU.mjs";
2
- import { createHash } from "node:crypto";
3
-
4
- //#region src/canonicalize-json.ts
5
- function sortKeys(value) {
6
- if (value === null || typeof value !== "object") return value;
7
- if (Array.isArray(value)) return value.map(sortKeys);
8
- const sorted = {};
9
- for (const key of Object.keys(value).sort()) sorted[key] = sortKeys(value[key]);
10
- return sorted;
11
- }
12
- function canonicalizeJson(value) {
13
- return JSON.stringify(sortKeys(value));
14
- }
15
-
16
- //#endregion
17
- //#region src/attestation.ts
18
- function sha256Hex(input) {
19
- return createHash("sha256").update(input).digest("hex");
20
- }
21
- /**
22
- * Content-addressed migration identity over (manifest envelope sans
23
- * contracts/hints, ops). See ADR 199 "Storage-only migration identity"
24
- * for the rationale: contracts are anchored separately by the
25
- * storage-hash bookends inside the envelope; planner hints are advisory
26
- * and must not affect identity.
27
- *
28
- * The `migrationId` field on the manifest is stripped before hashing so
29
- * the function can be used both at write time (when no id exists yet)
30
- * and at verify time (rehashing an already-attested manifest).
31
- */
32
- function computeMigrationId(manifest, ops) {
33
- const { migrationId: _migrationId, signature: _signature, fromContract: _fromContract, toContract: _toContract, hints: _hints, ...strippedMeta } = manifest;
34
- return `sha256:${sha256Hex(canonicalizeJson([canonicalizeJson(strippedMeta), canonicalizeJson(ops)].map(sha256Hex)))}`;
35
- }
36
- /**
37
- * Re-hash an on-disk migration bundle and compare against the stored
38
- * `migrationId`. Returns `{ ok: true }` when the package is internally
39
- * consistent (manifest + ops still produce the recorded id), or
40
- * `{ ok: false, reason: 'mismatch', stored, computed }` when they do
41
- * not — typically a sign of FS corruption, partial writes, or a
42
- * post-emit hand edit.
43
- */
44
- function verifyMigrationBundle(bundle) {
45
- const computed = computeMigrationId(bundle.manifest, bundle.ops);
46
- if (bundle.manifest.migrationId === computed) return {
47
- ok: true,
48
- storedMigrationId: bundle.manifest.migrationId,
49
- computedMigrationId: computed
50
- };
51
- return {
52
- ok: false,
53
- reason: "mismatch",
54
- storedMigrationId: bundle.manifest.migrationId,
55
- computedMigrationId: computed
56
- };
57
- }
58
- /** Convenience wrapper: read the package from disk then verify it. */
59
- async function verifyMigration(dir) {
60
- return verifyMigrationBundle(await readMigrationPackage(dir));
61
- }
62
-
63
- //#endregion
64
- export { verifyMigration as n, verifyMigrationBundle as r, computeMigrationId as t };
65
- //# sourceMappingURL=attestation-DtF8tEOM.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attestation-DtF8tEOM.mjs","names":["sorted: Record<string, unknown>"],"sources":["../src/canonicalize-json.ts","../src/attestation.ts"],"sourcesContent":["function sortKeys(value: unknown): unknown {\n if (value === null || typeof value !== 'object') {\n return value;\n }\n if (Array.isArray(value)) {\n return value.map(sortKeys);\n }\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).sort()) {\n sorted[key] = sortKeys((value as Record<string, unknown>)[key]);\n }\n return sorted;\n}\n\nexport function canonicalizeJson(value: unknown): string {\n return JSON.stringify(sortKeys(value));\n}\n","import { createHash } from 'node:crypto';\nimport { canonicalizeJson } from './canonicalize-json';\nimport { readMigrationPackage } from './io';\nimport type { MigrationBundle, MigrationManifest, MigrationOps } from './types';\n\nexport interface VerifyResult {\n readonly ok: boolean;\n readonly reason?: 'mismatch';\n readonly storedMigrationId?: string;\n readonly computedMigrationId?: string;\n}\n\nfunction sha256Hex(input: string): string {\n return createHash('sha256').update(input).digest('hex');\n}\n\n/**\n * Content-addressed migration identity over (manifest envelope sans\n * contracts/hints, ops). See ADR 199 \"Storage-only migration identity\"\n * for the rationale: contracts are anchored separately by the\n * storage-hash bookends inside the envelope; planner hints are advisory\n * and must not affect identity.\n *\n * The `migrationId` field on the manifest is stripped before hashing so\n * the function can be used both at write time (when no id exists yet)\n * and at verify time (rehashing an already-attested manifest).\n */\nexport function computeMigrationId(\n manifest: Omit<MigrationManifest, 'migrationId'> & { readonly migrationId?: string },\n ops: MigrationOps,\n): string {\n const {\n migrationId: _migrationId,\n signature: _signature,\n fromContract: _fromContract,\n toContract: _toContract,\n hints: _hints,\n ...strippedMeta\n } = manifest;\n\n const canonicalManifest = canonicalizeJson(strippedMeta);\n const canonicalOps = canonicalizeJson(ops);\n\n const partHashes = [canonicalManifest, canonicalOps].map(sha256Hex);\n const hash = sha256Hex(canonicalizeJson(partHashes));\n\n return `sha256:${hash}`;\n}\n\n/**\n * Re-hash an on-disk migration bundle and compare against the stored\n * `migrationId`. Returns `{ ok: true }` when the package is internally\n * consistent (manifest + ops still produce the recorded id), or\n * `{ ok: false, reason: 'mismatch', stored, computed }` when they do\n * not — typically a sign of FS corruption, partial writes, or a\n * post-emit hand edit.\n */\nexport function verifyMigrationBundle(bundle: MigrationBundle): VerifyResult {\n const computed = computeMigrationId(bundle.manifest, bundle.ops);\n\n if (bundle.manifest.migrationId === computed) {\n return {\n ok: true,\n storedMigrationId: bundle.manifest.migrationId,\n computedMigrationId: computed,\n };\n }\n\n return {\n ok: false,\n reason: 'mismatch',\n storedMigrationId: bundle.manifest.migrationId,\n computedMigrationId: computed,\n };\n}\n\n/** Convenience wrapper: read the package from disk then verify it. */\nexport async function verifyMigration(dir: string): Promise<VerifyResult> {\n const pkg = await readMigrationPackage(dir);\n return verifyMigrationBundle(pkg);\n}\n"],"mappings":";;;;AAAA,SAAS,SAAS,OAAyB;AACzC,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,QAAO;AAET,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,SAAS;CAE5B,MAAMA,SAAkC,EAAE;AAC1C,MAAK,MAAM,OAAO,OAAO,KAAK,MAAM,CAAC,MAAM,CACzC,QAAO,OAAO,SAAU,MAAkC,KAAK;AAEjE,QAAO;;AAGT,SAAgB,iBAAiB,OAAwB;AACvD,QAAO,KAAK,UAAU,SAAS,MAAM,CAAC;;;;;ACHxC,SAAS,UAAU,OAAuB;AACxC,QAAO,WAAW,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;;;;;;;;;;;;AAczD,SAAgB,mBACd,UACA,KACQ;CACR,MAAM,EACJ,aAAa,cACb,WAAW,YACX,cAAc,eACd,YAAY,aACZ,OAAO,QACP,GAAG,iBACD;AAQJ,QAAO,UAFM,UAAU,iBADJ,CAHO,iBAAiB,aAAa,EACnC,iBAAiB,IAAI,CAEU,CAAC,IAAI,UAAU,CAChB,CAAC;;;;;;;;;;AAatD,SAAgB,sBAAsB,QAAuC;CAC3E,MAAM,WAAW,mBAAmB,OAAO,UAAU,OAAO,IAAI;AAEhE,KAAI,OAAO,SAAS,gBAAgB,SAClC,QAAO;EACL,IAAI;EACJ,mBAAmB,OAAO,SAAS;EACnC,qBAAqB;EACtB;AAGH,QAAO;EACL,IAAI;EACJ,QAAQ;EACR,mBAAmB,OAAO,SAAS;EACnC,qBAAqB;EACtB;;;AAIH,eAAsB,gBAAgB,KAAoC;AAExE,QAAO,sBADK,MAAM,qBAAqB,IAAI,CACV"}
@@ -1,160 +0,0 @@
1
- //#region src/errors.ts
2
- /**
3
- * Structured error for migration tooling operations.
4
- *
5
- * Follows the NAMESPACE.SUBCODE convention from ADR 027. All codes live under
6
- * the MIGRATION namespace. These are tooling-time errors (file I/O, attestation,
7
- * migration history reconstruction), distinct from the runtime MIGRATION.* codes for apply-time
8
- * failures (PRECHECK_FAILED, POSTCHECK_FAILED, etc.).
9
- *
10
- * Fields:
11
- * - code: Stable machine-readable code (MIGRATION.SUBCODE)
12
- * - category: Always 'MIGRATION'
13
- * - why: Explains the cause in plain language
14
- * - fix: Actionable remediation step
15
- * - details: Machine-readable structured data for agents
16
- */
17
- var MigrationToolsError = class extends Error {
18
- code;
19
- category = "MIGRATION";
20
- why;
21
- fix;
22
- details;
23
- constructor(code, summary, options) {
24
- super(summary);
25
- this.name = "MigrationToolsError";
26
- this.code = code;
27
- this.why = options.why;
28
- this.fix = options.fix;
29
- this.details = options.details;
30
- }
31
- static is(error) {
32
- if (!(error instanceof Error)) return false;
33
- const candidate = error;
34
- return candidate.name === "MigrationToolsError" && typeof candidate.code === "string";
35
- }
36
- };
37
- function errorDirectoryExists(dir) {
38
- return new MigrationToolsError("MIGRATION.DIR_EXISTS", "Migration directory already exists", {
39
- why: `The directory "${dir}" already exists. Each migration must have a unique directory.`,
40
- fix: "Use --name to pick a different name, or delete the existing directory and re-run.",
41
- details: { dir }
42
- });
43
- }
44
- function errorMissingFile(file, dir) {
45
- return new MigrationToolsError("MIGRATION.FILE_MISSING", `Missing ${file}`, {
46
- why: `Expected "${file}" in "${dir}" but the file does not exist.`,
47
- fix: "Ensure the migration directory contains both migration.json and ops.json. If the directory is corrupt, delete it and re-run migration plan.",
48
- details: {
49
- file,
50
- dir
51
- }
52
- });
53
- }
54
- function errorInvalidJson(filePath, parseError) {
55
- return new MigrationToolsError("MIGRATION.INVALID_JSON", "Invalid JSON in migration file", {
56
- why: `Failed to parse "${filePath}": ${parseError}`,
57
- fix: "Fix the JSON syntax error, or delete the migration directory and re-run migration plan.",
58
- details: {
59
- filePath,
60
- parseError
61
- }
62
- });
63
- }
64
- function errorInvalidManifest(filePath, reason) {
65
- return new MigrationToolsError("MIGRATION.INVALID_MANIFEST", "Invalid migration manifest", {
66
- why: `Manifest at "${filePath}" is invalid: ${reason}`,
67
- fix: "Ensure the manifest has all required fields (from, to, kind, toContract). If corrupt, delete and re-plan.",
68
- details: {
69
- filePath,
70
- reason
71
- }
72
- });
73
- }
74
- function errorInvalidSlug(slug) {
75
- return new MigrationToolsError("MIGRATION.INVALID_NAME", "Invalid migration name", {
76
- why: `The slug "${slug}" contains no valid characters after sanitization (only a-z, 0-9 are kept).`,
77
- fix: "Provide a name with at least one alphanumeric character, e.g. --name add_users.",
78
- details: { slug }
79
- });
80
- }
81
- function errorInvalidDestName(destName) {
82
- return new MigrationToolsError("MIGRATION.INVALID_DEST_NAME", "Invalid copy destination name", {
83
- why: `The destination name "${destName}" must be a single path segment (no ".." or directory separators).`,
84
- fix: "Use a simple file name such as \"contract.json\" for each destination in the copy list.",
85
- details: { destName }
86
- });
87
- }
88
- function errorSameSourceAndTarget(dirName, hash) {
89
- return new MigrationToolsError("MIGRATION.SAME_SOURCE_AND_TARGET", "Migration has same source and target", {
90
- why: `Migration "${dirName}" has from === to === "${hash}". A migration must transition between two different contract states.`,
91
- fix: "Delete the invalid migration directory and re-run migration plan.",
92
- details: {
93
- dirName,
94
- hash
95
- }
96
- });
97
- }
98
- function errorAmbiguousTarget(branchTips, context) {
99
- const divergenceInfo = context ? `\nDivergence point: ${context.divergencePoint}\nBranches:\n${context.branches.map((b) => ` → ${b.tip} (${b.edges.length} edge(s): ${b.edges.map((e) => e.dirName).join(" → ") || "direct"})`).join("\n")}` : "";
100
- return new MigrationToolsError("MIGRATION.AMBIGUOUS_TARGET", "Ambiguous migration target", {
101
- why: `The migration history has diverged into multiple branches: ${branchTips.join(", ")}. This typically happens when two developers plan migrations from the same starting point.${divergenceInfo}`,
102
- fix: "Use `migration ref set <name> <hash>` to target a specific branch, delete one of the conflicting migration directories and re-run `migration plan`, or use --from <hash> to explicitly select a starting point.",
103
- details: {
104
- branchTips,
105
- ...context ? {
106
- divergencePoint: context.divergencePoint,
107
- branches: context.branches
108
- } : {}
109
- }
110
- });
111
- }
112
- function errorNoInitialMigration(nodes) {
113
- return new MigrationToolsError("MIGRATION.NO_INITIAL_MIGRATION", "No initial migration found", {
114
- why: `No migration starts from the empty contract state (known hashes: ${nodes.join(", ")}). At least one migration must originate from the empty state.`,
115
- fix: "Inspect the migrations directory for corrupted migration.json files. At least one migration must start from the empty contract hash.",
116
- details: { nodes }
117
- });
118
- }
119
- function errorInvalidRefs(refsPath, reason) {
120
- return new MigrationToolsError("MIGRATION.INVALID_REFS", "Invalid refs.json", {
121
- why: `refs.json at "${refsPath}" is invalid: ${reason}`,
122
- fix: "Ensure refs.json is a flat object mapping valid ref names to contract hash strings.",
123
- details: {
124
- path: refsPath,
125
- reason
126
- }
127
- });
128
- }
129
- function errorInvalidRefName(refName) {
130
- return new MigrationToolsError("MIGRATION.INVALID_REF_NAME", "Invalid ref name", {
131
- why: `Ref name "${refName}" is invalid. Names must be lowercase alphanumeric with hyphens or forward slashes (no "." or ".." segments).`,
132
- fix: `Use a valid ref name (e.g., "staging", "envs/production").`,
133
- details: { refName }
134
- });
135
- }
136
- function errorNoTarget(reachableHashes) {
137
- return new MigrationToolsError("MIGRATION.NO_TARGET", "No migration target could be resolved", {
138
- why: `The migration history contains cycles and no target can be resolved automatically (reachable hashes: ${reachableHashes.join(", ")}). This typically happens after rollback migrations (e.g., C1→C2→C1).`,
139
- fix: "Use --from <hash> to specify the planning origin explicitly.",
140
- details: { reachableHashes }
141
- });
142
- }
143
- function errorInvalidRefValue(value) {
144
- return new MigrationToolsError("MIGRATION.INVALID_REF_VALUE", "Invalid ref value", {
145
- why: `Ref value "${value}" is not a valid contract hash. Values must be in the format "sha256:<64 hex chars>" or "sha256:empty".`,
146
- fix: "Use a valid storage hash from `prisma-next contract emit` output or an existing migration.",
147
- details: { value }
148
- });
149
- }
150
- function errorDuplicateMigrationId(migrationId) {
151
- return new MigrationToolsError("MIGRATION.DUPLICATE_MIGRATION_ID", "Duplicate migrationId in migration graph", {
152
- why: `Multiple migrations share migrationId "${migrationId}". Each migration must have a unique content-addressed identity.`,
153
- fix: "Regenerate one of the conflicting migrations so each migrationId is unique, then re-run migration commands.",
154
- details: { migrationId }
155
- });
156
- }
157
-
158
- //#endregion
159
- export { errorInvalidDestName as a, errorInvalidRefName as c, errorInvalidSlug as d, errorMissingFile as f, errorSameSourceAndTarget as h, errorDuplicateMigrationId as i, errorInvalidRefValue as l, errorNoTarget as m, errorAmbiguousTarget as n, errorInvalidJson as o, errorNoInitialMigration as p, errorDirectoryExists as r, errorInvalidManifest as s, MigrationToolsError as t, errorInvalidRefs as u };
160
- //# sourceMappingURL=errors-BKbRGCJM.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-BKbRGCJM.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Structured error for migration tooling operations.\n *\n * Follows the NAMESPACE.SUBCODE convention from ADR 027. All codes live under\n * the MIGRATION namespace. These are tooling-time errors (file I/O, attestation,\n * migration history reconstruction), distinct from the runtime MIGRATION.* codes for apply-time\n * failures (PRECHECK_FAILED, POSTCHECK_FAILED, etc.).\n *\n * Fields:\n * - code: Stable machine-readable code (MIGRATION.SUBCODE)\n * - category: Always 'MIGRATION'\n * - why: Explains the cause in plain language\n * - fix: Actionable remediation step\n * - details: Machine-readable structured data for agents\n */\nexport class MigrationToolsError extends Error {\n readonly code: string;\n readonly category = 'MIGRATION' as const;\n readonly why: string;\n readonly fix: string;\n readonly details: Record<string, unknown> | undefined;\n\n constructor(\n code: string,\n summary: string,\n options: {\n readonly why: string;\n readonly fix: string;\n readonly details?: Record<string, unknown>;\n },\n ) {\n super(summary);\n this.name = 'MigrationToolsError';\n this.code = code;\n this.why = options.why;\n this.fix = options.fix;\n this.details = options.details;\n }\n\n static is(error: unknown): error is MigrationToolsError {\n if (!(error instanceof Error)) return false;\n const candidate = error as MigrationToolsError;\n return candidate.name === 'MigrationToolsError' && typeof candidate.code === 'string';\n }\n}\n\nexport function errorDirectoryExists(dir: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.DIR_EXISTS', 'Migration directory already exists', {\n why: `The directory \"${dir}\" already exists. Each migration must have a unique directory.`,\n fix: 'Use --name to pick a different name, or delete the existing directory and re-run.',\n details: { dir },\n });\n}\n\nexport function errorMissingFile(file: string, dir: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.FILE_MISSING', `Missing ${file}`, {\n why: `Expected \"${file}\" in \"${dir}\" but the file does not exist.`,\n fix: 'Ensure the migration directory contains both migration.json and ops.json. If the directory is corrupt, delete it and re-run migration plan.',\n details: { file, dir },\n });\n}\n\nexport function errorInvalidJson(filePath: string, parseError: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_JSON', 'Invalid JSON in migration file', {\n why: `Failed to parse \"${filePath}\": ${parseError}`,\n fix: 'Fix the JSON syntax error, or delete the migration directory and re-run migration plan.',\n details: { filePath, parseError },\n });\n}\n\nexport function errorInvalidManifest(filePath: string, reason: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_MANIFEST', 'Invalid migration manifest', {\n why: `Manifest at \"${filePath}\" is invalid: ${reason}`,\n fix: 'Ensure the manifest has all required fields (from, to, kind, toContract). If corrupt, delete and re-plan.',\n details: { filePath, reason },\n });\n}\n\nexport function errorInvalidSlug(slug: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_NAME', 'Invalid migration name', {\n why: `The slug \"${slug}\" contains no valid characters after sanitization (only a-z, 0-9 are kept).`,\n fix: 'Provide a name with at least one alphanumeric character, e.g. --name add_users.',\n details: { slug },\n });\n}\n\nexport function errorInvalidDestName(destName: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_DEST_NAME', 'Invalid copy destination name', {\n why: `The destination name \"${destName}\" must be a single path segment (no \"..\" or directory separators).`,\n fix: 'Use a simple file name such as \"contract.json\" for each destination in the copy list.',\n details: { destName },\n });\n}\n\nexport function errorSameSourceAndTarget(dirName: string, hash: string): MigrationToolsError {\n return new MigrationToolsError(\n 'MIGRATION.SAME_SOURCE_AND_TARGET',\n 'Migration has same source and target',\n {\n why: `Migration \"${dirName}\" has from === to === \"${hash}\". A migration must transition between two different contract states.`,\n fix: 'Delete the invalid migration directory and re-run migration plan.',\n details: { dirName, hash },\n },\n );\n}\n\nexport function errorAmbiguousTarget(\n branchTips: readonly string[],\n context?: {\n divergencePoint: string;\n branches: readonly {\n tip: string;\n edges: readonly { dirName: string; from: string; to: string }[];\n }[];\n },\n): MigrationToolsError {\n const divergenceInfo = context\n ? `\\nDivergence point: ${context.divergencePoint}\\nBranches:\\n${context.branches.map((b) => ` → ${b.tip} (${b.edges.length} edge(s): ${b.edges.map((e) => e.dirName).join(' → ') || 'direct'})`).join('\\n')}`\n : '';\n return new MigrationToolsError('MIGRATION.AMBIGUOUS_TARGET', 'Ambiguous migration target', {\n why: `The migration history has diverged into multiple branches: ${branchTips.join(', ')}. This typically happens when two developers plan migrations from the same starting point.${divergenceInfo}`,\n fix: 'Use `migration ref set <name> <hash>` to target a specific branch, delete one of the conflicting migration directories and re-run `migration plan`, or use --from <hash> to explicitly select a starting point.',\n details: {\n branchTips,\n ...(context ? { divergencePoint: context.divergencePoint, branches: context.branches } : {}),\n },\n });\n}\n\nexport function errorNoInitialMigration(nodes: readonly string[]): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.NO_INITIAL_MIGRATION', 'No initial migration found', {\n why: `No migration starts from the empty contract state (known hashes: ${nodes.join(', ')}). At least one migration must originate from the empty state.`,\n fix: 'Inspect the migrations directory for corrupted migration.json files. At least one migration must start from the empty contract hash.',\n details: { nodes },\n });\n}\n\nexport function errorInvalidRefs(refsPath: string, reason: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_REFS', 'Invalid refs.json', {\n why: `refs.json at \"${refsPath}\" is invalid: ${reason}`,\n fix: 'Ensure refs.json is a flat object mapping valid ref names to contract hash strings.',\n details: { path: refsPath, reason },\n });\n}\n\nexport function errorInvalidRefFile(filePath: string, reason: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_REF_FILE', 'Invalid ref file', {\n why: `Ref file at \"${filePath}\" is invalid: ${reason}`,\n fix: 'Ensure the ref file contains valid JSON with { \"hash\": \"sha256:<64 hex chars>\", \"invariants\": [\"...\"] }.',\n details: { path: filePath, reason },\n });\n}\n\nexport function errorInvalidRefName(refName: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_REF_NAME', 'Invalid ref name', {\n why: `Ref name \"${refName}\" is invalid. Names must be lowercase alphanumeric with hyphens or forward slashes (no \".\" or \"..\" segments).`,\n fix: `Use a valid ref name (e.g., \"staging\", \"envs/production\").`,\n details: { refName },\n });\n}\n\nexport function errorNoTarget(reachableHashes: readonly string[]): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.NO_TARGET', 'No migration target could be resolved', {\n why: `The migration history contains cycles and no target can be resolved automatically (reachable hashes: ${reachableHashes.join(', ')}). This typically happens after rollback migrations (e.g., C1→C2→C1).`,\n fix: 'Use --from <hash> to specify the planning origin explicitly.',\n details: { reachableHashes },\n });\n}\n\nexport function errorInvalidRefValue(value: string): MigrationToolsError {\n return new MigrationToolsError('MIGRATION.INVALID_REF_VALUE', 'Invalid ref value', {\n why: `Ref value \"${value}\" is not a valid contract hash. Values must be in the format \"sha256:<64 hex chars>\" or \"sha256:empty\".`,\n fix: 'Use a valid storage hash from `prisma-next contract emit` output or an existing migration.',\n details: { value },\n });\n}\n\nexport function errorDuplicateMigrationId(migrationId: string): MigrationToolsError {\n return new MigrationToolsError(\n 'MIGRATION.DUPLICATE_MIGRATION_ID',\n 'Duplicate migrationId in migration graph',\n {\n why: `Multiple migrations share migrationId \"${migrationId}\". Each migration must have a unique content-addressed identity.`,\n fix: 'Regenerate one of the conflicting migrations so each migrationId is unique, then re-run migration commands.',\n details: { migrationId },\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,AAAS;CACT,AAAS,WAAW;CACpB,AAAS;CACT,AAAS;CACT,AAAS;CAET,YACE,MACA,SACA,SAKA;AACA,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,QAAQ;AACnB,OAAK,UAAU,QAAQ;;CAGzB,OAAO,GAAG,OAA8C;AACtD,MAAI,EAAE,iBAAiB,OAAQ,QAAO;EACtC,MAAM,YAAY;AAClB,SAAO,UAAU,SAAS,yBAAyB,OAAO,UAAU,SAAS;;;AAIjF,SAAgB,qBAAqB,KAAkC;AACrE,QAAO,IAAI,oBAAoB,wBAAwB,sCAAsC;EAC3F,KAAK,kBAAkB,IAAI;EAC3B,KAAK;EACL,SAAS,EAAE,KAAK;EACjB,CAAC;;AAGJ,SAAgB,iBAAiB,MAAc,KAAkC;AAC/E,QAAO,IAAI,oBAAoB,0BAA0B,WAAW,QAAQ;EAC1E,KAAK,aAAa,KAAK,QAAQ,IAAI;EACnC,KAAK;EACL,SAAS;GAAE;GAAM;GAAK;EACvB,CAAC;;AAGJ,SAAgB,iBAAiB,UAAkB,YAAyC;AAC1F,QAAO,IAAI,oBAAoB,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gB,wBAAwB,OAA+C;AACrF,QAAO,IAAI,oBAAoB,kCAAkC,8BAA8B;EAC7F,KAAK,oEAAoE,MAAM,KAAK,KAAK,CAAC;EAC1F,KAAK;EACL,SAAS,EAAE,OAAO;EACnB,CAAC;;AAGJ,SAAgB,iBAAiB,UAAkB,QAAqC;AACtF,QAAO,IAAI,oBAAoB,0BAA0B,qBAAqB;EAC5E,KAAK,iBAAiB,SAAS,gBAAgB;EAC/C,KAAK;EACL,SAAS;GAAE,MAAM;GAAU;GAAQ;EACpC,CAAC;;AAWJ,SAAgB,oBAAoB,SAAsC;AACxE,QAAO,IAAI,oBAAoB,8BAA8B,oBAAoB;EAC/E,KAAK,aAAa,QAAQ;EAC1B,KAAK;EACL,SAAS,EAAE,SAAS;EACrB,CAAC;;AAGJ,SAAgB,cAAc,iBAAyD;AACrF,QAAO,IAAI,oBAAoB,uBAAuB,yCAAyC;EAC7F,KAAK,wGAAwG,gBAAgB,KAAK,KAAK,CAAC;EACxI,KAAK;EACL,SAAS,EAAE,iBAAiB;EAC7B,CAAC;;AAGJ,SAAgB,qBAAqB,OAAoC;AACvE,QAAO,IAAI,oBAAoB,+BAA+B,qBAAqB;EACjF,KAAK,cAAc,MAAM;EACzB,KAAK;EACL,SAAS,EAAE,OAAO;EACnB,CAAC;;AAGJ,SAAgB,0BAA0B,aAA0C;AAClF,QAAO,IAAI,oBACT,oCACA,4CACA;EACE,KAAK,0CAA0C,YAAY;EAC3D,KAAK;EACL,SAAS,EAAE,aAAa;EACzB,CACF"}
@@ -1,37 +0,0 @@
1
- import { a as MigrationManifest, o as MigrationOps, t as MigrationBundle } from "../types-DyGXcWWp.mjs";
2
-
3
- //#region src/attestation.d.ts
4
- interface VerifyResult {
5
- readonly ok: boolean;
6
- readonly reason?: 'mismatch';
7
- readonly storedMigrationId?: string;
8
- readonly computedMigrationId?: string;
9
- }
10
- /**
11
- * Content-addressed migration identity over (manifest envelope sans
12
- * contracts/hints, ops). See ADR 199 "Storage-only migration identity"
13
- * for the rationale: contracts are anchored separately by the
14
- * storage-hash bookends inside the envelope; planner hints are advisory
15
- * and must not affect identity.
16
- *
17
- * The `migrationId` field on the manifest is stripped before hashing so
18
- * the function can be used both at write time (when no id exists yet)
19
- * and at verify time (rehashing an already-attested manifest).
20
- */
21
- declare function computeMigrationId(manifest: Omit<MigrationManifest, 'migrationId'> & {
22
- readonly migrationId?: string;
23
- }, ops: MigrationOps): string;
24
- /**
25
- * Re-hash an on-disk migration bundle and compare against the stored
26
- * `migrationId`. Returns `{ ok: true }` when the package is internally
27
- * consistent (manifest + ops still produce the recorded id), or
28
- * `{ ok: false, reason: 'mismatch', stored, computed }` when they do
29
- * not — typically a sign of FS corruption, partial writes, or a
30
- * post-emit hand edit.
31
- */
32
- declare function verifyMigrationBundle(bundle: MigrationBundle): VerifyResult;
33
- /** Convenience wrapper: read the package from disk then verify it. */
34
- declare function verifyMigration(dir: string): Promise<VerifyResult>;
35
- //#endregion
36
- export { type VerifyResult, computeMigrationId, verifyMigration, verifyMigrationBundle };
37
- //# sourceMappingURL=attestation.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attestation.d.mts","names":[],"sources":["../../src/attestation.ts"],"sourcesContent":[],"mappings":";;;UAKiB,YAAA;;EAAA,SAAA,MAAY,CAAA,EAAA,UAAA;EAsBb,SAAA,iBAAkB,CAAA,EAAA,MAAA;EACjB,SAAA,mBAAA,CAAA,EAAA,MAAA;;;;AA6BjB;AAoBA;;;;;;;;iBAlDgB,kBAAA,WACJ,KAAK;;QACV;;;;;;;;;iBA4BS,qBAAA,SAA8B,kBAAkB;;iBAoB1C,eAAA,eAA8B,QAAQ"}
@@ -1,4 +0,0 @@
1
- import "../io-CCnYsUHU.mjs";
2
- import { n as verifyMigration, r as verifyMigrationBundle, t as computeMigrationId } from "../attestation-DtF8tEOM.mjs";
3
-
4
- export { computeMigrationId, verifyMigration, verifyMigrationBundle };
@@ -1 +0,0 @@
1
- {"version":3,"file":"dag.d.mts","names":[],"sources":["../../src/dag.ts"],"sourcesContent":[],"mappings":";;;iBAgCgB,gBAAA,oBAAoC,oBAAoB;;AAAxE;AAmFA;AAyCA;AAaA;AA8FA;AAkBA;AAwCA;AAQgB,iBAtNA,QAAA,CAsNoB,KAAA,EArN3B,cAqNyC,EAAA,QAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAAA,SAlNtC,mBAkNsC,EAAA,GAAA,IAAA;AA8DlC,UA3OC,YAAA,CA2OY;kCA1OK;;;;;;;;;;;iBAYlB,oBAAA,QACP,qEAIN;;;;;iBAyFa,mBAAA,QAA2B;;;;;;;;;iBAkB3B,QAAA,QAAgB;;;;;;iBAwChB,mBAAA,QAA2B,iBAAiB;iBAQ5C,YAAA,QAAoB;iBA8DpB,aAAA,QAAqB,0BAA0B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dag.mjs","names":["migration: MigrationChainEntry","LABEL_PRIORITY: Record<string, number>","path: MigrationChainEntry[]","tieBreakReasons: string[]","leaves: string[]","cycles: string[][]","stack: Frame[]","cycle: string[]","startNodes: string[]","orphans: MigrationChainEntry[]"],"sources":["../../src/queue.ts","../../src/graph-ops.ts","../../src/dag.ts"],"sourcesContent":["/**\n * FIFO queue with amortised O(1) push and shift.\n *\n * Uses a head-index cursor over a backing array rather than\n * `Array.prototype.shift()`, which is O(n) on V8. Intended for BFS-shaped\n * traversals where the queue is drained in a single pass — it does not\n * reclaim memory for already-shifted items, so it is not suitable for\n * long-lived queues with many push/shift cycles.\n */\nexport class Queue<T> {\n private readonly items: T[];\n private head = 0;\n\n constructor(initial: Iterable<T> = []) {\n this.items = [...initial];\n }\n\n push(item: T): void {\n this.items.push(item);\n }\n\n /**\n * Remove and return the next item. Caller must check `isEmpty` first —\n * shifting an empty queue throws.\n */\n shift(): T {\n if (this.head >= this.items.length) {\n throw new Error('Queue.shift called on empty queue');\n }\n // biome-ignore lint/style/noNonNullAssertion: bounds-checked on the line above\n return this.items[this.head++]!;\n }\n\n get isEmpty(): boolean {\n return this.head >= this.items.length;\n }\n}\n","import { Queue } from './queue';\n\n/**\n * One step of a BFS traversal.\n *\n * `parent` and `incomingEdge` are `null` for start nodes — they were not\n * reached via any edge. For every other node they record the node and edge\n * by which this node was first reached.\n */\nexport interface BfsStep<E> {\n readonly node: string;\n readonly parent: string | null;\n readonly incomingEdge: E | null;\n}\n\n/**\n * Generic breadth-first traversal.\n *\n * Direction (forward/reverse) is expressed by the caller's `neighbours`\n * closure: return `{ next, edge }` pairs where `next` is the node to visit\n * next and `edge` is the edge that connects them. Callers that don't need\n * path reconstruction can ignore the `parent`/`incomingEdge` fields of each\n * yielded step.\n *\n * Stops are intrinsic — callers `break` out of the `for..of` loop when\n * they've found what they're looking for.\n *\n * `ordering`, if provided, controls the order in which neighbours of each\n * node are enqueued. Only matters for path-finding: a deterministic ordering\n * makes BFS return a deterministic shortest path when multiple exist.\n */\nexport function* bfs<E>(\n starts: Iterable<string>,\n neighbours: (node: string) => Iterable<{ next: string; edge: E }>,\n ordering?: (items: readonly { next: string; edge: E }[]) => readonly { next: string; edge: E }[],\n): Generator<BfsStep<E>> {\n const visited = new Set<string>();\n const parentMap = new Map<string, { parent: string; edge: E }>();\n const queue = new Queue<string>();\n for (const start of starts) {\n if (!visited.has(start)) {\n visited.add(start);\n queue.push(start);\n }\n }\n while (!queue.isEmpty) {\n const current = queue.shift();\n const parentInfo = parentMap.get(current);\n yield {\n node: current,\n parent: parentInfo?.parent ?? null,\n incomingEdge: parentInfo?.edge ?? null,\n };\n\n const items = neighbours(current);\n const toVisit = ordering ? ordering([...items]) : items;\n for (const { next, edge } of toVisit) {\n if (!visited.has(next)) {\n visited.add(next);\n parentMap.set(next, { parent: current, edge });\n queue.push(next);\n }\n }\n }\n}\n","import { ifDefined } from '@prisma-next/utils/defined';\nimport { EMPTY_CONTRACT_HASH } from './constants';\nimport {\n errorAmbiguousTarget,\n errorDuplicateMigrationId,\n errorNoInitialMigration,\n errorNoTarget,\n errorSameSourceAndTarget,\n} from './errors';\nimport { bfs } from './graph-ops';\nimport type { MigrationBundle, MigrationChainEntry, MigrationGraph } from './types';\n\n/** Forward-edge neighbours for BFS: edge `e` from `n` visits `e.to` next. */\nfunction forwardNeighbours(graph: MigrationGraph, node: string) {\n return (graph.forwardChain.get(node) ?? []).map((edge) => ({ next: edge.to, edge }));\n}\n\n/** Reverse-edge neighbours for BFS: edge `e` from `n` visits `e.from` next. */\nfunction reverseNeighbours(graph: MigrationGraph, node: string) {\n return (graph.reverseChain.get(node) ?? []).map((edge) => ({ next: edge.from, edge }));\n}\n\nfunction appendEdge(\n map: Map<string, MigrationChainEntry[]>,\n key: string,\n entry: MigrationChainEntry,\n): void {\n const bucket = map.get(key);\n if (bucket) bucket.push(entry);\n else map.set(key, [entry]);\n}\n\nexport function reconstructGraph(packages: readonly MigrationBundle[]): MigrationGraph {\n const nodes = new Set<string>();\n const forwardChain = new Map<string, MigrationChainEntry[]>();\n const reverseChain = new Map<string, MigrationChainEntry[]>();\n const migrationById = new Map<string, MigrationChainEntry>();\n\n for (const pkg of packages) {\n const { from, to } = pkg.manifest;\n\n if (from === to) {\n throw errorSameSourceAndTarget(pkg.dirName, from);\n }\n\n nodes.add(from);\n nodes.add(to);\n\n const migration: MigrationChainEntry = {\n from,\n to,\n migrationId: pkg.manifest.migrationId,\n dirName: pkg.dirName,\n createdAt: pkg.manifest.createdAt,\n labels: pkg.manifest.labels,\n };\n\n if (migrationById.has(migration.migrationId)) {\n throw errorDuplicateMigrationId(migration.migrationId);\n }\n migrationById.set(migration.migrationId, migration);\n\n appendEdge(forwardChain, from, migration);\n appendEdge(reverseChain, to, migration);\n }\n\n return { nodes, forwardChain, reverseChain, migrationById };\n}\n\n// ---------------------------------------------------------------------------\n// Deterministic tie-breaking for BFS neighbour order.\n// Used by `findPath` and `findPathWithDecision` only; not a general-purpose\n// utility. Ordering: label priority → createdAt → to → migrationId.\n// ---------------------------------------------------------------------------\n\nconst LABEL_PRIORITY: Record<string, number> = { main: 0, default: 1, feature: 2 };\n\nfunction labelPriority(labels: readonly string[]): number {\n let best = 3;\n for (const l of labels) {\n const p = LABEL_PRIORITY[l];\n if (p !== undefined && p < best) best = p;\n }\n return best;\n}\n\nfunction compareTieBreak(a: MigrationChainEntry, b: MigrationChainEntry): number {\n const lp = labelPriority(a.labels) - labelPriority(b.labels);\n if (lp !== 0) return lp;\n const ca = a.createdAt.localeCompare(b.createdAt);\n if (ca !== 0) return ca;\n const tc = a.to.localeCompare(b.to);\n if (tc !== 0) return tc;\n return a.migrationId.localeCompare(b.migrationId);\n}\n\nfunction sortedNeighbors(edges: readonly MigrationChainEntry[]): readonly MigrationChainEntry[] {\n return [...edges].sort(compareTieBreak);\n}\n\n/** Ordering adapter for `bfs` — sorts `{next, edge}` pairs by tie-break. */\nfunction bfsOrdering(\n items: readonly { next: string; edge: MigrationChainEntry }[],\n): readonly { next: string; edge: MigrationChainEntry }[] {\n return items.slice().sort((a, b) => compareTieBreak(a.edge, b.edge));\n}\n\n/**\n * Find the shortest path from `fromHash` to `toHash` using BFS over the\n * contract-hash graph. Returns the ordered list of edges, or null if no path\n * exists. Returns an empty array when `fromHash === toHash` (no-op).\n *\n * Neighbor ordering is deterministic via the tie-break sort key:\n * label priority → createdAt → to → migrationId.\n */\nexport function findPath(\n graph: MigrationGraph,\n fromHash: string,\n toHash: string,\n): readonly MigrationChainEntry[] | null {\n if (fromHash === toHash) return [];\n\n const parents = new Map<string, { parent: string; edge: MigrationChainEntry }>();\n for (const step of bfs([fromHash], (n) => forwardNeighbours(graph, n), bfsOrdering)) {\n if (step.parent !== null && step.incomingEdge !== null) {\n parents.set(step.node, { parent: step.parent, edge: step.incomingEdge });\n }\n if (step.node === toHash) {\n const path: MigrationChainEntry[] = [];\n let cur = toHash;\n let p = parents.get(cur);\n while (p) {\n path.push(p.edge);\n cur = p.parent;\n p = parents.get(cur);\n }\n path.reverse();\n return path;\n }\n }\n\n return null;\n}\n\n/**\n * Reverse-BFS from `toHash` over `reverseChain` to collect every node from\n * which `toHash` is reachable (inclusive of `toHash` itself).\n */\nfunction collectNodesReachingTarget(graph: MigrationGraph, toHash: string): Set<string> {\n const reached = new Set<string>();\n for (const step of bfs([toHash], (n) => reverseNeighbours(graph, n))) {\n reached.add(step.node);\n }\n return reached;\n}\n\nexport interface PathDecision {\n readonly selectedPath: readonly MigrationChainEntry[];\n readonly fromHash: string;\n readonly toHash: string;\n readonly alternativeCount: number;\n readonly tieBreakReasons: readonly string[];\n readonly refName?: string;\n}\n\n/**\n * Find the shortest path from `fromHash` to `toHash` and return structured\n * path-decision metadata for machine-readable output.\n */\nexport function findPathWithDecision(\n graph: MigrationGraph,\n fromHash: string,\n toHash: string,\n refName?: string,\n): PathDecision | null {\n if (fromHash === toHash) {\n return {\n selectedPath: [],\n fromHash,\n toHash,\n alternativeCount: 0,\n tieBreakReasons: [],\n ...ifDefined('refName', refName),\n };\n }\n\n const path = findPath(graph, fromHash, toHash);\n if (!path) return null;\n\n // Single reverse BFS marks every node from which `toHash` is reachable.\n // Replaces a per-edge `findPath(e.to, toHash)` call inside the loop below,\n // which made the whole function O(|path| · (V + E)) instead of O(V + E).\n const reachesTarget = collectNodesReachingTarget(graph, toHash);\n\n const tieBreakReasons: string[] = [];\n let alternativeCount = 0;\n\n for (const edge of path) {\n const outgoing = graph.forwardChain.get(edge.from);\n if (outgoing && outgoing.length > 1) {\n const reachable = outgoing.filter((e) => reachesTarget.has(e.to));\n if (reachable.length > 1) {\n alternativeCount += reachable.length - 1;\n const sorted = sortedNeighbors(reachable);\n if (sorted[0] && sorted[0].migrationId === edge.migrationId) {\n if (reachable.some((e) => e.migrationId !== edge.migrationId)) {\n tieBreakReasons.push(\n `at ${edge.from}: ${reachable.length} candidates, selected by tie-break`,\n );\n }\n }\n }\n }\n }\n\n return {\n selectedPath: path,\n fromHash,\n toHash,\n alternativeCount,\n tieBreakReasons,\n ...ifDefined('refName', refName),\n };\n}\n\n/**\n * Walk ancestors of each branch tip back to find the last node\n * that appears on all paths. Returns `fromHash` if no shared ancestor is found.\n */\nfunction findDivergencePoint(\n graph: MigrationGraph,\n fromHash: string,\n leaves: readonly string[],\n): string {\n const ancestorSets = leaves.map((leaf) => {\n const ancestors = new Set<string>();\n for (const step of bfs([leaf], (n) => reverseNeighbours(graph, n))) {\n ancestors.add(step.node);\n }\n return ancestors;\n });\n\n const commonAncestors = [...(ancestorSets[0] ?? [])].filter((node) =>\n ancestorSets.every((s) => s.has(node)),\n );\n\n let deepest = fromHash;\n let deepestDepth = -1;\n for (const ancestor of commonAncestors) {\n const path = findPath(graph, fromHash, ancestor);\n const depth = path ? path.length : 0;\n if (depth > deepestDepth) {\n deepestDepth = depth;\n deepest = ancestor;\n }\n }\n return deepest;\n}\n\n/**\n * Find all branch tips (nodes with no outgoing edges) reachable from\n * `fromHash` via forward edges.\n */\nexport function findReachableLeaves(graph: MigrationGraph, fromHash: string): readonly string[] {\n const leaves: string[] = [];\n for (const step of bfs([fromHash], (n) => forwardNeighbours(graph, n))) {\n if (!graph.forwardChain.get(step.node)?.length) {\n leaves.push(step.node);\n }\n }\n return leaves;\n}\n\n/**\n * Find the target contract hash of the migration graph reachable from\n * EMPTY_CONTRACT_HASH. Returns `null` for a graph that has no target\n * state (either empty, or containing only the root with no outgoing\n * edges). Throws NO_INITIAL_MIGRATION if the graph has nodes but none\n * originate from the empty hash, and AMBIGUOUS_TARGET if multiple\n * branch tips exist.\n */\nexport function findLeaf(graph: MigrationGraph): string | null {\n if (graph.nodes.size === 0) {\n return null;\n }\n\n if (!graph.nodes.has(EMPTY_CONTRACT_HASH)) {\n throw errorNoInitialMigration([...graph.nodes]);\n }\n\n const leaves = findReachableLeaves(graph, EMPTY_CONTRACT_HASH);\n\n if (leaves.length === 0) {\n const reachable = [...graph.nodes].filter((n) => n !== EMPTY_CONTRACT_HASH);\n if (reachable.length > 0) {\n throw errorNoTarget(reachable);\n }\n return null;\n }\n\n if (leaves.length > 1) {\n const divergencePoint = findDivergencePoint(graph, EMPTY_CONTRACT_HASH, leaves);\n const branches = leaves.map((tip) => {\n const path = findPath(graph, divergencePoint, tip);\n return {\n tip,\n edges: (path ?? []).map((e) => ({ dirName: e.dirName, from: e.from, to: e.to })),\n };\n });\n throw errorAmbiguousTarget(leaves, { divergencePoint, branches });\n }\n\n // biome-ignore lint/style/noNonNullAssertion: leaves.length is neither 0 nor >1 per the branches above, so exactly one leaf remains\n return leaves[0]!;\n}\n\n/**\n * Find the latest migration entry by traversing from EMPTY_CONTRACT_HASH\n * to the single target. Returns null for an empty graph.\n * Throws AMBIGUOUS_TARGET if the graph has multiple branch tips.\n */\nexport function findLatestMigration(graph: MigrationGraph): MigrationChainEntry | null {\n const leafHash = findLeaf(graph);\n if (leafHash === null) return null;\n\n const path = findPath(graph, EMPTY_CONTRACT_HASH, leafHash);\n return path?.at(-1) ?? null;\n}\n\nexport function detectCycles(graph: MigrationGraph): readonly string[][] {\n const WHITE = 0;\n const GRAY = 1;\n const BLACK = 2;\n\n const color = new Map<string, number>();\n const parentMap = new Map<string, string | null>();\n const cycles: string[][] = [];\n\n for (const node of graph.nodes) {\n color.set(node, WHITE);\n }\n\n // Iterative three-color DFS. A frame is (node, outgoing edges, next-index).\n interface Frame {\n node: string;\n outgoing: readonly MigrationChainEntry[];\n index: number;\n }\n const stack: Frame[] = [];\n\n function pushFrame(u: string): void {\n color.set(u, GRAY);\n stack.push({ node: u, outgoing: graph.forwardChain.get(u) ?? [], index: 0 });\n }\n\n for (const root of graph.nodes) {\n if (color.get(root) !== WHITE) continue;\n parentMap.set(root, null);\n pushFrame(root);\n\n while (stack.length > 0) {\n // biome-ignore lint/style/noNonNullAssertion: stack.length > 0 should guarantee that this cannot be undefined\n const frame = stack[stack.length - 1]!;\n if (frame.index >= frame.outgoing.length) {\n color.set(frame.node, BLACK);\n stack.pop();\n continue;\n }\n // biome-ignore lint/style/noNonNullAssertion: the early-continue above guarantees frame.index < frame.outgoing.length here, so this is defined\n const edge = frame.outgoing[frame.index++]!;\n const v = edge.to;\n const vColor = color.get(v);\n if (vColor === GRAY) {\n const cycle: string[] = [v];\n let cur = frame.node;\n while (cur !== v) {\n cycle.push(cur);\n cur = parentMap.get(cur) ?? v;\n }\n cycle.reverse();\n cycles.push(cycle);\n } else if (vColor === WHITE) {\n parentMap.set(v, frame.node);\n pushFrame(v);\n }\n }\n }\n\n return cycles;\n}\n\nexport function detectOrphans(graph: MigrationGraph): readonly MigrationChainEntry[] {\n if (graph.nodes.size === 0) return [];\n\n const reachable = new Set<string>();\n const startNodes: string[] = [];\n\n if (graph.forwardChain.has(EMPTY_CONTRACT_HASH)) {\n startNodes.push(EMPTY_CONTRACT_HASH);\n } else {\n const allTargets = new Set<string>();\n for (const edges of graph.forwardChain.values()) {\n for (const edge of edges) {\n allTargets.add(edge.to);\n }\n }\n for (const node of graph.nodes) {\n if (!allTargets.has(node)) {\n startNodes.push(node);\n }\n }\n }\n\n for (const step of bfs(startNodes, (n) => forwardNeighbours(graph, n))) {\n reachable.add(step.node);\n }\n\n const orphans: MigrationChainEntry[] = [];\n for (const [from, migrations] of graph.forwardChain) {\n if (!reachable.has(from)) {\n orphans.push(...migrations);\n }\n }\n\n return orphans;\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,IAAa,QAAb,MAAsB;CACpB,AAAiB;CACjB,AAAQ,OAAO;CAEf,YAAY,UAAuB,EAAE,EAAE;AACrC,OAAK,QAAQ,CAAC,GAAG,QAAQ;;CAG3B,KAAK,MAAe;AAClB,OAAK,MAAM,KAAK,KAAK;;;;;;CAOvB,QAAW;AACT,MAAI,KAAK,QAAQ,KAAK,MAAM,OAC1B,OAAM,IAAI,MAAM,oCAAoC;AAGtD,SAAO,KAAK,MAAM,KAAK;;CAGzB,IAAI,UAAmB;AACrB,SAAO,KAAK,QAAQ,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;ACHnC,UAAiB,IACf,QACA,YACA,UACuB;CACvB,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,4BAAY,IAAI,KAA0C;C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M,QAAQ,IAAI,aAAa,MAAM,kBAAkB,OAAO,EAAE,CAAC,CACpE,WAAU,IAAI,KAAK,KAAK;CAG1B,MAAMC,UAAiC,EAAE;AACzC,MAAK,MAAM,CAAC,MAAM,eAAe,MAAM,aACrC,KAAI,CAAC,UAAU,IAAI,KAAK,CACtB,SAAQ,KAAK,GAAG,WAAW;AAI/B,QAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/errors.ts"],"sourcesContent":[],"mappings":";;;;;;;AAeA;;;;;;;;;;;;cAAa,mBAAA,SAA4B,KAAA;;;;;oBAKrB;;;;uBAQK;;sCAWa"}
@@ -1,3 +0,0 @@
1
- import { t as MigrationToolsError } from "../errors-BKbRGCJM.mjs";
2
-
3
- export { MigrationToolsError };