@supernova-studio/client 0.48.7 → 1.0.1

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.
Files changed (121) hide show
  1. package/dist/index.d.mts +1166 -44514
  2. package/dist/index.mjs +4583 -9906
  3. package/dist/index.mjs.map +1 -1
  4. package/package.json +11 -30
  5. package/dist/index.d.ts +0 -44757
  6. package/dist/index.js +0 -11011
  7. package/dist/index.js.map +0 -1
  8. package/src/api/conversion/documentation/documentation-group-v1-to-dto.ts +0 -114
  9. package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +0 -92
  10. package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +0 -52
  11. package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +0 -34
  12. package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +0 -132
  13. package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +0 -69
  14. package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +0 -72
  15. package/src/api/conversion/documentation/index.ts +0 -7
  16. package/src/api/conversion/export/index.ts +0 -1
  17. package/src/api/conversion/export/pipeline.ts +0 -24
  18. package/src/api/conversion/index.ts +0 -3
  19. package/src/api/conversion/integrations/git.ts +0 -37
  20. package/src/api/conversion/integrations/index.ts +0 -2
  21. package/src/api/conversion/integrations/integration.ts +0 -37
  22. package/src/api/dto/design-systems/brand.ts +0 -22
  23. package/src/api/dto/design-systems/data-source.ts +0 -122
  24. package/src/api/dto/design-systems/design-system.ts +0 -18
  25. package/src/api/dto/design-systems/elements-diff.ts +0 -14
  26. package/src/api/dto/design-systems/exporter-property.ts +0 -8
  27. package/src/api/dto/design-systems/index.ts +0 -7
  28. package/src/api/dto/design-systems/version.ts +0 -57
  29. package/src/api/dto/design-systems/view.ts +0 -45
  30. package/src/api/dto/documentation/anchor.ts +0 -15
  31. package/src/api/dto/documentation/block-definition.ts +0 -28
  32. package/src/api/dto/documentation/block.ts +0 -6
  33. package/src/api/dto/documentation/documentation-page-snapshot.ts +0 -18
  34. package/src/api/dto/documentation/index.ts +0 -6
  35. package/src/api/dto/documentation/link-preview.ts +0 -23
  36. package/src/api/dto/documentation/publish.ts +0 -23
  37. package/src/api/dto/elements/documentation/draft-state.ts +0 -35
  38. package/src/api/dto/elements/documentation/group-action.ts +0 -108
  39. package/src/api/dto/elements/documentation/group-v1.ts +0 -35
  40. package/src/api/dto/elements/documentation/group-v2.ts +0 -109
  41. package/src/api/dto/elements/documentation/hierarchy.ts +0 -36
  42. package/src/api/dto/elements/documentation/index.ts +0 -11
  43. package/src/api/dto/elements/documentation/item-configuration-v1.ts +0 -24
  44. package/src/api/dto/elements/documentation/item-configuration-v2.ts +0 -14
  45. package/src/api/dto/elements/documentation/page-actions-v2.ts +0 -108
  46. package/src/api/dto/elements/documentation/page-content.ts +0 -15
  47. package/src/api/dto/elements/documentation/page-v1.ts +0 -21
  48. package/src/api/dto/elements/documentation/page-v2.ts +0 -105
  49. package/src/api/dto/elements/elements-action-v2.ts +0 -114
  50. package/src/api/dto/elements/figma-nodes/figma-node.ts +0 -55
  51. package/src/api/dto/elements/figma-nodes/index.ts +0 -2
  52. package/src/api/dto/elements/figma-nodes/node-actions-v2.ts +0 -24
  53. package/src/api/dto/elements/get-elements-v2.ts +0 -21
  54. package/src/api/dto/elements/index.ts +0 -5
  55. package/src/api/dto/elements/properties/index.ts +0 -3
  56. package/src/api/dto/elements/properties/property-definitions-actions-v2.ts +0 -53
  57. package/src/api/dto/elements/properties/property-definitions.ts +0 -62
  58. package/src/api/dto/elements/properties/property-values.ts +0 -17
  59. package/src/api/dto/export/exporter.ts +0 -73
  60. package/src/api/dto/export/index.ts +0 -3
  61. package/src/api/dto/export/job.ts +0 -75
  62. package/src/api/dto/export/pipeline.ts +0 -20
  63. package/src/api/dto/figma-components/assets/download.ts +0 -30
  64. package/src/api/dto/figma-components/assets/index.ts +0 -1
  65. package/src/api/dto/figma-components/index.ts +0 -1
  66. package/src/api/dto/index.ts +0 -8
  67. package/src/api/dto/liveblocks/auth-response.ts +0 -7
  68. package/src/api/dto/liveblocks/index.ts +0 -1
  69. package/src/api/dto/users/index.ts +0 -1
  70. package/src/api/dto/users/profile/index.ts +0 -1
  71. package/src/api/dto/users/profile/update.ts +0 -7
  72. package/src/api/dto/workspaces/git.ts +0 -32
  73. package/src/api/dto/workspaces/index.ts +0 -5
  74. package/src/api/dto/workspaces/integrations.ts +0 -34
  75. package/src/api/dto/workspaces/membership.ts +0 -29
  76. package/src/api/dto/workspaces/npm-registry.ts +0 -35
  77. package/src/api/dto/workspaces/workspace.ts +0 -16
  78. package/src/api/index.ts +0 -3
  79. package/src/api/payloads/design-systems/brand.ts +0 -11
  80. package/src/api/payloads/design-systems/index.ts +0 -2
  81. package/src/api/payloads/design-systems/version.ts +0 -29
  82. package/src/api/payloads/documentation/block-definitions.ts +0 -12
  83. package/src/api/payloads/documentation/design-data-doc-diff.ts +0 -7
  84. package/src/api/payloads/documentation/index.ts +0 -2
  85. package/src/api/payloads/export/index.ts +0 -1
  86. package/src/api/payloads/export/pipeline.ts +0 -46
  87. package/src/api/payloads/index.ts +0 -6
  88. package/src/api/payloads/liveblocks/auth.ts +0 -7
  89. package/src/api/payloads/liveblocks/index.ts +0 -1
  90. package/src/api/payloads/users/index.ts +0 -2
  91. package/src/api/payloads/users/notifications/index.ts +0 -1
  92. package/src/api/payloads/users/notifications/notification-settings.ts +0 -17
  93. package/src/api/payloads/users/profile/index.ts +0 -1
  94. package/src/api/payloads/users/profile/update.ts +0 -4
  95. package/src/api/payloads/workspaces/index.ts +0 -2
  96. package/src/api/payloads/workspaces/workspace-configuration.ts +0 -50
  97. package/src/api/payloads/workspaces/workspace-integrations.ts +0 -26
  98. package/src/index.ts +0 -3
  99. package/src/utils/hash.ts +0 -62
  100. package/src/utils/index.ts +0 -1
  101. package/src/yjs/design-system-content/documentation-hierarchy.ts +0 -33
  102. package/src/yjs/design-system-content/index.ts +0 -2
  103. package/src/yjs/design-system-content/item-configuration.ts +0 -93
  104. package/src/yjs/docs-editor/blocks-to-prosemirror.ts +0 -697
  105. package/src/yjs/docs-editor/index.ts +0 -7
  106. package/src/yjs/docs-editor/list-tree-builder.ts +0 -135
  107. package/src/yjs/docs-editor/mock.ts +0 -2447
  108. package/src/yjs/docs-editor/model/block.ts +0 -8
  109. package/src/yjs/docs-editor/model/index.ts +0 -2
  110. package/src/yjs/docs-editor/model/page.ts +0 -8
  111. package/src/yjs/docs-editor/prosemirror/index.ts +0 -2
  112. package/src/yjs/docs-editor/prosemirror/schema.ts +0 -657
  113. package/src/yjs/docs-editor/prosemirror/types.ts +0 -19
  114. package/src/yjs/docs-editor/prosemirror-to-blocks.ts +0 -900
  115. package/src/yjs/docs-editor/utils.ts +0 -115
  116. package/src/yjs/index.ts +0 -3
  117. package/src/yjs/version-room/backend.ts +0 -60
  118. package/src/yjs/version-room/base.ts +0 -185
  119. package/src/yjs/version-room/frontend.ts +0 -298
  120. package/src/yjs/version-room/index.ts +0 -4
  121. package/src/yjs/version-room/utils.ts +0 -6
@@ -1,114 +0,0 @@
1
- import {
2
- DocumentationGroupV1,
3
- DocumentationItemConfigurationV1,
4
- DocumentationPageV1,
5
- DocumentationPageV2,
6
- groupBy,
7
- } from "@supernova-studio/model";
8
- import { DTODocumentationGroupStructureV1, DTODocumentationGroupV1 } from "../../dto/elements/documentation/group-v1";
9
- import {
10
- documentationItemConfigurationToDTOV1,
11
- getDtoDefaultItemConfigurationV1,
12
- } from "./documentation-item-configuration-v1-to-dto";
13
- import { applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
14
-
15
- // The fact that DTO conversion is located here instead of main backend code is due to the fact
16
- // that we store page and group data in YJS documents in the same way as they are stored in the database.
17
- // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
18
- //
19
- // Please do not put more DTO conversion here unless you know what you're doing.
20
-
21
- export function elementGroupsToDocumentationGroupStructureDTOV1(
22
- groups: DocumentationGroupV1[],
23
- pages: (DocumentationPageV1 | DocumentationPageV2)[]
24
- ): DTODocumentationGroupStructureV1[] {
25
- const childrenIdsMap = calculateChildrenIdsMapV1(pages, groups);
26
-
27
- return groups.map(group => elementGroupToDocumentationGroupStructureDTOV1(group, childrenIdsMap));
28
- }
29
-
30
- export function elementGroupsToDocumentationGroupDTOV1(
31
- groups: DocumentationGroupV1[],
32
- pages: (DocumentationPageV1 | DocumentationPageV2)[]
33
- ): DTODocumentationGroupV1[] {
34
- const childrenIdsMap = calculateChildrenIdsMapV1(pages, groups);
35
-
36
- return groups.map(group => {
37
- return {
38
- ...elementGroupToDocumentationGroupStructureDTOV1(group, childrenIdsMap),
39
- configuration: documentationItemConfigurationToDTOV1(group.data?.configuration),
40
- };
41
- });
42
- }
43
-
44
- export function elementGroupsToDocumentationGroupFixedConfigurationDTOV1(
45
- groups: DocumentationGroupV1[],
46
- pages: (DocumentationPageV1 | DocumentationPageV2)[]
47
- ): DTODocumentationGroupV1[] {
48
- const childrenIdsMap = calculateChildrenIdsMapV1(pages, groups);
49
-
50
- const { groups: fixedGroups } = applyPrivacyConfigurationToNestedItems<
51
- DocumentationPageV1 | DocumentationPageV2,
52
- DocumentationGroupV1,
53
- DocumentationItemConfigurationV1
54
- >(pages, groups, getDtoDefaultItemConfigurationV1);
55
-
56
- return fixedGroups.map(group => {
57
- const configuration = documentationItemConfigurationToDTOV1(group.data?.configuration);
58
-
59
- return {
60
- ...elementGroupToDocumentationGroupStructureDTOV1(group, childrenIdsMap),
61
- // backward compatibility with custom doc exporters, anyway these groups will not be shown, so we can adjust title
62
- title: configuration.isHidden && !group.meta.name.startsWith("_") ? "_" + group.meta.name : group.meta.name,
63
- configuration,
64
- };
65
- });
66
- }
67
-
68
- function elementGroupToDocumentationGroupStructureDTOV1(
69
- group: DocumentationGroupV1,
70
- childrenIdsMap: Map<string, string[]>
71
- ): DTODocumentationGroupStructureV1 {
72
- const childrenIds = childrenIdsMap.get(group.persistentId) ?? [];
73
-
74
- if (!group.shortPersistentId) {
75
- throw new Error(`Short persistent id is required for docs groups, group id: ${group.id}`);
76
- }
77
-
78
- return {
79
- id: group.id,
80
- designSystemVersionId: group.designSystemVersionId,
81
- persistentId: group.persistentId,
82
- slug: group.slug,
83
- userSlug: group.userSlug,
84
- createdAt: group.createdAt,
85
- updatedAt: group.updatedAt,
86
- title: group.meta.name,
87
- childrenIds: childrenIds,
88
- isRoot: !group.parentPersistentId,
89
- groupBehavior: group.data?.behavior ?? "Group",
90
- shortPersistentId: group.shortPersistentId,
91
- type: "Group",
92
- };
93
- }
94
-
95
- function calculateChildrenIdsMapV1(
96
- elements: { persistentId: string; parentPersistentId: string; sortOrder: number }[],
97
- groups: DocumentationGroupV1[]
98
- ): Map<string, string[]> {
99
- const byParentId = groupBy([...elements, ...groups], e => e.parentPersistentId);
100
-
101
- const childrenIdsMap = new Map<string, string[]>();
102
-
103
- for (const [parentPersistentId, children] of byParentId) {
104
- if (!parentPersistentId) continue;
105
- children.sort((lhs, rhs) => lhs.sortOrder - rhs.sortOrder);
106
-
107
- childrenIdsMap.set(
108
- parentPersistentId,
109
- children.map(c => c.persistentId)
110
- );
111
- }
112
-
113
- return childrenIdsMap;
114
- }
@@ -1,92 +0,0 @@
1
- import {
2
- DocumentationItemConfigurationV2,
3
- DocumentationPageV1,
4
- DocumentationPageV2,
5
- ElementGroup,
6
- groupBy,
7
- } from "@supernova-studio/model";
8
- import { DTODocumentationGroupV2 } from "../../dto";
9
- import {
10
- documentationItemConfigurationToDTOV2,
11
- getDtoDefaultItemConfigurationV2,
12
- } from "./documentation-item-configuration-v2-to-dto";
13
- import { applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
14
-
15
- // The fact that DTO conversion is located here instead of main backend code is due to the fact
16
- // that we store page and group data in YJS documents in the same way as they are stored in the database.
17
- // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
18
- //
19
- // Please do not put more DTO conversion here unless you know what you're doing.
20
-
21
- export function elementGroupsToDocumentationGroupDTOV2(
22
- groups: ElementGroup[],
23
- pages: (DocumentationPageV1 | DocumentationPageV2)[]
24
- ): DTODocumentationGroupV2[] {
25
- const childrenIdsMap = calculateChildrenIdsMapV2(pages, groups);
26
-
27
- return groups.map(group => elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap));
28
- }
29
-
30
- export function elementGroupsToDocumentationGroupFixedConfigurationDTOV2(
31
- groups: ElementGroup[],
32
- pages: (DocumentationPageV1 | DocumentationPageV2)[]
33
- ): DTODocumentationGroupV2[] {
34
- const childrenIdsMap = calculateChildrenIdsMapV2(pages, groups);
35
-
36
- const { groups: fixedGroups } = applyPrivacyConfigurationToNestedItems<
37
- DocumentationPageV1 | DocumentationPageV2,
38
- ElementGroup,
39
- DocumentationItemConfigurationV2
40
- >(pages, groups, getDtoDefaultItemConfigurationV2);
41
-
42
- return fixedGroups.map(group => elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap));
43
- }
44
-
45
- function elementGroupToDocumentationGroupStructureDTOV2(
46
- group: ElementGroup,
47
- childrenIdsMap: Map<string, string[]>
48
- ): DTODocumentationGroupV2 {
49
- const childrenIds = childrenIdsMap.get(group.persistentId) ?? [];
50
-
51
- if (!group.shortPersistentId) {
52
- throw new Error(`Short persistent id is required for docs groups, group id: ${group.id}`);
53
- }
54
-
55
- return {
56
- id: group.id,
57
- designSystemVersionId: group.designSystemVersionId,
58
- persistentId: group.persistentId,
59
- slug: group.slug,
60
- userSlug: group.userSlug,
61
- createdAt: group.createdAt,
62
- updatedAt: group.updatedAt,
63
- title: group.meta.name,
64
- configuration: documentationItemConfigurationToDTOV2(group?.data?.configuration),
65
- childrenIds: childrenIds,
66
- isRoot: !group.parentPersistentId,
67
- groupBehavior: group.data?.behavior ?? "Group",
68
- shortPersistentId: group.shortPersistentId,
69
- type: "Group",
70
- };
71
- }
72
-
73
- function calculateChildrenIdsMapV2(
74
- elements: { persistentId: string; parentPersistentId: string; sortOrder: number }[],
75
- groups: ElementGroup[]
76
- ): Map<string, string[]> {
77
- const byParentId = groupBy([...elements, ...groups], e => e.parentPersistentId);
78
-
79
- const childrenIdsMap = new Map<string, string[]>();
80
-
81
- for (const [parentPersistentId, children] of byParentId) {
82
- if (!parentPersistentId) continue;
83
- children.sort((lhs, rhs) => lhs.sortOrder - rhs.sortOrder);
84
-
85
- childrenIdsMap.set(
86
- parentPersistentId,
87
- children.map(c => c.persistentId)
88
- );
89
- }
90
-
91
- return childrenIdsMap;
92
- }
@@ -1,52 +0,0 @@
1
- import {
2
- ColorTokenData,
3
- DocumentationItemConfigurationV1,
4
- DocumentationItemHeaderAlignment,
5
- DocumentationItemHeaderImageScaleType,
6
- } from "@supernova-studio/model";
7
- import { DTODocumentationItemConfigurationV1 } from "../../dto";
8
-
9
- export const getDtoDefaultItemConfigurationV1 = () =>
10
- ({
11
- showSidebar: true,
12
- isHidden: false,
13
- isPrivate: false,
14
- header: {
15
- alignment: DocumentationItemHeaderAlignment.Left,
16
- backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
17
- description: "",
18
- showBackgroundOverlay: false,
19
- showCoverText: true,
20
- },
21
- } as const);
22
-
23
- export function documentationItemConfigurationToDTOV1(
24
- config: DocumentationItemConfigurationV1 | undefined
25
- ): DTODocumentationItemConfigurationV1 {
26
- const dtoDefaultItemConfigurationV1 = getDtoDefaultItemConfigurationV1();
27
- if (!config) return dtoDefaultItemConfigurationV1;
28
-
29
- const { backgroundColor, foregroundColor, ...headerRest } = config.header;
30
-
31
- return {
32
- showSidebar: config.showSidebar,
33
- isHidden: config.isHidden ?? dtoDefaultItemConfigurationV1.isHidden,
34
- isPrivate: config.isPrivate ?? dtoDefaultItemConfigurationV1.isPrivate,
35
- header: {
36
- ...headerRest,
37
- backgroundColor: colorToDTOV1(backgroundColor ?? undefined),
38
- foregroundColor: colorToDTOV1(foregroundColor ?? undefined),
39
- },
40
- };
41
- }
42
-
43
- function colorToDTOV1(color: ColorTokenData | undefined) {
44
- if (!color) return undefined;
45
- if (color.aliasTo) return { aliasTo: color.aliasTo };
46
- if (!color.value) return undefined;
47
-
48
- if (typeof color.value === "string") return { value: color.value };
49
- if (typeof color.value.color === "string") return { value: color.value.color };
50
-
51
- return undefined;
52
- }
@@ -1,34 +0,0 @@
1
- import {
2
- DocumentationItemConfigurationV2,
3
- DocumentationItemHeaderAlignment,
4
- DocumentationItemHeaderImageScaleType,
5
- } from "@supernova-studio/model";
6
- import { DTODocumentationItemConfigurationV2 } from "../../dto/elements/documentation/item-configuration-v2";
7
-
8
- export const getDtoDefaultItemConfigurationV2 = () =>
9
- ({
10
- showSidebar: true,
11
- isHidden: false,
12
- isPrivate: false,
13
- header: {
14
- alignment: DocumentationItemHeaderAlignment.Left,
15
- backgroundImageScaleType: DocumentationItemHeaderImageScaleType.AspectFill,
16
- description: "",
17
- showBackgroundOverlay: false,
18
- showCoverText: true,
19
- },
20
- } as const);
21
-
22
- export function documentationItemConfigurationToDTOV2(
23
- config: DocumentationItemConfigurationV2 | undefined
24
- ): DTODocumentationItemConfigurationV2 {
25
- const dtoDefaultItemConfigurationV2 = getDtoDefaultItemConfigurationV2();
26
- if (!config) return dtoDefaultItemConfigurationV2;
27
-
28
- return {
29
- header: config.header,
30
- isHidden: config.isHidden ?? dtoDefaultItemConfigurationV2.isHidden,
31
- isPrivate: config.isPrivate ?? dtoDefaultItemConfigurationV2.isPrivate,
32
- showSidebar: config.showSidebar,
33
- };
34
- }
@@ -1,132 +0,0 @@
1
- import {
2
- DocumentationItemConfigurationV1,
3
- DocumentationItemConfigurationV2,
4
- DocumentationGroupV1,
5
- DocumentationPageV1,
6
- DocumentationPageV2,
7
- ElementGroup,
8
- mapByUnique,
9
- slugify,
10
- } from "@supernova-studio/model";
11
-
12
- type GroupLike = {
13
- persistentId: string;
14
- parentPersistentId?: string;
15
- };
16
-
17
- // The fact that DTO conversion is located here instead of main backend code is due to the fact
18
- // that we store page and group data in YJS documents in the same way as they are stored in the database.
19
- // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
20
- //
21
- // Please do not put more DTO conversion here unless you know what you're doing.
22
-
23
- export function buildDocPagePublishPaths(
24
- groups: (ElementGroup | DocumentationGroupV1)[],
25
- pages: (DocumentationPageV1 | DocumentationPageV2)[],
26
- routingVersion: string
27
- ): Map<string, string> {
28
- const groupPersistentIdToGroupMap = mapByUnique(groups, group => group.persistentId);
29
- const result = new Map<string, string>();
30
-
31
- for (const page of pages) {
32
- const parentChain = calculateElementParentChain(page.parentPersistentId, groupPersistentIdToGroupMap);
33
-
34
- let pathV1 = `${page.userSlug || page.slug}.html`;
35
- let pathV2 = `${slugify(page.meta.name)}-${page.shortPersistentId}`;
36
-
37
- for (const parent of parentChain) {
38
- if (!parent.parentPersistentId) continue;
39
-
40
- pathV1 = `${parent.userSlug || parent.slug}/${pathV1}`;
41
- pathV2 = `${slugify(parent.meta.name)}/${pathV2}`;
42
- }
43
-
44
- pathV1 = `/${pathV1}`;
45
- pathV2 = `/${pathV2}`;
46
-
47
- if (routingVersion === "2") {
48
- result.set(page.persistentId, pathV2);
49
- } else {
50
- result.set(page.persistentId, pathV1);
51
- }
52
- }
53
-
54
- return result;
55
- }
56
-
57
- export function calculateElementParentChain<T extends GroupLike>(
58
- elementParentPersistentId: string,
59
- groupPersistentIdToGroupMap: Map<string, T>
60
- ): T[] {
61
- const result: T[] = [];
62
-
63
- let parentId: string | undefined = elementParentPersistentId;
64
- while (parentId) {
65
- const parent = groupPersistentIdToGroupMap.get(parentId);
66
- if (parent) result.push(parent);
67
-
68
- parentId = parent?.parentPersistentId;
69
- }
70
-
71
- return result;
72
- }
73
-
74
- export function applyPrivacyConfigurationToNestedItems<
75
- PageType extends DocumentationPageV1 | DocumentationPageV2,
76
- GroupType extends DocumentationGroupV1 | ElementGroup,
77
- ItemConfigurationType extends DocumentationItemConfigurationV1 | DocumentationItemConfigurationV2
78
- >(
79
- pages: PageType[],
80
- groups: GroupType[],
81
- getDefaultItemConfiguration: () => ItemConfigurationType
82
- ): { pages: PageType[]; groups: GroupType[] } {
83
- // copy groups to mutate them later
84
- const fixedGroups = groups.map(group => ({
85
- ...group,
86
- data: {
87
- ...group.data,
88
- configuration: group.data?.configuration ?? getDefaultItemConfiguration(),
89
- },
90
- }));
91
- const groupPersistentIdToGroupMap = mapByUnique(fixedGroups, group => group.persistentId);
92
-
93
- for (const groupToFix of fixedGroups) {
94
- let isHidden = groupToFix.data.configuration.isHidden;
95
- let isPrivate = groupToFix.data.configuration.isPrivate;
96
-
97
- let nextParentId: string | undefined = groupToFix.parentPersistentId;
98
- while ((!isHidden || !isPrivate) && nextParentId) {
99
- const parent = groupPersistentIdToGroupMap.get(nextParentId);
100
- if (!parent) break;
101
-
102
- isHidden = isHidden || parent.data?.configuration?.isHidden || false;
103
- isPrivate = isPrivate || parent.data?.configuration?.isPrivate || false;
104
-
105
- nextParentId = parent.parentPersistentId;
106
- }
107
-
108
- groupToFix.data.configuration.isHidden = isHidden;
109
- groupToFix.data.configuration.isPrivate = isPrivate;
110
- }
111
-
112
- const fixedPages: PageType[] = [];
113
- // set isHidden and isPrivate configuration fields based on page and parents value
114
- for (const page of pages) {
115
- const configuration = page.data?.configuration ?? getDefaultItemConfiguration();
116
- const parent = groupPersistentIdToGroupMap.get(page.parentPersistentId);
117
-
118
- fixedPages.push({
119
- ...page,
120
- data: {
121
- ...page.data,
122
- configuration: {
123
- ...configuration,
124
- isHidden: configuration.isHidden || parent?.data?.configuration?.isHidden || false,
125
- isPrivate: configuration.isPrivate || parent?.data?.configuration?.isPrivate || false,
126
- },
127
- },
128
- });
129
- }
130
-
131
- return { pages: fixedPages, groups: fixedGroups };
132
- }
@@ -1,69 +0,0 @@
1
- import {
2
- DocumentationGroupV1,
3
- DocumentationItemConfigurationV1,
4
- DocumentationPageV1,
5
- SupernovaException,
6
- } from "@supernova-studio/model";
7
- import { DocumentationPageV1DTO } from "../../dto";
8
- import {
9
- documentationItemConfigurationToDTOV1,
10
- getDtoDefaultItemConfigurationV1,
11
- } from "./documentation-item-configuration-v1-to-dto";
12
- import { buildDocPagePublishPaths, applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
13
-
14
- // The fact that DTO conversion is located here instead of main backend code is due to the fact
15
- // that we store page and group data in YJS documents in the same way as they are stored in the database.
16
- // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
17
- //
18
- // Please do not put more DTO conversion here unless you know what you're doing.
19
-
20
- export function documentationPagesToDTOV1(
21
- pages: DocumentationPageV1[],
22
- groups: DocumentationGroupV1[],
23
- routingVersion: string
24
- ): DocumentationPageV1DTO[] {
25
- const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
26
-
27
- return pages.map(page => documentationPageToDTOV1(page, pathsMap));
28
- }
29
-
30
- export function documentationPagesFixedConfigurationToDTOV1(
31
- pages: DocumentationPageV1[],
32
- groups: DocumentationGroupV1[],
33
- routingVersion: string
34
- ): DocumentationPageV1DTO[] {
35
- const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
36
-
37
- const { pages: fixedPages } = applyPrivacyConfigurationToNestedItems<
38
- DocumentationPageV1,
39
- DocumentationGroupV1,
40
- DocumentationItemConfigurationV1
41
- >(pages, groups, getDtoDefaultItemConfigurationV1);
42
-
43
- return fixedPages.map((page: DocumentationPageV1) => documentationPageToDTOV1(page, pathsMap));
44
- }
45
-
46
- function documentationPageToDTOV1(page: DocumentationPageV1, pagePathMap: Map<string, string>): DocumentationPageV1DTO {
47
- let path = pagePathMap.get(page.persistentId);
48
- if (!path) throw SupernovaException.conflict(`Path for page ${page.id} was not calculated`);
49
-
50
- if (path.startsWith("/")) path = path.substring(1);
51
-
52
- const configuration = documentationItemConfigurationToDTOV1(page.data.configuration);
53
-
54
- return {
55
- id: page.id,
56
- designSystemVersionId: page.designSystemVersionId,
57
- persistentId: page.persistentId,
58
- shortPersistentId: page.shortPersistentId,
59
- // backward compatibility with custom doc exporters, anyway these pages will not be shown, so we can adjust title
60
- title: configuration.isHidden && !page.meta.name.startsWith("_") ? "_" + page.meta.name : page.meta.name,
61
- blocks: page.data.blocks,
62
- slug: page.slug,
63
- userSlug: page.userSlug,
64
- configuration,
65
- createdAt: page.createdAt,
66
- updatedAt: page.updatedAt,
67
- path: path,
68
- };
69
- }
@@ -1,72 +0,0 @@
1
- import { DocumentationItemConfigurationV2, DocumentationPageV2, ElementGroup } from "@supernova-studio/model";
2
- import { DTODocumentationPageV2 } from "../../dto";
3
- import {
4
- documentationItemConfigurationToDTOV2,
5
- getDtoDefaultItemConfigurationV2,
6
- } from "./documentation-item-configuration-v2-to-dto";
7
- import { applyPrivacyConfigurationToNestedItems, buildDocPagePublishPaths } from "./documentation-page-to-dto-utils";
8
-
9
- // The fact that DTO conversion is located here instead of main backend code is due to the fact
10
- // that we store page and group data in YJS documents in the same way as they are stored in the database.
11
- // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
12
- //
13
- // Please do not put more DTO conversion here unless you know what you're doing.
14
-
15
- export function documentationPageToDTOV2(
16
- page: DocumentationPageV2,
17
- groups: ElementGroup[],
18
- routingVersion: string
19
- ): DTODocumentationPageV2 {
20
- const pathsMap = buildDocPagePublishPaths(groups, [page], routingVersion);
21
- return _documentationPageToDTOV2(page, pathsMap);
22
- }
23
-
24
- export function documentationPagesToDTOV2(
25
- pages: DocumentationPageV2[],
26
- groups: ElementGroup[],
27
- routingVersion: string
28
- ): DTODocumentationPageV2[] {
29
- const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
30
- return pages.map(page => _documentationPageToDTOV2(page, pathsMap));
31
- }
32
-
33
- export function documentationPagesFixedConfigurationToDTOV2(
34
- pages: DocumentationPageV2[],
35
- groups: ElementGroup[],
36
- routingVersion: string
37
- ): DTODocumentationPageV2[] {
38
- const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
39
-
40
- const { pages: fixedPages } = applyPrivacyConfigurationToNestedItems<
41
- DocumentationPageV2,
42
- ElementGroup,
43
- DocumentationItemConfigurationV2
44
- >(pages, groups, getDtoDefaultItemConfigurationV2);
45
-
46
- return fixedPages.map(page => _documentationPageToDTOV2(page, pathsMap));
47
- }
48
-
49
- function _documentationPageToDTOV2(
50
- page: DocumentationPageV2,
51
- pagePathMap: Map<string, string>
52
- ): DTODocumentationPageV2 {
53
- let path = pagePathMap.get(page.persistentId);
54
- if (!path) throw new Error(`Path for page ${page.id} was not calculated`);
55
-
56
- if (path.startsWith("/")) path = path.substring(1);
57
-
58
- return {
59
- id: page.id,
60
- designSystemVersionId: page.designSystemVersionId,
61
- persistentId: page.persistentId,
62
- shortPersistentId: page.shortPersistentId,
63
- title: page.meta.name,
64
- slug: page.slug,
65
- userSlug: page.userSlug,
66
- configuration: documentationItemConfigurationToDTOV2(page.data.configuration),
67
- createdAt: page.createdAt,
68
- updatedAt: page.updatedAt,
69
- path: path,
70
- type: "Page",
71
- };
72
- }
@@ -1,7 +0,0 @@
1
- export * from "./documentation-group-v1-to-dto";
2
- export * from "./documentation-group-v2-to-dto";
3
- export * from "./documentation-item-configuration-v1-to-dto";
4
- export * from "./documentation-item-configuration-v2-to-dto";
5
- export * from "./documentation-page-to-dto-utils";
6
- export * from "./documentation-page-v1-to-dto";
7
- export * from "./documentation-page-v2-to-dto";
@@ -1 +0,0 @@
1
- export * from "./pipeline";
@@ -1,24 +0,0 @@
1
- import { Pipeline } from "@supernova-studio/model";
2
- import { DTOPipeline } from "../../dto/export/pipeline";
3
-
4
- export function pipelineToDto(pipeline: Pipeline): DTOPipeline {
5
- return {
6
- id: pipeline.id,
7
- name: pipeline.name,
8
- eventType: pipeline.eventType,
9
- isEnabled: pipeline.isEnabled,
10
- workspaceId: pipeline.workspaceId,
11
- designSystemId: pipeline.designSystemId,
12
- exporterId: pipeline.exporterId,
13
- brandPersistentId: pipeline.brandPersistentId,
14
- themePersistentId: pipeline.themePersistentId,
15
- destinationAzure: pipeline.destinationAzure,
16
- destinationBitbucket: pipeline.destinationBitbucket,
17
- destinationSnDocs: pipeline.destinationSnDocs,
18
- destinationGithub: pipeline.destinationGithub,
19
- destinationGitlab: pipeline.destinationGitlab,
20
- destinationS3: pipeline.destinationS3,
21
- webhookUrl: pipeline.webhookUrl,
22
- latestJobs: [],
23
- };
24
- }
@@ -1,3 +0,0 @@
1
- export * from "./documentation";
2
- export * from "./export";
3
- export * from "./integrations";
@@ -1,37 +0,0 @@
1
- import { GitBranch, GitOrganization, GitProject, GitRepository } from "@supernova-studio/model";
2
- import { DTOGitBranch, DTOGitOrganization, DTOGitProject, DTOGitRepository } from "../../dto";
3
-
4
- export function gitOrganizationToDto(org: GitOrganization): DTOGitOrganization {
5
- return {
6
- id: org.id,
7
- name: org.name,
8
- url: org.url,
9
- slug: org.slug,
10
- };
11
- }
12
-
13
- export function gitProjectToDto(project: GitProject): DTOGitProject {
14
- return {
15
- id: project.id,
16
- name: project.name,
17
- url: project.url,
18
- slug: project.slug,
19
- };
20
- }
21
-
22
- export function gitRepositoryToDto(repo: GitRepository): DTOGitRepository {
23
- return {
24
- id: repo.id,
25
- name: repo.name,
26
- url: repo.url,
27
- slug: repo.slug,
28
- defaultBranch: repo.defaultBranch,
29
- };
30
- }
31
-
32
- export function gitBranchToDto(branch: GitBranch): DTOGitBranch {
33
- return {
34
- name: branch.name,
35
- lastCommitId: branch.lastCommitId,
36
- };
37
- }
@@ -1,2 +0,0 @@
1
- export * from "./git";
2
- export * from "./integration";