@fishjam-cloud/js-server-sdk 0.20.0 → 0.22.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,99 @@ 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 {SubscribeMode}
31
+ * @memberof Peer
32
+ */
33
+ 'subscribeMode': SubscribeMode;
34
+ /**
35
+ * Describes peer\'s subscriptions in manual mode
36
+ * @type {Array<string>}
37
+ * @memberof Peer
38
+ */
39
+ 'subscriptions': Array<string>;
29
40
  /**
30
41
  * List of all peer\'s tracks
31
42
  * @type {Array<Track>}
32
43
  * @memberof Peer
33
44
  */
34
- 'tracks': Array<Track>;
45
+ 'tracks': Array<Track$1>;
35
46
  /**
36
- * Peer type
37
- * @type {string}
47
+ *
48
+ * @type {PeerType}
38
49
  * @memberof Peer
39
50
  */
40
- 'type': string;
51
+ 'type': PeerType;
41
52
  }
42
53
  /**
43
54
  * @type PeerOptions
44
55
  * Peer-specific options
45
56
  * @export
46
57
  */
47
- type PeerOptions = PeerOptionsWebRTC;
58
+ type PeerOptions = PeerOptionsAgent | PeerOptionsWebRTC;
59
+ /**
60
+ * Options specific to the Agent peer
61
+ * @export
62
+ * @interface PeerOptionsAgent
63
+ */
64
+ interface PeerOptionsAgent {
65
+ /**
66
+ *
67
+ * @type {PeerOptionsAgentOutput}
68
+ * @memberof PeerOptionsAgent
69
+ */
70
+ 'output'?: PeerOptionsAgentOutput;
71
+ /**
72
+ * Configuration of peer\'s subscribing policy
73
+ * @type {string}
74
+ * @memberof PeerOptionsAgent
75
+ */
76
+ 'subscribeMode'?: PeerOptionsAgentSubscribeModeEnum;
77
+ }
78
+ declare const PeerOptionsAgentSubscribeModeEnum: {
79
+ readonly Auto: "auto";
80
+ readonly Manual: "manual";
81
+ };
82
+ type PeerOptionsAgentSubscribeModeEnum = typeof PeerOptionsAgentSubscribeModeEnum[keyof typeof PeerOptionsAgentSubscribeModeEnum];
83
+ /**
84
+ * Output audio options
85
+ * @export
86
+ * @interface PeerOptionsAgentOutput
87
+ */
88
+ interface PeerOptionsAgentOutput {
89
+ /**
90
+ * The format of the output audio
91
+ * @type {string}
92
+ * @memberof PeerOptionsAgentOutput
93
+ */
94
+ 'audioFormat'?: PeerOptionsAgentOutputAudioFormatEnum;
95
+ /**
96
+ * The sample rate of the output audio
97
+ * @type {number}
98
+ * @memberof PeerOptionsAgentOutput
99
+ */
100
+ 'audioSampleRate'?: PeerOptionsAgentOutputAudioSampleRateEnum;
101
+ }
102
+ declare const PeerOptionsAgentOutputAudioFormatEnum: {
103
+ readonly Pcm16: "pcm16";
104
+ };
105
+ type PeerOptionsAgentOutputAudioFormatEnum = typeof PeerOptionsAgentOutputAudioFormatEnum[keyof typeof PeerOptionsAgentOutputAudioFormatEnum];
106
+ declare const PeerOptionsAgentOutputAudioSampleRateEnum: {
107
+ readonly NUMBER_16000: 16000;
108
+ readonly NUMBER_24000: 24000;
109
+ };
110
+ type PeerOptionsAgentOutputAudioSampleRateEnum = typeof PeerOptionsAgentOutputAudioSampleRateEnum[keyof typeof PeerOptionsAgentOutputAudioSampleRateEnum];
48
111
  /**
49
112
  * Options specific to the WebRTC peer
50
113
  * @export
@@ -65,7 +128,18 @@ interface PeerOptionsWebRTC {
65
128
  'metadata'?: {
66
129
  [key: string]: any;
67
130
  };
131
+ /**
132
+ * Configuration of peer\'s subscribing policy
133
+ * @type {string}
134
+ * @memberof PeerOptionsWebRTC
135
+ */
136
+ 'subscribeMode'?: PeerOptionsWebRTCSubscribeModeEnum;
68
137
  }
138
+ declare const PeerOptionsWebRTCSubscribeModeEnum: {
139
+ readonly Auto: "auto";
140
+ readonly Manual: "manual";
141
+ };
142
+ type PeerOptionsWebRTCSubscribeModeEnum = typeof PeerOptionsWebRTCSubscribeModeEnum[keyof typeof PeerOptionsWebRTCSubscribeModeEnum];
69
143
  /**
70
144
  * Informs about the peer status
71
145
  * @export
@@ -76,6 +150,16 @@ declare const PeerStatus: {
76
150
  readonly Disconnected: "disconnected";
77
151
  };
78
152
  type PeerStatus = typeof PeerStatus[keyof typeof PeerStatus];
153
+ /**
154
+ * Peer type
155
+ * @export
156
+ * @enum {string}
157
+ */
158
+ declare const PeerType: {
159
+ readonly Webrtc: "webrtc";
160
+ readonly Agent: "agent";
161
+ };
162
+ type PeerType = typeof PeerType[keyof typeof PeerType];
79
163
  /**
80
164
  * Room configuration
81
165
  * @export
@@ -105,7 +189,7 @@ interface RoomConfig {
105
189
  * @type {string}
106
190
  * @memberof RoomConfig
107
191
  */
108
- 'videoCodec'?: RoomConfigVideoCodecEnum | null;
192
+ 'videoCodec'?: RoomConfigVideoCodecEnum;
109
193
  /**
110
194
  * URL where Fishjam notifications will be sent
111
195
  * @type {string}
@@ -119,6 +203,7 @@ declare const RoomConfigRoomTypeEnum: {
119
203
  readonly Broadcaster: "broadcaster";
120
204
  readonly Livestream: "livestream";
121
205
  readonly Conference: "conference";
206
+ readonly AudioOnlyLivestream: "audio_only_livestream";
122
207
  };
123
208
  type RoomConfigRoomTypeEnum = typeof RoomConfigRoomTypeEnum[keyof typeof RoomConfigRoomTypeEnum];
124
209
  declare const RoomConfigVideoCodecEnum: {
@@ -140,23 +225,33 @@ interface StreamerToken {
140
225
  'token': string;
141
226
  }
142
227
  /**
143
- * Describes media track of a Peer or Component
228
+ * Configuration of peer\'s subscribing policy
229
+ * @export
230
+ * @enum {string}
231
+ */
232
+ declare const SubscribeMode: {
233
+ readonly Auto: "auto";
234
+ readonly Manual: "manual";
235
+ };
236
+ type SubscribeMode = typeof SubscribeMode[keyof typeof SubscribeMode];
237
+ /**
238
+ * Describes media track of a Peer
144
239
  * @export
145
240
  * @interface Track
146
241
  */
147
- interface Track {
242
+ interface Track$1 {
148
243
  /**
149
- *
244
+ * Assigned track id
150
245
  * @type {string}
151
246
  * @memberof Track
152
247
  */
153
248
  'id'?: string;
154
249
  /**
155
250
  *
156
- * @type {any}
251
+ * @type {object}
157
252
  * @memberof Track
158
253
  */
159
- 'metadata'?: any | null;
254
+ 'metadata'?: object | null;
160
255
  /**
161
256
  *
162
257
  * @type {string}
@@ -183,6 +278,299 @@ interface ViewerToken {
183
278
  'token': string;
184
279
  }
185
280
 
281
+ /** Defines types of tracks being published by peers and component */
282
+ declare enum TrackType$1 {
283
+ TRACK_TYPE_UNSPECIFIED = 0,
284
+ TRACK_TYPE_VIDEO = 1,
285
+ TRACK_TYPE_AUDIO = 2,
286
+ UNRECOGNIZED = -1
287
+ }
288
+ /** Describes a media track */
289
+ interface Track {
290
+ id: string;
291
+ type: TrackType$1;
292
+ metadata: string;
293
+ }
294
+ declare const Track: MessageFns$2<Track>;
295
+ type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
296
+ 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 {} ? {
297
+ [K in keyof T]?: DeepPartial$2<T[K]>;
298
+ } : Partial<T>;
299
+ type KeysOfUnion$2<T> = T extends T ? keyof T : never;
300
+ type Exact$2<P, I extends P> = P extends Builtin$2 ? P : P & {
301
+ [K in keyof P]: Exact$2<P[K], I[K]>;
302
+ } & {
303
+ [K in Exclude<keyof I, KeysOfUnion$2<P>>]: never;
304
+ };
305
+ interface MessageFns$2<T> {
306
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
307
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
308
+ fromJSON(object: any): T;
309
+ toJSON(message: T): unknown;
310
+ create<I extends Exact$2<DeepPartial$2<T>, I>>(base?: I): T;
311
+ fromPartial<I extends Exact$2<DeepPartial$2<T>, I>>(object: I): T;
312
+ }
313
+
314
+ declare enum ServerMessage_PeerType {
315
+ PEER_TYPE_UNSPECIFIED = 0,
316
+ PEER_TYPE_WEBRTC = 1,
317
+ PEER_TYPE_AGENT = 2,
318
+ UNRECOGNIZED = -1
319
+ }
320
+ /** Defines message groups for which peer can subscribe */
321
+ declare enum ServerMessage_EventType {
322
+ EVENT_TYPE_UNSPECIFIED = 0,
323
+ EVENT_TYPE_SERVER_NOTIFICATION = 1,
324
+ UNRECOGNIZED = -1
325
+ }
326
+ /** Defines any type of message passed between FJ and server peer */
327
+ interface ServerMessage {
328
+ roomCrashed?: ServerMessage_RoomCrashed | undefined;
329
+ peerConnected?: ServerMessage_PeerConnected | undefined;
330
+ peerDisconnected?: ServerMessage_PeerDisconnected | undefined;
331
+ peerCrashed?: ServerMessage_PeerCrashed | undefined;
332
+ componentCrashed?: ServerMessage_ComponentCrashed | undefined;
333
+ authenticated?: ServerMessage_Authenticated | undefined;
334
+ authRequest?: ServerMessage_AuthRequest | undefined;
335
+ subscribeRequest?: ServerMessage_SubscribeRequest | undefined;
336
+ subscribeResponse?: ServerMessage_SubscribeResponse | undefined;
337
+ roomCreated?: ServerMessage_RoomCreated | undefined;
338
+ roomDeleted?: ServerMessage_RoomDeleted | undefined;
339
+ hlsPlayable?: ServerMessage_HlsPlayable | undefined;
340
+ hlsUploaded?: ServerMessage_HlsUploaded | undefined;
341
+ hlsUploadCrashed?: ServerMessage_HlsUploadCrashed | undefined;
342
+ peerMetadataUpdated?: ServerMessage_PeerMetadataUpdated | undefined;
343
+ trackAdded?: ServerMessage_TrackAdded | undefined;
344
+ trackRemoved?: ServerMessage_TrackRemoved | undefined;
345
+ trackMetadataUpdated?: ServerMessage_TrackMetadataUpdated | undefined;
346
+ peerAdded?: ServerMessage_PeerAdded | undefined;
347
+ peerDeleted?: ServerMessage_PeerDeleted | undefined;
348
+ /** @deprecated */
349
+ streamConnected?: ServerMessage_StreamConnected | undefined;
350
+ /** @deprecated */
351
+ streamDisconnected?: ServerMessage_StreamDisconnected | undefined;
352
+ viewerConnected?: ServerMessage_ViewerConnected | undefined;
353
+ viewerDisconnected?: ServerMessage_ViewerDisconnected | undefined;
354
+ streamerConnected?: ServerMessage_StreamerConnected | undefined;
355
+ streamerDisconnected?: ServerMessage_StreamerDisconnected | undefined;
356
+ }
357
+ declare const ServerMessage: MessageFns$1<ServerMessage>;
358
+ /** Notification sent when a room crashes */
359
+ interface ServerMessage_RoomCrashed {
360
+ roomId: string;
361
+ }
362
+ declare const ServerMessage_RoomCrashed: MessageFns$1<ServerMessage_RoomCrashed>;
363
+ /** Notification sent when a peer is added */
364
+ interface ServerMessage_PeerAdded {
365
+ roomId: string;
366
+ peerId: string;
367
+ peerType: ServerMessage_PeerType;
368
+ }
369
+ declare const ServerMessage_PeerAdded: MessageFns$1<ServerMessage_PeerAdded>;
370
+ /** Notification sent when a peer is removed */
371
+ interface ServerMessage_PeerDeleted {
372
+ roomId: string;
373
+ peerId: string;
374
+ peerType: ServerMessage_PeerType;
375
+ }
376
+ declare const ServerMessage_PeerDeleted: MessageFns$1<ServerMessage_PeerDeleted>;
377
+ /** Notification sent when a peer connects */
378
+ interface ServerMessage_PeerConnected {
379
+ roomId: string;
380
+ peerId: string;
381
+ peerType: ServerMessage_PeerType;
382
+ }
383
+ declare const ServerMessage_PeerConnected: MessageFns$1<ServerMessage_PeerConnected>;
384
+ /** Notification sent when a peer disconnects from FJ */
385
+ interface ServerMessage_PeerDisconnected {
386
+ roomId: string;
387
+ peerId: string;
388
+ peerType: ServerMessage_PeerType;
389
+ }
390
+ declare const ServerMessage_PeerDisconnected: MessageFns$1<ServerMessage_PeerDisconnected>;
391
+ /** Notification sent when a peer crashes */
392
+ interface ServerMessage_PeerCrashed {
393
+ roomId: string;
394
+ peerId: string;
395
+ reason: string;
396
+ peerType: ServerMessage_PeerType;
397
+ }
398
+ declare const ServerMessage_PeerCrashed: MessageFns$1<ServerMessage_PeerCrashed>;
399
+ /** Notification sent when a component crashes */
400
+ interface ServerMessage_ComponentCrashed {
401
+ roomId: string;
402
+ componentId: string;
403
+ }
404
+ declare const ServerMessage_ComponentCrashed: MessageFns$1<ServerMessage_ComponentCrashed>;
405
+ /** Response sent by FJ, confirming successfull authentication */
406
+ interface ServerMessage_Authenticated {
407
+ }
408
+ declare const ServerMessage_Authenticated: MessageFns$1<ServerMessage_Authenticated>;
409
+ /** Request sent by peer, to authenticate to FJ server */
410
+ interface ServerMessage_AuthRequest {
411
+ token: string;
412
+ }
413
+ declare const ServerMessage_AuthRequest: MessageFns$1<ServerMessage_AuthRequest>;
414
+ /** Request sent by peer to subsribe for certain message type */
415
+ interface ServerMessage_SubscribeRequest {
416
+ eventType: ServerMessage_EventType;
417
+ }
418
+ declare const ServerMessage_SubscribeRequest: MessageFns$1<ServerMessage_SubscribeRequest>;
419
+ /** Response sent by FJ, confirming subscription for message type */
420
+ interface ServerMessage_SubscribeResponse {
421
+ eventType: ServerMessage_EventType;
422
+ }
423
+ declare const ServerMessage_SubscribeResponse: MessageFns$1<ServerMessage_SubscribeResponse>;
424
+ /** Notification sent when a room is created */
425
+ interface ServerMessage_RoomCreated {
426
+ roomId: string;
427
+ }
428
+ declare const ServerMessage_RoomCreated: MessageFns$1<ServerMessage_RoomCreated>;
429
+ /** Notification sent when a room is deleted */
430
+ interface ServerMessage_RoomDeleted {
431
+ roomId: string;
432
+ }
433
+ declare const ServerMessage_RoomDeleted: MessageFns$1<ServerMessage_RoomDeleted>;
434
+ /** Notification sent when the HLS stream becomes available in a room */
435
+ interface ServerMessage_HlsPlayable {
436
+ roomId: string;
437
+ componentId: string;
438
+ }
439
+ declare const ServerMessage_HlsPlayable: MessageFns$1<ServerMessage_HlsPlayable>;
440
+ /** Notification sent when the HLS recording is successfully uploded to AWS S3 */
441
+ interface ServerMessage_HlsUploaded {
442
+ roomId: string;
443
+ }
444
+ declare const ServerMessage_HlsUploaded: MessageFns$1<ServerMessage_HlsUploaded>;
445
+ /** Notification sent when the upload of HLS recording to AWS S3 fails */
446
+ interface ServerMessage_HlsUploadCrashed {
447
+ roomId: string;
448
+ }
449
+ declare const ServerMessage_HlsUploadCrashed: MessageFns$1<ServerMessage_HlsUploadCrashed>;
450
+ /** Notification sent when peer updates its metadata */
451
+ interface ServerMessage_PeerMetadataUpdated {
452
+ roomId: string;
453
+ peerId: string;
454
+ metadata: string;
455
+ peerType: ServerMessage_PeerType;
456
+ }
457
+ declare const ServerMessage_PeerMetadataUpdated: MessageFns$1<ServerMessage_PeerMetadataUpdated>;
458
+ /** Notification sent when peer or component adds new track */
459
+ interface ServerMessage_TrackAdded {
460
+ roomId: string;
461
+ peerId?: string | undefined;
462
+ componentId?: string | undefined;
463
+ track: Track | undefined;
464
+ }
465
+ declare const ServerMessage_TrackAdded: MessageFns$1<ServerMessage_TrackAdded>;
466
+ /** Notification sent when a track is removed */
467
+ interface ServerMessage_TrackRemoved {
468
+ roomId: string;
469
+ peerId?: string | undefined;
470
+ componentId?: string | undefined;
471
+ track: Track | undefined;
472
+ }
473
+ declare const ServerMessage_TrackRemoved: MessageFns$1<ServerMessage_TrackRemoved>;
474
+ /** Notification sent when metadata of a multimedia track is updated */
475
+ interface ServerMessage_TrackMetadataUpdated {
476
+ roomId: string;
477
+ peerId?: string | undefined;
478
+ componentId?: string | undefined;
479
+ track: Track | undefined;
480
+ }
481
+ declare const ServerMessage_TrackMetadataUpdated: MessageFns$1<ServerMessage_TrackMetadataUpdated>;
482
+ /** Notification sent when streamer successfully connects */
483
+ interface ServerMessage_StreamConnected {
484
+ streamId: string;
485
+ }
486
+ declare const ServerMessage_StreamConnected: MessageFns$1<ServerMessage_StreamConnected>;
487
+ /** Notification sent when streamer disconnects */
488
+ interface ServerMessage_StreamDisconnected {
489
+ streamId: string;
490
+ }
491
+ declare const ServerMessage_StreamDisconnected: MessageFns$1<ServerMessage_StreamDisconnected>;
492
+ /** Notification sent when viewer successfully connects */
493
+ interface ServerMessage_ViewerConnected {
494
+ streamId: string;
495
+ viewerId: string;
496
+ }
497
+ declare const ServerMessage_ViewerConnected: MessageFns$1<ServerMessage_ViewerConnected>;
498
+ /** Notification sent when viewer disconnects */
499
+ interface ServerMessage_ViewerDisconnected {
500
+ streamId: string;
501
+ viewerId: string;
502
+ }
503
+ declare const ServerMessage_ViewerDisconnected: MessageFns$1<ServerMessage_ViewerDisconnected>;
504
+ interface ServerMessage_StreamerConnected {
505
+ streamId: string;
506
+ streamerId: string;
507
+ }
508
+ declare const ServerMessage_StreamerConnected: MessageFns$1<ServerMessage_StreamerConnected>;
509
+ interface ServerMessage_StreamerDisconnected {
510
+ streamId: string;
511
+ streamerId: string;
512
+ }
513
+ declare const ServerMessage_StreamerDisconnected: MessageFns$1<ServerMessage_StreamerDisconnected>;
514
+ type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
515
+ 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 {} ? {
516
+ [K in keyof T]?: DeepPartial$1<T[K]>;
517
+ } : Partial<T>;
518
+ type KeysOfUnion$1<T> = T extends T ? keyof T : never;
519
+ type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
520
+ [K in keyof P]: Exact$1<P[K], I[K]>;
521
+ } & {
522
+ [K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
523
+ };
524
+ interface MessageFns$1<T> {
525
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
526
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
527
+ fromJSON(object: any): T;
528
+ toJSON(message: T): unknown;
529
+ create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
530
+ fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
531
+ }
532
+ /** Notification containing a chunk of an agent's track's data stream */
533
+ interface AgentRequest_TrackData {
534
+ trackId: string;
535
+ data: Uint8Array;
536
+ }
537
+ declare const AgentRequest_TrackData: MessageFns<AgentRequest_TrackData>;
538
+ /** Defines any type of message passed from Fishjam to agent peer */
539
+ interface AgentResponse {
540
+ authenticated?: AgentResponse_Authenticated | undefined;
541
+ trackData?: AgentResponse_TrackData | undefined;
542
+ }
543
+ declare const AgentResponse: MessageFns<AgentResponse>;
544
+ /** Response confirming successful authentication */
545
+ interface AgentResponse_Authenticated {
546
+ }
547
+ declare const AgentResponse_Authenticated: MessageFns<AgentResponse_Authenticated>;
548
+ /** Notification containing a chunk of a track's data stream */
549
+ interface AgentResponse_TrackData {
550
+ peerId: string;
551
+ track: Track | undefined;
552
+ data: Uint8Array;
553
+ }
554
+ declare const AgentResponse_TrackData: MessageFns<AgentResponse_TrackData>;
555
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
556
+ 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 {} ? {
557
+ [K in keyof T]?: DeepPartial<T[K]>;
558
+ } : Partial<T>;
559
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
560
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
561
+ [K in keyof P]: Exact<P[K], I[K]>;
562
+ } & {
563
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
564
+ };
565
+ interface MessageFns<T> {
566
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
567
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
568
+ fromJSON(object: any): T;
569
+ toJSON(message: T): unknown;
570
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
571
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
572
+ }
573
+
186
574
  type EventMap = {
187
575
  [key: string]: (...args: any[]) => void
188
576
  }
@@ -250,15 +638,57 @@ type Room = {
250
638
  config: RoomConfig;
251
639
  };
252
640
  type FishjamConfig = {
253
- fishjamId?: string;
254
- fishjamUrl?: string;
641
+ fishjamId: string;
255
642
  managementToken: string;
256
643
  };
257
-
258
- type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
259
- type ErrorEventHandler = (msg: Error) => void;
644
+ type ErrorEventHandler = (msg: Event) => void;
260
645
  type CloseEventHandler = (code: number, reason: string) => void;
261
- type NotificationEvents = Record<ExpectedEvents, (message: ServerMessage) => void>;
646
+
647
+ type WithRoomId<T> = {
648
+ [P in keyof T]: NonNullable<T[P]> extends {
649
+ roomId: string;
650
+ } ? Omit<NonNullable<T[P]>, 'roomId'> & {
651
+ roomId: RoomId;
652
+ } : T[P];
653
+ };
654
+ type WithPeerId<T> = {
655
+ [P in keyof T]: NonNullable<T[P]> extends {
656
+ peerId: string;
657
+ } ? Omit<NonNullable<T[P]>, 'peerId'> & {
658
+ peerId: PeerId;
659
+ } : T[P];
660
+ };
661
+
662
+ type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'streamConnected' | 'streamDisconnected' | 'viewerConnected' | 'viewerDisconnected' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
663
+ /**
664
+ * @inline
665
+ */
666
+ type MessageWithIds = WithPeerId<WithRoomId<ServerMessage>>;
667
+ /**
668
+ * @inline
669
+ */
670
+ type Notifications = {
671
+ [K in ExpectedEvents]: NonNullable<MessageWithIds[K]>;
672
+ };
673
+ type RoomCreated = Notifications['roomCreated'];
674
+ type RoomDeleted = Notifications['roomDeleted'];
675
+ type RoomCrashed = Notifications['roomCrashed'];
676
+ type PeerAdded = Notifications['peerAdded'];
677
+ type PeerDeleted = Notifications['peerDeleted'];
678
+ type PeerConnected = Notifications['peerConnected'];
679
+ type PeerDisconnected = Notifications['peerDisconnected'];
680
+ type PeerMetadataUpdated = Notifications['peerMetadataUpdated'];
681
+ type PeerCrashed = Notifications['peerCrashed'];
682
+ type StreamConnected = Notifications['streamConnected'];
683
+ type StreamDisconnected = Notifications['streamDisconnected'];
684
+ type ViewerConnected = Notifications['viewerConnected'];
685
+ type ViewerDisconnected = Notifications['viewerDisconnected'];
686
+ type TrackAdded = Notifications['trackAdded'];
687
+ type TrackRemoved = Notifications['trackRemoved'];
688
+ type TrackMetadataUpdated = Notifications['trackMetadataUpdated'];
689
+ type NotificationEvents = {
690
+ [K in ExpectedEvents]: (message: NonNullable<MessageWithIds[K]>) => void;
691
+ };
262
692
  declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEvents>;
263
693
  /**
264
694
  * Notifier object that can be used to get notified about various events related to the Fishjam App.
@@ -266,7 +696,55 @@ declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEv
266
696
  */
267
697
  declare class FishjamWSNotifier extends FishjamWSNotifier_base {
268
698
  private readonly client;
269
- constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler, onConnectionFailed: ErrorEventHandler);
699
+ constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler);
700
+ private dispatchNotification;
701
+ private setupConnection;
702
+ private isExpectedEvent;
703
+ }
704
+
705
+ declare const expectedEventsList: readonly ["trackData"];
706
+ /**
707
+ * @useDeclaredType
708
+ */
709
+ type ExpectedAgentEvents = (typeof expectedEventsList)[number];
710
+ type IncomingTrackData = Omit<NonNullable<AgentResponse_TrackData>, 'peerId'> & {
711
+ peerId: PeerId;
712
+ };
713
+ type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
714
+ peerId: PeerId;
715
+ };
716
+ type AgentTrack = Track;
717
+ type TrackType = 'audio' | 'video';
718
+ type AudioCodecParameters = {
719
+ encoding: 'opus' | 'pcm16';
720
+ sampleRate: 16000 | 24000 | 48000;
721
+ channels: 1;
722
+ };
723
+ type TrackId = Brand<string, 'TrackId'>;
724
+ /**
725
+ * @inline
726
+ */
727
+ type ResponseWithPeerId = WithPeerId<AgentResponse>;
728
+ type AgentEvents = {
729
+ [K in ExpectedAgentEvents]: (message: NonNullable<ResponseWithPeerId[K]>) => void;
730
+ };
731
+ declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
732
+ declare class FishjamAgent extends FishjamAgent_base {
733
+ private readonly client;
734
+ constructor(config: FishjamConfig, agentToken: string, onError: ErrorEventHandler, onClose: CloseEventHandler);
735
+ /**
736
+ * Creates an outgoing audio track for the agent
737
+ * @returns a new audio track
738
+ */
739
+ createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
740
+ /**
741
+ * Deletes an outgoing audio track for the agent
742
+ */
743
+ deleteTrack(trackId: TrackId): void;
744
+ /**
745
+ * Send audio data for the given track
746
+ */
747
+ sendData(trackId: TrackId, data: Uint8Array): void;
270
748
  private dispatchNotification;
271
749
  private setupConnection;
272
750
  private isExpectedEvent;
@@ -274,20 +752,21 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
274
752
 
275
753
  /**
276
754
  * Client class that allows to manage Rooms and Peers for a Fishjam App.
277
- * It requires the Fishjam URL and management token that can be retrieved from the Fishjam Dashboard.
755
+ * It requires the Fishjam ID and management token that can be retrieved from the Fishjam Dashboard.
278
756
  * @category Client
279
757
  */
280
758
  declare class FishjamClient {
281
759
  private readonly roomApi;
282
760
  private readonly viewerApi;
283
761
  private readonly streamerApi;
762
+ private readonly fishjamConfig;
284
763
  /**
285
764
  * Create new instance of Fishjam Client.
286
765
  *
287
766
  * Example usage:
288
767
  * ```
289
768
  * const fishjamClient = new FishjamClient({
290
- * fishjamUrl: fastify.config.FISHJAM_URL,
769
+ * fishjamId: fastify.config.FISHJAM_ID,
291
770
  * managementToken: fastify.config.FISHJAM_MANAGEMENT_TOKEN,
292
771
  * });
293
772
  * ```
@@ -312,6 +791,13 @@ declare class FishjamClient {
312
791
  peer: Peer;
313
792
  peerToken: string;
314
793
  }>;
794
+ /**
795
+ * Create a new agent assigned to a room.
796
+ */
797
+ createAgent(roomId: RoomId, options: PeerOptions | undefined, onError: ErrorEventHandler, onClose: CloseEventHandler): Promise<{
798
+ agent: FishjamAgent;
799
+ peer: Peer;
800
+ }>;
315
801
  /**
316
802
  * Get details about a given room.
317
803
  */
@@ -320,6 +806,16 @@ declare class FishjamClient {
320
806
  * Delete a peer - this will also disconnect the peer from the room.
321
807
  */
322
808
  deletePeer(roomId: RoomId, peerId: PeerId): Promise<void>;
809
+ /**
810
+ * Subscribe a peer to another peer - this will make all tracks from the publisher available to the subscriber.
811
+ * Using this function only makes sense if subscribeMode is set to manual
812
+ */
813
+ subscribePeer(roomId: RoomId, subscriberPeerId: PeerId, publisherPeerId: PeerId): Promise<void>;
814
+ /**
815
+ * Subscribe a peer to specific tracks from another peer - this will make only the specified tracks from the publisher available to the subscriber.
816
+ * Using this function only makes sense if subscribeMode is set to manual
817
+ */
818
+ subscribeTracks(roomId: RoomId, subscriberPeerId: PeerId, tracks: TrackId[]): Promise<void>;
323
819
  /**
324
820
  * Refresh the peer token for an already existing peer.
325
821
  * If an already created peer has not been connected to the room for more than 24 hours, the token will become invalid. This method can be used to generate a new peer token for the existing peer.
@@ -364,4 +860,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
364
860
  declare class UnknownException extends FishjamBaseException {
365
861
  }
366
862
 
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 };
863
+ 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 };