@supernova-studio/client 1.96.6 → 1.96.7
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 +101177 -143251
- package/dist/index.d.ts +101177 -143251
- package/dist/index.js +408 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5542 -5239
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -9
- package/src/api/client.ts +62 -0
- package/src/api/conversion/analytics/index.ts +3 -0
- package/src/api/conversion/analytics/page-visits-to-comparison-dto.ts +65 -0
- package/src/api/conversion/analytics/page-visits-to-dto.ts +68 -0
- package/src/api/conversion/analytics/page-visits-to-heatmap-dto.ts +49 -0
- package/src/api/conversion/documentation/documentation-group-v1-to-dto.ts +114 -0
- package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +91 -0
- package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +52 -0
- package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +34 -0
- package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +134 -0
- package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +69 -0
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +84 -0
- package/src/api/conversion/documentation/documentation-settings-to-dto.ts +14 -0
- package/src/api/conversion/documentation/index.ts +8 -0
- package/src/api/conversion/export/index.ts +1 -0
- package/src/api/conversion/export/pipeline.ts +27 -0
- package/src/api/conversion/index.ts +4 -0
- package/src/api/conversion/integrations/git.ts +37 -0
- package/src/api/conversion/integrations/index.ts +2 -0
- package/src/api/conversion/integrations/integration.ts +37 -0
- package/src/api/dto/access-tokens/access-token.ts +45 -0
- package/src/api/dto/access-tokens/index.ts +1 -0
- package/src/api/dto/aux/color.ts +7 -0
- package/src/api/dto/aux/index.ts +4 -0
- package/src/api/dto/aux/meta.ts +8 -0
- package/src/api/dto/aux/object-metadata.ts +29 -0
- package/src/api/dto/aux/pagination.ts +8 -0
- package/src/api/dto/bff/app-bootstrap-data.ts +20 -0
- package/src/api/dto/bff/index.ts +1 -0
- package/src/api/dto/collections/index.ts +1 -0
- package/src/api/dto/collections/token-collection.ts +32 -0
- package/src/api/dto/design-systems/brand.ts +44 -0
- package/src/api/dto/design-systems/code-component-usage.ts +52 -0
- package/src/api/dto/design-systems/code-component.ts +101 -0
- package/src/api/dto/design-systems/code-history.ts +43 -0
- package/src/api/dto/design-systems/code-scan.ts +29 -0
- package/src/api/dto/design-systems/code-snapshots.ts +46 -0
- package/src/api/dto/design-systems/component.ts +40 -0
- package/src/api/dto/design-systems/contact.ts +11 -0
- package/src/api/dto/design-systems/data-source.ts +216 -0
- package/src/api/dto/design-systems/design-system.ts +75 -0
- package/src/api/dto/design-systems/documentation-search.ts +31 -0
- package/src/api/dto/design-systems/elements-diff.ts +14 -0
- package/src/api/dto/design-systems/figma-variables.ts +122 -0
- package/src/api/dto/design-systems/file.ts +71 -0
- package/src/api/dto/design-systems/import-job.ts +62 -0
- package/src/api/dto/design-systems/index.ts +24 -0
- package/src/api/dto/design-systems/members.ts +52 -0
- package/src/api/dto/design-systems/redirects.ts +33 -0
- package/src/api/dto/design-systems/role.ts +11 -0
- package/src/api/dto/design-systems/stats.ts +20 -0
- package/src/api/dto/design-systems/storybook.ts +45 -0
- package/src/api/dto/design-systems/user-design-systems.ts +10 -0
- package/src/api/dto/design-systems/version-room.ts +12 -0
- package/src/api/dto/design-systems/version.ts +56 -0
- package/src/api/dto/design-systems/view.ts +45 -0
- package/src/api/dto/design-tokens/design-token.ts +78 -0
- package/src/api/dto/design-tokens/index.ts +1 -0
- package/src/api/dto/documentation/analytics-v2.ts +80 -0
- package/src/api/dto/documentation/analytics.ts +32 -0
- package/src/api/dto/documentation/anchor.ts +15 -0
- package/src/api/dto/documentation/approvals.ts +21 -0
- package/src/api/dto/documentation/block-definition.ts +28 -0
- package/src/api/dto/documentation/block.ts +6 -0
- package/src/api/dto/documentation/documentation-page-snapshot.ts +18 -0
- package/src/api/dto/documentation/documentation.ts +34 -0
- package/src/api/dto/documentation/index.ts +11 -0
- package/src/api/dto/documentation/link-preview.ts +23 -0
- package/src/api/dto/documentation/publish.ts +23 -0
- package/src/api/dto/documentation/room.ts +12 -0
- package/src/api/dto/elements/components/figma-component-group.ts +19 -0
- package/src/api/dto/elements/components/figma-component.ts +56 -0
- package/src/api/dto/elements/components/index.ts +2 -0
- package/src/api/dto/elements/documentation/configuration.ts +20 -0
- package/src/api/dto/elements/documentation/draft-state.ts +37 -0
- package/src/api/dto/elements/documentation/group-action.ts +108 -0
- package/src/api/dto/elements/documentation/group-v1.ts +35 -0
- package/src/api/dto/elements/documentation/group-v2.ts +117 -0
- package/src/api/dto/elements/documentation/hierarchy.ts +25 -0
- package/src/api/dto/elements/documentation/index.ts +16 -0
- package/src/api/dto/elements/documentation/item-configuration-v1.ts +24 -0
- package/src/api/dto/elements/documentation/item-configuration-v2.ts +14 -0
- package/src/api/dto/elements/documentation/metadata.ts +8 -0
- package/src/api/dto/elements/documentation/page-actions-v2.ts +138 -0
- package/src/api/dto/elements/documentation/page-content.ts +15 -0
- package/src/api/dto/elements/documentation/page-dependencies.ts +30 -0
- package/src/api/dto/elements/documentation/page-v1.ts +21 -0
- package/src/api/dto/elements/documentation/page-v2.ts +132 -0
- package/src/api/dto/elements/documentation/settings.ts +9 -0
- package/src/api/dto/elements/documentation/structure.ts +37 -0
- package/src/api/dto/elements/elements-action-v2.ts +125 -0
- package/src/api/dto/elements/figma-nodes/figma-node-structure.ts +27 -0
- package/src/api/dto/elements/figma-nodes/figma-node-v1.ts +32 -0
- package/src/api/dto/elements/figma-nodes/figma-node-v2.ts +32 -0
- package/src/api/dto/elements/figma-nodes/figma-node.ts +103 -0
- package/src/api/dto/elements/figma-nodes/index.ts +5 -0
- package/src/api/dto/elements/figma-nodes/node-actions-v2.ts +25 -0
- package/src/api/dto/elements/frame-node-structures/frame-node-structure.ts +17 -0
- package/src/api/dto/elements/frame-node-structures/index.ts +1 -0
- package/src/api/dto/elements/get-elements-v2.ts +27 -0
- package/src/api/dto/elements/index.ts +7 -0
- package/src/api/dto/elements/properties/index.ts +2 -0
- package/src/api/dto/elements/properties/property-definitions.ts +75 -0
- package/src/api/dto/elements/properties/property-values.ts +50 -0
- package/src/api/dto/events/forge-project.ts +51 -0
- package/src/api/dto/events/index.ts +2 -0
- package/src/api/dto/events/workspace.ts +81 -0
- package/src/api/dto/export/exporter-property.ts +114 -0
- package/src/api/dto/export/exporter.ts +115 -0
- package/src/api/dto/export/filter.ts +20 -0
- package/src/api/dto/export/index.ts +5 -0
- package/src/api/dto/export/job.ts +114 -0
- package/src/api/dto/export/pipeline.ts +60 -0
- package/src/api/dto/figma-components/assets/download.ts +30 -0
- package/src/api/dto/figma-components/assets/index.ts +1 -0
- package/src/api/dto/figma-components/index.ts +1 -0
- package/src/api/dto/figma-exporter/figma-node.ts +11 -0
- package/src/api/dto/figma-exporter/index.ts +1 -0
- package/src/api/dto/files/files.ts +94 -0
- package/src/api/dto/files/index.ts +1 -0
- package/src/api/dto/forge/agent.ts +38 -0
- package/src/api/dto/forge/artifact.ts +94 -0
- package/src/api/dto/forge/feature-messages.ts +551 -0
- package/src/api/dto/forge/feature-room.ts +12 -0
- package/src/api/dto/forge/figma-node.ts +117 -0
- package/src/api/dto/forge/index.ts +28 -0
- package/src/api/dto/forge/iteration-message-old.ts +43 -0
- package/src/api/dto/forge/knowledge-item.ts +67 -0
- package/src/api/dto/forge/memory.ts +67 -0
- package/src/api/dto/forge/participant.ts +44 -0
- package/src/api/dto/forge/project-action.ts +123 -0
- package/src/api/dto/forge/project-artifact-room.ts +12 -0
- package/src/api/dto/forge/project-artifact.ts +85 -0
- package/src/api/dto/forge/project-context-feedback.ts +141 -0
- package/src/api/dto/forge/project-context-override.ts +41 -0
- package/src/api/dto/forge/project-context-scope.ts +23 -0
- package/src/api/dto/forge/project-context-v2.ts +228 -0
- package/src/api/dto/forge/project-context.ts +72 -0
- package/src/api/dto/forge/project-feature.ts +86 -0
- package/src/api/dto/forge/project-figma-node.ts +9 -0
- package/src/api/dto/forge/project-file.ts +48 -0
- package/src/api/dto/forge/project-invitation.ts +46 -0
- package/src/api/dto/forge/project-iteration-old.ts +54 -0
- package/src/api/dto/forge/project-member.ts +67 -0
- package/src/api/dto/forge/project-room.ts +12 -0
- package/src/api/dto/forge/project-section.ts +37 -0
- package/src/api/dto/forge/project.ts +105 -0
- package/src/api/dto/forge/relation.ts +34 -0
- package/src/api/dto/forge/threads.ts +153 -0
- package/src/api/dto/index.ts +25 -0
- package/src/api/dto/liveblocks/auth-response.ts +7 -0
- package/src/api/dto/liveblocks/index.ts +1 -0
- package/src/api/dto/mcp/index.ts +1 -0
- package/src/api/dto/mcp/stream.ts +17 -0
- package/src/api/dto/notifications/index.ts +2 -0
- package/src/api/dto/notifications/notifications.ts +65 -0
- package/src/api/dto/notifications/settings.ts +10 -0
- package/src/api/dto/portal/index.ts +1 -0
- package/src/api/dto/portal/portal-settings.ts +45 -0
- package/src/api/dto/sandboxes/index.ts +1 -0
- package/src/api/dto/sandboxes/template.ts +143 -0
- package/src/api/dto/storybook-sites/index.ts +1 -0
- package/src/api/dto/storybook-sites/storybook-sites.ts +60 -0
- package/src/api/dto/themes/index.ts +2 -0
- package/src/api/dto/themes/override.ts +27 -0
- package/src/api/dto/themes/theme.ts +53 -0
- package/src/api/dto/threads/index.ts +1 -0
- package/src/api/dto/threads/threads.ts +280 -0
- package/src/api/dto/trail-events/index.ts +1 -0
- package/src/api/dto/trail-events/trail-events.ts +172 -0
- package/src/api/dto/users/authenticated-user.ts +92 -0
- package/src/api/dto/users/index.ts +2 -0
- package/src/api/dto/users/user.ts +27 -0
- package/src/api/dto/workspaces/billing.ts +156 -0
- package/src/api/dto/workspaces/enums.ts +13 -0
- package/src/api/dto/workspaces/git.ts +32 -0
- package/src/api/dto/workspaces/index.ts +15 -0
- package/src/api/dto/workspaces/integrations.ts +34 -0
- package/src/api/dto/workspaces/invitations.ts +47 -0
- package/src/api/dto/workspaces/ip-whitelist.ts +33 -0
- package/src/api/dto/workspaces/knowledge-items-search.ts +37 -0
- package/src/api/dto/workspaces/login-screen.ts +42 -0
- package/src/api/dto/workspaces/membership.ts +55 -0
- package/src/api/dto/workspaces/npm-registry.ts +62 -0
- package/src/api/dto/workspaces/products.ts +45 -0
- package/src/api/dto/workspaces/subscription.ts +170 -0
- package/src/api/dto/workspaces/transfer-ownership.ts +7 -0
- package/src/api/dto/workspaces/untyped-data.ts +35 -0
- package/src/api/dto/workspaces/workspace.ts +49 -0
- package/src/api/endpoints/auth-tokens.ts +28 -0
- package/src/api/endpoints/codegen/codegen.ts +16 -0
- package/src/api/endpoints/codegen/ds-pipelines.ts +37 -0
- package/src/api/endpoints/codegen/exporters.ts +54 -0
- package/src/api/endpoints/codegen/index.ts +5 -0
- package/src/api/endpoints/codegen/jobs.ts +15 -0
- package/src/api/endpoints/codegen/pipelines.ts +55 -0
- package/src/api/endpoints/design-system/analytics.ts +14 -0
- package/src/api/endpoints/design-system/bff.ts +13 -0
- package/src/api/endpoints/design-system/code-snapshots.ts +47 -0
- package/src/api/endpoints/design-system/contact.ts +12 -0
- package/src/api/endpoints/design-system/design-systems.ts +90 -0
- package/src/api/endpoints/design-system/figma-node-structures.ts +20 -0
- package/src/api/endpoints/design-system/index.ts +11 -0
- package/src/api/endpoints/design-system/members.ts +24 -0
- package/src/api/endpoints/design-system/redirects.ts +46 -0
- package/src/api/endpoints/design-system/sources.ts +80 -0
- package/src/api/endpoints/design-system/storybook.ts +28 -0
- package/src/api/endpoints/design-system/versions/brands.ts +45 -0
- package/src/api/endpoints/design-system/versions/documentation.ts +107 -0
- package/src/api/endpoints/design-system/versions/ds-components.ts +30 -0
- package/src/api/endpoints/design-system/versions/elements-action.ts +65 -0
- package/src/api/endpoints/design-system/versions/elements.ts +27 -0
- package/src/api/endpoints/design-system/versions/figma-component-groups.ts +13 -0
- package/src/api/endpoints/design-system/versions/figma-components.ts +15 -0
- package/src/api/endpoints/design-system/versions/figma-frame-structures.ts +13 -0
- package/src/api/endpoints/design-system/versions/files.ts +43 -0
- package/src/api/endpoints/design-system/versions/import-jobs.ts +13 -0
- package/src/api/endpoints/design-system/versions/index.ts +19 -0
- package/src/api/endpoints/design-system/versions/overrides.ts +17 -0
- package/src/api/endpoints/design-system/versions/property-definitions.ts +43 -0
- package/src/api/endpoints/design-system/versions/property-values.ts +25 -0
- package/src/api/endpoints/design-system/versions/stats.ts +12 -0
- package/src/api/endpoints/design-system/versions/themes.ts +35 -0
- package/src/api/endpoints/design-system/versions/token-collections.ts +13 -0
- package/src/api/endpoints/design-system/versions/token-groups.ts +30 -0
- package/src/api/endpoints/design-system/versions/tokens.ts +29 -0
- package/src/api/endpoints/design-system/versions/versions.ts +90 -0
- package/src/api/endpoints/feedback.ts +60 -0
- package/src/api/endpoints/files.ts +25 -0
- package/src/api/endpoints/forge/agents.ts +54 -0
- package/src/api/endpoints/forge/artifacts.ts +54 -0
- package/src/api/endpoints/forge/documents.ts +18 -0
- package/src/api/endpoints/forge/feature-artifacts.ts +39 -0
- package/src/api/endpoints/forge/feature-iterations.ts +49 -0
- package/src/api/endpoints/forge/feature-messages.ts +68 -0
- package/src/api/endpoints/forge/features.ts +63 -0
- package/src/api/endpoints/forge/forge.ts +38 -0
- package/src/api/endpoints/forge/index.ts +16 -0
- package/src/api/endpoints/forge/iteration-tags.ts +13 -0
- package/src/api/endpoints/forge/memory.ts +41 -0
- package/src/api/endpoints/forge/project-contexts.ts +49 -0
- package/src/api/endpoints/forge/project-files.ts +41 -0
- package/src/api/endpoints/forge/project-invitations.ts +39 -0
- package/src/api/endpoints/forge/project-iterations.ts +65 -0
- package/src/api/endpoints/forge/project-members.ts +55 -0
- package/src/api/endpoints/forge/projects.ts +56 -0
- package/src/api/endpoints/index.ts +13 -0
- package/src/api/endpoints/liveblocks.ts +14 -0
- package/src/api/endpoints/mcp/index.ts +1 -0
- package/src/api/endpoints/mcp/streams.ts +21 -0
- package/src/api/endpoints/sandboxes/builds.ts +30 -0
- package/src/api/endpoints/sandboxes/index.ts +3 -0
- package/src/api/endpoints/sandboxes/sandboxes.ts +13 -0
- package/src/api/endpoints/sandboxes/templates.ts +16 -0
- package/src/api/endpoints/storybook-sites.ts +42 -0
- package/src/api/endpoints/threads.ts +38 -0
- package/src/api/endpoints/users.ts +26 -0
- package/src/api/endpoints/workspaces/billing.ts +24 -0
- package/src/api/endpoints/workspaces/chat-threads.ts +95 -0
- package/src/api/endpoints/workspaces/index.ts +9 -0
- package/src/api/endpoints/workspaces/integrations.ts +15 -0
- package/src/api/endpoints/workspaces/invites.ts +34 -0
- package/src/api/endpoints/workspaces/knowledge-items.ts +59 -0
- package/src/api/endpoints/workspaces/members.ts +31 -0
- package/src/api/endpoints/workspaces/npm-register.ts +20 -0
- package/src/api/endpoints/workspaces/subscription.ts +31 -0
- package/src/api/endpoints/workspaces/workspaces.ts +84 -0
- package/src/api/index.ts +6 -0
- package/src/api/payloads/design-systems/code-snapshots.ts +27 -0
- package/src/api/payloads/design-systems/index.ts +3 -0
- package/src/api/payloads/design-systems/update-design-system.ts +42 -0
- package/src/api/payloads/design-systems/version.ts +29 -0
- package/src/api/payloads/documentation/analytics.ts +36 -0
- package/src/api/payloads/documentation/block-definitions.ts +18 -0
- package/src/api/payloads/documentation/design-data-doc-diff.ts +7 -0
- package/src/api/payloads/documentation/index.ts +3 -0
- package/src/api/payloads/export/index.ts +1 -0
- package/src/api/payloads/export/pipeline.ts +111 -0
- package/src/api/payloads/index.ts +6 -0
- package/src/api/payloads/liveblocks/auth.ts +7 -0
- package/src/api/payloads/liveblocks/index.ts +1 -0
- package/src/api/payloads/users/index.ts +1 -0
- package/src/api/payloads/users/notifications/index.ts +1 -0
- package/src/api/payloads/users/notifications/notification-settings.ts +17 -0
- package/src/api/payloads/workspaces/index.ts +2 -0
- package/src/api/payloads/workspaces/workspace-configuration.ts +62 -0
- package/src/api/payloads/workspaces/workspace-integrations.ts +35 -0
- package/src/api/transport/index.ts +2 -0
- package/src/api/transport/request-executor-error.ts +60 -0
- package/src/api/transport/request-executor.ts +94 -0
- package/src/events/design-system.ts +21 -0
- package/src/events/event.ts +6 -0
- package/src/events/index.ts +2 -0
- package/src/index.ts +5 -0
- package/src/sync/docs-local-action-executor.ts +412 -0
- package/src/sync/docs-structure-repo.ts +283 -0
- package/src/sync/index.ts +5 -0
- package/src/sync/project-content-repo.ts +215 -0
- package/src/sync/project-local-action-executor.ts +415 -0
- package/src/sync/types.ts +37 -0
- package/src/utils/figma.ts +72 -0
- package/src/utils/hash.ts +62 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/query.ts +41 -0
- package/src/utils/redirect-validation.ts +76 -0
- package/src/yjs/design-system-content/documentation-hierarchy.ts +35 -0
- package/src/yjs/design-system-content/index.ts +2 -0
- package/src/yjs/design-system-content/item-configuration.ts +62 -0
- package/src/yjs/docs-editor/blocks-to-prosemirror.ts +764 -0
- package/src/yjs/docs-editor/index.ts +7 -0
- package/src/yjs/docs-editor/list-tree-builder.ts +127 -0
- package/src/yjs/docs-editor/mock.ts +2271 -0
- package/src/yjs/docs-editor/model/block.ts +8 -0
- package/src/yjs/docs-editor/model/index.ts +2 -0
- package/src/yjs/docs-editor/model/page.ts +8 -0
- package/src/yjs/docs-editor/prosemirror/index.ts +3 -0
- package/src/yjs/docs-editor/prosemirror/inner-editor-schema.ts +145 -0
- package/src/yjs/docs-editor/prosemirror/main-editor-schema.ts +577 -0
- package/src/yjs/docs-editor/prosemirror/types.ts +19 -0
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +986 -0
- package/src/yjs/docs-editor/utils.ts +115 -0
- package/src/yjs/feature-room/backend.ts +36 -0
- package/src/yjs/feature-room/base.ts +109 -0
- package/src/yjs/feature-room/frontend.ts +53 -0
- package/src/yjs/feature-room/index.ts +3 -0
- package/src/yjs/forge-project-room/backend.ts +59 -0
- package/src/yjs/forge-project-room/base.ts +190 -0
- package/src/yjs/forge-project-room/index.ts +2 -0
- package/src/yjs/index.ts +7 -0
- package/src/yjs/thread-room/backend.ts +32 -0
- package/src/yjs/thread-room/base.ts +71 -0
- package/src/yjs/thread-room/frontend.ts +39 -0
- package/src/yjs/thread-room/index.ts +3 -0
- package/src/yjs/utils/index.ts +1 -0
- package/src/yjs/utils/key-value-storage.ts +57 -0
- package/src/yjs/version-room/backend.ts +101 -0
- package/src/yjs/version-room/base.ts +323 -0
- package/src/yjs/version-room/compute-dto.ts +387 -0
- package/src/yjs/version-room/frontend.ts +76 -0
- package/src/yjs/version-room/index.ts +6 -0
- package/src/yjs/version-room/types.ts +31 -0
- package/src/yjs/version-room/utils.ts +109 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supernova-studio/client",
|
|
3
|
-
"version": "1.96.
|
|
3
|
+
"version": "1.96.7",
|
|
4
4
|
"description": "Supernova Data Models",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": {
|
|
@@ -13,33 +13,44 @@
|
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"module": "./dist/index.mjs",
|
|
17
16
|
"default": "./dist/index.js"
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
"files": [
|
|
22
|
-
"dist/**"
|
|
21
|
+
"dist/**",
|
|
22
|
+
"src/**"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "tsup",
|
|
26
|
-
"
|
|
25
|
+
"build": "npm run index && tsc -b && tsup",
|
|
26
|
+
"emit-types": "tsc -b",
|
|
27
|
+
"typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
|
|
27
28
|
"test:unit": "vitest run",
|
|
28
29
|
"index": "node ./create-indexes.js"
|
|
29
30
|
},
|
|
30
31
|
"author": "",
|
|
31
32
|
"license": "ISC",
|
|
32
33
|
"dependencies": {
|
|
34
|
+
"@supernova-studio/model": "1.96.7",
|
|
33
35
|
"p-queue": "^8.0.1",
|
|
36
|
+
"prosemirror-model": "^1.25.4",
|
|
34
37
|
"queue-promise": "^2.2.1",
|
|
35
38
|
"y-prosemirror": "^1.3.7",
|
|
39
|
+
"y-protocols": "^1.0.7",
|
|
36
40
|
"y-utility": "0.1.4",
|
|
37
|
-
"prosemirror-model": "^1.25.4",
|
|
38
41
|
"yjs": "^13.6.29",
|
|
39
42
|
"zod": "3.25.76"
|
|
40
43
|
},
|
|
41
44
|
"devDependencies": {
|
|
45
|
+
"date-fns": "2.30.0",
|
|
42
46
|
"tsup": "8.5.0",
|
|
43
|
-
"typescript": "5.8.3"
|
|
47
|
+
"typescript": "5.8.3",
|
|
48
|
+
"vite-tsconfig-paths": "4.3.2",
|
|
49
|
+
"vitest": "4.1.4"
|
|
50
|
+
},
|
|
51
|
+
"module": "./dist/index.mjs",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/Supernova-Studio/cloud.git"
|
|
44
55
|
}
|
|
45
56
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthTokensEndpoint,
|
|
3
|
+
CodegenEndpoint,
|
|
4
|
+
FeedbackEndpoint,
|
|
5
|
+
FilesEndpoint,
|
|
6
|
+
StorybookSitesEndpoint,
|
|
7
|
+
WorkspacesEndpoint,
|
|
8
|
+
} from "./endpoints";
|
|
9
|
+
import { DesignSystemsEndpoint } from "./endpoints/design-system";
|
|
10
|
+
import { ForgeEndpoint } from "./endpoints/forge";
|
|
11
|
+
import { LiveblocksEndpoint } from "./endpoints/liveblocks";
|
|
12
|
+
import { MCPStreamsEndpoint } from "./endpoints/mcp";
|
|
13
|
+
import { SandboxesEndpoint } from "./endpoints/sandboxes";
|
|
14
|
+
import { ThreadsEndpoint } from "./endpoints/threads";
|
|
15
|
+
import { UsersEndpoint } from "./endpoints/users";
|
|
16
|
+
import { RequestExecutor } from "./transport/request-executor";
|
|
17
|
+
|
|
18
|
+
type SupernovaApiClientConfig = {
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
accessToken: string;
|
|
21
|
+
apiSecret?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export class SupernovaApiClient {
|
|
25
|
+
readonly authTokens: AuthTokensEndpoint;
|
|
26
|
+
readonly users: UsersEndpoint;
|
|
27
|
+
readonly workspaces: WorkspacesEndpoint;
|
|
28
|
+
readonly designSystems: DesignSystemsEndpoint;
|
|
29
|
+
readonly codegen: CodegenEndpoint;
|
|
30
|
+
readonly liveblocks: LiveblocksEndpoint;
|
|
31
|
+
readonly feedback: FeedbackEndpoint;
|
|
32
|
+
readonly forge: ForgeEndpoint;
|
|
33
|
+
readonly files: FilesEndpoint;
|
|
34
|
+
readonly threads: ThreadsEndpoint;
|
|
35
|
+
readonly mcpStreams: MCPStreamsEndpoint;
|
|
36
|
+
readonly sandboxes: SandboxesEndpoint;
|
|
37
|
+
readonly storybookSites: StorybookSitesEndpoint;
|
|
38
|
+
|
|
39
|
+
constructor(readonly config: SupernovaApiClientConfig) {
|
|
40
|
+
const apiSecret = config.apiSecret ?? process?.env?.SUPERNOVA_API_SECRET;
|
|
41
|
+
|
|
42
|
+
const requestExecutor = new RequestExecutor({
|
|
43
|
+
apiSecret,
|
|
44
|
+
baseUrl: config.baseUrl,
|
|
45
|
+
accessToken: config.accessToken,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this.authTokens = new AuthTokensEndpoint(requestExecutor);
|
|
49
|
+
this.users = new UsersEndpoint(requestExecutor);
|
|
50
|
+
this.workspaces = new WorkspacesEndpoint(requestExecutor);
|
|
51
|
+
this.designSystems = new DesignSystemsEndpoint(requestExecutor);
|
|
52
|
+
this.codegen = new CodegenEndpoint(requestExecutor);
|
|
53
|
+
this.liveblocks = new LiveblocksEndpoint(requestExecutor);
|
|
54
|
+
this.feedback = new FeedbackEndpoint(requestExecutor);
|
|
55
|
+
this.forge = new ForgeEndpoint(requestExecutor);
|
|
56
|
+
this.files = new FilesEndpoint(requestExecutor);
|
|
57
|
+
this.threads = new ThreadsEndpoint(requestExecutor);
|
|
58
|
+
this.mcpStreams = new MCPStreamsEndpoint(requestExecutor);
|
|
59
|
+
this.sandboxes = new SandboxesEndpoint(requestExecutor);
|
|
60
|
+
this.storybookSites = new StorybookSitesEndpoint(requestExecutor);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PublishedDocPageVisitsEntry, SupernovaException } from "@supernova-studio/model";
|
|
2
|
+
import {
|
|
3
|
+
DTODocumentationAnalyticsTimeFrame,
|
|
4
|
+
DTOPublishedDocAnalyticsComparisonData,
|
|
5
|
+
DTOPublishedDocPageAnalyticsComparisonData,
|
|
6
|
+
} from "../../dto";
|
|
7
|
+
import { documentationAnalyticsToGlobalDto } from "./page-visits-to-dto";
|
|
8
|
+
|
|
9
|
+
//
|
|
10
|
+
// Page analytics
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
type PageAnalyticsInput = {
|
|
14
|
+
pagePersistentId: string;
|
|
15
|
+
priorDataPoints: PublishedDocPageVisitsEntry[];
|
|
16
|
+
currentDataPoints: PublishedDocPageVisitsEntry[];
|
|
17
|
+
timeFrame: DTODocumentationAnalyticsTimeFrame;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function documentationAnalyticsToPageComparisonDto(
|
|
21
|
+
input: PageAnalyticsInput
|
|
22
|
+
): DTOPublishedDocPageAnalyticsComparisonData {
|
|
23
|
+
const { pagePersistentId } = input;
|
|
24
|
+
|
|
25
|
+
function validateDataPoint(dataPoint: PublishedDocPageVisitsEntry) {
|
|
26
|
+
if (dataPoint.pagePersistentId !== pagePersistentId) {
|
|
27
|
+
throw SupernovaException.shouldNotHappen(`Tried to include invalid analytics data point!`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
input.priorDataPoints.forEach(validateDataPoint);
|
|
32
|
+
input.currentDataPoints.forEach(validateDataPoint);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...documentationAnalyticsToComparisonDto(input),
|
|
36
|
+
pagePersistentId,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//
|
|
41
|
+
// Global analytics
|
|
42
|
+
//
|
|
43
|
+
|
|
44
|
+
type GlobalAnalyticsInput = {
|
|
45
|
+
priorDataPoints: PublishedDocPageVisitsEntry[];
|
|
46
|
+
currentDataPoints: PublishedDocPageVisitsEntry[];
|
|
47
|
+
timeFrame: DTODocumentationAnalyticsTimeFrame;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function documentationAnalyticsToComparisonDto(
|
|
51
|
+
input: GlobalAnalyticsInput
|
|
52
|
+
): DTOPublishedDocAnalyticsComparisonData {
|
|
53
|
+
const { timeFrame } = input;
|
|
54
|
+
|
|
55
|
+
const priorDataPoints = documentationAnalyticsToGlobalDto(input.priorDataPoints);
|
|
56
|
+
const currentDataPoints = documentationAnalyticsToGlobalDto(input.currentDataPoints);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
timeFrame,
|
|
60
|
+
priorSessionCount: priorDataPoints.reduce((sum, d) => sum + d.sessions, 0),
|
|
61
|
+
priorVisitCount: priorDataPoints.reduce((sum, d) => sum + d.visits, 0),
|
|
62
|
+
currentSessionCount: currentDataPoints.reduce((sum, d) => sum + d.sessions, 0),
|
|
63
|
+
currentVisitCount: currentDataPoints.reduce((sum, d) => sum + d.visits, 0),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { groupBy, nonNullishFilter, PublishedDocPageVisitsEntry } from "@supernova-studio/model";
|
|
2
|
+
import { DTOPublishedDocPageVisitData, DTOPublishedDocVisitData } from "../../dto";
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Analytics data conversion
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function documentationAnalyticsToGlobalDto(entries: PublishedDocPageVisitsEntry[]): DTOPublishedDocVisitData[] {
|
|
9
|
+
return squashAndConvertToDto(entries);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// Analytics data per page conversion
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
export function documentationAnalyticsToPageDto(
|
|
17
|
+
entries: PublishedDocPageVisitsEntry[]
|
|
18
|
+
): DTOPublishedDocPageVisitData[] {
|
|
19
|
+
// Group by page id
|
|
20
|
+
const byPageIdEntries = Array.from(groupBy(entries, e => e.pagePersistentId).entries());
|
|
21
|
+
byPageIdEntries.sort((lhs, rhs) => lhs[0].localeCompare(rhs[0]));
|
|
22
|
+
|
|
23
|
+
return byPageIdEntries.flatMap(([pagePersistentId, entries]) => {
|
|
24
|
+
const dtoWithoutPageId = squashAndConvertToDto(entries);
|
|
25
|
+
return dtoWithoutPageId.map(dto => ({ ...dto, pagePersistentId }));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//
|
|
30
|
+
// Base
|
|
31
|
+
//
|
|
32
|
+
|
|
33
|
+
function squashAndConvertToDto(entries: PublishedDocPageVisitsEntry[]): DTOPublishedDocVisitData[] {
|
|
34
|
+
// Group by beginning of day
|
|
35
|
+
const byDay = groupBy(entries, e => getStartOfUTCDay(e.timestamp));
|
|
36
|
+
|
|
37
|
+
const obj = Object.fromEntries(
|
|
38
|
+
Array.from(byDay.entries()).map(([date, values]) => [new Date(date).toISOString(), values.length])
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Convert model to DTO by squashing model entries that belong to the same day
|
|
42
|
+
return Array.from(byDay.entries()).map(([startOfDay, dayEntries]) => {
|
|
43
|
+
const firstEntry = dayEntries[0];
|
|
44
|
+
|
|
45
|
+
// Sessions are number of unique user IDs who visited the page during that day
|
|
46
|
+
const uniqueSessions = new Set(dayEntries.map(e => e.anonymousId).filter(nonNullishFilter)).size;
|
|
47
|
+
|
|
48
|
+
// Visits are sum of all recorded visits of the page during that day
|
|
49
|
+
const visitsSum = dayEntries.reduce((prev, curr) => prev + curr.visits, 0);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
versionId: firstEntry.versionId,
|
|
53
|
+
timestamp: new Date(startOfDay),
|
|
54
|
+
sessions: uniqueSessions,
|
|
55
|
+
visits: visitsSum,
|
|
56
|
+
|
|
57
|
+
...(firstEntry.locale && { locale: firstEntry.locale }),
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getStartOfUTCDay(date: Date): number {
|
|
63
|
+
const year = date.getUTCFullYear();
|
|
64
|
+
const month = date.getUTCMonth();
|
|
65
|
+
const day = date.getUTCDate();
|
|
66
|
+
|
|
67
|
+
return Date.UTC(year, month, day, 0, 0, 0, 0);
|
|
68
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { groupBy, PublishedDocPageVisitsEntry } from "@supernova-studio/model";
|
|
2
|
+
import { DTODocumentationAnalyticsTimeFrame, DTOPublishedDocVisitHeatMapWeek } from "../../dto";
|
|
3
|
+
|
|
4
|
+
export function documentationAnalyticsToHeatMapDto(
|
|
5
|
+
entries: PublishedDocPageVisitsEntry[],
|
|
6
|
+
timeFrame: DTODocumentationAnalyticsTimeFrame
|
|
7
|
+
): DTOPublishedDocVisitHeatMapWeek {
|
|
8
|
+
const byWeekDay = groupBy(entries, e => e.timestamp.getUTCDay());
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
timeFrame,
|
|
12
|
+
mon: entriesToHeatmapDay(byWeekDay.get(1)),
|
|
13
|
+
tue: entriesToHeatmapDay(byWeekDay.get(2)),
|
|
14
|
+
wed: entriesToHeatmapDay(byWeekDay.get(3)),
|
|
15
|
+
thu: entriesToHeatmapDay(byWeekDay.get(4)),
|
|
16
|
+
fri: entriesToHeatmapDay(byWeekDay.get(5)),
|
|
17
|
+
sat: entriesToHeatmapDay(byWeekDay.get(6)),
|
|
18
|
+
sun: entriesToHeatmapDay(byWeekDay.get(7)),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function entriesToHeatmapDay(entries: PublishedDocPageVisitsEntry[] | undefined): number[] {
|
|
23
|
+
const byHour = groupBy(entries ?? [], e => e.timestamp.getUTCHours());
|
|
24
|
+
|
|
25
|
+
return [
|
|
26
|
+
sumVisits(byHour.get(0), byHour.get(1)), // 0am-2am
|
|
27
|
+
sumVisits(byHour.get(2), byHour.get(3)), // 2am-4am
|
|
28
|
+
sumVisits(byHour.get(4), byHour.get(5)), // 4am-6am
|
|
29
|
+
sumVisits(byHour.get(6), byHour.get(7)), // 6am-6am
|
|
30
|
+
sumVisits(byHour.get(8), byHour.get(9)), // 8am-6am
|
|
31
|
+
sumVisits(byHour.get(10), byHour.get(11)), // 10am-12pm
|
|
32
|
+
sumVisits(byHour.get(12), byHour.get(13)), // 12pm-2pm
|
|
33
|
+
sumVisits(byHour.get(14), byHour.get(15)), // 2pm-4pm
|
|
34
|
+
sumVisits(byHour.get(16), byHour.get(17)), // 4pm-6pm
|
|
35
|
+
sumVisits(byHour.get(18), byHour.get(19)), // 6pm-8pm
|
|
36
|
+
sumVisits(byHour.get(20), byHour.get(21)), // 8pm-10pm
|
|
37
|
+
sumVisits(byHour.get(22), byHour.get(23)), // 10pm-12pm
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function sumVisits(...entryArrays: (PublishedDocPageVisitsEntry[] | undefined)[]) {
|
|
42
|
+
let sum = 0;
|
|
43
|
+
|
|
44
|
+
entryArrays.forEach(a => {
|
|
45
|
+
a?.forEach(e => (sum += e.visits));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return sum;
|
|
49
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DocumentationItemConfigurationV2, DocumentationPageV1, groupBy } from "@supernova-studio/model";
|
|
2
|
+
import { VersionRoomDocsPage, VersionRoomDocsPageGroup } from "../../../yjs/version-room/types";
|
|
3
|
+
import { LocalDocsPage, LocalDocsPageGroup } from "../../../sync/types";
|
|
4
|
+
import { DTODocumentationGroupV2 } from "../../dto";
|
|
5
|
+
import {
|
|
6
|
+
documentationItemConfigurationToDTOV2,
|
|
7
|
+
getDtoDefaultItemConfigurationV2,
|
|
8
|
+
} from "./documentation-item-configuration-v2-to-dto";
|
|
9
|
+
import { applyPrivacyConfigurationToNestedItems } from "./documentation-page-to-dto-utils";
|
|
10
|
+
|
|
11
|
+
type DocsPage = LocalDocsPage | VersionRoomDocsPage;
|
|
12
|
+
type DocsPageGroup = LocalDocsPageGroup | VersionRoomDocsPageGroup;
|
|
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 elementGroupsToDocumentationGroupDTOV2(
|
|
21
|
+
groups: DocsPageGroup[],
|
|
22
|
+
pages: (DocumentationPageV1 | DocsPage)[]
|
|
23
|
+
): DTODocumentationGroupV2[] {
|
|
24
|
+
const childrenIdsMap = calculateChildrenIdsMapV2(pages, groups);
|
|
25
|
+
|
|
26
|
+
return groups.map(group => elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function elementGroupsToDocumentationGroupFixedConfigurationDTOV2(
|
|
30
|
+
groups: DocsPageGroup[],
|
|
31
|
+
pages: (DocumentationPageV1 | DocsPage)[]
|
|
32
|
+
): DTODocumentationGroupV2[] {
|
|
33
|
+
const childrenIdsMap = calculateChildrenIdsMapV2(pages, groups);
|
|
34
|
+
|
|
35
|
+
const { groups: fixedGroups } = applyPrivacyConfigurationToNestedItems<
|
|
36
|
+
DocumentationPageV1 | DocsPage,
|
|
37
|
+
DocsPageGroup,
|
|
38
|
+
DocumentationItemConfigurationV2
|
|
39
|
+
>(pages, groups, getDtoDefaultItemConfigurationV2);
|
|
40
|
+
|
|
41
|
+
return fixedGroups.map(group => elementGroupToDocumentationGroupStructureDTOV2(group, childrenIdsMap));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function elementGroupToDocumentationGroupStructureDTOV2(
|
|
45
|
+
group: DocsPageGroup,
|
|
46
|
+
childrenIdsMap: Map<string, string[]>
|
|
47
|
+
): DTODocumentationGroupV2 {
|
|
48
|
+
const childrenIds = childrenIdsMap.get(group.persistentId) ?? [];
|
|
49
|
+
|
|
50
|
+
if (!group.shortPersistentId) {
|
|
51
|
+
throw new Error(`Short persistent id is required for docs groups, group id: ${group.persistentId}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
id: "to_be_removed",
|
|
56
|
+
designSystemVersionId: group.designSystemVersionId,
|
|
57
|
+
persistentId: group.persistentId,
|
|
58
|
+
slug: group.slug,
|
|
59
|
+
userSlug: group.userSlug,
|
|
60
|
+
createdAt: group.createdAt,
|
|
61
|
+
updatedAt: group.updatedAt,
|
|
62
|
+
title: group.meta.name,
|
|
63
|
+
configuration: documentationItemConfigurationToDTOV2(group?.data?.configuration),
|
|
64
|
+
childrenIds: childrenIds,
|
|
65
|
+
isRoot: !group.parentPersistentId,
|
|
66
|
+
groupBehavior: group.data?.behavior ?? "Group",
|
|
67
|
+
shortPersistentId: group.shortPersistentId,
|
|
68
|
+
type: "Group",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function calculateChildrenIdsMapV2(
|
|
73
|
+
elements: { persistentId: string; parentPersistentId: string; sortOrder: number }[],
|
|
74
|
+
groups: DocsPageGroup[]
|
|
75
|
+
): Map<string, string[]> {
|
|
76
|
+
const byParentId = groupBy([...elements, ...groups], e => e.parentPersistentId);
|
|
77
|
+
|
|
78
|
+
const childrenIdsMap = new Map<string, string[]>();
|
|
79
|
+
|
|
80
|
+
for (const [parentPersistentId, children] of byParentId) {
|
|
81
|
+
if (!parentPersistentId) continue;
|
|
82
|
+
children.sort((lhs, rhs) => lhs.sortOrder - rhs.sortOrder);
|
|
83
|
+
|
|
84
|
+
childrenIdsMap.set(
|
|
85
|
+
parentPersistentId,
|
|
86
|
+
children.map(c => c.persistentId)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return childrenIdsMap;
|
|
91
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|