@ktfun/pulse-protocol 0.0.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/dist/common.d.ts +283 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +92 -0
- package/dist/device.d.ts +864 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +304 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/media.d.ts +382 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +141 -0
- package/dist/page.d.ts +228 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +105 -0
- package/dist/shared.d.ts +107 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +76 -0
- package/package.json +33 -0
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CLIENT_COMMON_WS_PROTOCOL = "client.common.ws.v1";
|
|
3
|
+
export declare const ClientSessionClaimRequestSchema: z.ZodObject<{
|
|
4
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
5
|
+
sdkVersion: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const ClientSessionClaimResponseSchema: z.ZodObject<{
|
|
8
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
9
|
+
sessionId: z.ZodString;
|
|
10
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
11
|
+
userId: z.ZodString;
|
|
12
|
+
username: z.ZodOptional<z.ZodString>;
|
|
13
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const ClientCommonHelloFrameSchema: z.ZodObject<{
|
|
17
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
18
|
+
type: z.ZodLiteral<"hello">;
|
|
19
|
+
supportedProtocols: z.ZodTuple<[z.ZodLiteral<"client.common.ws.v1">], null>;
|
|
20
|
+
sdkVersion: z.ZodString;
|
|
21
|
+
sessionId: z.ZodString;
|
|
22
|
+
tabId: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const ClientCommonHelloAckFrameSchema: z.ZodObject<{
|
|
25
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
26
|
+
type: z.ZodLiteral<"hello_ack">;
|
|
27
|
+
selectedProtocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
28
|
+
connectionId: z.ZodString;
|
|
29
|
+
session: z.ZodObject<{
|
|
30
|
+
sessionId: z.ZodString;
|
|
31
|
+
tabId: z.ZodString;
|
|
32
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
userId: z.ZodString;
|
|
34
|
+
username: z.ZodOptional<z.ZodString>;
|
|
35
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export declare const ClientCommonSessionPageSchema: z.ZodObject<{
|
|
40
|
+
canonicalUrl: z.ZodString;
|
|
41
|
+
title: z.ZodOptional<z.ZodString>;
|
|
42
|
+
url: z.ZodOptional<z.ZodString>;
|
|
43
|
+
tabCount: z.ZodNumber;
|
|
44
|
+
lastSeenAt: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export declare const ClientCommonSessionDetailSchema: z.ZodObject<{
|
|
47
|
+
sessionId: z.ZodString;
|
|
48
|
+
tabCount: z.ZodNumber;
|
|
49
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
userId: z.ZodString;
|
|
51
|
+
username: z.ZodOptional<z.ZodString>;
|
|
52
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
55
|
+
canonicalUrl: z.ZodString;
|
|
56
|
+
title: z.ZodOptional<z.ZodString>;
|
|
57
|
+
url: z.ZodOptional<z.ZodString>;
|
|
58
|
+
tabCount: z.ZodNumber;
|
|
59
|
+
lastSeenAt: z.ZodString;
|
|
60
|
+
}, z.core.$strip>>;
|
|
61
|
+
lastSeenAt: z.ZodString;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export declare const ClientCommonActivePageDetailSchema: z.ZodObject<{
|
|
64
|
+
canonicalUrl: z.ZodString;
|
|
65
|
+
title: z.ZodOptional<z.ZodString>;
|
|
66
|
+
url: z.ZodOptional<z.ZodString>;
|
|
67
|
+
sessionCount: z.ZodNumber;
|
|
68
|
+
lastSeenAt: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export declare const ClientCommonGlobalSnapshotSchema: z.ZodObject<{
|
|
71
|
+
revision: z.ZodNumber;
|
|
72
|
+
updatedAt: z.ZodString;
|
|
73
|
+
sessions: z.ZodObject<{
|
|
74
|
+
totalCount: z.ZodNumber;
|
|
75
|
+
recent: z.ZodArray<z.ZodObject<{
|
|
76
|
+
sessionId: z.ZodString;
|
|
77
|
+
tabCount: z.ZodNumber;
|
|
78
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
userId: z.ZodString;
|
|
80
|
+
username: z.ZodOptional<z.ZodString>;
|
|
81
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
84
|
+
canonicalUrl: z.ZodString;
|
|
85
|
+
title: z.ZodOptional<z.ZodString>;
|
|
86
|
+
url: z.ZodOptional<z.ZodString>;
|
|
87
|
+
tabCount: z.ZodNumber;
|
|
88
|
+
lastSeenAt: z.ZodString;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
lastSeenAt: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
activePages: z.ZodObject<{
|
|
94
|
+
totalCount: z.ZodNumber;
|
|
95
|
+
top: z.ZodArray<z.ZodObject<{
|
|
96
|
+
canonicalUrl: z.ZodString;
|
|
97
|
+
title: z.ZodOptional<z.ZodString>;
|
|
98
|
+
url: z.ZodOptional<z.ZodString>;
|
|
99
|
+
sessionCount: z.ZodNumber;
|
|
100
|
+
lastSeenAt: z.ZodString;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
owner: z.ZodObject<{
|
|
104
|
+
focus: z.ZodNullable<z.ZodObject<{
|
|
105
|
+
app: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
id: z.ZodOptional<z.ZodString>;
|
|
107
|
+
name: z.ZodOptional<z.ZodString>;
|
|
108
|
+
category: z.ZodOptional<z.ZodString>;
|
|
109
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
title: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, z.core.$strip>>;
|
|
114
|
+
updatedAt: z.ZodString;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
export declare const ClientCommonSnapshotFrameSchema: z.ZodObject<{
|
|
119
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
120
|
+
type: z.ZodLiteral<"snapshot">;
|
|
121
|
+
snapshot: z.ZodObject<{
|
|
122
|
+
revision: z.ZodNumber;
|
|
123
|
+
updatedAt: z.ZodString;
|
|
124
|
+
sessions: z.ZodObject<{
|
|
125
|
+
totalCount: z.ZodNumber;
|
|
126
|
+
recent: z.ZodArray<z.ZodObject<{
|
|
127
|
+
sessionId: z.ZodString;
|
|
128
|
+
tabCount: z.ZodNumber;
|
|
129
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
130
|
+
userId: z.ZodString;
|
|
131
|
+
username: z.ZodOptional<z.ZodString>;
|
|
132
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
135
|
+
canonicalUrl: z.ZodString;
|
|
136
|
+
title: z.ZodOptional<z.ZodString>;
|
|
137
|
+
url: z.ZodOptional<z.ZodString>;
|
|
138
|
+
tabCount: z.ZodNumber;
|
|
139
|
+
lastSeenAt: z.ZodString;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
lastSeenAt: z.ZodString;
|
|
142
|
+
}, z.core.$strip>>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
activePages: z.ZodObject<{
|
|
145
|
+
totalCount: z.ZodNumber;
|
|
146
|
+
top: z.ZodArray<z.ZodObject<{
|
|
147
|
+
canonicalUrl: z.ZodString;
|
|
148
|
+
title: z.ZodOptional<z.ZodString>;
|
|
149
|
+
url: z.ZodOptional<z.ZodString>;
|
|
150
|
+
sessionCount: z.ZodNumber;
|
|
151
|
+
lastSeenAt: z.ZodString;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
}, z.core.$strip>;
|
|
154
|
+
owner: z.ZodObject<{
|
|
155
|
+
focus: z.ZodNullable<z.ZodObject<{
|
|
156
|
+
app: z.ZodOptional<z.ZodObject<{
|
|
157
|
+
id: z.ZodOptional<z.ZodString>;
|
|
158
|
+
name: z.ZodOptional<z.ZodString>;
|
|
159
|
+
category: z.ZodOptional<z.ZodString>;
|
|
160
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
163
|
+
title: z.ZodOptional<z.ZodString>;
|
|
164
|
+
}, z.core.$strip>>;
|
|
165
|
+
updatedAt: z.ZodString;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
export declare const ClientCommonErrorFrameSchema: z.ZodObject<{
|
|
171
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
172
|
+
type: z.ZodLiteral<"error">;
|
|
173
|
+
code: z.ZodEnum<{
|
|
174
|
+
connection_superseded: "connection_superseded";
|
|
175
|
+
hello_required: "hello_required";
|
|
176
|
+
internal_error: "internal_error";
|
|
177
|
+
invalid_frame: "invalid_frame";
|
|
178
|
+
invalid_session: "invalid_session";
|
|
179
|
+
unsupported_protocol: "unsupported_protocol";
|
|
180
|
+
}>;
|
|
181
|
+
message: z.ZodString;
|
|
182
|
+
fatal: z.ZodLiteral<true>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export declare const ClientCommonClientFrameSchema: z.ZodObject<{
|
|
185
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
186
|
+
type: z.ZodLiteral<"hello">;
|
|
187
|
+
supportedProtocols: z.ZodTuple<[z.ZodLiteral<"client.common.ws.v1">], null>;
|
|
188
|
+
sdkVersion: z.ZodString;
|
|
189
|
+
sessionId: z.ZodString;
|
|
190
|
+
tabId: z.ZodString;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
export declare const ClientCommonServerFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
193
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
194
|
+
type: z.ZodLiteral<"hello_ack">;
|
|
195
|
+
selectedProtocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
196
|
+
connectionId: z.ZodString;
|
|
197
|
+
session: z.ZodObject<{
|
|
198
|
+
sessionId: z.ZodString;
|
|
199
|
+
tabId: z.ZodString;
|
|
200
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
201
|
+
userId: z.ZodString;
|
|
202
|
+
username: z.ZodOptional<z.ZodString>;
|
|
203
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
207
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
208
|
+
type: z.ZodLiteral<"snapshot">;
|
|
209
|
+
snapshot: z.ZodObject<{
|
|
210
|
+
revision: z.ZodNumber;
|
|
211
|
+
updatedAt: z.ZodString;
|
|
212
|
+
sessions: z.ZodObject<{
|
|
213
|
+
totalCount: z.ZodNumber;
|
|
214
|
+
recent: z.ZodArray<z.ZodObject<{
|
|
215
|
+
sessionId: z.ZodString;
|
|
216
|
+
tabCount: z.ZodNumber;
|
|
217
|
+
user: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
userId: z.ZodString;
|
|
219
|
+
username: z.ZodOptional<z.ZodString>;
|
|
220
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
221
|
+
}, z.core.$strip>>;
|
|
222
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
223
|
+
canonicalUrl: z.ZodString;
|
|
224
|
+
title: z.ZodOptional<z.ZodString>;
|
|
225
|
+
url: z.ZodOptional<z.ZodString>;
|
|
226
|
+
tabCount: z.ZodNumber;
|
|
227
|
+
lastSeenAt: z.ZodString;
|
|
228
|
+
}, z.core.$strip>>;
|
|
229
|
+
lastSeenAt: z.ZodString;
|
|
230
|
+
}, z.core.$strip>>;
|
|
231
|
+
}, z.core.$strip>;
|
|
232
|
+
activePages: z.ZodObject<{
|
|
233
|
+
totalCount: z.ZodNumber;
|
|
234
|
+
top: z.ZodArray<z.ZodObject<{
|
|
235
|
+
canonicalUrl: z.ZodString;
|
|
236
|
+
title: z.ZodOptional<z.ZodString>;
|
|
237
|
+
url: z.ZodOptional<z.ZodString>;
|
|
238
|
+
sessionCount: z.ZodNumber;
|
|
239
|
+
lastSeenAt: z.ZodString;
|
|
240
|
+
}, z.core.$strip>>;
|
|
241
|
+
}, z.core.$strip>;
|
|
242
|
+
owner: z.ZodObject<{
|
|
243
|
+
focus: z.ZodNullable<z.ZodObject<{
|
|
244
|
+
app: z.ZodOptional<z.ZodObject<{
|
|
245
|
+
id: z.ZodOptional<z.ZodString>;
|
|
246
|
+
name: z.ZodOptional<z.ZodString>;
|
|
247
|
+
category: z.ZodOptional<z.ZodString>;
|
|
248
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
249
|
+
}, z.core.$strip>>;
|
|
250
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
251
|
+
title: z.ZodOptional<z.ZodString>;
|
|
252
|
+
}, z.core.$strip>>;
|
|
253
|
+
updatedAt: z.ZodString;
|
|
254
|
+
}, z.core.$strip>>;
|
|
255
|
+
}, z.core.$strip>;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
258
|
+
protocol: z.ZodLiteral<"client.common.ws.v1">;
|
|
259
|
+
type: z.ZodLiteral<"error">;
|
|
260
|
+
code: z.ZodEnum<{
|
|
261
|
+
connection_superseded: "connection_superseded";
|
|
262
|
+
hello_required: "hello_required";
|
|
263
|
+
internal_error: "internal_error";
|
|
264
|
+
invalid_frame: "invalid_frame";
|
|
265
|
+
invalid_session: "invalid_session";
|
|
266
|
+
unsupported_protocol: "unsupported_protocol";
|
|
267
|
+
}>;
|
|
268
|
+
message: z.ZodString;
|
|
269
|
+
fatal: z.ZodLiteral<true>;
|
|
270
|
+
}, z.core.$strip>], "type">;
|
|
271
|
+
export type ClientSessionClaimRequest = z.infer<typeof ClientSessionClaimRequestSchema>;
|
|
272
|
+
export type ClientSessionClaimResponse = z.infer<typeof ClientSessionClaimResponseSchema>;
|
|
273
|
+
export type ClientCommonHelloFrame = z.infer<typeof ClientCommonHelloFrameSchema>;
|
|
274
|
+
export type ClientCommonHelloAckFrame = z.infer<typeof ClientCommonHelloAckFrameSchema>;
|
|
275
|
+
export type ClientCommonSessionPage = z.infer<typeof ClientCommonSessionPageSchema>;
|
|
276
|
+
export type ClientCommonSessionDetail = z.infer<typeof ClientCommonSessionDetailSchema>;
|
|
277
|
+
export type ClientCommonActivePageDetail = z.infer<typeof ClientCommonActivePageDetailSchema>;
|
|
278
|
+
export type ClientCommonGlobalSnapshot = z.infer<typeof ClientCommonGlobalSnapshotSchema>;
|
|
279
|
+
export type ClientCommonSnapshotFrame = z.infer<typeof ClientCommonSnapshotFrameSchema>;
|
|
280
|
+
export type ClientCommonErrorFrame = z.infer<typeof ClientCommonErrorFrameSchema>;
|
|
281
|
+
export type ClientCommonClientFrame = z.infer<typeof ClientCommonClientFrameSchema>;
|
|
282
|
+
export type ClientCommonServerFrame = z.infer<typeof ClientCommonServerFrameSchema>;
|
|
283
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,eAAO,MAAM,+BAA+B;;;iBAG1C,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;;;;;;iBAI3C,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;iBAOvC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;iBAU1C,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;iBAMxC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;iBAM1C,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;iBAM7C,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAc3C,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI1C,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;iBAavC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;iBAA+B,CAAC;AAE1E,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAIxC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AACF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,kCAAkC,CAC1C,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC"}
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ClientUserSchema, IsoDateTimeSchema, OwnerFocusSchema, } from "./shared";
|
|
3
|
+
export const CLIENT_COMMON_WS_PROTOCOL = "client.common.ws.v1";
|
|
4
|
+
export const ClientSessionClaimRequestSchema = z.object({
|
|
5
|
+
protocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
6
|
+
sdkVersion: z.string().min(1),
|
|
7
|
+
});
|
|
8
|
+
export const ClientSessionClaimResponseSchema = z.object({
|
|
9
|
+
protocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
10
|
+
sessionId: z.string().min(1),
|
|
11
|
+
user: ClientUserSchema.optional(),
|
|
12
|
+
});
|
|
13
|
+
export const ClientCommonHelloFrameSchema = z.object({
|
|
14
|
+
protocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
15
|
+
type: z.literal("hello"),
|
|
16
|
+
supportedProtocols: z.tuple([z.literal(CLIENT_COMMON_WS_PROTOCOL)]),
|
|
17
|
+
sdkVersion: z.string().min(1),
|
|
18
|
+
sessionId: z.string().min(1),
|
|
19
|
+
tabId: z.string().min(1),
|
|
20
|
+
});
|
|
21
|
+
export const ClientCommonHelloAckFrameSchema = z.object({
|
|
22
|
+
protocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
23
|
+
type: z.literal("hello_ack"),
|
|
24
|
+
selectedProtocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
25
|
+
connectionId: z.string().min(1),
|
|
26
|
+
session: z.object({
|
|
27
|
+
sessionId: z.string().min(1),
|
|
28
|
+
tabId: z.string().min(1),
|
|
29
|
+
user: ClientUserSchema.optional(),
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
export const ClientCommonSessionPageSchema = z.object({
|
|
33
|
+
canonicalUrl: z.string().min(1),
|
|
34
|
+
title: z.string().min(1).optional(),
|
|
35
|
+
url: z.string().min(1).optional(),
|
|
36
|
+
tabCount: z.number().int().nonnegative(),
|
|
37
|
+
lastSeenAt: IsoDateTimeSchema,
|
|
38
|
+
});
|
|
39
|
+
export const ClientCommonSessionDetailSchema = z.object({
|
|
40
|
+
sessionId: z.string().min(1),
|
|
41
|
+
tabCount: z.number().int().nonnegative(),
|
|
42
|
+
user: ClientUserSchema.optional(),
|
|
43
|
+
pages: z.array(ClientCommonSessionPageSchema),
|
|
44
|
+
lastSeenAt: IsoDateTimeSchema,
|
|
45
|
+
});
|
|
46
|
+
export const ClientCommonActivePageDetailSchema = z.object({
|
|
47
|
+
canonicalUrl: z.string().min(1),
|
|
48
|
+
title: z.string().min(1).optional(),
|
|
49
|
+
url: z.string().min(1).optional(),
|
|
50
|
+
sessionCount: z.number().int().nonnegative(),
|
|
51
|
+
lastSeenAt: IsoDateTimeSchema,
|
|
52
|
+
});
|
|
53
|
+
export const ClientCommonGlobalSnapshotSchema = z.object({
|
|
54
|
+
revision: z.number().int().nonnegative(),
|
|
55
|
+
updatedAt: IsoDateTimeSchema,
|
|
56
|
+
sessions: z.object({
|
|
57
|
+
totalCount: z.number().int().nonnegative(),
|
|
58
|
+
recent: z.array(ClientCommonSessionDetailSchema),
|
|
59
|
+
}),
|
|
60
|
+
activePages: z.object({
|
|
61
|
+
totalCount: z.number().int().nonnegative(),
|
|
62
|
+
top: z.array(ClientCommonActivePageDetailSchema),
|
|
63
|
+
}),
|
|
64
|
+
owner: z.object({
|
|
65
|
+
focus: OwnerFocusSchema.nullable(),
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
export const ClientCommonSnapshotFrameSchema = z.object({
|
|
69
|
+
protocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
70
|
+
type: z.literal("snapshot"),
|
|
71
|
+
snapshot: ClientCommonGlobalSnapshotSchema,
|
|
72
|
+
});
|
|
73
|
+
export const ClientCommonErrorFrameSchema = z.object({
|
|
74
|
+
protocol: z.literal(CLIENT_COMMON_WS_PROTOCOL),
|
|
75
|
+
type: z.literal("error"),
|
|
76
|
+
code: z.enum([
|
|
77
|
+
"invalid_frame",
|
|
78
|
+
"hello_required",
|
|
79
|
+
"unsupported_protocol",
|
|
80
|
+
"invalid_session",
|
|
81
|
+
"connection_superseded",
|
|
82
|
+
"internal_error",
|
|
83
|
+
]),
|
|
84
|
+
message: z.string(),
|
|
85
|
+
fatal: z.literal(true),
|
|
86
|
+
});
|
|
87
|
+
export const ClientCommonClientFrameSchema = ClientCommonHelloFrameSchema;
|
|
88
|
+
export const ClientCommonServerFrameSchema = z.discriminatedUnion("type", [
|
|
89
|
+
ClientCommonHelloAckFrameSchema,
|
|
90
|
+
ClientCommonSnapshotFrameSchema,
|
|
91
|
+
ClientCommonErrorFrameSchema,
|
|
92
|
+
]);
|