@supernova-studio/model 0.4.1 → 0.6.0
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 +10079 -28309
- package/dist/index.d.ts +10079 -28309
- package/dist/index.js +108 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +908 -834
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/dsm/data-sources/data-source.ts +1 -0
- package/src/dsm/elements/data/base.ts +3 -3
- package/src/dsm/elements/data/documentation-block-v1.ts +2 -0
- package/src/dsm/elements/data/documentation-block-v2.ts +1 -0
- package/src/dsm/elements/data/documentation.ts +7 -1
- package/src/dsm/elements/data/index.ts +3 -0
- package/src/dsm/elements/data/item-header.ts +49 -0
- package/src/dsm/elements/data/page-asset.ts +27 -0
- package/src/dsm/elements/data/safe-id.ts +13 -0
- package/src/dsm/elements/documentation-page-v1.ts +0 -14
- package/src/dsm/elements/group.ts +1 -23
- package/src/dsm/elements/raw-element.ts +3 -3
- package/src/helpers/nullish-to-optional.ts +2 -2
- package/src/multiplayer/index.ts +1 -0
- package/src/multiplayer/room-type.ts +10 -0
- package/src/utils/index.ts +1 -0
- package/src/workspace/npm-registry-settings.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supernova-studio/model",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Supernova Data Models",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"build": "tsup",
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
27
|
"publish": "npm run build && npm publish",
|
|
28
|
-
"test:unit": "vitest run"
|
|
28
|
+
"test:unit": "vitest run",
|
|
29
|
+
"index": "node ./create-indexes.js"
|
|
29
30
|
},
|
|
30
31
|
"author": "",
|
|
31
32
|
"license": "ISC",
|
|
@@ -66,6 +66,7 @@ export const DataSourceFigmaRemote = z.object({
|
|
|
66
66
|
state: DataSourceFigmaState,
|
|
67
67
|
lastImportMetadata: DataSourceFigmaImportMetadata.optional(),
|
|
68
68
|
downloadChunkSize: z.number().optional(),
|
|
69
|
+
figmaRenderChunkSize: z.number().optional(),
|
|
69
70
|
});
|
|
70
71
|
|
|
71
72
|
export type DataSourceFigmaFileData = z.infer<typeof DataSourceFigmaFileData>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodSchema, z } from "zod";
|
|
1
|
+
import { ZodSchema, ZodTypeDef, z } from "zod";
|
|
2
2
|
|
|
3
3
|
export const TokenDataAliasSchema = z.object({
|
|
4
4
|
aliasTo: z
|
|
@@ -8,11 +8,11 @@ export const TokenDataAliasSchema = z.object({
|
|
|
8
8
|
.transform(v => v ?? undefined),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
export function tokenAliasOrValue<
|
|
11
|
+
export function tokenAliasOrValue<I, O>(value: ZodSchema<I, ZodTypeDef, O>) {
|
|
12
12
|
return TokenDataAliasSchema.extend({
|
|
13
13
|
value: value
|
|
14
14
|
.optional()
|
|
15
15
|
.nullable()
|
|
16
|
-
.transform(v => (v ?? undefined) as z.output<
|
|
16
|
+
.transform(v => (v ?? undefined) as z.output<typeof value> | undefined),
|
|
17
17
|
});
|
|
18
18
|
}
|
|
@@ -234,6 +234,8 @@ export type PageBlockTextSpan = z.infer<typeof PageBlockTextSpan>;
|
|
|
234
234
|
export type PageBlockText = z.infer<typeof PageBlockText>;
|
|
235
235
|
export type PageBlockFrame = z.infer<typeof PageBlockFrame>;
|
|
236
236
|
export type PageBlockFrameOrigin = z.infer<typeof PageBlockFrameOrigin>;
|
|
237
|
+
export type PageBlockAsset = z.infer<typeof PageBlockAsset>;
|
|
238
|
+
export type PageBlockTableColumn = z.infer<typeof PageBlockTableColumn>;
|
|
237
239
|
|
|
238
240
|
//
|
|
239
241
|
// Block
|
|
@@ -181,6 +181,7 @@ export const PageBlockItemTextValue = z.object({
|
|
|
181
181
|
export const PageBlockItemTokenValue = z.object({
|
|
182
182
|
selectedPropertyIds: z.array(z.string()).optional(),
|
|
183
183
|
selectedThemeIds: z.array(z.string()).optional(),
|
|
184
|
+
themeDisplayMode: z.enum(["Split", "Override"]).optional(),
|
|
184
185
|
value: z.array(
|
|
185
186
|
z.object({
|
|
186
187
|
entityId: z.string(),
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { DocumentationItemHeader, defaultDocumentationItemHeader } from "./item-header";
|
|
2
3
|
|
|
3
4
|
export const DocumentationItemConfiguration = z.object({
|
|
4
5
|
showSidebar: z.boolean(),
|
|
5
|
-
header:
|
|
6
|
+
header: DocumentationItemHeader,
|
|
6
7
|
});
|
|
7
8
|
|
|
8
9
|
export type DocumentationItemConfiguration = z.infer<typeof DocumentationItemConfiguration>;
|
|
10
|
+
|
|
11
|
+
export const defaultDocumentationItemConfiguration: DocumentationItemConfiguration = {
|
|
12
|
+
header: defaultDocumentationItemHeader,
|
|
13
|
+
showSidebar: true,
|
|
14
|
+
};
|
|
@@ -19,12 +19,15 @@ export * from "./font-size";
|
|
|
19
19
|
export * from "./font-weight";
|
|
20
20
|
export * from "./gradient";
|
|
21
21
|
export * from "./group";
|
|
22
|
+
export * from "./item-header";
|
|
22
23
|
export * from "./letter-spacing";
|
|
23
24
|
export * from "./line-height";
|
|
24
25
|
export * from "./opacity";
|
|
26
|
+
export * from "./page-asset";
|
|
25
27
|
export * from "./paragraph-indent";
|
|
26
28
|
export * from "./paragraph-spacing";
|
|
27
29
|
export * from "./product-copy";
|
|
30
|
+
export * from "./safe-id";
|
|
28
31
|
export * from "./shadow";
|
|
29
32
|
export * from "./size";
|
|
30
33
|
export * from "./space";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DocumentationPageAsset } from "./page-asset";
|
|
3
|
+
import { ColorTokenData } from "./color";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Consts
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
export const colorValueRegex = /^#[a-f0-9]{8}$/;
|
|
10
|
+
export const colorValueFormatDescription = "Must match /^#[a-f0-9]{8}$/";
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// Enums
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
export const DocumentationItemHeaderAlignmentSchema = z.enum(["Left", "Center"]);
|
|
17
|
+
export const DocumentationItemHeaderImageScaleTypeSchema = z.enum(["AspectFill", "AspectFit"]);
|
|
18
|
+
|
|
19
|
+
export const DocumentationItemHeaderAlignment = DocumentationItemHeaderAlignmentSchema.enum;
|
|
20
|
+
export const DocumentationItemHeaderImageScaleType = DocumentationItemHeaderImageScaleTypeSchema.enum;
|
|
21
|
+
|
|
22
|
+
export type DocumentationItemHeaderImageScaleType = z.infer<typeof DocumentationItemHeaderImageScaleTypeSchema>;
|
|
23
|
+
export type DocumentationItemHeaderAlignment = z.infer<typeof DocumentationItemHeaderAlignmentSchema>;
|
|
24
|
+
|
|
25
|
+
//
|
|
26
|
+
// Definitions
|
|
27
|
+
//
|
|
28
|
+
|
|
29
|
+
export const DocumentationItemHeader = z.object({
|
|
30
|
+
description: z.string(),
|
|
31
|
+
alignment: DocumentationItemHeaderAlignmentSchema,
|
|
32
|
+
foregroundColor: ColorTokenData.nullish(),
|
|
33
|
+
backgroundColor: ColorTokenData.nullish(),
|
|
34
|
+
backgroundImageAsset: DocumentationPageAsset.nullish(),
|
|
35
|
+
backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
|
|
36
|
+
showBackgroundOverlay: z.boolean(),
|
|
37
|
+
showCoverText: z.boolean(),
|
|
38
|
+
minHeight: z.number().nullish(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type DocumentationItemHeader = z.infer<typeof DocumentationItemHeader>;
|
|
42
|
+
|
|
43
|
+
export const defaultDocumentationItemHeader: DocumentationItemHeader = {
|
|
44
|
+
alignment: DocumentationItemHeaderAlignment.Left,
|
|
45
|
+
backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
|
|
46
|
+
description: "",
|
|
47
|
+
showBackgroundOverlay: false,
|
|
48
|
+
showCoverText: true,
|
|
49
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { SafeIdSchema } from "./safe-id";
|
|
3
|
+
import { PageBlockFrame } from "./documentation-block-v1";
|
|
4
|
+
|
|
5
|
+
export const DocumentationPageAssetType = z.enum(["image", "figmaFrame"]);
|
|
6
|
+
export type DocumentationPageAssetType = z.infer<typeof DocumentationPageAssetType>;
|
|
7
|
+
|
|
8
|
+
export const DocumentationPageImageAsset = z.object({
|
|
9
|
+
type: z.literal(DocumentationPageAssetType.Enum.image),
|
|
10
|
+
url: z.string().url().optional(),
|
|
11
|
+
id: SafeIdSchema,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const DocumentationPageFrameAsset = z.object({
|
|
15
|
+
type: z.literal(DocumentationPageAssetType.Enum.figmaFrame),
|
|
16
|
+
url: z.string().url().optional(),
|
|
17
|
+
figmaFrame: PageBlockFrame,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const DocumentationPageAsset = z.discriminatedUnion("type", [
|
|
21
|
+
DocumentationPageImageAsset,
|
|
22
|
+
DocumentationPageFrameAsset,
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
export type DocumentationPageImageAsset = z.infer<typeof DocumentationPageImageAsset>;
|
|
26
|
+
export type DocumentationPageFrameAsset = z.infer<typeof DocumentationPageFrameAsset>;
|
|
27
|
+
export type DocumentationPageAsset = z.infer<typeof DocumentationPageAsset>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const RESERVED_OBJECT_ID_PREFIX = "x-sn-reserved-";
|
|
4
|
+
|
|
5
|
+
// Really only checks if the schema does not have the reserved prefix
|
|
6
|
+
export const SafeIdSchema = z.string().refine(
|
|
7
|
+
value => {
|
|
8
|
+
return !value.startsWith(RESERVED_OBJECT_ID_PREFIX);
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
message: `ID value can't start with ${RESERVED_OBJECT_ID_PREFIX}`,
|
|
12
|
+
}
|
|
13
|
+
);
|
|
@@ -14,17 +14,3 @@ export type DocumentationPageV1 = z.infer<typeof DocumentationPageV1>;
|
|
|
14
14
|
|
|
15
15
|
export type CreateDocumentationPageV1 = DbCreateInputOmit<DocumentationPageV1>;
|
|
16
16
|
export type UpdateDocumentationPageV1 = OmitStrict<DbUpdate<DocumentationPageV1>, "designSystemVersionId">;
|
|
17
|
-
|
|
18
|
-
export const DocumentationPageDTOV1 = DocumentationPageV1.omit({
|
|
19
|
-
data: true,
|
|
20
|
-
meta: true,
|
|
21
|
-
parentPersistentId: true,
|
|
22
|
-
sortOrder: true,
|
|
23
|
-
})
|
|
24
|
-
.extend(DocumentationPageV1.shape.data.shape)
|
|
25
|
-
.extend({
|
|
26
|
-
title: z.string(),
|
|
27
|
-
path: z.string(),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export type DocumentationPageDTOV1 = z.infer<typeof DocumentationPageDTOV1>;
|
|
@@ -5,6 +5,7 @@ import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
|
5
5
|
import { OmitStrict } from "../../helpers";
|
|
6
6
|
import { DocumentationGroupBehavior, ElementGroupData } from "./data";
|
|
7
7
|
import { DocumentationItemConfiguration } from "./data";
|
|
8
|
+
|
|
8
9
|
export const ElementGroup = DesignElementBase.extend(DesignElementGroupablePart.shape)
|
|
9
10
|
.extend(DesignElementSlugPart.shape)
|
|
10
11
|
.extend(DesignElementBrandedPart.partial().shape)
|
|
@@ -34,26 +35,3 @@ export type ElementGroupsDiff = {
|
|
|
34
35
|
toUpdate: UpdateElementGroup[];
|
|
35
36
|
toDelete: ElementGroup["id"][];
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
// DTO
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
export const DocumentationGroupDTO = ElementGroup.omit({
|
|
43
|
-
sortOrder: true,
|
|
44
|
-
parentPersistentId: true,
|
|
45
|
-
brandPersistentId: true,
|
|
46
|
-
meta: true,
|
|
47
|
-
childType: true,
|
|
48
|
-
data: true,
|
|
49
|
-
shortPersistentId: true,
|
|
50
|
-
}).extend({
|
|
51
|
-
title: z.string(),
|
|
52
|
-
isRoot: z.boolean(),
|
|
53
|
-
childrenIds: z.array(z.string()),
|
|
54
|
-
groupBehavior: DocumentationGroupBehavior,
|
|
55
|
-
configuration: DocumentationItemConfiguration,
|
|
56
|
-
shortPersistentId: z.string(),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export type DocumentationGroupDTO = z.infer<typeof DocumentationGroupDTO>;
|
|
@@ -43,7 +43,7 @@ export const DesignTokenType = z.enum([
|
|
|
43
43
|
"Font",
|
|
44
44
|
]);
|
|
45
45
|
|
|
46
|
-
export const tokenElementTypes:
|
|
46
|
+
export const tokenElementTypes: DesignTokenType[] = [...DesignTokenType.options.filter(v => v !== "Font")];
|
|
47
47
|
|
|
48
48
|
export type DesignTokenType = z.infer<typeof DesignTokenType>;
|
|
49
49
|
|
|
@@ -118,8 +118,8 @@ export const DesignElement = ShallowDesignElement.extend({
|
|
|
118
118
|
createdAt: z.date(),
|
|
119
119
|
updatedAt: z.date(),
|
|
120
120
|
exportProperties: DesignSystemElementExportProps.optional(),
|
|
121
|
-
data: z.any(),
|
|
122
|
-
origin: z.any().optional(),
|
|
121
|
+
data: z.record(z.any()),
|
|
122
|
+
origin: z.record(z.any()).optional(),
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
export type ShallowDesignElement = z.infer<typeof ShallowDesignElement>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ZodType, z } from "zod";
|
|
1
|
+
import { ZodType, ZodTypeDef, z } from "zod";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Allows both null and undefined as input values in addition to the actual value,
|
|
5
5
|
* but coerces them both to undefined.
|
|
6
6
|
*/
|
|
7
|
-
export function nullishToOptional<
|
|
7
|
+
export function nullishToOptional<I, O>(type: ZodType<I, ZodTypeDef, O>) {
|
|
8
8
|
return type.nullish().transform(t => t ?? undefined);
|
|
9
9
|
}
|
package/src/multiplayer/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export enum RoomTypeEnum {
|
|
4
|
+
DocumentationPage = "documentation-page",
|
|
5
|
+
DesignSystemVersion = "design-system-version",
|
|
6
|
+
}
|
|
7
|
+
export const RoomTypeSchema = z.nativeEnum(RoomTypeEnum);
|
|
8
|
+
|
|
9
|
+
export type RoomType = z.infer<typeof RoomTypeSchema>;
|
|
10
|
+
export const RoomType = RoomTypeSchema.enum;
|
package/src/utils/index.ts
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
export const NpmRegistryAuthType = z.enum(["Basic", "Bearer", "None", "Custom"]);
|
|
4
|
-
|
|
4
|
+
const registryTypesWithoutAzure = ["NPMJS", "GitHub", "Artifactory", "Custom"] as const;
|
|
5
|
+
export const NpmRegistryType = z.enum([...registryTypesWithoutAzure, "AzureDevOps"]);
|
|
6
|
+
export const NpmRegistryTypeWithoutAzure = z.enum(registryTypesWithoutAzure);
|
|
5
7
|
|
|
6
8
|
export const NpmRegistryBasicAuthConfig = z.object({
|
|
9
|
+
registryType: NpmRegistryType,
|
|
7
10
|
authType: z.literal(NpmRegistryAuthType.Enum.Basic),
|
|
8
11
|
username: z.string(),
|
|
9
12
|
password: z.string(),
|
|
10
13
|
});
|
|
11
14
|
|
|
12
15
|
export const NpmRegistryBearerAuthConfig = z.object({
|
|
16
|
+
registryType: NpmRegistryTypeWithoutAzure,
|
|
13
17
|
authType: z.literal(NpmRegistryAuthType.Enum.Bearer),
|
|
14
18
|
accessToken: z.string(),
|
|
15
19
|
});
|
|
16
20
|
|
|
17
21
|
export const NpmRegistryNoAuthConfig = z.object({
|
|
22
|
+
registryType: NpmRegistryTypeWithoutAzure,
|
|
18
23
|
authType: z.literal(NpmRegistryAuthType.Enum.None),
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
export const NpmRegistrCustomAuthConfig = z.object({
|
|
27
|
+
registryType: NpmRegistryTypeWithoutAzure,
|
|
22
28
|
authType: z.literal(NpmRegistryAuthType.Enum.Custom),
|
|
23
29
|
authHeaderName: z.string(),
|
|
24
30
|
authHeaderValue: z.string(),
|
|
@@ -32,7 +38,6 @@ export const NpmRegistryAuthConfig = z.discriminatedUnion("authType", [
|
|
|
32
38
|
]);
|
|
33
39
|
|
|
34
40
|
const NpmRegistryConfigBase = z.object({
|
|
35
|
-
registryType: NpmRegistryType,
|
|
36
41
|
enabledScopes: z.array(z.string()),
|
|
37
42
|
customRegistryUrl: z.string().optional(),
|
|
38
43
|
bypassProxy: z.boolean().default(false),
|