@supernova-studio/client 0.58.20 → 0.58.22
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 +104 -4
- package/dist/index.d.ts +104 -4
- package/dist/index.js +57 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +14 -8
- package/src/api/dto/elements/documentation/page-v2.ts +3 -0
- package/src/yjs/version-room/base.ts +15 -0
- package/src/yjs/version-room/frontend.ts +3 -1
package/package.json
CHANGED
|
@@ -15,25 +15,28 @@ import { applyPrivacyConfigurationToNestedItems, buildDocPagePublishPaths } from
|
|
|
15
15
|
export function documentationPageToDTOV2(
|
|
16
16
|
page: DocumentationPageV2,
|
|
17
17
|
groups: ElementGroup[],
|
|
18
|
-
routingVersion: string
|
|
18
|
+
routingVersion: string,
|
|
19
|
+
pageLiveblocksRoomIdMap: Map<string, string>
|
|
19
20
|
): DTODocumentationPageV2 {
|
|
20
21
|
const pathsMap = buildDocPagePublishPaths(groups, [page], routingVersion);
|
|
21
|
-
return _documentationPageToDTOV2(page, pathsMap);
|
|
22
|
+
return _documentationPageToDTOV2(page, pathsMap, pageLiveblocksRoomIdMap);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function documentationPagesToDTOV2(
|
|
25
26
|
pages: DocumentationPageV2[],
|
|
26
27
|
groups: ElementGroup[],
|
|
27
|
-
routingVersion: string
|
|
28
|
+
routingVersion: string,
|
|
29
|
+
pageLiveblocksRoomIdMap: Map<string, string>
|
|
28
30
|
): DTODocumentationPageV2[] {
|
|
29
31
|
const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
|
|
30
|
-
return pages.map(page => _documentationPageToDTOV2(page, pathsMap));
|
|
32
|
+
return pages.map(page => _documentationPageToDTOV2(page, pathsMap, pageLiveblocksRoomIdMap));
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export function documentationPagesFixedConfigurationToDTOV2(
|
|
34
36
|
pages: DocumentationPageV2[],
|
|
35
37
|
groups: ElementGroup[],
|
|
36
|
-
routingVersion: string
|
|
38
|
+
routingVersion: string,
|
|
39
|
+
pageLiveblocksRoomIdMap: Map<string, string>
|
|
37
40
|
): DTODocumentationPageV2[] {
|
|
38
41
|
const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
|
|
39
42
|
|
|
@@ -43,18 +46,20 @@ export function documentationPagesFixedConfigurationToDTOV2(
|
|
|
43
46
|
DocumentationItemConfigurationV2
|
|
44
47
|
>(pages, groups, getDtoDefaultItemConfigurationV2);
|
|
45
48
|
|
|
46
|
-
return fixedPages.map(page => _documentationPageToDTOV2(page, pathsMap));
|
|
49
|
+
return fixedPages.map(page => _documentationPageToDTOV2(page, pathsMap, pageLiveblocksRoomIdMap));
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
function _documentationPageToDTOV2(
|
|
50
53
|
page: DocumentationPageV2,
|
|
51
|
-
pagePathMap: Map<string, string
|
|
54
|
+
pagePathMap: Map<string, string>,
|
|
55
|
+
pageLiveblocksRoomIdMap: Map<string, string>
|
|
52
56
|
): DTODocumentationPageV2 {
|
|
53
57
|
let path = pagePathMap.get(page.persistentId);
|
|
54
58
|
if (!path) throw new Error(`Path for page ${page.id} was not calculated`);
|
|
55
|
-
|
|
56
59
|
if (path.startsWith("/")) path = path.substring(1);
|
|
57
60
|
|
|
61
|
+
const liveblocksRoomId = pageLiveblocksRoomIdMap.get(page.persistentId);
|
|
62
|
+
|
|
58
63
|
return {
|
|
59
64
|
id: page.id,
|
|
60
65
|
designSystemVersionId: page.designSystemVersionId,
|
|
@@ -68,5 +73,6 @@ function _documentationPageToDTOV2(
|
|
|
68
73
|
updatedAt: page.updatedAt,
|
|
69
74
|
path: path,
|
|
70
75
|
type: "Page",
|
|
76
|
+
...(liveblocksRoomId && { liveblocksRoomId }),
|
|
71
77
|
};
|
|
72
78
|
}
|
|
@@ -37,6 +37,9 @@ export const DTODocumentationPageV2 = z.object({
|
|
|
37
37
|
/** Defines the approval state of the documentation page */
|
|
38
38
|
approvalState: DTODocumentationPageApprovalState.optional(),
|
|
39
39
|
|
|
40
|
+
/** Id of the page document room */
|
|
41
|
+
liveblocksRoomId: z.string().optional(),
|
|
42
|
+
|
|
40
43
|
// Backward compatibility
|
|
41
44
|
type: z.literal("Page"),
|
|
42
45
|
});
|
|
@@ -183,6 +183,21 @@ export class VersionRoomBaseYDoc {
|
|
|
183
183
|
return result;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
getDocumentationPageLiveblocksRoomIds(): Record<string, string> {
|
|
187
|
+
const map = this.documentationPageLiveblocksRoomIdsYMap;
|
|
188
|
+
|
|
189
|
+
const result: Record<string, string> = {};
|
|
190
|
+
map.forEach((hash, key) => {
|
|
191
|
+
if (typeof hash === "string") result[key] = hash;
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private get documentationPageLiveblocksRoomIdsYMap() {
|
|
198
|
+
return this.yDoc.getMap<string>("documentationPageLiveblocksRoomIds");
|
|
199
|
+
}
|
|
200
|
+
|
|
186
201
|
updateDocumentationPageContentHashes(hashes: Record<string, string>) {
|
|
187
202
|
const map = this.documentationPageContentHashesYMap;
|
|
188
203
|
Object.entries(hashes).forEach(([key, hash]) => map.set(key, hash));
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
mapByUnique,
|
|
10
10
|
pickLatestGroupSnapshots,
|
|
11
11
|
pickLatestPageSnapshots,
|
|
12
|
+
recordToMap,
|
|
12
13
|
} from "@supernova-studio/model";
|
|
13
14
|
import * as Y from "yjs";
|
|
14
15
|
import {
|
|
@@ -54,6 +55,7 @@ export class FrontendVersionRoomYDoc {
|
|
|
54
55
|
const groups = doc.getGroups();
|
|
55
56
|
const pageSnapshots = doc.getPageSnapshots();
|
|
56
57
|
const groupSnapshots = doc.getGroupSnapshots();
|
|
58
|
+
const liveblocksRoomIds = recordToMap(doc.getDocumentationPageLiveblocksRoomIds());
|
|
57
59
|
|
|
58
60
|
if (includeDeletedContent) {
|
|
59
61
|
pages.push(...this.getDeletedPages(pages, pageSnapshots));
|
|
@@ -63,7 +65,7 @@ export class FrontendVersionRoomYDoc {
|
|
|
63
65
|
const settings = doc.getDocumentationInternalSettings();
|
|
64
66
|
|
|
65
67
|
// Convert pages to DTOs
|
|
66
|
-
const pageDTOs = documentationPagesToDTOV2(pages, groups, settings.routingVersion);
|
|
68
|
+
const pageDTOs = documentationPagesToDTOV2(pages, groups, settings.routingVersion, liveblocksRoomIds);
|
|
67
69
|
const groupDTOs = elementGroupsToDocumentationGroupDTOV2(groups, pages);
|
|
68
70
|
|
|
69
71
|
// If draft feature is not yet adopted, no snapshot-based features should not be provided
|