@prisma-next/migration-tools 0.11.0-dev.59 → 0.11.0-dev.60

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 (62) hide show
  1. package/dist/exports/aggregate.d.mts +7 -7
  2. package/dist/exports/aggregate.mjs +3 -4
  3. package/dist/exports/aggregate.mjs.map +1 -1
  4. package/dist/exports/graph.d.mts +1 -1
  5. package/dist/exports/hash.d.mts +2 -2
  6. package/dist/exports/invariants.d.mts +1 -1
  7. package/dist/exports/io.d.mts +1 -1
  8. package/dist/exports/metadata.d.mts +1 -1
  9. package/dist/exports/migration-graph.d.mts +2 -2
  10. package/dist/exports/migration.d.mts +1 -1
  11. package/dist/exports/package.d.mts +1 -1
  12. package/dist/exports/ref-resolution.d.mts +2 -2
  13. package/dist/exports/ref-resolution.mjs +1 -1
  14. package/dist/exports/refs.d.mts +2 -2
  15. package/dist/exports/refs.mjs +3 -3
  16. package/dist/exports/spaces.d.mts +3 -3
  17. package/dist/exports/spaces.mjs +1 -2
  18. package/dist/exports/spaces.mjs.map +1 -1
  19. package/dist/{graph-BwjwIZmb.d.mts → graph-3dLMZp5l.d.mts} +1 -1
  20. package/dist/{graph-BwjwIZmb.d.mts.map → graph-3dLMZp5l.d.mts.map} +1 -1
  21. package/dist/{io-g7fQCYNJ.d.mts → io-BH4G3F-i.d.mts} +2 -2
  22. package/dist/{io-g7fQCYNJ.d.mts.map → io-BH4G3F-i.d.mts.map} +1 -1
  23. package/dist/{migration-graph-CC7PSXw0.d.mts → migration-graph-CWEM2SLR.d.mts} +3 -3
  24. package/dist/{migration-graph-CC7PSXw0.d.mts.map → migration-graph-CWEM2SLR.d.mts.map} +1 -1
  25. package/dist/{package-C31VGBCK.d.mts → package-Ca-J_z_0.d.mts} +1 -1
  26. package/dist/{package-C31VGBCK.d.mts.map → package-Ca-J_z_0.d.mts.map} +1 -1
  27. package/dist/{verify-contract-spaces-3u7gzhqT.mjs → read-contract-space-contract-TbeXuJXL.mjs} +82 -7
  28. package/dist/read-contract-space-contract-TbeXuJXL.mjs.map +1 -0
  29. package/dist/{refs-Ditzcs06.mjs → refs-C-_WUrPw.mjs} +23 -2
  30. package/dist/{refs-Ditzcs06.mjs.map → refs-C-_WUrPw.mjs.map} +1 -1
  31. package/dist/{refs-BPYU-r14.d.mts → refs-C7wuYFqZ.d.mts} +18 -2
  32. package/dist/refs-C7wuYFqZ.d.mts.map +1 -0
  33. package/dist/{snapshot-CVg78oBp.mjs → snapshot-38tKJ9o9.mjs} +2 -2
  34. package/dist/{snapshot-CVg78oBp.mjs.map → snapshot-38tKJ9o9.mjs.map} +1 -1
  35. package/dist/{verify-contract-spaces-C7EZktZP.d.mts → verify-contract-spaces-BdysZdQk.d.mts} +1 -1
  36. package/dist/{verify-contract-spaces-C7EZktZP.d.mts.map → verify-contract-spaces-BdysZdQk.d.mts.map} +1 -1
  37. package/package.json +6 -18
  38. package/src/exports/refs.ts +3 -0
  39. package/src/refs.ts +27 -0
  40. package/dist/exports/enumerate-migration-spaces.d.mts +0 -53
  41. package/dist/exports/enumerate-migration-spaces.d.mts.map +0 -1
  42. package/dist/exports/enumerate-migration-spaces.mjs +0 -107
  43. package/dist/exports/enumerate-migration-spaces.mjs.map +0 -1
  44. package/dist/exports/migration-list-graph-topology.d.mts +0 -13
  45. package/dist/exports/migration-list-graph-topology.d.mts.map +0 -1
  46. package/dist/exports/migration-list-graph-topology.mjs +0 -105
  47. package/dist/exports/migration-list-graph-topology.mjs.map +0 -1
  48. package/dist/exports/migration-list-types.d.mts +0 -2
  49. package/dist/exports/migration-list-types.mjs +0 -1
  50. package/dist/migration-list-types-B8NY0jQ1.d.mts +0 -23
  51. package/dist/migration-list-types-B8NY0jQ1.d.mts.map +0 -1
  52. package/dist/read-contract-space-contract-BbcST3Lm.mjs +0 -82
  53. package/dist/read-contract-space-contract-BbcST3Lm.mjs.map +0 -1
  54. package/dist/refs-BPYU-r14.d.mts.map +0 -1
  55. package/dist/verify-contract-spaces-3u7gzhqT.mjs.map +0 -1
  56. package/src/enumerate-migration-spaces.ts +0 -127
  57. package/src/exports/enumerate-migration-spaces.ts +0 -4
  58. package/src/exports/migration-list-graph-topology.ts +0 -5
  59. package/src/exports/migration-list-types.ts +0 -5
  60. package/src/migration-list-graph-topology.ts +0 -158
  61. package/src/migration-list-types.ts +0 -21
  62. /package/dist/{metadata-CH3tNNkp.d.mts → metadata-Bp9X04gM.d.mts} +0 -0
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@prisma-next/migration-tools",
3
- "version": "0.11.0-dev.59",
3
+ "version": "0.11.0-dev.60",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "description": "On-disk migration persistence, hash verification, and chain reconstruction for Prisma Next",
8
8
  "dependencies": {
9
- "@prisma-next/contract": "0.11.0-dev.59",
10
- "@prisma-next/framework-components": "0.11.0-dev.59",
11
- "@prisma-next/utils": "0.11.0-dev.59",
9
+ "@prisma-next/contract": "0.11.0-dev.60",
10
+ "@prisma-next/framework-components": "0.11.0-dev.60",
11
+ "@prisma-next/utils": "0.11.0-dev.60",
12
12
  "arktype": "^2.2.0",
13
13
  "pathe": "^2.0.3",
14
14
  "prettier": "^3.8.3"
15
15
  },
16
16
  "devDependencies": {
17
- "@prisma-next/tsconfig": "0.11.0-dev.59",
18
- "@prisma-next/tsdown": "0.11.0-dev.59",
17
+ "@prisma-next/tsconfig": "0.11.0-dev.60",
18
+ "@prisma-next/tsdown": "0.11.0-dev.60",
19
19
  "tsdown": "0.22.0",
20
20
  "typescript": "5.9.3",
21
21
  "vitest": "4.1.6"
@@ -60,18 +60,6 @@
60
60
  "types": "./dist/exports/migration-graph.d.mts",
61
61
  "import": "./dist/exports/migration-graph.mjs"
62
62
  },
63
- "./migration-list-types": {
64
- "types": "./dist/exports/migration-list-types.d.mts",
65
- "import": "./dist/exports/migration-list-types.mjs"
66
- },
67
- "./enumerate-migration-spaces": {
68
- "types": "./dist/exports/enumerate-migration-spaces.d.mts",
69
- "import": "./dist/exports/enumerate-migration-spaces.mjs"
70
- },
71
- "./migration-list-graph-topology": {
72
- "types": "./dist/exports/migration-list-graph-topology.d.mts",
73
- "import": "./dist/exports/migration-list-graph-topology.mjs"
74
- },
75
63
  "./refs": {
76
64
  "types": "./dist/exports/refs.d.mts",
77
65
  "import": "./dist/exports/refs.mjs"
@@ -1,9 +1,12 @@
1
1
  export type { RefEntry, Refs } from '../refs';
2
2
  export {
3
3
  deleteRef,
4
+ HEAD_REF_NAME,
4
5
  readRef,
5
6
  readRefs,
7
+ refsByContractHash,
6
8
  resolveRef,
9
+ resolveRefsByContractHash,
7
10
  validateRefName,
8
11
  validateRefValue,
9
12
  writeRef,
package/src/refs.ts CHANGED
@@ -288,6 +288,33 @@ export async function deleteRef(refsDir: string, name: string): Promise<void> {
288
288
  }
289
289
  }
290
290
 
291
+ /**
292
+ * Index user-authored refs by the contract hash each ref points at.
293
+ * Each bucket is sorted lex-asc for deterministic output.
294
+ */
295
+ export function refsByContractHash(refs: Refs): ReadonlyMap<string, readonly string[]> {
296
+ const byHash = new Map<string, string[]>();
297
+ for (const [name, entry] of Object.entries(refs)) {
298
+ const bucket = byHash.get(entry.hash);
299
+ if (bucket) bucket.push(name);
300
+ else byHash.set(entry.hash, [name]);
301
+ }
302
+ for (const bucket of byHash.values()) {
303
+ bucket.sort();
304
+ }
305
+ return byHash;
306
+ }
307
+
308
+ /**
309
+ * Read `migrations/<space>/refs/*.json` and index by destination hash.
310
+ * Returns an empty map when the refs directory does not exist.
311
+ */
312
+ export async function resolveRefsByContractHash(
313
+ refsDir: string,
314
+ ): Promise<ReadonlyMap<string, readonly string[]>> {
315
+ return refsByContractHash(await readRefs(refsDir));
316
+ }
317
+
291
318
  export function resolveRef(refs: Refs, name: string): RefEntry {
292
319
  if (!validateRefName(name)) {
293
320
  throw errorInvalidRefName(name);
@@ -1,53 +0,0 @@
1
- import { r as MigrationSpaceListEntry } from "../migration-list-types-B8NY0jQ1.mjs";
2
-
3
- //#region src/enumerate-migration-spaces.d.ts
4
- /**
5
- * Index `migrations/<space>/refs/*.json` by the contract hash each ref
6
- * points at, so callers can attach `(ref names)` decorations to every
7
- * row whose destination contract hash matches.
8
- *
9
- * Each bucket is sorted lex-asc to keep rendered output deterministic
10
- * (adjacent rows pointing at the same hash render their ref decorations
11
- * in the same order).
12
- *
13
- * Refs whose hash matches no migration on disk are still indexed; the
14
- * caller decides whether to surface them. Migration rows only carry
15
- * `(refs)` decorations when a matching destination contract hash exists
16
- * on disk — orphan refs are not rendered on any row.
17
- *
18
- * Returns an empty map when the refs directory does not exist
19
- * ({@link readRefs} treats `ENOENT` as "no refs").
20
- */
21
- declare function resolveRefsByContractHash(refsDir: string): Promise<ReadonlyMap<string, readonly string[]>>;
22
- /**
23
- * Enumerate every contract space's on-disk migrations under
24
- * `<projectMigrationsDir>/`. For each valid space directory:
25
- *
26
- * - Loads on-disk packages via {@link readMigrationsDir}.
27
- * - Attaches ref decorations: each migration's `refs[]` lists every ref
28
- * name from `migrations/<spaceId>/refs/*.json` whose hash equals the
29
- * migration's destination contract hash.
30
- * - Sorts migrations within the space by `dirName` descending
31
- * (reverse-filename, latest first).
32
- *
33
- * Contract spaces are returned with {@link APP_SPACE_ID} first when
34
- * present, then the remaining ids lex-asc. A contract-space directory
35
- * that contains no migrations becomes `{ spaceId, migrations: [] }` so
36
- * the renderer's empty-state path can surface it.
37
- *
38
- * Directory entries that are not valid {@link isValidSpaceId} names are
39
- * skipped (a stray non-space directory under `migrations/` does not
40
- * spawn a phantom space entry). Entries whose name appears in
41
- * {@link RESERVED_SPACE_SUBDIR_NAMES} are also skipped — the per-space
42
- * `refs/` subdirectory name shape would otherwise satisfy
43
- * {@link isValidSpaceId} and surface as a phantom contract space.
44
- *
45
- * Returns `[]` when `<projectMigrationsDir>` does not exist — a fresh
46
- * project that has not authored any migration yet.
47
- */
48
- declare function enumerateMigrationSpaces(args: {
49
- readonly projectMigrationsDir: string;
50
- }): Promise<readonly MigrationSpaceListEntry[]>;
51
- //#endregion
52
- export { enumerateMigrationSpaces, resolveRefsByContractHash };
53
- //# sourceMappingURL=enumerate-migration-spaces.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enumerate-migration-spaces.d.mts","names":[],"sources":["../../src/enumerate-migration-spaces.ts"],"mappings":";;;;;AA6BA;;;;;;;;AAEsB;AA8DtB;;;;;;iBAhEsB,yBAAA,CACpB,OAAA,WACC,OAAO,CAAC,WAAA;;;AAgEiC;;;;;;;;;;;;;;;;;;;;;;;;iBAFtB,wBAAA,CAAyB,IAAA;EAAA,SACpC,oBAAA;AAAA,IACP,OAAO,UAAU,uBAAA"}
@@ -1,107 +0,0 @@
1
- import { s as readMigrationsDir } from "../io-BGlPOt9b.mjs";
2
- import { i as readRefs } from "../refs-Ditzcs06.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-3u7gzhqT.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
@@ -1 +0,0 @@
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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.d.ts
4
- type MigrationEdgeKind = 'forward' | 'rollback' | 'self';
5
- interface MigrationListGraphTopology {
6
- readonly kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>;
7
- readonly forwardInDegree: ReadonlyMap<string, number>;
8
- readonly forwardOutDegree: ReadonlyMap<string, number>;
9
- }
10
- declare function classifyMigrationListGraphTopology(entries: readonly MigrationListEntry[]): MigrationListGraphTopology;
11
- //#endregion
12
- export { type MigrationEdgeKind, type MigrationListGraphTopology, classifyMigrationListGraphTopology };
13
- //# sourceMappingURL=migration-list-graph-topology.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migration-list-graph-topology.d.mts","names":[],"sources":["../../src/migration-list-graph-topology.ts"],"mappings":";;;KAGY,iBAAA;AAAA,UAEK,0BAAA;EAAA,SACN,mBAAA,EAAqB,WAAA,SAAoB,iBAAA;EAAA,SACzC,eAAA,EAAiB,WAAA;EAAA,SACjB,gBAAA,EAAkB,WAAA;AAAA;AAAA,iBAqBb,kCAAA,CACd,OAAA,WAAkB,kBAAA,KACjB,0BAA0B"}
@@ -1,105 +0,0 @@
1
- import "../constants-DWV9_o2Z.mjs";
2
- //#region src/migration-list-graph-topology.ts
3
- function canonicalFrom(from) {
4
- return from ?? "sha256:empty";
5
- }
6
- function compareDirNameDesc(a, b) {
7
- return b.dirName.localeCompare(a.dirName);
8
- }
9
- function bumpDegree(map, key) {
10
- map.set(key, (map.get(key) ?? 0) + 1);
11
- }
12
- function classifyMigrationListGraphTopology(entries) {
13
- const nodes = /* @__PURE__ */ new Set();
14
- const kindByMigrationHash = /* @__PURE__ */ new Map();
15
- const outgoingByFrom = /* @__PURE__ */ new Map();
16
- for (const entry of entries) {
17
- const from = canonicalFrom(entry.from);
18
- const to = entry.to;
19
- nodes.add(from);
20
- nodes.add(to);
21
- if (from === to) {
22
- kindByMigrationHash.set(entry.migrationHash, "self");
23
- continue;
24
- }
25
- const bucket = outgoingByFrom.get(from);
26
- const edge = {
27
- entry,
28
- from,
29
- to
30
- };
31
- if (bucket) bucket.push(edge);
32
- else outgoingByFrom.set(from, [edge]);
33
- }
34
- for (const bucket of outgoingByFrom.values()) bucket.sort((a, b) => compareDirNameDesc(a.entry, b.entry));
35
- const nonSelfInDegree = /* @__PURE__ */ new Map();
36
- for (const node of nodes) nonSelfInDegree.set(node, 0);
37
- for (const bucket of outgoingByFrom.values()) for (const edge of bucket) bumpDegree(nonSelfInDegree, edge.to);
38
- const dfsRoots = [];
39
- for (const node of nodes) if ((nonSelfInDegree.get(node) ?? 0) === 0) dfsRoots.push(node);
40
- dfsRoots.sort((a, b) => {
41
- if (a === "sha256:empty") return -1;
42
- if (b === "sha256:empty") return 1;
43
- return a.localeCompare(b);
44
- });
45
- if (dfsRoots.length === 0) dfsRoots.push(...[...nodes].sort((a, b) => a.localeCompare(b)));
46
- const WHITE = 0;
47
- const GRAY = 1;
48
- const BLACK = 2;
49
- const color = /* @__PURE__ */ new Map();
50
- for (const node of nodes) color.set(node, WHITE);
51
- const stack = [];
52
- function pushFrame(node) {
53
- color.set(node, GRAY);
54
- stack.push({
55
- node,
56
- outgoing: outgoingByFrom.get(node) ?? [],
57
- index: 0
58
- });
59
- }
60
- function runDfsFrom(root) {
61
- if (color.get(root) !== WHITE) return;
62
- pushFrame(root);
63
- while (stack.length > 0) {
64
- const frame = stack[stack.length - 1];
65
- if (frame === void 0) break;
66
- if (frame.index >= frame.outgoing.length) {
67
- color.set(frame.node, BLACK);
68
- stack.pop();
69
- continue;
70
- }
71
- const edge = frame.outgoing[frame.index];
72
- frame.index += 1;
73
- if (edge === void 0) continue;
74
- const v = edge.to;
75
- const vColor = color.get(v);
76
- if (vColor === GRAY) kindByMigrationHash.set(edge.entry.migrationHash, "rollback");
77
- else {
78
- kindByMigrationHash.set(edge.entry.migrationHash, "forward");
79
- if (vColor === WHITE) pushFrame(v);
80
- }
81
- }
82
- }
83
- for (const root of dfsRoots) runDfsFrom(root);
84
- const remainingWhite = [...nodes].filter((node) => color.get(node) === WHITE);
85
- remainingWhite.sort((a, b) => a.localeCompare(b));
86
- for (const root of remainingWhite) runDfsFrom(root);
87
- const forwardInDegree = /* @__PURE__ */ new Map();
88
- const forwardOutDegree = /* @__PURE__ */ new Map();
89
- for (const entry of entries) {
90
- if (kindByMigrationHash.get(entry.migrationHash) !== "forward") continue;
91
- const from = canonicalFrom(entry.from);
92
- const to = entry.to;
93
- bumpDegree(forwardOutDegree, from);
94
- bumpDegree(forwardInDegree, to);
95
- }
96
- return {
97
- kindByMigrationHash,
98
- forwardInDegree,
99
- forwardOutDegree
100
- };
101
- }
102
- //#endregion
103
- export { classifyMigrationListGraphTopology };
104
-
105
- //# sourceMappingURL=migration-list-graph-topology.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migration-list-graph-topology.mjs","names":[],"sources":["../../src/migration-list-graph-topology.ts"],"sourcesContent":["import { EMPTY_CONTRACT_HASH } from './constants';\nimport type { MigrationListEntry } from './migration-list-types';\n\nexport type MigrationEdgeKind = 'forward' | 'rollback' | 'self';\n\nexport interface MigrationListGraphTopology {\n readonly kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>;\n readonly forwardInDegree: ReadonlyMap<string, number>;\n readonly forwardOutDegree: ReadonlyMap<string, number>;\n}\n\ninterface NonSelfEdge {\n readonly entry: MigrationListEntry;\n readonly from: string;\n readonly to: string;\n}\n\nfunction canonicalFrom(from: string | null): string {\n return from ?? EMPTY_CONTRACT_HASH;\n}\n\nfunction compareDirNameDesc(a: MigrationListEntry, b: MigrationListEntry): number {\n return b.dirName.localeCompare(a.dirName);\n}\n\nfunction bumpDegree(map: Map<string, number>, key: string): void {\n map.set(key, (map.get(key) ?? 0) + 1);\n}\n\nexport function classifyMigrationListGraphTopology(\n entries: readonly MigrationListEntry[],\n): MigrationListGraphTopology {\n const nodes = new Set<string>();\n const kindByMigrationHash = new Map<string, MigrationEdgeKind>();\n const outgoingByFrom = new Map<string, NonSelfEdge[]>();\n\n for (const entry of entries) {\n const from = canonicalFrom(entry.from);\n const to = entry.to;\n nodes.add(from);\n nodes.add(to);\n\n if (from === to) {\n kindByMigrationHash.set(entry.migrationHash, 'self');\n continue;\n }\n\n const bucket = outgoingByFrom.get(from);\n const edge: NonSelfEdge = { entry, from, to };\n if (bucket) bucket.push(edge);\n else outgoingByFrom.set(from, [edge]);\n }\n\n for (const bucket of outgoingByFrom.values()) {\n bucket.sort((a, b) => compareDirNameDesc(a.entry, b.entry));\n }\n\n const nonSelfInDegree = new Map<string, number>();\n for (const node of nodes) {\n nonSelfInDegree.set(node, 0);\n }\n for (const bucket of outgoingByFrom.values()) {\n for (const edge of bucket) {\n bumpDegree(nonSelfInDegree, edge.to);\n }\n }\n\n const dfsRoots: string[] = [];\n for (const node of nodes) {\n if ((nonSelfInDegree.get(node) ?? 0) === 0) {\n dfsRoots.push(node);\n }\n }\n dfsRoots.sort((a, b) => {\n if (a === EMPTY_CONTRACT_HASH) return -1;\n if (b === EMPTY_CONTRACT_HASH) return 1;\n return a.localeCompare(b);\n });\n if (dfsRoots.length === 0) {\n dfsRoots.push(...[...nodes].sort((a, b) => a.localeCompare(b)));\n }\n\n const WHITE = 0;\n const GRAY = 1;\n const BLACK = 2;\n const color = new Map<string, number>();\n for (const node of nodes) {\n color.set(node, WHITE);\n }\n\n interface Frame {\n node: string;\n outgoing: readonly NonSelfEdge[];\n index: number;\n }\n const stack: Frame[] = [];\n\n function pushFrame(node: string): void {\n color.set(node, GRAY);\n stack.push({ node, outgoing: outgoingByFrom.get(node) ?? [], index: 0 });\n }\n\n function runDfsFrom(root: string): void {\n if (color.get(root) !== WHITE) return;\n pushFrame(root);\n\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame === undefined) break;\n if (frame.index >= frame.outgoing.length) {\n color.set(frame.node, BLACK);\n stack.pop();\n continue;\n }\n\n const edge = frame.outgoing[frame.index];\n frame.index += 1;\n if (edge === undefined) continue;\n\n const v = edge.to;\n const vColor = color.get(v);\n if (vColor === GRAY) {\n kindByMigrationHash.set(edge.entry.migrationHash, 'rollback');\n } else {\n kindByMigrationHash.set(edge.entry.migrationHash, 'forward');\n if (vColor === WHITE) {\n pushFrame(v);\n }\n }\n }\n }\n\n for (const root of dfsRoots) {\n runDfsFrom(root);\n }\n const remainingWhite = [...nodes].filter((node) => color.get(node) === WHITE);\n remainingWhite.sort((a, b) => a.localeCompare(b));\n for (const root of remainingWhite) {\n runDfsFrom(root);\n }\n\n const forwardInDegree = new Map<string, number>();\n const forwardOutDegree = new Map<string, number>();\n\n for (const entry of entries) {\n if (kindByMigrationHash.get(entry.migrationHash) !== 'forward') continue;\n const from = canonicalFrom(entry.from);\n const to = entry.to;\n bumpDegree(forwardOutDegree, from);\n bumpDegree(forwardInDegree, to);\n }\n\n return {\n kindByMigrationHash,\n forwardInDegree,\n forwardOutDegree,\n };\n}\n"],"mappings":";;AAiBA,SAAS,cAAc,MAA6B;CAClD,OAAO,QAAA;AACT;AAEA,SAAS,mBAAmB,GAAuB,GAA+B;CAChF,OAAO,EAAE,QAAQ,cAAc,EAAE,OAAO;AAC1C;AAEA,SAAS,WAAW,KAA0B,KAAmB;CAC/D,IAAI,IAAI,MAAM,IAAI,IAAI,GAAG,KAAK,KAAK,CAAC;AACtC;AAEA,SAAgB,mCACd,SAC4B;CAC5B,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,sCAAsB,IAAI,IAA+B;CAC/D,MAAM,iCAAiB,IAAI,IAA2B;CAEtD,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,cAAc,MAAM,IAAI;EACrC,MAAM,KAAK,MAAM;EACjB,MAAM,IAAI,IAAI;EACd,MAAM,IAAI,EAAE;EAEZ,IAAI,SAAS,IAAI;GACf,oBAAoB,IAAI,MAAM,eAAe,MAAM;GACnD;EACF;EAEA,MAAM,SAAS,eAAe,IAAI,IAAI;EACtC,MAAM,OAAoB;GAAE;GAAO;GAAM;EAAG;EAC5C,IAAI,QAAQ,OAAO,KAAK,IAAI;OACvB,eAAe,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SAAS,MAAM,SAAS,QAAQ;IACxC,MAAM,IAAI,MAAM,MAAM,KAAK;IAC3B,MAAM,IAAI;IACV;GACF;GAEA,MAAM,OAAO,MAAM,SAAS,MAAM;GAClC,MAAM,SAAS;GACf,IAAI,SAAS,KAAA,GAAW;GAExB,MAAM,IAAI,KAAK;GACf,MAAM,SAAS,MAAM,IAAI,CAAC;GAC1B,IAAI,WAAW,MACb,oBAAoB,IAAI,KAAK,MAAM,eAAe,UAAU;QACvD;IACL,oBAAoB,IAAI,KAAK,MAAM,eAAe,SAAS;IAC3D,IAAI,WAAW,OACb,UAAU,CAAC;GAEf;EACF;CACF;CAEA,KAAK,MAAM,QAAQ,UACjB,WAAW,IAAI;CAEjB,MAAM,iBAAiB,CAAC,GAAG,KAAK,EAAE,QAAQ,SAAS,MAAM,IAAI,IAAI,MAAM,KAAK;CAC5E,eAAe,MAAM,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;CAChD,KAAK,MAAM,QAAQ,gBACjB,WAAW,IAAI;CAGjB,MAAM,kCAAkB,IAAI,IAAoB;CAChD,MAAM,mCAAmB,IAAI,IAAoB;CAEjD,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,oBAAoB,IAAI,MAAM,aAAa,MAAM,WAAW;EAChE,MAAM,OAAO,cAAc,MAAM,IAAI;EACrC,MAAM,KAAK,MAAM;EACjB,WAAW,kBAAkB,IAAI;EACjC,WAAW,iBAAiB,EAAE;CAChC;CAEA,OAAO;EACL;EACA;EACA;CACF;AACF"}
@@ -1,2 +0,0 @@
1
- import { n as MigrationListResult, r as MigrationSpaceListEntry, t as MigrationListEntry } from "../migration-list-types-B8NY0jQ1.mjs";
2
- export { type MigrationListEntry, type MigrationListResult, type MigrationSpaceListEntry };
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- //#region src/migration-list-types.d.ts
2
- interface MigrationListEntry {
3
- readonly dirName: string;
4
- readonly from: string | null;
5
- readonly to: string;
6
- readonly migrationHash: string;
7
- readonly operationCount: number;
8
- readonly createdAt: string;
9
- readonly refs: readonly string[];
10
- readonly providedInvariants: readonly string[];
11
- }
12
- interface MigrationSpaceListEntry {
13
- readonly spaceId: string;
14
- readonly migrations: readonly MigrationListEntry[];
15
- }
16
- interface MigrationListResult {
17
- readonly ok: true;
18
- readonly spaces: readonly MigrationSpaceListEntry[];
19
- readonly summary: string;
20
- }
21
- //#endregion
22
- export { MigrationListResult as n, MigrationSpaceListEntry as r, MigrationListEntry as t };
23
- //# sourceMappingURL=migration-list-types-B8NY0jQ1.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migration-list-types-B8NY0jQ1.d.mts","names":[],"sources":["../src/migration-list-types.ts"],"mappings":";UAAiB,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,aAAA;EAAA,SACA,cAAA;EAAA,SACA,SAAA;EAAA,SACA,IAAA;EAAA,SACA,kBAAA;AAAA;AAAA,UAGM,uBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA,WAAqB,kBAAkB;AAAA;AAAA,UAGjC,mBAAA;EAAA,SACN,EAAA;EAAA,SACA,MAAA,WAAiB,uBAAuB;EAAA,SACxC,OAAA;AAAA"}
@@ -1,82 +0,0 @@
1
- import { f as errorInvalidJson, h as errorInvalidRefFile, x as errorMissingFile } from "./errors-vFROOhCR.mjs";
2
- import { c as spaceMigrationDirectory, l as spaceRefsDirectory, o as assertValidSpaceId } from "./verify-contract-spaces-3u7gzhqT.mjs";
3
- import { join } from "pathe";
4
- import { readFile } from "node:fs/promises";
5
- //#region src/read-contract-space-head-ref.ts
6
- function hasErrnoCode$1(error, code) {
7
- return error instanceof Error && error.code === code;
8
- }
9
- /**
10
- * Read the head ref (`hash` + `invariants`) for a contract space from
11
- * `<projectMigrationsDir>/<spaceId>/refs/head.json`.
12
- *
13
- * Returns `null` when the file does not exist (first emit). Surfaces
14
- * `MIGRATION.INVALID_JSON` / `MIGRATION.INVALID_REF_FILE` on a corrupt
15
- * `refs/head.json` so callers can distinguish "no head ref on disk"
16
- * (returns `null`) from "head ref present but unreadable" (throws).
17
- *
18
- * Validates the space id against `[a-z][a-z0-9_-]{0,63}` for the same
19
- * filesystem-safety reasons as the rest of the per-space helpers. The
20
- * helper is uniform across the app and extension spaces.
21
- */
22
- async function readContractSpaceHeadRef(projectMigrationsDir, spaceId) {
23
- assertValidSpaceId(spaceId);
24
- const filePath = join(spaceRefsDirectory(spaceMigrationDirectory(projectMigrationsDir, spaceId)), "head.json");
25
- let raw;
26
- try {
27
- raw = await readFile(filePath, "utf-8");
28
- } catch (error) {
29
- if (hasErrnoCode$1(error, "ENOENT")) return null;
30
- throw error;
31
- }
32
- let parsed;
33
- try {
34
- parsed = JSON.parse(raw);
35
- } catch (e) {
36
- throw errorInvalidJson(filePath, e instanceof Error ? e.message : String(e));
37
- }
38
- if (typeof parsed !== "object" || parsed === null) throw errorInvalidRefFile(filePath, "expected an object");
39
- const obj = parsed;
40
- if (typeof obj.hash !== "string") throw errorInvalidRefFile(filePath, "expected an object with a string `hash` field");
41
- if (!Array.isArray(obj.invariants) || obj.invariants.some((value) => typeof value !== "string")) throw errorInvalidRefFile(filePath, "expected an object with an `invariants` array of strings");
42
- return {
43
- hash: obj.hash,
44
- invariants: obj.invariants
45
- };
46
- }
47
- //#endregion
48
- //#region src/read-contract-space-contract.ts
49
- function hasErrnoCode(error, code) {
50
- return error instanceof Error && error.code === code;
51
- }
52
- /**
53
- * Read the on-disk contract value for a contract space
54
- * (`<projectMigrationsDir>/<spaceId>/contract.json`). Returns the parsed
55
- * JSON value as `unknown` — callers that need a typed contract validate
56
- * via their family's `deserializeContract` to surface schema issues.
57
- *
58
- * Companion to {@link import('./read-contract-space-head-ref').readContractSpaceHeadRef}
59
- * — same ENOENT-throws / corrupt-file-error semantics. Returns the
60
- * canonical-JSON value the framework wrote during emit, so re-running
61
- * this helper across machines / runs yields a byte-identical value.
62
- */
63
- async function readContractSpaceContract(projectMigrationsDir, spaceId) {
64
- assertValidSpaceId(spaceId);
65
- const filePath = join(projectMigrationsDir, spaceId, "contract.json");
66
- let raw;
67
- try {
68
- raw = await readFile(filePath, "utf-8");
69
- } catch (error) {
70
- if (hasErrnoCode(error, "ENOENT")) throw errorMissingFile("contract.json", join(projectMigrationsDir, spaceId));
71
- throw error;
72
- }
73
- try {
74
- return JSON.parse(raw);
75
- } catch (e) {
76
- throw errorInvalidJson(filePath, e instanceof Error ? e.message : String(e));
77
- }
78
- }
79
- //#endregion
80
- export { readContractSpaceHeadRef as n, readContractSpaceContract as t };
81
-
82
- //# sourceMappingURL=read-contract-space-contract-BbcST3Lm.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-contract-space-contract-BbcST3Lm.mjs","names":["hasErrnoCode"],"sources":["../src/read-contract-space-head-ref.ts","../src/read-contract-space-contract.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { ContractSpaceHeadRef } from '@prisma-next/framework-components/control';\nimport { join } from 'pathe';\nimport { errorInvalidJson, errorInvalidRefFile } from './errors';\nimport { assertValidSpaceId, spaceMigrationDirectory, spaceRefsDirectory } from './space-layout';\n\nexport type { ContractSpaceHeadRef };\n\nfunction hasErrnoCode(error: unknown, code: string): boolean {\n return error instanceof Error && (error as { code?: string }).code === code;\n}\n\n/**\n * Read the head ref (`hash` + `invariants`) for a contract space from\n * `<projectMigrationsDir>/<spaceId>/refs/head.json`.\n *\n * Returns `null` when the file does not exist (first emit). Surfaces\n * `MIGRATION.INVALID_JSON` / `MIGRATION.INVALID_REF_FILE` on a corrupt\n * `refs/head.json` so callers can distinguish \"no head ref on disk\"\n * (returns `null`) from \"head ref present but unreadable\" (throws).\n *\n * Validates the space id against `[a-z][a-z0-9_-]{0,63}` for the same\n * filesystem-safety reasons as the rest of the per-space helpers. The\n * helper is uniform across the app and extension spaces.\n */\nexport async function readContractSpaceHeadRef(\n projectMigrationsDir: string,\n spaceId: string,\n): Promise<ContractSpaceHeadRef | null> {\n assertValidSpaceId(spaceId);\n\n const filePath = join(\n spaceRefsDirectory(spaceMigrationDirectory(projectMigrationsDir, spaceId)),\n 'head.json',\n );\n\n let raw: string;\n try {\n raw = await readFile(filePath, 'utf-8');\n } catch (error) {\n if (hasErrnoCode(error, 'ENOENT')) {\n return null;\n }\n throw error;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n throw errorInvalidJson(filePath, e instanceof Error ? e.message : String(e));\n }\n\n if (typeof parsed !== 'object' || parsed === null) {\n throw errorInvalidRefFile(filePath, 'expected an object');\n }\n const obj = parsed as { hash?: unknown; invariants?: unknown };\n if (typeof obj.hash !== 'string') {\n throw errorInvalidRefFile(filePath, 'expected an object with a string `hash` field');\n }\n if (!Array.isArray(obj.invariants) || obj.invariants.some((value) => typeof value !== 'string')) {\n throw errorInvalidRefFile(filePath, 'expected an object with an `invariants` array of strings');\n }\n\n return { hash: obj.hash, invariants: obj.invariants as readonly string[] };\n}\n","import { readFile } from 'node:fs/promises';\nimport { join } from 'pathe';\nimport { errorInvalidJson, errorMissingFile } from './errors';\nimport { assertValidSpaceId } from './space-layout';\n\nfunction hasErrnoCode(error: unknown, code: string): boolean {\n return error instanceof Error && (error as { code?: string }).code === code;\n}\n\n/**\n * Read the on-disk contract value for a contract space\n * (`<projectMigrationsDir>/<spaceId>/contract.json`). Returns the parsed\n * JSON value as `unknown` — callers that need a typed contract validate\n * via their family's `deserializeContract` to surface schema issues.\n *\n * Companion to {@link import('./read-contract-space-head-ref').readContractSpaceHeadRef}\n * — same ENOENT-throws / corrupt-file-error semantics. Returns the\n * canonical-JSON value the framework wrote during emit, so re-running\n * this helper across machines / runs yields a byte-identical value.\n */\nexport async function readContractSpaceContract(\n projectMigrationsDir: string,\n spaceId: string,\n): Promise<unknown> {\n assertValidSpaceId(spaceId);\n\n const filePath = join(projectMigrationsDir, spaceId, 'contract.json');\n\n let raw: string;\n try {\n raw = await readFile(filePath, 'utf-8');\n } catch (error) {\n if (hasErrnoCode(error, 'ENOENT')) {\n throw errorMissingFile('contract.json', join(projectMigrationsDir, spaceId));\n }\n throw error;\n }\n\n try {\n return JSON.parse(raw);\n } catch (e) {\n throw errorInvalidJson(filePath, e instanceof Error ? e.message : String(e));\n }\n}\n"],"mappings":";;;;;AAQA,SAASA,eAAa,OAAgB,MAAuB;CAC3D,OAAO,iBAAiB,SAAU,MAA4B,SAAS;AACzE;;;;;;;;;;;;;;AAeA,eAAsB,yBACpB,sBACA,SACsC;CACtC,mBAAmB,OAAO;CAE1B,MAAM,WAAW,KACf,mBAAmB,wBAAwB,sBAAsB,OAAO,CAAC,GACzE,WACF;CAEA,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,SAAS,UAAU,OAAO;CACxC,SAAS,OAAO;EACd,IAAIA,eAAa,OAAO,QAAQ,GAC9B,OAAO;EAET,MAAM;CACR;CAEA,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,GAAG;CACzB,SAAS,GAAG;EACV,MAAM,iBAAiB,UAAU,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;CAC7E;CAEA,IAAI,OAAO,WAAW,YAAY,WAAW,MAC3C,MAAM,oBAAoB,UAAU,oBAAoB;CAE1D,MAAM,MAAM;CACZ,IAAI,OAAO,IAAI,SAAS,UACtB,MAAM,oBAAoB,UAAU,+CAA+C;CAErF,IAAI,CAAC,MAAM,QAAQ,IAAI,UAAU,KAAK,IAAI,WAAW,MAAM,UAAU,OAAO,UAAU,QAAQ,GAC5F,MAAM,oBAAoB,UAAU,0DAA0D;CAGhG,OAAO;EAAE,MAAM,IAAI;EAAM,YAAY,IAAI;CAAgC;AAC3E;;;AC5DA,SAAS,aAAa,OAAgB,MAAuB;CAC3D,OAAO,iBAAiB,SAAU,MAA4B,SAAS;AACzE;;;;;;;;;;;;AAaA,eAAsB,0BACpB,sBACA,SACkB;CAClB,mBAAmB,OAAO;CAE1B,MAAM,WAAW,KAAK,sBAAsB,SAAS,eAAe;CAEpE,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,SAAS,UAAU,OAAO;CACxC,SAAS,OAAO;EACd,IAAI,aAAa,OAAO,QAAQ,GAC9B,MAAM,iBAAiB,iBAAiB,KAAK,sBAAsB,OAAO,CAAC;EAE7E,MAAM;CACR;CAEA,IAAI;EACF,OAAO,KAAK,MAAM,GAAG;CACvB,SAAS,GAAG;EACV,MAAM,iBAAiB,UAAU,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;CAC7E;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"refs-BPYU-r14.d.mts","names":[],"sources":["../src/refs.ts"],"mappings":";UAUiB,QAAA;EAAA,SACN,IAAA;EAAA,SACA,UAAU;AAAA;AAAA,KAGT,IAAA,GAAO,QAAA,CAAS,MAAA,SAAe,QAAA;;;;;;;UAe1B,cAAA;EAAA,SACN,OAAA;EAAA,SACA,MAAM;AAAA;AAAA,iBAWD,eAAA,CAAgB,IAAY;AAAA,iBAQ5B,gBAAA,CAAiB,KAAa;AAAA,iBAsBxB,OAAA,CAAQ,OAAA,UAAiB,IAAA,WAAe,OAAO,CAAC,QAAA;AAAA,iBAmChD,QAAA,CAAS,OAAA,WAAkB,OAAO,CAAC,IAAA;AAAA,iBA4HnC,QAAA,CAAS,OAAA,UAAiB,IAAA,UAAc,KAAA,EAAO,QAAA,GAAW,OAAO;AAAA,iBAoBjE,SAAA,CAAU,OAAA,UAAiB,IAAA,WAAe,OAAO;AAAA,iBAsCvD,UAAA,CAAW,IAAA,EAAM,IAAA,EAAM,IAAA,WAAe,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-contract-spaces-3u7gzhqT.mjs","names":[],"sources":["../src/space-layout.ts","../src/verify-contract-spaces.ts"],"sourcesContent":["import { APP_SPACE_ID } from '@prisma-next/framework-components/control';\nimport { join } from 'pathe';\nimport { errorInvalidSpaceId } from './errors';\n\nexport { APP_SPACE_ID };\n\n/**\n * Branded string carrying a compile-time guarantee that the value has\n * been validated by {@link assertValidSpaceId}. Downstream filesystem\n * helpers (e.g. {@link spaceMigrationDirectory}) accept this type to\n * make \"validated\" tracking visible at the type level rather than\n * relying purely on a runtime check.\n */\nexport type ValidSpaceId = string & { readonly __brand: 'ValidSpaceId' };\n\n/**\n * Pattern a contract-space identifier must match. The constraint is\n * filesystem-friendly: lowercase letters / digits / hyphen / underscore,\n * starts with a letter, max 64 characters.\n */\nconst SPACE_ID_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;\n\nexport function isValidSpaceId(spaceId: string): spaceId is ValidSpaceId {\n return SPACE_ID_PATTERN.test(spaceId);\n}\n\nexport function assertValidSpaceId(spaceId: string): asserts spaceId is ValidSpaceId {\n if (!isValidSpaceId(spaceId)) {\n throw errorInvalidSpaceId(spaceId);\n }\n}\n\n/**\n * Resolve the migrations subdirectory for a given contract space.\n *\n * Every contract space — including the app space (default `'app'`) —\n * lands under `<projectMigrationsDir>/<spaceId>/`. The space id is\n * validated against {@link SPACE_ID_PATTERN} because it becomes a\n * filesystem directory name verbatim.\n *\n * `projectMigrationsDir` is the project's top-level `migrations/`\n * directory; the helper does not assume anything about its absolute /\n * relative shape and is symmetric with `pathe.join`.\n */\nexport function spaceMigrationDirectory(projectMigrationsDir: string, spaceId: string): string {\n assertValidSpaceId(spaceId);\n return join(projectMigrationsDir, spaceId);\n}\n\n/**\n * Per-space subdirectory name reserved for the ref store\n * (`migrations/<space>/<SPACE_REFS_DIRNAME>/*.json`). Single source of\n * truth: every helper that composes a per-space refs path imports this\n * constant, and the enumerator uses it (via\n * {@link RESERVED_SPACE_SUBDIR_NAMES}) to exclude reserved names from\n * the contract-space candidate list.\n */\nexport const SPACE_REFS_DIRNAME = 'refs';\n\n/**\n * Names reserved as per-space subdirectories of `migrations/<space>/`.\n * Used by the enumerator to filter contract-space candidates so a\n * reserved name (e.g. a top-level `migrations/refs/` left in the wrong\n * place) is never enumerated as a phantom contract space. Currently\n * holds `SPACE_REFS_DIRNAME`; extend if future per-space layouts add\n * more reserved subdirectories.\n */\nexport const RESERVED_SPACE_SUBDIR_NAMES: ReadonlySet<string> = new Set([SPACE_REFS_DIRNAME]);\n\n/**\n * Resolve the per-space refs directory for `spaceMigrationsDir`\n * (typically the value returned by {@link spaceMigrationDirectory}).\n * Composes the canonical {@link SPACE_REFS_DIRNAME} so callers do not\n * hard-code the literal.\n */\nexport function spaceRefsDirectory(spaceMigrationsDir: string): string {\n return join(spaceMigrationsDir, SPACE_REFS_DIRNAME);\n}\n","import { readdir, stat } from 'node:fs/promises';\nimport { join } from 'pathe';\nimport { MANIFEST_FILE } from './io';\nimport { APP_SPACE_ID } from './space-layout';\n\nfunction hasErrnoCode(error: unknown, code: string): boolean {\n return error instanceof Error && (error as { code?: string }).code === code;\n}\n\n/**\n * List the per-space subdirectories under\n * `<projectRoot>/migrations/`. Returns space-id directory names (sorted\n * alphabetically) — i.e. any non-dot-prefixed subdirectory whose root\n * does **not** contain a `migration.json` manifest. The manifest is the\n * structural marker of a user-authored migration directory (see\n * `readMigrationsDir` in `./io`); directory names themselves belong to\n * the user and are not part of the contract.\n *\n * Returns `[]` if the migrations directory does not exist (greenfield\n * project).\n *\n * Reads only the user's repo. **No descriptor import.** The caller\n * (verifier) feeds the result into {@link verifyContractSpaces} alongside\n * the loaded-space set and the marker rows.\n */\nexport async function listContractSpaceDirectories(\n projectMigrationsDir: string,\n): Promise<readonly string[]> {\n let entries: { readonly name: string; readonly isDirectory: boolean }[];\n try {\n const dirents = await readdir(projectMigrationsDir, { withFileTypes: true });\n entries = dirents.map((d) => ({ name: d.name, isDirectory: d.isDirectory() }));\n } catch (error) {\n if (hasErrnoCode(error, 'ENOENT')) {\n return [];\n }\n throw error;\n }\n\n const namedCandidates = entries\n .filter((e) => e.isDirectory)\n .map((e) => e.name)\n .filter((name) => !name.startsWith('.'))\n .sort();\n\n const manifestChecks = await Promise.all(\n namedCandidates.map(async (name) => {\n try {\n await stat(join(projectMigrationsDir, name, MANIFEST_FILE));\n return { name, isMigrationDir: true };\n } catch (error) {\n if (hasErrnoCode(error, 'ENOENT')) {\n return { name, isMigrationDir: false };\n }\n throw error;\n }\n }),\n );\n\n return manifestChecks.filter((c) => !c.isMigrationDir).map((c) => c.name);\n}\n\n/**\n * On-disk head value (`(hash, invariants)`) for one contract space.\n * The verifier compares this against the marker row for the same space\n * to detect drift between the user-emitted artefacts and the live DB\n * marker.\n */\nexport interface ContractSpaceHeadRecord {\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\n/**\n * Marker row read from `prisma_contract.marker` (one per `space`).\n * Caller resolves these via the family runtime's marker reader before\n * invoking {@link verifyContractSpaces}.\n */\nexport interface SpaceMarkerRecord {\n readonly hash: string;\n readonly invariants: readonly string[];\n}\n\nexport interface VerifyContractSpacesInputs {\n /**\n * Set of contract spaces the project declares: `'app'` plus each\n * extension space in `extensionPacks`. The caller's discovery path\n * never reads the extension descriptor module — it walks the\n * `extensionPacks` configuration in `prisma-next.config.ts` for the\n * space ids.\n */\n readonly loadedSpaces: ReadonlySet<string>;\n\n /**\n * Per-space subdirectories observed under\n * `<projectRoot>/migrations/`. Resolved via\n * {@link listContractSpaceDirectories}.\n */\n readonly spaceDirsOnDisk: readonly string[];\n\n /**\n * Head ref per space, keyed by space id. Caller reads\n * `<projectRoot>/migrations/<space-id>/contract.json` and\n * `<projectRoot>/migrations/<space-id>/refs/head.json` to construct\n * this map. Spaces with no contract-space dir on disk simply omit a\n * map entry.\n */\n readonly headRefsBySpace: ReadonlyMap<string, ContractSpaceHeadRecord>;\n\n /**\n * Marker rows keyed by `space`. Caller reads them from the\n * `prisma_contract.marker` table.\n */\n readonly markerRowsBySpace: ReadonlyMap<string, SpaceMarkerRecord>;\n}\n\nexport type SpaceVerifierViolation =\n | {\n readonly kind: 'declaredButUnmigrated';\n readonly spaceId: string;\n readonly remediation: string;\n }\n | {\n readonly kind: 'orphanMarker';\n readonly spaceId: string;\n readonly remediation: string;\n }\n | {\n readonly kind: 'orphanSpaceDir';\n readonly spaceId: string;\n readonly remediation: string;\n }\n | {\n readonly kind: 'hashMismatch';\n readonly spaceId: string;\n readonly priorHeadHash: string;\n readonly markerHash: string;\n readonly remediation: string;\n }\n | {\n readonly kind: 'invariantsMismatch';\n readonly spaceId: string;\n readonly onDiskInvariants: readonly string[];\n readonly markerInvariants: readonly string[];\n readonly remediation: string;\n };\n\nexport type VerifyContractSpacesResult =\n | { readonly ok: true }\n | { readonly ok: false; readonly violations: readonly SpaceVerifierViolation[] };\n\n/**\n * Pure structural verifier for the per-space mechanism. Aggregates the\n * three orphan / missing checks plus per-space hash and invariant\n * comparison.\n *\n * Algorithm:\n *\n * - For every extension space declared in `loadedSpaces` (`'app'`\n * excluded — the per-space verifier is scoped to extension members;\n * the app is verified through the aggregate path):\n * - If no contract-space dir on disk → `declaredButUnmigrated`.\n * - Else if `markerRowsBySpace` lacks an entry → no violation here;\n * the live-DB compare done outside this helper is where the\n * absence shows up.\n * - Else compare marker hash / invariants vs. on-disk head hash /\n * invariants → `hashMismatch` / `invariantsMismatch` on drift.\n * - For every contract-space dir on disk that is not in `loadedSpaces` →\n * `orphanSpaceDir`.\n * - For every marker row whose `space` is not in `loadedSpaces` →\n * `orphanMarker`. The app-space marker is always loaded (`'app'` is\n * in `loadedSpaces` by definition).\n *\n * Output is deterministic: violations are sorted first by `kind`\n * (`declaredButUnmigrated` → `orphanMarker` → `orphanSpaceDir` →\n * `hashMismatch` → `invariantsMismatch`) then by `spaceId`. Two callers\n * passing equivalent inputs see byte-identical violation lists.\n *\n * Synchronous, pure, no I/O. **Does not import the extension descriptor**\n * (the inputs are pre-resolved by the caller); the verifier reads only\n * the user repo, not `node_modules`.\n */\nexport function verifyContractSpaces(\n inputs: VerifyContractSpacesInputs,\n): VerifyContractSpacesResult {\n const violations: SpaceVerifierViolation[] = [];\n\n for (const spaceId of [...inputs.loadedSpaces].sort()) {\n if (spaceId === APP_SPACE_ID) continue;\n\n if (!inputs.spaceDirsOnDisk.includes(spaceId)) {\n violations.push({\n kind: 'declaredButUnmigrated',\n spaceId,\n remediation: `Extension '${spaceId}' is declared in extensionPacks but has not been emitted; run \\`prisma-next migrate\\`.`,\n });\n continue;\n }\n\n const head = inputs.headRefsBySpace.get(spaceId);\n const marker = inputs.markerRowsBySpace.get(spaceId);\n if (!head || !marker) {\n continue;\n }\n\n if (head.hash !== marker.hash) {\n violations.push({\n kind: 'hashMismatch',\n spaceId,\n priorHeadHash: head.hash,\n markerHash: marker.hash,\n remediation: `Marker row for space '${spaceId}' is keyed at ${marker.hash}, but the on-disk ${join('migrations', spaceId, 'contract.json')} resolves to ${head.hash}. Run \\`prisma-next db update\\` to advance the database, or \\`prisma-next migrate\\` if the descriptor was bumped without re-emitting.`,\n });\n continue;\n }\n\n const onDiskInvariants = [...head.invariants].sort();\n const markerInvariants = new Set(marker.invariants);\n const missing = onDiskInvariants.filter((id) => !markerInvariants.has(id));\n if (missing.length > 0) {\n violations.push({\n kind: 'invariantsMismatch',\n spaceId,\n onDiskInvariants,\n markerInvariants: [...marker.invariants].sort(),\n remediation: `Marker row for space '${spaceId}' is missing invariants [${missing.map((s) => JSON.stringify(s)).join(', ')}]. Run \\`prisma-next db update\\` to apply the corresponding data-transform migrations.`,\n });\n }\n }\n\n for (const dir of [...inputs.spaceDirsOnDisk].sort()) {\n if (!inputs.loadedSpaces.has(dir)) {\n violations.push({\n kind: 'orphanSpaceDir',\n spaceId: dir,\n remediation: `Orphan contract-space directory \\`${join('migrations', dir)}/\\` for an extension not in extensionPacks; remove the directory or re-add the extension.`,\n });\n }\n }\n\n for (const space of [...inputs.markerRowsBySpace.keys()].sort()) {\n if (!inputs.loadedSpaces.has(space)) {\n violations.push({\n kind: 'orphanMarker',\n spaceId: space,\n remediation: `Orphan marker row for space '${space}' (no longer in extensionPacks); remediation: manually delete the row from \\`prisma_contract.marker\\`.`,\n });\n }\n }\n\n if (violations.length === 0) {\n return { ok: true };\n }\n\n const kindOrder: Record<SpaceVerifierViolation['kind'], number> = {\n declaredButUnmigrated: 0,\n orphanMarker: 1,\n orphanSpaceDir: 2,\n hashMismatch: 3,\n invariantsMismatch: 4,\n };\n\n violations.sort((a, b) => {\n const k = kindOrder[a.kind] - kindOrder[b.kind];\n if (k !== 0) return k;\n if (a.spaceId < b.spaceId) return -1;\n if (a.spaceId > b.spaceId) return 1;\n return 0;\n });\n\n return { ok: false, violations };\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,mBAAmB;AAEzB,SAAgB,eAAe,SAA0C;CACvE,OAAO,iBAAiB,KAAK,OAAO;AACtC;AAEA,SAAgB,mBAAmB,SAAkD;CACnF,IAAI,CAAC,eAAe,OAAO,GACzB,MAAM,oBAAoB,OAAO;AAErC;;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,sBAA8B,SAAyB;CAC7F,mBAAmB,OAAO;CAC1B,OAAO,KAAK,sBAAsB,OAAO;AAC3C;;;;;;;;;AAUA,MAAa,qBAAqB;;;;;;;;;AAUlC,MAAa,8BAAmD,IAAI,IAAI,CAAC,kBAAkB,CAAC;;;;;;;AAQ5F,SAAgB,mBAAmB,oBAAoC;CACrE,OAAO,KAAK,oBAAoB,kBAAkB;AACpD;;;ACxEA,SAAS,aAAa,OAAgB,MAAuB;CAC3D,OAAO,iBAAiB,SAAU,MAA4B,SAAS;AACzE;;;;;;;;;;;;;;;;;AAkBA,eAAsB,6BACpB,sBAC4B;CAC5B,IAAI;CACJ,IAAI;EAEF,WAAU,MADY,QAAQ,sBAAsB,EAAE,eAAe,KAAK,CAAC,GACzD,KAAK,OAAO;GAAE,MAAM,EAAE;GAAM,aAAa,EAAE,YAAY;EAAE,EAAE;CAC/E,SAAS,OAAO;EACd,IAAI,aAAa,OAAO,QAAQ,GAC9B,OAAO,CAAC;EAEV,MAAM;CACR;CAEA,MAAM,kBAAkB,QACrB,QAAQ,MAAM,EAAE,WAAW,EAC3B,KAAK,MAAM,EAAE,IAAI,EACjB,QAAQ,SAAS,CAAC,KAAK,WAAW,GAAG,CAAC,EACtC,KA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