@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
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { documentationPagesToStructureDTOV2 } from "./documentation-page-v2-to-dto";
|
|
2
|
+
import { elementGroupsToDocumentationGroupStructureDTO } from "./documentation-group-to-dto";
|
|
3
|
+
import { DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
|
|
4
|
+
import { DTODocumentationHierarchyV2 } from "../../dto";
|
|
5
|
+
|
|
6
|
+
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
7
|
+
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
8
|
+
// Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
|
|
9
|
+
//
|
|
10
|
+
// Please do not put more DTO conversion here unless you know what you're doing.
|
|
11
|
+
|
|
12
|
+
export function documentationElementsToHierarchyDto(
|
|
13
|
+
docPages: DocumentationPageV2[],
|
|
14
|
+
docGroups: ElementGroup[]
|
|
15
|
+
): DTODocumentationHierarchyV2 {
|
|
16
|
+
return {
|
|
17
|
+
pages: documentationPagesToStructureDTOV2(docPages, docGroups),
|
|
18
|
+
groups: elementGroupsToDocumentationGroupStructureDTO(docGroups, docPages),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { defaultDocumentationItemHeader, DocumentationPageV1, groupBy } from "@supernova-studio/model";
|
|
2
|
+
import { DocumentationPageV2 } from "@supernova-studio/model";
|
|
3
|
+
import { ElementGroup } from "@supernova-studio/model";
|
|
4
|
+
import { DTODocumentationGroup, DTODocumentationGroupStructure } from "../../dto";
|
|
5
|
+
|
|
6
|
+
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
7
|
+
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
8
|
+
// Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
|
|
9
|
+
//
|
|
10
|
+
// Please do not put more DTO conversion here unless you know what you're doing.
|
|
11
|
+
|
|
12
|
+
export function elementGroupsToDocumentationGroupStructureDTO(
|
|
13
|
+
groups: ElementGroup[],
|
|
14
|
+
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
15
|
+
): DTODocumentationGroupStructure[] {
|
|
16
|
+
const childrenIdsMap = calculateChildrenIdsMap(pages, groups);
|
|
17
|
+
|
|
18
|
+
return groups.map(group => elementGroupToDocumentationGroupStructureDTO(group, childrenIdsMap));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function elementGroupsToDocumentationGroupDTO(
|
|
22
|
+
groups: ElementGroup[],
|
|
23
|
+
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
24
|
+
): DTODocumentationGroup[] {
|
|
25
|
+
const childrenIdsMap = calculateChildrenIdsMap(pages, groups);
|
|
26
|
+
|
|
27
|
+
return groups.map(group => {
|
|
28
|
+
return {
|
|
29
|
+
...elementGroupToDocumentationGroupStructureDTO(group, childrenIdsMap),
|
|
30
|
+
configuration: group.data?.configuration ?? {
|
|
31
|
+
showSidebar: true,
|
|
32
|
+
header: defaultDocumentationItemHeader,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function elementGroupToDocumentationGroupStructureDTO(
|
|
39
|
+
group: ElementGroup,
|
|
40
|
+
childrenIdsMap: Map<string, string[]>
|
|
41
|
+
): DTODocumentationGroupStructure {
|
|
42
|
+
const childrenIds = childrenIdsMap.get(group.persistentId) ?? [];
|
|
43
|
+
|
|
44
|
+
if (!group.shortPersistentId) {
|
|
45
|
+
throw new Error(`Short persistent id is required for docs groups, group id: ${group.id}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
id: group.id,
|
|
50
|
+
designSystemVersionId: group.designSystemVersionId,
|
|
51
|
+
persistentId: group.persistentId,
|
|
52
|
+
slug: group.slug,
|
|
53
|
+
userSlug: group.userSlug,
|
|
54
|
+
createdAt: group.createdAt,
|
|
55
|
+
updatedAt: group.updatedAt,
|
|
56
|
+
title: group.meta.name,
|
|
57
|
+
childrenIds: childrenIds,
|
|
58
|
+
isRoot: !group.parentPersistentId,
|
|
59
|
+
groupBehavior: group.data?.behavior ?? "Group",
|
|
60
|
+
shortPersistentId: group.shortPersistentId,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function calculateChildrenIdsMap(
|
|
65
|
+
elements: { persistentId: string; parentPersistentId: string; sortOrder: number }[],
|
|
66
|
+
groups: ElementGroup[]
|
|
67
|
+
): Map<string, string[]> {
|
|
68
|
+
const byParentId = groupBy([...elements, ...groups], e => e.parentPersistentId);
|
|
69
|
+
|
|
70
|
+
const childrenIdsMap = new Map<string, string[]>();
|
|
71
|
+
|
|
72
|
+
for (const [parentPersistentId, children] of byParentId) {
|
|
73
|
+
if (!parentPersistentId) continue;
|
|
74
|
+
children.sort((lhs, rhs) => lhs.sortOrder - rhs.sortOrder);
|
|
75
|
+
|
|
76
|
+
childrenIdsMap.set(
|
|
77
|
+
parentPersistentId,
|
|
78
|
+
children.map(c => c.persistentId)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return childrenIdsMap;
|
|
83
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DocumentationPageV1, DocumentationPageV2, ElementGroup, slugify } from "@supernova-studio/model";
|
|
2
|
+
import { mapByUnique } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
5
|
+
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
6
|
+
// Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
|
|
7
|
+
//
|
|
8
|
+
// Please do not put more DTO conversion here unless you know what you're doing.
|
|
9
|
+
|
|
10
|
+
export function buildDocPagePublishPaths(
|
|
11
|
+
groups: ElementGroup[],
|
|
12
|
+
pages: (DocumentationPageV1 | DocumentationPageV2)[]
|
|
13
|
+
): Map<string, string> {
|
|
14
|
+
const groupPersistentIdToGroupMap = mapByUnique(groups, group => group.persistentId);
|
|
15
|
+
const result = new Map<string, string>();
|
|
16
|
+
|
|
17
|
+
for (const page of pages) {
|
|
18
|
+
const parentChain = calculateElementParentChain(page.parentPersistentId, groupPersistentIdToGroupMap);
|
|
19
|
+
|
|
20
|
+
let pathV1 = `${page.userSlug || page.slug}.html`;
|
|
21
|
+
let pathV2 = `${slugify(page.meta.name)}-${page.shortPersistentId}`;
|
|
22
|
+
|
|
23
|
+
for (const parent of parentChain) {
|
|
24
|
+
if (!parent.parentPersistentId) continue;
|
|
25
|
+
|
|
26
|
+
pathV1 = `${parent.userSlug || parent.slug}/${pathV1}`;
|
|
27
|
+
pathV2 = `${slugify(parent.meta.name)}/${pathV2}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
pathV1 = `/${pathV1}`;
|
|
31
|
+
pathV2 = `/${pathV2}`;
|
|
32
|
+
|
|
33
|
+
result.set(page.persistentId, pathV2);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function calculateElementParentChain(
|
|
40
|
+
elementParentPersistentId: string,
|
|
41
|
+
groupPersistentIdToGroupMap: Map<string, ElementGroup>
|
|
42
|
+
): ElementGroup[] {
|
|
43
|
+
const result: ElementGroup[] = [];
|
|
44
|
+
|
|
45
|
+
let parentId: string | undefined = elementParentPersistentId;
|
|
46
|
+
while (parentId) {
|
|
47
|
+
const parent = groupPersistentIdToGroupMap.get(parentId);
|
|
48
|
+
if (parent) result.push(parent);
|
|
49
|
+
|
|
50
|
+
parentId = parent?.parentPersistentId;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SupernovaException } from "@supernova-studio/model";
|
|
2
|
+
import { defaultDocumentationItemHeader, DocumentationPageV1 } from "@supernova-studio/model";
|
|
3
|
+
import { ElementGroup } from "@supernova-studio/model";
|
|
4
|
+
import { buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
|
|
5
|
+
import { DocumentationPageV1DTO } from "../../dto";
|
|
6
|
+
|
|
7
|
+
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
8
|
+
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
9
|
+
// Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
|
|
10
|
+
//
|
|
11
|
+
// Please do not put more DTO conversion here unless you know what you're doing.
|
|
12
|
+
|
|
13
|
+
export function documentationPagesToDTOV1(
|
|
14
|
+
pages: DocumentationPageV1[],
|
|
15
|
+
groups: ElementGroup[]
|
|
16
|
+
): DocumentationPageV1DTO[] {
|
|
17
|
+
const pathsMap = buildDocPagePublishPaths(groups, pages);
|
|
18
|
+
|
|
19
|
+
return pages.map(page => {
|
|
20
|
+
let path = pathsMap.get(page.persistentId);
|
|
21
|
+
if (!path) throw SupernovaException.conflict(`Path for page ${page.id} was not calculated`);
|
|
22
|
+
|
|
23
|
+
if (path.startsWith("/")) path = path.substring(1);
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
id: page.id,
|
|
27
|
+
designSystemVersionId: page.designSystemVersionId,
|
|
28
|
+
persistentId: page.persistentId,
|
|
29
|
+
shortPersistentId: page.shortPersistentId,
|
|
30
|
+
title: page.meta.name,
|
|
31
|
+
blocks: page.data.blocks,
|
|
32
|
+
slug: page.slug,
|
|
33
|
+
userSlug: page.userSlug,
|
|
34
|
+
configuration: page.data.configuration ?? {
|
|
35
|
+
showSidebar: true,
|
|
36
|
+
header: defaultDocumentationItemHeader,
|
|
37
|
+
},
|
|
38
|
+
createdAt: page.createdAt,
|
|
39
|
+
updatedAt: page.updatedAt,
|
|
40
|
+
path: path,
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defaultDocumentationItemHeader, DocumentationPageV2 } from "@supernova-studio/model";
|
|
2
|
+
import { ElementGroup } from "@supernova-studio/model";
|
|
3
|
+
import { buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
|
|
4
|
+
import { DTODocumentationPageStructureV2, DTODocumentationPageV2 } from "../../dto";
|
|
5
|
+
|
|
6
|
+
// The fact that DTO conversion is located here instead of main backend code is due to the fact
|
|
7
|
+
// that we store page and group data in YJS documents in the same way as they are stored in the database.
|
|
8
|
+
// Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
|
|
9
|
+
//
|
|
10
|
+
// Please do not put more DTO conversion here unless you know what you're doing.
|
|
11
|
+
|
|
12
|
+
export function documentationPagesToStructureDTOV2(
|
|
13
|
+
pages: DocumentationPageV2[],
|
|
14
|
+
groups: ElementGroup[]
|
|
15
|
+
): DTODocumentationPageStructureV2[] {
|
|
16
|
+
const pathsMap = buildDocPagePublishPaths(groups, pages);
|
|
17
|
+
return pages.map(page => documentationPageToStructureDTOV2(page, pathsMap));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function documentationPagesToDTOV2(
|
|
21
|
+
pages: DocumentationPageV2[],
|
|
22
|
+
groups: ElementGroup[]
|
|
23
|
+
): DTODocumentationPageV2[] {
|
|
24
|
+
const pathsMap = buildDocPagePublishPaths(groups, pages);
|
|
25
|
+
return pages.map(page => {
|
|
26
|
+
return {
|
|
27
|
+
...documentationPageToStructureDTOV2(page, pathsMap),
|
|
28
|
+
configuration: page.data.configuration ?? {
|
|
29
|
+
showSidebar: true,
|
|
30
|
+
header: defaultDocumentationItemHeader,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function documentationPageToStructureDTOV2(
|
|
37
|
+
page: DocumentationPageV2,
|
|
38
|
+
pagePathMap: Map<string, string>
|
|
39
|
+
): DTODocumentationPageStructureV2 {
|
|
40
|
+
let path = pagePathMap.get(page.persistentId);
|
|
41
|
+
if (!path) throw new Error(`Path for page ${page.id} was not calculated`);
|
|
42
|
+
|
|
43
|
+
if (path.startsWith("/")) path = path.substring(1);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
id: page.id,
|
|
47
|
+
designSystemVersionId: page.designSystemVersionId,
|
|
48
|
+
persistentId: page.persistentId,
|
|
49
|
+
shortPersistentId: page.shortPersistentId,
|
|
50
|
+
title: page.meta.name,
|
|
51
|
+
slug: page.slug,
|
|
52
|
+
userSlug: page.userSlug,
|
|
53
|
+
createdAt: page.createdAt,
|
|
54
|
+
updatedAt: page.updatedAt,
|
|
55
|
+
path: path,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./documentation";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { DesignSystem, ObjectMeta } from "@supernova-studio/model";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
//
|
|
5
|
+
// Read
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export const DTODesignSystem = DesignSystem.omit({
|
|
5
9
|
name: true,
|
|
6
10
|
description: true,
|
|
7
11
|
}).extend({
|
|
8
12
|
meta: ObjectMeta,
|
|
9
13
|
});
|
|
10
14
|
|
|
11
|
-
export type
|
|
15
|
+
export type DTODesignSystem = z.infer<typeof DTODesignSystem>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./design-system";
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
DTOCreateDocumentationGroupInput,
|
|
4
|
+
DTODeleteDocumentationGroupInput,
|
|
5
|
+
DTODocumentationGroup,
|
|
6
|
+
DTODuplicateDocumentationGroupInput,
|
|
7
|
+
DTOUpdateDocumentationGroupInput,
|
|
8
|
+
} from "./group";
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
// Read
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
const SuccessPayload = z.object({
|
|
15
|
+
success: z.literal(true),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const DTODocumentationGroupCreateActionOutputV2 = z.object({
|
|
19
|
+
type: z.literal("DocumentationGroupCreate"),
|
|
20
|
+
output: SuccessPayload,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const DTODocumentationGroupUpdateActionOutputV2 = z.object({
|
|
24
|
+
type: z.literal("DocumentationGroupUpdate"),
|
|
25
|
+
output: SuccessPayload,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DTODocumentationGroupDuplicateActionOutputV2 = z.object({
|
|
29
|
+
type: z.literal("DocumentationGroupDuplicate"),
|
|
30
|
+
output: SuccessPayload,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const DTODocumentationGroupDeleteActionOutputV2 = z.object({
|
|
34
|
+
type: z.literal("DocumentationGroupDelete"),
|
|
35
|
+
output: SuccessPayload,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type DTODocumentationGroupCreateActionOutputV2 = z.infer<typeof DTODocumentationGroupCreateActionOutputV2>;
|
|
39
|
+
export type DTODocumentationGroupUpdateActionOutputV2 = z.infer<typeof DTODocumentationGroupUpdateActionOutputV2>;
|
|
40
|
+
export type DTODocumentationGroupDuplicateActionOutputV2 = z.infer<typeof DTODocumentationGroupDuplicateActionOutputV2>;
|
|
41
|
+
export type DTODocumentationGroupDeleteActionOutputV2 = z.infer<typeof DTODocumentationGroupDeleteActionOutputV2>;
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
// Write
|
|
45
|
+
//
|
|
46
|
+
|
|
47
|
+
export const DTODocumentationGroupCreateActionInputV2 = z.object({
|
|
48
|
+
type: z.literal("DocumentationGroupCreate"),
|
|
49
|
+
input: DTOCreateDocumentationGroupInput,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const DTODocumentationGroupUpdateActionInputV2 = z.object({
|
|
53
|
+
type: z.literal("DocumentationGroupUpdate"),
|
|
54
|
+
input: DTOUpdateDocumentationGroupInput,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const DTODocumentationGroupDuplicateActionInputV2 = z.object({
|
|
58
|
+
type: z.literal("DocumentationGroupDuplicate"),
|
|
59
|
+
input: DTODuplicateDocumentationGroupInput,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const DTODocumentationGroupDeleteActionInputV2 = z.object({
|
|
63
|
+
type: z.literal("DocumentationGroupDelete"),
|
|
64
|
+
input: DTODeleteDocumentationGroupInput,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export type DTODocumentationGroupCreateActionInputV2 = z.infer<typeof DTODocumentationGroupCreateActionInputV2>;
|
|
68
|
+
export type DTODocumentationGroupUpdateActionInputV2 = z.infer<typeof DTODocumentationGroupUpdateActionInputV2>;
|
|
69
|
+
export type DTODocumentationGroupDuplicateActionInputV2 = z.infer<typeof DTODocumentationGroupDuplicateActionInputV2>;
|
|
70
|
+
export type DTODocumentationGroupDeleteActionInputV2 = z.infer<typeof DTODocumentationGroupDeleteActionInputV2>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DocumentationGroupBehavior, DocumentationItemConfiguration, ElementGroup } from "@supernova-studio/model";
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Read
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Structure DTO is element properties minus element data (in other words data required
|
|
10
|
+
* to display the element in the left panel)
|
|
11
|
+
*/
|
|
12
|
+
export const DTODocumentationGroupStructure = ElementGroup.omit({
|
|
13
|
+
sortOrder: true,
|
|
14
|
+
parentPersistentId: true,
|
|
15
|
+
brandPersistentId: true,
|
|
16
|
+
meta: true,
|
|
17
|
+
childType: true,
|
|
18
|
+
data: true,
|
|
19
|
+
shortPersistentId: true,
|
|
20
|
+
}).extend({
|
|
21
|
+
title: z.string(),
|
|
22
|
+
isRoot: z.boolean(),
|
|
23
|
+
childrenIds: z.array(z.string()),
|
|
24
|
+
groupBehavior: DocumentationGroupBehavior,
|
|
25
|
+
shortPersistentId: z.string(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DTODocumentationGroup = DTODocumentationGroupStructure.extend({
|
|
29
|
+
configuration: DocumentationItemConfiguration,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type DTODocumentationGroupStructure = z.infer<typeof DTODocumentationGroupStructure>;
|
|
33
|
+
export type DTODocumentationGroup = z.infer<typeof DTODocumentationGroup>;
|
|
34
|
+
|
|
35
|
+
//
|
|
36
|
+
// Write
|
|
37
|
+
//
|
|
38
|
+
|
|
39
|
+
export const DTOCreateDocumentationGroupInput = z.object({
|
|
40
|
+
// Identifier
|
|
41
|
+
persistentId: z.string().uuid(),
|
|
42
|
+
|
|
43
|
+
// Group properties
|
|
44
|
+
title: z.string(),
|
|
45
|
+
configuration: DocumentationItemConfiguration.optional(),
|
|
46
|
+
groupBehavior: DocumentationGroupBehavior,
|
|
47
|
+
|
|
48
|
+
// Group placement properties
|
|
49
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
50
|
+
parentPersistentId: z.string().uuid(),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const DTOUpdateDocumentationGroupInput = z.object({
|
|
54
|
+
// Identifier of the group to update
|
|
55
|
+
id: z.string().uuid(),
|
|
56
|
+
|
|
57
|
+
// Group properties
|
|
58
|
+
title: z.string().optional(),
|
|
59
|
+
configuration: DocumentationItemConfiguration.optional(),
|
|
60
|
+
|
|
61
|
+
// Group placement properties
|
|
62
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
63
|
+
parentPersistentId: z.string().uuid().optional(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const DTODuplicateDocumentationGroupInput = z.object({
|
|
67
|
+
// Identifier of the group to duplicate from
|
|
68
|
+
id: z.string(),
|
|
69
|
+
|
|
70
|
+
// New group persistent id
|
|
71
|
+
persistentId: z.string().uuid(),
|
|
72
|
+
|
|
73
|
+
// Group placement properties
|
|
74
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
75
|
+
parentPersistentId: z.string().uuid(),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const DTOCreateDocumentationTabGroupInput = z.object({
|
|
79
|
+
// New group persistent id
|
|
80
|
+
persistentId: z.string().uuid(),
|
|
81
|
+
|
|
82
|
+
// Page that will become first tab of the tab group
|
|
83
|
+
fromPageId: z.string(),
|
|
84
|
+
tabName: z.string(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const DTODeleteDocumentationTabGroupInput = z.object({
|
|
88
|
+
// Deleted group id
|
|
89
|
+
id: z.string(),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const DTODeleteDocumentationGroupInput = z.object({
|
|
93
|
+
// Identifier
|
|
94
|
+
id: z.string(),
|
|
95
|
+
|
|
96
|
+
// Deletion options
|
|
97
|
+
deleteSubtree: z.boolean().default(false),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export type DTOCreateDocumentationGroupInput = z.infer<typeof DTOCreateDocumentationGroupInput>;
|
|
101
|
+
export type DTOUpdateDocumentationGroupInput = z.infer<typeof DTOUpdateDocumentationGroupInput>;
|
|
102
|
+
export type DTODuplicateDocumentationGroupInput = z.infer<typeof DTODuplicateDocumentationGroupInput>;
|
|
103
|
+
export type DTOCreateDocumentationTabGroupInput = z.infer<typeof DTOCreateDocumentationTabGroupInput>;
|
|
104
|
+
export type DTODeleteDocumentationTabGroupInput = z.infer<typeof DTODeleteDocumentationTabGroupInput>;
|
|
105
|
+
export type DTODeleteDocumentationGroupInput = z.infer<typeof DTODeleteDocumentationGroupInput>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
DTOCreateDocumentationPageInputV2,
|
|
4
|
+
DTODeleteDocumentationPageInputV2,
|
|
5
|
+
DTODocumentationPageV2,
|
|
6
|
+
DTODuplicateDocumentationPageInputV2,
|
|
7
|
+
DTOUpdateDocumentationPageInputV2,
|
|
8
|
+
} from "./page-v2";
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
// Read
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
const SuccessPayload = z.object({
|
|
15
|
+
success: z.literal(true),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const DTODocumentationPageCreateActionOutputV2 = z.object({
|
|
19
|
+
type: z.literal("DocumentationPageCreate"),
|
|
20
|
+
output: SuccessPayload,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const DTODocumentationPageUpdateActionOutputV2 = z.object({
|
|
24
|
+
type: z.literal("DocumentationPageUpdate"),
|
|
25
|
+
output: SuccessPayload,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DTODocumentationPageDuplicateActionOutputV2 = z.object({
|
|
29
|
+
type: z.literal("DocumentationPageDuplicate"),
|
|
30
|
+
output: SuccessPayload,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const DTODocumentationPageDeleteActionOutputV2 = z.object({
|
|
34
|
+
type: z.literal("DocumentationPageDelete"),
|
|
35
|
+
output: SuccessPayload,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type DTODocumentationPageCreateActionOutputV2 = z.infer<typeof DTODocumentationPageCreateActionOutputV2>;
|
|
39
|
+
export type DTODocumentationPageUpdateActionOutputV2 = z.infer<typeof DTODocumentationPageUpdateActionOutputV2>;
|
|
40
|
+
export type DTODocumentationPageDuplicateActionOutputV2 = z.infer<typeof DTODocumentationPageDuplicateActionOutputV2>;
|
|
41
|
+
export type DTODocumentationPageDeleteActionOutputV2 = z.infer<typeof DTODocumentationPageDeleteActionOutputV2>;
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
// Write
|
|
45
|
+
//
|
|
46
|
+
|
|
47
|
+
export const DTODocumentationPageCreateActionInputV2 = z.object({
|
|
48
|
+
type: z.literal("DocumentationPageCreate"),
|
|
49
|
+
input: DTOCreateDocumentationPageInputV2,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const DTODocumentationPageUpdateActionInputV2 = z.object({
|
|
53
|
+
type: z.literal("DocumentationPageUpdate"),
|
|
54
|
+
input: DTOUpdateDocumentationPageInputV2,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const DTODocumentationPageDuplicateActionInputV2 = z.object({
|
|
58
|
+
type: z.literal("DocumentationPageDuplicate"),
|
|
59
|
+
input: DTODuplicateDocumentationPageInputV2,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const DTODocumentationPageDeleteActionInputV2 = z.object({
|
|
63
|
+
type: z.literal("DocumentationPageDelete"),
|
|
64
|
+
input: DTODeleteDocumentationPageInputV2,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export type DTODocumentationPageCreateActionInputV2 = z.infer<typeof DTODocumentationPageCreateActionInputV2>;
|
|
68
|
+
export type DTODocumentationPageUpdateActionInputV2 = z.infer<typeof DTODocumentationPageUpdateActionInputV2>;
|
|
69
|
+
export type DTODocumentationPageDuplicateActionInputV2 = z.infer<typeof DTODocumentationPageDuplicateActionInputV2>;
|
|
70
|
+
export type DTODocumentationPageDeleteActionInputV2 = z.infer<typeof DTODocumentationPageDeleteActionInputV2>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DocumentationItemConfiguration as DocumentationItemConfigurationV2 } from "@supernova-studio/model";
|
|
3
|
+
import { DocumentationPageV2 } from "@supernova-studio/model";
|
|
4
|
+
import { DTODocumentationGroupStructure } from "./group";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// Read
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Structure DTO is element properties minus element data (in other words data required
|
|
12
|
+
* to display the element in the left panel)
|
|
13
|
+
*/
|
|
14
|
+
export const DTODocumentationPageStructureV2 = DocumentationPageV2.omit({
|
|
15
|
+
data: true,
|
|
16
|
+
meta: true,
|
|
17
|
+
parentPersistentId: true,
|
|
18
|
+
sortOrder: true,
|
|
19
|
+
}).extend({
|
|
20
|
+
title: z.string(),
|
|
21
|
+
path: z.string(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const DTODocumentationPageV2 = DTODocumentationPageStructureV2.extend({
|
|
25
|
+
configuration: DocumentationItemConfigurationV2,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DTODocumentationHierarchyV2 = z.object({
|
|
29
|
+
pages: z.array(DTODocumentationPageStructureV2),
|
|
30
|
+
groups: z.array(DTODocumentationGroupStructure),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type DTODocumentationPageV2 = z.infer<typeof DTODocumentationPageV2>;
|
|
34
|
+
export type DTODocumentationPageStructureV2 = z.infer<typeof DTODocumentationPageStructureV2>;
|
|
35
|
+
export type DTODocumentationHierarchyV2 = z.infer<typeof DTODocumentationHierarchyV2>;
|
|
36
|
+
|
|
37
|
+
//
|
|
38
|
+
// Write
|
|
39
|
+
//
|
|
40
|
+
|
|
41
|
+
export const DTOCreateDocumentationPageInputV2 = z.object({
|
|
42
|
+
// Identifier
|
|
43
|
+
persistentId: z.string().uuid(),
|
|
44
|
+
|
|
45
|
+
// Page properties
|
|
46
|
+
title: z.string(),
|
|
47
|
+
configuration: DocumentationItemConfigurationV2.optional(),
|
|
48
|
+
|
|
49
|
+
// Page placement properties
|
|
50
|
+
parentPersistentId: z.string().uuid(),
|
|
51
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const DTOUpdateDocumentationPageInputV2 = z.object({
|
|
55
|
+
// Identifier of the group to update
|
|
56
|
+
id: z.string(),
|
|
57
|
+
|
|
58
|
+
// Page properties
|
|
59
|
+
title: z.string().optional(),
|
|
60
|
+
configuration: DocumentationItemConfigurationV2.optional(),
|
|
61
|
+
|
|
62
|
+
// Page placement properties
|
|
63
|
+
parentPersistentId: z.string().optional(),
|
|
64
|
+
afterPersistentId: z.string().optional(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const DTODuplicateDocumentationPageInputV2 = z.object({
|
|
68
|
+
// Identifier of the page to duplicate from
|
|
69
|
+
id: z.string(),
|
|
70
|
+
|
|
71
|
+
// New page persistent id
|
|
72
|
+
persistentId: z.string().uuid(),
|
|
73
|
+
|
|
74
|
+
// Page placement properties
|
|
75
|
+
parentPersistentId: z.string().uuid(),
|
|
76
|
+
afterPersistentId: z.string().uuid().optional(),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const DTODeleteDocumentationPageInputV2 = z.object({
|
|
80
|
+
// Identifier
|
|
81
|
+
id: z.string(),
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export type DTOCreateDocumentationPageInputV2 = z.infer<typeof DTOCreateDocumentationPageInputV2>;
|
|
85
|
+
export type DTOUpdateDocumentationPageInputV2 = z.infer<typeof DTOUpdateDocumentationPageInputV2>;
|
|
86
|
+
export type DTODuplicateDocumentationPageInputV2 = z.infer<typeof DTODuplicateDocumentationPageInputV2>;
|
|
87
|
+
export type DTODeleteDocumentationPageInputV2 = z.infer<typeof DTODeleteDocumentationPageInputV2>;
|