@codeleap/query
Advanced tools
+4
-4
| { | ||
| "name": "@codeleap/query", | ||
| "version": "5.8.8", | ||
| "version": "5.8.9", | ||
| "main": "src/index.ts", | ||
@@ -12,4 +12,4 @@ "license": "UNLICENSED", | ||
| "devDependencies": { | ||
| "@codeleap/config": "5.8.8", | ||
| "@codeleap/types": "5.8.8", | ||
| "@codeleap/config": "5.8.9", | ||
| "@codeleap/types": "5.8.9", | ||
| "ts-node-dev": "1.1.8" | ||
@@ -21,3 +21,3 @@ }, | ||
| "peerDependencies": { | ||
| "@codeleap/types": "5.8.8", | ||
| "@codeleap/types": "5.8.9", | ||
| "typescript": "5.5.2", | ||
@@ -24,0 +24,0 @@ "@tanstack/react-query": "5.89.0" |
@@ -5,2 +5,3 @@ import { InfiniteData } from '@tanstack/query-core' | ||
| import deepEqual from 'fast-deep-equal' | ||
| import { TypeGuards } from '@codeleap/types' | ||
@@ -133,6 +134,6 @@ /** | ||
| */ | ||
| removeItem(itemId: QueryItem['id']): RemovedItemMap | null { | ||
| removeItem(itemId: QueryItem['id'], listFilters?: F): RemovedItemMap | null { | ||
| this.queryKeys.removeRetrieveQueryData(itemId) | ||
| const listQueries = this.queryKeys.getAllListQueries() | ||
| const listQueries = TypeGuards.isNil(listFilters) ? this.queryKeys.getAllListQueries() : [this.queryKeys.getListQuery(listFilters)] | ||
@@ -139,0 +140,0 @@ const removedItemMap: RemovedItemMap = [] |
@@ -339,2 +339,10 @@ import { CancelOptions, InfiniteData, InvalidateOptions, InvalidateQueryFilters, Query, QueryFilters, QueryKey, RefetchOptions, RefetchQueryFilters } from '@tanstack/react-query' | ||
| } | ||
| getListQuery(listFilters?: F) { | ||
| const query = this.queryClient.getQueryCache().find({ | ||
| queryKey: this.listKeyWithFilters(listFilters) | ||
| }) | ||
| return query as Query<ListPaginationResponse<T>, Error, Omit<ListSelector<T>, 'allItems'>, QueryKey> | ||
| } | ||
| } | ||
@@ -341,0 +349,0 @@ |
@@ -1,2 +0,2 @@ | ||
| import { FetchQueryOptions, InfiniteData, MutationFunctionContext, QueryKey, useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query' | ||
| import { FetchInfiniteQueryOptions, FetchQueryOptions, InfiniteData, MutationFunctionContext, QueryKey, useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query' | ||
| import { useCallback } from 'react' | ||
@@ -488,2 +488,37 @@ import { createQueryKeys, QueryKeys } from './QueryKeys' | ||
| } | ||
| /** | ||
| * Prefetches a paginated list with filters for improved performance | ||
| * @param filters - Filter parameters to apply to the list query | ||
| * @param options - Prefetch options compatible with React Query's infinite queries | ||
| * @param options.initialOffset - Starting offset for pagination (default: 0) | ||
| * @returns Promise that resolves when prefetch is complete | ||
| * | ||
| * @description | ||
| * Use this method to preload paginated list data that users are likely to need soon. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * const handle = () => { | ||
| * queryManager.prefetchList( | ||
| * { category: 'electronics' }, | ||
| * { staleTime: 5 * 60 * 1000 } | ||
| * ) | ||
| * } | ||
| * | ||
| * ``` | ||
| */ | ||
| prefetchList( | ||
| filters?: F, | ||
| options: Omit<FetchInfiniteQueryOptions<ListPaginationResponse<T>, Error, ListPaginationResponse<T>, QueryKey, number>, 'queryKey' | 'queryFn' | 'initialPageParam'> & { initialOffset?: number } = {} | ||
| ) { | ||
| const { initialOffset = 0, ...prefetchOptions } = options | ||
| return this.options.queryClient.prefetchInfiniteQuery({ | ||
| ...prefetchOptions as any, | ||
| initialPageParam: initialOffset, | ||
| queryKey: this.queryKeys.listKeyWithFilters(filters), | ||
| queryFn: () => this.options.listFn(this.options.listLimit ?? 10, initialOffset, filters), | ||
| }) | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
Explicitly Unlicensed Item
LicenseSomething was found which is explicitly marked as unlicensed.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Explicitly Unlicensed Item
LicenseSomething was found which is explicitly marked as unlicensed.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
134769
1.3%3464
1.17%