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.
- package/dist/cjs/index.browser.js +2196 -3902
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +2197 -3902
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +2199 -3905
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +120 -233
- package/dist/types/CooldownTimer.d.ts +8 -23
- package/dist/types/EventHandlerPipeline.d.ts +17 -37
- package/dist/types/LiveLocationManager.d.ts +22 -50
- package/dist/types/api-client.d.ts +9 -14
- package/dist/types/channel.d.ts +253 -448
- package/dist/types/channel_state.d.ts +48 -95
- package/dist/types/client.d.ts +245 -370
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +30 -124
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +59 -87
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
- package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
- package/dist/types/connection/networkConnection/types.d.ts +12 -27
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
- package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
- package/dist/types/connection/wsConnection/config.d.ts +8 -28
- package/dist/types/connection/wsConnection/types.d.ts +17 -70
- package/dist/types/entityStore/EntityStore.d.ts +153 -113
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
- package/dist/types/errors.d.ts +7 -19
- package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
- package/dist/types/gen/chat/ChatApi.d.ts +28 -14
- package/dist/types/gen/models/index.d.ts +769 -86
- package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/types/languageNames.d.ts +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
- package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
- package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +29 -56
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
- package/dist/types/messageComposer/messageComposer.d.ts +30 -164
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +8 -4
- package/dist/types/messageComposer/textComposer.d.ts +3 -9
- package/dist/types/messageComposer/types.d.ts +5 -8
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
- package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
- package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
- package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
- package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
- package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
- package/dist/types/messageOperations/types.d.ts +15 -30
- package/dist/types/middleware.d.ts +7 -5
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +8 -31
- package/dist/types/notifications/types.d.ts +19 -59
- package/dist/types/offline-support/offline_support_api.d.ts +145 -539
- package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
- package/dist/types/offline-support/queueableOperations.d.ts +24 -52
- package/dist/types/offline-support/types.d.ts +24 -187
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +14 -14
- package/dist/types/poll_manager.d.ts +11 -2
- package/dist/types/poll_optimistic_votes.d.ts +10 -14
- package/dist/types/reminders/Reminder.d.ts +4 -4
- package/dist/types/reminders/ReminderManager.d.ts +7 -20
- package/dist/types/search/BaseSearchSource.d.ts +7 -12
- package/dist/types/search/ChannelSearchSource.d.ts +7 -7
- package/dist/types/search/MessageSearchSource.d.ts +7 -9
- package/dist/types/search/SearchController.d.ts +17 -22
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +23 -71
- package/dist/types/thread_manager.d.ts +45 -70
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +64 -125
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +17 -45
- package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
- package/dist/types/utils/WithSubscriptions.d.ts +5 -15
- package/dist/types/utils/concurrency.d.ts +11 -19
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +24 -64
- package/dist/types/utils.d.ts +40 -86
- package/package.json +7 -2
- package/src/ChannelManager.ts +159 -300
- package/src/CooldownTimer.ts +11 -29
- package/src/EventHandlerPipeline.ts +21 -44
- package/src/LiveLocationManager.ts +35 -74
- package/src/api-client.ts +43 -61
- package/src/campaign.ts +1 -1
- package/src/channel.ts +396 -749
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +50 -105
- package/src/client.ts +360 -588
- package/src/client_state.ts +1 -6
- package/src/configuration/ConfigController.ts +41 -157
- package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +67 -70
- package/src/configuration/types.ts +60 -100
- package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +20 -49
- package/src/connection/ConnectionRecoveryManager.ts +51 -178
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
- package/src/connection/networkConnection/reporters.ts +9 -36
- package/src/connection/networkConnection/types.ts +12 -27
- package/src/connection/wsConnection/StableWSConnection.ts +73 -193
- package/src/connection/wsConnection/WSConnection.ts +56 -131
- package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
- package/src/connection/wsConnection/config.ts +13 -48
- package/src/connection/wsConnection/types.ts +17 -70
- package/src/constants.ts +4 -4
- package/src/entityStore/EntityStore.ts +162 -167
- package/src/entityStore/StoreBackedItemIndex.ts +14 -47
- package/src/errors.ts +7 -19
- package/src/formatMessageMemo.ts +3 -9
- package/src/gen/chat/ChannelApi.ts +19 -0
- package/src/gen/chat/ChatApi.ts +87 -13
- package/src/gen/models/index.ts +793 -71
- package/src/gen/moderation/ModerationApi.ts +0 -4
- package/src/index.ts +10 -14
- package/src/languageNames.ts +9 -24
- package/src/logger.ts +1 -3
- package/src/messageComposer/LocationComposer.ts +7 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +2 -13
- package/src/messageComposer/attachmentManager.ts +17 -63
- package/src/messageComposer/attachmentUtils.ts +3 -17
- package/src/messageComposer/configuration/configuration.ts +5 -8
- package/src/messageComposer/configuration/types.ts +29 -56
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/linkPreviewsManager.ts +8 -20
- package/src/messageComposer/messageComposer.ts +54 -222
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +11 -8
- package/src/messageComposer/textComposer.ts +9 -59
- package/src/messageComposer/types.ts +9 -12
- package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
- package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
- package/src/messageOperations/FailedSendCache.ts +4 -9
- package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
- package/src/messageOperations/MessageOperations.ts +33 -62
- package/src/messageOperations/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +17 -33
- package/src/messageOperations/reflectReactionEvent.ts +5 -13
- package/src/messageOperations/sendOrdering.ts +4 -7
- package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
- package/src/messageOperations/types.ts +15 -30
- package/src/middleware.ts +7 -10
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +11 -35
- package/src/notifications/types.ts +19 -59
- package/src/offline-support/offline_support_api.ts +178 -608
- package/src/offline-support/offline_sync_manager.ts +25 -69
- package/src/offline-support/queueableOperations.ts +31 -84
- package/src/offline-support/types.ts +25 -188
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/paginators/BasePaginator.ts +422 -976
- package/src/pagination/paginators/ChannelPaginator.ts +130 -190
- package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
- package/src/pagination/paginators/MessagePaginator.ts +135 -175
- package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
- package/src/pagination/paginators/ReminderPaginator.ts +12 -15
- package/src/pagination/paginators/ThreadPaginator.ts +16 -26
- package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +19 -19
- package/src/poll_manager.ts +16 -20
- package/src/poll_optimistic_votes.ts +17 -22
- package/src/reminders/Reminder.ts +5 -6
- package/src/reminders/ReminderManager.ts +9 -34
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +14 -29
- package/src/search/ChannelSearchSource.ts +8 -8
- package/src/search/MessageSearchSource.ts +19 -25
- package/src/search/SearchController.ts +18 -24
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +72 -173
- package/src/thread_manager.ts +59 -76
- package/src/token_manager.ts +11 -21
- package/src/types.ts +78 -126
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +22 -54
- package/src/utils/FixedSizeQueueCache.ts +13 -21
- package/src/utils/WithSubscriptions.ts +5 -15
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +26 -66
- package/src/utils.ts +72 -128
|
@@ -2,31 +2,21 @@ import type { StreamChat } from '../client';
|
|
|
2
2
|
import type { AbstractOfflineDB } from './offline_support_api';
|
|
3
3
|
import type { Unsubscribe } from '@stream-io/state-store';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Responsible for detecting connection changes, syncing channel data, and executing
|
|
8
|
-
* pending tasks queued during offline periods. This class ensures the database remains
|
|
9
|
-
* consistent with the server once connectivity is restored.
|
|
5
|
+
* Keeps the offline DB in line with the server. When the socket becomes healthy it replays the
|
|
6
|
+
* tasks queued while offline, then syncs missed events into the DB.
|
|
10
7
|
*/
|
|
11
8
|
export declare class OfflineDBSyncManager {
|
|
12
9
|
isSynced: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Releases the subscription to the socket's status store. A bare unsubscribe now that this reads a
|
|
15
|
-
* store rather than an event, which no longer wraps it in an object.
|
|
16
|
-
*/
|
|
10
|
+
/** Releases the subscription to the socket's status store. */
|
|
17
11
|
connectionChangedListener: Unsubscribe | null;
|
|
18
12
|
private syncStatusListeners;
|
|
19
13
|
private scheduledSyncStatusCallbacks;
|
|
20
14
|
private client;
|
|
21
15
|
private offlineDb;
|
|
22
16
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* bring visible surfaces up to date.
|
|
27
|
-
*
|
|
28
|
-
* `undefined` or any non-positive value means "no limit" and event replay always
|
|
29
|
-
* runs with whatever maximum the server decides to return.
|
|
17
|
+
* Cap on the events a single `/sync` response may contain. Above it, event replay into local
|
|
18
|
+
* storage is skipped and the reconnect-time channel refresh updates what is visible. `undefined`
|
|
19
|
+
* or non-positive means no limit.
|
|
30
20
|
*/
|
|
31
21
|
readonly syncMaxEventCount?: number;
|
|
32
22
|
constructor({ client, offlineDb, syncMaxEventCount, }: {
|
|
@@ -35,14 +25,12 @@ export declare class OfflineDBSyncManager {
|
|
|
35
25
|
syncMaxEventCount?: number;
|
|
36
26
|
});
|
|
37
27
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* Cleans up old listeners if re-initialized to avoid memory leaks.
|
|
41
|
-
* Starts syncing immediately if already connected, otherwise waits for reconnection.
|
|
28
|
+
* Syncs immediately when the socket is already healthy, then on every later healthy transition.
|
|
29
|
+
* Re-initializing replaces the previous subscription.
|
|
42
30
|
*/
|
|
43
31
|
init: () => Promise<void>;
|
|
44
32
|
/**
|
|
45
|
-
*
|
|
33
|
+
* Calls `listener` with the new sync status on every change.
|
|
46
34
|
*
|
|
47
35
|
* @param listener - A callback invoked with the new sync status (`true` or `false`).
|
|
48
36
|
* @returns An object with an `unsubscribe` function to remove the listener.
|
|
@@ -51,34 +39,22 @@ export declare class OfflineDBSyncManager {
|
|
|
51
39
|
unsubscribe: () => void;
|
|
52
40
|
};
|
|
53
41
|
/**
|
|
54
|
-
*
|
|
42
|
+
* Runs a callback once, the next time the sync status turns `true` (after the next sync attempt,
|
|
43
|
+
* even a failed one).
|
|
55
44
|
*
|
|
56
|
-
* @param tag - A unique key to identify and manage the callback.
|
|
45
|
+
* @param tag - A unique key to identify and manage the callback. Scheduling the same tag replaces
|
|
46
|
+
* it.
|
|
57
47
|
* @param callback - An async function to run after sync.
|
|
58
48
|
*/
|
|
59
49
|
scheduleSyncStatusChangeCallback: (tag: string | symbol, callback: () => Promise<void>) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Invokes all registered sync status listeners and executes any scheduled sync callbacks.
|
|
62
|
-
*
|
|
63
|
-
* @param status - The new sync status (`true` or `false`).
|
|
64
|
-
*/
|
|
50
|
+
/** Notifies the listeners and, on `true`, runs and clears the scheduled callbacks. */
|
|
65
51
|
private invokeSyncStatusListeners;
|
|
66
|
-
/**
|
|
67
|
-
* Performs synchronization with the Stream backend.
|
|
68
|
-
*
|
|
69
|
-
* This includes downloading events since the last sync, updating the local DB,
|
|
70
|
-
* and handling sync failures (e.g., if syncing beyond the allowed retention window).
|
|
71
|
-
*/
|
|
52
|
+
/** Replays the events since the last sync into the DB, or resets the DB if too much was missed. */
|
|
72
53
|
private sync;
|
|
73
54
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* neither can escape to the callers (init + the status subscription).
|
|
78
|
-
* This guarantees the subsequent invokeSyncStatusListeners(true) always runs,
|
|
79
|
-
* so isSynced recovers to true and gated channel queries are unblocked.
|
|
80
|
-
* Failed syncs degrade to "possibly stale data until the next query" rather
|
|
81
|
-
* than freezing all future queries. See issue #1816.
|
|
55
|
+
* Replays queued tasks, then syncs. Each step swallows its own failure so the caller always goes
|
|
56
|
+
* on to `invokeSyncStatusListeners(true)`: a failed sync leaves possibly stale data rather than
|
|
57
|
+
* blocking later channel queries.
|
|
82
58
|
*/
|
|
83
59
|
private syncAndExecutePendingTasks;
|
|
84
60
|
}
|
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
import type { Channel } from '../channel';
|
|
2
2
|
import type { StreamChat } from '../client';
|
|
3
3
|
import type { PendingTaskOf, QueueableResult, QueueableType } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* How one queued operation runs, on a first attempt and on a replay.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
4
9
|
export type QueueableOperation<T extends QueueableType> = {
|
|
5
|
-
/**
|
|
6
|
-
* How a failed QUEUEING attempt is logged. Declared per operation rather than passed in per call,
|
|
7
|
-
* because the wording is a property of the operation, not of the caller — and the caller is then left
|
|
8
|
-
* saying only which operation it wants.
|
|
9
|
-
*/
|
|
10
|
+
/** How a rejected `queueTask` attempt is logged. */
|
|
10
11
|
logFailureAs: {
|
|
11
12
|
message: string;
|
|
12
13
|
method: string;
|
|
13
14
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Whether a replay has to look the channel up from the task. Such a task is only queued when it
|
|
16
|
-
* carries `channelId` and `channelType`, because without them it could never be replayed.
|
|
17
|
-
*/
|
|
15
|
+
/** Whether a replay needs the channel. Such a task is only queued with a channel type and ID. */
|
|
18
16
|
needsChannel: boolean;
|
|
19
17
|
/**
|
|
20
|
-
* Performs the request.
|
|
21
|
-
*
|
|
22
|
-
* `channel` is the instance the CALLER already holds, when there is one. A first attempt comes from a
|
|
23
|
-
* channel's or thread's `messageOperations`, or a `Channel` method such as `createDraft`, and must run
|
|
24
|
-
* on that exact channel; only a replay has to look one up.
|
|
18
|
+
* Performs the request. `channel` is the instance the caller already holds (a first attempt); a
|
|
19
|
+
* replay has none and resolves it from the task.
|
|
25
20
|
*/
|
|
26
21
|
run: (params: {
|
|
27
22
|
channel?: Channel;
|
|
28
23
|
client: StreamChat;
|
|
29
24
|
task: PendingTaskOf<T>;
|
|
30
25
|
}) => Promise<QueueableResult<T>>;
|
|
31
|
-
/**
|
|
32
|
-
* Local state to settle AFTER a replay, and only after a replay — a first attempt has an optimistic
|
|
33
|
-
* layer above it that already owns this. Declared per operation rather than hidden in a branch,
|
|
34
|
-
* because "a replay does more than a first attempt" is the kind of asymmetry that goes unnoticed.
|
|
35
|
-
*/
|
|
26
|
+
/** Settles local state after a replay only: a first attempt has an optimistic layer for it. */
|
|
36
27
|
onReplay?: (params: {
|
|
37
28
|
client: StreamChat;
|
|
38
29
|
result: QueueableResult<T>;
|
|
@@ -40,8 +31,7 @@ export type QueueableOperation<T extends QueueableType> = {
|
|
|
40
31
|
}) => void;
|
|
41
32
|
};
|
|
42
33
|
/**
|
|
43
|
-
*
|
|
44
|
-
* compile.
|
|
34
|
+
* One entry per queueable operation.
|
|
45
35
|
*
|
|
46
36
|
* @internal
|
|
47
37
|
*/
|
|
@@ -49,30 +39,16 @@ export declare const QUEUEABLE_OPERATIONS: {
|
|
|
49
39
|
[T in QueueableType]: QueueableOperation<T>;
|
|
50
40
|
};
|
|
51
41
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* rejected — run it directly.
|
|
42
|
+
* Runs the task through `offlineDb.queueTask` (queued for replay on an ephemeral failure), or
|
|
43
|
+
* directly when there is no offline DB, `queue` is `false` or the task is not replayable.
|
|
55
44
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* and the replay were two independent statements of the same thing.
|
|
59
|
-
*
|
|
60
|
-
* Note the direct call is BOTH the no-offline-DB path — its actual purpose — and, on a queue failure, a
|
|
61
|
-
* second attempt at a request that may already have reached the server. That predates this helper and
|
|
62
|
-
* is unchanged by it; having one place to fix it is a reason this exists.
|
|
63
|
-
*
|
|
64
|
-
* A failed queueing attempt is logged, not rethrown: falling back to running the request directly is
|
|
65
|
-
* the point. What it is logged as comes off the operation's own `logFailureAs`, so a caller says which
|
|
66
|
-
* operation it wants and nothing about how to describe it.
|
|
45
|
+
* If `queueTask` rejects, the failure is logged and the request runs directly. It may already have
|
|
46
|
+
* reached the server or been stored for replay, so it can repeat.
|
|
67
47
|
*
|
|
68
48
|
* @internal
|
|
69
49
|
*
|
|
70
|
-
* @param params.channel - The channel instance
|
|
71
|
-
*
|
|
72
|
-
* @param params.client - Resolves the operation, and carries the offline DB when one is registered.
|
|
73
|
-
* @param params.queue - Whether this task can be queued at all. `false` for a send with no message id,
|
|
74
|
-
* which there is nothing to key a queue entry on — it still runs, just not through the queue.
|
|
75
|
-
* @param params.task - Which operation to run, and the arguments to run it with.
|
|
50
|
+
* @param params.channel - The caller's channel instance, so a first attempt runs on that object.
|
|
51
|
+
* @param params.queue - `false` for a send with no message ID (nothing to key a queue entry on).
|
|
76
52
|
*/
|
|
77
53
|
export declare const queueOrRun: <T extends QueueableType>({ channel, client, queue, task, }: {
|
|
78
54
|
channel?: Channel;
|
|
@@ -81,7 +57,7 @@ export declare const queueOrRun: <T extends QueueableType>({ channel, client, qu
|
|
|
81
57
|
task: PendingTaskOf<T>;
|
|
82
58
|
}) => Promise<QueueableResult<T>>;
|
|
83
59
|
/**
|
|
84
|
-
*
|
|
60
|
+
* Runs a task through its operation, for a first attempt and for a replay.
|
|
85
61
|
*
|
|
86
62
|
* @internal
|
|
87
63
|
*/
|
|
@@ -91,16 +67,12 @@ export declare const runQueueableOperation: <T extends QueueableType>({ channel,
|
|
|
91
67
|
task: PendingTaskOf<T>;
|
|
92
68
|
}) => Promise<QueueableResult<T>>;
|
|
93
69
|
/**
|
|
94
|
-
* Whether this message
|
|
95
|
-
* mutation is pending, not failed
|
|
96
|
-
*
|
|
97
|
-
* Reads the queue. Inferring it from the error's shape ("an initialized offline DB plus an
|
|
98
|
-
* `isEphemeral` error, so it must have been queued") over-reports, because the queue declines
|
|
99
|
-
* tasks no error shape can predict — an `update-message` whose payload still points at a local
|
|
100
|
-
* attachment URL is refused by `isMessageUpdateReplayable`, and the edit would then be suppressed as
|
|
101
|
-
* "pending" with nothing to replay it. A row in the pending-tasks table is the actual fact.
|
|
70
|
+
* Whether this message has a mutation of one of `types` waiting in the offline queue. A queued
|
|
71
|
+
* mutation is pending, not failed.
|
|
102
72
|
*
|
|
103
|
-
*
|
|
104
|
-
* the
|
|
73
|
+
* It reads the queue because the queue can decline a task (for example an `update-message` refused
|
|
74
|
+
* by `isMessageUpdateReplayable`), which the error alone cannot tell. `queueTask` awaits
|
|
75
|
+
* `handleAddPendingTask` before it rethrows, so the row exists by the time an operation's `catch`
|
|
76
|
+
* runs.
|
|
105
77
|
*/
|
|
106
78
|
export declare const isQueuedForReplay: (client: StreamChat, messageId: string, types: readonly QueueableType[]) => Promise<boolean>;
|
|
@@ -2,315 +2,166 @@ import type { ChannelFilters, ChannelMemberResponse, ChannelOptions, ChannelResp
|
|
|
2
2
|
import type { Channel } from '../channel';
|
|
3
3
|
import type { StreamChat } from '../client';
|
|
4
4
|
export type PrepareBatchDBQueries = [string] | [string, Array<unknown> | Array<Array<unknown>>];
|
|
5
|
-
/**
|
|
6
|
-
* Options to insert a reaction into a message.
|
|
7
|
-
*/
|
|
8
5
|
export type DBInsertReactionType = {
|
|
9
|
-
/** MessageRequest to which the reaction is applied. */
|
|
10
6
|
message: MessageResponse | LocalMessage;
|
|
11
|
-
/** The reaction to insert. */
|
|
12
7
|
reaction: ReactionResponse;
|
|
13
|
-
/** Whether to immediately execute the operation. */
|
|
14
8
|
execute?: boolean;
|
|
15
9
|
};
|
|
16
|
-
/**
|
|
17
|
-
* Options to upsert channel IDs associated with a query.
|
|
18
|
-
*/
|
|
19
10
|
export type DBUpsertCidsForQueryType = {
|
|
20
|
-
/** Array of channel IDs. */
|
|
21
11
|
cids: string[];
|
|
22
|
-
/** Optional filters for the channels. */
|
|
23
12
|
filters?: ChannelFilters;
|
|
24
|
-
/** Optional full query options for the channels. */
|
|
25
13
|
options?: ChannelOptions;
|
|
26
|
-
/** Whether to immediately execute the operation. */
|
|
27
14
|
execute?: boolean;
|
|
28
15
|
/**
|
|
29
|
-
* The predefined-filter metadata the backend resolved for this query, stored
|
|
30
|
-
*
|
|
31
|
-
*
|
|
16
|
+
* The predefined-filter metadata the backend resolved for this query, stored with the cid order
|
|
17
|
+
* so a cache-seeded list sorts and matches by the same rule. Absent for a plain
|
|
18
|
+
* `filter_conditions` query, which clears any stored metadata.
|
|
32
19
|
*/
|
|
33
20
|
predefinedFilter?: ParsedPredefinedFilterResponse;
|
|
34
|
-
/** Optional sorting applied to the channels. */
|
|
35
21
|
sort?: SortParamRequest[];
|
|
36
22
|
};
|
|
37
|
-
/**
|
|
38
|
-
* Options to upsert multiple channels.
|
|
39
|
-
*/
|
|
40
23
|
export type DBUpsertChannelsType = {
|
|
41
|
-
/** Array of channel API responses. */
|
|
42
24
|
channels: ChannelStateResponseFields[];
|
|
43
|
-
/** Whether to immediately execute the operation. */
|
|
44
25
|
execute?: boolean;
|
|
45
26
|
/** If true, marks that the latest messages are already set. */
|
|
46
27
|
isLatestMessagesSet?: boolean;
|
|
47
28
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Options to upsert application settings for a user.
|
|
50
|
-
*/
|
|
51
29
|
export type DBUpsertAppSettingsType = {
|
|
52
|
-
/** App settings data. */
|
|
53
30
|
appSettings: GetApplicationResponse;
|
|
54
|
-
/** ID of the user the settings belong to. */
|
|
55
31
|
userId: string;
|
|
56
|
-
/** Whether to immediately execute the operation. */
|
|
57
32
|
execute?: boolean;
|
|
58
33
|
};
|
|
59
|
-
/**
|
|
60
|
-
* Sync status information for a user.
|
|
61
|
-
*/
|
|
62
34
|
export type DBUpsertUserSyncStatusType = {
|
|
63
|
-
/** ID of the user. */
|
|
64
35
|
userId: string;
|
|
65
|
-
/**
|
|
36
|
+
/** A date string `new Date()` can parse. */
|
|
66
37
|
lastSyncedAt: string;
|
|
67
|
-
/** Whether to immediately execute the operation. */
|
|
68
38
|
execute?: boolean;
|
|
69
39
|
};
|
|
70
|
-
/**
|
|
71
|
-
* Options to upsert a poll.
|
|
72
|
-
*/
|
|
73
40
|
export type DBUpsertPollType = {
|
|
74
|
-
/** Poll data to be stored. */
|
|
75
41
|
poll: PollResponseData;
|
|
76
|
-
/** Whether to immediately execute the operation. */
|
|
77
42
|
execute?: boolean;
|
|
78
43
|
};
|
|
79
|
-
/**
|
|
80
|
-
* Options to upsert individual channel data.
|
|
81
|
-
*/
|
|
82
44
|
export type DBUpsertChannelDataType = {
|
|
83
|
-
/** Channel data. */
|
|
84
45
|
channel: ChannelResponse;
|
|
85
|
-
/** Whether to immediately execute the operation. */
|
|
86
46
|
execute?: boolean;
|
|
87
47
|
};
|
|
88
|
-
/**
|
|
89
|
-
* Options to upsert read statuses for a channel.
|
|
90
|
-
*/
|
|
91
48
|
export type DBUpsertReadsType = {
|
|
92
|
-
/** Channel ID. */
|
|
93
49
|
cid: string;
|
|
94
|
-
/** Array of read statuses. */
|
|
95
50
|
reads: ReadStateResponse[];
|
|
96
|
-
/** Whether to immediately execute the operation. */
|
|
97
51
|
execute?: boolean;
|
|
98
52
|
};
|
|
99
|
-
/**
|
|
100
|
-
* Options to upsert multiple messages.
|
|
101
|
-
*/
|
|
102
53
|
export type DBUpsertMessagesType = {
|
|
103
|
-
/** Array of message responses. */
|
|
104
54
|
messages: MessageResponse[];
|
|
105
|
-
/** Whether to immediately execute the operation. */
|
|
106
55
|
execute?: boolean;
|
|
107
56
|
};
|
|
108
|
-
/**
|
|
109
|
-
* Options to upsert members in a channel.
|
|
110
|
-
*/
|
|
111
57
|
export type DBUpsertMembersType = {
|
|
112
|
-
/** Channel ID. */
|
|
113
58
|
cid: string;
|
|
114
|
-
/** Array of channel members. */
|
|
115
59
|
members: ChannelMemberResponse[];
|
|
116
|
-
/** Whether to immediately execute the operation. */
|
|
117
60
|
execute?: boolean;
|
|
118
61
|
};
|
|
119
|
-
/**
|
|
120
|
-
* Options to update a reaction.
|
|
121
|
-
*/
|
|
122
62
|
export type DBUpdateReactionType = {
|
|
123
|
-
/** MessageRequest associated with the reaction. */
|
|
124
63
|
message: MessageResponse | LocalMessage;
|
|
125
|
-
/** The updated reaction. */
|
|
126
64
|
reaction: ReactionResponse;
|
|
127
|
-
/** Whether to immediately execute the operation. */
|
|
128
65
|
execute?: boolean;
|
|
129
66
|
};
|
|
130
|
-
/**
|
|
131
|
-
* Options to update a message.
|
|
132
|
-
*/
|
|
133
67
|
export type DBUpdateMessageType = {
|
|
134
|
-
/** MessageRequest to update. */
|
|
135
68
|
message: MessageResponse | LocalMessage;
|
|
136
|
-
/** Whether to immediately execute the operation. */
|
|
137
69
|
execute?: boolean;
|
|
138
70
|
};
|
|
139
|
-
/**
|
|
140
|
-
* Options to get channels by their IDs.
|
|
141
|
-
*/
|
|
142
71
|
export type DBGetChannelsType = {
|
|
143
|
-
/** Array of channel IDs. */
|
|
144
72
|
cids: string[];
|
|
145
|
-
/** ID of the user. */
|
|
146
73
|
userId: string;
|
|
147
74
|
};
|
|
148
|
-
/**
|
|
149
|
-
* Options to get channels based on filters.
|
|
150
|
-
*/
|
|
151
75
|
export type DBGetChannelsForQueryType = {
|
|
152
|
-
/** ID of the user. */
|
|
153
76
|
userId: string;
|
|
154
|
-
/** Optional filters for channels. */
|
|
155
77
|
options?: QueryChannelsRequest;
|
|
156
78
|
};
|
|
157
79
|
/**
|
|
158
|
-
* A cached channel query:
|
|
159
|
-
* produced that order.
|
|
160
|
-
* the order without the rule is what lets a cache-seeded list sort and match by the wrong one.
|
|
80
|
+
* A cached channel query: its channels in query order, and the predefined-filter metadata that
|
|
81
|
+
* produced that order. They are written as one cache row, so they are read together.
|
|
161
82
|
*/
|
|
162
83
|
export type DBGetChannelsForQueryResult = {
|
|
163
|
-
/** Channels in cached query order. */
|
|
164
84
|
channels: Omit<ChannelStateResponseFields, 'duration'>[];
|
|
165
|
-
/**
|
|
85
|
+
/** Set when the query was cached from a predefined-filter query. */
|
|
166
86
|
predefinedFilter?: ParsedPredefinedFilterResponse;
|
|
167
87
|
};
|
|
168
|
-
/**
|
|
169
|
-
* Payload for retrieving the last sync timestamp for a user.
|
|
170
|
-
*/
|
|
171
88
|
export type DBGetLastSyncedAtType = {
|
|
172
|
-
/** ID of the user. */
|
|
173
89
|
userId: string;
|
|
174
90
|
};
|
|
175
|
-
/**
|
|
176
|
-
* Options to fetch pending tasks for a specific message.
|
|
177
|
-
*/
|
|
178
91
|
export type DBGetPendingTasksType = {
|
|
179
|
-
/**
|
|
92
|
+
/** Returns only this message's tasks. */
|
|
180
93
|
messageId?: string;
|
|
181
94
|
};
|
|
182
|
-
/**
|
|
183
|
-
* Payload for retrieving application settings for a user.
|
|
184
|
-
*/
|
|
185
95
|
export type DBGetAppSettingsType = {
|
|
186
|
-
/** ID of the user. */
|
|
187
96
|
userId: string;
|
|
188
97
|
};
|
|
189
|
-
/**
|
|
190
|
-
* Options to retrieve reactions for a message.
|
|
191
|
-
*/
|
|
192
98
|
export type DBGetReactionsType = {
|
|
193
|
-
/** ID of the message. */
|
|
194
99
|
messageId: string;
|
|
195
|
-
/** Optional filter to apply to reactions. */
|
|
196
100
|
filters?: ReactionFilters;
|
|
197
|
-
/** Optional sorting for reactions. */
|
|
198
101
|
sort?: SortParamRequest[];
|
|
199
|
-
/** Optional maximum number of reactions to return. */
|
|
200
102
|
limit?: number;
|
|
201
103
|
};
|
|
202
|
-
/**
|
|
203
|
-
* Payload for deleting a pending task by ID.
|
|
204
|
-
*/
|
|
205
104
|
export type DBDeletePendingTaskType = {
|
|
206
|
-
/** ID of the pending task. */
|
|
207
105
|
id: number;
|
|
208
106
|
};
|
|
209
|
-
/**
|
|
210
|
-
* Payload for updating a pending task by ID.
|
|
211
|
-
*/
|
|
212
107
|
export type DBUpdatePendingTaskType = {
|
|
213
|
-
/** ID of the pending task. */
|
|
214
108
|
id: number;
|
|
215
|
-
/** The next task payload to persist. */
|
|
216
109
|
task: PendingTask;
|
|
217
110
|
};
|
|
218
|
-
/**
|
|
219
|
-
* Options to delete a reaction from a message.
|
|
220
|
-
*/
|
|
221
111
|
export type DBDeleteReactionType = {
|
|
222
|
-
/** The reaction to delete. */
|
|
223
112
|
reaction: ReactionResponse;
|
|
224
|
-
/** Optional message associated with the reaction. */
|
|
225
113
|
message?: MessageResponse | LocalMessage;
|
|
226
|
-
/** Whether to immediately execute the operation. */
|
|
227
114
|
execute?: boolean;
|
|
228
115
|
};
|
|
229
|
-
/**
|
|
230
|
-
* Options to delete a channel member.
|
|
231
|
-
*/
|
|
232
116
|
export type DBDeleteMemberType = {
|
|
233
|
-
/** Channel ID. */
|
|
234
117
|
cid: string;
|
|
235
|
-
/** Member to remove. */
|
|
236
118
|
member: ChannelMemberResponse;
|
|
237
|
-
/** Whether to immediately execute the operation. */
|
|
238
119
|
execute?: boolean;
|
|
239
120
|
};
|
|
240
|
-
/**
|
|
241
|
-
* Options to drop all pending tasks for a message.
|
|
242
|
-
*/
|
|
243
121
|
export type DBDropPendingTasksType = {
|
|
244
|
-
/** ID of the message. */
|
|
245
122
|
messageId: string;
|
|
246
|
-
/** Whether to immediately execute the operation. */
|
|
247
123
|
execute?: boolean;
|
|
248
124
|
};
|
|
249
|
-
/**
|
|
250
|
-
* Options to delete a message.
|
|
251
|
-
*/
|
|
252
125
|
export type DBDeleteMessageType = {
|
|
253
|
-
/** ID of the message. */
|
|
254
126
|
id: string;
|
|
255
|
-
/**
|
|
127
|
+
/** Delete for the current user only. */
|
|
256
128
|
deleteForMe?: boolean;
|
|
257
|
-
/** Whether to immediately execute the operation. */
|
|
258
129
|
execute?: boolean;
|
|
259
130
|
};
|
|
260
|
-
/**
|
|
261
|
-
* Options to delete a channel.
|
|
262
|
-
*/
|
|
263
131
|
export type DBDeleteChannelType = {
|
|
264
|
-
/** Channel ID. */
|
|
265
132
|
cid: string;
|
|
266
|
-
/** Whether to immediately execute the operation. */
|
|
267
133
|
execute?: boolean;
|
|
268
134
|
};
|
|
269
|
-
/**
|
|
270
|
-
* Options to delete messages in a channel.
|
|
271
|
-
*/
|
|
272
135
|
export type DBDeleteMessagesForChannelType = {
|
|
273
|
-
/** Channel ID. */
|
|
274
136
|
cid: string;
|
|
275
|
-
/**
|
|
276
|
-
/** Unix nanoseconds, as the API sends it. */
|
|
137
|
+
/** Messages before this timestamp are deleted (unix nanoseconds, as the API sends it). */
|
|
277
138
|
truncated_at?: TimestampNS;
|
|
278
|
-
/** Whether to immediately execute the operation. */
|
|
279
139
|
execute?: boolean;
|
|
280
140
|
};
|
|
281
|
-
/**
|
|
282
|
-
* Payload for checking whether a channel exists by ID.
|
|
283
|
-
*/
|
|
284
141
|
export type DBChannelExistsType = {
|
|
285
|
-
/** Channel ID. */
|
|
286
142
|
cid: string;
|
|
287
143
|
};
|
|
288
144
|
export type DBUpsertDraftType = {
|
|
289
|
-
/** Draft message to upsert. */
|
|
290
145
|
draft: DraftResponse;
|
|
291
|
-
/** Whether to immediately execute the operation. */
|
|
292
146
|
execute?: boolean;
|
|
293
147
|
};
|
|
294
148
|
export type DBGetDraftType = {
|
|
295
|
-
/** Channel ID for which to get the draft. */
|
|
296
149
|
cid: string;
|
|
297
|
-
/** ID of the user requesting the draft. */
|
|
298
150
|
userId: string;
|
|
299
|
-
/**
|
|
151
|
+
/** The thread's parent message ID, for a thread draft. */
|
|
300
152
|
parent_id?: string;
|
|
301
153
|
};
|
|
302
154
|
export type DBDeleteDraftType = {
|
|
303
|
-
/** Channel ID for which to delete the draft. */
|
|
304
155
|
cid: string;
|
|
305
|
-
/**
|
|
156
|
+
/** The thread's parent message ID, for a thread draft. */
|
|
306
157
|
parent_id?: string;
|
|
307
|
-
/** Whether to immediately execute the operation. */
|
|
308
158
|
execute?: boolean;
|
|
309
159
|
};
|
|
160
|
+
export type ExecuteBatchDBQueriesType = PrepareBatchDBQueries[];
|
|
310
161
|
/**
|
|
311
|
-
*
|
|
162
|
+
* The storage contract. A member taking `execute` returns its prepared queries whether or not it
|
|
163
|
+
* already ran them.
|
|
312
164
|
*/
|
|
313
|
-
export type ExecuteBatchDBQueriesType = PrepareBatchDBQueries[];
|
|
314
165
|
export interface OfflineDBApi {
|
|
315
166
|
insertReaction: (options: DBInsertReactionType) => Promise<ExecuteBatchDBQueriesType>;
|
|
316
167
|
upsertCidsForQuery: (options: DBUpsertCidsForQueryType) => Promise<ExecuteBatchDBQueriesType>;
|
|
@@ -363,15 +214,12 @@ export type PendingTaskTypes = {
|
|
|
363
214
|
deleteDraft: 'delete-draft';
|
|
364
215
|
};
|
|
365
216
|
/**
|
|
366
|
-
* Every operation the offline queue can replay,
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* derived from it, and `QUEUEABLE_OPERATIONS` has to supply a resolver for each key — so a new task
|
|
370
|
-
* type is a compile error until both its signature and its resolver exist, rather than a runtime
|
|
371
|
-
* "Tried to execute invalid pending task type" the first time somebody queues one.
|
|
217
|
+
* Every operation the offline queue can replay, as the method that performs it. `PendingTask` is
|
|
218
|
+
* derived from it and `QUEUEABLE_OPERATIONS` needs an entry per key, so a new task type does not
|
|
219
|
+
* compile until both exist.
|
|
372
220
|
*
|
|
373
|
-
* Each
|
|
374
|
-
*
|
|
221
|
+
* Each method only sends the request (a queueing one would re-queue on replay), hence the drafts'
|
|
222
|
+
* `_`-prefixed forms.
|
|
375
223
|
*
|
|
376
224
|
* @internal
|
|
377
225
|
*/
|
|
@@ -386,21 +234,14 @@ export type QueueableOperationSignatures = {
|
|
|
386
234
|
};
|
|
387
235
|
export type QueueableType = keyof QueueableOperationSignatures;
|
|
388
236
|
/**
|
|
389
|
-
* The argument list of a queueable operation
|
|
237
|
+
* The argument list of a queueable operation, which a task carries as its `payload`.
|
|
390
238
|
*
|
|
391
239
|
* @internal
|
|
392
240
|
*/
|
|
393
241
|
export type QueueablePayload<T extends QueueableType> = Parameters<QueueableOperationSignatures[T]>;
|
|
394
|
-
/**
|
|
395
|
-
* What a queueable operation resolves with.
|
|
396
|
-
*
|
|
397
|
-
* @internal
|
|
398
|
-
*/
|
|
242
|
+
/** @internal */
|
|
399
243
|
export type QueueableResult<T extends QueueableType> = Awaited<ReturnType<QueueableOperationSignatures[T]>>;
|
|
400
|
-
/**
|
|
401
|
-
* A queued request: which operation, and the arguments to replay it with. The payload is the argument
|
|
402
|
-
* list of the method named in {@link QueueableOperationSignatures}, so the two cannot drift.
|
|
403
|
-
*/
|
|
244
|
+
/** A queued request: the operation and the arguments to replay it with. */
|
|
404
245
|
export type PendingTask = {
|
|
405
246
|
channelId?: string;
|
|
406
247
|
channelType?: string;
|
|
@@ -413,11 +254,7 @@ export type PendingTask = {
|
|
|
413
254
|
type: T;
|
|
414
255
|
};
|
|
415
256
|
}[QueueableType];
|
|
416
|
-
/**
|
|
417
|
-
* A task narrowed to one operation.
|
|
418
|
-
*
|
|
419
|
-
* @internal
|
|
420
|
-
*/
|
|
257
|
+
/** @internal */
|
|
421
258
|
export type PendingTaskOf<T extends QueueableType> = Extract<PendingTask, {
|
|
422
259
|
type: T;
|
|
423
260
|
}>;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* it dedupes content across collections and fans changes out to every holder; backed by a private
|
|
6
|
-
* store (the default, owner-less mode) it behaves as a plain per-instance index. Keeping this as an
|
|
7
|
-
* interface lets `BasePaginator` stay agnostic to which backing a given paginator uses.
|
|
8
|
-
*
|
|
9
|
-
* @template T The domain item type managed by the index.
|
|
2
|
+
* The CRUD surface a paginator relies on from its item index. The only implementation is
|
|
3
|
+
* `StoreBackedItemIndex`: on a shared client store it dedupes items across collections and fans
|
|
4
|
+
* changes out to every holder, on a private store it is a plain per-instance index.
|
|
10
5
|
*/
|
|
11
6
|
export interface ItemIndexApi<T> {
|
|
12
7
|
setMany(items: T[]): void;
|
|
@@ -17,9 +12,6 @@ export interface ItemIndexApi<T> {
|
|
|
17
12
|
clear(): void;
|
|
18
13
|
entries(): [string, T][];
|
|
19
14
|
values(): T[];
|
|
20
|
-
/**
|
|
21
|
-
* Runs `fn`, coalescing any change notifications it produces into a single flush. A private-store
|
|
22
|
-
* (owner-less) index has nothing to fan out and simply runs `fn`.
|
|
23
|
-
*/
|
|
15
|
+
/** Runs `fn`, coalescing the change notifications it produces into a single flush. */
|
|
24
16
|
batch<R>(fn: () => R): R;
|
|
25
17
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Interval, PaginationFlags } from '../paginators';
|
|
2
|
+
/**
|
|
3
|
+
* Flags for a page centred on a point (`id_around` / `created_at_around`). The server splits the
|
|
4
|
+
* limit evenly around the point and fills a side that runs out from the other, so on a full page a
|
|
5
|
+
* side with less than the smaller half is exhausted. A page shorter than the limit holds everything.
|
|
6
|
+
*/
|
|
7
|
+
export declare const deriveAroundPaginationFlags: ({ interval, newerCount, olderCount, pageLength, requestedPageSize, }: {
|
|
8
|
+
interval: Interval;
|
|
9
|
+
newerCount: number;
|
|
10
|
+
olderCount: number;
|
|
11
|
+
pageLength: number;
|
|
12
|
+
requestedPageSize: number;
|
|
13
|
+
}) => PaginationFlags;
|