@supernova-studio/model 0.19.2 → 0.20.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.19.2",
3
+ "version": "0.20.0",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,6 +25,24 @@ export type PageBlockThemeDisplayMode = z.infer<typeof PageBlockThemeDisplayMode
25
25
  // Definitions - Block
26
26
  //
27
27
 
28
+ export const PageBlockImageReference = z.object({
29
+ type: PageBlockImageType,
30
+ url: z.string(),
31
+ assetId: z.string().optional(),
32
+ size: Size.optional(),
33
+ figmaFile: z
34
+ .object({
35
+ sourceId: z.string(),
36
+ frameId: z.string(),
37
+ frameReferenceId: z.string(),
38
+ origin: z.object({
39
+ title: z.string().optional(),
40
+ sourceFileName: z.string().optional(),
41
+ }),
42
+ })
43
+ .optional(),
44
+ });
45
+
28
46
  export const PageBlockColorV2 = z.object({
29
47
  value: z.string(),
30
48
  referencedTokenId: z.string().optional(),
@@ -63,6 +81,7 @@ export const PageBlockDataV2 = z.object({
63
81
  items: z.array(PageBlockItemV2),
64
82
  });
65
83
 
84
+ export type PageBlockImageReference = z.infer<typeof PageBlockImageReference>;
66
85
  export type PageBlockColorV2 = z.infer<typeof PageBlockColorV2>;
67
86
  export type PageBlockAppearanceV2 = z.infer<typeof PageBlockAppearanceV2>;
68
87
  export type PageBlockItemUntypedValue = z.infer<typeof PageBlockItemUntypedValue>;
@@ -74,24 +93,6 @@ export type PageBlockDataV2 = z.infer<typeof PageBlockDataV2>;
74
93
  // Definitions - Typed Values
75
94
  //
76
95
 
77
- export const PageBlockItemImageReference = z.object({
78
- type: PageBlockImageType,
79
- url: z.string(),
80
- assetId: z.string().optional(),
81
- size: Size.optional(),
82
- figmaFile: z
83
- .object({
84
- sourceId: z.string(),
85
- frameId: z.string(),
86
- frameReferenceId: z.string(),
87
- origin: z.object({
88
- title: z.string().optional(),
89
- sourceFileName: z.string().optional(),
90
- }),
91
- })
92
- .optional(),
93
- });
94
-
95
96
  export const PageBlockItemAssetValue = z.object({
96
97
  selectedPropertyIds: z.array(z.string()).optional(),
97
98
  showSearch: z.boolean().optional(),
@@ -186,7 +187,7 @@ export const PageBlockItemImageValue = z.object({
186
187
  alt: z.string().optional(),
187
188
  caption: z.string().optional(),
188
189
  alignment: PageBlockImageAlignment.optional(),
189
- value: PageBlockItemImageReference.optional(),
190
+ value: PageBlockImageReference.optional(),
190
191
  });
191
192
 
192
193
  export const PageBlockItemMarkdownValue = z.object({
@@ -256,8 +257,6 @@ export const PageBlockItemUrlValue = z.object({
256
257
  value: z.string(),
257
258
  });
258
259
 
259
- export type PageBlockItemImageReference = z.infer<typeof PageBlockItemImageReference>;
260
-
261
260
  export type PageBlockItemAssetValue = z.infer<typeof PageBlockItemAssetValue>;
262
261
  export type PageBlockItemAssetPropertyValue = z.infer<typeof PageBlockItemAssetPropertyValue>;
263
262
  export type PageBlockItemBooleanValue = z.infer<typeof PageBlockItemBooleanValue>;
@@ -1,13 +1,14 @@
1
1
  import { z } from "zod";
2
- import { DocumentationItemConfiguration } from "./documentation";
2
+ import { DocumentationItemConfigurationV1 } from "./documentation-v1";
3
3
  import { PageBlockV1 } from "./documentation-block-v1";
4
4
  import { nullishToOptional } from "../../../helpers";
5
5
 
6
6
  export const DocumentationPageDataV1 = z.object({
7
7
  blocks: z.array(PageBlockV1),
8
- configuration: nullishToOptional(DocumentationItemConfiguration),
8
+ configuration: nullishToOptional(DocumentationItemConfigurationV1),
9
9
  });
10
10
 
11
11
  export const DocumentationPageElementDataV1 = z.object({
12
+ dataVersion: z.literal(1).optional().default(1),
12
13
  value: DocumentationPageDataV1,
13
14
  });
@@ -1,11 +1,13 @@
1
1
  import { z } from "zod";
2
- import { DocumentationItemConfiguration } from "./documentation";
2
+ import { DocumentationItemConfigurationV2 } from "./documentation-v2";
3
3
  import { nullishToOptional } from "../../../helpers";
4
+ import { DocumentationPageDataV1 } from "./documentation-page-v1";
4
5
 
5
6
  export const DocumentationPageDataV2 = z.object({
6
- configuration: nullishToOptional(DocumentationItemConfiguration),
7
+ configuration: nullishToOptional(DocumentationItemConfigurationV2),
7
8
  });
8
9
 
9
10
  export const DocumentationPageElementDataV2 = z.object({
10
- value: DocumentationPageDataV2,
11
+ value: DocumentationPageDataV1,
12
+ valueV2: DocumentationPageDataV2.optional(),
11
13
  });
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { DocumentationItemHeaderV1, defaultDocumentationItemHeaderV1 } from "./item-header-v1";
3
+
4
+ export const DocumentationItemConfigurationV1 = z.object({
5
+ showSidebar: z.boolean(),
6
+ header: DocumentationItemHeaderV1,
7
+ });
8
+
9
+ export type DocumentationItemConfigurationV1 = z.infer<typeof DocumentationItemConfigurationV1>;
10
+
11
+ export const defaultDocumentationItemConfigurationV1: DocumentationItemConfigurationV1 = {
12
+ header: defaultDocumentationItemHeaderV1,
13
+ showSidebar: true,
14
+ };
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ import { DocumentationItemHeaderV2, defaultDocumentationItemHeaderV2 } from "./item-header-v2";
3
+
4
+ export const DocumentationItemConfigurationV2 = z.object({
5
+ showSidebar: z.boolean(),
6
+ header: DocumentationItemHeaderV2,
7
+ });
8
+
9
+ export type DocumentationItemConfigurationV2 = z.infer<typeof DocumentationItemConfigurationV2>;
10
+
11
+ export const defaultDocumentationItemConfigurationV2: DocumentationItemConfigurationV2 = {
12
+ header: defaultDocumentationItemHeaderV2,
13
+ showSidebar: true,
14
+ };
@@ -1,17 +1,24 @@
1
1
  import { z } from "zod";
2
2
  import { nullishToOptional } from "../../../helpers";
3
- import { DocumentationItemConfiguration } from "./documentation";
3
+ import { DocumentationItemConfigurationV1 } from "./documentation-v1";
4
+ import { DocumentationItemConfigurationV2 } from "./documentation-v2";
4
5
 
5
6
  export const DocumentationGroupBehavior = z.enum(["Group", "Tabs"]);
6
7
 
7
- export const ElementGroupData = z.object({
8
+ export const ElementGroupDataDeprecated = z.object({
8
9
  behavior: nullishToOptional(DocumentationGroupBehavior.optional()),
9
- configuration: nullishToOptional(DocumentationItemConfiguration),
10
+ configuration: nullishToOptional(DocumentationItemConfigurationV1),
11
+ });
12
+
13
+ export const ElementGroupDataV2 = z.object({
14
+ behavior: nullishToOptional(DocumentationGroupBehavior.optional()),
15
+ configuration: nullishToOptional(DocumentationItemConfigurationV2),
10
16
  });
11
17
 
12
18
  export const ElementGroupElementData = z.object({
13
- value: ElementGroupData.optional(),
19
+ value: ElementGroupDataDeprecated.optional(),
20
+ valueV2: ElementGroupDataV2.optional(),
14
21
  });
15
22
 
16
23
  export type DocumentationGroupBehavior = z.infer<typeof DocumentationGroupBehavior>;
17
- export type ElementGroupData = z.infer<typeof ElementGroupData>;
24
+ export type ElementGroupDataV2 = z.infer<typeof ElementGroupDataV2>;
@@ -10,7 +10,8 @@ export * from "./documentation-block-v1";
10
10
  export * from "./documentation-block-v2";
11
11
  export * from "./documentation-page-v1";
12
12
  export * from "./documentation-page-v2";
13
- export * from "./documentation";
13
+ export * from "./documentation-v1";
14
+ export * from "./documentation-v2";
14
15
  export * from "./duration";
15
16
  export * from "./figma-file-structure";
16
17
  export * from "./figma-node-reference";
@@ -19,6 +20,8 @@ export * from "./font-size";
19
20
  export * from "./font-weight";
20
21
  export * from "./gradient";
21
22
  export * from "./group";
23
+ export * from "./item-header-v1";
24
+ export * from "./item-header-v2";
22
25
  export * from "./item-header";
23
26
  export * from "./letter-spacing";
24
27
  export * from "./line-height";
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { DocumentationPageAsset } from "./page-asset";
3
+ import { ColorTokenData } from "./color";
4
+ import {
5
+ DocumentationItemHeaderAlignment,
6
+ DocumentationItemHeaderAlignmentSchema,
7
+ DocumentationItemHeaderImageScaleType,
8
+ DocumentationItemHeaderImageScaleTypeSchema,
9
+ } from "./item-header";
10
+
11
+ //
12
+ // Definitions
13
+ //
14
+
15
+ export const DocumentationItemHeaderV1 = z.object({
16
+ description: z.string(),
17
+ alignment: DocumentationItemHeaderAlignmentSchema,
18
+ foregroundColor: ColorTokenData.nullish(),
19
+ backgroundColor: ColorTokenData.nullish(),
20
+ backgroundImageAsset: DocumentationPageAsset.nullish(),
21
+ backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
22
+ showBackgroundOverlay: z.boolean(),
23
+ showCoverText: z.boolean(),
24
+ minHeight: z.number().nullish(),
25
+ });
26
+
27
+ export type DocumentationItemHeaderV1 = z.infer<typeof DocumentationItemHeaderV1>;
28
+
29
+ export const defaultDocumentationItemHeaderV1: DocumentationItemHeaderV1 = {
30
+ alignment: DocumentationItemHeaderAlignment.Left,
31
+ backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
32
+ description: "",
33
+ showBackgroundOverlay: false,
34
+ showCoverText: true,
35
+ };
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { DocumentationPageAsset } from "./page-asset";
3
+ import {
4
+ DocumentationItemHeaderAlignment,
5
+ DocumentationItemHeaderAlignmentSchema,
6
+ DocumentationItemHeaderImageScaleType,
7
+ DocumentationItemHeaderImageScaleTypeSchema,
8
+ } from "./item-header";
9
+ import { PageBlockColorV2 } from "./documentation-block-v2";
10
+
11
+ //
12
+ // Definitions
13
+ //
14
+
15
+ export const DocumentationItemHeaderV2 = z.object({
16
+ description: z.string(),
17
+ alignment: DocumentationItemHeaderAlignmentSchema,
18
+ foregroundColor: PageBlockColorV2.nullish(),
19
+ backgroundColor: PageBlockColorV2.nullish(),
20
+ backgroundImageAsset: DocumentationPageAsset.nullish(),
21
+ backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
22
+ showBackgroundOverlay: z.boolean(),
23
+ showCoverText: z.boolean(),
24
+ minHeight: z.number().nullish(),
25
+ });
26
+
27
+ export type DocumentationItemHeaderV2 = z.infer<typeof DocumentationItemHeaderV2>;
28
+
29
+ export const defaultDocumentationItemHeaderV2: DocumentationItemHeaderV2 = {
30
+ alignment: DocumentationItemHeaderAlignment.Left,
31
+ backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
32
+ description: "",
33
+ showBackgroundOverlay: false,
34
+ showCoverText: true,
35
+ };
@@ -1,18 +1,9 @@
1
- import { z } from "zod";
2
- import { DocumentationPageAsset } from "./page-asset";
3
- import { ColorTokenData } from "./color";
4
-
5
- //
6
- // Consts
7
- //
8
-
9
- export const colorValueRegex = /^#[a-f0-9]{8}$/;
10
- export const colorValueFormatDescription = "Must match /^#[a-f0-9]{8}$/";
11
-
12
1
  //
13
2
  // Enums
14
3
  //
15
4
 
5
+ import { z } from "zod";
6
+
16
7
  export const DocumentationItemHeaderAlignmentSchema = z.enum(["Left", "Center"]);
17
8
  export const DocumentationItemHeaderImageScaleTypeSchema = z.enum(["AspectFill", "AspectFit"]);
18
9
 
@@ -21,29 +12,3 @@ export const DocumentationItemHeaderImageScaleType = DocumentationItemHeaderImag
21
12
 
22
13
  export type DocumentationItemHeaderImageScaleType = z.infer<typeof DocumentationItemHeaderImageScaleTypeSchema>;
23
14
  export type DocumentationItemHeaderAlignment = z.infer<typeof DocumentationItemHeaderAlignmentSchema>;
24
-
25
- //
26
- // Definitions
27
- //
28
-
29
- export const DocumentationItemHeader = z.object({
30
- description: z.string(),
31
- alignment: DocumentationItemHeaderAlignmentSchema,
32
- foregroundColor: ColorTokenData.nullish(),
33
- backgroundColor: ColorTokenData.nullish(),
34
- backgroundImageAsset: DocumentationPageAsset.nullish(),
35
- backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
36
- showBackgroundOverlay: z.boolean(),
37
- showCoverText: z.boolean(),
38
- minHeight: z.number().nullish(),
39
- });
40
-
41
- export type DocumentationItemHeader = z.infer<typeof DocumentationItemHeader>;
42
-
43
- export const defaultDocumentationItemHeader: DocumentationItemHeader = {
44
- alignment: DocumentationItemHeaderAlignment.Left,
45
- backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
46
- description: "",
47
- showBackgroundOverlay: false,
48
- showCoverText: true,
49
- };
@@ -3,12 +3,15 @@ import { DesignElementBase, DesignElementGroupableRequiredPart, DesignElementSlu
3
3
  import { DbCreateInputOmit, DbUpdate } from "../../helpers";
4
4
  import { OmitStrict } from "../../utils";
5
5
  import { DocumentationPageDataV2 } from "./data/documentation-page-v2";
6
+ import { PageBlockV1 } from "./data";
6
7
 
7
8
  export const DocumentationPageV2 = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
8
9
  .extend(DesignElementSlugPart.shape)
9
10
  .extend({
10
11
  shortPersistentId: z.string(),
11
- data: DocumentationPageDataV2,
12
+ data: DocumentationPageDataV2.extend({
13
+ oldBlocks: z.array(PageBlockV1).optional(),
14
+ }),
12
15
  });
13
16
 
14
17
  export type DocumentationPageV2 = z.infer<typeof DocumentationPageV2>;
@@ -3,7 +3,7 @@ import { DesignElementBase, DesignElementBrandedPart, DesignElementGroupablePart
3
3
  import { z } from "zod";
4
4
  import { DbCreateInputOmit, DbUpdate } from "../../helpers";
5
5
  import { OmitStrict } from "../../utils";
6
- import { ElementGroupData } from "./data";
6
+ import { ElementGroupDataV2 } from "./data";
7
7
 
8
8
  export const ElementGroup = DesignElementBase.extend(DesignElementGroupablePart.shape)
9
9
  .extend(DesignElementSlugPart.shape)
@@ -11,7 +11,7 @@ export const ElementGroup = DesignElementBase.extend(DesignElementGroupablePart.
11
11
  .extend({
12
12
  shortPersistentId: z.string().optional(),
13
13
  childType: DesignElementType,
14
- data: ElementGroupData.optional(),
14
+ data: ElementGroupDataV2.optional(),
15
15
  });
16
16
 
17
17
  export const BrandedElementGroup = ElementGroup.extend(DesignElementBrandedPart.shape);
@@ -1,14 +0,0 @@
1
- import { z } from "zod";
2
- import { DocumentationItemHeader, defaultDocumentationItemHeader } from "./item-header";
3
-
4
- export const DocumentationItemConfiguration = z.object({
5
- showSidebar: z.boolean(),
6
- header: DocumentationItemHeader,
7
- });
8
-
9
- export type DocumentationItemConfiguration = z.infer<typeof DocumentationItemConfiguration>;
10
-
11
- export const defaultDocumentationItemConfiguration: DocumentationItemConfiguration = {
12
- header: defaultDocumentationItemHeader,
13
- showSidebar: true,
14
- };