@fishjam-cloud/js-server-sdk 0.20.0 → 0.21.0

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 CHANGED
@@ -1,6 +1,5 @@
1
- import { ServerMessage } from './proto.mjs';
1
+ import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
2
2
  import axios from 'axios';
3
- import '@bufbuild/protobuf/wire';
4
3
 
5
4
  /**
6
5
  * Describes peer status
@@ -16,35 +15,41 @@ interface Peer$1 {
16
15
  'id': string;
17
16
  /**
18
17
  * Custom metadata set by the peer
19
- * @type {any}
18
+ * @type {object}
20
19
  * @memberof Peer
21
20
  */
22
- 'metadata': any | null;
21
+ 'metadata': object | null;
23
22
  /**
24
23
  *
25
24
  * @type {PeerStatus}
26
25
  * @memberof Peer
27
26
  */
28
27
  'status': PeerStatus;
28
+ /**
29
+ *
30
+ * @type {SubscribeOptions}
31
+ * @memberof Peer
32
+ */
33
+ 'subscribe': SubscribeOptions | null;
29
34
  /**
30
35
  * List of all peer\'s tracks
31
36
  * @type {Array<Track>}
32
37
  * @memberof Peer
33
38
  */
34
- 'tracks': Array<Track>;
39
+ 'tracks': Array<Track$1>;
35
40
  /**
36
- * Peer type
37
- * @type {string}
41
+ *
42
+ * @type {PeerType}
38
43
  * @memberof Peer
39
44
  */
40
- 'type': string;
45
+ 'type': PeerType;
41
46
  }
42
47
  /**
43
48
  * @type PeerOptions
44
49
  * Peer-specific options
45
50
  * @export
46
51
  */
47
- type PeerOptions = PeerOptionsWebRTC;
52
+ type PeerOptions = PeerOptionsWebRTC | object;
48
53
  /**
49
54
  * Options specific to the WebRTC peer
50
55
  * @export
@@ -65,6 +70,12 @@ interface PeerOptionsWebRTC {
65
70
  'metadata'?: {
66
71
  [key: string]: any;
67
72
  };
73
+ /**
74
+ *
75
+ * @type {SubscribeOptions1}
76
+ * @memberof PeerOptionsWebRTC
77
+ */
78
+ 'subscribe'?: SubscribeOptions1 | null;
68
79
  }
69
80
  /**
70
81
  * Informs about the peer status
@@ -76,6 +87,16 @@ declare const PeerStatus: {
76
87
  readonly Disconnected: "disconnected";
77
88
  };
78
89
  type PeerStatus = typeof PeerStatus[keyof typeof PeerStatus];
90
+ /**
91
+ * Peer type
92
+ * @export
93
+ * @enum {string}
94
+ */
95
+ declare const PeerType: {
96
+ readonly Webrtc: "webrtc";
97
+ readonly Agent: "agent";
98
+ };
99
+ type PeerType = typeof PeerType[keyof typeof PeerType];
79
100
  /**
80
101
  * Room configuration
81
102
  * @export
@@ -105,7 +126,7 @@ interface RoomConfig {
105
126
  * @type {string}
106
127
  * @memberof RoomConfig
107
128
  */
108
- 'videoCodec'?: RoomConfigVideoCodecEnum | null;
129
+ 'videoCodec'?: RoomConfigVideoCodecEnum;
109
130
  /**
110
131
  * URL where Fishjam notifications will be sent
111
132
  * @type {string}
@@ -139,12 +160,68 @@ interface StreamerToken {
139
160
  */
140
161
  'token': string;
141
162
  }
163
+ /**
164
+ * Configuration of server-side subscriptions to the peer\'s tracks
165
+ * @export
166
+ * @interface SubscribeOptions
167
+ */
168
+ interface SubscribeOptions {
169
+ /**
170
+ * The format of the output audio
171
+ * @type {string}
172
+ * @memberof SubscribeOptions
173
+ */
174
+ 'audioFormat'?: SubscribeOptionsAudioFormatEnum;
175
+ /**
176
+ * The sample rate of the output audio
177
+ * @type {number}
178
+ * @memberof SubscribeOptions
179
+ */
180
+ 'audioSampleRate'?: SubscribeOptionsAudioSampleRateEnum;
181
+ }
182
+ declare const SubscribeOptionsAudioFormatEnum: {
183
+ readonly Pcm16: "pcm16";
184
+ };
185
+ type SubscribeOptionsAudioFormatEnum = typeof SubscribeOptionsAudioFormatEnum[keyof typeof SubscribeOptionsAudioFormatEnum];
186
+ declare const SubscribeOptionsAudioSampleRateEnum: {
187
+ readonly NUMBER_16000: 16000;
188
+ readonly NUMBER_24000: 24000;
189
+ };
190
+ type SubscribeOptionsAudioSampleRateEnum = typeof SubscribeOptionsAudioSampleRateEnum[keyof typeof SubscribeOptionsAudioSampleRateEnum];
191
+ /**
192
+ * Configuration of server-side subscriptions to the peer\'s tracks
193
+ * @export
194
+ * @interface SubscribeOptions1
195
+ */
196
+ interface SubscribeOptions1 {
197
+ /**
198
+ * The format of the output audio
199
+ * @type {string}
200
+ * @memberof SubscribeOptions1
201
+ */
202
+ 'audioFormat'?: SubscribeOptions1AudioFormatEnum;
203
+ /**
204
+ * The sample rate of the output audio
205
+ * @type {number}
206
+ * @memberof SubscribeOptions1
207
+ */
208
+ 'audioSampleRate'?: SubscribeOptions1AudioSampleRateEnum;
209
+ }
210
+ declare const SubscribeOptions1AudioFormatEnum: {
211
+ readonly Pcm16: "pcm16";
212
+ };
213
+ type SubscribeOptions1AudioFormatEnum = typeof SubscribeOptions1AudioFormatEnum[keyof typeof SubscribeOptions1AudioFormatEnum];
214
+ declare const SubscribeOptions1AudioSampleRateEnum: {
215
+ readonly NUMBER_16000: 16000;
216
+ readonly NUMBER_24000: 24000;
217
+ };
218
+ type SubscribeOptions1AudioSampleRateEnum = typeof SubscribeOptions1AudioSampleRateEnum[keyof typeof SubscribeOptions1AudioSampleRateEnum];
142
219
  /**
143
220
  * Describes media track of a Peer or Component
144
221
  * @export
145
222
  * @interface Track
146
223
  */
147
- interface Track {
224
+ interface Track$1 {
148
225
  /**
149
226
  *
150
227
  * @type {string}
@@ -153,10 +230,10 @@ interface Track {
153
230
  'id'?: string;
154
231
  /**
155
232
  *
156
- * @type {any}
233
+ * @type {object}
157
234
  * @memberof Track
158
235
  */
159
- 'metadata'?: any | null;
236
+ 'metadata'?: object | null;
160
237
  /**
161
238
  *
162
239
  * @type {string}
@@ -183,6 +260,285 @@ interface ViewerToken {
183
260
  'token': string;
184
261
  }
185
262
 
263
+ /** Defines types of tracks being published by peers and component */
264
+ declare enum TrackType$1 {
265
+ TRACK_TYPE_UNSPECIFIED = 0,
266
+ TRACK_TYPE_VIDEO = 1,
267
+ TRACK_TYPE_AUDIO = 2,
268
+ UNRECOGNIZED = -1
269
+ }
270
+ /** Describes a media track */
271
+ interface Track {
272
+ id: string;
273
+ type: TrackType$1;
274
+ metadata: string;
275
+ }
276
+ declare const Track: MessageFns$2<Track>;
277
+ type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
278
+ type DeepPartial$2<T> = T extends Builtin$2 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$2<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$2<U>> : T extends {} ? {
279
+ [K in keyof T]?: DeepPartial$2<T[K]>;
280
+ } : Partial<T>;
281
+ type KeysOfUnion$2<T> = T extends T ? keyof T : never;
282
+ type Exact$2<P, I extends P> = P extends Builtin$2 ? P : P & {
283
+ [K in keyof P]: Exact$2<P[K], I[K]>;
284
+ } & {
285
+ [K in Exclude<keyof I, KeysOfUnion$2<P>>]: never;
286
+ };
287
+ interface MessageFns$2<T> {
288
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
289
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
290
+ fromJSON(object: any): T;
291
+ toJSON(message: T): unknown;
292
+ create<I extends Exact$2<DeepPartial$2<T>, I>>(base?: I): T;
293
+ fromPartial<I extends Exact$2<DeepPartial$2<T>, I>>(object: I): T;
294
+ }
295
+
296
+ declare enum ServerMessage_PeerType {
297
+ PEER_TYPE_UNSPECIFIED = 0,
298
+ PEER_TYPE_WEBRTC = 1,
299
+ PEER_TYPE_AGENT = 2,
300
+ UNRECOGNIZED = -1
301
+ }
302
+ /** Defines message groups for which peer can subscribe */
303
+ declare enum ServerMessage_EventType {
304
+ EVENT_TYPE_UNSPECIFIED = 0,
305
+ EVENT_TYPE_SERVER_NOTIFICATION = 1,
306
+ UNRECOGNIZED = -1
307
+ }
308
+ /** Defines any type of message passed between FJ and server peer */
309
+ interface ServerMessage {
310
+ roomCrashed?: ServerMessage_RoomCrashed | undefined;
311
+ peerConnected?: ServerMessage_PeerConnected | undefined;
312
+ peerDisconnected?: ServerMessage_PeerDisconnected | undefined;
313
+ peerCrashed?: ServerMessage_PeerCrashed | undefined;
314
+ componentCrashed?: ServerMessage_ComponentCrashed | undefined;
315
+ authenticated?: ServerMessage_Authenticated | undefined;
316
+ authRequest?: ServerMessage_AuthRequest | undefined;
317
+ subscribeRequest?: ServerMessage_SubscribeRequest | undefined;
318
+ subscribeResponse?: ServerMessage_SubscribeResponse | undefined;
319
+ roomCreated?: ServerMessage_RoomCreated | undefined;
320
+ roomDeleted?: ServerMessage_RoomDeleted | undefined;
321
+ hlsPlayable?: ServerMessage_HlsPlayable | undefined;
322
+ hlsUploaded?: ServerMessage_HlsUploaded | undefined;
323
+ hlsUploadCrashed?: ServerMessage_HlsUploadCrashed | undefined;
324
+ peerMetadataUpdated?: ServerMessage_PeerMetadataUpdated | undefined;
325
+ trackAdded?: ServerMessage_TrackAdded | undefined;
326
+ trackRemoved?: ServerMessage_TrackRemoved | undefined;
327
+ trackMetadataUpdated?: ServerMessage_TrackMetadataUpdated | undefined;
328
+ peerAdded?: ServerMessage_PeerAdded | undefined;
329
+ peerDeleted?: ServerMessage_PeerDeleted | undefined;
330
+ streamConnected?: ServerMessage_StreamConnected | undefined;
331
+ streamDisconnected?: ServerMessage_StreamDisconnected | undefined;
332
+ viewerConnected?: ServerMessage_ViewerConnected | undefined;
333
+ viewerDisconnected?: ServerMessage_ViewerDisconnected | undefined;
334
+ }
335
+ declare const ServerMessage: MessageFns$1<ServerMessage>;
336
+ /** Notification sent when a room crashes */
337
+ interface ServerMessage_RoomCrashed {
338
+ roomId: string;
339
+ }
340
+ declare const ServerMessage_RoomCrashed: MessageFns$1<ServerMessage_RoomCrashed>;
341
+ /** Notification sent when a peer is added */
342
+ interface ServerMessage_PeerAdded {
343
+ roomId: string;
344
+ peerId: string;
345
+ peerType: ServerMessage_PeerType;
346
+ }
347
+ declare const ServerMessage_PeerAdded: MessageFns$1<ServerMessage_PeerAdded>;
348
+ /** Notification sent when a peer is removed */
349
+ interface ServerMessage_PeerDeleted {
350
+ roomId: string;
351
+ peerId: string;
352
+ peerType: ServerMessage_PeerType;
353
+ }
354
+ declare const ServerMessage_PeerDeleted: MessageFns$1<ServerMessage_PeerDeleted>;
355
+ /** Notification sent when a peer connects */
356
+ interface ServerMessage_PeerConnected {
357
+ roomId: string;
358
+ peerId: string;
359
+ peerType: ServerMessage_PeerType;
360
+ }
361
+ declare const ServerMessage_PeerConnected: MessageFns$1<ServerMessage_PeerConnected>;
362
+ /** Notification sent when a peer disconnects from FJ */
363
+ interface ServerMessage_PeerDisconnected {
364
+ roomId: string;
365
+ peerId: string;
366
+ peerType: ServerMessage_PeerType;
367
+ }
368
+ declare const ServerMessage_PeerDisconnected: MessageFns$1<ServerMessage_PeerDisconnected>;
369
+ /** Notification sent when a peer crashes */
370
+ interface ServerMessage_PeerCrashed {
371
+ roomId: string;
372
+ peerId: string;
373
+ reason: string;
374
+ peerType: ServerMessage_PeerType;
375
+ }
376
+ declare const ServerMessage_PeerCrashed: MessageFns$1<ServerMessage_PeerCrashed>;
377
+ /** Notification sent when a component crashes */
378
+ interface ServerMessage_ComponentCrashed {
379
+ roomId: string;
380
+ componentId: string;
381
+ }
382
+ declare const ServerMessage_ComponentCrashed: MessageFns$1<ServerMessage_ComponentCrashed>;
383
+ /** Response sent by FJ, confirming successfull authentication */
384
+ interface ServerMessage_Authenticated {
385
+ }
386
+ declare const ServerMessage_Authenticated: MessageFns$1<ServerMessage_Authenticated>;
387
+ /** Request sent by peer, to authenticate to FJ server */
388
+ interface ServerMessage_AuthRequest {
389
+ token: string;
390
+ }
391
+ declare const ServerMessage_AuthRequest: MessageFns$1<ServerMessage_AuthRequest>;
392
+ /** Request sent by peer to subsribe for certain message type */
393
+ interface ServerMessage_SubscribeRequest {
394
+ eventType: ServerMessage_EventType;
395
+ }
396
+ declare const ServerMessage_SubscribeRequest: MessageFns$1<ServerMessage_SubscribeRequest>;
397
+ /** Response sent by FJ, confirming subscription for message type */
398
+ interface ServerMessage_SubscribeResponse {
399
+ eventType: ServerMessage_EventType;
400
+ }
401
+ declare const ServerMessage_SubscribeResponse: MessageFns$1<ServerMessage_SubscribeResponse>;
402
+ /** Notification sent when a room is created */
403
+ interface ServerMessage_RoomCreated {
404
+ roomId: string;
405
+ }
406
+ declare const ServerMessage_RoomCreated: MessageFns$1<ServerMessage_RoomCreated>;
407
+ /** Notification sent when a room is deleted */
408
+ interface ServerMessage_RoomDeleted {
409
+ roomId: string;
410
+ }
411
+ declare const ServerMessage_RoomDeleted: MessageFns$1<ServerMessage_RoomDeleted>;
412
+ /** Notification sent when the HLS stream becomes available in a room */
413
+ interface ServerMessage_HlsPlayable {
414
+ roomId: string;
415
+ componentId: string;
416
+ }
417
+ declare const ServerMessage_HlsPlayable: MessageFns$1<ServerMessage_HlsPlayable>;
418
+ /** Notification sent when the HLS recording is successfully uploded to AWS S3 */
419
+ interface ServerMessage_HlsUploaded {
420
+ roomId: string;
421
+ }
422
+ declare const ServerMessage_HlsUploaded: MessageFns$1<ServerMessage_HlsUploaded>;
423
+ /** Notification sent when the upload of HLS recording to AWS S3 fails */
424
+ interface ServerMessage_HlsUploadCrashed {
425
+ roomId: string;
426
+ }
427
+ declare const ServerMessage_HlsUploadCrashed: MessageFns$1<ServerMessage_HlsUploadCrashed>;
428
+ /** Notification sent when peer updates its metadata */
429
+ interface ServerMessage_PeerMetadataUpdated {
430
+ roomId: string;
431
+ peerId: string;
432
+ metadata: string;
433
+ peerType: ServerMessage_PeerType;
434
+ }
435
+ declare const ServerMessage_PeerMetadataUpdated: MessageFns$1<ServerMessage_PeerMetadataUpdated>;
436
+ /** Notification sent when peer or component adds new track */
437
+ interface ServerMessage_TrackAdded {
438
+ roomId: string;
439
+ peerId?: string | undefined;
440
+ componentId?: string | undefined;
441
+ track: Track | undefined;
442
+ }
443
+ declare const ServerMessage_TrackAdded: MessageFns$1<ServerMessage_TrackAdded>;
444
+ /** Notification sent when a track is removed */
445
+ interface ServerMessage_TrackRemoved {
446
+ roomId: string;
447
+ peerId?: string | undefined;
448
+ componentId?: string | undefined;
449
+ track: Track | undefined;
450
+ }
451
+ declare const ServerMessage_TrackRemoved: MessageFns$1<ServerMessage_TrackRemoved>;
452
+ /** Notification sent when metadata of a multimedia track is updated */
453
+ interface ServerMessage_TrackMetadataUpdated {
454
+ roomId: string;
455
+ peerId?: string | undefined;
456
+ componentId?: string | undefined;
457
+ track: Track | undefined;
458
+ }
459
+ declare const ServerMessage_TrackMetadataUpdated: MessageFns$1<ServerMessage_TrackMetadataUpdated>;
460
+ /** Notification sent when streamer successfully connects */
461
+ interface ServerMessage_StreamConnected {
462
+ streamId: string;
463
+ }
464
+ declare const ServerMessage_StreamConnected: MessageFns$1<ServerMessage_StreamConnected>;
465
+ /** Notification sent when streamer disconnects */
466
+ interface ServerMessage_StreamDisconnected {
467
+ streamId: string;
468
+ }
469
+ declare const ServerMessage_StreamDisconnected: MessageFns$1<ServerMessage_StreamDisconnected>;
470
+ /** Notification sent when viewer successfully connects */
471
+ interface ServerMessage_ViewerConnected {
472
+ streamId: string;
473
+ viewerId: string;
474
+ }
475
+ declare const ServerMessage_ViewerConnected: MessageFns$1<ServerMessage_ViewerConnected>;
476
+ /** Notification sent when viewer disconnects */
477
+ interface ServerMessage_ViewerDisconnected {
478
+ streamId: string;
479
+ viewerId: string;
480
+ }
481
+ declare const ServerMessage_ViewerDisconnected: MessageFns$1<ServerMessage_ViewerDisconnected>;
482
+ type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
483
+ type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
484
+ [K in keyof T]?: DeepPartial$1<T[K]>;
485
+ } : Partial<T>;
486
+ type KeysOfUnion$1<T> = T extends T ? keyof T : never;
487
+ type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
488
+ [K in keyof P]: Exact$1<P[K], I[K]>;
489
+ } & {
490
+ [K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
491
+ };
492
+ interface MessageFns$1<T> {
493
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
494
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
495
+ fromJSON(object: any): T;
496
+ toJSON(message: T): unknown;
497
+ create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
498
+ fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
499
+ }
500
+ /** Notification containing a chunk of an agent's track's data stream */
501
+ interface AgentRequest_TrackData {
502
+ trackId: string;
503
+ data: Uint8Array;
504
+ }
505
+ declare const AgentRequest_TrackData: MessageFns<AgentRequest_TrackData>;
506
+ /** Defines any type of message passed from Fishjam to agent peer */
507
+ interface AgentResponse {
508
+ authenticated?: AgentResponse_Authenticated | undefined;
509
+ trackData?: AgentResponse_TrackData | undefined;
510
+ }
511
+ declare const AgentResponse: MessageFns<AgentResponse>;
512
+ /** Response confirming successful authentication */
513
+ interface AgentResponse_Authenticated {
514
+ }
515
+ declare const AgentResponse_Authenticated: MessageFns<AgentResponse_Authenticated>;
516
+ /** Notification containing a chunk of a track's data stream */
517
+ interface AgentResponse_TrackData {
518
+ peerId: string;
519
+ track: Track | undefined;
520
+ data: Uint8Array;
521
+ }
522
+ declare const AgentResponse_TrackData: MessageFns<AgentResponse_TrackData>;
523
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
524
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
525
+ [K in keyof T]?: DeepPartial<T[K]>;
526
+ } : Partial<T>;
527
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
528
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
529
+ [K in keyof P]: Exact<P[K], I[K]>;
530
+ } & {
531
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
532
+ };
533
+ interface MessageFns<T> {
534
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
535
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
536
+ fromJSON(object: any): T;
537
+ toJSON(message: T): unknown;
538
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
539
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
540
+ }
541
+
186
542
  type EventMap = {
187
543
  [key: string]: (...args: any[]) => void
188
544
  }
@@ -254,11 +610,54 @@ type FishjamConfig = {
254
610
  fishjamUrl?: string;
255
611
  managementToken: string;
256
612
  };
257
-
258
- type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
259
- type ErrorEventHandler = (msg: Error) => void;
613
+ type ErrorEventHandler = (msg: Event) => void;
260
614
  type CloseEventHandler = (code: number, reason: string) => void;
261
- type NotificationEvents = Record<ExpectedEvents, (message: ServerMessage) => void>;
615
+
616
+ type WithRoomId<T> = {
617
+ [P in keyof T]: NonNullable<T[P]> extends {
618
+ roomId: string;
619
+ } ? Omit<NonNullable<T[P]>, 'roomId'> & {
620
+ roomId: RoomId;
621
+ } : T[P];
622
+ };
623
+ type WithPeerId<T> = {
624
+ [P in keyof T]: NonNullable<T[P]> extends {
625
+ peerId: string;
626
+ } ? Omit<NonNullable<T[P]>, 'peerId'> & {
627
+ peerId: PeerId;
628
+ } : T[P];
629
+ };
630
+
631
+ type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'streamConnected' | 'streamDisconnected' | 'viewerConnected' | 'viewerDisconnected' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
632
+ /**
633
+ * @inline
634
+ */
635
+ type MessageWithIds = WithPeerId<WithRoomId<ServerMessage>>;
636
+ /**
637
+ * @inline
638
+ */
639
+ type Notifications = {
640
+ [K in ExpectedEvents]: NonNullable<MessageWithIds[K]>;
641
+ };
642
+ type RoomCreated = Notifications['roomCreated'];
643
+ type RoomDeleted = Notifications['roomDeleted'];
644
+ type RoomCrashed = Notifications['roomCrashed'];
645
+ type PeerAdded = Notifications['peerAdded'];
646
+ type PeerDeleted = Notifications['peerDeleted'];
647
+ type PeerConnected = Notifications['peerConnected'];
648
+ type PeerDisconnected = Notifications['peerDisconnected'];
649
+ type PeerMetadataUpdated = Notifications['peerMetadataUpdated'];
650
+ type PeerCrashed = Notifications['peerCrashed'];
651
+ type StreamConnected = Notifications['streamConnected'];
652
+ type StreamDisconnected = Notifications['streamDisconnected'];
653
+ type ViewerConnected = Notifications['viewerConnected'];
654
+ type ViewerDisconnected = Notifications['viewerDisconnected'];
655
+ type TrackAdded = Notifications['trackAdded'];
656
+ type TrackRemoved = Notifications['trackRemoved'];
657
+ type TrackMetadataUpdated = Notifications['trackMetadataUpdated'];
658
+ type NotificationEvents = {
659
+ [K in ExpectedEvents]: (message: NonNullable<MessageWithIds[K]>) => void;
660
+ };
262
661
  declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEvents>;
263
662
  /**
264
663
  * Notifier object that can be used to get notified about various events related to the Fishjam App.
@@ -266,7 +665,55 @@ declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEv
266
665
  */
267
666
  declare class FishjamWSNotifier extends FishjamWSNotifier_base {
268
667
  private readonly client;
269
- constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler, onConnectionFailed: ErrorEventHandler);
668
+ constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler);
669
+ private dispatchNotification;
670
+ private setupConnection;
671
+ private isExpectedEvent;
672
+ }
673
+
674
+ declare const expectedEventsList: readonly ["trackData"];
675
+ /**
676
+ * @useDeclaredType
677
+ */
678
+ type ExpectedAgentEvents = (typeof expectedEventsList)[number];
679
+ type IncomingTrackData = Omit<NonNullable<AgentResponse_TrackData>, 'peerId'> & {
680
+ peerId: PeerId;
681
+ };
682
+ type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
683
+ peerId: PeerId;
684
+ };
685
+ type AgentTrack = Track;
686
+ type TrackType = 'audio' | 'video';
687
+ type AudioCodecParameters = {
688
+ encoding: 'opus' | 'pcm16';
689
+ sampleRate: 16000 | 24000 | 48000;
690
+ channels: 1;
691
+ };
692
+ type TrackId = Brand<string, 'TrackId'>;
693
+ /**
694
+ * @inline
695
+ */
696
+ type ResponseWithPeerId = WithPeerId<AgentResponse>;
697
+ type AgentEvents = {
698
+ [K in ExpectedAgentEvents]: (message: NonNullable<ResponseWithPeerId[K]>) => void;
699
+ };
700
+ declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
701
+ declare class FishjamAgent extends FishjamAgent_base {
702
+ private readonly client;
703
+ constructor(config: FishjamConfig, agentToken: string, onError: ErrorEventHandler, onClose: CloseEventHandler);
704
+ /**
705
+ * Creates an outgoing audio track for the agent
706
+ * @returns a new audio track
707
+ */
708
+ createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
709
+ /**
710
+ * Deletes an outgoing audio track for the agent
711
+ */
712
+ deleteTrack(trackId: TrackId): void;
713
+ /**
714
+ * Send audio data for the given track
715
+ */
716
+ sendData(trackId: TrackId, data: Uint8Array): void;
270
717
  private dispatchNotification;
271
718
  private setupConnection;
272
719
  private isExpectedEvent;
@@ -281,6 +728,7 @@ declare class FishjamClient {
281
728
  private readonly roomApi;
282
729
  private readonly viewerApi;
283
730
  private readonly streamerApi;
731
+ private readonly fishjamConfig;
284
732
  /**
285
733
  * Create new instance of Fishjam Client.
286
734
  *
@@ -312,6 +760,13 @@ declare class FishjamClient {
312
760
  peer: Peer;
313
761
  peerToken: string;
314
762
  }>;
763
+ /**
764
+ * Create a new agent assigned to a room.
765
+ */
766
+ createAgent(roomId: RoomId, options: PeerOptions | undefined, onError: ErrorEventHandler, onClose: CloseEventHandler): Promise<{
767
+ agent: FishjamAgent;
768
+ peer: Peer;
769
+ }>;
315
770
  /**
316
771
  * Get details about a given room.
317
772
  */
@@ -364,4 +819,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
364
819
  declare class UnknownException extends FishjamBaseException {
365
820
  }
366
821
 
367
- export { BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedEvents, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, MissingFishjamIdException, type NotificationEvents, type Peer, type PeerId, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomId, RoomNotFoundException, ServiceUnavailableException, type StreamerToken, UnauthorizedException, UnknownException, type ViewerToken };
822
+ export { type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };