@supernova-studio/client 0.59.10 → 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/dist/index.d.mts +307 -3
- package/dist/index.d.ts +307 -3
- package/dist/index.js +51 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +850 -803
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/dto/design-systems/index.ts +1 -0
- package/src/api/dto/design-systems/version-room.ts +12 -0
- package/src/api/dto/elements/elements-action-v2.ts +30 -24
- package/src/api/dto/users/authenticated-user.ts +4 -1
- package/src/api/endpoints/design-system/versions/elements-action.ts +3 -0
- package/src/api/endpoints/design-system/versions/versions.ts +8 -0
- package/src/yjs/version-room/backend.ts +5 -0
- package/src/yjs/version-room/base.ts +26 -0
package/package.json
CHANGED
|
@@ -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
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
export const DTOElementActionInput = z
|
|
83
|
+
.discriminatedUnion("type", [
|
|
84
|
+
// Documentation pages
|
|
85
|
+
DTODocumentationPageCreateActionInputV2,
|
|
86
|
+
DTODocumentationPageUpdateActionInputV2,
|
|
87
|
+
DTODocumentationPageMoveActionInputV2,
|
|
88
|
+
DTODocumentationPageDuplicateActionInputV2,
|
|
89
|
+
DTODocumentationPageDeleteActionInputV2,
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
// Documentation groups
|
|
92
|
+
DTODocumentationGroupCreateActionInputV2,
|
|
93
|
+
DTODocumentationTabCreateActionInputV2,
|
|
94
|
+
DTODocumentationGroupUpdateActionInputV2,
|
|
95
|
+
DTODocumentationGroupMoveActionInputV2,
|
|
96
|
+
DTODocumentationGroupDuplicateActionInputV2,
|
|
97
|
+
DTODocumentationGroupDeleteActionInputV2,
|
|
98
|
+
DTODocumentationTabGroupDeleteActionInputV2,
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
// Figma frames
|
|
101
|
+
DTOFigmaNodeRenderActionInput,
|
|
102
|
+
DTOFigmaNodeRenderAsyncActionInput,
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
// Restore
|
|
105
|
+
DTODocumentationPageRestoreActionInput,
|
|
106
|
+
DTODocumentationGroupRestoreActionInput,
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
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,10 +1,11 @@
|
|
|
1
|
-
import { UserOnboardingDepartment, UserOnboardingJobLevel, UserSource } from "@supernova-studio/model";
|
|
1
|
+
import { UserOnboardingDepartment, UserOnboardingJobLevel, UserSource, UserTheme } from "@supernova-studio/model";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { DTOUser, DTOUserProfile } from "./user";
|
|
4
4
|
|
|
5
5
|
export const DTOUserOnboardingDepartment = UserOnboardingDepartment;
|
|
6
6
|
export const DTOUserOnboardingJobLevel = UserOnboardingJobLevel;
|
|
7
7
|
export const DTOUserSource = UserSource;
|
|
8
|
+
export const DTOUserTheme = UserTheme;
|
|
8
9
|
|
|
9
10
|
export const DTOUserOnboarding = z.object({
|
|
10
11
|
companyName: z.string().optional(),
|
|
@@ -21,6 +22,7 @@ export const DTOUserOnboarding = z.object({
|
|
|
21
22
|
|
|
22
23
|
export const DTOAuthenticatedUserProfile = DTOUserProfile.extend({
|
|
23
24
|
onboarding: DTOUserOnboarding.optional(),
|
|
25
|
+
theme: DTOUserTheme.optional(),
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
export const DTOAuthenticatedUser = DTOUser.extend({
|
|
@@ -37,6 +39,7 @@ export const DTOAuthenticatedUserResponse = z.object({
|
|
|
37
39
|
export type DTOUserOnboardingDepartment = z.infer<typeof DTOUserOnboardingDepartment>;
|
|
38
40
|
export type DTOUserOnboardingJobLevel = z.infer<typeof DTOUserOnboardingJobLevel>;
|
|
39
41
|
export type DTOUserSource = z.infer<typeof DTOUserSource>;
|
|
42
|
+
export type DTOUserTheme = z.infer<typeof DTOUserTheme>;
|
|
40
43
|
export type DTOUserOnboarding = z.infer<typeof DTOUserOnboarding>;
|
|
41
44
|
export type DTOAuthenticatedUserProfile = z.infer<typeof DTOAuthenticatedUserProfile>;
|
|
42
45
|
export type DTOAuthenticatedUser = z.infer<typeof DTOAuthenticatedUser>;
|
|
@@ -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
|
}
|