stream-chat 9.50.3 → 10.0.0-rc.2

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.
Files changed (242) hide show
  1. package/dist/cjs/index.browser.js +19798 -14472
  2. package/dist/cjs/index.browser.js.map +4 -4
  3. package/dist/cjs/index.node.js +19817 -14482
  4. package/dist/cjs/index.node.js.map +4 -4
  5. package/dist/esm/index.mjs +19795 -14469
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +221 -0
  8. package/dist/types/EventHandlerPipeline.d.ts +104 -0
  9. package/dist/types/api-client.d.ts +26 -0
  10. package/dist/types/campaign.d.ts +0 -44
  11. package/dist/types/channel.d.ts +454 -479
  12. package/dist/types/channel_batch_updater.d.ts +0 -93
  13. package/dist/types/channel_state.d.ts +53 -201
  14. package/dist/types/client.d.ts +451 -1920
  15. package/dist/types/client_state.d.ts +4 -4
  16. package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
  17. package/dist/types/configuration/index.d.ts +1 -0
  18. package/dist/types/configuration/types.d.ts +53 -0
  19. package/dist/types/connection.d.ts +49 -41
  20. package/dist/types/connection_fallback.d.ts +6 -4
  21. package/dist/types/constants.d.ts +0 -4
  22. package/dist/types/custom_types.d.ts +2 -0
  23. package/dist/types/entityStore/EntityStore.d.ts +111 -0
  24. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +60 -0
  25. package/dist/types/entityStore/applyReactionLocally.d.ts +26 -0
  26. package/dist/types/entityStore/index.d.ts +2 -0
  27. package/dist/types/errors.d.ts +10 -2
  28. package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
  29. package/dist/types/gen/chat/ChatApi.d.ts +334 -0
  30. package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
  31. package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
  32. package/dist/types/gen/models/index.d.ts +8836 -0
  33. package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
  34. package/dist/types/gen-imports.d.ts +3 -0
  35. package/dist/types/index.d.ts +8 -7
  36. package/dist/types/insights.d.ts +9 -8
  37. package/dist/types/logger.d.ts +9 -0
  38. package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
  39. package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
  40. package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
  41. package/dist/types/messageComposer/configuration/types.d.ts +11 -11
  42. package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
  43. package/dist/types/messageComposer/messageComposer.d.ts +10 -10
  44. package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
  45. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
  46. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
  47. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
  48. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
  49. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
  50. package/dist/types/messageComposer/pollComposer.d.ts +5 -4
  51. package/dist/types/messageComposer/textComposer.d.ts +8 -3
  52. package/dist/types/messageComposer/types.d.ts +6 -28
  53. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
  54. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
  55. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
  56. package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
  57. package/dist/types/messageOperations/index.d.ts +3 -0
  58. package/dist/types/messageOperations/types.d.ts +49 -0
  59. package/dist/types/moderation.d.ts +21 -203
  60. package/dist/types/notifications/types.d.ts +8 -7
  61. package/dist/types/offline-support/offline_support_api.d.ts +111 -87
  62. package/dist/types/offline-support/offline_sync_manager.d.ts +0 -7
  63. package/dist/types/offline-support/types.d.ts +19 -23
  64. package/dist/types/offline-support/util.d.ts +4 -2
  65. package/dist/types/pagination/FilterBuilder.d.ts +1 -1
  66. package/dist/types/pagination/ItemIndex.d.ts +25 -0
  67. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
  68. package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
  69. package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
  70. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
  71. package/dist/types/pagination/filterCompiler.d.ts +7 -0
  72. package/dist/types/pagination/index.d.ts +1 -3
  73. package/dist/types/pagination/paginators/BasePaginator.d.ts +848 -0
  74. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +212 -0
  75. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +282 -0
  76. package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
  77. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
  78. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
  79. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
  80. package/dist/types/pagination/paginators/index.d.ts +7 -0
  81. package/dist/types/pagination/paginators/stateThrottling.d.ts +2 -0
  82. package/dist/types/pagination/sortCompiler.d.ts +49 -0
  83. package/dist/types/pagination/types.normalization.d.ts +11 -0
  84. package/dist/types/pagination/utility.normalization.d.ts +18 -0
  85. package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
  86. package/dist/types/pagination/utility.search.d.ts +13 -0
  87. package/dist/types/permissions.d.ts +1 -1
  88. package/dist/types/poll.d.ts +29 -32
  89. package/dist/types/poll_manager.d.ts +2 -2
  90. package/dist/types/reminders/Reminder.d.ts +2 -5
  91. package/dist/types/reminders/ReminderManager.d.ts +2 -9
  92. package/dist/types/search/MessageSearchSource.d.ts +4 -4
  93. package/dist/types/search/UserSearchSource.d.ts +1 -1
  94. package/dist/types/search/types.d.ts +3 -3
  95. package/dist/types/segment.d.ts +0 -34
  96. package/dist/types/signing.d.ts +105 -65
  97. package/dist/types/store.d.ts +1 -0
  98. package/dist/types/thread.d.ts +70 -34
  99. package/dist/types/thread_manager.d.ts +3 -3
  100. package/dist/types/token_manager.d.ts +15 -10
  101. package/dist/types/types.d.ts +197 -3404
  102. package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
  103. package/dist/types/utils/WithSubscriptions.d.ts +2 -1
  104. package/dist/types/utils/concurrency.d.ts +4 -4
  105. package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
  106. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
  107. package/dist/types/utils/retryable.d.ts +34 -0
  108. package/dist/types/utils/throttling/throttle.d.ts +36 -0
  109. package/dist/types/utils.d.ts +100 -194
  110. package/package.json +7 -3
  111. package/src/ChannelManager.ts +724 -0
  112. package/src/CooldownTimer.ts +2 -2
  113. package/src/EventHandlerPipeline.ts +228 -0
  114. package/src/LiveLocationManager.ts +12 -11
  115. package/src/api-client.ts +275 -0
  116. package/src/campaign.ts +1 -77
  117. package/src/channel.ts +1344 -1282
  118. package/src/channel_batch_updater.ts +1 -211
  119. package/src/channel_state.ts +144 -1013
  120. package/src/client.ts +936 -3995
  121. package/src/client_state.ts +4 -4
  122. package/src/configuration/InstanceConfigurationService.ts +73 -0
  123. package/src/configuration/index.ts +1 -0
  124. package/src/configuration/types.ts +81 -0
  125. package/src/connection.ts +145 -94
  126. package/src/connection_fallback.ts +29 -27
  127. package/src/constants.ts +1 -5
  128. package/src/custom_types.ts +4 -1
  129. package/src/entityStore/EntityStore.ts +208 -0
  130. package/src/entityStore/StoreBackedItemIndex.ts +115 -0
  131. package/src/entityStore/applyReactionLocally.ts +113 -0
  132. package/src/entityStore/index.ts +2 -0
  133. package/src/errors.ts +14 -2
  134. package/src/gen/chat/ChannelApi.ts +275 -0
  135. package/src/gen/chat/ChatApi.ts +2554 -0
  136. package/src/gen/model-decoders/decoders.ts +2680 -0
  137. package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
  138. package/src/gen/models/index.ts +12673 -0
  139. package/src/gen/moderation/ModerationApi.ts +607 -0
  140. package/src/gen-imports.ts +3 -0
  141. package/src/index.ts +11 -12
  142. package/src/insights.ts +6 -5
  143. package/src/logger.ts +28 -0
  144. package/src/messageComposer/LocationComposer.ts +9 -5
  145. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
  146. package/src/messageComposer/attachmentIdentity.ts +16 -9
  147. package/src/messageComposer/attachmentManager.ts +13 -8
  148. package/src/messageComposer/configuration/types.ts +11 -11
  149. package/src/messageComposer/linkPreviewsManager.ts +9 -10
  150. package/src/messageComposer/messageComposer.ts +57 -53
  151. package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
  152. package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
  153. package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
  154. package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
  155. package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
  156. package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
  157. package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
  158. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
  159. package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
  160. package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
  161. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
  162. package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
  163. package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
  164. package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
  165. package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
  166. package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
  167. package/src/messageComposer/middleware/textComposer/types.ts +9 -4
  168. package/src/messageComposer/pollComposer.ts +6 -8
  169. package/src/messageComposer/textComposer.ts +27 -2
  170. package/src/messageComposer/types.ts +6 -28
  171. package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
  172. package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
  173. package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
  174. package/src/messageOperations/MessageOperations.ts +212 -0
  175. package/src/messageOperations/index.ts +10 -0
  176. package/src/messageOperations/types.ts +64 -0
  177. package/src/moderation.ts +38 -431
  178. package/src/notifications/types.ts +8 -7
  179. package/src/offline-support/offline_support_api.ts +200 -133
  180. package/src/offline-support/offline_sync_manager.ts +23 -44
  181. package/src/offline-support/types.ts +23 -26
  182. package/src/offline-support/util.ts +5 -4
  183. package/src/pagination/FilterBuilder.ts +4 -1
  184. package/src/pagination/ItemIndex.ts +25 -0
  185. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
  186. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
  187. package/src/pagination/cursorDerivation/index.ts +1 -0
  188. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
  189. package/src/pagination/filterCompiler.ts +196 -0
  190. package/src/pagination/index.ts +1 -3
  191. package/src/pagination/paginators/BasePaginator.ts +2859 -0
  192. package/src/pagination/paginators/ChannelPaginator.ts +729 -0
  193. package/src/pagination/paginators/MessageIntervalPaginator.ts +1116 -0
  194. package/src/pagination/paginators/MessagePaginator.ts +508 -0
  195. package/src/pagination/paginators/PinnedMessagePaginator.ts +108 -0
  196. package/src/pagination/paginators/ReminderPaginator.ts +107 -0
  197. package/src/pagination/paginators/UserGroupPaginator.ts +127 -0
  198. package/src/pagination/paginators/index.ts +7 -0
  199. package/src/pagination/paginators/stateThrottling.ts +31 -0
  200. package/src/pagination/sortCompiler.ts +193 -0
  201. package/src/pagination/types.normalization.ts +14 -0
  202. package/src/pagination/utility.normalization.ts +106 -0
  203. package/src/pagination/utility.queryChannel.ts +84 -0
  204. package/src/pagination/utility.search.ts +80 -0
  205. package/src/permissions.ts +7 -8
  206. package/src/poll.ts +101 -110
  207. package/src/poll_manager.ts +14 -8
  208. package/src/reminders/Reminder.ts +2 -5
  209. package/src/reminders/ReminderManager.ts +19 -21
  210. package/src/search/BaseSearchSource.ts +0 -3
  211. package/src/search/ChannelMemberSearchSource.ts +7 -1
  212. package/src/search/ChannelSearchSource.ts +10 -3
  213. package/src/search/MessageSearchSource.ts +29 -30
  214. package/src/search/UserSearchSource.ts +12 -8
  215. package/src/search/types.ts +3 -4
  216. package/src/segment.ts +1 -95
  217. package/src/signing.ts +107 -67
  218. package/src/store.ts +2 -1
  219. package/src/thread.ts +562 -238
  220. package/src/thread_manager.ts +37 -16
  221. package/src/token_manager.ts +21 -10
  222. package/src/types.ts +364 -4533
  223. package/src/uploadManager.ts +8 -0
  224. package/src/utils/FixedSizeQueueCache.ts +12 -6
  225. package/src/utils/WithSubscriptions.ts +2 -1
  226. package/src/utils/concurrency.ts +4 -4
  227. package/src/utils/mergeWith/mergeWith.ts +3 -3
  228. package/src/utils/mergeWith/mergeWithCore.ts +140 -164
  229. package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
  230. package/src/utils/retryable.ts +117 -0
  231. package/src/utils/throttling/throttle.ts +130 -0
  232. package/src/utils.ts +208 -754
  233. package/dist/types/channel_manager.d.ts +0 -122
  234. package/dist/types/events.d.ts +0 -72
  235. package/dist/types/pagination/BasePaginator.d.ts +0 -69
  236. package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
  237. package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
  238. package/src/channel_manager.ts +0 -830
  239. package/src/events.ts +0 -75
  240. package/src/pagination/BasePaginator.ts +0 -184
  241. package/src/pagination/ReminderPaginator.ts +0 -56
  242. package/src/pagination/UserGroupPaginator.ts +0 -93
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * A cache that stores a fixed number of values in a queue.
3
3
  * The most recently added or retrieved value is kept at the front of the queue.
4
+ *
4
5
  * @template K - The type of the keys.
5
6
  * @template T - The type of the values.
6
7
  */
@@ -13,19 +14,24 @@ export declare class FixedSizeQueueCache<K, T> {
13
14
  dispose: (key: K, value: T) => void;
14
15
  });
15
16
  /**
16
- * Adds a new or moves the existing reference to the front of the queue
17
- * @param key
18
- * @param value
17
+ * Adds a new entry or moves the existing reference to the front of the queue.
18
+ *
19
+ * @param key - The cache key.
20
+ * @param value - The value to associate with `key`.
19
21
  */
20
22
  add(key: K, value: T): void;
21
23
  /**
22
- * Retrieves the value by key.
23
- * @param key
24
+ * Retrieves the value by key without changing its position in the queue.
25
+ *
26
+ * @param key - The cache key.
27
+ * @returns The value, or `undefined` when the key is not cached.
24
28
  */
25
29
  peek(key: K): T | undefined;
26
30
  /**
27
31
  * Retrieves the value and moves it to the front of the queue.
28
- * @param key
32
+ *
33
+ * @param key - The cache key.
34
+ * @returns The value, or `undefined` when the key is not cached.
29
35
  */
30
36
  get(key: K): T | undefined;
31
37
  /**
@@ -1,7 +1,8 @@
1
1
  import type { Unsubscribe } from '../store';
2
2
  /**
3
- * @private
4
3
  * Class to use as a template for subscribable entities.
4
+ *
5
+ * @internal
5
6
  */
6
7
  export declare abstract class WithSubscriptions {
7
8
  private unsubscribeFunctions;
@@ -3,9 +3,9 @@
3
3
  * should never run simultaneously: if marked with the same tag, functions
4
4
  * will run one after another.
5
5
  *
6
- * @param tag Async functions with the same tag will run serially. Async functions
6
+ * @param tag - Async functions with the same tag will run serially. Async functions
7
7
  * with different tags can run in parallel.
8
- * @param cb Async function to run.
8
+ * @param cb - Async function to run.
9
9
  * @returns Promise that resolves when async functions returns.
10
10
  */
11
11
  export declare const withoutConcurrency: <T>(tag: string | symbol, cb: () => Promise<T>) => Promise<T>;
@@ -18,9 +18,9 @@ export declare const withoutConcurrency: <T>(tag: string | symbol, cb: () => Pro
18
18
  * If an async function is already running and was canceled, it will be notified
19
19
  * via an abort signal passed as an argument.
20
20
  *
21
- * @param tag Async functions with the same tag will run serially and are canceled
21
+ * @param tag - Async functions with the same tag will run serially and are canceled
22
22
  * when a new action with the same tag is scheduled.
23
- * @param cb Async function to run. Receives AbortSignal as the only argument.
23
+ * @param cb - Async function to run. Receives AbortSignal as the only argument.
24
24
  * @returns Promise that resolves when async functions returns. If the function didn't
25
25
  * start and was canceled, will resolve with 'canceled'. If the function started to run,
26
26
  * it's up to the function to decide how to react to cancelation.
@@ -6,9 +6,9 @@
6
6
  * (objValue, srcValue, key, object, source, stack).
7
7
  *
8
8
  * @category Object
9
- * @param object The destination object.
10
- * @param source A single source object or an array of objects to be merged into the .
11
- * @param customizer The function to customize assigned values.
9
+ * @param object - The destination object.
10
+ * @param source - A single source object or an array of objects to be merged into the .
11
+ * @param customizer - The function to customize assigned values.
12
12
  * @returns Returns `object`.
13
13
  * @example
14
14
  *
@@ -17,11 +17,15 @@ export interface DiffNode {
17
17
  oldValue?: unknown;
18
18
  }
19
19
  export declare const isClassInstance: (value: unknown) => boolean;
20
+ type PairMemo = WeakMap<object, WeakSet<object>>;
20
21
  /**
21
- * Performs a deep comparison between two values to determine if they are equivalent.
22
- * This is similar to Lodash's isEqual implementation but simplified.
22
+ * Deep semantic equality with cycle safety and symbol-key support.
23
+ * Keeps your existing semantics:
24
+ * - Dates/RegExps compared by value
25
+ * - "Class instances" are treated atomically (unequal unless ===)
26
+ * - NaN equals NaN; -0 equals 0 (same as ===)
23
27
  */
24
- export declare const isEqual: (value1: unknown, value2: unknown, compareStack?: Set<[unknown, unknown]>, objectStack1?: WeakSet<object>, objectStack2?: WeakSet<object>) => boolean;
28
+ export declare const isEqual: (value1: unknown, value2: unknown, pairMemo?: PairMemo) => boolean;
25
29
  /**
26
30
  * Generates a diff between original and modified objects.
27
31
  * This is used after the merge operation to track what has changed.
@@ -38,3 +42,4 @@ export declare function createMergeCore<T extends object>(options?: {
38
42
  diff: DiffNode | null;
39
43
  };
40
44
  export declare function cleanupDiffTree(diffNode: DiffNode): DiffNode | null;
45
+ export {};
@@ -0,0 +1,34 @@
1
+ type FunctionToRetry<T = any> = (...functionArguments: any[]) => PromiseLike<T>;
2
+ declare enum RetryErrorType {
3
+ ABORT = 0,
4
+ ATTEMPT_LIMIT_REACHED = 1
5
+ }
6
+ export declare class RetryError extends Error {
7
+ name: string;
8
+ private static errorMap;
9
+ constructor({ type }: {
10
+ type: RetryErrorType;
11
+ });
12
+ }
13
+ export declare const sleep: (duration: number) => Promise<unknown>;
14
+ export type RunWithRetryOptions<T extends FunctionToRetry> = {
15
+ retryAttempts?: number;
16
+ delayBetweenRetries?: number | ((attempt: number) => number);
17
+ isRetryable?: (error: unknown) => boolean;
18
+ didValueChange?: (...functionArguments: Parameters<T>) => Promise<boolean> | boolean;
19
+ };
20
+ /**
21
+ * Function which wraps asynchronous functions with retry mechanism which'll keep executing said
22
+ * function pre-defined number of times until it resolves, rejects or the retry mechanism runs out of available attempts.
23
+ *
24
+ * #### Available options:
25
+ * - `didValueChange` - check function with initial argument value to check against new values, return `true` to abort next attempt
26
+ *
27
+ * - `isRetryable` - error evaluation function which determines whether to retry the execution
28
+ *
29
+ * - `delayBetweenRetries` - accepts either fixed numeric value or function which provides retry attempt as the argument, expects number as return value
30
+ *
31
+ * - `retryAttempts` - number of attempts to try out before rejecting the promise
32
+ */
33
+ export declare const runWithRetry: <T extends FunctionToRetry>(f: T, { retryAttempts, delayBetweenRetries, isRetryable, didValueChange, }?: RunWithRetryOptions<T>) => (...functionArguments: Parameters<T>) => Promise<NonNullable<Awaited<ReturnType<T>>>>;
34
+ export {};
@@ -0,0 +1,36 @@
1
+ export type ThrottledCallback = (...args: unknown[]) => unknown;
2
+ export type ThrottleOptions = {
3
+ /** Call on the leading edge (default: true). */
4
+ leading?: boolean;
5
+ /** Call once at the end of the window with the latest args (default: false). */
6
+ trailing?: boolean;
7
+ };
8
+ export type Throttled<T extends unknown[]> = {
9
+ /**
10
+ * The throttled function — call it as often as you like; it invokes `fn` at most once per window
11
+ * (leading and/or trailing per options).
12
+ */
13
+ throttledFn: (...args: T) => void;
14
+ /** Clear a pending trailing invocation WITHOUT firing it. */
15
+ cancelTimer: () => void;
16
+ /**
17
+ * Fire a pending trailing invocation immediately (with the latest stored args), clearing the timer.
18
+ * No-op when nothing is pending. Use to bypass the throttle delay for updates that must land now.
19
+ */
20
+ flush: () => void;
21
+ };
22
+ /**
23
+ * Throttle a function so it runs at most once per `timeout` ms.
24
+ *
25
+ * - `leading`: fire immediately when the window opens
26
+ * - `trailing`: remember the latest args/this and fire once when the window closes
27
+ *
28
+ * defaults: `{ leading: true, trailing: false }`
29
+ *
30
+ * Copied verbatim from the Feeds client (`packages/feeds-client/src/utils/throttling/throttle.ts`)
31
+ * and extended with a `flush()` method (the Feeds version only exposes `cancelTimer()`).
32
+ *
33
+ * notes:
34
+ * - make one throttled instance and reuse it; re-creating it resets internal state
35
+ */
36
+ export declare const throttle: <T extends unknown[]>(fn: (...args: T) => void, timeout?: number, { leading, trailing }?: ThrottleOptions) => Throttled<T>;
@@ -1,15 +1,14 @@
1
1
  import FormData from 'form-data';
2
- import type { AscDesc, ChannelFilters, ChannelQueryOptions, ChannelSort, ChannelSortBase, LocalMessage, LocalMessageBase, Logger, Message, MessagePaginationOptions, MessageResponse, MessageResponseBase, MessageSet, OwnUserResponse, PromoteChannelParams, ReactionGroupResponse, UpdatedMessage, UserResponse } from './types';
2
+ import type { LocalMessage, MessageRequest, MessageResponse, OwnUserResponse, ReactionGroupResponse, ReactionResponse, UpdatedMessage, UserResponse } from './types';
3
3
  import type { StreamChat } from './client';
4
4
  import type { Channel } from './channel';
5
5
  import type { AxiosRequestConfig } from 'axios';
6
6
  /**
7
- * logChatPromiseExecution - utility function for logging the execution of a promise..
8
- * use this when you want to run the promise and handle errors by logging a warning
9
- *
10
- * @param {Promise<T>} promise The promise you want to run and log
11
- * @param {string} name A descriptive name of what the promise does for log output
7
+ * Logs the execution of a promise. Use this when you want to run the promise and handle errors by
8
+ * logging a warning.
12
9
  *
10
+ * @param promise - The promise you want to run and log.
11
+ * @param name - A descriptive name of what the promise does for log output.
13
12
  */
14
13
  export declare function logChatPromiseExecution<T>(promise: Promise<T>, name: string): void;
15
14
  export declare const sleep: (m: number) => Promise<void>;
@@ -34,14 +33,10 @@ export declare const channelTracksReadLocally: (channel?: Channel) => boolean;
34
33
  */
35
34
  export declare const userHasReadReceipts: (client: StreamChat) => boolean;
36
35
  export declare function addFileToFormData(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string): FormData;
37
- export declare function normalizeQuerySort<T extends Record<string, AscDesc | undefined>>(sort: T | T[]): {
38
- direction: AscDesc;
39
- field: keyof T;
40
- }[];
41
36
  /**
42
37
  * retryInterval - A retry interval which increases acc to number of failures
43
38
  *
44
- * @return {number} Duration to wait in milliseconds
39
+ * @returns Duration to wait in milliseconds
45
40
  */
46
41
  export declare function retryInterval(numberOfFailures: number): number;
47
42
  export declare function randomId(): string;
@@ -59,115 +54,122 @@ export declare function addConnectionEventListeners(cb: (e: Event) => void): voi
59
54
  export declare function removeConnectionEventListeners(cb: (e: Event) => void): void;
60
55
  export declare const axiosParamsSerializer: AxiosRequestConfig['paramsSerializer'];
61
56
  /**
62
- * Takes the message object, parses the dates, sets `__html`
63
- * and sets the status to `received` if missing; returns a new LocalMessage object.
57
+ * Takes the message object, adds SDK-specific fields (status, error),
58
+ * and returns a new LocalMessage object.
64
59
  *
65
- * @param {LocalMessage} message `LocalMessage` object
60
+ * @param message - message object
66
61
  */
67
- export declare function formatMessage(message: MessageResponse | MessageResponseBase | LocalMessage): LocalMessage;
62
+ export declare function formatMessage(message: MessageResponse | LocalMessage): LocalMessage;
68
63
  /**
69
- * @private
64
+ * Computes the current user's `own_reactions` after applying a single reaction change, off a
65
+ * `current` base. A WS reaction/edit event carries `own_reactions: []` (or stale), so consumers
66
+ * must recompute from the copy they already hold rather than trusting the event — this is the
67
+ * shared core used by both the message paginator (`reflectReaction`) and the thread's parent
68
+ * message (which is not held in any paginator, so it needs the same logic directly).
70
69
  *
71
- * Takes a LocalMessage, parses the dates back to strings,
72
- * and converts the message back to a MessageResponse.
70
+ * - `removed`: drop the current user's reaction of this type.
71
+ * - `enforceUnique`: replace any existing own reaction with the incoming one (used by
72
+ * `reaction.updated`, where a user's reaction supersedes their previous one).
73
+ * - otherwise: add the reaction, de-duped by type.
73
74
  *
74
- * @param {MessageResponse} message `MessageResponse` object
75
+ * A reaction by another user never changes the current user's `own_reactions`.
76
+ */
77
+ export declare function computeOwnReactions({ current, enforceUnique, reaction, removed, userId, }: {
78
+ current: ReactionResponse[];
79
+ reaction: ReactionResponse;
80
+ enforceUnique?: boolean;
81
+ removed?: boolean;
82
+ userId?: string;
83
+ }): ReactionResponse[];
84
+ /**
85
+ * Returns a copy of `message` with `reaction` folded into its `reaction_groups` /
86
+ * `latest_reactions`. Does not touch `own_reactions` — the reaction entry points
87
+ * ({@link MessageIntervalPaginator.reflectReaction} / `Thread.applyParentReactionLocally`) own that
88
+ * via {@link computeOwnReactions}. Shared so both the paginator and the (paginator-less) thread
89
+ * parent compute counts identically.
90
+ */
91
+ export declare function messageWithReactionAdded(message: LocalMessage, reaction: ReactionResponse, enforceUnique: boolean): LocalMessage;
92
+ /**
93
+ * Returns a copy of `message` with the current user's reaction of `reaction.type` backed out of its
94
+ * `reaction_groups` / `latest_reactions`. Does not touch `own_reactions`.
75
95
  */
76
- export declare function unformatMessage(message: LocalMessage): MessageResponse;
77
- export declare const localMessageToNewMessagePayload: (localMessage: LocalMessage) => Message;
96
+ export declare function messageWithReactionRemoved(message: LocalMessage, reaction: ReactionResponse): LocalMessage;
97
+ export declare const localMessageToNewMessagePayload: (localMessage: LocalMessage) => MessageRequest;
78
98
  export declare const toUpdatedMessagePayload: (message: LocalMessage | Partial<MessageResponse>) => UpdatedMessage;
79
99
  export declare const toDeletedMessage: ({ message, deletedAt, hardDelete, }: {
80
- message: LocalMessage | LocalMessageBase;
100
+ message: LocalMessage;
81
101
  deletedAt: LocalMessage["deleted_at"];
82
102
  hardDelete: boolean;
83
103
  }) => {
84
104
  attachments: never[];
85
- cid: string | undefined;
105
+ cid: string;
86
106
  created_at: Date;
87
- deleted_at: Date | null;
107
+ deleted_at: Date | undefined;
88
108
  id: string;
89
109
  latest_reactions: never[];
90
110
  mentioned_users: never[];
91
111
  own_reactions: never[];
92
112
  parent_id: string | undefined;
93
- reply_count: number | undefined;
113
+ reply_count: number;
94
114
  status: string;
95
115
  thread_participants: UserResponse[] | undefined;
96
116
  type: "deleted";
97
117
  updated_at: Date;
98
- user: UserResponse | null | undefined;
118
+ user: UserResponse;
99
119
  } | {
100
120
  attachments: never[];
101
121
  type: string;
102
- deleted_at: Date | null;
103
- text?: string | undefined;
104
- user_id?: string | undefined;
105
- command?: string | undefined;
106
- mentioned_groups?: import("./types").UserGroupResponse[] | undefined;
107
- mentioned_users?: UserResponse[] | undefined;
108
- latest_reactions?: import("./types").ReactionResponse[] | undefined;
109
- own_reactions?: import("./types").ReactionResponse[] | null | undefined;
110
- reaction_counts?: {
111
- [key: string]: number;
112
- } | null | undefined;
113
- reply_count?: number | undefined;
114
- i18n?: (import("./types").RequireAtLeastOne<Record<`${import("./types").TranslationLanguages}_text`, string>> & {
115
- language: import("./types").TranslationLanguages;
116
- }) | undefined;
117
- html?: string | undefined;
118
- user?: (UserResponse | null) | undefined;
119
- id: string;
120
- mml?: string | undefined;
121
- parent_id?: string | undefined;
122
- pin_expires?: string | null | undefined;
123
- pinned?: boolean | undefined;
124
- poll_id?: string | undefined;
125
- quoted_message_id?: string | undefined;
126
- restricted_visibility?: string[] | undefined;
127
- show_in_channel?: boolean | undefined;
128
- silent?: boolean | undefined;
129
- args?: string | undefined;
130
- before_message_send_failed?: boolean | undefined;
131
- channel?: import("./types").ChannelResponse | undefined;
132
- cid?: string | undefined;
133
- command_info?: {
134
- name?: string;
135
- } | undefined;
136
- deleted_reply_count?: number | undefined;
137
- member?: import("./types").ChannelMemberResponse | undefined;
138
- mentioned_channel?: boolean | undefined;
139
- mentioned_here?: boolean | undefined;
140
- mentioned_group_ids?: string[] | undefined;
141
- mentioned_roles?: string[] | undefined;
142
- message_text_updated_at?: string | undefined;
143
- moderation?: import("./types").ModerationResponse | undefined;
144
- moderation_details?: import("./types").ModerationDetailsResponse | undefined;
145
- pinned_by?: (UserResponse | null) | undefined;
146
- poll?: import("./types").PollResponse | undefined;
147
- reaction_groups?: {
148
- [key: string]: ReactionGroupResponse;
149
- } | null | undefined;
150
- reaction_scores?: {
151
- [key: string]: number;
152
- } | null | undefined;
153
- reminder?: import("./types").ReminderResponseBase | undefined;
154
- shadowed?: boolean | undefined;
155
- shared_location?: import("./types").SharedLocationResponse | undefined;
156
- thread_participants?: UserResponse[] | undefined;
157
- deleted_for_me?: boolean | undefined;
122
+ deleted_at: Date | undefined;
123
+ cid: string;
158
124
  created_at: Date;
159
- pinned_at: Date | null;
160
- status: string;
125
+ deleted_reply_count: number;
126
+ html: string;
127
+ id: string;
128
+ mentioned_channel: boolean;
129
+ mentioned_here: boolean;
130
+ pinned: boolean;
131
+ reply_count: number;
132
+ shadowed: boolean;
133
+ silent: boolean;
134
+ text: string;
161
135
  updated_at: Date;
162
- error?: import("./types").ErrorFromResponse<import("./types").APIErrorResponse> | null;
163
- quoted_message?: LocalMessageBase | null;
164
- };
165
- export declare const deleteUserMessages: ({ messages, user, hardDelete, deletedAt, }: {
166
- messages: Array<LocalMessage>;
136
+ latest_reactions: Array<ReactionResponse>;
137
+ mentioned_users: Array<UserResponse>;
138
+ own_reactions: Array<ReactionResponse>;
139
+ restricted_visibility: Array<string>;
140
+ custom: import("./custom_types").CustomMessageData;
141
+ reaction_counts: Record<string, number>;
142
+ reaction_scores: Record<string, number>;
167
143
  user: UserResponse;
168
- hardDelete: boolean;
169
- deletedAt: LocalMessage["deleted_at"];
170
- }) => void;
144
+ command?: string;
145
+ deleted_for_me?: boolean;
146
+ message_text_updated_at?: Date;
147
+ mml?: string;
148
+ parent_id?: string;
149
+ pin_expires?: Date;
150
+ pinned_at?: Date;
151
+ poll_id?: string;
152
+ quoted_message_id?: string;
153
+ show_in_channel?: boolean;
154
+ mentioned_group_ids?: Array<string>;
155
+ mentioned_groups?: Array<import(".").UserGroupResponse>;
156
+ mentioned_roles?: Array<string>;
157
+ thread_participants?: Array<UserResponse>;
158
+ draft?: import(".").DraftResponse;
159
+ i18n?: Record<string, string>;
160
+ image_labels?: Record<string, Array<string>>;
161
+ member?: import(".").ChannelMemberResponse;
162
+ moderation?: import(".").ModerationV2Response;
163
+ pinned_by?: UserResponse;
164
+ poll?: import(".").PollResponseData;
165
+ quoted_message?: MessageResponse;
166
+ reaction_groups?: Record<string, ReactionGroupResponse>;
167
+ reminder?: import(".").ReminderResponseData;
168
+ shared_location?: import(".").SharedLocationResponseData;
169
+ status: string;
170
+ error?: import("./types").StreamAPIError;
171
+ user_id?: string;
172
+ };
171
173
  export declare const findIndexInSortedArray: <T, L>({ needle, sortedArray, selectKey, selectValueToCompare, sortDirection, }: {
172
174
  needle: T;
173
175
  sortedArray: readonly T[];
@@ -202,7 +204,6 @@ export declare const findIndexInSortedArray: <T, L>({ needle, sortedArray, selec
202
204
  */
203
205
  sortDirection?: "ascending" | "descending";
204
206
  }) => number;
205
- export declare function addToMessageList<T extends LocalMessage>(messages: readonly T[], newMessage: T, timestampChanged?: boolean, sortBy?: 'pinned_at' | 'created_at', addIfDoesNotExist?: boolean): T[];
206
207
  export interface DebouncedFunc<T extends (...args: any[]) => any> {
207
208
  /**
208
209
  * Call the original function, but applying the debounce rules.
@@ -231,113 +232,18 @@ export declare const debounce: <T extends (...args: any[]) => any>(fn: T, timeou
231
232
  leading?: boolean;
232
233
  trailing?: boolean;
233
234
  }) => DebouncedFunc<T>;
234
- export declare const throttle: <T extends (...args: any[]) => any>(fn: T, timeout?: number, { leading, trailing }?: {
235
- leading?: boolean;
236
- trailing?: boolean;
237
- }) => (...args: Parameters<T>) => void;
235
+ export { throttle } from './utils/throttling/throttle';
236
+ export type { Throttled, ThrottleOptions, ThrottledCallback, } from './utils/throttling/throttle';
238
237
  export declare const uniqBy: <T>(array: T[] | unknown, iteratee: ((item: T) => unknown) | keyof T) => T[];
239
- type MessagePaginationUpdatedParams = {
240
- parentSet: MessageSet;
241
- requestedPageSize: number;
242
- returnedPage: MessageResponse[];
243
- filteredReturnedPage: MessageResponse[];
244
- logger?: Logger;
245
- messagePaginationOptions?: MessagePaginationOptions;
246
- };
247
- export declare function binarySearchByDateEqualOrNearestGreater(array: {
248
- created_at?: string;
249
- }[], targetDate: Date): number;
250
- export declare const messageSetPagination: (params: MessagePaginationUpdatedParams) => {
251
- hasNext: boolean;
252
- hasPrev: boolean;
253
- };
254
- type GetChannelParams = {
255
- client: StreamChat;
256
- channel?: Channel;
257
- id?: string;
258
- members?: string[];
259
- options?: ChannelQueryOptions;
260
- type?: string;
261
- };
262
- /**
263
- * Calls channel.watch() if it was not already recently called. Waits for watch promise to resolve even if it was invoked previously.
264
- * 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.
265
- * @param client
266
- * @param members
267
- * @param options
268
- * @param type
269
- * @param id
270
- * @param channel
271
- */
272
- export declare const getAndWatchChannel: ({ channel, client, id, members, options, type, }: GetChannelParams) => Promise<Channel>;
273
238
  /**
274
239
  * Generates a temporary channel.cid for channels created without ID, as they need to be referenced
275
240
  * by an identifier until the back-end generates the final ID. The cid is generated by its member IDs
276
241
  * which are sorted and can be recreated the same every time given the same arguments.
277
- * @param channelType
278
- * @param members
242
+ *
243
+ * @param channelType - The channel type.
244
+ * @param members - The member ids used to build the temporary cid.
279
245
  */
280
246
  export declare const generateChannelTempCid: (channelType: string, members: string[]) => string | undefined;
281
- /**
282
- * Checks if a channel is pinned or not. Will return true only if channel.state.membership.pinned_at exists.
283
- * @param channel
284
- */
285
- export declare const isChannelPinned: (channel: Channel) => boolean;
286
- /**
287
- * Checks if a channel is archived or not. Will return true only if channel.state.membership.archived_at exists.
288
- * @param channel
289
- */
290
- export declare const isChannelArchived: (channel: Channel) => boolean;
291
- /**
292
- * A utility that tells us whether we should consider archived channels or not based
293
- * on filters. Will return true only if filters.archived exists and is a boolean value.
294
- * @param filters
295
- */
296
- export declare const shouldConsiderArchivedChannels: (filters: ChannelFilters) => boolean;
297
- /**
298
- * Extracts the value of the sort parameter at a given index, for a targeted key. Can
299
- * handle both array and object versions of sort. Will return null if the index/key
300
- * combination does not exist.
301
- * @param atIndex - the index at which we'll examine the sort value, if it's an array one
302
- * @param sort - the sort value - both array and object notations are accepted
303
- * @param targetKey - the target key which needs to exist for the sort at a certain index
304
- */
305
- export declare const extractSortValue: ({ atIndex, sort, targetKey, }: {
306
- atIndex: number;
307
- targetKey: keyof ChannelSortBase;
308
- sort?: ChannelSort;
309
- }) => AscDesc | null;
310
- /**
311
- * Returns true only if `{ pinned_at: -1 }` or `{ pinned_at: 1 }` option is first within the `sort` array.
312
- */
313
- export declare const shouldConsiderPinnedChannels: (sort: ChannelSort) => boolean;
314
- /**
315
- * Checks whether the sort value of type object contains a pinned_at value or if
316
- * an array sort value type has the first value be an object containing pinned_at.
317
- * @param sort
318
- */
319
- export declare const findPinnedAtSortOrder: ({ sort }: {
320
- sort: ChannelSort;
321
- }) => AscDesc | null;
322
- /**
323
- * Finds the index of the last consecutively pinned channel, starting from the start of the
324
- * array. Will not consider any pinned channels after the contiguous subsequence at the
325
- * start of the array.
326
- * @param channels
327
- */
328
- export declare const findLastPinnedChannelIndex: ({ channels }: {
329
- channels: Channel[];
330
- }) => number | null;
331
- /**
332
- * A utility used to move a channel towards the beginning of a list of channels (promote it to a higher position). It
333
- * considers pinned channels in the process if needed and makes sure to only update the list reference if the list
334
- * should actually change. It will try to move the channel as high as it can within the list.
335
- * @param channels - the list of channels we want to modify
336
- * @param channelToMove - the channel we want to promote
337
- * @param channelToMoveIndexWithinChannels - optionally, the index of the channel we want to move if we know it (will skip a manual check)
338
- * @param sort - the sort value used to check for pinned channels
339
- */
340
- export declare const promoteChannel: ({ channels, channelToMove, channelToMoveIndexWithinChannels, sort, }: PromoteChannelParams) => Channel[];
341
247
  export declare const isDate: (value: unknown) => value is Date;
342
248
  export declare const isLocalMessage: (message: unknown) => message is LocalMessage;
343
249
  export declare const runDetached: <T>(callback: Promise<void | T>, options?: {
@@ -347,4 +253,4 @@ export declare const runDetached: <T>(callback: Promise<void | T>, options?: {
347
253
  }) => void;
348
254
  export declare const isBlockedMessage: (message: LocalMessage) => boolean;
349
255
  export declare const isBouncedMessage: (message: LocalMessage) => boolean;
350
- export {};
256
+ export declare const getEnv: (envKey: keyof NodeJS.ProcessEnv) => string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.50.3",
3
+ "version": "10.0.0-rc.2",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -50,6 +50,7 @@
50
50
  "/src"
51
51
  ],
52
52
  "dependencies": {
53
+ "@stream-io/logger": "^2.0.0",
53
54
  "@types/jsonwebtoken": "^9.0.8",
54
55
  "@types/ws": "^8.18.1",
55
56
  "axios": "^1.16.1",
@@ -75,6 +76,8 @@
75
76
  "esbuild": "^0.28.0",
76
77
  "eslint": "^9.39.4",
77
78
  "eslint-plugin-import": "^2.32.0",
79
+ "eslint-plugin-jsdoc": "^63.0.7",
80
+ "eslint-plugin-unused-imports": "^4.4.1",
78
81
  "globals": "^17.6.0",
79
82
  "husky": "^9.1.7",
80
83
  "lint-staged": "^17.0.5",
@@ -90,7 +93,7 @@
90
93
  "start": "concurrently 'tsc --watch' './scripts/bundle.mjs --watch'",
91
94
  "types": "tsc --noEmit",
92
95
  "lint": "yarn run prettier && yarn run eslint",
93
- "lint-fix": "yarn run prettier-fix && yarn run eslint-fix",
96
+ "lint-fix": "yarn run eslint-fix; yarn run prettier-fix",
94
97
  "prettier": "prettier '**/*.{json,js,mjs,ts,yml,md}' --check",
95
98
  "prettier-fix": "yarn run prettier --write",
96
99
  "eslint": "eslint --max-warnings 0",
@@ -104,7 +107,8 @@
104
107
  "fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",
105
108
  "semantic-release": "semantic-release",
106
109
  "postinstall": "node -e \"require('fs').existsSync('scripts/install-husky.mjs') && import('./scripts/install-husky.mjs')\"",
107
- "prepare": "yarn run build"
110
+ "prepare": "yarn run build",
111
+ "generate-client": "./scripts/generate-client.sh"
108
112
  },
109
113
  "engines": {
110
114
  "node": ">=18"