react-query-kit 3.0.0-beta.3 → 3.0.0-rc.2

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 CHANGED
@@ -46,6 +46,7 @@ English | [简体中文](./README-zh_CN.md)
46
46
  - [createSuspenseQuery](#createsuspensequery)
47
47
  - [createSuspenseInfiniteQuery](#createsuspenseinfinitequery)
48
48
  - [createMutation](#createmutation)
49
+ - [router](#router)
49
50
  - [Middleware](#middleware)
50
51
  - [Type inference](#type-inference)
51
52
  - [FAQ](#faq)
@@ -315,10 +316,6 @@ const useAddTodo = createMutation({
315
316
  mutationFn: async (variables: { title: string; content: string }) =>
316
317
  fetch('/post', {
317
318
  method: 'POST',
318
- headers: {
319
- Accept: 'application/json',
320
- 'Content-Type': 'application/json',
321
- },
322
319
  body: JSON.stringify(variables),
323
320
  }).then(res => res.json()),
324
321
  onSuccess(data, variables, context) {
@@ -376,6 +373,76 @@ Returns
376
373
  - `getOptions: () => UseMutationOptions`
377
374
  - `mutationFn: MutationFunction<TData, TVariables>`
378
375
 
376
+ ## router
377
+
378
+ `router` which allow you to create a shape of your entire API
379
+
380
+ ### Usage
381
+
382
+ ```tsx
383
+ import { router } from 'react-query-kit'
384
+
385
+ const posts = router(`posts`, {
386
+ byId: router.query({
387
+ fetcher: (variables: { id: number }) =>
388
+ fetch(`/posts/${variables.id}`).then(res => res.json()),
389
+ use: [myMiddleware],
390
+ }),
391
+
392
+ list: router.infiniteQuery({
393
+ fetcher: (_variables, { pageParam }) =>
394
+ fetch(`/posts/?cursor=${pageParam}`).then(res => res.json()),
395
+ getNextPageParam: lastPage => lastPage.nextCursor,
396
+ initialPageParam: 0,
397
+ }),
398
+
399
+ add: router.mutation({
400
+ mutationFn: async (variables: { title: string; content: string }) =>
401
+ fetch('/posts', {
402
+ method: 'POST',
403
+ body: JSON.stringify(variables),
404
+ }).then(res => res.json()),
405
+ }),
406
+ })
407
+
408
+ // get root key
409
+ posts.getKey() // ['posts']
410
+
411
+ // hooks
412
+ posts.byId.useQuery({ variables: { id: 1 } })
413
+ posts.byId.useSuspenseQuery({ variables: { id: 1 } })
414
+ posts.list.useInfiniteQuery()
415
+ posts.list.useSuspenseInfiniteQuery()
416
+ posts.add.useMutation()
417
+
418
+ // expose methods
419
+ posts.byId.getKey({ id: 1 }) // ['posts', 'byId', { id: 1 }]
420
+ posts.byId.getFetchOptions({ id: 1 })
421
+ posts.byId.getOptions({ id: 1 })
422
+ posts.byId.fetcher({ id: 1 })
423
+ posts.add.getKey() // ['posts', 'add']
424
+ posts.add.getOptions()
425
+ posts.add.mutationFn({ title: 'title', content: 'content' })
426
+
427
+ // infer types
428
+ type Data = inferData<typeof posts.list>
429
+ type FnData = inferFnData<typeof posts.list>
430
+ type Variables = inferVariables<typeof posts.list>
431
+ ```
432
+
433
+ ## API Reference
434
+
435
+ `type Router = (key: string, config: TConfig) => TRouter`
436
+
437
+ Expose Methods
438
+
439
+ - `query`
440
+ Similar to `createQuery` but without option `queryKey`
441
+ - `infiniteQuery`
442
+ Similar to `createInfiniteQuery` but without option `queryKey`
443
+ - `mutation`
444
+ Similar to `createMutation` but without option `mutationKey`
445
+
379
446
  ## Middleware
380
447
 
381
448
  This feature is inspired by the [Middleware feature from SWR](https://swr.vercel.app/docs/middleware). The middleware feature is a new addition in ReactQueryKit 1.5.0 that enables you to execute logic before and after hooks.
@@ -390,9 +457,9 @@ import { Middleware, MutationHook, QueryHook, getKey } from 'react-query-kit'
390
457
 
391
458
  const logger: Middleware<QueryHook<Response, Variables>> = useQueryNext => {
392
459
  return options => {
393
- const logger = useLogger()
460
+ const log = useLogger()
394
461
  const fetcher = (variables, context) => {
395
- logger.log(context.queryKey, variables)
462
+ log(context.queryKey, variables)
396
463
  return options.fetcher(variables, context)
397
464
  }
398
465
 
@@ -404,7 +471,6 @@ const logger: Middleware<QueryHook<Response, Variables>> = useQueryNext => {
404
471
  }
405
472
 
406
473
  const useUser = createQuery<Response, Variables>({
407
- // ...
408
474
  use: [logger],
409
475
  })
410
476
 
@@ -524,7 +590,7 @@ inferOptions<typeof useProjects> // InfiniteQueryHookOptions<...>
524
590
 
525
591
  ### What is the difference between `getFetchOptions` and `getOptions`?
526
592
 
527
- `getFetchOptions` will only return necessary options, while options like `staleTime` and `retry` will be ignored
593
+ `getFetchOptions` will only return necessary options, while options like `staleTime` and `retry` will be omited
528
594
 
529
595
  ```ts
530
596
  const useTest1 = createQuery({
@@ -4,4 +4,5 @@ export * from './createInfiniteQuery';
4
4
  export * from './createSuspenseInfiniteQuery';
5
5
  export * from './createMutation';
6
6
  export * from './types';
7
+ export * from './router';
7
8
  export { getKey } from './utils';
@@ -3,5 +3,6 @@ export { createSuspenseQuery } from './createSuspenseQuery.esm.js';
3
3
  export { createInfiniteQuery } from './createInfiniteQuery.esm.js';
4
4
  export { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery.esm.js';
5
5
  export { createMutation } from './createMutation.esm.js';
6
+ export { router } from './router.esm.js';
6
7
  export { getKey } from './utils.esm.js';
7
8
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -7,6 +7,7 @@ var createSuspenseQuery = require('./createSuspenseQuery.js');
7
7
  var createInfiniteQuery = require('./createInfiniteQuery.js');
8
8
  var createSuspenseInfiniteQuery = require('./createSuspenseInfiniteQuery.js');
9
9
  var createMutation = require('./createMutation.js');
10
+ var router = require('./router.js');
10
11
  var utils = require('./utils.js');
11
12
 
12
13
 
@@ -16,5 +17,6 @@ exports.createSuspenseQuery = createSuspenseQuery.createSuspenseQuery;
16
17
  exports.createInfiniteQuery = createInfiniteQuery.createInfiniteQuery;
17
18
  exports.createSuspenseInfiniteQuery = createSuspenseInfiniteQuery.createSuspenseInfiniteQuery;
18
19
  exports.createMutation = createMutation.createMutation;
20
+ exports.router = router.router;
19
21
  exports.getKey = utils.getKey;
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
@@ -3,5 +3,6 @@ export { createSuspenseQuery } from './createSuspenseQuery.mjs';
3
3
  export { createInfiniteQuery } from './createInfiniteQuery.mjs';
4
4
  export { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery.mjs';
5
5
  export { createMutation } from './createMutation.mjs';
6
+ export { router } from './router.mjs';
6
7
  export { getKey } from './utils.mjs';
7
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,7 @@
1
+ import type { CreateInfiniteQueryOptions, CreateMutationOptions, CreateQueryOptions, CreateRouter, RouterConfig, RouterInfiniteQuery, RouterMutation, RouterQuery } from './types';
2
+ export declare const router: {
3
+ <TConfig extends RouterConfig>(scope: string, config: TConfig): CreateRouter<TConfig>;
4
+ query<TFnData, TVariables = void, TError = Error>(options: Omit<CreateQueryOptions<TFnData, TVariables, TError>, "queryKey">): RouterQuery<TFnData, TVariables, TError>;
5
+ infiniteQuery<TFnData_1, TVariables_1 = void, TError_1 = Error, TPageParam = number>(options: Omit<CreateInfiniteQueryOptions<TFnData_1, TVariables_1, TError_1, TPageParam>, "queryKey">): RouterInfiniteQuery<TFnData_1, TVariables_1, TError_1, TPageParam>;
6
+ mutation<TFnData_2 = unknown, TVariables_2 = void, TError_2 = Error, TContext = unknown>(options: Omit<CreateMutationOptions<TFnData_2, TVariables_2, TError_2, TContext>, "mutationKey">): RouterMutation<TFnData_2, TVariables_2, TError_2, TContext>;
7
+ };
@@ -0,0 +1,49 @@
1
+ import { createInfiniteQuery } from './createInfiniteQuery.esm.js';
2
+ import { createMutation } from './createMutation.esm.js';
3
+ import { createQuery } from './createQuery.esm.js';
4
+ import { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery.esm.js';
5
+ import { createSuspenseQuery } from './createSuspenseQuery.esm.js';
6
+
7
+ const router = (scope, config) => {
8
+ return Object.entries(config).reduce((acc, [key, opts]) => {
9
+ const options = { ...opts,
10
+ [opts._type === "m" ? "mutationKey" : "queryKey"]: [scope, key]
11
+ };
12
+ acc[key] = opts._type === "m" ? {
13
+ useMutation: createMutation(options),
14
+ ...createMutation(options)
15
+ } : opts._type === "q" ? {
16
+ useQuery: createQuery(options),
17
+ useSuspenseQuery: createSuspenseQuery(options),
18
+ ...createQuery(options)
19
+ } : {
20
+ useInfiniteQuery: createInfiniteQuery(options),
21
+ useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),
22
+ ...createInfiniteQuery(options)
23
+ };
24
+ return acc;
25
+ }, {
26
+ getKey: () => [scope]
27
+ });
28
+ };
29
+
30
+ router.query = options => {
31
+ return { ...options,
32
+ _type: 'q'
33
+ };
34
+ };
35
+
36
+ router.infiniteQuery = options => {
37
+ return { ...options,
38
+ _type: 'inf'
39
+ };
40
+ };
41
+
42
+ router.mutation = options => {
43
+ return { ...options,
44
+ _type: 'm'
45
+ };
46
+ };
47
+
48
+ export { router };
49
+ //# sourceMappingURL=router.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.esm.js","sources":["../../src/router.ts"],"sourcesContent":["import { createInfiniteQuery } from './createInfiniteQuery'\nimport { createMutation } from './createMutation'\nimport { createQuery } from './createQuery'\nimport { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery'\nimport { createSuspenseQuery } from './createSuspenseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n CreateMutationOptions,\n CreateQueryOptions,\n CreateRouter,\n RouterConfig,\n RouterInfiniteQuery,\n RouterMutation,\n RouterQuery,\n} from './types'\n\nexport const router = <TConfig extends RouterConfig>(\n scope: string,\n config: TConfig\n): CreateRouter<TConfig> => {\n return Object.entries(config).reduce(\n (acc, [key, opts]) => {\n const options: any = {\n ...opts,\n [opts._type === `m` ? `mutationKey` : `queryKey`]: [scope, key],\n }\n\n acc[key] =\n opts._type === `m`\n ? {\n useMutation: createMutation(options),\n ...createMutation(options),\n }\n : opts._type === `q`\n ? {\n useQuery: createQuery(options),\n useSuspenseQuery: createSuspenseQuery(options),\n ...createQuery(options),\n }\n : {\n useInfiniteQuery: createInfiniteQuery(options),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),\n ...createInfiniteQuery(options),\n }\n\n return acc\n },\n {\n getKey: () => [scope],\n } as any\n )\n}\n\nrouter.query = <TFnData, TVariables = void, TError = CompatibleError>(\n options: Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'>\n): RouterQuery<TFnData, TVariables, TError> => {\n return {\n ...options,\n _type: 'q',\n }\n}\n\nrouter.infiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: Omit<\n CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>,\n 'queryKey'\n >\n): RouterInfiniteQuery<TFnData, TVariables, TError, TPageParam> => {\n return { ...options, _type: 'inf' }\n}\n\nrouter.mutation = <\n TFnData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n options: Omit<\n CreateMutationOptions<TFnData, TVariables, TError, TContext>,\n 'mutationKey'\n >\n): RouterMutation<TFnData, TVariables, TError, TContext> => {\n return { ...options, _type: 'm' }\n}\n"],"names":["router","scope","config","Object","entries","reduce","acc","key","opts","options","_type","useMutation","createMutation","useQuery","createQuery","useSuspenseQuery","createSuspenseQuery","useInfiniteQuery","createInfiniteQuery","useSuspenseInfiniteQuery","createSuspenseInfiniteQuery","getKey","query","infiniteQuery","mutation"],"mappings":";;;;;;MAiBaA,MAAM,GAAG,CACpBC,KADoB,EAEpBC,MAFoB,KAGM;AAC1B,EAAA,OAAOC,MAAM,CAACC,OAAP,CAAeF,MAAf,EAAuBG,MAAvB,CACL,CAACC,GAAD,EAAM,CAACC,GAAD,EAAMC,IAAN,CAAN,KAAsB;AACpB,IAAA,MAAMC,OAAY,GAAG,EACnB,GAAGD,IADgB;MAEnB,CAACA,IAAI,CAACE,KAAL,KAAA,GAAA,GAAA,aAAA,GAAA,UAAD,GAAmD,CAACT,KAAD,EAAQM,GAAR,CAAA;KAFrD,CAAA;AAKAD,IAAAA,GAAG,CAACC,GAAD,CAAH,GACEC,IAAI,CAACE,KAAL,KACI,GAAA,GAAA;AACEC,MAAAA,WAAW,EAAEC,cAAc,CAACH,OAAD,CAD7B;MAEE,GAAGG,cAAc,CAACH,OAAD,CAAA;AAFnB,KADJ,GAKID,IAAI,CAACE,KAAL,KACA,GAAA,GAAA;AACEG,MAAAA,QAAQ,EAAEC,WAAW,CAACL,OAAD,CADvB;AAEEM,MAAAA,gBAAgB,EAAEC,mBAAmB,CAACP,OAAD,CAFvC;MAGE,GAAGK,WAAW,CAACL,OAAD,CAAA;AAHhB,KADA,GAMA;AACEQ,MAAAA,gBAAgB,EAAEC,mBAAmB,CAACT,OAAD,CADvC;AAEEU,MAAAA,wBAAwB,EAAEC,2BAA2B,CAACX,OAAD,CAFvD;MAGE,GAAGS,mBAAmB,CAACT,OAAD,CAAA;KAf9B,CAAA;AAkBA,IAAA,OAAOH,GAAP,CAAA;AACD,GA1BI,EA2BL;IACEe,MAAM,EAAE,MAAM,CAACpB,KAAD,CAAA;AADhB,GA3BK,CAAP,CAAA;AA+BD,EAnCM;;AAqCPD,MAAM,CAACsB,KAAP,GACEb,OADa,IAEgC;EAC7C,OAAO,EACL,GAAGA,OADE;AAELC,IAAAA,KAAK,EAAE,GAAA;GAFT,CAAA;AAID,CAPD,CAAA;;AASAV,MAAM,CAACuB,aAAP,GAMEd,OANqB,IAU4C;EACjE,OAAO,EAAE,GAAGA,OAAL;AAAcC,IAAAA,KAAK,EAAE,KAAA;GAA5B,CAAA;AACD,CAZD,CAAA;;AAcAV,MAAM,CAACwB,QAAP,GAMEf,OANgB,IAU0C;EAC1D,OAAO,EAAE,GAAGA,OAAL;AAAcC,IAAAA,KAAK,EAAE,GAAA;GAA5B,CAAA;AACD,CAZD;;;;"}
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createInfiniteQuery = require('./createInfiniteQuery.js');
6
+ var createMutation = require('./createMutation.js');
7
+ var createQuery = require('./createQuery.js');
8
+ var createSuspenseInfiniteQuery = require('./createSuspenseInfiniteQuery.js');
9
+ var createSuspenseQuery = require('./createSuspenseQuery.js');
10
+
11
+ const router = (scope, config) => {
12
+ return Object.entries(config).reduce((acc, [key, opts]) => {
13
+ const options = { ...opts,
14
+ [opts._type === "m" ? "mutationKey" : "queryKey"]: [scope, key]
15
+ };
16
+ acc[key] = opts._type === "m" ? {
17
+ useMutation: createMutation.createMutation(options),
18
+ ...createMutation.createMutation(options)
19
+ } : opts._type === "q" ? {
20
+ useQuery: createQuery.createQuery(options),
21
+ useSuspenseQuery: createSuspenseQuery.createSuspenseQuery(options),
22
+ ...createQuery.createQuery(options)
23
+ } : {
24
+ useInfiniteQuery: createInfiniteQuery.createInfiniteQuery(options),
25
+ useSuspenseInfiniteQuery: createSuspenseInfiniteQuery.createSuspenseInfiniteQuery(options),
26
+ ...createInfiniteQuery.createInfiniteQuery(options)
27
+ };
28
+ return acc;
29
+ }, {
30
+ getKey: () => [scope]
31
+ });
32
+ };
33
+
34
+ router.query = options => {
35
+ return { ...options,
36
+ _type: 'q'
37
+ };
38
+ };
39
+
40
+ router.infiniteQuery = options => {
41
+ return { ...options,
42
+ _type: 'inf'
43
+ };
44
+ };
45
+
46
+ router.mutation = options => {
47
+ return { ...options,
48
+ _type: 'm'
49
+ };
50
+ };
51
+
52
+ exports.router = router;
53
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { createInfiniteQuery } from './createInfiniteQuery'\nimport { createMutation } from './createMutation'\nimport { createQuery } from './createQuery'\nimport { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery'\nimport { createSuspenseQuery } from './createSuspenseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n CreateMutationOptions,\n CreateQueryOptions,\n CreateRouter,\n RouterConfig,\n RouterInfiniteQuery,\n RouterMutation,\n RouterQuery,\n} from './types'\n\nexport const router = <TConfig extends RouterConfig>(\n scope: string,\n config: TConfig\n): CreateRouter<TConfig> => {\n return Object.entries(config).reduce(\n (acc, [key, opts]) => {\n const options: any = {\n ...opts,\n [opts._type === `m` ? `mutationKey` : `queryKey`]: [scope, key],\n }\n\n acc[key] =\n opts._type === `m`\n ? {\n useMutation: createMutation(options),\n ...createMutation(options),\n }\n : opts._type === `q`\n ? {\n useQuery: createQuery(options),\n useSuspenseQuery: createSuspenseQuery(options),\n ...createQuery(options),\n }\n : {\n useInfiniteQuery: createInfiniteQuery(options),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),\n ...createInfiniteQuery(options),\n }\n\n return acc\n },\n {\n getKey: () => [scope],\n } as any\n )\n}\n\nrouter.query = <TFnData, TVariables = void, TError = CompatibleError>(\n options: Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'>\n): RouterQuery<TFnData, TVariables, TError> => {\n return {\n ...options,\n _type: 'q',\n }\n}\n\nrouter.infiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: Omit<\n CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>,\n 'queryKey'\n >\n): RouterInfiniteQuery<TFnData, TVariables, TError, TPageParam> => {\n return { ...options, _type: 'inf' }\n}\n\nrouter.mutation = <\n TFnData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n options: Omit<\n CreateMutationOptions<TFnData, TVariables, TError, TContext>,\n 'mutationKey'\n >\n): RouterMutation<TFnData, TVariables, TError, TContext> => {\n return { ...options, _type: 'm' }\n}\n"],"names":["router","scope","config","Object","entries","reduce","acc","key","opts","options","_type","useMutation","createMutation","useQuery","createQuery","useSuspenseQuery","createSuspenseQuery","useInfiniteQuery","createInfiniteQuery","useSuspenseInfiniteQuery","createSuspenseInfiniteQuery","getKey","query","infiniteQuery","mutation"],"mappings":";;;;;;;;;;MAiBaA,MAAM,GAAG,CACpBC,KADoB,EAEpBC,MAFoB,KAGM;AAC1B,EAAA,OAAOC,MAAM,CAACC,OAAP,CAAeF,MAAf,EAAuBG,MAAvB,CACL,CAACC,GAAD,EAAM,CAACC,GAAD,EAAMC,IAAN,CAAN,KAAsB;AACpB,IAAA,MAAMC,OAAY,GAAG,EACnB,GAAGD,IADgB;MAEnB,CAACA,IAAI,CAACE,KAAL,KAAA,GAAA,GAAA,aAAA,GAAA,UAAD,GAAmD,CAACT,KAAD,EAAQM,GAAR,CAAA;KAFrD,CAAA;AAKAD,IAAAA,GAAG,CAACC,GAAD,CAAH,GACEC,IAAI,CAACE,KAAL,KACI,GAAA,GAAA;AACEC,MAAAA,WAAW,EAAEC,6BAAc,CAACH,OAAD,CAD7B;MAEE,GAAGG,6BAAc,CAACH,OAAD,CAAA;AAFnB,KADJ,GAKID,IAAI,CAACE,KAAL,KACA,GAAA,GAAA;AACEG,MAAAA,QAAQ,EAAEC,uBAAW,CAACL,OAAD,CADvB;AAEEM,MAAAA,gBAAgB,EAAEC,uCAAmB,CAACP,OAAD,CAFvC;MAGE,GAAGK,uBAAW,CAACL,OAAD,CAAA;AAHhB,KADA,GAMA;AACEQ,MAAAA,gBAAgB,EAAEC,uCAAmB,CAACT,OAAD,CADvC;AAEEU,MAAAA,wBAAwB,EAAEC,uDAA2B,CAACX,OAAD,CAFvD;MAGE,GAAGS,uCAAmB,CAACT,OAAD,CAAA;KAf9B,CAAA;AAkBA,IAAA,OAAOH,GAAP,CAAA;AACD,GA1BI,EA2BL;IACEe,MAAM,EAAE,MAAM,CAACpB,KAAD,CAAA;AADhB,GA3BK,CAAP,CAAA;AA+BD,EAnCM;;AAqCPD,MAAM,CAACsB,KAAP,GACEb,OADa,IAEgC;EAC7C,OAAO,EACL,GAAGA,OADE;AAELC,IAAAA,KAAK,EAAE,GAAA;GAFT,CAAA;AAID,CAPD,CAAA;;AASAV,MAAM,CAACuB,aAAP,GAMEd,OANqB,IAU4C;EACjE,OAAO,EAAE,GAAGA,OAAL;AAAcC,IAAAA,KAAK,EAAE,KAAA;GAA5B,CAAA;AACD,CAZD,CAAA;;AAcAV,MAAM,CAACwB,QAAP,GAMEf,OANgB,IAU0C;EAC1D,OAAO,EAAE,GAAGA,OAAL;AAAcC,IAAAA,KAAK,EAAE,GAAA;GAA5B,CAAA;AACD,CAZD;;;;"}
@@ -0,0 +1,49 @@
1
+ import { createInfiniteQuery } from './createInfiniteQuery.mjs';
2
+ import { createMutation } from './createMutation.mjs';
3
+ import { createQuery } from './createQuery.mjs';
4
+ import { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery.mjs';
5
+ import { createSuspenseQuery } from './createSuspenseQuery.mjs';
6
+
7
+ const router = (scope, config) => {
8
+ return Object.entries(config).reduce((acc, [key, opts]) => {
9
+ const options = { ...opts,
10
+ [opts._type === "m" ? "mutationKey" : "queryKey"]: [scope, key]
11
+ };
12
+ acc[key] = opts._type === "m" ? {
13
+ useMutation: createMutation(options),
14
+ ...createMutation(options)
15
+ } : opts._type === "q" ? {
16
+ useQuery: createQuery(options),
17
+ useSuspenseQuery: createSuspenseQuery(options),
18
+ ...createQuery(options)
19
+ } : {
20
+ useInfiniteQuery: createInfiniteQuery(options),
21
+ useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),
22
+ ...createInfiniteQuery(options)
23
+ };
24
+ return acc;
25
+ }, {
26
+ getKey: () => [scope]
27
+ });
28
+ };
29
+
30
+ router.query = options => {
31
+ return { ...options,
32
+ _type: 'q'
33
+ };
34
+ };
35
+
36
+ router.infiniteQuery = options => {
37
+ return { ...options,
38
+ _type: 'inf'
39
+ };
40
+ };
41
+
42
+ router.mutation = options => {
43
+ return { ...options,
44
+ _type: 'm'
45
+ };
46
+ };
47
+
48
+ export { router };
49
+ //# sourceMappingURL=router.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.mjs","sources":["../../src/router.ts"],"sourcesContent":["import { createInfiniteQuery } from './createInfiniteQuery'\nimport { createMutation } from './createMutation'\nimport { createQuery } from './createQuery'\nimport { createSuspenseInfiniteQuery } from './createSuspenseInfiniteQuery'\nimport { createSuspenseQuery } from './createSuspenseQuery'\nimport type {\n CompatibleError,\n CreateInfiniteQueryOptions,\n CreateMutationOptions,\n CreateQueryOptions,\n CreateRouter,\n RouterConfig,\n RouterInfiniteQuery,\n RouterMutation,\n RouterQuery,\n} from './types'\n\nexport const router = <TConfig extends RouterConfig>(\n scope: string,\n config: TConfig\n): CreateRouter<TConfig> => {\n return Object.entries(config).reduce(\n (acc, [key, opts]) => {\n const options: any = {\n ...opts,\n [opts._type === `m` ? `mutationKey` : `queryKey`]: [scope, key],\n }\n\n acc[key] =\n opts._type === `m`\n ? {\n useMutation: createMutation(options),\n ...createMutation(options),\n }\n : opts._type === `q`\n ? {\n useQuery: createQuery(options),\n useSuspenseQuery: createSuspenseQuery(options),\n ...createQuery(options),\n }\n : {\n useInfiniteQuery: createInfiniteQuery(options),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery(options),\n ...createInfiniteQuery(options),\n }\n\n return acc\n },\n {\n getKey: () => [scope],\n } as any\n )\n}\n\nrouter.query = <TFnData, TVariables = void, TError = CompatibleError>(\n options: Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'>\n): RouterQuery<TFnData, TVariables, TError> => {\n return {\n ...options,\n _type: 'q',\n }\n}\n\nrouter.infiniteQuery = <\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n>(\n options: Omit<\n CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>,\n 'queryKey'\n >\n): RouterInfiniteQuery<TFnData, TVariables, TError, TPageParam> => {\n return { ...options, _type: 'inf' }\n}\n\nrouter.mutation = <\n TFnData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n>(\n options: Omit<\n CreateMutationOptions<TFnData, TVariables, TError, TContext>,\n 'mutationKey'\n >\n): RouterMutation<TFnData, TVariables, TError, TContext> => {\n return { ...options, _type: 'm' }\n}\n"],"names":["router","scope","config","Object","entries","reduce","acc","key","opts","options","_type","useMutation","createMutation","useQuery","createQuery","useSuspenseQuery","createSuspenseQuery","useInfiniteQuery","createInfiniteQuery","useSuspenseInfiniteQuery","createSuspenseInfiniteQuery","getKey","query","infiniteQuery","mutation"],"mappings":";;;;;;MAiBaA,MAAM,GAAG,CACpBC,KADoB,EAEpBC,MAFoB,KAGM;AAC1B,EAAA,OAAOC,MAAM,CAACC,OAAP,CAAeF,MAAf,EAAuBG,MAAvB,CACL,CAACC,GAAD,EAAM,CAACC,GAAD,EAAMC,IAAN,CAAN,KAAsB;AACpB,IAAA,MAAMC,OAAY,GAAG,EACnB,GAAGD,IADgB;MAEnB,CAACA,IAAI,CAACE,KAAL,KAAA,GAAA,GAAA,aAAA,GAAA,UAAD,GAAmD,CAACT,KAAD,EAAQM,GAAR,CAAA;KAFrD,CAAA;AAKAD,IAAAA,GAAG,CAACC,GAAD,CAAH,GACEC,IAAI,CAACE,KAAL,KACI,GAAA,GAAA;AACEC,MAAAA,WAAW,EAAEC,cAAc,CAACH,OAAD,CAD7B;MAEE,GAAGG,cAAc,CAACH,OAAD,CAAA;AAFnB,KADJ,GAKID,IAAI,CAACE,KAAL,KACA,GAAA,GAAA;AACEG,MAAAA,QAAQ,EAAEC,WAAW,CAACL,OAAD,CADvB;AAEEM,MAAAA,gBAAgB,EAAEC,mBAAmB,CAACP,OAAD,CAFvC;MAGE,GAAGK,WAAW,CAACL,OAAD,CAAA;AAHhB,KADA,GAMA;AACEQ,MAAAA,gBAAgB,EAAEC,mBAAmB,CAACT,OAAD,CADvC;AAEEU,MAAAA,wBAAwB,EAAEC,2BAA2B,CAACX,OAAD,CAFvD;MAGE,GAAGS,mBAAmB,CAACT,OAAD,CAAA;KAf9B,CAAA;AAkBA,IAAA,OAAOH,GAAP,CAAA;AACD,GA1BI,EA2BL;IACEe,MAAM,EAAE,MAAM,CAACpB,KAAD,CAAA;AADhB,GA3BK,CAAP,CAAA;AA+BD,EAnCM;;AAqCPD,MAAM,CAACsB,KAAP,GACEb,OADa,IAEgC;EAC7C,OAAO,EACL,GAAGA,OADE;AAELC,IAAAA,KAAK,EAAE,GAAA;GAFT,CAAA;AAID,CAPD,CAAA;;AASAV,MAAM,CAACuB,aAAP,GAMEd,OANqB,IAU4C;EACjE,OAAO,EAAE,GAAGA,OAAL;AAAcC,IAAAA,KAAK,EAAE,KAAA;GAA5B,CAAA;AACD,CAZD,CAAA;;AAcAV,MAAM,CAACwB,QAAP,GAMEf,OANgB,IAU0C;EAC1D,OAAO,EAAE,GAAGA,OAAL;AAAcC,IAAAA,KAAK,EAAE,GAAA;GAA5B,CAAA;AACD,CAZD;;;;"}
@@ -6,20 +6,21 @@ type NonUndefinedGuard<T> = T extends undefined ? never : T;
6
6
  type WithRequired<T, K extends keyof T> = T & {
7
7
  [_ in K]: {};
8
8
  };
9
+ type DeepPartial<T> = T extends object ? {
10
+ [P in keyof T]?: DeepPartial<T[P]>;
11
+ } : T;
9
12
  export type CompatibleError = CompatibleWithV4<DefaultError, Error>;
10
- export type Fetcher<TFnData, TVariables = void, TPageParam = number> = (variables: TVariables, context: QueryFunctionContext<QueryKey, TPageParam>) => TFnData | Promise<TFnData>;
13
+ export type Fetcher<TFnData, TVariables = void, TPageParam = never> = (variables: TVariables, context: QueryFunctionContext<QueryKey, TPageParam>) => TFnData | Promise<TFnData>;
11
14
  export type AdditionalQueryOptions<TFnData, TVariables, TPageParam = never> = {
12
15
  fetcher: Fetcher<TFnData, TVariables, TPageParam>;
13
16
  variables?: TVariables;
14
17
  };
15
18
  type inferMiddlewareHook<T extends (...args: any) => any> = (options: inferCreateOptions<T>, queryClient?: CompatibleWithV4<QueryClient, void>) => ReturnType<T>;
16
19
  export type Middleware<T extends (...args: any) => any = QueryHook<any, any, any>> = (hook: inferMiddlewareHook<T>) => inferMiddlewareHook<T>;
17
- type DeepPartial<T> = T extends object ? {
18
- [P in keyof T]?: DeepPartial<T[P]>;
19
- } : T;
20
+ export type ExposeFetcher<TFnData, TVariables = void, TPageParam = never> = (variables: TVariables, context?: Partial<QueryFunctionContext<QueryKey, TPageParam>>) => TFnData | Promise<TFnData>;
20
21
  export type ExposeMethods<TFnData, TVariables, TError, TPageParam = never> = {
21
- fetcher: (variables: TVariables, context?: Partial<QueryFunctionContext<QueryKey, TPageParam>>) => TFnData | Promise<TFnData>;
22
- getKey: <V extends DeepPartial<TVariables> | void = void>(variables?: V) => CompatibleWithV4<DataTag<QueryKey, [
22
+ fetcher: ExposeFetcher<TFnData, TVariables, TPageParam>;
23
+ getKey: (variables?: DeepPartial<TVariables>) => CompatibleWithV4<DataTag<QueryKey, [
23
24
  TPageParam
24
25
  ] extends [never] ? TFnData : InfiniteData<TFnData, TPageParam>>, QueryKey>;
25
26
  getFetchOptions: (variables: TVariables extends void ? TVariables | void : TVariables) => Pick<ReturnType<ExposeMethods<TFnData, TVariables, TError, TPageParam>['getOptions']>, [
@@ -105,16 +106,50 @@ export interface MutationHookOptions<TData, TError, TVariables, TContext> extend
105
106
  use?: Middleware<MutationHook<TData, TError, TVariables>>[];
106
107
  }
107
108
  export type MutationHookResult<TData = unknown, TError = CompatibleError, TVariables = void, TContext = unknown> = UseMutationResult<TData, TError, TVariables, TContext>;
108
- export interface MutationHook<TData = unknown, TVariables = void, TError = unknown, TDefaultContext = unknown> {
109
- <TContext = TDefaultContext>(options?: MutationHookOptions<TData, TError, TVariables, TContext>, queryClient?: CompatibleWithV4<QueryClient, void>): MutationHookResult<TData, TError, TVariables, TContext>;
109
+ export interface ExposeMutationMethods<TData = unknown, TVariables = void, TError = unknown, TDefaultContext = unknown> {
110
110
  getKey: () => MutationKey | undefined;
111
111
  getOptions: () => UseMutationOptions<TData, TError, TVariables, TDefaultContext>;
112
112
  mutationFn: MutationFunction<TData, TVariables>;
113
113
  }
114
- export type inferVariables<T> = T extends QueryHook<any, infer TVariables, any> ? TVariables : T extends SuspenseQueryHook<any, infer TVariables, any> ? TVariables : T extends InfiniteQueryHook<any, infer TVariables, any> ? TVariables : T extends SuspenseInfiniteQueryHook<any, infer TVariables, any> ? TVariables : T extends MutationHook<any, infer TVariables, any> ? TVariables : never;
115
- export type inferData<T> = T extends QueryHook<infer TData, any, any> ? TData : T extends SuspenseQueryHook<infer TData, any, any> ? TData : T extends InfiniteQueryHook<infer TData, any, any, infer TPageParam> ? CompatibleInfiniteData<TData, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TData, any, any, infer TPageParam> ? CompatibleInfiniteData<TData, TPageParam> : T extends MutationHook<infer TData, any, any> ? TData : never;
116
- export type inferFnData<T> = T extends QueryHook<infer TData, any, any> ? TData : T extends SuspenseQueryHook<infer TData, any, any> ? TData : T extends InfiniteQueryHook<infer TData, any, any> ? TData : T extends SuspenseInfiniteQueryHook<infer TData, any, any> ? TData : T extends MutationHook<infer TData, any, any> ? TData : never;
117
- export type inferError<T> = T extends QueryHook<any, any, infer TError> ? TError : T extends SuspenseQueryHook<any, any, infer TError> ? TError : T extends InfiniteQueryHook<any, any, infer TError> ? TError : T extends SuspenseInfiniteQueryHook<any, any, infer TError> ? TError : T extends MutationHook<any, any, infer TError> ? TError : never;
114
+ export interface MutationHook<TData = unknown, TVariables = void, TError = unknown, TDefaultContext = unknown> extends ExposeMutationMethods<TData, TVariables, TError, TDefaultContext> {
115
+ <TContext = TDefaultContext>(options?: MutationHookOptions<TData, TError, TVariables, TContext>, queryClient?: CompatibleWithV4<QueryClient, void>): MutationHookResult<TData, TError, TVariables, TContext>;
116
+ }
117
+ export type inferVariables<T> = T extends {
118
+ fetcher: ExposeFetcher<any, infer TVariables, any>;
119
+ } ? TVariables : T extends ExposeMutationMethods<any, infer TVariables, any, any> ? TVariables : never;
120
+ export type inferData<T> = T extends {
121
+ fetcher: ExposeFetcher<infer TFnData, any, infer TPageParam>;
122
+ } ? [TPageParam] extends [never] ? TFnData : CompatibleInfiniteData<TFnData, TPageParam> : T extends ExposeMutationMethods<infer TFnData, any, any, any> ? TFnData : never;
123
+ export type inferFnData<T> = T extends {
124
+ fetcher: ExposeFetcher<infer TFnData, any, any>;
125
+ } ? TFnData : T extends ExposeMutationMethods<infer TFnData, any, any, any> ? TFnData : never;
126
+ export type inferError<T> = T extends {
127
+ fetcher: ExposeFetcher<any, infer TError, any>;
128
+ } ? TError : T extends ExposeMutationMethods<any, any, infer TError, any> ? TError : never;
118
129
  export type inferOptions<T> = T extends QueryHook<infer TFnData, infer TVariables, infer TError> ? QueryHookOptions<TFnData, TError, TFnData, TVariables> : T extends SuspenseQueryHook<infer TFnData, infer TVariables, infer TError> ? SuspenseQueryHookOptions<TFnData, TError, TFnData, TVariables> : T extends InfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? InfiniteQueryHookOptions<TFnData, TError, CompatibleWithV4<InfiniteData<TFnData, TPageParam>, TFnData>, TVariables, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? SuspenseInfiniteQueryHookOptions<TFnData, TError, CompatibleWithV4<InfiniteData<TFnData, TPageParam>, TFnData>, TVariables, TPageParam> : T extends MutationHook<infer TFnData, infer TVariables, infer TError> ? MutationHookOptions<TFnData, TError, TVariables, unknown> : never;
119
- export type inferCreateOptions<T> = T extends QueryHook<infer TFnData, infer TVariables, infer TError> ? CreateQueryOptions<TFnData, TVariables, TError> : T extends SuspenseQueryHook<infer TFnData, infer TVariables, infer TError> ? CreateSuspenseQueryOptions<TFnData, TVariables, TError> : T extends InfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateSuspenseInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends MutationHook<infer TFnData, infer TVariables, infer TError> ? CreateMutationOptions<TFnData, TError, TVariables, unknown> : never;
130
+ export type inferCreateOptions<T> = T extends QueryHook<infer TFnData, infer TVariables, infer TError> ? CreateQueryOptions<TFnData, TVariables, TError> : T extends SuspenseQueryHook<infer TFnData, infer TVariables, infer TError> ? CreateSuspenseQueryOptions<TFnData, TVariables, TError> : T extends InfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends SuspenseInfiniteQueryHook<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? CreateSuspenseInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam> : T extends MutationHook<infer TFnData, infer TVariables, infer TError, infer TContext> ? CreateMutationOptions<TFnData, TError, TVariables, TContext> : never;
131
+ export type RouterQuery<TFnData, TVariables = void, TError = CompatibleError> = Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'> & {
132
+ _type: `q`;
133
+ };
134
+ export type RouterInfiniteQuery<TFnData, TVariables = void, TError = CompatibleError, TPageParam = number> = Omit<CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>, 'queryKey'> & {
135
+ _type: `inf`;
136
+ };
137
+ export type RouterMutation<TData = unknown, TVariables = void, TError = CompatibleError, TContext = unknown> = Omit<CreateMutationOptions<TData, TVariables, TError, TContext>, 'mutationKey'> & {
138
+ _type: `m`;
139
+ };
140
+ type DefaultTo<T, D> = unknown extends T ? D : T;
141
+ export type RouterConfig = Record<string, RouterQuery<any, any, any> | RouterInfiniteQuery<any, any, any, any> | RouterMutation<any, any, any, any>>;
142
+ export type CreateRouter<TConfig extends RouterConfig> = {
143
+ [K in keyof TConfig]: TConfig[K] extends RouterMutation<infer TFnData, infer TVariables, infer TError, infer TContext> ? {
144
+ useMutation: MutationHook<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>, TContext>;
145
+ } & ExposeMutationMethods<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>, TContext> : TConfig[K] extends RouterInfiniteQuery<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? {
146
+ useInfiniteQuery: InfiniteQueryHook<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>, TPageParam>;
147
+ useSuspenseInfiniteQuery: SuspenseInfiniteQueryHook<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>, TPageParam>;
148
+ } & ExposeMethods<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>, TPageParam> : TConfig[K] extends Omit<RouterQuery<infer TFnData, infer TVariables, infer TError>, 'queryKey'> ? {
149
+ useQuery: QueryHook<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>>;
150
+ useSuspenseQuery: SuspenseQueryHook<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>>;
151
+ } & ExposeMethods<TFnData, DefaultTo<TVariables, void>, DefaultTo<TError, CompatibleError>> : never;
152
+ } & {
153
+ getKey: () => [string];
154
+ };
120
155
  export {};
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
4014
4014
  </script>
4015
4015
  <script>
4016
4016
  /*<!--*/
4017
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"zip.esm.js","children":[{"name":"src","children":[{"uid":"5709-1","name":"utils.ts"},{"uid":"5709-3","name":"createBaseQuery.ts"},{"uid":"5709-5","name":"createQuery.ts"},{"uid":"5709-7","name":"createSuspenseQuery.ts"},{"uid":"5709-9","name":"createInfiniteQuery.ts"},{"uid":"5709-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"5709-13","name":"createMutation.ts"},{"uid":"5709-15","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"5709-1":{"renderedLength":911,"gzipLength":456,"brotliLength":0,"mainUid":"5709-0"},"5709-3":{"renderedLength":1162,"gzipLength":397,"brotliLength":0,"mainUid":"5709-2"},"5709-5":{"renderedLength":91,"gzipLength":87,"brotliLength":0,"mainUid":"5709-4"},"5709-7":{"renderedLength":179,"gzipLength":118,"brotliLength":0,"mainUid":"5709-6"},"5709-9":{"renderedLength":107,"gzipLength":97,"brotliLength":0,"mainUid":"5709-8"},"5709-11":{"renderedLength":203,"gzipLength":128,"brotliLength":0,"mainUid":"5709-10"},"5709-13":{"renderedLength":271,"gzipLength":168,"brotliLength":0,"mainUid":"5709-12"},"5709-15":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"5709-14"}},"nodeMetas":{"5709-0":{"id":"/src/utils.ts","moduleParts":{"zip.esm.js":"5709-1"},"imported":[{"uid":"5709-17"}],"importedBy":[{"uid":"5709-14"},{"uid":"5709-4"},{"uid":"5709-6"},{"uid":"5709-8"},{"uid":"5709-10"},{"uid":"5709-12"},{"uid":"5709-2"}]},"5709-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"zip.esm.js":"5709-3"},"imported":[{"uid":"5709-0"}],"importedBy":[{"uid":"5709-4"},{"uid":"5709-6"},{"uid":"5709-8"},{"uid":"5709-10"}]},"5709-4":{"id":"/src/createQuery.ts","moduleParts":{"zip.esm.js":"5709-5"},"imported":[{"uid":"5709-2"},{"uid":"5709-0"}],"importedBy":[{"uid":"5709-14"}]},"5709-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"zip.esm.js":"5709-7"},"imported":[{"uid":"5709-2"},{"uid":"5709-0"}],"importedBy":[{"uid":"5709-14"}]},"5709-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"zip.esm.js":"5709-9"},"imported":[{"uid":"5709-2"},{"uid":"5709-0"}],"importedBy":[{"uid":"5709-14"}]},"5709-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"zip.esm.js":"5709-11"},"imported":[{"uid":"5709-2"},{"uid":"5709-0"}],"importedBy":[{"uid":"5709-14"}]},"5709-12":{"id":"/src/createMutation.ts","moduleParts":{"zip.esm.js":"5709-13"},"imported":[{"uid":"5709-0"}],"importedBy":[{"uid":"5709-14"}]},"5709-14":{"id":"/src/index.ts","moduleParts":{"zip.esm.js":"5709-15"},"imported":[{"uid":"5709-4"},{"uid":"5709-6"},{"uid":"5709-8"},{"uid":"5709-10"},{"uid":"5709-12"},{"uid":"5709-16"},{"uid":"5709-0"}],"importedBy":[],"isEntry":true},"5709-16":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"5709-14"}]},"5709-17":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"5709-0"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4017
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"zip.esm.js","children":[{"name":"src","children":[{"uid":"98c8-1","name":"utils.ts"},{"uid":"98c8-3","name":"createBaseQuery.ts"},{"uid":"98c8-5","name":"createQuery.ts"},{"uid":"98c8-7","name":"createSuspenseQuery.ts"},{"uid":"98c8-9","name":"createInfiniteQuery.ts"},{"uid":"98c8-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"98c8-13","name":"createMutation.ts"},{"uid":"98c8-15","name":"router.ts"},{"uid":"98c8-17","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"98c8-1":{"renderedLength":911,"gzipLength":456,"brotliLength":0,"mainUid":"98c8-0"},"98c8-3":{"renderedLength":1162,"gzipLength":397,"brotliLength":0,"mainUid":"98c8-2"},"98c8-5":{"renderedLength":91,"gzipLength":87,"brotliLength":0,"mainUid":"98c8-4"},"98c8-7":{"renderedLength":179,"gzipLength":118,"brotliLength":0,"mainUid":"98c8-6"},"98c8-9":{"renderedLength":107,"gzipLength":97,"brotliLength":0,"mainUid":"98c8-8"},"98c8-11":{"renderedLength":203,"gzipLength":128,"brotliLength":0,"mainUid":"98c8-10"},"98c8-13":{"renderedLength":271,"gzipLength":168,"brotliLength":0,"mainUid":"98c8-12"},"98c8-15":{"renderedLength":949,"gzipLength":337,"brotliLength":0,"mainUid":"98c8-14"},"98c8-17":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"98c8-16"}},"nodeMetas":{"98c8-0":{"id":"/src/utils.ts","moduleParts":{"zip.esm.js":"98c8-1"},"imported":[{"uid":"98c8-19"}],"importedBy":[{"uid":"98c8-16"},{"uid":"98c8-4"},{"uid":"98c8-6"},{"uid":"98c8-8"},{"uid":"98c8-10"},{"uid":"98c8-12"},{"uid":"98c8-2"}]},"98c8-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"zip.esm.js":"98c8-3"},"imported":[{"uid":"98c8-0"}],"importedBy":[{"uid":"98c8-4"},{"uid":"98c8-6"},{"uid":"98c8-8"},{"uid":"98c8-10"}]},"98c8-4":{"id":"/src/createQuery.ts","moduleParts":{"zip.esm.js":"98c8-5"},"imported":[{"uid":"98c8-2"},{"uid":"98c8-0"}],"importedBy":[{"uid":"98c8-16"},{"uid":"98c8-14"}]},"98c8-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"zip.esm.js":"98c8-7"},"imported":[{"uid":"98c8-2"},{"uid":"98c8-0"}],"importedBy":[{"uid":"98c8-16"},{"uid":"98c8-14"}]},"98c8-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"zip.esm.js":"98c8-9"},"imported":[{"uid":"98c8-2"},{"uid":"98c8-0"}],"importedBy":[{"uid":"98c8-16"},{"uid":"98c8-14"}]},"98c8-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"zip.esm.js":"98c8-11"},"imported":[{"uid":"98c8-2"},{"uid":"98c8-0"}],"importedBy":[{"uid":"98c8-16"},{"uid":"98c8-14"}]},"98c8-12":{"id":"/src/createMutation.ts","moduleParts":{"zip.esm.js":"98c8-13"},"imported":[{"uid":"98c8-0"}],"importedBy":[{"uid":"98c8-16"},{"uid":"98c8-14"}]},"98c8-14":{"id":"/src/router.ts","moduleParts":{"zip.esm.js":"98c8-15"},"imported":[{"uid":"98c8-8"},{"uid":"98c8-12"},{"uid":"98c8-4"},{"uid":"98c8-10"},{"uid":"98c8-6"}],"importedBy":[{"uid":"98c8-16"}]},"98c8-16":{"id":"/src/index.ts","moduleParts":{"zip.esm.js":"98c8-17"},"imported":[{"uid":"98c8-4"},{"uid":"98c8-6"},{"uid":"98c8-8"},{"uid":"98c8-10"},{"uid":"98c8-12"},{"uid":"98c8-18"},{"uid":"98c8-14"},{"uid":"98c8-0"}],"importedBy":[],"isEntry":true},"98c8-18":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"98c8-16"}]},"98c8-19":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"98c8-0"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4018
4018
 
4019
4019
  const run = () => {
4020
4020
  const width = window.innerWidth;