@supernova-studio/model 0.57.5 → 0.57.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/dist/index.d.mts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/dsm/elements/data/component.ts +1 -0
- package/src/dsm/elements/figma-component.ts +1 -0
- package/src/dsm/elements/tokens.ts +16 -2
- package/src/dsm/import/component.ts +1 -0
package/package.json
CHANGED
|
@@ -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({
|