stream-chat 6.7.0 → 6.7.1
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/browser.es.js +409 -318
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +409 -318
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +409 -318
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +409 -318
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts +8 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +1 -0
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +11 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/types.d.ts +46 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +24 -1
- package/src/channel_state.ts +2 -2
- package/src/client.ts +12 -0
- package/src/types.ts +54 -0
package/src/channel.ts
CHANGED
|
@@ -50,6 +50,8 @@ import {
|
|
|
50
50
|
PinnedMessagePaginationOptions,
|
|
51
51
|
PinnedMessagesSort,
|
|
52
52
|
MessagePaginationOptions,
|
|
53
|
+
CreateCallOptions,
|
|
54
|
+
CreateCallResponse,
|
|
53
55
|
} from './types';
|
|
54
56
|
import { Role } from './permissions';
|
|
55
57
|
|
|
@@ -1077,6 +1079,16 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
1077
1079
|
});
|
|
1078
1080
|
}
|
|
1079
1081
|
|
|
1082
|
+
/**
|
|
1083
|
+
* createCall - creates a call for the current channel
|
|
1084
|
+
*
|
|
1085
|
+
* @param {CreateCallOptions} options
|
|
1086
|
+
* @returns {Promise<CreateCallResponse>}
|
|
1087
|
+
*/
|
|
1088
|
+
async createCall(options: CreateCallOptions) {
|
|
1089
|
+
return await this.getClient().post<CreateCallResponse>(this._channelURL() + '/call', options);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1080
1092
|
/**
|
|
1081
1093
|
* on - Listen to events on this channel.
|
|
1082
1094
|
*
|
|
@@ -1245,7 +1257,18 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
1245
1257
|
}
|
|
1246
1258
|
break;
|
|
1247
1259
|
case 'channel.truncated':
|
|
1248
|
-
|
|
1260
|
+
if (event.channel?.truncated_at) {
|
|
1261
|
+
const truncatedAt = +new Date(event.channel.truncated_at);
|
|
1262
|
+
|
|
1263
|
+
channelState.messageSets.forEach((messageSet, messageSetIndex) => {
|
|
1264
|
+
messageSet.messages.forEach(({ created_at: createdAt, id }) => {
|
|
1265
|
+
if (truncatedAt > +createdAt) channelState.removeMessage({ id, messageSetIndex });
|
|
1266
|
+
});
|
|
1267
|
+
});
|
|
1268
|
+
} else {
|
|
1269
|
+
channelState.clearMessages();
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1249
1272
|
channelState.unreadCount = 0;
|
|
1250
1273
|
// system messages don't increment unread counts
|
|
1251
1274
|
if (event.message) {
|
package/src/channel_state.ts
CHANGED
|
@@ -495,7 +495,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
|
|
|
495
495
|
*
|
|
496
496
|
* @return {boolean} Returns if the message was removed
|
|
497
497
|
*/
|
|
498
|
-
removeMessage(messageToRemove: { id: string; parent_id?: string }) {
|
|
498
|
+
removeMessage(messageToRemove: { id: string; messageSetIndex?: number; parent_id?: string }) {
|
|
499
499
|
let isRemoved = false;
|
|
500
500
|
if (messageToRemove.parent_id && this.threads[messageToRemove.parent_id]) {
|
|
501
501
|
const { removed, result: threadMessages } = this.removeMessageFromArray(
|
|
@@ -506,7 +506,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
|
|
|
506
506
|
this.threads[messageToRemove.parent_id] = threadMessages;
|
|
507
507
|
isRemoved = removed;
|
|
508
508
|
} else {
|
|
509
|
-
const messageSetIndex = this.findMessageSetIndex(messageToRemove);
|
|
509
|
+
const messageSetIndex = messageToRemove.messageSetIndex ?? this.findMessageSetIndex(messageToRemove);
|
|
510
510
|
if (messageSetIndex !== -1) {
|
|
511
511
|
const { removed, result: messages } = this.removeMessageFromArray(
|
|
512
512
|
this.messageSets[messageSetIndex].messages,
|
package/src/client.ts
CHANGED
|
@@ -141,6 +141,7 @@ import {
|
|
|
141
141
|
FlagsPaginationOptions,
|
|
142
142
|
FlagsResponse,
|
|
143
143
|
TestCampaignResponse,
|
|
144
|
+
GetCallTokenResponse,
|
|
144
145
|
APIErrorResponse,
|
|
145
146
|
ErrorFromResponse,
|
|
146
147
|
} from './types';
|
|
@@ -2047,6 +2048,17 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
2047
2048
|
});
|
|
2048
2049
|
}
|
|
2049
2050
|
|
|
2051
|
+
/**
|
|
2052
|
+
* getCallToken - retrieves the auth token needed to join a call
|
|
2053
|
+
*
|
|
2054
|
+
* @param {string} callID
|
|
2055
|
+
* @param {object} options
|
|
2056
|
+
* @returns {Promise<GetCallTokenResponse>}
|
|
2057
|
+
*/
|
|
2058
|
+
async getCallToken(callID: string, options: { user_id?: string } = {}) {
|
|
2059
|
+
return await this.post<GetCallTokenResponse>(this.baseURL + `/calls/${callID}`, { ...options });
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2050
2062
|
/**
|
|
2051
2063
|
* _queryFlags - Query flags.
|
|
2052
2064
|
*
|
package/src/types.ts
CHANGED
|
@@ -1437,7 +1437,23 @@ export type APNConfig = {
|
|
|
1437
1437
|
team_id?: string;
|
|
1438
1438
|
};
|
|
1439
1439
|
|
|
1440
|
+
export type AgoraOptions = {
|
|
1441
|
+
app_certificate: string;
|
|
1442
|
+
app_id: string;
|
|
1443
|
+
role_map?: Record<string, string>;
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
export type HMSOptions = {
|
|
1447
|
+
app_access_key: string;
|
|
1448
|
+
app_secret: string;
|
|
1449
|
+
default_role: string;
|
|
1450
|
+
default_room_template: string;
|
|
1451
|
+
default_region?: string;
|
|
1452
|
+
role_map?: Record<string, string>;
|
|
1453
|
+
};
|
|
1454
|
+
|
|
1440
1455
|
export type AppSettings = {
|
|
1456
|
+
agora_options?: AgoraOptions | null;
|
|
1441
1457
|
apn_config?: {
|
|
1442
1458
|
auth_key?: string;
|
|
1443
1459
|
auth_type?: string;
|
|
@@ -1465,6 +1481,7 @@ export type AppSettings = {
|
|
|
1465
1481
|
server_key?: string;
|
|
1466
1482
|
};
|
|
1467
1483
|
grants?: Record<string, string[]>;
|
|
1484
|
+
hms_options?: HMSOptions | null;
|
|
1468
1485
|
huawei_config?: {
|
|
1469
1486
|
id: string;
|
|
1470
1487
|
secret: string;
|
|
@@ -1483,6 +1500,7 @@ export type AppSettings = {
|
|
|
1483
1500
|
sqs_key?: string;
|
|
1484
1501
|
sqs_secret?: string;
|
|
1485
1502
|
sqs_url?: string;
|
|
1503
|
+
video_provider?: string;
|
|
1486
1504
|
webhook_events?: Array<string> | null;
|
|
1487
1505
|
webhook_url?: string;
|
|
1488
1506
|
xiaomi_config?: {
|
|
@@ -2325,6 +2343,42 @@ export type PushProviderListResponse = {
|
|
|
2325
2343
|
push_providers: PushProvider[];
|
|
2326
2344
|
};
|
|
2327
2345
|
|
|
2346
|
+
export type CreateCallOptions<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
2347
|
+
id: String;
|
|
2348
|
+
type: String;
|
|
2349
|
+
options?: Object;
|
|
2350
|
+
user?: UserResponse<StreamChatGenerics> | null;
|
|
2351
|
+
user_id?: string;
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
export type HMSCall = {
|
|
2355
|
+
room: String;
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
export type AgoraCall = {
|
|
2359
|
+
channel: String;
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
export type Call = {
|
|
2363
|
+
id: String;
|
|
2364
|
+
provider: String;
|
|
2365
|
+
agora?: AgoraCall;
|
|
2366
|
+
hms?: HMSCall;
|
|
2367
|
+
};
|
|
2368
|
+
|
|
2369
|
+
export type CreateCallResponse = APIResponse & {
|
|
2370
|
+
call: Call;
|
|
2371
|
+
token: String;
|
|
2372
|
+
agora_app_id?: String;
|
|
2373
|
+
agora_uid?: number;
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
export type GetCallTokenResponse = APIResponse & {
|
|
2377
|
+
token: String;
|
|
2378
|
+
agora_app_id?: String;
|
|
2379
|
+
agora_uid?: number;
|
|
2380
|
+
};
|
|
2381
|
+
|
|
2328
2382
|
type ErrorResponseDetails = {
|
|
2329
2383
|
code: number;
|
|
2330
2384
|
messages: string[];
|