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,295 @@
|
|
|
1
|
+
import { type __LEGIT_ANY__ } from '@ls-stack/utils/saferTyping';
|
|
2
|
+
import { createListQueryStore, type ListQueryStoreOptions } from '../../src/listQueryStore/listQueryStore';
|
|
3
|
+
import type { DerivedQueriesConfig, OffsetPaginationConfig, PartialResourcesConfig } from '../../src/listQueryStore/types';
|
|
4
|
+
import type { AnyOfflineOperationDefinition, ListQueryOfflineEntityRef } from '../../src/persistentStorage/offline/types';
|
|
5
|
+
import type { ListQueryPersistentStorageConfig, StorageAdapter } from '../../src/persistentStorage/types';
|
|
6
|
+
import type { FetchType } from '../../src/requestScheduler';
|
|
7
|
+
import { type StoreManager } from '../../src/storeManager';
|
|
8
|
+
import type { BrowserTabsPriorityTimings } from '../../src/utils/browserTabsPriority';
|
|
9
|
+
import type { BrowserTabsTransportFactory } from '../../src/utils/browserTabsSync';
|
|
10
|
+
import type { BlockWindowCloseHandler } from '../../src/utils/performMutation';
|
|
11
|
+
import { type FilterOperator, type ServerTableSharedState } from './serverTableMock';
|
|
12
|
+
type ListQueryItemPayload = string;
|
|
13
|
+
export type Row = {
|
|
14
|
+
id: number;
|
|
15
|
+
name: string;
|
|
16
|
+
age?: number;
|
|
17
|
+
city?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
type TestListQueryOfflineOperationsRegistry<TRow extends Row> = Record<string, AnyOfflineOperationDefinition & {
|
|
21
|
+
getEntityRefs: (ctx: {
|
|
22
|
+
input: __LEGIT_ANY__;
|
|
23
|
+
}) => ListQueryOfflineEntityRef<ListQueryItemPayload>[];
|
|
24
|
+
}> & ([TRow] extends [never] ? never : unknown);
|
|
25
|
+
type TestListQueryOfflineOperationsConfig<TRow extends Row> = TestListQueryOfflineOperationsRegistry<TRow> | null;
|
|
26
|
+
export type ListQueryParams = {
|
|
27
|
+
tableId: string;
|
|
28
|
+
filters?: FilterOperator[];
|
|
29
|
+
};
|
|
30
|
+
type TestListQueryPersistentStorageConfig<TRow extends Row, StorageState, TOfflineOperations extends TestListQueryOfflineOperationsConfig<TRow>> = ListQueryPersistentStorageConfig<TRow, ListQueryParams, ListQueryItemPayload, StorageState, TOfflineOperations>;
|
|
31
|
+
type ListQuerySnapshotConfig = {
|
|
32
|
+
tables?: string[];
|
|
33
|
+
items?: string[];
|
|
34
|
+
queries?: ListQueryParams[];
|
|
35
|
+
};
|
|
36
|
+
export type ListQueryStoreTestScenario =
|
|
37
|
+
/** App just opened, no data fetched yet. */
|
|
38
|
+
'idle'
|
|
39
|
+
/**
|
|
40
|
+
* App already opened before and data was fetched successfully.
|
|
41
|
+
* Using the default lowPriorityThrottleMs (200ms) it will still trigger a refetch on mount as initial system time is set to 10 seconds in the past.
|
|
42
|
+
*/
|
|
43
|
+
| {
|
|
44
|
+
loaded: ListQuerySnapshotConfig;
|
|
45
|
+
};
|
|
46
|
+
export type Tables<TRow extends Row = Row> = Record<string, TRow[]>;
|
|
47
|
+
export declare function createSharedListQueryServerTableState<TRow extends Row>(tables: Tables<TRow>): ServerTableSharedState<TRow>;
|
|
48
|
+
export declare function createListQueryStoreTestEnv<TRow extends Row = Row, TPartialResources extends boolean = false, TOffsetPagination extends boolean = false, TOfflineOperations extends TestListQueryOfflineOperationsConfig<TRow> = null, StorageState = unknown>(serverInitialData: Tables<TRow>, { id, getSessionKey: getSessionKeyOption, storeManager, sharedServerTableState, browserTabsTransportFactory, testBrowserTabId, browserTabsLeadershipTimings, bindFocusController, dynamicRealtimeThrottleMs, revalidateOnWindowFocus, transportReconnectCooldownMs, baseCoalescingWindowMs, backgroundCoalescingDelayMs, mediumPriorityDelayMs, defaultQuerySize, lowPriorityThrottleMs, testScenario, usesRealTimeUpdates, useBatchFetch, maxItemBatchSize, maxItems, maxQueries, onStateCleanup, getItemsBatchKey, disableFetchItemFn, optimisticListUpdates, partialResources, derivedQueries, offsetPagination, blockWindowClose, persistentStorage, storageAdapter, __DANGEROUS_IGNORE_INITIAL_TIME_CHECK__ }?: {
|
|
49
|
+
id?: string;
|
|
50
|
+
getSessionKey?: () => string | false;
|
|
51
|
+
sharedServerTableState?: ServerTableSharedState<TRow>;
|
|
52
|
+
browserTabsTransportFactory?: BrowserTabsTransportFactory;
|
|
53
|
+
testBrowserTabId?: string;
|
|
54
|
+
browserTabsLeadershipTimings?: BrowserTabsPriorityTimings;
|
|
55
|
+
/** Binds this env to a focus coordinator. Provides per-tab `getWindowIsFocused` and `onWindowFocus`/`onWindowBlur` for scoped focus events. */
|
|
56
|
+
bindFocusController?: {
|
|
57
|
+
getWindowIsFocused: () => boolean;
|
|
58
|
+
onWindowFocus: (handler: () => void) => () => void;
|
|
59
|
+
onWindowBlur: (handler: () => void) => () => void;
|
|
60
|
+
};
|
|
61
|
+
dynamicRealtimeThrottleMs?: (params: {
|
|
62
|
+
lastFetchDuration: number;
|
|
63
|
+
windowIsNotFocused: boolean;
|
|
64
|
+
}) => number;
|
|
65
|
+
revalidateOnWindowFocus?: boolean | (() => boolean);
|
|
66
|
+
transportReconnectCooldownMs?: number;
|
|
67
|
+
baseCoalescingWindowMs?: number;
|
|
68
|
+
backgroundCoalescingDelayMs?: number;
|
|
69
|
+
mediumPriorityDelayMs?: number;
|
|
70
|
+
defaultQuerySize?: number;
|
|
71
|
+
lowPriorityThrottleMs?: number;
|
|
72
|
+
testScenario?: ListQueryStoreTestScenario;
|
|
73
|
+
usesRealTimeUpdates?: boolean;
|
|
74
|
+
/** Enable batch fetch mode - uses batchFetchItemFn instead of per-item fetchItemFn */
|
|
75
|
+
useBatchFetch?: boolean;
|
|
76
|
+
/** Max items per batch. Defaults to 50 in the store when omitted. Only used when useBatchFetch is true. */
|
|
77
|
+
maxItemBatchSize?: number;
|
|
78
|
+
maxItems?: number;
|
|
79
|
+
maxQueries?: number;
|
|
80
|
+
onStateCleanup?: ListQueryStoreOptions<TRow, ListQueryParams, ListQueryItemPayload, TPartialResources, TOffsetPagination>['onStateCleanup'];
|
|
81
|
+
/** Optional function to group batch fetches by key */
|
|
82
|
+
getItemsBatchKey?: (payload: string) => string | false;
|
|
83
|
+
disableFetchItemFn?: boolean;
|
|
84
|
+
optimisticListUpdates?: Parameters<typeof createListQueryStore<TRow, ListQueryParams, ListQueryItemPayload>>[0]['optimisticListUpdates'];
|
|
85
|
+
partialResources?: PartialResourcesConfig<TRow>;
|
|
86
|
+
derivedQueries?: DerivedQueriesConfig<TRow, ListQueryParams, ListQueryItemPayload>;
|
|
87
|
+
offsetPagination?: OffsetPaginationConfig;
|
|
88
|
+
blockWindowClose?: BlockWindowCloseHandler;
|
|
89
|
+
persistentStorage?: TestListQueryPersistentStorageConfig<TRow, StorageState, TOfflineOperations>;
|
|
90
|
+
storageAdapter?: StorageAdapter;
|
|
91
|
+
__DANGEROUS_IGNORE_INITIAL_TIME_CHECK__?: boolean;
|
|
92
|
+
storeManager?: StoreManager;
|
|
93
|
+
}): {
|
|
94
|
+
apiStore: import("../../src/main").ListQueryStore<TRow, ListQueryParams, string, TPartialResources, TOfflineOperations>;
|
|
95
|
+
store: import("t-state").Store<import("../../src/main").TSFDListQueryState<TRow, ListQueryParams, string>>;
|
|
96
|
+
serverTable: Omit<{
|
|
97
|
+
fetch: (itemId: string, signal?: AbortSignal | undefined, options?: {
|
|
98
|
+
fields?: string[] | undefined;
|
|
99
|
+
} | undefined) => Promise<TRow>;
|
|
100
|
+
list: (options?: {
|
|
101
|
+
offset?: number | undefined;
|
|
102
|
+
limit?: number | undefined;
|
|
103
|
+
itemIds?: string[] | undefined;
|
|
104
|
+
filters?: FilterOperator[] | undefined;
|
|
105
|
+
tableId?: string | undefined;
|
|
106
|
+
fields?: string[] | undefined;
|
|
107
|
+
batchKey?: string | undefined;
|
|
108
|
+
} | undefined, signal?: AbortSignal | undefined) => Promise<{
|
|
109
|
+
items: {
|
|
110
|
+
itemId: string;
|
|
111
|
+
data: TRow;
|
|
112
|
+
}[];
|
|
113
|
+
hasMore: boolean;
|
|
114
|
+
}>;
|
|
115
|
+
listSync: (options?: {
|
|
116
|
+
offset?: number | undefined;
|
|
117
|
+
limit?: number | undefined;
|
|
118
|
+
itemIds?: string[] | undefined;
|
|
119
|
+
filters?: FilterOperator[] | undefined;
|
|
120
|
+
tableId?: string | undefined;
|
|
121
|
+
fields?: string[] | undefined;
|
|
122
|
+
batchKey?: string | undefined;
|
|
123
|
+
} | undefined) => {
|
|
124
|
+
items: {
|
|
125
|
+
itemId: string;
|
|
126
|
+
data: TRow;
|
|
127
|
+
}[];
|
|
128
|
+
hasMore: boolean;
|
|
129
|
+
};
|
|
130
|
+
get: (itemId: string) => TRow | undefined;
|
|
131
|
+
getAll: () => Record<string, TRow>;
|
|
132
|
+
getByPrefix: (prefix: string) => {
|
|
133
|
+
itemId: string;
|
|
134
|
+
data: TRow;
|
|
135
|
+
}[];
|
|
136
|
+
entries: () => [string, TRow][];
|
|
137
|
+
delayedSetItem(itemId: string, data: TRow, options?: {
|
|
138
|
+
durationMs?: number | undefined;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
delayedUpdateItem(itemId: string, data: Partial<TRow>, options?: {
|
|
141
|
+
durationMs?: number | undefined;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
delayedRemoveItem(itemId: string, options?: {
|
|
144
|
+
durationMs?: number | undefined;
|
|
145
|
+
}): Promise<void>;
|
|
146
|
+
setItem: (itemId: string, data: TRow, options?: {
|
|
147
|
+
triggerRTUEvent?: "for_all_items" | boolean | undefined;
|
|
148
|
+
prepend?: boolean | undefined;
|
|
149
|
+
} | undefined) => void;
|
|
150
|
+
removeItem: (itemId: string) => void;
|
|
151
|
+
updateItem: (itemId: string, data: Partial<TRow>) => void;
|
|
152
|
+
emulateClientMutation: (itemId: string, newData: TRow, options?: {
|
|
153
|
+
duration?: number | undefined;
|
|
154
|
+
setDataAt?: number | undefined;
|
|
155
|
+
triggerRTUEvent?: boolean | undefined;
|
|
156
|
+
addServerDataChangeAction?: boolean | undefined;
|
|
157
|
+
mutationId?: string | number | undefined;
|
|
158
|
+
}) => Promise<TRow>;
|
|
159
|
+
addItem: (itemId: string, data: TRow, options?: {
|
|
160
|
+
duration?: number | undefined;
|
|
161
|
+
setDataAt?: number | undefined;
|
|
162
|
+
triggerRTUEvent?: boolean | undefined;
|
|
163
|
+
addServerDataChangeAction?: boolean | undefined;
|
|
164
|
+
mutationId?: string | number | undefined;
|
|
165
|
+
}) => Promise<void>;
|
|
166
|
+
addItemWithAutoGeneratedKey: (tableId: string, createData: (id: number, itemId: string) => TRow, options?: {
|
|
167
|
+
duration?: number | undefined;
|
|
168
|
+
setDataAt?: number | undefined;
|
|
169
|
+
triggerRTUEvent?: boolean | undefined;
|
|
170
|
+
addServerDataChangeAction?: boolean | undefined;
|
|
171
|
+
mutationId?: string | number | undefined;
|
|
172
|
+
}) => Promise<{
|
|
173
|
+
id: number;
|
|
174
|
+
itemId: string;
|
|
175
|
+
data: TRow;
|
|
176
|
+
}>;
|
|
177
|
+
deleteItem: (itemId: string, options?: {
|
|
178
|
+
duration?: number | undefined;
|
|
179
|
+
setDataAt?: number | undefined;
|
|
180
|
+
triggerRTUEvent?: boolean | undefined;
|
|
181
|
+
addServerDataChangeAction?: boolean | undefined;
|
|
182
|
+
mutationId?: string | number | undefined;
|
|
183
|
+
}) => Promise<void>;
|
|
184
|
+
wsEvents: import("evtmitter").Emitter<{
|
|
185
|
+
data_changed: {
|
|
186
|
+
itemId: string;
|
|
187
|
+
data: TRow;
|
|
188
|
+
};
|
|
189
|
+
item_deleted: {
|
|
190
|
+
itemId: string;
|
|
191
|
+
};
|
|
192
|
+
item_added: {
|
|
193
|
+
itemId: string;
|
|
194
|
+
data: TRow;
|
|
195
|
+
};
|
|
196
|
+
list_changed: undefined;
|
|
197
|
+
}>;
|
|
198
|
+
getItemHistory: (itemId: string) => TRow[];
|
|
199
|
+
setFetchDurations(itemId: string, ...durations: number[]): void;
|
|
200
|
+
setNextFetchError(itemId: string, error: string | {
|
|
201
|
+
message: string;
|
|
202
|
+
path?: string | undefined;
|
|
203
|
+
method?: "DELETE" | "GET" | "PATCH" | "POST" | "PUT" | undefined;
|
|
204
|
+
code?: number | undefined;
|
|
205
|
+
}): void;
|
|
206
|
+
addListFetchStartDelay(delayMs: number): void;
|
|
207
|
+
setNextListFetchError(error: string | {
|
|
208
|
+
message: string;
|
|
209
|
+
path?: string | undefined;
|
|
210
|
+
method?: "DELETE" | "GET" | "PATCH" | "POST" | "PUT" | undefined;
|
|
211
|
+
code?: number | undefined;
|
|
212
|
+
}): void;
|
|
213
|
+
getNextFetchError(itemId: string): {
|
|
214
|
+
message: string;
|
|
215
|
+
path?: string | undefined;
|
|
216
|
+
method?: "DELETE" | "GET" | "PATCH" | "POST" | "PUT" | undefined;
|
|
217
|
+
code?: number | undefined;
|
|
218
|
+
} | undefined;
|
|
219
|
+
readonly numOfStartedFetches: number;
|
|
220
|
+
readonly numOfFinishedFetches: number;
|
|
221
|
+
fetchHistory: ({
|
|
222
|
+
type: "fetch";
|
|
223
|
+
itemId: string;
|
|
224
|
+
fields: string[] | undefined;
|
|
225
|
+
result: "aborted" | "error" | TRow;
|
|
226
|
+
startedAt: number;
|
|
227
|
+
duration: number;
|
|
228
|
+
} | {
|
|
229
|
+
type: "list";
|
|
230
|
+
itemIds: string[] | undefined;
|
|
231
|
+
offset: number;
|
|
232
|
+
limit: number | undefined;
|
|
233
|
+
fields: string[] | undefined;
|
|
234
|
+
filters: FilterOperator[] | undefined;
|
|
235
|
+
batchKey: string | undefined;
|
|
236
|
+
startedAt: number;
|
|
237
|
+
duration: number;
|
|
238
|
+
results: "aborted" | {
|
|
239
|
+
itemId: string;
|
|
240
|
+
data: "error" | TRow;
|
|
241
|
+
}[];
|
|
242
|
+
})[];
|
|
243
|
+
clearFetchHistory(): void;
|
|
244
|
+
getRequestHistory(fetchType?: "all" | "item" | "list", options?: {
|
|
245
|
+
includeTime?: boolean | undefined;
|
|
246
|
+
} | undefined): {
|
|
247
|
+
_type: "item" | "list" | undefined;
|
|
248
|
+
payload: unknown;
|
|
249
|
+
time?: string | undefined;
|
|
250
|
+
returned_items?: number | undefined;
|
|
251
|
+
}[];
|
|
252
|
+
}, "wsEvents">;
|
|
253
|
+
readonly uiChanges: Record<string, unknown>[];
|
|
254
|
+
readonly actions: {
|
|
255
|
+
action: string;
|
|
256
|
+
time: number;
|
|
257
|
+
uiValue: unknown;
|
|
258
|
+
actionValue?: unknown;
|
|
259
|
+
id?: string | number | undefined;
|
|
260
|
+
itemId?: string | undefined;
|
|
261
|
+
itemUiValues?: Record<string, unknown> | undefined;
|
|
262
|
+
}[];
|
|
263
|
+
trackItemUI: (itemId: string, value: unknown) => unknown;
|
|
264
|
+
addTimelineComments: (reference: "afterLastAction" | "beforeNextAction" | {
|
|
265
|
+
action: string;
|
|
266
|
+
id?: string | number | undefined;
|
|
267
|
+
}, comments: (string | {
|
|
268
|
+
comment: string;
|
|
269
|
+
deltaMs?: number | undefined;
|
|
270
|
+
})[]) => void;
|
|
271
|
+
getItemKey: (tableId: string, rowId: number) => string;
|
|
272
|
+
getStoreItemKey: (tableId: string, rowId: number) => string;
|
|
273
|
+
getStoreItemKeyFromRaw: (rawKey: string) => string;
|
|
274
|
+
getQueryKey: (params: ListQueryParams) => string;
|
|
275
|
+
getItemQueryState: (rawItemKey: string) => import("../../src/main").TSDFItemQuery<string> | null | undefined;
|
|
276
|
+
scheduleFetch: (fetchType: FetchType, params: ListQueryParams, size?: number | undefined, options?: {
|
|
277
|
+
mediumPriorityDelayMs?: number | undefined;
|
|
278
|
+
} | undefined) => "scheduled" | "skipped" | "started" | "triggered";
|
|
279
|
+
scheduleItemFetch: (fetchType: FetchType, itemPayload: string, options?: {
|
|
280
|
+
mediumPriorityDelayMs?: number | undefined;
|
|
281
|
+
} | undefined) => "scheduled" | "skipped" | "started" | "triggered";
|
|
282
|
+
forceListUpdate: (params: ListQueryParams) => "started" | "triggered";
|
|
283
|
+
performClientItemUpdateAction: (itemId: string, newValue: Partial<TRow>, { withRevalidation, withOptimisticUpdate, duration, triggerRTU, addServerDataChangeAction, error, }?: {
|
|
284
|
+
withRevalidation?: boolean | undefined;
|
|
285
|
+
withOptimisticUpdate?: boolean | undefined;
|
|
286
|
+
duration?: number | undefined;
|
|
287
|
+
triggerRTU?: boolean | undefined;
|
|
288
|
+
addServerDataChangeAction?: boolean | undefined;
|
|
289
|
+
error?: string | undefined;
|
|
290
|
+
}) => Promise<import("t-result").Result<unknown, import("../../src/main").MutationSkipped | import("../../src/main").StoreMutationError>>;
|
|
291
|
+
readonly timelineString: string;
|
|
292
|
+
clearTimeline(): void;
|
|
293
|
+
getRelativeTime: () => number;
|
|
294
|
+
};
|
|
295
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
type MockBrowserOpfsBaseOperation = {
|
|
2
|
+
path: string;
|
|
3
|
+
startedTime: number;
|
|
4
|
+
time: number;
|
|
5
|
+
};
|
|
6
|
+
type MockBrowserOpfsScopeOperation = MockBrowserOpfsBaseOperation & {
|
|
7
|
+
created: boolean;
|
|
8
|
+
exists: boolean;
|
|
9
|
+
type: 'ensureDir' | 'openDir';
|
|
10
|
+
};
|
|
11
|
+
type MockBrowserOpfsFileOperation = MockBrowserOpfsBaseOperation & {
|
|
12
|
+
created: boolean;
|
|
13
|
+
exists: boolean;
|
|
14
|
+
type: 'ensureFile' | 'openFile';
|
|
15
|
+
};
|
|
16
|
+
type MockBrowserOpfsReadWriteOperation = MockBrowserOpfsBaseOperation & ({
|
|
17
|
+
readRaw: string;
|
|
18
|
+
type: 'readFile';
|
|
19
|
+
valueByteSize: number;
|
|
20
|
+
} | {
|
|
21
|
+
writeRaw: string;
|
|
22
|
+
type: 'writeFile';
|
|
23
|
+
valueChanged: boolean;
|
|
24
|
+
valueByteSizeAfter: number;
|
|
25
|
+
valueByteSizeBefore: number;
|
|
26
|
+
} | {
|
|
27
|
+
errorName: string;
|
|
28
|
+
phase: 'close' | 'createWritable';
|
|
29
|
+
type: 'writeFileFailed';
|
|
30
|
+
});
|
|
31
|
+
type MockBrowserOpfsDeleteFileOperation = MockBrowserOpfsBaseOperation & {
|
|
32
|
+
exists: boolean;
|
|
33
|
+
type: 'deleteFile';
|
|
34
|
+
};
|
|
35
|
+
type MockBrowserOpfsListDirOperation = MockBrowserOpfsBaseOperation & {
|
|
36
|
+
entries: string[];
|
|
37
|
+
method: 'entries' | 'keys' | 'values';
|
|
38
|
+
type: 'listDir';
|
|
39
|
+
};
|
|
40
|
+
type MockBrowserOpfsDeleteDirOperation = MockBrowserOpfsBaseOperation & {
|
|
41
|
+
deleted: boolean;
|
|
42
|
+
exists: boolean;
|
|
43
|
+
recursive: boolean;
|
|
44
|
+
type: 'deleteDir';
|
|
45
|
+
};
|
|
46
|
+
export type MockBrowserOpfsOperation = MockBrowserOpfsScopeOperation | MockBrowserOpfsFileOperation | MockBrowserOpfsReadWriteOperation | MockBrowserOpfsDeleteFileOperation | MockBrowserOpfsListDirOperation | MockBrowserOpfsDeleteDirOperation;
|
|
47
|
+
export declare class MockBrowserOpfsEnvironment {
|
|
48
|
+
#private;
|
|
49
|
+
readonly operations: MockBrowserOpfsOperation[];
|
|
50
|
+
getRootDirectoryHandle(): Promise<FileSystemDirectoryHandle>;
|
|
51
|
+
clearInstrumentation(): void;
|
|
52
|
+
hasPendingLatencies(): boolean;
|
|
53
|
+
flushLatencies(): Promise<void>;
|
|
54
|
+
setReadDelay(pathPrefix: string, delayMs: number): void;
|
|
55
|
+
setDynamicReadDelay(matches: (path: string) => boolean, delayMs: number): void;
|
|
56
|
+
failRemoveEntry(path: string, times?: number): void;
|
|
57
|
+
ensureDir(path: string): void;
|
|
58
|
+
writeFile(path: string, raw: string): void;
|
|
59
|
+
readFile(path: string): string | null;
|
|
60
|
+
removeFile(path: string): void;
|
|
61
|
+
fileExists(path: string): boolean;
|
|
62
|
+
listEntries(path: string): string[];
|
|
63
|
+
getElapsedTime(): number;
|
|
64
|
+
}
|
|
65
|
+
export declare function createMockBrowserOpfs(): MockBrowserOpfsEnvironment;
|
|
66
|
+
export declare function hasPendingMockBrowserOpfsLatenciesForTests(): boolean;
|
|
67
|
+
export declare function flushMockBrowserOpfsLatenciesForTests(): Promise<void>;
|
|
68
|
+
export declare function readMockBrowserOpfsFileForTests(path: string): string | null;
|
|
69
|
+
export declare function resetMockBrowserOpfsForTests(): void;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ItemLoadedFields } from '../../src/listQueryStore/types';
|
|
2
|
+
import { createLocalStoragePersistentTestStore, type PersistentTestStoreScope } from '../utils/persistentStorageTestStore';
|
|
3
|
+
type MockLocalStorageInitialScope = {
|
|
4
|
+
storeName: string;
|
|
5
|
+
sessionKey: string;
|
|
6
|
+
document?: {
|
|
7
|
+
data: unknown;
|
|
8
|
+
timestamp?: number;
|
|
9
|
+
version?: number;
|
|
10
|
+
};
|
|
11
|
+
collection?: Array<{
|
|
12
|
+
payload: string;
|
|
13
|
+
data: unknown;
|
|
14
|
+
timestamp?: number;
|
|
15
|
+
version?: number;
|
|
16
|
+
}>;
|
|
17
|
+
listQuery?: {
|
|
18
|
+
items?: Array<{
|
|
19
|
+
tableId: string;
|
|
20
|
+
id: number | string;
|
|
21
|
+
data: unknown;
|
|
22
|
+
loadedFields?: ItemLoadedFields;
|
|
23
|
+
timestamp?: number;
|
|
24
|
+
version?: number;
|
|
25
|
+
}>;
|
|
26
|
+
queries?: Array<{
|
|
27
|
+
params: unknown;
|
|
28
|
+
items: Array<string | {
|
|
29
|
+
tableId: string;
|
|
30
|
+
id: number | string;
|
|
31
|
+
}>;
|
|
32
|
+
hasMore?: boolean;
|
|
33
|
+
timestamp?: number;
|
|
34
|
+
version?: number;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
type MockLocalStorageStoreOptions = {
|
|
39
|
+
storeName?: string;
|
|
40
|
+
sessionKey?: string;
|
|
41
|
+
initialState?: {
|
|
42
|
+
document?: MockLocalStorageInitialScope['document'];
|
|
43
|
+
collection?: MockLocalStorageInitialScope['collection'];
|
|
44
|
+
listQuery?: MockLocalStorageInitialScope['listQuery'];
|
|
45
|
+
rawEntries?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type MockLocalStorageStoreBase = {
|
|
49
|
+
storage: ReturnType<typeof createLocalStoragePersistentTestStore>['storage'];
|
|
50
|
+
scope: ReturnType<typeof createLocalStoragePersistentTestStore>['scope'];
|
|
51
|
+
getRaw: (key: string) => string | null;
|
|
52
|
+
has: (key: string) => boolean;
|
|
53
|
+
setRaw: (key: string, raw: string) => void;
|
|
54
|
+
setValue: <T>(key: string, value: T) => void;
|
|
55
|
+
};
|
|
56
|
+
export declare function createMockLocalStorageStore(options: MockLocalStorageStoreOptions & {
|
|
57
|
+
storeName: string;
|
|
58
|
+
sessionKey: string;
|
|
59
|
+
}): MockLocalStorageStoreBase & PersistentTestStoreScope;
|
|
60
|
+
export declare function createMockLocalStorageStore(options?: MockLocalStorageStoreOptions): MockLocalStorageStoreBase;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PersistentStorageDataSchema, StorageAdapter } from '../../src/persistentStorage/types';
|
|
2
|
+
import type { ValidStoreState } from '../../src/utils/storeShared';
|
|
3
|
+
export declare function seedDocumentScenarioPersistentStorage<TState extends ValidStoreState, TStorage>(args: {
|
|
4
|
+
storeName: string;
|
|
5
|
+
sessionKey: string | false;
|
|
6
|
+
persistentStorage: {
|
|
7
|
+
adapter: StorageAdapter;
|
|
8
|
+
version?: number;
|
|
9
|
+
schema: PersistentStorageDataSchema<TState, TStorage>;
|
|
10
|
+
} | null;
|
|
11
|
+
initialData: TState | undefined;
|
|
12
|
+
timestamp?: number;
|
|
13
|
+
}): void;
|
|
14
|
+
type CollectionInitialData<TState> = Array<{
|
|
15
|
+
payload: string;
|
|
16
|
+
data: TState;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function seedCollectionScenarioPersistentStorage<TState extends ValidStoreState, TStorage>(args: {
|
|
19
|
+
storeName: string;
|
|
20
|
+
sessionKey: string | false;
|
|
21
|
+
persistentStorage: {
|
|
22
|
+
adapter: StorageAdapter;
|
|
23
|
+
version?: number;
|
|
24
|
+
schema: PersistentStorageDataSchema<TState, TStorage>;
|
|
25
|
+
} | null;
|
|
26
|
+
initialData: CollectionInitialData<TState> | undefined;
|
|
27
|
+
timestamp?: number;
|
|
28
|
+
}): void;
|
|
29
|
+
type ListQueryInitialData<TState, TQueryPayload> = {
|
|
30
|
+
queries: Array<{
|
|
31
|
+
payload: TQueryPayload;
|
|
32
|
+
hasMore: boolean;
|
|
33
|
+
items: string[];
|
|
34
|
+
}>;
|
|
35
|
+
items: Array<{
|
|
36
|
+
payload: string;
|
|
37
|
+
data: TState;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
export declare function seedListQueryScenarioPersistentStorage<TState extends ValidStoreState, TQueryPayload, TStorage>(args: {
|
|
41
|
+
storeName: string;
|
|
42
|
+
sessionKey: string | false;
|
|
43
|
+
persistentStorage: {
|
|
44
|
+
adapter: StorageAdapter;
|
|
45
|
+
version?: number;
|
|
46
|
+
schema: PersistentStorageDataSchema<TState, TStorage>;
|
|
47
|
+
} | null;
|
|
48
|
+
initialData: ListQueryInitialData<TState, TQueryPayload> | undefined;
|
|
49
|
+
timestamp?: number;
|
|
50
|
+
}): void;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { evtmitter } from 'evtmitter';
|
|
2
|
+
import type { StoreError } from '../../src/utils/storeShared';
|
|
3
|
+
export declare const DEFAULT_FETCH_DURATION_MS = 800;
|
|
4
|
+
export declare const DEFAULT_MUTATION_DURATION_MS = 1200;
|
|
5
|
+
export type FetchErrorConfig = {
|
|
6
|
+
message: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
method?: StoreError['method'];
|
|
9
|
+
code?: number;
|
|
10
|
+
};
|
|
11
|
+
type FetchHistoryEntry<Data> = {
|
|
12
|
+
id: string;
|
|
13
|
+
startTime: number;
|
|
14
|
+
endTime: number;
|
|
15
|
+
duration: number;
|
|
16
|
+
result: 'success' | 'error' | 'aborted';
|
|
17
|
+
data?: Data;
|
|
18
|
+
error?: Error;
|
|
19
|
+
};
|
|
20
|
+
type AddActionFn = (action: string, options?: {
|
|
21
|
+
id?: string | number;
|
|
22
|
+
actionValue?: unknown;
|
|
23
|
+
}) => void;
|
|
24
|
+
type ServerMockEvents = {
|
|
25
|
+
data_changed: undefined;
|
|
26
|
+
};
|
|
27
|
+
export type SharedServerMockState<Data> = {
|
|
28
|
+
serverDataHistory: Data[];
|
|
29
|
+
wsEvents: ReturnType<typeof evtmitter<ServerMockEvents>>;
|
|
30
|
+
};
|
|
31
|
+
export declare function createSharedServerMockState<Data>(initialData: Data): SharedServerMockState<Data>;
|
|
32
|
+
export declare function createServerMock<Data>(initialData: Data, addAction?: AddActionFn, sharedState?: SharedServerMockState<Data>): {
|
|
33
|
+
mutateData: (newData: Data, { duration, setDataAt, triggerRTUEvent, addServerDataChangeAction, mutationId, addMutationResolvedAction, }?: {
|
|
34
|
+
duration?: number | undefined;
|
|
35
|
+
setDataAt?: number | undefined;
|
|
36
|
+
triggerRTUEvent?: boolean | undefined;
|
|
37
|
+
addServerDataChangeAction?: boolean | undefined;
|
|
38
|
+
addMutationResolvedAction?: boolean | undefined;
|
|
39
|
+
mutationId?: string | number | undefined;
|
|
40
|
+
}) => Promise<void>;
|
|
41
|
+
wsEvents: import("evtmitter").Emitter<ServerMockEvents>;
|
|
42
|
+
delayedSetData(value: Data, options?: {
|
|
43
|
+
durationMs?: number | undefined;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
setData(value: Data): void;
|
|
46
|
+
readonly current: Data;
|
|
47
|
+
history: Data[];
|
|
48
|
+
fetch: (signal?: AbortSignal | undefined, duration?: number) => Promise<Data>;
|
|
49
|
+
setFetchDurations(...durations: number[]): void;
|
|
50
|
+
setNextFetchError(error: string | FetchErrorConfig): void;
|
|
51
|
+
readonly numOfStartedFetches: number;
|
|
52
|
+
readonly numOfFinishedFetches: number;
|
|
53
|
+
fetchHistory: FetchHistoryEntry<Data>[];
|
|
54
|
+
clearFetchHistory(): void;
|
|
55
|
+
};
|
|
56
|
+
export {};
|