@supernova-studio/client 0.59.11 → 0.59.12

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.59.11",
3
+ "version": "0.59.12",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -10,5 +10,6 @@ export * from "./members";
10
10
  export * from "./redirects";
11
11
  export * from "./role";
12
12
  export * from "./stats";
13
+ export * from "./version-room";
13
14
  export * from "./version";
14
15
  export * from "./view";
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+
3
+ export const DTODesignSystemVersionRoom = z.object({
4
+ id: z.string(),
5
+ });
6
+
7
+ export const DTODesignSystemVersionRoomResponse = z.object({
8
+ room: DTODesignSystemVersionRoom,
9
+ });
10
+
11
+ export type DTODesignSystemVersionRoom = z.infer<typeof DTODesignSystemVersionRoom>;
12
+ export type DTODesignSystemVersionRoomResponse = z.infer<typeof DTODesignSystemVersionRoomResponse>;
@@ -79,33 +79,39 @@ export type DTOElementActionOutput = z.infer<typeof DTOElementActionOutput>;
79
79
  // Write
80
80
  //
81
81
 
82
- export const DTOElementActionInput = z.discriminatedUnion("type", [
83
- // Documentation pages
84
- DTODocumentationPageCreateActionInputV2,
85
- DTODocumentationPageUpdateActionInputV2,
86
- DTODocumentationPageMoveActionInputV2,
87
- DTODocumentationPageDuplicateActionInputV2,
88
- DTODocumentationPageDeleteActionInputV2,
82
+ export const DTOElementActionInput = z
83
+ .discriminatedUnion("type", [
84
+ // Documentation pages
85
+ DTODocumentationPageCreateActionInputV2,
86
+ DTODocumentationPageUpdateActionInputV2,
87
+ DTODocumentationPageMoveActionInputV2,
88
+ DTODocumentationPageDuplicateActionInputV2,
89
+ DTODocumentationPageDeleteActionInputV2,
89
90
 
90
- // Documentation groups
91
- DTODocumentationGroupCreateActionInputV2,
92
- DTODocumentationTabCreateActionInputV2,
93
- DTODocumentationGroupUpdateActionInputV2,
94
- DTODocumentationGroupMoveActionInputV2,
95
- DTODocumentationGroupDuplicateActionInputV2,
96
- DTODocumentationGroupDeleteActionInputV2,
97
- DTODocumentationTabGroupDeleteActionInputV2,
91
+ // Documentation groups
92
+ DTODocumentationGroupCreateActionInputV2,
93
+ DTODocumentationTabCreateActionInputV2,
94
+ DTODocumentationGroupUpdateActionInputV2,
95
+ DTODocumentationGroupMoveActionInputV2,
96
+ DTODocumentationGroupDuplicateActionInputV2,
97
+ DTODocumentationGroupDeleteActionInputV2,
98
+ DTODocumentationTabGroupDeleteActionInputV2,
98
99
 
99
- // Figma frames
100
- DTOFigmaNodeRenderActionInput,
101
- DTOFigmaNodeRenderAsyncActionInput,
100
+ // Figma frames
101
+ DTOFigmaNodeRenderActionInput,
102
+ DTOFigmaNodeRenderAsyncActionInput,
102
103
 
103
- // Restore
104
- DTODocumentationPageRestoreActionInput,
105
- DTODocumentationGroupRestoreActionInput,
104
+ // Restore
105
+ DTODocumentationPageRestoreActionInput,
106
+ DTODocumentationGroupRestoreActionInput,
106
107
 
107
- // Approval
108
- DTODocumentationPageApprovalStateChangeActionInput,
109
- ]);
108
+ // Approval
109
+ DTODocumentationPageApprovalStateChangeActionInput,
110
+ ])
111
+ .and(
112
+ z.object({
113
+ tId: z.string().optional(),
114
+ })
115
+ );
110
116
 
111
117
  export type DTOElementActionInput = z.infer<typeof DTOElementActionInput>;
@@ -1,3 +1,4 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import {
2
3
  DTOCreateDocumentationGroupInput,
3
4
  DTOCreateDocumentationPageInputV2,
@@ -48,6 +49,8 @@ export class ElementsActionEndpoint {
48
49
  }
49
50
 
50
51
  private async action(dsId: string, vId: string, input: DTOElementActionInput) {
52
+ if (!input.tId) input.tId = randomUUID();
53
+
51
54
  return this.requestExecutor.json(
52
55
  `/design-systems/${dsId}/versions/${vId}/elements-action`,
53
56
  DTOElementActionOutput,
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DTODesignSystemVersionCreationResponse,
3
3
  DTODesignSystemVersionJobStatusResponse,
4
+ DTODesignSystemVersionRoomResponse,
4
5
  DTODesignSystemVersionsListResponse,
5
6
  } from "../../../dto";
6
7
  import { DTOCreateVersionInput } from "../../../payloads";
@@ -76,4 +77,11 @@ export class DesignSystemVersionsEndpoint {
76
77
  DTODesignSystemVersionJobStatusResponse
77
78
  );
78
79
  }
80
+
81
+ room(dsId: string, vId: string) {
82
+ return this.requestExecutor.json(
83
+ `/design-systems/${dsId}/versions/${vId}/room`,
84
+ DTODesignSystemVersionRoomResponse
85
+ );
86
+ }
79
87
  }
@@ -28,6 +28,8 @@ type DocumentationHierarchyTransaction = {
28
28
 
29
29
  pageApprovals?: DocumentationPageApproval[];
30
30
  pageApprovalIdsToDelete?: string[];
31
+
32
+ executedTransactionIds?: string[];
31
33
  };
32
34
 
33
35
  export class BackendVersionRoomYDoc {
@@ -62,6 +64,9 @@ export class BackendVersionRoomYDoc {
62
64
  transaction.pageHashesToUpdate && yDoc.updateDocumentationPageContentHashes(transaction.pageHashesToUpdate);
63
65
  transaction.pageApprovals && yDoc.updateApprovalStates(transaction.pageApprovals);
64
66
  transaction.pageApprovalIdsToDelete && yDoc.removeApprovalStates(transaction.pageApprovalIdsToDelete);
67
+
68
+ // Executed transaction ids
69
+ transaction.executedTransactionIds && yDoc.updateExecutedTransactionIds(transaction.executedTransactionIds);
65
70
  });
66
71
  }
67
72
 
@@ -207,7 +207,10 @@ export class VersionRoomBaseYDoc {
207
207
  return this.yDoc.getMap<string>("documentationPageHashes");
208
208
  }
209
209
 
210
+ //
210
211
  // Approval states
212
+ //
213
+
211
214
  updateApprovalStates(updates: DocumentationPageApproval[]) {
212
215
  this.setObjects(this.documentationPageApprovalsMap, updates);
213
216
  }
@@ -223,4 +226,27 @@ export class VersionRoomBaseYDoc {
223
226
  private get documentationPageApprovalsMap() {
224
227
  return this.yDoc.getMap<object>("documentationPageApprovals");
225
228
  }
229
+
230
+ //
231
+ // Executed transactions
232
+ //
233
+
234
+ updateExecutedTransactionIds(transactionIds: string[]) {
235
+ transactionIds = Array.from(new Set(transactionIds));
236
+ if (!transactionIds.length) return;
237
+
238
+ const array = this.executedTransactionIdsArray;
239
+
240
+ // Append transactions at the end
241
+ array.push(transactionIds);
242
+
243
+ // Trim from the beginning in case it contains more than 100
244
+ if (array.length > 100) {
245
+ array.delete(0, array.length - 100);
246
+ }
247
+ }
248
+
249
+ private get executedTransactionIdsArray() {
250
+ return this.yDoc.getArray<unknown>("executedTransactionIds");
251
+ }
226
252
  }