@supernova-studio/client 1.96.5 → 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 +101428 -143199
- package/dist/index.d.ts +101428 -143199
- package/dist/index.js +489 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5607 -5217
- 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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const figmaFileIdRegex = /^[0-9a-zA-Z]{22,128}$/;
|
|
2
|
+
const nodeIdRegex = /^\d+-\d+$/;
|
|
3
|
+
const nodeTypeRegex = /^[0-9a-zA-Z]^/;
|
|
4
|
+
|
|
5
|
+
export enum ParsedFigmaFileURLError {
|
|
6
|
+
InvalidUrl = "InvalidUrl",
|
|
7
|
+
InvalidFigmaFileId = "InvalidFigmaFileId",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ParsedFigmaFileURL =
|
|
11
|
+
| {
|
|
12
|
+
status: "Success";
|
|
13
|
+
fileId: string;
|
|
14
|
+
fileName: string | null;
|
|
15
|
+
nodeId: string | null;
|
|
16
|
+
nodeType: string | null;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
status: "Error";
|
|
20
|
+
error: ParsedFigmaFileURLError;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const FigmaUtils = {
|
|
24
|
+
tryParseFigmaFileURL(urlString: string): ParsedFigmaFileURL {
|
|
25
|
+
if (!URL.canParse(urlString)) {
|
|
26
|
+
return { status: "Error", error: ParsedFigmaFileURLError.InvalidUrl };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Validate that this is a Figma URL
|
|
30
|
+
const url = new URL(urlString);
|
|
31
|
+
if (!url.hostname.endsWith("figma.com")) {
|
|
32
|
+
return { status: "Error", error: ParsedFigmaFileURLError.InvalidUrl };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Validate that the URL type is the correct one (pointing to a design file)
|
|
36
|
+
const pathSegments = url.pathname.split("/");
|
|
37
|
+
if (pathSegments[1] !== "design" && pathSegments[1] !== "file") {
|
|
38
|
+
return { status: "Error", error: ParsedFigmaFileURLError.InvalidUrl };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Validate Figma file ID
|
|
42
|
+
const fileId = pathSegments[2];
|
|
43
|
+
if (!fileId || !fileId.match(figmaFileIdRegex)) {
|
|
44
|
+
return { status: "Error", error: ParsedFigmaFileURLError.InvalidFigmaFileId };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Parse Figma file name
|
|
48
|
+
let fileName: string | null = null;
|
|
49
|
+
const rawFileName = pathSegments[3];
|
|
50
|
+
if (rawFileName) {
|
|
51
|
+
fileName = rawFileName.replaceAll("-", " ");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Parse node id
|
|
55
|
+
let nodeId: string | null = null;
|
|
56
|
+
const nodeIdRaw = url.searchParams.get("node-id");
|
|
57
|
+
if (nodeIdRaw && nodeIdRaw.match(nodeIdRegex)) {
|
|
58
|
+
nodeId = nodeIdRaw.replace("-", ":");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Parse node type
|
|
62
|
+
let nodeType: string | null = null;
|
|
63
|
+
const nodeTypeRaw = url.searchParams.get("node-type");
|
|
64
|
+
if (nodeTypeRaw && nodeTypeRaw.match(nodeTypeRegex)) {
|
|
65
|
+
nodeType = nodeTypeRaw;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { status: "Success", fileId, fileName, nodeId, nodeType };
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// https://www.figma.com/design/U3Mg3I8WbvqF6CcZtRJM7w?node-id=2-3&t=9Qev2vhsldyFMhuE-1
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function hash(input: string): string {
|
|
2
|
+
return farmhash(input).toString(16);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function farmhash(input: string): number {
|
|
6
|
+
const seed = 0x9e3779b9;
|
|
7
|
+
let hash = seed;
|
|
8
|
+
|
|
9
|
+
for (let i = 0; i < input.length; i++) {
|
|
10
|
+
const charCode = input.charCodeAt(i);
|
|
11
|
+
hash ^= charCode;
|
|
12
|
+
hash = Math.imul(hash, 0x5bd1e995);
|
|
13
|
+
hash ^= hash >>> 15;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
hash = Math.imul(hash, 0x5bd1e995);
|
|
17
|
+
hash ^= hash >>> 13;
|
|
18
|
+
hash = Math.imul(hash, 0x5bd1e995);
|
|
19
|
+
hash ^= hash >>> 15;
|
|
20
|
+
|
|
21
|
+
return hash >>> 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function prepareObject(obj: any): any {
|
|
25
|
+
if (obj === null || typeof obj !== "object") {
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(obj)) {
|
|
29
|
+
return obj.map(prepareObject);
|
|
30
|
+
}
|
|
31
|
+
const sortedObj: any = {};
|
|
32
|
+
for (const key of Object.keys(obj).sort()) {
|
|
33
|
+
if (obj[key] === null || obj[key] === undefined) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
sortedObj[key] = prepareObject(obj[key]);
|
|
37
|
+
}
|
|
38
|
+
return sortedObj;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function generateHash(input: object | string, debug = false): string {
|
|
42
|
+
if (typeof input === "object") {
|
|
43
|
+
const sanitized = JSON.stringify(prepareObject(input));
|
|
44
|
+
if (debug) {
|
|
45
|
+
console.log("Hashing sanitized string:");
|
|
46
|
+
console.log(sanitized);
|
|
47
|
+
}
|
|
48
|
+
return hash(sanitized);
|
|
49
|
+
} else {
|
|
50
|
+
try {
|
|
51
|
+
const obj = JSON.parse(input);
|
|
52
|
+
const sanitized = JSON.stringify(prepareObject(obj));
|
|
53
|
+
if (debug) {
|
|
54
|
+
console.log("Hashing sanitized string:");
|
|
55
|
+
console.log(sanitized);
|
|
56
|
+
}
|
|
57
|
+
return hash(sanitized);
|
|
58
|
+
} catch {
|
|
59
|
+
return hash(input);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
type CompatibleValue = number | string | boolean | undefined;
|
|
4
|
+
type QueryObject = Record<string, CompatibleValue | CompatibleValue[]>;
|
|
5
|
+
|
|
6
|
+
export function serializeQuery(query: QueryObject): URLSearchParams {
|
|
7
|
+
const queryWithStrings = Object.fromEntries(
|
|
8
|
+
Object.entries(query)
|
|
9
|
+
.filter(e => !!e[1])
|
|
10
|
+
.map(([k, v]) => {
|
|
11
|
+
if (Array.isArray(v)) {
|
|
12
|
+
return [k, v.join(", ")];
|
|
13
|
+
} else {
|
|
14
|
+
return [k, v!.toString()];
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return new URLSearchParams(queryWithStrings);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function zodQueryBoolean() {
|
|
23
|
+
return z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.transform(string => {
|
|
27
|
+
// Not provided
|
|
28
|
+
if (!string) return undefined;
|
|
29
|
+
|
|
30
|
+
const lc = string.toLowerCase();
|
|
31
|
+
|
|
32
|
+
// False
|
|
33
|
+
if (lc === "0" || lc === "false") return false;
|
|
34
|
+
|
|
35
|
+
// True
|
|
36
|
+
if (lc === "1" || lc === "true") return true;
|
|
37
|
+
|
|
38
|
+
// Unknown
|
|
39
|
+
return undefined;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const exhaustiveInvalidUriPaths = {
|
|
2
|
+
emptyPath: "",
|
|
3
|
+
spacesInPath: "/invalid path/with spaces",
|
|
4
|
+
specialCharacter1: "/path/with|invalid>characters",
|
|
5
|
+
specialCharacter2: "/path/with<invalid*characters",
|
|
6
|
+
specialCharacter3: "/path/{invalid}?characters",
|
|
7
|
+
consecutiveSlashes: "/path//with///too/many/slashes",
|
|
8
|
+
unencodedPercent: "/path/with/unencoded%percent",
|
|
9
|
+
unencodedSpaces: "/path/with unencoded spaces",
|
|
10
|
+
fragmentIdentifier: "/path/with#fragment",
|
|
11
|
+
queryParameters: "/path/with?query=parameter",
|
|
12
|
+
nullCharacter: "/path/with/\u0000nullcharacter",
|
|
13
|
+
onlySlash: "/",
|
|
14
|
+
controlCharacter: "/path/with/control\0character",
|
|
15
|
+
extremelyLongPath: "/" + "a".repeat(2047),
|
|
16
|
+
invalidStartCharacter: "///path/starting/with/slashes",
|
|
17
|
+
invalidStartCharacterColon: ":/path/starting/with/colon",
|
|
18
|
+
invalidTrailingDot: "/path/ending/with/dot.",
|
|
19
|
+
invalidPercentEncoding1: "/path/with/%2",
|
|
20
|
+
invalidPercentEncoding2: "/path/with/%ZZ",
|
|
21
|
+
invalidPercentEncoding3: "/path/with/%G1",
|
|
22
|
+
reservedCharacter1: "/path/with?<reserved>",
|
|
23
|
+
reservedCharacter2: '/path/with/"quotes"',
|
|
24
|
+
reservedCharacter3: "/path/with/[brackets]",
|
|
25
|
+
reservedCharacter4: "/path/with/\\backslashes",
|
|
26
|
+
nonAscii1: "/path/with/你好",
|
|
27
|
+
nonAscii2: "/path/with/emoji/😃",
|
|
28
|
+
mixedEncodingPath: "/path/%41A%42B%C3%28",
|
|
29
|
+
directoryTraversal1: "/path/../../etc/passwd",
|
|
30
|
+
directoryTraversal2: "/path/./././",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type ValidationErrorReason = "TooLong" | "InvalidURI" | "Empty" | "ContainsQuery" | "ContainsFragment";
|
|
34
|
+
|
|
35
|
+
export function isValidRedirectPath(path: string): { isValid: boolean; reason: ValidationErrorReason | undefined } {
|
|
36
|
+
const trimmedPath = path.toLowerCase().trim();
|
|
37
|
+
const url = "https://www.example.com" + trimmedPath;
|
|
38
|
+
if (url.length > 2048) {
|
|
39
|
+
return {
|
|
40
|
+
isValid: false,
|
|
41
|
+
reason: "TooLong",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (trimmedPath === "") {
|
|
45
|
+
return {
|
|
46
|
+
isValid: false,
|
|
47
|
+
reason: "Empty",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (url === "/") {
|
|
51
|
+
return {
|
|
52
|
+
isValid: false,
|
|
53
|
+
reason: "Empty",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (url.includes("?")) {
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
reason: "ContainsQuery",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (url.includes("#")) {
|
|
64
|
+
return {
|
|
65
|
+
isValid: false,
|
|
66
|
+
reason: "ContainsFragment",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const regex = /^\/[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/;
|
|
71
|
+
const isValid = regex.test(trimmedPath);
|
|
72
|
+
return {
|
|
73
|
+
isValid: regex.test(trimmedPath),
|
|
74
|
+
reason: !isValid ? "InvalidURI" : undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { DTODocumentationHierarchyV2 } from "../../api";
|
|
4
|
+
import { FrontendVersionRoomYDoc } from "../version-room/frontend";
|
|
5
|
+
|
|
6
|
+
// We store pages and groups in the same way they are stored in the database.
|
|
7
|
+
// This means that instead of groups having childrenIds array, all items have
|
|
8
|
+
// parentPersistentId property that points to the parent item in the tree.
|
|
9
|
+
// Upon read this gets converted to the format that client expects, which is
|
|
10
|
+
// ordered childrenIds array on all groups.
|
|
11
|
+
//
|
|
12
|
+
// The decision behind it is that we potentially want to get rid of childrenIds
|
|
13
|
+
// array entirely because it makes group updates more complicated. For now
|
|
14
|
+
// resolving it on fly is a tradeoff for not rewriting client to stop relying
|
|
15
|
+
// on children ids array.
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Types
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export const DocumentationHierarchySettings = z.object({
|
|
22
|
+
routingVersion: z.string(),
|
|
23
|
+
isDraftFeatureAdopted: z.boolean(),
|
|
24
|
+
isApprovalFeatureEnabled: z.boolean(),
|
|
25
|
+
approvalRequiredForPublishing: z.boolean(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type DocumentationHierarchySettings = z.infer<typeof DocumentationHierarchySettings>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated - Use FrontendVersionRoomYDoc.getDocumentationHierarchy
|
|
32
|
+
*/
|
|
33
|
+
export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarchyV2 {
|
|
34
|
+
return new FrontendVersionRoomYDoc(doc).getDocumentationHierarchy();
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DocumentationItemHeaderV2 } from "@supernova-studio/model";
|
|
2
|
+
import * as Y from "yjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { DTODocumentationItemConfigurationV2 } from "../../api/dto/elements/documentation/item-configuration-v2";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// Types
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
export const DTODocumentationPageRoomHeaderData = z.object({
|
|
11
|
+
title: z.string(),
|
|
12
|
+
configuration: DTODocumentationItemConfigurationV2,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const DTODocumentationPageRoomHeaderDataUpdate = z.object({
|
|
16
|
+
title: z.string().optional(),
|
|
17
|
+
configuration: DTODocumentationItemConfigurationV2.omit({ header: true })
|
|
18
|
+
.extend({ header: DocumentationItemHeaderV2.partial() })
|
|
19
|
+
.optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export type DTODocumentationPageRoomHeaderData = z.infer<typeof DTODocumentationPageRoomHeaderData>;
|
|
23
|
+
export type DTODocumentationPageRoomHeaderDataUpdate = z.infer<typeof DTODocumentationPageRoomHeaderDataUpdate>;
|
|
24
|
+
|
|
25
|
+
//
|
|
26
|
+
// YJS Bindings
|
|
27
|
+
//
|
|
28
|
+
|
|
29
|
+
export function itemConfigurationToYjs(yDoc: Y.Doc, item: DTODocumentationPageRoomHeaderDataUpdate) {
|
|
30
|
+
yDoc.transact(trx => {
|
|
31
|
+
const { title, configuration } = item;
|
|
32
|
+
|
|
33
|
+
const header = configuration?.header;
|
|
34
|
+
|
|
35
|
+
if (title !== undefined) {
|
|
36
|
+
const headerYMap = trx.doc.getMap("itemTitle");
|
|
37
|
+
headerYMap.set("title", title);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (header) {
|
|
41
|
+
const headerYMap = trx.doc.getMap("itemHeader");
|
|
42
|
+
|
|
43
|
+
header.description !== undefined && headerYMap.set("description", header.description);
|
|
44
|
+
header.alignment !== undefined && headerYMap.set("alignment", header.alignment);
|
|
45
|
+
header.foregroundColor !== undefined && headerYMap.set("foregroundColor", header.foregroundColor);
|
|
46
|
+
header.backgroundColor !== undefined && headerYMap.set("backgroundColor", header.backgroundColor);
|
|
47
|
+
header.backgroundImageAsset !== undefined && headerYMap.set("backgroundImageAsset", header.backgroundImageAsset);
|
|
48
|
+
header.backgroundImageScaleType !== undefined &&
|
|
49
|
+
headerYMap.set("backgroundImageScaleType", header.backgroundImageScaleType);
|
|
50
|
+
header.showBackgroundOverlay !== undefined &&
|
|
51
|
+
headerYMap.set("showBackgroundOverlay", header.showBackgroundOverlay);
|
|
52
|
+
header.showCoverText !== undefined && headerYMap.set("showCoverText", header.showCoverText);
|
|
53
|
+
header.minHeight !== undefined && headerYMap.set("minHeight", header.minHeight);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const configYMap = trx.doc.getMap("itemConfiguration");
|
|
57
|
+
|
|
58
|
+
configuration?.showSidebar !== undefined && configYMap.set("showSidebar", configuration.showSidebar);
|
|
59
|
+
configuration?.isHidden !== undefined && configYMap.set("isHidden", configuration.isHidden);
|
|
60
|
+
configuration?.isPrivate !== undefined && configYMap.set("isPrivate", configuration.isPrivate);
|
|
61
|
+
});
|
|
62
|
+
}
|