@supernova-studio/client 0.47.38 → 0.47.39
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 +80 -2
- package/dist/index.d.ts +80 -2
- package/dist/index.js +101 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2149 -2103
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/documentation/documentation-elements-to-hierarchy-v2-dto.ts +3 -1
- package/src/api/dto/elements/documentation/page-v2.ts +3 -2
- package/src/yjs/design-system-content/documentation-hierarchy.ts +33 -3
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
1
|
+
import { DesignElementSnapshot, DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
2
2
|
import { DTODocumentationHierarchyV2 } from "../../dto";
|
|
3
3
|
import { elementGroupsToDocumentationGroupStructureDTOV2 } from "./documentation-group-v2-to-dto";
|
|
4
4
|
import { documentationPagesToStructureDTOV2 } from "./documentation-page-v2-to-dto";
|
|
@@ -12,10 +12,12 @@ import { documentationPagesToStructureDTOV2 } from "./documentation-page-v2-to-d
|
|
|
12
12
|
export function documentationElementsToHierarchyDto(
|
|
13
13
|
docPages: DocumentationPageV2[],
|
|
14
14
|
docGroups: ElementGroup[],
|
|
15
|
+
publishedPagesSnapshots: DesignElementSnapshot[],
|
|
15
16
|
routingVersion: string
|
|
16
17
|
): DTODocumentationHierarchyV2 {
|
|
17
18
|
return {
|
|
18
19
|
pages: documentationPagesToStructureDTOV2(docPages, docGroups, routingVersion),
|
|
19
20
|
groups: elementGroupsToDocumentationGroupStructureDTOV2(docGroups, docPages),
|
|
21
|
+
publishedPagesSnapshots,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DocumentationPageV2 } from "@supernova-studio/model";
|
|
1
|
+
import { DesignElementSnapshot, DocumentationPageV2 } from "@supernova-studio/model";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { DTODocumentationItemConfigurationV2 } from "./item-configuration-v2";
|
|
4
3
|
import { DTODocumentationGroupStructureV2 } from "./group-v2";
|
|
4
|
+
import { DTODocumentationItemConfigurationV2 } from "./item-configuration-v2";
|
|
5
5
|
//
|
|
6
6
|
// Read
|
|
7
7
|
//
|
|
@@ -29,6 +29,7 @@ export type DTODocumentationPageStructureV2 = DTODocumentationPageV2;
|
|
|
29
29
|
export const DTODocumentationHierarchyV2 = z.object({
|
|
30
30
|
pages: z.array(DTODocumentationPageStructureV2),
|
|
31
31
|
groups: z.array(DTODocumentationGroupStructureV2),
|
|
32
|
+
publishedPagesSnapshots: DesignElementSnapshot.array(),
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
export type DTODocumentationHierarchyV2 = z.infer<typeof DTODocumentationHierarchyV2>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
1
|
+
import { DesignElementSnapshot, DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { DTODocumentationHierarchyV2, documentationElementsToHierarchyDto } from "../../api";
|
|
@@ -23,12 +23,14 @@ type DocumentationHierarchyTransaction = {
|
|
|
23
23
|
groups: ElementGroup[];
|
|
24
24
|
pageIdsToDelete: string[];
|
|
25
25
|
groupIdsToDelete: string[];
|
|
26
|
+
publishedPageSnapshots: DesignElementSnapshot[];
|
|
26
27
|
|
|
27
28
|
internalSettings: DocumentationHierarchySettings | undefined;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export const DocumentationHierarchySettings = z.object({
|
|
31
32
|
routingVersion: z.string(),
|
|
33
|
+
isDraftFeatureAdopted: z.boolean(),
|
|
32
34
|
});
|
|
33
35
|
|
|
34
36
|
export type DocumentationHierarchySettings = z.infer<typeof DocumentationHierarchySettings>;
|
|
@@ -69,6 +71,13 @@ export function documentationHierarchyToYjs(doc: Y.Doc, transaction: Documentati
|
|
|
69
71
|
groupsMap.set(group.id, JSON.parse(JSON.stringify(group)));
|
|
70
72
|
});
|
|
71
73
|
|
|
74
|
+
// Published state
|
|
75
|
+
const publishedSnapshotsMap = getPublishedSnapshotsYMap(trx.doc);
|
|
76
|
+
|
|
77
|
+
transaction.publishedPageSnapshots.forEach(state => {
|
|
78
|
+
publishedSnapshotsMap.set(state.id, JSON.parse(JSON.stringify(state)));
|
|
79
|
+
});
|
|
80
|
+
|
|
72
81
|
// Internal settings
|
|
73
82
|
if (transaction.internalSettings) {
|
|
74
83
|
serializeDocumentationInternalSettings(trx.doc, transaction.internalSettings);
|
|
@@ -82,11 +91,13 @@ function serializeDocumentationInternalSettings(doc: Y.Doc, settings: Documentat
|
|
|
82
91
|
const map = getInternalSettingsYMap(doc);
|
|
83
92
|
|
|
84
93
|
map.set("routingVersion", settings.routingVersion);
|
|
94
|
+
settings.isDraftFeatureAdopted !== undefined && map.set("isDraftFeatureAdapted", settings.isDraftFeatureAdopted);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarchyV2 {
|
|
88
98
|
const pagesMap = getPagesYMap(doc);
|
|
89
99
|
const groupsMap = getGroupsYMap(doc);
|
|
100
|
+
const publishedSnapshotsMap = getPublishedSnapshotsYMap(doc);
|
|
90
101
|
|
|
91
102
|
// Read pages
|
|
92
103
|
const pages: DocumentationPageV2[] = [];
|
|
@@ -100,11 +111,22 @@ export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarc
|
|
|
100
111
|
groups.push(ElementGroup.parse(group));
|
|
101
112
|
});
|
|
102
113
|
|
|
114
|
+
// Read states
|
|
115
|
+
const publishedSnapshots: DesignElementSnapshot[] = [];
|
|
116
|
+
publishedSnapshotsMap.forEach(state => {
|
|
117
|
+
publishedSnapshots.push(DesignElementSnapshot.parse(state));
|
|
118
|
+
});
|
|
119
|
+
|
|
103
120
|
// Parse internalSettings
|
|
104
121
|
const internalSettings = parseDocumentationInternalSettings(doc);
|
|
105
122
|
|
|
106
123
|
// Map model onto client DTO
|
|
107
|
-
const hierarchy = documentationElementsToHierarchyDto(
|
|
124
|
+
const hierarchy = documentationElementsToHierarchyDto(
|
|
125
|
+
pages,
|
|
126
|
+
groups,
|
|
127
|
+
publishedSnapshots,
|
|
128
|
+
internalSettings.routingVersion ?? "2"
|
|
129
|
+
);
|
|
108
130
|
|
|
109
131
|
return hierarchy;
|
|
110
132
|
}
|
|
@@ -114,11 +136,15 @@ function parseDocumentationInternalSettings(doc: Y.Doc): DocumentationHierarchyS
|
|
|
114
136
|
|
|
115
137
|
const rawSettings: Record<keyof DocumentationHierarchySettings, any> = {
|
|
116
138
|
routingVersion: map.get("routingVersion"),
|
|
139
|
+
isDraftFeatureAdopted: map.get("isDraftFeatureAdapted") ?? false,
|
|
117
140
|
};
|
|
118
141
|
|
|
119
142
|
const settingsParseResult = DocumentationHierarchySettings.safeParse(rawSettings);
|
|
120
143
|
if (!settingsParseResult.success) {
|
|
121
|
-
return {
|
|
144
|
+
return {
|
|
145
|
+
routingVersion: "2",
|
|
146
|
+
isDraftFeatureAdopted: false,
|
|
147
|
+
};
|
|
122
148
|
}
|
|
123
149
|
|
|
124
150
|
return settingsParseResult.data;
|
|
@@ -139,3 +165,7 @@ function getGroupsYMap(doc: Y.Doc) {
|
|
|
139
165
|
function getInternalSettingsYMap(doc: Y.Doc) {
|
|
140
166
|
return doc.getMap<unknown>("documentationInternalSettings");
|
|
141
167
|
}
|
|
168
|
+
|
|
169
|
+
function getPublishedSnapshotsYMap(doc: Y.Doc) {
|
|
170
|
+
return doc.getMap<DesignElementSnapshot>("documentationPagePublishedSnapshots");
|
|
171
|
+
}
|