@supernova-studio/model 0.48.14 → 0.48.16

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.48.14",
3
+ "version": "0.48.16",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+
3
+ export const FigmaComponentPropertyType = z.enum(["Boolean", "InstanceSwap", "Variant", "Text"]);
4
+
5
+ export const FigmaComponentBooleanProperty = z.object({
6
+ type: z.literal(FigmaComponentPropertyType.enum.Boolean),
7
+ value: z.boolean(),
8
+ defaultValue: z.boolean(),
9
+ });
10
+
11
+ export const FigmaComponentInstanceSwapProperty = z.object({
12
+ type: z.literal(FigmaComponentPropertyType.enum.InstanceSwap),
13
+ value: z.string(), // Persistent ID of a Component to swap?
14
+ });
15
+
16
+ export const FigmaComponentVariantProperty = z.object({
17
+ type: z.literal(FigmaComponentPropertyType.enum.Variant),
18
+ value: z.string(),
19
+ options: z.array(z.string()),
20
+ });
21
+
22
+ export const FigmaComponentTextProperty = z.object({
23
+ type: z.literal(FigmaComponentPropertyType.enum.Text),
24
+ value: z.string(),
25
+ });
26
+
27
+ export const FigmaComponentProperties = z.record(
28
+ z.string(),
29
+ z.discriminatedUnion("type", [
30
+ FigmaComponentBooleanProperty,
31
+ FigmaComponentInstanceSwapProperty,
32
+ FigmaComponentTextProperty,
33
+ ])
34
+ );
35
+
36
+ export const FigmaComponentSetProperties = z.record(
37
+ z.string(),
38
+ z.discriminatedUnion("type", [
39
+ FigmaComponentBooleanProperty,
40
+ FigmaComponentInstanceSwapProperty,
41
+ FigmaComponentTextProperty,
42
+ FigmaComponentVariantProperty,
43
+ ])
44
+ );
45
+
46
+ export type FigmaComponentPropertyType = z.infer<typeof FigmaComponentPropertyType>;
47
+ export type FigmaComponentBooleanProperty = z.infer<typeof FigmaComponentBooleanProperty>;
48
+ export type FigmaComponentInstanceSwapProperty = z.infer<typeof FigmaComponentInstanceSwapProperty>;
49
+ export type FigmaComponentVariantProperty = z.infer<typeof FigmaComponentVariantProperty>;
50
+ export type FigmaComponentTextProperty = z.infer<typeof FigmaComponentTextProperty>;
51
+ export type FigmaComponentProperties = z.infer<typeof FigmaComponentProperties>;
52
+ export type FigmaComponentSetProperties = z.infer<typeof FigmaComponentSetProperties>;
@@ -0,0 +1,10 @@
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
+
10
+ export type ComponentSet = z.infer<typeof ComponentSet>;
@@ -7,6 +7,7 @@ import {
7
7
  DesignElementGroupableRequiredPart,
8
8
  DesignElementOrigin,
9
9
  } from "./base";
10
+ import { FigmaComponentProperties, FigmaComponentSetProperties } from "./component-properties";
10
11
 
11
12
  export const ComponentOriginPart = z.object({
12
13
  nodeId: z.string().optional(),
@@ -21,14 +22,19 @@ const ComponentAsset = z.object({
21
22
 
22
23
  export const ComponentOrigin = DesignElementOrigin.extend(ComponentOriginPart.shape);
23
24
 
24
- export const Component = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
25
+ export const BaseComponent = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
25
26
  .extend(DesignElementBrandedPart.shape)
26
27
  .extend({
27
28
  origin: ComponentOrigin.optional(),
28
29
  thumbnail: ComponentAsset,
30
+ });
31
+
32
+ export const Component = BaseComponent.extend({
29
33
  svg: ComponentAsset.optional(),
30
34
  isAsset: z.boolean(),
31
- });
35
+ componentSetId: z.string().optional(),
36
+ properties: FigmaComponentProperties.optional(),
37
+ });
32
38
 
33
39
  export type ComponentAsset = z.infer<typeof ComponentAsset>;
34
40
  export type Component = z.infer<typeof Component>;
@@ -1,6 +1,8 @@
1
1
  export * from "./data";
2
2
  export * from "./primitives";
3
3
  export * from "./base";
4
+ export * from "./component-properties";
5
+ export * from "./component-set";
4
6
  export * from "./component";
5
7
  export * from "./documentation-page-v1";
6
8
  export * from "./documentation-page-v2";