@glyphjs/schemas 0.9.1 → 0.10.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/dist/index.cjs +292 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +486 -92
- package/dist/index.d.ts +486 -92
- package/dist/index.js +288 -61
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -28,8 +28,7 @@ var graphSchema = zod.z.object({
|
|
|
28
28
|
})
|
|
29
29
|
),
|
|
30
30
|
layout: zod.z.enum(["top-down", "left-right", "bottom-up", "radial", "force"]).optional(),
|
|
31
|
-
interactionMode: zod.z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
|
|
32
|
-
markdown: zod.z.boolean().default(false)
|
|
31
|
+
interactionMode: zod.z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
|
|
33
32
|
});
|
|
34
33
|
var tableSchema = zod.z.object({
|
|
35
34
|
columns: zod.z.array(
|
|
@@ -47,8 +46,7 @@ var tableSchema = zod.z.object({
|
|
|
47
46
|
column: zod.z.string(),
|
|
48
47
|
function: zod.z.enum(["sum", "avg", "count", "min", "max"])
|
|
49
48
|
})
|
|
50
|
-
).optional()
|
|
51
|
-
markdown: zod.z.boolean().default(false)
|
|
49
|
+
).optional()
|
|
52
50
|
});
|
|
53
51
|
var chartSchema = zod.z.object({
|
|
54
52
|
type: zod.z.enum(["line", "bar", "area", "ohlc"]),
|
|
@@ -60,8 +58,7 @@ var chartSchema = zod.z.object({
|
|
|
60
58
|
),
|
|
61
59
|
xAxis: zod.z.object({ key: zod.z.string(), label: inlineContentSchema.optional() }).optional(),
|
|
62
60
|
yAxis: zod.z.object({ key: zod.z.string(), label: inlineContentSchema.optional() }).optional(),
|
|
63
|
-
legend: zod.z.boolean().optional()
|
|
64
|
-
markdown: zod.z.boolean().default(false)
|
|
61
|
+
legend: zod.z.boolean().optional()
|
|
65
62
|
});
|
|
66
63
|
var relationSchema = zod.z.object({
|
|
67
64
|
entities: zod.z.array(
|
|
@@ -86,26 +83,31 @@ var relationSchema = zod.z.object({
|
|
|
86
83
|
})
|
|
87
84
|
),
|
|
88
85
|
layout: zod.z.enum(["top-down", "left-right"]).optional(),
|
|
89
|
-
interactionMode: zod.z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
|
|
90
|
-
|
|
86
|
+
interactionMode: zod.z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
|
|
87
|
+
});
|
|
88
|
+
var baseEventFields = {
|
|
89
|
+
title: inlineContentSchema,
|
|
90
|
+
description: inlineContentSchema.optional(),
|
|
91
|
+
type: zod.z.string().optional()
|
|
92
|
+
};
|
|
93
|
+
var eventWithDate = zod.z.object({
|
|
94
|
+
...baseEventFields,
|
|
95
|
+
date: zod.z.string(),
|
|
96
|
+
label: zod.z.string().optional()
|
|
97
|
+
});
|
|
98
|
+
var eventWithLabel = zod.z.object({
|
|
99
|
+
...baseEventFields,
|
|
100
|
+
date: zod.z.string().optional(),
|
|
101
|
+
label: zod.z.string()
|
|
91
102
|
});
|
|
92
103
|
var timelineSchema = zod.z.object({
|
|
93
|
-
events: zod.z.array(
|
|
94
|
-
|
|
95
|
-
date: zod.z.string(),
|
|
96
|
-
title: inlineContentSchema,
|
|
97
|
-
description: inlineContentSchema.optional(),
|
|
98
|
-
type: zod.z.string().optional()
|
|
99
|
-
})
|
|
100
|
-
),
|
|
101
|
-
orientation: zod.z.enum(["vertical", "horizontal"]).optional(),
|
|
102
|
-
markdown: zod.z.boolean().default(false)
|
|
104
|
+
events: zod.z.array(zod.z.union([eventWithDate, eventWithLabel])),
|
|
105
|
+
orientation: zod.z.enum(["vertical", "horizontal"]).optional()
|
|
103
106
|
});
|
|
104
107
|
var calloutSchema = zod.z.object({
|
|
105
108
|
type: zod.z.enum(["info", "warning", "error", "tip"]),
|
|
106
109
|
title: inlineContentSchema.optional(),
|
|
107
|
-
content: inlineContentSchema
|
|
108
|
-
markdown: zod.z.boolean().default(false)
|
|
110
|
+
content: inlineContentSchema
|
|
109
111
|
});
|
|
110
112
|
var tabsSchema = zod.z.object({
|
|
111
113
|
tabs: zod.z.array(
|
|
@@ -114,7 +116,7 @@ var tabsSchema = zod.z.object({
|
|
|
114
116
|
content: inlineContentSchema
|
|
115
117
|
})
|
|
116
118
|
),
|
|
117
|
-
|
|
119
|
+
_slotChildCounts: zod.z.array(zod.z.number()).optional()
|
|
118
120
|
});
|
|
119
121
|
var stepsSchema = zod.z.object({
|
|
120
122
|
steps: zod.z.array(
|
|
@@ -124,7 +126,7 @@ var stepsSchema = zod.z.object({
|
|
|
124
126
|
content: inlineContentSchema
|
|
125
127
|
})
|
|
126
128
|
),
|
|
127
|
-
|
|
129
|
+
_slotChildCounts: zod.z.array(zod.z.number()).optional()
|
|
128
130
|
});
|
|
129
131
|
var iconEnum = zod.z.enum([
|
|
130
132
|
"server",
|
|
@@ -178,8 +180,7 @@ var kpiSchema = zod.z.object({
|
|
|
178
180
|
unit: zod.z.string().optional()
|
|
179
181
|
})
|
|
180
182
|
).min(1).max(8),
|
|
181
|
-
columns: zod.z.number().min(1).max(4).optional()
|
|
182
|
-
markdown: zod.z.boolean().default(false)
|
|
183
|
+
columns: zod.z.number().min(1).max(4).optional()
|
|
183
184
|
});
|
|
184
185
|
var accordionSchema = zod.z.object({
|
|
185
186
|
title: zod.z.string().optional(),
|
|
@@ -190,8 +191,7 @@ var accordionSchema = zod.z.object({
|
|
|
190
191
|
})
|
|
191
192
|
).min(1),
|
|
192
193
|
defaultOpen: zod.z.array(zod.z.number()).optional(),
|
|
193
|
-
multiple: zod.z.boolean().default(true)
|
|
194
|
-
markdown: zod.z.boolean().default(false)
|
|
194
|
+
multiple: zod.z.boolean().default(true)
|
|
195
195
|
});
|
|
196
196
|
var comparisonSchema = zod.z.object({
|
|
197
197
|
title: zod.z.string().optional(),
|
|
@@ -206,8 +206,7 @@ var comparisonSchema = zod.z.object({
|
|
|
206
206
|
name: zod.z.string(),
|
|
207
207
|
values: zod.z.array(inlineContentSchema)
|
|
208
208
|
})
|
|
209
|
-
).min(1)
|
|
210
|
-
markdown: zod.z.boolean().default(false)
|
|
209
|
+
).min(1)
|
|
211
210
|
}).refine((data) => data.features.every((f) => f.values.length === data.options.length), {
|
|
212
211
|
message: "Each feature must have one value per option"
|
|
213
212
|
});
|
|
@@ -216,8 +215,7 @@ var codediffSchema = zod.z.object({
|
|
|
216
215
|
before: zod.z.string(),
|
|
217
216
|
after: zod.z.string(),
|
|
218
217
|
beforeLabel: inlineContentSchema.optional(),
|
|
219
|
-
afterLabel: inlineContentSchema.optional()
|
|
220
|
-
markdown: zod.z.boolean().default(false)
|
|
218
|
+
afterLabel: inlineContentSchema.optional()
|
|
221
219
|
});
|
|
222
220
|
var flowchartSchema = zod.z.object({
|
|
223
221
|
title: inlineContentSchema.optional(),
|
|
@@ -236,8 +234,7 @@ var flowchartSchema = zod.z.object({
|
|
|
236
234
|
})
|
|
237
235
|
).min(1),
|
|
238
236
|
direction: zod.z.enum(["top-down", "left-right"]).default("top-down"),
|
|
239
|
-
interactionMode: zod.z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
|
|
240
|
-
markdown: zod.z.boolean().default(false)
|
|
237
|
+
interactionMode: zod.z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
|
|
241
238
|
});
|
|
242
239
|
var fileNodeSchema = zod.z.object({
|
|
243
240
|
name: zod.z.string(),
|
|
@@ -264,8 +261,7 @@ var sequenceSchema = zod.z.object({
|
|
|
264
261
|
label: inlineContentSchema,
|
|
265
262
|
type: zod.z.enum(["message", "reply", "self"]).default("message")
|
|
266
263
|
})
|
|
267
|
-
).min(1)
|
|
268
|
-
markdown: zod.z.boolean().default(false)
|
|
264
|
+
).min(1)
|
|
269
265
|
});
|
|
270
266
|
var mindmapNodeSchema = zod.z.object({
|
|
271
267
|
label: zod.z.string(),
|
|
@@ -284,8 +280,7 @@ var equationSchema = zod.z.object({
|
|
|
284
280
|
expression: zod.z.string(),
|
|
285
281
|
annotation: inlineContentSchema.optional()
|
|
286
282
|
})
|
|
287
|
-
).optional()
|
|
288
|
-
markdown: zod.z.boolean().default(false)
|
|
283
|
+
).optional()
|
|
289
284
|
}).refine(
|
|
290
285
|
(data) => data.expression !== void 0 || data.steps !== void 0 && data.steps.length > 0,
|
|
291
286
|
{ message: "Either expression or steps must be provided" }
|
|
@@ -318,8 +313,7 @@ var quizQuestion = zod.z.discriminatedUnion("type", [
|
|
|
318
313
|
var quizSchema = zod.z.object({
|
|
319
314
|
questions: zod.z.array(quizQuestion).min(1),
|
|
320
315
|
showScore: zod.z.boolean().default(true),
|
|
321
|
-
title: zod.z.string().optional()
|
|
322
|
-
markdown: zod.z.boolean().default(false)
|
|
316
|
+
title: zod.z.string().optional()
|
|
323
317
|
});
|
|
324
318
|
var cardActionSchema = zod.z.object({
|
|
325
319
|
label: zod.z.string(),
|
|
@@ -337,8 +331,7 @@ var cardSchema = zod.z.object({
|
|
|
337
331
|
title: zod.z.string().optional(),
|
|
338
332
|
cards: zod.z.array(cardItemSchema).min(1).max(12),
|
|
339
333
|
variant: zod.z.enum(["default", "outlined", "elevated"]).default("default"),
|
|
340
|
-
columns: zod.z.number().min(1).max(4).optional()
|
|
341
|
-
markdown: zod.z.boolean().default(false)
|
|
334
|
+
columns: zod.z.number().min(1).max(4).optional()
|
|
342
335
|
});
|
|
343
336
|
var statItemSchema = zod.z.object({
|
|
344
337
|
type: zod.z.literal("stat"),
|
|
@@ -399,16 +392,14 @@ var infographicSectionSchema = zod.z.object({
|
|
|
399
392
|
});
|
|
400
393
|
var infographicSchema = zod.z.object({
|
|
401
394
|
title: zod.z.string().optional(),
|
|
402
|
-
sections: zod.z.array(infographicSectionSchema).min(1).max(8)
|
|
403
|
-
markdown: zod.z.boolean().default(false)
|
|
395
|
+
sections: zod.z.array(infographicSectionSchema).min(1).max(8)
|
|
404
396
|
});
|
|
405
397
|
var pollSchema = zod.z.object({
|
|
406
398
|
question: inlineContentSchema,
|
|
407
|
-
options: zod.z.array(
|
|
399
|
+
options: zod.z.array(inlineContentSchema).min(2).max(10),
|
|
408
400
|
multiple: zod.z.boolean().default(false),
|
|
409
401
|
showResults: zod.z.boolean().default(true),
|
|
410
|
-
title: zod.z.string().optional()
|
|
411
|
-
markdown: zod.z.boolean().default(false)
|
|
402
|
+
title: zod.z.string().optional()
|
|
412
403
|
});
|
|
413
404
|
var ratingItem = zod.z.object({
|
|
414
405
|
label: zod.z.string(),
|
|
@@ -422,8 +413,7 @@ var ratingSchema = zod.z.object({
|
|
|
422
413
|
low: zod.z.string(),
|
|
423
414
|
high: zod.z.string()
|
|
424
415
|
}).optional(),
|
|
425
|
-
items: zod.z.array(ratingItem).min(1)
|
|
426
|
-
markdown: zod.z.boolean().default(false)
|
|
416
|
+
items: zod.z.array(ratingItem).min(1)
|
|
427
417
|
});
|
|
428
418
|
var rankerItem = zod.z.object({
|
|
429
419
|
id: zod.z.string(),
|
|
@@ -432,8 +422,7 @@ var rankerItem = zod.z.object({
|
|
|
432
422
|
});
|
|
433
423
|
var rankerSchema = zod.z.object({
|
|
434
424
|
title: zod.z.string().optional(),
|
|
435
|
-
items: zod.z.array(rankerItem).min(2)
|
|
436
|
-
markdown: zod.z.boolean().default(false)
|
|
425
|
+
items: zod.z.array(rankerItem).min(2)
|
|
437
426
|
});
|
|
438
427
|
var sliderParameter = zod.z.object({
|
|
439
428
|
id: zod.z.string(),
|
|
@@ -447,8 +436,7 @@ var sliderParameter = zod.z.object({
|
|
|
447
436
|
var sliderSchema = zod.z.object({
|
|
448
437
|
title: zod.z.string().optional(),
|
|
449
438
|
layout: zod.z.enum(["vertical", "horizontal"]).default("vertical"),
|
|
450
|
-
parameters: zod.z.array(sliderParameter).min(1)
|
|
451
|
-
markdown: zod.z.boolean().default(false)
|
|
439
|
+
parameters: zod.z.array(sliderParameter).min(1)
|
|
452
440
|
});
|
|
453
441
|
var matrixColumn = zod.z.object({
|
|
454
442
|
id: zod.z.string(),
|
|
@@ -464,8 +452,7 @@ var matrixSchema = zod.z.object({
|
|
|
464
452
|
scale: zod.z.number().int().min(2).max(10).default(5),
|
|
465
453
|
showTotals: zod.z.boolean().default(true),
|
|
466
454
|
columns: zod.z.array(matrixColumn).min(1),
|
|
467
|
-
rows: zod.z.array(matrixRow).min(1)
|
|
468
|
-
markdown: zod.z.boolean().default(false)
|
|
455
|
+
rows: zod.z.array(matrixRow).min(1)
|
|
469
456
|
});
|
|
470
457
|
var textField = zod.z.object({
|
|
471
458
|
type: zod.z.literal("text"),
|
|
@@ -519,8 +506,7 @@ var formSchema = zod.z.object({
|
|
|
519
506
|
title: zod.z.string().optional(),
|
|
520
507
|
description: inlineContentSchema.optional(),
|
|
521
508
|
submitLabel: zod.z.string().default("Submit"),
|
|
522
|
-
fields: zod.z.array(formField).min(1)
|
|
523
|
-
markdown: zod.z.boolean().default(false)
|
|
509
|
+
fields: zod.z.array(formField).min(1)
|
|
524
510
|
});
|
|
525
511
|
var kanbanCard = zod.z.object({
|
|
526
512
|
id: zod.z.string(),
|
|
@@ -537,8 +523,7 @@ var kanbanColumn = zod.z.object({
|
|
|
537
523
|
});
|
|
538
524
|
var kanbanSchema = zod.z.object({
|
|
539
525
|
title: zod.z.string().optional(),
|
|
540
|
-
columns: zod.z.array(kanbanColumn).min(1)
|
|
541
|
-
markdown: zod.z.boolean().default(false)
|
|
526
|
+
columns: zod.z.array(kanbanColumn).min(1)
|
|
542
527
|
});
|
|
543
528
|
var annotateLabel = zod.z.object({
|
|
544
529
|
name: zod.z.string(),
|
|
@@ -554,8 +539,70 @@ var annotateSchema = zod.z.object({
|
|
|
554
539
|
title: zod.z.string().optional(),
|
|
555
540
|
labels: zod.z.array(annotateLabel).min(1),
|
|
556
541
|
text: zod.z.string(),
|
|
557
|
-
annotations: zod.z.array(annotation).default([])
|
|
558
|
-
|
|
542
|
+
annotations: zod.z.array(annotation).default([])
|
|
543
|
+
});
|
|
544
|
+
var sankeyNodeSchema = zod.z.object({
|
|
545
|
+
id: zod.z.string(),
|
|
546
|
+
label: zod.z.string(),
|
|
547
|
+
color: zod.z.string().optional()
|
|
548
|
+
});
|
|
549
|
+
var sankeyFlowSchema = zod.z.object({
|
|
550
|
+
from: zod.z.string(),
|
|
551
|
+
to: zod.z.string(),
|
|
552
|
+
value: zod.z.number().positive(),
|
|
553
|
+
label: zod.z.string().optional()
|
|
554
|
+
});
|
|
555
|
+
function hasCycle(nodes, flows) {
|
|
556
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
557
|
+
const indegree = /* @__PURE__ */ new Map();
|
|
558
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
559
|
+
for (const id of ids) {
|
|
560
|
+
indegree.set(id, 0);
|
|
561
|
+
adjacency.set(id, []);
|
|
562
|
+
}
|
|
563
|
+
for (const flow of flows) {
|
|
564
|
+
if (!ids.has(flow.from) || !ids.has(flow.to)) continue;
|
|
565
|
+
if (flow.from === flow.to) return true;
|
|
566
|
+
const fromList = adjacency.get(flow.from);
|
|
567
|
+
if (!fromList) continue;
|
|
568
|
+
fromList.push(flow.to);
|
|
569
|
+
indegree.set(flow.to, (indegree.get(flow.to) ?? 0) + 1);
|
|
570
|
+
}
|
|
571
|
+
const queue = [];
|
|
572
|
+
for (const [id, deg] of indegree) {
|
|
573
|
+
if (deg === 0) queue.push(id);
|
|
574
|
+
}
|
|
575
|
+
let visited = 0;
|
|
576
|
+
while (queue.length > 0) {
|
|
577
|
+
const id = queue.shift();
|
|
578
|
+
if (id === void 0) break;
|
|
579
|
+
visited += 1;
|
|
580
|
+
for (const next of adjacency.get(id) ?? []) {
|
|
581
|
+
const nextDeg = (indegree.get(next) ?? 0) - 1;
|
|
582
|
+
indegree.set(next, nextDeg);
|
|
583
|
+
if (nextDeg === 0) queue.push(next);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return visited !== ids.size;
|
|
587
|
+
}
|
|
588
|
+
var sankeySchema = zod.z.object({
|
|
589
|
+
title: zod.z.string().optional(),
|
|
590
|
+
nodes: zod.z.array(sankeyNodeSchema).min(2),
|
|
591
|
+
flows: zod.z.array(sankeyFlowSchema).min(1),
|
|
592
|
+
orientation: zod.z.enum(["left-right", "top-down"]).default("left-right"),
|
|
593
|
+
unit: zod.z.string().optional()
|
|
594
|
+
}).refine(
|
|
595
|
+
(data) => {
|
|
596
|
+
const ids = new Set(data.nodes.map((n) => n.id));
|
|
597
|
+
return data.flows.every((f) => ids.has(f.from) && ids.has(f.to));
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
message: "Every flow must reference declared node IDs (from/to).",
|
|
601
|
+
path: ["flows"]
|
|
602
|
+
}
|
|
603
|
+
).refine((data) => !hasCycle(data.nodes, data.flows), {
|
|
604
|
+
message: "Sankey must be a DAG \u2014 cycles are not allowed.",
|
|
605
|
+
path: ["flows"]
|
|
559
606
|
});
|
|
560
607
|
var columnsSchema = zod.z.object({
|
|
561
608
|
children: zod.z.array(zod.z.string()).min(1),
|
|
@@ -572,6 +619,181 @@ var panelSchema = zod.z.object({
|
|
|
572
619
|
style: zod.z.enum(["card", "bordered", "elevated", "ghost"]).optional(),
|
|
573
620
|
padding: zod.z.string().optional()
|
|
574
621
|
});
|
|
622
|
+
var heatmapSchema = zod.z.object({
|
|
623
|
+
title: zod.z.string().optional(),
|
|
624
|
+
rows: zod.z.array(zod.z.string()).min(1),
|
|
625
|
+
cols: zod.z.array(zod.z.string()).min(1),
|
|
626
|
+
values: zod.z.array(zod.z.array(zod.z.number().nullable())).min(1),
|
|
627
|
+
scale: zod.z.enum(["sequential", "diverging"]).default("sequential"),
|
|
628
|
+
domain: zod.z.tuple([zod.z.number(), zod.z.number()]).optional(),
|
|
629
|
+
unit: zod.z.string().optional(),
|
|
630
|
+
showValues: zod.z.boolean().default(false),
|
|
631
|
+
legend: zod.z.boolean().default(true)
|
|
632
|
+
}).refine(
|
|
633
|
+
(d) => d.values.length === d.rows.length && d.values.every((r) => r.length === d.cols.length),
|
|
634
|
+
{ message: "values matrix dimensions must match rows \xD7 cols" }
|
|
635
|
+
);
|
|
636
|
+
var funnelSchema = zod.z.object({
|
|
637
|
+
title: zod.z.string().optional(),
|
|
638
|
+
stages: zod.z.array(
|
|
639
|
+
zod.z.object({
|
|
640
|
+
label: zod.z.string(),
|
|
641
|
+
value: zod.z.number().nonnegative(),
|
|
642
|
+
description: zod.z.string().optional()
|
|
643
|
+
})
|
|
644
|
+
).min(2).max(12),
|
|
645
|
+
showConversion: zod.z.boolean().default(true),
|
|
646
|
+
orientation: zod.z.enum(["vertical", "horizontal"]).default("vertical"),
|
|
647
|
+
unit: zod.z.string().optional()
|
|
648
|
+
}).refine(
|
|
649
|
+
(d) => {
|
|
650
|
+
for (let i = 1; i < d.stages.length; i++) {
|
|
651
|
+
const prev = d.stages[i - 1];
|
|
652
|
+
const curr = d.stages[i];
|
|
653
|
+
if (prev === void 0 || curr === void 0) return false;
|
|
654
|
+
if (curr.value > prev.value) return false;
|
|
655
|
+
}
|
|
656
|
+
return true;
|
|
657
|
+
},
|
|
658
|
+
{ message: "funnel stages must be monotonically non-increasing" }
|
|
659
|
+
);
|
|
660
|
+
var decisiontreeNodeSchema = zod.z.object({
|
|
661
|
+
id: zod.z.string(),
|
|
662
|
+
type: zod.z.enum(["question", "outcome"]).default("question"),
|
|
663
|
+
label: zod.z.string(),
|
|
664
|
+
sentiment: zod.z.enum(["positive", "neutral", "negative"]).optional(),
|
|
665
|
+
confidence: zod.z.number().min(0).max(1).optional()
|
|
666
|
+
});
|
|
667
|
+
var decisiontreeEdgeSchema = zod.z.object({
|
|
668
|
+
from: zod.z.string(),
|
|
669
|
+
to: zod.z.string(),
|
|
670
|
+
condition: zod.z.string().optional()
|
|
671
|
+
});
|
|
672
|
+
var decisiontreeSchema = zod.z.object({
|
|
673
|
+
title: zod.z.string().optional(),
|
|
674
|
+
nodes: zod.z.array(decisiontreeNodeSchema).min(1),
|
|
675
|
+
edges: zod.z.array(decisiontreeEdgeSchema).default([]),
|
|
676
|
+
orientation: zod.z.enum(["left-right", "top-down"]).default("left-right")
|
|
677
|
+
}).superRefine((data, ctx) => {
|
|
678
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
679
|
+
for (const node of data.nodes) {
|
|
680
|
+
if (nodeIds.has(node.id)) {
|
|
681
|
+
ctx.addIssue({
|
|
682
|
+
code: zod.z.ZodIssueCode.custom,
|
|
683
|
+
message: `duplicate node id: ${node.id}`,
|
|
684
|
+
path: ["nodes"]
|
|
685
|
+
});
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
nodeIds.add(node.id);
|
|
689
|
+
}
|
|
690
|
+
for (const edge of data.edges) {
|
|
691
|
+
if (!nodeIds.has(edge.from)) {
|
|
692
|
+
ctx.addIssue({
|
|
693
|
+
code: zod.z.ZodIssueCode.custom,
|
|
694
|
+
message: `edge references unknown node: ${edge.from}`,
|
|
695
|
+
path: ["edges"]
|
|
696
|
+
});
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
if (!nodeIds.has(edge.to)) {
|
|
700
|
+
ctx.addIssue({
|
|
701
|
+
code: zod.z.ZodIssueCode.custom,
|
|
702
|
+
message: `edge references unknown node: ${edge.to}`,
|
|
703
|
+
path: ["edges"]
|
|
704
|
+
});
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
const parentCount = /* @__PURE__ */ new Map();
|
|
709
|
+
for (const id of nodeIds) parentCount.set(id, 0);
|
|
710
|
+
for (const edge of data.edges) {
|
|
711
|
+
parentCount.set(edge.to, (parentCount.get(edge.to) ?? 0) + 1);
|
|
712
|
+
}
|
|
713
|
+
const roots = [];
|
|
714
|
+
for (const [id, count] of parentCount) {
|
|
715
|
+
if (count === 0) roots.push(id);
|
|
716
|
+
if (count > 1) {
|
|
717
|
+
ctx.addIssue({
|
|
718
|
+
code: zod.z.ZodIssueCode.custom,
|
|
719
|
+
message: `node has multiple parents (tree requires exactly one): ${id}`,
|
|
720
|
+
path: ["edges"]
|
|
721
|
+
});
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (roots.length === 0) {
|
|
726
|
+
ctx.addIssue({
|
|
727
|
+
code: zod.z.ZodIssueCode.custom,
|
|
728
|
+
message: "decision tree has no root (cycle detected)",
|
|
729
|
+
path: ["nodes"]
|
|
730
|
+
});
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
if (roots.length > 1) {
|
|
734
|
+
ctx.addIssue({
|
|
735
|
+
code: zod.z.ZodIssueCode.custom,
|
|
736
|
+
message: `decision tree must have exactly one root, found ${String(roots.length)}: ${roots.join(", ")}`,
|
|
737
|
+
path: ["nodes"]
|
|
738
|
+
});
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const root = roots[0];
|
|
742
|
+
if (root === void 0) return;
|
|
743
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
744
|
+
for (const id of nodeIds) adjacency.set(id, []);
|
|
745
|
+
for (const edge of data.edges) {
|
|
746
|
+
const list = adjacency.get(edge.from);
|
|
747
|
+
if (list) list.push(edge.to);
|
|
748
|
+
}
|
|
749
|
+
const visited = /* @__PURE__ */ new Set();
|
|
750
|
+
const queue = [root];
|
|
751
|
+
while (queue.length > 0) {
|
|
752
|
+
const current = queue.shift();
|
|
753
|
+
if (current === void 0) break;
|
|
754
|
+
if (visited.has(current)) {
|
|
755
|
+
ctx.addIssue({
|
|
756
|
+
code: zod.z.ZodIssueCode.custom,
|
|
757
|
+
message: `cycle detected at node: ${current}`,
|
|
758
|
+
path: ["edges"]
|
|
759
|
+
});
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
visited.add(current);
|
|
763
|
+
for (const next of adjacency.get(current) ?? []) {
|
|
764
|
+
queue.push(next);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (visited.size !== nodeIds.size) {
|
|
768
|
+
const orphans = [];
|
|
769
|
+
for (const id of nodeIds) {
|
|
770
|
+
if (!visited.has(id)) orphans.push(id);
|
|
771
|
+
}
|
|
772
|
+
ctx.addIssue({
|
|
773
|
+
code: zod.z.ZodIssueCode.custom,
|
|
774
|
+
message: `orphan nodes not reachable from root: ${orphans.join(", ")}`,
|
|
775
|
+
path: ["nodes"]
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
var gaugeSchema = zod.z.object({
|
|
780
|
+
label: zod.z.string(),
|
|
781
|
+
value: zod.z.number(),
|
|
782
|
+
min: zod.z.number().default(0),
|
|
783
|
+
max: zod.z.number(),
|
|
784
|
+
unit: zod.z.string().optional(),
|
|
785
|
+
zones: zod.z.array(
|
|
786
|
+
zod.z.object({
|
|
787
|
+
max: zod.z.number(),
|
|
788
|
+
label: zod.z.string().optional(),
|
|
789
|
+
sentiment: zod.z.enum(["positive", "neutral", "negative"]).optional()
|
|
790
|
+
})
|
|
791
|
+
).min(1).max(6).optional(),
|
|
792
|
+
target: zod.z.number().optional(),
|
|
793
|
+
shape: zod.z.enum(["semicircle", "full"]).default("semicircle")
|
|
794
|
+
}).refine((d) => d.min < d.max, { message: "min must be less than max" }).refine((d) => d.value >= d.min && d.value <= d.max, {
|
|
795
|
+
message: "value must fall within [min, max]"
|
|
796
|
+
});
|
|
575
797
|
var entries = [
|
|
576
798
|
["graph", graphSchema],
|
|
577
799
|
["table", tableSchema],
|
|
@@ -602,9 +824,14 @@ var entries = [
|
|
|
602
824
|
["form", formSchema],
|
|
603
825
|
["kanban", kanbanSchema],
|
|
604
826
|
["annotate", annotateSchema],
|
|
827
|
+
["sankey", sankeySchema],
|
|
605
828
|
["columns", columnsSchema],
|
|
606
829
|
["rows", rowsSchema],
|
|
607
|
-
["panel", panelSchema]
|
|
830
|
+
["panel", panelSchema],
|
|
831
|
+
["heatmap", heatmapSchema],
|
|
832
|
+
["funnel", funnelSchema],
|
|
833
|
+
["decisiontree", decisiontreeSchema],
|
|
834
|
+
["gauge", gaugeSchema]
|
|
608
835
|
];
|
|
609
836
|
var componentSchemas = new Map(entries);
|
|
610
837
|
function getJsonSchema(componentType) {
|
|
@@ -623,12 +850,16 @@ exports.codediffSchema = codediffSchema;
|
|
|
623
850
|
exports.columnsSchema = columnsSchema;
|
|
624
851
|
exports.comparisonSchema = comparisonSchema;
|
|
625
852
|
exports.componentSchemas = componentSchemas;
|
|
853
|
+
exports.decisiontreeSchema = decisiontreeSchema;
|
|
626
854
|
exports.equationSchema = equationSchema;
|
|
627
855
|
exports.filetreeSchema = filetreeSchema;
|
|
628
856
|
exports.flowchartSchema = flowchartSchema;
|
|
629
857
|
exports.formSchema = formSchema;
|
|
858
|
+
exports.funnelSchema = funnelSchema;
|
|
859
|
+
exports.gaugeSchema = gaugeSchema;
|
|
630
860
|
exports.getJsonSchema = getJsonSchema;
|
|
631
861
|
exports.graphSchema = graphSchema;
|
|
862
|
+
exports.heatmapSchema = heatmapSchema;
|
|
632
863
|
exports.infographicSchema = infographicSchema;
|
|
633
864
|
exports.inlineContentSchema = inlineContentSchema;
|
|
634
865
|
exports.kanbanSchema = kanbanSchema;
|
|
@@ -642,6 +873,7 @@ exports.rankerSchema = rankerSchema;
|
|
|
642
873
|
exports.ratingSchema = ratingSchema;
|
|
643
874
|
exports.relationSchema = relationSchema;
|
|
644
875
|
exports.rowsSchema = rowsSchema;
|
|
876
|
+
exports.sankeySchema = sankeySchema;
|
|
645
877
|
exports.sequenceSchema = sequenceSchema;
|
|
646
878
|
exports.sliderSchema = sliderSchema;
|
|
647
879
|
exports.stepsSchema = stepsSchema;
|