@tanstack/svelte-query 5.0.0-alpha.73 → 5.0.0-alpha.76
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/createBaseQuery.js +3 -3
- package/dist/createMutation.js +3 -3
- package/dist/createQueries.d.ts +3 -3
- package/dist/createQueries.d.ts.map +1 -1
- package/dist/createQueries.js +3 -3
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/useIsFetching.d.ts +1 -1
- package/dist/useIsFetching.d.ts.map +1 -1
- package/dist/useIsMutating.d.ts +1 -1
- package/dist/useIsMutating.d.ts.map +1 -1
- package/dist/useQueryClient.d.ts.map +1 -1
- package/dist/useQueryClient.js +2 -4
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/src/createBaseQuery.ts +3 -3
- package/src/createMutation.ts +3 -3
- package/src/createQueries.ts +6 -5
- package/src/types.ts +4 -4
- package/src/useIsFetching.ts +2 -1
- package/src/useIsMutating.ts +2 -1
- package/src/useQueryClient.ts +2 -7
- package/src/utils.ts +6 -6
package/dist/createBaseQuery.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { derived, get, readable
|
|
1
|
+
import { derived, get, readable } from 'svelte/store';
|
|
2
2
|
import { notifyManager } from '@tanstack/query-core';
|
|
3
3
|
import { useQueryClient } from './useQueryClient';
|
|
4
|
-
import {
|
|
4
|
+
import { isSvelteStore } from './utils';
|
|
5
5
|
export function createBaseQuery(options, Observer, queryClient) {
|
|
6
6
|
const client = useQueryClient(queryClient);
|
|
7
|
-
const optionsStore =
|
|
7
|
+
const optionsStore = isSvelteStore(options) ? options : readable(options);
|
|
8
8
|
const defaultedOptionsStore = derived(optionsStore, ($options) => {
|
|
9
9
|
const defaultedOptions = client.defaultQueryOptions($options);
|
|
10
10
|
defaultedOptions._optimisticResults = 'optimistic';
|
package/dist/createMutation.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { readable, derived,
|
|
1
|
+
import { readable, derived, get } from 'svelte/store';
|
|
2
2
|
import { MutationObserver, notifyManager } from '@tanstack/query-core';
|
|
3
3
|
import { useQueryClient } from './useQueryClient';
|
|
4
|
-
import {
|
|
4
|
+
import { isSvelteStore } from './utils';
|
|
5
5
|
export function createMutation(options, queryClient) {
|
|
6
6
|
const client = useQueryClient(queryClient);
|
|
7
|
-
const optionsStore =
|
|
7
|
+
const optionsStore = isSvelteStore(options) ? options : readable(options);
|
|
8
8
|
const observer = new MutationObserver(client, get(optionsStore));
|
|
9
9
|
let mutate;
|
|
10
10
|
optionsStore.subscribe(($options) => {
|
package/dist/createQueries.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QueryKey, QueryFunction, QueryClient, QueriesPlaceholderDataFunction, QueryObserverResult, DefaultError, QueryObserverOptions } from '@tanstack/query-core';
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Readable } from 'svelte/store';
|
|
3
|
+
import type { StoreOrVal } from './types';
|
|
4
4
|
type QueryObserverOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'placeholderData'> & {
|
|
5
5
|
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
6
6
|
};
|
|
@@ -46,7 +46,7 @@ export type QueriesOptions<T extends any[], Result extends any[] = [], Depth ext
|
|
|
46
46
|
*/
|
|
47
47
|
export type QueriesResults<T extends any[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? QueryObserverResult[] : T extends [] ? [] : T extends [infer Head] ? [...Result, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]> : T extends QueryObserverOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, any>[] ? QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError>[] : QueryObserverResult[];
|
|
48
48
|
export declare function createQueries<T extends any[], TCombinedResult = QueriesResults<T>>({ queries, ...options }: {
|
|
49
|
-
queries:
|
|
49
|
+
queries: StoreOrVal<[...QueriesOptions<T>]>;
|
|
50
50
|
combine?: (result: QueriesResults<T>) => TCombinedResult;
|
|
51
51
|
}, queryClient?: QueryClient): Readable<TCombinedResult>;
|
|
52
52
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQueries.d.ts","sourceRoot":"","sources":["../../src/createQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,8BAA8B,EAC9B,mBAAmB,EACnB,YAAY,EAEZ,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"createQueries.d.ts","sourceRoot":"","sources":["../../src/createQueries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,8BAA8B,EAC9B,mBAAmB,EACnB,YAAY,EAEZ,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,KAAK,oCAAoC,CACvC,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,SAAS,SAAS,QAAQ,GAAG,QAAQ,IACnC,IAAI,CACN,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,CAAC,EAC1E,iBAAiB,CAClB,GAAG;IACF,eAAe,CAAC,EAAE,YAAY,GAAG,8BAA8B,CAAC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AAC,MAAM,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,GACrC,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GACvE,CAAC,SAAS,oCAAoC,CAC5C,MAAM,YAAY,EAClB,MAAM,MAAM,EACZ,MAAM,KAAK,EACX,GAAG,CACJ,EAAE,GAEH,mBAAmB,CACjB,OAAO,SAAS,KAAK,GAAG,YAAY,GAAG,KAAK,EAC5C,OAAO,SAAS,MAAM,GAAG,YAAY,GAAG,MAAM,CAC/C,EAAE,GAEH,mBAAmB,EAAE,CAAA;AAEzB,wBAAgB,aAAa,CAC3B,CAAC,SAAS,GAAG,EAAE,EACf,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,EAEnC,EACE,OAAO,EACP,GAAG,OAAO,EACX,EAAE;IACD,OAAO,EAAE,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,eAAe,CAAA;CACzD,EACD,WAAW,CAAC,EAAE,WAAW,GACxB,QAAQ,CAAC,eAAe,CAAC,CAwC3B"}
|
package/dist/createQueries.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { notifyManager, QueriesObserver } from '@tanstack/query-core';
|
|
2
|
-
import { derived, get, readable
|
|
2
|
+
import { derived, get, readable } from 'svelte/store';
|
|
3
3
|
import { useQueryClient } from './useQueryClient';
|
|
4
|
-
import {
|
|
4
|
+
import { isSvelteStore } from './utils';
|
|
5
5
|
export function createQueries({ queries, ...options }, queryClient) {
|
|
6
6
|
const client = useQueryClient(queryClient);
|
|
7
7
|
// const isRestoring = useIsRestoring()
|
|
8
|
-
const queriesStore =
|
|
8
|
+
const queriesStore = isSvelteStore(queries) ? queries : readable(queries);
|
|
9
9
|
const defaultedQueriesStore = derived(queriesStore, ($queries) => {
|
|
10
10
|
return $queries.map((opts) => {
|
|
11
11
|
const defaultedOptions = client.defaultQueryOptions(opts);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { InfiniteQueryObserverOptions, InfiniteQueryObserverResult, MutationObserverResult, QueryObserverOptions, QueryObserverResult, QueryKey, MutationObserverOptions, MutateFunction, DefinedQueryObserverResult, DefaultError } from '@tanstack/query-core';
|
|
2
2
|
import type { Readable, Writable } from 'svelte/store';
|
|
3
3
|
/** Allows a type to be either the base object or a store of that object */
|
|
4
|
-
export type
|
|
4
|
+
export type StoreOrVal<T> = T | Readable<T> | Writable<T>;
|
|
5
5
|
/** Options for createBaseQuery */
|
|
6
|
-
export type CreateBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> =
|
|
6
|
+
export type CreateBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = StoreOrVal<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>;
|
|
7
7
|
/** Result from createBaseQuery */
|
|
8
8
|
export type CreateBaseQueryResult<TData = unknown, TError = DefaultError> = Readable<QueryObserverResult<TData, TError>>;
|
|
9
9
|
/** Options for createQuery */
|
|
@@ -11,7 +11,7 @@ export type CreateQueryOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
11
11
|
/** Result from createQuery */
|
|
12
12
|
export type CreateQueryResult<TData = unknown, TError = DefaultError> = CreateBaseQueryResult<TData, TError>;
|
|
13
13
|
/** Options for createInfiniteQuery */
|
|
14
|
-
export type CreateInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> =
|
|
14
|
+
export type CreateInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = StoreOrVal<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>>;
|
|
15
15
|
/** Result from createInfiniteQuery */
|
|
16
16
|
export type CreateInfiniteQueryResult<TData = unknown, TError = DefaultError> = Readable<InfiniteQueryObserverResult<TData, TError>>;
|
|
17
17
|
/** Options for createBaseQuery with initialData */
|
|
@@ -19,7 +19,7 @@ export type DefinedCreateBaseQueryResult<TData = unknown, TError = DefaultError>
|
|
|
19
19
|
/** Options for createQuery with initialData */
|
|
20
20
|
export type DefinedCreateQueryResult<TData = unknown, TError = DefaultError> = DefinedCreateBaseQueryResult<TData, TError>;
|
|
21
21
|
/** Options for createMutation */
|
|
22
|
-
export type CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> =
|
|
22
|
+
export type CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = StoreOrVal<Omit<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted' | 'variables'>>;
|
|
23
23
|
export type CreateMutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = (...args: Parameters<MutateFunction<TData, TError, TVariables, TContext>>) => void;
|
|
24
24
|
export type CreateMutateAsyncFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = MutateFunction<TData, TError, TVariables, TContext>;
|
|
25
25
|
export type CreateBaseMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TContext = unknown> = Override<MutationObserverResult<TData, TError, TVariables, TContext>, {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B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IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA"}
|
package/dist/useIsFetching.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type QueryFilters, type QueryClient } from '@tanstack/query-core';
|
|
2
|
-
import {
|
|
2
|
+
import type { Readable } from 'svelte/store';
|
|
3
3
|
export declare function useIsFetching(filters?: QueryFilters, queryClient?: QueryClient): Readable<number>;
|
|
4
4
|
//# sourceMappingURL=useIsFetching.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFetching.d.ts","sourceRoot":"","sources":["../../src/useIsFetching.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"useIsFetching.d.ts","sourceRoot":"","sources":["../../src/useIsFetching.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG5C,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,YAAY,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,QAAQ,CAAC,MAAM,CAAC,CAoBlB"}
|
package/dist/useIsMutating.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type MutationFilters, type QueryClient } from '@tanstack/query-core';
|
|
2
|
-
import {
|
|
2
|
+
import type { Readable } from 'svelte/store';
|
|
3
3
|
export declare function useIsMutating(filters?: MutationFilters, queryClient?: QueryClient): Readable<number>;
|
|
4
4
|
//# sourceMappingURL=useIsMutating.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsMutating.d.ts","sourceRoot":"","sources":["../../src/useIsMutating.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"useIsMutating.d.ts","sourceRoot":"","sources":["../../src/useIsMutating.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG5C,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,WAAW,GACxB,QAAQ,CAAC,MAAM,CAAC,CAoBlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.d.ts","sourceRoot":"","sources":["../../src/useQueryClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGvD,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"useQueryClient.d.ts","sourceRoot":"","sources":["../../src/useQueryClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGvD,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,WAAW,CAGrE"}
|
package/dist/useQueryClient.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export declare function
|
|
1
|
+
import type { Readable } from 'svelte/store';
|
|
2
|
+
import type { StoreOrVal } from './types';
|
|
3
|
+
export declare function isSvelteStore<T extends object>(obj: StoreOrVal<T>): obj is Readable<T>;
|
|
4
4
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAC5C,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GACjB,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CAEpB"}
|
package/dist/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function
|
|
2
|
-
return 'subscribe' in obj &&
|
|
1
|
+
export function isSvelteStore(obj) {
|
|
2
|
+
return 'subscribe' in obj && typeof obj.subscribe === 'function';
|
|
3
3
|
}
|
package/package.json
CHANGED
package/src/createBaseQuery.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { derived, get, readable
|
|
1
|
+
import { derived, get, readable } from 'svelte/store'
|
|
2
2
|
import { notifyManager } from '@tanstack/query-core'
|
|
3
3
|
import type { QueryClient, QueryKey, QueryObserver } from '@tanstack/query-core'
|
|
4
4
|
import type { CreateBaseQueryOptions, CreateBaseQueryResult } from './types'
|
|
5
5
|
import { useQueryClient } from './useQueryClient'
|
|
6
|
-
import {
|
|
6
|
+
import { isSvelteStore } from './utils'
|
|
7
7
|
|
|
8
8
|
export function createBaseQuery<
|
|
9
9
|
TQueryFnData,
|
|
@@ -24,7 +24,7 @@ export function createBaseQuery<
|
|
|
24
24
|
): CreateBaseQueryResult<TData, TError> {
|
|
25
25
|
const client = useQueryClient(queryClient)
|
|
26
26
|
|
|
27
|
-
const optionsStore =
|
|
27
|
+
const optionsStore = isSvelteStore(options) ? options : readable(options)
|
|
28
28
|
|
|
29
29
|
const defaultedOptionsStore = derived(optionsStore, ($options) => {
|
|
30
30
|
const defaultedOptions = client.defaultQueryOptions($options)
|
package/src/createMutation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readable, derived,
|
|
1
|
+
import { readable, derived, get } from 'svelte/store'
|
|
2
2
|
import type { QueryClient, DefaultError } from '@tanstack/query-core'
|
|
3
3
|
import { MutationObserver, notifyManager } from '@tanstack/query-core'
|
|
4
4
|
import type {
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
CreateMutationResult,
|
|
8
8
|
} from './types'
|
|
9
9
|
import { useQueryClient } from './useQueryClient'
|
|
10
|
-
import {
|
|
10
|
+
import { isSvelteStore } from './utils'
|
|
11
11
|
|
|
12
12
|
export function createMutation<
|
|
13
13
|
TData = unknown,
|
|
@@ -20,7 +20,7 @@ export function createMutation<
|
|
|
20
20
|
): CreateMutationResult<TData, TError, TVariables, TContext> {
|
|
21
21
|
const client = useQueryClient(queryClient)
|
|
22
22
|
|
|
23
|
-
const optionsStore =
|
|
23
|
+
const optionsStore = isSvelteStore(options) ? options : readable(options)
|
|
24
24
|
|
|
25
25
|
const observer = new MutationObserver<TData, TError, TVariables, TContext>(
|
|
26
26
|
client,
|
package/src/createQueries.ts
CHANGED
|
@@ -9,10 +9,11 @@ import type {
|
|
|
9
9
|
QueryObserverOptions,
|
|
10
10
|
} from '@tanstack/query-core'
|
|
11
11
|
import { notifyManager, QueriesObserver } from '@tanstack/query-core'
|
|
12
|
-
import { derived, get, readable
|
|
13
|
-
import type {
|
|
12
|
+
import { derived, get, readable } from 'svelte/store'
|
|
13
|
+
import type { Readable } from 'svelte/store'
|
|
14
|
+
import type { StoreOrVal } from './types'
|
|
14
15
|
import { useQueryClient } from './useQueryClient'
|
|
15
|
-
import {
|
|
16
|
+
import { isSvelteStore } from './utils'
|
|
16
17
|
|
|
17
18
|
// This defines the `CreateQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
|
|
18
19
|
// `placeholderData` function does not have a parameter
|
|
@@ -168,7 +169,7 @@ export function createQueries<
|
|
|
168
169
|
queries,
|
|
169
170
|
...options
|
|
170
171
|
}: {
|
|
171
|
-
queries:
|
|
172
|
+
queries: StoreOrVal<[...QueriesOptions<T>]>
|
|
172
173
|
combine?: (result: QueriesResults<T>) => TCombinedResult
|
|
173
174
|
},
|
|
174
175
|
queryClient?: QueryClient,
|
|
@@ -176,7 +177,7 @@ export function createQueries<
|
|
|
176
177
|
const client = useQueryClient(queryClient)
|
|
177
178
|
// const isRestoring = useIsRestoring()
|
|
178
179
|
|
|
179
|
-
const queriesStore =
|
|
180
|
+
const queriesStore = isSvelteStore(queries) ? queries : readable(queries)
|
|
180
181
|
|
|
181
182
|
const defaultedQueriesStore = derived(queriesStore, ($queries) => {
|
|
182
183
|
return $queries.map((opts) => {
|
package/src/types.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
import type { Readable, Writable } from 'svelte/store'
|
|
14
14
|
|
|
15
15
|
/** Allows a type to be either the base object or a store of that object */
|
|
16
|
-
export type
|
|
16
|
+
export type StoreOrVal<T> = T | Readable<T> | Writable<T>
|
|
17
17
|
|
|
18
18
|
/** Options for createBaseQuery */
|
|
19
19
|
export type CreateBaseQueryOptions<
|
|
@@ -22,7 +22,7 @@ export type CreateBaseQueryOptions<
|
|
|
22
22
|
TData = TQueryFnData,
|
|
23
23
|
TQueryData = TQueryFnData,
|
|
24
24
|
TQueryKey extends QueryKey = QueryKey,
|
|
25
|
-
> =
|
|
25
|
+
> = StoreOrVal<
|
|
26
26
|
QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>
|
|
27
27
|
>
|
|
28
28
|
|
|
@@ -54,7 +54,7 @@ export type CreateInfiniteQueryOptions<
|
|
|
54
54
|
TQueryData = TQueryFnData,
|
|
55
55
|
TQueryKey extends QueryKey = QueryKey,
|
|
56
56
|
TPageParam = unknown,
|
|
57
|
-
> =
|
|
57
|
+
> = StoreOrVal<
|
|
58
58
|
InfiniteQueryObserverOptions<
|
|
59
59
|
TQueryFnData,
|
|
60
60
|
TError,
|
|
@@ -89,7 +89,7 @@ export type CreateMutationOptions<
|
|
|
89
89
|
TError = DefaultError,
|
|
90
90
|
TVariables = void,
|
|
91
91
|
TContext = unknown,
|
|
92
|
-
> =
|
|
92
|
+
> = StoreOrVal<
|
|
93
93
|
Omit<
|
|
94
94
|
MutationObserverOptions<TData, TError, TVariables, TContext>,
|
|
95
95
|
'_defaulted' | 'variables'
|
package/src/useIsFetching.ts
CHANGED
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
type QueryClient,
|
|
4
4
|
notifyManager,
|
|
5
5
|
} from '@tanstack/query-core'
|
|
6
|
-
import {
|
|
6
|
+
import { readable } from 'svelte/store'
|
|
7
|
+
import type { Readable } from 'svelte/store'
|
|
7
8
|
import { useQueryClient } from './useQueryClient'
|
|
8
9
|
|
|
9
10
|
export function useIsFetching(
|
package/src/useIsMutating.ts
CHANGED
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
type QueryClient,
|
|
4
4
|
notifyManager,
|
|
5
5
|
} from '@tanstack/query-core'
|
|
6
|
-
import {
|
|
6
|
+
import { readable } from 'svelte/store'
|
|
7
|
+
import type { Readable } from 'svelte/store'
|
|
7
8
|
import { useQueryClient } from './useQueryClient'
|
|
8
9
|
|
|
9
10
|
export function useIsMutating(
|
package/src/useQueryClient.ts
CHANGED
|
@@ -2,11 +2,6 @@ import type { QueryClient } from '@tanstack/query-core'
|
|
|
2
2
|
import { getQueryClientContext } from './context'
|
|
3
3
|
|
|
4
4
|
export function useQueryClient(queryClient?: QueryClient): QueryClient {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (queryClient) {
|
|
8
|
-
return queryClient
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return client
|
|
5
|
+
if (queryClient) return queryClient
|
|
6
|
+
return getQueryClientContext()
|
|
12
7
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Readable } from 'svelte/store'
|
|
2
|
+
import type { StoreOrVal } from './types'
|
|
3
3
|
|
|
4
|
-
export function
|
|
5
|
-
obj:
|
|
6
|
-
): obj is
|
|
7
|
-
return 'subscribe' in obj &&
|
|
4
|
+
export function isSvelteStore<T extends object>(
|
|
5
|
+
obj: StoreOrVal<T>,
|
|
6
|
+
): obj is Readable<T> {
|
|
7
|
+
return 'subscribe' in obj && typeof obj.subscribe === 'function'
|
|
8
8
|
}
|