react-query-kit 2.0.2 → 2.0.3
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/README.md +6 -7
- package/build/lib/createBaseQuery.d.ts +1 -1
- package/build/lib/createBaseQuery.esm.js +11 -11
- package/build/lib/createBaseQuery.esm.js.map +1 -1
- package/build/lib/createBaseQuery.js +11 -11
- package/build/lib/createBaseQuery.js.map +1 -1
- package/build/lib/createBaseQuery.mjs +11 -11
- package/build/lib/createBaseQuery.mjs.map +1 -1
- package/build/lib/createInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createInfiniteQuery.js.map +1 -1
- package/build/lib/createInfiniteQuery.mjs.map +1 -1
- package/build/lib/createMutation.esm.js.map +1 -1
- package/build/lib/createMutation.js.map +1 -1
- package/build/lib/createMutation.mjs.map +1 -1
- package/build/lib/createQuery.esm.js.map +1 -1
- package/build/lib/createQuery.js.map +1 -1
- package/build/lib/createQuery.mjs.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -8
- package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.js +2 -8
- package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
- package/build/lib/createSuspenseInfiniteQuery.mjs +2 -8
- package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
- package/build/lib/createSuspenseQuery.esm.js +2 -8
- package/build/lib/createSuspenseQuery.esm.js.map +1 -1
- package/build/lib/createSuspenseQuery.js +2 -8
- package/build/lib/createSuspenseQuery.js.map +1 -1
- package/build/lib/createSuspenseQuery.mjs +2 -8
- package/build/lib/createSuspenseQuery.mjs.map +1 -1
- package/build/lib/index.d.ts +1 -1
- package/build/lib/types.d.ts +17 -17
- package/build/lib/utils.d.ts +8 -2
- package/build/lib/utils.esm.js +9 -3
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +9 -2
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +9 -3
- package/build/lib/utils.mjs.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats.json +116 -91
- package/build/umd/index.development.js +21 -29
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/build/zip/zip.esm.js +1 -0
- package/package.json +1 -1
- package/src/createBaseQuery.ts +17 -20
- package/src/createInfiniteQuery.ts +2 -6
- package/src/createMutation.ts +2 -2
- package/src/createQuery.tsx +2 -2
- package/src/createSuspenseInfiniteQuery.ts +3 -10
- package/src/createSuspenseQuery.ts +3 -14
- package/src/index.ts +1 -28
- package/src/types.ts +28 -26
- package/src/utils.ts +12 -5
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<br />
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
7
|
-
<a aria-label="NPM version" href="
|
|
7
|
+
<a aria-label="NPM version" href="./assets/logo.svg">
|
|
8
8
|
<img alt="" src="./assets/logo.svg" height="40">
|
|
9
9
|
</a>
|
|
10
10
|
</p>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<p align="center">
|
|
15
15
|
<a href="https://github.com/liaoliao666/react-query-kit/actions/workflows/tests.yml"><img src="https://github.com/liaoliao666/react-query-kit/actions/workflows/tests.yml/badge.svg?branch=main" alt="Latest build" target="\_parent"></a>
|
|
16
16
|
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/v/react-query-kit" alt="Latest published version" target="\_parent"></a>
|
|
17
|
-
<a href="https://unpkg.com/browse/react-query-kit@latest/build/
|
|
17
|
+
<a href="https://unpkg.com/browse/react-query-kit@latest/build/zip/zip.esm.js" rel="nofollow"><img src="https://img.badgesize.io/https:/unpkg.com/react-query-kit@latest/build/zip/zip.esm.js?label=gzip%20size&compression=gzip" alt="gzip size"></a>
|
|
18
18
|
<a href="https://github.com/liaoliao666/react-query-kit"><img src="https://badgen.net/npm/types/react-query-kit" alt="Types included" target="\_parent"></a>
|
|
19
19
|
<a href="https://github.com/liaoliao666/react-query-kit/blob/main/LICENSE"><img src="https://badgen.net/npm/license/react-query-kit" alt="License" target="\_parent"></a>
|
|
20
20
|
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/dt/react-query-kit" alt="Number of downloads" target="\_parent"></a>
|
|
@@ -93,7 +93,6 @@ const usePost = createQuery<Response, Variables, Error>({
|
|
|
93
93
|
// primaryKey equals to '/posts'
|
|
94
94
|
return fetch(`${primaryKey}/${variables.id}`).then(res => res.json())
|
|
95
95
|
},
|
|
96
|
-
suspense: true,
|
|
97
96
|
// u can also pass middleware to cutomize this hook's behavior
|
|
98
97
|
use: [myMiddleware]
|
|
99
98
|
})
|
|
@@ -104,7 +103,7 @@ const variables = { id: 1 }
|
|
|
104
103
|
// example
|
|
105
104
|
export default function Page() {
|
|
106
105
|
// queryKey equals to ['/posts', { id: 1 }]
|
|
107
|
-
const { data } = usePost({ variables
|
|
106
|
+
const { data } = usePost({ variables })
|
|
108
107
|
|
|
109
108
|
return (
|
|
110
109
|
<div>
|
|
@@ -160,9 +159,9 @@ Expose Methods
|
|
|
160
159
|
|
|
161
160
|
- `getPrimaryKey: () => primaryKey`
|
|
162
161
|
- `getKey: (variables: TVariables) => [primaryKey, variables]`
|
|
163
|
-
- `getFetchOptions: (variables: TVariables) => {queryKey, queryFn, queryKeyHashFn}`
|
|
164
162
|
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
|
|
165
163
|
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
|
|
164
|
+
- `getFetchOptions: (variables: TVariables) => ({ queryKey, queryFn, queryKeyHashFn })`
|
|
166
165
|
|
|
167
166
|
## createInfiniteQuery
|
|
168
167
|
|
|
@@ -192,7 +191,7 @@ const variables = { active: true }
|
|
|
192
191
|
export default function Page() {
|
|
193
192
|
// queryKey equals to ['projects', { active: true }]
|
|
194
193
|
const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
195
|
-
useProjects({ variables
|
|
194
|
+
useProjects({ variables })
|
|
196
195
|
|
|
197
196
|
return (
|
|
198
197
|
<div>
|
|
@@ -256,9 +255,9 @@ Expose Methods
|
|
|
256
255
|
|
|
257
256
|
- `getPrimaryKey: () => primaryKey`
|
|
258
257
|
- `getKey: (variables: TVariables) => [primaryKey, variables]`
|
|
259
|
-
- `getFetchOptions: (variables: TVariables) => {queryKey, queryFn, queryKeyHashFn, getNextPageParam, getPreviousPageParam, initialPageParam}`
|
|
260
258
|
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
|
|
261
259
|
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
|
|
260
|
+
- `getFetchOptions: (variables: TVariables) => ({ queryKey, queryFn, queryKeyHashFn, getNextPageParam, getPreviousPageParam, initialPageParam })`
|
|
262
261
|
|
|
263
262
|
## createSuspenseQuery
|
|
264
263
|
|
|
@@ -2,5 +2,5 @@ import type { UseBaseQueryOptions } from '@tanstack/react-query';
|
|
|
2
2
|
type QueryBaseHookOptions = Omit<UseBaseQueryOptions, 'queryKey' | 'queryFn'> & {
|
|
3
3
|
variables?: any;
|
|
4
4
|
};
|
|
5
|
-
export declare
|
|
5
|
+
export declare const createBaseQuery: (defaultOptions: any, useRQHook: (options: any, queryClient?: any) => any, overrideOptions?: QueryBaseHookOptions) => any;
|
|
6
6
|
export {};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { withMiddleware, getKey } from './utils.esm.js';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const createBaseQuery = (defaultOptions, useRQHook, overrideOptions) => {
|
|
4
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
if (defaultOptions.useDefaultOptions) {
|
|
7
|
+
throw new Error('useDefaultOptions is not supported, please use middleware instead.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
const {
|
|
5
12
|
primaryKey,
|
|
6
13
|
queryFn,
|
|
@@ -10,13 +17,6 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
10
17
|
initialPageParam
|
|
11
18
|
} = defaultOptions;
|
|
12
19
|
|
|
13
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
if (defaultOptions.useDefaultOptions) {
|
|
16
|
-
throw new Error('useDefaultOptions is not supported, please use middleware instead.');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
20
|
const getPrimaryKey = () => primaryKey;
|
|
21
21
|
|
|
22
22
|
const getKey$1 = variables => getKey(primaryKey, variables);
|
|
@@ -34,9 +34,9 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
34
34
|
|
|
35
35
|
const useBaseHook = ({
|
|
36
36
|
variables,
|
|
37
|
-
...
|
|
37
|
+
...restOptions
|
|
38
38
|
}, queryClient) => {
|
|
39
|
-
return useRQHook({ ...
|
|
39
|
+
return useRQHook({ ...restOptions,
|
|
40
40
|
...overrideOptions,
|
|
41
41
|
queryKey: getKey$1(variables)
|
|
42
42
|
}, queryClient);
|
|
@@ -49,7 +49,7 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
49
49
|
queryKeyHashFn,
|
|
50
50
|
getFetchOptions
|
|
51
51
|
});
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
|
|
54
54
|
export { createBaseQuery };
|
|
55
55
|
//# sourceMappingURL=createBaseQuery.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.esm.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"createBaseQuery.esm.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type { AdditionalQueryOptions, Middleware } from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalQueryOptions<any, any> {\n use?: Middleware[]\n variables?: any\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n throw new Error(\n 'useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKey: getKey(variables),\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n }\n }\n\n const useBaseHook = (\n { variables, ...restOptions }: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...restOptions,\n ...overrideOptions,\n queryKey: getKey(variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getFetchOptions,\n })\n}\n"],"names":["createBaseQuery","defaultOptions","useRQHook","overrideOptions","process","env","NODE_ENV","useDefaultOptions","Error","primaryKey","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","getPrimaryKey","getKey","variables","getQueryKey","getFetchOptions","queryKey","useBaseHook","restOptions","queryClient","Object","assign","withMiddleware"],"mappings":";;AAuBO,MAAMA,eAAe,GAAG,CAC7BC,cAD6B,EAE7BC,SAF6B,EAG7BC,eAH6B,KAIrB;AACR,EAAA,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;IACA,IAAIL,cAAc,CAACM,iBAAnB,EAAsC;AACpC,MAAA,MAAM,IAAIC,KAAJ,CACJ,oEADI,CAAN,CAAA;AAGD,KAAA;AACF,GAAA;;EAED,MAAM;IACJC,UADI;IAEJC,OAFI;IAGJC,cAHI;IAIJC,oBAJI;IAKJC,gBALI;AAMJC,IAAAA,gBAAAA;AANI,GAAA,GAOFb,cAPJ,CAAA;;EASA,MAAMc,aAAa,GAAG,MAAMN,UAA5B,CAAA;;EAEA,MAAMO,QAAM,GAAIC,SAAD,IAAqBC,MAAW,CAACT,UAAD,EAAaQ,SAAb,CAA/C,CAAA;;EAEA,MAAME,eAAe,GAAIF,SAAD,IAAoB;IAC1C,OAAO;AACLG,MAAAA,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CADX;MAELP,OAFK;MAGLC,cAHK;MAILC,oBAJK;MAKLC,gBALK;AAMLC,MAAAA,gBAAAA;KANF,CAAA;GADF,CAAA;;EAWA,MAAMO,WAAW,GAAG,CAClB;IAAEJ,SAAF;IAAa,GAAGK,WAAAA;GADE,EAElBC,WAFkB,KAGf;AACH,IAAA,OAAOrB,SAAS,CACd,EACE,GAAGoB,WADL;AAEE,MAAA,GAAGnB,eAFL;MAGEiB,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CAAA;KAJJ,EAMdM,WANc,CAAhB,CAAA;GAJF,CAAA;;AAcA,EAAA,OAAOC,MAAM,CAACC,MAAP,CAAcC,cAAc,CAACL,WAAD,EAAcpB,cAAd,EAA8B,SAA9B,CAA5B,EAAsE;IAC3Ec,aAD2E;YAE3EC,QAF2E;IAG3EN,OAH2E;IAI3EC,cAJ2E;AAK3EQ,IAAAA,eAAAA;AAL2E,GAAtE,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -4,7 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var utils = require('./utils.js');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const createBaseQuery = (defaultOptions, useRQHook, overrideOptions) => {
|
|
8
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
if (defaultOptions.useDefaultOptions) {
|
|
11
|
+
throw new Error('useDefaultOptions is not supported, please use middleware instead.');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
const {
|
|
9
16
|
primaryKey,
|
|
10
17
|
queryFn,
|
|
@@ -14,13 +21,6 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
14
21
|
initialPageParam
|
|
15
22
|
} = defaultOptions;
|
|
16
23
|
|
|
17
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
if (defaultOptions.useDefaultOptions) {
|
|
20
|
-
throw new Error('useDefaultOptions is not supported, please use middleware instead.');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
24
|
const getPrimaryKey = () => primaryKey;
|
|
25
25
|
|
|
26
26
|
const getKey = variables => utils.getKey(primaryKey, variables);
|
|
@@ -38,9 +38,9 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
38
38
|
|
|
39
39
|
const useBaseHook = ({
|
|
40
40
|
variables,
|
|
41
|
-
...
|
|
41
|
+
...restOptions
|
|
42
42
|
}, queryClient) => {
|
|
43
|
-
return useRQHook({ ...
|
|
43
|
+
return useRQHook({ ...restOptions,
|
|
44
44
|
...overrideOptions,
|
|
45
45
|
queryKey: getKey(variables)
|
|
46
46
|
}, queryClient);
|
|
@@ -53,7 +53,7 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
53
53
|
queryKeyHashFn,
|
|
54
54
|
getFetchOptions
|
|
55
55
|
});
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
|
|
58
58
|
exports.createBaseQuery = createBaseQuery;
|
|
59
59
|
//# sourceMappingURL=createBaseQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"createBaseQuery.js","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type { AdditionalQueryOptions, Middleware } from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalQueryOptions<any, any> {\n use?: Middleware[]\n variables?: any\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n throw new Error(\n 'useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKey: getKey(variables),\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n }\n }\n\n const useBaseHook = (\n { variables, ...restOptions }: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...restOptions,\n ...overrideOptions,\n queryKey: getKey(variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getFetchOptions,\n })\n}\n"],"names":["createBaseQuery","defaultOptions","useRQHook","overrideOptions","process","env","NODE_ENV","useDefaultOptions","Error","primaryKey","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","getPrimaryKey","getKey","variables","getQueryKey","getFetchOptions","queryKey","useBaseHook","restOptions","queryClient","Object","assign","withMiddleware"],"mappings":";;;;;;AAuBO,MAAMA,eAAe,GAAG,CAC7BC,cAD6B,EAE7BC,SAF6B,EAG7BC,eAH6B,KAIrB;AACR,EAAA,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;IACA,IAAIL,cAAc,CAACM,iBAAnB,EAAsC;AACpC,MAAA,MAAM,IAAIC,KAAJ,CACJ,oEADI,CAAN,CAAA;AAGD,KAAA;AACF,GAAA;;EAED,MAAM;IACJC,UADI;IAEJC,OAFI;IAGJC,cAHI;IAIJC,oBAJI;IAKJC,gBALI;AAMJC,IAAAA,gBAAAA;AANI,GAAA,GAOFb,cAPJ,CAAA;;EASA,MAAMc,aAAa,GAAG,MAAMN,UAA5B,CAAA;;EAEA,MAAMO,MAAM,GAAIC,SAAD,IAAqBC,YAAW,CAACT,UAAD,EAAaQ,SAAb,CAA/C,CAAA;;EAEA,MAAME,eAAe,GAAIF,SAAD,IAAoB;IAC1C,OAAO;AACLG,MAAAA,QAAQ,EAAEJ,MAAM,CAACC,SAAD,CADX;MAELP,OAFK;MAGLC,cAHK;MAILC,oBAJK;MAKLC,gBALK;AAMLC,MAAAA,gBAAAA;KANF,CAAA;GADF,CAAA;;EAWA,MAAMO,WAAW,GAAG,CAClB;IAAEJ,SAAF;IAAa,GAAGK,WAAAA;GADE,EAElBC,WAFkB,KAGf;AACH,IAAA,OAAOrB,SAAS,CACd,EACE,GAAGoB,WADL;AAEE,MAAA,GAAGnB,eAFL;MAGEiB,QAAQ,EAAEJ,MAAM,CAACC,SAAD,CAAA;KAJJ,EAMdM,WANc,CAAhB,CAAA;GAJF,CAAA;;AAcA,EAAA,OAAOC,MAAM,CAACC,MAAP,CAAcC,oBAAc,CAACL,WAAD,EAAcpB,cAAd,EAA8B,SAA9B,CAA5B,EAAsE;IAC3Ec,aAD2E;IAE3EC,MAF2E;IAG3EN,OAH2E;IAI3EC,cAJ2E;AAK3EQ,IAAAA,eAAAA;AAL2E,GAAtE,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { withMiddleware, getKey } from './utils.mjs';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const createBaseQuery = (defaultOptions, useRQHook, overrideOptions) => {
|
|
4
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
if (defaultOptions.useDefaultOptions) {
|
|
7
|
+
throw new Error('useDefaultOptions is not supported, please use middleware instead.');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
const {
|
|
5
12
|
primaryKey,
|
|
6
13
|
queryFn,
|
|
@@ -10,13 +17,6 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
10
17
|
initialPageParam
|
|
11
18
|
} = defaultOptions;
|
|
12
19
|
|
|
13
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
if (defaultOptions.useDefaultOptions) {
|
|
16
|
-
throw new Error('useDefaultOptions is not supported, please use middleware instead.');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
20
|
const getPrimaryKey = () => primaryKey;
|
|
21
21
|
|
|
22
22
|
const getKey$1 = variables => getKey(primaryKey, variables);
|
|
@@ -34,9 +34,9 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
34
34
|
|
|
35
35
|
const useBaseHook = ({
|
|
36
36
|
variables,
|
|
37
|
-
...
|
|
37
|
+
...restOptions
|
|
38
38
|
}, queryClient) => {
|
|
39
|
-
return useRQHook({ ...
|
|
39
|
+
return useRQHook({ ...restOptions,
|
|
40
40
|
...overrideOptions,
|
|
41
41
|
queryKey: getKey$1(variables)
|
|
42
42
|
}, queryClient);
|
|
@@ -49,7 +49,7 @@ function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
|
|
|
49
49
|
queryKeyHashFn,
|
|
50
50
|
getFetchOptions
|
|
51
51
|
});
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
|
|
54
54
|
export { createBaseQuery };
|
|
55
55
|
//# sourceMappingURL=createBaseQuery.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.mjs","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type {
|
|
1
|
+
{"version":3,"file":"createBaseQuery.mjs","sources":["../../src/createBaseQuery.ts"],"sourcesContent":["import type {\n QueryClient,\n UseBaseQueryOptions,\n UseInfiniteQueryOptions,\n} from '@tanstack/react-query'\n\nimport type { AdditionalQueryOptions, Middleware } from './types'\nimport { getKey as getQueryKey, withMiddleware } from './utils'\n\ninterface CreateBaseQueryOptions\n extends Omit<UseInfiniteQueryOptions, 'queryKey' | 'queryFn'>,\n AdditionalQueryOptions<any, any> {\n use?: Middleware[]\n variables?: any\n}\n\ntype QueryBaseHookOptions = Omit<\n UseBaseQueryOptions,\n 'queryKey' | 'queryFn'\n> & {\n variables?: any\n}\n\nexport const createBaseQuery = (\n defaultOptions: any,\n useRQHook: (options: any, queryClient?: any) => any,\n overrideOptions?: QueryBaseHookOptions\n): any => {\n if (process.env.NODE_ENV !== 'production') {\n // @ts-ignore\n if (defaultOptions.useDefaultOptions) {\n throw new Error(\n 'useDefaultOptions is not supported, please use middleware instead.'\n )\n }\n }\n\n const {\n primaryKey,\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n } = defaultOptions as CreateBaseQueryOptions\n\n const getPrimaryKey = () => primaryKey\n\n const getKey = (variables?: any) => getQueryKey(primaryKey, variables)\n\n const getFetchOptions = (variables: any) => {\n return {\n queryKey: getKey(variables),\n queryFn,\n queryKeyHashFn,\n getPreviousPageParam,\n getNextPageParam,\n initialPageParam,\n }\n }\n\n const useBaseHook = (\n { variables, ...restOptions }: QueryBaseHookOptions,\n queryClient?: QueryClient\n ) => {\n return useRQHook(\n {\n ...restOptions,\n ...overrideOptions,\n queryKey: getKey(variables),\n },\n queryClient\n )\n }\n\n return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {\n getPrimaryKey,\n getKey,\n queryFn,\n queryKeyHashFn,\n getFetchOptions,\n })\n}\n"],"names":["createBaseQuery","defaultOptions","useRQHook","overrideOptions","process","env","NODE_ENV","useDefaultOptions","Error","primaryKey","queryFn","queryKeyHashFn","getPreviousPageParam","getNextPageParam","initialPageParam","getPrimaryKey","getKey","variables","getQueryKey","getFetchOptions","queryKey","useBaseHook","restOptions","queryClient","Object","assign","withMiddleware"],"mappings":";;AAuBO,MAAMA,eAAe,GAAG,CAC7BC,cAD6B,EAE7BC,SAF6B,EAG7BC,eAH6B,KAIrB;AACR,EAAA,IAAIC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;IACA,IAAIL,cAAc,CAACM,iBAAnB,EAAsC;AACpC,MAAA,MAAM,IAAIC,KAAJ,CACJ,oEADI,CAAN,CAAA;AAGD,KAAA;AACF,GAAA;;EAED,MAAM;IACJC,UADI;IAEJC,OAFI;IAGJC,cAHI;IAIJC,oBAJI;IAKJC,gBALI;AAMJC,IAAAA,gBAAAA;AANI,GAAA,GAOFb,cAPJ,CAAA;;EASA,MAAMc,aAAa,GAAG,MAAMN,UAA5B,CAAA;;EAEA,MAAMO,QAAM,GAAIC,SAAD,IAAqBC,MAAW,CAACT,UAAD,EAAaQ,SAAb,CAA/C,CAAA;;EAEA,MAAME,eAAe,GAAIF,SAAD,IAAoB;IAC1C,OAAO;AACLG,MAAAA,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CADX;MAELP,OAFK;MAGLC,cAHK;MAILC,oBAJK;MAKLC,gBALK;AAMLC,MAAAA,gBAAAA;KANF,CAAA;GADF,CAAA;;EAWA,MAAMO,WAAW,GAAG,CAClB;IAAEJ,SAAF;IAAa,GAAGK,WAAAA;GADE,EAElBC,WAFkB,KAGf;AACH,IAAA,OAAOrB,SAAS,CACd,EACE,GAAGoB,WADL;AAEE,MAAA,GAAGnB,eAFL;MAGEiB,QAAQ,EAAEJ,QAAM,CAACC,SAAD,CAAA;KAJJ,EAMdM,WANc,CAAhB,CAAA;GAJF,CAAA;;AAcA,EAAA,OAAOC,MAAM,CAACC,MAAP,CAAcC,cAAc,CAACL,WAAD,EAAcpB,cAAd,EAA8B,SAA9B,CAA5B,EAAsE;IAC3Ec,aAD2E;YAE3EC,QAF2E;IAG3EN,OAH2E;IAI3EC,cAJ2E;AAK3EQ,IAAAA,eAAAA;AAL2E,GAAtE,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfiniteQuery.esm.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {
|
|
1
|
+
{"version":3,"file":"createInfiniteQuery.esm.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateInfiniteQueryOptions, InfiniteQueryHook } from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = Error,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery)\n}\n"],"names":["createInfiniteQuery","options","createBaseQuery","useInfiniteQuery"],"mappings":";;;AAKaA,MAAAA,mBAAmB,GAM9BC,OANiC,IAO8B;AAC/D,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,gBAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfiniteQuery.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {
|
|
1
|
+
{"version":3,"file":"createInfiniteQuery.js","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateInfiniteQueryOptions, InfiniteQueryHook } from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = Error,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery)\n}\n"],"names":["createInfiniteQuery","options","createBaseQuery","useInfiniteQuery"],"mappings":";;;;;;;AAKaA,MAAAA,mBAAmB,GAM9BC,OANiC,IAO8B;AAC/D,EAAA,OAAOC,+BAAe,CAACD,OAAD,EAAUE,2BAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfiniteQuery.mjs","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {
|
|
1
|
+
{"version":3,"file":"createInfiniteQuery.mjs","sources":["../../src/createInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateInfiniteQueryOptions, InfiniteQueryHook } from './types'\n\nexport const createInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = Error,\n TPageParam = number\n>(\n options: CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>\n): InfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery)\n}\n"],"names":["createInfiniteQuery","options","createBaseQuery","useInfiniteQuery"],"mappings":";;;AAKaA,MAAAA,mBAAmB,GAM9BC,OANiC,IAO8B;AAC/D,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,gBAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMutation.esm.js","sources":["../../src/createMutation.ts"],"sourcesContent":["import { useMutation } from '@tanstack/react-query'\n\nimport type { CreateMutationOptions,
|
|
1
|
+
{"version":3,"file":"createMutation.esm.js","sources":["../../src/createMutation.ts"],"sourcesContent":["import { useMutation } from '@tanstack/react-query'\n\nimport type { CreateMutationOptions, MutationHook } from './types'\nimport { withMiddleware } from './utils'\n\nexport const createMutation = <\n TData = unknown,\n TVariables = void,\n TError = Error,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError> => {\n const getKey = () => defaultOptions.mutationKey\n\n return Object.assign(\n withMiddleware(useMutation, defaultOptions, 'mutations'),\n {\n getKey,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError>\n}\n"],"names":["createMutation","defaultOptions","getKey","mutationKey","Object","assign","withMiddleware","useMutation","mutationFn"],"mappings":";;;AAKaA,MAAAA,cAAc,GAMzBC,cAN4B,IAOgB;AAC5C,EAAA,MAAMC,MAAM,GAAG,MAAMD,cAAc,CAACE,WAApC,CAAA;;AAEA,EAAA,OAAOC,MAAM,CAACC,MAAP,CACLC,cAAc,CAACC,WAAD,EAAcN,cAAd,EAA8B,WAA9B,CADT,EAEL;IACEC,MADF;IAEEM,UAAU,EAAEP,cAAc,CAACO,UAAAA;AAF7B,GAFK,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMutation.js","sources":["../../src/createMutation.ts"],"sourcesContent":["import { useMutation } from '@tanstack/react-query'\n\nimport type { CreateMutationOptions,
|
|
1
|
+
{"version":3,"file":"createMutation.js","sources":["../../src/createMutation.ts"],"sourcesContent":["import { useMutation } from '@tanstack/react-query'\n\nimport type { CreateMutationOptions, MutationHook } from './types'\nimport { withMiddleware } from './utils'\n\nexport const createMutation = <\n TData = unknown,\n TVariables = void,\n TError = Error,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError> => {\n const getKey = () => defaultOptions.mutationKey\n\n return Object.assign(\n withMiddleware(useMutation, defaultOptions, 'mutations'),\n {\n getKey,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError>\n}\n"],"names":["createMutation","defaultOptions","getKey","mutationKey","Object","assign","withMiddleware","useMutation","mutationFn"],"mappings":";;;;;;;AAKaA,MAAAA,cAAc,GAMzBC,cAN4B,IAOgB;AAC5C,EAAA,MAAMC,MAAM,GAAG,MAAMD,cAAc,CAACE,WAApC,CAAA;;AAEA,EAAA,OAAOC,MAAM,CAACC,MAAP,CACLC,oBAAc,CAACC,sBAAD,EAAcN,cAAd,EAA8B,WAA9B,CADT,EAEL;IACEC,MADF;IAEEM,UAAU,EAAEP,cAAc,CAACO,UAAAA;AAF7B,GAFK,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMutation.mjs","sources":["../../src/createMutation.ts"],"sourcesContent":["import { useMutation } from '@tanstack/react-query'\n\nimport type { CreateMutationOptions,
|
|
1
|
+
{"version":3,"file":"createMutation.mjs","sources":["../../src/createMutation.ts"],"sourcesContent":["import { useMutation } from '@tanstack/react-query'\n\nimport type { CreateMutationOptions, MutationHook } from './types'\nimport { withMiddleware } from './utils'\n\nexport const createMutation = <\n TData = unknown,\n TVariables = void,\n TError = Error,\n TContext = unknown\n>(\n defaultOptions: CreateMutationOptions<TData, TVariables, TError, TContext>\n): MutationHook<TData, TVariables, TError> => {\n const getKey = () => defaultOptions.mutationKey\n\n return Object.assign(\n withMiddleware(useMutation, defaultOptions, 'mutations'),\n {\n getKey,\n mutationFn: defaultOptions.mutationFn,\n }\n ) as MutationHook<TData, TVariables, TError>\n}\n"],"names":["createMutation","defaultOptions","getKey","mutationKey","Object","assign","withMiddleware","useMutation","mutationFn"],"mappings":";;;AAKaA,MAAAA,cAAc,GAMzBC,cAN4B,IAOgB;AAC5C,EAAA,MAAMC,MAAM,GAAG,MAAMD,cAAc,CAACE,WAApC,CAAA;;AAEA,EAAA,OAAOC,MAAM,CAACC,MAAP,CACLC,cAAc,CAACC,WAAD,EAAcN,cAAd,EAA8B,WAA9B,CADT,EAEL;IACEC,MADF;IAEEM,UAAU,EAAEP,cAAc,CAACO,UAAAA;AAF7B,GAFK,CAAP,CAAA;AAOD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQuery.esm.js","sources":["../../src/createQuery.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateQueryOptions,
|
|
1
|
+
{"version":3,"file":"createQuery.esm.js","sources":["../../src/createQuery.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateQueryOptions, QueryHook } from './types'\n\nexport const createQuery = <TFnData, TVariables = any, TError = Error>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, useQuery)\n}\n"],"names":["createQuery","options","createBaseQuery","useQuery"],"mappings":";;;AAKaA,MAAAA,WAAW,GACtBC,OADyB,IAEkB;AAC3C,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,QAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQuery.js","sources":["../../src/createQuery.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateQueryOptions,
|
|
1
|
+
{"version":3,"file":"createQuery.js","sources":["../../src/createQuery.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateQueryOptions, QueryHook } from './types'\n\nexport const createQuery = <TFnData, TVariables = any, TError = Error>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, useQuery)\n}\n"],"names":["createQuery","options","createBaseQuery","useQuery"],"mappings":";;;;;;;AAKaA,MAAAA,WAAW,GACtBC,OADyB,IAEkB;AAC3C,EAAA,OAAOC,+BAAe,CAACD,OAAD,EAAUE,mBAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQuery.mjs","sources":["../../src/createQuery.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateQueryOptions,
|
|
1
|
+
{"version":3,"file":"createQuery.mjs","sources":["../../src/createQuery.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateQueryOptions, QueryHook } from './types'\n\nexport const createQuery = <TFnData, TVariables = any, TError = Error>(\n options: CreateQueryOptions<TFnData, TVariables, TError>\n): QueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, useQuery)\n}\n"],"names":["createQuery","options","createBaseQuery","useQuery"],"mappings":";;;AAKaA,MAAAA,WAAW,GACtBC,OADyB,IAEkB;AAC3C,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,QAAV,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
2
|
import { createBaseQuery } from './createBaseQuery.esm.js';
|
|
3
|
+
import { suspenseOptions } from './utils.esm.js';
|
|
3
4
|
|
|
4
5
|
const createSuspenseInfiniteQuery = options => {
|
|
5
|
-
return createBaseQuery(options, useInfiniteQuery,
|
|
6
|
-
enabled: true,
|
|
7
|
-
suspense: true,
|
|
8
|
-
throwOnError: true,
|
|
9
|
-
// compatible with ReactQuery v4
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
useErrorBoundary: true
|
|
12
|
-
});
|
|
6
|
+
return createBaseQuery(options, useInfiniteQuery, suspenseOptions);
|
|
13
7
|
};
|
|
14
8
|
|
|
15
9
|
export { createSuspenseInfiniteQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspenseInfiniteQuery.esm.js","sources":["../../src/createSuspenseInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateSuspenseInfiniteQueryOptions,\n
|
|
1
|
+
{"version":3,"file":"createSuspenseInfiniteQuery.esm.js","sources":["../../src/createSuspenseInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { suspenseOptions } from './utils'\n\nexport const createSuspenseInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = Error,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery, suspenseOptions)\n}\n"],"names":["createSuspenseInfiniteQuery","options","createBaseQuery","useInfiniteQuery","suspenseOptions"],"mappings":";;;;AASaA,MAAAA,2BAA2B,GAMtCC,OANyC,IAY8B;AACvE,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,gBAAV,EAA4BC,eAA5B,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -4,16 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var reactQuery = require('@tanstack/react-query');
|
|
6
6
|
var createBaseQuery = require('./createBaseQuery.js');
|
|
7
|
+
var utils = require('./utils.js');
|
|
7
8
|
|
|
8
9
|
const createSuspenseInfiniteQuery = options => {
|
|
9
|
-
return createBaseQuery.createBaseQuery(options, reactQuery.useInfiniteQuery,
|
|
10
|
-
enabled: true,
|
|
11
|
-
suspense: true,
|
|
12
|
-
throwOnError: true,
|
|
13
|
-
// compatible with ReactQuery v4
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
useErrorBoundary: true
|
|
16
|
-
});
|
|
10
|
+
return createBaseQuery.createBaseQuery(options, reactQuery.useInfiniteQuery, utils.suspenseOptions);
|
|
17
11
|
};
|
|
18
12
|
|
|
19
13
|
exports.createSuspenseInfiniteQuery = createSuspenseInfiniteQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspenseInfiniteQuery.js","sources":["../../src/createSuspenseInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateSuspenseInfiniteQueryOptions,\n
|
|
1
|
+
{"version":3,"file":"createSuspenseInfiniteQuery.js","sources":["../../src/createSuspenseInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { suspenseOptions } from './utils'\n\nexport const createSuspenseInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = Error,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery, suspenseOptions)\n}\n"],"names":["createSuspenseInfiniteQuery","options","createBaseQuery","useInfiniteQuery","suspenseOptions"],"mappings":";;;;;;;;AASaA,MAAAA,2BAA2B,GAMtCC,OANyC,IAY8B;AACvE,EAAA,OAAOC,+BAAe,CAACD,OAAD,EAAUE,2BAAV,EAA4BC,qBAA5B,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
2
|
import { createBaseQuery } from './createBaseQuery.mjs';
|
|
3
|
+
import { suspenseOptions } from './utils.mjs';
|
|
3
4
|
|
|
4
5
|
const createSuspenseInfiniteQuery = options => {
|
|
5
|
-
return createBaseQuery(options, useInfiniteQuery,
|
|
6
|
-
enabled: true,
|
|
7
|
-
suspense: true,
|
|
8
|
-
throwOnError: true,
|
|
9
|
-
// compatible with ReactQuery v4
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
useErrorBoundary: true
|
|
12
|
-
});
|
|
6
|
+
return createBaseQuery(options, useInfiniteQuery, suspenseOptions);
|
|
13
7
|
};
|
|
14
8
|
|
|
15
9
|
export { createSuspenseInfiniteQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspenseInfiniteQuery.mjs","sources":["../../src/createSuspenseInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateSuspenseInfiniteQueryOptions,\n
|
|
1
|
+
{"version":3,"file":"createSuspenseInfiniteQuery.mjs","sources":["../../src/createSuspenseInfiniteQuery.ts"],"sourcesContent":["import { useInfiniteQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type {\n CreateSuspenseInfiniteQueryOptions,\n SuspenseInfiniteQueryHook,\n} from './types'\nimport { suspenseOptions } from './utils'\n\nexport const createSuspenseInfiniteQuery = <\n TFnData,\n TVariables = any,\n TError = Error,\n TPageParam = number\n>(\n options: CreateSuspenseInfiniteQueryOptions<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n): SuspenseInfiniteQueryHook<TFnData, TVariables, TError, TPageParam> => {\n return createBaseQuery(options, useInfiniteQuery, suspenseOptions)\n}\n"],"names":["createSuspenseInfiniteQuery","options","createBaseQuery","useInfiniteQuery","suspenseOptions"],"mappings":";;;;AASaA,MAAAA,2BAA2B,GAMtCC,OANyC,IAY8B;AACvE,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,gBAAV,EAA4BC,eAA5B,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { createBaseQuery } from './createBaseQuery.esm.js';
|
|
3
|
+
import { suspenseOptions } from './utils.esm.js';
|
|
3
4
|
|
|
4
5
|
const createSuspenseQuery = options => {
|
|
5
|
-
return createBaseQuery(options, useQuery,
|
|
6
|
-
enabled: true,
|
|
7
|
-
suspense: true,
|
|
8
|
-
throwOnError: true,
|
|
9
|
-
// compatible with ReactQuery v4
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
useErrorBoundary: true
|
|
12
|
-
});
|
|
6
|
+
return createBaseQuery(options, useQuery, suspenseOptions);
|
|
13
7
|
};
|
|
14
8
|
|
|
15
9
|
export { createSuspenseQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspenseQuery.esm.js","sources":["../../src/createSuspenseQuery.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"createSuspenseQuery.esm.js","sources":["../../src/createSuspenseQuery.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateSuspenseQueryOptions, SuspenseQueryHook } from './types'\nimport { suspenseOptions } from './utils'\n\nexport const createSuspenseQuery = <TFnData, TVariables = any, TError = Error>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, useQuery, suspenseOptions)\n}\n"],"names":["createSuspenseQuery","options","createBaseQuery","useQuery","suspenseOptions"],"mappings":";;;;AAMaA,MAAAA,mBAAmB,GAC9BC,OADiC,IAEkB;AACnD,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,QAAV,EAAoBC,eAApB,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -4,16 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var reactQuery = require('@tanstack/react-query');
|
|
6
6
|
var createBaseQuery = require('./createBaseQuery.js');
|
|
7
|
+
var utils = require('./utils.js');
|
|
7
8
|
|
|
8
9
|
const createSuspenseQuery = options => {
|
|
9
|
-
return createBaseQuery.createBaseQuery(options, reactQuery.useQuery,
|
|
10
|
-
enabled: true,
|
|
11
|
-
suspense: true,
|
|
12
|
-
throwOnError: true,
|
|
13
|
-
// compatible with ReactQuery v4
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
useErrorBoundary: true
|
|
16
|
-
});
|
|
10
|
+
return createBaseQuery.createBaseQuery(options, reactQuery.useQuery, utils.suspenseOptions);
|
|
17
11
|
};
|
|
18
12
|
|
|
19
13
|
exports.createSuspenseQuery = createSuspenseQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspenseQuery.js","sources":["../../src/createSuspenseQuery.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"createSuspenseQuery.js","sources":["../../src/createSuspenseQuery.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateSuspenseQueryOptions, SuspenseQueryHook } from './types'\nimport { suspenseOptions } from './utils'\n\nexport const createSuspenseQuery = <TFnData, TVariables = any, TError = Error>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, useQuery, suspenseOptions)\n}\n"],"names":["createSuspenseQuery","options","createBaseQuery","useQuery","suspenseOptions"],"mappings":";;;;;;;;AAMaA,MAAAA,mBAAmB,GAC9BC,OADiC,IAEkB;AACnD,EAAA,OAAOC,+BAAe,CAACD,OAAD,EAAUE,mBAAV,EAAoBC,qBAApB,CAAtB,CAAA;AACD;;;;"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { createBaseQuery } from './createBaseQuery.mjs';
|
|
3
|
+
import { suspenseOptions } from './utils.mjs';
|
|
3
4
|
|
|
4
5
|
const createSuspenseQuery = options => {
|
|
5
|
-
return createBaseQuery(options, useQuery,
|
|
6
|
-
enabled: true,
|
|
7
|
-
suspense: true,
|
|
8
|
-
throwOnError: true,
|
|
9
|
-
// compatible with ReactQuery v4
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
useErrorBoundary: true
|
|
12
|
-
});
|
|
6
|
+
return createBaseQuery(options, useQuery, suspenseOptions);
|
|
13
7
|
};
|
|
14
8
|
|
|
15
9
|
export { createSuspenseQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSuspenseQuery.mjs","sources":["../../src/createSuspenseQuery.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"createSuspenseQuery.mjs","sources":["../../src/createSuspenseQuery.ts"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\n\nimport { createBaseQuery } from './createBaseQuery'\nimport type { CreateSuspenseQueryOptions, SuspenseQueryHook } from './types'\nimport { suspenseOptions } from './utils'\n\nexport const createSuspenseQuery = <TFnData, TVariables = any, TError = Error>(\n options: CreateSuspenseQueryOptions<TFnData, TVariables, TError>\n): SuspenseQueryHook<TFnData, TVariables, TError> => {\n return createBaseQuery(options, useQuery, suspenseOptions)\n}\n"],"names":["createSuspenseQuery","options","createBaseQuery","useQuery","suspenseOptions"],"mappings":";;;;AAMaA,MAAAA,mBAAmB,GAC9BC,OADiC,IAEkB;AACnD,EAAA,OAAOC,eAAe,CAACD,OAAD,EAAUE,QAAV,EAAoBC,eAApB,CAAtB,CAAA;AACD;;;;"}
|
package/build/lib/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './createSuspenseQuery';
|
|
|
3
3
|
export * from './createInfiniteQuery';
|
|
4
4
|
export * from './createSuspenseInfiniteQuery';
|
|
5
5
|
export * from './createMutation';
|
|
6
|
+
export * from './types';
|
|
6
7
|
export { getKey } from './utils';
|
|
7
|
-
export type { CreateQueryOptions, QueryHookOptions, QueryHook, QueryHookResult, CreateInfiniteQueryOptions, InfiniteQueryHookOptions, InfiniteQueryHook, InfiniteQueryHookResult, CreateSuspenseQueryOptions, SuspenseQueryHook, SuspenseQueryHookOptions, SuspenseQueryHookResult, CreateSuspenseInfiniteQueryOptions, SuspenseInfiniteQueryHook, SuspenseInfiniteQueryHookOptions, SuspenseInfiniteQueryHookResult, CreateMutationOptions, MutationHookOptions, MutationHook, inferVariables, inferData, inferFnData, inferOptions, inferError, inferCreateOptions, Middleware, } from './types';
|