camstreamerlib 3.5.2 → 4.0.0-beta.2

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.
Files changed (72) hide show
  1. package/CamOverlayAPI.d.ts +11 -28
  2. package/CamOverlayAPI.js +116 -138
  3. package/CamOverlayDrawingAPI.js +26 -18
  4. package/CamOverlayPainter/Frame.js +167 -182
  5. package/CamOverlayPainter/Painter.js +80 -101
  6. package/CamOverlayPainter/ResourceManager.js +31 -46
  7. package/CamScripterAPI.d.ts +19 -0
  8. package/CamScripterAPI.js +66 -0
  9. package/CamScripterAPICameraEventsGenerator.js +22 -16
  10. package/CamStreamerAPI.d.ts +5 -27
  11. package/CamStreamerAPI.js +45 -71
  12. package/CamSwitcherAPI.d.ts +38 -71
  13. package/CamSwitcherAPI.js +329 -91
  14. package/CamSwitcherEvents.d.ts +15 -33
  15. package/CamSwitcherEvents.js +53 -97
  16. package/CreatePackage.js +5 -7
  17. package/README.md +3 -1
  18. package/VapixAPI.d.ts +66 -0
  19. package/VapixAPI.js +454 -0
  20. package/VapixEvents.js +18 -16
  21. package/errors/errors.d.ts +34 -0
  22. package/errors/errors.js +66 -0
  23. package/events/AxisCameraStationEvents.js +29 -42
  24. package/events/GenetecAgent.d.ts +14 -15
  25. package/events/GenetecAgent.js +81 -100
  26. package/internal/Digest.js +5 -11
  27. package/internal/ProxyClient.d.ts +11 -0
  28. package/internal/ProxyClient.js +40 -0
  29. package/internal/common.d.ts +19 -4
  30. package/internal/common.js +11 -26
  31. package/internal/constants.d.ts +1 -0
  32. package/internal/constants.js +1 -0
  33. package/internal/transformers.d.ts +5 -0
  34. package/internal/transformers.js +25 -0
  35. package/internal/utils.d.ts +11 -0
  36. package/internal/utils.js +34 -0
  37. package/internal/versionCompare.d.ts +6 -0
  38. package/internal/versionCompare.js +44 -0
  39. package/node/DefaultClient.d.ts +15 -0
  40. package/node/DefaultClient.js +50 -0
  41. package/{internal → node}/HttpRequestSender.d.ts +2 -2
  42. package/node/HttpRequestSender.js +85 -0
  43. package/{HttpServer.d.ts → node/HttpServer.d.ts} +1 -1
  44. package/{HttpServer.js → node/HttpServer.js} +22 -24
  45. package/{internal → node}/WsClient.d.ts +1 -1
  46. package/{internal → node}/WsClient.js +32 -39
  47. package/node/WsEventClient.d.ts +13 -0
  48. package/node/WsEventClient.js +18 -0
  49. package/package.json +7 -3
  50. package/types/CamOverlayAPI.d.ts +188 -0
  51. package/types/CamOverlayAPI.js +44 -0
  52. package/types/CamScripterAPI.d.ts +67 -0
  53. package/types/CamScripterAPI.js +17 -0
  54. package/types/CamStreamerAPI.d.ts +139 -0
  55. package/types/CamStreamerAPI.js +25 -0
  56. package/types/CamSwitcherAPI.d.ts +814 -0
  57. package/types/CamSwitcherAPI.js +134 -0
  58. package/types/CamswitcherEvents.d.ts +491 -0
  59. package/types/CamswitcherEvents.js +59 -0
  60. package/types/VapixAPI.d.ts +1704 -0
  61. package/types/VapixAPI.js +129 -0
  62. package/types/common.d.ts +37 -0
  63. package/types/common.js +11 -0
  64. package/web/DefaultClient.d.ts +6 -0
  65. package/web/DefaultClient.js +16 -0
  66. package/web/WsClient.d.ts +13 -0
  67. package/web/WsClient.js +58 -0
  68. package/CameraVapix.d.ts +0 -98
  69. package/CameraVapix.js +0 -441
  70. package/DefaultAgent.d.ts +0 -15
  71. package/DefaultAgent.js +0 -68
  72. package/internal/HttpRequestSender.js +0 -117
@@ -0,0 +1,134 @@
1
+ import { z } from 'zod';
2
+ import { toCamelCase, toCamelCaseDeep } from '../internal/transformers';
3
+ import { storageTypeSchema, keyboardShortcutsSchema, h264ProfileSchema, audioChannelCountSchema, } from './common';
4
+ const channelTypeSchema = z.union([z.literal('audio'), z.literal('video'), z.literal('av')]);
5
+ const playlistPlayTypeSchema = z.union([
6
+ z.literal('PLAY_ALL'),
7
+ z.literal('PLAY_ALL_LOOP'),
8
+ z.literal('PLAY_ALL_SHUFFLED'),
9
+ z.literal('PLAY_ALL_LOOP_SHUFFLED'),
10
+ z.literal('PLAY_ONE_RANDOM'),
11
+ ]);
12
+ export const storageInfoListSchema = z.array(z.object({
13
+ storage: storageTypeSchema,
14
+ writable: z.boolean(),
15
+ size: z.number(),
16
+ available: z.number(),
17
+ }));
18
+ export const outputInfoSchema = z
19
+ .object({
20
+ rtsp_url: z.string(),
21
+ ws: z.string(),
22
+ ws_initial_message: z.string(),
23
+ })
24
+ .transform(toCamelCase);
25
+ export const audioPushInfoSchema = z
26
+ .object({
27
+ ws: z.string(),
28
+ ws_initial_message: z.string(),
29
+ })
30
+ .transform(toCamelCase);
31
+ const streamSaveSchema = z.object({
32
+ niceName: z.string(),
33
+ ip: z.string(),
34
+ mdnsName: z.string(),
35
+ port: z.number(),
36
+ enabled: z.boolean(),
37
+ auth: z.string(),
38
+ query: z.string(),
39
+ channel: channelTypeSchema,
40
+ keyboard: keyboardShortcutsSchema,
41
+ sortIndexOverview: z.number().optional(),
42
+ viewNumber: z.number(),
43
+ });
44
+ export const streamSaveLoadSchema = z.record(z.string(), streamSaveSchema.partial());
45
+ export const clipSaveSchema = z.object({
46
+ niceName: z.string(),
47
+ channel: channelTypeSchema,
48
+ keyboard: keyboardShortcutsSchema,
49
+ sortIndexOverview: z.number(),
50
+ });
51
+ export const clipSaveLoadSchema = z.record(z.string(), clipSaveSchema.partial());
52
+ const playlistStreamSaveSchema = z
53
+ .object({
54
+ stream_name: z.string(),
55
+ clip_name: z.string(),
56
+ tracker_name: z.string(),
57
+ storage: storageTypeSchema,
58
+ })
59
+ .partial();
60
+ const playlistSaveSchema = z.object({
61
+ channel: channelTypeSchema,
62
+ isFavourite: z.boolean(),
63
+ keyboard: keyboardShortcutsSchema,
64
+ niceName: z.string(),
65
+ sortIndexFavourite: z.number().optional(),
66
+ sortIndexOverview: z.number().optional(),
67
+ play_type: playlistPlayTypeSchema,
68
+ default: z.boolean().optional(),
69
+ stream_list: z.array(z.object({
70
+ id: z.string(),
71
+ isTimeoutCustom: z.boolean(),
72
+ ptz_preset_pos_name: z.string(),
73
+ repeat: z.number(),
74
+ timeout: z.number(),
75
+ video: playlistStreamSaveSchema,
76
+ audio: playlistStreamSaveSchema.optional(),
77
+ })),
78
+ });
79
+ export const playlistSaveLoadSchema = z.record(z.string(), playlistSaveSchema.partial());
80
+ export const trackerSaveSchema = z.object({
81
+ id: z.string(),
82
+ name: z.string(),
83
+ previewId: z.string(),
84
+ duration: z.number(),
85
+ keyboard: keyboardShortcutsSchema,
86
+ channel: channelTypeSchema,
87
+ sortIndexOverview: z.number(),
88
+ width: z.number(),
89
+ height: z.number(),
90
+ fps: z.number(),
91
+ motion_history_frames: z.number(),
92
+ include_zone: z.array(z.array(z.number()).length(2)),
93
+ include_node_ids: z.array(z.string()),
94
+ camera_list: z.array(z.object({
95
+ id: z.string(),
96
+ name: z.string(),
97
+ overview: z.boolean(),
98
+ zone: z.array(z.number()).length(4),
99
+ playlist_name: z.string(),
100
+ ptz_preset_pos_no: z.number(),
101
+ })),
102
+ viewNumber: z.number(),
103
+ camera_view_number: z.number(),
104
+ });
105
+ export const trackerSaveLoadSchema = z.record(z.string(), trackerSaveSchema.partial());
106
+ export const playlistQueueSchema = z
107
+ .object({
108
+ playlist_queue_list: z.array(z.string()),
109
+ })
110
+ .transform(toCamelCaseDeep);
111
+ export const clipListSchema = z.object({
112
+ clip_list: z.record(z.string(), z.object({
113
+ storage: storageTypeSchema,
114
+ duration: z.number(),
115
+ stream_list: z.array(z.union([
116
+ z.object({
117
+ type: z.literal('video'),
118
+ width: z.number(),
119
+ height: z.number(),
120
+ sample_rate: z.number(),
121
+ h264_profile: h264ProfileSchema,
122
+ h264_level: z.literal('4.1'),
123
+ gop: z.number(),
124
+ fps: z.number(),
125
+ bitrate: z.number(),
126
+ }),
127
+ z.object({
128
+ type: z.literal('audio'),
129
+ sample_rate: z.number(),
130
+ channel_count: audioChannelCountSchema,
131
+ }),
132
+ ])),
133
+ })),
134
+ });
@@ -0,0 +1,491 @@
1
+ import { z } from 'zod';
2
+ declare const cswEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3
+ type: z.ZodLiteral<"authorization">;
4
+ state: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ type: "authorization";
7
+ state: string;
8
+ }, {
9
+ type: "authorization";
10
+ state: string;
11
+ }>, z.ZodObject<{
12
+ type: z.ZodLiteral<"PlaylistSwitch">;
13
+ playlist_name: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ type: "PlaylistSwitch";
16
+ playlist_name: string;
17
+ }, {
18
+ type: "PlaylistSwitch";
19
+ playlist_name: string;
20
+ }>, z.ZodObject<{
21
+ type: z.ZodLiteral<"StreamAvailable">;
22
+ stream_name: z.ZodString;
23
+ state: z.ZodBoolean;
24
+ }, "strip", z.ZodTypeAny, {
25
+ type: "StreamAvailable";
26
+ stream_name: string;
27
+ state: boolean;
28
+ }, {
29
+ type: "StreamAvailable";
30
+ stream_name: string;
31
+ state: boolean;
32
+ }>, z.ZodObject<{
33
+ type: z.ZodLiteral<"StreamSwitchAudio">;
34
+ stream_name: z.ZodOptional<z.ZodString>;
35
+ clip_name: z.ZodOptional<z.ZodString>;
36
+ master_audio: z.ZodBoolean;
37
+ }, "strip", z.ZodTypeAny, {
38
+ type: "StreamSwitchAudio";
39
+ master_audio: boolean;
40
+ stream_name?: string | undefined;
41
+ clip_name?: string | undefined;
42
+ }, {
43
+ type: "StreamSwitchAudio";
44
+ master_audio: boolean;
45
+ stream_name?: string | undefined;
46
+ clip_name?: string | undefined;
47
+ }>, z.ZodObject<{
48
+ type: z.ZodLiteral<"StreamSwitchAudioError">;
49
+ stream_name: z.ZodOptional<z.ZodString>;
50
+ clip_name: z.ZodOptional<z.ZodString>;
51
+ master_audio: z.ZodBoolean;
52
+ }, "strip", z.ZodTypeAny, {
53
+ type: "StreamSwitchAudioError";
54
+ master_audio: boolean;
55
+ stream_name?: string | undefined;
56
+ clip_name?: string | undefined;
57
+ }, {
58
+ type: "StreamSwitchAudioError";
59
+ master_audio: boolean;
60
+ stream_name?: string | undefined;
61
+ clip_name?: string | undefined;
62
+ }>, z.ZodObject<{
63
+ type: z.ZodLiteral<"StreamSwitchVideo">;
64
+ playlist_active_stream: z.ZodNumber;
65
+ stream_name: z.ZodOptional<z.ZodString>;
66
+ playlist_name: z.ZodOptional<z.ZodString>;
67
+ clip_name: z.ZodOptional<z.ZodString>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ type: "StreamSwitchVideo";
70
+ playlist_active_stream: number;
71
+ stream_name?: string | undefined;
72
+ clip_name?: string | undefined;
73
+ playlist_name?: string | undefined;
74
+ }, {
75
+ type: "StreamSwitchVideo";
76
+ playlist_active_stream: number;
77
+ stream_name?: string | undefined;
78
+ clip_name?: string | undefined;
79
+ playlist_name?: string | undefined;
80
+ }>, z.ZodObject<{
81
+ type: z.ZodLiteral<"PlaylistQueueChange">;
82
+ queue: z.ZodArray<z.ZodString, "many">;
83
+ }, "strip", z.ZodTypeAny, {
84
+ type: "PlaylistQueueChange";
85
+ queue: string[];
86
+ }, {
87
+ type: "PlaylistQueueChange";
88
+ queue: string[];
89
+ }>, z.ZodObject<{
90
+ type: z.ZodLiteral<"ClipUpload">;
91
+ clip_name: z.ZodOptional<z.ZodString>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ type: "ClipUpload";
94
+ clip_name?: string | undefined;
95
+ }, {
96
+ type: "ClipUpload";
97
+ clip_name?: string | undefined;
98
+ }>, z.ZodObject<{
99
+ type: z.ZodLiteral<"SwitcherStop">;
100
+ default_playlist_id: z.ZodOptional<z.ZodString>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ type: "SwitcherStop";
103
+ default_playlist_id?: string | undefined;
104
+ }, {
105
+ type: "SwitcherStop";
106
+ default_playlist_id?: string | undefined;
107
+ }>, z.ZodObject<{
108
+ type: z.ZodLiteral<"SwitcherStart">;
109
+ default_playlist_id: z.ZodOptional<z.ZodString>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ type: "SwitcherStart";
112
+ default_playlist_id?: string | undefined;
113
+ }, {
114
+ type: "SwitcherStart";
115
+ default_playlist_id?: string | undefined;
116
+ }>, z.ZodObject<{
117
+ type: z.ZodLiteral<"MediaServerStarted">;
118
+ }, "strip", z.ZodTypeAny, {
119
+ type: "MediaServerStarted";
120
+ }, {
121
+ type: "MediaServerStarted";
122
+ }>, z.ZodObject<{
123
+ type: z.ZodLiteral<"ClipRemove">;
124
+ clip_name: z.ZodString;
125
+ }, "strip", z.ZodTypeAny, {
126
+ type: "ClipRemove";
127
+ clip_name: string;
128
+ }, {
129
+ type: "ClipRemove";
130
+ clip_name: string;
131
+ }>]>;
132
+ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
133
+ type: z.ZodLiteral<"init">;
134
+ data: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
135
+ type: z.ZodLiteral<"authorization">;
136
+ state: z.ZodString;
137
+ }, "strip", z.ZodTypeAny, {
138
+ type: "authorization";
139
+ state: string;
140
+ }, {
141
+ type: "authorization";
142
+ state: string;
143
+ }>, z.ZodObject<{
144
+ type: z.ZodLiteral<"PlaylistSwitch">;
145
+ playlist_name: z.ZodString;
146
+ }, "strip", z.ZodTypeAny, {
147
+ type: "PlaylistSwitch";
148
+ playlist_name: string;
149
+ }, {
150
+ type: "PlaylistSwitch";
151
+ playlist_name: string;
152
+ }>, z.ZodObject<{
153
+ type: z.ZodLiteral<"StreamAvailable">;
154
+ stream_name: z.ZodString;
155
+ state: z.ZodBoolean;
156
+ }, "strip", z.ZodTypeAny, {
157
+ type: "StreamAvailable";
158
+ stream_name: string;
159
+ state: boolean;
160
+ }, {
161
+ type: "StreamAvailable";
162
+ stream_name: string;
163
+ state: boolean;
164
+ }>, z.ZodObject<{
165
+ type: z.ZodLiteral<"StreamSwitchAudio">;
166
+ stream_name: z.ZodOptional<z.ZodString>;
167
+ clip_name: z.ZodOptional<z.ZodString>;
168
+ master_audio: z.ZodBoolean;
169
+ }, "strip", z.ZodTypeAny, {
170
+ type: "StreamSwitchAudio";
171
+ master_audio: boolean;
172
+ stream_name?: string | undefined;
173
+ clip_name?: string | undefined;
174
+ }, {
175
+ type: "StreamSwitchAudio";
176
+ master_audio: boolean;
177
+ stream_name?: string | undefined;
178
+ clip_name?: string | undefined;
179
+ }>, z.ZodObject<{
180
+ type: z.ZodLiteral<"StreamSwitchAudioError">;
181
+ stream_name: z.ZodOptional<z.ZodString>;
182
+ clip_name: z.ZodOptional<z.ZodString>;
183
+ master_audio: z.ZodBoolean;
184
+ }, "strip", z.ZodTypeAny, {
185
+ type: "StreamSwitchAudioError";
186
+ master_audio: boolean;
187
+ stream_name?: string | undefined;
188
+ clip_name?: string | undefined;
189
+ }, {
190
+ type: "StreamSwitchAudioError";
191
+ master_audio: boolean;
192
+ stream_name?: string | undefined;
193
+ clip_name?: string | undefined;
194
+ }>, z.ZodObject<{
195
+ type: z.ZodLiteral<"StreamSwitchVideo">;
196
+ playlist_active_stream: z.ZodNumber;
197
+ stream_name: z.ZodOptional<z.ZodString>;
198
+ playlist_name: z.ZodOptional<z.ZodString>;
199
+ clip_name: z.ZodOptional<z.ZodString>;
200
+ }, "strip", z.ZodTypeAny, {
201
+ type: "StreamSwitchVideo";
202
+ playlist_active_stream: number;
203
+ stream_name?: string | undefined;
204
+ clip_name?: string | undefined;
205
+ playlist_name?: string | undefined;
206
+ }, {
207
+ type: "StreamSwitchVideo";
208
+ playlist_active_stream: number;
209
+ stream_name?: string | undefined;
210
+ clip_name?: string | undefined;
211
+ playlist_name?: string | undefined;
212
+ }>, z.ZodObject<{
213
+ type: z.ZodLiteral<"PlaylistQueueChange">;
214
+ queue: z.ZodArray<z.ZodString, "many">;
215
+ }, "strip", z.ZodTypeAny, {
216
+ type: "PlaylistQueueChange";
217
+ queue: string[];
218
+ }, {
219
+ type: "PlaylistQueueChange";
220
+ queue: string[];
221
+ }>, z.ZodObject<{
222
+ type: z.ZodLiteral<"ClipUpload">;
223
+ clip_name: z.ZodOptional<z.ZodString>;
224
+ }, "strip", z.ZodTypeAny, {
225
+ type: "ClipUpload";
226
+ clip_name?: string | undefined;
227
+ }, {
228
+ type: "ClipUpload";
229
+ clip_name?: string | undefined;
230
+ }>, z.ZodObject<{
231
+ type: z.ZodLiteral<"SwitcherStop">;
232
+ default_playlist_id: z.ZodOptional<z.ZodString>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ type: "SwitcherStop";
235
+ default_playlist_id?: string | undefined;
236
+ }, {
237
+ type: "SwitcherStop";
238
+ default_playlist_id?: string | undefined;
239
+ }>, z.ZodObject<{
240
+ type: z.ZodLiteral<"SwitcherStart">;
241
+ default_playlist_id: z.ZodOptional<z.ZodString>;
242
+ }, "strip", z.ZodTypeAny, {
243
+ type: "SwitcherStart";
244
+ default_playlist_id?: string | undefined;
245
+ }, {
246
+ type: "SwitcherStart";
247
+ default_playlist_id?: string | undefined;
248
+ }>, z.ZodObject<{
249
+ type: z.ZodLiteral<"MediaServerStarted">;
250
+ }, "strip", z.ZodTypeAny, {
251
+ type: "MediaServerStarted";
252
+ }, {
253
+ type: "MediaServerStarted";
254
+ }>, z.ZodObject<{
255
+ type: z.ZodLiteral<"ClipRemove">;
256
+ clip_name: z.ZodString;
257
+ }, "strip", z.ZodTypeAny, {
258
+ type: "ClipRemove";
259
+ clip_name: string;
260
+ }, {
261
+ type: "ClipRemove";
262
+ clip_name: string;
263
+ }>]>;
264
+ }, "strip", z.ZodTypeAny, {
265
+ type: "init";
266
+ data: {
267
+ type: "authorization";
268
+ state: string;
269
+ } | {
270
+ type: "PlaylistSwitch";
271
+ playlist_name: string;
272
+ } | {
273
+ type: "StreamAvailable";
274
+ stream_name: string;
275
+ state: boolean;
276
+ } | {
277
+ type: "StreamSwitchAudio";
278
+ master_audio: boolean;
279
+ stream_name?: string | undefined;
280
+ clip_name?: string | undefined;
281
+ } | {
282
+ type: "StreamSwitchAudioError";
283
+ master_audio: boolean;
284
+ stream_name?: string | undefined;
285
+ clip_name?: string | undefined;
286
+ } | {
287
+ type: "StreamSwitchVideo";
288
+ playlist_active_stream: number;
289
+ stream_name?: string | undefined;
290
+ clip_name?: string | undefined;
291
+ playlist_name?: string | undefined;
292
+ } | {
293
+ type: "PlaylistQueueChange";
294
+ queue: string[];
295
+ } | {
296
+ type: "ClipUpload";
297
+ clip_name?: string | undefined;
298
+ } | {
299
+ type: "SwitcherStop";
300
+ default_playlist_id?: string | undefined;
301
+ } | {
302
+ type: "SwitcherStart";
303
+ default_playlist_id?: string | undefined;
304
+ } | {
305
+ type: "MediaServerStarted";
306
+ } | {
307
+ type: "ClipRemove";
308
+ clip_name: string;
309
+ };
310
+ }, {
311
+ type: "init";
312
+ data: {
313
+ type: "authorization";
314
+ state: string;
315
+ } | {
316
+ type: "PlaylistSwitch";
317
+ playlist_name: string;
318
+ } | {
319
+ type: "StreamAvailable";
320
+ stream_name: string;
321
+ state: boolean;
322
+ } | {
323
+ type: "StreamSwitchAudio";
324
+ master_audio: boolean;
325
+ stream_name?: string | undefined;
326
+ clip_name?: string | undefined;
327
+ } | {
328
+ type: "StreamSwitchAudioError";
329
+ master_audio: boolean;
330
+ stream_name?: string | undefined;
331
+ clip_name?: string | undefined;
332
+ } | {
333
+ type: "StreamSwitchVideo";
334
+ playlist_active_stream: number;
335
+ stream_name?: string | undefined;
336
+ clip_name?: string | undefined;
337
+ playlist_name?: string | undefined;
338
+ } | {
339
+ type: "PlaylistQueueChange";
340
+ queue: string[];
341
+ } | {
342
+ type: "ClipUpload";
343
+ clip_name?: string | undefined;
344
+ } | {
345
+ type: "SwitcherStop";
346
+ default_playlist_id?: string | undefined;
347
+ } | {
348
+ type: "SwitcherStart";
349
+ default_playlist_id?: string | undefined;
350
+ } | {
351
+ type: "MediaServerStarted";
352
+ } | {
353
+ type: "ClipRemove";
354
+ clip_name: string;
355
+ };
356
+ }>, z.ZodObject<{
357
+ type: z.ZodLiteral<"authorization">;
358
+ state: z.ZodString;
359
+ }, "strip", z.ZodTypeAny, {
360
+ type: "authorization";
361
+ state: string;
362
+ }, {
363
+ type: "authorization";
364
+ state: string;
365
+ }>, z.ZodObject<{
366
+ type: z.ZodLiteral<"PlaylistSwitch">;
367
+ playlist_name: z.ZodString;
368
+ }, "strip", z.ZodTypeAny, {
369
+ type: "PlaylistSwitch";
370
+ playlist_name: string;
371
+ }, {
372
+ type: "PlaylistSwitch";
373
+ playlist_name: string;
374
+ }>, z.ZodObject<{
375
+ type: z.ZodLiteral<"StreamAvailable">;
376
+ stream_name: z.ZodString;
377
+ state: z.ZodBoolean;
378
+ }, "strip", z.ZodTypeAny, {
379
+ type: "StreamAvailable";
380
+ stream_name: string;
381
+ state: boolean;
382
+ }, {
383
+ type: "StreamAvailable";
384
+ stream_name: string;
385
+ state: boolean;
386
+ }>, z.ZodObject<{
387
+ type: z.ZodLiteral<"StreamSwitchAudio">;
388
+ stream_name: z.ZodOptional<z.ZodString>;
389
+ clip_name: z.ZodOptional<z.ZodString>;
390
+ master_audio: z.ZodBoolean;
391
+ }, "strip", z.ZodTypeAny, {
392
+ type: "StreamSwitchAudio";
393
+ master_audio: boolean;
394
+ stream_name?: string | undefined;
395
+ clip_name?: string | undefined;
396
+ }, {
397
+ type: "StreamSwitchAudio";
398
+ master_audio: boolean;
399
+ stream_name?: string | undefined;
400
+ clip_name?: string | undefined;
401
+ }>, z.ZodObject<{
402
+ type: z.ZodLiteral<"StreamSwitchAudioError">;
403
+ stream_name: z.ZodOptional<z.ZodString>;
404
+ clip_name: z.ZodOptional<z.ZodString>;
405
+ master_audio: z.ZodBoolean;
406
+ }, "strip", z.ZodTypeAny, {
407
+ type: "StreamSwitchAudioError";
408
+ master_audio: boolean;
409
+ stream_name?: string | undefined;
410
+ clip_name?: string | undefined;
411
+ }, {
412
+ type: "StreamSwitchAudioError";
413
+ master_audio: boolean;
414
+ stream_name?: string | undefined;
415
+ clip_name?: string | undefined;
416
+ }>, z.ZodObject<{
417
+ type: z.ZodLiteral<"StreamSwitchVideo">;
418
+ playlist_active_stream: z.ZodNumber;
419
+ stream_name: z.ZodOptional<z.ZodString>;
420
+ playlist_name: z.ZodOptional<z.ZodString>;
421
+ clip_name: z.ZodOptional<z.ZodString>;
422
+ }, "strip", z.ZodTypeAny, {
423
+ type: "StreamSwitchVideo";
424
+ playlist_active_stream: number;
425
+ stream_name?: string | undefined;
426
+ clip_name?: string | undefined;
427
+ playlist_name?: string | undefined;
428
+ }, {
429
+ type: "StreamSwitchVideo";
430
+ playlist_active_stream: number;
431
+ stream_name?: string | undefined;
432
+ clip_name?: string | undefined;
433
+ playlist_name?: string | undefined;
434
+ }>, z.ZodObject<{
435
+ type: z.ZodLiteral<"PlaylistQueueChange">;
436
+ queue: z.ZodArray<z.ZodString, "many">;
437
+ }, "strip", z.ZodTypeAny, {
438
+ type: "PlaylistQueueChange";
439
+ queue: string[];
440
+ }, {
441
+ type: "PlaylistQueueChange";
442
+ queue: string[];
443
+ }>, z.ZodObject<{
444
+ type: z.ZodLiteral<"ClipUpload">;
445
+ clip_name: z.ZodOptional<z.ZodString>;
446
+ }, "strip", z.ZodTypeAny, {
447
+ type: "ClipUpload";
448
+ clip_name?: string | undefined;
449
+ }, {
450
+ type: "ClipUpload";
451
+ clip_name?: string | undefined;
452
+ }>, z.ZodObject<{
453
+ type: z.ZodLiteral<"SwitcherStop">;
454
+ default_playlist_id: z.ZodOptional<z.ZodString>;
455
+ }, "strip", z.ZodTypeAny, {
456
+ type: "SwitcherStop";
457
+ default_playlist_id?: string | undefined;
458
+ }, {
459
+ type: "SwitcherStop";
460
+ default_playlist_id?: string | undefined;
461
+ }>, z.ZodObject<{
462
+ type: z.ZodLiteral<"SwitcherStart">;
463
+ default_playlist_id: z.ZodOptional<z.ZodString>;
464
+ }, "strip", z.ZodTypeAny, {
465
+ type: "SwitcherStart";
466
+ default_playlist_id?: string | undefined;
467
+ }, {
468
+ type: "SwitcherStart";
469
+ default_playlist_id?: string | undefined;
470
+ }>, z.ZodObject<{
471
+ type: z.ZodLiteral<"MediaServerStarted">;
472
+ }, "strip", z.ZodTypeAny, {
473
+ type: "MediaServerStarted";
474
+ }, {
475
+ type: "MediaServerStarted";
476
+ }>, z.ZodObject<{
477
+ type: z.ZodLiteral<"ClipRemove">;
478
+ clip_name: z.ZodString;
479
+ }, "strip", z.ZodTypeAny, {
480
+ type: "ClipRemove";
481
+ clip_name: string;
482
+ }, {
483
+ type: "ClipRemove";
484
+ clip_name: string;
485
+ }>]>;
486
+ export type TCamSwitcherEvent = z.infer<typeof cswEventsDataSchema>;
487
+ export type TCamSwitcherEventType = TCamSwitcherEvent['type'];
488
+ export type TCamSwitcherEventOfType<T extends TCamSwitcherEventType> = Extract<TCamSwitcherEvent, {
489
+ type: T;
490
+ }>;
491
+ export {};
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod';
2
+ const cswEventsDataSchema = z.discriminatedUnion('type', [
3
+ z.object({ type: z.literal('authorization'), state: z.string() }),
4
+ z.object({
5
+ type: z.literal('PlaylistSwitch'),
6
+ playlist_name: z.string(),
7
+ }),
8
+ z.object({
9
+ type: z.literal('StreamAvailable'),
10
+ stream_name: z.string(),
11
+ state: z.boolean(),
12
+ }),
13
+ z.object({
14
+ type: z.literal('StreamSwitchAudio'),
15
+ stream_name: z.string().optional(),
16
+ clip_name: z.string().optional(),
17
+ master_audio: z.boolean(),
18
+ }),
19
+ z.object({
20
+ type: z.literal('StreamSwitchAudioError'),
21
+ stream_name: z.string().optional(),
22
+ clip_name: z.string().optional(),
23
+ master_audio: z.boolean(),
24
+ }),
25
+ z.object({
26
+ type: z.literal('StreamSwitchVideo'),
27
+ playlist_active_stream: z.number(),
28
+ stream_name: z.string().optional(),
29
+ playlist_name: z.string().optional(),
30
+ clip_name: z.string().optional(),
31
+ }),
32
+ z.object({
33
+ type: z.literal('PlaylistQueueChange'),
34
+ queue: z.array(z.string()),
35
+ }),
36
+ z.object({
37
+ type: z.literal('ClipUpload'),
38
+ clip_name: z.string().optional(),
39
+ }),
40
+ z.object({
41
+ type: z.literal('SwitcherStop'),
42
+ default_playlist_id: z.string().optional(),
43
+ }),
44
+ z.object({
45
+ type: z.literal('SwitcherStart'),
46
+ default_playlist_id: z.string().optional(),
47
+ }),
48
+ z.object({
49
+ type: z.literal('MediaServerStarted'),
50
+ }),
51
+ z.object({
52
+ type: z.literal('ClipRemove'),
53
+ clip_name: z.string(),
54
+ }),
55
+ ]);
56
+ export const cswEventsSchema = z.discriminatedUnion('type', [
57
+ z.object({ type: z.literal('init'), data: cswEventsDataSchema }),
58
+ ...cswEventsDataSchema.options,
59
+ ]);