@supernova-studio/client 0.59.12 → 1.0.0-alpha.10

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 (204) hide show
  1. package/dist/index.d.mts +1592 -1952
  2. package/dist/index.d.ts +1592 -1952
  3. package/dist/index.js +865 -392
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +2569 -2096
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +4 -3
  8. package/src/api/client.ts +0 -31
  9. package/src/api/conversion/documentation/documentation-group-v1-to-dto.ts +0 -114
  10. package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +0 -92
  11. package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +0 -52
  12. package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +0 -34
  13. package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +0 -131
  14. package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +0 -69
  15. package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +0 -78
  16. package/src/api/conversion/documentation/index.ts +0 -7
  17. package/src/api/conversion/export/index.ts +0 -1
  18. package/src/api/conversion/export/pipeline.ts +0 -26
  19. package/src/api/conversion/index.ts +0 -3
  20. package/src/api/conversion/integrations/git.ts +0 -37
  21. package/src/api/conversion/integrations/index.ts +0 -2
  22. package/src/api/conversion/integrations/integration.ts +0 -37
  23. package/src/api/dto/aux/color.ts +0 -7
  24. package/src/api/dto/aux/index.ts +0 -3
  25. package/src/api/dto/aux/meta.ts +0 -8
  26. package/src/api/dto/aux/pagination.ts +0 -8
  27. package/src/api/dto/bff/app-bootstrap-data.ts +0 -20
  28. package/src/api/dto/bff/index.ts +0 -1
  29. package/src/api/dto/collections/index.ts +0 -1
  30. package/src/api/dto/collections/token-collection.ts +0 -24
  31. package/src/api/dto/design-systems/brand.ts +0 -44
  32. package/src/api/dto/design-systems/component.ts +0 -40
  33. package/src/api/dto/design-systems/contact.ts +0 -11
  34. package/src/api/dto/design-systems/data-source.ts +0 -141
  35. package/src/api/dto/design-systems/design-system.ts +0 -68
  36. package/src/api/dto/design-systems/elements-diff.ts +0 -14
  37. package/src/api/dto/design-systems/figma-variables.ts +0 -108
  38. package/src/api/dto/design-systems/import-job.ts +0 -61
  39. package/src/api/dto/design-systems/index.ts +0 -15
  40. package/src/api/dto/design-systems/members.ts +0 -50
  41. package/src/api/dto/design-systems/redirects.ts +0 -33
  42. package/src/api/dto/design-systems/role.ts +0 -11
  43. package/src/api/dto/design-systems/stats.ts +0 -19
  44. package/src/api/dto/design-systems/version-room.ts +0 -12
  45. package/src/api/dto/design-systems/version.ts +0 -56
  46. package/src/api/dto/design-systems/view.ts +0 -45
  47. package/src/api/dto/design-tokens/design-token.ts +0 -78
  48. package/src/api/dto/design-tokens/index.ts +0 -1
  49. package/src/api/dto/documentation/anchor.ts +0 -15
  50. package/src/api/dto/documentation/approvals.ts +0 -15
  51. package/src/api/dto/documentation/block-definition.ts +0 -28
  52. package/src/api/dto/documentation/block.ts +0 -6
  53. package/src/api/dto/documentation/documentation-page-snapshot.ts +0 -18
  54. package/src/api/dto/documentation/index.ts +0 -8
  55. package/src/api/dto/documentation/link-preview.ts +0 -23
  56. package/src/api/dto/documentation/publish.ts +0 -23
  57. package/src/api/dto/documentation/room.ts +0 -12
  58. package/src/api/dto/elements/components/figma-component-group.ts +0 -19
  59. package/src/api/dto/elements/components/figma-component.ts +0 -56
  60. package/src/api/dto/elements/components/index.ts +0 -2
  61. package/src/api/dto/elements/documentation/draft-state.ts +0 -37
  62. package/src/api/dto/elements/documentation/group-action.ts +0 -108
  63. package/src/api/dto/elements/documentation/group-v1.ts +0 -35
  64. package/src/api/dto/elements/documentation/group-v2.ts +0 -117
  65. package/src/api/dto/elements/documentation/hierarchy.ts +0 -22
  66. package/src/api/dto/elements/documentation/index.ts +0 -13
  67. package/src/api/dto/elements/documentation/item-configuration-v1.ts +0 -24
  68. package/src/api/dto/elements/documentation/item-configuration-v2.ts +0 -14
  69. package/src/api/dto/elements/documentation/metadata.ts +0 -8
  70. package/src/api/dto/elements/documentation/page-actions-v2.ts +0 -121
  71. package/src/api/dto/elements/documentation/page-content.ts +0 -15
  72. package/src/api/dto/elements/documentation/page-v1.ts +0 -21
  73. package/src/api/dto/elements/documentation/page-v2.ts +0 -123
  74. package/src/api/dto/elements/documentation/structure.ts +0 -37
  75. package/src/api/dto/elements/elements-action-v2.ts +0 -117
  76. package/src/api/dto/elements/figma-nodes/figma-node-v1.ts +0 -32
  77. package/src/api/dto/elements/figma-nodes/figma-node-v2.ts +0 -32
  78. package/src/api/dto/elements/figma-nodes/figma-node.ts +0 -103
  79. package/src/api/dto/elements/figma-nodes/index.ts +0 -4
  80. package/src/api/dto/elements/figma-nodes/node-actions-v2.ts +0 -44
  81. package/src/api/dto/elements/frame-node-structures/frame-node-structure.ts +0 -17
  82. package/src/api/dto/elements/frame-node-structures/index.ts +0 -1
  83. package/src/api/dto/elements/get-elements-v2.ts +0 -27
  84. package/src/api/dto/elements/index.ts +0 -7
  85. package/src/api/dto/elements/properties/index.ts +0 -2
  86. package/src/api/dto/elements/properties/property-definitions.ts +0 -75
  87. package/src/api/dto/elements/properties/property-values.ts +0 -38
  88. package/src/api/dto/export/exporter-property.ts +0 -105
  89. package/src/api/dto/export/exporter.ts +0 -87
  90. package/src/api/dto/export/filter.ts +0 -6
  91. package/src/api/dto/export/index.ts +0 -5
  92. package/src/api/dto/export/job.ts +0 -96
  93. package/src/api/dto/export/pipeline.ts +0 -43
  94. package/src/api/dto/figma-components/assets/download.ts +0 -30
  95. package/src/api/dto/figma-components/assets/index.ts +0 -1
  96. package/src/api/dto/figma-components/index.ts +0 -1
  97. package/src/api/dto/index.ts +0 -13
  98. package/src/api/dto/liveblocks/auth-response.ts +0 -7
  99. package/src/api/dto/liveblocks/index.ts +0 -1
  100. package/src/api/dto/themes/index.ts +0 -2
  101. package/src/api/dto/themes/override.ts +0 -27
  102. package/src/api/dto/themes/theme.ts +0 -45
  103. package/src/api/dto/users/authenticated-user.ts +0 -46
  104. package/src/api/dto/users/index.ts +0 -3
  105. package/src/api/dto/users/update.ts +0 -8
  106. package/src/api/dto/users/user.ts +0 -31
  107. package/src/api/dto/workspaces/git.ts +0 -32
  108. package/src/api/dto/workspaces/index.ts +0 -6
  109. package/src/api/dto/workspaces/integrations.ts +0 -34
  110. package/src/api/dto/workspaces/invitations.ts +0 -30
  111. package/src/api/dto/workspaces/membership.ts +0 -41
  112. package/src/api/dto/workspaces/npm-registry.ts +0 -35
  113. package/src/api/dto/workspaces/workspace.ts +0 -34
  114. package/src/api/endpoints/codegen/codegen.ts +0 -16
  115. package/src/api/endpoints/codegen/exporters.ts +0 -25
  116. package/src/api/endpoints/codegen/index.ts +0 -4
  117. package/src/api/endpoints/codegen/jobs.ts +0 -15
  118. package/src/api/endpoints/codegen/pipelines.ts +0 -44
  119. package/src/api/endpoints/design-system/bff.ts +0 -13
  120. package/src/api/endpoints/design-system/contact.ts +0 -12
  121. package/src/api/endpoints/design-system/design-systems.ts +0 -55
  122. package/src/api/endpoints/design-system/index.ts +0 -6
  123. package/src/api/endpoints/design-system/members.ts +0 -24
  124. package/src/api/endpoints/design-system/sources.ts +0 -35
  125. package/src/api/endpoints/design-system/versions/brands.ts +0 -45
  126. package/src/api/endpoints/design-system/versions/documentation.ts +0 -27
  127. package/src/api/endpoints/design-system/versions/ds-components.ts +0 -28
  128. package/src/api/endpoints/design-system/versions/elements-action.ts +0 -63
  129. package/src/api/endpoints/design-system/versions/elements.ts +0 -27
  130. package/src/api/endpoints/design-system/versions/figma-component-groups.ts +0 -13
  131. package/src/api/endpoints/design-system/versions/figma-components.ts +0 -13
  132. package/src/api/endpoints/design-system/versions/figma-frame-structures.ts +0 -13
  133. package/src/api/endpoints/design-system/versions/import-jobs.ts +0 -13
  134. package/src/api/endpoints/design-system/versions/index.ts +0 -18
  135. package/src/api/endpoints/design-system/versions/overrides.ts +0 -17
  136. package/src/api/endpoints/design-system/versions/property-definitions.ts +0 -43
  137. package/src/api/endpoints/design-system/versions/property-values.ts +0 -25
  138. package/src/api/endpoints/design-system/versions/stats.ts +0 -12
  139. package/src/api/endpoints/design-system/versions/themes.ts +0 -35
  140. package/src/api/endpoints/design-system/versions/token-collections.ts +0 -13
  141. package/src/api/endpoints/design-system/versions/token-groups.ts +0 -28
  142. package/src/api/endpoints/design-system/versions/tokens.ts +0 -27
  143. package/src/api/endpoints/design-system/versions/versions.ts +0 -87
  144. package/src/api/endpoints/index.ts +0 -5
  145. package/src/api/endpoints/liveblocks.ts +0 -14
  146. package/src/api/endpoints/users.ts +0 -26
  147. package/src/api/endpoints/workspaces/index.ts +0 -3
  148. package/src/api/endpoints/workspaces/workspace-invites.ts +0 -34
  149. package/src/api/endpoints/workspaces/workspace-members.ts +0 -31
  150. package/src/api/endpoints/workspaces/workspaces.ts +0 -47
  151. package/src/api/index.ts +0 -6
  152. package/src/api/payloads/design-systems/index.ts +0 -2
  153. package/src/api/payloads/design-systems/update-design-system.ts +0 -29
  154. package/src/api/payloads/design-systems/version.ts +0 -29
  155. package/src/api/payloads/documentation/block-definitions.ts +0 -12
  156. package/src/api/payloads/documentation/design-data-doc-diff.ts +0 -7
  157. package/src/api/payloads/documentation/index.ts +0 -2
  158. package/src/api/payloads/export/index.ts +0 -1
  159. package/src/api/payloads/export/pipeline.ts +0 -74
  160. package/src/api/payloads/index.ts +0 -6
  161. package/src/api/payloads/liveblocks/auth.ts +0 -7
  162. package/src/api/payloads/liveblocks/index.ts +0 -1
  163. package/src/api/payloads/users/index.ts +0 -2
  164. package/src/api/payloads/users/notifications/index.ts +0 -1
  165. package/src/api/payloads/users/notifications/notification-settings.ts +0 -17
  166. package/src/api/payloads/users/profile/index.ts +0 -1
  167. package/src/api/payloads/users/profile/update.ts +0 -4
  168. package/src/api/payloads/workspaces/index.ts +0 -3
  169. package/src/api/payloads/workspaces/transfer-ownership.ts +0 -7
  170. package/src/api/payloads/workspaces/workspace-configuration.ts +0 -50
  171. package/src/api/payloads/workspaces/workspace-integrations.ts +0 -26
  172. package/src/api/transport/index.ts +0 -2
  173. package/src/api/transport/request-executor-error.ts +0 -66
  174. package/src/api/transport/request-executor.ts +0 -87
  175. package/src/events/design-system.ts +0 -21
  176. package/src/events/event.ts +0 -6
  177. package/src/events/index.ts +0 -2
  178. package/src/index.ts +0 -4
  179. package/src/utils/figma.ts +0 -72
  180. package/src/utils/hash.ts +0 -62
  181. package/src/utils/index.ts +0 -3
  182. package/src/utils/query.ts +0 -18
  183. package/src/yjs/design-system-content/documentation-hierarchy.ts +0 -35
  184. package/src/yjs/design-system-content/index.ts +0 -2
  185. package/src/yjs/design-system-content/item-configuration.ts +0 -93
  186. package/src/yjs/docs-editor/blocks-to-prosemirror.ts +0 -764
  187. package/src/yjs/docs-editor/index.ts +0 -7
  188. package/src/yjs/docs-editor/list-tree-builder.ts +0 -127
  189. package/src/yjs/docs-editor/mock.ts +0 -2142
  190. package/src/yjs/docs-editor/model/block.ts +0 -8
  191. package/src/yjs/docs-editor/model/index.ts +0 -2
  192. package/src/yjs/docs-editor/model/page.ts +0 -8
  193. package/src/yjs/docs-editor/prosemirror/index.ts +0 -3
  194. package/src/yjs/docs-editor/prosemirror/inner-editor-schema.ts +0 -145
  195. package/src/yjs/docs-editor/prosemirror/main-editor-schema.ts +0 -577
  196. package/src/yjs/docs-editor/prosemirror/types.ts +0 -19
  197. package/src/yjs/docs-editor/prosemirror-to-blocks.ts +0 -975
  198. package/src/yjs/docs-editor/utils.ts +0 -115
  199. package/src/yjs/index.ts +0 -3
  200. package/src/yjs/version-room/backend.ts +0 -83
  201. package/src/yjs/version-room/base.ts +0 -252
  202. package/src/yjs/version-room/frontend.ts +0 -463
  203. package/src/yjs/version-room/index.ts +0 -4
  204. package/src/yjs/version-room/utils.ts +0 -109
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.59.12",
3
+ "version": "1.0.0-alpha.10",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -19,8 +19,7 @@
19
19
  }
20
20
  },
21
21
  "files": [
22
- "dist/**",
23
- "src/**"
22
+ "dist/**"
24
23
  ],
25
24
  "scripts": {
26
25
  "build": "tsup",
@@ -31,7 +30,9 @@
31
30
  "author": "",
32
31
  "license": "ISC",
33
32
  "dependencies": {
33
+ "p-queue": "^8.0.1",
34
34
  "prosemirror-model": "1.22.3",
35
+ "queue-promise": "^2.2.1",
35
36
  "y-prosemirror": "1.2.2",
36
37
  "yjs": "13.6.19",
37
38
  "zod": "3.23.6"
package/src/api/client.ts DELETED
@@ -1,31 +0,0 @@
1
- import { CodegenEndpoint, WorkspacesEndpoint } from "./endpoints";
2
- import { DesignSystemsEndpoint } from "./endpoints/design-system";
3
- import { LiveblocksEndpoint } from "./endpoints/liveblocks";
4
- import { UsersEndpoint } from "./endpoints/users";
5
- import { RequestExecutor } from "./transport/request-executor";
6
-
7
- type SupernovaApiClientConfig = {
8
- host: string;
9
- accessToken: string;
10
- };
11
-
12
- export class SupernovaApiClient {
13
- readonly users: UsersEndpoint;
14
- readonly workspaces: WorkspacesEndpoint;
15
- readonly designSystems: DesignSystemsEndpoint;
16
- readonly codegen: CodegenEndpoint;
17
- readonly liveblocks: LiveblocksEndpoint;
18
-
19
- constructor(config: SupernovaApiClientConfig) {
20
- const requestExecutor = new RequestExecutor({
21
- host: config.host,
22
- accessToken: config.accessToken,
23
- });
24
-
25
- this.users = new UsersEndpoint(requestExecutor);
26
- this.workspaces = new WorkspacesEndpoint(requestExecutor);
27
- this.designSystems = new DesignSystemsEndpoint(requestExecutor);
28
- this.codegen = new CodegenEndpoint(requestExecutor);
29
- this.liveblocks = new LiveblocksEndpoint(requestExecutor);
30
- }
31
- }
@@ -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,131 +0,0 @@
1
- import {
2
- DocumentationGroupV1,
3
- DocumentationItemConfigurationV1,
4
- DocumentationItemConfigurationV2,
5
- DocumentationPageV1,
6
- DocumentationPageV2,
7
- ElementGroup,
8
- mapByUnique,
9
- } from "@supernova-studio/model";
10
-
11
- type GroupLike = {
12
- persistentId: string;
13
- parentPersistentId?: string;
14
- };
15
-
16
- // The fact that DTO conversion is located here instead of main backend code is due to the fact
17
- // that we store page and group data in YJS documents in the same way as they are stored in the database.
18
- // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
19
- //
20
- // Please do not put more DTO conversion here unless you know what you're doing.
21
-
22
- export function buildDocPagePublishPaths(
23
- groups: (ElementGroup | DocumentationGroupV1)[],
24
- pages: (DocumentationPageV1 | DocumentationPageV2)[],
25
- routingVersion: string
26
- ): Map<string, string> {
27
- const groupPersistentIdToGroupMap = mapByUnique(groups, group => group.persistentId);
28
- const result = new Map<string, string>();
29
-
30
- for (const page of pages) {
31
- const parentChain = calculateElementParentChain(page.parentPersistentId, groupPersistentIdToGroupMap);
32
-
33
- let pathV1 = `${page.userSlug || page.slug}.html`;
34
- let pathV2 = `${page.slug}-${page.shortPersistentId}`;
35
-
36
- for (const parent of parentChain) {
37
- if (!parent.parentPersistentId) continue;
38
-
39
- pathV1 = `${parent.userSlug || parent.slug || "root"}/${pathV1}`;
40
- pathV2 = `${parent.slug || "root"}/${pathV2}`;
41
- }
42
-
43
- pathV1 = `/${pathV1}`;
44
- pathV2 = `/${pathV2}`;
45
-
46
- if (routingVersion === "2") {
47
- result.set(page.persistentId, pathV2);
48
- } else {
49
- result.set(page.persistentId, pathV1);
50
- }
51
- }
52
-
53
- return result;
54
- }
55
-
56
- export function calculateElementParentChain<T extends GroupLike>(
57
- elementParentPersistentId: string,
58
- groupPersistentIdToGroupMap: Map<string, T>
59
- ): T[] {
60
- const result: T[] = [];
61
-
62
- let parentId: string | undefined = elementParentPersistentId;
63
- while (parentId) {
64
- const parent = groupPersistentIdToGroupMap.get(parentId);
65
- if (parent) result.push(parent);
66
-
67
- parentId = parent?.parentPersistentId;
68
- }
69
-
70
- return result;
71
- }
72
-
73
- export function applyPrivacyConfigurationToNestedItems<
74
- PageType extends DocumentationPageV1 | DocumentationPageV2,
75
- GroupType extends DocumentationGroupV1 | ElementGroup,
76
- ItemConfigurationType extends DocumentationItemConfigurationV1 | DocumentationItemConfigurationV2
77
- >(
78
- pages: PageType[],
79
- groups: GroupType[],
80
- getDefaultItemConfiguration: () => ItemConfigurationType
81
- ): { pages: PageType[]; groups: GroupType[] } {
82
- // copy groups to mutate them later
83
- const fixedGroups = groups.map(group => ({
84
- ...group,
85
- data: {
86
- ...group.data,
87
- configuration: group.data?.configuration ?? getDefaultItemConfiguration(),
88
- },
89
- }));
90
- const groupPersistentIdToGroupMap = mapByUnique(fixedGroups, group => group.persistentId);
91
-
92
- for (const groupToFix of fixedGroups) {
93
- let isHidden = groupToFix.data.configuration.isHidden;
94
- let isPrivate = groupToFix.data.configuration.isPrivate;
95
-
96
- let nextParentId: string | undefined = groupToFix.parentPersistentId;
97
- while ((!isHidden || !isPrivate) && nextParentId) {
98
- const parent = groupPersistentIdToGroupMap.get(nextParentId);
99
- if (!parent) break;
100
-
101
- isHidden = isHidden || parent.data?.configuration?.isHidden || false;
102
- isPrivate = isPrivate || parent.data?.configuration?.isPrivate || false;
103
-
104
- nextParentId = parent.parentPersistentId;
105
- }
106
-
107
- groupToFix.data.configuration.isHidden = isHidden;
108
- groupToFix.data.configuration.isPrivate = isPrivate;
109
- }
110
-
111
- const fixedPages: PageType[] = [];
112
- // set isHidden and isPrivate configuration fields based on page and parents value
113
- for (const page of pages) {
114
- const configuration = page.data?.configuration ?? getDefaultItemConfiguration();
115
- const parent = groupPersistentIdToGroupMap.get(page.parentPersistentId);
116
-
117
- fixedPages.push({
118
- ...page,
119
- data: {
120
- ...page.data,
121
- configuration: {
122
- ...configuration,
123
- isHidden: configuration.isHidden || parent?.data?.configuration?.isHidden || false,
124
- isPrivate: configuration.isPrivate || parent?.data?.configuration?.isPrivate || false,
125
- },
126
- },
127
- });
128
- }
129
-
130
- return { pages: fixedPages, groups: fixedGroups };
131
- }
@@ -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,78 +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
- pageLiveblocksRoomIdMap: Map<string, string>
20
- ): DTODocumentationPageV2 {
21
- const pathsMap = buildDocPagePublishPaths(groups, [page], routingVersion);
22
- return _documentationPageToDTOV2(page, pathsMap, pageLiveblocksRoomIdMap);
23
- }
24
-
25
- export function documentationPagesToDTOV2(
26
- pages: DocumentationPageV2[],
27
- groups: ElementGroup[],
28
- routingVersion: string,
29
- pageLiveblocksRoomIdMap: Map<string, string>
30
- ): DTODocumentationPageV2[] {
31
- const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
32
- return pages.map(page => _documentationPageToDTOV2(page, pathsMap, pageLiveblocksRoomIdMap));
33
- }
34
-
35
- export function documentationPagesFixedConfigurationToDTOV2(
36
- pages: DocumentationPageV2[],
37
- groups: ElementGroup[],
38
- routingVersion: string,
39
- pageLiveblocksRoomIdMap: Map<string, string>
40
- ): DTODocumentationPageV2[] {
41
- const pathsMap = buildDocPagePublishPaths(groups, pages, routingVersion);
42
-
43
- const { pages: fixedPages } = applyPrivacyConfigurationToNestedItems<
44
- DocumentationPageV2,
45
- ElementGroup,
46
- DocumentationItemConfigurationV2
47
- >(pages, groups, getDtoDefaultItemConfigurationV2);
48
-
49
- return fixedPages.map(page => _documentationPageToDTOV2(page, pathsMap, pageLiveblocksRoomIdMap));
50
- }
51
-
52
- function _documentationPageToDTOV2(
53
- page: DocumentationPageV2,
54
- pagePathMap: Map<string, string>,
55
- pageLiveblocksRoomIdMap: Map<string, string>
56
- ): DTODocumentationPageV2 {
57
- let path = pagePathMap.get(page.persistentId);
58
- if (!path) throw new Error(`Path for page ${page.id} was not calculated`);
59
- if (path.startsWith("/")) path = path.substring(1);
60
-
61
- const liveblocksRoomId = pageLiveblocksRoomIdMap.get(page.persistentId);
62
-
63
- return {
64
- id: page.id,
65
- designSystemVersionId: page.designSystemVersionId,
66
- persistentId: page.persistentId,
67
- shortPersistentId: page.shortPersistentId,
68
- title: page.meta.name,
69
- slug: page.slug,
70
- userSlug: page.userSlug,
71
- configuration: documentationItemConfigurationToDTOV2(page.data.configuration),
72
- createdAt: page.createdAt,
73
- updatedAt: page.updatedAt,
74
- path: path,
75
- type: "Page",
76
- ...(liveblocksRoomId && { liveblocksRoomId }),
77
- };
78
- }
@@ -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,26 +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
- themePersistentIds: pipeline.themePersistentIds,
16
- destinationAzure: pipeline.destinationAzure,
17
- destinationBitbucket: pipeline.destinationBitbucket,
18
- destinationSnDocs: pipeline.destinationSnDocs,
19
- destinationGithub: pipeline.destinationGithub,
20
- destinationGitlab: pipeline.destinationGitlab,
21
- destinationS3: pipeline.destinationS3,
22
- exporterConfigurationProperties: pipeline.exporterConfigurationProperties,
23
- webhookUrl: pipeline.webhookUrl,
24
- latestJobs: [],
25
- };
26
- }
@@ -1,3 +0,0 @@
1
- export * from "./documentation";
2
- export * from "./export";
3
- export * from "./integrations";