ts-prorm-orm 1.2.2 → 2.0.0

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 (129) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/README.md +32 -24
  3. package/dist/compliance/index.d.ts +2 -0
  4. package/dist/compliance/index.js +13 -1
  5. package/dist/connection-manager.js +13 -1
  6. package/dist/core/expressions.d.ts +58 -0
  7. package/dist/core/expressions.js +83 -0
  8. package/dist/core/hooks-manager.d.ts +179 -0
  9. package/dist/core/hooks-manager.js +291 -0
  10. package/dist/core/types.d.ts +235 -0
  11. package/dist/core/types.js +9 -0
  12. package/dist/decorators/index.d.ts +2 -0
  13. package/dist/decorators/index.js +11 -1
  14. package/dist/diagrams/chen-diagram.d.ts +15 -12
  15. package/dist/diagrams/chen-diagram.js +76 -85
  16. package/dist/diagrams/class-diagram.d.ts +9 -8
  17. package/dist/diagrams/class-diagram.js +60 -82
  18. package/dist/diagrams/core/index.d.ts +13 -0
  19. package/dist/diagrams/core/index.js +33 -0
  20. package/dist/diagrams/core/layout.d.ts +104 -0
  21. package/dist/diagrams/core/layout.js +223 -0
  22. package/dist/diagrams/{svg-dom.d.ts → core/svg.d.ts} +8 -20
  23. package/dist/diagrams/{svg-dom.js → core/svg.js} +21 -29
  24. package/dist/diagrams/core/theme.d.ts +84 -0
  25. package/dist/diagrams/core/theme.js +62 -0
  26. package/dist/diagrams/dependency-diagram.d.ts +15 -14
  27. package/dist/diagrams/dependency-diagram.js +71 -105
  28. package/dist/diagrams/er-diagram.d.ts +13 -26
  29. package/dist/diagrams/er-diagram.js +180 -259
  30. package/dist/diagrams/flow-diagram.d.ts +16 -11
  31. package/dist/diagrams/flow-diagram.js +96 -91
  32. package/dist/diagrams/gantt-diagram.d.ts +10 -5
  33. package/dist/diagrams/gantt-diagram.js +77 -103
  34. package/dist/diagrams/index-diagram.d.ts +10 -10
  35. package/dist/diagrams/index-diagram.js +106 -116
  36. package/dist/diagrams/index.d.ts +6 -9
  37. package/dist/diagrams/index.js +9 -24
  38. package/dist/diagrams/migration-diagram.d.ts +8 -4
  39. package/dist/diagrams/migration-diagram.js +189 -161
  40. package/dist/diagrams/model-diagram.d.ts +34 -34
  41. package/dist/diagrams/model-diagram.js +106 -485
  42. package/dist/diagrams/package-diagram.d.ts +9 -6
  43. package/dist/diagrams/package-diagram.js +64 -101
  44. package/dist/diagrams/relational-diagram.d.ts +12 -10
  45. package/dist/diagrams/relational-diagram.js +87 -114
  46. package/dist/diagrams/schemadoc-diagram.d.ts +8 -8
  47. package/dist/diagrams/schemadoc-diagram.js +71 -93
  48. package/dist/diagrams/sequence-diagram.d.ts +10 -10
  49. package/dist/diagrams/sequence-diagram.js +64 -89
  50. package/dist/diagrams/state-diagram.d.ts +10 -9
  51. package/dist/diagrams/state-diagram.js +69 -92
  52. package/dist/diagrams/tree-diagram.d.ts +11 -5
  53. package/dist/diagrams/tree-diagram.js +41 -65
  54. package/dist/dialects/clickhouse/index.js +15 -0
  55. package/dist/dialects/cockroachdb/index.d.ts +1 -1
  56. package/dist/dialects/cockroachdb/index.js +32 -63
  57. package/dist/dialects/db2/index.js +23 -8
  58. package/dist/dialects/dialect.d.ts +29 -5
  59. package/dist/dialects/duckdb/index.js +9 -2
  60. package/dist/dialects/hana/index.js +22 -5
  61. package/dist/dialects/lock-clause-helper.d.ts +167 -0
  62. package/dist/dialects/lock-clause-helper.js +316 -0
  63. package/dist/dialects/mariadb/index.d.ts +7 -4
  64. package/dist/dialects/mariadb/index.js +36 -60
  65. package/dist/dialects/mssql/index.js +34 -3
  66. package/dist/dialects/mysql/index.d.ts +1 -1
  67. package/dist/dialects/mysql/index.js +17 -45
  68. package/dist/dialects/oracle/index.d.ts +14 -3
  69. package/dist/dialects/oracle/index.js +66 -36
  70. package/dist/dialects/order-expression-helper.d.ts +72 -0
  71. package/dist/dialects/order-expression-helper.js +154 -0
  72. package/dist/dialects/partial-index.d.ts +52 -0
  73. package/dist/dialects/partial-index.js +251 -0
  74. package/dist/dialects/postgres/index.d.ts +1 -1
  75. package/dist/dialects/postgres/index.js +43 -68
  76. package/dist/dialects/redshift/index.js +9 -2
  77. package/dist/dialects/snowflake/index.js +17 -0
  78. package/dist/dialects/spanner/index.js +7 -2
  79. package/dist/dialects/sqlite/driver.d.ts +55 -0
  80. package/dist/dialects/sqlite/driver.js +102 -0
  81. package/dist/dialects/sqlite/index.d.ts +1 -1
  82. package/dist/dialects/sqlite/index.js +49 -27
  83. package/dist/graph/base-graph-dialect.d.ts +24 -3
  84. package/dist/graph/base-graph-dialect.js +43 -2
  85. package/dist/graph/dgraph/index.js +6 -0
  86. package/dist/graph/gremlin/index.d.ts +6 -0
  87. package/dist/graph/gremlin/index.js +12 -1
  88. package/dist/graph/index.d.ts +1 -1
  89. package/dist/graph/neo4j/index.d.ts +2 -0
  90. package/dist/graph/neo4j/index.js +6 -1
  91. package/dist/graph/types.d.ts +12 -1
  92. package/dist/index.d.ts +13 -4
  93. package/dist/index.js +54 -7
  94. package/dist/logging/index.d.ts +10 -0
  95. package/dist/logging/index.js +23 -0
  96. package/dist/logging/query-logging.d.ts +82 -0
  97. package/dist/logging/query-logging.js +102 -0
  98. package/dist/models/decorators.d.ts +39 -3
  99. package/dist/models/decorators.js +74 -0
  100. package/dist/models/eager-load.d.ts +99 -0
  101. package/dist/models/eager-load.js +348 -5
  102. package/dist/models/indexes.d.ts +3 -2
  103. package/dist/models/indexes.js +7 -1
  104. package/dist/models/model.js +69 -43
  105. package/dist/prorm.d.ts +175 -409
  106. package/dist/prorm.js +1142 -557
  107. package/dist/query-builders/order-limit-builder.js +12 -10
  108. package/dist/query-builders/sql-compiler.d.ts +10 -3
  109. package/dist/query-builders/sql-compiler.js +14 -43
  110. package/dist/query-interface.d.ts +2 -1
  111. package/dist/sql-constants.d.ts +44 -0
  112. package/dist/sql-constants.js +138 -1
  113. package/dist/types/index.d.ts +53 -17
  114. package/dist/types/index.js +10 -15
  115. package/dist/types/query-types.d.ts +26 -0
  116. package/dist/types/query-types.js +30 -0
  117. package/package.json +32 -5
  118. package/dist/decorators/belongs-to-many.js +0 -115
  119. package/dist/decorators/belongs-to.js +0 -115
  120. package/dist/decorators/has-many.js +0 -127
  121. package/dist/decorators/has-one.js +0 -116
  122. package/dist/diagrams/palette.d.ts +0 -138
  123. package/dist/diagrams/palette.js +0 -194
  124. package/dist/hooks/hooks-manager.d.ts +0 -189
  125. package/dist/hooks/hooks-manager.js +0 -350
  126. package/dist/hooks/index.d.ts +0 -8
  127. package/dist/hooks/index.js +0 -37
  128. /package/dist/{logging.d.ts → logging/logger.d.ts} +0 -0
  129. /package/dist/{logging.js → logging/logger.js} +0 -0
@@ -1,23 +1,20 @@
1
1
  "use strict";
2
2
  /**
3
- * DependencyDiagram renders a directed dependency graph of models/tables.
3
+ * DependencyDiagram - renders a directed dependency graph of models/tables.
4
4
  *
5
- * Nodes are models/tables; a directed edge `from to` means "from depends on
5
+ * Nodes are models/tables; a directed edge `from -> to` means "from depends on
6
6
  * to" (e.g. table `from` holds a foreign key into table `to`). The generator:
7
7
  *
8
8
  * - Computes a layered / topological layout: each node's layer is the longest
9
9
  * dependency path to a leaf. Nodes with no dependencies sit in layer 0;
10
10
  * their dependents fan out into higher layers.
11
11
  * - Detects cycles (back edges) with a DFS colouring pass and visually flags
12
- * the cyclic edges in red. The layering pass carries its own visited guard
13
- * so a cycle can never send it into an infinite loop.
14
- * - Draws each node as a labelled rounded box sized to its label, with arrows
12
+ * the cyclic edges with a heavier dashed stroke. The layering pass carries
13
+ * its own visited guard so a cycle can never send it into an infinite loop.
14
+ * - Draws each node as a labelled box sized to its label, with arrows
15
15
  * between dependent boxes.
16
16
  *
17
- * Accent colour (`color`) drives the node fills / arrowheads; the theme
18
- * (`light` | `dark`) drives the canvas + text colours. Both genuinely change
19
- * real fill/stroke values in the emitted SVG. The viewBox auto-sizes to the
20
- * computed layout.
17
+ * The viewBox auto-sizes to the computed layout.
21
18
  *
22
19
  * Usage:
23
20
  * const d = new DependencyDiagram({ nodes, edges, title: 'Schema deps' });
@@ -61,18 +58,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
61
58
  exports.DependencyDiagram = void 0;
62
59
  const fs = __importStar(require("fs"));
63
60
  const path = __importStar(require("path"));
64
- const palette_1 = require("./palette");
65
- const svg_dom_1 = require("./svg-dom");
66
- // ─── Industry design system ────────────────────────────────────────────────
67
- // Barlow / JetBrains Mono typography, hairline borders and square "blueprint"
68
- // corners are fixed by the Industry spec; accent + surface colours still route
69
- // through resolveAccent / resolveTheme so --color / --theme keep working.
70
- const IND_FONT_HEAD = '"Barlow Condensed", system-ui, sans-serif';
71
- const IND_FONT_BODY = '"Barlow", system-ui, sans-serif';
72
- const IND_FONT_MONO = 'ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace';
73
- const IND_HAIRLINE = 'rgba(29,31,32,0.16)';
74
- const IND_FONT_IMPORT = "@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;700&family=Barlow+Condensed:wght@400;600&family=JetBrains+Mono&display=swap');";
75
- // ─── Main class ──────────────────────────────────────────────────────────────
61
+ const svg_1 = require("./core/svg");
62
+ const theme_1 = require("./core/theme");
63
+ const layout_1 = require("./core/layout");
76
64
  class DependencyDiagram {
77
65
  constructor(options) {
78
66
  this.opts = {
@@ -84,8 +72,8 @@ class DependencyDiagram {
84
72
  edges: options.edges ?? [],
85
73
  };
86
74
  }
87
- // ── Graph analysis ──────────────────────────────────────────────────────
88
- /** Adjacency: node the nodes it depends on (its outgoing edge targets). */
75
+ // -- Graph analysis --------------------------------------------------------
76
+ /** Adjacency: node -> the nodes it depends on (its outgoing edge targets). */
89
77
  buildAdjacency(names) {
90
78
  const adj = new Map();
91
79
  for (const n of names)
@@ -111,7 +99,7 @@ class DependencyDiagram {
111
99
  if (layer.has(node))
112
100
  return layer.get(node);
113
101
  if (onStack.has(node))
114
- return 0; // cycle guard break the recursion
102
+ return 0; // cycle guard - break the recursion
115
103
  onStack.add(node);
116
104
  let best = 0;
117
105
  for (const dep of adj.get(node) ?? []) {
@@ -126,7 +114,7 @@ class DependencyDiagram {
126
114
  return layer;
127
115
  }
128
116
  /**
129
- * Detect cyclic edges via DFS colouring. Returns a set of "fromto" keys that
117
+ * Detect cyclic edges via DFS colouring. Returns a set of "from-to" keys that
130
118
  * are back edges (participate in a cycle).
131
119
  */
132
120
  detectCyclicEdges(names, adj) {
@@ -142,7 +130,7 @@ class DependencyDiagram {
142
130
  for (const dep of adj.get(node) ?? []) {
143
131
  const c = color.get(dep);
144
132
  if (c === GRAY) {
145
- cyclic.add(`${node}${dep}`); // back edge cycle
133
+ cyclic.add(`${node}${dep}`); // back edge -> cycle
146
134
  }
147
135
  else if (c === WHITE) {
148
136
  dfs(dep);
@@ -155,13 +143,13 @@ class DependencyDiagram {
155
143
  dfs(n);
156
144
  return cyclic;
157
145
  }
158
- // ── Geometry helpers ─────────────────────────────────────────────────────
146
+ // -- Geometry helpers -------------------------------------------------------
159
147
  nodeWidth(name) {
160
148
  return Math.max(DependencyDiagram.MIN_NODE_W, Math.round(name.length * DependencyDiagram.CHAR_W + DependencyDiagram.NODE_PAD_X * 2));
161
149
  }
162
150
  /**
163
151
  * Point on the boundary of a rectangle along the line from the rect centre
164
- * toward an external point used so arrowheads land on the box edge.
152
+ * toward an external point - used so arrowheads land on the box edge.
165
153
  */
166
154
  edgePoint(node, tx, ty) {
167
155
  const cx = node.x + node.w / 2;
@@ -177,19 +165,14 @@ class DependencyDiagram {
177
165
  const scale = Math.min(scaleX, scaleY);
178
166
  return { x: cx + dx * scale, y: cy + dy * scale };
179
167
  }
180
- // ── Generate full SVG string ─────────────────────────────────────────────
181
- generate() {
182
- const { title, theme, color, direction } = this.opts;
183
- const accent = (0, palette_1.resolveAccent)(color);
184
- const palettes = (0, palette_1.rotatedPalettes)(color);
185
- const t = (0, palette_1.resolveTheme)(theme);
168
+ build() {
169
+ const { title, direction } = this.opts;
186
170
  const horizontal = direction !== 'vertical';
187
171
  const PAD = DependencyDiagram.PAD;
188
172
  const TITLE_H = DependencyDiagram.TITLE_H;
189
173
  const NODE_H = DependencyDiagram.NODE_H;
190
174
  const LAYER_GAP = DependencyDiagram.LAYER_GAP;
191
175
  const NODE_GAP = DependencyDiagram.NODE_GAP;
192
- const R = DependencyDiagram.R;
193
176
  // De-duplicate nodes by name, preserving first occurrence.
194
177
  const seen = new Set();
195
178
  const nodeDefs = [];
@@ -212,20 +195,10 @@ class DependencyDiagram {
212
195
  }
213
196
  for (let i = 0; i < layersArr.length; i++)
214
197
  layersArr[i] ?? (layersArr[i] = []);
215
- // Assign a stable palette per group (for node fill tinting).
216
- const groupPalette = new Map();
217
- let gi = 0;
218
- for (const n of nodeDefs) {
219
- const g = n.group;
220
- if (g && !groupPalette.has(g)) {
221
- groupPalette.set(g, palettes[gi % palettes.length]);
222
- gi++;
223
- }
224
- }
225
- // ── Compute placements ──────────────────────────────────────────────
198
+ // Compute placements.
226
199
  const placed = new Map();
227
200
  if (horizontal) {
228
- // Layers = columns (leftright). Nodes stacked vertically within a column.
201
+ // Layers = columns (left to right). Nodes stacked vertically within a column.
229
202
  const layerW = layersArr.map((layer) => layer.reduce((m, n) => Math.max(m, this.nodeWidth(n.name)), DependencyDiagram.MIN_NODE_W));
230
203
  const colX = [];
231
204
  let cursor = PAD;
@@ -239,12 +212,12 @@ class DependencyDiagram {
239
212
  const w = this.nodeWidth(n.name);
240
213
  const x = colX[l] + (layerW[l] - w) / 2;
241
214
  const y = contentTop + slot * (NODE_H + NODE_GAP);
242
- this.place(placed, n, l, slot, x, y, w, NODE_H, accent, groupPalette, t);
215
+ this.place(placed, n, l, slot, x, y, w, NODE_H);
243
216
  });
244
217
  }
245
218
  }
246
219
  else {
247
- // Layers = rows (topbottom). Nodes spread horizontally within a row.
220
+ // Layers = rows (top to bottom). Nodes spread horizontally within a row.
248
221
  const colW = names.reduce((m, nm) => Math.max(m, this.nodeWidth(nm)), DependencyDiagram.MIN_NODE_W);
249
222
  const contentLeft = PAD;
250
223
  for (let l = 0; l < layersArr.length; l++) {
@@ -252,11 +225,11 @@ class DependencyDiagram {
252
225
  layersArr[l].forEach((n, slot) => {
253
226
  const w = this.nodeWidth(n.name);
254
227
  const x = contentLeft + slot * (colW + NODE_GAP) + (colW - w) / 2;
255
- this.place(placed, n, l, slot, x, y, w, NODE_H, accent, groupPalette, t);
228
+ this.place(placed, n, l, slot, x, y, w, NODE_H);
256
229
  });
257
230
  }
258
231
  }
259
- // ── Auto-size the canvas ────────────────────────────────────────────
232
+ // Auto-size the canvas.
260
233
  let maxX = 0;
261
234
  let maxY = 0;
262
235
  for (const p of placed.values()) {
@@ -265,37 +238,33 @@ class DependencyDiagram {
265
238
  }
266
239
  const svgW = Math.round(maxX + PAD);
267
240
  const svgH = Math.round(maxY + PAD);
268
- // ── Build the document ──────────────────────────────────────────────
269
- const doc = new svg_dom_1.SvgDocument(svgW, svgH);
241
+ const doc = new svg_1.SvgDocument(svgW, svgH);
270
242
  const svg = doc.root;
271
- // Background + embedded Industry web-fonts.
272
- svg.child('rect', { width: svgW, height: svgH, fill: t.canvasBg });
273
- svg.child('style').text(IND_FONT_IMPORT);
274
- // Arrowhead markers (accent + cyclic red).
275
- const CYCLE_COLOR = '#DC2626';
276
- this.defineArrow(doc, 'depArrow', accent.mid);
277
- this.defineArrow(doc, 'depArrowCycle', CYCLE_COLOR);
278
- // Title
243
+ svg.child('rect', { width: svgW, height: svgH, fill: theme_1.INK.ground });
244
+ // Arrowhead markers: a plain arrow, and a heavier one for cyclic edges.
245
+ this.defineArrow(doc, 'depArrow', theme_1.STROKE.hair);
246
+ this.defineArrow(doc, 'depArrowCycle', theme_1.STROKE.heavy);
247
+ // Title.
279
248
  svg
280
249
  .child('text', {
281
250
  x: PAD,
282
251
  y: PAD + 6,
283
- 'font-family': IND_FONT_HEAD,
284
- 'font-size': 22,
285
- 'font-weight': 600,
286
- fill: t.textPrimary,
252
+ 'font-family': theme_1.FONT.family,
253
+ 'font-size': theme_1.FONT.title + 9,
254
+ 'font-weight': 'bold',
255
+ fill: theme_1.INK.line,
287
256
  })
288
257
  .text(title);
289
258
  svg
290
259
  .child('text', {
291
260
  x: PAD,
292
261
  y: PAD + 26,
293
- 'font-family': IND_FONT_BODY,
294
- 'font-size': 11,
295
- fill: t.textSecondary,
262
+ 'font-family': theme_1.FONT.family,
263
+ 'font-size': theme_1.FONT.small + 2,
264
+ fill: theme_1.INK.muted,
296
265
  })
297
- .text(`${placed.size} node${placed.size !== 1 ? 's' : ''} · ${this.opts.edges.length} edge${this.opts.edges.length !== 1 ? 's' : ''}${cyclicEdges.size ? ` · ${cyclicEdges.size} cyclic` : ''}`);
298
- // ── Edges (drawn before nodes so boxes sit on top) ──────────────────
266
+ .text(`${placed.size} node${placed.size !== 1 ? 's' : ''}, ${this.opts.edges.length} edge${this.opts.edges.length !== 1 ? 's' : ''}${cyclicEdges.size ? `, ${cyclicEdges.size} cyclic` : ''}`);
267
+ // Edges, drawn before nodes so boxes sit on top.
299
268
  const edgeLayer = svg.child('g', { 'stroke-linecap': 'round' });
300
269
  for (const e of this.opts.edges) {
301
270
  const from = placed.get(e.from);
@@ -304,7 +273,7 @@ class DependencyDiagram {
304
273
  continue;
305
274
  const isCyclic = cyclicEdges.has(`${e.from}${e.to}`);
306
275
  const isSelf = e.from === e.to;
307
- const stroke = isCyclic ? CYCLE_COLOR : accent.mid;
276
+ const strokeWidth = isCyclic ? theme_1.STROKE.heavy : theme_1.STROKE.hair;
308
277
  const marker = isCyclic ? 'url(#depArrowCycle)' : 'url(#depArrow)';
309
278
  if (isSelf) {
310
279
  // Self-dependency: small loop above the node.
@@ -313,8 +282,8 @@ class DependencyDiagram {
313
282
  edgeLayer.child('path', {
314
283
  d: `M ${lx - 10} ${ly} C ${lx - 26} ${ly - 34}, ${lx + 26} ${ly - 34}, ${lx + 10} ${ly}`,
315
284
  fill: 'none',
316
- stroke,
317
- 'stroke-width': isCyclic ? 2.4 : 1.8,
285
+ stroke: theme_1.INK.line,
286
+ 'stroke-width': strokeWidth,
318
287
  'stroke-dasharray': isCyclic ? '6 4' : undefined,
319
288
  'marker-end': marker,
320
289
  });
@@ -331,8 +300,8 @@ class DependencyDiagram {
331
300
  y1: start.y,
332
301
  x2: end.x,
333
302
  y2: end.y,
334
- stroke,
335
- 'stroke-width': isCyclic ? 2.4 : 1.7,
303
+ stroke: theme_1.INK.line,
304
+ 'stroke-width': strokeWidth,
336
305
  'stroke-dasharray': isCyclic ? '6 4' : undefined,
337
306
  'marker-end': marker,
338
307
  });
@@ -341,15 +310,15 @@ class DependencyDiagram {
341
310
  .child('text', {
342
311
  x: (start.x + end.x) / 2,
343
312
  y: (start.y + end.y) / 2 - 4,
344
- 'font-family': IND_FONT_MONO,
345
- 'font-size': 9,
346
- fill: isCyclic ? CYCLE_COLOR : t.textSecondary,
313
+ 'font-family': theme_1.FONT.mono,
314
+ 'font-size': theme_1.FONT.small - 1,
315
+ fill: theme_1.INK.muted,
347
316
  'text-anchor': 'middle',
348
317
  })
349
318
  .text(e.label);
350
319
  }
351
320
  }
352
- // ── Nodes ───────────────────────────────────────────────────────────
321
+ // Nodes.
353
322
  for (const n of nodeDefs) {
354
323
  const p = placed.get(n.name);
355
324
  if (!p)
@@ -360,35 +329,36 @@ class DependencyDiagram {
360
329
  y: p.y,
361
330
  width: p.w,
362
331
  height: p.h,
363
- fill: p.fill,
364
- stroke: p.stroke,
365
- 'stroke-width': 1,
332
+ fill: theme_1.INK.wash,
333
+ stroke: theme_1.INK.line,
334
+ 'stroke-width': theme_1.STROKE.hair,
366
335
  });
367
336
  g.child('text', {
368
337
  x: p.x + p.w / 2,
369
338
  y: p.y + p.h / 2 + 5,
370
- 'font-family': IND_FONT_MONO,
371
- 'font-size': 14,
372
- 'font-weight': 700,
373
- fill: p.text,
339
+ 'font-family': theme_1.FONT.mono,
340
+ 'font-size': theme_1.FONT.body + 3,
341
+ 'font-weight': 'bold',
342
+ fill: theme_1.INK.line,
374
343
  'text-anchor': 'middle',
375
- }).text(n.name);
344
+ }).text((0, layout_1.truncate)(n.name, p.w - 8, theme_1.FONT.body + 3, true));
376
345
  // Layer badge on the box shoulder.
377
346
  g.child('text', {
378
347
  x: p.x + 8,
379
348
  y: p.y + 13,
380
- 'font-family': IND_FONT_BODY,
381
- 'font-size': 9,
382
- 'font-weight': 700,
383
- fill: p.text,
384
- opacity: 0.55,
349
+ 'font-family': theme_1.FONT.family,
350
+ 'font-size': theme_1.FONT.small - 1,
351
+ 'font-weight': 'bold',
352
+ fill: theme_1.INK.muted,
385
353
  }).text(`L${p.layer}`);
386
354
  }
387
- return doc.toString('Generated by ts-prorm-orm DependencyDiagram');
355
+ return doc;
356
+ }
357
+ generate() {
358
+ return this.build().toString('Generated by ts-prorm-orm DependencyDiagram');
388
359
  }
389
- // ── place() records a node's geometry + resolved colours ─────────────────
390
- place(placed, n, layer, slot, x, y, w, h, accent, groupPalette, t) {
391
- const pal = (n.group && groupPalette.get(n.group)) || accent;
360
+ // -- place() records a node's geometry -------------------------------------
361
+ place(placed, n, layer, slot, x, y, w, h) {
392
362
  placed.set(n.name, {
393
363
  name: n.name,
394
364
  group: n.group,
@@ -398,23 +368,20 @@ class DependencyDiagram {
398
368
  y,
399
369
  w,
400
370
  h,
401
- fill: pal.light,
402
- stroke: pal.mid,
403
- text: pal.text,
404
371
  });
405
372
  }
406
- // ── Arrowhead marker in <defs> ───────────────────────────────────────────
407
- defineArrow(doc, id, color) {
373
+ // -- Arrowhead marker in <defs> ---------------------------------------------
374
+ defineArrow(doc, id, strokeWidth) {
408
375
  const marker = doc.defs().child('marker', {
409
376
  id,
410
377
  viewBox: '0 0 10 10',
411
378
  refX: 9,
412
379
  refY: 5,
413
- markerWidth: 7,
414
- markerHeight: 7,
380
+ markerWidth: strokeWidth === theme_1.STROKE.heavy ? 8 : 7,
381
+ markerHeight: strokeWidth === theme_1.STROKE.heavy ? 8 : 7,
415
382
  orient: 'auto-start-reverse',
416
383
  });
417
- marker.child('path', { d: 'M 0 0 L 10 5 L 0 10 z', fill: color });
384
+ marker.child('path', { d: 'M 0 0 L 10 5 L 0 10 z', fill: theme_1.INK.line });
418
385
  }
419
386
  /**
420
387
  * Write the SVG to a file, creating parent directories as needed.
@@ -438,4 +405,3 @@ DependencyDiagram.NODE_PAD_X = 22;
438
405
  DependencyDiagram.MIN_NODE_W = 72;
439
406
  DependencyDiagram.LAYER_GAP = 90; // gap between layer columns/rows
440
407
  DependencyDiagram.NODE_GAP = 26; // gap between nodes in a layer
441
- DependencyDiagram.R = 9;
@@ -1,17 +1,14 @@
1
1
  /**
2
- * ERDiagram generates a fully-rendered Entity-Relationship diagram SVG for
3
- * a collection of ORM models and their associations, styled to the "Industry"
4
- * blueprint design system.
2
+ * ERDiagram - generates a fully-rendered Entity-Relationship diagram SVG for
3
+ * a collection of ORM models and their associations.
5
4
  *
6
5
  * Look:
7
- * - #f2f2f3 ground with a faint hairline blueprint grid
8
- * - Solid accent (#5980a6) banner, Barlow Condensed title
9
- * - White entity cards on a grid: SQUARE corners, 1px hairline borders, a solid
10
- * accent / accent-2 (two-tone) header bar — no vibrant gradients or shadows
11
- * - Compact rows: name (mono) + type (mono, neutral) + PK/FK marks
6
+ * - White entity cards on a grid: square corners, 1px hairline borders, a
7
+ * solid header bar - no gradients or shadows
8
+ * - Compact rows: name (mono) + type (mono, muted) + PK/FK marks
12
9
  * - Hairline crow's-foot relationship connectors with mono cardinality marks
13
- * - Legend bottom-right, Barlow labels
14
- * - Fully self-contained SVG (fonts via an embedded @import + system fallbacks)
10
+ * - Legend bottom-right
11
+ * - Fully self-contained SVG (system font stack, no web-font import)
15
12
  *
16
13
  * Usage:
17
14
  * const er = new ERDiagram({
@@ -35,9 +32,12 @@ export interface ERDiagramOptions {
35
32
  hGap?: number;
36
33
  /** Vertical gap between entity boxes (px) */
37
34
  vGap?: number;
38
- /** Theme mode: light or dark */
35
+ /**
36
+ * Accepted for backward compatibility and ignored: diagrams render in a
37
+ * single monochrome theme.
38
+ */
39
39
  theme?: 'light' | 'dark';
40
- /** Named palette (e.g. "industry") or hex color for the accent */
40
+ /** Accepted for backward compatibility and ignored. */
41
41
  color?: string;
42
42
  }
43
43
  export declare class ERDiagram {
@@ -51,15 +51,7 @@ export declare class ERDiagram {
51
51
  private static readonly LEGEND_W;
52
52
  private static readonly LEGEND_PAD;
53
53
  private static readonly MARGIN;
54
- private accentMid;
55
- private accentText;
56
- private accentLight;
57
- private accent2Mid;
58
- private accent2Text;
59
- private accent2Light;
60
54
  constructor(options: ERDiagramOptions);
61
- /** Two-tone entity styling — even entities accent, odd accent-2. */
62
- private entityStyle;
63
55
  private boxHeight;
64
56
  private computeLayout;
65
57
  private renderBox;
@@ -68,12 +60,7 @@ export declare class ERDiagram {
68
60
  private singleBar;
69
61
  private renderBanner;
70
62
  private renderLegend;
71
- /**
72
- * Embedded font @import so browsers resolve Barlow / JetBrains Mono. Wrapped
73
- * in CDATA because the Google-Fonts URL contains raw `&` separators that
74
- * would otherwise be invalid XML in this string-built document.
75
- */
76
- private fontDefs;
63
+ private build;
77
64
  generate(): string;
78
65
  /**
79
66
  * Write the SVG to a file. Creates parent directories if needed.