@supernova-studio/client 0.45.0 → 0.46.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 +315 -122
- package/dist/index.d.ts +315 -122
- package/dist/index.js +315 -282
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +568 -535
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/documentation/documentation-group-v1-to-dto.ts +30 -5
- package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +28 -8
- package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +18 -16
- package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +15 -13
- package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +62 -0
- package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +47 -26
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +23 -9
- package/src/api/conversion/index.ts +0 -2
- package/src/api/dto/design-systems/version.ts +17 -0
- package/src/api/dto/workspaces/integrations.ts +2 -2
- package/src/api/payloads/design-systems/version.ts +5 -2
- package/src/api/payloads/workspaces/workspace-integrations.ts +9 -1
- package/src/yjs/design-system-content/index.ts +0 -1
- package/src/api/conversion/design-system/index.ts +0 -1
- package/src/api/conversion/design-system/version-to-dto.ts +0 -17
- package/src/api/conversion/design-systems/brand.ts +0 -14
- package/src/api/conversion/design-systems/elements/index.ts +0 -1
- package/src/api/conversion/design-systems/elements/properties/index.ts +0 -2
- package/src/api/conversion/design-systems/elements/properties/property-definition.ts +0 -21
- package/src/api/conversion/design-systems/elements/properties/property-value.ts +0 -28
- package/src/api/conversion/design-systems/index.ts +0 -3
- package/src/api/conversion/design-systems/view.ts +0 -18
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DocumentationGroupV1,
|
|
3
|
+
DocumentationItemConfigurationV1,
|
|
4
|
+
DocumentationPageV1,
|
|
5
|
+
DocumentationPageV2,
|
|
6
|
+
groupBy,
|
|
7
|
+
} from "@supernova-studio/model";
|
|
2
8
|
import { DTODocumentationGroupStructureV1, DTODocumentationGroupV1 } from "../../dto/elements/documentation/group-v1";
|
|
3
9
|
import {
|
|
4
10
|
documentationItemConfigurationToDTOV1,
|
|
5
|
-
|
|
11
|
+
getDtoDefaultItemConfigurationV1,
|
|
6
12
|
} from "./documentation-item-configuration-v1-to-dto";
|
|
13
|
+
import { applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
|
|
7
14
|
|
|
8
15
|
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
9
16
|
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
@@ -29,9 +36,27 @@ export function elementGroupsToDocumentationGroupDTOV1(
|
|
|
29
36
|
return groups.map(group => {
|
|
30
37
|
return {
|
|
31
38
|
...elementGroupToDocumentationGroupStructureDTOV1(group, childrenIdsMap),
|
|
32
|
-
configuration: group.data?.configuration
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
configuration: documentationItemConfigurationToDTOV1(group.data?.configuration),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function elementGroupsToDocumentationGroupFixedConfigurationDTOV1(
|
|
45
|
+
groups: DocumentationGroupV1[],
|
|
46
|
+
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
47
|
+
): DTODocumentationGroupV1[] {
|
|
48
|
+
const childrenIdsMap = calculateChildrenIdsMapV1(pages, groups);
|
|
49
|
+
|
|
50
|
+
const { groups: fixedGroups } = applyPrivacyConfigurationToNestedItems<
|
|
51
|
+
DocumentationPageV1 | DocumentationPageV2,
|
|
52
|
+
DocumentationGroupV1,
|
|
53
|
+
DocumentationItemConfigurationV1
|
|
54
|
+
>(pages, groups, getDtoDefaultItemConfigurationV1);
|
|
55
|
+
|
|
56
|
+
return fixedGroups.map(group => {
|
|
57
|
+
return {
|
|
58
|
+
...elementGroupToDocumentationGroupStructureDTOV1(group, childrenIdsMap),
|
|
59
|
+
configuration: documentationItemConfigurationToDTOV1(group.data?.configuration),
|
|
35
60
|
};
|
|
36
61
|
});
|
|
37
62
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DocumentationItemConfigurationV2,
|
|
3
|
+
DocumentationPageV1,
|
|
4
|
+
DocumentationPageV2,
|
|
5
|
+
ElementGroup,
|
|
6
|
+
groupBy,
|
|
7
|
+
} from "@supernova-studio/model";
|
|
2
8
|
import { DTODocumentationGroupStructureV2, DTODocumentationGroupV2 } from "../../dto";
|
|
3
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
documentationItemConfigurationToDTOV2,
|
|
11
|
+
getDtoDefaultItemConfigurationV2,
|
|
12
|
+
} from "./documentation-item-configuration-v2-to-dto";
|
|
13
|
+
import { applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
|
|
4
14
|
|
|
5
15
|
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
6
16
|
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
@@ -23,12 +33,22 @@ export function elementGroupsToDocumentationGroupDTOV2(
|
|
|
23
33
|
): DTODocumentationGroupV2[] {
|
|
24
34
|
const childrenIdsMap = calculateChildrenIdsMapV2(pages, groups);
|
|
25
35
|
|
|
26
|
-
return groups.map(group =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
return groups.map(group => elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function elementGroupsToDocumentationGroupFixedConfigurationDTOV2(
|
|
40
|
+
groups: ElementGroup[],
|
|
41
|
+
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
42
|
+
): DTODocumentationGroupV2[] {
|
|
43
|
+
const childrenIdsMap = calculateChildrenIdsMapV2(pages, groups);
|
|
44
|
+
|
|
45
|
+
const { groups: fixedGroups } = applyPrivacyConfigurationToNestedItems<
|
|
46
|
+
DocumentationPageV1 | DocumentationPageV2,
|
|
47
|
+
ElementGroup,
|
|
48
|
+
DocumentationItemConfigurationV2
|
|
49
|
+
>(pages, groups, getDtoDefaultItemConfigurationV2);
|
|
50
|
+
|
|
51
|
+
return fixedGroups.map(group => elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap));
|
|
32
52
|
}
|
|
33
53
|
|
|
34
54
|
function elementGroupToDocumentationGroupStructureDTOV2(
|
|
@@ -6,28 +6,30 @@ import {
|
|
|
6
6
|
} from "@supernova-studio/model";
|
|
7
7
|
import { DTODocumentationItemConfigurationV1 } from "../../dto";
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
9
|
+
export const getDtoDefaultItemConfigurationV1 = () =>
|
|
10
|
+
({
|
|
11
|
+
showSidebar: true,
|
|
12
|
+
isHidden: false,
|
|
13
|
+
isPrivate: false,
|
|
14
|
+
header: {
|
|
15
|
+
alignment: DocumentationItemHeaderAlignment.Left,
|
|
16
|
+
backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
|
|
17
|
+
description: "",
|
|
18
|
+
showBackgroundOverlay: false,
|
|
19
|
+
showCoverText: true,
|
|
20
|
+
},
|
|
21
|
+
} as const);
|
|
21
22
|
|
|
22
23
|
export function documentationItemConfigurationToDTOV1(
|
|
23
|
-
config: DocumentationItemConfigurationV1
|
|
24
|
+
config: DocumentationItemConfigurationV1 | undefined
|
|
24
25
|
): DTODocumentationItemConfigurationV1 {
|
|
25
|
-
const
|
|
26
|
+
const dtoDefaultItemConfigurationV1 = getDtoDefaultItemConfigurationV1();
|
|
27
|
+
if (!config) return dtoDefaultItemConfigurationV1;
|
|
26
28
|
|
|
27
|
-
const { backgroundColor, foregroundColor, ...headerRest } = header;
|
|
29
|
+
const { backgroundColor, foregroundColor, ...headerRest } = config.header;
|
|
28
30
|
|
|
29
31
|
return {
|
|
30
|
-
showSidebar,
|
|
32
|
+
showSidebar: config.showSidebar,
|
|
31
33
|
isHidden: config.isHidden ?? dtoDefaultItemConfigurationV1.isHidden,
|
|
32
34
|
isPrivate: config.isPrivate ?? dtoDefaultItemConfigurationV1.isPrivate,
|
|
33
35
|
header: {
|
|
@@ -5,27 +5,29 @@ import {
|
|
|
5
5
|
} from "@supernova-studio/model";
|
|
6
6
|
import { DTODocumentationItemConfigurationV2 } from "../../dto/elements/documentation/item-configuration-v2";
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
8
|
+
export const getDtoDefaultItemConfigurationV2 = () =>
|
|
9
|
+
({
|
|
10
|
+
showSidebar: true,
|
|
11
|
+
isHidden: false,
|
|
12
|
+
isPrivate: false,
|
|
13
|
+
header: {
|
|
14
|
+
alignment: DocumentationItemHeaderAlignment.Left,
|
|
15
|
+
backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
|
|
16
|
+
description: "",
|
|
17
|
+
showBackgroundOverlay: false,
|
|
18
|
+
showCoverText: true,
|
|
19
|
+
},
|
|
20
|
+
} as const);
|
|
20
21
|
|
|
21
22
|
export function documentationItemConfigurationToDTOV2(
|
|
22
23
|
config: DocumentationItemConfigurationV2 | undefined
|
|
23
24
|
): DTODocumentationItemConfigurationV2 {
|
|
25
|
+
const dtoDefaultItemConfigurationV2 = getDtoDefaultItemConfigurationV2();
|
|
24
26
|
if (!config) return dtoDefaultItemConfigurationV2;
|
|
25
27
|
|
|
26
28
|
return {
|
|
27
29
|
header: config.header,
|
|
28
|
-
isHidden: config.isHidden ?? dtoDefaultItemConfigurationV2.
|
|
30
|
+
isHidden: config.isHidden ?? dtoDefaultItemConfigurationV2.isHidden,
|
|
29
31
|
isPrivate: config.isPrivate ?? dtoDefaultItemConfigurationV2.isPrivate,
|
|
30
32
|
showSidebar: config.showSidebar,
|
|
31
33
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DocumentationItemConfigurationV1,
|
|
3
|
+
DocumentationItemConfigurationV2,
|
|
2
4
|
DocumentationGroupV1,
|
|
3
5
|
DocumentationPageV1,
|
|
4
6
|
DocumentationPageV2,
|
|
@@ -68,3 +70,63 @@ export function calculateElementParentChain<T extends GroupLike>(
|
|
|
68
70
|
|
|
69
71
|
return result;
|
|
70
72
|
}
|
|
73
|
+
|
|
74
|
+
export function applyPrivacyConfigurationToNestedItems<
|
|
75
|
+
PageType extends DocumentationPageV1 | DocumentationPageV2,
|
|
76
|
+
GroupType extends DocumentationGroupV1 | ElementGroup,
|
|
77
|
+
ItemConfigurationType extends DocumentationItemConfigurationV1 | DocumentationItemConfigurationV2
|
|
78
|
+
>(
|
|
79
|
+
pages: PageType[],
|
|
80
|
+
groups: GroupType[],
|
|
81
|
+
getDefaultItemConfiguration: () => ItemConfigurationType
|
|
82
|
+
): { pages: PageType[]; groups: GroupType[] } {
|
|
83
|
+
// copy groups to mutate them later
|
|
84
|
+
const fixedGroups = groups.map(group => ({
|
|
85
|
+
...group,
|
|
86
|
+
data: {
|
|
87
|
+
...group.data,
|
|
88
|
+
configuration: group.data?.configuration ?? getDefaultItemConfiguration(),
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
const groupPersistentIdToGroupMap = mapByUnique(fixedGroups, group => group.persistentId);
|
|
92
|
+
|
|
93
|
+
for (const groupToFix of fixedGroups) {
|
|
94
|
+
let isHidden = groupToFix.data.configuration.isHidden;
|
|
95
|
+
let isPrivate = groupToFix.data.configuration.isPrivate;
|
|
96
|
+
|
|
97
|
+
let nextParentId: string | undefined = groupToFix.parentPersistentId;
|
|
98
|
+
while ((!isHidden || !isPrivate) && nextParentId) {
|
|
99
|
+
const parent = groupPersistentIdToGroupMap.get(nextParentId);
|
|
100
|
+
if (!parent) break;
|
|
101
|
+
|
|
102
|
+
isHidden = isHidden || parent.data?.configuration?.isHidden || false;
|
|
103
|
+
isPrivate = isPrivate || parent.data?.configuration?.isPrivate || false;
|
|
104
|
+
|
|
105
|
+
nextParentId = parent.parentPersistentId;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
groupToFix.data.configuration.isHidden = isHidden;
|
|
109
|
+
groupToFix.data.configuration.isPrivate = isPrivate;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const fixedPages: PageType[] = [];
|
|
113
|
+
// set isHidden and isPrivate configuration fields based on page and parents value
|
|
114
|
+
for (const page of pages) {
|
|
115
|
+
const configuration = page.data?.configuration ?? getDefaultItemConfiguration();
|
|
116
|
+
const parent = groupPersistentIdToGroupMap.get(page.parentPersistentId);
|
|
117
|
+
|
|
118
|
+
fixedPages.push({
|
|
119
|
+
...page,
|
|
120
|
+
data: {
|
|
121
|
+
...page.data,
|
|
122
|
+
configuration: {
|
|
123
|
+
...configuration,
|
|
124
|
+
isHidden: configuration.isHidden || parent?.data?.configuration?.isHidden || false,
|
|
125
|
+
isPrivate: configuration.isPrivate || parent?.data?.configuration?.isPrivate || false,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { pages: fixedPages, groups: fixedGroups };
|
|
132
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DocumentationGroupV1,
|
|
3
|
+
DocumentationItemConfigurationV1,
|
|
4
|
+
DocumentationPageV1,
|
|
5
|
+
SupernovaException,
|
|
6
|
+
} from "@supernova-studio/model";
|
|
2
7
|
import { DocumentationPageV1DTO } from "../../dto";
|
|
3
8
|
import {
|
|
4
9
|
documentationItemConfigurationToDTOV1,
|
|
5
|
-
|
|
10
|
+
getDtoDefaultItemConfigurationV1,
|
|
6
11
|
} from "./documentation-item-configuration-v1-to-dto";
|
|
7
|
-
import { buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
|
|
12
|
+
import { buildDocPagePublishPaths, applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
|
|
8
13
|
|
|
9
14
|
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
10
15
|
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
@@ -19,27 +24,43 @@ export function documentationPagesToDTOV1(
|
|
|
19
24
|
): DocumentationPageV1DTO[] {
|
|
20
25
|
const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
|
|
21
26
|
|
|
22
|
-
return pages.map(page =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
return pages.map(page => documentationPageToDTOV1(page, pathsMap));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function documentationPagesFixedConfigurationToDTOV1(
|
|
31
|
+
pages: DocumentationPageV1[],
|
|
32
|
+
groups: DocumentationGroupV1[],
|
|
33
|
+
routingVersion: string
|
|
34
|
+
): DocumentationPageV1DTO[] {
|
|
35
|
+
const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
|
|
36
|
+
|
|
37
|
+
const { pages: fixedPages } = applyPrivacyConfigurationToNestedItems<
|
|
38
|
+
DocumentationPageV1,
|
|
39
|
+
DocumentationGroupV1,
|
|
40
|
+
DocumentationItemConfigurationV1
|
|
41
|
+
>(pages, groups, getDtoDefaultItemConfigurationV1);
|
|
42
|
+
|
|
43
|
+
return fixedPages.map((page: DocumentationPageV1) => documentationPageToDTOV1(page, pathsMap));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function documentationPageToDTOV1(page: DocumentationPageV1, pagePathMap: Map<string, string>): DocumentationPageV1DTO {
|
|
47
|
+
let path = pagePathMap.get(page.persistentId);
|
|
48
|
+
if (!path) throw SupernovaException.conflict(`Path for page ${page.id} was not calculated`);
|
|
49
|
+
|
|
50
|
+
if (path.startsWith("/")) path = path.substring(1);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
id: page.id,
|
|
54
|
+
designSystemVersionId: page.designSystemVersionId,
|
|
55
|
+
persistentId: page.persistentId,
|
|
56
|
+
shortPersistentId: page.shortPersistentId,
|
|
57
|
+
title: page.meta.name,
|
|
58
|
+
blocks: page.data.blocks,
|
|
59
|
+
slug: page.slug,
|
|
60
|
+
userSlug: page.userSlug,
|
|
61
|
+
configuration: documentationItemConfigurationToDTOV1(page.data.configuration),
|
|
62
|
+
createdAt: page.createdAt,
|
|
63
|
+
updatedAt: page.updatedAt,
|
|
64
|
+
path: path,
|
|
65
|
+
};
|
|
45
66
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
1
|
+
import { DocumentationItemConfigurationV2, DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
2
2
|
import { DTODocumentationPageStructureV2, DTODocumentationPageV2 } from "../../dto";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
documentationItemConfigurationToDTOV2,
|
|
5
|
+
getDtoDefaultItemConfigurationV2,
|
|
6
|
+
} from "./documentation-item-configuration-v2-to-dto";
|
|
7
|
+
import { buildDocPagePublishPaths, applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
|
|
5
8
|
|
|
6
9
|
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
7
10
|
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
@@ -25,12 +28,23 @@ export function documentationPagesToDTOV2(
|
|
|
25
28
|
): DTODocumentationPageV2[] {
|
|
26
29
|
const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
|
|
27
30
|
|
|
28
|
-
return pages.map(page =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
return pages.map(page => documentationPageToStructureDTOV2(page, pathsMap));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function documentationPagesFixedConfigurationToDTOV2(
|
|
35
|
+
pages: DocumentationPageV2[],
|
|
36
|
+
groups: ElementGroup[],
|
|
37
|
+
routingVersion: string
|
|
38
|
+
): DTODocumentationPageV2[] {
|
|
39
|
+
const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
|
|
40
|
+
|
|
41
|
+
const { pages: fixedPages } = applyPrivacyConfigurationToNestedItems<
|
|
42
|
+
DocumentationPageV2,
|
|
43
|
+
ElementGroup,
|
|
44
|
+
DocumentationItemConfigurationV2
|
|
45
|
+
>(pages, groups, getDtoDefaultItemConfigurationV2);
|
|
46
|
+
|
|
47
|
+
return fixedPages.map(page => documentationPageToStructureDTOV2(page, pathsMap));
|
|
34
48
|
}
|
|
35
49
|
|
|
36
50
|
function documentationPageToStructureDTOV2(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ObjectMeta } from "@supernova-studio/model";
|
|
3
|
+
import { DTOCreateVersionInput } from "../../payloads";
|
|
3
4
|
|
|
4
5
|
export const DTODesignSystemVersion = z.object({
|
|
5
6
|
id: z.string(),
|
|
@@ -19,6 +20,22 @@ export const DTODesignSystemVersionGetResponse = z.object({
|
|
|
19
20
|
designSystemVersion: DTODesignSystemVersion,
|
|
20
21
|
});
|
|
21
22
|
|
|
23
|
+
export const DTODesignSystemVersionCreationResponse = z.object({
|
|
24
|
+
meta: ObjectMeta,
|
|
25
|
+
version: z.string(),
|
|
26
|
+
changeLog: z.string(),
|
|
27
|
+
isReadOnly: z.boolean(),
|
|
28
|
+
designSystemId: z.string(),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export const VersionSQSPayload = z.object({
|
|
32
|
+
designSystemId: z.string(),
|
|
33
|
+
input: DTOCreateVersionInput,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export type VersionSQSPayload = z.infer<typeof VersionSQSPayload>;
|
|
37
|
+
|
|
38
|
+
export type DTODesignSystemVersionCreationResponse = z.infer<typeof DTODesignSystemVersionCreationResponse>;
|
|
22
39
|
export type DTODesignSystemVersion = z.infer<typeof DTODesignSystemVersion>;
|
|
23
40
|
export type DTODesignSystemVersionsListResponse = z.infer<typeof DTODesignSystemVersionsListResponse>;
|
|
24
41
|
export type DTODesignSystemVersionGetResponse = z.infer<typeof DTODesignSystemVersionGetResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegrationCredentials, IntegrationType } from "@supernova-studio/model";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
export const DTOIntegration = z.object({
|
|
@@ -6,7 +6,7 @@ export const DTOIntegration = z.object({
|
|
|
6
6
|
workspaceId: z.string(),
|
|
7
7
|
type: IntegrationType,
|
|
8
8
|
createdAt: z.coerce.date(),
|
|
9
|
-
integrationCredentials: z.array(
|
|
9
|
+
integrationCredentials: z.array(IntegrationCredentials).optional(),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export const DTOIntegrationOAuthGetResponse = z.object({
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { ObjectMeta } from "@supernova-studio/model";
|
|
3
2
|
|
|
3
|
+
export const ObjectMeta = z.object({
|
|
4
|
+
name: z.string().max(150).optional(),
|
|
5
|
+
description: z.string().max(2000).optional(),
|
|
6
|
+
});
|
|
4
7
|
|
|
5
8
|
export function validateSemver(version: string) {
|
|
6
9
|
const semverRegex = /^(\d+)(\.\d+)?(\.\d+)?$/;
|
|
@@ -12,7 +15,7 @@ export const DTOCreateVersionInput = z.object({
|
|
|
12
15
|
version: z.string().refine(validateSemver, {
|
|
13
16
|
message: "Invalid semantic versioning format",
|
|
14
17
|
}),
|
|
15
|
-
changeLog: z.string()
|
|
18
|
+
changeLog: z.string().max(2000).optional()
|
|
16
19
|
});
|
|
17
20
|
|
|
18
21
|
export type DTOCreateVersionInput = z.infer<typeof DTOCreateVersionInput>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationType } from "@supernova-studio/model";
|
|
1
|
+
import { IntegrationTokenResponse, IntegrationType } from "@supernova-studio/model";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
export const DTOWorkspaceIntegrationOauthInput = z.object({
|
|
@@ -6,3 +6,11 @@ export const DTOWorkspaceIntegrationOauthInput = z.object({
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
export type DTOWorkspaceIntegrationOauthInput = z.infer<typeof DTOWorkspaceIntegrationOauthInput>;
|
|
9
|
+
|
|
10
|
+
export const DTOWorkspaceIntegrationPATInput = z.object({
|
|
11
|
+
userId: z.string(),
|
|
12
|
+
type: IntegrationType,
|
|
13
|
+
token: IntegrationTokenResponse,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type DTOWorkspaceIntegrationPATInput = z.infer<typeof DTOWorkspaceIntegrationPATInput>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./version-to-dto";
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./properties";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ElementPropertyDefinition } from "@supernova-studio/model";
|
|
2
|
-
import { DTOElementPropertyDefinition } from "packages/client/src/api/dto";
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ElementPropertyValue } from "@supernova-studio/model";
|
|
2
|
-
import { DTOElementPropertyValue } from "packages/client/src/api/dto";
|
|
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
|
-
value = undefined;
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|