@supernova-studio/client 0.2.3 → 0.3.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.mjs CHANGED
@@ -883,24 +883,27 @@ var PageBlockImageAlignment = z33.enum(["Left", "Center", "Stretch"]);
883
883
  var PageBlockAppearanceV2 = z33.object({
884
884
  itemBackgroundColor: ColorValue
885
885
  });
886
- var PageBlockItemUntypedPropertyValue = z33.object({
886
+ var PageBlockItemUntypedValue = z33.object({
887
887
  value: z33.any()
888
888
  }).and(z33.record(z33.any()));
889
- var PageBlockItemRichTextPropertyValue = z33.object({
890
- value: PageBlockText,
891
- calloutType: PageBlockCalloutType.optional()
892
- });
893
- var PageBlockItemEmbedPropertyValue = z33.object({
894
- value: z33.string().optional(),
895
- caption: z33.string().optional(),
896
- height: z33.number().optional()
889
+ var PageBlockLinkV2 = z33.object({
890
+ type: PageBlockLinkType,
891
+ documentationItemId: z33.string().optional(),
892
+ pageHeadingId: z33.string().optional(),
893
+ url: z33.string().optional(),
894
+ openInNewTab: z33.boolean().optional()
897
895
  });
898
- var PageBlockItemMultiRichTextPropertyValue = z33.object({
899
- value: PageBlockText.array()
896
+ var PageBlockItemV2 = z33.object({
897
+ id: z33.string(),
898
+ linksTo: PageBlockLinkV2.optional(),
899
+ props: z33.record(PageBlockItemUntypedValue)
900
900
  });
901
- var PageBlockItemTextPropertyValue = z33.object({
902
- value: z33.string(),
903
- calloutType: PageBlockCalloutType.optional()
901
+ var PageBlockDataV2 = z33.object({
902
+ packageId: z33.string(),
903
+ variantId: z33.string().optional(),
904
+ indentLevel: z33.number(),
905
+ appearance: PageBlockAppearanceV2.optional(),
906
+ items: z33.array(PageBlockItemV2)
904
907
  });
905
908
  var PageBlockItemImageReference = z33.object({
906
909
  type: PageBlockImageType,
@@ -912,30 +915,111 @@ var PageBlockItemImageReference = z33.object({
912
915
  frameId: z33.string()
913
916
  }).optional()
914
917
  });
918
+ var PageBlockItemAssetValue = z33.object({
919
+ selectedPropertyIds: z33.array(z33.string()).optional(),
920
+ showSearch: z33.boolean().optional(),
921
+ previewContainerSize: z33.enum(["Centered", "NaturalHeight"]).optional(),
922
+ backgroundColor: z33.string().optional(),
923
+ value: z33.array(
924
+ z33.object({
925
+ entityId: z33.string(),
926
+ entityType: z33.enum(["Asset", "AssetGroup"])
927
+ })
928
+ )
929
+ });
930
+ var PageBlockItemAssetPropertyValue = z33.object({
931
+ value: z33.array(z33.string())
932
+ });
933
+ var PageBlockItemBooleanValue = z33.object({
934
+ value: z33.boolean()
935
+ });
936
+ var PageBlockItemCodeValue = z33.object({
937
+ format: PageBlockCodeLanguage.optional(),
938
+ caption: z33.string().optional(),
939
+ value: z33.string()
940
+ });
941
+ var PageBlockItemSandboxValue = z33.object({
942
+ showCode: z33.boolean().optional(),
943
+ backgroundColor: z33.string().optional(),
944
+ alignPreview: z33.enum(["Left", "Center"]).optional(),
945
+ value: z33.string()
946
+ });
947
+ var PageBlockItemColorValue = z33.record(z33.any());
948
+ var PageBlockItemComponentValue = z33.object({
949
+ selectedPropertyIds: z33.array(z33.string()).optional(),
950
+ value: z33.array(
951
+ z33.object({
952
+ entityId: z33.string(),
953
+ entityType: z33.enum(["Component", "ComponentGroup"])
954
+ })
955
+ )
956
+ });
957
+ var PageBlockItemComponentPropertyValue = z33.object({
958
+ value: z33.string()
959
+ });
960
+ var PageBlockItemDividerValue = z33.object({});
961
+ var PageBlockItemEmbedValue = z33.object({
962
+ value: z33.string().optional(),
963
+ caption: z33.string().optional(),
964
+ height: z33.number().optional()
965
+ });
915
966
  var PageBlockItemImageValue = z33.object({
916
967
  alt: z33.string().optional(),
917
968
  caption: z33.string().optional(),
918
969
  alignment: PageBlockImageAlignment.optional(),
919
970
  value: PageBlockItemImageReference.optional()
920
971
  });
921
- var PageBlockLinkV2 = z33.object({
922
- type: PageBlockLinkType,
923
- documentationItemId: z33.string().optional(),
924
- pageHeadingId: z33.string().optional(),
925
- url: z33.string().optional(),
926
- openInNewTab: z33.boolean().optional()
972
+ var PageBlockItemMarkdownValue = z33.object({
973
+ value: z33.string()
927
974
  });
928
- var PageBlockItemV2 = z33.object({
929
- id: z33.string(),
930
- linksTo: PageBlockLinkV2.optional(),
931
- props: z33.record(PageBlockItemUntypedPropertyValue)
975
+ var PageBlockItemMultiRichTextValue = z33.object({
976
+ value: PageBlockText.array()
932
977
  });
933
- var PageBlockDataV2 = z33.object({
934
- packageId: z33.string(),
935
- variantId: z33.string().optional(),
936
- indentLevel: z33.number(),
937
- appearance: PageBlockAppearanceV2.optional(),
938
- items: z33.array(PageBlockItemV2)
978
+ var PageBlockItemMultiSelectValue = z33.object({
979
+ value: z33.array(z33.string())
980
+ });
981
+ var PageBlockItemNumberValue = z33.object({
982
+ value: z33.number()
983
+ });
984
+ var PageBlockItemRichTextValue = z33.object({
985
+ value: PageBlockText,
986
+ calloutType: PageBlockCalloutType.optional()
987
+ });
988
+ var PageBlockItemSingleSelectValue = z33.object({
989
+ value: z33.string()
990
+ });
991
+ var PageBlockItemStorybookValue = z33.object({
992
+ caption: z33.string().optional(),
993
+ height: z33.number().optional(),
994
+ showAddons: z33.boolean().optional(),
995
+ value: z33.string()
996
+ });
997
+ var PageBlockItemTableValue = z33.object({
998
+ value: z33.any()
999
+ });
1000
+ var PageBlockItemTextValue = z33.object({
1001
+ value: z33.string()
1002
+ });
1003
+ var PageBlockItemTokenValue = z33.object({
1004
+ selectedPropertyIds: z33.array(z33.string()).optional(),
1005
+ selectedThemeIds: z33.array(z33.string()).optional(),
1006
+ value: z33.array(
1007
+ z33.object({
1008
+ entityId: z33.string(),
1009
+ entityType: z33.enum(["Token", "TokenGroup"])
1010
+ })
1011
+ )
1012
+ });
1013
+ var PageBlockItemTokenPropertyValue = z33.object({
1014
+ selectedPropertyIds: z33.array(z33.string()).optional(),
1015
+ selectedThemeIds: z33.array(z33.string()).optional(),
1016
+ value: z33.array(z33.string())
1017
+ });
1018
+ var PageBlockItemTokenTypeValue = z33.object({
1019
+ value: z33.array(DesignTokenType)
1020
+ });
1021
+ var PageBlockItemUrlValue = z33.object({
1022
+ value: z33.string()
939
1023
  });
940
1024
  var DocumentationItemConfiguration = z34.object({
941
1025
  showSidebar: z34.boolean(),
@@ -3690,17 +3774,17 @@ var BlockParsingUtils = {
3690
3774
  },
3691
3775
  richTextPropertyValue(item, propertyKey) {
3692
3776
  const objectValue = this.objectPropertyValue(item, propertyKey);
3693
- const richText = PageBlockItemRichTextPropertyValue.parse(objectValue);
3777
+ const richText = PageBlockItemRichTextValue.parse(objectValue);
3694
3778
  return richText;
3695
3779
  },
3696
3780
  multiRichTextPropertyValue(item, propertyKey) {
3697
3781
  const objectValue = this.objectPropertyValue(item, propertyKey);
3698
- const richText = PageBlockItemMultiRichTextPropertyValue.parse(objectValue);
3782
+ const richText = PageBlockItemMultiRichTextValue.parse(objectValue);
3699
3783
  return richText;
3700
3784
  },
3701
3785
  embedPropertyValue(item, propertyKey) {
3702
3786
  const objectValue = this.objectPropertyValue(item, propertyKey);
3703
- const embed = PageBlockItemEmbedPropertyValue.parse(objectValue);
3787
+ const embed = PageBlockItemEmbedValue.parse(objectValue);
3704
3788
  return embed;
3705
3789
  },
3706
3790
  objectPropertyValue(item, propertyKey) {
@@ -5657,20 +5741,11 @@ function parseItem(rawItem, definition) {
5657
5741
  if (!value) {
5658
5742
  continue;
5659
5743
  }
5660
- switch (property.type) {
5661
- case "Text":
5662
- PageBlockItemTextPropertyValue.parse(value);
5663
- break;
5664
- case "EmbedURL":
5665
- PageBlockItemEmbedPropertyValue.parse(value);
5666
- break;
5667
- case "Image":
5668
- PageBlockItemImageValue.parse(value);
5669
- break;
5670
- default:
5671
- return null;
5744
+ const valueSchema = valueSchemaForPropertyType(property.type);
5745
+ const validationResult = valueSchema.safeParse(value);
5746
+ if (validationResult.success) {
5747
+ sanitizedProps[property.id] = validationResult.data;
5672
5748
  }
5673
- sanitizedProps[property.id] = value;
5674
5749
  }
5675
5750
  return {
5676
5751
  id: parsedItem.data.id,
@@ -5678,6 +5753,58 @@ function parseItem(rawItem, definition) {
5678
5753
  props: sanitizedProps
5679
5754
  };
5680
5755
  }
5756
+ function valueSchemaForPropertyType(type) {
5757
+ switch (type) {
5758
+ case "RichText":
5759
+ return PageBlockItemRichTextValue;
5760
+ case "MultiRichText":
5761
+ return PageBlockItemMultiRichTextValue;
5762
+ case "Text":
5763
+ return PageBlockItemTextValue;
5764
+ case "Boolean":
5765
+ return PageBlockItemBooleanValue;
5766
+ case "Number":
5767
+ return PageBlockItemNumberValue;
5768
+ case "SingleSelect":
5769
+ return PageBlockItemSingleSelectValue;
5770
+ case "MultiSelect":
5771
+ return PageBlockItemMultiSelectValue;
5772
+ case "Image":
5773
+ return PageBlockItemImageValue;
5774
+ case "Token":
5775
+ return PageBlockItemTokenValue;
5776
+ case "TokenType":
5777
+ return PageBlockItemTokenTypeValue;
5778
+ case "TokenProperty":
5779
+ return PageBlockItemTokenPropertyValue;
5780
+ case "Component":
5781
+ return PageBlockItemComponentValue;
5782
+ case "ComponentProperty":
5783
+ return PageBlockItemComponentPropertyValue;
5784
+ case "Asset":
5785
+ return PageBlockItemAssetValue;
5786
+ case "AssetProperty":
5787
+ return PageBlockItemAssetPropertyValue;
5788
+ case "EmbedURL":
5789
+ return PageBlockItemEmbedValue;
5790
+ case "URL":
5791
+ return PageBlockItemUrlValue;
5792
+ case "Markdown":
5793
+ return PageBlockItemMarkdownValue;
5794
+ case "Code":
5795
+ return PageBlockItemCodeValue;
5796
+ case "CodeSandbox":
5797
+ return PageBlockItemSandboxValue;
5798
+ case "Table":
5799
+ return PageBlockItemTableValue;
5800
+ case "Divider":
5801
+ return PageBlockItemDividerValue;
5802
+ case "Storybook":
5803
+ return PageBlockItemStorybookValue;
5804
+ case "Color":
5805
+ return PageBlockItemColorValue;
5806
+ }
5807
+ }
5681
5808
  function parseProsemirrorBlockAttribute(prosemirrorNode, attributeName) {
5682
5809
  const attributeValue = parseProsemirrorOptionalBlockAttribute(prosemirrorNode, attributeName);
5683
5810
  if (!attributeValue) {
@@ -5963,13 +6090,32 @@ export {
5963
6090
  PageBlockFrameOrigin,
5964
6091
  PageBlockImageAlignment,
5965
6092
  PageBlockImageType,
5966
- PageBlockItemEmbedPropertyValue,
6093
+ PageBlockItemAssetPropertyValue,
6094
+ PageBlockItemAssetValue,
6095
+ PageBlockItemBooleanValue,
6096
+ PageBlockItemCodeValue,
6097
+ PageBlockItemColorValue,
6098
+ PageBlockItemComponentPropertyValue,
6099
+ PageBlockItemComponentValue,
6100
+ PageBlockItemDividerValue,
6101
+ PageBlockItemEmbedValue,
5967
6102
  PageBlockItemImageReference,
5968
6103
  PageBlockItemImageValue,
5969
- PageBlockItemMultiRichTextPropertyValue,
5970
- PageBlockItemRichTextPropertyValue,
5971
- PageBlockItemTextPropertyValue,
5972
- PageBlockItemUntypedPropertyValue,
6104
+ PageBlockItemMarkdownValue,
6105
+ PageBlockItemMultiRichTextValue,
6106
+ PageBlockItemMultiSelectValue,
6107
+ PageBlockItemNumberValue,
6108
+ PageBlockItemRichTextValue,
6109
+ PageBlockItemSandboxValue,
6110
+ PageBlockItemSingleSelectValue,
6111
+ PageBlockItemStorybookValue,
6112
+ PageBlockItemTableValue,
6113
+ PageBlockItemTextValue,
6114
+ PageBlockItemTokenPropertyValue,
6115
+ PageBlockItemTokenTypeValue,
6116
+ PageBlockItemTokenValue,
6117
+ PageBlockItemUntypedValue,
6118
+ PageBlockItemUrlValue,
5973
6119
  PageBlockItemV2,
5974
6120
  PageBlockLinkPreview,
5975
6121
  PageBlockLinkType,