stream-chat 10.0.0-rc.2 → 10.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/cjs/index.browser.js +15397 -12090
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +15349 -11991
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +15164 -11880
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +246 -6
- package/dist/types/CooldownTimer.d.ts +22 -8
- package/dist/types/EventHandlerPipeline.d.ts +12 -16
- package/dist/types/LiveLocationManager.d.ts +69 -6
- package/dist/types/api-client.d.ts +22 -9
- package/dist/types/channel.d.ts +550 -300
- package/dist/types/channel_state.d.ts +167 -22
- package/dist/types/client.d.ts +325 -305
- package/dist/types/configuration/ConfigController.d.ts +172 -0
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +192 -0
- package/dist/types/configuration/index.d.ts +3 -0
- package/dist/types/configuration/keys.d.ts +31 -0
- package/dist/types/configuration/shape.d.ts +58 -0
- package/dist/types/configuration/types.d.ts +206 -50
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +59 -0
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +1 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +24 -0
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +22 -0
- package/dist/types/configuration/utils/index.d.ts +1 -0
- package/dist/types/configuration/utils/serverAuthority.d.ts +49 -0
- package/dist/types/connection/ConnectionIdManager.d.ts +67 -0
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +164 -0
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +153 -0
- package/dist/types/connection/networkConnection/index.d.ts +3 -0
- package/dist/types/connection/networkConnection/reporters.d.ts +43 -0
- package/dist/types/connection/networkConnection/types.d.ts +55 -0
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +204 -0
- package/dist/types/connection/wsConnection/WSConnection.d.ts +168 -0
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +55 -0
- package/dist/types/connection/wsConnection/config.d.ts +51 -0
- package/dist/types/connection/wsConnection/index.d.ts +4 -0
- package/dist/types/connection/wsConnection/types.d.ts +99 -0
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/entityStore/EntityStore.d.ts +160 -40
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +48 -29
- package/dist/types/entityStore/index.d.ts +0 -1
- package/dist/types/errors.d.ts +24 -4
- package/dist/types/formatMessageMemo.d.ts +5 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +51 -23
- package/dist/types/gen/chat/ChatApi.d.ts +215 -168
- package/dist/types/gen/models/index.d.ts +2164 -557
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +39 -32
- package/dist/types/gen-imports.d.ts +1 -0
- package/dist/types/index.d.ts +20 -7
- package/dist/types/languageNames.d.ts +97 -0
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
- package/dist/types/messageComposer/LocationComposer.d.ts +10 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +11 -0
- package/dist/types/messageComposer/attachmentManager.d.ts +48 -10
- package/dist/types/messageComposer/attachmentUtils.d.ts +34 -0
- package/dist/types/messageComposer/configuration/commands.configuration.d.ts +1 -3
- package/dist/types/messageComposer/configuration/configuration.d.ts +9 -1
- package/dist/types/messageComposer/configuration/index.d.ts +0 -1
- package/dist/types/messageComposer/configuration/types.d.ts +57 -1
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +10 -4
- package/dist/types/messageComposer/messageComposer.d.ts +210 -14
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +20 -1
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +11 -0
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +2 -2
- package/dist/types/messageComposer/middleware/pollComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/middleware/pollComposer/state.d.ts +3 -2
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +9 -2
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +44 -0
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +2 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +94 -229
- package/dist/types/messageComposer/pollComposer.d.ts +8 -3
- package/dist/types/messageComposer/textComposer.d.ts +9 -1
- package/dist/types/messageComposer/types.d.ts +7 -3
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +64 -8
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +48 -11
- package/dist/types/messageOperations/FailedSendCache.d.ts +34 -0
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +52 -6
- package/dist/types/messageOperations/MessageOperations.d.ts +94 -11
- package/dist/types/{entityStore → messageOperations}/applyReactionLocally.d.ts +8 -2
- package/dist/types/messageOperations/createMessageOperations.d.ts +11 -0
- package/dist/types/messageOperations/index.d.ts +7 -1
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +24 -0
- package/dist/types/messageOperations/sendOrdering.d.ts +17 -0
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +28 -0
- package/dist/types/messageOperations/types.d.ts +66 -1
- package/dist/types/middleware.d.ts +8 -0
- package/dist/types/moderation.d.ts +18 -4
- package/dist/types/notifications/NotificationManager.d.ts +43 -2
- package/dist/types/notifications/types.d.ts +55 -42
- package/dist/types/offline-support/offline_support_api.d.ts +128 -12
- package/dist/types/offline-support/offline_sync_manager.d.ts +26 -5
- package/dist/types/offline-support/queueableOperations.d.ts +106 -0
- package/dist/types/offline-support/types.d.ts +77 -28
- package/dist/types/pagination/FilterBuilder.d.ts +1 -18
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -1
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +21 -3
- package/dist/types/pagination/filterCompiler.d.ts +5 -0
- package/dist/types/pagination/paginators/BasePaginator.d.ts +331 -7
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +54 -11
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +283 -66
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +10 -9
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +17 -1
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +8 -8
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +57 -0
- package/dist/types/pagination/paginators/index.d.ts +1 -0
- package/dist/types/pagination/utility.normalization.d.ts +29 -2
- package/dist/types/poll.d.ts +41 -14
- package/dist/types/poll_manager.d.ts +3 -2
- package/dist/types/poll_optimistic_votes.d.ts +61 -0
- package/dist/types/reminders/Reminder.d.ts +17 -7
- package/dist/types/reminders/ReminderManager.d.ts +34 -6
- package/dist/types/search/BaseSearchSource.d.ts +50 -25
- package/dist/types/search/ChannelMemberSearchSource.d.ts +11 -6
- package/dist/types/search/ChannelSearchSource.d.ts +27 -5
- package/dist/types/search/MessageSearchSource.d.ts +36 -6
- package/dist/types/search/SearchController.d.ts +44 -11
- package/dist/types/search/UserSearchSource.d.ts +11 -5
- package/dist/types/search/types.d.ts +14 -1
- package/dist/types/signing.d.ts +0 -157
- package/dist/types/thread.d.ts +118 -62
- package/dist/types/thread_manager.d.ts +124 -35
- package/dist/types/token_manager.d.ts +5 -8
- package/dist/types/types.d.ts +138 -562
- package/dist/types/types.utility.d.ts +8 -0
- package/dist/types/upload-utils.d.ts +20 -0
- package/dist/types/uploadManager.d.ts +50 -2
- package/dist/types/utils/FixedSizeQueueCache.d.ts +2 -0
- package/dist/types/utils/WithSubscriptions.d.ts +1 -1
- package/dist/types/utils/objectPath.d.ts +49 -0
- package/dist/types/utils/time.d.ts +85 -0
- package/dist/types/utils.d.ts +63 -40
- package/package.json +22 -33
- package/src/ChannelManager.ts +561 -109
- package/src/CooldownTimer.ts +55 -45
- package/src/EventHandlerPipeline.ts +13 -23
- package/src/LiveLocationManager.ts +191 -37
- package/src/api-client.ts +144 -53
- package/src/channel.ts +1573 -1050
- package/src/channel_state.ts +239 -129
- package/src/client.ts +843 -892
- package/src/client_state.ts +2 -2
- package/src/configuration/ConfigController.ts +298 -0
- package/src/configuration/InstanceConfigurationRegistry.ts +430 -0
- package/src/configuration/index.ts +7 -0
- package/src/configuration/keys.ts +86 -0
- package/src/configuration/shape.ts +776 -0
- package/src/configuration/types.ts +218 -60
- package/src/configuration/utils/applyInstanceConfiguration.ts +184 -0
- package/src/configuration/utils/copyConfigPatch.ts +61 -0
- package/src/configuration/utils/declarativeSlices.ts +81 -0
- package/src/configuration/utils/deepFreezeConfig.ts +33 -0
- package/src/configuration/utils/index.ts +5 -0
- package/src/configuration/utils/serverAuthority.ts +146 -0
- package/src/connection/ConnectionIdManager.ts +153 -0
- package/src/connection/ConnectionRecoveryManager.ts +371 -0
- package/src/connection/index.ts +4 -0
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +281 -0
- package/src/connection/networkConnection/index.ts +3 -0
- package/src/connection/networkConnection/reporters.ts +85 -0
- package/src/connection/networkConnection/types.ts +60 -0
- package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +242 -151
- package/src/connection/wsConnection/WSConnection.ts +345 -0
- package/src/connection/wsConnection/WSConnectionFallback.ts +259 -0
- package/src/connection/wsConnection/config.ts +108 -0
- package/src/connection/wsConnection/index.ts +4 -0
- package/src/connection/wsConnection/types.ts +101 -0
- package/src/constants.ts +5 -3
- package/src/entityStore/EntityStore.ts +350 -10
- package/src/entityStore/StoreBackedItemIndex.ts +66 -37
- package/src/entityStore/index.ts +0 -1
- package/src/errors.ts +40 -7
- package/src/formatMessageMemo.ts +23 -0
- package/src/gen/chat/ChannelApi.ts +230 -44
- package/src/gen/chat/ChatApi.ts +1047 -1745
- package/src/gen/models/index.ts +2378 -3721
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +218 -388
- package/src/gen-imports.ts +1 -0
- package/src/index.ts +82 -6
- package/src/languageNames.ts +103 -0
- package/src/logger.ts +1 -1
- package/src/messageComposer/CustomDataManager.ts +10 -1
- package/src/messageComposer/LocationComposer.ts +68 -20
- package/src/messageComposer/attachmentIdentity.ts +39 -0
- package/src/messageComposer/attachmentManager.ts +191 -68
- package/src/messageComposer/attachmentUtils.ts +58 -0
- package/src/messageComposer/configuration/commands.configuration.ts +1 -26
- package/src/messageComposer/configuration/configuration.ts +22 -3
- package/src/messageComposer/configuration/index.ts +0 -1
- package/src/messageComposer/configuration/types.ts +58 -1
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/linkPreviewsManager.ts +16 -10
- package/src/messageComposer/messageComposer.ts +487 -98
- package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +58 -33
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +7 -2
- package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +3 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +98 -1
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +20 -10
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +2 -7
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +11 -6
- package/src/messageComposer/middleware/pollComposer/index.ts +1 -0
- package/src/messageComposer/middleware/pollComposer/state.ts +43 -11
- package/src/messageComposer/middleware/pollComposer/types.ts +9 -2
- package/src/messageComposer/middleware/pollComposer/validation.ts +76 -0
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +1 -2
- package/src/messageComposer/middleware/textComposer/mentions.ts +91 -39
- package/src/messageComposer/pollComposer.ts +11 -3
- package/src/messageComposer/textComposer.ts +36 -4
- package/src/messageComposer/types.ts +19 -14
- package/src/messageDelivery/MessageDeliveryReporter.ts +154 -53
- package/src/messageDelivery/MessageReceiptsTracker.ts +136 -64
- package/src/messageOperations/FailedSendCache.ts +90 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +269 -27
- package/src/messageOperations/MessageOperations.ts +340 -136
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +10 -3
- package/src/messageOperations/createMessageOperations.ts +192 -0
- package/src/messageOperations/index.ts +7 -0
- package/src/messageOperations/reflectReactionEvent.ts +51 -0
- package/src/messageOperations/sendOrdering.ts +28 -0
- package/src/messageOperations/settlePendingAttachmentUploads.ts +110 -0
- package/src/messageOperations/types.ts +74 -0
- package/src/middleware.ts +11 -0
- package/src/moderation.ts +47 -24
- package/src/notifications/NotificationManager.ts +73 -3
- package/src/notifications/configuration.ts +10 -8
- package/src/notifications/types.ts +58 -42
- package/src/offline-support/offline_support_api.ts +380 -197
- package/src/offline-support/offline_sync_manager.ts +105 -32
- package/src/offline-support/queueableOperations.ts +270 -0
- package/src/offline-support/types.ts +85 -39
- package/src/pagination/FilterBuilder.ts +1 -22
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +11 -7
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +25 -7
- package/src/pagination/filterCompiler.ts +17 -0
- package/src/pagination/paginators/BasePaginator.ts +731 -81
- package/src/pagination/paginators/ChannelPaginator.ts +210 -102
- package/src/pagination/paginators/MessageIntervalPaginator.ts +703 -193
- package/src/pagination/paginators/MessagePaginator.ts +45 -36
- package/src/pagination/paginators/PinnedMessagePaginator.ts +74 -28
- package/src/pagination/paginators/ReminderPaginator.ts +15 -13
- package/src/pagination/paginators/ThreadPaginator.ts +181 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +8 -1
- package/src/pagination/paginators/index.ts +1 -0
- package/src/pagination/utility.normalization.ts +37 -9
- package/src/poll.ts +189 -112
- package/src/poll_manager.ts +14 -8
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +34 -16
- package/src/reminders/ReminderManager.ts +68 -41
- package/src/reminders/ReminderTimer.ts +7 -6
- package/src/search/BaseSearchSource.ts +133 -40
- package/src/search/ChannelMemberSearchSource.ts +27 -18
- package/src/search/ChannelSearchSource.ts +61 -7
- package/src/search/MessageSearchSource.ts +133 -28
- package/src/search/SearchController.ts +93 -16
- package/src/search/UserSearchSource.ts +27 -13
- package/src/search/types.ts +14 -1
- package/src/signing.ts +1 -315
- package/src/thread.ts +503 -511
- package/src/thread_manager.ts +339 -204
- package/src/token_manager.ts +12 -32
- package/src/types.ts +159 -780
- package/src/types.utility.ts +14 -0
- package/src/upload-utils.ts +53 -0
- package/src/uploadManager.ts +85 -7
- package/src/utils/FixedSizeQueueCache.ts +5 -0
- package/src/utils/WithSubscriptions.ts +1 -1
- package/src/utils/objectPath.ts +67 -0
- package/src/utils/time.ts +104 -0
- package/src/utils.ts +209 -157
- package/dist/types/base64.d.ts +0 -2
- package/dist/types/configuration/InstanceConfigurationService.d.ts +0 -26
- package/dist/types/connection.d.ts +0 -146
- package/dist/types/connection_fallback.d.ts +0 -42
- package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
- package/dist/types/insights.d.ts +0 -58
- package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
- package/dist/types/permissions.d.ts +0 -55
- package/dist/types/store.d.ts +0 -125
- package/src/base64.ts +0 -78
- package/src/configuration/InstanceConfigurationService.ts +0 -73
- package/src/connection_fallback.ts +0 -215
- package/src/gen/model-decoders/decoders.ts +0 -2680
- package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
- package/src/insights.ts +0 -83
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/permissions.ts +0 -102
- package/src/store.ts +0 -304
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ItemLocation } from '../sortCompiler';
|
|
2
|
-
import { StateStore, type ValueOrPatch } from '
|
|
2
|
+
import { StateStore, type ValueOrPatch } from '@stream-io/state-store';
|
|
3
3
|
import { type DebouncedFunc } from '../../utils';
|
|
4
4
|
import type { FieldToDataResolver } from '../types.normalization';
|
|
5
5
|
import type { ItemIndexApi } from '../ItemIndex';
|
|
@@ -149,6 +149,12 @@ export type PaginationQueryParams<Q> = {
|
|
|
149
149
|
queryShape?: Q;
|
|
150
150
|
/** Per-call override of the reset behavior. */
|
|
151
151
|
reset?: StateResetPolicy;
|
|
152
|
+
/**
|
|
153
|
+
* Options for the request the query sends that are not part of its query shape, so they don't
|
|
154
|
+
* decide whether the query starts a new first page. Each paginator documents the ones it reads;
|
|
155
|
+
* others are ignored. Retries send them again.
|
|
156
|
+
*/
|
|
157
|
+
requestOptions?: Record<string, unknown>;
|
|
152
158
|
/**
|
|
153
159
|
* How many times to **retry** a failed request, i.e. `retryCount + 1` attempts in total. Per-call
|
|
154
160
|
* override of `PaginatorOptions.retryCount`, which defaults to 0 (no retry).
|
|
@@ -255,7 +261,35 @@ export interface PaginatorPlugin<T> {
|
|
|
255
261
|
*
|
|
256
262
|
* All registered plugins are executed in the order they appear in this array.
|
|
257
263
|
*/
|
|
264
|
+
/**
|
|
265
|
+
* The value-level subset of paginator configuration that can be supplied declaratively through
|
|
266
|
+
* `client.config`. Structural inputs (`itemIndex`, `createItemIndex`) and subclass behaviour overrides
|
|
267
|
+
* (`doRequest`, `itemOrderComparator`, `deriveCursor`) are deliberately absent — see
|
|
268
|
+
* {@link BasePaginator.initializeConfig}.
|
|
269
|
+
*
|
|
270
|
+
* Declared standalone rather than derived from {@link PaginatorOptions} to avoid a circular type.
|
|
271
|
+
*/
|
|
272
|
+
export type DeclarativePaginatorConfig = {
|
|
273
|
+
debounceMs?: number;
|
|
274
|
+
hasPaginationQueryShapeChanged?: PaginationQueryShapeChangeIdentifier<any>;
|
|
275
|
+
initialCursor?: PaginatorCursor;
|
|
276
|
+
initialOffset?: number;
|
|
277
|
+
lockItemOrder?: boolean;
|
|
278
|
+
maxLoadedItems?: number;
|
|
279
|
+
pageSize?: number;
|
|
280
|
+
retryCount?: number;
|
|
281
|
+
stateThrottleMs?: number;
|
|
282
|
+
throwErrors?: boolean;
|
|
283
|
+
};
|
|
258
284
|
export type PaginatorOptions<T, Q> = {
|
|
285
|
+
/**
|
|
286
|
+
* Declarative configuration for this paginator, supplied by whoever constructs it from
|
|
287
|
+
* `client.config`. Kept separate from the other options so {@link BasePaginator.initializeConfig}
|
|
288
|
+
* can re-derive with a *fresh* slice — a reset then drops declarative values while preserving
|
|
289
|
+
* constructor-injected ones. Excluded from {@link BasePaginatorConfig}: it is an input, not part of
|
|
290
|
+
* the resolved configuration.
|
|
291
|
+
*/
|
|
292
|
+
declarativeConfig?: DeclarativePaginatorConfig;
|
|
259
293
|
/** The number of milliseconds to debounce the search query. The default interval is 300ms. */
|
|
260
294
|
debounceMs?: number;
|
|
261
295
|
/**
|
|
@@ -308,6 +342,17 @@ export type PaginatorOptions<T, Q> = {
|
|
|
308
342
|
* It does not guarantee global stability across interval changes or page jumps.
|
|
309
343
|
*/
|
|
310
344
|
lockItemOrder?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Caps how many items this paginator keeps loaded. Once the head window holds more than this, the
|
|
347
|
+
* oldest are dropped from it as new ones arrive — the paginator's membership is released and the
|
|
348
|
+
* shared store garbage-collects whatever no other holder still references. Pagination stays intact:
|
|
349
|
+
* the window re-opens its tailward edge, so scrolling back simply re-fetches.
|
|
350
|
+
*
|
|
351
|
+
* Unset (the default) means unbounded — see {@link BasePaginator.pruneTailToLimit} for the
|
|
352
|
+
* preconditions a prune must meet. Values below `pageSize` are clamped up to it: a cap smaller than
|
|
353
|
+
* a page would have the next page pruned away the moment it lands.
|
|
354
|
+
*/
|
|
355
|
+
maxLoadedItems?: number;
|
|
311
356
|
/** The item page size to be requested from the server. */
|
|
312
357
|
pageSize?: number;
|
|
313
358
|
/**
|
|
@@ -319,8 +364,17 @@ export type PaginatorOptions<T, Q> = {
|
|
|
319
364
|
/** Prevent silencing the errors thrown during the pagination execution. Default is false. */
|
|
320
365
|
throwErrors?: boolean;
|
|
321
366
|
};
|
|
322
|
-
type OptionalPaginatorConfigFields = 'stateThrottleMs' | '
|
|
323
|
-
|
|
367
|
+
type OptionalPaginatorConfigFields = 'stateThrottleMs' | 'maxLoadedItems' | 'deriveCursor' | 'doRequest' | 'initialCursor' | 'initialOffset' | 'itemOrderComparator' | 'throwErrors';
|
|
368
|
+
/**
|
|
369
|
+
* Construction-only inputs that are not part of the resolved configuration.
|
|
370
|
+
*
|
|
371
|
+
* `itemIndex` and `createItemIndex` are here rather than in {@link BasePaginatorConfig} because the
|
|
372
|
+
* constructor destructures them out before building the config and resolves them once into
|
|
373
|
+
* {@link BasePaginator._itemIndex}. They were typed as config members and never written, so
|
|
374
|
+
* `paginator.config.itemIndex` compiled and returned `undefined` for every paginator ever built.
|
|
375
|
+
*/
|
|
376
|
+
type ResolvedPaginatorOptions<T, Q> = Omit<PaginatorOptions<T, Q>, 'createItemIndex' | 'declarativeConfig' | 'itemIndex'>;
|
|
377
|
+
export type BasePaginatorConfig<T, Q> = Pick<ResolvedPaginatorOptions<T, Q>, OptionalPaginatorConfigFields> & Required<Omit<ResolvedPaginatorOptions<T, Q>, OptionalPaginatorConfigFields>>;
|
|
324
378
|
export declare const DEFAULT_PAGINATION_OPTIONS: BasePaginatorConfig<any, any>;
|
|
325
379
|
export declare abstract class BasePaginator<T, Q> {
|
|
326
380
|
state: StateStore<PaginatorState<T>>;
|
|
@@ -333,7 +387,27 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
333
387
|
* active window + pagination status.
|
|
334
388
|
*/
|
|
335
389
|
intervalViews: StateStore<PaginatorIntervalViews<T>>;
|
|
336
|
-
|
|
390
|
+
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
391
|
+
private readonly configController;
|
|
392
|
+
/**
|
|
393
|
+
* The paginator's resolved configuration, as a store so consumers can react to it.
|
|
394
|
+
*
|
|
395
|
+
* Every configurable class exposes its resolved configuration this way — `configState` for the store,
|
|
396
|
+
* {@link config} for the current value. Before this, paginators held a plain object that changed
|
|
397
|
+
* silently, so anything displaying a paginator's settings had to poll to notice a
|
|
398
|
+
* `client.config.set()` or `reset()`.
|
|
399
|
+
*
|
|
400
|
+
* This is *resolved* configuration, distinct from `client.config`, which holds the configuration you
|
|
401
|
+
* registered. The registered tree is an input to {@link initializeConfig}; this is its output.
|
|
402
|
+
*/
|
|
403
|
+
get configState(): StateStore<BasePaginatorConfig<T, Q>>;
|
|
404
|
+
/**
|
|
405
|
+
* Options this paginator was constructed with, kept so {@link initializeConfig} can rebuild the
|
|
406
|
+
* config from its real inputs instead of restoring a snapshot of the result. Excludes the
|
|
407
|
+
* declarative slice, which is supplied fresh on every call — that is what lets a reset drop
|
|
408
|
+
* declarative configuration while keeping constructor-injected options.
|
|
409
|
+
*/
|
|
410
|
+
private readonly explicitOptions;
|
|
337
411
|
/**
|
|
338
412
|
* Throttle for the active-window `state.items` publish (message list). Created only when
|
|
339
413
|
* `config.stateThrottleMs` is set; drives {@link scheduleWindowPublish} / {@link flushPendingPublishes}. See
|
|
@@ -349,6 +423,21 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
349
423
|
private _viewPublishThrottle?;
|
|
350
424
|
/** Changed ids buffered since the last {@link flushIntervalViewPublish} (throttled paginators only). */
|
|
351
425
|
private _pendingViewChangedIds;
|
|
426
|
+
/**
|
|
427
|
+
* Depth of active {@link batch} `coalesce` scopes. While > 0, `ingestItem` / `removeItem` record
|
|
428
|
+
* that the active window changed (see {@link _suspendedWindowDirty}) instead of publishing it, so
|
|
429
|
+
* the whole batch produces a single `state.items` emit — independent of state throttling.
|
|
430
|
+
*/
|
|
431
|
+
private _windowPublishSuspendDepth;
|
|
432
|
+
/**
|
|
433
|
+
* The interval a prune just shortened. A prune also moves `hasMoreTail` and `cursor` and those come with
|
|
434
|
+
* the next `state.items` publish rather than emitting their own. We use the id instead of direct values
|
|
435
|
+
* because that publish can be a throttle interval late, so {@link consumePendingPrunePaginationState} rereads them
|
|
436
|
+
* when it fires.
|
|
437
|
+
*/
|
|
438
|
+
private _prunedIntervalId?;
|
|
439
|
+
/** Set by a suspended op that changed the active window, so {@link batch} publishes once on exit. */
|
|
440
|
+
private _suspendedWindowDirty;
|
|
352
441
|
/**
|
|
353
442
|
* Intervals keep items in disconnected ranges.
|
|
354
443
|
* That is a scenario of jumping to non-sequential pages.
|
|
@@ -404,7 +493,14 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
404
493
|
* - the meaning of the head edge (controlled by `intervalItemIdsAreHeadFirst`)
|
|
405
494
|
*/
|
|
406
495
|
protected get intervalSortDirection(): 'asc' | 'desc';
|
|
407
|
-
|
|
496
|
+
/**
|
|
497
|
+
* @param options - what the **integrator** passed. Stage 3, so it outranks the declarative tree.
|
|
498
|
+
* @param builtInDefaults - what the SDK supplies on this instance's behalf — a subclass's defaults, or
|
|
499
|
+
* an owner's for the object it builds. Stage 1, so a `client.config.set()` overrides it. Keeping the
|
|
500
|
+
* two apart is what lets the documented layer order apply here at all: they arrive through the same
|
|
501
|
+
* object otherwise, and a paginator built with no configuration already carries four of them.
|
|
502
|
+
*/
|
|
503
|
+
protected constructor({ declarativeConfig, initialCursor, initialOffset, itemIndex, createItemIndex, ...options }?: PaginatorOptions<T, Q>, builtInDefaults?: Partial<BasePaginatorConfig<T, Q>>);
|
|
408
504
|
get lastQueryError(): Error | undefined;
|
|
409
505
|
get hasMoreTail(): boolean;
|
|
410
506
|
get hasMoreHead(): boolean;
|
|
@@ -445,6 +541,20 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
445
541
|
get headmostItem(): T | undefined;
|
|
446
542
|
get cursor(): PaginatorCursor | undefined;
|
|
447
543
|
get offset(): number | undefined;
|
|
544
|
+
/**
|
|
545
|
+
* The current resolved configuration.
|
|
546
|
+
*
|
|
547
|
+
* `Readonly` on purpose: the value is the store's live object, so assigning to a field of it would
|
|
548
|
+
* mutate state without notifying anyone. That used to be the only way to change these values, so the
|
|
549
|
+
* type is what turns those call sites into compile errors rather than silent non-reactive writes —
|
|
550
|
+
* use {@link updateConfig}.
|
|
551
|
+
*/
|
|
552
|
+
get config(): Readonly<BasePaginatorConfig<T, Q>>;
|
|
553
|
+
/**
|
|
554
|
+
* Merges a partial configuration into the resolved config and notifies subscribers, unless every
|
|
555
|
+
* field in the patch already holds an equal value.
|
|
556
|
+
*/
|
|
557
|
+
updateConfig(config: Partial<BasePaginatorConfig<T, Q>>): void;
|
|
448
558
|
get pageSize(): number;
|
|
449
559
|
set pageSize(size: number);
|
|
450
560
|
set initialCursor(cursor: PaginatorCursor);
|
|
@@ -513,13 +623,20 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
513
623
|
* {@link setIntervals}), which bypasses the per-interval {@link commitInterval}/{@link dropInterval}
|
|
514
624
|
* publishing. No-ops when the views are already empty so a reset does not emit needlessly.
|
|
515
625
|
*/
|
|
626
|
+
/**
|
|
627
|
+
* Drops every loaded interval and item without publishing anything, so the next ingest starts from
|
|
628
|
+
* empty storage while `state.items` keeps showing the previous window until the caller publishes.
|
|
629
|
+
*/
|
|
630
|
+
protected clearItemStorage(): void;
|
|
516
631
|
protected clearIntervalViews(): void;
|
|
517
632
|
abstract query(params: PaginationQueryParams<Q>): Promise<PaginationQueryReturnValue<T>>;
|
|
518
633
|
abstract filterQueryResults(items: T[]): T[];
|
|
519
634
|
/**
|
|
520
635
|
* Subclasses must return the query shape.
|
|
521
636
|
*/
|
|
522
|
-
protected getNextQueryShape(_params?: Pick<PaginationQueryParams<Q>, 'direction'>
|
|
637
|
+
protected getNextQueryShape(_params?: Pick<PaginationQueryParams<Q>, 'direction'> & {
|
|
638
|
+
pageSize?: number;
|
|
639
|
+
}): Q;
|
|
523
640
|
/**
|
|
524
641
|
* Filters an item is matched against locally (`matchesFilter`) — NOT the filters sent to the server.
|
|
525
642
|
* A paginator whose backend query is filtered has to build the request filters separately (see
|
|
@@ -539,6 +656,8 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
539
656
|
* live mutation publishes immediately, exactly as before this feature.
|
|
540
657
|
*/
|
|
541
658
|
protected get isStateThrottled(): boolean;
|
|
659
|
+
/** True while a coalescing {@link batch} scope is suspending this paginator's own window publishes. */
|
|
660
|
+
protected get isWindowPublishSuspended(): boolean;
|
|
542
661
|
/** Re-project the active window from its (live, source-of-truth) interval. `undefined` when inactive. */
|
|
543
662
|
private projectActiveWindow;
|
|
544
663
|
/**
|
|
@@ -554,11 +673,119 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
554
673
|
* {@link isStateThrottled}. Safe to call many times within one op — they coalesce to a single emit.
|
|
555
674
|
*/
|
|
556
675
|
protected scheduleWindowPublish(): void;
|
|
676
|
+
/**
|
|
677
|
+
* Run `fn` with this paginator's window publishes suspended, emitting once on exit.
|
|
678
|
+
*
|
|
679
|
+
* A replace is internally remove-then-insert and each half changes the window, so without this one
|
|
680
|
+
* logical `ingestItem` emits twice.
|
|
681
|
+
*
|
|
682
|
+
* `exit` decides how the single emit leaves the scope: `auto` rides the throttle when there is one
|
|
683
|
+
* (live ops, where successive events should coalesce across the trailing edge), `sync` always
|
|
684
|
+
* flushes ({@link batch}, whose contract is that a one-shot operation settles in a single update).
|
|
685
|
+
*
|
|
686
|
+
* **`lockItemOrder` lists are excluded.** Their emit is not a re-projection but a republish of the
|
|
687
|
+
* last-published array with the item spliced back at its original index, and exiting through
|
|
688
|
+
* {@link flushWindowPublish} re-derives from the active interval — reordering the list and dropping
|
|
689
|
+
* whatever the interval no longer holds, which is the whole point of locking the order.
|
|
690
|
+
*
|
|
691
|
+
* Re-entrant: only the outermost scope emits, so an `ingestItem` inside a coalescing `batch`
|
|
692
|
+
* defers to the batch.
|
|
693
|
+
*/
|
|
694
|
+
protected withSingleWindowPublish(fn: () => void, { exit }?: {
|
|
695
|
+
exit?: 'auto' | 'sync';
|
|
696
|
+
}): void;
|
|
557
697
|
/**
|
|
558
698
|
* Flush any pending throttled window + interval-view publishes immediately. No-op when nothing
|
|
559
699
|
* is pending or throttling is off.
|
|
560
700
|
*/
|
|
561
701
|
protected flushPendingPublishes(): void;
|
|
702
|
+
/**
|
|
703
|
+
* Whether pruning is on hold. `false` here means a paginator with no UI attached or a UI that
|
|
704
|
+
* never reports, still gets its configured cap. For example, a specific UI can ask pruning
|
|
705
|
+
* to not happen unless we are near to the tailing edge.
|
|
706
|
+
*/
|
|
707
|
+
protected get isPruningSuspended(): boolean;
|
|
708
|
+
/**
|
|
709
|
+
* Whether the server knows about `item`. That is what makes its id safe to send as a cursor, and it
|
|
710
|
+
* is all this checks — the id itself is never looked at. `true` here for anything present;
|
|
711
|
+
* subclasses holding locally-created items (an unsent message) narrow it. Both halves of a prune
|
|
712
|
+
* ask: an item the server knows may be dropped, and only such an item may become the window's new
|
|
713
|
+
* tailward cursor.
|
|
714
|
+
*/
|
|
715
|
+
protected isPaginationAnchorable(item: T | undefined): boolean;
|
|
716
|
+
/**
|
|
717
|
+
* The configured window cap, or `undefined` when unbounded. Clamped up to `pageSize`: a cap below a
|
|
718
|
+
* page would prune the page that a tailward query had just fetched, and `onEndReached` would fetch
|
|
719
|
+
* it again — a loop. Read fresh (both inputs are runtime-configurable), never cached.
|
|
720
|
+
*/
|
|
721
|
+
protected get effectiveMaxLoadedItems(): number | undefined;
|
|
722
|
+
/**
|
|
723
|
+
* Drops the oldest items from `interval` until at most `maxLoadedItems` remain, releasing each from
|
|
724
|
+
* the item index so the shared store can garbage-collect whatever no other holder references.
|
|
725
|
+
*
|
|
726
|
+
* ## Where this is called from, and why that matters
|
|
727
|
+
*
|
|
728
|
+
* From `ingestItem`, on the interval `insertItemIdIntoInterval` just returned — a **copy that has
|
|
729
|
+
* not been committed yet**. So this mutates an object nothing can observe, the single
|
|
730
|
+
* `commitInterval` that follows stores and republishes the already-pruned interval, and the window
|
|
731
|
+
* emit after it projects from the same interval. A prune therefore costs **no publish of its own**:
|
|
732
|
+
* it rides the ones the ingest was going to make anyway. That is the whole design — see
|
|
733
|
+
* {@link _prunedIntervalId} for the pagination half.
|
|
734
|
+
*
|
|
735
|
+
* ## Preconditions
|
|
736
|
+
*
|
|
737
|
+
* All must hold, or this is a no-op:
|
|
738
|
+
* - a cap is configured
|
|
739
|
+
* - the consumer has not suspended pruning ({@link isPruningSuspended})
|
|
740
|
+
* - the interval is anchored, is the dataset head, and is the active one. A jumped-away window is
|
|
741
|
+
* what the user is reading, and a logical interval has no pagination provenance — nothing dropped
|
|
742
|
+
* from it could ever be fetched back
|
|
743
|
+
* - it actually holds more than the cap
|
|
744
|
+
*
|
|
745
|
+
* Assumes cursor pagination: it drops ids without going through `removeItem`, so
|
|
746
|
+
* {@link shrinkOffsetAfterRemoval} never runs and an offset-paginated list would drift. That is not
|
|
747
|
+
* a reachable configuration today — `maxLoadedItems` only reaches message paginators — so it is
|
|
748
|
+
* stated rather than guarded.
|
|
749
|
+
*
|
|
750
|
+
* Items the server does not know about ({@link isPaginationAnchorable}) are **skipped, not stopped
|
|
751
|
+
* at**: an unsent message sorts by the time it was composed, so a cap would otherwise destroy it.
|
|
752
|
+
* Skipping leaves the window a few items above the cap at worst, and the next arrival trims it again.
|
|
753
|
+
*
|
|
754
|
+
* @returns whether anything was pruned.
|
|
755
|
+
*/
|
|
756
|
+
protected pruneTailToLimit(interval: AnyInterval): boolean;
|
|
757
|
+
/**
|
|
758
|
+
* The id at one pagination edge of `interval` that is usable as a cursor — the edge-most item the
|
|
759
|
+
* server knows about. Not simply `itemIds[0]`: a prune skips locally-created items, so the outermost
|
|
760
|
+
* id can be one the server has never seen, and paginating from it would send a client-generated id
|
|
761
|
+
* as `id_lt`.
|
|
762
|
+
*/
|
|
763
|
+
private getPaginationEdgeId;
|
|
764
|
+
/**
|
|
765
|
+
* Filters `items` down to the members of `interval`, preserving their given order. Used by the
|
|
766
|
+
* order-locked emit path, which composes its array from the previously published one instead of
|
|
767
|
+
* re-projecting, and so needs pruned ids taken out explicitly.
|
|
768
|
+
*/
|
|
769
|
+
private retainIntervalMembers;
|
|
770
|
+
/**
|
|
771
|
+
* The `state` pagination fields that a prune moved, derived from the **committed** active interval
|
|
772
|
+
* at call time and cleared. Called by every path that publishes the active window, so they ride that
|
|
773
|
+
* publish instead of emitting their own ({@link _prunedIntervalId} explains why this derives rather
|
|
774
|
+
* than replaying what the prune saw).
|
|
775
|
+
*
|
|
776
|
+
* Returns only fields that actually changed, so an unchanged `cursor` keeps its object identity and
|
|
777
|
+
* consumers selecting it are not woken.
|
|
778
|
+
*
|
|
779
|
+
* Three things it deliberately leaves alone:
|
|
780
|
+
* - a window that is no longer the pruned one. `state` tracks the active interval, so once the
|
|
781
|
+
* consumer has jumped elsewhere the prune says nothing about what is being published.
|
|
782
|
+
* - `cursor.headward`, which the prune never touched — carried over verbatim rather than re-derived,
|
|
783
|
+
* so a `config.deriveCursor` hook's verdict on the head edge survives.
|
|
784
|
+
* - a null tail edge (a window whose every remaining item is locally-created). Publishing `null`
|
|
785
|
+
* would read as "tailward exhausted"; the existing cursor still names a message the *server* has,
|
|
786
|
+
* so leaving it in place keeps back-pagination working.
|
|
787
|
+
*/
|
|
788
|
+
private consumePendingPrunePaginationState;
|
|
562
789
|
/**
|
|
563
790
|
* {@link _viewPublishThrottle} boundary: apply every interval-view change buffered since the last
|
|
564
791
|
* flush, then clear the buffer. Independent of the `state.items` window publish, so a view update
|
|
@@ -764,7 +991,34 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
764
991
|
* - if this is the active interval, re-emit state.items from interval
|
|
765
992
|
*/
|
|
766
993
|
ingestItem(ingestedItem: T): boolean;
|
|
994
|
+
private applyItemIngestion;
|
|
995
|
+
/**
|
|
996
|
+
* Run `fn` as one batched mutation over this paginator's items, collapsing the redundant emits a
|
|
997
|
+
* naive per-item loop would produce:
|
|
998
|
+
*
|
|
999
|
+
* - **Shared-store fan-out** (always, via the `_itemIndex.batch` wrapper): per-item store
|
|
1000
|
+
* notifications fold into a single flush, so sibling holders of the same ids (e.g. a thread /
|
|
1001
|
+
* pinned paginator sharing the entity) re-project once, not once per item. Inert for single-home
|
|
1002
|
+
* paginators (channels, reminders, user groups) whose index is over a private store with no
|
|
1003
|
+
* sibling subscribers — there it is a plain passthrough.
|
|
1004
|
+
* - **This paginator's own active window** (`coalesce: true`): every `ingestItem` / `removeItem`
|
|
1005
|
+
* inside `fn` records that the window changed instead of publishing it, then `batch` emits the
|
|
1006
|
+
* settled window exactly once on exit via {@link flushWindowPublish}. This is deterministic and
|
|
1007
|
+
* independent of state throttling — unlike leaving it off, where an un-throttled paginator emits
|
|
1008
|
+
* once per item and a throttled one merely coalesces within its 500ms window. Use it for one-shot
|
|
1009
|
+
* operations (reconciliation, reload re-ingest) that must settle in a single update. Omit it in WS
|
|
1010
|
+
* event handlers, where per-event publishes should ride the throttle so successive events coalesce
|
|
1011
|
+
* across its trailing edge rather than each forcing a synchronous emit.
|
|
1012
|
+
*/
|
|
1013
|
+
batch(fn: () => void, { coalesce }?: {
|
|
1014
|
+
coalesce?: boolean;
|
|
1015
|
+
}): void;
|
|
767
1016
|
protected removeItemAtCoordinates(coords: ItemCoordinates): ItemCoordinates;
|
|
1017
|
+
/**
|
|
1018
|
+
* Keeps `offset` addressing the same position in the *server's* result set after an item left the
|
|
1019
|
+
* loaded window.
|
|
1020
|
+
*/
|
|
1021
|
+
protected shrinkOffsetAfterRemoval(coordinates?: ItemCoordinates): void;
|
|
768
1022
|
/**
|
|
769
1023
|
* Meaning of location values
|
|
770
1024
|
* - currentIndex === -1 could not be found
|
|
@@ -780,7 +1034,77 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
780
1034
|
}): ItemCoordinates;
|
|
781
1035
|
/** Sets the items in the state, ingesting them so the active interval is updated. */
|
|
782
1036
|
setItems({ valueOrFactory, cursor, isFirstPage, isLastPage, }: SetPaginatorItemsParams<T>): void;
|
|
1037
|
+
/**
|
|
1038
|
+
* Records the shape a query would have used to produce the currently loaded window, so the next
|
|
1039
|
+
* pagination counts as a continuation rather than a shape change.
|
|
1040
|
+
*
|
|
1041
|
+
* Server data reaches a window without a query on two paths — a seeded page (`setItems`) and a
|
|
1042
|
+
* hydrate (`mergeNewestPage`). Leaving `_lastQueryShape` undefined afterwards makes the next
|
|
1043
|
+
* query look like a shape change, so `executeQuery` takes its first-page branch and publishes
|
|
1044
|
+
* `getStateBeforeFirstQuery()` (items `undefined`) BEFORE the request. A response with items
|
|
1045
|
+
* rebuilds the window from the surviving intervals, so that case merely churns; an empty one — a
|
|
1046
|
+
* tailward query on a thread whose replies are all loaded — has nothing to rebuild from and the
|
|
1047
|
+
* loaded window is lost.
|
|
1048
|
+
*
|
|
1049
|
+
* Only meaningful with items in hand: an empty window has no shape to continue from, and the
|
|
1050
|
+
* flags already say there is nothing more to fetch.
|
|
1051
|
+
*/
|
|
1052
|
+
protected recordLoadedWindowQueryShape(): void;
|
|
783
1053
|
setDebounceOptions: ({ debounceMs }: PaginatorDebounceOptions) => void;
|
|
1054
|
+
/**
|
|
1055
|
+
* Rebuilds the state-publish throttles for a new interval, or drops them when the interval is unset.
|
|
1056
|
+
*
|
|
1057
|
+
* This exists because `stateThrottleMs` is read *once*: the throttles capture the interval in their
|
|
1058
|
+
* closures, so assigning `config.stateThrottleMs` afterwards does nothing at all — an unthrottled
|
|
1059
|
+
* paginator never gains a throttle, and a throttled one keeps its original interval. Anything
|
|
1060
|
+
* changing the value at runtime (declarative configuration registered after construction, or
|
|
1061
|
+
* `client.config.reset()`) has to come through here.
|
|
1062
|
+
*
|
|
1063
|
+
* Pending publishes are flushed first, so a swap cannot swallow a trailing-edge emit that was
|
|
1064
|
+
* already scheduled.
|
|
1065
|
+
*/
|
|
1066
|
+
setStateThrottleOptions: ({ stateThrottleMs }: {
|
|
1067
|
+
stateThrottleMs?: number;
|
|
1068
|
+
}) => void;
|
|
1069
|
+
/** Rebuilds the state-publish throttles for a new interval, or drops them when it is unset. */
|
|
1070
|
+
private rebuildStatePublishThrottles;
|
|
1071
|
+
/**
|
|
1072
|
+
* Re-derives this paginator's configuration from its real inputs: package defaults, the options it
|
|
1073
|
+
* was constructed with, and the declarative slice passed in.
|
|
1074
|
+
*
|
|
1075
|
+
* Called by the constructor and by `client.config.reset()` (through the owning `Channel` / `Thread`),
|
|
1076
|
+
* so the two share one code path and cannot drift. Both read-once fields are routed through their
|
|
1077
|
+
* rebuild setters, because assigning them would be silently discarded.
|
|
1078
|
+
*
|
|
1079
|
+
* Structural wiring is untouched here because it never reaches `config` in the first place:
|
|
1080
|
+
* `itemIndex` and `createItemIndex` are destructured out of the constructor's options and resolved
|
|
1081
|
+
* once into {@link _itemIndex}, so there is nothing in the derived config for a re-derivation to drop.
|
|
1082
|
+
*
|
|
1083
|
+
* Subclass behaviour overrides are folded in through {@link getBehaviourOverrides} rather than written
|
|
1084
|
+
* afterwards, so one re-derivation is one `configState` publish carrying a complete config. It used to
|
|
1085
|
+
* be a second write from an `initializeConfig` override, and the claim that both writes carried a
|
|
1086
|
+
* complete config was wrong: the base derivation knows nothing of the overlay, so it published the
|
|
1087
|
+
* config with `doRequest`, `deriveCursor` and `itemOrderComparator` **stripped**, and the subclass then
|
|
1088
|
+
* put them back. A `PinnedMessagePaginator` re-derivation emitted three notifications, of which the
|
|
1089
|
+
* first had no request function at all — a subscriber that paginated during that synchronous window
|
|
1090
|
+
* would have found none.
|
|
1091
|
+
*
|
|
1092
|
+
* Applied last, so the overlay still wins over constructor options exactly as the second write did.
|
|
1093
|
+
*/
|
|
1094
|
+
initializeConfig(declarativeConfig?: DeclarativePaginatorConfig): void;
|
|
1095
|
+
/**
|
|
1096
|
+
* Behaviour a subclass installs that no set of options can express — a comparator or `deriveCursor`
|
|
1097
|
+
* closed over `this`, a `doRequest` bound to a particular endpoint. Empty on the base paginator.
|
|
1098
|
+
*
|
|
1099
|
+
* Folded into the single derivation in {@link initializeConfig}, which is why an override must return
|
|
1100
|
+
* **stable references**: rebuilding the closures on each call makes every derived config differ from
|
|
1101
|
+
* the last, defeating the guard above and republishing on every unrelated re-derivation. Memoize them
|
|
1102
|
+
* — their inputs are fixed at construction.
|
|
1103
|
+
*
|
|
1104
|
+
* Called only after construction. The base constructor builds `configState` directly rather than
|
|
1105
|
+
* through `initializeConfig`, so an override is never invoked before its own fields are initialized.
|
|
1106
|
+
*/
|
|
1107
|
+
protected getBehaviourOverrides(): Partial<BasePaginatorConfig<T, Q>>;
|
|
784
1108
|
protected shouldResetStateBeforeQuery(prevQueryShape: unknown | undefined, nextQueryShape: unknown | undefined): boolean;
|
|
785
1109
|
protected canExecuteQuery: ({ direction, reset, }: {
|
|
786
1110
|
direction?: PaginationDirection;
|
|
@@ -809,7 +1133,7 @@ export declare abstract class BasePaginator<T, Q> {
|
|
|
809
1133
|
* @param params.silent - Suppress loading/state updates for this query.
|
|
810
1134
|
* @param params.updateState - Whether to write the query results back to state.
|
|
811
1135
|
*/
|
|
812
|
-
executeQuery({ direction, keepPreviousItems, queryShape: forcedQueryShape, reset, retryCount, silent, updateState, }?: PaginationQueryParams<Q>): Promise<ExecuteQueryReturnValue<T> | void>;
|
|
1136
|
+
executeQuery({ direction, keepPreviousItems, queryShape: forcedQueryShape, requestOptions, reset, retryCount, silent, updateState, }?: PaginationQueryParams<Q>): Promise<ExecuteQueryReturnValue<T> | void>;
|
|
813
1137
|
postQueryReconcile({ direction, isFirstPage, keepPreviousItems, queryShape, requestedPageSize, results, updateState, }: PostQueryReconcileParams<T, Q>): ExecuteQueryReturnValue<T>;
|
|
814
1138
|
cancelScheduledQuery(): void;
|
|
815
1139
|
resetState(): void;
|
|
@@ -2,9 +2,10 @@ import type { ItemCoordinates, PaginationQueryParams, PaginationQueryReturnValue
|
|
|
2
2
|
import { BasePaginator } from './BasePaginator';
|
|
3
3
|
import type { FilterBuilderOptions } from '../FilterBuilder';
|
|
4
4
|
import { FilterBuilder } from '../FilterBuilder';
|
|
5
|
+
import type { EntityStore } from '../../entityStore/EntityStore';
|
|
5
6
|
import type { StreamChat } from '../../client';
|
|
6
7
|
import type { Channel } from '../../channel';
|
|
7
|
-
import type { ChannelFilters, ChannelOptions,
|
|
8
|
+
import type { ChannelFilters, ChannelOptions, ChannelStateOptions, ParsedPredefinedFilterResponse, QueryChannelsRequest, SortParamRequest } from '../../types';
|
|
8
9
|
/**
|
|
9
10
|
* The `queryChannels` request this paginator will send, plus the client-only `stateOptions`.
|
|
10
11
|
*
|
|
@@ -21,7 +22,7 @@ export type ChannelPaginatorState = PaginatorState<Channel>;
|
|
|
21
22
|
export type ChannelPaginatorRequestOptions = Partial<Omit<ChannelOptions, 'offset' | 'limit'>>;
|
|
22
23
|
export type ChannelSortComparatorFactoryParams = {
|
|
23
24
|
/** Sort the comparator is being built for — the effective sort, so a backend-resolved sort template. */
|
|
24
|
-
sort:
|
|
25
|
+
sort: SortParamRequest[];
|
|
25
26
|
/**
|
|
26
27
|
* The comparator `ChannelPaginator` would use for this sort. Delegate to it for the fields you do not
|
|
27
28
|
* want to handle yourself instead of reimplementing channel field resolution and the cid tiebreaker.
|
|
@@ -42,8 +43,15 @@ export type ChannelPaginatorOptions = {
|
|
|
42
43
|
id?: string;
|
|
43
44
|
paginatorOptions?: PaginatorOptions<Channel, ChannelQueryShape>;
|
|
44
45
|
requestOptions?: ChannelPaginatorRequestOptions;
|
|
45
|
-
sort?:
|
|
46
|
+
sort?: SortParamRequest[];
|
|
46
47
|
sortComparatorFactory?: ChannelSortComparatorFactory;
|
|
48
|
+
/**
|
|
49
|
+
* The channel store the list's index holds its channels in. Defaults to `client.channelManager`'s
|
|
50
|
+
* store, so every list shares one instance per cid and keeps the channels it lists stored.
|
|
51
|
+
*
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
store?: EntityStore<Channel>;
|
|
47
55
|
};
|
|
48
56
|
/**
|
|
49
57
|
* A paginated channel list. Filters are described along three independent axes — the names follow them:
|
|
@@ -68,7 +76,7 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
68
76
|
private readonly _id;
|
|
69
77
|
private client;
|
|
70
78
|
protected _staticFilters: ChannelFilters | undefined;
|
|
71
|
-
protected _sort:
|
|
79
|
+
protected _sort: SortParamRequest[] | undefined;
|
|
72
80
|
protected _options: ChannelPaginatorRequestOptions | undefined;
|
|
73
81
|
protected _channelStateOptions: ChannelStateOptions | undefined;
|
|
74
82
|
protected _nextQueryShape: ChannelQueryShape | undefined;
|
|
@@ -79,10 +87,19 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
79
87
|
* `postQueryReconcile` decides whether it should be committed (first page only).
|
|
80
88
|
*/
|
|
81
89
|
private _pendingPredefinedFilter;
|
|
90
|
+
/**
|
|
91
|
+
* True while the loaded items came ONLY from the offline cache - seeded by `setItems`, never
|
|
92
|
+
* confirmed by a query. Such a state has no pagination position worth continuing from, so the seed
|
|
93
|
+
* records `offset = <cache size>` and a query shape, which is what makes the next query look like a
|
|
94
|
+
* continuation rather than a first page. See `executeQuery`.
|
|
95
|
+
*/
|
|
96
|
+
private _itemsLoadedFromOfflineDB;
|
|
97
|
+
/** The query in flight refreshes a cache-only window, so its response replaces the window. */
|
|
98
|
+
private _replaceOfflineSeedOnResponse;
|
|
82
99
|
protected _sortComparatorFactory: ChannelSortComparatorFactory | undefined;
|
|
83
100
|
sortComparator: (a: Channel, b: Channel) => number;
|
|
84
101
|
filterBuilder: FilterBuilder<ChannelFilters>;
|
|
85
|
-
constructor({ channelStateOptions, client, id, filterBuilderOptions, filters, paginatorOptions, requestOptions, sort, sortComparatorFactory, }: ChannelPaginatorOptions);
|
|
102
|
+
constructor({ channelStateOptions, client, id, filterBuilderOptions, filters, paginatorOptions, requestOptions, sort, sortComparatorFactory, store, }: ChannelPaginatorOptions);
|
|
86
103
|
/**
|
|
87
104
|
* Builds the comparator for the given sort — the single construction point, so every rebuild (the
|
|
88
105
|
* `sort` setter, a backend-resolved predefined sort) keeps the channel-specific path resolver and the
|
|
@@ -94,11 +111,11 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
94
111
|
* supply `sortComparatorFactory` (it is consulted on every rebuild and may delegate to
|
|
95
112
|
* `defaultComparator`), or override this method in a subclass.
|
|
96
113
|
*/
|
|
97
|
-
protected buildSortComparator(sort:
|
|
114
|
+
protected buildSortComparator(sort: SortParamRequest[]): (a: Channel, b: Channel) => number;
|
|
98
115
|
get id(): string;
|
|
99
116
|
get isOfflineSupportEnabled(): boolean;
|
|
100
117
|
get staticFilters(): ChannelFilters | undefined;
|
|
101
|
-
get sort():
|
|
118
|
+
get sort(): SortParamRequest[];
|
|
102
119
|
/**
|
|
103
120
|
* What the backend reported it actually filtered and sorted by for the last first-page query —
|
|
104
121
|
* `QueryChannelsResponse.predefined_filter` (`name`, `filter`, and `sort` when the stored filter
|
|
@@ -117,11 +134,11 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
117
134
|
* backend-resolved predefined filter takes precedence over the requested sort, matching backend
|
|
118
135
|
* precedence rules.
|
|
119
136
|
*/
|
|
120
|
-
get effectiveSort():
|
|
137
|
+
get effectiveSort(): SortParamRequest[];
|
|
121
138
|
get options(): ChannelOptions | undefined;
|
|
122
139
|
get channelStateOptions(): ChannelStateOptions | undefined;
|
|
123
140
|
set staticFilters(filters: ChannelFilters | undefined);
|
|
124
|
-
set sort(sort:
|
|
141
|
+
set sort(sort: SortParamRequest[] | undefined);
|
|
125
142
|
set options(options: ChannelPaginatorRequestOptions | undefined);
|
|
126
143
|
set channelStateOptions(options: ChannelStateOptions | undefined);
|
|
127
144
|
get sortComparatorFactory(): ChannelSortComparatorFactory | undefined;
|
|
@@ -162,7 +179,9 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
162
179
|
* `matchesFilter` and the comparators this metadata feeds.
|
|
163
180
|
*/
|
|
164
181
|
postQueryReconcile(params: PostQueryReconcileParams<Channel, ChannelQueryShape>): import("./BasePaginator").ExecuteQueryReturnValue<Channel>;
|
|
165
|
-
protected getNextQueryShape(
|
|
182
|
+
protected getNextQueryShape({ pageSize, }?: {
|
|
183
|
+
pageSize?: number;
|
|
184
|
+
}): ChannelQueryShape;
|
|
166
185
|
/** The query that produced the currently loaded list, i.e. the cache key its cids belong under. */
|
|
167
186
|
protected get loadedQueryRequest(): QueryChannelsRequest;
|
|
168
187
|
/**
|
|
@@ -174,6 +193,11 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
174
193
|
* `predefined_filter` / `filter_values` / `sort_values` appear, without which two predefined-filter
|
|
175
194
|
* lists cannot be told apart. The duplication goes away once `convertFilterSortToQuery` derives the
|
|
176
195
|
* key from `options` (a change in that implementation plus a schema-version bump to flush stale rows).
|
|
196
|
+
*
|
|
197
|
+
* The resolved `predefinedFilter` rides along with the order it produced: a cache-seeded list has no
|
|
198
|
+
* response to learn it from, and without it `effectiveFilters` / `effectiveSort` fall back to the
|
|
199
|
+
* local filters and the default sort - i.e. it would match and order by a different rule than the
|
|
200
|
+
* one the cached order came from.
|
|
177
201
|
*/
|
|
178
202
|
protected cacheCidsForQuery({ cids, request, }: {
|
|
179
203
|
cids: string[];
|
|
@@ -204,7 +228,26 @@ export declare class ChannelPaginator extends BasePaginator<Channel, ChannelQuer
|
|
|
204
228
|
query: () => Promise<PaginationQueryReturnValue<Channel>>;
|
|
205
229
|
filterQueryResults: (items: Channel[]) => Channel[];
|
|
206
230
|
setItems(params: SetPaginatorItemsParams<Channel>): void;
|
|
207
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Places `channel` in the list if it matches, or drops it if it no longer does. A provisional
|
|
233
|
+
* channel (created from members, still without an id) is refused: it is stored under a temporary
|
|
234
|
+
* cid until its first query gives it the real one, and a list holding it would keep the temporary
|
|
235
|
+
* cid. It is listed once it has its id, as the channels in a server page always do. Another
|
|
236
|
+
* instance for a stored cid (a superseded one, or one made with `new Channel()`) is replaced by
|
|
237
|
+
* the stored instance (see `ChannelManager.resolveListedChannel`).
|
|
238
|
+
*/
|
|
239
|
+
ingestItem(input: Channel): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Entity-store subscriber (as the owner of its index). A channel publishes its own changes through
|
|
242
|
+
* `channel.state`, so the list has nothing to re-project when the store reports a change.
|
|
243
|
+
*/
|
|
244
|
+
onEntitiesChanged(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Entity-store subscriber: the store removed a channel this list holds (a known end, logout), so
|
|
247
|
+
* the list drops it from its windows.
|
|
248
|
+
*/
|
|
249
|
+
onEntityRemoved(id: string, channel: unknown): void;
|
|
250
|
+
resetState(): void;
|
|
208
251
|
removeItem(params: {
|
|
209
252
|
id?: string;
|
|
210
253
|
item?: Channel;
|