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

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)
@@ -376,6 +377,81 @@ Returns
376
377
  - `getOptions: () => UseMutationOptions`
377
378
  - `mutationFn: MutationFunction<TData, TVariables>`
378
379
 
380
+ ## router
381
+
382
+ `router` 允许您创建整个 API 的形状
383
+
384
+ ### Usage
385
+
386
+ ```tsx
387
+ import { router } from 'react-query-kit'
388
+
389
+ const posts = router(`posts`, {
390
+ byId: router.query({
391
+ fetcher: (variables: { id: number }) => {
392
+ return fetch(`/posts/${variables.id}`).then(res => res.json())
393
+ },
394
+ use: [myMiddleware],
395
+ }),
396
+
397
+ list: router.infiniteQuery({
398
+ fetcher: (
399
+ variables: { active: boolean },
400
+ { pageParam }
401
+ ): Promise<{
402
+ projects: { id: string; name: string }[]
403
+ nextCursor: number
404
+ }> => {
405
+ return fetch(
406
+ `/posts/?cursor=${pageParam}?active=${variables.active}`
407
+ ).then(res => res.json())
408
+ },
409
+ getNextPageParam: lastPage => lastPage.nextCursor,
410
+ initialPageParam: 0,
411
+ }),
412
+
413
+ add: router.mutation({
414
+ mutationFn: async (variables: { title: string; content: string }) =>
415
+ fetch('/posts', {
416
+ method: 'POST',
417
+ headers: {
418
+ Accept: 'application/json',
419
+ 'Content-Type': 'application/json',
420
+ },
421
+ body: JSON.stringify(variables),
422
+ }).then(res => res.json()),
423
+ }),
424
+ })
425
+
426
+ // get root key
427
+ posts.getKey() // ['posts']
428
+
429
+ // hooks
430
+ posts.byId.useQuery({ variables: { id: 1 } })
431
+ posts.byId.useSuspenseQuery({ variables: { id: 1 } })
432
+ posts.list.useInfiniteQuery({ variables: { active: true } })
433
+ posts.list.useSuspenseInfiniteQuery({ variables: { active: true } })
434
+ posts.add.useMutation()
435
+
436
+ // expose methods
437
+ posts.byId.getKey({ id: 1 }) // ['posts', 'byId', { id: 1 }]
438
+ posts.byId.getFetchOptions({ id: 1 })
439
+ posts.byId.getOptions({ id: 1 })
440
+ posts.byId.fetcher({ id: 1 })
441
+ posts.add.getKey() // ['posts', 'add']
442
+ posts.add.getOptions()
443
+ posts.add.mutationFn({ title: 'title', content: 'content' })
444
+ ```
445
+
446
+ Expose Methods
447
+
448
+ - `query`
449
+ Similar to `createQuery` but without option `queryKey`
450
+ - `infiniteQuery`
451
+ Similar to `createInfiniteQuery` but without option `queryKey`
452
+ - `mutation`
453
+ Similar to `createMutation` but without option `mutationKey`
454
+
379
455
  ## Middleware
380
456
 
381
457
  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.
@@ -524,7 +600,7 @@ inferOptions<typeof useProjects> // InfiniteQueryHookOptions<...>
524
600
 
525
601
  ### What is the difference between `getFetchOptions` and `getOptions`?
526
602
 
527
- `getFetchOptions` will only return necessary options, while options like `staleTime` and `retry` will be ignored
603
+ `getFetchOptions` will only return necessary options, while options like `staleTime` and `retry` will be omited
528
604
 
529
605
  ```ts
530
606
  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,30 @@
1
+ import type { CompatibleError, CreateInfiniteQueryOptions, CreateMutationOptions, CreateQueryOptions, ExposeMethods, ExposeMutationMethods, InfiniteQueryHook, MutationHook, QueryHook, SuspenseQueryHook } from './types';
2
+ export type RouterQuery<TFnData, TVariables = void, TError = CompatibleError> = Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'> & {
3
+ _type: `q`;
4
+ };
5
+ export type RouterInfiniteQuery<TFnData, TVariables = void, TError = CompatibleError, TPageParam = number> = Omit<CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>, 'queryKey'> & {
6
+ _type: `inf`;
7
+ };
8
+ export type RouterMutation<TData = unknown, TVariables = void, TError = CompatibleError, TContext = unknown> = Omit<CreateMutationOptions<TData, TVariables, TError, TContext>, 'mutationKey'> & {
9
+ _type: `m`;
10
+ };
11
+ export type RouterConfig = Record<string, RouterQuery<any, any, any> | RouterInfiniteQuery<any, any, any> | RouterMutation<any, any, any>>;
12
+ export type CreateRouter<TConfig extends RouterConfig> = {
13
+ [K in keyof TConfig]: TConfig[K] extends RouterMutation<infer TFnData, infer TVariables, infer TError, infer TContext> ? {
14
+ useMutation: MutationHook<TFnData, TVariables, TError, TContext>;
15
+ } & ExposeMutationMethods<TFnData, TVariables, TError, TContext> : TConfig[K] extends RouterInfiniteQuery<infer TFnData, infer TVariables, infer TError, infer TPageParam> ? {
16
+ useInfiniteQuery: InfiniteQueryHook<TFnData, TVariables, TError, TPageParam>;
17
+ useSuspenseInfiniteQuery: InfiniteQueryHook<TFnData, TVariables, TError, TPageParam>;
18
+ } & ExposeMethods<TFnData, TVariables, TError, TPageParam> : TConfig[K] extends Omit<RouterQuery<infer TFnData, infer TVariables, infer TError>, 'queryKey'> ? {
19
+ useQuery: QueryHook<TFnData, TVariables, TError>;
20
+ useSuspenseQuery: SuspenseQueryHook<TFnData, TVariables, TError>;
21
+ } & ExposeMethods<TFnData, TVariables, TError> : never;
22
+ } & {
23
+ getKey: () => [string];
24
+ };
25
+ export declare const router: {
26
+ <TConfig extends RouterConfig>(scope: string, config: TConfig): CreateRouter<TConfig>;
27
+ query<TFnData, TVariables = void, TError = Error>(options: Omit<CreateQueryOptions<TFnData, TVariables, TError>, "queryKey">): RouterQuery<TFnData, TVariables, TError>;
28
+ 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>;
29
+ 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>;
30
+ };
@@ -0,0 +1,71 @@
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 keys = [scope, key];
10
+
11
+ if (opts._type === "m") {
12
+ acc[key] = {
13
+ useMutation: createMutation({ ...opts,
14
+ mutationKey: keys
15
+ }),
16
+ ...createMutation({ ...opts,
17
+ mutationKey: keys
18
+ })
19
+ };
20
+ } else if (opts._type === "q") {
21
+ acc[key] = {
22
+ useQuery: createQuery({ ...opts,
23
+ queryKey: keys
24
+ }),
25
+ useSuspenseQuery: createSuspenseQuery({ ...opts,
26
+ queryKey: keys
27
+ }),
28
+ ...createQuery({ ...opts,
29
+ queryKey: keys
30
+ })
31
+ };
32
+ } else {
33
+ acc[key] = {
34
+ useInfiniteQuery: createInfiniteQuery({ ...opts,
35
+ queryKey: keys
36
+ }),
37
+ useSuspenseInfiniteQuery: createSuspenseInfiniteQuery({ ...opts,
38
+ queryKey: keys
39
+ }),
40
+ ...createInfiniteQuery({ ...opts,
41
+ queryKey: keys
42
+ })
43
+ };
44
+ }
45
+
46
+ return acc;
47
+ }, {
48
+ getKey: () => [scope]
49
+ });
50
+ };
51
+
52
+ router.query = options => {
53
+ return { ...options,
54
+ _type: 'q'
55
+ };
56
+ };
57
+
58
+ router.infiniteQuery = options => {
59
+ return { ...options,
60
+ _type: 'inf'
61
+ };
62
+ };
63
+
64
+ router.mutation = options => {
65
+ return { ...options,
66
+ _type: 'm'
67
+ };
68
+ };
69
+
70
+ export { router };
71
+ //# 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 ExposeMethods,\n ExposeMutationMethods,\n InfiniteQueryHook,\n MutationHook,\n QueryHook,\n SuspenseQueryHook,\n} from './types'\n\nexport type RouterQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError\n> = Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'> & {\n _type: `q`\n}\n\nexport type RouterInfiniteQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n> = Omit<\n CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>,\n 'queryKey'\n> & {\n _type: `inf`\n}\n\nexport type RouterMutation<\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n> = Omit<\n CreateMutationOptions<TData, TVariables, TError, TContext>,\n 'mutationKey'\n> & {\n _type: `m`\n}\n\nexport type RouterConfig = Record<\n string,\n | RouterQuery<any, any, any>\n | RouterInfiniteQuery<any, any, any>\n | RouterMutation<any, any, any>\n>\n\nexport type CreateRouter<TConfig extends RouterConfig> = {\n [K in keyof TConfig]: TConfig[K] extends RouterMutation<\n infer TFnData,\n infer TVariables,\n infer TError,\n infer TContext\n >\n ? {\n useMutation: MutationHook<TFnData, TVariables, TError, TContext>\n } & ExposeMutationMethods<TFnData, TVariables, TError, TContext>\n : TConfig[K] extends RouterInfiniteQuery<\n infer TFnData,\n infer TVariables,\n infer TError,\n infer TPageParam\n >\n ? {\n useInfiniteQuery: InfiniteQueryHook<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n useSuspenseInfiniteQuery: InfiniteQueryHook<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n } & ExposeMethods<TFnData, TVariables, TError, TPageParam>\n : TConfig[K] extends Omit<\n RouterQuery<infer TFnData, infer TVariables, infer TError>,\n 'queryKey'\n >\n ? {\n useQuery: QueryHook<TFnData, TVariables, TError>\n useSuspenseQuery: SuspenseQueryHook<TFnData, TVariables, TError>\n } & ExposeMethods<TFnData, TVariables, TError>\n : never\n} & { getKey: () => [string] }\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 keys = [scope, key]\n\n if (opts._type === `m`) {\n acc[key] = {\n useMutation: createMutation({\n ...opts,\n mutationKey: keys,\n }),\n ...createMutation({\n ...opts,\n mutationKey: keys,\n }),\n }\n } else if (opts._type === `q`) {\n acc[key] = {\n useQuery: createQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n useSuspenseQuery: createSuspenseQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n ...createQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n }\n } else {\n acc[key] = {\n useInfiniteQuery: createInfiniteQuery({\n ...opts,\n queryKey: keys,\n }),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n ...createInfiniteQuery({\n ...opts,\n queryKey: keys,\n }),\n }\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","keys","_type","useMutation","createMutation","mutationKey","useQuery","createQuery","queryKey","useSuspenseQuery","createSuspenseQuery","useInfiniteQuery","createInfiniteQuery","useSuspenseInfiniteQuery","createSuspenseInfiniteQuery","getKey","query","options","infiniteQuery","mutation"],"mappings":";;;;;;MAkGaA,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,IAAI,GAAG,CAACR,KAAD,EAAQM,GAAR,CAAb,CAAA;;AAEA,IAAA,IAAIC,IAAI,CAACE,KAAL,KAAA,GAAJ,EAAwB;MACtBJ,GAAG,CAACC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AA;AAqDD,EAzDM;;AA2DPD,MAAM,CAACwB,KAAP,GACEC,OADa,IAEgC;EAC7C,OAAO,EACL,GAAGA,OADE;AAELf,IAAAA,KAAK,EAAE,GAAA;GAFT,CAAA;AAID,CAPD,CAAA;;AASAV,MAAM,CAAC0B,aAAP,GAMED,OANqB,IAU4C;EACjE,OAAO,EAAE,GAAGA,OAAL;AAAcf,IAAAA,KAAK,EAAE,KAAA;GAA5B,CAAA;AACD,CAZD,CAAA;;AAcAV,MAAM,CAAC2B,QAAP,GAMEF,OANgB,IAU0C;EAC1D,OAAO,EAAE,GAAGA,OAAL;AAAcf,IAAAA,KAAK,EAAE,GAAA;GAA5B,CAAA;AACD,CAZD;;;;"}
@@ -0,0 +1,75 @@
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 keys = [scope, key];
14
+
15
+ if (opts._type === "m") {
16
+ acc[key] = {
17
+ useMutation: createMutation.createMutation({ ...opts,
18
+ mutationKey: keys
19
+ }),
20
+ ...createMutation.createMutation({ ...opts,
21
+ mutationKey: keys
22
+ })
23
+ };
24
+ } else if (opts._type === "q") {
25
+ acc[key] = {
26
+ useQuery: createQuery.createQuery({ ...opts,
27
+ queryKey: keys
28
+ }),
29
+ useSuspenseQuery: createSuspenseQuery.createSuspenseQuery({ ...opts,
30
+ queryKey: keys
31
+ }),
32
+ ...createQuery.createQuery({ ...opts,
33
+ queryKey: keys
34
+ })
35
+ };
36
+ } else {
37
+ acc[key] = {
38
+ useInfiniteQuery: createInfiniteQuery.createInfiniteQuery({ ...opts,
39
+ queryKey: keys
40
+ }),
41
+ useSuspenseInfiniteQuery: createSuspenseInfiniteQuery.createSuspenseInfiniteQuery({ ...opts,
42
+ queryKey: keys
43
+ }),
44
+ ...createInfiniteQuery.createInfiniteQuery({ ...opts,
45
+ queryKey: keys
46
+ })
47
+ };
48
+ }
49
+
50
+ return acc;
51
+ }, {
52
+ getKey: () => [scope]
53
+ });
54
+ };
55
+
56
+ router.query = options => {
57
+ return { ...options,
58
+ _type: 'q'
59
+ };
60
+ };
61
+
62
+ router.infiniteQuery = options => {
63
+ return { ...options,
64
+ _type: 'inf'
65
+ };
66
+ };
67
+
68
+ router.mutation = options => {
69
+ return { ...options,
70
+ _type: 'm'
71
+ };
72
+ };
73
+
74
+ exports.router = router;
75
+ //# 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 ExposeMethods,\n ExposeMutationMethods,\n InfiniteQueryHook,\n MutationHook,\n QueryHook,\n SuspenseQueryHook,\n} from './types'\n\nexport type RouterQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError\n> = Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'> & {\n _type: `q`\n}\n\nexport type RouterInfiniteQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n> = Omit<\n CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>,\n 'queryKey'\n> & {\n _type: `inf`\n}\n\nexport type RouterMutation<\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n> = Omit<\n CreateMutationOptions<TData, TVariables, TError, TContext>,\n 'mutationKey'\n> & {\n _type: `m`\n}\n\nexport type RouterConfig = Record<\n string,\n | RouterQuery<any, any, any>\n | RouterInfiniteQuery<any, any, any>\n | RouterMutation<any, any, any>\n>\n\nexport type CreateRouter<TConfig extends RouterConfig> = {\n [K in keyof TConfig]: TConfig[K] extends RouterMutation<\n infer TFnData,\n infer TVariables,\n infer TError,\n infer TContext\n >\n ? {\n useMutation: MutationHook<TFnData, TVariables, TError, TContext>\n } & ExposeMutationMethods<TFnData, TVariables, TError, TContext>\n : TConfig[K] extends RouterInfiniteQuery<\n infer TFnData,\n infer TVariables,\n infer TError,\n infer TPageParam\n >\n ? {\n useInfiniteQuery: InfiniteQueryHook<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n useSuspenseInfiniteQuery: InfiniteQueryHook<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n } & ExposeMethods<TFnData, TVariables, TError, TPageParam>\n : TConfig[K] extends Omit<\n RouterQuery<infer TFnData, infer TVariables, infer TError>,\n 'queryKey'\n >\n ? {\n useQuery: QueryHook<TFnData, TVariables, TError>\n useSuspenseQuery: SuspenseQueryHook<TFnData, TVariables, TError>\n } & ExposeMethods<TFnData, TVariables, TError>\n : never\n} & { getKey: () => [string] }\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 keys = [scope, key]\n\n if (opts._type === `m`) {\n acc[key] = {\n useMutation: createMutation({\n ...opts,\n mutationKey: keys,\n }),\n ...createMutation({\n ...opts,\n mutationKey: keys,\n }),\n }\n } else if (opts._type === `q`) {\n acc[key] = {\n useQuery: createQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n useSuspenseQuery: createSuspenseQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n ...createQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n }\n } else {\n acc[key] = {\n useInfiniteQuery: createInfiniteQuery({\n ...opts,\n queryKey: keys,\n }),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n ...createInfiniteQuery({\n ...opts,\n queryKey: keys,\n }),\n }\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","keys","_type","useMutation","createMutation","mutationKey","useQuery","createQuery","queryKey","useSuspenseQuery","createSuspenseQuery","useInfiniteQuery","createInfiniteQuery","useSuspenseInfiniteQuery","createSuspenseInfiniteQuery","getKey","query","options","infiniteQuery","mutation"],"mappings":";;;;;;;;;;MAkGaA,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,IAAI,GAAG,CAACR,KAAD,EAAQM,GAAR,CAAb,CAAA;;AAEA,IAAA,IAAIC,IAAI,CAACE,KAAL,KAAA,GAAJ,EAAwB;MACtBJ,GAAG,CAACC,GA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AAA;AAqDD,EAzDM;;AA2DPD,MAAM,CAACwB,KAAP,GACEC,OADa,IAEgC;EAC7C,OAAO,EACL,GAAGA,OADE;AAELf,IAAAA,KAAK,EAAE,GAAA;GAFT,CAAA;AAID,CAPD,CAAA;;AASAV,MAAM,CAAC0B,aAAP,GAMED,OANqB,IAU4C;EACjE,OAAO,EAAE,GAAGA,OAAL;AAAcf,IAAAA,KAAK,EAAE,KAAA;GAA5B,CAAA;AACD,CAZD,CAAA;;AAcAV,MAAM,CAAC2B,QAAP,GAMEF,OANgB,IAU0C;EAC1D,OAAO,EAAE,GAAGA,OAAL;AAAcf,IAAAA,KAAK,EAAE,GAAA;GAA5B,CAAA;AACD,CAZD;;;;"}
@@ -0,0 +1,71 @@
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 keys = [scope, key];
10
+
11
+ if (opts._type === "m") {
12
+ acc[key] = {
13
+ useMutation: createMutation({ ...opts,
14
+ mutationKey: keys
15
+ }),
16
+ ...createMutation({ ...opts,
17
+ mutationKey: keys
18
+ })
19
+ };
20
+ } else if (opts._type === "q") {
21
+ acc[key] = {
22
+ useQuery: createQuery({ ...opts,
23
+ queryKey: keys
24
+ }),
25
+ useSuspenseQuery: createSuspenseQuery({ ...opts,
26
+ queryKey: keys
27
+ }),
28
+ ...createQuery({ ...opts,
29
+ queryKey: keys
30
+ })
31
+ };
32
+ } else {
33
+ acc[key] = {
34
+ useInfiniteQuery: createInfiniteQuery({ ...opts,
35
+ queryKey: keys
36
+ }),
37
+ useSuspenseInfiniteQuery: createSuspenseInfiniteQuery({ ...opts,
38
+ queryKey: keys
39
+ }),
40
+ ...createInfiniteQuery({ ...opts,
41
+ queryKey: keys
42
+ })
43
+ };
44
+ }
45
+
46
+ return acc;
47
+ }, {
48
+ getKey: () => [scope]
49
+ });
50
+ };
51
+
52
+ router.query = options => {
53
+ return { ...options,
54
+ _type: 'q'
55
+ };
56
+ };
57
+
58
+ router.infiniteQuery = options => {
59
+ return { ...options,
60
+ _type: 'inf'
61
+ };
62
+ };
63
+
64
+ router.mutation = options => {
65
+ return { ...options,
66
+ _type: 'm'
67
+ };
68
+ };
69
+
70
+ export { router };
71
+ //# 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 ExposeMethods,\n ExposeMutationMethods,\n InfiniteQueryHook,\n MutationHook,\n QueryHook,\n SuspenseQueryHook,\n} from './types'\n\nexport type RouterQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError\n> = Omit<CreateQueryOptions<TFnData, TVariables, TError>, 'queryKey'> & {\n _type: `q`\n}\n\nexport type RouterInfiniteQuery<\n TFnData,\n TVariables = void,\n TError = CompatibleError,\n TPageParam = number\n> = Omit<\n CreateInfiniteQueryOptions<TFnData, TVariables, TError, TPageParam>,\n 'queryKey'\n> & {\n _type: `inf`\n}\n\nexport type RouterMutation<\n TData = unknown,\n TVariables = void,\n TError = CompatibleError,\n TContext = unknown\n> = Omit<\n CreateMutationOptions<TData, TVariables, TError, TContext>,\n 'mutationKey'\n> & {\n _type: `m`\n}\n\nexport type RouterConfig = Record<\n string,\n | RouterQuery<any, any, any>\n | RouterInfiniteQuery<any, any, any>\n | RouterMutation<any, any, any>\n>\n\nexport type CreateRouter<TConfig extends RouterConfig> = {\n [K in keyof TConfig]: TConfig[K] extends RouterMutation<\n infer TFnData,\n infer TVariables,\n infer TError,\n infer TContext\n >\n ? {\n useMutation: MutationHook<TFnData, TVariables, TError, TContext>\n } & ExposeMutationMethods<TFnData, TVariables, TError, TContext>\n : TConfig[K] extends RouterInfiniteQuery<\n infer TFnData,\n infer TVariables,\n infer TError,\n infer TPageParam\n >\n ? {\n useInfiniteQuery: InfiniteQueryHook<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n useSuspenseInfiniteQuery: InfiniteQueryHook<\n TFnData,\n TVariables,\n TError,\n TPageParam\n >\n } & ExposeMethods<TFnData, TVariables, TError, TPageParam>\n : TConfig[K] extends Omit<\n RouterQuery<infer TFnData, infer TVariables, infer TError>,\n 'queryKey'\n >\n ? {\n useQuery: QueryHook<TFnData, TVariables, TError>\n useSuspenseQuery: SuspenseQueryHook<TFnData, TVariables, TError>\n } & ExposeMethods<TFnData, TVariables, TError>\n : never\n} & { getKey: () => [string] }\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 keys = [scope, key]\n\n if (opts._type === `m`) {\n acc[key] = {\n useMutation: createMutation({\n ...opts,\n mutationKey: keys,\n }),\n ...createMutation({\n ...opts,\n mutationKey: keys,\n }),\n }\n } else if (opts._type === `q`) {\n acc[key] = {\n useQuery: createQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n useSuspenseQuery: createSuspenseQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n ...createQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n }\n } else {\n acc[key] = {\n useInfiniteQuery: createInfiniteQuery({\n ...opts,\n queryKey: keys,\n }),\n useSuspenseInfiniteQuery: createSuspenseInfiniteQuery({\n ...(opts as any),\n queryKey: keys,\n }),\n ...createInfiniteQuery({\n ...opts,\n queryKey: keys,\n }),\n }\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","keys","_type","useMutation","createMutation","mutationKey","useQuery","createQuery","queryKey","useSuspenseQuery","createSuspenseQuery","useInfiniteQuery","createInfiniteQuery","useSuspenseInfiniteQuery","createSuspenseInfiniteQuery","getKey","query","options","infiniteQuery","mutation"],"mappings":";;;;;;MAkGaA,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,IAAI,GAAG,CAACR,KAAD,EAAQM,GAAR,CAAb,CAAA;;AAEA,IAAA,IAAIC,IAAI,CAACE,KAAL,KAAA,GAAJ,EAAwB;MACtBJ,GAAG,CAACC,GAAD,CAAH,GAAW;AACTI,QAAAA,WAAW,EAAEC,cAAc,CAAC,EAC1B,GAAGJ,IADuB;AAE1BK,UAAAA,WAAW,EAAEJ,IAAAA;AAFa,SAAD,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FT,CAAA;AAID,CAPD,CAAA;;AASAV,MAAM,CAAC0B,aAAP,GAMED,OANqB,IAU4C;EACjE,OAAO,EAAE,GAAGA,OAAL;AAAcf,IAAAA,KAAK,EAAE,KAAA;GAA5B,CAAA;AACD,CAZD,CAAA;;AAcAV,MAAM,CAAC2B,QAAP,GAMEF,OANgB,IAU0C;EAC1D,OAAO,EAAE,GAAGA,OAAL;AAAcf,IAAAA,KAAK,EAAE,GAAA;GAA5B,CAAA;AACD,CAZD;;;;"}
@@ -7,8 +7,9 @@ type WithRequired<T, K extends keyof T> = T & {
7
7
  [_ in K]: {};
8
8
  };
9
9
  export type CompatibleError = CompatibleWithV4<DefaultError, Error>;
10
+ export type Fetcher<TFnData, TVariables = void, TPageParam = never> = (variables: TVariables, context: QueryFunctionContext<QueryKey, TPageParam>) => TFnData | Promise<TFnData>;
10
11
  export type AdditionalQueryOptions<TFnData, TVariables, TPageParam = never> = {
11
- fetcher: (variables: TVariables, context: QueryFunctionContext<QueryKey, TPageParam>) => TFnData | Promise<TFnData>;
12
+ fetcher: Fetcher<TFnData, TVariables, TPageParam>;
12
13
  variables?: TVariables;
13
14
  };
14
15
  type inferMiddlewareHook<T extends (...args: any) => any> = (options: inferCreateOptions<T>, queryClient?: CompatibleWithV4<QueryClient, void>) => ReturnType<T>;
@@ -104,12 +105,14 @@ export interface MutationHookOptions<TData, TError, TVariables, TContext> extend
104
105
  use?: Middleware<MutationHook<TData, TError, TVariables>>[];
105
106
  }
106
107
  export type MutationHookResult<TData = unknown, TError = CompatibleError, TVariables = void, TContext = unknown> = UseMutationResult<TData, TError, TVariables, TContext>;
107
- export interface MutationHook<TData = unknown, TVariables = void, TError = unknown, TDefaultContext = unknown> {
108
- <TContext = TDefaultContext>(options?: MutationHookOptions<TData, TError, TVariables, TContext>, queryClient?: CompatibleWithV4<QueryClient, void>): MutationHookResult<TData, TError, TVariables, TContext>;
108
+ export interface ExposeMutationMethods<TData = unknown, TVariables = void, TError = unknown, TDefaultContext = unknown> {
109
109
  getKey: () => MutationKey | undefined;
110
110
  getOptions: () => UseMutationOptions<TData, TError, TVariables, TDefaultContext>;
111
111
  mutationFn: MutationFunction<TData, TVariables>;
112
112
  }
113
+ export interface MutationHook<TData = unknown, TVariables = void, TError = unknown, TDefaultContext = unknown> extends ExposeMutationMethods<TData, TVariables, TError, TDefaultContext> {
114
+ <TContext = TDefaultContext>(options?: MutationHookOptions<TData, TError, TVariables, TContext>, queryClient?: CompatibleWithV4<QueryClient, void>): MutationHookResult<TData, TError, TVariables, TContext>;
115
+ }
113
116
  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;
114
117
  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;
115
118
  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;
@@ -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":"3e2c-1","name":"utils.ts"},{"uid":"3e2c-3","name":"createBaseQuery.ts"},{"uid":"3e2c-5","name":"createQuery.ts"},{"uid":"3e2c-7","name":"createSuspenseQuery.ts"},{"uid":"3e2c-9","name":"createInfiniteQuery.ts"},{"uid":"3e2c-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"3e2c-13","name":"createMutation.ts"},{"uid":"3e2c-15","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"3e2c-1":{"renderedLength":911,"gzipLength":456,"brotliLength":0,"mainUid":"3e2c-0"},"3e2c-3":{"renderedLength":1162,"gzipLength":397,"brotliLength":0,"mainUid":"3e2c-2"},"3e2c-5":{"renderedLength":91,"gzipLength":87,"brotliLength":0,"mainUid":"3e2c-4"},"3e2c-7":{"renderedLength":179,"gzipLength":118,"brotliLength":0,"mainUid":"3e2c-6"},"3e2c-9":{"renderedLength":107,"gzipLength":97,"brotliLength":0,"mainUid":"3e2c-8"},"3e2c-11":{"renderedLength":203,"gzipLength":128,"brotliLength":0,"mainUid":"3e2c-10"},"3e2c-13":{"renderedLength":271,"gzipLength":168,"brotliLength":0,"mainUid":"3e2c-12"},"3e2c-15":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"3e2c-14"}},"nodeMetas":{"3e2c-0":{"id":"/src/utils.ts","moduleParts":{"zip.esm.js":"3e2c-1"},"imported":[{"uid":"3e2c-17"}],"importedBy":[{"uid":"3e2c-14"},{"uid":"3e2c-4"},{"uid":"3e2c-6"},{"uid":"3e2c-8"},{"uid":"3e2c-10"},{"uid":"3e2c-12"},{"uid":"3e2c-2"}]},"3e2c-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"zip.esm.js":"3e2c-3"},"imported":[{"uid":"3e2c-0"}],"importedBy":[{"uid":"3e2c-4"},{"uid":"3e2c-6"},{"uid":"3e2c-8"},{"uid":"3e2c-10"}]},"3e2c-4":{"id":"/src/createQuery.ts","moduleParts":{"zip.esm.js":"3e2c-5"},"imported":[{"uid":"3e2c-2"},{"uid":"3e2c-0"}],"importedBy":[{"uid":"3e2c-14"}]},"3e2c-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"zip.esm.js":"3e2c-7"},"imported":[{"uid":"3e2c-2"},{"uid":"3e2c-0"}],"importedBy":[{"uid":"3e2c-14"}]},"3e2c-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"zip.esm.js":"3e2c-9"},"imported":[{"uid":"3e2c-2"},{"uid":"3e2c-0"}],"importedBy":[{"uid":"3e2c-14"}]},"3e2c-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"zip.esm.js":"3e2c-11"},"imported":[{"uid":"3e2c-2"},{"uid":"3e2c-0"}],"importedBy":[{"uid":"3e2c-14"}]},"3e2c-12":{"id":"/src/createMutation.ts","moduleParts":{"zip.esm.js":"3e2c-13"},"imported":[{"uid":"3e2c-0"}],"importedBy":[{"uid":"3e2c-14"}]},"3e2c-14":{"id":"/src/index.ts","moduleParts":{"zip.esm.js":"3e2c-15"},"imported":[{"uid":"3e2c-4"},{"uid":"3e2c-6"},{"uid":"3e2c-8"},{"uid":"3e2c-10"},{"uid":"3e2c-12"},{"uid":"3e2c-16"},{"uid":"3e2c-0"}],"importedBy":[],"isEntry":true},"3e2c-16":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"3e2c-14"}]},"3e2c-17":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"3e2c-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":"b25c-1","name":"utils.ts"},{"uid":"b25c-3","name":"createBaseQuery.ts"},{"uid":"b25c-5","name":"createQuery.ts"},{"uid":"b25c-7","name":"createSuspenseQuery.ts"},{"uid":"b25c-9","name":"createInfiniteQuery.ts"},{"uid":"b25c-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"b25c-13","name":"createMutation.ts"},{"uid":"b25c-15","name":"router.ts"},{"uid":"b25c-17","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"b25c-1":{"renderedLength":911,"gzipLength":456,"brotliLength":0,"mainUid":"b25c-0"},"b25c-3":{"renderedLength":1162,"gzipLength":397,"brotliLength":0,"mainUid":"b25c-2"},"b25c-5":{"renderedLength":91,"gzipLength":87,"brotliLength":0,"mainUid":"b25c-4"},"b25c-7":{"renderedLength":179,"gzipLength":118,"brotliLength":0,"mainUid":"b25c-6"},"b25c-9":{"renderedLength":107,"gzipLength":97,"brotliLength":0,"mainUid":"b25c-8"},"b25c-11":{"renderedLength":203,"gzipLength":128,"brotliLength":0,"mainUid":"b25c-10"},"b25c-13":{"renderedLength":271,"gzipLength":168,"brotliLength":0,"mainUid":"b25c-12"},"b25c-15":{"renderedLength":1284,"gzipLength":352,"brotliLength":0,"mainUid":"b25c-14"},"b25c-17":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"b25c-16"}},"nodeMetas":{"b25c-0":{"id":"/src/utils.ts","moduleParts":{"zip.esm.js":"b25c-1"},"imported":[{"uid":"b25c-19"}],"importedBy":[{"uid":"b25c-16"},{"uid":"b25c-4"},{"uid":"b25c-6"},{"uid":"b25c-8"},{"uid":"b25c-10"},{"uid":"b25c-12"},{"uid":"b25c-2"}]},"b25c-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"zip.esm.js":"b25c-3"},"imported":[{"uid":"b25c-0"}],"importedBy":[{"uid":"b25c-4"},{"uid":"b25c-6"},{"uid":"b25c-8"},{"uid":"b25c-10"}]},"b25c-4":{"id":"/src/createQuery.ts","moduleParts":{"zip.esm.js":"b25c-5"},"imported":[{"uid":"b25c-2"},{"uid":"b25c-0"}],"importedBy":[{"uid":"b25c-16"},{"uid":"b25c-14"}]},"b25c-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"zip.esm.js":"b25c-7"},"imported":[{"uid":"b25c-2"},{"uid":"b25c-0"}],"importedBy":[{"uid":"b25c-16"},{"uid":"b25c-14"}]},"b25c-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"zip.esm.js":"b25c-9"},"imported":[{"uid":"b25c-2"},{"uid":"b25c-0"}],"importedBy":[{"uid":"b25c-16"},{"uid":"b25c-14"}]},"b25c-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"zip.esm.js":"b25c-11"},"imported":[{"uid":"b25c-2"},{"uid":"b25c-0"}],"importedBy":[{"uid":"b25c-16"},{"uid":"b25c-14"}]},"b25c-12":{"id":"/src/createMutation.ts","moduleParts":{"zip.esm.js":"b25c-13"},"imported":[{"uid":"b25c-0"}],"importedBy":[{"uid":"b25c-16"},{"uid":"b25c-14"}]},"b25c-14":{"id":"/src/router.ts","moduleParts":{"zip.esm.js":"b25c-15"},"imported":[{"uid":"b25c-8"},{"uid":"b25c-12"},{"uid":"b25c-4"},{"uid":"b25c-10"},{"uid":"b25c-6"}],"importedBy":[{"uid":"b25c-16"}]},"b25c-16":{"id":"/src/index.ts","moduleParts":{"zip.esm.js":"b25c-17"},"imported":[{"uid":"b25c-4"},{"uid":"b25c-6"},{"uid":"b25c-8"},{"uid":"b25c-10"},{"uid":"b25c-12"},{"uid":"b25c-18"},{"uid":"b25c-14"},{"uid":"b25c-0"}],"importedBy":[],"isEntry":true},"b25c-18":{"id":"/src/types.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"b25c-16"}]},"b25c-19":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"b25c-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;