@supernova-studio/client 0.16.0 → 0.19.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 +14007 -6383
- package/dist/index.d.ts +14007 -6383
- package/dist/index.js +1188 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1219 -123
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/documentation/documentation-elements-to-hierarchy-v2-dto.ts +20 -0
- package/src/api/conversion/documentation/documentation-group-to-dto.ts +83 -0
- package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +54 -0
- package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +43 -0
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +57 -0
- package/src/api/conversion/documentation/index.ts +5 -0
- package/src/api/conversion/index.ts +1 -0
- package/src/api/dto/{design-system.ts → design-systems/design-system.ts} +6 -2
- package/src/api/dto/design-systems/index.ts +1 -0
- package/src/api/dto/documentation/index.ts +0 -0
- package/src/api/dto/elements/documentation/group-action.ts +70 -0
- package/src/api/dto/elements/documentation/group.ts +105 -0
- package/src/api/dto/elements/documentation/index.ts +5 -0
- package/src/api/dto/elements/documentation/page-actions-v2.ts +70 -0
- package/src/api/dto/{documentation-v1.ts → elements/documentation/page-v1.ts} +4 -0
- package/src/api/dto/elements/documentation/page-v2.ts +87 -0
- package/src/api/dto/elements/elements-action-v2.ts +61 -0
- package/src/api/dto/elements/index.ts +2 -0
- package/src/api/dto/index.ts +2 -3
- package/src/api/index.ts +2 -2
- package/src/api/payloads/documentation/block-definitions.ts +12 -0
- package/src/api/payloads/documentation/index.ts +1 -0
- package/src/api/payloads/index.ts +2 -0
- package/src/api/payloads/liveblocks/auth.ts +7 -0
- package/src/api/payloads/liveblocks/index.ts +1 -0
- package/src/index.ts +1 -2
- package/src/yjs/design-system-content/documentation-hierarchy.ts +100 -0
- package/src/{design-system-content → yjs/design-system-content}/item-configuration.ts +41 -10
- package/src/yjs/design-system-content/item-title.ts +0 -0
- package/src/yjs/docs-editor/model/block.ts +5 -0
- package/src/yjs/index.ts +2 -0
- package/src/api/dto/documentation-v2.ts +0 -28
- package/src/api/dto/documentation.ts +0 -29
- package/src/api/requests/elements/elements-transaction-v2.ts +0 -53
- package/src/api/requests/elements/index.ts +0 -1
- package/src/api/requests/index.ts +0 -2
- package/src/api/requests/post-liveblocks-auth.ts +0 -4
- package/src/api/responses/elements/elements-transaction-v2.ts +0 -11
- package/src/api/responses/elements/index.ts +0 -1
- package/src/api/responses/get-block-definitions.ts +0 -8
- package/src/api/responses/index.ts +0 -2
- package/src/design-system-content/documentation-hierarchy.ts +0 -74
- package/src/docs-editor/model/block.ts +0 -9
- /package/src/{design-system-content → yjs/design-system-content}/index.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/blocks-to-prosemirror.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/index.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/mock.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/model/index.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/model/page.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/prosemirror/index.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/prosemirror/schema.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/prosemirror/types.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/prosemirror-to-blocks.ts +0 -0
- /package/src/{docs-editor → yjs/docs-editor}/utils.ts +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
DTODocumentationPageCreateActionInputV2,
|
|
4
|
+
DTODocumentationPageCreateActionOutputV2,
|
|
5
|
+
DTODocumentationPageDeleteActionInputV2,
|
|
6
|
+
DTODocumentationPageDeleteActionOutputV2,
|
|
7
|
+
DTODocumentationPageDuplicateActionInputV2,
|
|
8
|
+
DTODocumentationPageDuplicateActionOutputV2,
|
|
9
|
+
DTODocumentationPageUpdateActionInputV2,
|
|
10
|
+
DTODocumentationPageUpdateActionOutputV2,
|
|
11
|
+
} from "./documentation/page-actions-v2";
|
|
12
|
+
import {
|
|
13
|
+
DTODocumentationGroupCreateActionInputV2,
|
|
14
|
+
DTODocumentationGroupCreateActionOutputV2,
|
|
15
|
+
DTODocumentationGroupDeleteActionInputV2,
|
|
16
|
+
DTODocumentationGroupDeleteActionOutputV2,
|
|
17
|
+
DTODocumentationGroupDuplicateActionInputV2,
|
|
18
|
+
DTODocumentationGroupDuplicateActionOutputV2,
|
|
19
|
+
DTODocumentationGroupUpdateActionInputV2,
|
|
20
|
+
DTODocumentationGroupUpdateActionOutputV2,
|
|
21
|
+
} from "./documentation/group-action";
|
|
22
|
+
|
|
23
|
+
//
|
|
24
|
+
// Read
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
export const DTOElementActionOutput = z.discriminatedUnion("type", [
|
|
28
|
+
// Documentation pages
|
|
29
|
+
DTODocumentationPageCreateActionOutputV2,
|
|
30
|
+
DTODocumentationPageUpdateActionOutputV2,
|
|
31
|
+
DTODocumentationPageDuplicateActionOutputV2,
|
|
32
|
+
DTODocumentationPageDeleteActionOutputV2,
|
|
33
|
+
|
|
34
|
+
// Documentation groups
|
|
35
|
+
DTODocumentationGroupCreateActionOutputV2,
|
|
36
|
+
DTODocumentationGroupUpdateActionOutputV2,
|
|
37
|
+
DTODocumentationGroupDuplicateActionOutputV2,
|
|
38
|
+
DTODocumentationGroupDeleteActionOutputV2,
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
export type DTOElementActionOutput = z.infer<typeof DTOElementActionOutput>;
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
// Write
|
|
45
|
+
//
|
|
46
|
+
|
|
47
|
+
export const DTOElementActionInput = z.discriminatedUnion("type", [
|
|
48
|
+
// Documentation pages
|
|
49
|
+
DTODocumentationPageCreateActionInputV2,
|
|
50
|
+
DTODocumentationPageUpdateActionInputV2,
|
|
51
|
+
DTODocumentationPageDuplicateActionInputV2,
|
|
52
|
+
DTODocumentationPageDeleteActionInputV2,
|
|
53
|
+
|
|
54
|
+
// Documentation groups
|
|
55
|
+
DTODocumentationGroupCreateActionInputV2,
|
|
56
|
+
DTODocumentationGroupUpdateActionInputV2,
|
|
57
|
+
DTODocumentationGroupDuplicateActionInputV2,
|
|
58
|
+
DTODocumentationGroupDeleteActionInputV2,
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
export type DTOElementActionInput = z.infer<typeof DTOElementActionInput>;
|
package/src/api/dto/index.ts
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PageBlockDefinition } from "@supernova-studio/model";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Read
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export const DTOGetBlockDefinitionsOutput = z.object({
|
|
9
|
+
definitions: z.array(PageBlockDefinition),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type DTOGetBlockDefinitionsOutput = z.infer<typeof DTOGetBlockDefinitionsOutput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./block-definitions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth";
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { DTODocumentationHierarchyV2, documentationElementsToHierarchyDto } from "../../api";
|
|
3
|
+
import { DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
4
|
+
|
|
5
|
+
// We store pages and groups in the same way they are stored in the database.
|
|
6
|
+
// This means that instead of groups having childrenIds array, all items have
|
|
7
|
+
// parentPersistentId property that points to the parent item in the tree.
|
|
8
|
+
// Upon read this gets converted to the format that client expects, which is
|
|
9
|
+
// ordered childrenIds array on all groups.
|
|
10
|
+
//
|
|
11
|
+
// The decision behind it is that we potentially want to get rid of childrenIds
|
|
12
|
+
// array entirely because it makes group updates more complicated. For now
|
|
13
|
+
// resolving it on fly is a tradeoff for not rewriting client to stop relying
|
|
14
|
+
// on children ids array.
|
|
15
|
+
|
|
16
|
+
//
|
|
17
|
+
// Types
|
|
18
|
+
//
|
|
19
|
+
|
|
20
|
+
type DocumentationHierarchyTransaction = {
|
|
21
|
+
pages: DocumentationPageV2[];
|
|
22
|
+
groups: ElementGroup[];
|
|
23
|
+
pageIdsToDelete: string[];
|
|
24
|
+
groupIdsToDelete: string[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//
|
|
28
|
+
// Init
|
|
29
|
+
//
|
|
30
|
+
|
|
31
|
+
export function documentationHierarchyToYjs(doc: Y.Doc, transaction: DocumentationHierarchyTransaction) {
|
|
32
|
+
doc.transact(trx => {
|
|
33
|
+
// Pages
|
|
34
|
+
const pagesMap = getPagesYMap(trx.doc);
|
|
35
|
+
|
|
36
|
+
transaction.pageIdsToDelete.forEach(pageId => {
|
|
37
|
+
pagesMap.delete(pageId);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
transaction.pages.forEach(page => {
|
|
41
|
+
// We remove header from the payload here because it will not get parsed anyway
|
|
42
|
+
const sanitizedPage: DocumentationPageV2 = {
|
|
43
|
+
...page,
|
|
44
|
+
data: {},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
pagesMap.set(page.id, sanitizedPage);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Groups
|
|
51
|
+
const groupsMap = getGroupsYMap(trx.doc);
|
|
52
|
+
|
|
53
|
+
transaction.groupIdsToDelete.forEach(id => {
|
|
54
|
+
groupsMap.delete(id);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
transaction.groups.forEach(group => {
|
|
58
|
+
// We remove header from the payload here because it will not get parsed anyway
|
|
59
|
+
const sanitizedGroup: ElementGroup = {
|
|
60
|
+
...group,
|
|
61
|
+
data: {},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
groupsMap.set(group.id, group);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return doc;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarchyV2 {
|
|
72
|
+
const pagesMap = getPagesYMap(doc);
|
|
73
|
+
const groupsMap = getGroupsYMap(doc);
|
|
74
|
+
|
|
75
|
+
const pages: DocumentationPageV2[] = [];
|
|
76
|
+
pagesMap.forEach(page => {
|
|
77
|
+
pages.push(DocumentationPageV2.parse(page));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const groups: ElementGroup[] = [];
|
|
81
|
+
groupsMap.forEach(group => {
|
|
82
|
+
groups.push(ElementGroup.parse(group));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const hierarchy = documentationElementsToHierarchyDto(pages, groups);
|
|
86
|
+
|
|
87
|
+
return hierarchy;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//
|
|
91
|
+
// Internals
|
|
92
|
+
//
|
|
93
|
+
|
|
94
|
+
function getPagesYMap(doc: Y.Doc) {
|
|
95
|
+
return doc.getMap<DocumentationPageV2>("documentationPages");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getGroupsYMap(doc: Y.Doc) {
|
|
99
|
+
return doc.getMap<ElementGroup>("documentationGroups");
|
|
100
|
+
}
|
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
import { DocumentationItemConfiguration, DocumentationItemHeader } from "@supernova-studio/model";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
//
|
|
6
|
+
// Types
|
|
7
|
+
//
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
+
export const DTODocumentationPageRoomHeaderData = z.object({
|
|
10
|
+
title: z.string(),
|
|
11
|
+
configuration: DocumentationItemConfiguration,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const DTODocumentationPageRoomHeaderDataUpdate = z.object({
|
|
15
|
+
title: z.string().optional(),
|
|
16
|
+
configuration: DocumentationItemConfiguration.omit({ header: true })
|
|
17
|
+
.extend({ header: DocumentationItemHeader.partial() })
|
|
18
|
+
.optional(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type DTODocumentationPageRoomHeaderData = z.infer<typeof DTODocumentationPageRoomHeaderData>;
|
|
22
|
+
export type DTODocumentationPageRoomHeaderDataUpdate = z.infer<typeof DTODocumentationPageRoomHeaderDataUpdate>;
|
|
23
|
+
|
|
24
|
+
//
|
|
25
|
+
// YJS Bindings
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
export function itemConfigurationToYjs(yDoc: Y.Doc, item: DTODocumentationPageRoomHeaderDataUpdate) {
|
|
9
29
|
yDoc.transact(trx => {
|
|
10
|
-
const
|
|
30
|
+
const { title, configuration } = item;
|
|
31
|
+
|
|
32
|
+
const header = configuration?.header;
|
|
33
|
+
|
|
34
|
+
if (title !== undefined) {
|
|
35
|
+
const headerYMap = trx.doc.getMap("itemTitle");
|
|
36
|
+
headerYMap.set("title", title);
|
|
37
|
+
}
|
|
11
38
|
|
|
12
39
|
if (header) {
|
|
13
40
|
const headerYMap = trx.doc.getMap("itemHeader");
|
|
@@ -25,15 +52,16 @@ export function itemConfigurationToYjs(yDoc: Y.Doc, item: UpdateDocumentationIte
|
|
|
25
52
|
header.minHeight !== undefined && headerYMap.set("minHeight", header.minHeight);
|
|
26
53
|
}
|
|
27
54
|
|
|
28
|
-
if (
|
|
55
|
+
if (configuration?.showSidebar !== undefined) {
|
|
29
56
|
const configYMap = trx.doc.getMap("itemConfiguration");
|
|
30
|
-
|
|
31
|
-
configYMap.set("showSidebar", item.showSidebar);
|
|
57
|
+
configYMap.set("showSidebar", configuration.showSidebar);
|
|
32
58
|
}
|
|
33
59
|
});
|
|
34
60
|
}
|
|
35
61
|
|
|
36
|
-
export function yjsToItemConfiguration(yDoc: Y.Doc):
|
|
62
|
+
export function yjsToItemConfiguration(yDoc: Y.Doc): DTODocumentationPageRoomHeaderData {
|
|
63
|
+
const title = yDoc.getMap("itemTitle").get("title");
|
|
64
|
+
|
|
37
65
|
const headerYMap = yDoc.getMap("itemHeader");
|
|
38
66
|
const rawHeader = {
|
|
39
67
|
description: headerYMap.get("description"),
|
|
@@ -53,5 +81,8 @@ export function yjsToItemConfiguration(yDoc: Y.Doc): DocumentationItemConfigurat
|
|
|
53
81
|
header: rawHeader,
|
|
54
82
|
};
|
|
55
83
|
|
|
56
|
-
return
|
|
84
|
+
return {
|
|
85
|
+
title: z.string().parse(title),
|
|
86
|
+
configuration: DocumentationItemConfiguration.parse(rawConfig),
|
|
87
|
+
};
|
|
57
88
|
}
|
|
File without changes
|
package/src/yjs/index.ts
ADDED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DocumentationPageV2 } from "@supernova-studio/model";
|
|
3
|
-
import { DocumentationGroupStructureDTO } from "./documentation";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Structure DTO is element properties minus element data (in other words data required
|
|
7
|
-
* to display the element in the left panel)
|
|
8
|
-
*/
|
|
9
|
-
export const DTODocumentationPageStructureV2 = DocumentationPageV2.omit({
|
|
10
|
-
data: true,
|
|
11
|
-
meta: true,
|
|
12
|
-
parentPersistentId: true,
|
|
13
|
-
sortOrder: true,
|
|
14
|
-
}).extend({
|
|
15
|
-
title: z.string(),
|
|
16
|
-
path: z.string(),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const DTODocumentationPageV2 = DTODocumentationPageStructureV2.extend(DocumentationPageV2.shape.data.shape);
|
|
20
|
-
|
|
21
|
-
export const DTODocumentationHierarchyV2 = z.object({
|
|
22
|
-
pages: z.array(DTODocumentationPageStructureV2),
|
|
23
|
-
groups: z.array(DocumentationGroupStructureDTO),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export type DTODocumentationPageV2 = z.infer<typeof DTODocumentationPageV2>;
|
|
27
|
-
export type DTODocumentationPageStructureV2 = z.infer<typeof DTODocumentationPageStructureV2>;
|
|
28
|
-
export type DTODocumentationHierarchyV2 = z.infer<typeof DTODocumentationHierarchyV2>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DocumentationGroupBehavior, DocumentationItemConfiguration, ElementGroup } from "@supernova-studio/model";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Structure DTO is element properties minus element data (in other words data required
|
|
6
|
-
* to display the element in the left panel)
|
|
7
|
-
*/
|
|
8
|
-
export const DocumentationGroupStructureDTO = ElementGroup.omit({
|
|
9
|
-
sortOrder: true,
|
|
10
|
-
parentPersistentId: true,
|
|
11
|
-
brandPersistentId: true,
|
|
12
|
-
meta: true,
|
|
13
|
-
childType: true,
|
|
14
|
-
data: true,
|
|
15
|
-
shortPersistentId: true,
|
|
16
|
-
}).extend({
|
|
17
|
-
title: z.string(),
|
|
18
|
-
isRoot: z.boolean(),
|
|
19
|
-
childrenIds: z.array(z.string()),
|
|
20
|
-
groupBehavior: DocumentationGroupBehavior,
|
|
21
|
-
shortPersistentId: z.string(),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const DocumentationGroupDTO = DocumentationGroupStructureDTO.extend({
|
|
25
|
-
configuration: DocumentationItemConfiguration,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export type DocumentationGroupStructureDTO = z.infer<typeof DocumentationGroupStructureDTO>;
|
|
29
|
-
export type DocumentationGroupDTO = z.infer<typeof DocumentationGroupDTO>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
import { DocumentationItemConfiguration } from "@supernova-studio/model";
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Documentation Pages
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
export const DTOCreateDocumentationPageInput = z.object({
|
|
10
|
-
parentPersistentId: z.string().uuid(),
|
|
11
|
-
persistentId: z.string().uuid(),
|
|
12
|
-
title: z.string(),
|
|
13
|
-
configuration: DocumentationItemConfiguration.optional(),
|
|
14
|
-
afterPersistentId: z.string().uuid().optional(),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const DTOUpdateDocumentationPageInput = z.object({
|
|
18
|
-
id: z.string(),
|
|
19
|
-
title: z.string().optional(),
|
|
20
|
-
configuration: DocumentationItemConfiguration.optional(),
|
|
21
|
-
parentPersistentId: z.string().optional(),
|
|
22
|
-
afterPersistentId: z.string().optional(),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const DTODuplicateDocumentationPageInput = z.object({
|
|
26
|
-
id: z.string(),
|
|
27
|
-
persistentId: z.string().uuid(),
|
|
28
|
-
parentPersistentId: z.string().uuid(),
|
|
29
|
-
afterPersistentId: z.string().uuid().optional(),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export const DTODocumentationElementsTransactionInput = z.object({
|
|
33
|
-
create: z.array(DTOCreateDocumentationPageInput).optional(),
|
|
34
|
-
update: z.array(DTOUpdateDocumentationPageInput).optional(),
|
|
35
|
-
duplicate: z.array(DTODuplicateDocumentationPageInput).optional(),
|
|
36
|
-
delete: z.array(z.string()).optional(),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export type DTOCreateDocumentationPageInput = z.infer<typeof DTOCreateDocumentationPageInput>;
|
|
40
|
-
export type DTOUpdateDocumentationPageInput = z.infer<typeof DTOUpdateDocumentationPageInput>;
|
|
41
|
-
export type DTODuplicateDocumentationPageInput = z.infer<typeof DTODuplicateDocumentationPageInput>;
|
|
42
|
-
|
|
43
|
-
export type DTODocumentationElementsTransactionInput = z.infer<typeof DTODocumentationElementsTransactionInput>;
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
// Transaction
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
export const DTOElementsTransactionInput = z.object({
|
|
50
|
-
documentationPages: DTODocumentationElementsTransactionInput,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export type DTOElementsTransactionInput = z.infer<typeof DTOElementsTransactionInput>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./elements-transaction-v2";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DTODocumentationPageV2 } from "../../dto";
|
|
2
|
-
|
|
3
|
-
export type DTODocumentationElementsTransactionOutput = {
|
|
4
|
-
created: DTODocumentationPageV2[];
|
|
5
|
-
updated: DTODocumentationPageV2[];
|
|
6
|
-
deleted: string[];
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type DTOElementsTransactionOutput = {
|
|
10
|
-
documentationPages: DTODocumentationElementsTransactionOutput;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./elements-transaction-v2";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PageBlockDefinition } from "@supernova-studio/model";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const GetBlockDefinitionsResponse = z.object({
|
|
5
|
-
definitions: z.array(PageBlockDefinition),
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export type GetBlockDefinitionsResponse = z.infer<typeof GetBlockDefinitionsResponse>;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { DTODocumentationHierarchyV2, DTODocumentationPageStructureV2 } from "../api/dto/documentation-v2";
|
|
3
|
-
import { DocumentationGroupStructureDTO } from "../api";
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Types
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
type ItemsToDelete = {
|
|
10
|
-
pagePersistentIdsToDelete: string[];
|
|
11
|
-
groupPersistentIdsToDelete: string[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
// Init
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
export function documentationHierarchyToYjs(
|
|
19
|
-
doc: Y.Doc,
|
|
20
|
-
documentationHierarchy: DTODocumentationHierarchyV2,
|
|
21
|
-
itemsToDelete: ItemsToDelete
|
|
22
|
-
) {
|
|
23
|
-
doc.transact(trx => {
|
|
24
|
-
const pagesMap = getPagesYMap(trx.doc);
|
|
25
|
-
itemsToDelete.pagePersistentIdsToDelete.forEach(persistentId => {
|
|
26
|
-
pagesMap.delete(persistentId);
|
|
27
|
-
});
|
|
28
|
-
documentationHierarchy.pages.forEach(page => {
|
|
29
|
-
pagesMap.set(page.persistentId, page);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const groupsMap = getGroupsYMap(trx.doc);
|
|
33
|
-
itemsToDelete.groupPersistentIdsToDelete.forEach(persistentId => {
|
|
34
|
-
groupsMap.delete(persistentId);
|
|
35
|
-
});
|
|
36
|
-
documentationHierarchy.groups.forEach(group => {
|
|
37
|
-
groupsMap.set(group.persistentId, group);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return doc;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarchyV2 {
|
|
45
|
-
const pagesMap = getPagesYMap(doc);
|
|
46
|
-
const groupsMap = getGroupsYMap(doc);
|
|
47
|
-
|
|
48
|
-
const pages: DTODocumentationPageStructureV2[] = [];
|
|
49
|
-
pagesMap.forEach(page => {
|
|
50
|
-
pages.push(DTODocumentationPageStructureV2.parse(page));
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const groups: DocumentationGroupStructureDTO[] = [];
|
|
54
|
-
groupsMap.forEach(group => {
|
|
55
|
-
groups.push(DocumentationGroupStructureDTO.parse(group));
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
pages,
|
|
60
|
-
groups,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
// Internals
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
function getPagesYMap(doc: Y.Doc) {
|
|
69
|
-
return doc.getMap<DTODocumentationPageStructureV2>("documentationPages");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getGroupsYMap(doc: Y.Doc) {
|
|
73
|
-
return doc.getMap<DocumentationGroupStructureDTO>("documentationGroups");
|
|
74
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|