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,9 +1,9 @@
1
1
  "use strict";
2
2
  /**
3
- * ClassDiagram renders one or more classes as UML class boxes.
3
+ * ClassDiagram - renders one or more classes as UML class boxes.
4
4
  *
5
5
  * Each class box has three compartments:
6
- * - a title bar (class name + optional «stereotype»),
6
+ * - a title bar (class name + optional <<stereotype>>),
7
7
  * - an attributes compartment (`+ name: type`, with +/-/# visibility markers),
8
8
  * - a methods compartment (`+ name(args): returnType`).
9
9
  *
@@ -12,12 +12,8 @@
12
12
  * (hollow triangle arrowhead) is drawn to its parent; when it declares plain
13
13
  * associations, a simple line connector is drawn instead.
14
14
  *
15
- * `--theme light|dark` drives canvas/box/text colors and `--color <name|hex>`
16
- * drives the accent used for title bars — both genuinely change fill/stroke
17
- * values in the generated SVG.
18
- *
19
15
  * Usage:
20
- * const diag = new ClassDiagram({ classes: [] });
16
+ * const diag = new ClassDiagram({ classes: [...] });
21
17
  * diag.save('./diagrams/classes.svg');
22
18
  * // or:
23
19
  * const svgString = diag.generate();
@@ -59,17 +55,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
59
55
  exports.ClassDiagram = void 0;
60
56
  const fs = __importStar(require("fs"));
61
57
  const path = __importStar(require("path"));
62
- const palette_1 = require("./palette");
63
- const svg_dom_1 = require("./svg-dom");
64
- // ─── Industry design system ────────────────────────────────────────────────
65
- // Barlow / JetBrains Mono typography, hairline borders and square "blueprint"
66
- // corners are fixed by the Industry spec; accent + surface colours still route
67
- // through resolveAccent / resolveTheme so --color / --theme keep working.
68
- const IND_FONT_HEAD = '"Barlow Condensed", system-ui, sans-serif';
69
- const IND_FONT_BODY = '"Barlow", system-ui, sans-serif';
70
- const IND_FONT_MONO = 'ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace';
71
- const IND_HAIRLINE = 'rgba(29,31,32,0.16)';
72
- 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');";
58
+ const svg_1 = require("./core/svg");
59
+ const theme_1 = require("./core/theme");
73
60
  const VIS_MARK = {
74
61
  public: '+',
75
62
  private: '-',
@@ -78,7 +65,6 @@ const VIS_MARK = {
78
65
  function visMark(v) {
79
66
  return VIS_MARK[v ?? 'public'] ?? '+';
80
67
  }
81
- // ─── Main class ────────────────────────────────────────────────────────────
82
68
  class ClassDiagram {
83
69
  constructor(options) {
84
70
  this.opts = {
@@ -143,11 +129,9 @@ class ClassDiagram {
143
129
  });
144
130
  return { placed, byName, cols, rowHeights };
145
131
  }
146
- generate() {
147
- const { title, theme, color } = this.opts;
148
- const accent = (0, palette_1.resolveAccent)(color);
149
- const t = (0, palette_1.resolveTheme)(theme);
150
- const { placed, byName, cols } = this.layout();
132
+ build() {
133
+ const { title } = this.opts;
134
+ const { placed, byName } = this.layout();
151
135
  // Compute canvas bounds from placed boxes.
152
136
  let maxRight = 0;
153
137
  let maxBottom = 0;
@@ -157,52 +141,47 @@ class ClassDiagram {
157
141
  }
158
142
  const svgW = maxRight + ClassDiagram.PAD;
159
143
  const svgH = maxBottom + ClassDiagram.PAD;
160
- const doc = new svg_dom_1.SvgDocument(svgW, svgH);
144
+ const doc = new svg_1.SvgDocument(svgW, svgH);
161
145
  const svg = doc.root;
162
- // Background + embedded Industry web-fonts.
163
- svg.child('rect', { width: svgW, height: svgH, fill: t.canvasBg });
164
- svg.child('style').text(IND_FONT_IMPORT);
165
- // Blueprint style: solid accent header bars + hairline frames, no gradients.
166
- // Optional diagram title.
146
+ svg.child('rect', { width: svgW, height: svgH, fill: theme_1.INK.ground });
167
147
  if (title) {
168
148
  svg
169
149
  .child('text', {
170
150
  x: ClassDiagram.PAD,
171
151
  y: ClassDiagram.PAD + 8,
172
- 'font-family': IND_FONT_HEAD,
173
- 'font-size': 20,
174
- 'font-weight': 600,
175
- fill: t.textPrimary,
152
+ 'font-family': theme_1.FONT.family,
153
+ 'font-size': theme_1.FONT.title + 7,
154
+ 'font-weight': 'bold',
155
+ fill: theme_1.INK.line,
176
156
  })
177
157
  .text(title);
178
158
  }
179
- // ── Connectors (drawn first, under the boxes) ─────────────────────────
159
+ // Connectors, drawn first so they sit under the boxes.
180
160
  for (const p of placed) {
181
161
  const cls = p.cls;
182
- // Inheritance: hollow triangle at the parent.
183
162
  if (cls.extends && byName.has(cls.extends)) {
184
163
  const parent = byName.get(cls.extends);
185
- this.drawInheritance(svg, p, parent, t, accent);
164
+ this.drawInheritance(svg, p, parent);
186
165
  }
187
- // Associations: plain line.
188
166
  for (const assoc of cls.associations ?? []) {
189
167
  const other = byName.get(assoc);
190
168
  if (other && other !== p) {
191
- this.drawAssociation(svg, p, other, t);
169
+ this.drawAssociation(svg, p, other);
192
170
  }
193
171
  }
194
172
  }
195
- // ── Class boxes (drawn on top of connectors) ──────────────────────────
196
173
  for (const p of placed) {
197
- this.drawClassBox(doc, svg, p, t, accent);
174
+ this.drawClassBox(svg, p);
198
175
  }
199
- void cols;
200
- return doc.toString('Generated by ts-prorm-orm ClassDiagram');
176
+ return doc;
177
+ }
178
+ generate() {
179
+ return this.build().toString('Generated by ts-prorm-orm ClassDiagram');
201
180
  }
202
181
  center(p) {
203
182
  return { x: p.x + p.w / 2, y: p.y + p.h / 2 };
204
183
  }
205
- drawAssociation(svg, a, b, t) {
184
+ drawAssociation(svg, a, b) {
206
185
  const c1 = this.center(a);
207
186
  const c2 = this.center(b);
208
187
  svg.child('line', {
@@ -210,11 +189,11 @@ class ClassDiagram {
210
189
  y1: c1.y,
211
190
  x2: c2.x,
212
191
  y2: c2.y,
213
- stroke: t.textSecondary,
214
- 'stroke-width': 1.5,
192
+ stroke: theme_1.INK.line,
193
+ 'stroke-width': theme_1.STROKE.hair,
215
194
  });
216
195
  }
217
- drawInheritance(svg, child, parent, t, accent) {
196
+ drawInheritance(svg, child, parent) {
218
197
  const from = this.center(child);
219
198
  const to = this.center(parent);
220
199
  const dx = to.x - from.x;
@@ -223,7 +202,6 @@ class ClassDiagram {
223
202
  const ux = dx / len;
224
203
  const uy = dy / len;
225
204
  // Stop the line short of the parent so the arrowhead sits at the edge.
226
- void parent;
227
205
  const size = 12;
228
206
  const lineEndX = to.x - ux * size * 1.6;
229
207
  const lineEndY = to.y - uy * size * 1.6;
@@ -232,12 +210,11 @@ class ClassDiagram {
232
210
  y1: from.y,
233
211
  x2: lineEndX,
234
212
  y2: lineEndY,
235
- stroke: accent.mid,
236
- 'stroke-width': 1.8,
213
+ stroke: theme_1.INK.line,
214
+ 'stroke-width': theme_1.STROKE.heavy,
237
215
  });
238
216
  // Hollow triangle arrowhead pointing at the parent center.
239
217
  const tip = { x: to.x - ux * 2, y: to.y - uy * 2 };
240
- // Perpendicular unit vector.
241
218
  const px = -uy;
242
219
  const py = ux;
243
220
  const baseX = tip.x - ux * size;
@@ -246,32 +223,34 @@ class ClassDiagram {
246
223
  const p2 = { x: baseX - px * (size * 0.7), y: baseY - py * (size * 0.7) };
247
224
  svg.child('polygon', {
248
225
  points: `${tip.x},${tip.y} ${p1.x},${p1.y} ${p2.x},${p2.y}`,
249
- fill: t.cardBg,
250
- stroke: accent.mid,
251
- 'stroke-width': 1.8,
226
+ fill: theme_1.INK.ground,
227
+ stroke: theme_1.INK.line,
228
+ 'stroke-width': theme_1.STROKE.heavy,
252
229
  });
253
230
  }
254
- drawClassBox(doc, svg, p, t, accent) {
231
+ drawClassBox(svg, p) {
255
232
  const { cls, x, y, w, h, titleH, attrH } = p;
256
233
  const attrs = cls.attributes ?? [];
257
234
  const methods = cls.methods ?? [];
258
- // Outer box (white interior, hairline border, square corners).
235
+ // Outer box (hairline border, square corners).
259
236
  svg.child('rect', {
260
237
  x,
261
238
  y,
262
239
  width: w,
263
240
  height: h,
264
- fill: t.cardBg,
265
- stroke: t.border,
266
- 'stroke-width': 1,
241
+ fill: theme_1.INK.ground,
242
+ stroke: theme_1.INK.line,
243
+ 'stroke-width': theme_1.STROKE.hair,
267
244
  });
268
- // Title bar (solid accent — blueprint label bar).
245
+ // Title bar.
269
246
  svg.child('rect', {
270
247
  x,
271
248
  y,
272
249
  width: w,
273
250
  height: titleH,
274
- fill: accent.mid,
251
+ fill: theme_1.INK.wash,
252
+ stroke: theme_1.INK.line,
253
+ 'stroke-width': theme_1.STROKE.hair,
275
254
  });
276
255
  let titleTextY = y + 26;
277
256
  if (cls.stereotype) {
@@ -279,36 +258,36 @@ class ClassDiagram {
279
258
  .child('text', {
280
259
  x: x + w / 2,
281
260
  y: y + 18,
282
- 'font-family': IND_FONT_BODY,
283
- 'font-size': 11,
261
+ 'font-family': theme_1.FONT.family,
262
+ 'font-size': theme_1.FONT.small + 2,
284
263
  'font-style': 'italic',
285
- fill: 'rgba(255,255,255,0.85)',
264
+ fill: theme_1.INK.muted,
286
265
  'text-anchor': 'middle',
287
266
  })
288
- .text(`«${cls.stereotype}»`);
267
+ .text(`<<${cls.stereotype}>>`);
289
268
  titleTextY = y + 34;
290
269
  }
291
270
  svg
292
271
  .child('text', {
293
272
  x: x + w / 2,
294
273
  y: titleTextY,
295
- 'font-family': IND_FONT_HEAD,
296
- 'font-size': 15,
297
- 'font-weight': 600,
298
- fill: '#FFFFFF',
274
+ 'font-family': theme_1.FONT.family,
275
+ 'font-size': theme_1.FONT.body + 4,
276
+ 'font-weight': 'bold',
277
+ fill: theme_1.INK.line,
299
278
  'text-anchor': 'middle',
300
279
  })
301
280
  .text(cls.name);
302
281
  // Attributes compartment.
303
282
  const attrTop = y + titleH;
304
- svg.child('rect', { x, y: attrTop, width: w, height: attrH, fill: t.rowAlt });
283
+ svg.child('rect', { x, y: attrTop, width: w, height: attrH, fill: theme_1.INK.wash });
305
284
  svg.child('line', {
306
285
  x1: x,
307
286
  y1: attrTop,
308
287
  x2: x + w,
309
288
  y2: attrTop,
310
- stroke: t.border,
311
- 'stroke-width': 1,
289
+ stroke: theme_1.INK.line,
290
+ 'stroke-width': theme_1.STROKE.hair,
312
291
  });
313
292
  attrs.forEach((a, i) => {
314
293
  const rowY = attrTop + ClassDiagram.COMPARTMENT_PAD + i * ClassDiagram.ROW_H + 15;
@@ -318,24 +297,24 @@ class ClassDiagram {
318
297
  .child('text', {
319
298
  x: x + 12,
320
299
  y: rowY,
321
- 'font-family': IND_FONT_MONO,
322
- 'font-size': 12,
300
+ 'font-family': theme_1.FONT.mono,
301
+ 'font-size': theme_1.FONT.body + 1,
323
302
  'font-weight': 500,
324
303
  'text-decoration': a.static ? 'underline' : undefined,
325
- fill: t.textPrimary,
304
+ fill: theme_1.INK.line,
326
305
  })
327
306
  .text(label);
328
307
  });
329
308
  // Methods compartment.
330
309
  const methodTop = attrTop + attrH;
331
- svg.child('rect', { x, y: methodTop, width: w, height: h - titleH - attrH, fill: t.cardBg });
310
+ svg.child('rect', { x, y: methodTop, width: w, height: h - titleH - attrH, fill: theme_1.INK.ground });
332
311
  svg.child('line', {
333
312
  x1: x,
334
313
  y1: methodTop,
335
314
  x2: x + w,
336
315
  y2: methodTop,
337
- stroke: t.border,
338
- 'stroke-width': 1,
316
+ stroke: theme_1.INK.line,
317
+ 'stroke-width': theme_1.STROKE.hair,
339
318
  });
340
319
  methods.forEach((m, i) => {
341
320
  const rowY = methodTop + ClassDiagram.COMPARTMENT_PAD + i * ClassDiagram.ROW_H + 15;
@@ -345,14 +324,13 @@ class ClassDiagram {
345
324
  .child('text', {
346
325
  x: x + 12,
347
326
  y: rowY,
348
- 'font-family': IND_FONT_MONO,
349
- 'font-size': 12,
327
+ 'font-family': theme_1.FONT.mono,
328
+ 'font-size': theme_1.FONT.body + 1,
350
329
  'font-weight': 500,
351
- fill: t.textSecondary,
330
+ fill: theme_1.INK.muted,
352
331
  })
353
332
  .text(label);
354
333
  });
355
- void doc;
356
334
  }
357
335
  /**
358
336
  * Write the SVG to a file. Creates parent directories if needed.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Diagram core: the minimal set every generator builds on.
3
+ *
4
+ * - `svg` DOM-backed element builder and document serializer
5
+ * - `theme` one monochrome hairline theme
6
+ * - `layout` text measurement, panels, edges, grid packing
7
+ */
8
+ export { El, SvgDocument } from './svg';
9
+ export type { AttrValue, Attrs } from './svg';
10
+ export { INK, STROKE, FONT, SPACE, ROW_HEIGHT, THEME } from './theme';
11
+ export type { Theme } from './theme';
12
+ export { measureText, truncate, rect, line, text, panel, panelSize, defineArrowhead, edge, gridPack, documentTitle, footer, } from './layout';
13
+ export type { Box, PanelRow, PanelOptions, TextOptions } from './layout';
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Diagram core: the minimal set every generator builds on.
4
+ *
5
+ * - `svg` DOM-backed element builder and document serializer
6
+ * - `theme` one monochrome hairline theme
7
+ * - `layout` text measurement, panels, edges, grid packing
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.footer = exports.documentTitle = exports.gridPack = exports.edge = exports.defineArrowhead = exports.panelSize = exports.panel = exports.text = exports.line = exports.rect = exports.truncate = exports.measureText = exports.THEME = exports.ROW_HEIGHT = exports.SPACE = exports.FONT = exports.STROKE = exports.INK = exports.SvgDocument = exports.El = void 0;
11
+ var svg_1 = require("./svg");
12
+ Object.defineProperty(exports, "El", { enumerable: true, get: function () { return svg_1.El; } });
13
+ Object.defineProperty(exports, "SvgDocument", { enumerable: true, get: function () { return svg_1.SvgDocument; } });
14
+ var theme_1 = require("./theme");
15
+ Object.defineProperty(exports, "INK", { enumerable: true, get: function () { return theme_1.INK; } });
16
+ Object.defineProperty(exports, "STROKE", { enumerable: true, get: function () { return theme_1.STROKE; } });
17
+ Object.defineProperty(exports, "FONT", { enumerable: true, get: function () { return theme_1.FONT; } });
18
+ Object.defineProperty(exports, "SPACE", { enumerable: true, get: function () { return theme_1.SPACE; } });
19
+ Object.defineProperty(exports, "ROW_HEIGHT", { enumerable: true, get: function () { return theme_1.ROW_HEIGHT; } });
20
+ Object.defineProperty(exports, "THEME", { enumerable: true, get: function () { return theme_1.THEME; } });
21
+ var layout_1 = require("./layout");
22
+ Object.defineProperty(exports, "measureText", { enumerable: true, get: function () { return layout_1.measureText; } });
23
+ Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return layout_1.truncate; } });
24
+ Object.defineProperty(exports, "rect", { enumerable: true, get: function () { return layout_1.rect; } });
25
+ Object.defineProperty(exports, "line", { enumerable: true, get: function () { return layout_1.line; } });
26
+ Object.defineProperty(exports, "text", { enumerable: true, get: function () { return layout_1.text; } });
27
+ Object.defineProperty(exports, "panel", { enumerable: true, get: function () { return layout_1.panel; } });
28
+ Object.defineProperty(exports, "panelSize", { enumerable: true, get: function () { return layout_1.panelSize; } });
29
+ Object.defineProperty(exports, "defineArrowhead", { enumerable: true, get: function () { return layout_1.defineArrowhead; } });
30
+ Object.defineProperty(exports, "edge", { enumerable: true, get: function () { return layout_1.edge; } });
31
+ Object.defineProperty(exports, "gridPack", { enumerable: true, get: function () { return layout_1.gridPack; } });
32
+ Object.defineProperty(exports, "documentTitle", { enumerable: true, get: function () { return layout_1.documentTitle; } });
33
+ Object.defineProperty(exports, "footer", { enumerable: true, get: function () { return layout_1.footer; } });
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Layout primitives shared by every generator.
3
+ *
4
+ * Each generator previously carried its own text measurement, box drawing,
5
+ * arrow routing and footer code. These are the pieces that were duplicated,
6
+ * factored once so a change to how a panel or an edge looks lands everywhere.
7
+ */
8
+ import { El } from './svg';
9
+ /**
10
+ * Approximate rendered width of a string.
11
+ *
12
+ * SVG has no text metrics without a layout engine, so this is the usual
13
+ * average-advance estimate. It is deliberately slightly generous: under-
14
+ * measuring clips text, over-measuring only adds whitespace.
15
+ */
16
+ export declare function measureText(text: string, size?: number, mono?: boolean): number;
17
+ /** Truncate to fit `maxWidth`, appending a single-character ellipsis. */
18
+ export declare function truncate(text: string, maxWidth: number, size?: number, mono?: boolean): string;
19
+ /** A laid-out rectangle. */
20
+ export interface Box {
21
+ x: number;
22
+ y: number;
23
+ w: number;
24
+ h: number;
25
+ }
26
+ /** Draw a plain hairline rectangle. */
27
+ export declare function rect(parent: El, box: Box, fill?: string): El;
28
+ /** Draw a hairline between two points. */
29
+ export declare function line(parent: El, x1: number, y1: number, x2: number, y2: number, dashed?: boolean): El;
30
+ /** Options for a single run of text. */
31
+ export interface TextOptions {
32
+ size?: number;
33
+ mono?: boolean;
34
+ fill?: string;
35
+ anchor?: 'start' | 'middle' | 'end';
36
+ weight?: 'normal' | 'bold';
37
+ }
38
+ /** Draw a run of text. */
39
+ export declare function text(parent: El, x: number, y: number, value: string, opts?: TextOptions): El;
40
+ /** One row inside a panel. */
41
+ export interface PanelRow {
42
+ /** Left-hand label (field name, column, step). */
43
+ label: string;
44
+ /** Optional right-hand detail (type, value). */
45
+ detail?: string;
46
+ /** Optional short marker rendered before the label (PK, FK, +, -). */
47
+ marker?: string;
48
+ /** Draw a rule above this row, for grouping. */
49
+ rule?: boolean;
50
+ }
51
+ /** A titled box with a header bar and a list of rows - the workhorse shape. */
52
+ export interface PanelOptions {
53
+ title: string;
54
+ subtitle?: string;
55
+ rows?: PanelRow[];
56
+ /** Minimum width; the panel grows to fit its content. */
57
+ minWidth?: number;
58
+ }
59
+ /** Compute a panel's size without drawing it, for layout passes. */
60
+ export declare function panelSize(opts: PanelOptions): {
61
+ w: number;
62
+ h: number;
63
+ };
64
+ /**
65
+ * Draw a titled panel at `x,y` and return the box it occupies.
66
+ *
67
+ * The header is a washed bar with a hairline under it; rows are plain text with
68
+ * the detail column right-aligned.
69
+ */
70
+ export declare function panel(parent: El, x: number, y: number, opts: PanelOptions): Box;
71
+ /** Register the single arrowhead marker. Call once per document. */
72
+ export declare function defineArrowhead(defs: El, id?: string): void;
73
+ /** Draw a straight edge, optionally arrowed and/or dashed, with a label. */
74
+ export declare function edge(parent: El, from: {
75
+ x: number;
76
+ y: number;
77
+ }, to: {
78
+ x: number;
79
+ y: number;
80
+ }, opts?: {
81
+ arrow?: boolean;
82
+ dashed?: boolean;
83
+ label?: string;
84
+ markerId?: string;
85
+ }): El;
86
+ /** Pack boxes into a grid, returning positions and the total canvas size. */
87
+ export declare function gridPack(sizes: Array<{
88
+ w: number;
89
+ h: number;
90
+ }>, columns: number, gap?: number, origin?: {
91
+ x: 24;
92
+ y: 24;
93
+ }): {
94
+ positions: Array<{
95
+ x: number;
96
+ y: number;
97
+ }>;
98
+ width: number;
99
+ height: number;
100
+ };
101
+ /** Draw a title at the top of a document. Returns the y to continue from. */
102
+ export declare function documentTitle(parent: El, x: number, y: number, title: string): number;
103
+ /** Draw a footer line. Plain text, no separators or glyphs. */
104
+ export declare function footer(parent: El, x: number, y: number, parts: string[]): El;