@stream-io/video-client 0.1.1 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.1.3](https://github.com/GetStream/stream-video-js/compare/client0.1.2...client0.1.3) (2023-07-20)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * server side user connect + add tests ([#825](https://github.com/GetStream/stream-video-js/issues/825)) ([95ea24d](https://github.com/GetStream/stream-video-js/commit/95ea24d03306d1b25c3c5af042a202a7b551d865))
11
+
12
+ ### [0.1.2](https://github.com/GetStream/stream-video-js/compare/client0.1.1...client0.1.2) (2023-07-19)
13
+
14
+
15
+ ### Features
16
+
17
+ * server-side client ([#815](https://github.com/GetStream/stream-video-js/issues/815)) ([c3bc445](https://github.com/GetStream/stream-video-js/commit/c3bc445c7db68965934c3e72f005ff7e949e9328))
18
+
5
19
  ### [0.1.1](https://github.com/GetStream/stream-video-js/compare/client0.1.0...client0.1.1) (2023-07-18)
6
20
 
7
21
 
@@ -10725,6 +10725,7 @@ class StableWSConnection {
10725
10725
  * @return {ConnectAPIResponse<ConnectedEvent>} Promise that completes once the first health check message is received
10726
10726
  */
10727
10727
  _connect() {
10728
+ var _a, _b, _c, _d;
10728
10729
  return __awaiter(this, void 0, void 0, function* () {
10729
10730
  if (this.isConnecting ||
10730
10731
  (this.isDisconnected && this.client.options.enableWSFallback))
@@ -10761,7 +10762,7 @@ class StableWSConnection {
10761
10762
  this.isConnecting = false;
10762
10763
  if (response) {
10763
10764
  this.connectionID = response.connection_id;
10764
- this.client.resolveConnectionId(this.connectionID);
10765
+ (_b = (_a = this.client).resolveConnectionId) === null || _b === void 0 ? void 0 : _b.call(_a, this.connectionID);
10765
10766
  if (this.client.insightMetrics.wsConsecutiveFailures > 0 &&
10766
10767
  this.client.options.enableInsights) {
10767
10768
  postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
@@ -10780,7 +10781,7 @@ class StableWSConnection {
10780
10781
  const insights = buildWsFatalInsight(this, convertErrorToJson(err));
10781
10782
  postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
10782
10783
  }
10783
- this.client.rejectConnectionId();
10784
+ (_d = (_c = this.client).rejectConnectionId) === null || _d === void 0 ? void 0 : _d.call(_c);
10784
10785
  throw err;
10785
10786
  }
10786
10787
  });
@@ -11186,6 +11187,7 @@ class WSConnectionFallback {
11186
11187
  undefined, {
11187
11188
  config: Object.assign(Object.assign({}, config), { cancelToken: (_a = this.cancelToken) === null || _a === void 0 ? void 0 : _a.token }),
11188
11189
  params,
11190
+ publicEndpoint: true,
11189
11191
  });
11190
11192
  this.consecutiveFailures = 0; // always reset in case of no error
11191
11193
  return res;
@@ -11242,6 +11244,7 @@ class WSConnectionFallback {
11242
11244
  * @param reconnect should be false for first call and true for subsequent calls to keep the connection alive and call recoverState
11243
11245
  */
11244
11246
  this.connect = (reconnect = false) => __awaiter(this, void 0, void 0, function* () {
11247
+ var _c, _d, _e, _f;
11245
11248
  if (this.state === ConnectionState.Connecting) {
11246
11249
  this._log('connect() - connecting already in progress', { reconnect }, 'warn');
11247
11250
  return;
@@ -11258,7 +11261,7 @@ class WSConnectionFallback {
11258
11261
  }, reconnect);
11259
11262
  this._setState(ConnectionState.Connected);
11260
11263
  this.connectionID = event.connection_id;
11261
- this.client.resolveConnectionId();
11264
+ (_d = (_c = this.client).resolveConnectionId) === null || _d === void 0 ? void 0 : _d.call(_c);
11262
11265
  // @ts-expect-error
11263
11266
  this.client.dispatchEvent(event);
11264
11267
  this._poll();
@@ -11266,7 +11269,7 @@ class WSConnectionFallback {
11266
11269
  }
11267
11270
  catch (err) {
11268
11271
  this._setState(ConnectionState.Closed);
11269
- this.client.rejectConnectionId();
11272
+ (_f = (_e = this.client).rejectConnectionId) === null || _f === void 0 ? void 0 : _f.call(_e);
11270
11273
  throw err;
11271
11274
  }
11272
11275
  });
@@ -11277,10 +11280,10 @@ class WSConnectionFallback {
11277
11280
  return !!this.connectionID && this.state === ConnectionState.Connected;
11278
11281
  };
11279
11282
  this.disconnect = (timeout = 2000) => __awaiter(this, void 0, void 0, function* () {
11280
- var _c;
11283
+ var _g;
11281
11284
  removeConnectionEventListeners(this._onlineStatusChanged);
11282
11285
  this._setState(ConnectionState.Disconnected);
11283
- (_c = this.cancelToken) === null || _c === void 0 ? void 0 : _c.cancel('disconnect() is called');
11286
+ (_g = this.cancelToken) === null || _g === void 0 ? void 0 : _g.cancel('disconnect() is called');
11284
11287
  this.cancelToken = undefined;
11285
11288
  const connection_id = this.connectionID;
11286
11289
  this.connectionID = undefined;
@@ -11317,7 +11320,7 @@ class WSConnectionFallback {
11317
11320
  }
11318
11321
  }
11319
11322
 
11320
- const version = '0.1.1';
11323
+ const version = '0.1.3';
11321
11324
 
11322
11325
  const logger = getLogger(['location']);
11323
11326
  const HINT_URL = `https://hint.stream-io-video.com/`;
@@ -11494,6 +11497,10 @@ class StreamClient {
11494
11497
  this.logger('info', 'client:openConnection() - openConnection called twice, healthy connection already exists');
11495
11498
  return Promise.resolve();
11496
11499
  }
11500
+ this.connectionIdPromise = new Promise((resolve, reject) => {
11501
+ this.resolveConnectionId = resolve;
11502
+ this.rejectConnectionId = reject;
11503
+ });
11497
11504
  this.clientID = `${this.userID}--${randomId()}`;
11498
11505
  this.wsPromise = this.connect();
11499
11506
  return this.wsPromise;
@@ -11522,11 +11529,19 @@ class StreamClient {
11522
11529
  this.anonymous = false;
11523
11530
  yield this.closeConnection(timeout);
11524
11531
  this.tokenManager.reset();
11532
+ this.connectionIdPromise = undefined;
11533
+ this.rejectConnectionId = undefined;
11534
+ this.resolveConnectionId = undefined;
11525
11535
  });
11526
11536
  /**
11527
11537
  * connectAnonymousUser - Set an anonymous user and open a WebSocket connection
11528
11538
  */
11529
11539
  this.connectAnonymousUser = (user, tokenOrProvider) => __awaiter(this, void 0, void 0, function* () {
11540
+ var _g;
11541
+ this.connectionIdPromise = new Promise((resolve, reject) => {
11542
+ this.resolveConnectionId = resolve;
11543
+ this.rejectConnectionId = reject;
11544
+ });
11530
11545
  this.anonymous = true;
11531
11546
  yield this._setToken(user, tokenOrProvider, this.anonymous);
11532
11547
  if (this.resolveConnectPromise) {
@@ -11538,7 +11553,7 @@ class StreamClient {
11538
11553
  // some endpoints require a connection_id to be resolved.
11539
11554
  // as anonymous users aren't allowed to open WS connections, we just
11540
11555
  // resolve the connection_id here.
11541
- this.resolveConnectionId();
11556
+ (_g = this.resolveConnectionId) === null || _g === void 0 ? void 0 : _g.call(this);
11542
11557
  });
11543
11558
  /**
11544
11559
  * on - Listen to events on all channels and users your watching
@@ -11601,8 +11616,8 @@ class StreamClient {
11601
11616
  });
11602
11617
  };
11603
11618
  this.doAxiosRequest = (type, url, data, options = {}) => __awaiter(this, void 0, void 0, function* () {
11604
- var _g;
11605
- if (!options.publicEndpoint || this.user) {
11619
+ var _h;
11620
+ if (!options.publicEndpoint) {
11606
11621
  if (this.waitForConnectPromise) {
11607
11622
  yield this.waitForConnectPromise;
11608
11623
  }
@@ -11643,7 +11658,7 @@ class StreamClient {
11643
11658
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11644
11659
  }
11645
11660
  catch (e /**TODO: generalize error types */) {
11646
- e.client_request_id = (_g = requestConfig.headers) === null || _g === void 0 ? void 0 : _g['x-client-request-id'];
11661
+ e.client_request_id = (_h = requestConfig.headers) === null || _h === void 0 ? void 0 : _h['x-client-request-id'];
11647
11662
  this._logApiError(type, url, e);
11648
11663
  this.consecutiveFailures += 1;
11649
11664
  if (e.response) {
@@ -11908,10 +11923,6 @@ class StreamClient {
11908
11923
  keepAliveMsecs: 3000,
11909
11924
  });
11910
11925
  }
11911
- this.connectionIdPromise = new Promise((resolve, reject) => {
11912
- this.resolveConnectionId = resolve;
11913
- this.rejectConnectionId = reject;
11914
- });
11915
11926
  this.setBaseURL(this.options.baseURL || 'https://video.stream-io-api.com/video');
11916
11927
  if (typeof process !== 'undefined' && process.env.STREAM_LOCAL_TEST_RUN) {
11917
11928
  this.setBaseURL('http://localhost:3030/video');
@@ -12044,22 +12055,6 @@ class StreamVideoClient {
12044
12055
  this.edges = () => __awaiter(this, void 0, void 0, function* () {
12045
12056
  return this.streamClient.get(`/edges`);
12046
12057
  });
12047
- // server-side only endpoints
12048
- this.createCallType = (data) => __awaiter(this, void 0, void 0, function* () {
12049
- return this.streamClient.post(`/calltypes`, data);
12050
- });
12051
- this.getCallType = (name) => __awaiter(this, void 0, void 0, function* () {
12052
- return this.streamClient.get(`/calltypes/${name}`);
12053
- });
12054
- this.updateCallType = (name, data) => __awaiter(this, void 0, void 0, function* () {
12055
- return this.streamClient.put(`/calltypes/${name}`, data);
12056
- });
12057
- this.deleteCallType = (name) => __awaiter(this, void 0, void 0, function* () {
12058
- return this.streamClient.delete(`/calltypes/${name}`);
12059
- });
12060
- this.listCallTypes = () => __awaiter(this, void 0, void 0, function* () {
12061
- return this.streamClient.get(`/calltypes`);
12062
- });
12063
12058
  /**
12064
12059
  * addDevice - Adds a push device for a user.
12065
12060
  *
@@ -12279,6 +12274,27 @@ class StreamVideoClient {
12279
12274
  return yield this.addDevice(id, push_provider, push_provider_name, userID, true);
12280
12275
  });
12281
12276
  }
12277
+ }
12278
+
12279
+ class StreamVideoServerClient extends StreamVideoClient {
12280
+ constructor(apiKey, options) {
12281
+ super({ apiKey, options });
12282
+ this.getCallTypes = () => {
12283
+ return this.streamClient.get('/calltypes');
12284
+ };
12285
+ this.getCallType = (name) => {
12286
+ return this.streamClient.get(`/calltypes/${name}`);
12287
+ };
12288
+ this.createCallType = (data) => {
12289
+ return this.streamClient.post('/calltypes', data);
12290
+ };
12291
+ this.deleteCallType = (name) => {
12292
+ return this.streamClient.delete(`/calltypes/${name}`);
12293
+ };
12294
+ this.updateCallType = (name, data) => {
12295
+ return this.streamClient.put(`/calltypes/${name}`, data);
12296
+ };
12297
+ }
12282
12298
  /**
12283
12299
  * createToken - Creates a token to authenticate this user. This function is used server side.
12284
12300
  * The resulting token should be passed to the client side when the users register or logs in.
@@ -12628,5 +12644,5 @@ var browsers = /*#__PURE__*/Object.freeze({
12628
12644
  isSafari: isSafari
12629
12645
  });
12630
12646
 
12631
- export { AudioSettingsDefaultDeviceEnum, AudioSettingsRequestDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CreateDeviceRequestPushProviderEnum, DebounceType, ErrorFromResponse, OwnCapability, RecordSettingsModeEnum, RecordSettingsQualityEnum, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, events as SfuEvents, models as SfuModels, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoWriteableStateStore, TranscriptionSettingsModeEnum, TranscriptionSettingsRequestModeEnum, VideoSettingsCameraFacingEnum, VideoSettingsRequestCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, disposeOfMediaStream, dominantSpeaker, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoDevices, getVideoStream, isStreamVideoLocalParticipant, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, speakerLayoutSortPreset, speaking, watchForAddedDefaultAudioDevice, watchForAddedDefaultAudioOutputDevice, watchForAddedDefaultVideoDevice, watchForDisconnectedAudioDevice, watchForDisconnectedAudioOutputDevice, watchForDisconnectedVideoDevice };
12647
+ export { AudioSettingsDefaultDeviceEnum, AudioSettingsRequestDefaultDeviceEnum, browsers as Browsers, Call, CallState, CallType, CallTypes, CallingState, CreateDeviceRequestPushProviderEnum, DebounceType, ErrorFromResponse, OwnCapability, RecordSettingsModeEnum, RecordSettingsQualityEnum, RecordSettingsRequestModeEnum, RecordSettingsRequestQualityEnum, rxUtils as RxUtils, events as SfuEvents, models as SfuModels, StreamSfuClient, StreamVideoClient, StreamVideoReadOnlyStateStore, StreamVideoServerClient, StreamVideoWriteableStateStore, TranscriptionSettingsModeEnum, TranscriptionSettingsRequestModeEnum, VideoSettingsCameraFacingEnum, VideoSettingsRequestCameraFacingEnum, ViewportTracker, VisibilityState, checkIfAudioOutputChangeSupported, combineComparators, conditional, createSoundDetector, defaultSortPreset, descending, disposeOfMediaStream, dominantSpeaker, getAudioDevices, getAudioOutputDevices, getAudioStream, getClientDetails, getDeviceInfo, getLogger, getOSInfo, getScreenShareStream, getSdkInfo, getVideoDevices, getVideoStream, isStreamVideoLocalParticipant, livestreamOrAudioRoomSortPreset, logLevels, logToConsole, name, noopComparator, pinned, publishingAudio, publishingVideo, reactionType, role, screenSharing, setDeviceInfo, setLogLevel, setLogger, setOSInfo, setSdkInfo, speakerLayoutSortPreset, speaking, watchForAddedDefaultAudioDevice, watchForAddedDefaultAudioOutputDevice, watchForAddedDefaultVideoDevice, watchForDisconnectedAudioDevice, watchForDisconnectedAudioOutputDevice, watchForDisconnectedVideoDevice };
12632
12648
  //# sourceMappingURL=index.browser.es.js.map