@supernova-studio/client 0.52.2 → 0.52.3

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.3",
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,6 +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);
100
+ const groupApprovalStates = this.buildGroupApprovalStates(groups, groupSnapshots);
99
101
 
100
102
  groupDTOs.forEach(g => {
101
103
  // Assign draft state
@@ -105,6 +107,9 @@ export class FrontendVersionRoomYDoc {
105
107
  // Assign publish metadata
106
108
  const publishMetadata = groupPublishedMetadata.get(g.id);
107
109
  publishMetadata && (g.publishMetadata = publishMetadata);
110
+
111
+ const approvalState = groupApprovalStates.get(g.id);
112
+ approvalState && (g.approvalState = approvalState);
108
113
  });
109
114
 
110
115
  return {
@@ -377,6 +382,21 @@ export class FrontendVersionRoomYDoc {
377
382
  return undefined;
378
383
  }
379
384
 
385
+ private buildGroupApprovalStates(groups: ElementGroup[], groupSnapshots: ElementGroupSnapshot[]) {
386
+ const result = new Map<string, DTODocumentationGroupApprovalState>();
387
+ const allGroups = [...groups, ...groupSnapshots];
388
+ for (const g of allGroups) {
389
+ const approvalState: DTODocumentationGroupApprovalState = {
390
+ approvalState: "Approved",
391
+ designSystemVersionId: g.designSystemVersionId,
392
+ persistentId: g.persistentId,
393
+ groupId: g.id,
394
+ };
395
+ result.set(g.persistentId, approvalState);
396
+ }
397
+ return result;
398
+ }
399
+
380
400
  //
381
401
  // Update page content hash
382
402
  //