@supernova-studio/client 0.52.2 → 0.52.4

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.52.2",
3
+ "version": "0.52.4",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -1,5 +1,15 @@
1
- import { DocumentationPageApproval } from "@supernova-studio/model";
1
+ import { DocumentationPageApproval, DocumentationPageApprovalState } from "@supernova-studio/model";
2
+ import { z } from "zod";
2
3
 
3
4
  export const DTODocumentationPageApprovalState = DocumentationPageApproval;
4
5
 
5
6
  export type DTODocumentationPageApprovalState = DocumentationPageApproval;
7
+
8
+ export const DTODocumentationGroupApprovalState = z.object({
9
+ persistentId: z.string(),
10
+ groupId: z.string(),
11
+ designSystemVersionId: z.string(),
12
+ approvalState: DocumentationPageApprovalState,
13
+ });
14
+
15
+ export type DTODocumentationGroupApprovalState = z.infer<typeof DTODocumentationGroupApprovalState>;
@@ -3,6 +3,7 @@ import { z } from "zod";
3
3
  import { DTODocumentationDraftState } from "./draft-state";
4
4
  import { DTODocumentationItemConfigurationV2 } from "./item-configuration-v2";
5
5
  import { DTODocumentationPublishMetadata } from "./metadata";
6
+ import { DTODocumentationGroupApprovalState } from "../../documentation";
6
7
 
7
8
  //
8
9
  // Read
@@ -30,6 +31,9 @@ export const DTODocumentationGroupV2 = ElementGroup.omit({
30
31
 
31
32
  /** Defined if a group was published at least once and contains metadata about last publish */
32
33
  publishMetadata: DTODocumentationPublishMetadata.optional(),
34
+
35
+ //** An approval state for frontend to utilize. */
36
+ approvalState: DTODocumentationGroupApprovalState.optional(),
33
37
  });
34
38
 
35
39
  export type DTODocumentationGroupV2 = z.infer<typeof DTODocumentationGroupV2>;
@@ -15,6 +15,7 @@ import * as Y from "yjs";
15
15
  import {
16
16
  DTODocumentationDraftState,
17
17
  DTODocumentationDraftStateUpdated,
18
+ DTODocumentationGroupApprovalState,
18
19
  DTODocumentationHierarchyV2,
19
20
  DTODocumentationPageApprovalState,
20
21
  documentationItemConfigurationToDTOV2,
@@ -96,7 +97,7 @@ export class FrontendVersionRoomYDoc {
96
97
  const groupDraftStates = this.buildGroupDraftCreatedAndUpdatedStates(groups, groupSnapshots);
97
98
  const groupDraftDeletedStates = this.buildGroupDraftDeletedStates(groups, groupSnapshots);
98
99
  const groupPublishedMetadata = this.buildGroupPublishedMetadata(groups, groupSnapshots);
99
-
100
+ const groupApprovalStates = this.buildGroupApprovalStates(groups, groupSnapshots);
100
101
  groupDTOs.forEach(g => {
101
102
  // Assign draft state
102
103
  const draftState = groupDraftDeletedStates.get(g.id) ?? groupDraftStates.get(g.id);
@@ -105,6 +106,9 @@ export class FrontendVersionRoomYDoc {
105
106
  // Assign publish metadata
106
107
  const publishMetadata = groupPublishedMetadata.get(g.id);
107
108
  publishMetadata && (g.publishMetadata = publishMetadata);
109
+
110
+ const approvalState = groupApprovalStates.get(g.id);
111
+ approvalState && (g.approvalState = approvalState);
108
112
  });
109
113
 
110
114
  return {
@@ -377,6 +381,21 @@ export class FrontendVersionRoomYDoc {
377
381
  return undefined;
378
382
  }
379
383
 
384
+ private buildGroupApprovalStates(groups: ElementGroup[], groupSnapshots: ElementGroupSnapshot[]) {
385
+ const result = new Map<string, DTODocumentationGroupApprovalState>();
386
+ const allGroups = [...groups, ...groupSnapshots];
387
+ for (const g of allGroups) {
388
+ const approvalState: DTODocumentationGroupApprovalState = {
389
+ approvalState: "Approved",
390
+ designSystemVersionId: g.designSystemVersionId,
391
+ persistentId: g.persistentId,
392
+ groupId: g.id,
393
+ };
394
+ result.set(g.id, approvalState);
395
+ }
396
+ return result;
397
+ }
398
+
380
399
  //
381
400
  // Update page content hash
382
401
  //