stream-chat 10.0.0-rc.21 → 10.0.0-rc.23

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 (269) hide show
  1. package/dist/cjs/index.browser.js +2196 -3902
  2. package/dist/cjs/index.browser.js.map +3 -3
  3. package/dist/cjs/index.node.js +2197 -3902
  4. package/dist/cjs/index.node.js.map +3 -3
  5. package/dist/esm/index.mjs +2199 -3905
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +120 -233
  8. package/dist/types/CooldownTimer.d.ts +8 -23
  9. package/dist/types/EventHandlerPipeline.d.ts +17 -37
  10. package/dist/types/LiveLocationManager.d.ts +22 -50
  11. package/dist/types/api-client.d.ts +9 -14
  12. package/dist/types/channel.d.ts +253 -448
  13. package/dist/types/channel_state.d.ts +48 -95
  14. package/dist/types/client.d.ts +245 -370
  15. package/dist/types/client_state.d.ts +1 -3
  16. package/dist/types/configuration/ConfigController.d.ts +30 -124
  17. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
  18. package/dist/types/configuration/keys.d.ts +5 -19
  19. package/dist/types/configuration/shape.d.ts +12 -29
  20. package/dist/types/configuration/types.d.ts +59 -87
  21. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
  22. package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
  23. package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
  24. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
  25. package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
  26. package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
  27. package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
  28. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
  29. package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
  30. package/dist/types/connection/networkConnection/types.d.ts +12 -27
  31. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
  32. package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
  33. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
  34. package/dist/types/connection/wsConnection/config.d.ts +8 -28
  35. package/dist/types/connection/wsConnection/types.d.ts +17 -70
  36. package/dist/types/entityStore/EntityStore.d.ts +153 -113
  37. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
  38. package/dist/types/errors.d.ts +7 -19
  39. package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
  40. package/dist/types/gen/chat/ChatApi.d.ts +28 -14
  41. package/dist/types/gen/models/index.d.ts +769 -86
  42. package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
  43. package/dist/types/index.d.ts +2 -4
  44. package/dist/types/languageNames.d.ts +9 -24
  45. package/dist/types/logger.d.ts +1 -3
  46. package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
  47. package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
  48. package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
  49. package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
  50. package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
  51. package/dist/types/messageComposer/configuration/types.d.ts +29 -56
  52. package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
  53. package/dist/types/messageComposer/messageComposer.d.ts +30 -164
  54. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
  55. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
  56. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
  57. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
  58. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
  59. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
  60. package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
  61. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
  62. package/dist/types/messageComposer/pollComposer.d.ts +8 -4
  63. package/dist/types/messageComposer/textComposer.d.ts +3 -9
  64. package/dist/types/messageComposer/types.d.ts +5 -8
  65. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
  66. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
  67. package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
  68. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
  69. package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
  70. package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
  71. package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
  72. package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
  73. package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
  74. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
  75. package/dist/types/messageOperations/types.d.ts +15 -30
  76. package/dist/types/middleware.d.ts +7 -5
  77. package/dist/types/moderation.d.ts +21 -14
  78. package/dist/types/notifications/NotificationManager.d.ts +8 -31
  79. package/dist/types/notifications/types.d.ts +19 -59
  80. package/dist/types/offline-support/offline_support_api.d.ts +145 -539
  81. package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
  82. package/dist/types/offline-support/queueableOperations.d.ts +24 -52
  83. package/dist/types/offline-support/types.d.ts +24 -187
  84. package/dist/types/pagination/ItemIndex.d.ts +4 -12
  85. package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
  86. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
  87. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
  88. package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
  89. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
  90. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
  91. package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
  92. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
  93. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
  94. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
  95. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
  96. package/dist/types/pagination/sortCompiler.d.ts +11 -22
  97. package/dist/types/pagination/utility.normalization.d.ts +5 -23
  98. package/dist/types/pagination/utility.search.d.ts +3 -8
  99. package/dist/types/poll.d.ts +14 -14
  100. package/dist/types/poll_manager.d.ts +11 -2
  101. package/dist/types/poll_optimistic_votes.d.ts +10 -14
  102. package/dist/types/reminders/Reminder.d.ts +4 -4
  103. package/dist/types/reminders/ReminderManager.d.ts +7 -20
  104. package/dist/types/search/BaseSearchSource.d.ts +7 -12
  105. package/dist/types/search/ChannelSearchSource.d.ts +7 -7
  106. package/dist/types/search/MessageSearchSource.d.ts +7 -9
  107. package/dist/types/search/SearchController.d.ts +17 -22
  108. package/dist/types/search/types.d.ts +6 -10
  109. package/dist/types/signing.d.ts +12 -3
  110. package/dist/types/thread.d.ts +23 -71
  111. package/dist/types/thread_manager.d.ts +45 -70
  112. package/dist/types/token_manager.d.ts +8 -13
  113. package/dist/types/types.d.ts +64 -125
  114. package/dist/types/types.utility.d.ts +3 -3
  115. package/dist/types/upload-utils.d.ts +5 -10
  116. package/dist/types/uploadManager.d.ts +17 -45
  117. package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
  118. package/dist/types/utils/WithSubscriptions.d.ts +5 -15
  119. package/dist/types/utils/concurrency.d.ts +11 -19
  120. package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
  121. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
  122. package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
  123. package/dist/types/utils/objectPath.d.ts +6 -41
  124. package/dist/types/utils/retryable.d.ts +8 -12
  125. package/dist/types/utils/throttling/throttle.d.ts +8 -23
  126. package/dist/types/utils/time.d.ts +24 -64
  127. package/dist/types/utils.d.ts +40 -86
  128. package/package.json +7 -2
  129. package/src/ChannelManager.ts +159 -300
  130. package/src/CooldownTimer.ts +11 -29
  131. package/src/EventHandlerPipeline.ts +21 -44
  132. package/src/LiveLocationManager.ts +35 -74
  133. package/src/api-client.ts +43 -61
  134. package/src/campaign.ts +1 -1
  135. package/src/channel.ts +396 -749
  136. package/src/channel_batch_updater.ts +1 -1
  137. package/src/channel_state.ts +50 -105
  138. package/src/client.ts +360 -588
  139. package/src/client_state.ts +1 -6
  140. package/src/configuration/ConfigController.ts +41 -157
  141. package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
  142. package/src/configuration/index.ts +1 -1
  143. package/src/configuration/keys.ts +13 -32
  144. package/src/configuration/shape.ts +67 -70
  145. package/src/configuration/types.ts +60 -100
  146. package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
  147. package/src/configuration/utils/copyConfigPatch.ts +11 -32
  148. package/src/configuration/utils/declarativeSlices.ts +9 -39
  149. package/src/configuration/utils/deepFreezeConfig.ts +3 -17
  150. package/src/configuration/utils/index.ts +2 -4
  151. package/src/configuration/utils/serverAuthority.ts +20 -68
  152. package/src/connection/ConnectionIdManager.ts +20 -49
  153. package/src/connection/ConnectionRecoveryManager.ts +51 -178
  154. package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
  155. package/src/connection/networkConnection/reporters.ts +9 -36
  156. package/src/connection/networkConnection/types.ts +12 -27
  157. package/src/connection/wsConnection/StableWSConnection.ts +73 -193
  158. package/src/connection/wsConnection/WSConnection.ts +56 -131
  159. package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
  160. package/src/connection/wsConnection/config.ts +13 -48
  161. package/src/connection/wsConnection/types.ts +17 -70
  162. package/src/constants.ts +4 -4
  163. package/src/entityStore/EntityStore.ts +162 -167
  164. package/src/entityStore/StoreBackedItemIndex.ts +14 -47
  165. package/src/errors.ts +7 -19
  166. package/src/formatMessageMemo.ts +3 -9
  167. package/src/gen/chat/ChannelApi.ts +19 -0
  168. package/src/gen/chat/ChatApi.ts +87 -13
  169. package/src/gen/models/index.ts +793 -71
  170. package/src/gen/moderation/ModerationApi.ts +0 -4
  171. package/src/index.ts +10 -14
  172. package/src/languageNames.ts +9 -24
  173. package/src/logger.ts +1 -3
  174. package/src/messageComposer/LocationComposer.ts +7 -23
  175. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
  176. package/src/messageComposer/attachmentIdentity.ts +2 -13
  177. package/src/messageComposer/attachmentManager.ts +17 -63
  178. package/src/messageComposer/attachmentUtils.ts +3 -17
  179. package/src/messageComposer/configuration/configuration.ts +5 -8
  180. package/src/messageComposer/configuration/types.ts +29 -56
  181. package/src/messageComposer/fileUtils.ts +1 -1
  182. package/src/messageComposer/linkPreviewsManager.ts +8 -20
  183. package/src/messageComposer/messageComposer.ts +54 -222
  184. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
  185. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
  186. package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
  187. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
  188. package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
  189. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
  190. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  191. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  192. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  193. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
  194. package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
  195. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  196. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  197. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  198. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  199. package/src/messageComposer/pollComposer.ts +11 -8
  200. package/src/messageComposer/textComposer.ts +9 -59
  201. package/src/messageComposer/types.ts +9 -12
  202. package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
  203. package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
  204. package/src/messageOperations/FailedSendCache.ts +4 -9
  205. package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
  206. package/src/messageOperations/MessageOperations.ts +33 -62
  207. package/src/messageOperations/applyReactionLocally.ts +9 -28
  208. package/src/messageOperations/createMessageOperations.ts +17 -33
  209. package/src/messageOperations/reflectReactionEvent.ts +5 -13
  210. package/src/messageOperations/sendOrdering.ts +4 -7
  211. package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
  212. package/src/messageOperations/types.ts +15 -30
  213. package/src/middleware.ts +7 -10
  214. package/src/moderation.ts +25 -21
  215. package/src/notifications/NotificationManager.ts +11 -35
  216. package/src/notifications/types.ts +19 -59
  217. package/src/offline-support/offline_support_api.ts +178 -608
  218. package/src/offline-support/offline_sync_manager.ts +25 -69
  219. package/src/offline-support/queueableOperations.ts +31 -84
  220. package/src/offline-support/types.ts +25 -188
  221. package/src/pagination/ItemIndex.ts +4 -12
  222. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  223. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
  224. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  225. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
  226. package/src/pagination/filterCompiler.ts +11 -25
  227. package/src/pagination/paginators/BasePaginator.ts +422 -976
  228. package/src/pagination/paginators/ChannelPaginator.ts +130 -190
  229. package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
  230. package/src/pagination/paginators/MessagePaginator.ts +135 -175
  231. package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
  232. package/src/pagination/paginators/ReminderPaginator.ts +12 -15
  233. package/src/pagination/paginators/ThreadPaginator.ts +16 -26
  234. package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
  235. package/src/pagination/paginators/stateThrottling.ts +5 -10
  236. package/src/pagination/sortCompiler.ts +23 -50
  237. package/src/pagination/utility.normalization.ts +8 -30
  238. package/src/pagination/utility.search.ts +4 -11
  239. package/src/poll.ts +19 -19
  240. package/src/poll_manager.ts +16 -20
  241. package/src/poll_optimistic_votes.ts +17 -22
  242. package/src/reminders/Reminder.ts +5 -6
  243. package/src/reminders/ReminderManager.ts +9 -34
  244. package/src/reminders/ReminderTimer.ts +1 -2
  245. package/src/search/BaseSearchSource.ts +14 -29
  246. package/src/search/ChannelSearchSource.ts +8 -8
  247. package/src/search/MessageSearchSource.ts +19 -25
  248. package/src/search/SearchController.ts +18 -24
  249. package/src/search/types.ts +6 -10
  250. package/src/segment.ts +1 -1
  251. package/src/signing.ts +23 -3
  252. package/src/thread.ts +72 -173
  253. package/src/thread_manager.ts +59 -76
  254. package/src/token_manager.ts +11 -21
  255. package/src/types.ts +78 -126
  256. package/src/types.utility.ts +3 -3
  257. package/src/upload-utils.ts +5 -10
  258. package/src/uploadManager.ts +22 -54
  259. package/src/utils/FixedSizeQueueCache.ts +13 -21
  260. package/src/utils/WithSubscriptions.ts +5 -15
  261. package/src/utils/concurrency.ts +16 -55
  262. package/src/utils/mergeWith/mergeWith.ts +10 -13
  263. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  264. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  265. package/src/utils/objectPath.ts +6 -41
  266. package/src/utils/retryable.ts +10 -14
  267. package/src/utils/throttling/throttle.ts +9 -25
  268. package/src/utils/time.ts +26 -66
  269. package/src/utils.ts +72 -128
@@ -36,11 +36,9 @@ export const DEFAULT_MESSAGE_OPERATIONS_CONFIG: MessageOperationsConfig =
36
36
  });
37
37
 
38
38
  /**
39
- * Every optimistic operation on a message, each one method reading top to bottom.
40
- *
41
- * Send, retry, update and delete are message REQUESTS with a status lifecycle, so they share
42
- * {@link run} and {@link MessageOperationStatePolicy}. Anything else (reactions, and whatever comes
43
- * next) applies its change, sends its request, and on failure calls {@link rollbackUnlessQueued}.
39
+ * Every optimistic operation on a message. Send, retry, update and delete have a status lifecycle and
40
+ * share {@link run} and {@link MessageOperationStatePolicy}. Reactions apply their change, send their
41
+ * request, and on failure call {@link rollbackUnlessQueued}.
44
42
  */
45
43
  export class MessageOperations {
46
44
  private ctx: MessageOperationsContext;
@@ -53,7 +51,6 @@ export class MessageOperations {
53
51
  MessageOperationsContext['sequenceRequests']
54
52
  >;
55
53
 
56
- /** The shared configuration machinery — see {@link ConfigController}. */
57
54
  private readonly configController: ConfigController<MessageOperationsConfig>;
58
55
 
59
56
  constructor(ctx: MessageOperationsContext) {
@@ -73,37 +70,27 @@ export class MessageOperations {
73
70
  });
74
71
  }
75
72
 
76
- /**
77
- * Resolved configuration, as a store — the shape every configurable class exposes
78
- * (`configState` / `config` / `updateConfig`).
79
- */
80
73
  get configState(): StateStore<MessageOperationsConfig> {
81
74
  return this.configController.state;
82
75
  }
83
76
 
84
- /** The current resolved configuration. `Readonly` — change it through {@link updateConfig}. */
85
77
  get config(): Readonly<MessageOperationsConfig> {
86
78
  return this.configState.getLatestValue();
87
79
  }
88
80
 
89
- /** Merges a partial configuration into the resolved config and notifies subscribers. */
81
+ /**
82
+ * Merges a partial configuration into the resolved config.
83
+ *
84
+ * @param config - Fields to merge into the resolved config.
85
+ */
90
86
  updateConfig(config: Partial<MessageOperationsConfig>) {
91
87
  this.configController.patch(config);
92
88
  }
93
89
 
94
90
  /**
95
- * Rebuilds the resolved configuration from package defaults plus the declarative slice.
91
+ * Re-derives the configuration from the declarative slice.
96
92
  *
97
- * The derivation entry point every configurable entity exposes, so the owner routes a slice here and
98
- * knows nothing about MessageOperations's defaults or merge semantics. This logic used to live in the owner,
99
- * which is how `reset()` became a no-op for the client key (F4) and how a registered
100
- * `notifications.sortComparator` became unremovable (G8) — an owner writing another object's
101
- * derivation gets that object's rules wrong sooner or later.
102
- *
103
- * Routed through {@link updateConfig} rather than replacing the store, which is exact here because
104
- * every field of `MessageOperationsConfig` is required and present in the defaults, so a patch naming all of
105
- * them amounts to a replacement. `NotificationManager` cannot do this — its `sortComparator` is
106
- * optional with no default, so a patch can never remove one — which is why it replaces outright.
93
+ * @param config - The declarative slice. Leave it out to rebuild from the defaults.
107
94
  */
108
95
  initializeConfig(config?: Partial<MessageOperationsConfig>) {
109
96
  this.configController.initialize(config);
@@ -121,9 +108,8 @@ export class MessageOperations {
121
108
  if (!settle || !attachments?.length) return { params };
122
109
 
123
110
  const { attachments: settledAttachments, failureReason } = await settle(attachments);
124
- // Same array reference unless something uploaded just now, in which case the payload has to be
125
- // rebuilt from it: the composition middleware left `message.attachments` holding only the
126
- // attachments that already had a URL.
111
+ // Same reference unless an upload just resolved. Then the payload is rebuilt, since
112
+ // `message.attachments` only holds the attachments that already had a URL.
127
113
  if (settledAttachments === attachments) return { failureReason, params };
128
114
 
129
115
  const wirePayload =
@@ -142,10 +128,8 @@ export class MessageOperations {
142
128
  }
143
129
 
144
130
  /**
145
- * The shared lifecycle: apply the optimistic state, settle any attachment upload still in flight,
146
- * fire the request, then reconcile or record the failure. `kind` is threaded through because the
147
- * three operations want materially different state transitions — see
148
- * {@link MessageOperationStatePolicy}.
131
+ * The shared lifecycle: apply the optimistic state, settle uploads still in flight, fire the request,
132
+ * then reconcile or record the failure. The per-kind rules are in {@link MessageOperationStatePolicy}.
149
133
  */
150
134
  private async run<K extends OperationKind>(
151
135
  kind: K,
@@ -156,27 +140,22 @@ export class MessageOperations {
156
140
 
157
141
  const optimistic = this.policy.optimistic(kind, params);
158
142
 
159
- // Carries whatever the settle step resolved, so a failure records partial progress and a
160
- // retry re-uploads only what is missing.
143
+ // Carries what the settle step resolved, so a failure records partial progress.
161
144
  let effective = params;
162
145
 
163
146
  try {
164
- // Ordering starts here, after the optimistic update and around the settle + request — the
165
- // transfer is the slow part being ordered.
147
+ // Ordering covers the settle and the request, not the optimistic update.
166
148
  const response = await this.sequenceRequests(kind, async () => {
167
- // An edit composes through the same middleware as a send, so it too can carry a pending
168
- // upload. Only a delete is excluded — it discards the message. Deliberately not the
169
- // `sequenceRequests` predicate, which asks a different question.
149
+ // An edit composes like a send, so it can carry a pending upload. A delete cannot.
170
150
  if (kind !== 'delete') {
171
151
  const settled = await this.withSettledUploads(params);
172
- // Writes the outer `effective`, not a new local — the `catch` is outside this callback
173
- // and needs the settled attachments to report partial success.
152
+ // Assigns the outer `effective`: the `catch` below needs the settled attachments.
174
153
  effective = settled.params;
175
154
  if (settled.failureReason) throw settled.failureReason;
176
155
 
177
156
  // Settling released the local previews, so publish the URLs now or the list points at a
178
- // revoked blob for a round-trip. Patches what is held, since `effective.localMessage`
179
- // still carries the caller's status and a retry would revert to `failed`.
157
+ // revoked blob until the response. Patches what is held, since `effective.localMessage` still
158
+ // has the caller's status (a retry would revert to `failed`).
180
159
  const settledAttachments = effective.localMessage.attachments;
181
160
  const held =
182
161
  settledAttachments === params.localMessage.attachments
@@ -189,8 +168,7 @@ export class MessageOperations {
189
168
  }
190
169
  }
191
170
 
192
- // Destructured defensively: a custom request handler is free to resolve with nothing, and
193
- // the policy's own guard treats a missing message as "no server copy to apply".
171
+ // A custom handler may resolve with nothing, which the policy treats as "no server copy".
194
172
  return await doRequest(effective);
195
173
  });
196
174
  this.policy.success({
@@ -214,10 +192,9 @@ export class MessageOperations {
214
192
  }
215
193
 
216
194
  /*
217
- * Each operation sends through the integrator's handler for its kind
218
- * (`ChannelConfig.requestHandlers`) when one is registered, and through `defaults.<kind>`
219
- * otherwise. A handler is handed the default as `defaultRequest`, so it can still send that way.
220
- * There is deliberately no per-call override: one would win over whatever the host SDK registered.
195
+ * Each operation sends through the integrator's handler for its kind (`ChannelConfig.requestHandlers`)
196
+ * when one is registered, else through `defaults.<kind>`. A handler receives the default as
197
+ * `defaultRequest`. There is no per-call override: it would win over the host SDK's handler.
221
198
  */
222
199
 
223
200
  private resolveRequest<K extends OperationKind>(
@@ -324,12 +301,10 @@ export class MessageOperations {
324
301
  }
325
302
 
326
303
  /**
327
- * Adds a reaction with an optimistic local state update: the reaction is applied to the cached
328
- * message immediately, then the request is sent through the offline queue. The server-authoritative counts reconcile on the response; the reaction is
329
- * rolled back on a definitive failure, and left alone when the request was queued for replay.
330
- *
331
- * The request routes through the channel because reactions are channel-level, while the local write
332
- * is addressed by message id and so reaches a pure thread reply that no channel collection holds.
304
+ * Adds a reaction optimistically: it is applied to the cached message at once, then sent through the
305
+ * offline queue. The response's counts reconcile; a definitive failure rolls it back, a request queued
306
+ * for replay does not. The local write is by message ID, so it also reaches a thread reply that no
307
+ * channel collection holds.
333
308
  */
334
309
  async addReaction({
335
310
  messageId,
@@ -341,8 +316,7 @@ export class MessageOperations {
341
316
  options?: Pick<SendReactionRequest, 'enforce_unique' | 'skip_push'>;
342
317
  }): Promise<void> {
343
318
  const { channel } = this.ctx;
344
- // `reaction` is a REQUEST, so any timestamps on it are `Date`s. The local store speaks the wire
345
- // unit, so bring them across rather than handing a `Date` to a numeric field.
319
+ // `reaction` is a request, so its timestamps are `Date`s. The local store uses the wire unit.
346
320
  const { created_at, updated_at, ...restOfReaction } = reaction;
347
321
  const undo = applyReactionLocally(channel.getClient(), {
348
322
  enforceUnique: options?.enforce_unique ?? false,
@@ -391,9 +365,9 @@ export class MessageOperations {
391
365
  }
392
366
 
393
367
  /**
394
- * The failure rule every operation outside {@link run} shares: a request queued for replay is
395
- * pending, not failed, so its optimistic change stays. Name the operation's OWN task types — every
396
- * task carries the same `messageId`, so "anything queued" would let an unrelated task answer.
368
+ * The failure rule for operations outside {@link run}: a request queued for replay is pending, so its
369
+ * optimistic change stays. Pass the operation's own task types, as every task carries the same
370
+ * `messageId`.
397
371
  */
398
372
  private async rollbackUnlessQueued(
399
373
  messageId: string,
@@ -403,10 +377,7 @@ export class MessageOperations {
403
377
  if (!(await this.ctx.isQueued(messageId, types))) undo?.();
404
378
  }
405
379
 
406
- /**
407
- * Reconciles the server-authoritative copy, but only if we still hold it — a bare upsert of an unheld
408
- * id would orphan it (the store's refcount GC only reclaims held ids).
409
- */
380
+ /** Reconciles the server copy only if still held: a bare upsert of an unheld ID would orphan it. */
410
381
  private reconcileHeldMessage(message: MessageResponse | undefined | null) {
411
382
  if (!message) return;
412
383
  const { messageStore } = this.ctx.channel.getClient();
@@ -8,22 +8,10 @@ import {
8
8
  } from '../utils';
9
9
 
10
10
  /**
11
- * Applies a reaction to the single canonical copy of a message in the client-global
12
- * {@link EntityStore} (`client.messageStore`), addressed purely by id — NOT through any paginator's
13
- * membership. It reads the
14
- * current message POJO (`store.get`), produces a new POJO with the reaction folded into its
15
- * `reaction_groups` / `latest_reactions` (shared count helpers) and `own_reactions`
16
- * ({@link computeOwnReactions}), and writes it back (`store.upsert`). The store then notifies every
17
- * collection currently holding that id — the main-list / thread-reply paginators, a thread's
18
- * subscribed parent, any future consumer — and each re-projects. The message stays a plain object;
19
- * the store's per-id registry is the reactivity.
20
- *
21
- * Because it is keyed by id rather than by a paginator's `getItem`, it reaches a message held by ANY
22
- * collection, including the thread parent that lives in no paginator — with no per-home wiring.
23
- *
24
- * Writes memory (synchronous) + the offline DB (fire-and-forget), and returns an `undo()` reversing
25
- * both on the current state (inverse deltas, concurrency-safe), or `undefined` when the user isn't
26
- * connected or the message isn't in the store.
11
+ * Applies a reaction to the canonical copy of a message in `client.messageStore`, by ID, and mirrors it
12
+ * to the offline DB (fire-and-forget). The store notifies every collection holding the message. Returns
13
+ * an `undo()` reversing both on the current state, or `undefined` when the user is not connected or the
14
+ * message is not in the store.
27
15
  */
28
16
  export const applyReactionLocally = (
29
17
  client: StreamChat,
@@ -34,12 +22,7 @@ export const applyReactionLocally = (
34
22
  removed = false,
35
23
  }: {
36
24
  messageId: string;
37
- /**
38
- * A response-shaped partial the caller already holds — a captured reaction being re-applied by
39
- * `undo()`, or a freshly composed one. Response-shaped rather than `ReactionRequest` because its
40
- * timestamps are the wire's numbers and it flows straight into the message store and the offline
41
- * DB, both of which speak `ReactionResponse`.
42
- */
25
+ /** A response-shaped partial the caller holds, such as a captured reaction re-applied by `undo()`. */
43
26
  reaction: Partial<ReactionResponse> & Pick<ReactionResponse, 'type'>;
44
27
  enforceUnique?: boolean;
45
28
  removed?: boolean;
@@ -51,10 +34,8 @@ export const applyReactionLocally = (
51
34
  if (!user || !existing) return;
52
35
 
53
36
  const now = nowNs();
54
- // Spread `reaction` first so the authoritative fields below win, while still preserving any values
55
- // the caller already carried (e.g. the original `created_at` when undo re-applies a captured
56
- // reaction) via `?? now`. `message_id`/`user`/`user_id` are always derived from this message and
57
- // the connected user, so they never need to come off `reaction`.
37
+ // Spread first so the derived fields below win; `??` keeps what the caller carried (e.g. the
38
+ // original `created_at` on undo).
58
39
  const reactionResponse: ReactionResponse = {
59
40
  ...reaction,
60
41
  created_at: reaction.created_at ?? now,
@@ -67,8 +48,8 @@ export const applyReactionLocally = (
67
48
  user_id: user.id,
68
49
  };
69
50
 
70
- // Capture what this op removes so undo() can restore it faithfully (reaction spread last): the
71
- // deleted reaction for a removal, or the user's displaced reactions for an enforce_unique add.
51
+ // What this op removes, so undo() can restore it: the deleted reaction, or those an enforce_unique
52
+ // add displaces.
72
53
  const removedReactions: ReactionResponse[] = removed
73
54
  ? (existing.own_reactions?.filter((r) => r.type === reactionResponse.type) ?? [])
74
55
  : enforceUnique
@@ -9,17 +9,12 @@ import type { PendingTaskOf, QueueableType } from '../offline-support/types';
9
9
  import type { Thread } from '../thread';
10
10
 
11
11
  /**
12
- * Builds the `MessageOperations` a message collection owns, shared by `Channel` and `Thread` so the
13
- * two cannot drift.
14
- *
15
- * Everything it needs is derivable from the collection: a `Thread` sends against its parent channel
16
- * and stamps its own id as `parent_id`, a `Channel` against itself with no stamp.
12
+ * Builds the `MessageOperations` a message collection owns, shared by `Channel` and `Thread`. A
13
+ * `Thread` sends against its parent channel and stamps its own ID as `parent_id`; a `Channel` sends
14
+ * against itself.
17
15
  */
18
16
  export const createMessageOperations = (collection: Channel | Thread) => {
19
- // Read off the paginator rather than discriminating on the collection: it already holds both, and a
20
- // `Channel | Thread` discriminator would have to be either an `instanceof` (a value import that
21
- // closes a module-load cycle back to `channel.ts`) or a duck-type that a codegen run could silently
22
- // invert.
17
+ // Read off the paginator, which holds both: an `instanceof` check would import `channel.ts` back.
23
18
  const paginator = collection.messagePaginator;
24
19
  const { channel, parentMessageId } = paginator;
25
20
 
@@ -27,8 +22,8 @@ export const createMessageOperations = (collection: Channel | Thread) => {
27
22
  task: PendingTaskOf<T>,
28
23
  { queue = true }: { queue?: boolean } = {},
29
24
  ) => queueOrRun({ channel, client: channel.getClient(), queue, task });
30
- // Read on every call, because a channel created from its member list only gets an id once the
31
- // server has created it.
25
+ // Read on every call: a channel created from its member list only gets an ID once the server has
26
+ // created it.
32
27
  const channelTaskData = () => ({ channelId: channel.id, channelType: channel.type });
33
28
 
34
29
  return new MessageOperations({
@@ -42,15 +37,13 @@ export const createMessageOperations = (collection: Channel | Thread) => {
42
37
  settlePendingUploads: (attachments) =>
43
38
  settlePendingAttachmentUploads({
44
39
  attachments,
45
- // A reply uploads against the channel the thread belongs to - there is no thread-scoped
46
- // upload target.
40
+ // A reply uploads against its channel: there is no thread-scoped upload target.
47
41
  channelCid: channel.cid,
48
42
  client: channel.getClient(),
49
43
  }),
50
44
  channel,
51
- // We don't wait for the offline DB here. It only mirrors what's in memory, so if it isn't ready
52
- // or the write fails, the message operation should carry on as if nothing happened.
53
- // Replies are stored under their channel, like any other message.
45
+ // Not awaited: the offline DB only mirrors memory, so a slow or failed write must not affect the
46
+ // operation. Replies are stored under their channel.
54
47
  persist: (message) => {
55
48
  channel.getClient().offlineDb?.executeQuerySafely(
56
49
  (db) =>
@@ -71,14 +64,9 @@ export const createMessageOperations = (collection: Channel | Thread) => {
71
64
  isQueuedForReplay(channel.getClient(), messageId, types),
72
65
  ingest: (m) => {
73
66
  const store = channel.getClient().messageStore;
74
- // The paginator is the entry point whenever it can hold the message — it owns interval
75
- // placement, and its "no longer matches the filter" branch correctly evicts a message that
76
- // stopped matching. But its filter is `{ cid, parent_id? }`, so an operation aimed at a message
77
- // this paginator does not accept (most importantly a THREAD PARENT edited or deleted from
78
- // inside the open thread, which the reply paginator rejects for having no `parent_id`) would
79
- // otherwise be silently dropped. Falling back to the client-global store reaches the message
80
- // wherever it is held and fans out to every collection holding it — the same reason
81
- // `applyReactionLocally` addresses purely by id.
67
+ // The paginator ingests what matches its filter (`{ cid, parent_id? }`). Otherwise fall back to
68
+ // the client-global store, so an operation on a message the paginator rejects (a thread parent
69
+ // edited from inside its thread) is not dropped.
82
70
  if (paginator.matchesFilter(m)) {
83
71
  paginator.ingestItem(m);
84
72
  } else if (store.has(m.id)) {
@@ -86,10 +74,8 @@ export const createMessageOperations = (collection: Channel | Thread) => {
86
74
  }
87
75
  store.flushSubscribers(m.id);
88
76
  },
89
- // Mirrors `ingest`'s routing: a message this paginator does not hold can still be held by the
90
- // client-global store (a thread parent, a message displayed by another collection), and the
91
- // policy uses this both for its freshness comparison and to decide whether there is anything to
92
- // update optimistically at all. Reading only the paginator would make those two disagree.
77
+ // Mirrors `ingest`: a message the paginator does not hold may still be in the client-global store
78
+ // (a thread parent).
93
79
  get: (id) => paginator.getItem(id) ?? channel.getClient().messageStore.get(id),
94
80
  remove: (id) => {
95
81
  const client = channel.getClient();
@@ -106,9 +92,8 @@ export const createMessageOperations = (collection: Channel | Thread) => {
106
92
  ...(parentMessageId
107
93
  ? { normalizeOutgoingMessage: (m) => ({ ...m, parent_id: parentMessageId }) }
108
94
  : {}),
109
- // We stop typing before the send and don't wait for it. A send with an upload can take as long
110
- // as the transfer, and everyone would see us typing the whole time. A thread reply stops the
111
- // typing in its thread.
95
+ // Typing stops before the send, without waiting for it: a send with an upload lasts as long as the
96
+ // transfer. A thread reply stops typing in its thread.
112
97
  beforeSend: () => {
113
98
  if (collection.messageComposer.config.text.publishTypingEvents) {
114
99
  channel.stopTyping(parentMessageId).catch(() => undefined);
@@ -141,7 +126,6 @@ export const createMessageOperations = (collection: Channel | Thread) => {
141
126
  updateMessageRequest({ localMessage, options }, defaultRequest)),
142
127
  };
143
128
  },
144
- // The HTTP requests, through the offline queue so they replay on reconnect.
145
129
  defaults: {
146
130
  delete: async (id, o) => {
147
131
  const { message } = await queueOrRunTask({
@@ -159,7 +143,7 @@ export const createMessageOperations = (collection: Channel | Thread) => {
159
143
  payload: [{ message: m, ...o }],
160
144
  type: 'send-message',
161
145
  },
162
- // Without a message id there is nothing to key a queue entry on, so it just runs.
146
+ // Without a message ID there is nothing to key a queue entry on, so it just runs.
163
147
  { queue: !!m.id },
164
148
  );
165
149
  return { message };
@@ -3,20 +3,12 @@ import type { StreamChat } from '../client';
3
3
  import type { LocalMessage, MessageResponse, ReactionResponse } from '../types';
4
4
 
5
5
  /**
6
- * Applies a `reaction.new` / `reaction.updated` / `reaction.deleted` event to the canonical copy of
7
- * the message, addressed by id — the server-event counterpart of `applyReactionLocally`.
6
+ * Applies a `reaction.new` / `reaction.updated` / `reaction.deleted` event to the canonical copy of the
7
+ * message, by ID. The event's counts are taken as they are; `own_reactions` is derived from what the
8
+ * store holds, because the event omits the current user's reactions or reports another user's.
8
9
  *
9
- * The event carries the server's updated counts, so those are taken as they are; only `own_reactions`
10
- * is derived, because the event either omits the current user's reactions or reports another user's.
11
- * The base for that derivation is whatever the store already holds, so a reaction by someone else
12
- * cannot wipe yours.
13
- *
14
- * One write reaches every collection holding the message — main list, pinned list, thread replies,
15
- * and a thread's subscribed parent, which lives in no paginator at all. Calling it once per
16
- * collection instead is what produced 9 publishes for a single reaction: each call minted a fresh
17
- * object, so the store's reference bail never fired and every write re-projected the others.
18
- *
19
- * No-op when nothing holds the message — there is no view to update.
10
+ * One write reaches every collection holding the message (main list, pinned list, thread replies, a
11
+ * thread's parent). No-op when nothing holds the message.
20
12
  */
21
13
  export const reflectReactionEvent = (
22
14
  client: StreamChat,
@@ -4,12 +4,9 @@ import type { MessageComposer } from '../messageComposer/messageComposer';
4
4
  import type { OperationKind } from './types';
5
5
 
6
6
  /**
7
- * The ordering policy `Channel` and `Thread` both install as
8
- * {@link MessageOperationsContext.sequenceRequests}.
9
- *
10
- * Sends and retries wait for each other while the composer may hand over still-uploading files,
11
- * so a short text sent after a photo is not dated first. Edits and deletes never wait. Shared so
12
- * both owners keep the same rule; the tag differs, a thread reply being tagged by its channel.
7
+ * The {@link MessageOperationsContext.sequenceRequests} policy of `Channel` and `Thread`. Sends and
8
+ * retries wait for each other while the composer may hand over still-uploading files, so a short text
9
+ * sent after a photo is not dated first. Edits and deletes never wait.
13
10
  */
14
11
  export const keepSendOrderWhilePendingUploadsAllowed = <T>({
15
12
  channelCid,
@@ -17,7 +14,7 @@ export const keepSendOrderWhilePendingUploadsAllowed = <T>({
17
14
  kind,
18
15
  request,
19
16
  }: {
20
- /** Scope of the ordering — a thread passes its channel's cid. */
17
+ /** Scope of the ordering: a thread passes its channel's cid. */
21
18
  channelCid: string;
22
19
  composer: MessageComposer;
23
20
  kind: OperationKind;
@@ -29,34 +29,24 @@ const applyUploadResult = (
29
29
  (enriched as LocalNotImageAttachment).thumb_url = response.thumb_url;
30
30
  }
31
31
 
32
- // The message has owned this preview since the composition was handed over — see
33
- // `createPostUploadAttachmentEnrichmentMiddleware`, which stops revoking once the composer
34
- // no longer holds the attachment.
32
+ // The message owns this preview once the composition is handed over.
35
33
  const { previewUri } = attachment.localMetadata;
36
34
  if (previewUri?.startsWith('blob:')) URL.revokeObjectURL?.(previewUri);
37
35
 
38
- // `localMetadata` is dropped, not read - the attachment leaves here as a plain server payload.
36
+ // `localMetadata` is dropped: the attachment leaves as a plain server payload.
39
37
  const { localMetadata: _localMetadata, ...rest } = enriched;
40
38
  return rest;
41
39
  };
42
40
 
43
41
  /**
44
- * Settles the uploads of any attachment that is still in flight, and reports the outcome.
42
+ * Settles the uploads of attachments still in flight and reports the outcome. Unresolved attachments
43
+ * only reach the send path when {@link AttachmentManagerConfig.pendingUploadsEnabled} is on.
44
+ * {@link UploadManager.upload} is idempotent by `localMetadata.id`, so this awaits the composer's
45
+ * request rather than starting a second one; an upload that never started (a retry, an offline replay)
46
+ * starts here. A `failed` upload is retried, while `blocked` is left alone since no retry can settle it.
45
47
  *
46
- * A message only ever reaches the send path with an unresolved attachment when
47
- * {@link AttachmentManagerConfig.pendingUploadsEnabled} is on — otherwise the composition
48
- * middleware discards such a composition instead. {@link UploadManager.upload} is idempotent by
49
- * `localMetadata.id`, so this awaits the request the composer already started rather than
50
- * starting a second one; an attachment whose upload never started (a retry, an offline replay)
51
- * is uploaded here for the first time.
52
- *
53
- * An upload that already `failed` is retried here rather than dropped — offline is the case that
54
- * needs it, where the first attempt could not have succeeded. `blocked` is left alone: the
55
- * server's upload configuration refused it, so no retry can settle it.
56
- *
57
- * Resolved attachments come back carrying their URL and **without** `localMetadata`, and their
58
- * local preview is revoked. Failed ones are returned untouched, `localMetadata` and all, so a
59
- * retry re-uploads only what is still missing.
48
+ * Resolved attachments come back with their URL, without `localMetadata`, and with their local preview
49
+ * revoked. Failed ones come back untouched, so a retry re-uploads only what is missing.
60
50
  */
61
51
  export const settlePendingAttachmentUploads = async ({
62
52
  attachments,
@@ -96,8 +86,7 @@ export const settlePendingAttachmentUploads = async ({
96
86
  return;
97
87
  }
98
88
 
99
- // Deliberately `allSettled`, and the resolved URLs above are kept even though the message as
100
- // a whole now fails: a retry then only re-uploads what did not make it.
89
+ // Resolved URLs above are kept even when the message fails: a retry re-uploads only the rest.
101
90
  if (!failureReason) {
102
91
  failureReason =
103
92
  result.status === 'rejected'
@@ -62,32 +62,20 @@ export type MessageOperationsHandlers = {
62
62
  };
63
63
 
64
64
  export type MessageOperationsContext = {
65
- /**
66
- * The channel every request and offline-DB row belongs to. A `Thread` passes its parent channel,
67
- * since a reply is sent, persisted and reacted to against the channel like any other message. It is
68
- * what lets the reaction operations live here rather than being written once per owner.
69
- */
65
+ /** The channel every request and offline-DB row belongs to. A `Thread` passes its parent channel. */
70
66
  channel: Channel;
71
67
  ingest: (m: LocalMessage) => void;
72
68
  get: (id: string) => LocalMessage | undefined;
73
- /**
74
- * Drops the message from local state entirely. Needed by the delete lifecycle: a hard delete removes
75
- * the message rather than marking it `deleted` (mirroring the `message.deleted` WS handler, which
76
- * branches on `event.hard_delete` the same way).
77
- */
69
+ /** Drops the message from local state: a hard delete removes it rather than marking it `deleted`. */
78
70
  remove: (id: string) => void;
79
- /**
80
- * Mirrors a message into the offline DB. Fire-and-forget: local state is the source of truth, so a
81
- * failed DB write must never fail the operation.
82
- */
71
+ /** Mirrors a message into the offline DB. Fire-and-forget: a failed write never fails the operation. */
83
72
  persist: (m: LocalMessage) => void;
84
73
  /** Removes a message's offline-DB row (the hard-delete counterpart of {@link persist}). */
85
74
  purge: (id: string) => void;
86
75
  /**
87
- * Whether this message's mutation is sitting in the offline queue waiting to be replayed — read from
88
- * the queue, not inferred from the error ({@link isQueuedForReplay}). A queued mutation is pending,
89
- * not failed, so the optimistic state stays exactly as it is: no `failed` status, no error, no revert.
90
- * Reactions run the same predicate, which is what keeps the two from drifting.
76
+ * Whether this message's mutation sits in the offline queue waiting to be replayed, read from the
77
+ * queue rather than inferred from the error ({@link isQueuedForReplay}). A queued mutation is pending,
78
+ * not failed: the optimistic state stays as it is. Reactions use the same predicate.
91
79
  */
92
80
  isQueued: (messageId: string, types: readonly QueueableType[]) => Promise<boolean>;
93
81
 
@@ -97,25 +85,22 @@ export type MessageOperationsContext = {
97
85
  beforeSend?: () => void;
98
86
 
99
87
  /**
100
- * Lets the owner run a request on its own instead of in parallel — the server dates a message
101
- * on arrival, so a short text sent after a photo would otherwise be dated first. Wraps the
102
- * request only; call it once and return its result.
88
+ * Lets the owner serialize requests: the server dates a message on arrival, so a short text sent after
89
+ * a photo would otherwise be dated first. Wraps the request only; call it once and return its result.
103
90
  */
104
91
  sequenceRequests?: <T>(kind: OperationKind, request: () => Promise<T>) => Promise<T>;
105
92
 
106
93
  /**
107
- * Resolves any attachment upload still in flight, returning the attachments with their URLs
108
- * written on. Supplied by the owner, which knows the target `cid` and the client. Only reachable
109
- * with {@link AttachmentManagerConfig.pendingUploadsEnabled} on.
94
+ * Resolves any attachment upload still in flight, returning the attachments with their URLs written
95
+ * on. Only reachable with {@link AttachmentManagerConfig.pendingUploadsEnabled} on.
110
96
  */
111
97
  settlePendingUploads?: (
112
98
  attachments: NonNullable<LocalMessage['attachments']>,
113
99
  ) => Promise<{
114
100
  /**
115
- * The same list, with each upload that resolved replaced by its uploaded form — URL written,
116
- * `localMetadata` dropped. Ones that did not resolve come back untouched, so on failure this
117
- * is a mix; `failureReason` is what distinguishes the two cases. Returned by reference when
118
- * nothing was pending.
101
+ * The same list, with each resolved upload replaced by its uploaded form (URL written,
102
+ * `localMetadata` dropped). Unresolved ones come back untouched, so on failure this is a mix. The
103
+ * same reference when nothing was pending.
119
104
  */
120
105
  attachments: NonNullable<LocalMessage['attachments']>;
121
106
  /** Set if any upload failed. The ones that did resolve are still kept above. */
@@ -123,8 +108,8 @@ export type MessageOperationsContext = {
123
108
  }>;
124
109
 
125
110
  /**
126
- * The HTTP requests, through the offline queue — used when no integrator {@link handlers} entry
127
- * replaces them. A replaced request still reaches them through its `defaultRequest`.
111
+ * The HTTP requests, through the offline queue, used when no {@link handlers} entry replaces them.
112
+ * A replaced request still reaches them through its `defaultRequest`.
128
113
  */
129
114
  defaults: {
130
115
  delete: (id: string, o?: DeleteMessageOptions) => Promise<OperationResponse>;
package/src/middleware.ts CHANGED
@@ -21,12 +21,11 @@ export type MiddlewareExecutionResult<TValue> = {
21
21
  export type ExecuteParams<TValue> = {
22
22
  eventName: string;
23
23
  initialValue: TValue;
24
- /*
25
- Determines how the concurrently run middleware handlers will be executed:
26
- - async - all handlers are executed even though the same handler is invoked more than once
27
- - cancelable - previously invoked handlers of the same eventName that have not yet resolved are canceled
24
+ /**
25
+ * `cancelable`: a new run cancels the unresolved previous run of the same `eventName`.
26
+ * `concurrent`: every run executes. Defaults to `cancelable`.
28
27
  */
29
- mode?: 'concurrent' | 'cancelable'; // default 'cancelable'
28
+ mode?: 'concurrent' | 'cancelable';
30
29
  };
31
30
 
32
31
  export type MiddlewareHandlerParams<TValue> = {
@@ -59,11 +58,9 @@ export class MiddlewareExecutor<TValue, THandlers extends string> {
59
58
  }
60
59
 
61
60
  /**
62
- * The middleware currently installed, in execution order.
63
- *
64
- * Read-only: use `use` / `insert` / `replace` / `setOrder` / `remove` to change the chain. It
65
- * exists so components can ask what the chain is capable of - a middleware may declare
66
- * behaviour its host has to account for, and the host has no other way to find out.
61
+ * The installed middleware in execution order, read-only, so a host component can check what the
62
+ * chain contains (by `id`). Change the chain with `use`, `insert`, `replace`, `setOrder` or
63
+ * `remove`.
67
64
  */
68
65
  get installedMiddleware(): ReadonlyArray<Middleware<TValue, THandlers>> {
69
66
  return this.middleware;