@supernova-studio/client 0.47.72 → 0.47.74

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.47.72",
3
+ "version": "0.47.74",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -76,7 +76,7 @@ export class VersionRoomBaseYDoc {
76
76
 
77
77
  const rawSettings: Record<keyof DocumentationHierarchySettings, any> = {
78
78
  routingVersion: map.get("routingVersion"),
79
- isDraftFeatureAdopted: map.get("isDraftFeatureAdapted") ?? false,
79
+ isDraftFeatureAdopted: map.get("isDraftFeatureAdopted") ?? false,
80
80
  };
81
81
 
82
82
  const settingsParseResult = DocumentationHierarchySettings.safeParse(rawSettings);
@@ -94,6 +94,7 @@ export class VersionRoomBaseYDoc {
94
94
  const map = this.internalSettingsYMap;
95
95
 
96
96
  map.set("routingVersion", settings.routingVersion);
97
+ map.set("isDraftFeatureAdopted", settings.isDraftFeatureAdopted);
97
98
  }
98
99
 
99
100
  private get internalSettingsYMap() {
@@ -4,6 +4,7 @@ import {
4
4
  DocumentationPageV2,
5
5
  ElementGroup,
6
6
  ElementGroupSnapshot,
7
+ defaultDocumentationItemConfigurationV2,
7
8
  mapByUnique,
8
9
  } from "@supernova-studio/model";
9
10
  import * as Y from "yjs";
@@ -22,7 +23,7 @@ import { generatePageContentHash } from "./utils";
22
23
 
23
24
  type ItemState = {
24
25
  title: string;
25
- configuration: DocumentationItemConfigurationV2 | undefined;
26
+ configuration: DocumentationItemConfigurationV2;
26
27
  contentHash: string;
27
28
  };
28
29
 
@@ -48,16 +49,26 @@ export class FrontendVersionRoomYDoc {
48
49
 
49
50
  const settings = doc.getDocumentationInternalSettings();
50
51
 
51
- // Convert pages to DTOs with draft states
52
+ // Convert pages to DTOs
52
53
  const pageDTOs = documentationPagesToDTOV2(pages, groups, settings.routingVersion);
54
+ const groupDTOs = elementGroupsToDocumentationGroupDTOV2(groups, pages);
55
+
56
+ // If draft feature is not yet adopted, no snapshot-based features should not be provided
57
+ if (!settings.isDraftFeatureAdopted) {
58
+ return {
59
+ pages: pageDTOs,
60
+ groups: groupDTOs,
61
+ deletedGroups: [],
62
+ deletedPages: [],
63
+ };
64
+ }
65
+
53
66
  const pageDraftStates = this.buildPageDraftStates(pages, pageSnapshots);
54
67
  pageDTOs.forEach(p => {
55
68
  const draftState = pageDraftStates.get(p.id);
56
69
  draftState && (p.draftState = draftState);
57
70
  });
58
71
 
59
- // Convert groups to DTOs with draft states
60
- const groupDTOs = elementGroupsToDocumentationGroupDTOV2(groups, pages);
61
72
  const groupDraftStates = this.buildGroupDraftStates(groups, groupSnapshots);
62
73
  groupDTOs.forEach(g => {
63
74
  const draftState = groupDraftStates.get(g.id);
@@ -149,7 +160,7 @@ export class FrontendVersionRoomYDoc {
149
160
  private itemStateFromPage(page: DocumentationPageV2, pageContentHash: string): ItemState {
150
161
  return {
151
162
  title: page.meta.name,
152
- configuration: page.data.configuration,
163
+ configuration: page.data.configuration ?? defaultDocumentationItemConfigurationV2,
153
164
  contentHash: pageContentHash,
154
165
  };
155
166
  }
@@ -198,7 +209,7 @@ export class FrontendVersionRoomYDoc {
198
209
  private itemStateFromGroup(group: ElementGroup): ItemState {
199
210
  return {
200
211
  title: group.meta.name,
201
- configuration: group.data?.configuration,
212
+ configuration: group.data?.configuration ?? defaultDocumentationItemConfigurationV2,
202
213
  contentHash: "-",
203
214
  };
204
215
  }
@@ -231,12 +242,7 @@ export class FrontendVersionRoomYDoc {
231
242
  updatedDraftState.changes.previousTitle = publishedState.title;
232
243
  }
233
244
 
234
- const currentStateConfigHash = currentState.configuration ? generateHash(currentState.configuration) : "default";
235
- const publishedStateConfigHash = publishedState.configuration
236
- ? generateHash(publishedState.configuration)
237
- : "default";
238
-
239
- if (currentStateConfigHash !== publishedStateConfigHash) {
245
+ if (generateHash(currentState.configuration) !== generateHash(publishedState.configuration)) {
240
246
  if (this.debug) {
241
247
  console.log(`Item ${itemPersistentId} (${currentState.title}): updated configuration`);
242
248
  }