@fishjam-cloud/js-server-sdk 0.28.0-rc.0 → 0.28.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.28.0-rc.0",
4
+ version: "0.28.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",
@@ -90,8 +90,7 @@ var package_default = {
90
90
  "*.{js,ts,tsx,mjs,cjs}": [
91
91
  "eslint --fix --config eslint.config.mjs"
92
92
  ]
93
- },
94
- stableVersion: "0.27.0"
93
+ }
95
94
  };
96
95
 
97
96
  export {
package/dist/index.d.mts CHANGED
@@ -926,6 +926,17 @@ type ChannelRemoved = Notifications['channelRemoved'];
926
926
  type NotificationEvents = {
927
927
  [K in ExpectedEvents]: (message: Notifications[K]) => void;
928
928
  };
929
+ /**
930
+ * A single decoded, mapped server notification tagged with its event type.
931
+ * The discriminated `type` lets consumers narrow `notification` to the matching
932
+ * payload (e.g. `if (n.type === 'peerConnected') n.notification.peerType`).
933
+ */
934
+ type ServerNotification = {
935
+ [K in ExpectedEvents]: {
936
+ type: K;
937
+ notification: Notifications[K];
938
+ };
939
+ }[ExpectedEvents];
929
940
 
930
941
  declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEvents>;
931
942
  /**
@@ -937,9 +948,37 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
937
948
  constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler);
938
949
  private dispatchNotification;
939
950
  private setupConnection;
940
- private isExpectedEvent;
941
951
  }
942
952
 
953
+ /**
954
+ * Decode a raw Fishjam webhook body (`application/x-protobuf`) into typed,
955
+ * mapped notifications.
956
+ *
957
+ * A room/stream created with `batchWebhookNotifications: true` may deliver
958
+ * several notifications coalesced into a single `NotificationBatch`; this helper
959
+ * transparently unwraps that batch, so a single message and a batch are handled
960
+ * the same way. Notifications are returned in wire order, with the same payload
961
+ * mapping the {@link FishjamWSNotifier} applies (branded ids, `peerType`/`track`
962
+ * enums). Non-surfaced variants (handshake, deprecated) are omitted.
963
+ *
964
+ * Accepts a Node `Buffer` (a `Uint8Array` subclass), a `Uint8Array`, or an
965
+ * `ArrayBuffer`.
966
+ *
967
+ * @example
968
+ * ```ts
969
+ * import { decodeServerNotifications } from '@fishjam-cloud/js-server-sdk';
970
+ *
971
+ * declare const body: Uint8Array;
972
+ * declare const handlePeerConnected: (notification: unknown) => void;
973
+ * // ---cut---
974
+ * for (const { type, notification } of decodeServerNotifications(body)) {
975
+ * if (type === 'peerConnected') handlePeerConnected(notification);
976
+ * }
977
+ * ```
978
+ * @category Notifications
979
+ */
980
+ declare const decodeServerNotifications: (data: Uint8Array | ArrayBuffer) => ServerNotification[];
981
+
943
982
  declare const expectedEventsList: readonly ["trackData"];
944
983
  /**
945
984
  * @useDeclaredType
@@ -1170,4 +1209,4 @@ declare class QuotaExceededException extends FishjamBaseException {
1170
1209
  declare class UnknownException extends FishjamBaseException {
1171
1210
  }
1172
1211
 
1173
- 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, InvalidFishjamCredentialsException, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Override, 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, QuotaExceededException, 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 };
1212
+ 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, InvalidFishjamCredentialsException, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Override, 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, QuotaExceededException, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, type ServerNotification, 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, decodeServerNotifications };
package/dist/index.d.ts CHANGED
@@ -926,6 +926,17 @@ type ChannelRemoved = Notifications['channelRemoved'];
926
926
  type NotificationEvents = {
927
927
  [K in ExpectedEvents]: (message: Notifications[K]) => void;
928
928
  };
929
+ /**
930
+ * A single decoded, mapped server notification tagged with its event type.
931
+ * The discriminated `type` lets consumers narrow `notification` to the matching
932
+ * payload (e.g. `if (n.type === 'peerConnected') n.notification.peerType`).
933
+ */
934
+ type ServerNotification = {
935
+ [K in ExpectedEvents]: {
936
+ type: K;
937
+ notification: Notifications[K];
938
+ };
939
+ }[ExpectedEvents];
929
940
 
930
941
  declare const FishjamWSNotifier_base: new () => TypedEventEmitter<NotificationEvents>;
931
942
  /**
@@ -937,9 +948,37 @@ declare class FishjamWSNotifier extends FishjamWSNotifier_base {
937
948
  constructor(config: FishjamConfig, onError: ErrorEventHandler, onClose: CloseEventHandler);
938
949
  private dispatchNotification;
939
950
  private setupConnection;
940
- private isExpectedEvent;
941
951
  }
942
952
 
953
+ /**
954
+ * Decode a raw Fishjam webhook body (`application/x-protobuf`) into typed,
955
+ * mapped notifications.
956
+ *
957
+ * A room/stream created with `batchWebhookNotifications: true` may deliver
958
+ * several notifications coalesced into a single `NotificationBatch`; this helper
959
+ * transparently unwraps that batch, so a single message and a batch are handled
960
+ * the same way. Notifications are returned in wire order, with the same payload
961
+ * mapping the {@link FishjamWSNotifier} applies (branded ids, `peerType`/`track`
962
+ * enums). Non-surfaced variants (handshake, deprecated) are omitted.
963
+ *
964
+ * Accepts a Node `Buffer` (a `Uint8Array` subclass), a `Uint8Array`, or an
965
+ * `ArrayBuffer`.
966
+ *
967
+ * @example
968
+ * ```ts
969
+ * import { decodeServerNotifications } from '@fishjam-cloud/js-server-sdk';
970
+ *
971
+ * declare const body: Uint8Array;
972
+ * declare const handlePeerConnected: (notification: unknown) => void;
973
+ * // ---cut---
974
+ * for (const { type, notification } of decodeServerNotifications(body)) {
975
+ * if (type === 'peerConnected') handlePeerConnected(notification);
976
+ * }
977
+ * ```
978
+ * @category Notifications
979
+ */
980
+ declare const decodeServerNotifications: (data: Uint8Array | ArrayBuffer) => ServerNotification[];
981
+
943
982
  declare const expectedEventsList: readonly ["trackData"];
944
983
  /**
945
984
  * @useDeclaredType
@@ -1170,4 +1209,4 @@ declare class QuotaExceededException extends FishjamBaseException {
1170
1209
  declare class UnknownException extends FishjamBaseException {
1171
1210
  }
1172
1211
 
1173
- 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, InvalidFishjamCredentialsException, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Override, 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, QuotaExceededException, 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 };
1212
+ 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, InvalidFishjamCredentialsException, MissingFishjamIdException, type MoqToken, type MoqTokenConfig, type NotificationEvents, type OutgoingTrackData, type Override, 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, QuotaExceededException, type Room, type RoomConfig, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, RoomType, ServerMessage, type ServerNotification, 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, decodeServerNotifications };
package/dist/index.js CHANGED
@@ -48,7 +48,8 @@ __export(index_exports, {
48
48
  ServiceUnavailableException: () => ServiceUnavailableException,
49
49
  UnauthorizedException: () => UnauthorizedException,
50
50
  UnknownException: () => UnknownException,
51
- VideoCodec: () => VideoCodec
51
+ VideoCodec: () => VideoCodec,
52
+ decodeServerNotifications: () => decodeServerNotifications
52
53
  });
53
54
  module.exports = __toCommonJS(index_exports);
54
55
 
@@ -6056,6 +6057,16 @@ var mapNotification = (event, msg) => {
6056
6057
  }
6057
6058
  return msg;
6058
6059
  };
6060
+ var isExpectedEvent = (event) => expectedEventsList.includes(event);
6061
+ var flattenServerMessage = (message) => message.notificationBatch?.notifications ?? [message];
6062
+ var toServerNotification = (message) => {
6063
+ const entry = Object.entries(message).find(([, value]) => value);
6064
+ if (!entry) return null;
6065
+ const [event, msg] = entry;
6066
+ if (!isExpectedEvent(event)) return null;
6067
+ return { type: event, notification: mapNotification(event, msg) };
6068
+ };
6069
+ var extractNotifications = (message) => flattenServerMessage(message).map(toServerNotification).filter((notification) => notification !== null);
6059
6070
 
6060
6071
  // src/ws_notifier.ts
6061
6072
  var FishjamWSNotifier = class extends import_events.EventEmitter {
@@ -6073,12 +6084,11 @@ var FishjamWSNotifier = class extends import_events.EventEmitter {
6073
6084
  }
6074
6085
  dispatchNotification(message) {
6075
6086
  try {
6076
- const data = new Uint8Array(message.data);
6077
- const decodedMessage = ServerMessage.decode(data);
6078
- const [notification, msg] = Object.entries(decodedMessage).find(([_k, v]) => v);
6079
- if (!this.isExpectedEvent(notification)) return;
6080
- const emit = this.emit;
6081
- emit(notification, mapNotification(notification, msg));
6087
+ const decodedMessage = ServerMessage.decode(new Uint8Array(message.data));
6088
+ const emit = this.emit.bind(this);
6089
+ for (const { type, notification } of extractNotifications(decodedMessage)) {
6090
+ emit(type, notification);
6091
+ }
6082
6092
  } catch (e) {
6083
6093
  console.error("Couldn't decode websocket server message", e, message);
6084
6094
  }
@@ -6091,11 +6101,11 @@ var FishjamWSNotifier = class extends import_events.EventEmitter {
6091
6101
  this.client.send(auth);
6092
6102
  this.client.send(subscription);
6093
6103
  }
6094
- isExpectedEvent(notification) {
6095
- return expectedEventsList.includes(notification);
6096
- }
6097
6104
  };
6098
6105
 
6106
+ // src/webhook.ts
6107
+ var decodeServerNotifications = (data) => extractNotifications(ServerMessage.decode(data instanceof Uint8Array ? data : new Uint8Array(data)));
6108
+
6099
6109
  // src/agent.ts
6100
6110
  var import_events2 = require("events");
6101
6111
  var import_uuid = require("uuid");
@@ -6285,7 +6295,7 @@ var mapException = (error, entity) => {
6285
6295
  // package.json
6286
6296
  var package_default = {
6287
6297
  name: "@fishjam-cloud/js-server-sdk",
6288
- version: "0.28.0-rc.0",
6298
+ version: "0.28.0",
6289
6299
  description: "Fishjam server SDK for JavaScript",
6290
6300
  homepage: "https://github.com/fishjam-cloud/js-server-sdk",
6291
6301
  author: "Fishjam Team",
@@ -6374,8 +6384,7 @@ var package_default = {
6374
6384
  "*.{js,ts,tsx,mjs,cjs}": [
6375
6385
  "eslint --fix --config eslint.config.mjs"
6376
6386
  ]
6377
- },
6378
- stableVersion: "0.27.0"
6387
+ }
6379
6388
  };
6380
6389
 
6381
6390
  // src/client.ts
@@ -6671,5 +6680,6 @@ var FishjamClient = class _FishjamClient {
6671
6680
  ServiceUnavailableException,
6672
6681
  UnauthorizedException,
6673
6682
  UnknownException,
6674
- VideoCodec
6683
+ VideoCodec,
6684
+ decodeServerNotifications
6675
6685
  });
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./chunk-GERVP75S.mjs";
3
+ } from "./chunk-7QSC3SIL.mjs";
4
4
 
5
5
  // ../fishjam-openapi/dist/index.js
6
6
  import globalAxios2 from "axios";
@@ -6006,6 +6006,16 @@ var mapNotification = (event, msg) => {
6006
6006
  }
6007
6007
  return msg;
6008
6008
  };
6009
+ var isExpectedEvent = (event) => expectedEventsList.includes(event);
6010
+ var flattenServerMessage = (message) => message.notificationBatch?.notifications ?? [message];
6011
+ var toServerNotification = (message) => {
6012
+ const entry = Object.entries(message).find(([, value]) => value);
6013
+ if (!entry) return null;
6014
+ const [event, msg] = entry;
6015
+ if (!isExpectedEvent(event)) return null;
6016
+ return { type: event, notification: mapNotification(event, msg) };
6017
+ };
6018
+ var extractNotifications = (message) => flattenServerMessage(message).map(toServerNotification).filter((notification) => notification !== null);
6009
6019
 
6010
6020
  // src/ws_notifier.ts
6011
6021
  var FishjamWSNotifier = class extends EventEmitter {
@@ -6023,12 +6033,11 @@ var FishjamWSNotifier = class extends EventEmitter {
6023
6033
  }
6024
6034
  dispatchNotification(message) {
6025
6035
  try {
6026
- const data = new Uint8Array(message.data);
6027
- const decodedMessage = ServerMessage.decode(data);
6028
- const [notification, msg] = Object.entries(decodedMessage).find(([_k, v]) => v);
6029
- if (!this.isExpectedEvent(notification)) return;
6030
- const emit = this.emit;
6031
- emit(notification, mapNotification(notification, msg));
6036
+ const decodedMessage = ServerMessage.decode(new Uint8Array(message.data));
6037
+ const emit = this.emit.bind(this);
6038
+ for (const { type, notification } of extractNotifications(decodedMessage)) {
6039
+ emit(type, notification);
6040
+ }
6032
6041
  } catch (e) {
6033
6042
  console.error("Couldn't decode websocket server message", e, message);
6034
6043
  }
@@ -6041,11 +6050,11 @@ var FishjamWSNotifier = class extends EventEmitter {
6041
6050
  this.client.send(auth);
6042
6051
  this.client.send(subscription);
6043
6052
  }
6044
- isExpectedEvent(notification) {
6045
- return expectedEventsList.includes(notification);
6046
- }
6047
6053
  };
6048
6054
 
6055
+ // src/webhook.ts
6056
+ var decodeServerNotifications = (data) => extractNotifications(ServerMessage.decode(data instanceof Uint8Array ? data : new Uint8Array(data)));
6057
+
6049
6058
  // src/agent.ts
6050
6059
  import { EventEmitter as EventEmitter2 } from "events";
6051
6060
  import { v4 as uuid4 } from "uuid";
@@ -6524,5 +6533,6 @@ export {
6524
6533
  ServiceUnavailableException,
6525
6534
  UnauthorizedException,
6526
6535
  UnknownException,
6527
- VideoCodec
6536
+ VideoCodec,
6537
+ decodeServerNotifications
6528
6538
  };
@@ -31,7 +31,7 @@ var import_genai = require("@google/genai");
31
31
  // package.json
32
32
  var package_default = {
33
33
  name: "@fishjam-cloud/js-server-sdk",
34
- version: "0.28.0-rc.0",
34
+ version: "0.28.0",
35
35
  description: "Fishjam server SDK for JavaScript",
36
36
  homepage: "https://github.com/fishjam-cloud/js-server-sdk",
37
37
  author: "Fishjam Team",
@@ -120,8 +120,7 @@ var package_default = {
120
120
  "*.{js,ts,tsx,mjs,cjs}": [
121
121
  "eslint --fix --config eslint.config.mjs"
122
122
  ]
123
- },
124
- stableVersion: "0.27.0"
123
+ }
125
124
  };
126
125
 
127
126
  // src/integrations/gemini.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunk-GERVP75S.mjs";
3
+ } from "../chunk-7QSC3SIL.mjs";
4
4
 
5
5
  // src/integrations/gemini.ts
6
6
  import { GoogleGenAI } from "@google/genai";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishjam-cloud/js-server-sdk",
3
- "version": "0.28.0-rc.0",
3
+ "version": "0.28.0",
4
4
  "description": "Fishjam server SDK for JavaScript",
5
5
  "homepage": "https://github.com/fishjam-cloud/js-server-sdk",
6
6
  "author": "Fishjam Team",
@@ -74,8 +74,8 @@
74
74
  }
75
75
  },
76
76
  "devDependencies": {
77
- "@fishjam-cloud/fishjam-openapi": "0.28.0-rc.0",
78
- "@fishjam-cloud/fishjam-proto": "0.28.0-rc.0",
77
+ "@fishjam-cloud/fishjam-openapi": "0.28.0",
78
+ "@fishjam-cloud/fishjam-proto": "0.28.0",
79
79
  "@openapitools/openapi-generator-cli": "^2.18.4",
80
80
  "@types/node": "^22.13.16",
81
81
  "@types/websocket": "^1.0.10",
@@ -89,6 +89,5 @@
89
89
  "*.{js,ts,tsx,mjs,cjs}": [
90
90
  "eslint --fix --config eslint.config.mjs"
91
91
  ]
92
- },
93
- "stableVersion": "0.27.0"
92
+ }
94
93
  }