tsdf 17.0.3 → 17.0.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/async-storage.d.ts +1 -1
- package/dist/async-storage.js +1 -1
- package/dist/{asyncStorageAdapter-URS9eulL.js → asyncStorageAdapter-BuGjbXYA.js} +25 -165
- package/dist/{asyncStorageAdapter-DgsuE-T8.d.ts → asyncStorageAdapter-CMohMeKm.d.ts} +1 -1
- package/dist/{asyncStorageAdapters-Bxrrj_Mt.js → asyncStorageAdapters-ClUvxNQA.js} +2 -2
- package/dist/indexed-db-storage.d.ts +1 -1
- package/dist/indexed-db-storage.js +1 -1
- package/dist/{indexedDbPersistentStorage-BameJ4st.js → indexedDbPersistentStorage-BSlgLveB.js} +1 -11
- package/dist/main.d.ts +30 -34
- package/dist/main.js +257 -856
- package/dist/opfs-storage.d.ts +1 -1
- package/dist/opfs-storage.js +1 -1
- package/dist/{opfsPersistentStorage-BngS1m0X.d.ts → opfsPersistentStorage-Ci0JcCo5.d.ts} +1 -1
- package/dist/{opfsPersistentStorage-JsSCNBTr.js → opfsPersistentStorage-D_k77Srq.js} +1 -1
- package/dist/src/async-storage.d.ts +1 -0
- package/dist/src/cacheLimits/lruCacheRuntime.d.ts +9 -0
- package/dist/src/cacheLimits/scheduleIdleThrottled.d.ts +1 -0
- package/dist/src/cacheLimits/useRegisterActiveKeys.d.ts +1 -0
- package/dist/src/collectionStore/collectionCacheLimits.d.ts +1 -0
- package/dist/src/collectionStore/collectionStore.d.ts +385 -0
- package/dist/src/collectionStore/executeBatchFetch.d.ts +6 -0
- package/dist/src/collectionStore/useItem.d.ts +15 -0
- package/dist/src/collectionStore/useMultipleItems.d.ts +35 -0
- package/dist/src/debug.d.ts +30 -0
- package/dist/src/documentStore.d.ts +290 -0
- package/dist/src/hooks/useListItem.d.ts +22 -0
- package/dist/src/hooks/useListItemIsDeleted.d.ts +13 -0
- package/dist/src/hooks/useListItemIsLoading.d.ts +16 -0
- package/dist/src/indexed-db-storage.d.ts +1 -0
- package/dist/src/internal/offlineTestInstrumentation.d.ts +12 -0
- package/dist/src/internal/testTimelineTypes.d.ts +1 -0
- package/dist/src/invalidationUtils.d.ts +8 -0
- package/dist/src/isOffScreenContext.d.ts +16 -0
- package/dist/src/listQueryStore/createFetchApi.d.ts +1 -0
- package/dist/src/listQueryStore/createMutationApi.d.ts +1 -0
- package/dist/src/listQueryStore/executeItemBatchFetch.d.ts +20 -0
- package/dist/src/listQueryStore/executeQueryFetch.d.ts +7 -0
- package/dist/src/listQueryStore/itemFieldUtils.d.ts +77 -0
- package/dist/src/listQueryStore/listQueryCacheLimits.d.ts +1 -0
- package/dist/src/listQueryStore/listQueryStore.d.ts +538 -0
- package/dist/src/listQueryStore/types.d.ts +347 -0
- package/dist/src/listQueryStore/useFindItem.d.ts +7 -0
- package/dist/src/listQueryStore/useItem.d.ts +29 -0
- package/dist/src/listQueryStore/useListQuery.d.ts +29 -0
- package/dist/src/listQueryStore/useMultipleItems.d.ts +44 -0
- package/dist/src/listQueryStore/useMultipleListQueries.d.ts +46 -0
- package/dist/src/listQueryStore/usePendingOfflineItems.d.ts +19 -0
- package/dist/src/main.d.ts +23 -0
- package/dist/src/opfs-storage.d.ts +1 -0
- package/dist/src/persistentStorage/asyncStorageAdapter.d.ts +95 -0
- package/dist/src/persistentStorage/asyncStorageAdapters.d.ts +2 -0
- package/dist/src/persistentStorage/asyncStorageShared.d.ts +23 -0
- package/dist/src/persistentStorage/collectionStorePersistence.d.ts +26 -0
- package/dist/src/persistentStorage/compactListQueryLocalStorageEntry.d.ts +11 -0
- package/dist/src/persistentStorage/compactLocalStorageEntry.d.ts +8 -0
- package/dist/src/persistentStorage/documentEntryKey.d.ts +1 -0
- package/dist/src/persistentStorage/documentStorePersistence.d.ts +17 -0
- package/dist/src/persistentStorage/indexedDbAsyncStorageAdapter.d.ts +165 -0
- package/dist/src/persistentStorage/indexedDbPersistentStorage.d.ts +6 -0
- package/dist/src/persistentStorage/listQueryStorePersistence.d.ts +37 -0
- package/dist/src/persistentStorage/localStorageMetadata.d.ts +126 -0
- package/dist/src/persistentStorage/navigatorLocks.d.ts +3 -0
- package/dist/src/persistentStorage/offline/entityMetadata.d.ts +12 -0
- package/dist/src/persistentStorage/offline/fetchRuntime.d.ts +35 -0
- package/dist/src/persistentStorage/offline/mutationRuntime.d.ts +31 -0
- package/dist/src/persistentStorage/offline/offlineResolution.typeGuards.d.ts +1 -0
- package/dist/src/persistentStorage/offline/overlayStoreLifecycle.d.ts +13 -0
- package/dist/src/persistentStorage/offline/sessionCoordinator.d.ts +94 -0
- package/dist/src/persistentStorage/offline/sessionProtectionRegistry.d.ts +11 -0
- package/dist/src/persistentStorage/offline/storeController.d.ts +86 -0
- package/dist/src/persistentStorage/offline/types.d.ts +1255 -0
- package/dist/src/persistentStorage/offlineUploadRegistry.d.ts +11 -0
- package/dist/src/persistentStorage/offlineUploadTypes.d.ts +97 -0
- package/dist/src/persistentStorage/offlineUploadsShared.d.ts +4 -0
- package/dist/src/persistentStorage/opfsAsyncStorageAdapter.d.ts +24 -0
- package/dist/src/persistentStorage/opfsFileNaming.d.ts +23 -0
- package/dist/src/persistentStorage/opfsHelpers.d.ts +3 -0
- package/dist/src/persistentStorage/opfsOfflineUploadAdapter.d.ts +2 -0
- package/dist/src/persistentStorage/opfsPersistentStorage.d.ts +2 -0
- package/dist/src/persistentStorage/parsePersistedData.d.ts +45 -0
- package/dist/src/persistentStorage/persistenceUtils.d.ts +52 -0
- package/dist/src/persistentStorage/persistentStorageDefaults.d.ts +4 -0
- package/dist/src/persistentStorage/persistentStorageManager.d.ts +197 -0
- package/dist/src/persistentStorage/quotaDebug.d.ts +16 -0
- package/dist/src/persistentStorage/scheduleIdleCleanup.d.ts +28 -0
- package/dist/src/persistentStorage/storageAdapter.d.ts +41 -0
- package/dist/src/persistentStorage/storageEntryPrefixes.d.ts +16 -0
- package/dist/src/persistentStorage/types.d.ts +412 -0
- package/dist/src/persistentStorage/validateWithSchema.d.ts +12 -0
- package/dist/src/requestScheduler.d.ts +81 -0
- package/dist/src/storeManager.d.ts +160 -0
- package/dist/src/utils/automaticFetchPolicy.d.ts +29 -0
- package/dist/src/utils/browserTabsPriority.d.ts +43 -0
- package/dist/src/utils/browserTabsSync.d.ts +33 -0
- package/dist/src/utils/optimisticMutationTracker.d.ts +20 -0
- package/dist/src/utils/optimisticRollback.d.ts +11 -0
- package/dist/src/utils/payloadDebounce.d.ts +5 -0
- package/dist/src/utils/performMutation.d.ts +19 -0
- package/dist/src/utils/reusePrevIfEqual.d.ts +1 -0
- package/dist/src/utils/storeFocusLifecycle.d.ts +1 -0
- package/dist/src/utils/storeShared.d.ts +126 -0
- package/dist/src/utils/useEnsureIsLoaded.d.ts +6 -0
- package/dist/src/utils/useRequireFreshData.d.ts +6 -0
- package/dist/tests/basic-functionality/collection-store.test.d.ts +1 -0
- package/dist/tests/basic-functionality/document-store.test.d.ts +1 -0
- package/dist/tests/basic-functionality/list-query-state-manipulation.test.d.ts +1 -0
- package/dist/tests/basic-functionality/list-query-store.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-background-rtu-batch.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-background-rtu.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-background-scheduling.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-list-query-pagination.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-non-cancelable-fetches.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-optimistic-sync.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-partial-resources.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-priority.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-snapshot-consistency.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-state-methods.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-sync-coordinator.test.d.ts +1 -0
- package/dist/tests/browser-tabs/browser-tabs-test-helpers.d.ts +69 -0
- package/dist/tests/browser-tabs/focus-coordinator.test.d.ts +1 -0
- package/dist/tests/hooks/collection-hooks-2.test.d.ts +1 -0
- package/dist/tests/hooks/collection-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/collection-useListItem.test.d.ts +1 -0
- package/dist/tests/hooks/debounce-payload-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/disable-refetches.test.d.ts +1 -0
- package/dist/tests/hooks/document-hooks-2.test.d.ts +1 -0
- package/dist/tests/hooks/document-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/document-useListItem.test.d.ts +1 -0
- package/dist/tests/hooks/fetch-error-recovery.test.d.ts +1 -0
- package/dist/tests/hooks/hook-memoization.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks-2.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks-3.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks-mutations.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-hooks.test.d.ts +1 -0
- package/dist/tests/hooks/list-query-pending-offline-items.test.d.ts +1 -0
- package/dist/tests/hooks/off-screen-context.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-derived-queries.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-offset-pagination.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-optimistic-filters.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-2.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-3.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-regressions.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources-show-partial-status.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-partial-resources.test.d.ts +1 -0
- package/dist/tests/list-query-features/list-query-size-coalescing-partial-resources.test.d.ts +1 -0
- package/dist/tests/mocks/browserTabsTestUtils.d.ts +17 -0
- package/dist/tests/mocks/collectionStoreTestEnv.d.ts +265 -0
- package/dist/tests/mocks/documentStoreTestEnv.d.ts +140 -0
- package/dist/tests/mocks/duplicateStoreGuard.test.d.ts +1 -0
- package/dist/tests/mocks/listQueryStoreTestEnv.d.ts +295 -0
- package/dist/tests/mocks/mockBrowserOpfs.d.ts +70 -0
- package/dist/tests/mocks/mockBrowserOpfs.test.d.ts +1 -0
- package/dist/tests/mocks/mockLocalStorageStore.d.ts +61 -0
- package/dist/tests/mocks/seedScenarioPersistentStorage.d.ts +51 -0
- package/dist/tests/mocks/serverMock.d.ts +56 -0
- package/dist/tests/mocks/serverTableMock.d.ts +174 -0
- package/dist/tests/mocks/testEnvUtils.d.ts +120 -0
- package/dist/tests/mocks/testScenarioPersistentStorage.test.d.ts +1 -0
- package/dist/tests/offline/offline-fetching-scenarios.test.d.ts +1 -0
- package/dist/tests/offline/offline-mixed-adapter-storage.test.d.ts +1 -0
- package/dist/tests/offline/offline-mutation-fallback.test.d.ts +1 -0
- package/dist/tests/offline/offline-network-recovery.test.d.ts +1 -0
- package/dist/tests/offline/offline-outage.test.d.ts +1 -0
- package/dist/tests/offline/offline-overlays.test.d.ts +1 -0
- package/dist/tests/offline/offline-query-replay.test.d.ts +1 -0
- package/dist/tests/offline/offline-reads.test.d.ts +1 -0
- package/dist/tests/offline/offline-replay-conflicts.test.d.ts +1 -0
- package/dist/tests/offline/offline-replay-queueing.test.d.ts +1 -0
- package/dist/tests/offline/offline-resolution-dependencies.test.d.ts +1 -0
- package/dist/tests/offline/offline-runtime-controls.test.d.ts +1 -0
- package/dist/tests/offline/offline-session-and-global-state.test.d.ts +1 -0
- package/dist/tests/offline/offline-storage.test.d.ts +1 -0
- package/dist/tests/offline/offline-uploads.test.d.ts +1 -0
- package/dist/tests/offline/offlineReplayTestShared.d.ts +292 -0
- package/dist/tests/offline/offlineTestShared.d.ts +156 -0
- package/dist/tests/perform-mutation/mutation-error-rollback.test.d.ts +1 -0
- package/dist/tests/perform-mutation/perform-mutation-block-window-close.test.d.ts +1 -0
- package/dist/tests/perform-mutation/perform-mutation-debounce.test.d.ts +1 -0
- package/dist/tests/perform-mutation/store-events.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/collection.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/document.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/list-query.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/maintenance.test.d.ts +1 -0
- package/dist/tests/persistent-storage/async-storage-efficiency/shared.d.ts +804 -0
- package/dist/tests/persistent-storage/async-storage-shared.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.converted.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.converted.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/collection-store-persistence.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.converted.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.converted.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/document-store-persistence.test.d.ts +1 -0
- package/dist/tests/persistent-storage/expiration-scan.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/collection.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/document.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/list-query.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/maintenance.test.d.ts +1 -0
- package/dist/tests/persistent-storage/indexeddb-async-storage-efficiency/shared.d.ts +780 -0
- package/dist/tests/persistent-storage/indexeddb-storage-adapter.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.converted.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.converted.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.opfs.test.d.ts +1 -0
- package/dist/tests/persistent-storage/list-query-store-persistence.test.d.ts +1 -0
- package/dist/tests/persistent-storage/persistence-with-tabs-sync.test.d.ts +1 -0
- package/dist/tests/persistent-storage/persistentStorageByteBudgetTestUtils.d.ts +18 -0
- package/dist/tests/persistent-storage/quota-exceeded-recovery-no-locks.test.d.ts +1 -0
- package/dist/tests/persistent-storage/quota-exceeded-recovery.test.d.ts +1 -0
- package/dist/tests/persistent-storage/quotaRecoveryTestUtils.d.ts +228 -0
- package/dist/tests/persistent-storage/storage-adapter.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/collection.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/document.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/list-query.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/maintenance.test.d.ts +1 -0
- package/dist/tests/persistent-storage/sync-storage-efficiency/shared.d.ts +784 -0
- package/dist/tests/playwright/browser-tabs.spec.d.ts +1 -0
- package/dist/tests/playwright/persistent-storage.spec.d.ts +1 -0
- package/dist/tests/request-schedulling/batch-medium-priority.test.d.ts +1 -0
- package/dist/tests/request-schedulling/batch-realtime-updates.test.d.ts +1 -0
- package/dist/tests/request-schedulling/collection-batch-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/collection-batch-key-grouping.test.d.ts +1 -0
- package/dist/tests/request-schedulling/collection-fetch-orchestration.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-await-fetch.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-base-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-fetch-orchestration.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-medium-priority-fetch.test.d.ts +1 -0
- package/dist/tests/request-schedulling/document-realtime-updates.test.d.ts +1 -0
- package/dist/tests/request-schedulling/list-query-item-batch-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/list-query-item-batch-key-grouping.test.d.ts +1 -0
- package/dist/tests/request-schedulling/list-query-size-coalescing.test.d.ts +1 -0
- package/dist/tests/request-schedulling/medium-vs-realtime.test.d.ts +1 -0
- package/dist/tests/request-schedulling/request-scheduler-cross-tab-sync.test.d.ts +1 -0
- package/dist/tests/request-schedulling/window-focus.test.d.ts +1 -0
- package/dist/tests/store-manager.test.d.ts +1 -0
- package/dist/tests/user-facing-api/collection-offline-usage.test.d.ts +1 -0
- package/dist/tests/user-facing-api/document-offline-usage.test.d.ts +1 -0
- package/dist/tests/user-facing-api/list-query-offline-usage.test.d.ts +1 -0
- package/dist/tests/user-facing-api/result-returning-callbacks.test.d.ts +1 -0
- package/dist/tests/utils/genericTestUtils.d.ts +6 -0
- package/dist/tests/utils/indexedDbPersistentStorageOptimizationTestUtils.d.ts +79 -0
- package/dist/tests/utils/indexedDbPersistentStorageTestStore.d.ts +181 -0
- package/dist/tests/utils/listQueryHooksTestUtils.d.ts +8 -0
- package/dist/tests/utils/networkMock.d.ts +11 -0
- package/dist/tests/utils/opfsPersistentStorageTestStore.d.ts +220 -0
- package/dist/tests/utils/persistentStorageOptimizationTestUtils.d.ts +54 -0
- package/dist/tests/utils/persistentStorageOptimizationTestUtils.test.d.ts +1 -0
- package/dist/tests/utils/persistentStorageTestStore.d.ts +66 -0
- package/dist/tests/utils/resetSessionForTests.d.ts +3 -0
- package/dist/tests/utils/withSuppressedActError.d.ts +4 -0
- package/dist/{types-BlyGC_PO.d.ts → types-D0ttVGmj.d.ts} +3 -3
- package/package.json +2 -2
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { FetchType } from '../requestScheduler';
|
|
2
|
+
import { StoreError, TSDFStatus, ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
3
|
+
/** Lifecycle status for a list query or list item query. */
|
|
4
|
+
export type QueryStatus = TSDFStatus | 'loadingMore';
|
|
5
|
+
/** Raw cached state for one list query. */
|
|
6
|
+
export type TSFDListQuery<QueryPayload extends ValidPayload> = {
|
|
7
|
+
/** Last fetch error for this query, when the latest fetch failed. */
|
|
8
|
+
error: StoreError | null;
|
|
9
|
+
/** Current fetch lifecycle status for this query. */
|
|
10
|
+
status: QueryStatus;
|
|
11
|
+
/** Payload used to identify and fetch this query. */
|
|
12
|
+
payload: QueryPayload;
|
|
13
|
+
/** Whether another page is available. */
|
|
14
|
+
hasMore: boolean;
|
|
15
|
+
/** Whether this query has ever loaded successfully. */
|
|
16
|
+
wasLoaded: boolean;
|
|
17
|
+
/** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
18
|
+
refetchOnMount: false | FetchType;
|
|
19
|
+
/** Ordered item keys included in the cached query page. */
|
|
20
|
+
items: string[];
|
|
21
|
+
};
|
|
22
|
+
/** Raw cached state for one item query in a list-query store. */
|
|
23
|
+
export type TSDFItemQuery<ItemPayload extends ValidPayload> = {
|
|
24
|
+
/** Last item fetch error, if any. */
|
|
25
|
+
error: StoreError | null;
|
|
26
|
+
/** Current fetch lifecycle status for this item. */
|
|
27
|
+
status: Exclude<QueryStatus, 'loadingMore'>;
|
|
28
|
+
/** Whether this item has ever loaded successfully. */
|
|
29
|
+
wasLoaded: boolean;
|
|
30
|
+
/** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
31
|
+
refetchOnMount: false | FetchType;
|
|
32
|
+
/** Payload used to identify and fetch this item. */
|
|
33
|
+
payload: ItemPayload;
|
|
34
|
+
};
|
|
35
|
+
/** Loaded partial-resource fields for one item, or `'*'` when fully loaded. */
|
|
36
|
+
export type ItemLoadedFields = string[] | '*';
|
|
37
|
+
/** Raw t-state shape used by a list-query store. */
|
|
38
|
+
export type TSFDListQueryState<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
39
|
+
/** Item data records keyed by item store key. */
|
|
40
|
+
items: Record<string, ItemState | null>;
|
|
41
|
+
/** List query records keyed by query store key. */
|
|
42
|
+
queries: Record<string, TSFDListQuery<QueryPayload>>;
|
|
43
|
+
/** Item query records keyed by item store key. */
|
|
44
|
+
itemQueries: Record<string, TSDFItemQuery<ItemPayload> | null>;
|
|
45
|
+
/** Loaded partial-resource fields for each item key. */
|
|
46
|
+
itemLoadedFields: Record<string, ItemLoadedFields>;
|
|
47
|
+
/** Pending field invalidations for each item key. */
|
|
48
|
+
itemFieldInvalidationFields: Record<string, string[]>;
|
|
49
|
+
};
|
|
50
|
+
export type ListQueryOfflineOverlay<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
|
|
51
|
+
item: ItemState | null;
|
|
52
|
+
itemPayload?: ItemPayload;
|
|
53
|
+
queryMemberships: Record<string, number>;
|
|
54
|
+
/**
|
|
55
|
+
* Temporary-id remaps can leave a child mutation in manual resolution while
|
|
56
|
+
* it already targets the real server item. Keep that overlay visible until
|
|
57
|
+
* the child resolution is cleared.
|
|
58
|
+
*/
|
|
59
|
+
keepVisibleWhileResolutionRequired?: boolean;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Partial-resource fields to request.
|
|
63
|
+
*
|
|
64
|
+
* Pass a field-name array to load only those fields, or `'*'` to load the
|
|
65
|
+
* complete item.
|
|
66
|
+
*/
|
|
67
|
+
export type FieldsInput = string[] | '*';
|
|
68
|
+
/** Value returned by `ListQueryStore.useListQuery(...)` and `useMultipleListQueries(...)`. */
|
|
69
|
+
export type TSFDUseListQueryReturn<Selected, QueryPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined, HasPartialResources extends boolean = false> = {
|
|
70
|
+
/** Selected items included in the current query result. */
|
|
71
|
+
items: Selected[];
|
|
72
|
+
/** Hook-visible query status, including `idle` before a query runs. */
|
|
73
|
+
status: QueryStatus | 'idle';
|
|
74
|
+
/** Query payload for this result, unless omitted or unavailable. */
|
|
75
|
+
payload: QueryPayload | undefined;
|
|
76
|
+
/** Requested partial-resource fields for this query result. */
|
|
77
|
+
fields: HasPartialResources extends true ? FieldsInput : FieldsInput | undefined;
|
|
78
|
+
/** Requested partial-resource fields that are still pending. */
|
|
79
|
+
loadingFields?: string[];
|
|
80
|
+
/** Last query fetch error, if any. */
|
|
81
|
+
error: StoreError | null;
|
|
82
|
+
/** Stable store key for the current query payload. */
|
|
83
|
+
queryKey: string;
|
|
84
|
+
/** Whether another page is available. */
|
|
85
|
+
hasMore: boolean;
|
|
86
|
+
/** Whether this result was derived from local items instead of fetched directly. */
|
|
87
|
+
isDerived: boolean;
|
|
88
|
+
/** Shorthand for `status === 'loading'`. Stays `false` while loaded data is `refetching`. */
|
|
89
|
+
isLoading: boolean;
|
|
90
|
+
/** Whether a `loadMore(...)` request is currently active. */
|
|
91
|
+
isLoadingMore: boolean;
|
|
92
|
+
/** Whether this result has local offline changes that still need to sync to the server. */
|
|
93
|
+
pendingSync: boolean;
|
|
94
|
+
/** Caller-provided metadata copied from the query descriptor. */
|
|
95
|
+
queryMetadata: QueryMetadata;
|
|
96
|
+
};
|
|
97
|
+
/** Value returned by `ListQueryStore.useItem(...)` and `useMultipleItems(...)`. */
|
|
98
|
+
export type TSFDUseListItemReturn<Selected, ItemPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
99
|
+
/** Selected item data. Defaults to the full item or `null`. */
|
|
100
|
+
data: Selected;
|
|
101
|
+
/** Hook-visible item status, including idle/deleted states for hook ergonomics. */
|
|
102
|
+
status: QueryStatus | 'idle' | 'deleted';
|
|
103
|
+
/** Item payload for this result, or `null` when unavailable. */
|
|
104
|
+
payload: ItemPayload | null;
|
|
105
|
+
/** Requested partial-resource fields that are still pending. */
|
|
106
|
+
loadingFields?: string[];
|
|
107
|
+
/** Last item fetch error, if any. */
|
|
108
|
+
error: StoreError | null;
|
|
109
|
+
/** Shorthand for `status === 'loading'`. Stays `false` while loaded data is `refetching`. */
|
|
110
|
+
isLoading: boolean;
|
|
111
|
+
/** Stable store key for the current item payload. */
|
|
112
|
+
itemStateKey: string;
|
|
113
|
+
/** Whether this result has local offline changes that still need to sync to the server. */
|
|
114
|
+
pendingSync: boolean;
|
|
115
|
+
/** Caller-provided metadata copied from the query descriptor. */
|
|
116
|
+
queryMetadata: QueryMetadata;
|
|
117
|
+
};
|
|
118
|
+
/** Value returned by `ListQueryStore.usePendingOfflineItems(...)`. */
|
|
119
|
+
export type TSFDUsePendingOfflineItemsReturn<Selected, ItemPayload extends ValidPayload> = {
|
|
120
|
+
/** Locally created or updated offline items selected by the hook. */
|
|
121
|
+
items: Selected[];
|
|
122
|
+
/** Payloads for locally deleted offline items. */
|
|
123
|
+
deletedItems: ItemPayload[];
|
|
124
|
+
};
|
|
125
|
+
/** One item returned from a list query fetch function. */
|
|
126
|
+
export type FetchListFnReturnItem<ItemPayload extends ValidPayload, ItemState extends ValidStoreState> = {
|
|
127
|
+
/** Item payload used to key and refetch the returned item. */
|
|
128
|
+
itemPayload: ItemPayload;
|
|
129
|
+
/** Item data returned by the server. */
|
|
130
|
+
data: ItemState;
|
|
131
|
+
};
|
|
132
|
+
/** Return shape for list query fetch functions. */
|
|
133
|
+
export type FetchListFnReturn<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = {
|
|
134
|
+
/** Items included in the fetched page. */
|
|
135
|
+
items: FetchListFnReturnItem<ItemPayload, ItemState>[];
|
|
136
|
+
/** Whether the query has another page available. */
|
|
137
|
+
hasMore: boolean;
|
|
138
|
+
};
|
|
139
|
+
/** Item descriptor accepted by `ListQueryStore.useMultipleItems(...)`. */
|
|
140
|
+
export type ListQueryUseMultipleItemsQuery<ItemPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
141
|
+
/** Item payload to subscribe to and fetch when needed. */
|
|
142
|
+
payload: ItemPayload;
|
|
143
|
+
/**
|
|
144
|
+
* Partial-resource fields to request for this item.
|
|
145
|
+
*
|
|
146
|
+
* Pass `'*'` to fetch the complete item. This option is required when
|
|
147
|
+
* `partialResources` is enabled and optional otherwise.
|
|
148
|
+
*/
|
|
149
|
+
fields?: FieldsInput;
|
|
150
|
+
/** Metadata returned with this item result for caller-side bookkeeping. */
|
|
151
|
+
queryMetadata?: QueryMetadata;
|
|
152
|
+
/**
|
|
153
|
+
* Only fetches when the item is missing from state, skipping stale-state and
|
|
154
|
+
* invalidation refetches.
|
|
155
|
+
*/
|
|
156
|
+
disableRefetches?: boolean;
|
|
157
|
+
/** Prevents the automatic mount refetch for stale loaded data. */
|
|
158
|
+
disableRefetchOnMount?: boolean;
|
|
159
|
+
/** Returns `idle` instead of `loading` while the item has not been fetched. */
|
|
160
|
+
returnIdleStatus?: boolean;
|
|
161
|
+
/** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
162
|
+
returnRefetchingStatus?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* When requested fields are missing but cached partial data exists, return
|
|
165
|
+
* `refetching` instead of `loading`.
|
|
166
|
+
*/
|
|
167
|
+
showPartialAsRefetching?: boolean;
|
|
168
|
+
/** Marks this subscription as off-screen, lowering automatic fetch priority. */
|
|
169
|
+
isOffScreen?: boolean;
|
|
170
|
+
};
|
|
171
|
+
/** Query descriptor accepted by `ListQueryStore.useMultipleListQueries(...)`. */
|
|
172
|
+
export type ListQueryUseMultipleListQueriesQuery<QueryPayload extends ValidPayload, QueryMetadata extends undefined | Record<string, unknown> = undefined> = {
|
|
173
|
+
/** Query payload to subscribe to and fetch when needed. */
|
|
174
|
+
payload: QueryPayload;
|
|
175
|
+
/**
|
|
176
|
+
* Partial-resource fields to request for each item in this query.
|
|
177
|
+
*
|
|
178
|
+
* Pass `'*'` to fetch complete items. This option is required when
|
|
179
|
+
* `partialResources` is enabled and optional otherwise.
|
|
180
|
+
*/
|
|
181
|
+
fields?: FieldsInput;
|
|
182
|
+
/** Metadata returned with this query result for caller-side bookkeeping. */
|
|
183
|
+
queryMetadata?: QueryMetadata;
|
|
184
|
+
/** Omits `payload` from this query result. */
|
|
185
|
+
omitPayload?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Only fetches when the query is missing from state, skipping stale-state and
|
|
188
|
+
* invalidation refetches.
|
|
189
|
+
*/
|
|
190
|
+
disableRefetches?: boolean;
|
|
191
|
+
/** Prevents the automatic mount refetch for stale loaded data. */
|
|
192
|
+
disableRefetchOnMount?: boolean;
|
|
193
|
+
/** Returns `idle` instead of `loading` while the query has not been fetched. */
|
|
194
|
+
returnIdleStatus?: boolean;
|
|
195
|
+
/** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
196
|
+
returnRefetchingStatus?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* When requested fields are missing but cached partial data exists, return
|
|
199
|
+
* `refetching` instead of `loading`.
|
|
200
|
+
*/
|
|
201
|
+
showPartialAsRefetching?: boolean;
|
|
202
|
+
/** Marks this subscription as off-screen, lowering automatic fetch priority. */
|
|
203
|
+
isOffScreen?: boolean;
|
|
204
|
+
/** Number of items to request when fetching this query page. */
|
|
205
|
+
loadSize?: number;
|
|
206
|
+
};
|
|
207
|
+
/** Callback invoked when an already-loaded list query is invalidated. */
|
|
208
|
+
export type OnListQueryInvalidate<QueryPayload extends ValidPayload> = (query: QueryPayload, priority: FetchType) => void;
|
|
209
|
+
/** Callback invoked when an already-loaded list-query item is invalidated. */
|
|
210
|
+
export type OnListQueryItemInvalidate<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (props: {
|
|
211
|
+
/** Current cached item state at invalidation time. */
|
|
212
|
+
itemState: ItemState;
|
|
213
|
+
/** Payload of the invalidated item. */
|
|
214
|
+
payload: ItemPayload;
|
|
215
|
+
/** Fetch priority requested for the invalidation. */
|
|
216
|
+
priority: FetchType;
|
|
217
|
+
}) => void;
|
|
218
|
+
/** Rule for keeping cached list query membership in sync after item updates. */
|
|
219
|
+
export type OptimisticListUpdate<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
220
|
+
/** Query payloads, or a predicate over query payloads, affected by this rule. */
|
|
221
|
+
queries: QueryPayload | ((query: QueryPayload) => boolean) | QueryPayload[];
|
|
222
|
+
/** Restricts this rule to items that should belong in the affected query set. */
|
|
223
|
+
filterItem?: (item: ItemState) => boolean | null;
|
|
224
|
+
/** Where newly matching items should be inserted in affected query pages. */
|
|
225
|
+
appendNewTo?: 'start' | 'end';
|
|
226
|
+
/**
|
|
227
|
+
* Schedules a background refetch of queries this rule mutated. Leave off
|
|
228
|
+
* unless the optimistic update can't represent the final server state —
|
|
229
|
+
* e.g. server-assigned sort fields (`updatedAt`, computed scores), server-
|
|
230
|
+
* only membership data (permissions), or cursor pagination shifts.
|
|
231
|
+
*/
|
|
232
|
+
invalidateQueries?: boolean;
|
|
233
|
+
/** Sort order to maintain inside affected query pages. */
|
|
234
|
+
sort?: {
|
|
235
|
+
/** Selects sortable values from an item. */
|
|
236
|
+
sortBy: (item: ItemState, itemPayload: ItemPayload) => string | number | (string | number)[];
|
|
237
|
+
/** Sort direction for each `sortBy` value. */
|
|
238
|
+
order?: 'asc' | 'desc' | ('asc' | 'desc')[];
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
/** Payload passed to list fetch functions. */
|
|
242
|
+
export type QueryFetchPayload<QueryPayload extends ValidPayload> = {
|
|
243
|
+
/** Whether this request loads the first page or a later page. */
|
|
244
|
+
type: 'load' | 'loadMore';
|
|
245
|
+
/** Query payload being fetched. */
|
|
246
|
+
payload: QueryPayload;
|
|
247
|
+
/** Offset used for offset-paginated fetches. */
|
|
248
|
+
offset: number;
|
|
249
|
+
/** Maximum number of items requested. */
|
|
250
|
+
limit: number;
|
|
251
|
+
/** Partial-resource fields requested for each item in the fetched query. */
|
|
252
|
+
fields?: string[];
|
|
253
|
+
};
|
|
254
|
+
/** Options for offset-based list pagination. */
|
|
255
|
+
export type OffsetPaginationConfig = {
|
|
256
|
+
/** Largest item count requested when refetching invalidated offset queries. */
|
|
257
|
+
maxInvalidationLimit: number;
|
|
258
|
+
/** Max parallel chunk requests during chunked invalidation (default: 3) */
|
|
259
|
+
maxParallel?: number;
|
|
260
|
+
};
|
|
261
|
+
/** Partial-resource helpers used to merge and select field subsets. */
|
|
262
|
+
export type PartialResourcesConfig<ItemState extends ValidStoreState> = {
|
|
263
|
+
/** Merges a partial fetch result into an existing item snapshot. */
|
|
264
|
+
mergeItems: (prev: ItemState | undefined, fetched: ItemState) => ItemState;
|
|
265
|
+
/** Returns an item containing only the requested fields. */
|
|
266
|
+
selectFields: (fields: string[], item: ItemState) => ItemState;
|
|
267
|
+
/**
|
|
268
|
+
* Reports which logical fields are genuinely present in an item snapshot,
|
|
269
|
+
* or `'*'` when the snapshot is complete.
|
|
270
|
+
*
|
|
271
|
+
* It is the only availability signal for snapshots without loaded-field
|
|
272
|
+
* metadata (manually inserted items, persisted fallback snapshots, offline
|
|
273
|
+
* optimistic rows), but it is also consulted for metadata-tracked items:
|
|
274
|
+
* metadata only records what fetches delivered, so `inferFields` can vouch
|
|
275
|
+
* for fields present beyond the tracked list (e.g. written by a mutation)
|
|
276
|
+
* and avoid refetching data that is already there.
|
|
277
|
+
*
|
|
278
|
+
* Because it can vouch for any snapshot, it must only report fields whose
|
|
279
|
+
* data is genuinely usable — never return `'*'` unconditionally unless
|
|
280
|
+
* every snapshot the store can hold is complete. Staleness is handled by
|
|
281
|
+
* TSDF: fields awaiting an invalidation refetch are excluded before
|
|
282
|
+
* `inferFields` is consulted.
|
|
283
|
+
*/
|
|
284
|
+
inferFields: (item: ItemState) => ItemLoadedFields;
|
|
285
|
+
};
|
|
286
|
+
export type DerivedQuerySummary<QueryPayload extends ValidPayload> = {
|
|
287
|
+
payload: QueryPayload;
|
|
288
|
+
hasMore: boolean;
|
|
289
|
+
itemCount: number;
|
|
290
|
+
};
|
|
291
|
+
export type DerivedQueryItem<ItemState extends ValidStoreState> = {
|
|
292
|
+
key: string;
|
|
293
|
+
data: ItemState;
|
|
294
|
+
};
|
|
295
|
+
/** Why a derived query is currently being resolved. */
|
|
296
|
+
export type DerivedQuerySource = 'online' | 'offline' | 'sticky-offline';
|
|
297
|
+
/** Runtime context passed to `derivedQueries.deriveQuery(...)`. */
|
|
298
|
+
export type DerivedQueryContext = {
|
|
299
|
+
/** The requested hook fields for this query, when partial resources are enabled. */
|
|
300
|
+
fields: FieldsInput | undefined;
|
|
301
|
+
/** Whether the store is currently in offline mode. */
|
|
302
|
+
isOfflineMode: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* What caused derivation to run.
|
|
305
|
+
* `sticky-offline` means a query that was derived offline is still sticking
|
|
306
|
+
* to the local derived view after reconnect, until explicit invalidation.
|
|
307
|
+
*/
|
|
308
|
+
deriveSource: DerivedQuerySource;
|
|
309
|
+
};
|
|
310
|
+
/** Configuration for deriving query membership from locally materialized items. */
|
|
311
|
+
export type DerivedQueriesConfig<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
312
|
+
/** Extracts the domain/group key for a query payload. */
|
|
313
|
+
getQueryGroup: (queryPayload: QueryPayload) => string;
|
|
314
|
+
/** Extracts the domain/group key for a materialized item. */
|
|
315
|
+
getItemGroup: (item: ItemState, itemPayload: ItemPayload) => string;
|
|
316
|
+
/**
|
|
317
|
+
* Returns whether the local data for the query group is complete enough to
|
|
318
|
+
* derive from while online.
|
|
319
|
+
*/
|
|
320
|
+
isComplete: (queryPayload: QueryPayload, context: {
|
|
321
|
+
queries: DerivedQuerySummary<QueryPayload>[];
|
|
322
|
+
}) => boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Computes a derived ordered list of item keys for a query, or `false` to
|
|
325
|
+
* fall back to the regular fetch/cache path. `context.fields` lets the
|
|
326
|
+
* callback decide whether partial-resource queries should still derive.
|
|
327
|
+
*/
|
|
328
|
+
deriveQuery: (queryPayload: QueryPayload, items: DerivedQueryItem<ItemState>[], context: DerivedQueryContext) => string[] | false;
|
|
329
|
+
};
|
|
330
|
+
/** Field option shape used by APIs that are conditional on `partialResources`. */
|
|
331
|
+
export type FieldsOption<HasPartialResources extends boolean> = HasPartialResources extends true ? {
|
|
332
|
+
/**
|
|
333
|
+
* Partial-resource fields to request.
|
|
334
|
+
*
|
|
335
|
+
* Pass `'*'` to fetch complete items. This option is required when
|
|
336
|
+
* `partialResources` is enabled.
|
|
337
|
+
*/
|
|
338
|
+
fields: FieldsInput;
|
|
339
|
+
} : {
|
|
340
|
+
/**
|
|
341
|
+
* Partial-resource fields to request.
|
|
342
|
+
*
|
|
343
|
+
* Pass `'*'` to fetch complete items. This option is optional when
|
|
344
|
+
* `partialResources` is not enabled.
|
|
345
|
+
*/
|
|
346
|
+
fields?: FieldsInput;
|
|
347
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Store } from 't-state';
|
|
2
|
+
import { ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
3
|
+
import type { TSFDListQueryState } from './types';
|
|
4
|
+
export declare function useFindItem<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, SelectedItem = ItemState | null>(findItemFn: (item: ItemState, itemPayload: ItemPayload) => boolean, { selector }: {
|
|
5
|
+
/** Maps the matched item before it is returned from the hook. */
|
|
6
|
+
selector?: (data: ItemState, id: ItemPayload) => SelectedItem;
|
|
7
|
+
}, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, registerActiveItems: (itemKeys: string[]) => () => void, touchItems: (itemKeys: string[]) => void): SelectedItem | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Store } from 't-state';
|
|
2
|
+
import { FetchType, ScheduleFetchResults } from '../requestScheduler';
|
|
3
|
+
import { ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
4
|
+
import type { FieldsInput, ListQueryUseMultipleItemsQuery, TSFDListQueryState, TSFDUseListItemReturn } from './types';
|
|
5
|
+
import type { UseMultipleItemsOptions } from './useMultipleItems';
|
|
6
|
+
export type UseItemOptions<ItemState extends ValidStoreState, Selected> = UseMultipleItemsOptions<ItemState, Selected> & {
|
|
7
|
+
/**
|
|
8
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
9
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
10
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
11
|
+
* Cannot be combined with `debouncePayload`.
|
|
12
|
+
*/
|
|
13
|
+
requireFreshData?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Partial-resource fields to request for this item.
|
|
16
|
+
*
|
|
17
|
+
* Pass `'*'` to fetch the complete item. This option is required when
|
|
18
|
+
* `partialResources` is enabled and optional otherwise.
|
|
19
|
+
*/
|
|
20
|
+
fields?: FieldsInput;
|
|
21
|
+
/**
|
|
22
|
+
* When requested fields are missing but cached partial data exists, return
|
|
23
|
+
* `refetching` instead of `loading`.
|
|
24
|
+
*/
|
|
25
|
+
showPartialAsRefetching?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function useItem<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, Selected = ItemState | null>(itemPayload: ItemPayload | false | null | undefined, { selector, requireFreshData, loadFromStateOnly, disableRefetches, disableRefetchOnMount, returnIdleStatus, returnRefetchingStatus, showPartialAsRefetching, isOffScreen, fields, debouncePayload }: UseItemOptions<ItemState, Selected>, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, scheduleItemFetch: (fetchType: FetchType, payload: ItemPayload, options?: {
|
|
28
|
+
fields?: FieldsInput;
|
|
29
|
+
}) => ScheduleFetchResults, useMultipleItems: <S = ItemState | null>(items: ListQueryUseMultipleItemsQuery<ItemPayload, undefined>[], options: UseMultipleItemsOptions<ItemState, S>) => readonly TSFDUseListItemReturn<S, ItemPayload, undefined>[]): TSFDUseListItemReturn<Selected, ItemPayload>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Store } from 't-state';
|
|
2
|
+
import { FetchType, ScheduleFetchResults } from '../requestScheduler';
|
|
3
|
+
import { ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
4
|
+
import type { FieldsInput, ListQueryUseMultipleListQueriesQuery, TSFDListQueryState, TSFDUseListQueryReturn } from './types';
|
|
5
|
+
import type { UseMultipleListQueriesOptions } from './useMultipleListQueries';
|
|
6
|
+
export type UseListQueryOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, SelectedItem> = UseMultipleListQueriesOptions<ItemState, ItemPayload, SelectedItem> & {
|
|
7
|
+
/**
|
|
8
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
9
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
10
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
11
|
+
* Cannot be combined with `debouncePayload`.
|
|
12
|
+
*/
|
|
13
|
+
requireFreshData?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Partial-resource fields to request for each item in this query.
|
|
16
|
+
*
|
|
17
|
+
* Pass `'*'` to fetch complete items. This option is required when
|
|
18
|
+
* `partialResources` is enabled and optional otherwise.
|
|
19
|
+
*/
|
|
20
|
+
fields?: FieldsInput;
|
|
21
|
+
/**
|
|
22
|
+
* When requested fields are missing but cached partial data exists, return
|
|
23
|
+
* `refetching` instead of `loading`.
|
|
24
|
+
*/
|
|
25
|
+
showPartialAsRefetching?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare function useListQuery<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, SelectedItem = ItemState>(payload: QueryPayload | false | null | undefined, { itemSelector, omitPayload, disableRefetches, disableRefetchOnMount, returnIdleStatus, returnRefetchingStatus, showPartialAsRefetching, loadSize, isOffScreen, requireFreshData, fields, debouncePayload }: UseListQueryOptions<ItemState, ItemPayload, SelectedItem>, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, getQueryKey: (params: QueryPayload) => string, scheduleListQueryFetch: (fetchType: FetchType, payload: QueryPayload, size?: number, options?: {
|
|
28
|
+
fields?: FieldsInput;
|
|
29
|
+
}) => ScheduleFetchResults, useMultipleListQueries: <S = ItemState>(queries: ListQueryUseMultipleListQueriesQuery<QueryPayload, undefined>[], options: UseMultipleListQueriesOptions<ItemState, ItemPayload, S>) => readonly TSFDUseListQueryReturn<S, QueryPayload, undefined>[]): TSFDUseListQueryReturn<SelectedItem, QueryPayload>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Emitter } from 'evtmitter';
|
|
2
|
+
import { Store } from 't-state';
|
|
3
|
+
import type { GlobalOfflineEntity } from '../persistentStorage/offline/types';
|
|
4
|
+
import { FetchType, ScheduleFetchResults } from '../requestScheduler';
|
|
5
|
+
import { type PayloadDebounce, ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
6
|
+
import type { ListQueryStoreEvents } from './listQueryStore';
|
|
7
|
+
import { type FieldsInput, type ItemLoadedFields, type ListQueryOfflineOverlay, type ListQueryUseMultipleItemsQuery, type PartialResourcesConfig, type TSDFItemQuery, type TSFDListQueryState, type TSFDUseListItemReturn } from './types';
|
|
8
|
+
export type UseMultipleItemsOptions<ItemState extends ValidStoreState, Selected> = {
|
|
9
|
+
/** Maps each item before it is returned from the hook. */
|
|
10
|
+
selector?: (data: ItemState | null, payload: ValidPayload | null) => Selected;
|
|
11
|
+
/** Reads only from the current store state and never schedules fetches. */
|
|
12
|
+
loadFromStateOnly?: boolean;
|
|
13
|
+
/** Returns `idle` instead of `loading` while items have not been fetched. */
|
|
14
|
+
returnIdleStatus?: boolean;
|
|
15
|
+
/** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
16
|
+
returnRefetchingStatus?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* When requested fields are missing but cached partial data exists, return
|
|
19
|
+
* `refetching` instead of `loading`.
|
|
20
|
+
*/
|
|
21
|
+
showPartialAsRefetching?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Only fetches when an item is missing from state, skipping stale-state and
|
|
24
|
+
* invalidation refetches.
|
|
25
|
+
*/
|
|
26
|
+
disableRefetches?: boolean;
|
|
27
|
+
/** Prevents automatic mount refetches for stale loaded data. */
|
|
28
|
+
disableRefetchOnMount?: boolean;
|
|
29
|
+
/** Marks these subscriptions as off-screen, lowering automatic fetch priority. */
|
|
30
|
+
isOffScreen?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Debounces automatic fetches caused by payload changes, while selection
|
|
33
|
+
* still reads from the latest payload. Supports trailing debounce via `ms`,
|
|
34
|
+
* optional `leading`, and optional `maxWait`.
|
|
35
|
+
*/
|
|
36
|
+
debouncePayload?: PayloadDebounce;
|
|
37
|
+
};
|
|
38
|
+
export declare function useMultipleItems<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, Selected = ItemState | null, QueryMetadata extends undefined | Record<string, unknown> = undefined>(items: ListQueryUseMultipleItemsQuery<ItemPayload, QueryMetadata>[], { selector, loadFromStateOnly, returnIdleStatus: allItemsReturnIdleStatus, returnRefetchingStatus: allItemsReturnRefetchingStatus, showPartialAsRefetching: allItemsShowPartialAsRefetching, disableRefetches: allItemsDisableRefetches, disableRefetchOnMount: allItemsDisableRefetchOnMount, isOffScreen: allItemsIsOffScreen, debouncePayload }: UseMultipleItemsOptions<ItemState, Selected>, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, events: Emitter<ListQueryStoreEvents>, getItemKey: (params: ItemPayload) => string, registerActiveItems: (itemKeys: string[]) => () => void, touchItems: (itemKeys: string[]) => void, scheduleAutomaticItemFetch: (fetchType: FetchType, payload: ItemPayload, options?: {
|
|
39
|
+
fields?: FieldsInput;
|
|
40
|
+
}) => ScheduleFetchResults, preloadItems: ((payloads: ItemPayload[]) => Promise<boolean[]>) | undefined, preloadItemsBeforePaint: boolean, readFallbackItemState: ((itemKey: string) => {
|
|
41
|
+
item: ItemState | null | undefined;
|
|
42
|
+
itemQuery: TSDFItemQuery<ItemPayload> | null | undefined;
|
|
43
|
+
loadedFields: ItemLoadedFields | undefined;
|
|
44
|
+
} | undefined) | undefined, itemInvalidationWasTriggered: Set<string>, itemPendingInvalidationFields: Map<string, Map<string, FetchType | null>>, itemsPendingFullInvalidation: Map<string, FetchType>, globalDisableRefetchOnMount: boolean | undefined, fetchItemFn: unknown, partialResources: PartialResourcesConfig<ItemState> | undefined, offlineEntities: readonly GlobalOfflineEntity[], offlineOverlays: Readonly<Record<string, ListQueryOfflineOverlay<ItemState, ItemPayload>>>): readonly TSFDUseListItemReturn<Selected, ItemPayload, QueryMetadata>[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Emitter } from 'evtmitter';
|
|
2
|
+
import { Store } from 't-state';
|
|
3
|
+
import type { GlobalOfflineEntity } from '../persistentStorage/offline/types';
|
|
4
|
+
import { FetchType, ScheduleFetchResults } from '../requestScheduler';
|
|
5
|
+
import { type PayloadDebounce, ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
6
|
+
import type { ListQueryStoreEvents } from './listQueryStore';
|
|
7
|
+
import { type DerivedQueriesConfig, type FieldsInput, type ItemLoadedFields, type ListQueryOfflineOverlay, type ListQueryUseMultipleListQueriesQuery, type PartialResourcesConfig, type TSDFItemQuery, type TSFDListQuery, type TSFDListQueryState, type TSFDUseListQueryReturn } from './types';
|
|
8
|
+
export type UseMultipleListQueriesOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, SelectedItem> = {
|
|
9
|
+
/** Maps each query item before it is returned from the hook. */
|
|
10
|
+
itemSelector?: (data: ItemState, itemPayload: ItemPayload, itemKey: string) => SelectedItem;
|
|
11
|
+
/** Returns `idle` instead of `loading` while queries have not been fetched. */
|
|
12
|
+
returnIdleStatus?: boolean;
|
|
13
|
+
/** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
14
|
+
returnRefetchingStatus?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* When requested fields are missing but cached partial data exists, return
|
|
17
|
+
* `refetching` instead of `loading`.
|
|
18
|
+
*/
|
|
19
|
+
showPartialAsRefetching?: boolean;
|
|
20
|
+
/** Omits `payload` from each query result unless overridden per query. */
|
|
21
|
+
omitPayload?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Only fetches when a query is missing from state, skipping stale-state and
|
|
24
|
+
* invalidation refetches.
|
|
25
|
+
*/
|
|
26
|
+
disableRefetches?: boolean;
|
|
27
|
+
/** Prevents automatic mount refetches for stale loaded data. */
|
|
28
|
+
disableRefetchOnMount?: boolean;
|
|
29
|
+
/** Marks these subscriptions as off-screen, lowering automatic fetch priority. */
|
|
30
|
+
isOffScreen?: boolean;
|
|
31
|
+
/** Number of items to request when fetching each query page. */
|
|
32
|
+
loadSize?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Debounces automatic fetches caused by payload changes, while selection
|
|
35
|
+
* still reads from the latest payload. Supports trailing debounce via `ms`,
|
|
36
|
+
* optional `leading`, and optional `maxWait`.
|
|
37
|
+
*/
|
|
38
|
+
debouncePayload?: PayloadDebounce;
|
|
39
|
+
};
|
|
40
|
+
export declare function useMultipleListQueries<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, SelectedItem = ItemState, QueryMetadata extends undefined | Record<string, unknown> = undefined>(queries: ListQueryUseMultipleListQueriesQuery<QueryPayload, QueryMetadata>[], { itemSelector, returnIdleStatus: allItemsReturnIdleStatus, returnRefetchingStatus: allItemsReturnRefetchingStatus, showPartialAsRefetching: allItemsShowPartialAsRefetching, omitPayload: allItemsOmitPayload, disableRefetches: allItemsDisableRefetches, disableRefetchOnMount: allItemsDisableRefetchOnMount, isOffScreen: allItemsIsOffScreen, loadSize: allItemsLoadSize, debouncePayload }: UseMultipleListQueriesOptions<ItemState, ItemPayload, SelectedItem>, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, events: Emitter<ListQueryStoreEvents>, getQueryKey: (params: QueryPayload) => string, registerActiveQueries: (queryKeys: string[]) => () => void, touchQueries: (queryKeys: string[]) => void, getQueryState: (params: QueryPayload) => TSFDListQuery<QueryPayload> | undefined, readFallbackQueryState: ((queryKey: string) => TSFDListQuery<QueryPayload> | undefined) | undefined, preloadQueries: ((payloads: QueryPayload[]) => Promise<boolean[]>) | undefined, preloadQueriesBeforePaint: boolean, preloadDerivedQueryItems: ((payloads: QueryPayload[]) => Promise<boolean[]>) | undefined, readFallbackItemState: ((itemKey: string) => {
|
|
41
|
+
item: ItemState | null | undefined;
|
|
42
|
+
itemQuery: TSDFItemQuery<ItemPayload> | null | undefined;
|
|
43
|
+
loadedFields: ItemLoadedFields | undefined;
|
|
44
|
+
} | undefined) | undefined, scheduleAutomaticListQueryFetch: (fetchType: FetchType, payload: QueryPayload, size?: number, options?: {
|
|
45
|
+
fields?: FieldsInput;
|
|
46
|
+
}) => ScheduleFetchResults, queryInvalidationWasTriggered: Set<string>, itemPendingInvalidationFields: Map<string, Map<string, FetchType | null>>, itemsPendingFullInvalidation: Map<string, FetchType>, globalDisableRefetchOnMount: boolean | undefined, partialResources: PartialResourcesConfig<ItemState> | undefined, derivedQueries: DerivedQueriesConfig<ItemState, QueryPayload, ItemPayload> | undefined, isOfflineMode: boolean, offlineEntities: readonly GlobalOfflineEntity[], offlineOverlays: Readonly<Record<string, ListQueryOfflineOverlay<ItemState, ItemPayload>>>): readonly TSFDUseListQueryReturn<SelectedItem, QueryPayload, QueryMetadata>[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Store } from 't-state';
|
|
2
|
+
import type { InternalGlobalOfflineEntity } from '../persistentStorage/offline/types';
|
|
3
|
+
import { ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
4
|
+
import type { ItemLoadedFields, ListQueryOfflineOverlay, TSFDListQueryState, TSFDUsePendingOfflineItemsReturn } from './types';
|
|
5
|
+
export type UsePendingOfflineItemsOptions<ItemState extends ValidStoreState, ItemPayload extends ValidPayload, SelectedItem> = {
|
|
6
|
+
/** Maps each visible pending item before it is returned from the hook. */
|
|
7
|
+
selector?: (data: ItemState, payload: ItemPayload) => SelectedItem;
|
|
8
|
+
/** Narrows the hook output using the tracked item payload, before selection. */
|
|
9
|
+
filterPayload?: (payload: ItemPayload) => boolean;
|
|
10
|
+
/** Includes entities currently blocked in manual resolution. */
|
|
11
|
+
includeResolutionRequired?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function usePendingOfflineItems<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, SelectedItem = ItemState>({ selector, filterPayload, includeResolutionRequired }: UsePendingOfflineItemsOptions<ItemState, ItemPayload, SelectedItem>, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, registerActiveItems: (itemKeys: string[]) => () => void, touchItems: (itemKeys: string[]) => void, preloadItems: ((itemKeys: string[]) => Promise<boolean[]>) | undefined, preloadItemsBeforePaint: boolean, readHydratedItem: ((itemKey: string) => {
|
|
14
|
+
item: ItemState | null | undefined;
|
|
15
|
+
itemQuery: {
|
|
16
|
+
payload: ItemPayload;
|
|
17
|
+
} | null | undefined;
|
|
18
|
+
loadedFields: ItemLoadedFields | undefined;
|
|
19
|
+
} | undefined) | undefined, offlineEntities: readonly InternalGlobalOfflineEntity[], offlineOverlays: Readonly<Record<string, ListQueryOfflineOverlay<ItemState, ItemPayload>>>): TSFDUsePendingOfflineItemsReturn<SelectedItem, ItemPayload>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { createCollectionStore } from './collectionStore/collectionStore';
|
|
2
|
+
export { createDocumentStore } from './documentStore';
|
|
3
|
+
export { createListQueryStore } from './listQueryStore/listQueryStore';
|
|
4
|
+
export { fetchTypePriority, mutationSkipped, StoreFetchError, StoreMutationError, } from './utils/storeShared';
|
|
5
|
+
export { GET_ALL } from './invalidationUtils';
|
|
6
|
+
export { IsOffScreenContext } from './isOffScreenContext';
|
|
7
|
+
export { createStoreManager, type CreateStoreManagerOptions, type DynamicRealtimeThrottleMs, type StoreManager, } from './storeManager';
|
|
8
|
+
export type { TSDFFocusDebugOperation, TSDFDebugLogArea, TSDFDebugLogger, TSDFDebugLogEntry, TSDFDebugLogLevel, TSDFLoggerOptions, } from './debug';
|
|
9
|
+
export * from './documentStore';
|
|
10
|
+
export * from './collectionStore/collectionStore';
|
|
11
|
+
export type { ListQueryStore, ListQueryStoreEvents, ListQueryStoreOptions, } from './listQueryStore/listQueryStore';
|
|
12
|
+
export type { DerivedQueryContext, DerivedQueriesConfig, FetchListFnReturn, FetchListFnReturnItem, FieldsInput, FieldsOption, DerivedQuerySource, ListQueryUseMultipleItemsQuery, ListQueryUseMultipleListQueriesQuery, OffsetPaginationConfig, OnListQueryInvalidate, OnListQueryItemInvalidate, OptimisticListUpdate, PartialResourcesConfig, QueryFetchPayload, QueryStatus, TSDFItemQuery, TSFDListQuery, TSFDListQueryState, TSFDUseListItemReturn, TSFDUseListQueryReturn, TSFDUsePendingOfflineItemsReturn, } from './listQueryStore/types';
|
|
13
|
+
export type { MaybeTSDFResult, MutationSkipped, PayloadDebounce, StoreError, StoreMutationErrorOptions, TSDFStatus, ValidPayload, ValidStoreState, } from './utils/storeShared';
|
|
14
|
+
export type { BlockWindowCloseHandler, MutationDebounce, } from './utils/performMutation';
|
|
15
|
+
export type { AsyncStorageAdapter, AsyncStorageDiscoveredScope, AsyncStorageDriver, AsyncStorageDriverSetEntry, AsyncStorageMetadataOrder, AsyncStorageNamespaceCommitArgs, AsyncStorageNamespaceCommitTouch, AsyncStorageNamespaceCommitUpsert, AsyncStorageNamespaceGetResult, AsyncStorageNamespaceHandle, AsyncStorageNamespaceKind, AsyncStorageNamespaceScope, AsyncStorageReadOptions, PersistentStorageSchema, PersistentStorageDataSchema, ConvertedPersistentStorageDataSchema, PersistentStorageBaseConfig, PersistentStoragePreloadResult, DocumentPersistentStorageConfig, CollectionPersistentStorageConfig, ListQueryPersistentStorageConfig, StorageAdapter, } from './persistentStorage/types';
|
|
16
|
+
export type { OfflineMutationUploadsInput, OfflineOperationUploadsContext, OfflineSessionUploadsConfig, OfflineStoredUploadRecord, OfflineUpload, OfflineUploadAdapter, OfflineUploadProgress, OfflineUploadSource, OfflineUploadState, OfflineUploadTransportContext, } from './persistentStorage/offlineUploadTypes';
|
|
17
|
+
export type { OfflineAccumulationConfig, OfflineAccumulationMergeContext, CollectionOfflineOperationDefinition, CollectionOfflineEntityRef, DefineCollectionOfflineOperations, DefineOfflineOperation, DefineDocumentOfflineOperations, DefineListQueryOfflineOperations, DocumentOfflineOperationDefinition, OfflineConflictResolutionAction, OfflineEntityMutationKind, GlobalOfflineEntity, GlobalOfflineStatus, OfflineMutationInput, OfflineOperationKind, OfflineRuntimeConfig, OfflineRuntimeConfigUpdate, OfflineMutationQueueingConfig, OfflineMutationQueueingCause, OfflineMutationQueueingPolicy, OfflineSession, OfflineSessionConfig, OfflineReplayRetryConfig, OfflineResolutionAction, OfflineResolutionActionForOperation, OfflineResolutionConflictParseErrorCode, OfflineResolutionConflictParseError, OfflineResolutionRecordForStore, OfflineResolutionRecordForOperation, OfflineSupersedeConfig, ListQueryOfflineEntityRef, ListQueryOfflineOperationDefinition, OfflineResolutionRecord, OfflineRetryExhaustedResolutionAction, OfflineMutationDescriptor, OfflineQueueEntry, OperationConflict, OperationResult, ParsedOfflineResolutionConflictResultForOperation, OfflineSyncState, OfflineTempEntitiesConfig, OfflineTempEntitiesReconciliation, OfflineTempEntityConfig, OfflineTempEntityPendingEntry, } from './persistentStorage/offline/types';
|
|
18
|
+
export { defaultOfflineRuntimeConfig } from './persistentStorage/offline/types';
|
|
19
|
+
export type { OfflineMutationResult } from './persistentStorage/offline/mutationRuntime';
|
|
20
|
+
export { getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus, } from './persistentStorage/offline/sessionCoordinator';
|
|
21
|
+
export { clearSessionStorage, clearAllSessionStorage, } from './persistentStorage/persistentStorageManager';
|
|
22
|
+
export { localPersistentStorage } from './persistentStorage/storageAdapter';
|
|
23
|
+
export { opfsOfflineUploadAdapter } from './persistentStorage/opfsOfflineUploadAdapter';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { opfsPersistentStorage } from './persistentStorage/opfsPersistentStorage';
|