@supernova-studio/client 0.19.2 → 0.20.1
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 +848 -6089
- package/dist/index.d.ts +848 -6089
- package/dist/index.js +104 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1094 -1037
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/documentation/documentation-group-to-dto.ts +6 -6
- package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +2 -2
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +2 -2
- package/src/api/dto/elements/documentation/group-action.ts +26 -1
- package/src/api/dto/elements/documentation/group.ts +8 -9
- package/src/api/dto/elements/documentation/page-v2.ts +3 -3
- package/src/api/dto/elements/elements-action-v2.ts +16 -0
- package/src/yjs/design-system-content/index.ts +1 -0
- package/src/yjs/design-system-content/item-configuration.ts +5 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultDocumentationItemHeaderV2, DocumentationPageV1, groupBy } from "@supernova-studio/model";
|
|
2
2
|
import { DocumentationPageV2 } from "@supernova-studio/model";
|
|
3
3
|
import { ElementGroup } from "@supernova-studio/model";
|
|
4
|
-
import {
|
|
4
|
+
import { DTODocumentationGroupV2, DTODocumentationGroupStructureV2 } from "../../dto";
|
|
5
5
|
|
|
6
6
|
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
7
7
|
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
@@ -12,7 +12,7 @@ import { DTODocumentationGroup, DTODocumentationGroupStructure } from "../../dto
|
|
|
12
12
|
export function elementGroupsToDocumentationGroupStructureDTO(
|
|
13
13
|
groups: ElementGroup[],
|
|
14
14
|
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
15
|
-
):
|
|
15
|
+
): DTODocumentationGroupStructureV2[] {
|
|
16
16
|
const childrenIdsMap = calculateChildrenIdsMap(pages, groups);
|
|
17
17
|
|
|
18
18
|
return groups.map(group => elementGroupToDocumentationGroupStructureDTO(group, childrenIdsMap));
|
|
@@ -21,7 +21,7 @@ export function elementGroupsToDocumentationGroupStructureDTO(
|
|
|
21
21
|
export function elementGroupsToDocumentationGroupDTO(
|
|
22
22
|
groups: ElementGroup[],
|
|
23
23
|
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
24
|
-
):
|
|
24
|
+
): DTODocumentationGroupV2[] {
|
|
25
25
|
const childrenIdsMap = calculateChildrenIdsMap(pages, groups);
|
|
26
26
|
|
|
27
27
|
return groups.map(group => {
|
|
@@ -29,7 +29,7 @@ export function elementGroupsToDocumentationGroupDTO(
|
|
|
29
29
|
...elementGroupToDocumentationGroupStructureDTO(group, childrenIdsMap),
|
|
30
30
|
configuration: group.data?.configuration ?? {
|
|
31
31
|
showSidebar: true,
|
|
32
|
-
header:
|
|
32
|
+
header: defaultDocumentationItemHeaderV2,
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
});
|
|
@@ -38,7 +38,7 @@ export function elementGroupsToDocumentationGroupDTO(
|
|
|
38
38
|
function elementGroupToDocumentationGroupStructureDTO(
|
|
39
39
|
group: ElementGroup,
|
|
40
40
|
childrenIdsMap: Map<string, string[]>
|
|
41
|
-
):
|
|
41
|
+
): DTODocumentationGroupStructureV2 {
|
|
42
42
|
const childrenIds = childrenIdsMap.get(group.persistentId) ?? [];
|
|
43
43
|
|
|
44
44
|
if (!group.shortPersistentId) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SupernovaException } from "@supernova-studio/model";
|
|
2
|
-
import {
|
|
2
|
+
import { defaultDocumentationItemHeaderV1, DocumentationPageV1 } from "@supernova-studio/model";
|
|
3
3
|
import { ElementGroup } from "@supernova-studio/model";
|
|
4
4
|
import { buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
|
|
5
5
|
import { DocumentationPageV1DTO } from "../../dto";
|
|
@@ -33,7 +33,7 @@ export function documentationPagesToDTOV1(
|
|
|
33
33
|
userSlug: page.userSlug,
|
|
34
34
|
configuration: page.data.configuration ?? {
|
|
35
35
|
showSidebar: true,
|
|
36
|
-
header:
|
|
36
|
+
header: defaultDocumentationItemHeaderV1,
|
|
37
37
|
},
|
|
38
38
|
createdAt: page.createdAt,
|
|
39
39
|
updatedAt: page.updatedAt,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentationPageV2, defaultDocumentationItemHeaderV2 } from "@supernova-studio/model";
|
|
2
2
|
import { ElementGroup } from "@supernova-studio/model";
|
|
3
3
|
import { buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
|
|
4
4
|
import { DTODocumentationPageStructureV2, DTODocumentationPageV2 } from "../../dto";
|
|
@@ -27,7 +27,7 @@ export function documentationPagesToDTOV2(
|
|
|
27
27
|
...documentationPageToStructureDTOV2(page, pathsMap),
|
|
28
28
|
configuration: page.data.configuration ?? {
|
|
29
29
|
showSidebar: true,
|
|
30
|
-
header:
|
|
30
|
+
header: defaultDocumentationItemHeaderV2,
|
|
31
31
|
},
|
|
32
32
|
};
|
|
33
33
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import {
|
|
3
3
|
DTOCreateDocumentationGroupInput,
|
|
4
|
+
DTOCreateDocumentationTabGroupInput,
|
|
4
5
|
DTODeleteDocumentationGroupInput,
|
|
5
|
-
|
|
6
|
+
DTODeleteDocumentationTabGroupInput,
|
|
6
7
|
DTODuplicateDocumentationGroupInput,
|
|
7
8
|
DTOMoveDocumentationGroupInput,
|
|
8
9
|
DTOUpdateDocumentationGroupInput,
|
|
@@ -21,6 +22,11 @@ export const DTODocumentationGroupCreateActionOutputV2 = z.object({
|
|
|
21
22
|
output: SuccessPayload,
|
|
22
23
|
});
|
|
23
24
|
|
|
25
|
+
export const DTODocumentationTabGroupCreateActionOutputV2 = z.object({
|
|
26
|
+
type: z.literal("DocumentationTabGroupCreate"),
|
|
27
|
+
output: SuccessPayload,
|
|
28
|
+
});
|
|
29
|
+
|
|
24
30
|
export const DTODocumentationGroupUpdateActionOutputV2 = z.object({
|
|
25
31
|
type: z.literal("DocumentationGroupUpdate"),
|
|
26
32
|
output: SuccessPayload,
|
|
@@ -41,11 +47,18 @@ export const DTODocumentationGroupDeleteActionOutputV2 = z.object({
|
|
|
41
47
|
output: SuccessPayload,
|
|
42
48
|
});
|
|
43
49
|
|
|
50
|
+
export const DTODocumentationTabGroupDeleteActionOutputV2 = z.object({
|
|
51
|
+
type: z.literal("DocumentationTabGroupDelete"),
|
|
52
|
+
output: SuccessPayload,
|
|
53
|
+
});
|
|
54
|
+
|
|
44
55
|
export type DTODocumentationGroupCreateActionOutputV2 = z.infer<typeof DTODocumentationGroupCreateActionOutputV2>;
|
|
56
|
+
export type DTODocumentationTabGroupCreateActionOutputV2 = z.infer<typeof DTODocumentationTabGroupCreateActionOutputV2>;
|
|
45
57
|
export type DTODocumentationGroupUpdateActionOutputV2 = z.infer<typeof DTODocumentationGroupUpdateActionOutputV2>;
|
|
46
58
|
export type DTODocumentationGroupMoveActionOutputV2 = z.infer<typeof DTODocumentationGroupMoveActionOutputV2>;
|
|
47
59
|
export type DTODocumentationGroupDuplicateActionOutputV2 = z.infer<typeof DTODocumentationGroupDuplicateActionOutputV2>;
|
|
48
60
|
export type DTODocumentationGroupDeleteActionOutputV2 = z.infer<typeof DTODocumentationGroupDeleteActionOutputV2>;
|
|
61
|
+
export type DTODocumentationTabGroupDeleteActionOutputV2 = z.infer<typeof DTODocumentationTabGroupDeleteActionOutputV2>;
|
|
49
62
|
|
|
50
63
|
//
|
|
51
64
|
// Write
|
|
@@ -56,6 +69,11 @@ export const DTODocumentationGroupCreateActionInputV2 = z.object({
|
|
|
56
69
|
input: DTOCreateDocumentationGroupInput,
|
|
57
70
|
});
|
|
58
71
|
|
|
72
|
+
export const DTODocumentationTabGroupCreateActionInputV2 = z.object({
|
|
73
|
+
type: z.literal("DocumentationTabGroupCreate"),
|
|
74
|
+
input: DTOCreateDocumentationTabGroupInput,
|
|
75
|
+
});
|
|
76
|
+
|
|
59
77
|
export const DTODocumentationGroupUpdateActionInputV2 = z.object({
|
|
60
78
|
type: z.literal("DocumentationGroupUpdate"),
|
|
61
79
|
input: DTOUpdateDocumentationGroupInput,
|
|
@@ -76,8 +94,15 @@ export const DTODocumentationGroupDeleteActionInputV2 = z.object({
|
|
|
76
94
|
input: DTODeleteDocumentationGroupInput,
|
|
77
95
|
});
|
|
78
96
|
|
|
97
|
+
export const DTODocumentationTabGroupDeleteActionInputV2 = z.object({
|
|
98
|
+
type: z.literal("DocumentationTabGroupDelete"),
|
|
99
|
+
input: DTODeleteDocumentationTabGroupInput,
|
|
100
|
+
});
|
|
101
|
+
|
|
79
102
|
export type DTODocumentationGroupCreateActionInputV2 = z.infer<typeof DTODocumentationGroupCreateActionInputV2>;
|
|
103
|
+
export type DTODocumentationTabGroupCreateActionInputV2 = z.infer<typeof DTODocumentationTabGroupCreateActionInputV2>;
|
|
80
104
|
export type DTODocumentationGroupUpdateActionInputV2 = z.infer<typeof DTODocumentationGroupUpdateActionInputV2>;
|
|
81
105
|
export type DTODocumentationGroupMoveActionInputV2 = z.infer<typeof DTODocumentationGroupMoveActionInputV2>;
|
|
82
106
|
export type DTODocumentationGroupDuplicateActionInputV2 = z.infer<typeof DTODocumentationGroupDuplicateActionInputV2>;
|
|
83
107
|
export type DTODocumentationGroupDeleteActionInputV2 = z.infer<typeof DTODocumentationGroupDeleteActionInputV2>;
|
|
108
|
+
export type DTODocumentationTabGroupDeleteActionInputV2 = z.infer<typeof DTODocumentationTabGroupDeleteActionInputV2>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { DocumentationGroupBehavior,
|
|
2
|
+
import { DocumentationGroupBehavior, DocumentationItemConfigurationV2, ElementGroup } from "@supernova-studio/model";
|
|
3
3
|
|
|
4
4
|
//
|
|
5
5
|
// Read
|
|
@@ -9,7 +9,7 @@ import { DocumentationGroupBehavior, DocumentationItemConfiguration, ElementGrou
|
|
|
9
9
|
* Structure DTO is element properties minus element data (in other words data required
|
|
10
10
|
* to display the element in the left panel)
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
12
|
+
export const DTODocumentationGroupStructureV2 = ElementGroup.omit({
|
|
13
13
|
sortOrder: true,
|
|
14
14
|
parentPersistentId: true,
|
|
15
15
|
brandPersistentId: true,
|
|
@@ -26,12 +26,12 @@ export const DTODocumentationGroupStructure = ElementGroup.omit({
|
|
|
26
26
|
type: z.literal("Group"),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
export const
|
|
30
|
-
configuration:
|
|
29
|
+
export const DTODocumentationGroupV2 = DTODocumentationGroupStructureV2.extend({
|
|
30
|
+
configuration: DocumentationItemConfigurationV2,
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
export type
|
|
34
|
-
export type
|
|
33
|
+
export type DTODocumentationGroupStructureV2 = z.infer<typeof DTODocumentationGroupStructureV2>;
|
|
34
|
+
export type DTODocumentationGroupV2 = z.infer<typeof DTODocumentationGroupV2>;
|
|
35
35
|
|
|
36
36
|
//
|
|
37
37
|
// Write
|
|
@@ -43,8 +43,7 @@ export const DTOCreateDocumentationGroupInput = z.object({
|
|
|
43
43
|
|
|
44
44
|
// Group properties
|
|
45
45
|
title: z.string(),
|
|
46
|
-
configuration:
|
|
47
|
-
groupBehavior: DocumentationGroupBehavior,
|
|
46
|
+
configuration: DocumentationItemConfigurationV2.optional(),
|
|
48
47
|
|
|
49
48
|
// Group placement properties
|
|
50
49
|
afterPersistentId: z.string().uuid().optional(),
|
|
@@ -57,7 +56,7 @@ export const DTOUpdateDocumentationGroupInput = z.object({
|
|
|
57
56
|
|
|
58
57
|
// Group properties
|
|
59
58
|
title: z.string().optional(),
|
|
60
|
-
configuration:
|
|
59
|
+
configuration: DocumentationItemConfigurationV2.optional(),
|
|
61
60
|
});
|
|
62
61
|
|
|
63
62
|
export const DTOMoveDocumentationGroupInput = z.object({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { DocumentationItemConfigurationV2 } from "@supernova-studio/model";
|
|
3
3
|
import { DocumentationPageV2 } from "@supernova-studio/model";
|
|
4
|
-
import {
|
|
4
|
+
import { DTODocumentationGroupStructureV2 } from "./group";
|
|
5
5
|
|
|
6
6
|
//
|
|
7
7
|
// Read
|
|
@@ -28,7 +28,7 @@ export const DTODocumentationPageV2 = DTODocumentationPageStructureV2.extend({
|
|
|
28
28
|
|
|
29
29
|
export const DTODocumentationHierarchyV2 = z.object({
|
|
30
30
|
pages: z.array(DTODocumentationPageStructureV2),
|
|
31
|
-
groups: z.array(
|
|
31
|
+
groups: z.array(DTODocumentationGroupStructureV2),
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export type DTODocumentationPageV2 = z.infer<typeof DTODocumentationPageV2>;
|
|
@@ -22,6 +22,10 @@ import {
|
|
|
22
22
|
DTODocumentationGroupMoveActionOutputV2,
|
|
23
23
|
DTODocumentationGroupUpdateActionInputV2,
|
|
24
24
|
DTODocumentationGroupUpdateActionOutputV2,
|
|
25
|
+
DTODocumentationTabGroupCreateActionInputV2,
|
|
26
|
+
DTODocumentationTabGroupCreateActionOutputV2,
|
|
27
|
+
DTODocumentationTabGroupDeleteActionInputV2,
|
|
28
|
+
DTODocumentationTabGroupDeleteActionOutputV2,
|
|
25
29
|
} from "./documentation/group-action";
|
|
26
30
|
|
|
27
31
|
//
|
|
@@ -38,10 +42,12 @@ export const DTOElementActionOutput = z.discriminatedUnion("type", [
|
|
|
38
42
|
|
|
39
43
|
// Documentation groups
|
|
40
44
|
DTODocumentationGroupCreateActionOutputV2,
|
|
45
|
+
DTODocumentationTabGroupCreateActionOutputV2,
|
|
41
46
|
DTODocumentationGroupUpdateActionOutputV2,
|
|
42
47
|
DTODocumentationGroupMoveActionOutputV2,
|
|
43
48
|
DTODocumentationGroupDuplicateActionOutputV2,
|
|
44
49
|
DTODocumentationGroupDeleteActionOutputV2,
|
|
50
|
+
DTODocumentationTabGroupDeleteActionOutputV2,
|
|
45
51
|
]);
|
|
46
52
|
|
|
47
53
|
export type DTOElementActionOutput = z.infer<typeof DTOElementActionOutput>;
|
|
@@ -60,10 +66,20 @@ export const DTOElementActionInput = z.discriminatedUnion("type", [
|
|
|
60
66
|
|
|
61
67
|
// Documentation groups
|
|
62
68
|
DTODocumentationGroupCreateActionInputV2,
|
|
69
|
+
DTODocumentationTabGroupCreateActionInputV2,
|
|
63
70
|
DTODocumentationGroupUpdateActionInputV2,
|
|
64
71
|
DTODocumentationGroupMoveActionInputV2,
|
|
65
72
|
DTODocumentationGroupDuplicateActionInputV2,
|
|
66
73
|
DTODocumentationGroupDeleteActionInputV2,
|
|
74
|
+
DTODocumentationTabGroupDeleteActionInputV2,
|
|
67
75
|
]);
|
|
68
76
|
|
|
69
77
|
export type DTOElementActionInput = z.infer<typeof DTOElementActionInput>;
|
|
78
|
+
|
|
79
|
+
function hue(action: DTOElementActionInput) {
|
|
80
|
+
action.type;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function hue2(action: DTOElementActionOutput) {
|
|
84
|
+
action.type;
|
|
85
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DocumentationItemConfigurationV2, DocumentationItemHeaderV2 } from "@supernova-studio/model";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
@@ -8,13 +8,13 @@ import { z } from "zod";
|
|
|
8
8
|
|
|
9
9
|
export const DTODocumentationPageRoomHeaderData = z.object({
|
|
10
10
|
title: z.string(),
|
|
11
|
-
configuration:
|
|
11
|
+
configuration: DocumentationItemConfigurationV2,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
export const DTODocumentationPageRoomHeaderDataUpdate = z.object({
|
|
15
15
|
title: z.string().optional(),
|
|
16
|
-
configuration:
|
|
17
|
-
.extend({ header:
|
|
16
|
+
configuration: DocumentationItemConfigurationV2.omit({ header: true })
|
|
17
|
+
.extend({ header: DocumentationItemHeaderV2.partial() })
|
|
18
18
|
.optional(),
|
|
19
19
|
});
|
|
20
20
|
|
|
@@ -83,6 +83,6 @@ export function yjsToItemConfiguration(yDoc: Y.Doc): DTODocumentationPageRoomHea
|
|
|
83
83
|
|
|
84
84
|
return {
|
|
85
85
|
title: z.string().parse(title),
|
|
86
|
-
configuration:
|
|
86
|
+
configuration: DocumentationItemConfigurationV2.parse(rawConfig),
|
|
87
87
|
};
|
|
88
88
|
}
|