@supernova-studio/client 0.36.0 → 0.36.2
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 +1140 -91
- package/dist/index.d.ts +1140 -91
- package/dist/index.js +278 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +896 -627
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/design-system/index.ts +1 -0
- package/src/api/conversion/design-system/version-to-dto.ts +17 -0
- package/src/api/conversion/design-systems/brand.ts +14 -0
- package/src/api/conversion/design-systems/elements/index.ts +1 -0
- package/src/api/conversion/design-systems/elements/properties/index.ts +2 -0
- package/src/api/conversion/design-systems/elements/properties/property-definition.ts +21 -0
- package/src/api/conversion/design-systems/elements/properties/property-value.ts +28 -0
- package/src/api/conversion/design-systems/index.ts +3 -0
- package/src/api/conversion/design-systems/view.ts +18 -0
- package/src/api/conversion/index.ts +2 -0
- package/src/api/dto/design-systems/brand.ts +17 -0
- package/src/api/dto/design-systems/index.ts +3 -0
- package/src/api/dto/design-systems/version.ts +24 -0
- package/src/api/dto/design-systems/view.ts +45 -0
- package/src/api/dto/elements/index.ts +1 -0
- package/src/api/dto/elements/properties/index.ts +2 -0
- package/src/api/dto/elements/properties/property-definitions.ts +27 -0
- package/src/api/dto/elements/properties/property-values.ts +17 -0
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +36 -36
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./version-to-dto";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DTODesignSystemVersion } from "../../dto";
|
|
2
|
+
import { DesignSystemVersion } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
export function designSystemVersionToDto(version: DesignSystemVersion): DTODesignSystemVersion {
|
|
5
|
+
return {
|
|
6
|
+
id: version.id,
|
|
7
|
+
designSystemId: version.designSystemId,
|
|
8
|
+
createdAt: version.createdAt,
|
|
9
|
+
meta: {
|
|
10
|
+
name: version.name,
|
|
11
|
+
description: version.comment,
|
|
12
|
+
},
|
|
13
|
+
version: version.version,
|
|
14
|
+
changeLog: version.changeLog,
|
|
15
|
+
isReadonly: version.isReadonly,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DTOBrand } from "../../dto";
|
|
2
|
+
import { Brand } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
export function designSystemBrandToDto(brand: Brand): DTOBrand {
|
|
5
|
+
return {
|
|
6
|
+
id: brand.id,
|
|
7
|
+
designSystemVersionId: brand.designSystemVersionId,
|
|
8
|
+
persistentId: brand.persistentId,
|
|
9
|
+
meta: {
|
|
10
|
+
name: brand.name,
|
|
11
|
+
description: brand.description,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./properties";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ElementPropertyDefinition } from "@supernova-studio/model";
|
|
2
|
+
import { DTOElementPropertyDefinition } from "packages/client/src/api/dto/elements/properties/property-definitions";
|
|
3
|
+
|
|
4
|
+
export function elementPropertyDefinitionToDto(
|
|
5
|
+
elementProperyDefinition: ElementPropertyDefinition
|
|
6
|
+
): DTOElementPropertyDefinition {
|
|
7
|
+
return {
|
|
8
|
+
id: elementProperyDefinition.id,
|
|
9
|
+
designSystemVersionId: elementProperyDefinition.designSystemVersionId,
|
|
10
|
+
meta: {
|
|
11
|
+
name: elementProperyDefinition.name,
|
|
12
|
+
description: elementProperyDefinition.description,
|
|
13
|
+
},
|
|
14
|
+
persistentId: elementProperyDefinition.persistentId,
|
|
15
|
+
type: elementProperyDefinition.type,
|
|
16
|
+
targetElementType: elementProperyDefinition.targetElementType,
|
|
17
|
+
codeName: elementProperyDefinition.codeName,
|
|
18
|
+
options: elementProperyDefinition.options,
|
|
19
|
+
linkElementType: elementProperyDefinition.linkElementType,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ElementPropertyValue, SupernovaException } from "@supernova-studio/model";
|
|
2
|
+
import { DTOElementPropertyValue } from "packages/client/src/api/dto/elements/properties/property-values";
|
|
3
|
+
|
|
4
|
+
export function elementPropertyValueToDto(elementPropertyValue: ElementPropertyValue): DTOElementPropertyValue {
|
|
5
|
+
let value: string | number | boolean | undefined;
|
|
6
|
+
let valuePreview;
|
|
7
|
+
|
|
8
|
+
if (elementPropertyValue.stringValue) {
|
|
9
|
+
value = elementPropertyValue.stringValue;
|
|
10
|
+
} else if (elementPropertyValue.numberValue) {
|
|
11
|
+
value = elementPropertyValue.numberValue;
|
|
12
|
+
} else if (typeof elementPropertyValue.booleanValue === "boolean") {
|
|
13
|
+
value = elementPropertyValue.booleanValue;
|
|
14
|
+
} else if (elementPropertyValue.referenceValue) {
|
|
15
|
+
value = elementPropertyValue.referenceValue;
|
|
16
|
+
valuePreview = elementPropertyValue.referenceValuePreview;
|
|
17
|
+
} else {
|
|
18
|
+
throw SupernovaException.shouldNotHappen(`Invalid element property value, id: ${elementPropertyValue.id}`);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
id: elementPropertyValue.id,
|
|
22
|
+
designSystemVersionId: elementPropertyValue.designSystemVersionId,
|
|
23
|
+
definitionId: elementPropertyValue.definitionPersistentId,
|
|
24
|
+
targetElementId: elementPropertyValue.targetElementPersistentId,
|
|
25
|
+
value,
|
|
26
|
+
valuePreview,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementView, ElementViewColumn } from "@supernova-studio/model";
|
|
2
|
+
import { DTOElementView } from "../../dto";
|
|
3
|
+
|
|
4
|
+
export function elementViewToDto(elementView: ElementView, columns: ElementViewColumn[]): DTOElementView {
|
|
5
|
+
columns.sort((lhs, rhs) => lhs.sortPosition - rhs.sortPosition);
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
id: elementView.id,
|
|
9
|
+
persistentId: elementView.persistentId,
|
|
10
|
+
targetElementType: elementView.targetElementType,
|
|
11
|
+
isDefault: elementView.isDefault,
|
|
12
|
+
meta: {
|
|
13
|
+
name: elementView.name,
|
|
14
|
+
description: elementView.description,
|
|
15
|
+
},
|
|
16
|
+
columns,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ObjectMeta } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
export const DTOBrand = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
designSystemVersionId: z.string(),
|
|
7
|
+
persistentId: z.string(),
|
|
8
|
+
meta: ObjectMeta,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const DTOBrandGetResponse = z.object({ brand: DTOBrand });
|
|
12
|
+
|
|
13
|
+
export const DTOBrandsListResponse = z.object({ brands: z.array(DTOBrand) });
|
|
14
|
+
|
|
15
|
+
export type DTOBrand = z.infer<typeof DTOBrand>;
|
|
16
|
+
export type DTOBrandGetResponse = z.infer<typeof DTOBrandGetResponse>;
|
|
17
|
+
export type DTOBrandsListResponse = z.infer<typeof DTOBrandsListResponse>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ObjectMeta } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
export const DTODesignSystemVersion = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
createdAt: z.date(),
|
|
7
|
+
meta: ObjectMeta,
|
|
8
|
+
version: z.string(),
|
|
9
|
+
isReadonly: z.boolean(),
|
|
10
|
+
changeLog: z.string(),
|
|
11
|
+
designSystemId: z.string(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const DTODesignSystemVersionsListResponse = z.object({
|
|
15
|
+
designSystemVersions: z.array(DTODesignSystemVersion),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const DTODesignSystemVersionGetResponse = z.object({
|
|
19
|
+
designSystemVersion: DTODesignSystemVersion,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type DTODesignSystemVersion = z.infer<typeof DTODesignSystemVersion>;
|
|
23
|
+
export type DTODesignSystemVersionsListResponse = z.infer<typeof DTODesignSystemVersionsListResponse>;
|
|
24
|
+
export type DTODesignSystemVersionGetResponse = z.infer<typeof DTODesignSystemVersionGetResponse>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ElementPropertyTargetType, ElementViewBaseColumnType, ObjectMeta } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
export const DTOElementViewColumnSharedAttributes = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
persistentId: z.string(),
|
|
7
|
+
width: z.number(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const DTOElementViewBasePropertyColumn = DTOElementViewColumnSharedAttributes.extend({
|
|
11
|
+
type: z.literal("BaseProperty"),
|
|
12
|
+
basePropertyType: ElementViewBaseColumnType,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const DTOElementViewPropertyDefinitionColumn = DTOElementViewColumnSharedAttributes.extend({
|
|
16
|
+
type: z.literal("PropertyDefinition"),
|
|
17
|
+
propertyDefinitionId: z.string(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const DTOElementViewThemeColumn = DTOElementViewColumnSharedAttributes.extend({
|
|
21
|
+
type: z.literal("Theme"),
|
|
22
|
+
themeId: z.string(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const DTOElementViewColumn = z.discriminatedUnion("type", [
|
|
26
|
+
DTOElementViewBasePropertyColumn,
|
|
27
|
+
DTOElementViewPropertyDefinitionColumn,
|
|
28
|
+
DTOElementViewThemeColumn,
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
export const DTOElementView = z.object({
|
|
32
|
+
meta: ObjectMeta,
|
|
33
|
+
persistentId: z.string(),
|
|
34
|
+
targetElementType: ElementPropertyTargetType,
|
|
35
|
+
id: z.string(),
|
|
36
|
+
isDefault: z.boolean(),
|
|
37
|
+
columns: z.array(DTOElementViewColumn),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const DTOElementViewsListResponse = z.object({
|
|
41
|
+
elementDataViews: z.array(DTOElementView),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export type DTOElementView = z.infer<typeof DTOElementView>;
|
|
45
|
+
export type DTOElementViewsListResponse = z.infer<typeof DTOElementViewsListResponse>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
ElementPropertyDefinitionOption,
|
|
4
|
+
ElementPropertyLinkType,
|
|
5
|
+
ElementPropertyTargetType,
|
|
6
|
+
ElementPropertyTypeSchema,
|
|
7
|
+
ObjectMeta,
|
|
8
|
+
} from "@supernova-studio/model";
|
|
9
|
+
|
|
10
|
+
export const DTOElementPropertyDefinition = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
designSystemVersionId: z.string(),
|
|
13
|
+
meta: ObjectMeta,
|
|
14
|
+
persistentId: z.string(),
|
|
15
|
+
type: ElementPropertyTypeSchema,
|
|
16
|
+
targetElementType: ElementPropertyTargetType,
|
|
17
|
+
codeName: z.string(),
|
|
18
|
+
options: z.array(ElementPropertyDefinitionOption).optional(),
|
|
19
|
+
linkElementType: ElementPropertyLinkType.optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const DTOElementPropertyDefinitionsGetResponse = z.object({
|
|
23
|
+
definitions: z.array(DTOElementPropertyDefinition),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type DTOElementPropertyDefinition = z.infer<typeof DTOElementPropertyDefinition>;
|
|
27
|
+
export type DTOElementPropertyDefinitionsGetResponse = z.infer<typeof DTOElementPropertyDefinitionsGetResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const DTOElementPropertyValue = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
designSystemVersionId: z.string(),
|
|
6
|
+
definitionId: z.string(),
|
|
7
|
+
targetElementId: z.string(),
|
|
8
|
+
value: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
9
|
+
valuePreview: z.string().optional(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const DTOElementPropertyValuesGetResponse = z.object({
|
|
13
|
+
values: z.array(DTOElementPropertyValue),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type DTOElementPropertyValue = z.infer<typeof DTOElementPropertyValue>;
|
|
17
|
+
export type DTOElementPropertyValuesGetResponse = z.infer<typeof DTOElementPropertyValuesGetResponse>;
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { ProsemirrorNode, ProsemirrorMark } from "./prosemirror/types";
|
|
3
1
|
import {
|
|
2
|
+
PageBlockAppearanceV2,
|
|
3
|
+
PageBlockCalloutType,
|
|
4
|
+
PageBlockColorV2,
|
|
4
5
|
PageBlockDefinition,
|
|
5
|
-
PageBlockText,
|
|
6
|
-
PageBlockTextSpan,
|
|
7
|
-
PageBlockTextSpanAttribute,
|
|
8
6
|
PageBlockDefinitionProperty,
|
|
9
|
-
PageBlockCalloutType,
|
|
10
|
-
PageBlockItemEmbedValue,
|
|
11
|
-
PageBlockItemV2,
|
|
12
|
-
PageBlockItemTextValue,
|
|
13
|
-
PageBlockItemImageValue,
|
|
14
|
-
PageBlockItemRichTextValue,
|
|
15
7
|
PageBlockDefinitionPropertyType,
|
|
16
|
-
|
|
8
|
+
PageBlockItemAssetPropertyValue,
|
|
9
|
+
PageBlockItemAssetValue,
|
|
17
10
|
PageBlockItemBooleanValue,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
PageBlockItemMultiSelectValue,
|
|
21
|
-
PageBlockItemTokenValue,
|
|
22
|
-
PageBlockItemTokenTypeValue,
|
|
23
|
-
PageBlockItemTokenPropertyValue,
|
|
24
|
-
PageBlockItemComponentValue,
|
|
11
|
+
PageBlockItemCodeValue,
|
|
12
|
+
PageBlockItemColorValue,
|
|
25
13
|
PageBlockItemComponentPropertyValue,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
PageBlockItemComponentValue,
|
|
15
|
+
PageBlockItemDividerValue,
|
|
16
|
+
PageBlockItemEmbedValue,
|
|
17
|
+
PageBlockItemFigmaNodeValue,
|
|
18
|
+
PageBlockItemImageValue,
|
|
29
19
|
PageBlockItemMarkdownValue,
|
|
30
|
-
|
|
20
|
+
PageBlockItemMultiRichTextValue,
|
|
21
|
+
PageBlockItemMultiSelectValue,
|
|
22
|
+
PageBlockItemNumberValue,
|
|
23
|
+
PageBlockItemRichTextValue,
|
|
31
24
|
PageBlockItemSandboxValue,
|
|
32
|
-
|
|
33
|
-
PageBlockItemDividerValue,
|
|
25
|
+
PageBlockItemSingleSelectValue,
|
|
34
26
|
PageBlockItemStorybookValue,
|
|
35
|
-
PageBlockItemColorValue,
|
|
36
|
-
PageBlockItemUntypedValue,
|
|
37
|
-
PageBlockItemTableNode,
|
|
38
27
|
PageBlockItemTableCell,
|
|
28
|
+
PageBlockItemTableNode,
|
|
29
|
+
PageBlockItemTableValue,
|
|
30
|
+
PageBlockItemTextValue,
|
|
31
|
+
PageBlockItemTokenPropertyValue,
|
|
32
|
+
PageBlockItemTokenTypeValue,
|
|
33
|
+
PageBlockItemTokenValue,
|
|
34
|
+
PageBlockItemUntypedValue,
|
|
35
|
+
PageBlockItemUrlValue,
|
|
36
|
+
PageBlockItemV2,
|
|
39
37
|
PageBlockTableCellAlignment,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
PageBlockColorV2,
|
|
44
|
-
PageSectionItemV2,
|
|
38
|
+
PageBlockText,
|
|
39
|
+
PageBlockTextSpan,
|
|
40
|
+
PageBlockTextSpanAttribute,
|
|
45
41
|
PageSectionColumnV2,
|
|
42
|
+
PageSectionItemV2,
|
|
43
|
+
nullishToOptional,
|
|
46
44
|
} from "@supernova-studio/model";
|
|
45
|
+
import { yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
|
|
46
|
+
import * as Y from "yjs";
|
|
47
|
+
import { ZodSchema, ZodTypeDef, z } from "zod";
|
|
47
48
|
import { PageBlockEditorModel, PageSectionEditorModel } from "./model/block";
|
|
48
49
|
import { DocumentationPageEditorModel } from "./model/page";
|
|
50
|
+
import { ProsemirrorMark, ProsemirrorNode } from "./prosemirror/types";
|
|
49
51
|
import { BlockDefinitionUtils } from "./utils";
|
|
50
|
-
import { yXmlFragmentToProsemirrorJSON } from "y-prosemirror";
|
|
51
|
-
import { ZodSchema, ZodTypeDef, z } from "zod";
|
|
52
52
|
|
|
53
53
|
export function yDocToPage(yDoc: Y.Doc, definitions: PageBlockDefinition[]): DocumentationPageEditorModel {
|
|
54
54
|
return yXmlFragmentToPage(yDoc.getXmlFragment("default"), definitions);
|
|
@@ -752,7 +752,7 @@ function parseItem(rawItem: unknown, definition: PageBlockDefinition): PageBlock
|
|
|
752
752
|
if (validationResult.success) {
|
|
753
753
|
sanitizedProps[property.id] = validationResult.data;
|
|
754
754
|
} else {
|
|
755
|
-
console.log(validationResult.error.
|
|
755
|
+
console.log(validationResult.error.toString());
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
|