@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,39 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { DTOFeatureAgentResponseTracker } from "../../api/dto/forge/feature-messages";
|
|
3
|
+
import { ThreadRoomBaseYDoc, ThreadRoomBaseYDocState } from "./base";
|
|
4
|
+
|
|
5
|
+
export class FrontendThreadRoomYDoc {
|
|
6
|
+
private readonly yDoc: Y.Doc;
|
|
7
|
+
|
|
8
|
+
constructor(yDoc: Y.Doc, private readonly debug = false) {
|
|
9
|
+
this.yDoc = yDoc;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// State Access
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
getState(): ThreadRoomBaseYDocState {
|
|
17
|
+
const doc = new ThreadRoomBaseYDoc(this.yDoc);
|
|
18
|
+
return doc.getState();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//
|
|
22
|
+
// Agent Response Trackers
|
|
23
|
+
//
|
|
24
|
+
|
|
25
|
+
getAgentResponseTrackers(): DTOFeatureAgentResponseTracker[] {
|
|
26
|
+
const doc = new ThreadRoomBaseYDoc(this.yDoc);
|
|
27
|
+
return doc.getAgentResponseTrackers();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
updateAgentResponseTracker(tracker: DTOFeatureAgentResponseTracker) {
|
|
31
|
+
const doc = new ThreadRoomBaseYDoc(this.yDoc);
|
|
32
|
+
return doc.updateAgentResponseTrackers([tracker]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
deleteAgentResponseTrackers(id: string) {
|
|
36
|
+
const doc = new ThreadRoomBaseYDoc(this.yDoc);
|
|
37
|
+
return doc.deleteAgentResponseTrackers([id]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./key-value-storage";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { YKeyValue } from "y-utility/y-keyvalue";
|
|
2
|
+
import * as Y from "yjs";
|
|
3
|
+
|
|
4
|
+
export interface YJSKeyValueStorage<T> {
|
|
5
|
+
forEach(fn: (item: T, key: string) => void): void;
|
|
6
|
+
get(key: string): T | undefined;
|
|
7
|
+
set(key: string, value: T): void;
|
|
8
|
+
delete(key: string): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class YJSKeyValueStorageV1<T> implements YJSKeyValueStorage<T> {
|
|
12
|
+
private readonly map: Y.Map<T>;
|
|
13
|
+
|
|
14
|
+
constructor(yDoc: Y.Doc, key: string) {
|
|
15
|
+
this.map = yDoc.getMap(key);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
forEach(fn: (item: T, key: string) => void): void {
|
|
19
|
+
this.map.forEach((value, key) => fn(value, key));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get(key: string): T | undefined {
|
|
23
|
+
return this.map.get(key);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set(key: string, value: T): void {
|
|
27
|
+
this.map.set(key, value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
delete(key: string): void {
|
|
31
|
+
this.map.delete(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class YJSKeyValueStorageV2<T> implements YJSKeyValueStorage<T> {
|
|
36
|
+
private readonly kv: YKeyValue<T>;
|
|
37
|
+
|
|
38
|
+
constructor(yDoc: Y.Doc, key: string) {
|
|
39
|
+
this.kv = new YKeyValue(yDoc.getArray(key));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
forEach(fn: (item: T, key: string) => void): void {
|
|
43
|
+
this.kv.yarray.forEach(({ key, val }) => fn(val, key));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get(key: string): T | undefined {
|
|
47
|
+
return this.kv.get(key);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
set(key: string, value: T): void {
|
|
51
|
+
this.kv.set(key, value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
delete(key: string): void {
|
|
55
|
+
this.kv.delete(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DocumentationPageApproval,
|
|
3
|
+
DocumentationPageSnapshot,
|
|
4
|
+
DocumentationPageV2,
|
|
5
|
+
ElementGroup,
|
|
6
|
+
ElementGroupSnapshot,
|
|
7
|
+
} from "@supernova-studio/model";
|
|
8
|
+
import * as Y from "yjs";
|
|
9
|
+
import { DocumentationHierarchySettings } from "../design-system-content";
|
|
10
|
+
import { VersionRoomBaseYDoc } from "./base";
|
|
11
|
+
|
|
12
|
+
type DocumentationHierarchyTransaction = {
|
|
13
|
+
pages?: DocumentationPageV2[];
|
|
14
|
+
pageIdsToDelete?: string[];
|
|
15
|
+
|
|
16
|
+
groups?: ElementGroup[];
|
|
17
|
+
groupIdsToDelete?: string[];
|
|
18
|
+
|
|
19
|
+
pageSnapshots?: DocumentationPageSnapshot[];
|
|
20
|
+
pageSnapshotIdsToDelete?: string[];
|
|
21
|
+
|
|
22
|
+
groupSnapshots?: ElementGroupSnapshot[];
|
|
23
|
+
groupSnapshotIdsToDelete?: string[];
|
|
24
|
+
|
|
25
|
+
internalSettings?: Partial<DocumentationHierarchySettings>;
|
|
26
|
+
|
|
27
|
+
pageHashesToUpdate?: Record<string, string>;
|
|
28
|
+
|
|
29
|
+
pageApprovals?: DocumentationPageApproval[];
|
|
30
|
+
pageApprovalIdsToDelete?: string[];
|
|
31
|
+
|
|
32
|
+
executedTransactionIds?: string[];
|
|
33
|
+
|
|
34
|
+
roomMetadata?: {
|
|
35
|
+
storageVersion?: 1 | 2;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export class BackendVersionRoomYDoc {
|
|
40
|
+
private readonly yDoc: Y.Doc;
|
|
41
|
+
|
|
42
|
+
constructor(yDoc: Y.Doc) {
|
|
43
|
+
this.yDoc = yDoc;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getDocumentationHierarchy() {
|
|
47
|
+
const yDoc = new VersionRoomBaseYDoc(this.yDoc);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
pages: yDoc.getPages(),
|
|
51
|
+
pageSnapshots: yDoc.getPageSnapshots(),
|
|
52
|
+
groups: yDoc.getGroups(),
|
|
53
|
+
groupSnapshots: yDoc.getGroupSnapshots(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
updateDocumentationHierarchy(transaction: DocumentationHierarchyTransaction) {
|
|
58
|
+
this.yDoc.transact(trx => {
|
|
59
|
+
const yDoc = new VersionRoomBaseYDoc(trx.doc);
|
|
60
|
+
|
|
61
|
+
// Room metadata (needs to come first as it can define underlying mechanics of the room)
|
|
62
|
+
transaction.roomMetadata?.storageVersion && yDoc.setStorageVersion(transaction.roomMetadata.storageVersion);
|
|
63
|
+
|
|
64
|
+
// Pages
|
|
65
|
+
transaction.pageIdsToDelete && yDoc.deletePages(transaction.pageIdsToDelete);
|
|
66
|
+
transaction.pages && yDoc.updatePages(transaction.pages);
|
|
67
|
+
|
|
68
|
+
// Groups
|
|
69
|
+
transaction.groupIdsToDelete && yDoc.deleteGroups(transaction.groupIdsToDelete);
|
|
70
|
+
transaction.groups && yDoc.updateGroups(transaction.groups);
|
|
71
|
+
|
|
72
|
+
// Page snapshots
|
|
73
|
+
transaction.pageSnapshotIdsToDelete && yDoc.deletePageSnapshots(transaction.pageSnapshotIdsToDelete);
|
|
74
|
+
transaction.pageSnapshots && yDoc.updatePageSnapshots(transaction.pageSnapshots);
|
|
75
|
+
|
|
76
|
+
// Snapshots - published groups
|
|
77
|
+
transaction.groupSnapshotIdsToDelete && yDoc.deleteGroupSnapshots(transaction.groupSnapshotIdsToDelete);
|
|
78
|
+
transaction.groupSnapshots && yDoc.updateGroupSnapshots(transaction.groupSnapshots);
|
|
79
|
+
|
|
80
|
+
// Settings
|
|
81
|
+
transaction.internalSettings && yDoc.updateDocumentationInternalSettings(transaction.internalSettings);
|
|
82
|
+
transaction.pageHashesToUpdate && yDoc.updateDocumentationPageContentHashes(transaction.pageHashesToUpdate);
|
|
83
|
+
transaction.pageApprovals && yDoc.updateApprovalStates(transaction.pageApprovals);
|
|
84
|
+
transaction.pageApprovalIdsToDelete && yDoc.removeApprovalStates(transaction.pageApprovalIdsToDelete);
|
|
85
|
+
|
|
86
|
+
// Executed transaction ids
|
|
87
|
+
transaction.executedTransactionIds && yDoc.updateExecutedTransactionIds(transaction.executedTransactionIds);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getDocumentationPageContentHashes() {
|
|
92
|
+
const versionDoc = new VersionRoomBaseYDoc(this.yDoc);
|
|
93
|
+
|
|
94
|
+
// Limit each hash string by 100 characters
|
|
95
|
+
const validHashes = Object.entries(versionDoc.getDocumentationPageContentHashes()).filter(e => {
|
|
96
|
+
return e[1].length < 100;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return Object.fromEntries(validHashes);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DocumentationPageApproval,
|
|
3
|
+
DocumentationPageSnapshot,
|
|
4
|
+
DocumentationPageV2,
|
|
5
|
+
ElementGroup,
|
|
6
|
+
ElementGroupSnapshot,
|
|
7
|
+
} from "@supernova-studio/model";
|
|
8
|
+
import * as Y from "yjs";
|
|
9
|
+
import { ZodSchema, ZodTypeDef } from "zod";
|
|
10
|
+
import { DocumentationHierarchySettings } from "../design-system-content";
|
|
11
|
+
import { YJSKeyValueStorage, YJSKeyValueStorageV1, YJSKeyValueStorageV2 } from "../utils/key-value-storage";
|
|
12
|
+
import { VersionRoomBaseYDocState } from "./types";
|
|
13
|
+
|
|
14
|
+
type YJSSerializable = { id: string };
|
|
15
|
+
|
|
16
|
+
export class VersionRoomBaseYDoc {
|
|
17
|
+
private readonly yDoc: Y.Doc;
|
|
18
|
+
|
|
19
|
+
constructor(yDoc: Y.Doc) {
|
|
20
|
+
this.yDoc = yDoc;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getState(): VersionRoomBaseYDocState {
|
|
24
|
+
// For backward compatibility we are using groups array to determine if Y doc content
|
|
25
|
+
// was loaded: if the content was loaded there has to be at least one (root) group in
|
|
26
|
+
// the doc. To be improved later if needed.
|
|
27
|
+
|
|
28
|
+
const groups = this.getGroups();
|
|
29
|
+
const isLoaded = !!groups.length;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
isLoaded,
|
|
33
|
+
groups,
|
|
34
|
+
pages: this.getPages(),
|
|
35
|
+
approvals: this.getApprovals(),
|
|
36
|
+
groupSnapshots: this.getGroupSnapshots(),
|
|
37
|
+
pageContentHashes: this.getDocumentationPageContentHashes(),
|
|
38
|
+
pageSnapshots: this.getPageSnapshots(),
|
|
39
|
+
settings: this.getDocumentationInternalSettings(),
|
|
40
|
+
pageLiveblockRoomIds: this.getDocumentationPageLiveblocksRoomIds(),
|
|
41
|
+
executedTransactionIds: this.getExecutedTransactionIds(),
|
|
42
|
+
storageVersion: this.getStorageVersion(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//
|
|
47
|
+
// Pages
|
|
48
|
+
//
|
|
49
|
+
|
|
50
|
+
getPages(): DocumentationPageV2[] {
|
|
51
|
+
return this.getObjects(this.pagesYMap, DocumentationPageV2);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
updatePages(pages: DocumentationPageV2[]) {
|
|
55
|
+
pages = pages.map(page => {
|
|
56
|
+
// We remove blocks from the payload here because it will not get parsed anyway
|
|
57
|
+
return {
|
|
58
|
+
...page,
|
|
59
|
+
data: {
|
|
60
|
+
configuration: page.data.configuration,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
this.setObjects(this.pagesYMap, pages);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
deletePages(ids: string[]) {
|
|
69
|
+
this.deleteObjects(this.pagesYMap, ids);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private get pagesYMap(): YJSKeyValueStorage<object> {
|
|
73
|
+
return this.getKeyValueStorage<object>("documentationPages");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//
|
|
77
|
+
// Groups
|
|
78
|
+
//
|
|
79
|
+
|
|
80
|
+
getGroups(): ElementGroup[] {
|
|
81
|
+
return this.getObjects(this.groupsYMap, ElementGroup);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
updateGroups(groups: ElementGroup[]) {
|
|
85
|
+
this.setObjects(this.groupsYMap, groups);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
deleteGroups(ids: string[]) {
|
|
89
|
+
this.deleteObjects(this.groupsYMap, ids);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private get groupsYMap(): YJSKeyValueStorage<object> {
|
|
93
|
+
return this.getKeyValueStorage<object>("documentationGroups");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//
|
|
97
|
+
// Documentation internal settings
|
|
98
|
+
//
|
|
99
|
+
|
|
100
|
+
getDocumentationInternalSettings(): DocumentationHierarchySettings {
|
|
101
|
+
const map = this.internalSettingsYMap;
|
|
102
|
+
|
|
103
|
+
const rawSettings: Record<keyof DocumentationHierarchySettings, any> = {
|
|
104
|
+
routingVersion: map.get("routingVersion"),
|
|
105
|
+
isDraftFeatureAdopted: map.get("isDraftFeatureAdopted") ?? false,
|
|
106
|
+
isApprovalFeatureEnabled: map.get("isApprovalFeatureEnabled") ?? false,
|
|
107
|
+
approvalRequiredForPublishing: map.get("approvalRequiredForPublishing") ?? false,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const settingsParseResult = DocumentationHierarchySettings.safeParse(rawSettings);
|
|
111
|
+
if (!settingsParseResult.success) {
|
|
112
|
+
return {
|
|
113
|
+
routingVersion: "2",
|
|
114
|
+
isDraftFeatureAdopted: false,
|
|
115
|
+
isApprovalFeatureEnabled: false,
|
|
116
|
+
approvalRequiredForPublishing: false,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return settingsParseResult.data;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
updateDocumentationInternalSettings(settings: Partial<DocumentationHierarchySettings>) {
|
|
124
|
+
const map = this.internalSettingsYMap;
|
|
125
|
+
map.set("routingVersion", settings.routingVersion ?? map.get("routingVersion"));
|
|
126
|
+
map.set("isDraftFeatureAdopted", settings.isDraftFeatureAdopted ?? map.get("isDraftFeatureAdopted"));
|
|
127
|
+
map.set("isApprovalFeatureEnabled", settings.isApprovalFeatureEnabled ?? map.get("isApprovalFeatureEnabled"));
|
|
128
|
+
map.set(
|
|
129
|
+
"approvalRequiredForPublishing",
|
|
130
|
+
settings.approvalRequiredForPublishing ?? map.get("approvalRequiredForPublishing")
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private get internalSettingsYMap(): YJSKeyValueStorage<unknown> {
|
|
135
|
+
return this.getKeyValueStorage<unknown>("documentationInternalSettings");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//
|
|
139
|
+
// Documentation page snapshot
|
|
140
|
+
//
|
|
141
|
+
|
|
142
|
+
getPageSnapshots(): DocumentationPageSnapshot[] {
|
|
143
|
+
return this.getObjects(this.documentationPagePublishedStatesYMap, DocumentationPageSnapshot);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
updatePageSnapshots(snapshots: DocumentationPageSnapshot[]) {
|
|
147
|
+
this.setObjects(this.documentationPagePublishedStatesYMap, snapshots);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
deletePageSnapshots(ids: string[]) {
|
|
151
|
+
this.deleteObjects(this.documentationPagePublishedStatesYMap, ids);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private get documentationPagePublishedStatesYMap(): YJSKeyValueStorage<object> {
|
|
155
|
+
return this.getKeyValueStorage<object>("documentationPageSnapshots");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
//
|
|
159
|
+
// Documentation group snapshots
|
|
160
|
+
//
|
|
161
|
+
|
|
162
|
+
getGroupSnapshots(): ElementGroupSnapshot[] {
|
|
163
|
+
return this.getObjects(this.documentationGroupPublishedStatesYMap, ElementGroupSnapshot);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
updateGroupSnapshots(snapshots: ElementGroupSnapshot[]) {
|
|
167
|
+
this.setObjects(this.documentationGroupPublishedStatesYMap, snapshots);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
deleteGroupSnapshots(ids: string[]) {
|
|
171
|
+
this.deleteObjects(this.documentationGroupPublishedStatesYMap, ids);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private get documentationGroupPublishedStatesYMap(): YJSKeyValueStorage<object> {
|
|
175
|
+
return this.getKeyValueStorage<object>("documentationGroupSnapshots");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
//
|
|
179
|
+
// Utils
|
|
180
|
+
//
|
|
181
|
+
|
|
182
|
+
private getObjects<T extends YJSSerializable, I>(
|
|
183
|
+
map: YJSKeyValueStorage<object>,
|
|
184
|
+
schema: ZodSchema<T, ZodTypeDef, I>
|
|
185
|
+
): T[] {
|
|
186
|
+
const results: T[] = [];
|
|
187
|
+
map.forEach(object => results.push(schema.parse(object)));
|
|
188
|
+
return results;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private setObjects<T extends YJSSerializable>(map: YJSKeyValueStorage<object>, objects: T[]) {
|
|
192
|
+
objects.forEach(o => map.set(o.id, JSON.parse(JSON.stringify(o))));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private deleteObjects(map: YJSKeyValueStorage<object>, ids: string[]) {
|
|
196
|
+
ids.forEach(id => map.delete(id));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//
|
|
200
|
+
// Documentation page content hashes
|
|
201
|
+
//
|
|
202
|
+
|
|
203
|
+
getDocumentationPageContentHashes(): Record<string, string> {
|
|
204
|
+
const map = this.documentationPageContentHashesYMap;
|
|
205
|
+
|
|
206
|
+
const result: Record<string, string> = {};
|
|
207
|
+
map.forEach((hash, key) => {
|
|
208
|
+
if (typeof hash === "string") result[key] = hash;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
getDocumentationPageLiveblocksRoomIds(): Record<string, string> {
|
|
215
|
+
const map = this.documentationPageLiveblocksRoomIdsYMap;
|
|
216
|
+
|
|
217
|
+
const result: Record<string, string> = {};
|
|
218
|
+
map.forEach((hash, key) => {
|
|
219
|
+
if (typeof hash === "string") result[key] = hash;
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private get documentationPageLiveblocksRoomIdsYMap(): YJSKeyValueStorage<string> {
|
|
226
|
+
return this.getKeyValueStorage<string>("documentationPageLiveblocksRoomIds");
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
updateDocumentationPageContentHashes(hashes: Record<string, string>) {
|
|
230
|
+
const map = this.documentationPageContentHashesYMap;
|
|
231
|
+
Object.entries(hashes).forEach(([key, hash]) => map.set(key, hash));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private get documentationPageContentHashesYMap(): YJSKeyValueStorage<string> {
|
|
235
|
+
return this.getKeyValueStorage<string>("documentationPageHashes");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
//
|
|
239
|
+
// Approval states
|
|
240
|
+
//
|
|
241
|
+
|
|
242
|
+
updateApprovalStates(updates: DocumentationPageApproval[]) {
|
|
243
|
+
this.setObjects(this.documentationPageApprovalsMap, updates);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
removeApprovalStates(ids: string[]) {
|
|
247
|
+
this.deleteObjects(this.documentationPageApprovalsMap, ids);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
getApprovals() {
|
|
251
|
+
return this.getObjects(this.documentationPageApprovalsMap, DocumentationPageApproval);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private get documentationPageApprovalsMap(): YJSKeyValueStorage<object> {
|
|
255
|
+
return this.getKeyValueStorage<object>("documentationPageApprovals");
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
//
|
|
259
|
+
// Executed transactions
|
|
260
|
+
//
|
|
261
|
+
|
|
262
|
+
updateExecutedTransactionIds(transactionIds: string[]) {
|
|
263
|
+
transactionIds = Array.from(new Set(transactionIds));
|
|
264
|
+
if (!transactionIds.length) return;
|
|
265
|
+
|
|
266
|
+
const array = this.executedTransactionIdsArray;
|
|
267
|
+
|
|
268
|
+
// Append transactions at the end
|
|
269
|
+
array.push(transactionIds);
|
|
270
|
+
|
|
271
|
+
// Trim from the beginning in case it contains more than 100
|
|
272
|
+
if (array.length > 100) {
|
|
273
|
+
array.delete(0, array.length - 100);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
getExecutedTransactionIds(): string[] {
|
|
278
|
+
const array = this.executedTransactionIdsArray;
|
|
279
|
+
|
|
280
|
+
// Y.Array doesn't support filtering
|
|
281
|
+
const transactionIds: string[] = [];
|
|
282
|
+
array.forEach(e => typeof e === "string" && transactionIds.push(e));
|
|
283
|
+
|
|
284
|
+
return transactionIds;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
private get executedTransactionIdsArray() {
|
|
288
|
+
return this.yDoc.getArray<unknown>("executedTransactionIds");
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
//
|
|
292
|
+
// Room metadata
|
|
293
|
+
//
|
|
294
|
+
|
|
295
|
+
setStorageVersion(version: 1 | 2) {
|
|
296
|
+
this.roomMetadataMap.set("storageVersion", version.toString());
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
getStorageVersion(): 1 | 2 {
|
|
300
|
+
const storageVersion = this.roomMetadataMap.get("storageVersion");
|
|
301
|
+
if (storageVersion === "2") return 2;
|
|
302
|
+
else return 1;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private get roomMetadataMap() {
|
|
306
|
+
return this.yDoc.getMap<string>("roomMetadata");
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//
|
|
310
|
+
// Utils
|
|
311
|
+
//
|
|
312
|
+
|
|
313
|
+
private getKeyValueStorage<T>(key: string): YJSKeyValueStorage<T> {
|
|
314
|
+
const version = this.getStorageVersion();
|
|
315
|
+
switch (version) {
|
|
316
|
+
case 2:
|
|
317
|
+
key += "V2";
|
|
318
|
+
return new YJSKeyValueStorageV2(this.yDoc, key);
|
|
319
|
+
default:
|
|
320
|
+
return new YJSKeyValueStorageV1(this.yDoc, key);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|