@supernova-studio/model 0.0.9 → 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.
@@ -8,6 +8,7 @@ import { PageBlockDefinitionVariant } from "./variant";
8
8
 
9
9
  export const PageBlockDefinitionPropertyType = z.enum([
10
10
  "RichText",
11
+ "MultiRichText",
11
12
  "Text",
12
13
  "Boolean",
13
14
  "Number",
@@ -29,6 +30,7 @@ export const PageBlockDefinitionPropertyType = z.enum([
29
30
  "Table",
30
31
  "Divider",
31
32
  "Storybook",
33
+ "Color",
32
34
  ]);
33
35
 
34
36
  export const PageBlockDefinitionRichTextPropertyStyle = z.enum([
@@ -39,11 +41,11 @@ export const PageBlockDefinitionRichTextPropertyStyle = z.enum([
39
41
  "Title5",
40
42
  "Quote",
41
43
  "Callout",
42
- "OL",
43
- "UL",
44
44
  "Default",
45
45
  ]);
46
46
 
47
+ export const PageBlockDefinitionMultiRichTextPropertyStyle = z.enum(["OL", "UL", "Default"]);
48
+
47
49
  export const PageBlockDefinitionTextPropertyStyle = z.enum([
48
50
  "Title1",
49
51
  "Title2",
@@ -69,6 +71,9 @@ export const PageBlockDefinitionMultiSelectPropertyStyle = z.enum(["SegmentedCon
69
71
 
70
72
  export type PageBlockDefinitionPropertyType = z.infer<typeof PageBlockDefinitionPropertyType>;
71
73
  export type PageBlockDefinitionRichTextPropertyStyle = z.infer<typeof PageBlockDefinitionRichTextPropertyStyle>;
74
+ export type PageBlockDefinitionMultiRichTextPropertyStyle = z.infer<
75
+ typeof PageBlockDefinitionMultiRichTextPropertyStyle
76
+ >;
72
77
  export type PageBlockDefinitionTextPropertyStyle = z.infer<typeof PageBlockDefinitionTextPropertyStyle>;
73
78
  export type PageBlockDefinitionBooleanPropertyStyle = z.infer<typeof PageBlockDefinitionBooleanPropertyStyle>;
74
79
  export type PageBlockDefinitionSingleSelectPropertyStyle = z.infer<typeof PageBlockDefinitionSingleSelectPropertyStyle>;
@@ -81,6 +86,7 @@ export type PageBlockDefinitionMultiSelectPropertyStyle = z.infer<typeof PageBlo
81
86
  export const PageBlockDefinitionPropertyOptions = z
82
87
  .object({
83
88
  richTextStyle: PageBlockDefinitionRichTextPropertyStyle.optional(),
89
+ multiRichTextStyle: PageBlockDefinitionMultiRichTextPropertyStyle.optional(),
84
90
  textStyle: PageBlockDefinitionTextPropertyStyle.optional(),
85
91
  placeholder: z.string().optional(),
86
92
  })
@@ -219,6 +219,15 @@ export const PageBlockText = z.object({
219
219
  spans: z.array(PageBlockTextSpan),
220
220
  });
221
221
 
222
+ export type PageBlockCalloutType = z.infer<typeof PageBlockCalloutType>;
223
+ export type PageBlockCodeLanguage = z.infer<typeof PageBlockCodeLanguage>;
224
+ export type PageBlockAlignment = z.infer<typeof PageBlockAlignment>;
225
+ export type PageBlockThemeType = z.infer<typeof PageBlockThemeType>;
226
+ export type PageBlockAssetType = z.infer<typeof PageBlockAssetType>;
227
+ export type PageBlockTilesAlignment = z.infer<typeof PageBlockTilesAlignment>;
228
+ export type PageBlockTilesLayout = z.infer<typeof PageBlockTilesLayout>;
229
+ export type PageBlockTextSpanAttributeType = z.infer<typeof PageBlockTextSpanAttributeType>;
230
+
222
231
  export type PageBlockTypeV1 = z.infer<typeof PageBlockTypeV1>;
223
232
  export type PageBlockTextSpanAttribute = z.infer<typeof PageBlockTextSpanAttribute>;
224
233
  export type PageBlockTextSpan = z.infer<typeof PageBlockTextSpan>;
@@ -1,33 +1,39 @@
1
1
  import { z } from "zod";
2
2
  import { ColorValue } from "./color";
3
- import { PageBlockCalloutType } from "./documentation-block-v1";
3
+ import { PageBlockCalloutType, PageBlockCodeLanguage, PageBlockText } from "./documentation-block-v1";
4
+ import { Size } from "../primitives";
5
+ import { DesignTokenType } from "../raw-element";
4
6
 
5
7
  //
6
8
  // Enums
7
9
  //
8
10
 
9
- export const PageBlockLinkType = z.enum(["Page", "PageHeading", "Group", "Url"]);
11
+ export const PageBlockLinkType = z.enum(["DocumentationItem", "PageHeading", "Url"]);
12
+ export const PageBlockImageType = z.enum(["Upload", "Asset", "FigmaFrame"]);
13
+ export const PageBlockImageAlignment = z.enum(["Left", "Center", "Stretch"]);
10
14
 
11
15
  export type PageBlockLinkType = z.infer<typeof PageBlockLinkType>;
16
+ export type PageBlockImageType = z.infer<typeof PageBlockImageType>;
17
+ export type PageBlockImageAlignment = z.infer<typeof PageBlockImageAlignment>;
12
18
 
13
19
  //
14
- // Definitions
20
+ // Definitions - Block
15
21
  //
16
22
 
17
23
  export const PageBlockAppearanceV2 = z.object({
18
24
  itemBackgroundColor: ColorValue,
19
25
  });
20
26
 
21
- export const PageBlockItemPropertyValue = z.object({
22
- value: z.any(),
23
- calloutType: PageBlockCalloutType.optional(),
24
- });
27
+ export const PageBlockItemUntypedValue = z
28
+ .object({
29
+ value: z.any(),
30
+ })
31
+ .and(z.record(z.any()));
25
32
 
26
33
  export const PageBlockLinkV2 = z.object({
27
34
  type: PageBlockLinkType,
28
- pageId: z.string().optional(),
35
+ documentationItemId: z.string().optional(),
29
36
  pageHeadingId: z.string().optional(),
30
- groupId: z.string().optional(),
31
37
  url: z.string().optional(),
32
38
  openInNewTab: z.boolean().optional(),
33
39
  });
@@ -35,7 +41,7 @@ export const PageBlockLinkV2 = z.object({
35
41
  export const PageBlockItemV2 = z.object({
36
42
  id: z.string(),
37
43
  linksTo: PageBlockLinkV2.optional(),
38
- props: z.record(PageBlockItemPropertyValue),
44
+ props: z.record(PageBlockItemUntypedValue),
39
45
  });
40
46
 
41
47
  export const PageBlockDataV2 = z.object({
@@ -47,7 +53,181 @@ export const PageBlockDataV2 = z.object({
47
53
  });
48
54
 
49
55
  export type PageBlockAppearanceV2 = z.infer<typeof PageBlockAppearanceV2>;
50
- export type PageBlockItemPropertyValue = z.infer<typeof PageBlockItemPropertyValue>;
56
+ export type PageBlockItemUntypedValue = z.infer<typeof PageBlockItemUntypedValue>;
51
57
  export type PageBlockLinkV2 = z.infer<typeof PageBlockLinkV2>;
52
58
  export type PageBlockItemV2 = z.infer<typeof PageBlockItemV2>;
53
59
  export type PageBlockDataV2 = z.infer<typeof PageBlockDataV2>;
60
+
61
+ //
62
+ // Definitions - Typed Values
63
+ //
64
+
65
+ export const PageBlockItemImageReference = z.object({
66
+ type: PageBlockImageType,
67
+ url: z.string(),
68
+ assetId: z.string().optional(),
69
+ size: Size.optional(),
70
+ figmaFile: z
71
+ .object({
72
+ sourceId: z.string(),
73
+ frameId: z.string(),
74
+ })
75
+ .optional(),
76
+ });
77
+
78
+ export const PageBlockItemAssetValue = z.object({
79
+ selectedPropertyIds: z.array(z.string()).optional(),
80
+ showSearch: z.boolean().optional(),
81
+ previewContainerSize: z.enum(["Centered", "NaturalHeight"]).optional(),
82
+ backgroundColor: z.string().optional(),
83
+ value: z.array(
84
+ z.object({
85
+ entityId: z.string(),
86
+ entityType: z.enum(["Asset", "AssetGroup"]),
87
+ })
88
+ ),
89
+ });
90
+
91
+ export const PageBlockItemAssetPropertyValue = z.object({
92
+ value: z.array(z.string()),
93
+ });
94
+
95
+ export const PageBlockItemBooleanValue = z.object({
96
+ value: z.boolean(),
97
+ });
98
+
99
+ export const PageBlockItemCodeValue = z.object({
100
+ format: PageBlockCodeLanguage.optional(),
101
+ caption: z.string().optional(),
102
+ value: z.string(),
103
+ });
104
+
105
+ export const PageBlockItemSandboxValue = z.object({
106
+ showCode: z.boolean().optional(),
107
+ backgroundColor: z.string().optional(),
108
+ alignPreview: z.enum(["Left", "Center"]).optional(),
109
+ value: z.string(),
110
+ });
111
+
112
+ export const PageBlockItemColorValue = z.record(z.any());
113
+
114
+ export const PageBlockItemComponentValue = z.object({
115
+ selectedPropertyIds: z.array(z.string()).optional(),
116
+ value: z.array(
117
+ z.object({
118
+ entityId: z.string(),
119
+ entityType: z.enum(["Component", "ComponentGroup"]),
120
+ })
121
+ ),
122
+ });
123
+
124
+ export const PageBlockItemComponentPropertyValue = z.object({
125
+ value: z.string(),
126
+ });
127
+
128
+ export const PageBlockItemDividerValue = z.object({});
129
+
130
+ export const PageBlockItemEmbedValue = z.object({
131
+ value: z.string().optional(),
132
+ caption: z.string().optional(),
133
+ height: z.number().optional(),
134
+ });
135
+
136
+ export const PageBlockItemImageValue = z.object({
137
+ alt: z.string().optional(),
138
+ caption: z.string().optional(),
139
+ alignment: PageBlockImageAlignment.optional(),
140
+ value: PageBlockItemImageReference.optional(),
141
+ });
142
+
143
+ export const PageBlockItemMarkdownValue = z.object({
144
+ value: z.string(),
145
+ });
146
+
147
+ export const PageBlockItemMultiRichTextValue = z.object({
148
+ value: PageBlockText.array(),
149
+ });
150
+
151
+ export const PageBlockItemMultiSelectValue = z.object({
152
+ value: z.array(z.string()),
153
+ });
154
+
155
+ export const PageBlockItemNumberValue = z.object({
156
+ value: z.number(),
157
+ });
158
+
159
+ export const PageBlockItemRichTextValue = z.object({
160
+ value: PageBlockText,
161
+ calloutType: PageBlockCalloutType.optional(),
162
+ });
163
+
164
+ export const PageBlockItemSingleSelectValue = z.object({
165
+ value: z.string(),
166
+ });
167
+
168
+ export const PageBlockItemStorybookValue = z.object({
169
+ caption: z.string().optional(),
170
+ height: z.number().optional(),
171
+ showAddons: z.boolean().optional(),
172
+ value: z.string(),
173
+ });
174
+
175
+ export const PageBlockItemTableValue = z.object({
176
+ value: z.any(),
177
+ });
178
+
179
+ export const PageBlockItemTextValue = z.object({
180
+ value: z.string(),
181
+ });
182
+
183
+ export const PageBlockItemTokenValue = z.object({
184
+ selectedPropertyIds: z.array(z.string()).optional(),
185
+ selectedThemeIds: z.array(z.string()).optional(),
186
+ value: z.array(
187
+ z.object({
188
+ entityId: z.string(),
189
+ entityType: z.enum(["Token", "TokenGroup"]),
190
+ })
191
+ ),
192
+ });
193
+
194
+ export const PageBlockItemTokenPropertyValue = z.object({
195
+ selectedPropertyIds: z.array(z.string()).optional(),
196
+ selectedThemeIds: z.array(z.string()).optional(),
197
+ value: z.array(z.string()),
198
+ });
199
+
200
+ export const PageBlockItemTokenTypeValue = z.object({
201
+ value: z.array(DesignTokenType),
202
+ });
203
+
204
+ export const PageBlockItemUrlValue = z.object({
205
+ value: z.string(),
206
+ });
207
+
208
+ export type PageBlockItemImageReference = z.infer<typeof PageBlockItemImageReference>;
209
+
210
+ export type PageBlockItemAssetValue = z.infer<typeof PageBlockItemAssetValue>;
211
+ export type PageBlockItemAssetPropertyValue = z.infer<typeof PageBlockItemAssetPropertyValue>;
212
+ export type PageBlockItemBooleanValue = z.infer<typeof PageBlockItemBooleanValue>;
213
+ export type PageBlockItemCodeValue = z.infer<typeof PageBlockItemCodeValue>;
214
+ export type PageBlockItemSandboxValue = z.infer<typeof PageBlockItemSandboxValue>;
215
+ export type PageBlockItemColorValue = z.infer<typeof PageBlockItemColorValue>;
216
+ export type PageBlockItemComponentValue = z.infer<typeof PageBlockItemComponentValue>;
217
+ export type PageBlockItemComponentPropertyValue = z.infer<typeof PageBlockItemComponentPropertyValue>;
218
+ export type PageBlockItemDividerValue = z.infer<typeof PageBlockItemDividerValue>;
219
+ export type PageBlockItemEmbedValue = z.infer<typeof PageBlockItemEmbedValue>;
220
+ export type PageBlockItemImageValue = z.infer<typeof PageBlockItemImageValue>;
221
+ export type PageBlockItemMarkdownValue = z.infer<typeof PageBlockItemMarkdownValue>;
222
+ export type PageBlockItemMultiRichTextValue = z.infer<typeof PageBlockItemMultiRichTextValue>;
223
+ export type PageBlockItemMultiSelectValue = z.infer<typeof PageBlockItemMultiSelectValue>;
224
+ export type PageBlockItemNumberValue = z.infer<typeof PageBlockItemNumberValue>;
225
+ export type PageBlockItemRichTextValue = z.infer<typeof PageBlockItemRichTextValue>;
226
+ export type PageBlockItemSingleSelectValue = z.infer<typeof PageBlockItemSingleSelectValue>;
227
+ export type PageBlockItemStorybookValue = z.infer<typeof PageBlockItemStorybookValue>;
228
+ export type PageBlockItemTableValue = z.infer<typeof PageBlockItemTableValue>;
229
+ export type PageBlockItemTextValue = z.infer<typeof PageBlockItemTextValue>;
230
+ export type PageBlockItemTokenValue = z.infer<typeof PageBlockItemTokenValue>;
231
+ export type PageBlockItemTokenPropertyValue = z.infer<typeof PageBlockItemTokenPropertyValue>;
232
+ export type PageBlockItemTokenTypeValue = z.infer<typeof PageBlockItemTokenTypeValue>;
233
+ export type PageBlockItemUrlValue = z.infer<typeof PageBlockItemUrlValue>;
@@ -1,4 +1,3 @@
1
1
  export * from "./common";
2
2
  export * from "./db";
3
3
  export * from "./nullish-to-optional";
4
- export * from "./slug-helper";
@@ -0,0 +1,4 @@
1
+ // Consists of lowercased letters, digits and hyphens.
2
+ // Can not start or end with hyphen.
3
+ // Warning: does not forbid consecutive hyphens
4
+ export const slugRegex = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { UserInvites } from "./user-invite";
3
- import { SLUG_REGEX } from "../helpers";
4
3
  import { ProductCodeSchema } from "../billing";
4
+ import { slugRegex } from "../utils/validation";
5
5
 
6
6
  const WORKSPACE_NAME_MIN_LENGTH: number = 2;
7
7
  const WORKSPACE_NAME_MAX_LENGTH: number = 64;
@@ -15,7 +15,7 @@ export const CreateWorkspaceInput = z.object({
15
15
  billingEmail: z.string().email().optional(),
16
16
  handle: z
17
17
  .string()
18
- .regex(SLUG_REGEX)
18
+ .regex(slugRegex)
19
19
  .min(HANDLE_MIN_LENGTH)
20
20
  .max(HANDLE_MAX_LENGTH)
21
21
  .refine(value => value?.length > 0)
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src';