11import {
22 createQuery ,
3- type QueryClient ,
43 useQueryClient ,
54 type CreateQueryResult ,
65 type FetchQueryOptions ,
6+ type QueryClient ,
77 type QueryKey
88} from '@tanstack/svelte-query' ;
99
10- import { setAutoFreeze , produce , type Draft } from 'immer' ;
10+ import { produce , setAutoFreeze , type Draft } from 'immer' ;
1111
12- import type Client from 'pocketbase' ;
1312import type {
13+ ClientResponseError ,
1414 Record ,
1515 RecordListQueryParams ,
16- RecordSubscription ,
17- ClientResponseError
16+ RecordService ,
17+ RecordSubscription
1818} from 'pocketbase' ;
1919
20- import { collectionKeys } from '../query-key-factory' ;
2120import { realtimeStoreExpand } from '../internal' ;
22- import type { CollectionStoreOptions , CollectionQueryPrefetchOptions } from '../types' ;
21+ import { collectionKeys } from '../query-key-factory' ;
22+ import type { CollectionQueryPrefetchOptions , CollectionStoreOptions } from '../types' ;
2323
2424setAutoFreeze ( false ) ;
2525
@@ -30,7 +30,7 @@ const collectionStoreCallback = async <
3030 queryClient : QueryClient ,
3131 queryKey : TQueryKey ,
3232 subscription : RecordSubscription < T > ,
33- collection : ReturnType < Client [ 'collection' ] > ,
33+ collection : RecordService ,
3434 queryParams : RecordListQueryParams | undefined = undefined ,
3535 sortFunction ?: ( a : T , b : T ) => number ,
3636 filterFunction ?: ( value : T , index : number , array : T [ ] ) => boolean ,
@@ -106,9 +106,9 @@ const collectionStoreCallback = async <
106106export const createCollectionQueryInitialData = async <
107107 T extends Pick < Record , 'id' | 'updated' > = Pick < Record , 'id' | 'updated' >
108108> (
109- collection : ReturnType < Client [ 'collection' ] > ,
109+ collection : RecordService ,
110110 { queryParams = undefined } : { queryParams ?: RecordListQueryParams }
111- ) : Promise < Array < T > > => [ ...( await collection . getFullList < T > ( undefined , queryParams ) ) ] ;
111+ ) : Promise < Array < T > > => [ ...( await collection . getFullList < T > ( queryParams ) ) ] ;
112112
113113/**
114114 * Meant for SSR use, allows for prefetching queries on the server so that data is already available in the cache, and no initial fetch occurs client-side. See [TanStack's documentation](https://tanstack.com/query/v4/docs/svelte/ssr#using-prefetchquery) and this project's README.md for some examples.
@@ -124,7 +124,7 @@ export const createCollectionQueryPrefetch = <
124124 T extends Pick < Record , 'id' | 'updated' > = Pick < Record , 'id' | 'updated' > ,
125125 TQueryKey extends QueryKey = QueryKey
126126> (
127- collection : ReturnType < Client [ 'collection' ] > ,
127+ collection : RecordService ,
128128 {
129129 staleTime = Infinity ,
130130 queryParams = undefined ,
@@ -168,7 +168,7 @@ export const createCollectionQuery = <
168168 T extends Pick < Record , 'id' | 'updated' > = Pick < Record , 'id' | 'updated' > ,
169169 TQueryKey extends QueryKey = QueryKey
170170> (
171- collection : ReturnType < Client [ 'collection' ] > ,
171+ collection : RecordService ,
172172 {
173173 staleTime = Infinity ,
174174 refetchOnReconnect = 'always' ,
0 commit comments