@supernova-studio/model 0.57.5 → 0.57.7

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.57.5",
3
+ "version": "0.57.7",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,6 +23,7 @@ export const ComponentElementData = z.object({
23
23
  parentComponentPersistentId: nullishToOptional(z.string()),
24
24
  componentPropertyDefinitions: nullishToOptional(FigmaComponentPropertyMap),
25
25
  variantPropertyValues: nullishToOptional(z.record(z.string())),
26
+ renderNodeId: nullishToOptional(z.string()),
26
27
  }),
27
28
  });
28
29
 
@@ -37,6 +37,7 @@ export const FigmaComponent = DesignElementBase.extend(DesignElementGroupableReq
37
37
  svg: FigmaComponentAsset.optional(),
38
38
  isAsset: z.boolean(),
39
39
  parentComponentPersistentId: nullishToOptional(z.string()),
40
+ renderNodeId: z.string().optional(),
40
41
  });
41
42
 
42
43
  export type FigmaComponentAsset = z.infer<typeof FigmaComponentAsset>;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { DbUpdate, zodCreateInputOmit, zodUpdateInputOmit } from "../../helpers";
3
- import { OmitStrict } from "../../utils";
3
+ import { OmitStrict, SupernovaException } from "../../utils";
4
4
  import {
5
5
  DesignElementBase,
6
6
  DesignElementBrandedPart,
@@ -35,7 +35,7 @@ import {
35
35
  VisibilityTokenData,
36
36
  ZIndexTokenData,
37
37
  } from "./data";
38
- import { DesignTokenType } from "./raw-element";
38
+ import { areTokenTypesCompatible, DesignTokenType } from "./raw-element";
39
39
 
40
40
  //
41
41
  // Base
@@ -275,6 +275,20 @@ export function extractTokenTypedData<T extends DesignTokenType, I extends Desig
275
275
  } as DesignTokenTypedDataOfType<T>;
276
276
  }
277
277
 
278
+ export function convertTokenTypedData<I extends DesignTokenType, O extends DesignTokenType>(
279
+ source: DesignTokenTypedDataOfType<I>,
280
+ type: O
281
+ ): DesignTokenTypedDataOfType<O> {
282
+ if (!areTokenTypesCompatible(source.type, type)) {
283
+ throw SupernovaException.invalidOperation(`Cannot convert token from ${source.type} to ${type}`);
284
+ }
285
+
286
+ return {
287
+ type: type,
288
+ data: source.data,
289
+ } as DesignTokenTypedDataOfType<O>;
290
+ }
291
+
278
292
  export function isImportedDesignToken<T extends DesignTokenType>(
279
293
  designToken: DesignTokenOfType<T>
280
294
  ): designToken is ImportedDesignTokenOfType<T> {
@@ -12,6 +12,7 @@ const FigmaComponentImportModelPart = z.object({
12
12
  parentComponentId: z.string().optional(),
13
13
  componentPropertyDefinitions: FigmaComponentPropertyMap.optional(),
14
14
  variantPropertyValues: z.record(z.string()).optional(),
15
+ renderNodeId: z.string(),
15
16
  });
16
17
 
17
18
  export const FigmaComponentImportModel = ImportModelBase.extend(FigmaComponentImportModelPart.shape).extend({
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { DbCreateInputOmit } from "../helpers";
3
- import { OmitStrict } from "../utils";
4
3
  import { WorkspaceRoleSchema } from "../workspace";
5
4
 
6
5
  export const PersonalAccessToken = z.object({
@@ -8,6 +7,7 @@ export const PersonalAccessToken = z.object({
8
7
  userId: z.string(),
9
8
 
10
9
  workspaceId: z.string().optional(),
10
+ designSystemId: z.string().optional(),
11
11
  workspaceRole: WorkspaceRoleSchema.optional(),
12
12
 
13
13
  name: z.string(),