@supernova-studio/model 0.52.11 → 0.52.13

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.52.11",
3
+ "version": "0.52.13",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,7 +49,15 @@ export const PageBlockDefinitionRichTextPropertyStyle = z.enum([
49
49
 
50
50
  export const PageBlockDefinitionMultiRichTextPropertyStyle = z.enum(["OL", "UL", "Default"]);
51
51
 
52
- export const PageBlockDefinitionRichTextEditorPropertyStyle = z.enum(["OL", "UL", "Bold","Italic","Link","Strikethrough", "InlineCode"]);
52
+ export const PageBlockDefinitionRichTextEditorPropertyStyle = z.enum([
53
+ "OL",
54
+ "UL",
55
+ "Bold",
56
+ "Italic",
57
+ "Link",
58
+ "Strikethrough",
59
+ "InlineCode",
60
+ ]);
53
61
 
54
62
  export const PageBlockDefinitionTextPropertyStyle = z.enum([
55
63
  "Title1",
@@ -91,11 +99,7 @@ export const PageBlockDefinitionSingleSelectPropertyColor = z.enum([
91
99
  "Fuchsia",
92
100
  ]);
93
101
 
94
- export const IconSet = z.enum([
95
- "CheckCircle",
96
- "CrossCircle",
97
- "Alert",
98
- ]);
102
+ export const IconSet = z.enum(["CheckCircle", "CrossCircle", "Alert"]);
99
103
 
100
104
  export const PageBlockDefinitionMultiSelectPropertyStyle = z.enum(["SegmentedControl", "Select", "Checkbox"]);
101
105
 
@@ -4,34 +4,38 @@ export const FigmaComponentPropertyType = z.enum(["Boolean", "InstanceSwap", "Va
4
4
 
5
5
  export const FigmaComponentBooleanProperty = z.object({
6
6
  type: z.literal(FigmaComponentPropertyType.enum.Boolean),
7
- value: z.boolean(),
8
7
  defaultValue: z.boolean(),
9
8
  });
10
9
 
11
10
  export const FigmaComponentInstanceSwapProperty = z.object({
12
11
  type: z.literal(FigmaComponentPropertyType.enum.InstanceSwap),
13
- value: z.string(), // Persistent ID of a Component to swap??
12
+ defaultValue: z.string(),
13
+ preferredValues: z
14
+ .object({
15
+ type: z.enum(["Component", "ComponentSet"]),
16
+ key: z.string(),
17
+ })
18
+ .array(),
14
19
  });
15
20
 
16
21
  export const FigmaComponentVariantProperty = z.object({
17
22
  type: z.literal(FigmaComponentPropertyType.enum.Variant),
18
- value: z.string(),
23
+ defaultValue: z.string(),
19
24
  options: z.array(z.string()),
20
25
  });
21
26
 
22
27
  export const FigmaComponentTextProperty = z.object({
23
28
  type: z.literal(FigmaComponentPropertyType.enum.Text),
24
- value: z.string(),
29
+ defaultValue: z.string(),
25
30
  });
26
31
 
27
- export const FigmaComponentProperties = z.record(
28
- z.string(),
29
- z.discriminatedUnion("type", [
30
- FigmaComponentBooleanProperty,
31
- FigmaComponentInstanceSwapProperty,
32
- FigmaComponentTextProperty,
33
- ])
34
- );
32
+ export const FigmaComponentProperty = z.discriminatedUnion("type", [
33
+ FigmaComponentBooleanProperty,
34
+ FigmaComponentInstanceSwapProperty,
35
+ FigmaComponentTextProperty,
36
+ ]);
37
+
38
+ export const FigmaComponentPropertyMap = z.record(z.string(), FigmaComponentProperty);
35
39
 
36
40
  export const FigmaComponentSetProperties = z.record(
37
41
  z.string(),
@@ -48,5 +52,6 @@ export type FigmaComponentBooleanProperty = z.infer<typeof FigmaComponentBoolean
48
52
  export type FigmaComponentInstanceSwapProperty = z.infer<typeof FigmaComponentInstanceSwapProperty>;
49
53
  export type FigmaComponentVariantProperty = z.infer<typeof FigmaComponentVariantProperty>;
50
54
  export type FigmaComponentTextProperty = z.infer<typeof FigmaComponentTextProperty>;
51
- export type FigmaComponentProperties = z.infer<typeof FigmaComponentProperties>;
55
+ export type FigmaComponentProperty = z.infer<typeof FigmaComponentProperty>;
56
+ export type FigmaComponentPropertyMap = z.infer<typeof FigmaComponentPropertyMap>;
52
57
  export type FigmaComponentSetProperties = z.infer<typeof FigmaComponentSetProperties>;
@@ -1,4 +1,6 @@
1
1
  import { z } from "zod";
2
+ import { nullishToOptional } from "../../../helpers/nullish-to-optional";
3
+ import { FigmaComponentPropertyMap } from "../component-properties";
2
4
 
3
5
  export const ComponentElementData = z.object({
4
6
  value: z.object({
@@ -17,6 +19,9 @@ export const ComponentElementData = z.object({
17
19
  }),
18
20
  })
19
21
  .optional(),
22
+
23
+ parentComponentPersistentId: nullishToOptional(z.string()),
24
+ componentPropertyDefinitions: nullishToOptional(FigmaComponentPropertyMap),
20
25
  }),
21
26
  });
22
27
 
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ import { DbCreateInputOmit, DbUpdate, nullishToOptional } from "../../helpers";
3
+ import { OmitStrict } from "../../utils";
4
+ import {
5
+ DesignElementBase,
6
+ DesignElementBrandedPart,
7
+ DesignElementGroupableRequiredPart,
8
+ DesignElementOrigin,
9
+ } from "./base";
10
+ import { FigmaComponentPropertyMap } from "./component-properties";
11
+
12
+ export const FigmaComponentOriginPart = z.object({
13
+ nodeId: z.string().optional(),
14
+ width: z.number().optional(),
15
+ height: z.number().optional(),
16
+ });
17
+
18
+ const FigmaComponentAsset = z.object({
19
+ assetId: z.string(),
20
+ assetPath: z.string(),
21
+ });
22
+
23
+ export const FigmaComponentOrigin = DesignElementOrigin.extend(FigmaComponentOriginPart.shape);
24
+
25
+ export const FigmaComponent = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
26
+ .extend(DesignElementBrandedPart.shape)
27
+ .extend({
28
+ origin: FigmaComponentOrigin.optional(),
29
+ thumbnail: FigmaComponentAsset,
30
+ componentPropertyDefinitions: FigmaComponentPropertyMap.optional(),
31
+
32
+ svg: FigmaComponentAsset.optional(),
33
+ isAsset: z.boolean(),
34
+ parentComponentPersistentId: nullishToOptional(z.string()),
35
+ });
36
+
37
+ export type FigmaComponentAsset = z.infer<typeof FigmaComponentAsset>;
38
+ export type FigmaComponent = z.infer<typeof FigmaComponent>;
39
+ export type FigmaComponentOrigin = z.infer<typeof FigmaComponentOrigin>;
40
+ export type ImportedFigmaComponent = OmitStrict<FigmaComponent, "origin"> & { origin: FigmaComponentOrigin };
41
+
42
+ export function isImportedFigmaComponent(component: FigmaComponent): component is ImportedFigmaComponent {
43
+ return !!component.origin;
44
+ }
45
+
46
+ export type CreateFigmaComponent = DbCreateInputOmit<FigmaComponent>;
47
+ export type UpdateFigmaComponent = OmitStrict<DbUpdate<FigmaComponent>, "brandPersistentId" | "designSystemVersionId">;
48
+
49
+ export type FigmaComponentDiff = {
50
+ toCreate: CreateFigmaComponent[];
51
+ toUpdate: UpdateFigmaComponent[];
52
+ toDelete: FigmaComponent["id"][];
53
+ };
@@ -2,10 +2,9 @@ export * from "./data";
2
2
  export * from "./primitives";
3
3
  export * from "./base";
4
4
  export * from "./component-properties";
5
- export * from "./component-set";
6
- export * from "./component";
7
5
  export * from "./documentation-page-v1";
8
6
  export * from "./documentation-page-v2";
7
+ export * from "./figma-component";
9
8
  export * from "./figma-file-structures";
10
9
  export * from "./figma-node-reference";
11
10
  export * from "./group";
@@ -1,6 +1,6 @@
1
- import { ComponentImportModelInput } from "./component";
1
+ import { FigmaComponentImportModelInput } from "./component";
2
2
  import { FigmaSvgRenderImportModel } from "./image";
3
3
 
4
- export type AssetImportModel = ComponentImportModelInput & {
4
+ export type AssetImportModel = FigmaComponentImportModelInput & {
5
5
  svg: FigmaSvgRenderImportModel;
6
6
  };
@@ -1,36 +1,38 @@
1
- import { FigmaSvgRenderImportModel, ImageImportModel } from "./image";
2
- import { ComponentOrigin, ComponentOriginPart } from "../elements";
3
1
  import { z } from "zod";
2
+ import { FigmaComponentOrigin, FigmaComponentOriginPart, FigmaComponentPropertyMap } from "../elements";
4
3
  import { ImportModelBase, ImportModelInputBase } from "./base";
4
+ import { FigmaSvgRenderImportModel, ImageImportModel } from "./image";
5
5
 
6
6
  //
7
7
  // Import model
8
8
  //
9
9
 
10
- const ComponentImportModelPart = z.object({
10
+ const FigmaComponentImportModelPart = z.object({
11
11
  thumbnail: ImageImportModel,
12
+ parentComponentId: z.string().optional(),
13
+ componentPropertyDefinitions: FigmaComponentPropertyMap.optional(),
12
14
  });
13
15
 
14
- export const ComponentImportModel = ImportModelBase.extend(ComponentImportModelPart.shape).extend({
16
+ export const FigmaComponentImportModel = ImportModelBase.extend(FigmaComponentImportModelPart.shape).extend({
15
17
  isAsset: z.boolean(),
16
18
  svg: FigmaSvgRenderImportModel.optional(),
17
- origin: ComponentOrigin,
19
+ origin: FigmaComponentOrigin,
18
20
  });
19
21
 
20
- export type ComponentImportModel = z.infer<typeof ComponentImportModel>;
22
+ export type FigmaComponentImportModel = z.infer<typeof FigmaComponentImportModel>;
21
23
 
22
24
  //
23
25
  // Import model input
24
26
  //
25
27
 
26
- export const ComponentImportModelInput = ImportModelInputBase.extend(ComponentImportModelPart.shape).extend({
27
- originMetadata: ComponentOriginPart,
28
+ export const FigmaComponentImportModelInput = ImportModelInputBase.extend(FigmaComponentImportModelPart.shape).extend({
29
+ originMetadata: FigmaComponentOriginPart,
28
30
  });
29
31
 
30
- export const AssetImportModelInput = ImportModelInputBase.extend(ComponentImportModelPart.shape).extend({
32
+ export const AssetImportModelInput = ImportModelInputBase.extend(FigmaComponentImportModelPart.shape).extend({
31
33
  svg: FigmaSvgRenderImportModel,
32
- originMetadata: ComponentOriginPart,
34
+ originMetadata: FigmaComponentOriginPart,
33
35
  });
34
36
 
35
- export type ComponentImportModelInput = z.infer<typeof ComponentImportModelInput>;
37
+ export type FigmaComponentImportModelInput = z.infer<typeof FigmaComponentImportModelInput>;
36
38
  export type AssetImportModelInput = z.infer<typeof AssetImportModelInput>;
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  export const FigmaFileDownloadScope = z.object({
4
4
  styles: z.boolean(),
5
5
  components: z.boolean(),
6
+ componentSets: z.boolean(),
6
7
  currentVersion: z.literal("__latest__").nullable(),
7
8
  publishedVersion: z.string().nullable(),
8
9
  downloadChunkSize: z.number().optional(),
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
- import { AssetImportModelInput, ComponentImportModel, ComponentImportModelInput } from "../component";
2
+ import { AssetImportModelInput, FigmaComponentImportModel, FigmaComponentImportModelInput } from "../component";
3
+ import { DataSourceImportModel } from "../data-source";
4
+ import { FigmaFileStructureImportModel, FigmaFileStructureImportModelInput } from "../figma-frames";
3
5
  import { ThemeImportModel, ThemeImportModelInput, ThemeUpdateImportModel, ThemeUpdateImportModelInput } from "../theme";
4
6
  import { DesignTokenImportModel, DesignTokenImportModelInput } from "../tokens";
5
- import { FigmaFileStructureImportModel, FigmaFileStructureImportModelInput } from "../figma-frames";
6
- import { DataSourceImportModel } from "../data-source";
7
7
 
8
8
  //
9
9
  // Collections
@@ -12,7 +12,7 @@ import { DataSourceImportModel } from "../data-source";
12
12
  export const ImportModelInputCollection = z.object({
13
13
  source: DataSourceImportModel,
14
14
  tokens: z.array(DesignTokenImportModelInput).default([]),
15
- components: z.array(ComponentImportModelInput).default([]),
15
+ components: z.array(FigmaComponentImportModelInput).default([]),
16
16
  assets: z.array(AssetImportModelInput).default([]),
17
17
  themeUpdates: z.array(ThemeUpdateImportModelInput).default([]),
18
18
  themes: z.array(ThemeImportModelInput).default([]),
@@ -22,7 +22,7 @@ export const ImportModelInputCollection = z.object({
22
22
  export const ImportModelCollection = z.object({
23
23
  sources: z.array(DataSourceImportModel),
24
24
  tokens: z.array(DesignTokenImportModel).default([]),
25
- components: z.array(ComponentImportModel).default([]),
25
+ components: z.array(FigmaComponentImportModel).default([]),
26
26
  themeUpdates: z.array(ThemeUpdateImportModel).default([]),
27
27
  themes: z.array(ThemeImportModel).default([]),
28
28
  figmaFileStructures: z.array(FigmaFileStructureImportModel),
@@ -5,7 +5,7 @@ import { OmitStrict } from "../utils";
5
5
  export const DesignSystemVersion = z.object({
6
6
  id: z.string(),
7
7
  version: z.string(),
8
- createdAt: z.date(),
8
+ createdAt: z.coerce.date(),
9
9
  designSystemId: z.string(),
10
10
  name: z.string(),
11
11
  comment: z.string(),
@@ -1,9 +0,0 @@
1
- import { BaseComponent } from "./component";
2
- import { FigmaComponentSetProperties } from "./component-properties";
3
- import { z } from "zod";
4
-
5
- export const ComponentSet = BaseComponent.extend({
6
- properties: FigmaComponentSetProperties,
7
- });
8
-
9
- export type ComponentSet = z.infer<typeof ComponentSet>;
@@ -1,55 +0,0 @@
1
- import { DbCreateInputOmit, DbUpdate } from "../../helpers";
2
- import { OmitStrict } from "../../utils";
3
- import { z } from "zod";
4
- import {
5
- DesignElementBase,
6
- DesignElementBrandedPart,
7
- DesignElementGroupableRequiredPart,
8
- DesignElementOrigin,
9
- } from "./base";
10
- import { FigmaComponentProperties, FigmaComponentSetProperties } from "./component-properties";
11
-
12
- export const ComponentOriginPart = z.object({
13
- nodeId: z.string().optional(),
14
- width: z.number().optional(),
15
- height: z.number().optional(),
16
- });
17
-
18
- const ComponentAsset = z.object({
19
- assetId: z.string(),
20
- assetPath: z.string(),
21
- });
22
-
23
- export const ComponentOrigin = DesignElementOrigin.extend(ComponentOriginPart.shape);
24
-
25
- export const BaseComponent = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
26
- .extend(DesignElementBrandedPart.shape)
27
- .extend({
28
- origin: ComponentOrigin.optional(),
29
- thumbnail: ComponentAsset,
30
- });
31
-
32
- export const Component = BaseComponent.extend({
33
- svg: ComponentAsset.optional(),
34
- isAsset: z.boolean(),
35
- componentSetId: z.string().optional(),
36
- properties: FigmaComponentProperties.optional(),
37
- });
38
-
39
- export type ComponentAsset = z.infer<typeof ComponentAsset>;
40
- export type Component = z.infer<typeof Component>;
41
- export type ComponentOrigin = z.infer<typeof ComponentOrigin>;
42
- export type ImportedComponent = OmitStrict<Component, "origin"> & { origin: ComponentOrigin };
43
-
44
- export function isImportedComponent(component: Component): component is ImportedComponent {
45
- return !!component.origin;
46
- }
47
-
48
- export type CreateComponent = DbCreateInputOmit<Component>;
49
- export type UpdateComponent = OmitStrict<DbUpdate<Component>, "brandPersistentId" | "designSystemVersionId">;
50
-
51
- export type ComponentDiff = {
52
- toCreate: CreateComponent[];
53
- toUpdate: UpdateComponent[];
54
- toDelete: Component["id"][];
55
- };