@stream-io/node-sdk 0.1.3 → 0.1.5

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.es.js CHANGED
@@ -8282,7 +8282,7 @@ class StreamCall {
8282
8282
  return this.getOrCreate(getOrCreateCallRequest);
8283
8283
  };
8284
8284
  this.goLive = (videoGoLiveRequest) => {
8285
- return this.apiClient.goLive(Object.assign(Object.assign({}, this.baseRequest), { videoGoLiveRequest: videoGoLiveRequest || null }));
8285
+ return this.apiClient.goLive(Object.assign(Object.assign({}, this.baseRequest), { videoGoLiveRequest: videoGoLiveRequest || {} }));
8286
8286
  };
8287
8287
  this.listRecordings = () => {
8288
8288
  return this.apiClient.listRecordings(Object.assign({}, this.baseRequest));
@@ -8339,7 +8339,8 @@ class StreamCall {
8339
8339
  };
8340
8340
  this.baseRequest = { id: this.id, type: this.type };
8341
8341
  const configuration = this.streamClient.getConfiguration({
8342
- basePath: this.streamClient.basePath || "https://video.stream-io-api.com/video",
8342
+ basePath: this.streamClient.options.basePath ||
8343
+ "https://video.stream-io-api.com/video",
8343
8344
  });
8344
8345
  this.apiClient = new DefaultApi(configuration);
8345
8346
  }
@@ -8377,7 +8378,8 @@ class StreamVideoClient {
8377
8378
  });
8378
8379
  };
8379
8380
  const configuration = this.streamClient.getConfiguration({
8380
- basePath: this.streamClient.basePath || "https://video.stream-io-api.com/video",
8381
+ basePath: this.streamClient.options.basePath ||
8382
+ "https://video.stream-io-api.com/video",
8381
8383
  });
8382
8384
  this.apiClient = new DefaultApi(configuration);
8383
8385
  this.videoServerSideApiClient = new ServerSideApi(configuration);
@@ -8408,10 +8410,17 @@ function JWTServerToken(apiSecret, jwtOptions = {}) {
8408
8410
  }
8409
8411
 
8410
8412
  class StreamClient {
8411
- constructor(apiKey, secret, basePath) {
8413
+ /**
8414
+ *
8415
+ * @param apiKey
8416
+ * @param secret
8417
+ * @param config can be a string, which will be interpreted as base path (deprecated), or a config object
8418
+ */
8419
+ constructor(apiKey, secret, config) {
8412
8420
  this.apiKey = apiKey;
8413
8421
  this.secret = secret;
8414
- this.basePath = basePath;
8422
+ this.config = config;
8423
+ this.options = {};
8415
8424
  this.createDevice = (createDeviceRequest) => {
8416
8425
  return this.devicesApi.createDevice({ createDeviceRequest });
8417
8426
  };
@@ -8457,6 +8466,11 @@ class StreamClient {
8457
8466
  this.deactivateUsers = (deactivateUsersRequest) => {
8458
8467
  return this.usersApi.deactivateUsers({ deactivateUsersRequest });
8459
8468
  };
8469
+ /**
8470
+ * @deprecated use `deleteUsers` instead
8471
+ * @param deleteUsersRequest
8472
+ * @returns
8473
+ */
8460
8474
  this.deleteUser = (request) => __awaiter(this, void 0, void 0, function* () {
8461
8475
  const response = yield this.usersApi.deleteUser(request);
8462
8476
  response.user = this.mapCustomDataAfterReceive(response.user);
@@ -8601,9 +8615,9 @@ class StreamClient {
8601
8615
  };
8602
8616
  return mapping[name];
8603
8617
  },
8604
- basePath: (options === null || options === void 0 ? void 0 : options.basePath) || this.basePath,
8618
+ basePath: (options === null || options === void 0 ? void 0 : options.basePath) || this.options.basePath,
8605
8619
  headers: {
8606
- "X-Stream-Client": "stream-node-" + "0.1.2",
8620
+ "X-Stream-Client": "stream-node-" + "0.1.5",
8607
8621
  },
8608
8622
  middleware: [
8609
8623
  {
@@ -8624,6 +8638,19 @@ class StreamClient {
8624
8638
  }
8625
8639
  }),
8626
8640
  },
8641
+ {
8642
+ pre: (context) => {
8643
+ context.init.signal = AbortSignal.timeout(this.options.timeout);
8644
+ return Promise.resolve(context);
8645
+ },
8646
+ onError: (context) => {
8647
+ const error = context.error;
8648
+ if (error.name === "AbortError" || error.name === "TimeoutError") {
8649
+ throw new FetchError(error, `The request was aborted due to to the ${this.options.timeout}ms timeout, you can set the timeout in the StreamClient constructor`);
8650
+ }
8651
+ return Promise.resolve(context.response);
8652
+ },
8653
+ },
8627
8654
  ],
8628
8655
  // https://github.com/OpenAPITools/openapi-generator/issues/13222
8629
8656
  queryParamsStringify: (params) => {
@@ -8695,6 +8722,13 @@ class StreamClient {
8695
8722
  this.token = JWTServerToken(this.secret);
8696
8723
  this.video = new StreamVideoClient(this);
8697
8724
  this.chat = new StreamChatClient(this);
8725
+ if (typeof config === "string") {
8726
+ this.options.basePath = config;
8727
+ this.options.timeout = StreamClient.DEFAULT_TIMEOUT;
8728
+ }
8729
+ else {
8730
+ this.options.timeout = (config === null || config === void 0 ? void 0 : config.timeout) || StreamClient.DEFAULT_TIMEOUT;
8731
+ }
8698
8732
  const chatConfiguration = this.getConfiguration();
8699
8733
  //@ts-expect-error typing problem
8700
8734
  this.usersApi = new UsersApi(chatConfiguration);
@@ -8719,11 +8753,11 @@ class StreamClient {
8719
8753
  *
8720
8754
  * @param userID
8721
8755
  * @param exp
8722
- * @param iat
8756
+ * @param iat deprecated, the default date will be set internally
8723
8757
  * @param call_cids this parameter is deprecated use `createCallToken` for call tokens
8724
8758
  * @returns
8725
8759
  */
8726
- createToken(userID, exp, iat = Math.round(Date.now() / 1000), call_cids) {
8760
+ createToken(userID, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000), call_cids) {
8727
8761
  const extra = {};
8728
8762
  if (exp) {
8729
8763
  extra.exp = exp;
@@ -8737,7 +8771,15 @@ class StreamClient {
8737
8771
  }
8738
8772
  return JWTUserToken(this.secret, userID, extra);
8739
8773
  }
8740
- createCallToken(userID, call_cids, exp, iat = Math.round(Date.now() / 1000)) {
8774
+ /**
8775
+ *
8776
+ * @param userID
8777
+ * @param call_cids
8778
+ * @param exp
8779
+ * @param iat this is deprecated, the current date will be set internally
8780
+ * @returns
8781
+ */
8782
+ createCallToken(userID, call_cids, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000)) {
8741
8783
  const extra = {};
8742
8784
  if (exp) {
8743
8785
  extra.exp = exp;
@@ -8749,6 +8791,7 @@ class StreamClient {
8749
8791
  return JWTUserToken(this.secret, userID, extra);
8750
8792
  }
8751
8793
  }
8794
+ StreamClient.DEFAULT_TIMEOUT = 3000;
8752
8795
 
8753
8796
  export { APNConfigRequestAuthTypeEnum, AppSearchBackendEnum, AsyncModerationCallbackConfigRequestModeEnum, AudioSettingsDefaultDeviceEnum, BlockListOptionsBehaviorEnum, BlockListOptionsRequestBehaviorEnum, ChannelConfigAutomodBehaviorEnum, ChannelConfigAutomodEnum, ChannelConfigBlocklistBehaviorEnum, ChannelConfigRequestBlocklistBehaviorEnum, ChannelConfigWithInfoAutomodBehaviorEnum, ChannelConfigWithInfoAutomodEnum, ChannelConfigWithInfoBlocklistBehaviorEnum, ChannelConfigWithInfoRequestAutomodBehaviorEnum, ChannelConfigWithInfoRequestAutomodEnum, ChannelConfigWithInfoRequestBlocklistBehaviorEnum, ChannelMemberRequestRoleEnum, ChannelMemberRoleEnum, ChannelTypeConfigAutomodBehaviorEnum, ChannelTypeConfigAutomodEnum, ChannelTypeConfigBlocklistBehaviorEnum, CheckPushRequestPushProviderTypeEnum, CheckSNSResponseStatusEnum, CheckSQSResponseStatusEnum, ConfigDefaultRoleEnum, ConfigRequestDefaultRoleEnum, CreateCallRequestTypeEnum, CreateChannelTypeRequestAutomodBehaviorEnum, CreateChannelTypeRequestAutomodEnum, CreateChannelTypeRequestBlocklistBehaviorEnum, CreateChannelTypeResponseAutomodBehaviorEnum, CreateChannelTypeResponseAutomodEnum, CreateChannelTypeResponseBlocklistBehaviorEnum, CreateDeviceRequestPushProviderEnum, CreateImportRequestModeEnum, DeleteUsersRequestConversationsEnum, DeleteUsersRequestMessagesEnum, DeleteUsersRequestUserEnum, DeviceFieldsPushProviderEnum, DevicePushProviderEnum, DeviceRequestPushProviderEnum, ImageSizeCropEnum, ImageSizeResizeEnum, LayoutSettingsNameEnum, MessageRequest1TypeEnum, MessageRequestTypeEnum, MessageTypeEnum, PermissionLevelEnum, PolicyRequest1ActionEnum, PolicyRequestActionEnum, PushConfigRequestVersionEnum, StreamCall, StreamChannel, StreamChatClient, StreamClient, StreamVideoClient, TranscriptionSettingsModeEnum, TranslateMessageRequestLanguageEnum, UpdateAppRequestEnforceUniqueUsernamesEnum, UpdateAppRequestPermissionVersionEnum, UpdateAppRequestVideoProviderEnum, UpdateChannelTypeRequestAutomodBehaviorEnum, UpdateChannelTypeRequestAutomodEnum, UpdateChannelTypeRequestBlocklistBehaviorEnum, UpdateChannelTypeResponseAutomodBehaviorEnum, UpdateChannelTypeResponseAutomodEnum, UpdateChannelTypeResponseBlocklistBehaviorEnum, VideoAudioSettingsDefaultDeviceEnum, VideoAudioSettingsRequestDefaultDeviceEnum, VideoCreateDeviceRequestPushProviderEnum, VideoLayoutSettingsNameEnum, VideoLayoutSettingsRequestNameEnum, VideoOwnCapability, VideoRecordSettingsRequestModeEnum, VideoRecordSettingsRequestQualityEnum, VideoSettingsCameraFacingEnum, VideoTranscriptionSettingsModeEnum, VideoTranscriptionSettingsRequestModeEnum, VideoVideoSettingsCameraFacingEnum, VideoVideoSettingsRequestCameraFacingEnum };
8754
8797
  //# sourceMappingURL=index.es.js.map