@stream-io/video-client 0.0.35 → 0.0.37

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.
@@ -70,9 +70,8 @@ export declare class StreamVideoClient {
70
70
  *
71
71
  * @param type the type of the call.
72
72
  * @param id the id of the call, if not provided a unique random value is used
73
- * @param {boolean} [ringing] whether the call should be created in the ringing state.
74
73
  */
75
- call: (type: string, id: string, ringing?: boolean) => Call;
74
+ call: (type: string, id: string) => Call;
76
75
  /**
77
76
  * Creates a new guest user with the given data.
78
77
  *
@@ -141,6 +140,12 @@ export declare class StreamVideoClient {
141
140
  * @return {string} Returns a token
142
141
  */
143
142
  createToken(userID: string, exp?: number, iat?: number, call_cids?: string[]): string;
143
+ /**
144
+ * A callback that can be used to create ringing calls from push notifications. If the call already exists, it will do nothing.
145
+ * @param call_cid
146
+ * @returns
147
+ */
148
+ onRingingCall: (call_cid: string) => Promise<Call>;
144
149
  /**
145
150
  * Connects the given anonymous user to the client.
146
151
  *
@@ -12,10 +12,10 @@ export interface APIError {
12
12
  StatusCode: number;
13
13
  /**
14
14
  * API error code
15
- * @type {string}
15
+ * @type {number}
16
16
  * @memberof APIError
17
17
  */
18
- code: APIErrorCodeEnum;
18
+ code: number;
19
19
  /**
20
20
  * Additional error-specific information
21
21
  * @type {Array<number>}
@@ -49,44 +49,6 @@ export interface APIError {
49
49
  */
50
50
  more_info: string;
51
51
  }
52
- /**
53
- * @export
54
- */
55
- export declare const APIErrorCodeEnum: {
56
- readonly INTERNAL_ERROR: "internal-error";
57
- readonly ACCESS_KEY_ERROR: "access-key-error";
58
- readonly INPUT_ERROR: "input-error";
59
- readonly AUTH_FAILED: "auth-failed";
60
- readonly DUPLICATE_USERNAME: "duplicate-username";
61
- readonly RATE_LIMITED: "rate-limited";
62
- readonly NOT_FOUND: "not-found";
63
- readonly NOT_ALLOWED: "not-allowed";
64
- readonly EVENT_NOT_SUPPORTED: "event-not-supported";
65
- readonly CHANNEL_FEATURE_NOT_SUPPORTED: "channel-feature-not-supported";
66
- readonly MESSAGE_TOO_LONG: "message-too-long";
67
- readonly MULTIPLE_NESTING_LEVEL: "multiple-nesting-level";
68
- readonly PAYLOAD_TOO_BIG: "payload-too-big";
69
- readonly EXPIRED_TOKEN: "expired-token";
70
- readonly TOKEN_NOT_VALID_YET: "token-not-valid-yet";
71
- readonly TOKEN_USED_BEFORE_IAT: "token-used-before-iat";
72
- readonly INVALID_TOKEN_SIGNATURE: "invalid-token-signature";
73
- readonly CUSTOM_COMMAND_ENDPOINT_MISSING: "custom-command-endpoint-missing";
74
- readonly CUSTOM_COMMAND_ENDPOINTCALL_ERROR: "custom-command-endpoint=call-error";
75
- readonly CONNECTION_ID_NOT_FOUND: "connection-id-not-found";
76
- readonly COOL_DOWN: "cool-down";
77
- readonly QUERY_CHANNEL_PERMISSIONS_MISMATCH: "query-channel-permissions-mismatch";
78
- readonly TOO_MANY_CONNECTIONS: "too-many-connections";
79
- readonly NOT_SUPPORTED_IN_PUSH_V1: "not-supported-in-push-v1";
80
- readonly MODERATION_FAILED: "moderation-failed";
81
- readonly VIDEO_PROVIDER_NOT_CONFIGURED: "video-provider-not-configured";
82
- readonly VIDEO_INVALID_CALL_ID: "video-invalid-call-id";
83
- readonly VIDEO_CREATE_CALL_FAILED: "video-create-call-failed";
84
- readonly APP_SUSPENDED: "app-suspended";
85
- readonly VIDEO_NO_DATACENTERS_AVAILABLE: "video-no-datacenters-available";
86
- readonly VIDEO_JOIN_CALL_FAILURE: "video-join-call-failure";
87
- readonly QUERY_CALLS_PERMISSIONS_MISMATCH: "query-calls-permissions-mismatch";
88
- };
89
- export type APIErrorCodeEnum = (typeof APIErrorCodeEnum)[keyof typeof APIErrorCodeEnum];
90
52
  /**
91
53
  *
92
54
  * @export
@@ -150,6 +112,12 @@ export interface AudioSettings {
150
112
  * @memberof AudioSettings
151
113
  */
152
114
  access_request_enabled: boolean;
115
+ /**
116
+ *
117
+ * @type {string}
118
+ * @memberof AudioSettings
119
+ */
120
+ default_device: AudioSettingsDefaultDeviceEnum;
153
121
  /**
154
122
  *
155
123
  * @type {boolean}
@@ -175,6 +143,13 @@ export interface AudioSettings {
175
143
  */
176
144
  speaker_default_on: boolean;
177
145
  }
146
+ /**
147
+ * @export
148
+ */
149
+ export declare const AudioSettingsDefaultDeviceEnum: {
150
+ readonly SPEAKER: "speaker";
151
+ };
152
+ export type AudioSettingsDefaultDeviceEnum = (typeof AudioSettingsDefaultDeviceEnum)[keyof typeof AudioSettingsDefaultDeviceEnum];
178
153
  /**
179
154
  *
180
155
  * @export
@@ -187,6 +162,12 @@ export interface AudioSettingsRequest {
187
162
  * @memberof AudioSettingsRequest
188
163
  */
189
164
  access_request_enabled?: boolean;
165
+ /**
166
+ *
167
+ * @type {string}
168
+ * @memberof AudioSettingsRequest
169
+ */
170
+ default_device: AudioSettingsRequestDefaultDeviceEnum;
190
171
  /**
191
172
  *
192
173
  * @type {boolean}
@@ -212,6 +193,13 @@ export interface AudioSettingsRequest {
212
193
  */
213
194
  speaker_default_on?: boolean;
214
195
  }
196
+ /**
197
+ * @export
198
+ */
199
+ export declare const AudioSettingsRequestDefaultDeviceEnum: {
200
+ readonly SPEAKER: "speaker";
201
+ };
202
+ export type AudioSettingsRequestDefaultDeviceEnum = (typeof AudioSettingsRequestDefaultDeviceEnum)[keyof typeof AudioSettingsRequestDefaultDeviceEnum];
215
203
  /**
216
204
  *
217
205
  * @export
@@ -1665,6 +1653,37 @@ export interface ConnectedEvent {
1665
1653
  */
1666
1654
  type: string;
1667
1655
  }
1656
+ /**
1657
+ * This event is sent when the WS connection fails
1658
+ * @export
1659
+ * @interface ConnectionErrorEvent
1660
+ */
1661
+ export interface ConnectionErrorEvent {
1662
+ /**
1663
+ *
1664
+ * @type {string}
1665
+ * @memberof ConnectionErrorEvent
1666
+ */
1667
+ connection_id: string;
1668
+ /**
1669
+ *
1670
+ * @type {string}
1671
+ * @memberof ConnectionErrorEvent
1672
+ */
1673
+ created_at: string;
1674
+ /**
1675
+ *
1676
+ * @type {APIError}
1677
+ * @memberof ConnectionErrorEvent
1678
+ */
1679
+ error: APIError | null;
1680
+ /**
1681
+ * The type of event: "connection.ok" in this case
1682
+ * @type {string}
1683
+ * @memberof ConnectionErrorEvent
1684
+ */
1685
+ type: string;
1686
+ }
1668
1687
  /**
1669
1688
  *
1670
1689
  * @export
@@ -2986,7 +3005,7 @@ export interface QueryCallsRequest {
2986
3005
  * @type {Array<SortParamRequest>}
2987
3006
  * @memberof QueryCallsRequest
2988
3007
  */
2989
- sort: Array<SortParamRequest>;
3008
+ sort?: Array<SortParamRequest>;
2990
3009
  /**
2991
3010
  *
2992
3011
  * @type {boolean}
@@ -3044,7 +3063,7 @@ export interface QueryMembersRequest {
3044
3063
  * @type {string}
3045
3064
  * @memberof QueryMembersRequest
3046
3065
  */
3047
- id?: string;
3066
+ id: string;
3048
3067
  /**
3049
3068
  *
3050
3069
  * @type {number}
@@ -3479,13 +3498,13 @@ export interface SendReactionResponse {
3479
3498
  */
3480
3499
  export interface SortParamRequest {
3481
3500
  /**
3482
- *
3501
+ * Direction of sorting, -1 for descending, 1 for ascending
3483
3502
  * @type {number}
3484
3503
  * @memberof SortParamRequest
3485
3504
  */
3486
3505
  direction?: number;
3487
3506
  /**
3488
- *
3507
+ * Name of field to sort by
3489
3508
  * @type {string}
3490
3509
  * @memberof SortParamRequest
3491
3510
  */
@@ -4185,6 +4204,8 @@ export type VideoEvent = ({
4185
4204
  } & CallUpdatedEvent) | ({
4186
4205
  type: 'call.user_muted';
4187
4206
  } & CallUserMuted) | ({
4207
+ type: 'connection.error';
4208
+ } & ConnectionErrorEvent) | ({
4188
4209
  type: 'connection.ok';
4189
4210
  } & ConnectedEvent) | ({
4190
4211
  type: 'custom';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -303,15 +303,13 @@ export class StreamVideoClient {
303
303
  *
304
304
  * @param type the type of the call.
305
305
  * @param id the id of the call, if not provided a unique random value is used
306
- * @param {boolean} [ringing] whether the call should be created in the ringing state.
307
306
  */
308
- call = (type: string, id: string, ringing?: boolean) => {
307
+ call = (type: string, id: string) => {
309
308
  return new Call({
310
309
  streamClient: this.streamClient,
311
310
  id: id,
312
311
  type: type,
313
312
  clientStore: this.writeableStateStore,
314
- ringing,
315
313
  });
316
314
  };
317
315
 
@@ -333,7 +331,6 @@ export class StreamVideoClient {
333
331
  * @param data the query data.
334
332
  */
335
333
  queryCalls = async (data: QueryCallsRequest) => {
336
- if (data.watch) await this.streamClient.connectionIdPromise;
337
334
  const response = await this.streamClient.post<
338
335
  QueryCallsResponse,
339
336
  QueryCallsRequest
@@ -485,6 +482,33 @@ export class StreamVideoClient {
485
482
  return this.streamClient.createToken(userID, exp, iat, call_cids);
486
483
  }
487
484
 
485
+ /**
486
+ * A callback that can be used to create ringing calls from push notifications. If the call already exists, it will do nothing.
487
+ * @param call_cid
488
+ * @returns
489
+ */
490
+ onRingingCall = async (call_cid: string) => {
491
+ // if we find the call and is already ringing, we don't need to create a new call
492
+ // as client would have received the call.ring state because the app had WS alive when receiving push notifications
493
+ let call = this.readOnlyStateStore.calls.find(
494
+ (c) => c.cid === call_cid && c.ringing,
495
+ );
496
+ if (!call) {
497
+ // if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
498
+ const [callType, callId] = call_cid.split(':');
499
+ call = new Call({
500
+ streamClient: this.streamClient,
501
+ type: callType,
502
+ id: callId,
503
+ clientStore: this.writeableStateStore,
504
+ ringing: true,
505
+ });
506
+ await call.get();
507
+ }
508
+
509
+ return call;
510
+ };
511
+
488
512
  /**
489
513
  * Connects the given anonymous user to the client.
490
514
  *
@@ -509,7 +509,10 @@ export class StreamClient {
509
509
  if (this.waitForConnectPromise) {
510
510
  await this.waitForConnectPromise;
511
511
  }
512
- await this.tokenManager.tokenReady();
512
+ await Promise.all([
513
+ this.tokenManager.tokenReady(),
514
+ this.connectionIdPromise,
515
+ ]);
513
516
  }
514
517
  const requestConfig = this._enrichAxiosOptions(options);
515
518
  try {
@@ -14,10 +14,10 @@ export interface APIError {
14
14
  StatusCode: number;
15
15
  /**
16
16
  * API error code
17
- * @type {string}
17
+ * @type {number}
18
18
  * @memberof APIError
19
19
  */
20
- code: APIErrorCodeEnum;
20
+ code: number;
21
21
  /**
22
22
  * Additional error-specific information
23
23
  * @type {Array<number>}
@@ -49,47 +49,6 @@ export interface APIError {
49
49
  */
50
50
  more_info: string;
51
51
  }
52
-
53
- /**
54
- * @export
55
- */
56
- export const APIErrorCodeEnum = {
57
- INTERNAL_ERROR: 'internal-error',
58
- ACCESS_KEY_ERROR: 'access-key-error',
59
- INPUT_ERROR: 'input-error',
60
- AUTH_FAILED: 'auth-failed',
61
- DUPLICATE_USERNAME: 'duplicate-username',
62
- RATE_LIMITED: 'rate-limited',
63
- NOT_FOUND: 'not-found',
64
- NOT_ALLOWED: 'not-allowed',
65
- EVENT_NOT_SUPPORTED: 'event-not-supported',
66
- CHANNEL_FEATURE_NOT_SUPPORTED: 'channel-feature-not-supported',
67
- MESSAGE_TOO_LONG: 'message-too-long',
68
- MULTIPLE_NESTING_LEVEL: 'multiple-nesting-level',
69
- PAYLOAD_TOO_BIG: 'payload-too-big',
70
- EXPIRED_TOKEN: 'expired-token',
71
- TOKEN_NOT_VALID_YET: 'token-not-valid-yet',
72
- TOKEN_USED_BEFORE_IAT: 'token-used-before-iat',
73
- INVALID_TOKEN_SIGNATURE: 'invalid-token-signature',
74
- CUSTOM_COMMAND_ENDPOINT_MISSING: 'custom-command-endpoint-missing',
75
- CUSTOM_COMMAND_ENDPOINTCALL_ERROR: 'custom-command-endpoint=call-error',
76
- CONNECTION_ID_NOT_FOUND: 'connection-id-not-found',
77
- COOL_DOWN: 'cool-down',
78
- QUERY_CHANNEL_PERMISSIONS_MISMATCH: 'query-channel-permissions-mismatch',
79
- TOO_MANY_CONNECTIONS: 'too-many-connections',
80
- NOT_SUPPORTED_IN_PUSH_V1: 'not-supported-in-push-v1',
81
- MODERATION_FAILED: 'moderation-failed',
82
- VIDEO_PROVIDER_NOT_CONFIGURED: 'video-provider-not-configured',
83
- VIDEO_INVALID_CALL_ID: 'video-invalid-call-id',
84
- VIDEO_CREATE_CALL_FAILED: 'video-create-call-failed',
85
- APP_SUSPENDED: 'app-suspended',
86
- VIDEO_NO_DATACENTERS_AVAILABLE: 'video-no-datacenters-available',
87
- VIDEO_JOIN_CALL_FAILURE: 'video-join-call-failure',
88
- QUERY_CALLS_PERMISSIONS_MISMATCH: 'query-calls-permissions-mismatch',
89
- } as const;
90
- export type APIErrorCodeEnum =
91
- (typeof APIErrorCodeEnum)[keyof typeof APIErrorCodeEnum];
92
-
93
52
  /**
94
53
  *
95
54
  * @export
@@ -153,6 +112,12 @@ export interface AudioSettings {
153
112
  * @memberof AudioSettings
154
113
  */
155
114
  access_request_enabled: boolean;
115
+ /**
116
+ *
117
+ * @type {string}
118
+ * @memberof AudioSettings
119
+ */
120
+ default_device: AudioSettingsDefaultDeviceEnum;
156
121
  /**
157
122
  *
158
123
  * @type {boolean}
@@ -178,6 +143,16 @@ export interface AudioSettings {
178
143
  */
179
144
  speaker_default_on: boolean;
180
145
  }
146
+
147
+ /**
148
+ * @export
149
+ */
150
+ export const AudioSettingsDefaultDeviceEnum = {
151
+ SPEAKER: 'speaker',
152
+ } as const;
153
+ export type AudioSettingsDefaultDeviceEnum =
154
+ (typeof AudioSettingsDefaultDeviceEnum)[keyof typeof AudioSettingsDefaultDeviceEnum];
155
+
181
156
  /**
182
157
  *
183
158
  * @export
@@ -190,6 +165,12 @@ export interface AudioSettingsRequest {
190
165
  * @memberof AudioSettingsRequest
191
166
  */
192
167
  access_request_enabled?: boolean;
168
+ /**
169
+ *
170
+ * @type {string}
171
+ * @memberof AudioSettingsRequest
172
+ */
173
+ default_device: AudioSettingsRequestDefaultDeviceEnum;
193
174
  /**
194
175
  *
195
176
  * @type {boolean}
@@ -215,6 +196,16 @@ export interface AudioSettingsRequest {
215
196
  */
216
197
  speaker_default_on?: boolean;
217
198
  }
199
+
200
+ /**
201
+ * @export
202
+ */
203
+ export const AudioSettingsRequestDefaultDeviceEnum = {
204
+ SPEAKER: 'speaker',
205
+ } as const;
206
+ export type AudioSettingsRequestDefaultDeviceEnum =
207
+ (typeof AudioSettingsRequestDefaultDeviceEnum)[keyof typeof AudioSettingsRequestDefaultDeviceEnum];
208
+
218
209
  /**
219
210
  *
220
211
  * @export
@@ -1650,6 +1641,37 @@ export interface ConnectedEvent {
1650
1641
  */
1651
1642
  type: string;
1652
1643
  }
1644
+ /**
1645
+ * This event is sent when the WS connection fails
1646
+ * @export
1647
+ * @interface ConnectionErrorEvent
1648
+ */
1649
+ export interface ConnectionErrorEvent {
1650
+ /**
1651
+ *
1652
+ * @type {string}
1653
+ * @memberof ConnectionErrorEvent
1654
+ */
1655
+ connection_id: string;
1656
+ /**
1657
+ *
1658
+ * @type {string}
1659
+ * @memberof ConnectionErrorEvent
1660
+ */
1661
+ created_at: string;
1662
+ /**
1663
+ *
1664
+ * @type {APIError}
1665
+ * @memberof ConnectionErrorEvent
1666
+ */
1667
+ error: APIError | null;
1668
+ /**
1669
+ * The type of event: "connection.ok" in this case
1670
+ * @type {string}
1671
+ * @memberof ConnectionErrorEvent
1672
+ */
1673
+ type: string;
1674
+ }
1653
1675
  /**
1654
1676
  *
1655
1677
  * @export
@@ -2958,7 +2980,7 @@ export interface QueryCallsRequest {
2958
2980
  * @type {Array<SortParamRequest>}
2959
2981
  * @memberof QueryCallsRequest
2960
2982
  */
2961
- sort: Array<SortParamRequest>;
2983
+ sort?: Array<SortParamRequest>;
2962
2984
  /**
2963
2985
  *
2964
2986
  * @type {boolean}
@@ -3014,7 +3036,7 @@ export interface QueryMembersRequest {
3014
3036
  * @type {string}
3015
3037
  * @memberof QueryMembersRequest
3016
3038
  */
3017
- id?: string;
3039
+ id: string;
3018
3040
  /**
3019
3041
  *
3020
3042
  * @type {number}
@@ -3453,13 +3475,13 @@ export interface SendReactionResponse {
3453
3475
  */
3454
3476
  export interface SortParamRequest {
3455
3477
  /**
3456
- *
3478
+ * Direction of sorting, -1 for descending, 1 for ascending
3457
3479
  * @type {number}
3458
3480
  * @memberof SortParamRequest
3459
3481
  */
3460
3482
  direction?: number;
3461
3483
  /**
3462
- *
3484
+ * Name of field to sort by
3463
3485
  * @type {string}
3464
3486
  * @memberof SortParamRequest
3465
3487
  */
@@ -4135,6 +4157,7 @@ export type VideoEvent =
4135
4157
  | ({ type: 'call.unblocked_user' } & UnblockedUserEvent)
4136
4158
  | ({ type: 'call.updated' } & CallUpdatedEvent)
4137
4159
  | ({ type: 'call.user_muted' } & CallUserMuted)
4160
+ | ({ type: 'connection.error' } & ConnectionErrorEvent)
4138
4161
  | ({ type: 'connection.ok' } & ConnectedEvent)
4139
4162
  | ({ type: 'custom' } & CustomVideoEvent)
4140
4163
  | ({ type: 'health.check' } & HealthCheckEvent);
@@ -27,8 +27,6 @@ export const join = async (
27
27
  id: string,
28
28
  data?: JoinCallData,
29
29
  ) => {
30
- await httpClient.connectionIdPromise;
31
-
32
30
  const joinCallResponse = await doJoin(httpClient, type, id, data);
33
31
  const { call, credentials, members, own_capabilities } = joinCallResponse;
34
32
  return {