@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.
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import "dotenv/config";
2
+ import { StreamClient } from "../src/StreamClient";
3
+ export declare const createTestClient: () => StreamClient;
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
@@ -1 +1 @@
1
- import "dotenv/config";
1
+ export {};
package/dist/index.cjs.js CHANGED
@@ -8284,7 +8284,7 @@ class StreamCall {
8284
8284
  return this.getOrCreate(getOrCreateCallRequest);
8285
8285
  };
8286
8286
  this.goLive = (videoGoLiveRequest) => {
8287
- return this.apiClient.goLive(Object.assign(Object.assign({}, this.baseRequest), { videoGoLiveRequest: videoGoLiveRequest || null }));
8287
+ return this.apiClient.goLive(Object.assign(Object.assign({}, this.baseRequest), { videoGoLiveRequest: videoGoLiveRequest || {} }));
8288
8288
  };
8289
8289
  this.listRecordings = () => {
8290
8290
  return this.apiClient.listRecordings(Object.assign({}, this.baseRequest));
@@ -8341,7 +8341,8 @@ class StreamCall {
8341
8341
  };
8342
8342
  this.baseRequest = { id: this.id, type: this.type };
8343
8343
  const configuration = this.streamClient.getConfiguration({
8344
- basePath: this.streamClient.basePath || "https://video.stream-io-api.com/video",
8344
+ basePath: this.streamClient.options.basePath ||
8345
+ "https://video.stream-io-api.com/video",
8345
8346
  });
8346
8347
  this.apiClient = new DefaultApi(configuration);
8347
8348
  }
@@ -8379,7 +8380,8 @@ class StreamVideoClient {
8379
8380
  });
8380
8381
  };
8381
8382
  const configuration = this.streamClient.getConfiguration({
8382
- basePath: this.streamClient.basePath || "https://video.stream-io-api.com/video",
8383
+ basePath: this.streamClient.options.basePath ||
8384
+ "https://video.stream-io-api.com/video",
8383
8385
  });
8384
8386
  this.apiClient = new DefaultApi(configuration);
8385
8387
  this.videoServerSideApiClient = new ServerSideApi(configuration);
@@ -8410,10 +8412,17 @@ function JWTServerToken(apiSecret, jwtOptions = {}) {
8410
8412
  }
8411
8413
 
8412
8414
  class StreamClient {
8413
- constructor(apiKey, secret, basePath) {
8415
+ /**
8416
+ *
8417
+ * @param apiKey
8418
+ * @param secret
8419
+ * @param config can be a string, which will be interpreted as base path (deprecated), or a config object
8420
+ */
8421
+ constructor(apiKey, secret, config) {
8414
8422
  this.apiKey = apiKey;
8415
8423
  this.secret = secret;
8416
- this.basePath = basePath;
8424
+ this.config = config;
8425
+ this.options = {};
8417
8426
  this.createDevice = (createDeviceRequest) => {
8418
8427
  return this.devicesApi.createDevice({ createDeviceRequest });
8419
8428
  };
@@ -8459,6 +8468,11 @@ class StreamClient {
8459
8468
  this.deactivateUsers = (deactivateUsersRequest) => {
8460
8469
  return this.usersApi.deactivateUsers({ deactivateUsersRequest });
8461
8470
  };
8471
+ /**
8472
+ * @deprecated use `deleteUsers` instead
8473
+ * @param deleteUsersRequest
8474
+ * @returns
8475
+ */
8462
8476
  this.deleteUser = (request) => __awaiter(this, void 0, void 0, function* () {
8463
8477
  const response = yield this.usersApi.deleteUser(request);
8464
8478
  response.user = this.mapCustomDataAfterReceive(response.user);
@@ -8603,9 +8617,9 @@ class StreamClient {
8603
8617
  };
8604
8618
  return mapping[name];
8605
8619
  },
8606
- basePath: (options === null || options === void 0 ? void 0 : options.basePath) || this.basePath,
8620
+ basePath: (options === null || options === void 0 ? void 0 : options.basePath) || this.options.basePath,
8607
8621
  headers: {
8608
- "X-Stream-Client": "stream-node-" + "0.1.2",
8622
+ "X-Stream-Client": "stream-node-" + "0.1.5",
8609
8623
  },
8610
8624
  middleware: [
8611
8625
  {
@@ -8626,6 +8640,19 @@ class StreamClient {
8626
8640
  }
8627
8641
  }),
8628
8642
  },
8643
+ {
8644
+ pre: (context) => {
8645
+ context.init.signal = AbortSignal.timeout(this.options.timeout);
8646
+ return Promise.resolve(context);
8647
+ },
8648
+ onError: (context) => {
8649
+ const error = context.error;
8650
+ if (error.name === "AbortError" || error.name === "TimeoutError") {
8651
+ 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`);
8652
+ }
8653
+ return Promise.resolve(context.response);
8654
+ },
8655
+ },
8629
8656
  ],
8630
8657
  // https://github.com/OpenAPITools/openapi-generator/issues/13222
8631
8658
  queryParamsStringify: (params) => {
@@ -8697,6 +8724,13 @@ class StreamClient {
8697
8724
  this.token = JWTServerToken(this.secret);
8698
8725
  this.video = new StreamVideoClient(this);
8699
8726
  this.chat = new StreamChatClient(this);
8727
+ if (typeof config === "string") {
8728
+ this.options.basePath = config;
8729
+ this.options.timeout = StreamClient.DEFAULT_TIMEOUT;
8730
+ }
8731
+ else {
8732
+ this.options.timeout = (config === null || config === void 0 ? void 0 : config.timeout) || StreamClient.DEFAULT_TIMEOUT;
8733
+ }
8700
8734
  const chatConfiguration = this.getConfiguration();
8701
8735
  //@ts-expect-error typing problem
8702
8736
  this.usersApi = new UsersApi(chatConfiguration);
@@ -8721,11 +8755,11 @@ class StreamClient {
8721
8755
  *
8722
8756
  * @param userID
8723
8757
  * @param exp
8724
- * @param iat
8758
+ * @param iat deprecated, the default date will be set internally
8725
8759
  * @param call_cids this parameter is deprecated use `createCallToken` for call tokens
8726
8760
  * @returns
8727
8761
  */
8728
- createToken(userID, exp, iat = Math.round(Date.now() / 1000), call_cids) {
8762
+ createToken(userID, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000), call_cids) {
8729
8763
  const extra = {};
8730
8764
  if (exp) {
8731
8765
  extra.exp = exp;
@@ -8739,7 +8773,15 @@ class StreamClient {
8739
8773
  }
8740
8774
  return JWTUserToken(this.secret, userID, extra);
8741
8775
  }
8742
- createCallToken(userID, call_cids, exp, iat = Math.round(Date.now() / 1000)) {
8776
+ /**
8777
+ *
8778
+ * @param userID
8779
+ * @param call_cids
8780
+ * @param exp
8781
+ * @param iat this is deprecated, the current date will be set internally
8782
+ * @returns
8783
+ */
8784
+ createCallToken(userID, call_cids, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000)) {
8743
8785
  const extra = {};
8744
8786
  if (exp) {
8745
8787
  extra.exp = exp;
@@ -8751,6 +8793,7 @@ class StreamClient {
8751
8793
  return JWTUserToken(this.secret, userID, extra);
8752
8794
  }
8753
8795
  }
8796
+ StreamClient.DEFAULT_TIMEOUT = 3000;
8754
8797
 
8755
8798
  exports.APNConfigRequestAuthTypeEnum = APNConfigRequestAuthTypeEnum;
8756
8799
  exports.AppSearchBackendEnum = AppSearchBackendEnum;