@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DesignSystem, DesignSystemAccessMode, DesignSystemSwitcher, ObjectMeta } from "@supernova-studio/model";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const DTODesignSystemUpdateInput = DesignSystem.partial()
|
|
5
|
+
.omit({
|
|
6
|
+
id: true,
|
|
7
|
+
workspaceId: true,
|
|
8
|
+
createdAt: true,
|
|
9
|
+
updatedAt: true,
|
|
10
|
+
docSlug: true,
|
|
11
|
+
docViewUrl: true,
|
|
12
|
+
accessMode: true,
|
|
13
|
+
iconFileId: true,
|
|
14
|
+
iconFilePath: true,
|
|
15
|
+
})
|
|
16
|
+
.extend({
|
|
17
|
+
meta: ObjectMeta.partial().optional(),
|
|
18
|
+
iconFileId: z.string().nullish(),
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use the `designSystems.updateSwitcher` endpoint instead
|
|
22
|
+
*/
|
|
23
|
+
designSystemSwitcher: DesignSystemSwitcher.optional(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const DTODesignSystemUpdateAccessModeInput = z.object({
|
|
27
|
+
accessMode: DesignSystemAccessMode,
|
|
28
|
+
retain: z
|
|
29
|
+
.object({
|
|
30
|
+
userIds: z.string().array(),
|
|
31
|
+
inviteIds: z.string().array(),
|
|
32
|
+
})
|
|
33
|
+
.optional(),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const DTODesignSystemUpdateSwitcherInput = z.object({
|
|
37
|
+
designSystemSwitcher: DesignSystemSwitcher,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type DTODesignSystemUpdateInput = z.infer<typeof DTODesignSystemUpdateInput>;
|
|
41
|
+
export type DTODesignSystemUpdateAccessModeInput = z.infer<typeof DTODesignSystemUpdateAccessModeInput>;
|
|
42
|
+
export type DTODesignSystemUpdateSwitcherInput = z.infer<typeof DTODesignSystemUpdateSwitcherInput>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const ObjectMeta = z.object({
|
|
4
|
+
name: z.string().max(150).optional(),
|
|
5
|
+
description: z.string().max(2000).optional(),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export function validateDesignSystemVersion(version: string) {
|
|
9
|
+
const urlCompliantRegex = /^[a-zA-Z0-9+.-]+$/;
|
|
10
|
+
return urlCompliantRegex.test(version);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DTOCreateVersionInput = z.object({
|
|
14
|
+
meta: ObjectMeta,
|
|
15
|
+
version: z.string().refine(validateDesignSystemVersion, {
|
|
16
|
+
message: "Invalid semantic versioning format",
|
|
17
|
+
}),
|
|
18
|
+
changeLog: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type DTOCreateVersionInput = z.infer<typeof DTOCreateVersionInput>;
|
|
22
|
+
|
|
23
|
+
export const DTOUpdateVersionInput = z.object({
|
|
24
|
+
meta: ObjectMeta,
|
|
25
|
+
version: z.string(), // required for PUT, but not editable
|
|
26
|
+
changeLog: z.string(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type DTOUpdateVersionInput = z.infer<typeof DTOUpdateVersionInput>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
// TO DELETE!
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
export const DTODocumentationAnalyticsTimeFrameComparison = z.object({
|
|
11
|
+
referencePeriod: z.object({
|
|
12
|
+
start: z.coerce.date(),
|
|
13
|
+
end: z.coerce.date().optional(),
|
|
14
|
+
}),
|
|
15
|
+
baselinePeriod: z.object({
|
|
16
|
+
start: z.coerce.date(),
|
|
17
|
+
end: z.coerce.date().optional(),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated
|
|
23
|
+
*/
|
|
24
|
+
export const DTODocumentationAnalyticsDiffPayload = z.object({
|
|
25
|
+
timeFrames: z.array(DTODocumentationAnalyticsTimeFrameComparison),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated
|
|
30
|
+
*/
|
|
31
|
+
export type DTODocumentationAnalyticsTimeFrameComparison = z.infer<typeof DTODocumentationAnalyticsTimeFrameComparison>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated
|
|
35
|
+
*/
|
|
36
|
+
export type DTODocumentationAnalyticsDiffPayload = z.infer<typeof DTODocumentationAnalyticsDiffPayload>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zodQueryBoolean } from "../../../utils/query";
|
|
3
|
+
import { DTOPageBlockDefinition } from "../../dto/documentation/block-definition";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Read
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
export const DTOGetBlockDefinitionsQuery = z.object({
|
|
10
|
+
files: zodQueryBoolean(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const DTOGetBlockDefinitionsOutput = z.object({
|
|
14
|
+
definitions: z.array(DTOPageBlockDefinition),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type DTOGetBlockDefinitionsOutput = z.infer<typeof DTOGetBlockDefinitionsOutput>;
|
|
18
|
+
export type DTOGetBlockDefinitionsQuery = z.infer<typeof DTOGetBlockDefinitionsQuery>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./pipeline";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExporterDestinationAzure,
|
|
3
|
+
ExporterDestinationBitbucket,
|
|
4
|
+
ExporterDestinationDocs,
|
|
5
|
+
ExporterDestinationGithub,
|
|
6
|
+
ExporterDestinationGitlab,
|
|
7
|
+
ExporterDestinationS3,
|
|
8
|
+
GitObjectsQuery,
|
|
9
|
+
PipelineDestinationType,
|
|
10
|
+
PipelineEventType,
|
|
11
|
+
} from "@supernova-studio/model";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { DTOExporterPropertyValueMap } from "../../dto/export/exporter-property";
|
|
14
|
+
|
|
15
|
+
export const GitDestinationOptions = z.object({
|
|
16
|
+
branch: z.string().min(1).nullish(),
|
|
17
|
+
commitMessage: z.string().min(1).nullish(),
|
|
18
|
+
commitAuthorName: z.string().min(1).nullish(),
|
|
19
|
+
commitAuthorEmail: z.string().email().nullish(),
|
|
20
|
+
pullRequestTitle: z.string().min(1).nullish(),
|
|
21
|
+
pullRequestDescription: z.string().min(1).nullish(),
|
|
22
|
+
relativePath: z.string().nullish(),
|
|
23
|
+
purgeDirectory: z.boolean().nullish(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const DTOPipelineCreateBody = z.object({
|
|
27
|
+
name: z.string(),
|
|
28
|
+
exporterId: z.string(),
|
|
29
|
+
designSystemId: z.string(),
|
|
30
|
+
isEnabled: z.boolean(),
|
|
31
|
+
eventType: PipelineEventType,
|
|
32
|
+
brandPersistentId: z.string().optional(),
|
|
33
|
+
themePersistentId: z.string().optional(),
|
|
34
|
+
themePersistentIds: z.string().array().optional(),
|
|
35
|
+
|
|
36
|
+
exporterPropertyValues: DTOExporterPropertyValueMap.optional(),
|
|
37
|
+
|
|
38
|
+
destination: PipelineDestinationType.optional(),
|
|
39
|
+
gitQuery: GitObjectsQuery,
|
|
40
|
+
destinations: z.object({
|
|
41
|
+
s3: ExporterDestinationS3.nullish(),
|
|
42
|
+
azure: ExporterDestinationAzure.nullish(),
|
|
43
|
+
bitbucket: ExporterDestinationBitbucket.nullish(),
|
|
44
|
+
github: ExporterDestinationGithub.nullish(),
|
|
45
|
+
gitlab: ExporterDestinationGitlab.nullish(),
|
|
46
|
+
documentation: ExporterDestinationDocs.nullish(),
|
|
47
|
+
webhookUrl: z.string().nullish(),
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const DTODesignSystemPipelineCreateBody = z.object({
|
|
52
|
+
name: z.string(),
|
|
53
|
+
exporterId: z.string(),
|
|
54
|
+
isEnabled: z.boolean(),
|
|
55
|
+
eventType: PipelineEventType,
|
|
56
|
+
brandPersistentId: z.string().optional(),
|
|
57
|
+
themePersistentId: z.string().optional(),
|
|
58
|
+
themePersistentIds: z.string().array().optional(),
|
|
59
|
+
|
|
60
|
+
exporterPropertyValues: DTOExporterPropertyValueMap.optional(),
|
|
61
|
+
|
|
62
|
+
destination: PipelineDestinationType.optional(),
|
|
63
|
+
gitQuery: GitObjectsQuery,
|
|
64
|
+
destinations: z.object({
|
|
65
|
+
s3: ExporterDestinationS3.nullish(),
|
|
66
|
+
azure: ExporterDestinationAzure.nullish(),
|
|
67
|
+
bitbucket: ExporterDestinationBitbucket.nullish(),
|
|
68
|
+
github: ExporterDestinationGithub.nullish(),
|
|
69
|
+
gitlab: ExporterDestinationGitlab.nullish(),
|
|
70
|
+
documentation: ExporterDestinationDocs.nullish(),
|
|
71
|
+
webhookUrl: z.string().nullish(),
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
export const DTOPipelineUpdateBody = z.object({
|
|
75
|
+
exporterId: z.string().optional(),
|
|
76
|
+
name: z.string().optional(),
|
|
77
|
+
isEnabled: z.boolean().optional(),
|
|
78
|
+
eventType: PipelineEventType.optional(),
|
|
79
|
+
|
|
80
|
+
brandPersistentId: z.string().optional(),
|
|
81
|
+
themePersistentId: z.string().optional(),
|
|
82
|
+
themePersistentIds: z.string().array().optional(),
|
|
83
|
+
|
|
84
|
+
exporterPropertyValues: DTOExporterPropertyValueMap.optional(),
|
|
85
|
+
|
|
86
|
+
destination: PipelineDestinationType.optional(),
|
|
87
|
+
gitQuery: GitObjectsQuery.optional(),
|
|
88
|
+
|
|
89
|
+
destinations: z
|
|
90
|
+
.object({
|
|
91
|
+
s3: ExporterDestinationS3.nullish(),
|
|
92
|
+
azure: ExporterDestinationAzure.nullish(),
|
|
93
|
+
bitbucket: ExporterDestinationBitbucket.nullish(),
|
|
94
|
+
github: ExporterDestinationGithub.nullish(),
|
|
95
|
+
gitlab: ExporterDestinationGitlab.nullish(),
|
|
96
|
+
documentation: ExporterDestinationDocs.nullish(),
|
|
97
|
+
webhookUrl: z.string().nullish(),
|
|
98
|
+
})
|
|
99
|
+
.optional(),
|
|
100
|
+
gitDestinationOptions: GitDestinationOptions.partial().optional(),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const DTOPipelineTriggerBody = z.object({
|
|
104
|
+
designSystemVersionId: z.string(),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export type GitDestinationOptions = z.infer<typeof GitDestinationOptions>;
|
|
108
|
+
export type DTOPipelineCreateBody = z.infer<typeof DTOPipelineCreateBody>;
|
|
109
|
+
export type DTOPipelineUpdateBody = z.infer<typeof DTOPipelineUpdateBody>;
|
|
110
|
+
export type DTOPipelineTriggerBody = z.infer<typeof DTOPipelineTriggerBody>;
|
|
111
|
+
export type DTODesignSystemPipelineCreateBody = z.infer<typeof DTODesignSystemPipelineCreateBody>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./notifications";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./notification-settings";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UserNotificationSettings } from "@supernova-studio/model";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const DTOUpdateUserNotificationSettingsPayload = z.object({
|
|
5
|
+
notificationSettings: UserNotificationSettings,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export type DTOUpdateUserNotificationSettingsPayload = z.infer<typeof DTOUpdateUserNotificationSettingsPayload>;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const DTOUserNotificationSettingsResponse = z.object({
|
|
12
|
+
userId: z.string(),
|
|
13
|
+
workspaceId: z.string(),
|
|
14
|
+
notificationSettings: UserNotificationSettings,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type DTOUserNotificationSettingsResponse = z.infer<typeof DTOUserNotificationSettingsResponse>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
SsoProvider,
|
|
4
|
+
WorkspaceDefaultProjectAccessMode,
|
|
5
|
+
WorkspaceDefaultProjectRole,
|
|
6
|
+
WorkspaceIpSettings,
|
|
7
|
+
WorkspaceProfile,
|
|
8
|
+
} from "@supernova-studio/model";
|
|
9
|
+
|
|
10
|
+
const prohibitedSsoKeys = ["providerId", "metadataXml", "emailDomains"];
|
|
11
|
+
|
|
12
|
+
export function validateSsoPayload(ssoPayload: Partial<SsoProvider> | undefined) {
|
|
13
|
+
const keys = [];
|
|
14
|
+
let valid = true;
|
|
15
|
+
if (!ssoPayload) {
|
|
16
|
+
valid = true;
|
|
17
|
+
return {
|
|
18
|
+
valid,
|
|
19
|
+
keys: [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
for (const key of Object.keys(ssoPayload)) {
|
|
23
|
+
if (prohibitedSsoKeys.includes(key)) {
|
|
24
|
+
keys.push(key);
|
|
25
|
+
valid = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
valid,
|
|
30
|
+
keys,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const NpmRegistryInput = z.object({
|
|
35
|
+
enabledScopes: z.array(z.string()),
|
|
36
|
+
customRegistryUrl: z.string().optional(),
|
|
37
|
+
bypassProxy: z.boolean().optional(),
|
|
38
|
+
npmProxyRegistryConfigId: z.string().optional(),
|
|
39
|
+
npmProxyVersion: z.number().optional(),
|
|
40
|
+
registryType: z.string(),
|
|
41
|
+
authType: z.string(),
|
|
42
|
+
authHeaderName: z.string(),
|
|
43
|
+
authHeaderValue: z.string(),
|
|
44
|
+
accessToken: z.string(),
|
|
45
|
+
username: z.string(),
|
|
46
|
+
password: z.string(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const WorkspaceConfigurationPayload = z.object({
|
|
50
|
+
ipWhitelist: WorkspaceIpSettings.partial().optional(),
|
|
51
|
+
sso: SsoProvider.partial().optional(),
|
|
52
|
+
npmRegistrySettings: NpmRegistryInput.partial().optional(),
|
|
53
|
+
profile: WorkspaceProfile.partial().optional(),
|
|
54
|
+
aiFeaturesEnabled: z.boolean().optional(),
|
|
55
|
+
projectsEnabled: z.boolean().optional(),
|
|
56
|
+
defaultProjectAccessMode: WorkspaceDefaultProjectAccessMode.optional(),
|
|
57
|
+
defaultProjectRole: WorkspaceDefaultProjectRole.optional(),
|
|
58
|
+
aiAskFeaturesEnabled: z.boolean().optional(),
|
|
59
|
+
aiCustomInstruction: z.string().optional(),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export type WorkspaceConfigurationPayload = z.infer<typeof WorkspaceConfigurationPayload>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IntegrationToken, IntegrationType } from "@supernova-studio/model";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const IntegrationOauthPlatform = z.enum(["Desktop", "Browser"]);
|
|
5
|
+
|
|
6
|
+
export type IntegrationOauthPlatform = z.infer<typeof IntegrationOauthPlatform>;
|
|
7
|
+
|
|
8
|
+
export const IntegrationOauthCallbackState = z.enum(["Success", "Error"]);
|
|
9
|
+
|
|
10
|
+
export type IntegrationOauthCallbackState = z.infer<typeof IntegrationOauthCallbackState>;
|
|
11
|
+
|
|
12
|
+
export const DTOWorkspaceIntegrationOauthInput = z.object({
|
|
13
|
+
type: IntegrationType,
|
|
14
|
+
platform: IntegrationOauthPlatform.optional().default("Browser"),
|
|
15
|
+
authId: z.string().optional(), // Allow FE client to distinguish between multiple parallel OAuth flows, useful for desktop where multiple flows can be initiated in parallel
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type DTOWorkspaceIntegrationOauthInput = z.infer<typeof DTOWorkspaceIntegrationOauthInput>;
|
|
19
|
+
|
|
20
|
+
export const DTOWorkspaceIntegrationPATInput = z.object({
|
|
21
|
+
type: IntegrationType,
|
|
22
|
+
token: IntegrationToken,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type DTOWorkspaceIntegrationPATInput = z.infer<typeof DTOWorkspaceIntegrationPATInput>;
|
|
26
|
+
|
|
27
|
+
export const DTOWorkspaceIntegrationGetGitObjectsInput = z.object({
|
|
28
|
+
organization: z.string().optional(), // Azure Organization | Bitbucket Workspace slug | Gitlab Group and Sub-Groups | Github Account (User or Organization)
|
|
29
|
+
project: z.string().optional(), // Only for Bitbucket and Azure
|
|
30
|
+
repository: z.string().optional(), // For all providers. Pay attention for Gitlab, they call repositories "projects".
|
|
31
|
+
branch: z.string().optional(), // For all providers, useful for PR creations.
|
|
32
|
+
user: z.string().optional(), // Only for Gitlab User Repositories
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type DTOWorkspaceIntegrationGetGitObjectsInput = z.infer<typeof DTOWorkspaceIntegrationGetGitObjectsInput>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SupernovaExceptionType } from "@supernova-studio/model";
|
|
2
|
+
|
|
3
|
+
export type RequestExecutorErrorType = "ServerError" | "ResponseParsingError";
|
|
4
|
+
export type RequestEexecutorServerErrorCode = SupernovaExceptionType | undefined;
|
|
5
|
+
|
|
6
|
+
export class RequestExecutorError extends Error {
|
|
7
|
+
readonly type: RequestExecutorErrorType;
|
|
8
|
+
readonly errorCode: RequestEexecutorServerErrorCode | undefined;
|
|
9
|
+
readonly serverErrorType: SupernovaExceptionType | undefined;
|
|
10
|
+
|
|
11
|
+
static tryParseJSON(body: string) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(body);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static serverError(endpoint: string, status: number, bodyText: string) {
|
|
20
|
+
const parsedBody = this.tryParseJSON(bodyText);
|
|
21
|
+
return new RequestExecutorError(
|
|
22
|
+
"ServerError",
|
|
23
|
+
`Endpoint ${endpoint} returned ${status}\n${bodyText}`,
|
|
24
|
+
parsedBody?.errorCode ?? null,
|
|
25
|
+
parsedBody?.type ?? null,
|
|
26
|
+
parsedBody ?? null
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static responseParsingError(endpoint: string, cause: Error) {
|
|
31
|
+
return new RequestExecutorError(
|
|
32
|
+
"ResponseParsingError",
|
|
33
|
+
`Endpoint ${endpoint} returned incompatible JSON`,
|
|
34
|
+
undefined,
|
|
35
|
+
undefined,
|
|
36
|
+
cause
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getDisplayMessage(): string {
|
|
41
|
+
if (this.type === "ServerError" && this.cause && typeof this.cause === "object" && "message" in this.cause) {
|
|
42
|
+
return (this.cause as { message: string }).message || this.message;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this.message;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private constructor(
|
|
49
|
+
type: RequestExecutorErrorType,
|
|
50
|
+
message: string,
|
|
51
|
+
errorCode: RequestEexecutorServerErrorCode | undefined,
|
|
52
|
+
serverErrorType?: SupernovaExceptionType | undefined,
|
|
53
|
+
cause?: unknown
|
|
54
|
+
) {
|
|
55
|
+
super(`${type}: ${message}`, { cause });
|
|
56
|
+
this.type = type;
|
|
57
|
+
this.errorCode = errorCode;
|
|
58
|
+
this.serverErrorType = serverErrorType;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z, ZodSchema, ZodTypeDef } from "zod";
|
|
2
|
+
import { RequestExecutorError } from "./request-executor-error";
|
|
3
|
+
|
|
4
|
+
export type RequestExecutorConfig = {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
accessToken?: string;
|
|
7
|
+
apiSecret?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type RequestExecutorJSONRequest = Omit<RequestInit, "body"> & {
|
|
11
|
+
body?: object;
|
|
12
|
+
query?: URLSearchParams;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const ResponseWrapper = z.object({
|
|
16
|
+
result: z.record(z.any()),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export class RequestExecutor {
|
|
20
|
+
private readonly testServerConfig: RequestExecutorConfig;
|
|
21
|
+
|
|
22
|
+
constructor(testServerConfig: RequestExecutorConfig) {
|
|
23
|
+
this.testServerConfig = testServerConfig;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async json<O, I>(
|
|
27
|
+
path: `/${string}`,
|
|
28
|
+
schema: ZodSchema<O, ZodTypeDef, I>,
|
|
29
|
+
requestInit: RequestExecutorJSONRequest = {}
|
|
30
|
+
) {
|
|
31
|
+
// Headers
|
|
32
|
+
const defaultHeaders: Record<string, string> = {
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (requestInit.body) defaultHeaders["Content-Type"] = "application/json";
|
|
37
|
+
|
|
38
|
+
if (this.testServerConfig.accessToken) {
|
|
39
|
+
defaultHeaders["Authorization"] = `Bearer ${this.testServerConfig.accessToken}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// API secret allows for more priviledged access from secure environments (e.g. other servers)
|
|
43
|
+
if (this.testServerConfig.apiSecret) {
|
|
44
|
+
defaultHeaders["x-sn-api-secret"] = this.testServerConfig.apiSecret;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Body
|
|
48
|
+
let body: string | undefined;
|
|
49
|
+
if (requestInit.body && typeof requestInit.body === "object") body = JSON.stringify(requestInit.body);
|
|
50
|
+
|
|
51
|
+
const fullUrl = this.fullUrl(path, requestInit.query);
|
|
52
|
+
const response = await fetch(fullUrl, {
|
|
53
|
+
...requestInit,
|
|
54
|
+
headers: {
|
|
55
|
+
...requestInit.headers,
|
|
56
|
+
...defaultHeaders,
|
|
57
|
+
},
|
|
58
|
+
body: body,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const endpoint = `${requestInit.method ?? "GET"} ${path}`;
|
|
62
|
+
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const bodyString = await response.text();
|
|
65
|
+
throw RequestExecutorError.serverError(endpoint, response.status, bodyString);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const json = await response.json();
|
|
69
|
+
const wrapperParseResult = ResponseWrapper.safeParse(json);
|
|
70
|
+
if (!wrapperParseResult.success) {
|
|
71
|
+
console.error(`Response was:`);
|
|
72
|
+
console.error(json);
|
|
73
|
+
throw RequestExecutorError.responseParsingError(endpoint, wrapperParseResult.error);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const responseParseResult = schema.safeParse(wrapperParseResult.data.result);
|
|
77
|
+
if (!responseParseResult.success) {
|
|
78
|
+
console.error(`Response was:`);
|
|
79
|
+
console.error(wrapperParseResult.data.result);
|
|
80
|
+
throw RequestExecutorError.responseParsingError(endpoint, responseParseResult.error);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return responseParseResult.data;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private fullUrl(path: string, query: URLSearchParams | undefined): string {
|
|
87
|
+
let url = `${this.testServerConfig.baseUrl}/api/v2${path}`;
|
|
88
|
+
|
|
89
|
+
const queryString = query?.toString();
|
|
90
|
+
if (queryString) url += `?${queryString}`;
|
|
91
|
+
|
|
92
|
+
return url;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataSourceRemoteType } from "@supernova-studio/model";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const DTOEventFigmaNodesRendered = z.object({
|
|
5
|
+
type: z.literal("DesignSystem.FigmaNodesRendered"),
|
|
6
|
+
designSystemId: z.string(),
|
|
7
|
+
versionId: z.string(),
|
|
8
|
+
figmaNodePersistentIds: z.string().array(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const DTOEventDataSourcesImported = z.object({
|
|
12
|
+
type: z.literal("DesignSystem.ImportJobFinished"),
|
|
13
|
+
designSystemId: z.string(),
|
|
14
|
+
versionId: z.string(),
|
|
15
|
+
importJobId: z.string(),
|
|
16
|
+
dataSourceType: DataSourceRemoteType,
|
|
17
|
+
dataSourceIds: z.string().array(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type DTOEventFigmaNodesRendered = z.infer<typeof DTOEventFigmaNodesRendered>;
|
|
21
|
+
export type DTOEventDataSourcesImported = z.infer<typeof DTOEventDataSourcesImported>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DTOEventDataSourcesImported, DTOEventFigmaNodesRendered } from "./design-system";
|
|
3
|
+
|
|
4
|
+
export const DTOEvent = z.discriminatedUnion("type", [DTOEventDataSourcesImported, DTOEventFigmaNodesRendered]);
|
|
5
|
+
|
|
6
|
+
export type DTOEvent = z.infer<typeof DTOEvent>;
|