tsdf 17.0.2 → 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/{asyncStorageAdapter-DuAUANgu.d.ts → asyncStorageAdapter-CMohMeKm.d.ts} +1 -1
- package/dist/indexed-db-storage.d.ts +1 -1
- package/dist/main.d.ts +28 -32
- package/dist/main.js +46 -46
- package/dist/opfs-storage.d.ts +1 -1
- package/dist/{opfsPersistentStorage-BB0qqnRz.d.ts → opfsPersistentStorage-Ci0JcCo5.d.ts} +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-aWgyZHLj.d.ts → types-D0ttVGmj.d.ts} +1 -1
- package/docs/browser-tabs-sync.md +2 -0
- package/docs/mutations.md +7 -3
- package/docs/persistent-storage.md +2 -0
- package/package.json +6 -3
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { type __LEGIT_ANY__ } from '@ls-stack/utils/saferTyping';
|
|
2
|
+
import { type Emitter } from 'evtmitter';
|
|
3
|
+
import { type Result as ResultType } from 't-result';
|
|
4
|
+
import { Store } from 't-state';
|
|
5
|
+
import { type OfflineMutationResult } from './persistentStorage/offline/mutationRuntime';
|
|
6
|
+
import { type AnyOfflineOperationDefinition, type GlobalOfflineEntity, type OfflineMutationInput, type OfflineResolutionActionForOperation, type OfflineResolutionRecord, type ParsedOfflineResolutionConflictResultForStore } from './persistentStorage/offline/types';
|
|
7
|
+
import type { OfflineMutationUploadsInput } from './persistentStorage/offlineUploadTypes';
|
|
8
|
+
import type { DocumentPersistentStorageConfig } from './persistentStorage/types';
|
|
9
|
+
import { FetchType, RequestSchedulerEventData, RequestSchedulerEvents, ScheduleFetchOptions, ScheduleFetchResults } from './requestScheduler';
|
|
10
|
+
import { type StoreManager } from './storeManager';
|
|
11
|
+
import { StoreFetchError, StoreMutationError, type MaybeTSDFResult, type MutationSkipped, type StoreError, type StoreMutationErrorOptions, type TSDFStatus, type UnwrapTSDFResult, type ValidStoreState } from './utils/storeShared';
|
|
12
|
+
/** Lifecycle status for a document store. */
|
|
13
|
+
export type DocumentStatus = 'idle' | TSDFStatus;
|
|
14
|
+
/** Value returned by `DocumentStore.useDocument(...)`. */
|
|
15
|
+
export type TSDFUseDocumentReturn<Selected> = {
|
|
16
|
+
/** Hook-visible document status. */
|
|
17
|
+
status: DocumentStatus;
|
|
18
|
+
/** Selected document data. Defaults to the full document or `null`. */
|
|
19
|
+
data: Selected;
|
|
20
|
+
/** Last document fetch error, if any. */
|
|
21
|
+
error: StoreError | null;
|
|
22
|
+
/** Shorthand for `status === 'loading'`. Stays `false` while loaded data is `refetching`. */
|
|
23
|
+
isLoading: boolean;
|
|
24
|
+
/** Whether this result has local offline changes that still need to sync to the server. */
|
|
25
|
+
pendingSync: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type DocumentStoreState<State extends ValidStoreState> = {
|
|
28
|
+
/** Latest loaded document data, or `null` before the document is available. */
|
|
29
|
+
data: State | null;
|
|
30
|
+
/** Last fetch error for this document, when the latest fetch failed. */
|
|
31
|
+
error: StoreError | null;
|
|
32
|
+
/** Current fetch lifecycle status for the document. */
|
|
33
|
+
status: DocumentStatus;
|
|
34
|
+
/** Pending automatic refetch priority for stale data mounted by hooks. */
|
|
35
|
+
refetchOnMount: false | FetchType;
|
|
36
|
+
};
|
|
37
|
+
type DocumentStoreEvents = {
|
|
38
|
+
invalidateData: FetchType;
|
|
39
|
+
};
|
|
40
|
+
export type OnDocumentInvalidate = (priority: FetchType) => void;
|
|
41
|
+
/** Events emitted by document mutation lifecycle helpers. */
|
|
42
|
+
export type DocumentStoreStoreEvents = {
|
|
43
|
+
/** Emitted when a mutation begins executing */
|
|
44
|
+
mutationStart: {
|
|
45
|
+
mutationId: number;
|
|
46
|
+
};
|
|
47
|
+
/** Emitted when a mutation completes, fails, or is skipped */
|
|
48
|
+
mutationEnd: {
|
|
49
|
+
mutationId: number;
|
|
50
|
+
status: 'success' | 'error' | 'skipped';
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type InternalDocumentOfflineOperations<State extends ValidStoreState> = Record<string, AnyOfflineOperationDefinition<__LEGIT_ANY__>> & ([State] extends [never] ? never : unknown);
|
|
54
|
+
type DocumentOfflineOperationsConfig<State extends ValidStoreState> = InternalDocumentOfflineOperations<State> | null;
|
|
55
|
+
export type DocumentStoreOptions<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null, StorageState = unknown> = {
|
|
56
|
+
/**
|
|
57
|
+
* Stable id for this logical document store. Used for debug labels,
|
|
58
|
+
* persistence namespaces, and browser tab sync.
|
|
59
|
+
*/
|
|
60
|
+
id: string;
|
|
61
|
+
/** Shared global store manager providing session scoping and error normalization. */
|
|
62
|
+
storeManager: StoreManager;
|
|
63
|
+
fetchFn: (signal: AbortSignal) => Promise<MaybeTSDFResult<State>>;
|
|
64
|
+
/** Overrides the manager's default minimum interval between low-priority fetches for this store. */
|
|
65
|
+
lowPriorityThrottleMs?: number;
|
|
66
|
+
/** Overrides the manager's default coalescing window for this store. */
|
|
67
|
+
baseCoalescingWindowMs?: number;
|
|
68
|
+
/** Computes a per-fetch throttle for real-time updates using recent fetch cost and focus state. */
|
|
69
|
+
dynamicRealtimeThrottleMs?: (params: {
|
|
70
|
+
lastFetchDuration: number;
|
|
71
|
+
windowIsNotFocused: boolean;
|
|
72
|
+
}) => number;
|
|
73
|
+
/** Store-level focus revalidation policy. Overrides the manager default. */
|
|
74
|
+
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
75
|
+
/** Reconnect-specific cooldown. Defaults to 2,000ms. The first reconnect revalidates immediately;
|
|
76
|
+
* additional reconnects within the cooldown are coalesced into one trailing
|
|
77
|
+
* revalidation. Set to `0` to disable this cooldown. */
|
|
78
|
+
transportReconnectCooldownMs?: number;
|
|
79
|
+
/** Delay applied to medium-priority requests before they enter the scheduler. */
|
|
80
|
+
mediumPriorityDelayMs?: number;
|
|
81
|
+
/** Observes request scheduler lifecycle events for this store. */
|
|
82
|
+
onSchedulerEvent?: (event: RequestSchedulerEvents, data?: RequestSchedulerEventData) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Store-specific mutation error handler.
|
|
85
|
+
*
|
|
86
|
+
* Overrides the manager fallback. Use `null` to disable inherited mutation
|
|
87
|
+
* error handling for this store.
|
|
88
|
+
*/
|
|
89
|
+
onMutationError?: ((error: unknown, options: StoreMutationErrorOptions) => void) | null;
|
|
90
|
+
/** Indicates that fresh data arrives via a real-time channel. Defaults to `false`. The store
|
|
91
|
+
* skips the mount-time stale refetch since real-time pushes already cover
|
|
92
|
+
* revalidation. */
|
|
93
|
+
usesRealTimeUpdates?: boolean;
|
|
94
|
+
/** Opt-in persistent storage configuration. When provided, cached data is loaded
|
|
95
|
+
* from storage on first read and saved back on successful fetches.
|
|
96
|
+
* Session scoping always reuses this store manager's `getSessionKey`, and the
|
|
97
|
+
* persisted namespace always reuses this store's `id`. */
|
|
98
|
+
persistentStorage?: DocumentPersistentStorageConfig<State, StorageState, TOfflineOperations>;
|
|
99
|
+
};
|
|
100
|
+
type ResolvedDocumentOfflineOperations<TOfflineOperations> = TOfflineOperations extends null ? Record<never, never> : Exclude<TOfflineOperations, null>;
|
|
101
|
+
type DocumentUpdateState<State extends ValidStoreState> = (produceNewData: (draftData: State) => State | void | undefined) => boolean;
|
|
102
|
+
type DocumentMutationContext<State extends ValidStoreState> = {
|
|
103
|
+
/** Updates the current document state during the mutation. Returns `false` when no document data is loaded. */
|
|
104
|
+
updateState: DocumentUpdateState<State>;
|
|
105
|
+
/** Document state at the moment the mutation function runs. */
|
|
106
|
+
currentState: State | null;
|
|
107
|
+
};
|
|
108
|
+
type DocumentMutationArgsBase<State extends ValidStoreState, T> = {
|
|
109
|
+
/**
|
|
110
|
+
* Applies an optimistic document update before the mutation runs.
|
|
111
|
+
*
|
|
112
|
+
* Return `false` to cancel the mutation before the async mutation function is
|
|
113
|
+
* called.
|
|
114
|
+
*/
|
|
115
|
+
optimisticUpdate?: (currentState: State | null) => void | boolean;
|
|
116
|
+
/** Performs the server mutation. */
|
|
117
|
+
mutation: (ctx: DocumentMutationContext<State>) => Promise<T>;
|
|
118
|
+
/** Debounces mutations with the same context and payload. Superseded calls are skipped. */
|
|
119
|
+
debounce?: {
|
|
120
|
+
context: string;
|
|
121
|
+
payload: __LEGIT_ANY__;
|
|
122
|
+
ms: number;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Passes `{ silentErrors: true }` to `onMutationError`.
|
|
126
|
+
*
|
|
127
|
+
* The handler is still called so centralized logging and recovery can run,
|
|
128
|
+
* but UI handlers can suppress user-facing notifications.
|
|
129
|
+
*/
|
|
130
|
+
silentErrors?: boolean;
|
|
131
|
+
/** Invalidates the document after a successful online mutation. */
|
|
132
|
+
revalidateOnSuccess?: boolean;
|
|
133
|
+
};
|
|
134
|
+
type DocumentOnlineMutationArgs<State extends ValidStoreState, T> = DocumentMutationArgsBase<State, T> & {
|
|
135
|
+
offline?: undefined;
|
|
136
|
+
upload?: undefined;
|
|
137
|
+
};
|
|
138
|
+
type DocumentOfflineMutationArgs<State extends ValidStoreState, T, TOfflineOperations extends DocumentOfflineOperationsConfig<State>> = DocumentMutationArgsBase<State, T> & {
|
|
139
|
+
/**
|
|
140
|
+
* Queues this mutation through the store's registered offline operation when
|
|
141
|
+
* the session is offline or the direct request fails with an offline outage.
|
|
142
|
+
*/
|
|
143
|
+
offline: TOfflineOperations extends null ? never : OfflineMutationInput<Exclude<TOfflineOperations, null>>;
|
|
144
|
+
/** Files to attach if this mutation is queued for offline replay. */
|
|
145
|
+
upload?: OfflineMutationUploadsInput;
|
|
146
|
+
};
|
|
147
|
+
type DocumentPerformMutation<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State>> = {
|
|
148
|
+
/**
|
|
149
|
+
* Runs a document mutation with optional optimistic updates and revalidation.
|
|
150
|
+
*
|
|
151
|
+
* Returns the direct server result when offline replay is not configured for
|
|
152
|
+
* this call.
|
|
153
|
+
*/
|
|
154
|
+
<T>(args: DocumentOnlineMutationArgs<State, T>): Promise<ResultType<UnwrapTSDFResult<Awaited<T>>, StoreMutationError | MutationSkipped>>;
|
|
155
|
+
/**
|
|
156
|
+
* Runs a document mutation that may fall back to durable offline queueing.
|
|
157
|
+
*
|
|
158
|
+
* When the mutation is queued, the result is `{ kind: 'queued' }` instead of
|
|
159
|
+
* the server payload.
|
|
160
|
+
*/
|
|
161
|
+
<T>(args: DocumentOfflineMutationArgs<State, T, TOfflineOperations>): Promise<ResultType<OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
162
|
+
<T>(args: DocumentOnlineMutationArgs<State, T> | DocumentOfflineMutationArgs<State, T, TOfflineOperations>): Promise<ResultType<UnwrapTSDFResult<Awaited<T>> | OfflineMutationResult<UnwrapTSDFResult<Awaited<T>>>, StoreMutationError | MutationSkipped>>;
|
|
163
|
+
};
|
|
164
|
+
export type DocumentStore<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null> = {
|
|
165
|
+
/** Underlying t-state store containing the raw document cache state. */
|
|
166
|
+
store: Store<DocumentStoreState<State>>;
|
|
167
|
+
/** Invalidation event emitter used by hooks and integrations. */
|
|
168
|
+
events: Emitter<DocumentStoreEvents>;
|
|
169
|
+
/** Mutation lifecycle event emitter for observers and tests. */
|
|
170
|
+
storeEvents: Emitter<DocumentStoreStoreEvents>;
|
|
171
|
+
/** Whether the document has been explicitly invalidated and is awaiting refresh. */
|
|
172
|
+
readonly invalidationWasTriggered: boolean;
|
|
173
|
+
/** Schedules a document fetch with the requested priority. */
|
|
174
|
+
scheduleFetch: (fetchType: FetchType, options?: ScheduleFetchOptions) => ScheduleFetchResults;
|
|
175
|
+
/** Waits for a document fetch to settle and returns data or a fetch error. */
|
|
176
|
+
awaitFetch: (options?: {
|
|
177
|
+
timeoutMs?: number;
|
|
178
|
+
}) => Promise<{
|
|
179
|
+
data: State;
|
|
180
|
+
error: null;
|
|
181
|
+
} | {
|
|
182
|
+
data: null;
|
|
183
|
+
error: StoreFetchError;
|
|
184
|
+
}>;
|
|
185
|
+
/** Returns cached document data when usable, otherwise fetches it first. */
|
|
186
|
+
getDataFromStateOrFetch: (options?: {
|
|
187
|
+
/** When `true`, stale cached data is ignored and refetched before returning. Defaults to `false`. */
|
|
188
|
+
ignoreStaleState?: boolean;
|
|
189
|
+
timeoutMs?: number;
|
|
190
|
+
}) => Promise<ResultType<State, StoreFetchError>>;
|
|
191
|
+
/** Loads cached document data from persistent storage when available. */
|
|
192
|
+
preloadPersistentStorage: () => Promise<void>;
|
|
193
|
+
/** Marks the document stale and schedules refetches for active subscriptions. Defaults to `highPriority`. */
|
|
194
|
+
invalidateData: (
|
|
195
|
+
/** Fetch priority used for refetches triggered by this invalidation. Defaults to `highPriority`. */
|
|
196
|
+
priority?: FetchType) => void;
|
|
197
|
+
/** Applies an immutable update to the cached document data. */
|
|
198
|
+
updateState: DocumentUpdateState<State>;
|
|
199
|
+
/** Clears in-memory state and cancels store-local runtime state. */
|
|
200
|
+
reset: () => void;
|
|
201
|
+
/** Unregisters listeners and releases resources owned by this store. */
|
|
202
|
+
dispose: () => void;
|
|
203
|
+
/** Marks the document as mutating and returns a function that ends the mutation. */
|
|
204
|
+
startMutation: () => () => boolean;
|
|
205
|
+
/** Returns offline sync metadata for this store's tracked entity. */
|
|
206
|
+
getOfflineEntities: () => GlobalOfflineEntity[];
|
|
207
|
+
/** React hook subscribing to this store's offline entity metadata. */
|
|
208
|
+
useOfflineEntities: () => readonly GlobalOfflineEntity[];
|
|
209
|
+
/** React hook subscribing to manual offline resolutions for this store. */
|
|
210
|
+
useOfflineResolutions: () => readonly OfflineResolutionRecord[];
|
|
211
|
+
/** Returns manual offline resolutions for this store. */
|
|
212
|
+
getOfflineResolutions: () => OfflineResolutionRecord[];
|
|
213
|
+
/** Parses a stored offline conflict into the operation-specific conflict shape. */
|
|
214
|
+
parseOfflineResolutionConflict: (resolution: OfflineResolutionRecord) => ParsedOfflineResolutionConflictResultForStore<ResolvedDocumentOfflineOperations<TOfflineOperations>>;
|
|
215
|
+
/** Applies a retry/discard/requeue/commit action to a pending offline resolution. */
|
|
216
|
+
resolveOfflineResolution: <TName extends keyof ResolvedDocumentOfflineOperations<TOfflineOperations> & string>(resolutionId: string, operationName: TName, resolution: OfflineResolutionActionForOperation<ResolvedDocumentOfflineOperations<TOfflineOperations>, TName>) => Promise<void> | void;
|
|
217
|
+
useDocument: <Selected = State | null>(args?: {
|
|
218
|
+
/** Maps the document data before it is returned from the hook. */
|
|
219
|
+
selector?: (data: State | null) => Selected;
|
|
220
|
+
/** Disables this hook subscription and prevents automatic fetches. */
|
|
221
|
+
disabled?: boolean;
|
|
222
|
+
/** Marks this subscription as off-screen, lowering automatic fetch priority. */
|
|
223
|
+
isOffScreen?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Only fetches when the document is missing from state, skipping stale-state
|
|
226
|
+
* and invalidation refetches.
|
|
227
|
+
*/
|
|
228
|
+
disableRefetches?: boolean;
|
|
229
|
+
/** Prevents the automatic mount refetch for stale loaded data. */
|
|
230
|
+
disableRefetchOnMount?: boolean;
|
|
231
|
+
/** Returns `idle` instead of `loading` while the document has not been fetched. */
|
|
232
|
+
returnIdleStatus?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Unconditionally schedules a high-priority fetch on mount and reports
|
|
235
|
+
* `loading` until that refresh succeeds or fails, even when cached data
|
|
236
|
+
* exists. Use sparingly because each mount can cause an extra request.
|
|
237
|
+
*/
|
|
238
|
+
requireFreshData?: boolean;
|
|
239
|
+
/** Returns `refetching` instead of keeping `loaded` status during refetches. */
|
|
240
|
+
returnRefetchingStatus?: boolean;
|
|
241
|
+
}) => TSDFUseDocumentReturn<Selected>;
|
|
242
|
+
/** React hook that tracks whether a nested list item is still loading. */
|
|
243
|
+
useListItemIsLoading: (args: {
|
|
244
|
+
/** Unique identifier of the item within the document. */
|
|
245
|
+
itemId: string;
|
|
246
|
+
/** Extracts the item from the document data. */
|
|
247
|
+
selector: (data: State | null) => unknown;
|
|
248
|
+
/** Called if the item is still missing and no refetch is in progress. */
|
|
249
|
+
loadItemFallback?: () => void;
|
|
250
|
+
/** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
251
|
+
requireFreshData?: boolean;
|
|
252
|
+
}) => boolean;
|
|
253
|
+
/** React hook that tracks whether a nested list item has been deleted. */
|
|
254
|
+
useListItemIsDeleted: (args: {
|
|
255
|
+
/** Unique identifier of the item within the document. */
|
|
256
|
+
itemId: string;
|
|
257
|
+
/** Extracts the item from the document data. */
|
|
258
|
+
selector: (data: State | null) => unknown;
|
|
259
|
+
/** Called once when deletion is detected. */
|
|
260
|
+
onDelete?: () => void;
|
|
261
|
+
/** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
262
|
+
requireFreshData?: boolean;
|
|
263
|
+
}) => boolean;
|
|
264
|
+
/** React hook for selecting one nested list item plus loading/deleted flags. */
|
|
265
|
+
useListItem: <Selected>(args: {
|
|
266
|
+
/** Unique identifier of the item within the document. */
|
|
267
|
+
itemId: string;
|
|
268
|
+
/** Extracts and maps the item from the document data. */
|
|
269
|
+
selector: (data: State | null) => Selected;
|
|
270
|
+
/** Called if the item is still missing and no refetch is in progress. */
|
|
271
|
+
loadItemFallback?: () => void;
|
|
272
|
+
/** Called once when deletion is detected. */
|
|
273
|
+
onDelete?: () => void;
|
|
274
|
+
/** Requires a mount refresh before reporting ready. May cause an extra request. */
|
|
275
|
+
requireFreshData?: boolean;
|
|
276
|
+
}) => {
|
|
277
|
+
isLoading: boolean;
|
|
278
|
+
isDeleted: boolean;
|
|
279
|
+
data: Selected;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Runs the full mutation lifecycle: optional optimistic update, async
|
|
283
|
+
* mutation, rollback/error handling, revalidation, and offline queue fallback.
|
|
284
|
+
*/
|
|
285
|
+
performMutation: DocumentPerformMutation<State, TOfflineOperations>;
|
|
286
|
+
/** Notifies the store that a shared transport reconnected and should revalidate active data. */
|
|
287
|
+
onTransportReconnect: () => void;
|
|
288
|
+
};
|
|
289
|
+
export declare function createDocumentStore<State extends ValidStoreState, TOfflineOperations extends DocumentOfflineOperationsConfig<State> = null, StorageState = unknown>(storeOptions: DocumentStoreOptions<State, TOfflineOperations, StorageState>): DocumentStore<State, TOfflineOperations>;
|
|
290
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Combined hook that composes {@link useListItemIsLoading} and {@link useListItemIsDeleted},
|
|
2
|
+
* returning `{ isLoading, isDeleted, data }` for a single item within a list/collection. */
|
|
3
|
+
export declare function useListItem<Data>({ itemId, isRefetching, listIsLoading, itemExists, loadItemFallback, data, onDelete }: {
|
|
4
|
+
/** Unique identifier of the item */
|
|
5
|
+
itemId: string;
|
|
6
|
+
/** Whether the parent list/collection is currently refetching */
|
|
7
|
+
isRefetching: boolean;
|
|
8
|
+
/** Whether the parent list/collection is in the initial loading state */
|
|
9
|
+
listIsLoading: boolean;
|
|
10
|
+
/** Whether the item exists in the current data */
|
|
11
|
+
itemExists: boolean;
|
|
12
|
+
/** Called after a timeout if the item is still missing and no refetch is in progress */
|
|
13
|
+
loadItemFallback: () => void;
|
|
14
|
+
/** The selected/mapped data for this item */
|
|
15
|
+
data: Data;
|
|
16
|
+
/** Called once when the deletion is detected */
|
|
17
|
+
onDelete?: () => void;
|
|
18
|
+
}): {
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
isDeleted: boolean;
|
|
21
|
+
data: Data;
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Detects when a list item has been deleted by tracking transitions from
|
|
2
|
+
* existing to non-existing state. Does not trigger during initial loading —
|
|
3
|
+
* only fires after the item was previously found and then disappears. */
|
|
4
|
+
export declare function useListItemIsDeleted({ itemExists, listIsLoading, onDelete, itemId }: {
|
|
5
|
+
/** Unique identifier of the item */
|
|
6
|
+
itemId: string;
|
|
7
|
+
/** Whether the item exists in the current data — if the list hasn't loaded yet, the item won't exist in memory */
|
|
8
|
+
itemExists: boolean;
|
|
9
|
+
/** Whether the parent list/collection is in the initial loading state */
|
|
10
|
+
listIsLoading: boolean;
|
|
11
|
+
/** Called once when the deletion is detected */
|
|
12
|
+
onDelete?: () => void;
|
|
13
|
+
}): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Detects if a list item may be loading when there is no clear indication of
|
|
2
|
+
* the status of individual items (e.g. an item in a document collection that is
|
|
3
|
+
* loaded on demand). If the item is not found and no refetch is in progress,
|
|
4
|
+
* calls `loadItemFallback` after a short timeout. */
|
|
5
|
+
export declare function useListItemIsLoading({ listIsLoading, isRefetching, itemExists, loadItemFallback, itemId }: {
|
|
6
|
+
/** Unique identifier of the item. Pass `null` or `false` to disable. */
|
|
7
|
+
itemId: string | null | false;
|
|
8
|
+
/** Whether the parent list/collection is currently refetching */
|
|
9
|
+
isRefetching: boolean;
|
|
10
|
+
/** Whether the parent list/collection is in the initial loading state */
|
|
11
|
+
listIsLoading: boolean;
|
|
12
|
+
/** Whether the item exists in the current data — if the list hasn't loaded yet, the item won't exist in memory */
|
|
13
|
+
itemExists: boolean;
|
|
14
|
+
/** Called after a timeout if the item is still missing and no refetch is in progress */
|
|
15
|
+
loadItemFallback: () => void;
|
|
16
|
+
}): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createIndexedDbPersistentStorage, indexedDbPersistentStorage, type IndexedDbPersistentStorageOptions, } from './persistentStorage/indexedDbPersistentStorage';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AnyOfflineOperationDefinition } from '../persistentStorage/offline/types';
|
|
2
|
+
import type { TestOfflineTimelineEvent, TestSessionKeyChangedEvent } from './testTimelineTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps `getSessionKey` to notify when the session key changes.
|
|
5
|
+
* Test-only instrumentation — should be gated behind `import.meta.env.TEST`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function wrapGetSessionKeyForTest(getSessionKey: () => string | false, onSessionKeyChanged: ((event: TestSessionKeyChangedEvent) => void) | undefined): () => string | false;
|
|
8
|
+
/**
|
|
9
|
+
* Wraps each operation's `execute` with timeline event emissions.
|
|
10
|
+
* Test-only instrumentation — should be gated behind `import.meta.env.TEST`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wrapOfflineOperationsForTimeline(operations: Record<string, AnyOfflineOperationDefinition>, onEvent: (event: TestOfflineTimelineEvent) => void): Record<string, AnyOfflineOperationDefinition>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Predicate that matches every currently known payload.
|
|
3
|
+
*
|
|
4
|
+
* Use it with APIs that accept payload filters, such as
|
|
5
|
+
* `invalidateQueryAndItems`, `invalidateItem`, `getItemState`, and
|
|
6
|
+
* `getQueriesState`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GET_ALL: (...args: unknown[]) => true;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Context } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Context to set `isOffScreen` for all TSDF hooks within a subtree.
|
|
4
|
+
*
|
|
5
|
+
* When `true`, hooks wrapped by this context will not trigger data fetching or
|
|
6
|
+
* respond to invalidation events, unless overridden by an explicit `isOffScreen`
|
|
7
|
+
* option passed directly to the hook.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <IsOffScreenContext.Provider value={!isTabActive}>
|
|
12
|
+
* <MyComponent />
|
|
13
|
+
* </IsOffScreenContext.Provider>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const IsOffScreenContext: Context<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Store } from 't-state';
|
|
2
|
+
import { type OfflineAwareFetchController } from '../persistentStorage/offline/fetchRuntime';
|
|
3
|
+
import { BatchRequest, FetchContext } from '../requestScheduler';
|
|
4
|
+
import { type MaybeTSDFResult, StoreError, ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
5
|
+
import { type PartialResourcesConfig, type TSFDListQueryState } from './types';
|
|
6
|
+
type ItemFetchData<ItemPayload extends ValidPayload> = {
|
|
7
|
+
payload: ItemPayload;
|
|
8
|
+
fields?: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare function executeItemBatchFetch<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>(requests: BatchRequest<ItemFetchData<ItemPayload>>[], fetchCtx: FetchContext, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, itemKeyToPayload: Map<string, ItemPayload>, fetchItemFn: (params: ItemPayload, options: {
|
|
11
|
+
signal: AbortSignal;
|
|
12
|
+
fields?: string[];
|
|
13
|
+
}) => Promise<MaybeTSDFResult<ItemState>>, batchFetchItemFn: ((requests: {
|
|
14
|
+
payload: ItemPayload;
|
|
15
|
+
fields?: string[];
|
|
16
|
+
}[], options: {
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
batchKey: string;
|
|
19
|
+
}) => Promise<MaybeTSDFResult<Map<ItemPayload, MaybeTSDFResult<ItemState> | Error>>>) | undefined, errorNormalizer: (exception: Error) => StoreError, partialResources?: PartialResourcesConfig<ItemState>, batchKey?: string, offlineController?: OfflineAwareFetchController | null): Promise<Map<string, boolean>>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Store } from 't-state';
|
|
2
|
+
import { type OfflineAwareFetchController } from '../persistentStorage/offline/fetchRuntime';
|
|
3
|
+
import { BatchRequest, FetchContext } from '../requestScheduler';
|
|
4
|
+
import { StoreError, ValidPayload, ValidStoreState } from '../utils/storeShared';
|
|
5
|
+
import { NormalizedFetchListFn } from './createFetchApi';
|
|
6
|
+
import { type OffsetPaginationConfig, type PartialResourcesConfig, type QueryFetchPayload, type TSFDListQueryState } from './types';
|
|
7
|
+
export declare function executeQueryFetch<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload>(requests: BatchRequest<QueryFetchPayload<QueryPayload>>[], fetchCtx: FetchContext, store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>, normalizedFetchListFn: NormalizedFetchListFn<ItemState, QueryPayload, ItemPayload>, errorNormalizer: (exception: Error) => StoreError, getItemKey: (params: ItemPayload) => string, updateItemSchedulerTiming: (itemKey: string, startTime: number) => void, partialResources?: PartialResourcesConfig<ItemState>, offsetPagination?: OffsetPaginationConfig, offlineController?: OfflineAwareFetchController | null): Promise<Map<string, boolean>>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { FetchType } from '../requestScheduler';
|
|
2
|
+
import type { ValidStoreState } from '../utils/storeShared';
|
|
3
|
+
import type { ItemLoadedFields, PartialResourcesConfig } from './types';
|
|
4
|
+
export declare function hasFullyLoadedFields(loadedFields: ItemLoadedFields | undefined): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a snapshot should be treated as holding every field of the item.
|
|
7
|
+
* True when the tracked `loadedFields` is the `'*'` sentinel, or when the
|
|
8
|
+
* snapshot carries no field metadata but `inferFields` reports the item is
|
|
9
|
+
* complete (`'*'`) — e.g. manually inserted items, offline optimistic rows, or
|
|
10
|
+
* persisted fallback snapshots.
|
|
11
|
+
*/
|
|
12
|
+
export declare function snapshotIsFullyLoaded<ItemState extends ValidStoreState>(loadedFields: ItemLoadedFields | undefined, item: ItemState | null | undefined, inferFields: (item: ItemState) => ItemLoadedFields): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Like {@link snapshotIsFullyLoaded}, but also returns `false` when the item is
|
|
15
|
+
* awaiting a full ('*') re-fetch after a full invalidation. A fully-loaded
|
|
16
|
+
* snapshot that was fully invalidated has its `loadedFields` reset while the
|
|
17
|
+
* (now stale) item data is still present, so `inferFields` would otherwise
|
|
18
|
+
* wrongly vouch for it as complete.
|
|
19
|
+
*/
|
|
20
|
+
export declare function snapshotIsFullyLoadedAndFresh<ItemState extends ValidStoreState>(itemKey: string, loadedFields: ItemLoadedFields | undefined, item: ItemState | null | undefined, inferFields: (item: ItemState) => ItemLoadedFields, itemsPendingFullInvalidation: Map<string, FetchType>): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Missing requested fields for an item snapshot, letting `inferFields` vouch
|
|
23
|
+
* for metadata-free item data (e.g. client-created items) — except for stale
|
|
24
|
+
* fields awaiting a re-fetch after an invalidation (per-field or full), when
|
|
25
|
+
* the item's stale data must not be vouched for.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getStaleOrMissingRequestedFields<ItemState extends ValidStoreState>(itemKey: string, loadedFields: ItemLoadedFields | undefined, item: ItemState | null | undefined, requestedFields: readonly string[], inferFields: (item: ItemState) => ItemLoadedFields, itemsPendingFullInvalidation: Map<string, FetchType>, pendingInvalidationFields: readonly string[]): string[];
|
|
28
|
+
export declare function fallbackItemHasRequestedFields<ItemState extends ValidStoreState>(fallbackItemState: {
|
|
29
|
+
item: ItemState | null | undefined;
|
|
30
|
+
loadedFields: ItemLoadedFields | undefined;
|
|
31
|
+
} | undefined, requestedFields: readonly string[], inferFields: (item: ItemState) => ItemLoadedFields): boolean;
|
|
32
|
+
export declare function getFallbackMissingRequestedFields<ItemState extends ValidStoreState>(fallbackItemState: {
|
|
33
|
+
item: ItemState | null | undefined;
|
|
34
|
+
loadedFields: ItemLoadedFields | undefined;
|
|
35
|
+
} | undefined, requestedFields: readonly string[], inferFields: (item: ItemState) => ItemLoadedFields): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Fields from `requestedFields` that are genuinely absent from the snapshot —
|
|
38
|
+
* not tracked as loaded, not vouched by `inferFields`, and not merely stale
|
|
39
|
+
* (awaiting an invalidation re-fetch). Stale fields were loaded when their
|
|
40
|
+
* invalidation was recorded, so their stale data is still present and may stay
|
|
41
|
+
* visible while the re-fetch runs; only genuinely absent fields have no data
|
|
42
|
+
* to show. Staleness is proven either by the field being in the unresolved
|
|
43
|
+
* pending invalidation list, or — for an item with data still present — by the
|
|
44
|
+
* unresolved full ('*') invalidation marker, which means the snapshot was
|
|
45
|
+
* complete when invalidated.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getGenuinelyMissingRequestedFields<ItemState extends ValidStoreState>(itemKey: string, fallbackItemState: {
|
|
48
|
+
item: ItemState | null | undefined;
|
|
49
|
+
loadedFields: ItemLoadedFields | undefined;
|
|
50
|
+
} | undefined, requestedFields: readonly string[], inferFields: (item: ItemState) => ItemLoadedFields, itemsPendingFullInvalidation: Map<string, FetchType>, unresolvedPendingInvalidationFields: readonly string[]): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Highest tracked invalidation priority owed to `requestedFields` (or to any
|
|
53
|
+
* unresolved field when `requestedFields` is `undefined` — an unbounded hook).
|
|
54
|
+
* Fields without a tracked priority (e.g. invalidations adopted from another
|
|
55
|
+
* tab via state sync) contribute nothing, so an all-unknown result stays
|
|
56
|
+
* `undefined` and callers treat the refetch as untracked (ungated, immediate).
|
|
57
|
+
* The full-invalidation marker owes a requested field only when that field is
|
|
58
|
+
* neither reloaded nor covered by a per-field entry (an entry supersedes the
|
|
59
|
+
* marker for its field). A `'*'`-loaded item has already resolved the marker
|
|
60
|
+
* (it only awaits pruning), so the marker contributes nothing then.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getPendingInvalidationPriorityOfFields(requestedFields: readonly string[] | undefined, loadedFields: ItemLoadedFields | undefined, unresolvedPendingInvalidationFields: readonly string[], pendingFieldPriorities: Map<string, FetchType | null> | undefined, fullInvalidationPriority: FetchType | undefined): FetchType | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the fields from `requestedFields` that are not yet present in
|
|
65
|
+
* `loadedFields`. When either argument is `undefined` or empty, returns `[]`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function excludeLoadedFields(loadedFields: ItemLoadedFields | undefined, requestedFields: readonly string[] | undefined): string[];
|
|
68
|
+
/**
|
|
69
|
+
* Applies a fetched item to the state using partial-resource merging. Merges
|
|
70
|
+
* `data` into any existing item and updates `itemLoadedFields` to reflect the
|
|
71
|
+
* fields now available. When `fields` is empty the loaded-field set is
|
|
72
|
+
* replaced with the keys of the merged item (a full fetch is assumed).
|
|
73
|
+
*/
|
|
74
|
+
export declare function applyPartialItemMerge<ItemState extends ValidStoreState>(draft: {
|
|
75
|
+
items: Record<string, ItemState | null>;
|
|
76
|
+
itemLoadedFields: Record<string, ItemLoadedFields>;
|
|
77
|
+
}, itemKey: string, data: ItemState, fields: string[] | undefined, partialResources: PartialResourcesConfig<ItemState>): ItemState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|