tsdf 17.0.0-alpha.8 → 17.0.0-alpha.9
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/async-storage.d.ts +1 -1
- package/dist/async-storage.js +2 -1
- package/dist/{asyncStorageAdapter-kvAIhrBD.d.ts → asyncStorageAdapter-BMYAF6rt.d.ts} +1 -1
- package/dist/asyncStorageAdapter-BZSj1ZO5.js +1868 -0
- package/dist/asyncStorageAdapters-DbyKyARM.js +3 -0
- package/dist/indexed-db-storage.d.ts +4 -2
- package/dist/indexed-db-storage.js +2 -1
- package/dist/indexedDbPersistentStorage-DlUjN1qY.js +902 -0
- package/dist/main.d.ts +410 -244
- package/dist/main.js +16153 -1
- package/dist/opfs-storage.d.ts +1 -1
- package/dist/opfs-storage.js +2 -1
- package/dist/opfsPersistentStorage-BO_uDxe4.js +838 -0
- package/dist/{opfsPersistentStorage-D_fecOJg.d.ts → opfsPersistentStorage-CBnUebnf.d.ts} +1 -1
- package/dist/{types-DkNgE_f9.d.ts → types-2zQlbxtw.d.ts} +132 -63
- package/docs/README.md +14 -14
- package/docs/batch-fetching.md +1 -1
- package/docs/browser-tabs-sync.md +2 -0
- package/docs/collection-store.md +24 -22
- package/docs/document-store.md +4 -2
- package/docs/fetch-scheduling.md +7 -7
- package/docs/list-query-store.md +35 -33
- package/docs/mutations.md +2 -0
- package/docs/persistent-storage.md +2 -0
- package/docs/real-time-updates.md +5 -5
- package/docs/store-manager.md +31 -12
- package/package.json +6 -3
- package/dist/asyncStorageAdapter-CgG3vm0t.js +0 -1
- package/dist/asyncStorageAdapters-eagaD77Y.js +0 -1
- package/dist/indexedDbPersistentStorage-JYXvMjTG.js +0 -1
- package/dist/opfsPersistentStorage-DS-SWDSq.js +0 -1
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as OfflineResolutionRecord, A as DefineListQueryOfflineOperations, At as
|
|
1
|
+
import { $ as OfflineResolutionRecord, A as DefineListQueryOfflineOperations, At as PayloadDebounce, B as OfflineEntityMutationKind, Bt as mutationSkipped, C as PersistentStorageSchema, Ct as OfflineUploadAdapter, D as CollectionOfflineOperationDefinition, Dt as OfflineUploadTransportContext, E as CollectionOfflineEntityRef, Et as OfflineUploadState, F as ListQueryOfflineEntityRef, Ft as TSDFStatus, G as OfflineMutationQueueingPolicy, Gt as ScheduleFetchResults, H as OfflineMutationInput, Ht as RequestSchedulerEventData, I as ListQueryOfflineOperationDefinition, It as UnwrapTSDFResult, J as OfflineReplayRetryConfig, Jt as TSDFDebugLogLevel, K as OfflineOperationKind, Kt as TSDFDebugLogArea, L as OfflineAccumulationConfig, Lt as ValidPayload, M as DocumentOfflineOperationDefinition, Mt as StoreFetchError, N as GlobalOfflineEntity, Nt as StoreMutationError, O as DefineCollectionOfflineOperations, Ot as MaybeTSDFResult, P as GlobalOfflineStatus, Pt as StoreMutationErrorOptions, Q as OfflineResolutionConflictParseErrorCode, R as OfflineAccumulationMergeContext, Rt as ValidStoreState, S as PersistentStoragePreloadResult, St as OfflineUpload, T as AnyOfflineOperationDefinition, Tt as OfflineUploadSource, U as OfflineMutationQueueingCause, Ut as RequestSchedulerEvents, V as OfflineMutationDescriptor, Vt as FetchType, W as OfflineMutationQueueingConfig, Wt as ScheduleFetchOptions, X as OfflineResolutionActionForOperation, Xt as TSDFDebugOptions, Y as OfflineResolutionAction, Yt as TSDFDebugLogger, Z as OfflineResolutionConflictParseError, _ as ListQueryOfflineOperationsConfig, _t as defaultOfflineRuntimeConfig, a as AsyncStorageMetadataOrder, at as OfflineSession, b as PersistentStorageDataSchema, bt as OfflineSessionUploadsConfig, c as AsyncStorageNamespaceCommitUpsert, ct as OfflineSyncState, d as AsyncStorageNamespaceKind, dt as OfflineTempEntityConfig, et as OfflineResolutionRecordForOperation, f as AsyncStorageNamespaceScope, ft as OfflineTempEntityPendingEntry, g as DocumentPersistentStorageConfig, gt as ParsedOfflineResolutionConflictResultForStore, h as ConvertedPersistentStorageDataSchema, ht as ParsedOfflineResolutionConflictResultForOperation, i as AsyncStorageDriverSetEntry, it as OfflineRuntimeConfigUpdate, j as DefineOfflineOperation, jt as StoreError, k as DefineDocumentOfflineOperations, kt as MutationSkipped, l as AsyncStorageNamespaceGetResult, lt as OfflineTempEntitiesConfig, m as CollectionPersistentStorageConfig, mt as OperationResult, n as AsyncStorageDiscoveredScope, nt as OfflineRetryExhaustedResolutionAction, o as AsyncStorageNamespaceCommitArgs, ot as OfflineSessionConfig, p as AsyncStorageReadOptions, pt as OperationConflict, q as OfflineQueueEntry, qt as TSDFDebugLogEntry, r as AsyncStorageDriver, rt as OfflineRuntimeConfig, s as AsyncStorageNamespaceCommitTouch, st as OfflineSupersedeConfig, t as AsyncStorageAdapter, tt as OfflineResolutionRecordForStore, u as AsyncStorageNamespaceHandle, ut as OfflineTempEntitiesReconciliation, v as ListQueryPersistentStorageConfig, vt as OfflineMutationUploadsInput, w as StorageAdapter, wt as OfflineUploadProgress, x as PersistentStorageErrorHandler, xt as OfflineStoredUploadRecord, y as PersistentStorageBaseConfig, yt as OfflineOperationUploadsContext, z as OfflineConflictResolutionAction, zt as fetchTypePriority } from "./types-2zQlbxtw.js";
|
|
2
2
|
import { __LEGIT_ANY__ } from "@ls-stack/utils/saferTyping";
|
|
3
3
|
import { Emitter } from "evtmitter";
|
|
4
4
|
import { Context } from "react";
|
|
@@ -13,26 +13,33 @@ import { Store } from "t-state";
|
|
|
13
13
|
* `queued` means the mutation was durably persisted for offline replay.
|
|
14
14
|
*/
|
|
15
15
|
type OfflineMutationResult<T> = {
|
|
16
|
-
kind: 'online';
|
|
16
|
+
/** The direct online mutation completed successfully. */kind: 'online'; /** Server payload returned by the direct mutation. */
|
|
17
17
|
data: Awaited<T>;
|
|
18
18
|
} | {
|
|
19
|
-
kind: 'queued';
|
|
19
|
+
/** The mutation was durably queued for offline replay. */kind: 'queued';
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/utils/performMutation.d.ts
|
|
23
|
+
/** Starts a temporary window-close block while a mutation is in progress. */
|
|
23
24
|
type BlockWindowCloseHandler = () => {
|
|
24
|
-
unblock: () => void;
|
|
25
|
+
/** Releases the window-close block. */unblock: () => void;
|
|
25
26
|
};
|
|
27
|
+
/** Debounce settings for mutation calls sharing a logical context and payload. */
|
|
26
28
|
type MutationDebounce = {
|
|
27
|
-
context: string;
|
|
28
|
-
payload: unknown;
|
|
29
|
+
/** Logical namespace for the debounced mutation group. */context: string; /** Payload compared with the context to decide which calls supersede each other. */
|
|
30
|
+
payload: unknown; /** Debounce window in milliseconds. */
|
|
29
31
|
ms: number;
|
|
30
32
|
};
|
|
31
33
|
//#endregion
|
|
32
34
|
//#region src/storeManager.d.ts
|
|
35
|
+
type DynamicRealtimeThrottleMs = (params: {
|
|
36
|
+
readonly lastFetchDuration: number;
|
|
37
|
+
readonly windowIsNotFocused: boolean;
|
|
38
|
+
}) => number;
|
|
33
39
|
type StoreManagerStoreDefaults = {
|
|
34
40
|
/** Default minimum interval between low-priority fetches for attached stores. */readonly lowPriorityThrottleMs: number; /** Default coalescing window used by attached stores when they do not override it. */
|
|
35
|
-
readonly baseCoalescingWindowMs: number; /**
|
|
41
|
+
readonly baseCoalescingWindowMs: number; /** Default adaptive throttle for real-time updates in attached stores. */
|
|
42
|
+
readonly dynamicRealtimeThrottleMs: DynamicRealtimeThrottleMs; /** Shared window-close blocker used by mutations in attached stores. */
|
|
36
43
|
readonly blockWindowClose: BlockWindowCloseHandler | null; /** Default focus revalidation policy for attached stores. */
|
|
37
44
|
readonly revalidateOnWindowFocus: boolean | (() => boolean) | undefined;
|
|
38
45
|
};
|
|
@@ -63,8 +70,10 @@ type StoreManagerOfflineApi<TUploadRef extends ValidPayload = ValidPayload> = {
|
|
|
63
70
|
useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** React hook subscribing to the manager's aggregated offline uploads. */
|
|
64
71
|
useOfflineUploads: () => readonly OfflineUpload<TUploadRef>[];
|
|
65
72
|
};
|
|
73
|
+
/** Shared coordinator passed to every TSDF store instance in an app/session. */
|
|
66
74
|
type StoreManager<TUploadRef extends ValidPayload = ValidPayload> = {
|
|
67
|
-
/** Returns the active shared session / tenant key. */getSessionKey: () => string | false; /**
|
|
75
|
+
/** Returns the active shared session / tenant key. */getSessionKey: () => string | false; /** Shared debug logger for browser-tab sync and persistent storage internals. */
|
|
76
|
+
debugLogger?: TSDFDebugLogger; /** Normalizes raw exceptions into the shared StoreError shape. */
|
|
68
77
|
errorNormalizer: (exception: Error) => StoreError; /** Global fallback for persistent storage failures in attached stores. */
|
|
69
78
|
onPersistentStorageError: PersistentStorageErrorHandler | undefined; /** Global fallback for mutation failures in attached stores. */
|
|
70
79
|
onMutationError: StoreManagerMutationErrorHandler | undefined; /** Shared defaults used by attached stores unless a store-level override exists. */
|
|
@@ -73,6 +82,7 @@ type StoreManager<TUploadRef extends ValidPayload = ValidPayload> = {
|
|
|
73
82
|
resetAll: (ignoreStores: string[]) => void; /** Signals a shared real-time transport reconnect to all registered stores. */
|
|
74
83
|
onTransportReconnect: () => void;
|
|
75
84
|
} & StoreManagerOfflineApi<TUploadRef>;
|
|
85
|
+
/** Options used to create a shared TSDF store manager. */
|
|
76
86
|
type CreateStoreManagerOptions<TUploadRef extends ValidPayload = ValidPayload> = {
|
|
77
87
|
/**
|
|
78
88
|
* Returns the current authenticated session / tenant key shared by all
|
|
@@ -82,11 +92,17 @@ type CreateStoreManagerOptions<TUploadRef extends ValidPayload = ValidPayload> =
|
|
|
82
92
|
getSessionKey: () => string | false; /** Normalizes raw exceptions into the shared StoreError shape. */
|
|
83
93
|
errorNormalizer: (exception: Error) => StoreError; /** Default minimum interval between low-priority fetches for attached stores. Defaults to 5ms. */
|
|
84
94
|
lowPriorityThrottleMs?: number; /** Default coalescing window for attached stores. Defaults to 10ms. */
|
|
85
|
-
baseCoalescingWindowMs?: number; /**
|
|
95
|
+
baseCoalescingWindowMs?: number; /** Default adaptive throttle for real-time updates in attached stores. Store-level values override it. */
|
|
96
|
+
dynamicRealtimeThrottleMs?: DynamicRealtimeThrottleMs; /** Shared window-close blocker used by mutations in attached stores. Pass `null` to disable. */
|
|
86
97
|
blockWindowClose?: BlockWindowCloseHandler | null; /** Global fallback for persistent storage failures when a store does not provide its own handler. */
|
|
87
98
|
onPersistentStorageError?: PersistentStorageErrorHandler; /** Global fallback for mutation failures when a store does not provide its own handler. */
|
|
88
99
|
onMutationError?: StoreManagerMutationErrorHandler; /** Default focus revalidation policy for attached stores. Store-level values override it. */
|
|
89
|
-
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
100
|
+
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
101
|
+
/**
|
|
102
|
+
* Enables debug logs for browser-tab sync and persistent storage operations.
|
|
103
|
+
* Pass `true` to use console logging, or pass a logger function.
|
|
104
|
+
*/
|
|
105
|
+
debug?: TSDFDebugOptions; /** Optional shared offline session config for every attached store. */
|
|
90
106
|
offlineSession?: OfflineSessionConfig<TUploadRef>;
|
|
91
107
|
};
|
|
92
108
|
declare function createStoreManager<TUploadRef extends ValidPayload = ValidPayload>(options: CreateStoreManagerOptions<TUploadRef>): StoreManager<TUploadRef>;
|
|
@@ -123,26 +139,31 @@ type UseItemOptions$1<ItemState extends ValidStoreState, Selected> = UseMultiple
|
|
|
123
139
|
};
|
|
124
140
|
//#endregion
|
|
125
141
|
//#region src/collectionStore/collectionStore.d.ts
|
|
142
|
+
/** Lifecycle status for a cached collection item. */
|
|
126
143
|
type CollectionItemStatus = TSDFStatus;
|
|
144
|
+
/** Raw cached state for one collection item. */
|
|
127
145
|
type TSFDCollectionItem<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
|
|
128
|
-
data: ItemState | null;
|
|
129
|
-
error: StoreError | null;
|
|
130
|
-
status: CollectionItemStatus;
|
|
131
|
-
payload: ItemPayload;
|
|
132
|
-
refetchOnMount: false | FetchType;
|
|
146
|
+
/** Latest loaded item data, or `null` before the item is available. */data: ItemState | null; /** Last fetch error for this item, when the latest fetch failed. */
|
|
147
|
+
error: StoreError | null; /** Current fetch lifecycle status for this item. */
|
|
148
|
+
status: CollectionItemStatus; /** Payload used to identify and fetch this item. */
|
|
149
|
+
payload: ItemPayload; /** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
150
|
+
refetchOnMount: false | FetchType; /** Whether this item has ever loaded successfully. */
|
|
133
151
|
wasLoaded: boolean;
|
|
134
152
|
};
|
|
153
|
+
/** Raw t-state shape used by a collection store. */
|
|
135
154
|
type TSFDCollectionState<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = Record<string, TSFDCollectionItem<ItemState, ItemPayload> | null>;
|
|
155
|
+
/** Value returned by `CollectionStore.useItem(...)` and `useMultipleItems(...)`. */
|
|
136
156
|
type TSFDUseCollectionItemReturn<Selected, ItemPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
137
|
-
data: Selected;
|
|
138
|
-
status: CollectionItemStatus | 'idle' | 'deleted';
|
|
139
|
-
payload: ItemPayload | undefined;
|
|
140
|
-
error: StoreError | null;
|
|
141
|
-
itemStateKey: string;
|
|
157
|
+
/** Selected item data. Defaults to the full item or `null`. */data: Selected; /** Hook-visible item status, including idle/deleted states for hook ergonomics. */
|
|
158
|
+
status: CollectionItemStatus | 'idle' | 'deleted'; /** Item payload for this result, unless omitted or unavailable. */
|
|
159
|
+
payload: ItemPayload | undefined; /** Last item fetch error, if any. */
|
|
160
|
+
error: StoreError | null; /** Stable store key for the current item payload. */
|
|
161
|
+
itemStateKey: string; /** Convenience flag for `loading` or `refetching` states. */
|
|
142
162
|
isLoading: boolean; /** Whether this result has local offline changes that still need to sync to the server. */
|
|
143
|
-
pendingSync: boolean;
|
|
163
|
+
pendingSync: boolean; /** Caller-provided metadata copied from the query descriptor. */
|
|
144
164
|
queryMetadata: QueryMetadata;
|
|
145
165
|
};
|
|
166
|
+
/** Item descriptor accepted by `CollectionStore.useMultipleItems(...)`. */
|
|
146
167
|
type CollectionUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
147
168
|
/** Item payload to subscribe to and fetch when needed. */payload: ItemPayload; /** Metadata returned with this query result for caller-side bookkeeping. */
|
|
148
169
|
queryMetadata?: QueryMetadata; /** Omits `payload` from this query result. */
|
|
@@ -157,11 +178,13 @@ type CollectionUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMeta
|
|
|
157
178
|
returnRefetchingStatus?: boolean; /** Marks this subscription as off-screen, lowering automatic fetch priority. */
|
|
158
179
|
isOffScreen?: boolean;
|
|
159
180
|
};
|
|
181
|
+
/** Callback invoked when an already-loaded collection item is invalidated. */
|
|
160
182
|
type OnCollectionItemInvalidate<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (props: {
|
|
161
|
-
itemState: ItemState;
|
|
162
|
-
payload: ItemPayload;
|
|
183
|
+
/** Current cached item state at invalidation time. */itemState: ItemState; /** Payload of the invalidated item. */
|
|
184
|
+
payload: ItemPayload; /** Fetch priority requested for the invalidation. */
|
|
163
185
|
priority: FetchType;
|
|
164
186
|
}) => void;
|
|
187
|
+
/** Events emitted by collection mutation lifecycle helpers. */
|
|
165
188
|
type CollectionStoreStoreEvents<ItemPayload extends ValidPayload> = {
|
|
166
189
|
/** Emitted when a mutation begins executing */mutationStart: {
|
|
167
190
|
mutationId: number;
|
|
@@ -177,9 +200,10 @@ type CollectionStoreStoreEvents<ItemPayload extends ValidPayload> = {
|
|
|
177
200
|
finalPayload: ItemPayload;
|
|
178
201
|
};
|
|
179
202
|
};
|
|
203
|
+
/** Details passed when collection cache-limit cleanup evicts cached items. */
|
|
180
204
|
type CollectionStateCleanup<ItemPayload extends ValidPayload> = {
|
|
181
|
-
reason: 'cacheLimitEviction';
|
|
182
|
-
itemKeys: string[];
|
|
205
|
+
/** Cleanup trigger that removed these items. */reason: 'cacheLimitEviction'; /** Store keys removed from the collection state. */
|
|
206
|
+
itemKeys: string[]; /** Original item payloads removed from the collection state. */
|
|
183
207
|
payloads: ItemPayload[];
|
|
184
208
|
};
|
|
185
209
|
type InternalCollectionOfflineOperations<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = Record<string, AnyOfflineOperationDefinition & {
|
|
@@ -188,33 +212,34 @@ type InternalCollectionOfflineOperations<ItemState extends ValidStoreState, Item
|
|
|
188
212
|
}) => CollectionOfflineEntityRef<ItemPayload>[];
|
|
189
213
|
}> & ([ItemState | ItemPayload] extends [never] ? never : unknown);
|
|
190
214
|
type CollectionOfflineOperationsConfig<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = InternalCollectionOfflineOperations<ItemState, ItemPayload> | null;
|
|
215
|
+
/** Options used to create a collection store. */
|
|
191
216
|
type CollectionStoreOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload> = null, StorageState = unknown> = {
|
|
192
217
|
/**
|
|
193
218
|
* Stable id for this logical collection store. Used for debug labels,
|
|
194
219
|
* persistence namespaces, and browser tab sync.
|
|
195
220
|
*/
|
|
196
221
|
id: string; /** Shared global store manager providing session scoping and error normalization. */
|
|
197
|
-
storeManager: StoreManager;
|
|
198
|
-
fetchFn: (params: ItemPayload, signal: AbortSignal) => Promise<ItemState
|
|
199
|
-
batchFetchFn?: (payloads: ItemPayload[], signal: AbortSignal, batchKey: string) => Promise<Map<ItemPayload, ItemState | Error
|
|
222
|
+
storeManager: StoreManager; /** Fetches one item by payload. */
|
|
223
|
+
fetchFn: (params: ItemPayload, signal: AbortSignal) => Promise<MaybeTSDFResult<ItemState>>; /** Optional batch fetch function for fetching multiple items at once */
|
|
224
|
+
batchFetchFn?: (payloads: ItemPayload[], signal: AbortSignal, batchKey: string) => Promise<MaybeTSDFResult<Map<ItemPayload, MaybeTSDFResult<ItemState> | Error>>>; /** Optional function to group batch fetches by key. When omitted, all batched items share one default batch key. Return false to fall back to individual fetchFn */
|
|
200
225
|
getItemsBatchKey?: (payload: ItemPayload) => string | false; /** Max items per batch - triggers immediate fetch when reached */
|
|
201
226
|
maxBatchSize?: number; /** Maximum number of cached items kept in memory. Defaults to 5,000. Inactive items are evicted in LRU order, while mounted hook items stay protected. */
|
|
202
227
|
maxItems?: number; /** Called when cache-limit eviction removes items from in-memory state. */
|
|
203
|
-
onStateCleanup?: (cleanup: CollectionStateCleanup<ItemPayload>) => void;
|
|
228
|
+
onStateCleanup?: (cleanup: CollectionStateCleanup<ItemPayload>) => void; /** Converts an item payload to the stable cache key used by this store. */
|
|
204
229
|
getCollectionItemKey?: (params: ItemPayload) => ValidPayload | unknown[]; /** Overrides the manager's default minimum interval between low-priority fetches for this store. */
|
|
205
230
|
lowPriorityThrottleMs?: number; /** Overrides the manager's default coalescing window for this store. */
|
|
206
|
-
baseCoalescingWindowMs?: number;
|
|
207
|
-
mediumPriorityDelayMs?: number;
|
|
231
|
+
baseCoalescingWindowMs?: number; /** Delay applied to medium-priority requests before they enter the scheduler. */
|
|
232
|
+
mediumPriorityDelayMs?: number; /** Computes a per-fetch throttle for real-time updates using recent fetch cost and focus state. */
|
|
208
233
|
dynamicRealtimeThrottleMs?: (params: {
|
|
209
234
|
lastFetchDuration: number;
|
|
210
235
|
windowIsNotFocused: boolean;
|
|
211
|
-
}) => number;
|
|
236
|
+
}) => number; /** Store-level focus revalidation policy. Overrides the manager default. */
|
|
212
237
|
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
213
|
-
/** Reconnect-specific cooldown. The first reconnect revalidates immediately;
|
|
238
|
+
/** Reconnect-specific cooldown. Defaults to 2,000ms. The first reconnect revalidates immediately;
|
|
214
239
|
* additional reconnects within the cooldown are coalesced into one trailing
|
|
215
240
|
* revalidation. Set to `0` to disable this cooldown. */
|
|
216
|
-
transportReconnectCooldownMs?: number;
|
|
217
|
-
onInvalidate?: OnCollectionItemInvalidate<ItemState, ItemPayload>;
|
|
241
|
+
transportReconnectCooldownMs?: number; /** Called when an already-loaded item is invalidated. */
|
|
242
|
+
onInvalidate?: OnCollectionItemInvalidate<ItemState, ItemPayload>; /** Observes request scheduler lifecycle events for this store. */
|
|
218
243
|
onSchedulerEvent?: (event: RequestSchedulerEvents, data?: RequestSchedulerEventData) => void;
|
|
219
244
|
/**
|
|
220
245
|
* Store-specific mutation error handler.
|
|
@@ -222,7 +247,7 @@ type CollectionStoreOptions<ItemState extends ValidStoreState, ItemPayload exten
|
|
|
222
247
|
* Overrides the manager fallback. Use `null` to disable inherited mutation
|
|
223
248
|
* error handling for this store.
|
|
224
249
|
*/
|
|
225
|
-
onMutationError?: ((error: unknown, options: StoreMutationErrorOptions) => void) | null;
|
|
250
|
+
onMutationError?: ((error: unknown, options: StoreMutationErrorOptions) => void) | null; /** Treats refetches as real-time driven, disabling stale mount refetches by default. Defaults to `false`. */
|
|
226
251
|
usesRealTimeUpdates?: boolean;
|
|
227
252
|
/** Opt-in persistent storage configuration. When provided, cached items are loaded
|
|
228
253
|
* from storage on first read and saved back on successful fetches.
|
|
@@ -230,9 +255,10 @@ type CollectionStoreOptions<ItemState extends ValidStoreState, ItemPayload exten
|
|
|
230
255
|
* persisted namespace always reuses this store's `id`. */
|
|
231
256
|
persistentStorage?: CollectionPersistentStorageConfig<ItemState, ItemPayload, StorageState, TOfflineOperations>;
|
|
232
257
|
};
|
|
258
|
+
/** Event payloads emitted by `CollectionStore.events`. */
|
|
233
259
|
type CollectionStoreEvents = {
|
|
234
|
-
invalidateData: {
|
|
235
|
-
priority: FetchType;
|
|
260
|
+
/** Emitted whenever one or more cached items are invalidated. */invalidateData: {
|
|
261
|
+
/** Fetch priority requested by the invalidation. */priority: FetchType; /** Store key for the invalidated item. */
|
|
236
262
|
itemKey: string;
|
|
237
263
|
};
|
|
238
264
|
};
|
|
@@ -249,7 +275,7 @@ type CollectionMutationArgsBase<T, ItemPayload extends ValidPayload> = {
|
|
|
249
275
|
*/
|
|
250
276
|
optimisticUpdate?: (payload: CollectionMutationPayloadToUse<ItemPayload>) => void | boolean; /** Performs the server mutation for the affected item payloads. */
|
|
251
277
|
mutation: (payload: CollectionMutationPayloadToUse<ItemPayload>) => Promise<T>; /** Called after a successful online mutation. */
|
|
252
|
-
onSuccess?: (response: Awaited<T
|
|
278
|
+
onSuccess?: (response: UnwrapTSDFResult<Awaited<T>>, payload: CollectionMutationPayloadToUse<ItemPayload>) => void; /** Invalidates affected items after a successful online mutation. */
|
|
253
279
|
revalidateOnSuccess?: boolean;
|
|
254
280
|
/**
|
|
255
281
|
* Passes `{ silentErrors: true }` to `onMutationError`.
|
|
@@ -269,25 +295,55 @@ type CollectionOnlineMutationArgs<T, ItemPayload extends ValidPayload> = Collect
|
|
|
269
295
|
upload?: undefined;
|
|
270
296
|
};
|
|
271
297
|
type CollectionOfflineMutationArgs<T, ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload>> = CollectionMutationArgsBase<T, ItemPayload> & {
|
|
272
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Queues this mutation through the store's registered offline operation when
|
|
300
|
+
* the session is offline or the direct request fails with an offline outage.
|
|
301
|
+
*/
|
|
302
|
+
offline: TOfflineOperations extends null ? never : OfflineMutationInput<Exclude<TOfflineOperations, null>>; /** Files to attach if this mutation is queued for offline replay. */
|
|
273
303
|
upload?: OfflineMutationUploadsInput;
|
|
274
304
|
};
|
|
275
305
|
type CollectionPerformMutation<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload>> = {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Runs a collection mutation for one or more existing item payloads.
|
|
308
|
+
*
|
|
309
|
+
* Returns the direct server result when offline replay is not configured for
|
|
310
|
+
* this call.
|
|
311
|
+
*/
|
|
312
|
+
<T>(payload: CollectionMutationTarget<ItemPayload>, args: CollectionOnlineMutationArgs<T, ItemPayload>): Promise<Result<UnwrapTSDFResult<Awaited<T>>, StoreMutationError | MutationSkipped>>;
|
|
313
|
+
/**
|
|
314
|
+
* Runs a collection mutation for one or more existing item payloads, with
|
|
315
|
+
* durable offline queueing as a fallback.
|
|
316
|
+
*
|
|
317
|
+
* When the mutation is queued, the result is `{ kind: 'queued' }` instead of
|
|
318
|
+
* the server payload.
|
|
319
|
+
*/
|
|
320
|
+
<T>(payload: CollectionMutationTarget<ItemPayload>, args: CollectionOfflineMutationArgs<T, ItemState, ItemPayload, TOfflineOperations>): Promise<Result<OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
321
|
+
/**
|
|
322
|
+
* Runs a collection mutation with no current item target.
|
|
323
|
+
*
|
|
324
|
+
* Use this for create mutations that do not have a pre-generated item payload
|
|
325
|
+
* yet. Optimistic updates are not available without a target payload.
|
|
326
|
+
*/
|
|
327
|
+
<T>(payload: null, args: Omit<CollectionOnlineMutationArgs<T, ItemPayload>, 'optimisticUpdate'>): Promise<Result<UnwrapTSDFResult<Awaited<T>>, StoreMutationError | MutationSkipped>>;
|
|
328
|
+
/**
|
|
329
|
+
* Runs an offline-capable collection mutation with no current item target.
|
|
330
|
+
*
|
|
331
|
+
* Use this for create mutations that do not have a pre-generated item payload
|
|
332
|
+
* yet. When the mutation is queued, the result is `{ kind: 'queued' }`.
|
|
333
|
+
*/
|
|
334
|
+
<T>(payload: null, args: Omit<CollectionOfflineMutationArgs<T, ItemState, ItemPayload, TOfflineOperations>, 'optimisticUpdate'>): Promise<Result<OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
335
|
+
<T>(payload: CollectionMutationPayload<ItemPayload>, args: CollectionOnlineMutationArgs<T, ItemPayload> | CollectionOfflineMutationArgs<T, ItemState, ItemPayload, TOfflineOperations>): Promise<Result<UnwrapTSDFResult<Awaited<T>> | OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
281
336
|
};
|
|
337
|
+
/** Public API returned by `createCollectionStore(...)`. */
|
|
282
338
|
type CollectionStore<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload> = null> = {
|
|
283
|
-
store: Store<TSFDCollectionState<ItemState, ItemPayload>>;
|
|
284
|
-
events: Emitter<CollectionStoreEvents>;
|
|
285
|
-
storeEvents: Emitter<CollectionStoreStoreEvents<ItemPayload>>;
|
|
286
|
-
readonly invalidationWasTriggered: Set<string>;
|
|
339
|
+
/** Underlying t-state store containing raw cached items. */store: Store<TSFDCollectionState<ItemState, ItemPayload>>; /** Invalidation event emitter used by hooks and integrations. */
|
|
340
|
+
events: Emitter<CollectionStoreEvents>; /** Mutation lifecycle event emitter for observers and tests. */
|
|
341
|
+
storeEvents: Emitter<CollectionStoreStoreEvents<ItemPayload>>; /** Item keys that have been explicitly invalidated and are awaiting refresh. */
|
|
342
|
+
readonly invalidationWasTriggered: Set<string>; /** Schedules a fetch for one item or a batch of item payloads. */
|
|
287
343
|
scheduleFetch: {
|
|
288
344
|
(fetchType: FetchType, payload: ItemPayload, options?: ScheduleFetchOptions): ScheduleFetchResults;
|
|
289
345
|
(fetchType: FetchType, payload: ItemPayload[], options?: ScheduleFetchOptions): ScheduleFetchResults[];
|
|
290
|
-
};
|
|
346
|
+
}; /** Waits for an item fetch to settle and returns data or a fetch error. */
|
|
291
347
|
awaitFetch: (params: ItemPayload, options?: {
|
|
292
348
|
timeoutMs?: number;
|
|
293
349
|
}) => Promise<{
|
|
@@ -296,25 +352,25 @@ type CollectionStore<ItemState extends ValidStoreState, ItemPayload extends Vali
|
|
|
296
352
|
} | {
|
|
297
353
|
data: null;
|
|
298
354
|
error: StoreFetchError;
|
|
299
|
-
}>;
|
|
355
|
+
}>; /** Returns cached item data when usable, otherwise fetches it first. */
|
|
300
356
|
getItemFromStateOrFetch: (params: ItemPayload, options?: {
|
|
301
|
-
ignoreStaleState?: boolean;
|
|
357
|
+
/** When `true`, stale cached data is ignored and refetched before returning. Defaults to `false`. */ignoreStaleState?: boolean;
|
|
302
358
|
timeoutMs?: number;
|
|
303
|
-
}) => Promise<Result<ItemState, StoreFetchError>>;
|
|
304
|
-
useMultipleItems: <Selected = ItemState | null, QueryMetadata extends undefined | Record<string, unknown> = undefined>(items: CollectionUseMultipleItemsQuery<ItemPayload, QueryMetadata>[], options?: UseMultipleItemsOptions$1<ItemState, Selected>) => readonly TSFDUseCollectionItemReturn<Selected, ItemPayload, QueryMetadata>[];
|
|
305
|
-
useItem: <Selected = ItemState | null>(payload: ItemPayload | undefined | false | null, options?: UseItemOptions$1<ItemState, Selected>) => TSFDUseCollectionItemReturn<Selected, ItemPayload>;
|
|
359
|
+
}) => Promise<Result<ItemState, StoreFetchError>>; /** React hook for subscribing to many collection items at once. */
|
|
360
|
+
useMultipleItems: <Selected = ItemState | null, QueryMetadata extends undefined | Record<string, unknown> = undefined>(items: CollectionUseMultipleItemsQuery<ItemPayload, QueryMetadata>[], options?: UseMultipleItemsOptions$1<ItemState, Selected>) => readonly TSFDUseCollectionItemReturn<Selected, ItemPayload, QueryMetadata>[]; /** React hook for subscribing to one collection item. */
|
|
361
|
+
useItem: <Selected = ItemState | null>(payload: ItemPayload | undefined | false | null, options?: UseItemOptions$1<ItemState, Selected>) => TSFDUseCollectionItemReturn<Selected, ItemPayload>; /** React hook that tracks whether a nested list item is still loading. */
|
|
306
362
|
useListItemIsLoading: (payload: ItemPayload, args: {
|
|
307
363
|
/** Unique identifier of the sub-item within the collection item. */itemId: string; /** Extracts the sub-item from the collection item data. */
|
|
308
364
|
selector: (data: ItemState | null) => unknown; /** Called if the sub-item is still missing and no refetch is in progress. */
|
|
309
365
|
loadItemFallback?: () => void; /** Forces a high-priority fetch and keeps the hook loading until data is loaded. */
|
|
310
366
|
ensureIsLoaded?: boolean;
|
|
311
|
-
}) => boolean;
|
|
367
|
+
}) => boolean; /** React hook that tracks whether a nested list item has been deleted. */
|
|
312
368
|
useListItemIsDeleted: (payload: ItemPayload, args: {
|
|
313
369
|
/** Unique identifier of the sub-item within the collection item. */itemId: string; /** Extracts the sub-item from the collection item data. */
|
|
314
370
|
selector: (data: ItemState | null) => unknown; /** Called once when deletion is detected. */
|
|
315
371
|
onDelete?: () => void; /** Forces a high-priority fetch and keeps the hook loading until data is loaded. */
|
|
316
372
|
ensureIsLoaded?: boolean;
|
|
317
|
-
}) => boolean;
|
|
373
|
+
}) => boolean; /** React hook for selecting one nested list item plus loading/deleted flags. */
|
|
318
374
|
useListItem: <Selected>(payload: ItemPayload, args: {
|
|
319
375
|
/** Unique identifier of the sub-item within the collection item. */itemId: string; /** Extracts and maps the sub-item from the collection item data. */
|
|
320
376
|
selector: (data: ItemState | null) => Selected; /** Called if the sub-item is still missing and no refetch is in progress. */
|
|
@@ -325,52 +381,61 @@ type CollectionStore<ItemState extends ValidStoreState, ItemPayload extends Vali
|
|
|
325
381
|
isLoading: boolean;
|
|
326
382
|
isDeleted: boolean;
|
|
327
383
|
data: Selected;
|
|
328
|
-
};
|
|
329
|
-
reset: () => void;
|
|
330
|
-
dispose: () => void;
|
|
331
|
-
preloadItemFromStorage: (params: ItemPayload | ItemPayload[]) => Promise<PersistentStoragePreloadResult<ItemPayload>[]>;
|
|
332
|
-
getItemKey: (params: ItemPayload) => string;
|
|
384
|
+
}; /** Clears in-memory state and cancels store-local runtime state. */
|
|
385
|
+
reset: () => void; /** Unregisters listeners and releases resources owned by this store. */
|
|
386
|
+
dispose: () => void; /** Loads item payloads from persistent storage into memory when available. */
|
|
387
|
+
preloadItemFromStorage: (params: ItemPayload | ItemPayload[]) => Promise<PersistentStoragePreloadResult<ItemPayload>[]>; /** Returns the stable cache key for an item payload. */
|
|
388
|
+
getItemKey: (params: ItemPayload) => string; /** Reads one or many cached items directly from store state. */
|
|
333
389
|
getItemState: {
|
|
334
390
|
(params: ItemPayload): TSFDCollectionItem<ItemState, ItemPayload> | undefined | null;
|
|
335
391
|
(params: ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>): TSFDCollectionItem<ItemState, ItemPayload>[];
|
|
336
|
-
};
|
|
337
|
-
getOfflineEntities: () => GlobalOfflineEntity[];
|
|
338
|
-
useOfflineEntities: () => readonly GlobalOfflineEntity[];
|
|
339
|
-
useOfflineResolutions: () => readonly OfflineResolutionRecord[];
|
|
340
|
-
getOfflineResolutions: () => OfflineResolutionRecord[];
|
|
341
|
-
parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedCollectionOfflineOperations<TOfflineOperations>>;
|
|
342
|
-
resolveOfflineResolution: <TName extends keyof ResolvedCollectionOfflineOperations<TOfflineOperations> & string>(resolutionId: string, operationName: TName, resolution: OfflineResolutionActionForOperation<ResolvedCollectionOfflineOperations<TOfflineOperations>, TName>) => Promise<void> | void;
|
|
343
|
-
startMutation: (fetchParams: ItemPayload | ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>) => () => void;
|
|
344
|
-
invalidateItem: (itemPayload: ItemPayload | ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>, priority
|
|
392
|
+
}; /** Returns offline sync metadata for this store's tracked entities. */
|
|
393
|
+
getOfflineEntities: () => GlobalOfflineEntity[]; /** React hook subscribing to this store's offline entity metadata. */
|
|
394
|
+
useOfflineEntities: () => readonly GlobalOfflineEntity[]; /** React hook subscribing to manual offline resolutions for this store. */
|
|
395
|
+
useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** Returns manual offline resolutions for this store. */
|
|
396
|
+
getOfflineResolutions: () => OfflineResolutionRecord[]; /** Parses a stored offline conflict into the operation-specific conflict shape. */
|
|
397
|
+
parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedCollectionOfflineOperations<TOfflineOperations>>; /** Applies a retry/discard/requeue/commit action to a pending offline resolution. */
|
|
398
|
+
resolveOfflineResolution: <TName extends keyof ResolvedCollectionOfflineOperations<TOfflineOperations> & string>(resolutionId: string, operationName: TName, resolution: OfflineResolutionActionForOperation<ResolvedCollectionOfflineOperations<TOfflineOperations>, TName>) => Promise<void> | void; /** Marks one or more items as mutating and returns a function that ends the mutation. */
|
|
399
|
+
startMutation: (fetchParams: ItemPayload | ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>) => () => void; /** Marks cached items stale and schedules refetches for active subscriptions. Defaults to `highPriority`. */
|
|
400
|
+
invalidateItem: (itemPayload: ItemPayload | ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>, /** Fetch priority used for refetches triggered by this invalidation. Defaults to `highPriority`. */
|
|
401
|
+
|
|
402
|
+
priority?: FetchType) => void; /** Applies an immutable update to one or more cached collection items. */
|
|
345
403
|
updateItemState: (fetchParams: ItemPayload | ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>, produceNewData: (draftData: ItemState, collectionItem: TSFDCollectionItem<ItemState, ItemPayload>) => void | ItemState, options?: {
|
|
346
404
|
ifNothingWasUpdated?: () => void;
|
|
347
|
-
}) => boolean;
|
|
348
|
-
addItemToState: (fetchParams: ItemPayload, data: ItemState) => void;
|
|
405
|
+
}) => boolean; /** Adds or replaces one cached item directly in state. */
|
|
406
|
+
addItemToState: (fetchParams: ItemPayload, data: ItemState) => void; /** Deletes one or more cached items directly from state. */
|
|
349
407
|
deleteItemState: (fetchParams: ItemPayload | ItemPayload[] | CollectionFilterItemsFn<ItemState, ItemPayload>) => void;
|
|
350
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Runs the full mutation lifecycle: optional optimistic update, async
|
|
410
|
+
* mutation, rollback/error handling, revalidation, and offline queue fallback.
|
|
411
|
+
*/
|
|
412
|
+
performMutation: CollectionPerformMutation<ItemState, ItemPayload, TOfflineOperations>; /** Notifies the store that a shared transport reconnected and should revalidate active data. */
|
|
351
413
|
onTransportReconnect: () => void;
|
|
352
414
|
};
|
|
353
415
|
declare function createCollectionStore<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload> = null, StorageState = unknown>(storeOptions: CollectionStoreOptions<ItemState, ItemPayload, TOfflineOperations, StorageState>): CollectionStore<ItemState, ItemPayload, TOfflineOperations>;
|
|
354
416
|
//#endregion
|
|
355
417
|
//#region src/documentStore.d.ts
|
|
418
|
+
/** Lifecycle status for a document store. */
|
|
356
419
|
type DocumentStatus = 'idle' | TSDFStatus;
|
|
420
|
+
/** Value returned by `DocumentStore.useDocument(...)`. */
|
|
357
421
|
type TSDFUseDocumentReturn<Selected> = {
|
|
358
|
-
status: DocumentStatus;
|
|
359
|
-
data: Selected;
|
|
360
|
-
error: StoreError | null;
|
|
422
|
+
/** Hook-visible document status. */status: DocumentStatus; /** Selected document data. Defaults to the full document or `null`. */
|
|
423
|
+
data: Selected; /** Last document fetch error, if any. */
|
|
424
|
+
error: StoreError | null; /** Convenience flag for `loading` or `refetching` states. */
|
|
361
425
|
isLoading: boolean; /** Whether this result has local offline changes that still need to sync to the server. */
|
|
362
426
|
pendingSync: boolean;
|
|
363
427
|
};
|
|
364
428
|
type DocumentStoreState<State extends ValidStoreState> = {
|
|
365
|
-
data: State | null;
|
|
366
|
-
error: StoreError | null;
|
|
367
|
-
status: DocumentStatus;
|
|
429
|
+
/** Latest loaded document data, or `null` before the document is available. */data: State | null; /** Last fetch error for this document, when the latest fetch failed. */
|
|
430
|
+
error: StoreError | null; /** Current fetch lifecycle status for the document. */
|
|
431
|
+
status: DocumentStatus; /** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
368
432
|
refetchOnMount: false | FetchType;
|
|
369
433
|
};
|
|
370
434
|
type DocumentStoreEvents = {
|
|
371
435
|
invalidateData: FetchType;
|
|
372
436
|
};
|
|
373
437
|
type OnDocumentInvalidate = (priority: FetchType) => void;
|
|
438
|
+
/** Events emitted by document mutation lifecycle helpers. */
|
|
374
439
|
type DocumentStoreStoreEvents = {
|
|
375
440
|
/** Emitted when a mutation begins executing */mutationStart: {
|
|
376
441
|
mutationId: number;
|
|
@@ -389,19 +454,19 @@ type DocumentStoreOptions<State extends ValidStoreState, TOfflineOperations exte
|
|
|
389
454
|
*/
|
|
390
455
|
id: string; /** Shared global store manager providing session scoping and error normalization. */
|
|
391
456
|
storeManager: StoreManager;
|
|
392
|
-
fetchFn: (signal: AbortSignal) => Promise<State
|
|
457
|
+
fetchFn: (signal: AbortSignal) => Promise<MaybeTSDFResult<State>>; /** Overrides the manager's default minimum interval between low-priority fetches for this store. */
|
|
393
458
|
lowPriorityThrottleMs?: number; /** Overrides the manager's default coalescing window for this store. */
|
|
394
|
-
baseCoalescingWindowMs?: number;
|
|
459
|
+
baseCoalescingWindowMs?: number; /** Computes a per-fetch throttle for real-time updates using recent fetch cost and focus state. */
|
|
395
460
|
dynamicRealtimeThrottleMs?: (params: {
|
|
396
461
|
lastFetchDuration: number;
|
|
397
462
|
windowIsNotFocused: boolean;
|
|
398
|
-
}) => number;
|
|
463
|
+
}) => number; /** Store-level focus revalidation policy. Overrides the manager default. */
|
|
399
464
|
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
400
|
-
/** Reconnect-specific cooldown. The first reconnect revalidates immediately;
|
|
465
|
+
/** Reconnect-specific cooldown. Defaults to 2,000ms. The first reconnect revalidates immediately;
|
|
401
466
|
* additional reconnects within the cooldown are coalesced into one trailing
|
|
402
467
|
* revalidation. Set to `0` to disable this cooldown. */
|
|
403
|
-
transportReconnectCooldownMs?: number;
|
|
404
|
-
mediumPriorityDelayMs?: number;
|
|
468
|
+
transportReconnectCooldownMs?: number; /** Delay applied to medium-priority requests before they enter the scheduler. */
|
|
469
|
+
mediumPriorityDelayMs?: number; /** Observes request scheduler lifecycle events for this store. */
|
|
405
470
|
onSchedulerEvent?: (event: RequestSchedulerEvents, data?: RequestSchedulerEventData) => void;
|
|
406
471
|
/**
|
|
407
472
|
* Store-specific mutation error handler.
|
|
@@ -410,6 +475,9 @@ type DocumentStoreOptions<State extends ValidStoreState, TOfflineOperations exte
|
|
|
410
475
|
* error handling for this store.
|
|
411
476
|
*/
|
|
412
477
|
onMutationError?: ((error: unknown, options: StoreMutationErrorOptions) => void) | null;
|
|
478
|
+
/** Indicates that fresh data arrives via a real-time channel. Defaults to `false`. The store
|
|
479
|
+
* skips the mount-time stale refetch since real-time pushes already cover
|
|
480
|
+
* revalidation. */
|
|
413
481
|
usesRealTimeUpdates?: boolean;
|
|
414
482
|
/** Opt-in persistent storage configuration. When provided, cached data is loaded
|
|
415
483
|
* from storage on first read and saved back on successful fetches.
|
|
@@ -451,20 +519,36 @@ type DocumentOnlineMutationArgs<State extends ValidStoreState, T> = DocumentMuta
|
|
|
451
519
|
upload?: undefined;
|
|
452
520
|
};
|
|
453
521
|
type DocumentOfflineMutationArgs<State extends ValidStoreState, T, TOfflineOperations extends DocumentOfflineOperationsConfig<State>> = DocumentMutationArgsBase<State, T> & {
|
|
454
|
-
|
|
522
|
+
/**
|
|
523
|
+
* Queues this mutation through the store's registered offline operation when
|
|
524
|
+
* the session is offline or the direct request fails with an offline outage.
|
|
525
|
+
*/
|
|
526
|
+
offline: TOfflineOperations extends null ? never : OfflineMutationInput<Exclude<TOfflineOperations, null>>; /** Files to attach if this mutation is queued for offline replay. */
|
|
455
527
|
upload?: OfflineMutationUploadsInput;
|
|
456
528
|
};
|
|
457
529
|
type DocumentPerformMutation<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State>> = {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
530
|
+
/**
|
|
531
|
+
* Runs a document mutation with optional optimistic updates and revalidation.
|
|
532
|
+
*
|
|
533
|
+
* Returns the direct server result when offline replay is not configured for
|
|
534
|
+
* this call.
|
|
535
|
+
*/
|
|
536
|
+
<T>(args: DocumentOnlineMutationArgs<State, T>): Promise<Result<UnwrapTSDFResult<Awaited<T>>, StoreMutationError | MutationSkipped>>;
|
|
537
|
+
/**
|
|
538
|
+
* Runs a document mutation that may fall back to durable offline queueing.
|
|
539
|
+
*
|
|
540
|
+
* When the mutation is queued, the result is `{ kind: 'queued' }` instead of
|
|
541
|
+
* the server payload.
|
|
542
|
+
*/
|
|
543
|
+
<T>(args: DocumentOfflineMutationArgs<State, T, TOfflineOperations>): Promise<Result<OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
544
|
+
<T>(args: DocumentOnlineMutationArgs<State, T> | DocumentOfflineMutationArgs<State, T, TOfflineOperations>): Promise<Result<UnwrapTSDFResult<Awaited<T>> | OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
461
545
|
};
|
|
462
546
|
type DocumentStore<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null> = {
|
|
463
|
-
store: Store<DocumentStoreState<State>>;
|
|
464
|
-
events: Emitter<DocumentStoreEvents>;
|
|
465
|
-
storeEvents: Emitter<DocumentStoreStoreEvents>;
|
|
466
|
-
readonly invalidationWasTriggered: boolean;
|
|
467
|
-
scheduleFetch: (fetchType: FetchType, options?: ScheduleFetchOptions) => ScheduleFetchResults;
|
|
547
|
+
/** Underlying t-state store containing the raw document cache state. */store: Store<DocumentStoreState<State>>; /** Invalidation event emitter used by hooks and integrations. */
|
|
548
|
+
events: Emitter<DocumentStoreEvents>; /** Mutation lifecycle event emitter for observers and tests. */
|
|
549
|
+
storeEvents: Emitter<DocumentStoreStoreEvents>; /** Whether the document has been explicitly invalidated and is awaiting refresh. */
|
|
550
|
+
readonly invalidationWasTriggered: boolean; /** Schedules a document fetch with the requested priority. */
|
|
551
|
+
scheduleFetch: (fetchType: FetchType, options?: ScheduleFetchOptions) => ScheduleFetchResults; /** Waits for a document fetch to settle and returns data or a fetch error. */
|
|
468
552
|
awaitFetch: (options?: {
|
|
469
553
|
timeoutMs?: number;
|
|
470
554
|
}) => Promise<{
|
|
@@ -473,22 +557,24 @@ type DocumentStore<State extends ValidStoreState, TOfflineOperations extends Doc
|
|
|
473
557
|
} | {
|
|
474
558
|
data: null;
|
|
475
559
|
error: StoreFetchError;
|
|
476
|
-
}>;
|
|
560
|
+
}>; /** Returns cached document data when usable, otherwise fetches it first. */
|
|
477
561
|
getDataFromStateOrFetch: (options?: {
|
|
478
|
-
ignoreStaleState?: boolean;
|
|
562
|
+
/** When `true`, stale cached data is ignored and refetched before returning. Defaults to `false`. */ignoreStaleState?: boolean;
|
|
479
563
|
timeoutMs?: number;
|
|
480
|
-
}) => Promise<Result<State, StoreFetchError>>;
|
|
481
|
-
preloadPersistentStorage: () => Promise<void>;
|
|
482
|
-
invalidateData: (priority
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
564
|
+
}) => Promise<Result<State, StoreFetchError>>; /** Loads cached document data from persistent storage when available. */
|
|
565
|
+
preloadPersistentStorage: () => Promise<void>; /** Marks the document stale and schedules refetches for active subscriptions. Defaults to `highPriority`. */
|
|
566
|
+
invalidateData: (/** Fetch priority used for refetches triggered by this invalidation. Defaults to `highPriority`. */
|
|
567
|
+
|
|
568
|
+
priority?: FetchType) => void; /** Applies an immutable update to the cached document data. */
|
|
569
|
+
updateState: DocumentUpdateState<State>; /** Clears in-memory state and cancels store-local runtime state. */
|
|
570
|
+
reset: () => void; /** Unregisters listeners and releases resources owned by this store. */
|
|
571
|
+
dispose: () => void; /** Marks the document as mutating and returns a function that ends the mutation. */
|
|
572
|
+
startMutation: () => () => boolean; /** Returns offline sync metadata for this store's tracked entity. */
|
|
573
|
+
getOfflineEntities: () => GlobalOfflineEntity[]; /** React hook subscribing to this store's offline entity metadata. */
|
|
574
|
+
useOfflineEntities: () => readonly GlobalOfflineEntity[]; /** React hook subscribing to manual offline resolutions for this store. */
|
|
575
|
+
useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** Returns manual offline resolutions for this store. */
|
|
576
|
+
getOfflineResolutions: () => OfflineResolutionRecord[]; /** Parses a stored offline conflict into the operation-specific conflict shape. */
|
|
577
|
+
parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedDocumentOfflineOperations<TOfflineOperations>>; /** Applies a retry/discard/requeue/commit action to a pending offline resolution. */
|
|
492
578
|
resolveOfflineResolution: <TName extends keyof ResolvedDocumentOfflineOperations<TOfflineOperations> & string>(resolutionId: string, operationName: TName, resolution: OfflineResolutionActionForOperation<ResolvedDocumentOfflineOperations<TOfflineOperations>, TName>) => Promise<void> | void;
|
|
493
579
|
useDocument: <Selected = State | null>(args?: {
|
|
494
580
|
/** Maps the document data before it is returned from the hook. */selector?: (data: State | null) => Selected; /** Disables this hook subscription and prevents automatic fetches. */
|
|
@@ -507,19 +593,19 @@ type DocumentStore<State extends ValidStoreState, TOfflineOperations extends Doc
|
|
|
507
593
|
*/
|
|
508
594
|
ensureIsLoaded?: boolean; /** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
509
595
|
returnRefetchingStatus?: boolean;
|
|
510
|
-
}) => TSDFUseDocumentReturn<Selected>;
|
|
596
|
+
}) => TSDFUseDocumentReturn<Selected>; /** React hook that tracks whether a nested list item is still loading. */
|
|
511
597
|
useListItemIsLoading: (args: {
|
|
512
598
|
/** Unique identifier of the item within the document. */itemId: string; /** Extracts the item from the document data. */
|
|
513
599
|
selector: (data: State | null) => unknown; /** Called if the item is still missing and no refetch is in progress. */
|
|
514
600
|
loadItemFallback?: () => void; /** Forces a high-priority fetch and keeps the hook loading until data is loaded. */
|
|
515
601
|
ensureIsLoaded?: boolean;
|
|
516
|
-
}) => boolean;
|
|
602
|
+
}) => boolean; /** React hook that tracks whether a nested list item has been deleted. */
|
|
517
603
|
useListItemIsDeleted: (args: {
|
|
518
604
|
/** Unique identifier of the item within the document. */itemId: string; /** Extracts the item from the document data. */
|
|
519
605
|
selector: (data: State | null) => unknown; /** Called once when deletion is detected. */
|
|
520
606
|
onDelete?: () => void; /** Forces a high-priority fetch and keeps the hook loading until data is loaded. */
|
|
521
607
|
ensureIsLoaded?: boolean;
|
|
522
|
-
}) => boolean;
|
|
608
|
+
}) => boolean; /** React hook for selecting one nested list item plus loading/deleted flags. */
|
|
523
609
|
useListItem: <Selected>(args: {
|
|
524
610
|
/** Unique identifier of the item within the document. */itemId: string; /** Extracts and maps the item from the document data. */
|
|
525
611
|
selector: (data: State | null) => Selected; /** Called if the item is still missing and no refetch is in progress. */
|
|
@@ -531,34 +617,42 @@ type DocumentStore<State extends ValidStoreState, TOfflineOperations extends Doc
|
|
|
531
617
|
isDeleted: boolean;
|
|
532
618
|
data: Selected;
|
|
533
619
|
};
|
|
534
|
-
|
|
620
|
+
/**
|
|
621
|
+
* Runs the full mutation lifecycle: optional optimistic update, async
|
|
622
|
+
* mutation, rollback/error handling, revalidation, and offline queue fallback.
|
|
623
|
+
*/
|
|
624
|
+
performMutation: DocumentPerformMutation<State, TOfflineOperations>; /** Notifies the store that a shared transport reconnected and should revalidate active data. */
|
|
535
625
|
onTransportReconnect: () => void;
|
|
536
626
|
};
|
|
537
627
|
declare function createDocumentStore<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null, StorageState = unknown>(storeOptions: DocumentStoreOptions<State, TOfflineOperations, StorageState>): DocumentStore<State, TOfflineOperations>;
|
|
538
628
|
//#endregion
|
|
539
629
|
//#region src/listQueryStore/types.d.ts
|
|
630
|
+
/** Lifecycle status for a list query or list item query. */
|
|
540
631
|
type QueryStatus = TSDFStatus | 'loadingMore';
|
|
632
|
+
/** Raw cached state for one list query. */
|
|
541
633
|
type TSFDListQuery<QueryPayload extends ValidPayload> = {
|
|
542
|
-
error: StoreError | null;
|
|
543
|
-
status: QueryStatus;
|
|
544
|
-
payload: QueryPayload;
|
|
545
|
-
hasMore: boolean;
|
|
546
|
-
wasLoaded: boolean;
|
|
547
|
-
refetchOnMount: false | FetchType;
|
|
634
|
+
/** Last fetch error for this query, when the latest fetch failed. */error: StoreError | null; /** Current fetch lifecycle status for this query. */
|
|
635
|
+
status: QueryStatus; /** Payload used to identify and fetch this query. */
|
|
636
|
+
payload: QueryPayload; /** Whether another page is available. */
|
|
637
|
+
hasMore: boolean; /** Whether this query has ever loaded successfully. */
|
|
638
|
+
wasLoaded: boolean; /** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
639
|
+
refetchOnMount: false | FetchType; /** Ordered item keys included in the cached query page. */
|
|
548
640
|
items: string[];
|
|
549
641
|
};
|
|
642
|
+
/** Raw cached state for one item query in a list-query store. */
|
|
550
643
|
type TSDFItemQuery<ItemPayload extends ValidPayload> = {
|
|
551
|
-
error: StoreError | null;
|
|
552
|
-
status: Exclude<QueryStatus, 'loadingMore'>;
|
|
553
|
-
wasLoaded: boolean;
|
|
554
|
-
refetchOnMount: false | FetchType;
|
|
644
|
+
/** Last item fetch error, if any. */error: StoreError | null; /** Current fetch lifecycle status for this item. */
|
|
645
|
+
status: Exclude<QueryStatus, 'loadingMore'>; /** Whether this item has ever loaded successfully. */
|
|
646
|
+
wasLoaded: boolean; /** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
647
|
+
refetchOnMount: false | FetchType; /** Payload used to identify and fetch this item. */
|
|
555
648
|
payload: ItemPayload;
|
|
556
649
|
};
|
|
650
|
+
/** Raw t-state shape used by a list-query store. */
|
|
557
651
|
type TSFDListQueryState<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
558
|
-
items: Record<string, ItemState | null>;
|
|
559
|
-
queries: Record<string, TSFDListQuery<QueryPayload>>;
|
|
560
|
-
itemQueries: Record<string, TSDFItemQuery<ItemPayload> | null>;
|
|
561
|
-
itemLoadedFields: Record<string, string[]>;
|
|
652
|
+
/** Item data records keyed by item store key. */items: Record<string, ItemState | null>; /** List query records keyed by query store key. */
|
|
653
|
+
queries: Record<string, TSFDListQuery<QueryPayload>>; /** Item query records keyed by item store key. */
|
|
654
|
+
itemQueries: Record<string, TSDFItemQuery<ItemPayload> | null>; /** Loaded partial-resource fields for each item key. */
|
|
655
|
+
itemLoadedFields: Record<string, string[]>; /** Pending field invalidations for each item key. */
|
|
562
656
|
itemFieldInvalidationFields: Record<string, string[]>;
|
|
563
657
|
};
|
|
564
658
|
/**
|
|
@@ -568,44 +662,50 @@ type TSFDListQueryState<ItemState extends ValidStoreState, QueryPayload extends
|
|
|
568
662
|
* complete item.
|
|
569
663
|
*/
|
|
570
664
|
type FieldsInput = string[] | '*';
|
|
665
|
+
/** Value returned by `ListQueryStore.useListQuery(...)` and `useMultipleListQueries(...)`. */
|
|
571
666
|
type TSFDUseListQueryReturn<Selected, QueryPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined, HasPartialResources extends boolean = false> = {
|
|
572
|
-
items: Selected[];
|
|
573
|
-
status: QueryStatus | 'idle';
|
|
574
|
-
payload: QueryPayload | undefined;
|
|
667
|
+
/** Selected items included in the current query result. */items: Selected[]; /** Hook-visible query status, including `idle` before a query runs. */
|
|
668
|
+
status: QueryStatus | 'idle'; /** Query payload for this result, unless omitted or unavailable. */
|
|
669
|
+
payload: QueryPayload | undefined; /** Requested partial-resource fields for this query result. */
|
|
575
670
|
fields: HasPartialResources extends true ? FieldsInput : FieldsInput | undefined; /** Requested partial-resource fields that are still pending. */
|
|
576
|
-
loadingFields?: string[];
|
|
577
|
-
error: StoreError | null;
|
|
578
|
-
queryKey: string;
|
|
579
|
-
hasMore: boolean;
|
|
580
|
-
isDerived: boolean;
|
|
581
|
-
isLoading: boolean;
|
|
671
|
+
loadingFields?: string[]; /** Last query fetch error, if any. */
|
|
672
|
+
error: StoreError | null; /** Stable store key for the current query payload. */
|
|
673
|
+
queryKey: string; /** Whether another page is available. */
|
|
674
|
+
hasMore: boolean; /** Whether this result was derived from local items instead of fetched directly. */
|
|
675
|
+
isDerived: boolean; /** Convenience flag for `loading` or `refetching` states. */
|
|
676
|
+
isLoading: boolean; /** Whether a `loadMore(...)` request is currently active. */
|
|
582
677
|
isLoadingMore: boolean; /** Whether this result has local offline changes that still need to sync to the server. */
|
|
583
|
-
pendingSync: boolean;
|
|
678
|
+
pendingSync: boolean; /** Caller-provided metadata copied from the query descriptor. */
|
|
584
679
|
queryMetadata: QueryMetadata;
|
|
585
680
|
};
|
|
681
|
+
/** Value returned by `ListQueryStore.useItem(...)` and `useMultipleItems(...)`. */
|
|
586
682
|
type TSFDUseListItemReturn<Selected, ItemPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
587
|
-
data: Selected;
|
|
588
|
-
status: QueryStatus | 'idle' | 'deleted';
|
|
683
|
+
/** Selected item data. Defaults to the full item or `null`. */data: Selected; /** Hook-visible item status, including idle/deleted states for hook ergonomics. */
|
|
684
|
+
status: QueryStatus | 'idle' | 'deleted'; /** Item payload for this result, or `null` when unavailable. */
|
|
589
685
|
payload: ItemPayload | null; /** Requested partial-resource fields that are still pending. */
|
|
590
|
-
loadingFields?: string[];
|
|
591
|
-
error: StoreError | null;
|
|
592
|
-
isLoading: boolean;
|
|
686
|
+
loadingFields?: string[]; /** Last item fetch error, if any. */
|
|
687
|
+
error: StoreError | null; /** Convenience flag for `loading` or `refetching` states. */
|
|
688
|
+
isLoading: boolean; /** Stable store key for the current item payload. */
|
|
593
689
|
itemStateKey: string; /** Whether this result has local offline changes that still need to sync to the server. */
|
|
594
|
-
pendingSync: boolean;
|
|
690
|
+
pendingSync: boolean; /** Caller-provided metadata copied from the query descriptor. */
|
|
595
691
|
queryMetadata: QueryMetadata;
|
|
596
692
|
};
|
|
693
|
+
/** Value returned by `ListQueryStore.usePendingOfflineItems(...)`. */
|
|
597
694
|
type TSFDUsePendingOfflineItemsReturn<Selected, ItemPayload extends ValidPayload> = {
|
|
598
|
-
items: Selected[];
|
|
695
|
+
/** Locally created or updated offline items selected by the hook. */items: Selected[]; /** Payloads for locally deleted offline items. */
|
|
599
696
|
deletedItems: ItemPayload[];
|
|
600
697
|
};
|
|
698
|
+
/** One item returned from a list query fetch function. */
|
|
601
699
|
type FetchListFnReturnItem<ItemPayload extends ValidPayload, ItemState extends ValidStoreState> = {
|
|
602
|
-
itemPayload: ItemPayload;
|
|
700
|
+
/** Item payload used to key and refetch the returned item. */itemPayload: ItemPayload; /** Item data returned by the server. */
|
|
603
701
|
data: ItemState;
|
|
604
702
|
};
|
|
703
|
+
/** Return shape for list query fetch functions. */
|
|
605
704
|
type FetchListFnReturn<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
|
|
606
|
-
items: FetchListFnReturnItem<ItemPayload, ItemState>[];
|
|
705
|
+
/** Items included in the fetched page. */items: FetchListFnReturnItem<ItemPayload, ItemState>[]; /** Whether the query has another page available. */
|
|
607
706
|
hasMore: boolean;
|
|
608
707
|
};
|
|
708
|
+
/** Item descriptor accepted by `ListQueryStore.useMultipleItems(...)`. */
|
|
609
709
|
type ListQueryUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
610
710
|
/** Item payload to subscribe to and fetch when needed. */payload: ItemPayload;
|
|
611
711
|
/**
|
|
@@ -631,6 +731,7 @@ type ListQueryUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMetad
|
|
|
631
731
|
showPartialAsRefetching?: boolean; /** Marks this subscription as off-screen, lowering automatic fetch priority. */
|
|
632
732
|
isOffScreen?: boolean;
|
|
633
733
|
};
|
|
734
|
+
/** Query descriptor accepted by `ListQueryStore.useMultipleListQueries(...)`. */
|
|
634
735
|
type ListQueryUseMultipleListQueriesQuery<QueryPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
635
736
|
/** Query payload to subscribe to and fetch when needed. */payload: QueryPayload;
|
|
636
737
|
/**
|
|
@@ -658,22 +759,26 @@ type ListQueryUseMultipleListQueriesQuery<QueryPayload extends ValidPayload, Que
|
|
|
658
759
|
isOffScreen?: boolean; /** Number of items to request when fetching this query page. */
|
|
659
760
|
loadSize?: number;
|
|
660
761
|
};
|
|
762
|
+
/** Callback invoked when an already-loaded list query is invalidated. */
|
|
661
763
|
type OnListQueryInvalidate<QueryPayload extends ValidPayload> = (query: QueryPayload, priority: FetchType) => void;
|
|
764
|
+
/** Callback invoked when an already-loaded list-query item is invalidated. */
|
|
662
765
|
type OnListQueryItemInvalidate<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (props: {
|
|
663
|
-
itemState: ItemState;
|
|
664
|
-
payload: ItemPayload;
|
|
766
|
+
/** Current cached item state at invalidation time. */itemState: ItemState; /** Payload of the invalidated item. */
|
|
767
|
+
payload: ItemPayload; /** Fetch priority requested for the invalidation. */
|
|
665
768
|
priority: FetchType;
|
|
666
769
|
}) => void;
|
|
770
|
+
/** Rule for keeping cached list query membership in sync after item updates. */
|
|
667
771
|
type OptimisticListUpdate<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
668
|
-
queries: QueryPayload | ((query: QueryPayload) => boolean) | QueryPayload[];
|
|
669
|
-
filterItem?: (item: ItemState) => boolean | null;
|
|
670
|
-
appendNewTo?: 'start' | 'end';
|
|
671
|
-
invalidateQueries?: boolean;
|
|
772
|
+
/** Query payloads, or a predicate over query payloads, affected by this rule. */queries: QueryPayload | ((query: QueryPayload) => boolean) | QueryPayload[]; /** Restricts this rule to items that should belong in the affected query set. */
|
|
773
|
+
filterItem?: (item: ItemState) => boolean | null; /** Where newly matching items should be inserted in affected query pages. */
|
|
774
|
+
appendNewTo?: 'start' | 'end'; /** Whether affected queries should still refetch after the optimistic list update. */
|
|
775
|
+
invalidateQueries?: boolean; /** Sort order to maintain inside affected query pages. */
|
|
672
776
|
sort?: {
|
|
673
|
-
sortBy: (item: ItemState, itemPayload: ItemPayload) => string | number | (string | number)[];
|
|
777
|
+
/** Selects sortable values from an item. */sortBy: (item: ItemState, itemPayload: ItemPayload) => string | number | (string | number)[]; /** Sort direction for each `sortBy` value. */
|
|
674
778
|
order?: 'asc' | 'desc' | ('asc' | 'desc')[];
|
|
675
779
|
};
|
|
676
780
|
};
|
|
781
|
+
/** Payload passed to list fetch functions. */
|
|
677
782
|
type QueryFetchPayload<QueryPayload extends ValidPayload> = {
|
|
678
783
|
/** Whether this request loads the first page or a later page. */type: 'load' | 'loadMore'; /** Query payload being fetched. */
|
|
679
784
|
payload: QueryPayload; /** Offset used for offset-paginated fetches. */
|
|
@@ -681,12 +786,14 @@ type QueryFetchPayload<QueryPayload extends ValidPayload> = {
|
|
|
681
786
|
limit: number; /** Partial-resource fields requested for each item in the fetched query. */
|
|
682
787
|
fields?: string[];
|
|
683
788
|
};
|
|
789
|
+
/** Options for offset-based list pagination. */
|
|
684
790
|
type OffsetPaginationConfig = {
|
|
685
|
-
maxInvalidationLimit: number; /** Max parallel chunk requests during chunked invalidation (default: 3) */
|
|
791
|
+
/** Largest item count requested when refetching invalidated offset queries. */maxInvalidationLimit: number; /** Max parallel chunk requests during chunked invalidation (default: 3) */
|
|
686
792
|
maxParallel?: number;
|
|
687
793
|
};
|
|
794
|
+
/** Partial-resource helpers used to merge and select field subsets. */
|
|
688
795
|
type PartialResourcesConfig<ItemState extends ValidStoreState> = {
|
|
689
|
-
mergeItems: (prev: ItemState | undefined, fetched: ItemState) => ItemState;
|
|
796
|
+
/** Merges a partial fetch result into an existing item snapshot. */mergeItems: (prev: ItemState | undefined, fetched: ItemState) => ItemState; /** Returns an item containing only the requested fields. */
|
|
690
797
|
selectFields: (fields: string[], item: ItemState) => ItemState;
|
|
691
798
|
};
|
|
692
799
|
type DerivedQuerySummary<QueryPayload extends ValidPayload> = {
|
|
@@ -711,6 +818,7 @@ type DerivedQueryContext = {
|
|
|
711
818
|
*/
|
|
712
819
|
deriveSource: DerivedQuerySource;
|
|
713
820
|
};
|
|
821
|
+
/** Configuration for deriving query membership from locally materialized items. */
|
|
714
822
|
type DerivedQueriesConfig<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
715
823
|
/** Extracts the domain/group key for a query payload. */getQueryGroup: (queryPayload: QueryPayload) => string; /** Extracts the domain/group key for a materialized item. */
|
|
716
824
|
getItemGroup: (item: ItemState, itemPayload: ItemPayload) => string;
|
|
@@ -728,6 +836,7 @@ type DerivedQueriesConfig<ItemState extends ValidStoreState, QueryPayload extend
|
|
|
728
836
|
*/
|
|
729
837
|
deriveQuery: (queryPayload: QueryPayload, items: DerivedQueryItem<ItemState>[], context: DerivedQueryContext) => string[] | false;
|
|
730
838
|
};
|
|
839
|
+
/** Field option shape used by APIs that are conditional on `partialResources`. */
|
|
731
840
|
type FieldsOption<HasPartialResources extends boolean> = HasPartialResources extends true ? {
|
|
732
841
|
/**
|
|
733
842
|
* Partial-resource fields to request.
|
|
@@ -851,14 +960,15 @@ type UsePendingOfflineItemsOptions<ItemState extends ValidStoreState, ItemPayloa
|
|
|
851
960
|
};
|
|
852
961
|
//#endregion
|
|
853
962
|
//#region src/listQueryStore/listQueryStore.d.ts
|
|
963
|
+
/** Event payloads emitted by `ListQueryStore.events`. */
|
|
854
964
|
type ListQueryStoreEvents = {
|
|
855
|
-
invalidateQuery: {
|
|
856
|
-
priority: FetchType;
|
|
965
|
+
/** Emitted whenever one or more list queries are invalidated. */invalidateQuery: {
|
|
966
|
+
/** Fetch priority requested by the invalidation. */priority: FetchType; /** Store key for the invalidated query. */
|
|
857
967
|
queryKey: string;
|
|
858
|
-
};
|
|
968
|
+
}; /** Emitted whenever one or more list-query items are invalidated. */
|
|
859
969
|
invalidateItem: {
|
|
860
|
-
priority: FetchType;
|
|
861
|
-
itemKey: string;
|
|
970
|
+
/** Fetch priority requested by the invalidation. */priority: FetchType; /** Store key for the invalidated item. */
|
|
971
|
+
itemKey: string; /** Partial-resource fields invalidated on this item, when applicable. */
|
|
862
972
|
invalidateFields?: string[];
|
|
863
973
|
};
|
|
864
974
|
};
|
|
@@ -898,19 +1008,19 @@ type ListQueryFetchFieldsOption<TPartialResources extends boolean> = ListQueryHa
|
|
|
898
1008
|
};
|
|
899
1009
|
type ListQueryScheduleFetchWithFieldsOption<TPartialResources extends boolean> = ScheduleFetchOptions & ListQueryFetchFieldsOption<TPartialResources>;
|
|
900
1010
|
type ListQueryScheduleListQueryFetchApi<QueryPayload extends ValidPayload, TPartialResources extends boolean> = {
|
|
901
|
-
(fetchType: FetchType, payload: QueryPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [size: number | undefined, options: ListQueryScheduleFetchWithFieldsOption<TPartialResources>] : [size?: number, options?: ListQueryScheduleFetchWithFieldsOption<TPartialResources>]): ScheduleFetchResults;
|
|
902
|
-
(fetchType: FetchType, payload: QueryPayload[], ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [size: number | undefined, options: ListQueryScheduleFetchWithFieldsOption<TPartialResources>] : [size?: number, options?: ListQueryScheduleFetchWithFieldsOption<TPartialResources>]): ScheduleFetchResults[];
|
|
1011
|
+
(fetchType: FetchType, payload: QueryPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [/** Number of items to request. Defaults to the store's `defaultQuerySize`. */size: number | undefined, options: ListQueryScheduleFetchWithFieldsOption<TPartialResources>] : [/** Number of items to request. Defaults to the store's `defaultQuerySize`. */size?: number, options?: ListQueryScheduleFetchWithFieldsOption<TPartialResources>]): ScheduleFetchResults;
|
|
1012
|
+
(fetchType: FetchType, payload: QueryPayload[], ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [/** Number of items to request. Defaults to the store's `defaultQuerySize`. */size: number | undefined, options: ListQueryScheduleFetchWithFieldsOption<TPartialResources>] : [/** Number of items to request. Defaults to the store's `defaultQuerySize`. */size?: number, options?: ListQueryScheduleFetchWithFieldsOption<TPartialResources>]): ScheduleFetchResults[];
|
|
903
1013
|
};
|
|
904
1014
|
type ListQueryScheduleItemFetchApi<ItemPayload extends ValidPayload, TPartialResources extends boolean> = {
|
|
905
1015
|
(fetchType: FetchType, itemPayload: ItemPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [options: ListQueryScheduleFetchWithFieldsOption<TPartialResources>] : [options?: ListQueryScheduleFetchWithFieldsOption<TPartialResources>]): ScheduleFetchResults;
|
|
906
1016
|
(fetchType: FetchType, itemPayload: ItemPayload[], ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [options: ListQueryScheduleFetchWithFieldsOption<TPartialResources>] : [options?: ListQueryScheduleFetchWithFieldsOption<TPartialResources>]): ScheduleFetchResults[];
|
|
907
1017
|
};
|
|
908
1018
|
type ListQueryLoadMoreWithFieldsOptions<TPartialResources extends boolean> = {
|
|
909
|
-
size?: number;
|
|
1019
|
+
/** Number of additional items to request. Defaults to the store's `defaultQuerySize`. */size?: number;
|
|
910
1020
|
} & ListQueryFetchFieldsOption<TPartialResources>;
|
|
911
|
-
type ListQueryLoadMoreApi<QueryPayload extends ValidPayload, TPartialResources extends boolean> = (params: QueryPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [size: number, options: ListQueryFetchFieldsOption<TPartialResources>] | [options: ListQueryLoadMoreWithFieldsOptions<TPartialResources>] : [size?: number, options?: ListQueryFetchFieldsOption<TPartialResources>] | [options?: ListQueryLoadMoreWithFieldsOptions<TPartialResources>]) => ScheduleFetchResults;
|
|
1021
|
+
type ListQueryLoadMoreApi<QueryPayload extends ValidPayload, TPartialResources extends boolean> = (params: QueryPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [size: number, options: ListQueryFetchFieldsOption<TPartialResources>] | [options: ListQueryLoadMoreWithFieldsOptions<TPartialResources>] : [/** Number of additional items to request. Defaults to the store's `defaultQuerySize`. */size?: number, options?: ListQueryFetchFieldsOption<TPartialResources>] | [options?: ListQueryLoadMoreWithFieldsOptions<TPartialResources>]) => ScheduleFetchResults;
|
|
912
1022
|
type ListQueryAwaitListQueryFetchOptions<TPartialResources extends boolean> = {
|
|
913
|
-
size?: number;
|
|
1023
|
+
/** Number of items to request. Defaults to the store's `defaultQuerySize`. */size?: number;
|
|
914
1024
|
timeoutMs?: number;
|
|
915
1025
|
} & ListQueryFetchFieldsOption<TPartialResources>;
|
|
916
1026
|
type ListQueryAwaitListQueryFetchApi<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean> = (params: QueryPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [options: ListQueryAwaitListQueryFetchOptions<TPartialResources>] : [options?: ListQueryAwaitListQueryFetchOptions<TPartialResources>]) => Promise<{
|
|
@@ -926,7 +1036,7 @@ type ListQueryAwaitListQueryFetchApi<ItemState extends ValidStoreState, QueryPay
|
|
|
926
1036
|
hasMore: boolean;
|
|
927
1037
|
}>;
|
|
928
1038
|
type ListQueryGetQueryFromStateOrFetchOptions<TPartialResources extends boolean> = {
|
|
929
|
-
ignoreStaleState?: boolean;
|
|
1039
|
+
/** When `true`, stale cached queries are ignored and refetched before returning. Defaults to `false`. */ignoreStaleState?: boolean; /** Number of items to request when a fetch is needed. Defaults to the store's `defaultQuerySize`. */
|
|
930
1040
|
size?: number;
|
|
931
1041
|
timeoutMs?: number;
|
|
932
1042
|
} & ListQueryFetchFieldsOption<TPartialResources>;
|
|
@@ -948,7 +1058,7 @@ type ListQueryAwaitItemFetchApi<ItemState extends ValidStoreState, ItemPayload e
|
|
|
948
1058
|
error: null;
|
|
949
1059
|
}>;
|
|
950
1060
|
type ListQueryGetItemFromStateOrFetchOptions<TPartialResources extends boolean> = {
|
|
951
|
-
ignoreStaleState?: boolean;
|
|
1061
|
+
/** When `true`, stale cached items are ignored and refetched before returning. Defaults to `false`. */ignoreStaleState?: boolean;
|
|
952
1062
|
timeoutMs?: number;
|
|
953
1063
|
} & ListQueryFetchFieldsOption<TPartialResources>;
|
|
954
1064
|
type ListQueryGetItemFromStateOrFetchApi<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TPartialResources extends boolean> = (itemPayload: ItemPayload, ...args: ListQueryHasPartialResources<TPartialResources> extends true ? [options: ListQueryGetItemFromStateOrFetchOptions<TPartialResources>] : [options?: ListQueryGetItemFromStateOrFetchOptions<TPartialResources>]) => Promise<Result<ItemState, StoreFetchError>>;
|
|
@@ -978,12 +1088,30 @@ type ListQueryFilterItem<ItemState extends ValidStoreState, ItemPayload extends
|
|
|
978
1088
|
type ListQueryMutationPayload<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload> | null;
|
|
979
1089
|
type ListQueryMutationPayloadToUse<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>;
|
|
980
1090
|
type ListQueryMutationArgsBase<T, ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
981
|
-
|
|
1091
|
+
/**
|
|
1092
|
+
* Applies optimistic updates for the affected item payloads before the
|
|
1093
|
+
* mutation runs. Return `false` to cancel the mutation before the async
|
|
1094
|
+
* mutation function is called.
|
|
1095
|
+
*/
|
|
1096
|
+
optimisticUpdate?: (payload: ListQueryMutationPayloadToUse<ItemState, ItemPayload>) => void | boolean; /** Performs the server mutation for the affected item payloads. */
|
|
982
1097
|
mutation: (payload: ListQueryMutationPayloadToUse<ItemState, ItemPayload>) => Promise<T>;
|
|
983
|
-
|
|
984
|
-
|
|
1098
|
+
/**
|
|
1099
|
+
* Controls query and item invalidation after a successful online mutation.
|
|
1100
|
+
*
|
|
1101
|
+
* Use `true` to invalidate affected items and all queries, `'queries'` to
|
|
1102
|
+
* invalidate only queries, a query filter to invalidate affected items and
|
|
1103
|
+
* matching queries, or `{ queries, items }` to choose both explicitly.
|
|
1104
|
+
*/
|
|
1105
|
+
revalidateOnSuccess?: ListQueryRevalidateOnSuccessOption<QueryPayload>; /** Called after a successful online mutation. */
|
|
1106
|
+
onSuccess?: (response: UnwrapTSDFResult<Awaited<T>>, payload: ListQueryMutationPayloadToUse<ItemState, ItemPayload>) => void; /** Called after a failed or skipped mutation. */
|
|
985
1107
|
onError?: (error: StoreMutationError | MutationSkipped) => void;
|
|
986
|
-
|
|
1108
|
+
/**
|
|
1109
|
+
* Passes `{ silentErrors: true }` to `onMutationError`.
|
|
1110
|
+
*
|
|
1111
|
+
* The handler is still called so centralized logging and recovery can run,
|
|
1112
|
+
* but UI handlers can suppress user-facing notifications.
|
|
1113
|
+
*/
|
|
1114
|
+
silentErrors?: boolean; /** Debounces mutations with the same context and payload. Superseded calls are skipped. */
|
|
987
1115
|
debounce?: {
|
|
988
1116
|
context: string;
|
|
989
1117
|
payload: unknown;
|
|
@@ -995,15 +1123,44 @@ type ListQueryOnlineMutationArgs<T, ItemState extends ValidStoreState, QueryPayl
|
|
|
995
1123
|
upload?: undefined;
|
|
996
1124
|
};
|
|
997
1125
|
type ListQueryOfflineMutationArgs<T, ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload>> = ListQueryMutationArgsBase<T, ItemState, QueryPayload, ItemPayload> & {
|
|
998
|
-
|
|
1126
|
+
/**
|
|
1127
|
+
* Queues this mutation through the store's registered offline operation when
|
|
1128
|
+
* the session is offline or the direct request fails with an offline outage.
|
|
1129
|
+
*/
|
|
1130
|
+
offline: TOfflineOperations extends null ? never : OfflineMutationInput<Exclude<TOfflineOperations, null>>; /** Files to attach if this mutation is queued for offline replay. */
|
|
999
1131
|
upload?: OfflineMutationUploadsInput;
|
|
1000
1132
|
};
|
|
1001
1133
|
type ListQueryPerformMutationApi<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload>> = {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1134
|
+
/**
|
|
1135
|
+
* Runs a list-query mutation for existing item payloads or an item filter.
|
|
1136
|
+
*
|
|
1137
|
+
* Returns the direct server result when offline replay is not configured for
|
|
1138
|
+
* this call.
|
|
1139
|
+
*/
|
|
1140
|
+
<T>(payload: ListQueryMutationPayloadToUse<ItemState, ItemPayload>, args: ListQueryOnlineMutationArgs<T, ItemState, QueryPayload, ItemPayload>): Promise<Result<UnwrapTSDFResult<Awaited<T>>, StoreMutationError | MutationSkipped>>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Runs a list-query mutation for existing item payloads or an item filter,
|
|
1143
|
+
* with durable offline queueing as a fallback.
|
|
1144
|
+
*
|
|
1145
|
+
* When the mutation is queued, the result is `{ kind: 'queued' }` instead of
|
|
1146
|
+
* the server payload.
|
|
1147
|
+
*/
|
|
1148
|
+
<T>(payload: ListQueryMutationPayloadToUse<ItemState, ItemPayload>, args: ListQueryOfflineMutationArgs<T, ItemState, QueryPayload, ItemPayload, TOfflineOperations>): Promise<Result<OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Runs a list-query mutation with no current item target.
|
|
1151
|
+
*
|
|
1152
|
+
* Use this for create mutations that do not have a pre-generated item payload
|
|
1153
|
+
* yet. Optimistic updates are not available without a target payload.
|
|
1154
|
+
*/
|
|
1155
|
+
<T>(payload: null, args: Omit<ListQueryOnlineMutationArgs<T, ItemState, QueryPayload, ItemPayload>, 'optimisticUpdate'>): Promise<Result<UnwrapTSDFResult<Awaited<T>>, StoreMutationError | MutationSkipped>>;
|
|
1156
|
+
/**
|
|
1157
|
+
* Runs an offline-capable list-query mutation with no current item target.
|
|
1158
|
+
*
|
|
1159
|
+
* Use this for create mutations that do not have a pre-generated item payload
|
|
1160
|
+
* yet. When the mutation is queued, the result is `{ kind: 'queued' }`.
|
|
1161
|
+
*/
|
|
1162
|
+
<T>(payload: null, args: Omit<ListQueryOfflineMutationArgs<T, ItemState, QueryPayload, ItemPayload, TOfflineOperations>, 'optimisticUpdate'>): Promise<Result<OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
1163
|
+
<T>(payload: ListQueryMutationPayload<ItemState, ItemPayload>, args: ListQueryOnlineMutationArgs<T, ItemState, QueryPayload, ItemPayload> | ListQueryOfflineMutationArgs<T, ItemState, QueryPayload, ItemPayload, TOfflineOperations>): Promise<Result<UnwrapTSDFResult<Awaited<T>> | OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
1007
1164
|
};
|
|
1008
1165
|
type ListQueryUpdateItemStateApi<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (itemIds: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>, produceNewData: (draftData: ItemState, itemPayload: ItemPayload) => void | ItemState, options?: {
|
|
1009
1166
|
ifNothingWasUpdated?: () => void;
|
|
@@ -1016,7 +1173,7 @@ type ListQueryAddItemToStateApi<ItemState extends ValidStoreState, QueryPayload
|
|
|
1016
1173
|
}) => void;
|
|
1017
1174
|
type ListQueryDeleteItemStateApi<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>) => void;
|
|
1018
1175
|
type ListQueryInvalidateQueryAndItemsArgs<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
1019
|
-
/** Invalidate every cached query and every cached item. */all: true; /** Fetch priority used for refetches triggered by this invalidation. */
|
|
1176
|
+
/** Invalidate every cached query and every cached item. */all: true; /** Fetch priority used for refetches triggered by this invalidation. Defaults to `highPriority`. */
|
|
1020
1177
|
type?: FetchType;
|
|
1021
1178
|
/**
|
|
1022
1179
|
* Partial-resource fields to invalidate on matching items.
|
|
@@ -1041,7 +1198,7 @@ type ListQueryInvalidateQueryAndItemsArgs<ItemState extends ValidStoreState, Que
|
|
|
1041
1198
|
* Pass one payload, many payloads, a predicate over cached queries, or
|
|
1042
1199
|
* `false` to skip query invalidation.
|
|
1043
1200
|
*/
|
|
1044
|
-
queryPayload: QueryPayload | QueryPayload[] | ListQueryFilterQuery<QueryPayload> | false; /** Fetch priority used for refetches triggered by this invalidation. */
|
|
1201
|
+
queryPayload: QueryPayload | QueryPayload[] | ListQueryFilterQuery<QueryPayload> | false; /** Fetch priority used for refetches triggered by this invalidation. Defaults to `highPriority`. */
|
|
1045
1202
|
type?: FetchType;
|
|
1046
1203
|
/**
|
|
1047
1204
|
* Partial-resource fields to invalidate on matching items.
|
|
@@ -1050,122 +1207,130 @@ type ListQueryInvalidateQueryAndItemsArgs<ItemState extends ValidStoreState, Que
|
|
|
1050
1207
|
*/
|
|
1051
1208
|
fields?: string[];
|
|
1052
1209
|
};
|
|
1210
|
+
/** Public API returned by `createListQueryStore(...)`. */
|
|
1053
1211
|
type ListQueryStore<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean = false, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload> = null> = {
|
|
1054
|
-
store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>;
|
|
1055
|
-
events: Emitter<ListQueryStoreEvents>;
|
|
1056
|
-
storeEvents: Emitter<ListQueryStoreStoreEvents<ItemPayload>>;
|
|
1057
|
-
readonly queryInvalidationWasTriggered: Set<string>;
|
|
1058
|
-
readonly itemInvalidationWasTriggered: Set<string>;
|
|
1059
|
-
reset: () => void;
|
|
1060
|
-
dispose: () => void;
|
|
1061
|
-
scheduleListQueryFetch: ListQueryScheduleListQueryFetchApi<QueryPayload, TPartialResources>;
|
|
1062
|
-
getQueryState: (params: QueryPayload) => TSFDListQuery<QueryPayload> | undefined;
|
|
1063
|
-
getQueryKey: (params: QueryPayload) => string;
|
|
1212
|
+
/** Underlying t-state store containing raw cached queries and items. */store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>; /** Invalidation event emitter used by hooks and integrations. */
|
|
1213
|
+
events: Emitter<ListQueryStoreEvents>; /** Mutation lifecycle event emitter for observers and tests. */
|
|
1214
|
+
storeEvents: Emitter<ListQueryStoreStoreEvents<ItemPayload>>; /** Query keys that have been explicitly invalidated and are awaiting refresh. */
|
|
1215
|
+
readonly queryInvalidationWasTriggered: Set<string>; /** Item keys that have been explicitly invalidated and are awaiting refresh. */
|
|
1216
|
+
readonly itemInvalidationWasTriggered: Set<string>; /** Clears in-memory state and cancels store-local runtime state. */
|
|
1217
|
+
reset: () => void; /** Unregisters listeners and releases resources owned by this store. */
|
|
1218
|
+
dispose: () => void; /** Schedules a list-query fetch with the requested priority. */
|
|
1219
|
+
scheduleListQueryFetch: ListQueryScheduleListQueryFetchApi<QueryPayload, TPartialResources>; /** Reads one cached query directly from store state. */
|
|
1220
|
+
getQueryState: (params: QueryPayload) => TSFDListQuery<QueryPayload> | undefined; /** Returns the stable cache key for a query payload. */
|
|
1221
|
+
getQueryKey: (params: QueryPayload) => string; /** Reads many cached queries directly from store state. */
|
|
1064
1222
|
getQueriesState: (params: QueryPayload[] | ListQueryFilterQuery<QueryPayload>) => {
|
|
1065
1223
|
query: TSFDListQuery<QueryPayload>;
|
|
1066
1224
|
key: string;
|
|
1067
|
-
}[];
|
|
1225
|
+
}[]; /** Finds cached queries that currently include the item payload. */
|
|
1068
1226
|
getQueriesRelatedToItem: (itemPayload: ItemPayload) => {
|
|
1069
1227
|
query: TSFDListQuery<QueryPayload>;
|
|
1070
1228
|
key: string;
|
|
1071
|
-
}[];
|
|
1072
|
-
awaitListQueryFetch: ListQueryAwaitListQueryFetchApi<ItemState, QueryPayload, ItemPayload, TPartialResources>;
|
|
1073
|
-
getQueryFromStateOrFetch: ListQueryGetQueryFromStateOrFetchApi<ItemState, QueryPayload, ItemPayload, TPartialResources>;
|
|
1074
|
-
preloadQueryFromStorage: (params: QueryPayload | QueryPayload[]) => Promise<PersistentStoragePreloadResult<QueryPayload>[]>;
|
|
1075
|
-
loadMore: ListQueryLoadMoreApi<QueryPayload, TPartialResources>;
|
|
1076
|
-
getItemKey: (params: ItemPayload) => string;
|
|
1229
|
+
}[]; /** Waits for a list-query fetch to settle and returns query data or a fetch error. */
|
|
1230
|
+
awaitListQueryFetch: ListQueryAwaitListQueryFetchApi<ItemState, QueryPayload, ItemPayload, TPartialResources>; /** Returns a cached query when usable, otherwise fetches it first. */
|
|
1231
|
+
getQueryFromStateOrFetch: ListQueryGetQueryFromStateOrFetchApi<ItemState, QueryPayload, ItemPayload, TPartialResources>; /** Loads query payloads from persistent storage into memory when available. */
|
|
1232
|
+
preloadQueryFromStorage: (params: QueryPayload | QueryPayload[]) => Promise<PersistentStoragePreloadResult<QueryPayload>[]>; /** Fetches and appends the next page for a list query. */
|
|
1233
|
+
loadMore: ListQueryLoadMoreApi<QueryPayload, TPartialResources>; /** Returns the stable cache key for an item payload. */
|
|
1234
|
+
getItemKey: (params: ItemPayload) => string; /** Reads one or many cached items directly from store state. */
|
|
1077
1235
|
getItemState: {
|
|
1078
1236
|
(itemPayload: ItemPayload): ItemState | null | undefined;
|
|
1079
1237
|
(itemPayload: ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>): {
|
|
1080
1238
|
payload: ItemPayload;
|
|
1081
1239
|
data: ItemState;
|
|
1082
1240
|
}[];
|
|
1083
|
-
};
|
|
1084
|
-
usePendingOfflineItems: ListQueryUsePendingOfflineItemsApi<ItemState, ItemPayload>;
|
|
1085
|
-
getOfflineEntities: () => GlobalOfflineEntity[];
|
|
1086
|
-
useOfflineEntities: () => readonly GlobalOfflineEntity[];
|
|
1087
|
-
useOfflineResolutions: () => readonly OfflineResolutionRecord[];
|
|
1088
|
-
getOfflineResolutions: () => OfflineResolutionRecord[];
|
|
1089
|
-
parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedListQueryOfflineOperations<TOfflineOperations>>;
|
|
1090
|
-
resolveOfflineResolution: <TName extends keyof ResolvedListQueryOfflineOperations<TOfflineOperations> & string>(resolutionId: string, operationName: TName, resolution: OfflineResolutionActionForOperation<ResolvedListQueryOfflineOperations<TOfflineOperations>, TName>) => Promise<void> | void;
|
|
1091
|
-
preloadItemFromStorage: (params: ItemPayload | ItemPayload[]) => Promise<PersistentStoragePreloadResult<ItemPayload>[]>;
|
|
1092
|
-
scheduleItemFetch: ListQueryScheduleItemFetchApi<ItemPayload, TPartialResources>;
|
|
1093
|
-
awaitItemFetch: ListQueryAwaitItemFetchApi<ItemState, ItemPayload, TPartialResources>;
|
|
1094
|
-
getItemFromStateOrFetch: ListQueryGetItemFromStateOrFetchApi<ItemState, ItemPayload, TPartialResources>;
|
|
1095
|
-
invalidateQueryAndItems: (args: ListQueryInvalidateQueryAndItemsArgs<ItemState, QueryPayload, ItemPayload>) => void;
|
|
1096
|
-
invalidateItem: (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>, priority
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1241
|
+
}; /** React hook for locally pending offline items in this store. */
|
|
1242
|
+
usePendingOfflineItems: ListQueryUsePendingOfflineItemsApi<ItemState, ItemPayload>; /** Returns offline sync metadata for this store's tracked entities. */
|
|
1243
|
+
getOfflineEntities: () => GlobalOfflineEntity[]; /** React hook subscribing to this store's offline entity metadata. */
|
|
1244
|
+
useOfflineEntities: () => readonly GlobalOfflineEntity[]; /** React hook subscribing to manual offline resolutions for this store. */
|
|
1245
|
+
useOfflineResolutions: () => readonly OfflineResolutionRecord[]; /** Returns manual offline resolutions for this store. */
|
|
1246
|
+
getOfflineResolutions: () => OfflineResolutionRecord[]; /** Parses a stored offline conflict into the operation-specific conflict shape. */
|
|
1247
|
+
parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedListQueryOfflineOperations<TOfflineOperations>>; /** Applies a retry/discard/requeue/commit action to a pending offline resolution. */
|
|
1248
|
+
resolveOfflineResolution: <TName extends keyof ResolvedListQueryOfflineOperations<TOfflineOperations> & string>(resolutionId: string, operationName: TName, resolution: OfflineResolutionActionForOperation<ResolvedListQueryOfflineOperations<TOfflineOperations>, TName>) => Promise<void> | void; /** Loads item payloads from persistent storage into memory when available. */
|
|
1249
|
+
preloadItemFromStorage: (params: ItemPayload | ItemPayload[]) => Promise<PersistentStoragePreloadResult<ItemPayload>[]>; /** Schedules an item fetch with the requested priority. */
|
|
1250
|
+
scheduleItemFetch: ListQueryScheduleItemFetchApi<ItemPayload, TPartialResources>; /** Waits for an item fetch to settle and returns data or a fetch error. */
|
|
1251
|
+
awaitItemFetch: ListQueryAwaitItemFetchApi<ItemState, ItemPayload, TPartialResources>; /** Returns cached item data when usable, otherwise fetches it first. */
|
|
1252
|
+
getItemFromStateOrFetch: ListQueryGetItemFromStateOrFetchApi<ItemState, ItemPayload, TPartialResources>; /** Invalidates selected queries and items together. Defaults to `highPriority`. */
|
|
1253
|
+
invalidateQueryAndItems: (args: ListQueryInvalidateQueryAndItemsArgs<ItemState, QueryPayload, ItemPayload>) => void; /** Marks cached items stale and schedules refetches for active subscriptions. Defaults to `highPriority`. */
|
|
1254
|
+
invalidateItem: (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>, /** Fetch priority used for refetches triggered by this invalidation. Defaults to `highPriority`. */
|
|
1255
|
+
|
|
1256
|
+
priority?: FetchType) => void; /** Marks one or more items as mutating and returns a function that ends the mutation. */
|
|
1257
|
+
startItemMutation: (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>) => () => void; /** Applies an immutable update to one or more cached list-query items. */
|
|
1258
|
+
updateItemState: ListQueryUpdateItemStateApi<ItemState, ItemPayload>; /** Adds or replaces one cached item directly in state. */
|
|
1259
|
+
addItemToState: ListQueryAddItemToStateApi<ItemState, QueryPayload, ItemPayload>; /** Deletes one cached item directly from state and query membership. */
|
|
1100
1260
|
deleteItemState: ListQueryDeleteItemStateApi<ItemState, ItemPayload>;
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1261
|
+
/**
|
|
1262
|
+
* Runs the full mutation lifecycle: optional optimistic update, async
|
|
1263
|
+
* mutation, rollback/error handling, revalidation, and offline queue fallback.
|
|
1264
|
+
*/
|
|
1265
|
+
performMutation: ListQueryPerformMutationApi<ItemState, QueryPayload, ItemPayload, TOfflineOperations>; /** React hook for subscribing to many list queries at once. */
|
|
1266
|
+
useMultipleListQueries: ListQueryUseMultipleListQueriesApi<ItemState, QueryPayload, ItemPayload, TPartialResources>; /** React hook for subscribing to one list query. */
|
|
1267
|
+
useListQuery: ListQueryUseListQueryApi<ItemState, QueryPayload, ItemPayload, TPartialResources>; /** React hook for subscribing to many list-query items at once. */
|
|
1268
|
+
useMultipleItems: ListQueryUseMultipleItemsApi<ItemState, ItemPayload, TPartialResources>; /** React hook for subscribing to one list-query item. */
|
|
1269
|
+
useItem: ListQueryUseItemApi<ItemState, ItemPayload, TPartialResources>; /** React hook for selecting the first cached item matching a predicate. */
|
|
1106
1270
|
useFindItem: <SelectedItem = ItemState | null>(findItemFn: (item: ItemState, itemPayload: ItemPayload) => boolean, options?: {
|
|
1107
1271
|
/** Maps the matched item before it is returned from the hook. */selector?: (data: ItemState, id: ItemPayload) => SelectedItem;
|
|
1108
|
-
}) => SelectedItem | null;
|
|
1272
|
+
}) => SelectedItem | null; /** Notifies the store that a shared transport reconnected and should revalidate active data. */
|
|
1109
1273
|
onTransportReconnect: () => void;
|
|
1110
1274
|
};
|
|
1275
|
+
/** Details passed when list-query cache-limit cleanup evicts cached items or queries. */
|
|
1111
1276
|
type ListQueryStateCleanup<QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
1112
|
-
reason: 'cacheLimitEviction';
|
|
1113
|
-
itemKeys: string[];
|
|
1114
|
-
itemPayloads: ItemPayload[];
|
|
1115
|
-
queryKeys: string[];
|
|
1277
|
+
/** Cleanup trigger that removed these records. */reason: 'cacheLimitEviction'; /** Item store keys removed from state. */
|
|
1278
|
+
itemKeys: string[]; /** Original item payloads removed from state. */
|
|
1279
|
+
itemPayloads: ItemPayload[]; /** Query store keys removed from state. */
|
|
1280
|
+
queryKeys: string[]; /** Original query payloads removed from state. */
|
|
1116
1281
|
queryPayloads: QueryPayload[];
|
|
1117
1282
|
};
|
|
1118
1283
|
type FetchListFnSizeMode<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = (payload: QueryPayload, size: number, options: {
|
|
1119
1284
|
signal: AbortSignal;
|
|
1120
1285
|
fields?: string[];
|
|
1121
|
-
}) => Promise<FetchListFnReturn<ItemState, ItemPayload
|
|
1286
|
+
}) => Promise<MaybeTSDFResult<FetchListFnReturn<ItemState, ItemPayload>>>;
|
|
1122
1287
|
type FetchListFnOffsetMode<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = (payload: QueryPayload, pagination: {
|
|
1123
1288
|
offset: number;
|
|
1124
1289
|
limit: number;
|
|
1125
1290
|
}, options: {
|
|
1126
1291
|
signal: AbortSignal;
|
|
1127
1292
|
fields?: string[];
|
|
1128
|
-
}) => Promise<FetchListFnReturn<ItemState, ItemPayload
|
|
1293
|
+
}) => Promise<MaybeTSDFResult<FetchListFnReturn<ItemState, ItemPayload>>>;
|
|
1129
1294
|
type ListQueryStoreOptionsBase<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean = false, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload> = null, StorageState = unknown> = {
|
|
1130
1295
|
/**
|
|
1131
1296
|
* Stable id for this logical list-query store. Used for debug labels,
|
|
1132
1297
|
* persistence namespaces, and browser tab sync.
|
|
1133
1298
|
*/
|
|
1134
1299
|
id: string; /** Shared global store manager providing session scoping and error normalization. */
|
|
1135
|
-
storeManager: StoreManager;
|
|
1300
|
+
storeManager: StoreManager; /** Fetches one item by payload. Required when items can be loaded outside list pages. */
|
|
1136
1301
|
fetchItemFn?: (payload: ItemPayload, options: {
|
|
1137
1302
|
signal: AbortSignal;
|
|
1138
1303
|
fields?: string[];
|
|
1139
|
-
}) => Promise<ItemState
|
|
1304
|
+
}) => Promise<MaybeTSDFResult<ItemState>>; /** Optional batch fetch function for fetching multiple items at once. */
|
|
1140
1305
|
batchFetchItemFn?: (requests: {
|
|
1141
1306
|
payload: ItemPayload;
|
|
1142
1307
|
fields?: string[];
|
|
1143
1308
|
}[], options: {
|
|
1144
1309
|
signal: AbortSignal;
|
|
1145
1310
|
batchKey: string;
|
|
1146
|
-
}) => Promise<Map<ItemPayload, ItemState | Error
|
|
1147
|
-
getItemsBatchKey?: (payload: ItemPayload) => string | false;
|
|
1148
|
-
defaultQuerySize?: number;
|
|
1311
|
+
}) => Promise<MaybeTSDFResult<Map<ItemPayload, MaybeTSDFResult<ItemState> | Error>>>; /** Optional function to group item batch fetches by key. When omitted, all batched items share one default batch key. Return false to fetch individually. */
|
|
1312
|
+
getItemsBatchKey?: (payload: ItemPayload) => string | false; /** Default number of items requested by list-query fetches. Defaults to 50. */
|
|
1313
|
+
defaultQuerySize?: number; /** Max items per item batch. Defaults to 50. Triggers an immediate fetch when reached. */
|
|
1149
1314
|
maxItemBatchSize?: number; /** Maximum number of cached items kept in memory. Defaults to 5,000. Item pressure may evict whole inactive queries to avoid leaving cached queries partially loaded. */
|
|
1150
1315
|
maxItems?: number; /** Maximum number of cached queries kept in memory. Defaults to 1,000. Inactive queries are evicted in LRU order while mounted hook queries stay protected. */
|
|
1151
1316
|
maxQueries?: number; /** Called when cache-limit eviction removes items or queries from in-memory state. */
|
|
1152
|
-
onStateCleanup?: (cleanup: ListQueryStateCleanup<QueryPayload, ItemPayload>) => void;
|
|
1317
|
+
onStateCleanup?: (cleanup: ListQueryStateCleanup<QueryPayload, ItemPayload>) => void; /** Treats refetches as real-time driven, disabling stale mount refetches by default. Defaults to `false`. */
|
|
1153
1318
|
usesRealTimeUpdates?: boolean; /** Overrides the manager's default minimum interval between low-priority fetches for this store. */
|
|
1154
1319
|
lowPriorityThrottleMs?: number; /** Overrides the manager's default coalescing window for this store. */
|
|
1155
|
-
baseCoalescingWindowMs?: number;
|
|
1156
|
-
mediumPriorityDelayMs?: number;
|
|
1320
|
+
baseCoalescingWindowMs?: number; /** Delay applied to medium-priority requests before they enter the scheduler. */
|
|
1321
|
+
mediumPriorityDelayMs?: number; /** Computes a per-fetch throttle for real-time updates using recent fetch cost and focus state. */
|
|
1157
1322
|
dynamicRealtimeThrottleMs?: (params: {
|
|
1158
1323
|
lastFetchDuration: number;
|
|
1159
1324
|
windowIsNotFocused: boolean;
|
|
1160
|
-
}) => number;
|
|
1325
|
+
}) => number; /** Store-level focus revalidation policy. Overrides the manager default. */
|
|
1161
1326
|
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
1162
|
-
/** Reconnect-specific cooldown. The first reconnect revalidates immediately;
|
|
1327
|
+
/** Reconnect-specific cooldown. Defaults to 2,000ms. The first reconnect revalidates immediately;
|
|
1163
1328
|
* additional reconnects within the cooldown are coalesced into one trailing
|
|
1164
1329
|
* revalidation. Set to `0` to disable this cooldown. */
|
|
1165
|
-
transportReconnectCooldownMs?: number;
|
|
1166
|
-
optimisticListUpdates?: OptimisticListUpdate<ItemState, QueryPayload, ItemPayload>[];
|
|
1167
|
-
onInvalidateQuery?: OnListQueryInvalidate<QueryPayload>;
|
|
1168
|
-
onInvalidateItem?: OnListQueryItemInvalidate<ItemState, ItemPayload>;
|
|
1330
|
+
transportReconnectCooldownMs?: number; /** Rules that keep cached query membership in sync after item updates. */
|
|
1331
|
+
optimisticListUpdates?: OptimisticListUpdate<ItemState, QueryPayload, ItemPayload>[]; /** Called when an already-loaded query is invalidated. */
|
|
1332
|
+
onInvalidateQuery?: OnListQueryInvalidate<QueryPayload>; /** Called when an already-loaded item is invalidated. */
|
|
1333
|
+
onInvalidateItem?: OnListQueryItemInvalidate<ItemState, ItemPayload>; /** Observes request scheduler lifecycle events for this store. */
|
|
1169
1334
|
onSchedulerEvent?: (event: RequestSchedulerEvents, data?: RequestSchedulerEventData) => void;
|
|
1170
1335
|
/**
|
|
1171
1336
|
* Store-specific mutation error handler.
|
|
@@ -1174,8 +1339,8 @@ type ListQueryStoreOptionsBase<ItemState extends ValidStoreState, QueryPayload e
|
|
|
1174
1339
|
* error handling for this store.
|
|
1175
1340
|
*/
|
|
1176
1341
|
onMutationError?: ((error: unknown, options: StoreMutationErrorOptions) => void) | null; /** Opt-in hook-level query derivation from locally materialized items. */
|
|
1177
|
-
derivedQueries?: DerivedQueriesConfig<ItemState, QueryPayload, ItemPayload>;
|
|
1178
|
-
getQueryKey?: (params: QueryPayload) => ValidPayload | unknown[];
|
|
1342
|
+
derivedQueries?: DerivedQueriesConfig<ItemState, QueryPayload, ItemPayload>; /** Converts a query payload to the stable cache key used by this store. */
|
|
1343
|
+
getQueryKey?: (params: QueryPayload) => ValidPayload | unknown[]; /** Converts an item payload to the stable cache key used by this store. */
|
|
1179
1344
|
getItemKey?: (params: ItemPayload) => ValidPayload | unknown[];
|
|
1180
1345
|
/** Opt-in persistent storage configuration. When provided, cached items and queries
|
|
1181
1346
|
* are loaded from storage on first read and saved back on successful fetches.
|
|
@@ -1187,11 +1352,12 @@ type ListQueryStoreOptionsBase<ItemState extends ValidStoreState, QueryPayload e
|
|
|
1187
1352
|
} : {
|
|
1188
1353
|
partialResources?: undefined;
|
|
1189
1354
|
});
|
|
1355
|
+
/** Options used to create a list-query store. */
|
|
1190
1356
|
type ListQueryStoreOptions<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean = false, TOffsetPagination extends boolean = false, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload> = null, StorageState = unknown> = ListQueryStoreOptionsBase<ItemState, QueryPayload, ItemPayload, TPartialResources, TOfflineOperations, StorageState> & ([TOffsetPagination] extends [true] ? {
|
|
1191
|
-
fetchListFn: FetchListFnOffsetMode<ItemState, QueryPayload, ItemPayload>;
|
|
1357
|
+
/** Fetches one offset-paginated list query page. */fetchListFn: FetchListFnOffsetMode<ItemState, QueryPayload, ItemPayload>; /** Enables offset-pagination behavior and invalidation sizing. */
|
|
1192
1358
|
offsetPagination: OffsetPaginationConfig;
|
|
1193
1359
|
} : {
|
|
1194
|
-
fetchListFn: FetchListFnSizeMode<ItemState, QueryPayload, ItemPayload>;
|
|
1360
|
+
/** Fetches one size-based list query page. */fetchListFn: FetchListFnSizeMode<ItemState, QueryPayload, ItemPayload>; /** Not allowed unless offset pagination is enabled. */
|
|
1195
1361
|
offsetPagination?: undefined;
|
|
1196
1362
|
});
|
|
1197
1363
|
declare function createListQueryStore<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean = false, TOffsetPagination extends boolean = false, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload> = null, StorageState = unknown>(storeOptions: ListQueryStoreOptions<ItemState, QueryPayload, ItemPayload, TPartialResources, TOffsetPagination, TOfflineOperations, StorageState>): ListQueryStore<ItemState, QueryPayload, ItemPayload, TPartialResources, TOfflineOperations>;
|
|
@@ -1345,4 +1511,4 @@ declare function clearAllSessionStorage(sessionKey: string): Promise<void>;
|
|
|
1345
1511
|
//#region src/persistentStorage/opfsOfflineUploadAdapter.d.ts
|
|
1346
1512
|
declare const opfsOfflineUploadAdapter: OfflineUploadAdapter;
|
|
1347
1513
|
//#endregion
|
|
1348
|
-
export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, CollectionItemStatus, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadProgress, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, StoreMutationError, type StoreMutationErrorOptions, type TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createCollectionStore, createDocumentStore, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
|
1514
|
+
export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, CollectionItemStatus, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type DynamicRealtimeThrottleMs, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MaybeTSDFResult, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadProgress, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, StoreMutationError, type StoreMutationErrorOptions, type TSDFDebugLogArea, type TSDFDebugLogEntry, type TSDFDebugLogLevel, type TSDFDebugLogger, type TSDFDebugOptions, type TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createCollectionStore, createDocumentStore, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|