tsdf 17.0.0-alpha.5 → 17.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +15 -15
- package/dist/main.js +18 -24
- package/docs/README.md +1 -1
- package/docs/invalidation.md +3 -3
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -2464,6 +2464,19 @@ type ListQueryAddItemToStateApi<ItemState extends ValidStoreState, QueryPayload
|
|
|
2464
2464
|
};
|
|
2465
2465
|
}) => void;
|
|
2466
2466
|
type ListQueryDeleteItemStateApi<ItemState extends ValidStoreState, ItemPayload extends ValidPayload> = (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>) => void;
|
|
2467
|
+
type ListQueryInvalidateQueryAndItemsArgs<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload> = {
|
|
2468
|
+
/** Invalidate every cached query and every cached item. */all: true;
|
|
2469
|
+
type?: FetchType;
|
|
2470
|
+
fields?: string[];
|
|
2471
|
+
itemPayload?: undefined;
|
|
2472
|
+
queryPayload?: undefined;
|
|
2473
|
+
} | {
|
|
2474
|
+
all?: undefined;
|
|
2475
|
+
itemPayload: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload> | false;
|
|
2476
|
+
queryPayload: QueryPayload | QueryPayload[] | ListQueryFilterQuery<QueryPayload> | false;
|
|
2477
|
+
type?: FetchType;
|
|
2478
|
+
fields?: string[];
|
|
2479
|
+
};
|
|
2467
2480
|
type ListQueryStore<ItemState extends ValidStoreState, QueryPayload extends ValidPayload, ItemPayload extends ValidPayload, TPartialResources extends boolean = false, TOfflineOperations extends ListQueryOfflineOperationsConfig<ItemState, QueryPayload, ItemPayload> = null> = {
|
|
2468
2481
|
store: Store<TSFDListQueryState<ItemState, QueryPayload, ItemPayload>>;
|
|
2469
2482
|
events: Emitter<ListQueryStoreEvents>;
|
|
@@ -2506,12 +2519,7 @@ type ListQueryStore<ItemState extends ValidStoreState, QueryPayload extends Vali
|
|
|
2506
2519
|
scheduleItemFetch: ListQueryScheduleItemFetchApi<ItemPayload, TPartialResources>;
|
|
2507
2520
|
awaitItemFetch: ListQueryAwaitItemFetchApi<ItemState, ItemPayload, TPartialResources>;
|
|
2508
2521
|
getItemFromStateOrFetch: ListQueryGetItemFromStateOrFetchApi<ItemState, ItemPayload, TPartialResources>;
|
|
2509
|
-
invalidateQueryAndItems: (args:
|
|
2510
|
-
itemPayload: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload> | false;
|
|
2511
|
-
queryPayload: QueryPayload | QueryPayload[] | ListQueryFilterQuery<QueryPayload> | false;
|
|
2512
|
-
type?: FetchType;
|
|
2513
|
-
fields?: string[];
|
|
2514
|
-
}) => void;
|
|
2522
|
+
invalidateQueryAndItems: (args: ListQueryInvalidateQueryAndItemsArgs<ItemState, QueryPayload, ItemPayload>) => void;
|
|
2515
2523
|
invalidateItem: (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>, priority?: FetchType) => void;
|
|
2516
2524
|
startItemMutation: (itemId: ItemPayload | ItemPayload[] | ListQueryFilterItem<ItemState, ItemPayload>) => () => void;
|
|
2517
2525
|
updateItemState: ListQueryUpdateItemStateApi<ItemState, ItemPayload>;
|
|
@@ -2669,14 +2677,6 @@ declare function createListQueryStore<ItemState extends ValidStoreState, QueryPa
|
|
|
2669
2677
|
* `getQueriesState`.
|
|
2670
2678
|
*/
|
|
2671
2679
|
declare const GET_ALL: (...args: unknown[]) => true;
|
|
2672
|
-
/**
|
|
2673
|
-
* Shared List Query invalidation target for invalidating every cached query and
|
|
2674
|
-
* every cached item.
|
|
2675
|
-
*/
|
|
2676
|
-
declare const ALL_QUERY_AND_ITEMS: {
|
|
2677
|
-
readonly queryPayload: typeof GET_ALL;
|
|
2678
|
-
readonly itemPayload: typeof GET_ALL;
|
|
2679
|
-
};
|
|
2680
2680
|
//#endregion
|
|
2681
2681
|
//#region src/isOffScreenContext.d.ts
|
|
2682
2682
|
/**
|
|
@@ -2829,4 +2829,4 @@ declare function clearAllSessionStorage(sessionKey: string): Promise<void>;
|
|
|
2829
2829
|
//#region src/persistentStorage/opfsOfflineUploadAdapter.d.ts
|
|
2830
2830
|
declare const opfsOfflineUploadAdapter: OfflineUploadAdapter;
|
|
2831
2831
|
//#endregion
|
|
2832
|
-
export {
|
|
2832
|
+
export { type AsyncStorageAdapter, type AsyncStorageDiscoveredScope, type AsyncStorageDriver, type AsyncStorageDriverSetEntry, type AsyncStorageMetadataOrder, type AsyncStorageNamespaceCommitArgs, type AsyncStorageNamespaceCommitTouch, type AsyncStorageNamespaceCommitUpsert, type AsyncStorageNamespaceGetResult, type AsyncStorageNamespaceHandle, type AsyncStorageNamespaceKind, type AsyncStorageNamespaceScope, type AsyncStorageReadOptions, type BlockWindowCloseHandler, CollectionBrowserTabsMessage, CollectionInitialStateItem, CollectionItemStatus, type CollectionOfflineEntityRef, type CollectionOfflineOperationDefinition, type CollectionPersistentStorageConfig, CollectionStateCleanup, CollectionStore, CollectionStoreEvents, CollectionStoreOptions, CollectionStoreStoreEvents, CollectionUseMultipleItemsQuery, type ConvertedPersistentStorageDataSchema, type CreateStoreManagerOptions, type DefineCollectionOfflineOperations, type DefineDocumentOfflineOperations, type DefineListQueryOfflineOperations, type DefineOfflineOperation, type DerivedQueriesConfig, type DerivedQueryContext, type DerivedQuerySource, DocumentBrowserTabsMessage, type DocumentOfflineOperationDefinition, type DocumentPersistentStorageConfig, DocumentStatus, DocumentStore, DocumentStoreOptions, DocumentStoreState, DocumentStoreStoreEvents, type FetchListFnReturn, type FetchListFnReturnItem, type FieldsInput, type FieldsOption, GET_ALL, type GlobalOfflineEntity, type GlobalOfflineStatus, type IndexedDbPersistentStorageOptions, IsOffScreenContext, type ListQueryOfflineEntityRef, type ListQueryOfflineOperationDefinition, type ListQueryPersistentStorageConfig, type ListQueryStore, type ListQueryStoreEvents, type ListQueryStoreInitialData, type ListQueryStoreOptions, type ListQueryUseMultipleItemsQuery, type ListQueryUseMultipleListQueriesQuery, type MutationDebounce, type MutationSkipped, type OfflineAccumulationConfig, type OfflineAccumulationMergeContext, type OfflineConflictResolutionAction, type OfflineEntityMutationKind, type OfflineMutationDescriptor, type OfflineMutationInput, type OfflineMutationQueueingCause, type OfflineMutationQueueingConfig, type OfflineMutationQueueingPolicy, type OfflineMutationResult, type OfflineMutationUploadsInput, type OfflineOperationKind, type OfflineOperationUploadsContext, type OfflineQueueEntry, type OfflineReplayRetryConfig, type OfflineResolutionAction, type OfflineResolutionActionForOperation, type OfflineResolutionConflictParseError, type OfflineResolutionConflictParseErrorCode, type OfflineResolutionRecord, type OfflineResolutionRecordForOperation, type OfflineResolutionRecordForStore, type OfflineRetryExhaustedResolutionAction, type OfflineRuntimeConfig, type OfflineRuntimeConfigUpdate, type OfflineSession, type OfflineSessionConfig, type OfflineSessionUploadsConfig, type OfflineStoredUploadRecord, type OfflineSupersedeConfig, type OfflineSyncState, type OfflineTempEntitiesConfig, type OfflineTempEntitiesReconciliation, type OfflineTempEntityConfig, type OfflineTempEntityPendingEntry, type OfflineUpload, type OfflineUploadAdapter, type OfflineUploadProgress, type OfflineUploadSource, type OfflineUploadState, type OfflineUploadTransportContext, type OffsetPaginationConfig, OnCollectionItemInvalidate, OnDocumentInvalidate, type OnListQueryInvalidate, type OnListQueryItemInvalidate, type OperationConflict, type OperationResult, type OptimisticListUpdate, type ParsedOfflineResolutionConflictResultForOperation, type PartialResourcesConfig, type PayloadDebounce, type PersistentStorageBaseConfig, type PersistentStorageDataSchema, type PersistentStoragePreloadResult, type PersistentStorageSchema, type QueryFetchPayload, type QueryStatus, type StorageAdapter, type StoreError, StoreFetchError, type StoreManager, StoreMutationError, type StoreMutationErrorOptions, type TSDFItemQuery, type TSDFStatus, TSDFUseDocumentReturn, TSFDCollectionItem, TSFDCollectionState, type TSFDListQuery, type TSFDListQueryState, TSFDUseCollectionItemReturn, type TSFDUseListItemReturn, type TSFDUseListQueryReturn, type TSFDUsePendingOfflineItemsReturn, type ValidPayload, type ValidStoreState, clearAllSessionStorage, clearSessionStorage, createAsyncStorageAdapter, createCollectionStore, createDocumentStore, createIndexedDbPersistentStorage, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, indexedDbPersistentStorage, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, opfsPersistentStorage, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
package/dist/main.js
CHANGED
|
@@ -15874,6 +15874,16 @@ function createFetchApi({ store, normalizedFetchListFn, offsetPagination, fetchI
|
|
|
15874
15874
|
};
|
|
15875
15875
|
}
|
|
15876
15876
|
//#endregion
|
|
15877
|
+
//#region src/invalidationUtils.ts
|
|
15878
|
+
/**
|
|
15879
|
+
* Predicate that matches every currently known payload.
|
|
15880
|
+
*
|
|
15881
|
+
* Use it with APIs that accept payload filters, such as
|
|
15882
|
+
* `invalidateQueryAndItems`, `invalidateItem`, `getItemState`, and
|
|
15883
|
+
* `getQueriesState`.
|
|
15884
|
+
*/
|
|
15885
|
+
const GET_ALL = () => true;
|
|
15886
|
+
//#endregion
|
|
15877
15887
|
//#region src/listQueryStore/createMutationApi.ts
|
|
15878
15888
|
/** @internal */
|
|
15879
15889
|
function createMutationApi({ store, fetchItemFn, partialResources, optimisticListUpdates, onInvalidateQuery, onInvalidateItem, onMutationError, errorNormalizer, getItemKey, getQueriesKeyArray, getQueriesRelatedToItem, getItemsKeyArray, getOrCreateItemScheduler, getOrCreateQueryScheduler, deleteItemFetchResources, emitInvalidateQuery, emitInvalidateItem, blockWindowClose, offlineController, runWithBroadcastConsistency, publishQuerySnapshot, publishItemSnapshot, onOfflineTimelineEvent }) {
|
|
@@ -15937,7 +15947,11 @@ function createMutationApi({ store, fetchItemFn, partialResources, optimisticLis
|
|
|
15937
15947
|
const itemInvalidationWasTriggered = /* @__PURE__ */ new Set();
|
|
15938
15948
|
const itemFieldInvalidationPriorities = /* @__PURE__ */ new Map();
|
|
15939
15949
|
const itemPendingInvalidationFields = /* @__PURE__ */ new Map();
|
|
15940
|
-
function invalidateQueryAndItems(
|
|
15950
|
+
function invalidateQueryAndItems(args) {
|
|
15951
|
+
const itemPayload = args.all ? GET_ALL : args.itemPayload;
|
|
15952
|
+
const queryPayload = args.all ? GET_ALL : args.queryPayload;
|
|
15953
|
+
const priority = args.type ?? "highPriority";
|
|
15954
|
+
const invalidateFields = args.fields;
|
|
15941
15955
|
const queriesKey = queryPayload ? getQueriesKeyArray(queryPayload) : [];
|
|
15942
15956
|
for (const { key, payload } of queriesKey) {
|
|
15943
15957
|
const queryState = store.state.queries[key];
|
|
@@ -18473,15 +18487,13 @@ function createListQueryStore(storeOptions) {
|
|
|
18473
18487
|
onWindowFocus: testOptions?.onWindowFocus ?? onWindowFocus,
|
|
18474
18488
|
onWindowFocusRevalidate: () => {
|
|
18475
18489
|
invalidateQueryAndItems({
|
|
18476
|
-
|
|
18477
|
-
itemPayload: () => true,
|
|
18490
|
+
all: true,
|
|
18478
18491
|
type: "lowPriority"
|
|
18479
18492
|
});
|
|
18480
18493
|
},
|
|
18481
18494
|
onTransportReconnectRevalidate: () => {
|
|
18482
18495
|
invalidateQueryAndItems({
|
|
18483
|
-
|
|
18484
|
-
itemPayload: () => true,
|
|
18496
|
+
all: true,
|
|
18485
18497
|
type: "realtimeUpdate"
|
|
18486
18498
|
});
|
|
18487
18499
|
}
|
|
@@ -18740,24 +18752,6 @@ function createListQueryStore(storeOptions) {
|
|
|
18740
18752
|
};
|
|
18741
18753
|
}
|
|
18742
18754
|
//#endregion
|
|
18743
|
-
//#region src/invalidationUtils.ts
|
|
18744
|
-
/**
|
|
18745
|
-
* Predicate that matches every currently known payload.
|
|
18746
|
-
*
|
|
18747
|
-
* Use it with APIs that accept payload filters, such as
|
|
18748
|
-
* `invalidateQueryAndItems`, `invalidateItem`, `getItemState`, and
|
|
18749
|
-
* `getQueriesState`.
|
|
18750
|
-
*/
|
|
18751
|
-
const GET_ALL = () => true;
|
|
18752
|
-
/**
|
|
18753
|
-
* Shared List Query invalidation target for invalidating every cached query and
|
|
18754
|
-
* every cached item.
|
|
18755
|
-
*/
|
|
18756
|
-
const ALL_QUERY_AND_ITEMS = {
|
|
18757
|
-
queryPayload: GET_ALL,
|
|
18758
|
-
itemPayload: GET_ALL
|
|
18759
|
-
};
|
|
18760
|
-
//#endregion
|
|
18761
18755
|
//#region src/persistentStorage/opfsOfflineUploadAdapter.ts
|
|
18762
18756
|
const OPFS_UPLOADS_ROOT_DIR = "tsdf-uploads";
|
|
18763
18757
|
const METADATA_FILE_NAME = "metadata.json";
|
|
@@ -18930,4 +18924,4 @@ var OpfsOfflineUploadDriver = class {
|
|
|
18930
18924
|
};
|
|
18931
18925
|
const opfsOfflineUploadAdapter = new OpfsOfflineUploadDriver();
|
|
18932
18926
|
//#endregion
|
|
18933
|
-
export {
|
|
18927
|
+
export { GET_ALL, IsOffScreenContext, StoreFetchError, StoreMutationError, clearAllSessionStorage, clearSessionStorage, createAsyncStorageAdapter, createCollectionStore, createDocumentStore, createIndexedDbPersistentStorage, createListQueryStore, createStoreManager, defaultOfflineRuntimeConfig, fetchTypePriority, getGlobalOfflineEntities, getGlobalOfflineResolutions, getGlobalOfflineStatus, indexedDbPersistentStorage, localPersistentStorage, mutationSkipped, opfsOfflineUploadAdapter, opfsPersistentStorage, useGlobalOfflineEntities, useGlobalOfflineResolutions, useGlobalOfflineStatus };
|
package/docs/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Notable additions:
|
|
|
36
36
|
|
|
37
37
|
- Hook payload debouncing is documented in [React Hooks](./hooks.md#debouncepayload)
|
|
38
38
|
- The exported `PayloadDebounce` type is documented in [Shared Types](./shared-types.md#payloaddebounce)
|
|
39
|
-
- `GET_ALL` and `
|
|
39
|
+
- `GET_ALL` and `{ all: true }` invalidation are documented in [Invalidation](./invalidation.md#list-query-store)
|
|
40
40
|
|
|
41
41
|
## Quick Start
|
|
42
42
|
|
package/docs/invalidation.md
CHANGED
|
@@ -45,10 +45,10 @@ store.invalidateItem('item-1', 'lowPriority');
|
|
|
45
45
|
The List Query Store has the most flexible invalidation through `invalidateQueryAndItems`:
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
|
-
import {
|
|
48
|
+
import { GET_ALL } from 'tsdf';
|
|
49
49
|
|
|
50
50
|
// Invalidate all queries and all items
|
|
51
|
-
store.invalidateQueryAndItems(
|
|
51
|
+
store.invalidateQueryAndItems({ all: true });
|
|
52
52
|
|
|
53
53
|
// Invalidate specific queries only (skip items)
|
|
54
54
|
store.invalidateQueryAndItems({
|
|
@@ -69,7 +69,7 @@ store.invalidateQueryAndItems({
|
|
|
69
69
|
type: 'lowPriority',
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
// Reuse the all-payload predicate
|
|
72
|
+
// Reuse the all-payload predicate when only one side should match everything
|
|
73
73
|
store.invalidateQueryAndItems({ queryPayload: GET_ALL, itemPayload: false });
|
|
74
74
|
```
|
|
75
75
|
|