stream-chat 8.54.1 → 8.56.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/browser.es.js +4048 -2245
- 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 +4057 -2244
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +4048 -2245
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4057 -2244
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_manager.d.ts +111 -0
- package/dist/types/channel_manager.d.ts.map +1 -0
- package/dist/types/client.d.ts +65 -2
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/insights.d.ts +2 -2
- package/dist/types/search_controller.d.ts +174 -0
- package/dist/types/search_controller.d.ts.map +1 -0
- package/dist/types/store.d.ts +3 -1
- package/dist/types/store.d.ts.map +1 -1
- package/dist/types/types.d.ts +11 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +118 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +6 -7
- package/src/channel_manager.ts +581 -0
- package/src/client.ts +27 -3
- package/src/index.ts +2 -0
- package/src/search_controller.ts +489 -0
- package/src/store.ts +4 -3
- package/src/types.ts +12 -0
- package/src/utils.ts +356 -0
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import FormData from 'form-data';
|
|
3
|
-
import { AscDesc, ExtendableGenerics, DefaultGenerics, Logger, OwnUserResponse, UserResponse, MessageResponse, FormatMessageResponse, MessageSet, MessagePaginationOptions } from './types';
|
|
3
|
+
import { AscDesc, ExtendableGenerics, DefaultGenerics, Logger, OwnUserResponse, UserResponse, MessageResponse, FormatMessageResponse, MessageSet, MessagePaginationOptions, ChannelQueryOptions, ChannelSort, ChannelFilters, ChannelSortBase, PromoteChannelParams } from './types';
|
|
4
|
+
import { StreamChat } from './client';
|
|
5
|
+
import { Channel } from './channel';
|
|
4
6
|
import { AxiosRequestConfig } from 'axios';
|
|
5
7
|
/**
|
|
6
8
|
* logChatPromiseExecution - utility function for logging the execution of a promise..
|
|
@@ -86,6 +88,34 @@ export declare const findIndexInSortedArray: <T, L>({ needle, sortedArray, selec
|
|
|
86
88
|
sortDirection?: "ascending" | "descending" | undefined;
|
|
87
89
|
}) => number;
|
|
88
90
|
export declare function addToMessageList<T extends FormatMessageResponse>(messages: readonly T[], newMessage: T, timestampChanged?: boolean, sortBy?: 'pinned_at' | 'created_at', addIfDoesNotExist?: boolean): T[];
|
|
91
|
+
export interface DebouncedFunc<T extends (...args: any[]) => any> {
|
|
92
|
+
/**
|
|
93
|
+
* Call the original function, but applying the debounce rules.
|
|
94
|
+
*
|
|
95
|
+
* If the debounced function can be run immediately, this calls it and returns its return
|
|
96
|
+
* value.
|
|
97
|
+
*
|
|
98
|
+
* Otherwise, it returns the return value of the last invocation, or undefined if the debounced
|
|
99
|
+
* function was not invoked yet.
|
|
100
|
+
*/
|
|
101
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Throw away any pending invocation of the debounced function.
|
|
104
|
+
*/
|
|
105
|
+
cancel(): void;
|
|
106
|
+
/**
|
|
107
|
+
* If there is a pending invocation of the debounced function, invoke it immediately and return
|
|
108
|
+
* its return value.
|
|
109
|
+
*
|
|
110
|
+
* Otherwise, return the value from the last invocation, or undefined if the debounced function
|
|
111
|
+
* was never invoked.
|
|
112
|
+
*/
|
|
113
|
+
flush(): ReturnType<T> | undefined;
|
|
114
|
+
}
|
|
115
|
+
export declare const debounce: <T extends (...args: any[]) => any>(fn: T, timeout?: number, { leading, trailing }?: {
|
|
116
|
+
leading?: boolean | undefined;
|
|
117
|
+
trailing?: boolean | undefined;
|
|
118
|
+
}) => DebouncedFunc<T>;
|
|
89
119
|
export declare const throttle: <T extends (...args: unknown[]) => unknown>(fn: T, timeout?: number, { leading, trailing }?: {
|
|
90
120
|
leading?: boolean | undefined;
|
|
91
121
|
trailing?: boolean | undefined;
|
|
@@ -104,5 +134,92 @@ export declare const messageSetPagination: <StreamChatGenerics extends Extendabl
|
|
|
104
134
|
hasNext: boolean;
|
|
105
135
|
hasPrev: boolean;
|
|
106
136
|
};
|
|
137
|
+
declare type GetChannelParams<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
138
|
+
client: StreamChat<StreamChatGenerics>;
|
|
139
|
+
channel?: Channel<StreamChatGenerics>;
|
|
140
|
+
id?: string;
|
|
141
|
+
members?: string[];
|
|
142
|
+
options?: ChannelQueryOptions<StreamChatGenerics>;
|
|
143
|
+
type?: string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
|
|
147
|
+
* If the channel is not passed as a property, it will get it either by its channel.cid or by its members list and do the same.
|
|
148
|
+
* @param client
|
|
149
|
+
* @param members
|
|
150
|
+
* @param options
|
|
151
|
+
* @param type
|
|
152
|
+
* @param id
|
|
153
|
+
* @param channel
|
|
154
|
+
*/
|
|
155
|
+
export declare const getAndWatchChannel: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>({ channel, client, id, members, options, type, }: GetChannelParams<StreamChatGenerics>) => Promise<Channel<StreamChatGenerics>>;
|
|
156
|
+
/**
|
|
157
|
+
* Generates a temporary channel.cid for channels created without ID, as they need to be referenced
|
|
158
|
+
* by an identifier until the back-end generates the final ID. The cid is generated by its member IDs
|
|
159
|
+
* which are sorted and can be recreated the same every time given the same arguments.
|
|
160
|
+
* @param channelType
|
|
161
|
+
* @param members
|
|
162
|
+
*/
|
|
163
|
+
export declare const generateChannelTempCid: (channelType: string, members: string[]) => string | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Checks if a channel is pinned or not. Will return true only if channel.state.membership.pinned_at exists.
|
|
166
|
+
* @param channel
|
|
167
|
+
*/
|
|
168
|
+
export declare const isChannelPinned: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>(channel: Channel<StreamChatGenerics>) => boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Checks if a channel is archived or not. Will return true only if channel.state.membership.archived_at exists.
|
|
171
|
+
* @param channel
|
|
172
|
+
*/
|
|
173
|
+
export declare const isChannelArchived: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>(channel: Channel<StreamChatGenerics>) => boolean;
|
|
174
|
+
/**
|
|
175
|
+
* A utility that tells us whether we should consider archived channels or not based
|
|
176
|
+
* on filters. Will return true only if filters.archived exists and is a boolean value.
|
|
177
|
+
* @param filters
|
|
178
|
+
*/
|
|
179
|
+
export declare const shouldConsiderArchivedChannels: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>(filters: ChannelFilters<StreamChatGenerics>) => boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Extracts the value of the sort parameter at a given index, for a targeted key. Can
|
|
182
|
+
* handle both array and object versions of sort. Will return null if the index/key
|
|
183
|
+
* combination does not exist.
|
|
184
|
+
* @param atIndex - the index at which we'll examine the sort value, if it's an array one
|
|
185
|
+
* @param sort - the sort value - both array and object notations are accepted
|
|
186
|
+
* @param targetKey - the target key which needs to exist for the sort at a certain index
|
|
187
|
+
*/
|
|
188
|
+
export declare const extractSortValue: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>({ atIndex, sort, targetKey, }: {
|
|
189
|
+
atIndex: number;
|
|
190
|
+
targetKey: "unread_count" | "created_at" | "pinned_at" | "updated_at" | "last_message_at" | "member_count" | keyof StreamChatGenerics["channelType"] | "has_unread" | "last_updated";
|
|
191
|
+
sort?: ChannelSort<StreamChatGenerics> | undefined;
|
|
192
|
+
}) => NonNullable<NonNullable<ChannelSortBase<StreamChatGenerics>>["unread_count" | "created_at" | "pinned_at" | "updated_at" | "last_message_at" | "member_count" | keyof StreamChatGenerics["channelType"] | "has_unread" | "last_updated"]> | null;
|
|
193
|
+
/**
|
|
194
|
+
* Returns true only if `{ pinned_at: -1 }` or `{ pinned_at: 1 }` option is first within the `sort` array.
|
|
195
|
+
*/
|
|
196
|
+
export declare const shouldConsiderPinnedChannels: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>(sort: ChannelSort<StreamChatGenerics>) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Checks whether the sort value of type object contains a pinned_at value or if
|
|
199
|
+
* an array sort value type has the first value be an object containing pinned_at.
|
|
200
|
+
* @param sort
|
|
201
|
+
*/
|
|
202
|
+
export declare const findPinnedAtSortOrder: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>({ sort, }: {
|
|
203
|
+
sort: ChannelSort<StreamChatGenerics>;
|
|
204
|
+
}) => NonNullable<NonNullable<ChannelSortBase<StreamChatGenerics>>["unread_count" | "created_at" | "pinned_at" | "updated_at" | "last_message_at" | "member_count" | "has_unread" | "last_updated" | keyof StreamChatGenerics["channelType"]]> | null;
|
|
205
|
+
/**
|
|
206
|
+
* Finds the index of the last consecutively pinned channel, starting from the start of the
|
|
207
|
+
* array. Will not consider any pinned channels after the contiguous subsequence at the
|
|
208
|
+
* start of the array.
|
|
209
|
+
* @param channels
|
|
210
|
+
*/
|
|
211
|
+
export declare const findLastPinnedChannelIndex: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>({ channels, }: {
|
|
212
|
+
channels: Channel<StreamChatGenerics>[];
|
|
213
|
+
}) => number | null;
|
|
214
|
+
/**
|
|
215
|
+
* A utility used to move a channel towards the beginning of a list of channels (promote it to a higher position). It
|
|
216
|
+
* considers pinned channels in the process if needed and makes sure to only update the list reference if the list
|
|
217
|
+
* should actually change. It will try to move the channel as high as it can within the list.
|
|
218
|
+
* @param channels - the list of channels we want to modify
|
|
219
|
+
* @param channelToMove - the channel we want to promote
|
|
220
|
+
* @param channelToMoveIndexWithinChannels - optionally, the index of the channel we want to move if we know it (will skip a manual check)
|
|
221
|
+
* @param sort - the sort value used to check for pinned channels
|
|
222
|
+
*/
|
|
223
|
+
export declare const promoteChannel: <StreamChatGenerics extends ExtendableGenerics = DefaultGenerics>({ channels, channelToMove, channelToMoveIndexWithinChannels, sort, }: PromoteChannelParams<StreamChatGenerics>) => Channel<StreamChatGenerics>[];
|
|
107
224
|
export {};
|
|
108
225
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,MAAM,EAEN,eAAe,EACf,YAAY,EACZ,eAAe,EACf,qBAAqB,EAErB,UAAU,EACV,wBAAwB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,MAAM,EAEN,eAAe,EACf,YAAY,EACZ,eAAe,EACf,qBAAqB,EAErB,UAAU,EACV,wBAAwB,EACxB,mBAAmB,EAEnB,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,QAI3E;AAED,eAAO,MAAM,KAAK,MAAO,MAAM,KAAG,QAAQ,IAAI,CAAyC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|
|
1
1
|
import { ChannelState } from './channel_state';
|
|
2
|
-
import { logChatPromiseExecution, messageSetPagination, normalizeQuerySort } from './utils';
|
|
2
|
+
import { generateChannelTempCid, logChatPromiseExecution, messageSetPagination, normalizeQuerySort } from './utils';
|
|
3
3
|
import { StreamChat } from './client';
|
|
4
4
|
import {
|
|
5
5
|
APIResponse,
|
|
@@ -1179,13 +1179,12 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
|
|
|
1179
1179
|
this.cid = state.channel.cid;
|
|
1180
1180
|
// set the channel as active...
|
|
1181
1181
|
|
|
1182
|
-
const
|
|
1183
|
-
.
|
|
1184
|
-
.
|
|
1185
|
-
|
|
1186
|
-
const tempChannelCid = `${this.type}:!members-${membersStr}`;
|
|
1182
|
+
const tempChannelCid = generateChannelTempCid(
|
|
1183
|
+
this.type,
|
|
1184
|
+
state.members.map((member) => member.user_id || member.user?.id || ''),
|
|
1185
|
+
);
|
|
1187
1186
|
|
|
1188
|
-
if (tempChannelCid in this.getClient().activeChannels) {
|
|
1187
|
+
if (tempChannelCid && tempChannelCid in this.getClient().activeChannels) {
|
|
1189
1188
|
// This gets set in `client.channel()` function, when channel is created
|
|
1190
1189
|
// using members, not id.
|
|
1191
1190
|
delete this.getClient().activeChannels[tempChannelCid];
|