prisma-next 0.12.0-dev.22 → 0.12.0-dev.23

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 (43) hide show
  1. package/dist/cli.mjs +6 -6
  2. package/dist/commands/migrate.d.mts +1 -1
  3. package/dist/commands/migration-graph.d.mts +4 -4
  4. package/dist/commands/migration-graph.mjs +164 -1
  5. package/dist/commands/migration-graph.mjs.map +1 -0
  6. package/dist/commands/migration-list.d.mts +3 -3
  7. package/dist/commands/migration-list.d.mts.map +1 -1
  8. package/dist/commands/migration-list.mjs +4 -6
  9. package/dist/commands/migration-list.mjs.map +1 -1
  10. package/dist/commands/migration-log.d.mts +3 -3
  11. package/dist/commands/migration-log.mjs +1 -1
  12. package/dist/commands/migration-plan.d.mts +1 -1
  13. package/dist/commands/migration-plan.mjs +1 -1
  14. package/dist/commands/migration-show.d.mts +1 -1
  15. package/dist/commands/migration-status.d.mts +1 -1
  16. package/dist/commands/ref.d.mts +1 -1
  17. package/dist/commands/telemetry/index.mjs +1 -1
  18. package/dist/exports/control-api.d.mts +1 -1
  19. package/dist/exports/init-output.mjs +1 -1
  20. package/dist/{global-flags-DSkV6iYT.d.mts → global-flags-DG4uY5tV.d.mts} +1 -1
  21. package/dist/{global-flags-DSkV6iYT.d.mts.map → global-flags-DG4uY5tV.d.mts.map} +1 -1
  22. package/dist/{init-S2vxszo_.mjs → init-B6kKrmf7.mjs} +2 -2
  23. package/dist/{init-S2vxszo_.mjs.map → init-B6kKrmf7.mjs.map} +1 -1
  24. package/dist/{migration-graph-CeBB07Cc.mjs → migration-graph-tree-render-BQdhKBO8.mjs} +405 -165
  25. package/dist/migration-graph-tree-render-BQdhKBO8.mjs.map +1 -0
  26. package/dist/{migration-log-Cj-T-r0o.mjs → migration-log-BzPmks3c.mjs} +2 -2
  27. package/dist/{migration-log-Cj-T-r0o.mjs.map → migration-log-BzPmks3c.mjs.map} +1 -1
  28. package/dist/{migration-plan-BQAbZkj_.mjs → migration-plan-CaeKCKp4.mjs} +1 -1
  29. package/dist/{migration-plan-BQAbZkj_.mjs.map → migration-plan-CaeKCKp4.mjs.map} +1 -1
  30. package/dist/{migration-types-Bhmj0RSa.d.mts → migration-types-CAQ-0TEE.d.mts} +1 -1
  31. package/dist/{migration-types-Bhmj0RSa.d.mts.map → migration-types-CAQ-0TEE.d.mts.map} +1 -1
  32. package/dist/{output-BD61elic.mjs → output-CF_hqzI-.mjs} +1 -1
  33. package/dist/{output-BD61elic.mjs.map → output-CF_hqzI-.mjs.map} +1 -1
  34. package/dist/{telemetry-Bu85x2Gy.mjs → telemetry-Q88WHwlv.mjs} +1 -1
  35. package/dist/{telemetry-Bu85x2Gy.mjs.map → telemetry-Q88WHwlv.mjs.map} +1 -1
  36. package/dist/{terminal-ui-BgLiAOYi.d.mts → terminal-ui-C3xGyxW-.d.mts} +1 -1
  37. package/dist/{terminal-ui-BgLiAOYi.d.mts.map → terminal-ui-C3xGyxW-.d.mts.map} +1 -1
  38. package/dist/{types-C8OcDFBe.d.mts → types-DiC683UW.d.mts} +1 -1
  39. package/dist/{types-C8OcDFBe.d.mts.map → types-DiC683UW.d.mts.map} +1 -1
  40. package/package.json +11 -11
  41. package/dist/migration-graph-CeBB07Cc.mjs.map +0 -1
  42. package/dist/migration-list-styler-CsMECsY4.mjs +0 -414
  43. package/dist/migration-list-styler-CsMECsY4.mjs.map +0 -1
@@ -1,414 +0,0 @@
1
- import { bold, cyan, cyanBright, dim, green, yellow } from "colorette";
2
- import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
3
- //#region src/utils/formatters/migration-list-graph-topology.ts
4
- function compareDirNameDesc(a, b) {
5
- return b.dirName.localeCompare(a.dirName);
6
- }
7
- function bumpDegree(map, key) {
8
- map.set(key, (map.get(key) ?? 0) + 1);
9
- }
10
- function compareNodesRootFirst(a, b) {
11
- if (a === EMPTY_CONTRACT_HASH) return -1;
12
- if (b === EMPTY_CONTRACT_HASH) return 1;
13
- return a.localeCompare(b);
14
- }
15
- /**
16
- * Shortest-path distance of each node from the forward roots, over the given
17
- * candidate edges. Roots are the in-degree-0 nodes (baseline first, then lex);
18
- * a rooted component therefore distances every node by how many forward steps
19
- * it sits from a root. A component with no root (a pure cycle) is seeded from
20
- * its single lexically-smallest node so the cycle still gets a stable layering.
21
- *
22
- * Crucially this is *shortest* path, not longest: a backward (rollback) edge
23
- * `deep → shallow` never offers a shorter route to the already-shallower
24
- * target, so it is inert here. Distances are thus stable whether or not the
25
- * rollbacks are still in the candidate set — which is what lets the peel below
26
- * tell a genuine back-edge (target strictly shallower than source) apart from a
27
- * forward edge that merely happens to share the back-edge's cycle.
28
- */
29
- function forwardDistances(nodes, candidates) {
30
- const inDegree = /* @__PURE__ */ new Map();
31
- for (const node of nodes) inDegree.set(node, 0);
32
- for (const edge of candidates) bumpDegree(inDegree, edge.to);
33
- const roots = [...nodes].filter((node) => (inDegree.get(node) ?? 0) === 0);
34
- roots.sort(compareNodesRootFirst);
35
- const seeds = roots.length > 0 ? roots : [...nodes].sort(compareNodesRootFirst).slice(0, 1);
36
- const dist = /* @__PURE__ */ new Map();
37
- for (const seed of seeds) dist.set(seed, 0);
38
- const maxPasses = nodes.size;
39
- for (let pass = 0; pass < maxPasses; pass++) {
40
- let changed = false;
41
- for (const edge of candidates) {
42
- const base = dist.get(edge.from);
43
- if (base === void 0) continue;
44
- const next = base + 1;
45
- if (next < (dist.get(edge.to) ?? Number.POSITIVE_INFINITY)) {
46
- dist.set(edge.to, next);
47
- changed = true;
48
- }
49
- }
50
- if (!changed) break;
51
- }
52
- for (const node of nodes) if (!dist.has(node)) dist.set(node, 0);
53
- return dist;
54
- }
55
- function canReachForward(start, goal, candidates) {
56
- if (start === goal) return true;
57
- const outgoing = /* @__PURE__ */ new Map();
58
- for (const edge of candidates) {
59
- const bucket = outgoing.get(edge.from);
60
- if (bucket) bucket.push(edge.to);
61
- else outgoing.set(edge.from, [edge.to]);
62
- }
63
- const visited = new Set([start]);
64
- const queue = [start];
65
- while (queue.length > 0) {
66
- const node = queue.shift();
67
- if (node === void 0) continue;
68
- for (const next of outgoing.get(node) ?? []) {
69
- if (next === goal) return true;
70
- if (!visited.has(next)) {
71
- visited.add(next);
72
- queue.push(next);
73
- }
74
- }
75
- }
76
- return false;
77
- }
78
- /**
79
- * Demote node-skipping rollbacks left forward by the DFS. An edge `from → to`
80
- * is a rollback exactly when both hold:
81
- * 1. `to` is a forward-ancestor of `from` — `to` can still reach `from` over
82
- * the other forward edges, so the edge closes a cycle; and
83
- * 2. `to` is strictly shallower than `from` (smaller forward distance) — the
84
- * edge points back toward the root rather than advancing history.
85
- *
86
- * Condition 2 is the discriminator: in a cycle created by a rollback every edge
87
- * satisfies condition 1, but only the rollback itself runs deep → shallow. The
88
- * forward chain edges run shallow → deep and are never peeled, however many
89
- * rollbacks converge on the same target. Tight back-edges whose source and
90
- * target sit at the same distance (mutual two-node cycles) are already resolved
91
- * by the DFS immediate-parent rule, so they never reach this pass. One edge is
92
- * peeled per iteration (dirName-descending tie-break) and distances/reachability
93
- * are recomputed, making the outcome independent of edge input order.
94
- */
95
- function peelNodeSkippingRollbacks(nodes, kindByMigrationHash, nonSelf) {
96
- let candidates = nonSelf.filter((edge) => kindByMigrationHash.get(edge.hash) === "forward");
97
- while (candidates.length > 0) {
98
- const dist = forwardDistances(nodes, candidates);
99
- const backEdges = candidates.filter((edge) => {
100
- if ((dist.get(edge.to) ?? 0) >= (dist.get(edge.from) ?? 0)) return false;
101
- const without = candidates.filter((candidate) => candidate !== edge);
102
- return canReachForward(edge.to, edge.from, without);
103
- });
104
- if (backEdges.length === 0) break;
105
- backEdges.sort(compareDirNameDesc);
106
- const rollback = backEdges[0];
107
- if (rollback === void 0) break;
108
- kindByMigrationHash.set(rollback.hash, "rollback");
109
- candidates = candidates.filter((edge) => edge !== rollback);
110
- }
111
- }
112
- /**
113
- * DFS with dirName-descending traversal. A GRAY target is a rollback only when it
114
- * is the immediate DFS parent of the source — cross-links to other GRAY nodes
115
- * stay forward. A follow-up peel pass demotes node-skipping rollbacks (target is
116
- * a forward-ancestor of the source and sits strictly shallower than it).
117
- */
118
- function classifyNormalizedEdges(edges) {
119
- const nodes = /* @__PURE__ */ new Set();
120
- const kindByMigrationHash = /* @__PURE__ */ new Map();
121
- const outgoingByFrom = /* @__PURE__ */ new Map();
122
- const nonSelf = [];
123
- for (const edge of edges) {
124
- nodes.add(edge.from);
125
- nodes.add(edge.to);
126
- if (edge.from === edge.to) {
127
- kindByMigrationHash.set(edge.hash, "self");
128
- continue;
129
- }
130
- nonSelf.push(edge);
131
- const bucket = outgoingByFrom.get(edge.from);
132
- if (bucket) bucket.push(edge);
133
- else outgoingByFrom.set(edge.from, [edge]);
134
- }
135
- for (const bucket of outgoingByFrom.values()) bucket.sort(compareDirNameDesc);
136
- const nonSelfInDegree = /* @__PURE__ */ new Map();
137
- for (const node of nodes) nonSelfInDegree.set(node, 0);
138
- for (const bucket of outgoingByFrom.values()) for (const edge of bucket) bumpDegree(nonSelfInDegree, edge.to);
139
- const dfsRoots = [];
140
- for (const node of nodes) if ((nonSelfInDegree.get(node) ?? 0) === 0) dfsRoots.push(node);
141
- dfsRoots.sort((a, b) => {
142
- if (a === EMPTY_CONTRACT_HASH) return -1;
143
- if (b === EMPTY_CONTRACT_HASH) return 1;
144
- return a.localeCompare(b);
145
- });
146
- if (dfsRoots.length === 0) dfsRoots.push(...[...nodes].sort((a, b) => a.localeCompare(b)));
147
- const WHITE = 0;
148
- const GRAY = 1;
149
- const BLACK = 2;
150
- const color = /* @__PURE__ */ new Map();
151
- const dfsParent = /* @__PURE__ */ new Map();
152
- for (const node of nodes) color.set(node, WHITE);
153
- const stack = [];
154
- function isImmediateDfsParent(ancestor, node) {
155
- return dfsParent.get(node) === ancestor;
156
- }
157
- function pushFrame(node, parent) {
158
- color.set(node, GRAY);
159
- dfsParent.set(node, parent);
160
- stack.push({
161
- node,
162
- outgoing: outgoingByFrom.get(node) ?? [],
163
- index: 0
164
- });
165
- }
166
- function runDfsFrom(root) {
167
- if (color.get(root) !== WHITE) return;
168
- pushFrame(root, void 0);
169
- while (stack.length > 0) {
170
- const frame = stack[stack.length - 1];
171
- if (frame === void 0) break;
172
- if (frame.index >= frame.outgoing.length) {
173
- color.set(frame.node, BLACK);
174
- stack.pop();
175
- continue;
176
- }
177
- const edge = frame.outgoing[frame.index];
178
- frame.index += 1;
179
- if (edge === void 0) continue;
180
- const v = edge.to;
181
- const vColor = color.get(v);
182
- if (vColor === GRAY && isImmediateDfsParent(v, frame.node)) kindByMigrationHash.set(edge.hash, "rollback");
183
- else {
184
- kindByMigrationHash.set(edge.hash, "forward");
185
- if (vColor === WHITE) pushFrame(v, frame.node);
186
- }
187
- }
188
- }
189
- for (const root of dfsRoots) runDfsFrom(root);
190
- const remainingWhite = [...nodes].filter((node) => color.get(node) === WHITE);
191
- remainingWhite.sort((a, b) => a.localeCompare(b));
192
- for (const root of remainingWhite) runDfsFrom(root);
193
- peelNodeSkippingRollbacks(nodes, kindByMigrationHash, nonSelf);
194
- const forwardInDegree = /* @__PURE__ */ new Map();
195
- const forwardOutDegree = /* @__PURE__ */ new Map();
196
- for (const edge of edges) {
197
- if (kindByMigrationHash.get(edge.hash) !== "forward") continue;
198
- bumpDegree(forwardOutDegree, edge.from);
199
- bumpDegree(forwardInDegree, edge.to);
200
- }
201
- return {
202
- kindByMigrationHash,
203
- forwardInDegree,
204
- forwardOutDegree
205
- };
206
- }
207
- function canonicalFrom(from) {
208
- return from ?? EMPTY_CONTRACT_HASH;
209
- }
210
- /**
211
- * Classify forward/rollback/self for a Tier-2 `MigrationListEntry[]` edge set.
212
- * Returns the kind of each migration plus the forward in/out degree of each
213
- * contract node. This is the established Tier-2 surface; its behaviour is
214
- * unchanged — only its implementation now delegates to the shared classifier.
215
- */
216
- function classifyMigrationListGraphTopology(entries) {
217
- return classifyNormalizedEdges(entries.map((entry) => ({
218
- hash: entry.migrationHash,
219
- from: canonicalFrom(entry.from),
220
- to: entry.to,
221
- dirName: entry.dirName
222
- })));
223
- }
224
- /**
225
- * Classify forward/rollback/self for a `MigrationGraph` edge set (Tier-3).
226
- * Delegates to the same shared classifier as `classifyMigrationListGraphTopology`
227
- * so both tiers agree on forward/rollback/self without duplicating logic.
228
- */
229
- function classifyMigrationGraphTopology(graph) {
230
- const normalized = [];
231
- for (const edges of graph.forwardChain.values()) for (const edge of edges) normalized.push({
232
- hash: edge.migrationHash,
233
- from: edge.from,
234
- to: edge.to,
235
- dirName: edge.dirName
236
- });
237
- return classifyNormalizedEdges(normalized);
238
- }
239
- const MIGRATION_LIST_UNICODE_KIND_GLYPH = {
240
- forward: "*",
241
- rollback: "↩",
242
- self: "⟲"
243
- };
244
- const MIGRATION_LIST_ASCII_KIND_GLYPH = {
245
- forward: "*",
246
- rollback: "<",
247
- self: "~"
248
- };
249
- function migrationListKindGlyph(glyphMode, edgeKind) {
250
- return glyphMode === "ascii" ? MIGRATION_LIST_ASCII_KIND_GLYPH[edgeKind] : MIGRATION_LIST_UNICODE_KIND_GLYPH[edgeKind];
251
- }
252
- function migrationListForwardArrow(glyphMode) {
253
- return glyphMode === "ascii" ? "->" : "→";
254
- }
255
- function migrationListEmptySource(glyphMode) {
256
- return glyphMode === "ascii" ? "-" : "∅";
257
- }
258
- function abbreviateContractHash(hash) {
259
- return (hash.startsWith("sha256:") ? hash.slice(7) : hash).slice(0, 7);
260
- }
261
- function computeMigrationDirNameWidth(migrations) {
262
- if (migrations.length === 0) return 0;
263
- return Math.max(...migrations.map((entry) => entry.dirName.length)) + 2;
264
- }
265
- function formatSourceColumn(from, style, emptySource) {
266
- if (from === null) return style.glyph(emptySource) + " ".repeat(7 - emptySource.length);
267
- return style.sourceHash(abbreviateContractHash(from));
268
- }
269
- function formatDecorations(providedInvariants, refs, style) {
270
- const blocks = [];
271
- if (providedInvariants.length > 0) blocks.push(style.invariants(providedInvariants));
272
- if (refs.length > 0) blocks.push(style.refs(refs));
273
- if (blocks.length === 0) return "";
274
- return ` ${blocks.join(" ")}`;
275
- }
276
- function formatMigrationDataColumn(migration, options) {
277
- const { dirNameWidth, edgeKind, style, forwardArrow = "→", emptySource = "∅" } = options;
278
- const dirNamePadding = " ".repeat(Math.max(0, dirNameWidth - migration.dirName.length));
279
- const dirName = `${style.dirName(migration.dirName)}${dirNamePadding}`;
280
- const decorations = formatDecorations(migration.providedInvariants, migration.refs, style);
281
- if (edgeKind === "self") {
282
- const contractHash = migration.from ?? migration.to;
283
- return `${dirName}${style.sourceHash(abbreviateContractHash(contractHash))}${decorations}`;
284
- }
285
- return `${dirName}${formatSourceColumn(migration.from, style, emptySource)} ${style.glyph(forwardArrow)} ${style.destHash(abbreviateContractHash(migration.to))}${decorations}`;
286
- }
287
- //#endregion
288
- //#region src/utils/formatters/migration-list-render.ts
289
- const IDENTITY_MIGRATION_LIST_STYLER = {
290
- kind: (text) => text,
291
- dirName: (text) => text,
292
- sourceHash: (text) => text,
293
- destHash: (text) => text,
294
- glyph: (text) => text,
295
- lane: (text) => text,
296
- invariants: (ids) => `{${ids.join(", ")}}`,
297
- refs: (names) => `(${names.join(", ")})`,
298
- spaceHeading: (text) => text,
299
- summary: (text) => text,
300
- emptyState: (text) => text
301
- };
302
- function resolveEdgeKind(migrationHash, kindByMigrationHash) {
303
- return kindByMigrationHash.get(migrationHash) ?? "forward";
304
- }
305
- function formatMigrationRow(migration, dirNameWidth, edgeKind, glyphMode, style) {
306
- return `${`${style.kind(migrationListKindGlyph(glyphMode, edgeKind))} `}${formatMigrationDataColumn(migration, {
307
- dirNameWidth,
308
- edgeKind,
309
- style,
310
- forwardArrow: migrationListForwardArrow(glyphMode),
311
- emptySource: migrationListEmptySource(glyphMode)
312
- })}`;
313
- }
314
- function formatEmptyStateLine(spaceId, style) {
315
- return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);
316
- }
317
- function renderSpaceBlock(spaceId, migrations, multiSpace, glyphMode, kindByMigrationHash, style) {
318
- if (migrations.length === 0) {
319
- const emptyLine = formatEmptyStateLine(spaceId, style);
320
- if (!multiSpace) return [emptyLine];
321
- return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];
322
- }
323
- const dirNameWidth = computeMigrationDirNameWidth(migrations);
324
- const rows = migrations.map((entry) => formatMigrationRow(entry, dirNameWidth, resolveEdgeKind(entry.migrationHash, kindByMigrationHash), glyphMode, style));
325
- if (!multiSpace) return rows;
326
- return [style.spaceHeading(`${spaceId}:`), ...rows.map((row) => ` ${row}`)];
327
- }
328
- function buildMigrationListTopologyBySpace(result) {
329
- const topologyBySpaceId = /* @__PURE__ */ new Map();
330
- for (const space of result.spaces) topologyBySpaceId.set(space.spaceId, classifyMigrationListGraphTopology(space.migrations));
331
- return topologyBySpaceId;
332
- }
333
- /**
334
- * Compose the styled `migration list` output. The renderer is
335
- * presentation-neutral — every token passes through `style` before
336
- * landing in the output, so the same composition serves the pure-text
337
- * path ({@link renderMigrationList} via
338
- * {@link IDENTITY_MIGRATION_LIST_STYLER}) and the ANSI-styled CLI path
339
- * (via the ANSI styler the CLI shell wires up).
340
- */
341
- function renderMigrationListWithStyle(result, style, glyphMode = "unicode", topologyBySpaceId = buildMigrationListTopologyBySpace(result)) {
342
- const multiSpace = result.spaces.length > 1;
343
- const lines = [];
344
- for (let index = 0; index < result.spaces.length; index++) {
345
- const space = result.spaces[index];
346
- if (index > 0) lines.push("");
347
- const kindByMigrationHash = topologyBySpaceId.get(space.spaceId)?.kindByMigrationHash ?? classifyMigrationListGraphTopology(space.migrations).kindByMigrationHash;
348
- lines.push(...renderSpaceBlock(space.spaceId, space.migrations, multiSpace, glyphMode, kindByMigrationHash, style));
349
- }
350
- if (result.spaces.reduce((count, space) => count + space.migrations.length, 0) > 0) {
351
- lines.push("");
352
- lines.push(style.summary(result.summary));
353
- }
354
- return lines.join("\n");
355
- }
356
- //#endregion
357
- //#region src/utils/formatters/migration-list-styler.ts
358
- /**
359
- * The current contract overlay marker. Unlike user refs, this names the user's
360
- * declared desired state — the implicit base/target for `plan` / `migrate` —
361
- * not a stored label. It is emphasized (bold) so it stands out from plain refs
362
- * (including the live-database `db` marker, which is just another ref).
363
- */
364
- const CONTRACT_MARKER_NAME = "contract";
365
- function styleRefName(name) {
366
- return name === "contract" ? bold(green(name)) : green(name);
367
- }
368
- /**
369
- * Build a {@link MigrationListStyler} that decorates `migration list`
370
- * tokens with ANSI SGR codes. When `useColor` is `false` (non-TTY,
371
- * `--no-color`, `NO_COLOR=1`, piped output) the function returns the
372
- * shared identity styler so callers get plain text with zero ANSI
373
- * bytes — pipe-friendly by construction.
374
- *
375
- * Palette:
376
- *
377
- * - `dirName`: bold
378
- * - `sourceHash`: dim cyan
379
- * - `destHash`: bright cyan
380
- * - `kind` (`*` / `↩` / `⟲`): bright — the signal; lanes and arrows dim
381
- * - `glyph` (`→` / `⟲` / `∅`): dim
382
- * - `lane` (graph gutter lines `│` and fan/join connectors `├─┐` / `├─┘`): dim
383
- * - `invariants` (`{...}`): yellow
384
- * - `refs` (`(...)`): green; the `contract` desired-state marker inside is
385
- * green-bold (the active ref is bolded separately by the tree styler)
386
- * - `spaceHeading` (`<spaceId>:`): bold
387
- * - `summary`: dim
388
- * - `emptyState`: dim
389
- */
390
- function createAnsiMigrationListStyler(opts) {
391
- if (!opts.useColor) return IDENTITY_MIGRATION_LIST_STYLER;
392
- return {
393
- kind: (text) => text,
394
- dirName: (text) => bold(text),
395
- sourceHash: (text) => dim(cyan(text)),
396
- destHash: (text) => cyanBright(text),
397
- glyph: (text) => dim(text),
398
- lane: (text) => dim(text),
399
- invariants: (ids) => yellow(`{${ids.join(", ")}}`),
400
- refs: (names) => {
401
- const open = green("(");
402
- const close = green(")");
403
- const separator = green(", ");
404
- return open + names.map(styleRefName).join(separator) + close;
405
- },
406
- spaceHeading: (text) => bold(text),
407
- summary: (text) => dim(text),
408
- emptyState: (text) => dim(text)
409
- };
410
- }
411
- //#endregion
412
- export { renderMigrationListWithStyle as a, migrationListForwardArrow as c, buildMigrationListTopologyBySpace as i, classifyMigrationGraphTopology as l, createAnsiMigrationListStyler as n, abbreviateContractHash as o, IDENTITY_MIGRATION_LIST_STYLER as r, migrationListEmptySource as s, CONTRACT_MARKER_NAME as t };
413
-
414
- //# sourceMappingURL=migration-list-styler-CsMECsY4.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migration-list-styler-CsMECsY4.mjs","names":[],"sources":["../src/utils/formatters/migration-list-graph-topology.ts","../src/utils/formatters/migration-list-data-column.ts","../src/utils/formatters/migration-list-render.ts","../src/utils/formatters/migration-list-styler.ts"],"sourcesContent":["import { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';\nimport type { MigrationGraph } from '@prisma-next/migration-tools/graph';\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\n// ---------------------------------------------------------------------------\n// Shared classifier — operates on a normalized edge shape common to both\n// MigrationListEntry (Tier-2) and MigrationEdge / MigrationGraph (Tier-3).\n// ---------------------------------------------------------------------------\n\ninterface NormalizedEdge {\n readonly hash: string;\n readonly from: string;\n readonly to: string;\n readonly dirName: string;\n}\n\nfunction compareDirNameDesc(a: NormalizedEdge, b: NormalizedEdge): 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\nfunction compareNodesRootFirst(a: string, b: string): number {\n if (a === EMPTY_CONTRACT_HASH) return -1;\n if (b === EMPTY_CONTRACT_HASH) return 1;\n return a.localeCompare(b);\n}\n\n/**\n * Shortest-path distance of each node from the forward roots, over the given\n * candidate edges. Roots are the in-degree-0 nodes (baseline first, then lex);\n * a rooted component therefore distances every node by how many forward steps\n * it sits from a root. A component with no root (a pure cycle) is seeded from\n * its single lexically-smallest node so the cycle still gets a stable layering.\n *\n * Crucially this is *shortest* path, not longest: a backward (rollback) edge\n * `deep → shallow` never offers a shorter route to the already-shallower\n * target, so it is inert here. Distances are thus stable whether or not the\n * rollbacks are still in the candidate set — which is what lets the peel below\n * tell a genuine back-edge (target strictly shallower than source) apart from a\n * forward edge that merely happens to share the back-edge's cycle.\n */\nfunction forwardDistances(\n nodes: ReadonlySet<string>,\n candidates: readonly NormalizedEdge[],\n): Map<string, number> {\n const inDegree = new Map<string, number>();\n for (const node of nodes) {\n inDegree.set(node, 0);\n }\n for (const edge of candidates) {\n bumpDegree(inDegree, edge.to);\n }\n\n const roots = [...nodes].filter((node) => (inDegree.get(node) ?? 0) === 0);\n roots.sort(compareNodesRootFirst);\n const seeds = roots.length > 0 ? roots : [...nodes].sort(compareNodesRootFirst).slice(0, 1);\n\n const dist = new Map<string, number>();\n for (const seed of seeds) {\n dist.set(seed, 0);\n }\n\n const maxPasses = nodes.size;\n for (let pass = 0; pass < maxPasses; pass++) {\n let changed = false;\n for (const edge of candidates) {\n const base = dist.get(edge.from);\n if (base === undefined) continue;\n const next = base + 1;\n if (next < (dist.get(edge.to) ?? Number.POSITIVE_INFINITY)) {\n dist.set(edge.to, next);\n changed = true;\n }\n }\n if (!changed) break;\n }\n\n for (const node of nodes) {\n if (!dist.has(node)) {\n dist.set(node, 0);\n }\n }\n\n return dist;\n}\n\nfunction canReachForward(\n start: string,\n goal: string,\n candidates: readonly NormalizedEdge[],\n): boolean {\n if (start === goal) return true;\n\n const outgoing = new Map<string, string[]>();\n for (const edge of candidates) {\n const bucket = outgoing.get(edge.from);\n if (bucket) bucket.push(edge.to);\n else outgoing.set(edge.from, [edge.to]);\n }\n\n const visited = new Set<string>([start]);\n const queue = [start];\n while (queue.length > 0) {\n const node = queue.shift();\n if (node === undefined) continue;\n for (const next of outgoing.get(node) ?? []) {\n if (next === goal) return true;\n if (!visited.has(next)) {\n visited.add(next);\n queue.push(next);\n }\n }\n }\n\n return false;\n}\n\n/**\n * Demote node-skipping rollbacks left forward by the DFS. An edge `from → to`\n * is a rollback exactly when both hold:\n * 1. `to` is a forward-ancestor of `from` — `to` can still reach `from` over\n * the other forward edges, so the edge closes a cycle; and\n * 2. `to` is strictly shallower than `from` (smaller forward distance) — the\n * edge points back toward the root rather than advancing history.\n *\n * Condition 2 is the discriminator: in a cycle created by a rollback every edge\n * satisfies condition 1, but only the rollback itself runs deep → shallow. The\n * forward chain edges run shallow → deep and are never peeled, however many\n * rollbacks converge on the same target. Tight back-edges whose source and\n * target sit at the same distance (mutual two-node cycles) are already resolved\n * by the DFS immediate-parent rule, so they never reach this pass. One edge is\n * peeled per iteration (dirName-descending tie-break) and distances/reachability\n * are recomputed, making the outcome independent of edge input order.\n */\nfunction peelNodeSkippingRollbacks(\n nodes: ReadonlySet<string>,\n kindByMigrationHash: Map<string, MigrationEdgeKind>,\n nonSelf: readonly NormalizedEdge[],\n): void {\n let candidates = nonSelf.filter((edge) => kindByMigrationHash.get(edge.hash) === 'forward');\n\n while (candidates.length > 0) {\n const dist = forwardDistances(nodes, candidates);\n const backEdges = candidates.filter((edge) => {\n const toDist = dist.get(edge.to) ?? 0;\n const fromDist = dist.get(edge.from) ?? 0;\n if (toDist >= fromDist) return false;\n const without = candidates.filter((candidate) => candidate !== edge);\n return canReachForward(edge.to, edge.from, without);\n });\n if (backEdges.length === 0) break;\n\n backEdges.sort(compareDirNameDesc);\n const rollback = backEdges[0];\n if (rollback === undefined) break;\n\n kindByMigrationHash.set(rollback.hash, 'rollback');\n candidates = candidates.filter((edge) => edge !== rollback);\n }\n}\n\n/**\n * DFS with dirName-descending traversal. A GRAY target is a rollback only when it\n * is the immediate DFS parent of the source — cross-links to other GRAY nodes\n * stay forward. A follow-up peel pass demotes node-skipping rollbacks (target is\n * a forward-ancestor of the source and sits strictly shallower than it).\n */\nfunction classifyNormalizedEdges(edges: readonly NormalizedEdge[]): MigrationListGraphTopology {\n const nodes = new Set<string>();\n const kindByMigrationHash = new Map<string, MigrationEdgeKind>();\n const outgoingByFrom = new Map<string, NormalizedEdge[]>();\n const nonSelf: NormalizedEdge[] = [];\n\n for (const edge of edges) {\n nodes.add(edge.from);\n nodes.add(edge.to);\n\n if (edge.from === edge.to) {\n kindByMigrationHash.set(edge.hash, 'self');\n continue;\n }\n\n nonSelf.push(edge);\n const bucket = outgoingByFrom.get(edge.from);\n if (bucket) bucket.push(edge);\n else outgoingByFrom.set(edge.from, [edge]);\n }\n\n for (const bucket of outgoingByFrom.values()) {\n bucket.sort(compareDirNameDesc);\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 const dfsParent = new Map<string, string | undefined>();\n for (const node of nodes) {\n color.set(node, WHITE);\n }\n\n interface Frame {\n node: string;\n outgoing: readonly NormalizedEdge[];\n index: number;\n }\n const stack: Frame[] = [];\n\n function isImmediateDfsParent(ancestor: string, node: string): boolean {\n return dfsParent.get(node) === ancestor;\n }\n\n function pushFrame(node: string, parent: string | undefined): void {\n color.set(node, GRAY);\n dfsParent.set(node, parent);\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, undefined);\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 && isImmediateDfsParent(v, frame.node)) {\n kindByMigrationHash.set(edge.hash, 'rollback');\n } else {\n kindByMigrationHash.set(edge.hash, 'forward');\n if (vColor === WHITE) {\n pushFrame(v, frame.node);\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 peelNodeSkippingRollbacks(nodes, kindByMigrationHash, nonSelf);\n\n const forwardInDegree = new Map<string, number>();\n const forwardOutDegree = new Map<string, number>();\n\n for (const edge of edges) {\n if (kindByMigrationHash.get(edge.hash) !== 'forward') continue;\n bumpDegree(forwardOutDegree, edge.from);\n bumpDegree(forwardInDegree, edge.to);\n }\n\n return {\n kindByMigrationHash,\n forwardInDegree,\n forwardOutDegree,\n };\n}\n\nfunction canonicalFrom(from: string | null): string {\n return from ?? EMPTY_CONTRACT_HASH;\n}\n\n/**\n * Classify forward/rollback/self for a Tier-2 `MigrationListEntry[]` edge set.\n * Returns the kind of each migration plus the forward in/out degree of each\n * contract node. This is the established Tier-2 surface; its behaviour is\n * unchanged — only its implementation now delegates to the shared classifier.\n */\nexport function classifyMigrationListGraphTopology(\n entries: readonly MigrationListEntry[],\n): MigrationListGraphTopology {\n const normalized: NormalizedEdge[] = entries.map((entry) => ({\n hash: entry.migrationHash,\n from: canonicalFrom(entry.from),\n to: entry.to,\n dirName: entry.dirName,\n }));\n return classifyNormalizedEdges(normalized);\n}\n\n/**\n * Classify forward/rollback/self for a `MigrationGraph` edge set (Tier-3).\n * Delegates to the same shared classifier as `classifyMigrationListGraphTopology`\n * so both tiers agree on forward/rollback/self without duplicating logic.\n */\nexport function classifyMigrationGraphTopology(graph: MigrationGraph): MigrationListGraphTopology {\n const normalized: NormalizedEdge[] = [];\n for (const edges of graph.forwardChain.values()) {\n for (const edge of edges) {\n normalized.push({\n hash: edge.migrationHash,\n from: edge.from,\n to: edge.to,\n dirName: edge.dirName,\n });\n }\n }\n return classifyNormalizedEdges(normalized);\n}\n","import type { GlyphMode } from '../glyph-mode';\nimport type { MigrationEdgeKind } from './migration-list-graph-topology';\nimport type { MigrationListStyler } from './migration-list-render';\nimport type { MigrationListEntry } from './migration-list-types';\n\nexport const MIGRATION_LIST_HASH_WIDTH = 7;\nexport const MIGRATION_LIST_EMPTY_SOURCE = '∅';\nexport const MIGRATION_LIST_ASCII_EMPTY_SOURCE = '-';\nexport const MIGRATION_LIST_FORWARD_EDGE_GLYPH = '→';\nexport const MIGRATION_LIST_ASCII_FORWARD_EDGE_GLYPH = '->';\nexport const MIGRATION_LIST_DECORATION_PREFIX = ' ';\n\nexport const MIGRATION_LIST_UNICODE_KIND_GLYPH: Record<MigrationEdgeKind, string> = {\n forward: '*',\n rollback: '↩',\n self: '⟲',\n};\n\nexport const MIGRATION_LIST_ASCII_KIND_GLYPH: Record<MigrationEdgeKind, string> = {\n forward: '*',\n rollback: '<',\n self: '~',\n};\n\nexport function migrationListKindGlyph(glyphMode: GlyphMode, edgeKind: MigrationEdgeKind): string {\n return glyphMode === 'ascii'\n ? MIGRATION_LIST_ASCII_KIND_GLYPH[edgeKind]\n : MIGRATION_LIST_UNICODE_KIND_GLYPH[edgeKind];\n}\n\nexport function migrationListForwardArrow(glyphMode: GlyphMode): string {\n return glyphMode === 'ascii'\n ? MIGRATION_LIST_ASCII_FORWARD_EDGE_GLYPH\n : MIGRATION_LIST_FORWARD_EDGE_GLYPH;\n}\n\nexport function migrationListEmptySource(glyphMode: GlyphMode): string {\n return glyphMode === 'ascii' ? MIGRATION_LIST_ASCII_EMPTY_SOURCE : MIGRATION_LIST_EMPTY_SOURCE;\n}\n\nexport function abbreviateContractHash(hash: string): string {\n const stripped = hash.startsWith('sha256:') ? hash.slice(7) : hash;\n return stripped.slice(0, MIGRATION_LIST_HASH_WIDTH);\n}\n\nexport function computeMigrationDirNameWidth(migrations: readonly MigrationListEntry[]): number {\n if (migrations.length === 0) return 0;\n return Math.max(...migrations.map((entry) => entry.dirName.length)) + 2;\n}\n\nfunction formatSourceColumn(\n from: string | null,\n style: MigrationListStyler,\n emptySource: string,\n): string {\n if (from === null) {\n return style.glyph(emptySource) + ' '.repeat(MIGRATION_LIST_HASH_WIDTH - emptySource.length);\n }\n return style.sourceHash(abbreviateContractHash(from));\n}\n\nexport function formatDecorations(\n providedInvariants: readonly string[],\n refs: readonly string[],\n style: MigrationListStyler,\n): string {\n const blocks: string[] = [];\n if (providedInvariants.length > 0) {\n blocks.push(style.invariants(providedInvariants));\n }\n if (refs.length > 0) {\n blocks.push(style.refs(refs));\n }\n if (blocks.length === 0) return '';\n return `${MIGRATION_LIST_DECORATION_PREFIX}${blocks.join(' ')}`;\n}\n\nexport interface MigrationDataColumnOptions {\n readonly dirNameWidth: number;\n readonly edgeKind: MigrationEdgeKind;\n readonly style: MigrationListStyler;\n readonly forwardArrow?: string;\n readonly emptySource?: string;\n}\n\nexport function formatMigrationDataColumn(\n migration: MigrationListEntry,\n options: MigrationDataColumnOptions,\n): string {\n const {\n dirNameWidth,\n edgeKind,\n style,\n forwardArrow = MIGRATION_LIST_FORWARD_EDGE_GLYPH,\n emptySource = MIGRATION_LIST_EMPTY_SOURCE,\n } = options;\n const dirNamePadding = ' '.repeat(Math.max(0, dirNameWidth - migration.dirName.length));\n const dirName = `${style.dirName(migration.dirName)}${dirNamePadding}`;\n const decorations = formatDecorations(migration.providedInvariants, migration.refs, style);\n\n if (edgeKind === 'self') {\n const contractHash = migration.from ?? migration.to;\n const hash = style.sourceHash(abbreviateContractHash(contractHash));\n return `${dirName}${hash}${decorations}`;\n }\n\n const source = formatSourceColumn(migration.from, style, emptySource);\n const arrow = style.glyph(forwardArrow);\n const dest = style.destHash(abbreviateContractHash(migration.to));\n return `${dirName}${source} ${arrow} ${dest}${decorations}`;\n}\n\nexport function formatNodeLineDataColumn(contractHash: string, style: MigrationListStyler): string {\n return style.sourceHash(abbreviateContractHash(contractHash));\n}\n","import type { GlyphMode } from '../glyph-mode';\nimport {\n computeMigrationDirNameWidth,\n formatMigrationDataColumn,\n migrationListEmptySource,\n migrationListForwardArrow,\n migrationListKindGlyph,\n} from './migration-list-data-column';\nimport {\n classifyMigrationListGraphTopology,\n type MigrationEdgeKind,\n type MigrationListGraphTopology,\n} from './migration-list-graph-topology';\nimport type { MigrationListEntry, MigrationListResult } from './migration-list-types';\n\nexport type { GlyphMode } from '../glyph-mode';\nexport type { MigrationEdgeKind } from './migration-list-graph-topology';\nexport type {\n MigrationListEntry,\n MigrationListResult,\n MigrationSpaceListEntry,\n} from './migration-list-types';\n\n/**\n * Semantic styler for `migration list` output tokens. Token-typed so\n * the renderer composes presentation-neutral fragments and the styler\n * decides how each token kind is decorated (ANSI codes, plain text,\n * etc.). The renderer pads with raw spaces *outside* styled tokens so\n * visible column widths stay stable regardless of what the styler\n * emits — adding ANSI escape sequences never disturbs alignment.\n *\n * `invariants` and `refs` receive the underlying string arrays rather\n * than a pre-joined string so per-element styling (e.g. distinguishing\n * the live-DB `db` marker from user-named refs) is possible without\n * having to re-parse a joined block.\n */\nexport interface MigrationListStyler {\n kind(text: string): string;\n dirName(text: string): string;\n sourceHash(text: string): string;\n destHash(text: string): string;\n glyph(text: string): string;\n lane(text: string): string;\n invariants(ids: readonly string[]): string;\n refs(names: readonly string[]): string;\n spaceHeading(text: string): string;\n summary(text: string): string;\n emptyState(text: string): string;\n}\n\nexport const IDENTITY_MIGRATION_LIST_STYLER: MigrationListStyler = {\n kind: (text) => text,\n dirName: (text) => text,\n sourceHash: (text) => text,\n destHash: (text) => text,\n glyph: (text) => text,\n lane: (text) => text,\n invariants: (ids) => `{${ids.join(', ')}}`,\n refs: (names) => `(${names.join(', ')})`,\n spaceHeading: (text) => text,\n summary: (text) => text,\n emptyState: (text) => text,\n};\n\nfunction resolveEdgeKind(\n migrationHash: string,\n kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>,\n): MigrationEdgeKind {\n return kindByMigrationHash.get(migrationHash) ?? 'forward';\n}\n\nfunction formatMigrationRow(\n migration: MigrationListEntry,\n dirNameWidth: number,\n edgeKind: MigrationEdgeKind,\n glyphMode: GlyphMode,\n style: MigrationListStyler,\n): string {\n const kindColumn = `${style.kind(migrationListKindGlyph(glyphMode, edgeKind))} `;\n const data = formatMigrationDataColumn(migration, {\n dirNameWidth,\n edgeKind,\n style,\n forwardArrow: migrationListForwardArrow(glyphMode),\n emptySource: migrationListEmptySource(glyphMode),\n });\n return `${kindColumn}${data}`;\n}\n\nfunction formatEmptyStateLine(spaceId: string, style: MigrationListStyler): string {\n return style.emptyState(`There are no migrations in migrations/${spaceId}/ yet`);\n}\n\nfunction renderSpaceBlock(\n spaceId: string,\n migrations: readonly MigrationListEntry[],\n multiSpace: boolean,\n glyphMode: GlyphMode,\n kindByMigrationHash: ReadonlyMap<string, MigrationEdgeKind>,\n style: MigrationListStyler,\n): readonly string[] {\n if (migrations.length === 0) {\n const emptyLine = formatEmptyStateLine(spaceId, style);\n if (!multiSpace) {\n return [emptyLine];\n }\n return [style.spaceHeading(`${spaceId}:`), ` ${emptyLine}`];\n }\n\n const dirNameWidth = computeMigrationDirNameWidth(migrations);\n const rows = migrations.map((entry) =>\n formatMigrationRow(\n entry,\n dirNameWidth,\n resolveEdgeKind(entry.migrationHash, kindByMigrationHash),\n glyphMode,\n style,\n ),\n );\n if (!multiSpace) {\n return rows;\n }\n return [style.spaceHeading(`${spaceId}:`), ...rows.map((row) => ` ${row}`)];\n}\n\nexport function buildMigrationListTopologyBySpace(\n result: MigrationListResult,\n): ReadonlyMap<string, MigrationListGraphTopology> {\n const topologyBySpaceId = new Map<string, MigrationListGraphTopology>();\n for (const space of result.spaces) {\n topologyBySpaceId.set(space.spaceId, classifyMigrationListGraphTopology(space.migrations));\n }\n return topologyBySpaceId;\n}\n\n/**\n * Compose the styled `migration list` output. The renderer is\n * presentation-neutral — every token passes through `style` before\n * landing in the output, so the same composition serves the pure-text\n * path ({@link renderMigrationList} via\n * {@link IDENTITY_MIGRATION_LIST_STYLER}) and the ANSI-styled CLI path\n * (via the ANSI styler the CLI shell wires up).\n */\nexport function renderMigrationListWithStyle(\n result: MigrationListResult,\n style: MigrationListStyler,\n glyphMode: GlyphMode = 'unicode',\n topologyBySpaceId: ReadonlyMap<\n string,\n MigrationListGraphTopology\n > = buildMigrationListTopologyBySpace(result),\n): string {\n const multiSpace = result.spaces.length > 1;\n const lines: string[] = [];\n\n for (let index = 0; index < result.spaces.length; index++) {\n const space = result.spaces[index]!;\n if (index > 0) {\n lines.push('');\n }\n const topology = topologyBySpaceId.get(space.spaceId);\n const kindByMigrationHash =\n topology?.kindByMigrationHash ??\n classifyMigrationListGraphTopology(space.migrations).kindByMigrationHash;\n lines.push(\n ...renderSpaceBlock(\n space.spaceId,\n space.migrations,\n multiSpace,\n glyphMode,\n kindByMigrationHash,\n style,\n ),\n );\n }\n\n const totalMigrations = result.spaces.reduce(\n (count, space) => count + space.migrations.length,\n 0,\n );\n if (totalMigrations > 0) {\n lines.push('');\n lines.push(style.summary(result.summary));\n }\n\n return lines.join('\\n');\n}\n\nexport function renderMigrationList(result: MigrationListResult): string {\n return renderMigrationListWithStyle(result, IDENTITY_MIGRATION_LIST_STYLER);\n}\n","import { bold, cyan, cyanBright, dim, green, yellow } from 'colorette';\nimport { IDENTITY_MIGRATION_LIST_STYLER, type MigrationListStyler } from './migration-list-render';\n\n/**\n * The current contract overlay marker. Unlike user refs, this names the user's\n * declared desired state — the implicit base/target for `plan` / `migrate` —\n * not a stored label. It is emphasized (bold) so it stands out from plain refs\n * (including the live-database `db` marker, which is just another ref).\n */\nexport const CONTRACT_MARKER_NAME = 'contract';\n\nfunction styleRefName(name: string): string {\n return name === CONTRACT_MARKER_NAME ? bold(green(name)) : green(name);\n}\n\n/**\n * Build a {@link MigrationListStyler} that decorates `migration list`\n * tokens with ANSI SGR codes. When `useColor` is `false` (non-TTY,\n * `--no-color`, `NO_COLOR=1`, piped output) the function returns the\n * shared identity styler so callers get plain text with zero ANSI\n * bytes — pipe-friendly by construction.\n *\n * Palette:\n *\n * - `dirName`: bold\n * - `sourceHash`: dim cyan\n * - `destHash`: bright cyan\n * - `kind` (`*` / `↩` / `⟲`): bright — the signal; lanes and arrows dim\n * - `glyph` (`→` / `⟲` / `∅`): dim\n * - `lane` (graph gutter lines `│` and fan/join connectors `├─┐` / `├─┘`): dim\n * - `invariants` (`{...}`): yellow\n * - `refs` (`(...)`): green; the `contract` desired-state marker inside is\n * green-bold (the active ref is bolded separately by the tree styler)\n * - `spaceHeading` (`<spaceId>:`): bold\n * - `summary`: dim\n * - `emptyState`: dim\n */\nexport function createAnsiMigrationListStyler(opts: {\n readonly useColor: boolean;\n}): MigrationListStyler {\n if (!opts.useColor) {\n return IDENTITY_MIGRATION_LIST_STYLER;\n }\n return {\n // Kind glyphs stay bright in both flat and graph views; lanes carry the dim gutter.\n kind: (text) => text,\n dirName: (text) => bold(text),\n sourceHash: (text) => dim(cyan(text)),\n destHash: (text) => cyanBright(text),\n glyph: (text) => dim(text),\n lane: (text) => dim(text),\n invariants: (ids) => yellow(`{${ids.join(', ')}}`),\n refs: (names) => {\n const open = green('(');\n const close = green(')');\n const separator = green(', ');\n return open + names.map(styleRefName).join(separator) + close;\n },\n spaceHeading: (text) => bold(text),\n summary: (text) => dim(text),\n emptyState: (text) => dim(text),\n };\n}\n"],"mappings":";;;AAwBA,SAAS,mBAAmB,GAAmB,GAA2B;CACxE,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,SA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