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.
- package/CHANGELOG.md +209 -0
- package/README.md +32 -24
- package/dist/compliance/index.d.ts +2 -0
- package/dist/compliance/index.js +13 -1
- package/dist/connection-manager.js +13 -1
- package/dist/core/expressions.d.ts +58 -0
- package/dist/core/expressions.js +83 -0
- package/dist/core/hooks-manager.d.ts +179 -0
- package/dist/core/hooks-manager.js +291 -0
- package/dist/core/types.d.ts +235 -0
- package/dist/core/types.js +9 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.js +11 -1
- package/dist/diagrams/chen-diagram.d.ts +15 -12
- package/dist/diagrams/chen-diagram.js +76 -85
- package/dist/diagrams/class-diagram.d.ts +9 -8
- package/dist/diagrams/class-diagram.js +60 -82
- package/dist/diagrams/core/index.d.ts +13 -0
- package/dist/diagrams/core/index.js +33 -0
- package/dist/diagrams/core/layout.d.ts +104 -0
- package/dist/diagrams/core/layout.js +223 -0
- package/dist/diagrams/{svg-dom.d.ts → core/svg.d.ts} +8 -20
- package/dist/diagrams/{svg-dom.js → core/svg.js} +21 -29
- package/dist/diagrams/core/theme.d.ts +84 -0
- package/dist/diagrams/core/theme.js +62 -0
- package/dist/diagrams/dependency-diagram.d.ts +15 -14
- package/dist/diagrams/dependency-diagram.js +71 -105
- package/dist/diagrams/er-diagram.d.ts +13 -26
- package/dist/diagrams/er-diagram.js +180 -259
- package/dist/diagrams/flow-diagram.d.ts +16 -11
- package/dist/diagrams/flow-diagram.js +96 -91
- package/dist/diagrams/gantt-diagram.d.ts +10 -5
- package/dist/diagrams/gantt-diagram.js +77 -103
- package/dist/diagrams/index-diagram.d.ts +10 -10
- package/dist/diagrams/index-diagram.js +106 -116
- package/dist/diagrams/index.d.ts +6 -9
- package/dist/diagrams/index.js +9 -24
- package/dist/diagrams/migration-diagram.d.ts +8 -4
- package/dist/diagrams/migration-diagram.js +189 -161
- package/dist/diagrams/model-diagram.d.ts +34 -34
- package/dist/diagrams/model-diagram.js +106 -485
- package/dist/diagrams/package-diagram.d.ts +9 -6
- package/dist/diagrams/package-diagram.js +64 -101
- package/dist/diagrams/relational-diagram.d.ts +12 -10
- package/dist/diagrams/relational-diagram.js +87 -114
- package/dist/diagrams/schemadoc-diagram.d.ts +8 -8
- package/dist/diagrams/schemadoc-diagram.js +71 -93
- package/dist/diagrams/sequence-diagram.d.ts +10 -10
- package/dist/diagrams/sequence-diagram.js +64 -89
- package/dist/diagrams/state-diagram.d.ts +10 -9
- package/dist/diagrams/state-diagram.js +69 -92
- package/dist/diagrams/tree-diagram.d.ts +11 -5
- package/dist/diagrams/tree-diagram.js +41 -65
- package/dist/dialects/clickhouse/index.js +15 -0
- package/dist/dialects/cockroachdb/index.d.ts +1 -1
- package/dist/dialects/cockroachdb/index.js +32 -63
- package/dist/dialects/db2/index.js +23 -8
- package/dist/dialects/dialect.d.ts +29 -5
- package/dist/dialects/duckdb/index.js +9 -2
- package/dist/dialects/hana/index.js +22 -5
- package/dist/dialects/lock-clause-helper.d.ts +167 -0
- package/dist/dialects/lock-clause-helper.js +316 -0
- package/dist/dialects/mariadb/index.d.ts +7 -4
- package/dist/dialects/mariadb/index.js +36 -60
- package/dist/dialects/mssql/index.js +34 -3
- package/dist/dialects/mysql/index.d.ts +1 -1
- package/dist/dialects/mysql/index.js +17 -45
- package/dist/dialects/oracle/index.d.ts +14 -3
- package/dist/dialects/oracle/index.js +66 -36
- package/dist/dialects/order-expression-helper.d.ts +72 -0
- package/dist/dialects/order-expression-helper.js +154 -0
- package/dist/dialects/partial-index.d.ts +52 -0
- package/dist/dialects/partial-index.js +251 -0
- package/dist/dialects/postgres/index.d.ts +1 -1
- package/dist/dialects/postgres/index.js +43 -68
- package/dist/dialects/redshift/index.js +9 -2
- package/dist/dialects/snowflake/index.js +17 -0
- package/dist/dialects/spanner/index.js +7 -2
- package/dist/dialects/sqlite/driver.d.ts +55 -0
- package/dist/dialects/sqlite/driver.js +102 -0
- package/dist/dialects/sqlite/index.d.ts +1 -1
- package/dist/dialects/sqlite/index.js +49 -27
- package/dist/graph/base-graph-dialect.d.ts +24 -3
- package/dist/graph/base-graph-dialect.js +43 -2
- package/dist/graph/dgraph/index.js +6 -0
- package/dist/graph/gremlin/index.d.ts +6 -0
- package/dist/graph/gremlin/index.js +12 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/neo4j/index.d.ts +2 -0
- package/dist/graph/neo4j/index.js +6 -1
- package/dist/graph/types.d.ts +12 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.js +54 -7
- package/dist/logging/index.d.ts +10 -0
- package/dist/logging/index.js +23 -0
- package/dist/logging/query-logging.d.ts +82 -0
- package/dist/logging/query-logging.js +102 -0
- package/dist/models/decorators.d.ts +39 -3
- package/dist/models/decorators.js +74 -0
- package/dist/models/eager-load.d.ts +99 -0
- package/dist/models/eager-load.js +348 -5
- package/dist/models/indexes.d.ts +3 -2
- package/dist/models/indexes.js +7 -1
- package/dist/models/model.js +69 -43
- package/dist/prorm.d.ts +175 -409
- package/dist/prorm.js +1142 -557
- package/dist/query-builders/order-limit-builder.js +12 -10
- package/dist/query-builders/sql-compiler.d.ts +10 -3
- package/dist/query-builders/sql-compiler.js +14 -43
- package/dist/query-interface.d.ts +2 -1
- package/dist/sql-constants.d.ts +44 -0
- package/dist/sql-constants.js +138 -1
- package/dist/types/index.d.ts +53 -17
- package/dist/types/index.js +10 -15
- package/dist/types/query-types.d.ts +26 -0
- package/dist/types/query-types.js +30 -0
- package/package.json +32 -5
- package/dist/decorators/belongs-to-many.js +0 -115
- package/dist/decorators/belongs-to.js +0 -115
- package/dist/decorators/has-many.js +0 -127
- package/dist/decorators/has-one.js +0 -116
- package/dist/diagrams/palette.d.ts +0 -138
- package/dist/diagrams/palette.js +0 -194
- package/dist/hooks/hooks-manager.d.ts +0 -189
- package/dist/hooks/hooks-manager.js +0 -350
- package/dist/hooks/index.d.ts +0 -8
- package/dist/hooks/index.js +0 -37
- /package/dist/{logging.d.ts → logging/logger.d.ts} +0 -0
- /package/dist/{logging.js → logging/logger.js} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* GanttDiagram
|
|
3
|
+
* GanttDiagram - generates a horizontal timeline / Gantt chart SVG.
|
|
4
4
|
*
|
|
5
5
|
* Features:
|
|
6
6
|
* - Left label column listing task/row names
|
|
7
7
|
* - Right time-axis area with vertical gridlines (days / weeks / months)
|
|
8
8
|
* - One horizontal bar per task, positioned/sized by its start & end dates
|
|
9
|
-
* - Tasks grouped into sections
|
|
9
|
+
* - Tasks grouped into sections
|
|
10
10
|
* - Optional % complete overlay drawn on top of each bar
|
|
11
11
|
* - Milestones rendered as diamonds
|
|
12
12
|
* - Dependency arrows drawn between a task and the task it depends on
|
|
13
|
-
* - Auto-sized SVG viewBox
|
|
13
|
+
* - Auto-sized SVG viewBox
|
|
14
14
|
*
|
|
15
15
|
* The time scale is computed from the minimum start to the maximum end across
|
|
16
|
-
* all tasks; dates are mapped linearly to x. Everything is deterministic
|
|
16
|
+
* all tasks; dates are mapped linearly to x. Everything is deterministic -
|
|
17
17
|
* no Date.now()/new Date()-with-no-args/Math.random() is used.
|
|
18
18
|
*
|
|
19
19
|
* Usage:
|
|
@@ -58,24 +58,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
58
58
|
exports.GanttDiagram = void 0;
|
|
59
59
|
const fs = __importStar(require("fs"));
|
|
60
60
|
const path = __importStar(require("path"));
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
// Barlow / JetBrains Mono typography, hairline borders and square "blueprint"
|
|
65
|
-
// corners are fixed by the Industry spec; accent + surface colours still route
|
|
66
|
-
// through resolveAccent / resolveTheme so --color / --theme keep working.
|
|
67
|
-
const IND_FONT_HEAD = '"Barlow Condensed", system-ui, sans-serif';
|
|
68
|
-
const IND_FONT_BODY = '"Barlow", system-ui, sans-serif';
|
|
69
|
-
const IND_FONT_MONO = 'ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace';
|
|
70
|
-
const IND_HAIRLINE = 'rgba(29,31,32,0.16)';
|
|
71
|
-
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');";
|
|
72
|
-
// ─── Internal helpers ──────────────────────────────────────────────────────
|
|
61
|
+
const svg_1 = require("./core/svg");
|
|
62
|
+
const theme_1 = require("./core/theme");
|
|
63
|
+
const layout_1 = require("./core/layout");
|
|
73
64
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
74
65
|
function parseDate(s) {
|
|
75
66
|
const t = new Date(s).getTime();
|
|
76
67
|
return Number.isNaN(t) ? 0 : t;
|
|
77
68
|
}
|
|
78
|
-
// ─── Main class ────────────────────────────────────────────────────────────
|
|
79
69
|
class GanttDiagram {
|
|
80
70
|
constructor(options) {
|
|
81
71
|
this.opts = {
|
|
@@ -88,7 +78,6 @@ class GanttDiagram {
|
|
|
88
78
|
}
|
|
89
79
|
/** Group tasks into sections preserving first-seen order. */
|
|
90
80
|
buildSections() {
|
|
91
|
-
const palettes = (0, palette_1.rotatedPalettes)(this.opts.color);
|
|
92
81
|
const order = [];
|
|
93
82
|
const map = new Map();
|
|
94
83
|
this.opts.tasks.forEach((task, index) => {
|
|
@@ -99,16 +88,13 @@ class GanttDiagram {
|
|
|
99
88
|
}
|
|
100
89
|
map.get(key).push({ task, index });
|
|
101
90
|
});
|
|
102
|
-
return order.map((name
|
|
91
|
+
return order.map((name) => ({
|
|
103
92
|
name,
|
|
104
|
-
accent: palettes[i % palettes.length],
|
|
105
93
|
tasks: map.get(name),
|
|
106
94
|
}));
|
|
107
95
|
}
|
|
108
|
-
|
|
109
|
-
const { title,
|
|
110
|
-
const accent = (0, palette_1.resolveAccent)(color);
|
|
111
|
-
const t = (0, palette_1.resolveTheme)(theme);
|
|
96
|
+
build() {
|
|
97
|
+
const { title, axis, tasks } = this.opts;
|
|
112
98
|
const LABEL_W = GanttDiagram.LABEL_W;
|
|
113
99
|
const AXIS_W = GanttDiagram.AXIS_W;
|
|
114
100
|
const HDR = GanttDiagram.HDR;
|
|
@@ -117,9 +103,8 @@ class GanttDiagram {
|
|
|
117
103
|
const SECTION_H = GanttDiagram.SECTION_H;
|
|
118
104
|
const BAR_PAD = GanttDiagram.BAR_PAD;
|
|
119
105
|
const PAD = GanttDiagram.PAD;
|
|
120
|
-
const FOOTER = GanttDiagram.FOOTER;
|
|
121
106
|
const sections = this.buildSections();
|
|
122
|
-
//
|
|
107
|
+
// Time scale: min start to max end across all tasks.
|
|
123
108
|
let minStart = Infinity;
|
|
124
109
|
let maxEnd = -Infinity;
|
|
125
110
|
for (const task of tasks) {
|
|
@@ -135,7 +120,7 @@ class GanttDiagram {
|
|
|
135
120
|
if (!Number.isFinite(maxEnd) || maxEnd <= minStart)
|
|
136
121
|
maxEnd = minStart + DAY_MS;
|
|
137
122
|
const span = maxEnd - minStart;
|
|
138
|
-
//
|
|
123
|
+
// Row layout: sections add a heading row each.
|
|
139
124
|
const showSectionHeadings = sections.some((s) => s.name !== '');
|
|
140
125
|
let bodyH = 0;
|
|
141
126
|
for (const sec of sections) {
|
|
@@ -147,54 +132,40 @@ class GanttDiagram {
|
|
|
147
132
|
const chartLeft = PAD;
|
|
148
133
|
const axisLeft = chartLeft + LABEL_W;
|
|
149
134
|
const svgW = LABEL_W + AXIS_W + 2 * PAD;
|
|
150
|
-
const svgH = chartTop + bodyH + FOOTER + PAD;
|
|
151
|
-
const doc = new
|
|
135
|
+
const svgH = chartTop + bodyH + GanttDiagram.FOOTER + PAD;
|
|
136
|
+
const doc = new svg_1.SvgDocument(svgW, svgH);
|
|
152
137
|
const svg = doc.root;
|
|
153
|
-
|
|
154
|
-
// ── Map a date (ms) → x within the axis area ─────────────────────────
|
|
138
|
+
// Map a date (ms) to x within the axis area.
|
|
155
139
|
const xForMs = (ms) => axisLeft + ((ms - minStart) / span) * AXIS_W;
|
|
156
140
|
const xForDate = (s) => xForMs(parseDate(s));
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// ── Defs: arrow marker (solid accent header — no gradient) ──────────
|
|
161
|
-
const marker = doc
|
|
162
|
-
.defs()
|
|
163
|
-
.child('marker', {
|
|
164
|
-
id: `arrow${uid}`,
|
|
165
|
-
markerWidth: 8,
|
|
166
|
-
markerHeight: 8,
|
|
167
|
-
refX: 6,
|
|
168
|
-
refY: 3,
|
|
169
|
-
orient: 'auto',
|
|
170
|
-
markerUnits: 'userSpaceOnUse',
|
|
171
|
-
});
|
|
172
|
-
marker.child('path', { d: 'M0,0 L6,3 L0,6 Z', fill: t.textSecondary });
|
|
173
|
-
// ── Header bar ──────────────────────────────────────────────────────
|
|
141
|
+
svg.child('rect', { class: 'canvas', width: svgW, height: svgH, fill: theme_1.INK.ground });
|
|
142
|
+
(0, layout_1.defineArrowhead)(doc.defs(), 'ganttArrow');
|
|
143
|
+
// Header bar.
|
|
174
144
|
svg.child('rect', {
|
|
175
145
|
class: 'header',
|
|
176
146
|
x: chartLeft,
|
|
177
147
|
y: PAD,
|
|
178
148
|
width: LABEL_W + AXIS_W,
|
|
179
149
|
height: HDR,
|
|
180
|
-
fill:
|
|
150
|
+
fill: theme_1.INK.wash,
|
|
151
|
+
stroke: theme_1.INK.line,
|
|
152
|
+
'stroke-width': theme_1.STROKE.hair,
|
|
181
153
|
});
|
|
182
154
|
svg
|
|
183
155
|
.child('text', {
|
|
184
156
|
x: chartLeft + 18,
|
|
185
157
|
y: PAD + 40,
|
|
186
|
-
'font-family':
|
|
187
|
-
'font-size':
|
|
188
|
-
'font-weight':
|
|
189
|
-
fill:
|
|
158
|
+
'font-family': theme_1.FONT.family,
|
|
159
|
+
'font-size': theme_1.FONT.title + 9,
|
|
160
|
+
'font-weight': 'bold',
|
|
161
|
+
fill: theme_1.INK.line,
|
|
190
162
|
})
|
|
191
163
|
.text(title);
|
|
192
|
-
//
|
|
164
|
+
// Axis area geometry.
|
|
193
165
|
const axisTop = PAD + HDR;
|
|
194
166
|
const chartBottom = chartTop + bodyH;
|
|
195
|
-
//
|
|
167
|
+
// Gridlines + axis tick labels.
|
|
196
168
|
const step = axis === 'days' ? DAY_MS : axis === 'months' ? 30 * DAY_MS : 7 * DAY_MS;
|
|
197
|
-
// Iterate from minStart to maxEnd inclusive, drawing a vertical line at each tick.
|
|
198
169
|
for (let ms = minStart; ms <= maxEnd + 1; ms += step) {
|
|
199
170
|
const x = xForMs(Math.min(ms, maxEnd));
|
|
200
171
|
svg.child('line', {
|
|
@@ -203,8 +174,8 @@ class GanttDiagram {
|
|
|
203
174
|
y1: axisTop + AXIS_HDR,
|
|
204
175
|
x2: x,
|
|
205
176
|
y2: chartBottom,
|
|
206
|
-
stroke:
|
|
207
|
-
'stroke-width':
|
|
177
|
+
stroke: theme_1.INK.line,
|
|
178
|
+
'stroke-width': theme_1.STROKE.hair,
|
|
208
179
|
});
|
|
209
180
|
const label = new Date(ms).toISOString().slice(0, 10);
|
|
210
181
|
svg
|
|
@@ -212,9 +183,9 @@ class GanttDiagram {
|
|
|
212
183
|
class: 'axis-tick',
|
|
213
184
|
x: x + 3,
|
|
214
185
|
y: axisTop + AXIS_HDR - 8,
|
|
215
|
-
'font-family':
|
|
216
|
-
'font-size':
|
|
217
|
-
fill:
|
|
186
|
+
'font-family': theme_1.FONT.mono,
|
|
187
|
+
'font-size': theme_1.FONT.small - 1,
|
|
188
|
+
fill: theme_1.INK.muted,
|
|
218
189
|
})
|
|
219
190
|
.text(label);
|
|
220
191
|
}
|
|
@@ -225,8 +196,8 @@ class GanttDiagram {
|
|
|
225
196
|
y1: axisTop + AXIS_HDR,
|
|
226
197
|
x2: xForMs(maxEnd),
|
|
227
198
|
y2: chartBottom,
|
|
228
|
-
stroke:
|
|
229
|
-
'stroke-width':
|
|
199
|
+
stroke: theme_1.INK.line,
|
|
200
|
+
'stroke-width': theme_1.STROKE.hair,
|
|
230
201
|
});
|
|
231
202
|
// Separator between label column and axis.
|
|
232
203
|
svg.child('line', {
|
|
@@ -235,11 +206,11 @@ class GanttDiagram {
|
|
|
235
206
|
y1: axisTop,
|
|
236
207
|
x2: axisLeft,
|
|
237
208
|
y2: chartBottom,
|
|
238
|
-
stroke:
|
|
239
|
-
'stroke-width':
|
|
209
|
+
stroke: theme_1.INK.line,
|
|
210
|
+
'stroke-width': theme_1.STROKE.heavy,
|
|
240
211
|
});
|
|
241
|
-
//
|
|
242
|
-
//
|
|
212
|
+
// Rows: sections + tasks + bars. Track each task's bar geometry by name
|
|
213
|
+
// for dependency arrows.
|
|
243
214
|
const barGeom = new Map();
|
|
244
215
|
let y = chartTop;
|
|
245
216
|
for (const sec of sections) {
|
|
@@ -250,7 +221,7 @@ class GanttDiagram {
|
|
|
250
221
|
y,
|
|
251
222
|
width: LABEL_W + AXIS_W,
|
|
252
223
|
height: SECTION_H,
|
|
253
|
-
fill:
|
|
224
|
+
fill: theme_1.INK.wash,
|
|
254
225
|
});
|
|
255
226
|
svg.child('rect', {
|
|
256
227
|
class: 'section-accent',
|
|
@@ -258,17 +229,17 @@ class GanttDiagram {
|
|
|
258
229
|
y,
|
|
259
230
|
width: 5,
|
|
260
231
|
height: SECTION_H,
|
|
261
|
-
fill:
|
|
232
|
+
fill: theme_1.INK.line,
|
|
262
233
|
});
|
|
263
234
|
svg
|
|
264
235
|
.child('text', {
|
|
265
236
|
class: 'section-label',
|
|
266
237
|
x: chartLeft + 16,
|
|
267
238
|
y: y + SECTION_H / 2 + 4,
|
|
268
|
-
'font-family':
|
|
269
|
-
'font-size':
|
|
270
|
-
'font-weight':
|
|
271
|
-
fill:
|
|
239
|
+
'font-family': theme_1.FONT.family,
|
|
240
|
+
'font-size': theme_1.FONT.body + 1,
|
|
241
|
+
'font-weight': 'bold',
|
|
242
|
+
fill: theme_1.INK.line,
|
|
272
243
|
'letter-spacing': 0.5,
|
|
273
244
|
})
|
|
274
245
|
.text(sec.name);
|
|
@@ -277,19 +248,18 @@ class GanttDiagram {
|
|
|
277
248
|
for (const { task } of sec.tasks) {
|
|
278
249
|
const rowY = y;
|
|
279
250
|
const midY = rowY + ROW_H / 2;
|
|
280
|
-
// Row label
|
|
281
|
-
const dispName = task.name.length > 26 ? task.name.slice(0, 25) + '…' : task.name;
|
|
251
|
+
// Row label.
|
|
282
252
|
svg
|
|
283
253
|
.child('text', {
|
|
284
254
|
class: 'task-label',
|
|
285
255
|
x: chartLeft + 14,
|
|
286
256
|
y: midY + 4,
|
|
287
|
-
'font-family':
|
|
288
|
-
'font-size':
|
|
289
|
-
'font-weight':
|
|
290
|
-
fill:
|
|
257
|
+
'font-family': theme_1.FONT.family,
|
|
258
|
+
'font-size': theme_1.FONT.body + 1,
|
|
259
|
+
'font-weight': 'bold',
|
|
260
|
+
fill: theme_1.INK.line,
|
|
291
261
|
})
|
|
292
|
-
.text(
|
|
262
|
+
.text((0, layout_1.truncate)(task.name, LABEL_W - 24, theme_1.FONT.body + 1));
|
|
293
263
|
const sx = xForDate(task.start);
|
|
294
264
|
const ex = xForDate(task.end);
|
|
295
265
|
if (task.milestone) {
|
|
@@ -300,9 +270,9 @@ class GanttDiagram {
|
|
|
300
270
|
svg.child('path', {
|
|
301
271
|
class: 'milestone',
|
|
302
272
|
d: `M${cx},${cy - r} L${cx + r},${cy} L${cx},${cy + r} L${cx - r},${cy} Z`,
|
|
303
|
-
fill:
|
|
304
|
-
stroke:
|
|
305
|
-
'stroke-width':
|
|
273
|
+
fill: theme_1.INK.line,
|
|
274
|
+
stroke: theme_1.INK.line,
|
|
275
|
+
'stroke-width': theme_1.STROKE.hair,
|
|
306
276
|
});
|
|
307
277
|
barGeom.set(task.name, { x: cx - r, y: cy - r, w: 2 * r, h: 2 * r });
|
|
308
278
|
}
|
|
@@ -310,17 +280,18 @@ class GanttDiagram {
|
|
|
310
280
|
const barY = rowY + BAR_PAD;
|
|
311
281
|
const barH = ROW_H - 2 * BAR_PAD;
|
|
312
282
|
const barW = Math.max(2, ex - sx);
|
|
313
|
-
// Full bar
|
|
283
|
+
// Full bar.
|
|
314
284
|
svg.child('rect', {
|
|
315
285
|
class: 'bar',
|
|
316
286
|
x: sx,
|
|
317
287
|
y: barY,
|
|
318
288
|
width: barW,
|
|
319
289
|
height: barH,
|
|
320
|
-
fill:
|
|
321
|
-
|
|
290
|
+
fill: theme_1.INK.wash,
|
|
291
|
+
stroke: theme_1.INK.line,
|
|
292
|
+
'stroke-width': theme_1.STROKE.hair,
|
|
322
293
|
});
|
|
323
|
-
// % complete overlay
|
|
294
|
+
// % complete overlay.
|
|
324
295
|
if (typeof task.percent === 'number' && task.percent > 0) {
|
|
325
296
|
const pct = Math.max(0, Math.min(100, task.percent));
|
|
326
297
|
svg.child('rect', {
|
|
@@ -329,17 +300,17 @@ class GanttDiagram {
|
|
|
329
300
|
y: barY,
|
|
330
301
|
width: Math.max(1, (barW * pct) / 100),
|
|
331
302
|
height: barH,
|
|
332
|
-
fill:
|
|
303
|
+
fill: theme_1.INK.line,
|
|
333
304
|
});
|
|
334
305
|
svg
|
|
335
306
|
.child('text', {
|
|
336
307
|
class: 'bar-pct',
|
|
337
308
|
x: sx + barW + 6,
|
|
338
309
|
y: midY + 4,
|
|
339
|
-
'font-family':
|
|
340
|
-
'font-size':
|
|
341
|
-
'font-weight':
|
|
342
|
-
fill:
|
|
310
|
+
'font-family': theme_1.FONT.mono,
|
|
311
|
+
'font-size': theme_1.FONT.small - 1,
|
|
312
|
+
'font-weight': 'bold',
|
|
313
|
+
fill: theme_1.INK.muted,
|
|
343
314
|
})
|
|
344
315
|
.text(`${pct}%`);
|
|
345
316
|
}
|
|
@@ -348,7 +319,7 @@ class GanttDiagram {
|
|
|
348
319
|
y += ROW_H;
|
|
349
320
|
}
|
|
350
321
|
}
|
|
351
|
-
//
|
|
322
|
+
// Dependency arrows.
|
|
352
323
|
for (const task of tasks) {
|
|
353
324
|
if (!task.dependsOn)
|
|
354
325
|
continue;
|
|
@@ -365,27 +336,30 @@ class GanttDiagram {
|
|
|
365
336
|
class: 'dependency',
|
|
366
337
|
d: `M${x1},${y1} C${midX},${y1} ${midX},${y2} ${x2},${y2}`,
|
|
367
338
|
fill: 'none',
|
|
368
|
-
stroke:
|
|
369
|
-
'stroke-width':
|
|
339
|
+
stroke: theme_1.INK.line,
|
|
340
|
+
'stroke-width': theme_1.STROKE.hair,
|
|
370
341
|
'stroke-dasharray': '4 3',
|
|
371
|
-
'marker-end':
|
|
342
|
+
'marker-end': 'url(#ganttArrow)',
|
|
372
343
|
});
|
|
373
344
|
}
|
|
374
|
-
//
|
|
345
|
+
// Footer.
|
|
375
346
|
const footerY = chartBottom + 10;
|
|
376
347
|
svg
|
|
377
348
|
.child('text', {
|
|
378
349
|
class: 'footer',
|
|
379
350
|
x: chartLeft + 2,
|
|
380
351
|
y: footerY + 22,
|
|
381
|
-
'font-family':
|
|
382
|
-
'font-size':
|
|
383
|
-
fill:
|
|
352
|
+
'font-family': theme_1.FONT.family,
|
|
353
|
+
'font-size': theme_1.FONT.small + 2,
|
|
354
|
+
fill: theme_1.INK.muted,
|
|
384
355
|
})
|
|
385
|
-
.text(`${tasks.length} task${tasks.length !== 1 ? 's' : ''}
|
|
356
|
+
.text(`${tasks.length} task${tasks.length !== 1 ? 's' : ''}, ${new Date(minStart)
|
|
386
357
|
.toISOString()
|
|
387
|
-
.slice(0, 10)}
|
|
388
|
-
return doc
|
|
358
|
+
.slice(0, 10)} - ${new Date(maxEnd).toISOString().slice(0, 10)}`);
|
|
359
|
+
return doc;
|
|
360
|
+
}
|
|
361
|
+
generate() {
|
|
362
|
+
return this.build().toString('Generated by ts-prorm-orm GanttDiagram');
|
|
389
363
|
}
|
|
390
364
|
/**
|
|
391
365
|
* Write the SVG to a file. Creates parent directories if needed.
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* IndexDiagram
|
|
2
|
+
* IndexDiagram - an INDEX & CONSTRAINT MAP for a single table.
|
|
3
3
|
*
|
|
4
4
|
* A table's columns are laid out as a horizontal strip of "column chips".
|
|
5
5
|
* Below the strip, every index/constraint is drawn as a labeled "bracket" that
|
|
6
|
-
* spans the column chips it covers
|
|
6
|
+
* spans the column chips it covers - so composite indexes visibly span multiple
|
|
7
7
|
* columns and overlapping coverage is obvious at a glance.
|
|
8
8
|
*
|
|
9
9
|
* Index kinds (PRIMARY / UNIQUE / INDEX / FULLTEXT / FOREIGN KEY / CHECK) are
|
|
10
|
-
* distinguished by
|
|
11
|
-
* its access method (btree/hash/gin
|
|
12
|
-
*
|
|
13
|
-
* `--theme light|dark` drives the canvas/text colors and `--color <name|hex>`
|
|
14
|
-
* drives the accent used for the header and the PRIMARY index — both genuinely
|
|
15
|
-
* change fill/stroke values in the generated SVG.
|
|
10
|
+
* distinguished by a short ASCII badge; each row also shows the index name,
|
|
11
|
+
* its access method (btree/hash/gin...) and whether it is unique.
|
|
16
12
|
*
|
|
17
13
|
* Usage:
|
|
18
14
|
* const diag = new IndexDiagram({ table: 'users', columns: [...], indexes: [...] });
|
|
@@ -37,8 +33,12 @@ export interface IndexDiagramOptions {
|
|
|
37
33
|
columns: IdxColumn[];
|
|
38
34
|
indexes: IdxIndex[];
|
|
39
35
|
title?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Accepted for backward compatibility and ignored: diagrams render in a
|
|
38
|
+
* single monochrome theme.
|
|
39
|
+
*/
|
|
40
40
|
theme?: 'light' | 'dark';
|
|
41
|
-
/**
|
|
41
|
+
/** Accepted for backward compatibility and ignored. */
|
|
42
42
|
color?: string;
|
|
43
43
|
}
|
|
44
44
|
export declare class IndexDiagram {
|
|
@@ -52,9 +52,9 @@ export declare class IndexDiagram {
|
|
|
52
52
|
private static readonly ROW_H;
|
|
53
53
|
private static readonly LABEL_W;
|
|
54
54
|
private static readonly MIN_CHIP_W;
|
|
55
|
-
private static readonly R;
|
|
56
55
|
constructor(options: IndexDiagramOptions);
|
|
57
56
|
private chipWidth;
|
|
57
|
+
private build;
|
|
58
58
|
generate(): string;
|
|
59
59
|
/** Write the SVG to a file. Creates parent directories if needed. */
|
|
60
60
|
save(outputPath: string): string;
|