@glyphjs/schemas 0.8.0 → 0.9.6

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.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { z } from 'zod';
2
2
  import { zodToJsonSchema } from 'zod-to-json-schema';
3
3
 
4
+ // src/graph.ts
5
+ var inlineContentSchema = z.union([z.string(), z.array(z.any())]);
6
+
4
7
  // src/graph.ts
5
8
  var graphSchema = z.object({
6
9
  type: z.enum(["dag", "flowchart", "mindmap", "force"]),
7
10
  nodes: z.array(
8
11
  z.object({
9
12
  id: z.string(),
10
- label: z.string(),
13
+ label: inlineContentSchema,
11
14
  type: z.string().optional(),
12
15
  style: z.record(z.string()).optional(),
13
16
  group: z.string().optional()
@@ -17,20 +20,19 @@ var graphSchema = z.object({
17
20
  z.object({
18
21
  from: z.string(),
19
22
  to: z.string(),
20
- label: z.string().optional(),
23
+ label: inlineContentSchema.optional(),
21
24
  type: z.string().optional(),
22
25
  style: z.record(z.string()).optional()
23
26
  })
24
27
  ),
25
28
  layout: z.enum(["top-down", "left-right", "bottom-up", "radial", "force"]).optional(),
26
- interactionMode: z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key"),
27
- markdown: z.boolean().default(false)
29
+ interactionMode: z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
28
30
  });
29
31
  var tableSchema = z.object({
30
32
  columns: z.array(
31
33
  z.object({
32
34
  key: z.string(),
33
- label: z.string(),
35
+ label: inlineContentSchema,
34
36
  sortable: z.boolean().optional(),
35
37
  filterable: z.boolean().optional(),
36
38
  type: z.enum(["string", "number", "date", "boolean"]).optional()
@@ -42,30 +44,28 @@ var tableSchema = z.object({
42
44
  column: z.string(),
43
45
  function: z.enum(["sum", "avg", "count", "min", "max"])
44
46
  })
45
- ).optional(),
46
- markdown: z.boolean().default(false)
47
+ ).optional()
47
48
  });
48
49
  var chartSchema = z.object({
49
50
  type: z.enum(["line", "bar", "area", "ohlc"]),
50
51
  series: z.array(
51
52
  z.object({
52
- name: z.string(),
53
+ name: inlineContentSchema,
53
54
  data: z.array(z.record(z.union([z.number(), z.string()])))
54
55
  })
55
56
  ),
56
- xAxis: z.object({ key: z.string(), label: z.string().optional() }).optional(),
57
- yAxis: z.object({ key: z.string(), label: z.string().optional() }).optional(),
58
- legend: z.boolean().optional(),
59
- markdown: z.boolean().default(false)
57
+ xAxis: z.object({ key: z.string(), label: inlineContentSchema.optional() }).optional(),
58
+ yAxis: z.object({ key: z.string(), label: inlineContentSchema.optional() }).optional(),
59
+ legend: z.boolean().optional()
60
60
  });
61
61
  var relationSchema = z.object({
62
62
  entities: z.array(
63
63
  z.object({
64
64
  id: z.string(),
65
- label: z.string(),
65
+ label: inlineContentSchema,
66
66
  attributes: z.array(
67
67
  z.object({
68
- name: z.string(),
68
+ name: inlineContentSchema,
69
69
  type: z.string(),
70
70
  primaryKey: z.boolean().optional()
71
71
  })
@@ -76,50 +76,55 @@ var relationSchema = z.object({
76
76
  z.object({
77
77
  from: z.string(),
78
78
  to: z.string(),
79
- label: z.string().optional(),
79
+ label: inlineContentSchema.optional(),
80
80
  cardinality: z.enum(["1:1", "1:N", "N:1", "N:M"])
81
81
  })
82
82
  ),
83
83
  layout: z.enum(["top-down", "left-right"]).optional(),
84
- interactionMode: z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key"),
85
- markdown: z.boolean().default(false)
84
+ interactionMode: z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
85
+ });
86
+ var baseEventFields = {
87
+ title: inlineContentSchema,
88
+ description: inlineContentSchema.optional(),
89
+ type: z.string().optional()
90
+ };
91
+ var eventWithDate = z.object({
92
+ ...baseEventFields,
93
+ date: z.string(),
94
+ label: z.string().optional()
95
+ });
96
+ var eventWithLabel = z.object({
97
+ ...baseEventFields,
98
+ date: z.string().optional(),
99
+ label: z.string()
86
100
  });
87
101
  var timelineSchema = z.object({
88
- events: z.array(
89
- z.object({
90
- date: z.string(),
91
- title: z.string(),
92
- description: z.string().optional(),
93
- type: z.string().optional()
94
- })
95
- ),
96
- orientation: z.enum(["vertical", "horizontal"]).optional(),
97
- markdown: z.boolean().default(false)
102
+ events: z.array(z.union([eventWithDate, eventWithLabel])),
103
+ orientation: z.enum(["vertical", "horizontal"]).optional()
98
104
  });
99
105
  var calloutSchema = z.object({
100
106
  type: z.enum(["info", "warning", "error", "tip"]),
101
- title: z.string().optional(),
102
- content: z.string(),
103
- markdown: z.boolean().default(false)
107
+ title: inlineContentSchema.optional(),
108
+ content: inlineContentSchema
104
109
  });
105
110
  var tabsSchema = z.object({
106
111
  tabs: z.array(
107
112
  z.object({
108
- label: z.string(),
109
- content: z.string()
113
+ label: inlineContentSchema,
114
+ content: inlineContentSchema
110
115
  })
111
116
  ),
112
- markdown: z.boolean().default(false)
117
+ _slotChildCounts: z.array(z.number()).optional()
113
118
  });
114
119
  var stepsSchema = z.object({
115
120
  steps: z.array(
116
121
  z.object({
117
122
  title: z.string(),
118
123
  status: z.enum(["pending", "active", "completed"]).optional(),
119
- content: z.string()
124
+ content: inlineContentSchema
120
125
  })
121
126
  ),
122
- markdown: z.boolean().default(false)
127
+ _slotChildCounts: z.array(z.number()).optional()
123
128
  });
124
129
  var iconEnum = z.enum([
125
130
  "server",
@@ -165,7 +170,7 @@ var kpiSchema = z.object({
165
170
  title: z.string().optional(),
166
171
  metrics: z.array(
167
172
  z.object({
168
- label: z.string(),
173
+ label: inlineContentSchema,
169
174
  value: z.string(),
170
175
  delta: z.string().optional(),
171
176
  trend: z.enum(["up", "down", "flat"]).optional(),
@@ -173,36 +178,33 @@ var kpiSchema = z.object({
173
178
  unit: z.string().optional()
174
179
  })
175
180
  ).min(1).max(8),
176
- columns: z.number().min(1).max(4).optional(),
177
- markdown: z.boolean().default(false)
181
+ columns: z.number().min(1).max(4).optional()
178
182
  });
179
183
  var accordionSchema = z.object({
180
184
  title: z.string().optional(),
181
185
  sections: z.array(
182
186
  z.object({
183
187
  title: z.string(),
184
- content: z.string()
188
+ content: inlineContentSchema
185
189
  })
186
190
  ).min(1),
187
191
  defaultOpen: z.array(z.number()).optional(),
188
- multiple: z.boolean().default(true),
189
- markdown: z.boolean().default(false)
192
+ multiple: z.boolean().default(true)
190
193
  });
191
194
  var comparisonSchema = z.object({
192
195
  title: z.string().optional(),
193
196
  options: z.array(
194
197
  z.object({
195
198
  name: z.string(),
196
- description: z.string().optional()
199
+ description: inlineContentSchema.optional()
197
200
  })
198
201
  ).min(2).max(6),
199
202
  features: z.array(
200
203
  z.object({
201
204
  name: z.string(),
202
- values: z.array(z.string())
205
+ values: z.array(inlineContentSchema)
203
206
  })
204
- ).min(1),
205
- markdown: z.boolean().default(false)
207
+ ).min(1)
206
208
  }).refine((data) => data.features.every((f) => f.values.length === data.options.length), {
207
209
  message: "Each feature must have one value per option"
208
210
  });
@@ -210,29 +212,27 @@ var codediffSchema = z.object({
210
212
  language: z.string().optional(),
211
213
  before: z.string(),
212
214
  after: z.string(),
213
- beforeLabel: z.string().optional(),
214
- afterLabel: z.string().optional(),
215
- markdown: z.boolean().default(false)
215
+ beforeLabel: inlineContentSchema.optional(),
216
+ afterLabel: inlineContentSchema.optional()
216
217
  });
217
218
  var flowchartSchema = z.object({
218
- title: z.string().optional(),
219
+ title: inlineContentSchema.optional(),
219
220
  nodes: z.array(
220
221
  z.object({
221
222
  id: z.string(),
222
223
  type: z.enum(["start", "end", "process", "decision"]).default("process"),
223
- label: z.string()
224
+ label: inlineContentSchema
224
225
  })
225
226
  ).min(2),
226
227
  edges: z.array(
227
228
  z.object({
228
229
  from: z.string(),
229
230
  to: z.string(),
230
- label: z.string().optional()
231
+ label: inlineContentSchema.optional()
231
232
  })
232
233
  ).min(1),
233
234
  direction: z.enum(["top-down", "left-right"]).default("top-down"),
234
- interactionMode: z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key"),
235
- markdown: z.boolean().default(false)
235
+ interactionMode: z.enum(["modifier-key", "click-to-activate", "always"]).default("modifier-key")
236
236
  });
237
237
  var fileNodeSchema = z.object({
238
238
  name: z.string(),
@@ -245,22 +245,21 @@ var filetreeSchema = z.object({
245
245
  defaultExpanded: z.boolean().default(true)
246
246
  });
247
247
  var sequenceSchema = z.object({
248
- title: z.string().optional(),
248
+ title: inlineContentSchema.optional(),
249
249
  actors: z.array(
250
250
  z.object({
251
251
  id: z.string(),
252
- label: z.string()
252
+ label: inlineContentSchema
253
253
  })
254
254
  ).min(2),
255
255
  messages: z.array(
256
256
  z.object({
257
257
  from: z.string(),
258
258
  to: z.string(),
259
- label: z.string(),
259
+ label: inlineContentSchema,
260
260
  type: z.enum(["message", "reply", "self"]).default("message")
261
261
  })
262
- ).min(1),
263
- markdown: z.boolean().default(false)
262
+ ).min(1)
264
263
  });
265
264
  var mindmapNodeSchema = z.object({
266
265
  label: z.string(),
@@ -273,37 +272,36 @@ var mindmapSchema = z.object({
273
272
  });
274
273
  var equationSchema = z.object({
275
274
  expression: z.string().optional(),
276
- label: z.string().optional(),
275
+ label: inlineContentSchema.optional(),
277
276
  steps: z.array(
278
277
  z.object({
279
278
  expression: z.string(),
280
- annotation: z.string().optional()
279
+ annotation: inlineContentSchema.optional()
281
280
  })
282
- ).optional(),
283
- markdown: z.boolean().default(false)
281
+ ).optional()
284
282
  }).refine(
285
283
  (data) => data.expression !== void 0 || data.steps !== void 0 && data.steps.length > 0,
286
284
  { message: "Either expression or steps must be provided" }
287
285
  );
288
286
  var multipleChoiceQuestion = z.object({
289
287
  type: z.literal("multiple-choice"),
290
- question: z.string(),
291
- options: z.array(z.string()).min(2).max(6),
288
+ question: inlineContentSchema,
289
+ options: z.array(inlineContentSchema).min(2).max(6),
292
290
  answer: z.number(),
293
- explanation: z.string().optional()
291
+ explanation: inlineContentSchema.optional()
294
292
  });
295
293
  var trueFalseQuestion = z.object({
296
294
  type: z.literal("true-false"),
297
- question: z.string(),
295
+ question: inlineContentSchema,
298
296
  answer: z.boolean(),
299
- explanation: z.string().optional()
297
+ explanation: inlineContentSchema.optional()
300
298
  });
301
299
  var multiSelectQuestion = z.object({
302
300
  type: z.literal("multi-select"),
303
- question: z.string(),
304
- options: z.array(z.string()).min(2).max(8),
301
+ question: inlineContentSchema,
302
+ options: z.array(inlineContentSchema).min(2).max(8),
305
303
  answer: z.array(z.number()),
306
- explanation: z.string().optional()
304
+ explanation: inlineContentSchema.optional()
307
305
  });
308
306
  var quizQuestion = z.discriminatedUnion("type", [
309
307
  multipleChoiceQuestion,
@@ -313,8 +311,7 @@ var quizQuestion = z.discriminatedUnion("type", [
313
311
  var quizSchema = z.object({
314
312
  questions: z.array(quizQuestion).min(1),
315
313
  showScore: z.boolean().default(true),
316
- title: z.string().optional(),
317
- markdown: z.boolean().default(false)
314
+ title: z.string().optional()
318
315
  });
319
316
  var cardActionSchema = z.object({
320
317
  label: z.string(),
@@ -322,29 +319,28 @@ var cardActionSchema = z.object({
322
319
  });
323
320
  var cardItemSchema = z.object({
324
321
  title: z.string(),
325
- subtitle: z.string().optional(),
322
+ subtitle: inlineContentSchema.optional(),
326
323
  image: z.string().optional(),
327
324
  icon: z.string().optional(),
328
- body: z.string().optional(),
325
+ body: inlineContentSchema.optional(),
329
326
  actions: z.array(cardActionSchema).max(3).optional()
330
327
  });
331
328
  var cardSchema = z.object({
332
329
  title: z.string().optional(),
333
330
  cards: z.array(cardItemSchema).min(1).max(12),
334
331
  variant: z.enum(["default", "outlined", "elevated"]).default("default"),
335
- columns: z.number().min(1).max(4).optional(),
336
- markdown: z.boolean().default(false)
332
+ columns: z.number().min(1).max(4).optional()
337
333
  });
338
334
  var statItemSchema = z.object({
339
335
  type: z.literal("stat"),
340
336
  label: z.string(),
341
337
  value: z.string(),
342
- description: z.string().optional()
338
+ description: inlineContentSchema.optional()
343
339
  });
344
340
  var factItemSchema = z.object({
345
341
  type: z.literal("fact"),
346
342
  icon: z.string().optional(),
347
- text: z.string()
343
+ text: inlineContentSchema
348
344
  });
349
345
  var progressItemSchema = z.object({
350
346
  type: z.literal("progress"),
@@ -377,7 +373,7 @@ var ratingItemSchema = z.object({
377
373
  label: z.string(),
378
374
  value: z.number().min(0).max(5),
379
375
  max: z.number().min(1).max(5).optional(),
380
- description: z.string().optional()
376
+ description: inlineContentSchema.optional()
381
377
  });
382
378
  var infographicItemSchema = z.discriminatedUnion("type", [
383
379
  statItemSchema,
@@ -394,16 +390,14 @@ var infographicSectionSchema = z.object({
394
390
  });
395
391
  var infographicSchema = z.object({
396
392
  title: z.string().optional(),
397
- sections: z.array(infographicSectionSchema).min(1).max(8),
398
- markdown: z.boolean().default(false)
393
+ sections: z.array(infographicSectionSchema).min(1).max(8)
399
394
  });
400
395
  var pollSchema = z.object({
401
- question: z.string(),
402
- options: z.array(z.string()).min(2).max(10),
396
+ question: inlineContentSchema,
397
+ options: z.array(inlineContentSchema).min(2).max(10),
403
398
  multiple: z.boolean().default(false),
404
399
  showResults: z.boolean().default(true),
405
- title: z.string().optional(),
406
- markdown: z.boolean().default(false)
400
+ title: z.string().optional()
407
401
  });
408
402
  var ratingItem = z.object({
409
403
  label: z.string(),
@@ -417,18 +411,16 @@ var ratingSchema = z.object({
417
411
  low: z.string(),
418
412
  high: z.string()
419
413
  }).optional(),
420
- items: z.array(ratingItem).min(1),
421
- markdown: z.boolean().default(false)
414
+ items: z.array(ratingItem).min(1)
422
415
  });
423
416
  var rankerItem = z.object({
424
417
  id: z.string(),
425
- label: z.string(),
418
+ label: inlineContentSchema,
426
419
  description: z.string().optional()
427
420
  });
428
421
  var rankerSchema = z.object({
429
422
  title: z.string().optional(),
430
- items: z.array(rankerItem).min(2),
431
- markdown: z.boolean().default(false)
423
+ items: z.array(rankerItem).min(2)
432
424
  });
433
425
  var sliderParameter = z.object({
434
426
  id: z.string(),
@@ -442,8 +434,7 @@ var sliderParameter = z.object({
442
434
  var sliderSchema = z.object({
443
435
  title: z.string().optional(),
444
436
  layout: z.enum(["vertical", "horizontal"]).default("vertical"),
445
- parameters: z.array(sliderParameter).min(1),
446
- markdown: z.boolean().default(false)
437
+ parameters: z.array(sliderParameter).min(1)
447
438
  });
448
439
  var matrixColumn = z.object({
449
440
  id: z.string(),
@@ -459,8 +450,7 @@ var matrixSchema = z.object({
459
450
  scale: z.number().int().min(2).max(10).default(5),
460
451
  showTotals: z.boolean().default(true),
461
452
  columns: z.array(matrixColumn).min(1),
462
- rows: z.array(matrixRow).min(1),
463
- markdown: z.boolean().default(false)
453
+ rows: z.array(matrixRow).min(1)
464
454
  });
465
455
  var textField = z.object({
466
456
  type: z.literal("text"),
@@ -512,15 +502,14 @@ var formField = z.discriminatedUnion("type", [
512
502
  ]);
513
503
  var formSchema = z.object({
514
504
  title: z.string().optional(),
515
- description: z.string().optional(),
505
+ description: inlineContentSchema.optional(),
516
506
  submitLabel: z.string().default("Submit"),
517
- fields: z.array(formField).min(1),
518
- markdown: z.boolean().default(false)
507
+ fields: z.array(formField).min(1)
519
508
  });
520
509
  var kanbanCard = z.object({
521
510
  id: z.string(),
522
- title: z.string(),
523
- description: z.string().optional(),
511
+ title: inlineContentSchema,
512
+ description: inlineContentSchema.optional(),
524
513
  priority: z.enum(["high", "medium", "low"]).optional(),
525
514
  tags: z.array(z.string()).optional()
526
515
  });
@@ -532,8 +521,7 @@ var kanbanColumn = z.object({
532
521
  });
533
522
  var kanbanSchema = z.object({
534
523
  title: z.string().optional(),
535
- columns: z.array(kanbanColumn).min(1),
536
- markdown: z.boolean().default(false)
524
+ columns: z.array(kanbanColumn).min(1)
537
525
  });
538
526
  var annotateLabel = z.object({
539
527
  name: z.string(),
@@ -549,8 +537,22 @@ var annotateSchema = z.object({
549
537
  title: z.string().optional(),
550
538
  labels: z.array(annotateLabel).min(1),
551
539
  text: z.string(),
552
- annotations: z.array(annotation).default([]),
553
- markdown: z.boolean().default(false)
540
+ annotations: z.array(annotation).default([])
541
+ });
542
+ var columnsSchema = z.object({
543
+ children: z.array(z.string()).min(1),
544
+ ratio: z.array(z.number().positive()).optional(),
545
+ gap: z.string().optional()
546
+ });
547
+ var rowsSchema = z.object({
548
+ children: z.array(z.string()).min(1),
549
+ ratio: z.array(z.number().positive()).optional(),
550
+ gap: z.string().optional()
551
+ });
552
+ var panelSchema = z.object({
553
+ child: z.string(),
554
+ style: z.enum(["card", "bordered", "elevated", "ghost"]).optional(),
555
+ padding: z.string().optional()
554
556
  });
555
557
  var entries = [
556
558
  ["graph", graphSchema],
@@ -581,7 +583,10 @@ var entries = [
581
583
  ["matrix", matrixSchema],
582
584
  ["form", formSchema],
583
585
  ["kanban", kanbanSchema],
584
- ["annotate", annotateSchema]
586
+ ["annotate", annotateSchema],
587
+ ["columns", columnsSchema],
588
+ ["rows", rowsSchema],
589
+ ["panel", panelSchema]
585
590
  ];
586
591
  var componentSchemas = new Map(entries);
587
592
  function getJsonSchema(componentType) {
@@ -590,6 +595,6 @@ function getJsonSchema(componentType) {
590
595
  return zodToJsonSchema(schema);
591
596
  }
592
597
 
593
- export { accordionSchema, annotateSchema, architectureSchema, calloutSchema, cardSchema, chartSchema, codediffSchema, comparisonSchema, componentSchemas, equationSchema, filetreeSchema, flowchartSchema, formSchema, getJsonSchema, graphSchema, infographicSchema, kanbanSchema, kpiSchema, matrixSchema, mindmapSchema, pollSchema, quizSchema, rankerSchema, ratingSchema, relationSchema, sequenceSchema, sliderSchema, stepsSchema, tableSchema, tabsSchema, timelineSchema };
598
+ export { accordionSchema, annotateSchema, architectureSchema, calloutSchema, cardSchema, chartSchema, codediffSchema, columnsSchema, comparisonSchema, componentSchemas, equationSchema, filetreeSchema, flowchartSchema, formSchema, getJsonSchema, graphSchema, infographicSchema, inlineContentSchema, kanbanSchema, kpiSchema, matrixSchema, mindmapSchema, panelSchema, pollSchema, quizSchema, rankerSchema, ratingSchema, relationSchema, rowsSchema, sequenceSchema, sliderSchema, stepsSchema, tableSchema, tabsSchema, timelineSchema };
594
599
  //# sourceMappingURL=index.js.map
595
600
  //# sourceMappingURL=index.js.map