@stina/extension-api 0.52.0 → 0.53.1
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.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/runtime.cjs +2 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +2 -2
- package/dist/runtime.js.map +1 -1
- package/dist/schemas/index.cjs +545 -2
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +735 -35
- package/dist/schemas/index.d.ts +735 -35
- package/dist/schemas/index.js +520 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/{types.tools-XpXCoPrJ.d.cts → types.tools-BL9WPsi_.d.cts} +314 -2
- package/dist/{types.tools-XpXCoPrJ.d.ts → types.tools-BL9WPsi_.d.ts} +314 -2
- package/package.json +1 -1
- package/src/index.ts +20 -0
- package/src/runtime.ts +2 -2
- package/src/schemas/card.schema.test.ts +235 -0
- package/src/schemas/card.schema.ts +606 -0
- package/src/schemas/components.schema.ts +241 -0
- package/src/schemas/index.ts +30 -0
- package/src/types.components.ts +336 -0
- package/src/types.context.ts +15 -1
- package/src/types.tools.ts +15 -0
package/dist/schemas/index.js
CHANGED
|
@@ -393,6 +393,146 @@ var ListPropsSchema = z2.object({
|
|
|
393
393
|
children: ExtensionComponentChildrenSchema.describe("Child components rendered as list items"),
|
|
394
394
|
style: ExtensionComponentStyleSchema.optional()
|
|
395
395
|
}).passthrough().describe("List component");
|
|
396
|
+
var WeatherConditionSchema = z2.enum([
|
|
397
|
+
"clear",
|
|
398
|
+
"partly-cloudy",
|
|
399
|
+
"cloudy",
|
|
400
|
+
"overcast",
|
|
401
|
+
"fog",
|
|
402
|
+
"light-rain",
|
|
403
|
+
"rain",
|
|
404
|
+
"heavy-rain",
|
|
405
|
+
"sleet",
|
|
406
|
+
"light-snow",
|
|
407
|
+
"snow",
|
|
408
|
+
"heavy-snow",
|
|
409
|
+
"thunderstorm",
|
|
410
|
+
"hail",
|
|
411
|
+
"windy"
|
|
412
|
+
]).describe("Weather condition");
|
|
413
|
+
var WeatherWindSchema = z2.object({
|
|
414
|
+
speed: z2.number().describe("Sustained wind speed"),
|
|
415
|
+
unit: z2.string().optional().describe("Unit written after the speed. Defaults to m/s"),
|
|
416
|
+
direction: z2.string().optional().describe("Compass direction, in the caller's own words"),
|
|
417
|
+
gust: z2.number().optional().describe("Gust speed, in the same unit")
|
|
418
|
+
}).passthrough().describe("Wind reading");
|
|
419
|
+
var WeatherNowPropsSchema = z2.object({
|
|
420
|
+
component: z2.literal("WeatherNow"),
|
|
421
|
+
place: z2.string().describe("Where the reading is from"),
|
|
422
|
+
condition: WeatherConditionSchema,
|
|
423
|
+
conditionLabel: z2.string().optional().describe("The condition in the user's own language"),
|
|
424
|
+
temperature: z2.number().describe("Current temperature"),
|
|
425
|
+
feelsLike: z2.number().optional().describe("Apparent temperature"),
|
|
426
|
+
unit: z2.string().optional().describe("Written after every temperature. Defaults to \xB0"),
|
|
427
|
+
wind: WeatherWindSchema.optional(),
|
|
428
|
+
night: z2.boolean().optional().describe("Draw the night variant of the icon"),
|
|
429
|
+
summary: z2.string().optional().describe("One line of context under the numbers"),
|
|
430
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
431
|
+
}).passthrough().describe("Current weather component");
|
|
432
|
+
var WeatherForecastStepSchema = z2.object({
|
|
433
|
+
label: z2.string().describe("Short step label, e.g. 14 or Tors"),
|
|
434
|
+
condition: WeatherConditionSchema,
|
|
435
|
+
conditionLabel: z2.string().optional(),
|
|
436
|
+
high: z2.number().describe("The warmer temperature, or the only one"),
|
|
437
|
+
low: z2.number().optional().describe("The colder temperature"),
|
|
438
|
+
night: z2.boolean().optional(),
|
|
439
|
+
precipitation: z2.number().min(0).max(100).optional().describe("Chance of precipitation, 0-100"),
|
|
440
|
+
current: z2.boolean().optional().describe("The step the reader is at; drawn larger")
|
|
441
|
+
}).passthrough().describe("One forecast step");
|
|
442
|
+
var WeatherForecastPropsSchema = z2.object({
|
|
443
|
+
component: z2.literal("WeatherForecast"),
|
|
444
|
+
title: z2.string().optional().describe("Heading above the row"),
|
|
445
|
+
icon: z2.string().optional().describe("Icon shown to the left of the title"),
|
|
446
|
+
unit: z2.string().optional().describe("Written after every temperature. Defaults to \xB0"),
|
|
447
|
+
steps: z2.array(WeatherForecastStepSchema).min(1).describe("Steps, hourly or daily"),
|
|
448
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
449
|
+
}).passthrough().describe("Weather forecast component");
|
|
450
|
+
var ChartKindSchema = z2.enum(["line", "bar", "area"]).describe("How the chart draws");
|
|
451
|
+
var ChartSeriesSchema = z2.object({
|
|
452
|
+
name: z2.string().optional().describe("Named in the legend"),
|
|
453
|
+
points: z2.array(z2.number().nullable()).describe("One value per label. null is a gap, drawn as one")
|
|
454
|
+
}).passthrough().describe("One chart series");
|
|
455
|
+
var ChartPropsSchema = z2.object({
|
|
456
|
+
component: z2.literal("Chart"),
|
|
457
|
+
chart: ChartKindSchema.optional().describe("Defaults to line"),
|
|
458
|
+
series: z2.array(ChartSeriesSchema).min(1).max(8).describe("At most eight series"),
|
|
459
|
+
labels: z2.array(z2.string()).optional().describe("One per point, along the horizontal axis"),
|
|
460
|
+
title: z2.string().optional().describe("Heading above the plot"),
|
|
461
|
+
icon: z2.string().optional().describe("Icon shown to the left of the title"),
|
|
462
|
+
unit: z2.string().optional().describe("Written after every value"),
|
|
463
|
+
zeroBaseline: z2.boolean().optional().describe("Force the value axis to include zero"),
|
|
464
|
+
height: z2.number().min(4).max(24).optional().describe("Plot height in rem. Defaults to 9"),
|
|
465
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
466
|
+
}).passthrough().describe("Chart component");
|
|
467
|
+
var StatTrendSchema = z2.enum(["up", "down", "flat"]).describe("Direction of change");
|
|
468
|
+
var StatTilePropsSchema = z2.object({
|
|
469
|
+
component: z2.literal("StatTile"),
|
|
470
|
+
label: z2.string().describe("What the number is"),
|
|
471
|
+
value: z2.union([z2.string(), z2.number()]).describe("The number itself"),
|
|
472
|
+
unit: z2.string().optional().describe("Written after the value in smaller type"),
|
|
473
|
+
caption: z2.string().optional().describe("One quiet line under the number"),
|
|
474
|
+
icon: z2.string().optional().describe("Icon name"),
|
|
475
|
+
trend: StatTrendSchema.optional(),
|
|
476
|
+
trendLabel: z2.string().optional().describe("The change in words"),
|
|
477
|
+
trendIsGood: z2.boolean().optional().describe("Whether up is the good direction. Defaults to true"),
|
|
478
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
479
|
+
}).passthrough().describe("Single-number stat tile component");
|
|
480
|
+
var KeyValueRowSchema = z2.object({
|
|
481
|
+
label: z2.string(),
|
|
482
|
+
value: z2.string(),
|
|
483
|
+
icon: z2.string().optional().describe("Icon name")
|
|
484
|
+
}).passthrough().describe("One key/value row");
|
|
485
|
+
var KeyValueListPropsSchema = z2.object({
|
|
486
|
+
component: z2.literal("KeyValueList"),
|
|
487
|
+
rows: z2.array(KeyValueRowSchema).min(1).describe("Facts in two aligned columns"),
|
|
488
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
489
|
+
}).passthrough().describe("Key/value list component");
|
|
490
|
+
var TimelineVariantSchema = z2.enum(["default", "accent", "success", "warning", "danger"]).describe("How much a timeline entry stands out");
|
|
491
|
+
var TimelineEntrySchema = z2.object({
|
|
492
|
+
time: z2.string().describe("When it happens, worded as it should be read"),
|
|
493
|
+
title: z2.string(),
|
|
494
|
+
description: z2.string().optional().describe("A line under the title"),
|
|
495
|
+
icon: z2.string().optional().describe("Icon name"),
|
|
496
|
+
duration: z2.string().optional().describe("How long it lasts, in words"),
|
|
497
|
+
badge: z2.string().optional().describe("Trailing badge"),
|
|
498
|
+
current: z2.boolean().optional().describe("The entry the reader is at"),
|
|
499
|
+
past: z2.boolean().optional().describe("Already behind us; drawn recessive"),
|
|
500
|
+
variant: TimelineVariantSchema.optional()
|
|
501
|
+
}).passthrough().describe("One timeline entry");
|
|
502
|
+
var TimelinePropsSchema = z2.object({
|
|
503
|
+
component: z2.literal("Timeline"),
|
|
504
|
+
title: z2.string().optional().describe("Heading above the rail"),
|
|
505
|
+
icon: z2.string().optional().describe("Icon shown to the left of the title"),
|
|
506
|
+
entries: z2.array(TimelineEntrySchema).min(1).describe("Entries, in the order they happen"),
|
|
507
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
508
|
+
}).passthrough().describe("Vertical timeline component");
|
|
509
|
+
var NoteVariantSchema = z2.enum(["default", "accent", "success", "warning", "danger"]).describe("How much a note stands out");
|
|
510
|
+
var NotePropsSchema = z2.object({
|
|
511
|
+
component: z2.literal("Note"),
|
|
512
|
+
title: z2.string().optional(),
|
|
513
|
+
icon: z2.string().optional().describe("Icon shown to the left of the title"),
|
|
514
|
+
badge: z2.string().optional().describe("Trailing badge next to the title"),
|
|
515
|
+
content: z2.string().describe("The body, as markdown"),
|
|
516
|
+
footer: z2.string().optional().describe("One quiet line at the bottom"),
|
|
517
|
+
variant: NoteVariantSchema.optional(),
|
|
518
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
519
|
+
}).passthrough().describe("Titled block of prose component");
|
|
520
|
+
var CalendarEventStatusSchema = z2.enum(["confirmed", "tentative", "cancelled"]).describe("Whether an event is going ahead");
|
|
521
|
+
var CalendarEventPropsSchema = z2.object({
|
|
522
|
+
component: z2.literal("CalendarEvent"),
|
|
523
|
+
title: z2.string(),
|
|
524
|
+
start: z2.string().describe("ISO 8601 with an offset"),
|
|
525
|
+
end: z2.string().optional().describe("ISO 8601 with an offset"),
|
|
526
|
+
allDay: z2.boolean().optional(),
|
|
527
|
+
location: z2.string().optional(),
|
|
528
|
+
organizer: z2.string().optional(),
|
|
529
|
+
attendees: z2.array(z2.string()).optional(),
|
|
530
|
+
calendar: z2.string().optional().describe("Which calendar it sits in; shown as a badge"),
|
|
531
|
+
status: CalendarEventStatusSchema.optional(),
|
|
532
|
+
recurrence: z2.string().optional().describe("How it repeats, in words"),
|
|
533
|
+
notes: z2.string().optional(),
|
|
534
|
+
style: ExtensionComponentStyleSchema.optional()
|
|
535
|
+
}).passthrough().describe("Single calendar event component");
|
|
396
536
|
|
|
397
537
|
// src/schemas/contributions.schema.ts
|
|
398
538
|
var LocalizedStringSchema = z3.union([z3.string(), z3.record(z3.string())]).describe("String or localized string map");
|
|
@@ -540,11 +680,374 @@ var ExtensionManifestSchema = z4.object({
|
|
|
540
680
|
permissions: z4.array(PermissionSchema).describe("Required permissions"),
|
|
541
681
|
contributes: ExtensionContributionsSchema.optional().describe("What the extension contributes")
|
|
542
682
|
}).describe("Extension manifest format");
|
|
683
|
+
|
|
684
|
+
// src/schemas/card.schema.ts
|
|
685
|
+
import { z as z5 } from "zod";
|
|
686
|
+
var style = ExtensionComponentStyleSchema.optional();
|
|
687
|
+
var children = z5.lazy(
|
|
688
|
+
() => z5.array(ChatCardComponentSchema).max(40)
|
|
689
|
+
);
|
|
690
|
+
var VerticalStackCardSchema = z5.object({
|
|
691
|
+
component: z5.literal("VerticalStack"),
|
|
692
|
+
gap: z5.number().min(0).max(8).optional(),
|
|
693
|
+
children,
|
|
694
|
+
style
|
|
695
|
+
}).strict();
|
|
696
|
+
var HorizontalStackCardSchema = z5.object({
|
|
697
|
+
component: z5.literal("HorizontalStack"),
|
|
698
|
+
gap: z5.number().min(0).max(8).optional(),
|
|
699
|
+
children,
|
|
700
|
+
style
|
|
701
|
+
}).strict();
|
|
702
|
+
var GridCardSchema = z5.object({
|
|
703
|
+
component: z5.literal("Grid"),
|
|
704
|
+
columns: z5.number().min(1).max(6),
|
|
705
|
+
gap: z5.number().min(0).max(8).optional(),
|
|
706
|
+
children,
|
|
707
|
+
style
|
|
708
|
+
}).strict();
|
|
709
|
+
var FrameCardSchema = z5.object({
|
|
710
|
+
component: z5.literal("Frame"),
|
|
711
|
+
// Only the string form: the components form of a title is for panels that
|
|
712
|
+
// put controls in their header, which a card has no business doing.
|
|
713
|
+
title: z5.string().optional(),
|
|
714
|
+
collapsible: z5.boolean().optional(),
|
|
715
|
+
defaultExpanded: z5.boolean().optional(),
|
|
716
|
+
variant: FrameVariantSchema.optional(),
|
|
717
|
+
children,
|
|
718
|
+
style
|
|
719
|
+
}).strict();
|
|
720
|
+
var ListCardSchema = z5.object({ component: z5.literal("List"), children, style }).strict();
|
|
721
|
+
var DividerCardSchema = z5.object({ component: z5.literal("Divider"), style }).strict();
|
|
722
|
+
var HeaderCardSchema = z5.object({
|
|
723
|
+
component: z5.literal("Header"),
|
|
724
|
+
level: z5.number().min(1).max(6),
|
|
725
|
+
title: z5.string(),
|
|
726
|
+
description: z5.union([z5.string(), z5.array(z5.string())]).optional(),
|
|
727
|
+
icon: z5.string().optional(),
|
|
728
|
+
style
|
|
729
|
+
}).strict();
|
|
730
|
+
var LabelCardSchema = z5.object({ component: z5.literal("Label"), text: z5.string(), style }).strict();
|
|
731
|
+
var ParagraphCardSchema = z5.object({ component: z5.literal("Paragraph"), text: z5.string(), style }).strict();
|
|
732
|
+
var MarkdownCardSchema = z5.object({ component: z5.literal("Markdown"), content: z5.string(), style }).strict();
|
|
733
|
+
var IconCardSchema = z5.object({
|
|
734
|
+
component: z5.literal("Icon"),
|
|
735
|
+
name: z5.string(),
|
|
736
|
+
title: z5.string().optional(),
|
|
737
|
+
style
|
|
738
|
+
}).strict();
|
|
739
|
+
var PillCardSchema = z5.object({
|
|
740
|
+
component: z5.literal("Pill"),
|
|
741
|
+
text: z5.string(),
|
|
742
|
+
icon: z5.string().optional(),
|
|
743
|
+
variant: PillVariantSchema.optional(),
|
|
744
|
+
style
|
|
745
|
+
}).strict();
|
|
746
|
+
var WeatherNowCardSchema = z5.object({
|
|
747
|
+
component: z5.literal("WeatherNow"),
|
|
748
|
+
place: z5.string(),
|
|
749
|
+
condition: WeatherConditionSchema,
|
|
750
|
+
conditionLabel: z5.string().optional(),
|
|
751
|
+
temperature: z5.number(),
|
|
752
|
+
feelsLike: z5.number().optional(),
|
|
753
|
+
unit: z5.string().optional(),
|
|
754
|
+
wind: WeatherWindSchema.optional(),
|
|
755
|
+
night: z5.boolean().optional(),
|
|
756
|
+
summary: z5.string().optional(),
|
|
757
|
+
style
|
|
758
|
+
}).strict();
|
|
759
|
+
var WeatherForecastCardSchema = z5.object({
|
|
760
|
+
component: z5.literal("WeatherForecast"),
|
|
761
|
+
title: z5.string().optional(),
|
|
762
|
+
icon: z5.string().optional(),
|
|
763
|
+
unit: z5.string().optional(),
|
|
764
|
+
steps: z5.array(
|
|
765
|
+
z5.object({
|
|
766
|
+
label: z5.string(),
|
|
767
|
+
condition: WeatherConditionSchema,
|
|
768
|
+
conditionLabel: z5.string().optional(),
|
|
769
|
+
high: z5.number(),
|
|
770
|
+
low: z5.number().optional(),
|
|
771
|
+
night: z5.boolean().optional(),
|
|
772
|
+
precipitation: z5.number().min(0).max(100).optional(),
|
|
773
|
+
current: z5.boolean().optional()
|
|
774
|
+
}).strict()
|
|
775
|
+
).min(1).max(24),
|
|
776
|
+
style
|
|
777
|
+
}).strict();
|
|
778
|
+
var ChartCardSchema = z5.object({
|
|
779
|
+
component: z5.literal("Chart"),
|
|
780
|
+
chart: ChartKindSchema.optional(),
|
|
781
|
+
series: z5.array(
|
|
782
|
+
z5.object({
|
|
783
|
+
name: z5.string().optional(),
|
|
784
|
+
points: z5.array(z5.number().nullable()).min(1).max(200)
|
|
785
|
+
}).strict()
|
|
786
|
+
).min(1).max(8),
|
|
787
|
+
labels: z5.array(z5.string()).max(200).optional(),
|
|
788
|
+
title: z5.string().optional(),
|
|
789
|
+
icon: z5.string().optional(),
|
|
790
|
+
unit: z5.string().optional(),
|
|
791
|
+
zeroBaseline: z5.boolean().optional(),
|
|
792
|
+
height: z5.number().min(4).max(24).optional(),
|
|
793
|
+
style
|
|
794
|
+
}).strict();
|
|
795
|
+
var StatTileCardSchema = z5.object({
|
|
796
|
+
component: z5.literal("StatTile"),
|
|
797
|
+
label: z5.string(),
|
|
798
|
+
value: z5.union([z5.string(), z5.number()]),
|
|
799
|
+
unit: z5.string().optional(),
|
|
800
|
+
caption: z5.string().optional(),
|
|
801
|
+
icon: z5.string().optional(),
|
|
802
|
+
trend: StatTrendSchema.optional(),
|
|
803
|
+
trendLabel: z5.string().optional(),
|
|
804
|
+
trendIsGood: z5.boolean().optional(),
|
|
805
|
+
style
|
|
806
|
+
}).strict();
|
|
807
|
+
var KeyValueListCardSchema = z5.object({
|
|
808
|
+
component: z5.literal("KeyValueList"),
|
|
809
|
+
rows: z5.array(
|
|
810
|
+
z5.object({ label: z5.string(), value: z5.string(), icon: z5.string().optional() }).strict()
|
|
811
|
+
).min(1).max(40),
|
|
812
|
+
style
|
|
813
|
+
}).strict();
|
|
814
|
+
var TimelineCardSchema = z5.object({
|
|
815
|
+
component: z5.literal("Timeline"),
|
|
816
|
+
title: z5.string().optional(),
|
|
817
|
+
icon: z5.string().optional(),
|
|
818
|
+
entries: z5.array(
|
|
819
|
+
z5.object({
|
|
820
|
+
time: z5.string(),
|
|
821
|
+
title: z5.string(),
|
|
822
|
+
description: z5.string().optional(),
|
|
823
|
+
icon: z5.string().optional(),
|
|
824
|
+
duration: z5.string().optional(),
|
|
825
|
+
badge: z5.string().optional(),
|
|
826
|
+
current: z5.boolean().optional(),
|
|
827
|
+
past: z5.boolean().optional(),
|
|
828
|
+
variant: TimelineVariantSchema.optional()
|
|
829
|
+
}).strict()
|
|
830
|
+
).min(1).max(40),
|
|
831
|
+
style
|
|
832
|
+
}).strict();
|
|
833
|
+
var NoteCardSchema = z5.object({
|
|
834
|
+
component: z5.literal("Note"),
|
|
835
|
+
title: z5.string().optional(),
|
|
836
|
+
icon: z5.string().optional(),
|
|
837
|
+
badge: z5.string().optional(),
|
|
838
|
+
content: z5.string(),
|
|
839
|
+
footer: z5.string().optional(),
|
|
840
|
+
variant: NoteVariantSchema.optional(),
|
|
841
|
+
style
|
|
842
|
+
}).strict();
|
|
843
|
+
var CalendarEventCardSchema = z5.object({
|
|
844
|
+
component: z5.literal("CalendarEvent"),
|
|
845
|
+
title: z5.string(),
|
|
846
|
+
start: z5.string(),
|
|
847
|
+
end: z5.string().optional(),
|
|
848
|
+
allDay: z5.boolean().optional(),
|
|
849
|
+
location: z5.string().optional(),
|
|
850
|
+
organizer: z5.string().optional(),
|
|
851
|
+
attendees: z5.array(z5.string()).max(40).optional(),
|
|
852
|
+
calendar: z5.string().optional(),
|
|
853
|
+
status: CalendarEventStatusSchema.optional(),
|
|
854
|
+
recurrence: z5.string().optional(),
|
|
855
|
+
notes: z5.string().optional(),
|
|
856
|
+
style
|
|
857
|
+
}).strict();
|
|
858
|
+
var CHAT_CARD_COMPONENTS = [
|
|
859
|
+
"VerticalStack",
|
|
860
|
+
"HorizontalStack",
|
|
861
|
+
"Grid",
|
|
862
|
+
"Frame",
|
|
863
|
+
"List",
|
|
864
|
+
"Divider",
|
|
865
|
+
"Header",
|
|
866
|
+
"Label",
|
|
867
|
+
"Paragraph",
|
|
868
|
+
"Markdown",
|
|
869
|
+
"Icon",
|
|
870
|
+
"Pill",
|
|
871
|
+
"WeatherNow",
|
|
872
|
+
"WeatherForecast",
|
|
873
|
+
"Chart",
|
|
874
|
+
"StatTile",
|
|
875
|
+
"KeyValueList",
|
|
876
|
+
"Timeline",
|
|
877
|
+
"Note",
|
|
878
|
+
"CalendarEvent"
|
|
879
|
+
];
|
|
880
|
+
var CARD_MEMBERS = [
|
|
881
|
+
VerticalStackCardSchema,
|
|
882
|
+
HorizontalStackCardSchema,
|
|
883
|
+
GridCardSchema,
|
|
884
|
+
FrameCardSchema,
|
|
885
|
+
ListCardSchema,
|
|
886
|
+
DividerCardSchema,
|
|
887
|
+
HeaderCardSchema,
|
|
888
|
+
LabelCardSchema,
|
|
889
|
+
ParagraphCardSchema,
|
|
890
|
+
MarkdownCardSchema,
|
|
891
|
+
IconCardSchema,
|
|
892
|
+
PillCardSchema,
|
|
893
|
+
WeatherNowCardSchema,
|
|
894
|
+
WeatherForecastCardSchema,
|
|
895
|
+
ChartCardSchema,
|
|
896
|
+
StatTileCardSchema,
|
|
897
|
+
KeyValueListCardSchema,
|
|
898
|
+
TimelineCardSchema,
|
|
899
|
+
NoteCardSchema,
|
|
900
|
+
CalendarEventCardSchema
|
|
901
|
+
];
|
|
902
|
+
var ChatCardComponentSchema = z5.lazy(
|
|
903
|
+
() => z5.discriminatedUnion(
|
|
904
|
+
"component",
|
|
905
|
+
CARD_MEMBERS
|
|
906
|
+
)
|
|
907
|
+
);
|
|
908
|
+
var ChatCardSchema = ChatCardComponentSchema;
|
|
909
|
+
var MAX_CARD_DEPTH = 8;
|
|
910
|
+
function findScopeReference(value, path) {
|
|
911
|
+
if (typeof value === "string") {
|
|
912
|
+
return value.startsWith("$") ? path : null;
|
|
913
|
+
}
|
|
914
|
+
if (Array.isArray(value)) {
|
|
915
|
+
for (let i = 0; i < value.length; i++) {
|
|
916
|
+
const found = findScopeReference(value[i], `${path}[${i}]`);
|
|
917
|
+
if (found) return found;
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
if (value && typeof value === "object") {
|
|
922
|
+
for (const [key, child] of Object.entries(value)) {
|
|
923
|
+
const found = findScopeReference(child, path ? `${path}.${key}` : key);
|
|
924
|
+
if (found) return found;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
function cardDepth(value) {
|
|
930
|
+
if (!value || typeof value !== "object") return 0;
|
|
931
|
+
const kids = value.children;
|
|
932
|
+
if (!Array.isArray(kids) || kids.length === 0) return 1;
|
|
933
|
+
let deepest = 0;
|
|
934
|
+
for (const child of kids) {
|
|
935
|
+
const depth = cardDepth(child);
|
|
936
|
+
if (depth > deepest) deepest = depth;
|
|
937
|
+
}
|
|
938
|
+
return deepest + 1;
|
|
939
|
+
}
|
|
940
|
+
function findMisalignedChart(value) {
|
|
941
|
+
if (!value || typeof value !== "object") return null;
|
|
942
|
+
if (Array.isArray(value)) {
|
|
943
|
+
for (const item of value) {
|
|
944
|
+
const found = findMisalignedChart(item);
|
|
945
|
+
if (found) return found;
|
|
946
|
+
}
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
const node = value;
|
|
950
|
+
if (node.component === "Chart" && Array.isArray(node.labels) && Array.isArray(node.series)) {
|
|
951
|
+
const expected = node.labels.length;
|
|
952
|
+
for (let i = 0; i < node.series.length; i++) {
|
|
953
|
+
const points = node.series[i]?.points;
|
|
954
|
+
if (Array.isArray(points) && points.length !== expected) {
|
|
955
|
+
return `Chart series ${i} has ${points.length} points but there are ${expected} labels. Points line up with labels by position \u2014 use null for a reading you do not have.`;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
for (const child of Object.values(node)) {
|
|
960
|
+
const found = findMisalignedChart(child);
|
|
961
|
+
if (found) return found;
|
|
962
|
+
}
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
function validateChatCard(card) {
|
|
966
|
+
const parsed = ChatCardSchema.safeParse(card);
|
|
967
|
+
if (!parsed.success) {
|
|
968
|
+
const issue = parsed.error.issues[0];
|
|
969
|
+
const where = issue?.path.length ? ` at ${issue.path.join(".")}` : "";
|
|
970
|
+
return { ok: false, error: `${issue?.message ?? "Invalid card"}${where}` };
|
|
971
|
+
}
|
|
972
|
+
const depth = cardDepth(parsed.data);
|
|
973
|
+
if (depth > MAX_CARD_DEPTH) {
|
|
974
|
+
return {
|
|
975
|
+
ok: false,
|
|
976
|
+
error: `Card nests ${depth} levels deep; at most ${MAX_CARD_DEPTH} are allowed. Flatten it.`
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
const misaligned = findMisalignedChart(parsed.data);
|
|
980
|
+
if (misaligned) {
|
|
981
|
+
return { ok: false, error: misaligned };
|
|
982
|
+
}
|
|
983
|
+
const reference = findScopeReference(parsed.data, "");
|
|
984
|
+
if (reference) {
|
|
985
|
+
return {
|
|
986
|
+
ok: false,
|
|
987
|
+
error: `The value at ${reference} starts with "$", which the component system reads as a reference to data that a card does not have, so it would render as nothing. Write the value without the leading "$".`
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
return { ok: true, card: parsed.data };
|
|
991
|
+
}
|
|
992
|
+
function describeType(schema) {
|
|
993
|
+
const def = schema._def;
|
|
994
|
+
switch (def.typeName) {
|
|
995
|
+
case "ZodOptional":
|
|
996
|
+
case "ZodNullable":
|
|
997
|
+
case "ZodDefault":
|
|
998
|
+
return describeType(schema.unwrap());
|
|
999
|
+
case "ZodLazy":
|
|
1000
|
+
return "component[]";
|
|
1001
|
+
case "ZodArray": {
|
|
1002
|
+
const inner = describeType(def.type);
|
|
1003
|
+
return `${inner}[]`;
|
|
1004
|
+
}
|
|
1005
|
+
case "ZodObject": {
|
|
1006
|
+
const shape = schema.shape;
|
|
1007
|
+
const fields = Object.entries(shape).map(
|
|
1008
|
+
([key, value]) => `${key}${value.isOptional() ? "?" : ""}`
|
|
1009
|
+
);
|
|
1010
|
+
return `{${fields.join(", ")}}`;
|
|
1011
|
+
}
|
|
1012
|
+
case "ZodEnum":
|
|
1013
|
+
return (def.values ?? []).join("|");
|
|
1014
|
+
case "ZodUnion":
|
|
1015
|
+
return (def.options ?? []).map(describeType).join("|");
|
|
1016
|
+
case "ZodLiteral":
|
|
1017
|
+
return String(def.value);
|
|
1018
|
+
case "ZodString":
|
|
1019
|
+
return "string";
|
|
1020
|
+
case "ZodNumber":
|
|
1021
|
+
return "number";
|
|
1022
|
+
case "ZodBoolean":
|
|
1023
|
+
return "boolean";
|
|
1024
|
+
case "ZodRecord":
|
|
1025
|
+
return "object";
|
|
1026
|
+
default:
|
|
1027
|
+
return "value";
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
function describeChatCardProfile() {
|
|
1031
|
+
return CARD_MEMBERS.map((member) => {
|
|
1032
|
+
const shape = member.shape;
|
|
1033
|
+
const name = shape["component"]._def.value;
|
|
1034
|
+
const fields = Object.entries(shape).filter(([key]) => key !== "component" && key !== "style").map(([key, value]) => `${key}${value.isOptional() ? "?" : ""}: ${describeType(value)}`);
|
|
1035
|
+
return fields.length ? `${name} \u2014 ${fields.join("; ")}` : name;
|
|
1036
|
+
}).join("\n");
|
|
1037
|
+
}
|
|
543
1038
|
export {
|
|
544
1039
|
AllowedCSSPropertySchema,
|
|
545
1040
|
AuthorSchema,
|
|
546
1041
|
ButtonPropsSchema,
|
|
1042
|
+
CHAT_CARD_COMPONENTS,
|
|
1043
|
+
CalendarEventPropsSchema,
|
|
1044
|
+
CalendarEventStatusSchema,
|
|
547
1045
|
CapabilityPermissionSchema,
|
|
1046
|
+
ChartKindSchema,
|
|
1047
|
+
ChartPropsSchema,
|
|
1048
|
+
ChartSeriesSchema,
|
|
1049
|
+
ChatCardComponentSchema,
|
|
1050
|
+
ChatCardSchema,
|
|
548
1051
|
CheckboxPropsSchema,
|
|
549
1052
|
CollapsiblePropsSchema,
|
|
550
1053
|
CommandDefinitionSchema,
|
|
@@ -570,12 +1073,16 @@ export {
|
|
|
570
1073
|
IconButtonTypeSchema,
|
|
571
1074
|
IconPickerPropsSchema,
|
|
572
1075
|
IconPropsSchema,
|
|
1076
|
+
KeyValueListPropsSchema,
|
|
1077
|
+
KeyValueRowSchema,
|
|
573
1078
|
LabelPropsSchema,
|
|
574
1079
|
ListPropsSchema,
|
|
575
1080
|
LocalizedStringSchema,
|
|
576
1081
|
MarkdownPropsSchema,
|
|
577
1082
|
ModalPropsSchema,
|
|
578
1083
|
NetworkPermissionSchema,
|
|
1084
|
+
NotePropsSchema,
|
|
1085
|
+
NoteVariantSchema,
|
|
579
1086
|
PERMISSION_PATTERNS,
|
|
580
1087
|
PanelActionDataSourceSchema,
|
|
581
1088
|
PanelActionSchema,
|
|
@@ -594,10 +1101,15 @@ export {
|
|
|
594
1101
|
ProviderConfigViewSchema,
|
|
595
1102
|
ProviderDefinitionSchema,
|
|
596
1103
|
SelectPropsSchema,
|
|
1104
|
+
StatTilePropsSchema,
|
|
1105
|
+
StatTrendSchema,
|
|
597
1106
|
StoragePermissionSchema,
|
|
598
1107
|
SystemPermissionSchema,
|
|
599
1108
|
TextInputPropsSchema,
|
|
600
1109
|
TextPreviewPropsSchema,
|
|
1110
|
+
TimelineEntrySchema,
|
|
1111
|
+
TimelinePropsSchema,
|
|
1112
|
+
TimelineVariantSchema,
|
|
601
1113
|
TogglePropsSchema,
|
|
602
1114
|
ToolDefinitionSchema,
|
|
603
1115
|
ToolSettingsActionDataSourceSchema,
|
|
@@ -610,6 +1122,13 @@ export {
|
|
|
610
1122
|
UserDataPermissionSchema,
|
|
611
1123
|
VALID_PERMISSIONS,
|
|
612
1124
|
VerticalStackPropsSchema,
|
|
613
|
-
|
|
1125
|
+
WeatherConditionSchema,
|
|
1126
|
+
WeatherForecastPropsSchema,
|
|
1127
|
+
WeatherForecastStepSchema,
|
|
1128
|
+
WeatherNowPropsSchema,
|
|
1129
|
+
WeatherWindSchema,
|
|
1130
|
+
describeChatCardProfile,
|
|
1131
|
+
isValidPermission,
|
|
1132
|
+
validateChatCard
|
|
614
1133
|
};
|
|
615
1134
|
//# sourceMappingURL=index.js.map
|