stream-chat 9.48.0 → 9.49.0
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/cjs/index.browser.js +32 -25
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +32 -25
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +32 -25
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/client.d.ts +4 -2
- package/dist/types/types.d.ts +10 -0
- package/package.json +1 -1
- package/src/client.ts +46 -28
- package/src/types.ts +8 -0
package/dist/types/client.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { WSConnectionFallback } from './connection_fallback';
|
|
|
8
8
|
import { Campaign } from './campaign';
|
|
9
9
|
import { ChannelBatchUpdater } from './channel_batch_updater';
|
|
10
10
|
import { Segment } from './segment';
|
|
11
|
-
import type { ActiveLiveLocationsAPIResponse, AddUserGroupMembersOptions, AddUserGroupMembersResponse, APIErrorResponse, APIResponse, AppSettings, AppSettingsAPIResponse, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BaseDeviceFields, BlockList, BlockListResponse, BlockUserAPIResponse, CampaignData, CampaignFilters, CampaignQueryOptions, CampaignResponse, CampaignSort, CastVoteAPIResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelResponse, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSNSResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CreateImportOptions, CreateImportResponse, CreateImportURLResponse, CreatePollAPIResponse, CreatePollData, CreatePollOptionAPIResponse, CreatePredefinedFilterOptions, CreateReminderOptions, CreateRoleAPIResponse, CreateUserGroupOptions, CreateUserGroupResponse, CustomPermissionOptions, DeactivateUsersOptions, DeleteCommandResponse, DeleteMessageOptions, DeleteUserGroupOptions, DeleteUserOptions, Device, DeviceIdentifier, DraftFilters, DraftSort, EndpointName, Event, EventAPIResponse, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, FutureChannelBansResponse, GetBlockedUsersAPIResponse, GetCampaignOptions, GetChannelTypeResponse, GetCommandResponse, GetHookEventsResponse, GetImportResponse, GetMessageOptions, GetPollAPIResponse, GetRateLimitsResponse, GetRetentionPolicyResponse, GetRetentionPolicyRunsOptions, GetRetentionPolicyRunsResponse, GetThreadAPIResponse, GetThreadOptions, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, GetUserGroupOptions, GetUserGroupResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, ListPredefinedFiltersOptions, ListPredefinedFiltersResponse, ListRolesAPIResponse, LocalMessage, Logger, MarkChannelsReadOptions, MarkDeliveredOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, Pager, PartialMessageUpdate, PartialPollUpdate, PartialThreadUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PollAnswersAPIResponse, PollData, PollOptionData, PollSort, PollVote, PollVoteData, PollVotesAPIResponse, PredefinedFilterResponse, Product, PushPreference, PushProvider, PushProviderConfig, PushProviderID, PushProviderListResponse, PushProviderUpsertResponse, QueryChannelsAPIResponse, QueryDraftsResponse, QueryFutureChannelBansOptions, QueryMessageHistoryFilters, QueryMessageHistoryOptions, QueryMessageHistoryResponse, QueryMessageHistorySort, QueryPollsFilters, QueryPollsOptions, QueryPollsResponse, QueryReactionsAPIResponse, QueryReactionsOptions, QueryRemindersOptions, QueryRemindersResponse, QuerySegmentsOptions, QuerySegmentTargetsFilter, QueryTeamUsageStatsOptions, QueryTeamUsageStatsResponse, QueryThreadsOptions, QueryUserGroupsOptions, QueryUserGroupsResponse, QueryVotesFilters, QueryVotesOptions, ReactionFilters, ReactionResponse, ReactionSort, ReactivateUserOptions, ReactivateUsersOptions, ReminderAPIResponse, RemoveUserGroupMembersOptions, RemoveUserGroupMembersResponse, ReviewFlagReportOptions, ReviewFlagReportResponse, SdkIdentifier, SearchAPIResponse, SearchOptions, SearchRolesAPIResponse, SearchRolesOptions, SearchUserGroupsOptions, SearchUserGroupsResponse, SegmentData, SegmentResponse, SegmentTargetsResponse, SegmentType, SendFileAPIResponse, SetRetentionPolicyResponse, SharedLocationResponse, SortParam, StreamChatOptions, SyncOptions, SyncResponse, TaskResponse, TaskStatus, TestPushDataInput, TestSNSDataInput, TestSQSDataInput, TokenOrProvider, TranslateResponse, UnBanUserOptions, UpdateChannelsBatchOptions, UpdateChannelTypeRequest, UpdateChannelTypeResponse, UpdateCommandOptions, UpdateCommandResponse, UpdateLocationPayload, UpdateMessageAPIResponse, UpdateMessageOptions, UpdatePollAPIResponse, UpdatePredefinedFilterOptions, UpdateReminderOptions, UpdateSegmentData, UpdateUserGroupOptions, UpdateUserGroupResponse, UpdateUsersAPIResponse, UpsertPushPreferencesResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, VoteSort } from './types';
|
|
11
|
+
import type { ActiveLiveLocationsAPIResponse, AddUserGroupMembersOptions, AddUserGroupMembersResponse, APIErrorResponse, APIResponse, AppIdentifier, AppSettings, AppSettingsAPIResponse, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BaseDeviceFields, BlockList, BlockListResponse, BlockUserAPIResponse, CampaignData, CampaignFilters, CampaignQueryOptions, CampaignResponse, CampaignSort, CastVoteAPIResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelResponse, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSNSResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CreateImportOptions, CreateImportResponse, CreateImportURLResponse, CreatePollAPIResponse, CreatePollData, CreatePollOptionAPIResponse, CreatePredefinedFilterOptions, CreateReminderOptions, CreateRoleAPIResponse, CreateUserGroupOptions, CreateUserGroupResponse, CustomPermissionOptions, DeactivateUsersOptions, DeleteCommandResponse, DeleteMessageOptions, DeleteUserGroupOptions, DeleteUserOptions, Device, DeviceIdentifier, DraftFilters, DraftSort, EndpointName, Event, EventAPIResponse, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, FutureChannelBansResponse, GetBlockedUsersAPIResponse, GetCampaignOptions, GetChannelTypeResponse, GetCommandResponse, GetHookEventsResponse, GetImportResponse, GetMessageOptions, GetPollAPIResponse, GetRateLimitsResponse, GetRetentionPolicyResponse, GetRetentionPolicyRunsOptions, GetRetentionPolicyRunsResponse, GetThreadAPIResponse, GetThreadOptions, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, GetUserGroupOptions, GetUserGroupResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, ListPredefinedFiltersOptions, ListPredefinedFiltersResponse, ListRolesAPIResponse, LocalMessage, Logger, MarkChannelsReadOptions, MarkDeliveredOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, Pager, PartialMessageUpdate, PartialPollUpdate, PartialThreadUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PollAnswersAPIResponse, PollData, PollOptionData, PollSort, PollVote, PollVoteData, PollVotesAPIResponse, PredefinedFilterResponse, Product, PushPreference, PushProvider, PushProviderConfig, PushProviderID, PushProviderListResponse, PushProviderUpsertResponse, QueryChannelsAPIResponse, QueryDraftsResponse, QueryFutureChannelBansOptions, QueryMessageHistoryFilters, QueryMessageHistoryOptions, QueryMessageHistoryResponse, QueryMessageHistorySort, QueryPollsFilters, QueryPollsOptions, QueryPollsResponse, QueryReactionsAPIResponse, QueryReactionsOptions, QueryRemindersOptions, QueryRemindersResponse, QuerySegmentsOptions, QuerySegmentTargetsFilter, QueryTeamUsageStatsOptions, QueryTeamUsageStatsResponse, QueryThreadsOptions, QueryUserGroupsOptions, QueryUserGroupsResponse, QueryVotesFilters, QueryVotesOptions, ReactionFilters, ReactionResponse, ReactionSort, ReactivateUserOptions, ReactivateUsersOptions, ReminderAPIResponse, RemoveUserGroupMembersOptions, RemoveUserGroupMembersResponse, ReviewFlagReportOptions, ReviewFlagReportResponse, SdkIdentifier, SearchAPIResponse, SearchOptions, SearchRolesAPIResponse, SearchRolesOptions, SearchUserGroupsOptions, SearchUserGroupsResponse, SegmentData, SegmentResponse, SegmentTargetsResponse, SegmentType, SendFileAPIResponse, SetRetentionPolicyResponse, SharedLocationResponse, SortParam, StreamChatOptions, SyncOptions, SyncResponse, TaskResponse, TaskStatus, TestPushDataInput, TestSNSDataInput, TestSQSDataInput, TokenOrProvider, TranslateResponse, UnBanUserOptions, UpdateChannelsBatchOptions, UpdateChannelTypeRequest, UpdateChannelTypeResponse, UpdateCommandOptions, UpdateCommandResponse, UpdateLocationPayload, UpdateMessageAPIResponse, UpdateMessageOptions, UpdatePollAPIResponse, UpdatePredefinedFilterOptions, UpdateReminderOptions, UpdateSegmentData, UpdateUserGroupOptions, UpdateUserGroupResponse, UpdateUsersAPIResponse, UpsertPushPreferencesResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, VoteSort } from './types';
|
|
12
12
|
import { ErrorFromResponse } from './types';
|
|
13
13
|
import { InsightMetrics } from './insights';
|
|
14
14
|
import { Thread } from './thread';
|
|
@@ -111,6 +111,8 @@ export declare class StreamChat {
|
|
|
111
111
|
defaultWSTimeout: number;
|
|
112
112
|
sdkIdentifier?: SdkIdentifier;
|
|
113
113
|
deviceIdentifier?: DeviceIdentifier;
|
|
114
|
+
appIdentifier?: AppIdentifier;
|
|
115
|
+
private cachedUserAgent?;
|
|
114
116
|
readonly messageComposerCache: FixedSizeQueueCache<string, MessageComposer>;
|
|
115
117
|
private nextRequestAbortController;
|
|
116
118
|
/**
|
|
@@ -1319,7 +1321,7 @@ export declare class StreamChat {
|
|
|
1319
1321
|
* @returns {GetThreadAPIResponse} Returns the updated thread.
|
|
1320
1322
|
*/
|
|
1321
1323
|
partialUpdateThread(messageId: string, partialThreadObject: PartialThreadUpdate): Promise<GetThreadAPIResponse>;
|
|
1322
|
-
getUserAgent()
|
|
1324
|
+
getUserAgent: () => string;
|
|
1323
1325
|
/**
|
|
1324
1326
|
* @deprecated use sdkIdentifier instead
|
|
1325
1327
|
* @param userAgent
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3389,6 +3389,16 @@ export type DeviceIdentifier = {
|
|
|
3389
3389
|
os: string;
|
|
3390
3390
|
model?: string;
|
|
3391
3391
|
};
|
|
3392
|
+
/**
|
|
3393
|
+
* An identifier containing information about the downstream application integrating
|
|
3394
|
+
* stream-chat, if available. `name` is reported as `app` and `version` as `app_version`
|
|
3395
|
+
* in the user agent. Distinct from the SDK ({@link SdkIdentifier}) and device
|
|
3396
|
+
* ({@link DeviceIdentifier}) identifiers.
|
|
3397
|
+
*/
|
|
3398
|
+
export type AppIdentifier = {
|
|
3399
|
+
name: string;
|
|
3400
|
+
version?: string;
|
|
3401
|
+
};
|
|
3392
3402
|
export type DraftResponse = {
|
|
3393
3403
|
channel_cid: string;
|
|
3394
3404
|
created_at: string;
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -46,6 +46,7 @@ import type {
|
|
|
46
46
|
AddUserGroupMembersResponse,
|
|
47
47
|
APIErrorResponse,
|
|
48
48
|
APIResponse,
|
|
49
|
+
AppIdentifier,
|
|
49
50
|
AppSettings,
|
|
50
51
|
AppSettingsAPIResponse,
|
|
51
52
|
BannedUsersFilters,
|
|
@@ -394,6 +395,8 @@ export class StreamChat {
|
|
|
394
395
|
defaultWSTimeout: number;
|
|
395
396
|
sdkIdentifier?: SdkIdentifier;
|
|
396
397
|
deviceIdentifier?: DeviceIdentifier;
|
|
398
|
+
appIdentifier?: AppIdentifier;
|
|
399
|
+
private cachedUserAgent?: string;
|
|
397
400
|
readonly messageComposerCache: FixedSizeQueueCache<string, MessageComposer>;
|
|
398
401
|
private nextRequestAbortController: AbortController | null = null;
|
|
399
402
|
/**
|
|
@@ -1641,6 +1644,19 @@ export class StreamChat {
|
|
|
1641
1644
|
});
|
|
1642
1645
|
}
|
|
1643
1646
|
|
|
1647
|
+
// Current user removed from a channel: evict it like channel.deleted so
|
|
1648
|
+
// recoverState won't re-watch it and no further events reach it (#2599).
|
|
1649
|
+
// Type-agnostic. We skip deleteAllChannelReference (unlike deletion) since
|
|
1650
|
+
// the channel still exists for its remaining members.
|
|
1651
|
+
if (event.type === 'notification.removed_from_channel' && event.cid) {
|
|
1652
|
+
const { cid } = event;
|
|
1653
|
+
this.activeChannels[cid]?._disconnect();
|
|
1654
|
+
|
|
1655
|
+
postListenerCallbacks.push(() => {
|
|
1656
|
+
delete this.activeChannels[cid];
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1644
1660
|
return postListenerCallbacks;
|
|
1645
1661
|
}
|
|
1646
1662
|
|
|
@@ -3709,40 +3725,42 @@ export class StreamChat {
|
|
|
3709
3725
|
);
|
|
3710
3726
|
}
|
|
3711
3727
|
|
|
3712
|
-
getUserAgent() {
|
|
3728
|
+
getUserAgent = (): string => {
|
|
3729
|
+
// An explicit override (deprecated `setUserAgent`) always wins and is never cached.
|
|
3713
3730
|
if (this.userAgent) {
|
|
3714
3731
|
return this.userAgent;
|
|
3715
3732
|
}
|
|
3716
3733
|
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3734
|
+
// Computed once, then memoized for the client's lifetime - inputs read on
|
|
3735
|
+
// the first call (sdk/device identifiers, build-time env) are not re-read.
|
|
3736
|
+
if (!this.cachedUserAgent) {
|
|
3737
|
+
const version = process.env.PKG_VERSION;
|
|
3738
|
+
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
3739
|
+
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
3740
|
+
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
3741
|
+
|
|
3742
|
+
const head = sdkName
|
|
3743
|
+
? `stream-chat-${sdkName}-v${sdkVersion}-llc-v${version}`
|
|
3744
|
+
: `stream-chat-js-v${version}-${this.node ? 'node' : 'browser'}`;
|
|
3745
|
+
|
|
3746
|
+
this.cachedUserAgent = [
|
|
3747
|
+
head,
|
|
3748
|
+
// reports the host app, the device OS, the device model, and the picked
|
|
3749
|
+
// exports bundle, each only when a value is present
|
|
3750
|
+
...Object.entries({
|
|
3751
|
+
app: appName,
|
|
3752
|
+
app_version: appVersion,
|
|
3753
|
+
os,
|
|
3754
|
+
device_model: deviceModel,
|
|
3755
|
+
client_bundle: process.env.CLIENT_BUNDLE,
|
|
3756
|
+
})
|
|
3757
|
+
.filter(([, value]) => value && value.length > 0)
|
|
3758
|
+
.map(([key, value]) => `${key}=${value}`),
|
|
3759
|
+
].join('|');
|
|
3725
3760
|
}
|
|
3726
3761
|
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
return (
|
|
3730
|
-
[
|
|
3731
|
-
// reports the device OS, if provided
|
|
3732
|
-
['os', os],
|
|
3733
|
-
// reports the device model, if provided
|
|
3734
|
-
['device_model', model],
|
|
3735
|
-
// reports which bundle is being picked from the exports
|
|
3736
|
-
['client_bundle', clientBundle],
|
|
3737
|
-
] as const
|
|
3738
|
-
).reduce(
|
|
3739
|
-
(withArguments, [key, value]) =>
|
|
3740
|
-
value && value.length > 0
|
|
3741
|
-
? withArguments.concat(`|${key}=${value}`)
|
|
3742
|
-
: withArguments,
|
|
3743
|
-
userAgentString,
|
|
3744
|
-
);
|
|
3745
|
-
}
|
|
3762
|
+
return this.cachedUserAgent;
|
|
3763
|
+
};
|
|
3746
3764
|
|
|
3747
3765
|
/**
|
|
3748
3766
|
* @deprecated use sdkIdentifier instead
|
package/src/types.ts
CHANGED
|
@@ -4537,6 +4537,14 @@ export type SdkIdentifier = {
|
|
|
4537
4537
|
*/
|
|
4538
4538
|
export type DeviceIdentifier = { os: string; model?: string };
|
|
4539
4539
|
|
|
4540
|
+
/**
|
|
4541
|
+
* An identifier containing information about the downstream application integrating
|
|
4542
|
+
* stream-chat, if available. `name` is reported as `app` and `version` as `app_version`
|
|
4543
|
+
* in the user agent. Distinct from the SDK ({@link SdkIdentifier}) and device
|
|
4544
|
+
* ({@link DeviceIdentifier}) identifiers.
|
|
4545
|
+
*/
|
|
4546
|
+
export type AppIdentifier = { name: string; version?: string };
|
|
4547
|
+
|
|
4540
4548
|
export type DraftResponse = {
|
|
4541
4549
|
channel_cid: string;
|
|
4542
4550
|
created_at: string;
|