@supernova-studio/model 0.2.2 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/model",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { ColorValue } from "./color";
3
- import { PageBlockCalloutType, PageBlockText } from "./documentation-block-v1";
3
+ import { PageBlockCalloutType, PageBlockCodeLanguage, PageBlockText } from "./documentation-block-v1";
4
4
  import { Size } from "../primitives";
5
+ import { DesignTokenType } from "../raw-element";
5
6
 
6
7
  //
7
8
  // Enums
@@ -10,44 +11,58 @@ import { Size } from "../primitives";
10
11
  export const PageBlockLinkType = z.enum(["DocumentationItem", "PageHeading", "Url"]);
11
12
  export const PageBlockImageType = z.enum(["Upload", "Asset", "FigmaFrame"]);
12
13
  export const PageBlockImageAlignment = z.enum(["Left", "Center", "Stretch"]);
14
+ export const PageBlockTableCellAlignment = z.enum(["Left", "Center", "Right"]);
13
15
 
14
16
  export type PageBlockLinkType = z.infer<typeof PageBlockLinkType>;
15
17
  export type PageBlockImageType = z.infer<typeof PageBlockImageType>;
16
18
  export type PageBlockImageAlignment = z.infer<typeof PageBlockImageAlignment>;
19
+ export type PageBlockTableCellAlignment = z.infer<typeof PageBlockTableCellAlignment>;
17
20
 
18
21
  //
19
- // Definitions
22
+ // Definitions - Block
20
23
  //
21
24
 
22
25
  export const PageBlockAppearanceV2 = z.object({
23
26
  itemBackgroundColor: ColorValue,
24
27
  });
25
28
 
26
- export const PageBlockItemUntypedPropertyValue = z
29
+ export const PageBlockItemUntypedValue = z
27
30
  .object({
28
31
  value: z.any(),
29
32
  })
30
33
  .and(z.record(z.any()));
31
34
 
32
- export const PageBlockItemRichTextPropertyValue = z.object({
33
- value: PageBlockText,
34
- calloutType: PageBlockCalloutType.optional(),
35
+ export const PageBlockLinkV2 = z.object({
36
+ type: PageBlockLinkType,
37
+ documentationItemId: z.string().optional(),
38
+ pageHeadingId: z.string().optional(),
39
+ url: z.string().optional(),
40
+ openInNewTab: z.boolean().optional(),
35
41
  });
36
42
 
37
- export const PageBlockItemEmbedPropertyValue = z.object({
38
- value: z.string().optional(),
39
- caption: z.string().optional(),
40
- height: z.number().optional(),
43
+ export const PageBlockItemV2 = z.object({
44
+ id: z.string(),
45
+ linksTo: PageBlockLinkV2.optional(),
46
+ props: z.record(PageBlockItemUntypedValue),
41
47
  });
42
48
 
43
- export const PageBlockItemMultiRichTextPropertyValue = z.object({
44
- value: PageBlockText.array(),
49
+ export const PageBlockDataV2 = z.object({
50
+ packageId: z.string(),
51
+ variantId: z.string().optional(),
52
+ indentLevel: z.number(),
53
+ appearance: PageBlockAppearanceV2.optional(),
54
+ items: z.array(PageBlockItemV2),
45
55
  });
46
56
 
47
- export const PageBlockItemTextPropertyValue = z.object({
48
- value: z.string(),
49
- calloutType: PageBlockCalloutType.optional(),
50
- });
57
+ export type PageBlockAppearanceV2 = z.infer<typeof PageBlockAppearanceV2>;
58
+ export type PageBlockItemUntypedValue = z.infer<typeof PageBlockItemUntypedValue>;
59
+ export type PageBlockLinkV2 = z.infer<typeof PageBlockLinkV2>;
60
+ export type PageBlockItemV2 = z.infer<typeof PageBlockItemV2>;
61
+ export type PageBlockDataV2 = z.infer<typeof PageBlockDataV2>;
62
+
63
+ //
64
+ // Definitions - Typed Values
65
+ //
51
66
 
52
67
  export const PageBlockItemImageReference = z.object({
53
68
  type: PageBlockImageType,
@@ -62,6 +77,64 @@ export const PageBlockItemImageReference = z.object({
62
77
  .optional(),
63
78
  });
64
79
 
80
+ export const PageBlockItemAssetValue = z.object({
81
+ selectedPropertyIds: z.array(z.string()).optional(),
82
+ showSearch: z.boolean().optional(),
83
+ previewContainerSize: z.enum(["Centered", "NaturalHeight"]).optional(),
84
+ backgroundColor: z.string().optional(),
85
+ value: z.array(
86
+ z.object({
87
+ entityId: z.string(),
88
+ entityType: z.enum(["Asset", "AssetGroup"]),
89
+ })
90
+ ),
91
+ });
92
+
93
+ export const PageBlockItemAssetPropertyValue = z.object({
94
+ value: z.array(z.string()),
95
+ });
96
+
97
+ export const PageBlockItemBooleanValue = z.object({
98
+ value: z.boolean(),
99
+ });
100
+
101
+ export const PageBlockItemCodeValue = z.object({
102
+ format: PageBlockCodeLanguage.optional(),
103
+ caption: z.string().optional(),
104
+ value: z.string(),
105
+ });
106
+
107
+ export const PageBlockItemSandboxValue = z.object({
108
+ showCode: z.boolean().optional(),
109
+ backgroundColor: z.string().optional(),
110
+ alignPreview: z.enum(["Left", "Center"]).optional(),
111
+ value: z.string(),
112
+ });
113
+
114
+ export const PageBlockItemColorValue = z.record(z.any());
115
+
116
+ export const PageBlockItemComponentValue = z.object({
117
+ selectedPropertyIds: z.array(z.string()).optional(),
118
+ value: z.array(
119
+ z.object({
120
+ entityId: z.string(),
121
+ entityType: z.enum(["Component", "ComponentGroup"]),
122
+ })
123
+ ),
124
+ });
125
+
126
+ export const PageBlockItemComponentPropertyValue = z.object({
127
+ value: z.string(),
128
+ });
129
+
130
+ export const PageBlockItemDividerValue = z.object({});
131
+
132
+ export const PageBlockItemEmbedValue = z.object({
133
+ value: z.string().optional(),
134
+ caption: z.string().optional(),
135
+ height: z.number().optional(),
136
+ });
137
+
65
138
  export const PageBlockItemImageValue = z.object({
66
139
  alt: z.string().optional(),
67
140
  caption: z.string().optional(),
@@ -69,37 +142,141 @@ export const PageBlockItemImageValue = z.object({
69
142
  value: PageBlockItemImageReference.optional(),
70
143
  });
71
144
 
72
- export const PageBlockLinkV2 = z.object({
73
- type: PageBlockLinkType,
74
- documentationItemId: z.string().optional(),
75
- pageHeadingId: z.string().optional(),
76
- url: z.string().optional(),
77
- openInNewTab: z.boolean().optional(),
145
+ export const PageBlockItemMarkdownValue = z.object({
146
+ value: z.string(),
78
147
  });
79
148
 
80
- export const PageBlockItemV2 = z.object({
81
- id: z.string(),
82
- linksTo: PageBlockLinkV2.optional(),
83
- props: z.record(PageBlockItemUntypedPropertyValue),
149
+ export const PageBlockItemMultiRichTextValue = z.object({
150
+ value: PageBlockText.array(),
84
151
  });
85
152
 
86
- export const PageBlockDataV2 = z.object({
87
- packageId: z.string(),
88
- variantId: z.string().optional(),
89
- indentLevel: z.number(),
90
- appearance: PageBlockAppearanceV2.optional(),
91
- items: z.array(PageBlockItemV2),
153
+ export const PageBlockItemMultiSelectValue = z.object({
154
+ value: z.array(z.string()),
155
+ });
156
+
157
+ export const PageBlockItemNumberValue = z.object({
158
+ value: z.number(),
159
+ });
160
+
161
+ export const PageBlockItemRichTextValue = z.object({
162
+ value: PageBlockText,
163
+ calloutType: PageBlockCalloutType.optional(),
164
+ });
165
+
166
+ export const PageBlockItemSingleSelectValue = z.object({
167
+ value: z.string(),
168
+ });
169
+
170
+ export const PageBlockItemStorybookValue = z.object({
171
+ caption: z.string().optional(),
172
+ height: z.number().optional(),
173
+ showAddons: z.boolean().optional(),
174
+ value: z.string(),
175
+ });
176
+
177
+ export const PageBlockItemTextValue = z.object({
178
+ value: z.string(),
179
+ });
180
+
181
+ export const PageBlockItemTokenValue = z.object({
182
+ selectedPropertyIds: z.array(z.string()).optional(),
183
+ selectedThemeIds: z.array(z.string()).optional(),
184
+ value: z.array(
185
+ z.object({
186
+ entityId: z.string(),
187
+ entityType: z.enum(["Token", "TokenGroup"]),
188
+ })
189
+ ),
190
+ });
191
+
192
+ export const PageBlockItemTokenPropertyValue = z.object({
193
+ selectedPropertyIds: z.array(z.string()).optional(),
194
+ selectedThemeIds: z.array(z.string()).optional(),
195
+ value: z.array(z.string()),
196
+ });
197
+
198
+ export const PageBlockItemTokenTypeValue = z.object({
199
+ value: z.array(DesignTokenType),
200
+ });
201
+
202
+ export const PageBlockItemUrlValue = z.object({
203
+ value: z.string(),
92
204
  });
93
205
 
94
- export type PageBlockAppearanceV2 = z.infer<typeof PageBlockAppearanceV2>;
95
- export type PageBlockItemUntypedPropertyValue = z.infer<typeof PageBlockItemUntypedPropertyValue>;
96
- export type PageBlockItemRichTextPropertyValue = z.infer<typeof PageBlockItemRichTextPropertyValue>;
97
- export type PageBlockItemMultiRichTextPropertyValue = z.infer<typeof PageBlockItemMultiRichTextPropertyValue>;
98
- export type PageBlockItemTextPropertyValue = z.infer<typeof PageBlockItemTextPropertyValue>;
99
- export type PageBlockItemEmbedPropertyValue = z.infer<typeof PageBlockItemEmbedPropertyValue>;
100
- export type PageBlockItemImageValue = z.infer<typeof PageBlockItemImageValue>;
101
206
  export type PageBlockItemImageReference = z.infer<typeof PageBlockItemImageReference>;
102
207
 
103
- export type PageBlockLinkV2 = z.infer<typeof PageBlockLinkV2>;
104
- export type PageBlockItemV2 = z.infer<typeof PageBlockItemV2>;
105
- export type PageBlockDataV2 = z.infer<typeof PageBlockDataV2>;
208
+ export type PageBlockItemAssetValue = z.infer<typeof PageBlockItemAssetValue>;
209
+ export type PageBlockItemAssetPropertyValue = z.infer<typeof PageBlockItemAssetPropertyValue>;
210
+ export type PageBlockItemBooleanValue = z.infer<typeof PageBlockItemBooleanValue>;
211
+ export type PageBlockItemCodeValue = z.infer<typeof PageBlockItemCodeValue>;
212
+ export type PageBlockItemSandboxValue = z.infer<typeof PageBlockItemSandboxValue>;
213
+ export type PageBlockItemColorValue = z.infer<typeof PageBlockItemColorValue>;
214
+ export type PageBlockItemComponentValue = z.infer<typeof PageBlockItemComponentValue>;
215
+ export type PageBlockItemComponentPropertyValue = z.infer<typeof PageBlockItemComponentPropertyValue>;
216
+ export type PageBlockItemDividerValue = z.infer<typeof PageBlockItemDividerValue>;
217
+ export type PageBlockItemEmbedValue = z.infer<typeof PageBlockItemEmbedValue>;
218
+ export type PageBlockItemImageValue = z.infer<typeof PageBlockItemImageValue>;
219
+ export type PageBlockItemMarkdownValue = z.infer<typeof PageBlockItemMarkdownValue>;
220
+ export type PageBlockItemMultiRichTextValue = z.infer<typeof PageBlockItemMultiRichTextValue>;
221
+ export type PageBlockItemMultiSelectValue = z.infer<typeof PageBlockItemMultiSelectValue>;
222
+ export type PageBlockItemNumberValue = z.infer<typeof PageBlockItemNumberValue>;
223
+ export type PageBlockItemRichTextValue = z.infer<typeof PageBlockItemRichTextValue>;
224
+ export type PageBlockItemSingleSelectValue = z.infer<typeof PageBlockItemSingleSelectValue>;
225
+ export type PageBlockItemStorybookValue = z.infer<typeof PageBlockItemStorybookValue>;
226
+ export type PageBlockItemTextValue = z.infer<typeof PageBlockItemTextValue>;
227
+ export type PageBlockItemTokenValue = z.infer<typeof PageBlockItemTokenValue>;
228
+ export type PageBlockItemTokenPropertyValue = z.infer<typeof PageBlockItemTokenPropertyValue>;
229
+ export type PageBlockItemTokenTypeValue = z.infer<typeof PageBlockItemTokenTypeValue>;
230
+ export type PageBlockItemUrlValue = z.infer<typeof PageBlockItemUrlValue>;
231
+
232
+ //
233
+ // Definitions - Table Value
234
+ //
235
+
236
+ export const PageBlockItemTableRichTextNode = z.object({
237
+ type: z.literal("RichText"),
238
+ value: PageBlockItemRichTextValue.shape.value,
239
+ });
240
+
241
+ export const PageBlockItemTableMultiRichTextNode = z.object({
242
+ type: z.literal("MultiRichText"),
243
+ value: PageBlockItemMultiRichTextValue.shape.value,
244
+ });
245
+
246
+ export const PageBlockItemTableImageNode = z.object({
247
+ type: z.literal("Image"),
248
+ value: PageBlockItemImageValue.shape.value,
249
+ });
250
+
251
+ export const PageBlockItemTableNode = z.discriminatedUnion("type", [
252
+ PageBlockItemTableRichTextNode,
253
+ PageBlockItemTableMultiRichTextNode,
254
+ PageBlockItemTableImageNode,
255
+ ]);
256
+
257
+ export const PageBlockItemTableCell = z.object({
258
+ id: z.string(),
259
+ nodes: z.array(PageBlockItemTableNode),
260
+ columnWidth: z.number().optional(),
261
+ alignment: PageBlockTableCellAlignment,
262
+ });
263
+
264
+ export const PageBlockItemTableRow = z.object({
265
+ cells: z.array(PageBlockItemTableCell),
266
+ });
267
+
268
+ export const PageBlockItemTableValue = z.object({
269
+ highlightHeaderColumn: z.boolean().optional(),
270
+ highlightHeaderRow: z.boolean().optional(),
271
+ showBorder: z.boolean().optional(),
272
+ width: z.number().optional(),
273
+ value: z.array(PageBlockItemTableRow),
274
+ });
275
+
276
+ export type PageBlockItemTableRichTextNode = z.infer<typeof PageBlockItemTableRichTextNode>;
277
+ export type PageBlockItemTableMultiRichTextNode = z.infer<typeof PageBlockItemTableMultiRichTextNode>;
278
+ export type PageBlockItemTableImageNode = z.infer<typeof PageBlockItemTableImageNode>;
279
+ export type PageBlockItemTableNode = z.infer<typeof PageBlockItemTableNode>;
280
+ export type PageBlockItemTableCell = z.infer<typeof PageBlockItemTableCell>;
281
+ export type PageBlockItemTableRow = z.infer<typeof PageBlockItemTableRow>;
282
+ export type PageBlockItemTableValue = z.infer<typeof PageBlockItemTableValue>;