tsdf 17.0.0-alpha.2 → 17.0.0-alpha.4
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/main.d.ts +31 -6
- package/dist/main.js +25 -7
- package/docs/README.md +2 -2
- package/docs/collection-store.md +22 -22
- package/docs/document-store.md +15 -16
- package/docs/invalidation.md +6 -4
- package/docs/list-query-store.md +1 -1
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -1629,7 +1629,10 @@ type InternalCollectionOfflineOperations<ItemState extends ValidStoreState, Item
|
|
|
1629
1629
|
}> & ([ItemState | ItemPayload] extends [never] ? never : unknown);
|
|
1630
1630
|
type CollectionOfflineOperationsConfig<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = InternalCollectionOfflineOperations<ItemState, ItemPayload> | null;
|
|
1631
1631
|
type CollectionStoreOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload> = null, StorageState = unknown> = {
|
|
1632
|
-
|
|
1632
|
+
/**
|
|
1633
|
+
* Stable id for this logical collection store. Used for debug labels,
|
|
1634
|
+
* persistence namespaces, and browser tab sync.
|
|
1635
|
+
*/
|
|
1633
1636
|
id: string; /** Shared global store manager providing session scoping and error normalization. */
|
|
1634
1637
|
storeManager: StoreManager;
|
|
1635
1638
|
fetchFn: (params: ItemPayload, signal: AbortSignal) => Promise<ItemState>; /** Optional batch fetch function for fetching multiple items at once */
|
|
@@ -1773,7 +1776,6 @@ type CollectionStore<ItemState extends ValidStoreState, ItemPayload extends Vali
|
|
|
1773
1776
|
onTransportReconnect: () => void;
|
|
1774
1777
|
};
|
|
1775
1778
|
declare function createCollectionStore<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, TOfflineOperations extends CollectionOfflineOperationsConfig<ItemState, ItemPayload> = null, StorageState = unknown>({
|
|
1776
|
-
debugName,
|
|
1777
1779
|
id,
|
|
1778
1780
|
storeManager,
|
|
1779
1781
|
fetchFn,
|
|
@@ -1844,7 +1846,10 @@ type DocumentBrowserTabsMessage<State extends ValidStoreState> = (BrowserTabsMes
|
|
|
1844
1846
|
type InternalDocumentOfflineOperations<State extends ValidStoreState> = Record<string, AnyOfflineOperationDefinition<__LEGIT_ANY__>> & ([State] extends [never] ? never : unknown);
|
|
1845
1847
|
type DocumentOfflineOperationsConfig<State extends ValidStoreState> = InternalDocumentOfflineOperations<State> | null;
|
|
1846
1848
|
type DocumentStoreOptions<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null, StorageState = unknown> = {
|
|
1847
|
-
|
|
1849
|
+
/**
|
|
1850
|
+
* Stable id for this logical document store. Used for debug labels,
|
|
1851
|
+
* persistence namespaces, and browser tab sync.
|
|
1852
|
+
*/
|
|
1848
1853
|
id: string; /** Shared global store manager providing session scoping and error normalization. */
|
|
1849
1854
|
storeManager: StoreManager;
|
|
1850
1855
|
fetchFn: (signal: AbortSignal) => Promise<State>; /** Overrides the manager's default minimum interval between low-priority fetches for this store. */
|
|
@@ -1969,7 +1974,6 @@ type DocumentStore<State extends ValidStoreState, TOfflineOperations extends Doc
|
|
|
1969
1974
|
onTransportReconnect: () => void;
|
|
1970
1975
|
};
|
|
1971
1976
|
declare function createDocumentStore<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null, StorageState = unknown>({
|
|
1972
|
-
debugName,
|
|
1973
1977
|
id,
|
|
1974
1978
|
storeManager,
|
|
1975
1979
|
fetchFn,
|
|
@@ -2534,7 +2538,10 @@ type ListQueryBrowserTabsMessage<ItemState extends ValidStoreState, QueryPayload
|
|
|
2534
2538
|
duration: number;
|
|
2535
2539
|
});
|
|
2536
2540
|
type ListQueryStoreOptionsBase<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean = false, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload> = null, StorageState = unknown> = {
|
|
2537
|
-
|
|
2541
|
+
/**
|
|
2542
|
+
* Stable id for this logical list-query store. Used for debug labels,
|
|
2543
|
+
* persistence namespaces, and browser tab sync.
|
|
2544
|
+
*/
|
|
2538
2545
|
id: string; /** Shared global store manager providing session scoping and error normalization. */
|
|
2539
2546
|
storeManager: StoreManager;
|
|
2540
2547
|
fetchItemFn?: (payload: ItemPayload, options: {
|
|
@@ -2610,6 +2617,24 @@ type ListQueryStoreOptions<ItemState extends ValidStoreState, QueryPayload exten
|
|
|
2610
2617
|
});
|
|
2611
2618
|
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>;
|
|
2612
2619
|
//#endregion
|
|
2620
|
+
//#region src/invalidationUtils.d.ts
|
|
2621
|
+
/**
|
|
2622
|
+
* Predicate that matches every currently known payload.
|
|
2623
|
+
*
|
|
2624
|
+
* Use it with APIs that accept payload filters, such as
|
|
2625
|
+
* `invalidateQueryAndItems`, `invalidateItem`, `getItemState`, and
|
|
2626
|
+
* `getQueriesState`.
|
|
2627
|
+
*/
|
|
2628
|
+
declare const GET_ALL: (...args: unknown[]) => true;
|
|
2629
|
+
/**
|
|
2630
|
+
* Shared List Query invalidation target for invalidating every cached query and
|
|
2631
|
+
* every cached item.
|
|
2632
|
+
*/
|
|
2633
|
+
declare const ALL_QUERY_AND_ITEMS: {
|
|
2634
|
+
readonly queryPayload: typeof GET_ALL;
|
|
2635
|
+
readonly itemPayload: typeof GET_ALL;
|
|
2636
|
+
};
|
|
2637
|
+
//#endregion
|
|
2613
2638
|
//#region src/isOffScreenContext.d.ts
|
|
2614
2639
|
/**
|
|
2615
2640
|
* Context to set `isOffScreen` for all TSDF hooks within a subtree.
|
|
@@ -2761,4 +2786,4 @@ declare function clearAllSessionStorage(sessionKey: string): Promise<void>;
|
|
|
2761
2786
|
//#region src/persistentStorage/opfsOfflineUploadAdapter.d.ts
|
|
2762
2787
|
declare const opfsOfflineUploadAdapter: OfflineUploadAdapter;
|
|
2763
2788
|
//#endregion
|
|
2764
|
-
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, CollectionBrowserTabsMessage, CollectionInitialStateItem, 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, DocumentBrowserTabsMessage, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, type GlobalOfflineEntity, type GlobalOfflineStatus, type IndexedDbPersistentStorageOptions, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreInitialData, 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 TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createAsyncStorageAdapter, createCollectionStore, createDocumentStore, createIndexedDbPersistentStorage, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, indexedDbPersistentStorage, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, opfsPersistentStorage, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
|
2789
|
+
export { ALL_QUERY_AND_ITEMS, 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, CollectionBrowserTabsMessage, CollectionInitialStateItem, 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, DocumentBrowserTabsMessage, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, type IndexedDbPersistentStorageOptions, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreInitialData, 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 TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createAsyncStorageAdapter, createCollectionStore, createDocumentStore, createIndexedDbPersistentStorage, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, indexedDbPersistentStorage, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, opfsPersistentStorage, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
package/dist/main.js
CHANGED
|
@@ -11467,7 +11467,7 @@ function useMultipleItems$1(items, { selector, returnIdleStatus: allItemsReturnI
|
|
|
11467
11467
|
//#endregion
|
|
11468
11468
|
//#region src/collectionStore/collectionStore.ts
|
|
11469
11469
|
const EMPTY_COLLECTION_OFFLINE_OPERATIONS = {};
|
|
11470
|
-
function createCollectionStore({
|
|
11470
|
+
function createCollectionStore({ id, storeManager, fetchFn, batchFetchFn, getItemsBatchKey, maxBatchSize, maxItems = 5e3, onStateCleanup, lowPriorityThrottleMs: storeLowPriorityThrottleMs, baseCoalescingWindowMs: storeBaseCoalescingWindowMs, mediumPriorityDelayMs, dynamicRealtimeThrottleMs, revalidateOnWindowFocus, transportReconnectCooldownMs = 2e3, getCollectionItemKey: filterCollectionItemObjKey, onInvalidate, onSchedulerEvent, onMutationError, usesRealTimeUpdates = false, persistentStorage: persistentStorageConfig, "~test": testOptions }) {
|
|
11471
11471
|
const lowPriorityThrottleMs = storeLowPriorityThrottleMs ?? storeManager.storeDefaults.lowPriorityThrottleMs;
|
|
11472
11472
|
const baseCoalescingWindowMs = storeBaseCoalescingWindowMs ?? storeManager.storeDefaults.baseCoalescingWindowMs;
|
|
11473
11473
|
const blockWindowClose = storeManager.storeDefaults.blockWindowClose;
|
|
@@ -11524,7 +11524,7 @@ function createCollectionStore({ debugName, id, storeManager, fetchFn, batchFetc
|
|
|
11524
11524
|
const persistence = resolvedPersistentStorageConfig ? setupCollectionPersistence(resolvedPersistentStorageConfig, { getItemKey }) : null;
|
|
11525
11525
|
const persistentStorageErrorReporter = resolvedPersistentStorageConfig ? resolvedPersistentStorageConfig.onPersistentStorageError : storeManager.onPersistentStorageError;
|
|
11526
11526
|
const store = new Store({
|
|
11527
|
-
debugName,
|
|
11527
|
+
debugName: id,
|
|
11528
11528
|
state: () => {
|
|
11529
11529
|
const initialState = {};
|
|
11530
11530
|
if (initialData) for (const item of initialData) {
|
|
@@ -12615,7 +12615,7 @@ function assertDocumentOfflineOperations(operations) {
|
|
|
12615
12615
|
}
|
|
12616
12616
|
const DOC_REQUEST_ID = "_doc";
|
|
12617
12617
|
const DOC_TARGET_KEY = "document";
|
|
12618
|
-
function createDocumentStore({
|
|
12618
|
+
function createDocumentStore({ id, storeManager, fetchFn, lowPriorityThrottleMs: storeLowPriorityThrottleMs, baseCoalescingWindowMs: storeBaseCoalescingWindowMs, dynamicRealtimeThrottleMs, revalidateOnWindowFocus, transportReconnectCooldownMs = 2e3, mediumPriorityDelayMs, onSchedulerEvent, onMutationError, usesRealTimeUpdates = false, persistentStorage: persistentStorageConfig, "~test": testOptions }) {
|
|
12619
12619
|
const lowPriorityThrottleMs = storeLowPriorityThrottleMs ?? storeManager.storeDefaults.lowPriorityThrottleMs;
|
|
12620
12620
|
const baseCoalescingWindowMs = storeBaseCoalescingWindowMs ?? storeManager.storeDefaults.baseCoalescingWindowMs;
|
|
12621
12621
|
const blockWindowClose = storeManager.storeDefaults.blockWindowClose;
|
|
@@ -12728,7 +12728,7 @@ function createDocumentStore({ debugName, id, storeManager, fetchFn, lowPriority
|
|
|
12728
12728
|
}
|
|
12729
12729
|
}) : null;
|
|
12730
12730
|
const store = new Store({
|
|
12731
|
-
debugName,
|
|
12731
|
+
debugName: id,
|
|
12732
12732
|
state: () => persistence?.createInitialState({
|
|
12733
12733
|
data: initialData,
|
|
12734
12734
|
error: initialError,
|
|
@@ -17689,7 +17689,7 @@ function usePendingOfflineItems({ selector, filterPayload, includeResolutionRequ
|
|
|
17689
17689
|
const EMPTY_LIST_QUERY_OFFLINE_OPERATIONS = {};
|
|
17690
17690
|
const noPartialResourcesFieldsOptionError = "fields option is required when partialResources is enabled";
|
|
17691
17691
|
function createListQueryStore(storeOptions) {
|
|
17692
|
-
const {
|
|
17692
|
+
const { id, storeManager, fetchItemFn, batchFetchItemFn, getItemsBatchKey, defaultQuerySize = 50, maxItemBatchSize, maxItems = 5e3, maxQueries = 1e3, onStateCleanup, usesRealTimeUpdates = false, "~test": testOptions, lowPriorityThrottleMs: storeLowPriorityThrottleMs, baseCoalescingWindowMs: storeBaseCoalescingWindowMs, mediumPriorityDelayMs, dynamicRealtimeThrottleMs, revalidateOnWindowFocus, transportReconnectCooldownMs = 2e3, optimisticListUpdates, onInvalidateQuery, onInvalidateItem, onSchedulerEvent, onMutationError, derivedQueries, getQueryKey: customGetQueryKey, getItemKey: customGetItemKey, partialResources, persistentStorage: persistentStorageConfig } = storeOptions;
|
|
17693
17693
|
const lowPriorityThrottleMs = storeLowPriorityThrottleMs ?? storeManager.storeDefaults.lowPriorityThrottleMs;
|
|
17694
17694
|
const baseCoalescingWindowMs = storeBaseCoalescingWindowMs ?? storeManager.storeDefaults.baseCoalescingWindowMs;
|
|
17695
17695
|
const blockWindowClose = storeManager.storeDefaults.blockWindowClose;
|
|
@@ -17755,7 +17755,7 @@ function createListQueryStore(storeOptions) {
|
|
|
17755
17755
|
const resolvedOfflineOperations = __LEGIT_CAST__(resolvedOfflineConfig?.operations ?? EMPTY_LIST_QUERY_OFFLINE_OPERATIONS);
|
|
17756
17756
|
const offlineOperationsForRuntime = import.meta.env.TEST && testOptions?.onOfflineTimelineEvent && resolvedOfflineConfig ? wrapOfflineOperationsForTimeline(resolvedOfflineOperations, testOptions.onOfflineTimelineEvent) : resolvedOfflineOperations;
|
|
17757
17757
|
const store = new Store({
|
|
17758
|
-
debugName,
|
|
17758
|
+
debugName: id,
|
|
17759
17759
|
state: () => {
|
|
17760
17760
|
const initialState = {
|
|
17761
17761
|
items: {},
|
|
@@ -18740,6 +18740,24 @@ function createListQueryStore(storeOptions) {
|
|
|
18740
18740
|
};
|
|
18741
18741
|
}
|
|
18742
18742
|
//#endregion
|
|
18743
|
+
//#region src/invalidationUtils.ts
|
|
18744
|
+
/**
|
|
18745
|
+
* Predicate that matches every currently known payload.
|
|
18746
|
+
*
|
|
18747
|
+
* Use it with APIs that accept payload filters, such as
|
|
18748
|
+
* `invalidateQueryAndItems`, `invalidateItem`, `getItemState`, and
|
|
18749
|
+
* `getQueriesState`.
|
|
18750
|
+
*/
|
|
18751
|
+
const GET_ALL = () => true;
|
|
18752
|
+
/**
|
|
18753
|
+
* Shared List Query invalidation target for invalidating every cached query and
|
|
18754
|
+
* every cached item.
|
|
18755
|
+
*/
|
|
18756
|
+
const ALL_QUERY_AND_ITEMS = {
|
|
18757
|
+
queryPayload: GET_ALL,
|
|
18758
|
+
itemPayload: GET_ALL
|
|
18759
|
+
};
|
|
18760
|
+
//#endregion
|
|
18743
18761
|
//#region src/persistentStorage/opfsOfflineUploadAdapter.ts
|
|
18744
18762
|
const OPFS_UPLOADS_ROOT_DIR = "tsdf-uploads";
|
|
18745
18763
|
const METADATA_FILE_NAME = "metadata.json";
|
|
@@ -18912,4 +18930,4 @@ var OpfsOfflineUploadDriver = class {
|
|
|
18912
18930
|
};
|
|
18913
18931
|
const opfsOfflineUploadAdapter = new OpfsOfflineUploadDriver();
|
|
18914
18932
|
//#endregion
|
|
18915
|
-
export { IsOffScreenContext, StoreFetchError, StoreMutationError, clearAllSessionStorage, clearSessionStorage, createAsyncStorageAdapter, createCollectionStore, createDocumentStore, createIndexedDbPersistentStorage, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, indexedDbPersistentStorage, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, opfsPersistentStorage, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
|
18933
|
+
export { ALL_QUERY_AND_ITEMS, GET_ALL, IsOffScreenContext, StoreFetchError, StoreMutationError, clearAllSessionStorage, clearSessionStorage, createAsyncStorageAdapter, createCollectionStore, createDocumentStore, createIndexedDbPersistentStorage, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, indexedDbPersistentStorage, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, opfsPersistentStorage, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
package/docs/README.md
CHANGED
|
@@ -36,6 +36,7 @@ Notable additions:
|
|
|
36
36
|
|
|
37
37
|
- Hook payload debouncing is documented in [React Hooks](./hooks.md#debouncepayload)
|
|
38
38
|
- The exported `PayloadDebounce` type is documented in [Shared Types](./shared-types.md#payloaddebounce)
|
|
39
|
+
- `GET_ALL` and `ALL_QUERY_AND_ITEMS` are documented in [Invalidation](./invalidation.md#list-query-store)
|
|
39
40
|
|
|
40
41
|
## Quick Start
|
|
41
42
|
|
|
@@ -83,7 +84,6 @@ All three store types share these creation options:
|
|
|
83
84
|
|
|
84
85
|
| Option | Type | Required | Description |
|
|
85
86
|
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
-
| `debugName` | `string` | No | Debug name for the store |
|
|
87
87
|
| `storeManager` | `StoreManager` | Yes | Shared global config with session scoping, store defaults, and global store controls |
|
|
88
88
|
| `lowPriorityThrottleMs` | `number` | No | Overrides the manager default minimum interval between low-priority fetches |
|
|
89
89
|
| `baseCoalescingWindowMs` | `number` | No | Overrides the manager default window to group multiple fetch requests into a batch |
|
|
@@ -95,4 +95,4 @@ All three store types share these creation options:
|
|
|
95
95
|
| `usesRealTimeUpdates` | `boolean` | No | Enables [real-time update mode](./real-time-updates.md) |
|
|
96
96
|
| `onSchedulerEvent` | `(event) => void` | No | Callback for [scheduler events](./fetch-scheduling.md) |
|
|
97
97
|
| `onMutationError` | `(error, options) => void \| null` | No | Store-specific handler for [mutation](./mutations.md) errors. Overrides the manager fallback; use `null` to disable it |
|
|
98
|
-
| `id` | `string` | Yes | Stable logical store id for [Browser Tabs Sync](./browser-tabs-sync.md)
|
|
98
|
+
| `id` | `string` | Yes | Stable logical store id used for debug labels, persistence namespaces, and [Browser Tabs Sync](./browser-tabs-sync.md) |
|
package/docs/collection-store.md
CHANGED
|
@@ -28,28 +28,28 @@ const productStore = createCollectionStore<Product, string>({
|
|
|
28
28
|
|
|
29
29
|
## Options
|
|
30
30
|
|
|
31
|
-
| Option | Type | Required | Description
|
|
32
|
-
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | -------- |
|
|
33
|
-
| `id` | `string` | Yes | Stable logical store id for [Browser Tabs Sync](./browser-tabs-sync.md)
|
|
34
|
-
| `storeManager` | `StoreManager` | Yes | Shared global config with `getSessionKey`, `errorNormalizer`, and global store controls
|
|
35
|
-
| `fetchFn` | `(params: ItemPayload, signal: AbortSignal) => Promise<ItemState>` | Yes | Fetches a single item
|
|
36
|
-
| `batchFetchFn` | `(payloads: ItemPayload[], signal: AbortSignal, batchKey: string) => Promise<Map<ItemPayload, ItemState \| Error>>` | No | See [Batch Fetching](./batch-fetching.md)
|
|
37
|
-
| `getItemsBatchKey` | `(payload: ItemPayload) => string \| false` | No | Groups batch fetches by key. `false` falls back to per-item fetch
|
|
38
|
-
| `maxBatchSize` | `number` | No | Triggers immediate fetch when batch reaches this size
|
|
39
|
-
| `maxItems` | `number` | No | Maximum cached items kept in memory. Defaults to `5000`. See [Cache Limits](./cache-limits.md)
|
|
40
|
-
| `onStateCleanup` | `(cleanup) => void` | No | Called when memory cache eviction removes items. See [Cache Limits](./cache-limits.md)
|
|
41
|
-
| `getCollectionItemKey` | `(params: ItemPayload) => ValidPayload \| unknown[]` | No | Custom key derivation from payload
|
|
42
|
-
| `lowPriorityThrottleMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md)
|
|
43
|
-
| `baseCoalescingWindowMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md)
|
|
44
|
-
| `mediumPriorityDelayMs` | `number` | No | Delay for medium-priority fetches
|
|
45
|
-
| `dynamicRealtimeThrottleMs` | `(params) => number` | No | See [Real-Time Updates](./real-time-updates.md)
|
|
46
|
-
| `revalidateOnWindowFocus` | `boolean \| (() => boolean)` | No | Refetch on window focus
|
|
47
|
-
| `transportReconnectCooldownMs` | `number` | No | Cooldown for repeated transport reconnect revalidation
|
|
48
|
-
| `usesRealTimeUpdates` | `boolean` | No | See [Real-Time Updates](./real-time-updates.md)
|
|
49
|
-
| `persistentStorage` | `CollectionPersistentStorageConfig<ItemState, ItemPayload>` | No | Configure cache persistence. See [Persistent Storage](./persistent-storage.md)
|
|
50
|
-
| `onInvalidate` | `(props: { itemState, payload, priority }) => void` | No | Called when an item is invalidated
|
|
51
|
-
| `onSchedulerEvent` | `(event, data?) => void` | No | Scheduler event listener
|
|
52
|
-
| `onMutationError` | `(error, options: { silentErrors? }) => void` | No | Global mutation error handler
|
|
31
|
+
| Option | Type | Required | Description |
|
|
32
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `id` | `string` | Yes | Stable logical store id used for debug labels, persistence namespaces, and [Browser Tabs Sync](./browser-tabs-sync.md) |
|
|
34
|
+
| `storeManager` | `StoreManager` | Yes | Shared global config with `getSessionKey`, `errorNormalizer`, and global store controls |
|
|
35
|
+
| `fetchFn` | `(params: ItemPayload, signal: AbortSignal) => Promise<ItemState>` | Yes | Fetches a single item |
|
|
36
|
+
| `batchFetchFn` | `(payloads: ItemPayload[], signal: AbortSignal, batchKey: string) => Promise<Map<ItemPayload, ItemState \| Error>>` | No | See [Batch Fetching](./batch-fetching.md) |
|
|
37
|
+
| `getItemsBatchKey` | `(payload: ItemPayload) => string \| false` | No | Groups batch fetches by key. `false` falls back to per-item fetch |
|
|
38
|
+
| `maxBatchSize` | `number` | No | Triggers immediate fetch when batch reaches this size |
|
|
39
|
+
| `maxItems` | `number` | No | Maximum cached items kept in memory. Defaults to `5000`. See [Cache Limits](./cache-limits.md) |
|
|
40
|
+
| `onStateCleanup` | `(cleanup) => void` | No | Called when memory cache eviction removes items. See [Cache Limits](./cache-limits.md) |
|
|
41
|
+
| `getCollectionItemKey` | `(params: ItemPayload) => ValidPayload \| unknown[]` | No | Custom key derivation from payload |
|
|
42
|
+
| `lowPriorityThrottleMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md) |
|
|
43
|
+
| `baseCoalescingWindowMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md) |
|
|
44
|
+
| `mediumPriorityDelayMs` | `number` | No | Delay for medium-priority fetches |
|
|
45
|
+
| `dynamicRealtimeThrottleMs` | `(params) => number` | No | See [Real-Time Updates](./real-time-updates.md) |
|
|
46
|
+
| `revalidateOnWindowFocus` | `boolean \| (() => boolean)` | No | Refetch on window focus |
|
|
47
|
+
| `transportReconnectCooldownMs` | `number` | No | Cooldown for repeated transport reconnect revalidation |
|
|
48
|
+
| `usesRealTimeUpdates` | `boolean` | No | See [Real-Time Updates](./real-time-updates.md) |
|
|
49
|
+
| `persistentStorage` | `CollectionPersistentStorageConfig<ItemState, ItemPayload>` | No | Configure cache persistence. See [Persistent Storage](./persistent-storage.md) |
|
|
50
|
+
| `onInvalidate` | `(props: { itemState, payload, priority }) => void` | No | Called when an item is invalidated |
|
|
51
|
+
| `onSchedulerEvent` | `(event, data?) => void` | No | Scheduler event listener |
|
|
52
|
+
| `onMutationError` | `(error, options: { silentErrors? }) => void` | No | Global mutation error handler |
|
|
53
53
|
|
|
54
54
|
## Item State Shape
|
|
55
55
|
|
package/docs/document-store.md
CHANGED
|
@@ -28,22 +28,21 @@ const userStore = createDocumentStore<User>({
|
|
|
28
28
|
|
|
29
29
|
## Options
|
|
30
30
|
|
|
31
|
-
| Option | Type | Required | Description
|
|
32
|
-
| ------------------------------ | -------------------------------------------------------------------------------- | -------- |
|
|
33
|
-
| `id` | `string` | Yes | Stable logical store id for [Browser Tabs Sync](./browser-tabs-sync.md)
|
|
34
|
-
| `storeManager` | `StoreManager` | Yes | Shared global config with `getSessionKey`, `errorNormalizer`, and global store controls
|
|
35
|
-
| `fetchFn` | `(signal: AbortSignal) => Promise<State>` | Yes | Fetches the document data
|
|
36
|
-
| `lowPriorityThrottleMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md)
|
|
37
|
-
| `baseCoalescingWindowMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md)
|
|
38
|
-
| `
|
|
39
|
-
| `
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `onMutationError` | `(error, options: { dontShowToast?: boolean }) => void` | No | Global mutation error handler |
|
|
31
|
+
| Option | Type | Required | Description |
|
|
32
|
+
| ------------------------------ | -------------------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `id` | `string` | Yes | Stable logical store id used for debug labels, persistence namespaces, and [Browser Tabs Sync](./browser-tabs-sync.md) |
|
|
34
|
+
| `storeManager` | `StoreManager` | Yes | Shared global config with `getSessionKey`, `errorNormalizer`, and global store controls |
|
|
35
|
+
| `fetchFn` | `(signal: AbortSignal) => Promise<State>` | Yes | Fetches the document data |
|
|
36
|
+
| `lowPriorityThrottleMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md) |
|
|
37
|
+
| `baseCoalescingWindowMs` | `number` | No | Overrides the manager default. See [Fetch Scheduling](./fetch-scheduling.md) |
|
|
38
|
+
| `dynamicRealtimeThrottleMs` | `(params: { lastFetchDuration: number; windowIsNotFocused: boolean }) => number` | No | See [Real-Time Updates](./real-time-updates.md) |
|
|
39
|
+
| `revalidateOnWindowFocus` | `boolean \| (() => boolean)` | No | Refetch on window focus |
|
|
40
|
+
| `transportReconnectCooldownMs` | `number` | No | Cooldown for repeated transport reconnect revalidation |
|
|
41
|
+
| `mediumPriorityDelayMs` | `number` | No | Delay for medium-priority fetches |
|
|
42
|
+
| `usesRealTimeUpdates` | `boolean` | No | Enables [Real-Time Updates](./real-time-updates.md) mode |
|
|
43
|
+
| `persistentStorage` | `DocumentPersistentStorageConfig<State>` | No | Configure cache persistence. See [Persistent Storage](./persistent-storage.md) |
|
|
44
|
+
| `onSchedulerEvent` | `(event) => void` | No | Scheduler event listener |
|
|
45
|
+
| `onMutationError` | `(error, options: { dontShowToast?: boolean }) => void` | No | Global mutation error handler |
|
|
47
46
|
|
|
48
47
|
## State Shape
|
|
49
48
|
|
package/docs/invalidation.md
CHANGED
|
@@ -45,11 +45,10 @@ store.invalidateItem('item-1', 'lowPriority');
|
|
|
45
45
|
The List Query Store has the most flexible invalidation through `invalidateQueryAndItems`:
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
|
+
import { ALL_QUERY_AND_ITEMS, GET_ALL } from 'tsdf';
|
|
49
|
+
|
|
48
50
|
// Invalidate all queries and all items
|
|
49
|
-
store.invalidateQueryAndItems(
|
|
50
|
-
queryPayload: () => true,
|
|
51
|
-
itemPayload: () => true,
|
|
52
|
-
});
|
|
51
|
+
store.invalidateQueryAndItems(ALL_QUERY_AND_ITEMS);
|
|
53
52
|
|
|
54
53
|
// Invalidate specific queries only (skip items)
|
|
55
54
|
store.invalidateQueryAndItems({
|
|
@@ -69,6 +68,9 @@ store.invalidateQueryAndItems({
|
|
|
69
68
|
itemPayload: (item, payload) => item.priority > 5,
|
|
70
69
|
type: 'lowPriority',
|
|
71
70
|
});
|
|
71
|
+
|
|
72
|
+
// Reuse the all-payload predicate with one side disabled
|
|
73
|
+
store.invalidateQueryAndItems({ queryPayload: GET_ALL, itemPayload: false });
|
|
72
74
|
```
|
|
73
75
|
|
|
74
76
|
### Item-only invalidation
|
package/docs/list-query-store.md
CHANGED
|
@@ -47,7 +47,7 @@ The type parameters are:
|
|
|
47
47
|
|
|
48
48
|
| Option | Type | Description |
|
|
49
49
|
| -------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
50
|
-
| `id` | `string` | Stable logical store id
|
|
50
|
+
| `id` | `string` | Stable logical store id used for debug labels, persistence namespaces, and tab sync |
|
|
51
51
|
| `storeManager` | `StoreManager` | Shared global config with `getSessionKey`, `errorNormalizer`, and global store controls |
|
|
52
52
|
| `fetchListFn` | Size mode: `(payload, size, options) => Promise<FetchListFnReturn>` | Fetches a paginated list. See [Pagination modes](#pagination-modes) |
|
|
53
53
|
|