@supernova-studio/client 0.13.0 → 0.15.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 +1988 -25
- package/dist/index.d.ts +1988 -25
- package/dist/index.js +39 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1172 -1157
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/dto/documentation-v2.ts +7 -7
- package/src/api/requests/elements/elements-transaction-v2.ts +53 -0
- package/src/api/requests/elements/index.ts +1 -0
- package/src/api/requests/index.ts +1 -1
- package/src/api/responses/elements/elements-transaction-v2.ts +11 -0
- package/src/api/responses/elements/index.ts +1 -0
- package/src/api/responses/index.ts +1 -0
- package/src/design-system-content/documentation-hierarchy.ts +43 -10
- package/src/design-system-content/item-configuration.ts +1 -1
- package/src/api/requests/post-bulk-doc-page-elements.ts +0 -47
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { DocumentationGroupStructureDTO } from "./documentation";
|
|
|
6
6
|
* Structure DTO is element properties minus element data (in other words data required
|
|
7
7
|
* to display the element in the left panel)
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const DTODocumentationPageStructureV2 = DocumentationPageV2.omit({
|
|
10
10
|
data: true,
|
|
11
11
|
meta: true,
|
|
12
12
|
parentPersistentId: true,
|
|
@@ -16,13 +16,13 @@ export const DocumentationPageStructureV2DTO = DocumentationPageV2.omit({
|
|
|
16
16
|
path: z.string(),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const DTODocumentationPageV2 = DTODocumentationPageStructureV2.extend(DocumentationPageV2.shape.data.shape);
|
|
20
20
|
|
|
21
|
-
export const
|
|
22
|
-
pages: z.array(
|
|
21
|
+
export const DTODocumentationHierarchyV2 = z.object({
|
|
22
|
+
pages: z.array(DTODocumentationPageStructureV2),
|
|
23
23
|
groups: z.array(DocumentationGroupStructureDTO),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export type
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
26
|
+
export type DTODocumentationPageV2 = z.infer<typeof DTODocumentationPageV2>;
|
|
27
|
+
export type DTODocumentationPageStructureV2 = z.infer<typeof DTODocumentationPageStructureV2>;
|
|
28
|
+
export type DTODocumentationHierarchyV2 = z.infer<typeof DTODocumentationHierarchyV2>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 DTODocumentationTransactionInput = 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 DTODocumentationTransactionInput = z.infer<typeof DTODocumentationTransactionInput>;
|
|
44
|
+
|
|
45
|
+
//
|
|
46
|
+
// Transaction
|
|
47
|
+
//
|
|
48
|
+
|
|
49
|
+
export const DTOElementsTransactionInput = z.object({
|
|
50
|
+
documentationPages: DTODocumentationTransactionInput,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type DTOElementsTransactionInput = z.infer<typeof DTOElementsTransactionInput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./elements-transaction-v2";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./elements";
|
|
2
2
|
export * from "./post-liveblocks-auth";
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./elements-transaction-v2";
|
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
import * as Y from "yjs";
|
|
2
|
-
import {
|
|
2
|
+
import { DTODocumentationHierarchyV2, DTODocumentationPageStructureV2 } from "../api/dto/documentation-v2";
|
|
3
3
|
import { DocumentationGroupStructureDTO } from "../api";
|
|
4
4
|
|
|
5
|
-
|
|
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
|
+
) {
|
|
6
23
|
doc.transact(trx => {
|
|
7
|
-
const pagesMap = trx.doc
|
|
24
|
+
const pagesMap = getPagesYMap(trx.doc);
|
|
25
|
+
itemsToDelete.pagePersistentIdsToDelete.forEach(persistentId => {
|
|
26
|
+
pagesMap.delete(persistentId);
|
|
27
|
+
});
|
|
8
28
|
documentationHierarchy.pages.forEach(page => {
|
|
9
29
|
pagesMap.set(page.persistentId, page);
|
|
10
30
|
});
|
|
11
31
|
|
|
12
|
-
const groupsMap = trx.doc
|
|
32
|
+
const groupsMap = getGroupsYMap(trx.doc);
|
|
33
|
+
itemsToDelete.groupPersistentIdsToDelete.forEach(persistentId => {
|
|
34
|
+
groupsMap.delete(persistentId);
|
|
35
|
+
});
|
|
13
36
|
documentationHierarchy.groups.forEach(group => {
|
|
14
37
|
groupsMap.set(group.persistentId, group);
|
|
15
38
|
});
|
|
@@ -18,13 +41,13 @@ export function documentationHierarchyToYjs(documentationHierarchy: Documentatio
|
|
|
18
41
|
return doc;
|
|
19
42
|
}
|
|
20
43
|
|
|
21
|
-
export function yjsToDocumentationHierarchy(doc: Y.Doc):
|
|
22
|
-
const pagesMap = doc
|
|
23
|
-
const groupsMap = doc
|
|
44
|
+
export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarchyV2 {
|
|
45
|
+
const pagesMap = getPagesYMap(doc);
|
|
46
|
+
const groupsMap = getGroupsYMap(doc);
|
|
24
47
|
|
|
25
|
-
const pages:
|
|
48
|
+
const pages: DTODocumentationPageStructureV2[] = [];
|
|
26
49
|
pagesMap.forEach(page => {
|
|
27
|
-
pages.push(
|
|
50
|
+
pages.push(DTODocumentationPageStructureV2.parse(page));
|
|
28
51
|
});
|
|
29
52
|
|
|
30
53
|
const groups: DocumentationGroupStructureDTO[] = [];
|
|
@@ -38,4 +61,14 @@ export function yjsToDocumentationHierarchy(doc: Y.Doc): DocumentationHierarchyV
|
|
|
38
61
|
};
|
|
39
62
|
}
|
|
40
63
|
|
|
41
|
-
//
|
|
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
|
+
}
|
|
@@ -5,7 +5,7 @@ type UpdateDocumentationItemConfiguration = Partial<DocumentationItemConfigurati
|
|
|
5
5
|
header?: Partial<DocumentationItemHeader>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export function itemConfigurationToYjs(
|
|
8
|
+
export function itemConfigurationToYjs(yDoc: Y.Doc, item: UpdateDocumentationItemConfiguration) {
|
|
9
9
|
yDoc.transact(trx => {
|
|
10
10
|
const header = item.header;
|
|
11
11
|
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
import { DocumentationItemConfiguration } from "@supernova-studio/model";
|
|
4
|
-
|
|
5
|
-
export const CreateBulkElementsInput = z.object({
|
|
6
|
-
parentPersistentId: z.string().uuid(),
|
|
7
|
-
persistentId: z.string().uuid(),
|
|
8
|
-
title: z.string(),
|
|
9
|
-
configuration: DocumentationItemConfiguration.optional(),
|
|
10
|
-
afterPersistentId: z.string().uuid().optional(),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export type CreateBulkElementsInput = z.infer<typeof CreateBulkElementsInput>;
|
|
14
|
-
|
|
15
|
-
export const UpdateBulkElementsInput = z.object({
|
|
16
|
-
id: z.string(),
|
|
17
|
-
title: z.string().optional(),
|
|
18
|
-
configuration: DocumentationItemConfiguration.optional(),
|
|
19
|
-
parentPersistentId: z.string().optional(),
|
|
20
|
-
afterPersistentId: z.string().optional(),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export type UpdateBulkElementsInput = z.infer<typeof UpdateBulkElementsInput>;
|
|
24
|
-
|
|
25
|
-
export const DeleteBulkElementsInput = z.array(z.string());
|
|
26
|
-
|
|
27
|
-
export type DeleteBulkElementsInput = z.infer<typeof DeleteBulkElementsInput>;
|
|
28
|
-
|
|
29
|
-
export const DuplicateBulkElementsInput = z.object({
|
|
30
|
-
id: z.string(),
|
|
31
|
-
persistentId: z.string().uuid(),
|
|
32
|
-
parentPersistentId: z.string().uuid(),
|
|
33
|
-
afterPersistentId: z.string().uuid().optional(),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export type DuplicateBulkElementsInput = z.infer<typeof DuplicateBulkElementsInput>;
|
|
37
|
-
|
|
38
|
-
export const BulkEditDocPageElementsInput = z.object({
|
|
39
|
-
documentationPages: z.object({
|
|
40
|
-
create: z.array(CreateBulkElementsInput).optional(),
|
|
41
|
-
update: z.array(UpdateBulkElementsInput).optional(),
|
|
42
|
-
delete: DeleteBulkElementsInput.optional(),
|
|
43
|
-
duplicate: z.array(DuplicateBulkElementsInput).optional(),
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export type BulkEditDocPageElementsInput = z.infer<typeof BulkEditDocPageElementsInput>;
|