@supernova-studio/model 0.0.4 → 0.0.6

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.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "index.ts",
6
6
  "source": "index.ts",
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  export const PageBlockDefinitionAppearance = z.object({
4
4
  isBordered: z.boolean().optional(),
5
5
  hasBackground: z.boolean().optional(),
6
+ isEditorPresentationDifferent: z.boolean().optional(),
6
7
  });
7
8
 
8
9
  export type PageBlockDefinitionAppearance = z.infer<typeof PageBlockDefinitionAppearance>;
@@ -7,63 +7,34 @@ import { PageBlockDefinitionAppearance } from "./aux";
7
7
  // Enums
8
8
  //
9
9
 
10
- export enum PageBlockCategory {
11
- /** Shows as a "Text Blocks" */
12
- text = "Text",
13
- /** Show as "Layout blocks" */
14
- layout = "Layout",
15
- /** Show as "Media blocks" */
16
- media = "Media",
17
- /** Show as "Embed blocks" */
18
- embed = "Embed",
19
- /** Show as "Figma blocks" */
20
- figma = "Figma",
21
- /** Show as "Code blocks" */
22
- code = "Code",
23
- /** Show as "Guidelines blocks" */
24
- guidelines = "Guidelines",
25
- /** Show as "Token blocks" */
26
- token = "Tokens",
27
- /** Show as "Component blocks" */
28
- component = "Components",
29
- /** Shows as "Asset blocks" */
30
- asset = "Assets",
31
- /** Show as "Data blocks" */
32
- data = "Data",
33
- /** Shows as "Other blocks" */
34
- other = "Other",
35
- }
10
+ export const PageBlockCategory = z.enum([
11
+ "Text",
12
+ "Layout",
13
+ "Media",
14
+ "Embed",
15
+ "Figma",
16
+ "Code",
17
+ "Guidelines",
18
+ "Tokens",
19
+ "Components",
20
+ "Assets",
21
+ "Data",
22
+ "Other",
23
+ ]);
36
24
 
37
- export enum PageBlockBehaviorDataType {
38
- /** Item type uses item definition alone to construct items - examples of this are RichText, Shortcut, etc. In this mode, data panel will be hidden */
39
- item = "Item",
40
- /** Token type allows selection of token entity and associated groups * */
41
- token = "Token",
42
- /** Asset type allows selection of asset entity and associated groups * */
43
- asset = "Asset",
44
- /** Component type allows selection of asset entity and associated groups * */
45
- component = "Component",
46
- }
25
+ export const PageBlockBehaviorDataType = z.enum(["Item", "Token", "Asset", "Component"]);
26
+ export const PageBlockBehaviorSelectionType = z.enum(["Entity", "Group", "EntityAndGroup"]);
47
27
 
48
- export enum PageBlockBehaviorSelectionType {
49
- /** Allows selection of data entities only */
50
- entity = "Entity",
51
- /** Allows selection of groups only */
52
- group = "Group",
53
- /** Allows combined selection of data entities and groups */
54
- entityAndGroup = "EntityAndGroup",
55
- }
56
-
57
- export const PageBlockCategorySchema = z.nativeEnum(PageBlockCategory);
58
- export const PageBlockBehaviorDataTypeSchema = z.nativeEnum(PageBlockBehaviorDataType);
59
- export const PageBlockBehaviorSelectionTypeSchema = z.nativeEnum(PageBlockBehaviorSelectionType);
28
+ export type PageBlockCategory = z.infer<typeof PageBlockCategory>;
29
+ export type PageBlockBehaviorDataType = z.infer<typeof PageBlockBehaviorDataType>;
30
+ export type PageBlockBehaviorSelectionType = z.infer<typeof PageBlockBehaviorSelectionType>;
60
31
 
61
32
  //
62
33
  // Definitions
63
34
  //
64
35
 
65
36
  export const PageBlockDefinitionBehavior = z.object({
66
- dataType: PageBlockBehaviorDataTypeSchema,
37
+ dataType: PageBlockBehaviorDataType,
67
38
  items: z
68
39
  .object({
69
40
  numberOfItems: z.number(),
@@ -72,7 +43,7 @@ export const PageBlockDefinitionBehavior = z.object({
72
43
  .optional(),
73
44
  entities: z
74
45
  .object({
75
- selectionType: PageBlockBehaviorSelectionTypeSchema,
46
+ selectionType: PageBlockBehaviorSelectionType,
76
47
  maxSelected: z.number(),
77
48
  })
78
49
  .optional(),
@@ -87,7 +58,7 @@ export const PageBlockDefinition = z.object({
87
58
  id: z.string(),
88
59
  name: z.string(),
89
60
  description: z.string(),
90
- category: PageBlockCategorySchema,
61
+ category: PageBlockCategory,
91
62
  icon: AssetValue.optional(),
92
63
  documentationLink: z.string().optional(),
93
64
  searchKeywords: z.array(z.string()).optional(),
@@ -6,79 +6,45 @@ import { PageBlockDefinitionVariant } from "./variant";
6
6
  // Enums
7
7
  //
8
8
 
9
- export enum PageBlockDefinitionPropertyType {
10
- /** Rich text property allows user to input rich text (with additional attributes like bold, links etc.) */
11
- richText = "RichText",
12
- /** Text property allows user to input plain text */
13
- text = "Text",
14
- /** Boolean property allows user to input true/false value */
15
- boolean = "Boolean",
16
- /** Number property allows user to input number */
17
- number = "Number",
18
- /** Single-select property allows user to select one of the options */
19
- singleSelect = "SingleSelect",
20
- /** Multi-select property allows user to select multiple of the options */
21
- multiSelect = "MultiSelect",
22
- /** Image property allows user to select or upload image */
23
- image = "Image",
24
- /** Token type allows data access to the tokens defined in design system */
25
- token = "Token",
26
- /** Token type allows selection of type(s) such as color, typography etc., for further use such as filtering */
27
- tokenType = "TokenType",
28
- /** Token property allows selection of custom token properties (columns) */
29
- tokenProperty = "TokenProperty",
30
- /** Component type allows data access to the components defined in design system */
31
- component = "Component",
32
- /** Component property allows selection of custom component properties (columns) */
33
- componentProperty = "ComponentProperty",
34
- /** Asset type allows data access to the assets defined in design system */
35
- asset = "Asset",
36
- /** Asset property allows selection of custom asset properties (columns) */
37
- assetProperty = "AssetProperty",
38
- /** Page type allows data access to the pages defined in design system */
39
- /** Page property allows selection of custom page properties (columns) */
40
- /** Embed property allows user to input page to be embedded via URL */
41
- embedURL = "EmbedURL",
42
- /** Embed property allows user to input page to be embedded via iframe */
43
- /** Markdown property allows user to add markdown to render */
44
- markdown = "Markdown",
45
- /** Code property allows user to add code to render */
46
- code = "Code",
47
- /** Sandbox property allows user to add code sandbox to render live component */
48
- codeSandbox = "CodeSandbox",
49
- /** Table property allows user to add table to render */
50
- table = "Table",
51
- /** Divider property that puts visual divider into the block. It has no user input */
52
- divider = "Divider",
53
- /** Storybook property allows user to add Storybook story to render */
54
- storybook = "Storybook",
55
- }
9
+ export const PageBlockDefinitionPropertyType = z.enum([
10
+ "RichText",
11
+ "Text",
12
+ "Boolean",
13
+ "Number",
14
+ "SingleSelect",
15
+ "MultiSelect",
16
+ "Image",
17
+ "Token",
18
+ "TokenType",
19
+ "TokenProperty",
20
+ "Component",
21
+ "ComponentProperty",
22
+ "Asset",
23
+ "AssetProperty",
24
+ "EmbedURL",
25
+ "Markdown",
26
+ "Code",
27
+ "CodeSandbox",
28
+ "Table",
29
+ "Divider",
30
+ "Storybook",
31
+ ]);
56
32
 
57
- export enum PageBlockDefinitionRichTextPropertyStyle {
58
- /** Title type 1, roughly equivalent of h2 in size */
59
- title1 = "Title1",
60
- /** Title type 2, roughly equivalent of h3 in size */
61
- title2 = "Title2",
62
- /** Title type 3, roughly equivalent of h4 in size */
63
- title3 = "Title3",
64
- /** Title type 4, roughly equivalent of h5 in size */
65
- title4 = "Title4",
66
- /** Title type 5, roughly equivalent of h6 in size */
67
- title5 = "Title5",
68
- /** Quote */
69
- quote = "Quote",
70
- /** Callout */
71
- callout = "Callout",
72
- /** Ordered list */
73
- ol = "OL",
74
- /** Unordered list */
75
- ul = "UL",
76
- /** Default option */
77
- default = "Default",
78
- }
33
+ export const PageBlockDefinitionRichTextPropertyStyle = z.enum([
34
+ "Title1",
35
+ "Title2",
36
+ "Title3",
37
+ "Title4",
38
+ "Title5",
39
+ "Quote",
40
+ "Callout",
41
+ "OL",
42
+ "UL",
43
+ "Default",
44
+ ]);
79
45
 
80
- export const PageBlockDefinitionPropertyTypeSchema = z.nativeEnum(PageBlockDefinitionPropertyType);
81
- export const PageBlockDefinitionRichTextPropertyStyleSchema = z.nativeEnum(PageBlockDefinitionRichTextPropertyStyle);
46
+ export type PageBlockDefinitionPropertyType = z.infer<typeof PageBlockDefinitionPropertyType>;
47
+ export type PageBlockDefinitionRichTextPropertyStyle = z.infer<typeof PageBlockDefinitionRichTextPropertyStyle>;
82
48
 
83
49
  //
84
50
  // Definitions
@@ -86,7 +52,7 @@ export const PageBlockDefinitionRichTextPropertyStyleSchema = z.nativeEnum(PageB
86
52
 
87
53
  export const PageBlockDefinitionPropertyOptions = z
88
54
  .object({
89
- style: PageBlockDefinitionRichTextPropertyStyleSchema.optional(),
55
+ style: PageBlockDefinitionRichTextPropertyStyle.optional(),
90
56
  placeholder: z.string().optional(),
91
57
  })
92
58
  .and(z.record(z.any()));
@@ -94,7 +60,7 @@ export const PageBlockDefinitionPropertyOptions = z
94
60
  export const PageBlockDefinitionProperty = z.object({
95
61
  id: z.string(),
96
62
  name: z.string(),
97
- type: PageBlockDefinitionPropertyTypeSchema,
63
+ type: PageBlockDefinitionPropertyType,
98
64
  description: z.string().optional(),
99
65
  // TODO Docs
100
66
  options: PageBlockDefinitionPropertyOptions.optional(),
@@ -5,54 +5,25 @@ import { PageBlockDefinitionAppearance } from "./aux";
5
5
  // Enums
6
6
  //
7
7
 
8
- export enum PageBlockDefinitionLayoutType {
9
- /** Layout will stack all its items in this group into column */
10
- column = "Column",
11
- /** Layout will stack all its items in this group into row */
12
- row = "Row",
13
- }
8
+ export const PageBlockDefinitionLayoutType = z.enum(["Column", "Row"]);
9
+ export const PageBlockDefinitionLayoutGap = z.enum(["Small", "Medium", "Large", "None"]);
10
+ export const PageBlockDefinitionLayoutAlign = z.enum(["Start", "Center", "End"]);
11
+ export const PageBlockDefinitionLayoutResizing = z.enum(["Fill", "Hug"]);
14
12
 
15
- export enum PageBlockDefinitionLayoutGap {
16
- /** small gap between columns/row */
17
- small = "Small",
18
- /** medium gap between columns/row */
19
- medium = "Medium",
20
- /** large gap between columns/row */
21
- large = "Large",
22
- /** no gap between columns/row */
23
- none = "None",
24
- }
25
-
26
- export enum PageBlockDefinitionLayoutAlign {
27
- /** Vertically on top */
28
- start = "Start",
29
- /** Vertically centered */
30
- center = "Center",
31
- /** Vertically on the bottom */
32
- end = "End",
33
- }
34
-
35
- export enum PageBlockDefinitionLayoutResizing {
36
- /** Will fill all available space for the column */
37
- fill = "Fill",
38
- /** Will hug content inside the column */
39
- hug = "Hug",
40
- }
41
-
42
- export const PageBlockDefinitionLayoutTypeSchema = z.nativeEnum(PageBlockDefinitionLayoutType);
43
- export const PageBlockDefinitionLayoutGapSchema = z.nativeEnum(PageBlockDefinitionLayoutGap);
44
- export const PageBlockDefinitionLayoutAlignSchema = z.nativeEnum(PageBlockDefinitionLayoutAlign);
45
- export const PageBlockDefinitionLayoutResizingSchema = z.nativeEnum(PageBlockDefinitionLayoutResizing);
13
+ export type PageBlockDefinitionLayoutType = z.infer<typeof PageBlockDefinitionLayoutType>;
14
+ export type PageBlockDefinitionLayoutGap = z.infer<typeof PageBlockDefinitionLayoutGap>;
15
+ export type PageBlockDefinitionLayoutAlign = z.infer<typeof PageBlockDefinitionLayoutAlign>;
16
+ export type PageBlockDefinitionLayoutResizing = z.infer<typeof PageBlockDefinitionLayoutResizing>;
46
17
 
47
18
  //
48
19
  // Definitions
49
20
  //
50
21
 
51
22
  export const PageBlockDefinitionLayoutBase = z.object({
52
- type: PageBlockDefinitionLayoutTypeSchema,
53
- gap: PageBlockDefinitionLayoutGapSchema.optional(),
54
- columnAlign: PageBlockDefinitionLayoutAlignSchema.optional(),
55
- columnResizing: PageBlockDefinitionLayoutResizingSchema.optional(),
23
+ type: PageBlockDefinitionLayoutType,
24
+ gap: PageBlockDefinitionLayoutGap.optional(),
25
+ columnAlign: PageBlockDefinitionLayoutAlign.optional(),
26
+ columnResizing: PageBlockDefinitionLayoutResizing.optional(),
56
27
  });
57
28
 
58
29
  export const PageBlockDefinitionLayout: z.ZodType<PageBlockDefinitionLayout, ZodTypeDef, PageBlockDefinitionLayout> =
@@ -9,14 +9,7 @@ import { nullishToOptional } from "../../../helpers";
9
9
  // Enums
10
10
  //
11
11
 
12
- export enum PageBlockCalloutType {
13
- info = "Info",
14
- success = "Success",
15
- warning = "Warning",
16
- error = "Error",
17
- }
18
-
19
- export const PageBlockCalloutTypeSchema = z.nativeEnum(PageBlockCalloutType);
12
+ export const PageBlockCalloutType = z.enum(["Info", "Success", "Warning", "Error"]);
20
13
 
21
14
  export const PageBlockTypeV1 = z.enum([
22
15
  "Text",
@@ -253,7 +246,7 @@ const PageBlockBaseV1 = z.object({
253
246
  caption: nullishToOptional(z.string()),
254
247
  headingType: nullishToOptional(z.number().min(1).max(3)),
255
248
  codeLanguage: nullishToOptional(PageBlockCodeLanguage),
256
- calloutType: nullishToOptional(PageBlockCalloutTypeSchema),
249
+ calloutType: nullishToOptional(PageBlockCalloutType),
257
250
  urlInput: nullishToOptional(z.string()),
258
251
  url: nullishToOptional(z.string()),
259
252
  urlPreview: nullishToOptional(PageBlockUrlPreview),
@@ -1,19 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { ColorValue } from "./color";
3
- import { PageBlockCalloutTypeSchema } from "./documentation-block-v1";
3
+ import { PageBlockCalloutType } from "./documentation-block-v1";
4
4
 
5
5
  //
6
6
  // Enums
7
7
  //
8
8
 
9
- export enum PageBlockLinkType {
10
- page = "Page",
11
- pageHeading = "pageHeading",
12
- group = "Group",
13
- url = "url",
14
- }
9
+ export const PageBlockLinkType = z.enum(["Page", "PageHeading", "Group", "Url"]);
15
10
 
16
- export const PageBlockLinkTypeSchema = z.enum(["Page", "PageHeading", "Group", "Url"]);
11
+ export type PageBlockLinkType = z.infer<typeof PageBlockLinkType>;
17
12
 
18
13
  //
19
14
  // Definitions
@@ -25,11 +20,11 @@ export const PageBlockAppearanceV2 = z.object({
25
20
 
26
21
  export const PageBlockItemPropertyValue = z.object({
27
22
  value: z.any(),
28
- calloutType: PageBlockCalloutTypeSchema.optional(),
23
+ calloutType: PageBlockCalloutType.optional(),
29
24
  });
30
25
 
31
26
  export const PageBlockLinkV2 = z.object({
32
- type: PageBlockLinkTypeSchema,
27
+ type: PageBlockCalloutType,
33
28
  pageId: z.string().optional(),
34
29
  pageHeadingId: z.string().optional(),
35
30
  groupId: z.string().optional(),