@fishjam-cloud/js-server-sdk 0.27.0-rc.0 → 0.27.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.
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@fishjam-cloud/js-server-sdk",
4
- version: "0.27.0-rc.0",
4
+ version: "0.27.0",
5
5
  description: "Fishjam server SDK for JavaScript",
6
6
  homepage: "https://github.com/fishjam-cloud/js-server-sdk",
7
7
  author: "Fishjam Team",
package/dist/index.d.mts CHANGED
@@ -52,6 +52,25 @@ interface MoqToken {
52
52
  */
53
53
  'token': string;
54
54
  }
55
+ /**
56
+ * MoQ token configuration
57
+ * @export
58
+ * @interface MoqTokenConfig
59
+ */
60
+ interface MoqTokenConfig {
61
+ /**
62
+ * Path under the root the token grants publish access to
63
+ * @type {string}
64
+ * @memberof MoqTokenConfig
65
+ */
66
+ 'publishPath'?: string | null;
67
+ /**
68
+ * Path under the root the token grants subscribe access to
69
+ * @type {string}
70
+ * @memberof MoqTokenConfig
71
+ */
72
+ 'subscribePath'?: string | null;
73
+ }
55
74
  /**
56
75
  * Describes peer status
57
76
  * @export
@@ -93,13 +112,13 @@ interface Peer$1 {
93
112
  * @type {Array<Track>}
94
113
  * @memberof Peer
95
114
  */
96
- 'tracks': Array<Track$1>;
115
+ 'tracks': Array<Track$2>;
97
116
  /**
98
117
  *
99
118
  * @type {PeerType}
100
119
  * @memberof Peer
101
120
  */
102
- 'type': PeerType;
121
+ 'type': PeerType$1;
103
122
  }
104
123
  /**
105
124
  * @type PeerOptions
@@ -187,18 +206,24 @@ type PeerStatus = typeof PeerStatus[keyof typeof PeerStatus];
187
206
  * @export
188
207
  * @enum {string}
189
208
  */
190
- declare const PeerType: {
209
+ declare const PeerType$1: {
191
210
  readonly Webrtc: "webrtc";
192
211
  readonly Agent: "agent";
193
212
  readonly Vapi: "vapi";
194
213
  };
195
- type PeerType = typeof PeerType[keyof typeof PeerType];
214
+ type PeerType$1 = typeof PeerType$1[keyof typeof PeerType$1];
196
215
  /**
197
216
  * Room configuration
198
217
  * @export
199
218
  * @interface RoomConfig
200
219
  */
201
220
  interface RoomConfig {
221
+ /**
222
+ * If true, webhook notifications for this room are coalesced into a single NotificationBatch per HTTP send instead of one request per notification. VAD notifications are unaffected.
223
+ * @type {boolean}
224
+ * @memberof RoomConfig
225
+ */
226
+ 'batchWebhookNotifications'?: boolean;
202
227
  /**
203
228
  * Maximum amount of peers allowed into the room
204
229
  * @type {number}
@@ -245,13 +270,13 @@ declare const RoomType: {
245
270
  };
246
271
  type RoomType = typeof RoomType[keyof typeof RoomType];
247
272
  /**
248
- * Token for authorizing broadcaster streamer connection
273
+ * Streamer authorization token
249
274
  * @export
250
275
  * @interface StreamerToken
251
276
  */
252
277
  interface StreamerToken {
253
278
  /**
254
- *
279
+ * Token streamer should authorize with
255
280
  * @type {string}
256
281
  * @memberof StreamerToken
257
282
  */
@@ -287,11 +312,11 @@ interface Subscriptions {
287
312
  'tracks': Array<string>;
288
313
  }
289
314
  /**
290
- * Describes media track of a Peer
315
+ * Media track of a Peer
291
316
  * @export
292
317
  * @interface Track
293
318
  */
294
- interface Track$1 {
319
+ interface Track$2 {
295
320
  /**
296
321
  * Assigned track id
297
322
  * @type {string}
@@ -299,7 +324,7 @@ interface Track$1 {
299
324
  */
300
325
  'id'?: string;
301
326
  /**
302
- *
327
+ * Metadata attached to the track by the peer
303
328
  * @type {object}
304
329
  * @memberof Track
305
330
  */
@@ -312,7 +337,7 @@ interface Track$1 {
312
337
  'type'?: TrackType$2;
313
338
  }
314
339
  /**
315
- *
340
+ * Media type carried by the track
316
341
  * @export
317
342
  * @enum {string}
318
343
  */
@@ -332,13 +357,13 @@ declare const VideoCodec: {
332
357
  };
333
358
  type VideoCodec = typeof VideoCodec[keyof typeof VideoCodec];
334
359
  /**
335
- * Token for authorizing broadcaster viewer connection
360
+ * Viewer authorization token
336
361
  * @export
337
362
  * @interface ViewerToken
338
363
  */
339
364
  interface ViewerToken {
340
365
  /**
341
- *
366
+ * Token viewer should authorize with
342
367
  * @type {string}
343
368
  * @memberof ViewerToken
344
369
  */
@@ -353,12 +378,12 @@ declare enum TrackType$1 {
353
378
  UNRECOGNIZED = -1
354
379
  }
355
380
  /** Describes a media track */
356
- interface Track {
381
+ interface Track$1 {
357
382
  id: string;
358
383
  type: TrackType$1;
359
384
  metadata: string;
360
385
  }
361
- declare const Track: MessageFns$2<Track>;
386
+ declare const Track$1: MessageFns$2<Track$1>;
362
387
  type Builtin$2 = Date | Function | Uint8Array | string | number | boolean | undefined;
363
388
  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 {} ? {
364
389
  [K in keyof T]?: DeepPartial$2<T[K]>;
@@ -424,6 +449,8 @@ interface ServerMessage {
424
449
  viewerDisconnected?: ServerMessage_ViewerDisconnected | undefined;
425
450
  streamerConnected?: ServerMessage_StreamerConnected | undefined;
426
451
  streamerDisconnected?: ServerMessage_StreamerDisconnected | undefined;
452
+ /** Batch */
453
+ notificationBatch?: ServerMessage_NotificationBatch | undefined;
427
454
  /** @deprecated */
428
455
  streamConnected?: ServerMessage_StreamConnected | undefined;
429
456
  /** @deprecated */
@@ -543,7 +570,7 @@ interface ServerMessage_TrackAdded {
543
570
  roomId: string;
544
571
  peerId?: string | undefined;
545
572
  componentId?: string | undefined;
546
- track: Track | undefined;
573
+ track: Track$1 | undefined;
547
574
  }
548
575
  declare const ServerMessage_TrackAdded: MessageFns$1<ServerMessage_TrackAdded>;
549
576
  /** Notification sent when a track is removed */
@@ -551,7 +578,7 @@ interface ServerMessage_TrackRemoved {
551
578
  roomId: string;
552
579
  peerId?: string | undefined;
553
580
  componentId?: string | undefined;
554
- track: Track | undefined;
581
+ track: Track$1 | undefined;
555
582
  }
556
583
  declare const ServerMessage_TrackRemoved: MessageFns$1<ServerMessage_TrackRemoved>;
557
584
  /** Notification sent when metadata of a multimedia track is updated */
@@ -559,7 +586,7 @@ interface ServerMessage_TrackMetadataUpdated {
559
586
  roomId: string;
560
587
  peerId?: string | undefined;
561
588
  componentId?: string | undefined;
562
- track: Track | undefined;
589
+ track: Track$1 | undefined;
563
590
  }
564
591
  declare const ServerMessage_TrackMetadataUpdated: MessageFns$1<ServerMessage_TrackMetadataUpdated>;
565
592
  /** Notification sent when a peer creates a channel */
@@ -585,8 +612,8 @@ interface ServerMessage_TrackForwarding {
585
612
  compositionUrl: string;
586
613
  inputId: string;
587
614
  /** Track has id, type, and metadata */
588
- audioTrack?: Track | undefined;
589
- videoTrack?: Track | undefined;
615
+ audioTrack?: Track$1 | undefined;
616
+ videoTrack?: Track$1 | undefined;
590
617
  }
591
618
  declare const ServerMessage_TrackForwarding: MessageFns$1<ServerMessage_TrackForwarding>;
592
619
  /** Sent when track forwarding is removed */
@@ -637,6 +664,23 @@ interface ServerMessage_StreamerDisconnected {
637
664
  streamerId: string;
638
665
  }
639
666
  declare const ServerMessage_StreamerDisconnected: MessageFns$1<ServerMessage_StreamerDisconnected>;
667
+ /**
668
+ * Carries multiple notifications in a single wire frame.
669
+ *
670
+ * Constraints (documented, not schema-enforced):
671
+ * - Each element's `content` MUST be a notification variant — never
672
+ * Authenticated, AuthRequest, SubscribeRequest, or SubscribeResponse.
673
+ * - NotificationBatch MUST NOT be nested inside another NotificationBatch.
674
+ * The schema technically permits this, but senders must not emit
675
+ * recursive batches and receivers may treat them as a protocol violation.
676
+ * - Notifications are delivered in array order; consumers must process
677
+ * them in order.
678
+ * - Sent only for webhooks, for peers that .
679
+ */
680
+ interface ServerMessage_NotificationBatch {
681
+ notifications: ServerMessage[];
682
+ }
683
+ declare const ServerMessage_NotificationBatch: MessageFns$1<ServerMessage_NotificationBatch>;
640
684
  type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
641
685
  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 {} ? {
642
686
  [K in keyof T]?: DeepPartial$1<T[K]>;
@@ -675,7 +719,7 @@ declare const AgentResponse_Authenticated: MessageFns<AgentResponse_Authenticate
675
719
  /** Notification containing a chunk of a track's data stream */
676
720
  interface AgentResponse_TrackData {
677
721
  peerId: string;
678
- track: Track | undefined;
722
+ track: Track$1 | undefined;
679
723
  data: Uint8Array;
680
724
  }
681
725
  declare const AgentResponse_TrackData: MessageFns<AgentResponse_TrackData>;
@@ -762,14 +806,19 @@ type RoomId = Brand<string, 'RoomId'>;
762
806
  * ID of Peer. Peer is associated with Room and can be created with {@link FishjamClient.createPeer}.
763
807
  */
764
808
  type PeerId = Brand<string, 'PeerId'>;
765
- /**
766
- * ID of a MoQ stream. Tokens for a stream can be created with
767
- * {@link FishjamClient.createMoqPublisherToken} and {@link FishjamClient.createMoqSubscriberToken}.
768
- */
769
- type StreamId = Brand<string, 'StreamId'>;
770
809
  type Peer = Omit<Peer$1, 'id'> & {
771
810
  id: PeerId;
772
811
  };
812
+ /**
813
+ * Peer type as emitted by {@link FishjamWSNotifier}. Matches the REST API's `PeerType`,
814
+ * with the addition of `'unspecified'` for messages whose peer type is not set on the wire.
815
+ */
816
+ type PeerType = PeerType$1 | 'unspecified';
817
+ /**
818
+ * Track type as emitted by {@link FishjamWSNotifier}. Matches the REST API's `TrackType`,
819
+ * with the addition of `'unspecified'` for messages whose track type is not set on the wire.
820
+ */
821
+ type TrackType = TrackType$2 | 'unspecified';
773
822
  type Room = {
774
823
  id: RoomId;
775
824
  peers: Peer[];
@@ -801,16 +850,57 @@ type WithPeerId<T> = {
801
850
  } : T[P];
802
851
  };
803
852
 
804
- type ExpectedEvents = 'roomCreated' | 'roomDeleted' | 'roomCrashed' | 'peerAdded' | 'peerDeleted' | 'peerConnected' | 'peerDisconnected' | 'peerMetadataUpdated' | 'peerCrashed' | 'streamConnected' | 'streamDisconnected' | 'viewerConnected' | 'viewerDisconnected' | 'trackAdded' | 'trackRemoved' | 'trackMetadataUpdated';
853
+ /**
854
+ * Track payload embedded in {@link TrackAdded}, {@link TrackRemoved}, {@link TrackMetadataUpdated}.
855
+ */
856
+ type Track = {
857
+ id: string;
858
+ type: TrackType;
859
+ metadata: string;
860
+ };
861
+ declare const expectedEventsList$1: readonly ["roomCreated", "roomDeleted", "roomCrashed", "peerAdded", "peerDeleted", "peerConnected", "peerDisconnected", "peerMetadataUpdated", "peerCrashed", "streamerConnected", "streamerDisconnected", "viewerConnected", "viewerDisconnected", "trackAdded", "trackRemoved", "trackMetadataUpdated", "channelAdded", "channelRemoved"];
862
+ type ExpectedEvents = (typeof expectedEventsList$1)[number];
863
+ /**
864
+ * `ServerMessage` oneof members that are intentionally NOT emitted to users.
865
+ * Grouped with a brief rationale so the classification stays reviewable.
866
+ * Mirrors the Python SDK's `IGNORED_NOTIFICATIONS` partition (FCE-3215).
867
+ */
868
+ declare const ignoredEventsList: readonly ["authenticated", "authRequest", "subscribeRequest", "subscribeResponse", "trackForwarding", "trackForwardingRemoved", "vadNotification", "notificationBatch", "streamConnected", "streamDisconnected", "hlsPlayable", "hlsUploaded", "hlsUploadCrashed", "componentCrashed"];
869
+ type IgnoredEvents = (typeof ignoredEventsList)[number];
805
870
  /**
806
871
  * @inline
807
872
  */
808
873
  type MessageWithIds = WithPeerId<WithRoomId<ServerMessage>>;
874
+ /** @inline */
875
+ type WithMappedPeerType<T> = Omit<T, 'peerType'> & {
876
+ peerType: PeerType;
877
+ };
878
+ /** @inline */
879
+ type WithMappedTrack<T> = Omit<T, 'track'> & {
880
+ track: Track | undefined;
881
+ };
809
882
  /**
810
883
  * @inline
811
884
  */
812
885
  type Notifications = {
813
- [K in ExpectedEvents]: NonNullable<MessageWithIds[K]>;
886
+ roomCreated: NonNullable<MessageWithIds['roomCreated']>;
887
+ roomDeleted: NonNullable<MessageWithIds['roomDeleted']>;
888
+ roomCrashed: NonNullable<MessageWithIds['roomCrashed']>;
889
+ peerAdded: WithMappedPeerType<NonNullable<MessageWithIds['peerAdded']>>;
890
+ peerDeleted: WithMappedPeerType<NonNullable<MessageWithIds['peerDeleted']>>;
891
+ peerConnected: WithMappedPeerType<NonNullable<MessageWithIds['peerConnected']>>;
892
+ peerDisconnected: WithMappedPeerType<NonNullable<MessageWithIds['peerDisconnected']>>;
893
+ peerMetadataUpdated: WithMappedPeerType<NonNullable<MessageWithIds['peerMetadataUpdated']>>;
894
+ peerCrashed: WithMappedPeerType<NonNullable<MessageWithIds['peerCrashed']>>;
895
+ streamerConnected: NonNullable<MessageWithIds['streamerConnected']>;
896
+ streamerDisconnected: NonNullable<MessageWithIds['streamerDisconnected']>;
897
+ viewerConnected: NonNullable<MessageWithIds['viewerConnected']>;
898
+ viewerDisconnected: NonNullable<MessageWithIds['viewerDisconnected']>;
899
+ trackAdded: WithMappedTrack<NonNullable<MessageWithIds['trackAdded']>>;
900
+ trackRemoved: WithMappedTrack<NonNullable<MessageWithIds['trackRemoved']>>;
901
+ trackMetadataUpdated: WithMappedTrack<NonNullable<MessageWithIds['trackMetadataUpdated']>>;
902
+ channelAdded: NonNullable<MessageWithIds['channelAdded']>;
903
+ channelRemoved: NonNullable<MessageWithIds['channelRemoved']>;
814
904
  };
815
905
  type RoomCreated = Notifications['roomCreated'];
816
906
  type RoomDeleted = Notifications['roomDeleted'];
@@ -821,16 +911,19 @@ type PeerConnected = Notifications['peerConnected'];
821
911
  type PeerDisconnected = Notifications['peerDisconnected'];
822
912
  type PeerMetadataUpdated = Notifications['peerMetadataUpdated'];
823
913
  type PeerCrashed = Notifications['peerCrashed'];
824
- type StreamConnected = Notifications['streamConnected'];
825
- type StreamDisconnected = Notifications['streamDisconnected'];
914
+ type StreamerConnected = Notifications['streamerConnected'];
915
+ type StreamerDisconnected = Notifications['streamerDisconnected'];
826
916
  type ViewerConnected = Notifications['viewerConnected'];
827
917
  type ViewerDisconnected = Notifications['viewerDisconnected'];
828
918
  type TrackAdded = Notifications['trackAdded'];
829
919
  type TrackRemoved = Notifications['trackRemoved'];
830
920
  type TrackMetadataUpdated = Notifications['trackMetadataUpdated'];
921
+ type ChannelAdded = Notifications['channelAdded'];
922
+ type ChannelRemoved = Notifications['channelRemoved'];
831
923
  type NotificationEvents = {
832
- [K in ExpectedEvents]: (message: NonNullable<MessageWithIds[K]>) => void;
924
+ [K in ExpectedEvents]: (message: Notifications[K]) => void;
833
925
  };
926
+
834
927
  declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEvents>;
835
928
  /**
836
929
  * Notifier object that can be used to get notified about various events related to the Fishjam App.
@@ -856,10 +949,9 @@ type IncomingTrackImage = NonNullable<AgentResponse_TrackImage>;
856
949
  type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
857
950
  peerId: PeerId;
858
951
  };
859
- type AgentTrack = Omit<Track, 'id'> & {
952
+ type AgentTrack = Omit<Track$1, 'id'> & {
860
953
  id: TrackId;
861
954
  };
862
- type TrackType = 'audio' | 'video';
863
955
  type AudioCodecParameters = {
864
956
  encoding: 'opus' | 'pcm16';
865
957
  sampleRate: 16000 | 24000 | 48000;
@@ -912,7 +1004,7 @@ declare class FishjamAgent extends FishjamAgent_base {
912
1004
  * @param timeoutMs - timeout in milliseconds (default: 5000)
913
1005
  * @returns a promise that resolves with the captured image data
914
1006
  */
915
- captureImage(trackId: string, timeoutMs?: number): Promise<IncomingTrackImage>;
1007
+ captureImage(trackId: TrackId, timeoutMs?: number): Promise<IncomingTrackImage>;
916
1008
  disconnect(): void;
917
1009
  private handleTrackImageMessage;
918
1010
  private rejectPendingCaptures;
@@ -1013,15 +1105,10 @@ declare class FishjamClient {
1013
1105
  */
1014
1106
  createLivestreamStreamerToken(roomId: RoomId): Promise<StreamerToken>;
1015
1107
  /**
1016
- * Creates a MoQ publisher token for the given stream.
1017
- * @returns a MoQ publisher token
1018
- */
1019
- createMoqPublisherToken(streamId: StreamId): Promise<MoqToken>;
1020
- /**
1021
- * Creates a MoQ subscriber token for the given stream.
1022
- * @returns a MoQ subscriber token
1108
+ * Creates a MoQ token.
1109
+ * @returns a MoQ token
1023
1110
  */
1024
- createMoqSubscriberToken(streamId: StreamId): Promise<MoqToken>;
1111
+ createMoqToken(config?: MoqTokenConfig): Promise<MoqToken>;
1025
1112
  }
1026
1113
 
1027
1114
  declare class MissingFishjamIdException extends Error {
@@ -1050,4 +1137,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
1050
1137
  declare class UnknownException extends FishjamBaseException {
1051
1138
  }
1052
1139
 
1053
- export { type AgentCallbacks, 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, type IncomingTrackImage, MissingFishjamIdException, type MoqToken, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsVapi, type PeerOptionsWebRTC, PeerStatus, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamId, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, VideoCodec, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
1140
+ export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type ChannelAdded, type ChannelRemoved, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IgnoredEvents, type IncomingTrackData, type IncomingTrackImage, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsVapi, type PeerOptionsWebRTC, PeerStatus, type PeerType, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, ServiceUnavailableException, type StreamerConnected, type StreamerDisconnected, type StreamerToken, type Track, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, VideoCodec, type ViewerConnected, type ViewerDisconnected, type ViewerToken };