react-query-kit 1.5.1 → 1.5.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.
Files changed (81) hide show
  1. package/README.md +17 -31
  2. package/build/lib/createBaseQuery.esm.js +12 -11
  3. package/build/lib/createBaseQuery.esm.js.map +1 -1
  4. package/build/lib/createBaseQuery.js +11 -10
  5. package/build/lib/createBaseQuery.js.map +1 -1
  6. package/build/lib/createBaseQuery.mjs +12 -11
  7. package/build/lib/createBaseQuery.mjs.map +1 -1
  8. package/build/lib/createInfiniteQuery.d.ts +1 -1
  9. package/build/lib/createInfiniteQuery.esm.js +2 -2
  10. package/build/lib/createInfiniteQuery.esm.js.map +1 -1
  11. package/build/lib/createInfiniteQuery.js +2 -2
  12. package/build/lib/createInfiniteQuery.js.map +1 -1
  13. package/build/lib/createInfiniteQuery.mjs +2 -2
  14. package/build/lib/createInfiniteQuery.mjs.map +1 -1
  15. package/build/lib/createMutation.d.ts +1 -1
  16. package/build/lib/createMutation.esm.js +4 -4
  17. package/build/lib/createMutation.esm.js.map +1 -1
  18. package/build/lib/createMutation.js +3 -3
  19. package/build/lib/createMutation.js.map +1 -1
  20. package/build/lib/createMutation.mjs +4 -4
  21. package/build/lib/createMutation.mjs.map +1 -1
  22. package/build/lib/createQuery.d.ts +1 -1
  23. package/build/lib/createQuery.esm.js +2 -2
  24. package/build/lib/createQuery.esm.js.map +1 -1
  25. package/build/lib/createQuery.js +2 -2
  26. package/build/lib/createQuery.js.map +1 -1
  27. package/build/lib/createQuery.mjs +2 -2
  28. package/build/lib/createQuery.mjs.map +1 -1
  29. package/build/lib/createSuspenseInfiniteQuery.d.ts +1 -1
  30. package/build/lib/createSuspenseInfiniteQuery.esm.js +2 -2
  31. package/build/lib/createSuspenseInfiniteQuery.esm.js.map +1 -1
  32. package/build/lib/createSuspenseInfiniteQuery.js +2 -2
  33. package/build/lib/createSuspenseInfiniteQuery.js.map +1 -1
  34. package/build/lib/createSuspenseInfiniteQuery.mjs +2 -2
  35. package/build/lib/createSuspenseInfiniteQuery.mjs.map +1 -1
  36. package/build/lib/createSuspenseQuery.d.ts +1 -1
  37. package/build/lib/createSuspenseQuery.esm.js +2 -2
  38. package/build/lib/createSuspenseQuery.esm.js.map +1 -1
  39. package/build/lib/createSuspenseQuery.js +2 -2
  40. package/build/lib/createSuspenseQuery.js.map +1 -1
  41. package/build/lib/createSuspenseQuery.mjs +2 -2
  42. package/build/lib/createSuspenseQuery.mjs.map +1 -1
  43. package/build/lib/index.d.ts +1 -2
  44. package/build/lib/index.esm.js +0 -1
  45. package/build/lib/index.esm.js.map +1 -1
  46. package/build/lib/index.js +0 -2
  47. package/build/lib/index.js.map +1 -1
  48. package/build/lib/index.mjs +0 -1
  49. package/build/lib/index.mjs.map +1 -1
  50. package/build/lib/types.d.ts +18 -16
  51. package/build/lib/utils.d.ts +4 -4
  52. package/build/lib/utils.esm.js +20 -19
  53. package/build/lib/utils.esm.js.map +1 -1
  54. package/build/lib/utils.js +20 -19
  55. package/build/lib/utils.js.map +1 -1
  56. package/build/lib/utils.mjs +20 -19
  57. package/build/lib/utils.mjs.map +1 -1
  58. package/build/stats-html.html +1 -1
  59. package/build/stats.json +91 -129
  60. package/build/umd/index.development.js +41 -54
  61. package/build/umd/index.development.js.map +1 -1
  62. package/build/umd/index.production.js +1 -1
  63. package/build/umd/index.production.js.map +1 -1
  64. package/package.json +2 -2
  65. package/src/createBaseQuery.ts +32 -33
  66. package/src/createInfiniteQuery.ts +2 -2
  67. package/src/createMutation.ts +4 -4
  68. package/src/createQuery.tsx +2 -2
  69. package/src/createSuspenseInfiniteQuery.ts +2 -2
  70. package/src/createSuspenseQuery.ts +2 -2
  71. package/src/index.ts +1 -4
  72. package/src/types.ts +117 -111
  73. package/src/utils.ts +22 -14
  74. package/build/lib/createImmutableQuery.d.ts +0 -6
  75. package/build/lib/createImmutableQuery.esm.js +0 -19
  76. package/build/lib/createImmutableQuery.esm.js.map +0 -1
  77. package/build/lib/createImmutableQuery.js +0 -23
  78. package/build/lib/createImmutableQuery.js.map +0 -1
  79. package/build/lib/createImmutableQuery.mjs +0 -19
  80. package/build/lib/createImmutableQuery.mjs.map +0 -1
  81. package/src/createImmutableQuery.tsx +0 -54
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["import { QueryClient, useQueryClient } from '@tanstack/react-query'\n\nimport { CompatibleWithV4, Middleware } from './types'\n\nexport const useCompatibeQueryClient = (\n options?: any,\n queryClient?: CompatibleWithV4<QueryClient, void>\n) =>\n // @ts-ignore\n useQueryClient(options?.context ? { context: options.context } : queryClient)\n\nexport const withMiddlewares = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n const { use = [], ...restOptions } = defaultOptions\n\n return function useMiddleware(\n options?: { client?: QueryClient; use?: Middleware[] },\n queryClient?: CompatibleWithV4<QueryClient, void>\n ) {\n const client = useCompatibeQueryClient(options, queryClient)\n\n let next = hook\n\n const { use: configUse = [], ...configOptions } =\n (client.getDefaultOptions()[type] as any) || {}\n\n const middleware: Middleware[] = configUse.concat(use)\n\n for (let i = middleware.length; i--; ) {\n next = middleware[i]!(next)\n }\n\n return next({ ...configOptions, ...restOptions, ...options }, queryClient)\n }\n}\n\nexport const getQueryKey = <TVariables>(\n primaryKey: string,\n variables?: TVariables\n) => {\n return variables === undefined ? [primaryKey] : [primaryKey, variables]\n}\n"],"names":["useCompatibeQueryClient","options","queryClient","useQueryClient","context","withMiddlewares","hook","defaultOptions","type","use","restOptions","useMiddleware","client","next","configUse","configOptions","getDefaultOptions","middleware","concat","i","length","getQueryKey","primaryKey","variables","undefined"],"mappings":";;MAIaA,uBAAuB,GAAG,CACrCC,OADqC,EAErCC,WAFqC;AAKrCC,cAAc,CAACF,OAAO,IAAA,IAAP,IAAAA,OAAO,CAAEG,OAAT,GAAmB;EAAEA,OAAO,EAAEH,OAAO,CAACG,OAAAA;AAAnB,CAAnB,GAAkDF,WAAnD,EALT;AAOA,MAAMG,eAAe,GAAG,CAC7BC,IAD6B,EAE7BC,cAF6B,EAG7BC,IAH6B,KAI1B;EACH,MAAM;AAAEC,IAAAA,GAAG,GAAG,EAAR;IAAY,GAAGC,WAAAA;AAAf,GAAA,GAA+BH,cAArC,CAAA;AAEA,EAAA,OAAO,SAASI,aAAT,CACLV,OADK,EAELC,WAFK,EAGL;AACA,IAAA,MAAMU,MAAM,GAAGZ,uBAAuB,CAACC,OAAD,EAAUC,WAAV,CAAtC,CAAA;IAEA,IAAIW,IAAI,GAAGP,IAAX,CAAA;IAEA,MAAM;MAAEG,GAAG,EAAEK,SAAS,GAAG,EAAnB;MAAuB,GAAGC,aAAAA;AAA1B,KAAA,GACHH,MAAM,CAACI,iBAAP,GAA2BR,IAA3B,CAAD,IAA6C,EAD/C,CAAA;AAGA,IAAA,MAAMS,UAAwB,GAAGH,SAAS,CAACI,MAAV,CAAiBT,GAAjB,CAAjC,CAAA;;IAEA,KAAK,IAAIU,CAAC,GAAGF,UAAU,CAACG,MAAxB,EAAgCD,CAAC,EAAjC,GAAuC;AACrCN,MAAAA,IAAI,GAAGI,UAAU,CAACE,CAAD,CAAV,CAAeN,IAAf,CAAP,CAAA;AACD,KAAA;;AAED,IAAA,OAAOA,IAAI,CAAC,EAAE,GAAGE,aAAL;AAAoB,MAAA,GAAGL,WAAvB;MAAoC,GAAGT,OAAAA;KAAxC,EAAmDC,WAAnD,CAAX,CAAA;GAjBF,CAAA;AAmBD,EA1BM;MA4BMmB,WAAW,GAAG,CACzBC,UADyB,EAEzBC,SAFyB,KAGtB;AACH,EAAA,OAAOA,SAAS,KAAKC,SAAd,GAA0B,CAACF,UAAD,CAA1B,GAAyC,CAACA,UAAD,EAAaC,SAAb,CAAhD,CAAA;AACD;;;;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/utils.ts"],"sourcesContent":["import { QueryClient, useQueryClient } from '@tanstack/react-query'\n\nimport { CompatibleWithV4, Middleware } from './types'\n\nexport const useCompatibeQueryClient = (\n options?: any,\n queryClient?: CompatibleWithV4<QueryClient, void>\n) => {\n return useQueryClient(\n // compatible with ReactQuery v4\n // @ts-ignore\n options?.context ? { context: options.context } : queryClient\n )\n}\n\nexport const withMiddleware = (\n hook: any,\n defaultOptions: any,\n type: 'queries' | 'mutations'\n) => {\n return function useMiddleware(\n options?: { client?: QueryClient; use?: Middleware[] },\n queryClient?: CompatibleWithV4<QueryClient, void>\n ) {\n const client = useCompatibeQueryClient(options, queryClient)\n const [middleware, opts] = [\n client.getDefaultOptions()[type],\n defaultOptions,\n options,\n ].reduce(\n (acc, item = {}) => {\n const [middleware, opts] = acc\n const { use = [], ...rest } = item\n return [[...middleware, ...use], { ...opts, ...rest }]\n },\n [[], {}]\n )\n\n let next = hook\n for (let i = middleware.length; i--; ) {\n next = middleware[i](next)\n }\n\n return next(opts, queryClient)\n }\n}\n\nexport const getQueryKey = <TVariables>(\n primaryKey: string,\n variables?: TVariables\n) => {\n return variables === undefined ? [primaryKey] : [primaryKey, variables]\n}\n"],"names":["useCompatibeQueryClient","options","queryClient","useQueryClient","context","withMiddleware","hook","defaultOptions","type","useMiddleware","client","middleware","opts","getDefaultOptions","reduce","acc","item","use","rest","next","i","length","getQueryKey","primaryKey","variables","undefined"],"mappings":";;MAIaA,uBAAuB,GAAG,CACrCC,OADqC,EAErCC,WAFqC,KAGlC;AACH,EAAA,OAAOC,cAAc;AAEnB;AACAF,EAAAA,OAAO,IAAP,IAAA,IAAAA,OAAO,CAAEG,OAAT,GAAmB;IAAEA,OAAO,EAAEH,OAAO,CAACG,OAAAA;GAAtC,GAAkDF,WAH/B,CAArB,CAAA;AAKD,EATM;AAWA,MAAMG,cAAc,GAAG,CAC5BC,IAD4B,EAE5BC,cAF4B,EAG5BC,IAH4B,KAIzB;AACH,EAAA,OAAO,SAASC,aAAT,CACLR,OADK,EAELC,WAFK,EAGL;AACA,IAAA,MAAMQ,MAAM,GAAGV,uBAAuB,CAACC,OAAD,EAAUC,WAAV,CAAtC,CAAA;IACA,MAAM,CAACS,UAAD,EAAaC,IAAb,CAAA,GAAqB,CACzBF,MAAM,CAACG,iBAAP,EAAA,CAA2BL,IAA3B,CADyB,EAEzBD,cAFyB,EAGzBN,OAHyB,CAAA,CAIzBa,MAJyB,CAKzB,CAACC,GAAD,EAAMC,IAAI,GAAG,EAAb,KAAoB;AAClB,MAAA,MAAM,CAACL,UAAD,EAAaC,IAAb,IAAqBG,GAA3B,CAAA;MACA,MAAM;AAAEE,QAAAA,GAAG,GAAG,EAAR;QAAY,GAAGC,IAAAA;AAAf,OAAA,GAAwBF,IAA9B,CAAA;MACA,OAAO,CAAC,CAAC,GAAGL,UAAJ,EAAgB,GAAGM,GAAnB,CAAD,EAA0B,EAAE,GAAGL,IAAL;QAAW,GAAGM,IAAAA;AAAd,OAA1B,CAAP,CAAA;AACD,KATwB,EAUzB,CAAC,EAAD,EAAK,EAAL,CAVyB,CAA3B,CAAA;IAaA,IAAIC,IAAI,GAAGb,IAAX,CAAA;;IACA,KAAK,IAAIc,CAAC,GAAGT,UAAU,CAACU,MAAxB,EAAgCD,CAAC,EAAjC,GAAuC;AACrCD,MAAAA,IAAI,GAAGR,UAAU,CAACS,CAAD,CAAV,CAAcD,IAAd,CAAP,CAAA;AACD,KAAA;;AAED,IAAA,OAAOA,IAAI,CAACP,IAAD,EAAOV,WAAP,CAAX,CAAA;GAvBF,CAAA;AAyBD,EA9BM;MAgCMoB,WAAW,GAAG,CACzBC,UADyB,EAEzBC,SAFyB,KAGtB;AACH,EAAA,OAAOA,SAAS,KAAKC,SAAd,GAA0B,CAACF,UAAD,CAA1B,GAAyC,CAACA,UAAD,EAAaC,SAAb,CAAhD,CAAA;AACD;;;;"}
@@ -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":"index.production.js","children":[{"name":"src","children":[{"uid":"d114-1","name":"utils.ts"},{"uid":"d114-3","name":"createBaseQuery.ts"},{"uid":"d114-5","name":"createQuery.tsx"},{"uid":"d114-7","name":"createImmutableQuery.tsx"},{"uid":"d114-9","name":"createSuspenseQuery.ts"},{"uid":"d114-11","name":"createInfiniteQuery.ts"},{"uid":"d114-13","name":"createSuspenseInfiniteQuery.ts"},{"uid":"d114-15","name":"createMutation.ts"},{"uid":"d114-17","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"d114-1":{"renderedLength":978,"gzipLength":414,"brotliLength":0,"mainUid":"d114-0"},"d114-3":{"renderedLength":1585,"gzipLength":512,"brotliLength":0,"mainUid":"d114-2"},"d114-5":{"renderedLength":95,"gzipLength":83,"brotliLength":0,"mainUid":"d114-4"},"d114-7":{"renderedLength":376,"gzipLength":204,"brotliLength":0,"mainUid":"d114-6"},"d114-9":{"renderedLength":269,"gzipLength":174,"brotliLength":0,"mainUid":"d114-8"},"d114-11":{"renderedLength":111,"gzipLength":92,"brotliLength":0,"mainUid":"d114-10"},"d114-13":{"renderedLength":285,"gzipLength":181,"brotliLength":0,"mainUid":"d114-12"},"d114-15":{"renderedLength":264,"gzipLength":174,"brotliLength":0,"mainUid":"d114-14"},"d114-17":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"d114-16"}},"nodeMetas":{"d114-0":{"id":"/src/utils.ts","moduleParts":{"index.production.js":"d114-1"},"imported":[{"uid":"d114-18"}],"importedBy":[{"uid":"d114-16"},{"uid":"d114-14"},{"uid":"d114-2"}]},"d114-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"index.production.js":"d114-3"},"imported":[{"uid":"d114-0"}],"importedBy":[{"uid":"d114-4"},{"uid":"d114-6"},{"uid":"d114-8"},{"uid":"d114-10"},{"uid":"d114-12"}]},"d114-4":{"id":"/src/createQuery.tsx","moduleParts":{"index.production.js":"d114-5"},"imported":[{"uid":"d114-18"},{"uid":"d114-2"}],"importedBy":[{"uid":"d114-16"}]},"d114-6":{"id":"/src/createImmutableQuery.tsx","moduleParts":{"index.production.js":"d114-7"},"imported":[{"uid":"d114-18"},{"uid":"d114-2"}],"importedBy":[{"uid":"d114-16"}]},"d114-8":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"index.production.js":"d114-9"},"imported":[{"uid":"d114-18"},{"uid":"d114-2"}],"importedBy":[{"uid":"d114-16"}]},"d114-10":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"index.production.js":"d114-11"},"imported":[{"uid":"d114-18"},{"uid":"d114-2"}],"importedBy":[{"uid":"d114-16"}]},"d114-12":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"index.production.js":"d114-13"},"imported":[{"uid":"d114-18"},{"uid":"d114-2"}],"importedBy":[{"uid":"d114-16"}]},"d114-14":{"id":"/src/createMutation.ts","moduleParts":{"index.production.js":"d114-15"},"imported":[{"uid":"d114-18"},{"uid":"d114-0"}],"importedBy":[{"uid":"d114-16"}]},"d114-16":{"id":"/src/index.ts","moduleParts":{"index.production.js":"d114-17"},"imported":[{"uid":"d114-4"},{"uid":"d114-6"},{"uid":"d114-8"},{"uid":"d114-10"},{"uid":"d114-12"},{"uid":"d114-14"},{"uid":"d114-0"}],"importedBy":[],"isEntry":true},"d114-18":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"d114-4"},{"uid":"d114-6"},{"uid":"d114-8"},{"uid":"d114-10"},{"uid":"d114-12"},{"uid":"d114-14"},{"uid":"d114-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":"index.production.js","children":[{"name":"src","children":[{"uid":"24d3-1","name":"utils.ts"},{"uid":"24d3-3","name":"createBaseQuery.ts"},{"uid":"24d3-5","name":"createQuery.tsx"},{"uid":"24d3-7","name":"createSuspenseQuery.ts"},{"uid":"24d3-9","name":"createInfiniteQuery.ts"},{"uid":"24d3-11","name":"createSuspenseInfiniteQuery.ts"},{"uid":"24d3-13","name":"createMutation.ts"},{"uid":"24d3-15","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"24d3-1":{"renderedLength":1070,"gzipLength":444,"brotliLength":0,"mainUid":"24d3-0"},"24d3-3":{"renderedLength":1470,"gzipLength":495,"brotliLength":0,"mainUid":"24d3-2"},"24d3-5":{"renderedLength":97,"gzipLength":90,"brotliLength":0,"mainUid":"24d3-4"},"24d3-7":{"renderedLength":271,"gzipLength":177,"brotliLength":0,"mainUid":"24d3-6"},"24d3-9":{"renderedLength":113,"gzipLength":99,"brotliLength":0,"mainUid":"24d3-8"},"24d3-11":{"renderedLength":287,"gzipLength":186,"brotliLength":0,"mainUid":"24d3-10"},"24d3-13":{"renderedLength":265,"gzipLength":173,"brotliLength":0,"mainUid":"24d3-12"},"24d3-15":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"mainUid":"24d3-14"}},"nodeMetas":{"24d3-0":{"id":"/src/utils.ts","moduleParts":{"index.production.js":"24d3-1"},"imported":[{"uid":"24d3-16"}],"importedBy":[{"uid":"24d3-14"},{"uid":"24d3-12"},{"uid":"24d3-2"}]},"24d3-2":{"id":"/src/createBaseQuery.ts","moduleParts":{"index.production.js":"24d3-3"},"imported":[{"uid":"24d3-0"}],"importedBy":[{"uid":"24d3-4"},{"uid":"24d3-6"},{"uid":"24d3-8"},{"uid":"24d3-10"}]},"24d3-4":{"id":"/src/createQuery.tsx","moduleParts":{"index.production.js":"24d3-5"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-6":{"id":"/src/createSuspenseQuery.ts","moduleParts":{"index.production.js":"24d3-7"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-8":{"id":"/src/createInfiniteQuery.ts","moduleParts":{"index.production.js":"24d3-9"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-10":{"id":"/src/createSuspenseInfiniteQuery.ts","moduleParts":{"index.production.js":"24d3-11"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-2"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-12":{"id":"/src/createMutation.ts","moduleParts":{"index.production.js":"24d3-13"},"imported":[{"uid":"24d3-16"},{"uid":"24d3-0"}],"importedBy":[{"uid":"24d3-14"}]},"24d3-14":{"id":"/src/index.ts","moduleParts":{"index.production.js":"24d3-15"},"imported":[{"uid":"24d3-4"},{"uid":"24d3-6"},{"uid":"24d3-8"},{"uid":"24d3-10"},{"uid":"24d3-12"},{"uid":"24d3-0"}],"importedBy":[],"isEntry":true},"24d3-16":{"id":"@tanstack/react-query","moduleParts":{},"imported":[],"importedBy":[{"uid":"24d3-4"},{"uid":"24d3-6"},{"uid":"24d3-8"},{"uid":"24d3-10"},{"uid":"24d3-12"},{"uid":"24d3-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;
package/build/stats.json CHANGED
@@ -10,39 +10,35 @@
10
10
  "name": "src",
11
11
  "children": [
12
12
  {
13
- "uid": "d114-20",
13
+ "uid": "24d3-18",
14
14
  "name": "utils.ts"
15
15
  },
16
16
  {
17
- "uid": "d114-22",
17
+ "uid": "24d3-20",
18
18
  "name": "createBaseQuery.ts"
19
19
  },
20
20
  {
21
- "uid": "d114-24",
21
+ "uid": "24d3-22",
22
22
  "name": "createQuery.tsx"
23
23
  },
24
24
  {
25
- "uid": "d114-26",
26
- "name": "createImmutableQuery.tsx"
27
- },
28
- {
29
- "uid": "d114-28",
25
+ "uid": "24d3-24",
30
26
  "name": "createSuspenseQuery.ts"
31
27
  },
32
28
  {
33
- "uid": "d114-30",
29
+ "uid": "24d3-26",
34
30
  "name": "createInfiniteQuery.ts"
35
31
  },
36
32
  {
37
- "uid": "d114-32",
33
+ "uid": "24d3-28",
38
34
  "name": "createSuspenseInfiniteQuery.ts"
39
35
  },
40
36
  {
41
- "uid": "d114-34",
37
+ "uid": "24d3-30",
42
38
  "name": "createMutation.ts"
43
39
  },
44
40
  {
45
- "uid": "d114-36",
41
+ "uid": "24d3-32",
46
42
  "name": "index.ts"
47
43
  }
48
44
  ]
@@ -53,282 +49,248 @@
53
49
  "isRoot": true
54
50
  },
55
51
  "nodeParts": {
56
- "d114-20": {
57
- "renderedLength": 978,
58
- "gzipLength": 414,
59
- "brotliLength": 0,
60
- "mainUid": "d114-19"
61
- },
62
- "d114-22": {
63
- "renderedLength": 1585,
64
- "gzipLength": 512,
52
+ "24d3-18": {
53
+ "renderedLength": 1070,
54
+ "gzipLength": 444,
65
55
  "brotliLength": 0,
66
- "mainUid": "d114-21"
56
+ "mainUid": "24d3-17"
67
57
  },
68
- "d114-24": {
69
- "renderedLength": 95,
70
- "gzipLength": 83,
58
+ "24d3-20": {
59
+ "renderedLength": 1470,
60
+ "gzipLength": 495,
71
61
  "brotliLength": 0,
72
- "mainUid": "d114-23"
62
+ "mainUid": "24d3-19"
73
63
  },
74
- "d114-26": {
75
- "renderedLength": 376,
76
- "gzipLength": 204,
64
+ "24d3-22": {
65
+ "renderedLength": 97,
66
+ "gzipLength": 90,
77
67
  "brotliLength": 0,
78
- "mainUid": "d114-25"
68
+ "mainUid": "24d3-21"
79
69
  },
80
- "d114-28": {
81
- "renderedLength": 269,
82
- "gzipLength": 174,
70
+ "24d3-24": {
71
+ "renderedLength": 271,
72
+ "gzipLength": 177,
83
73
  "brotliLength": 0,
84
- "mainUid": "d114-27"
74
+ "mainUid": "24d3-23"
85
75
  },
86
- "d114-30": {
87
- "renderedLength": 111,
88
- "gzipLength": 92,
76
+ "24d3-26": {
77
+ "renderedLength": 113,
78
+ "gzipLength": 99,
89
79
  "brotliLength": 0,
90
- "mainUid": "d114-29"
80
+ "mainUid": "24d3-25"
91
81
  },
92
- "d114-32": {
93
- "renderedLength": 285,
94
- "gzipLength": 181,
82
+ "24d3-28": {
83
+ "renderedLength": 287,
84
+ "gzipLength": 186,
95
85
  "brotliLength": 0,
96
- "mainUid": "d114-31"
86
+ "mainUid": "24d3-27"
97
87
  },
98
- "d114-34": {
99
- "renderedLength": 264,
100
- "gzipLength": 174,
88
+ "24d3-30": {
89
+ "renderedLength": 265,
90
+ "gzipLength": 173,
101
91
  "brotliLength": 0,
102
- "mainUid": "d114-33"
92
+ "mainUid": "24d3-29"
103
93
  },
104
- "d114-36": {
94
+ "24d3-32": {
105
95
  "renderedLength": 0,
106
96
  "gzipLength": 0,
107
97
  "brotliLength": 0,
108
- "mainUid": "d114-35"
98
+ "mainUid": "24d3-31"
109
99
  }
110
100
  },
111
101
  "nodeMetas": {
112
- "d114-19": {
102
+ "24d3-17": {
113
103
  "id": "/src/utils.ts",
114
104
  "moduleParts": {
115
- "index.production.js": "d114-20"
105
+ "index.production.js": "24d3-18"
116
106
  },
117
107
  "imported": [
118
108
  {
119
- "uid": "d114-37"
109
+ "uid": "24d3-33"
120
110
  }
121
111
  ],
122
112
  "importedBy": [
123
113
  {
124
- "uid": "d114-35"
114
+ "uid": "24d3-31"
125
115
  },
126
116
  {
127
- "uid": "d114-33"
117
+ "uid": "24d3-29"
128
118
  },
129
119
  {
130
- "uid": "d114-21"
120
+ "uid": "24d3-19"
131
121
  }
132
122
  ]
133
123
  },
134
- "d114-21": {
124
+ "24d3-19": {
135
125
  "id": "/src/createBaseQuery.ts",
136
126
  "moduleParts": {
137
- "index.production.js": "d114-22"
127
+ "index.production.js": "24d3-20"
138
128
  },
139
129
  "imported": [
140
130
  {
141
- "uid": "d114-19"
131
+ "uid": "24d3-17"
142
132
  }
143
133
  ],
144
134
  "importedBy": [
145
135
  {
146
- "uid": "d114-23"
147
- },
148
- {
149
- "uid": "d114-25"
136
+ "uid": "24d3-21"
150
137
  },
151
138
  {
152
- "uid": "d114-27"
139
+ "uid": "24d3-23"
153
140
  },
154
141
  {
155
- "uid": "d114-29"
142
+ "uid": "24d3-25"
156
143
  },
157
144
  {
158
- "uid": "d114-31"
145
+ "uid": "24d3-27"
159
146
  }
160
147
  ]
161
148
  },
162
- "d114-23": {
149
+ "24d3-21": {
163
150
  "id": "/src/createQuery.tsx",
164
151
  "moduleParts": {
165
- "index.production.js": "d114-24"
152
+ "index.production.js": "24d3-22"
166
153
  },
167
154
  "imported": [
168
155
  {
169
- "uid": "d114-37"
156
+ "uid": "24d3-33"
170
157
  },
171
158
  {
172
- "uid": "d114-21"
159
+ "uid": "24d3-19"
173
160
  }
174
161
  ],
175
162
  "importedBy": [
176
163
  {
177
- "uid": "d114-35"
164
+ "uid": "24d3-31"
178
165
  }
179
166
  ]
180
167
  },
181
- "d114-25": {
182
- "id": "/src/createImmutableQuery.tsx",
183
- "moduleParts": {
184
- "index.production.js": "d114-26"
185
- },
186
- "imported": [
187
- {
188
- "uid": "d114-37"
189
- },
190
- {
191
- "uid": "d114-21"
192
- }
193
- ],
194
- "importedBy": [
195
- {
196
- "uid": "d114-35"
197
- }
198
- ]
199
- },
200
- "d114-27": {
168
+ "24d3-23": {
201
169
  "id": "/src/createSuspenseQuery.ts",
202
170
  "moduleParts": {
203
- "index.production.js": "d114-28"
171
+ "index.production.js": "24d3-24"
204
172
  },
205
173
  "imported": [
206
174
  {
207
- "uid": "d114-37"
175
+ "uid": "24d3-33"
208
176
  },
209
177
  {
210
- "uid": "d114-21"
178
+ "uid": "24d3-19"
211
179
  }
212
180
  ],
213
181
  "importedBy": [
214
182
  {
215
- "uid": "d114-35"
183
+ "uid": "24d3-31"
216
184
  }
217
185
  ]
218
186
  },
219
- "d114-29": {
187
+ "24d3-25": {
220
188
  "id": "/src/createInfiniteQuery.ts",
221
189
  "moduleParts": {
222
- "index.production.js": "d114-30"
190
+ "index.production.js": "24d3-26"
223
191
  },
224
192
  "imported": [
225
193
  {
226
- "uid": "d114-37"
194
+ "uid": "24d3-33"
227
195
  },
228
196
  {
229
- "uid": "d114-21"
197
+ "uid": "24d3-19"
230
198
  }
231
199
  ],
232
200
  "importedBy": [
233
201
  {
234
- "uid": "d114-35"
202
+ "uid": "24d3-31"
235
203
  }
236
204
  ]
237
205
  },
238
- "d114-31": {
206
+ "24d3-27": {
239
207
  "id": "/src/createSuspenseInfiniteQuery.ts",
240
208
  "moduleParts": {
241
- "index.production.js": "d114-32"
209
+ "index.production.js": "24d3-28"
242
210
  },
243
211
  "imported": [
244
212
  {
245
- "uid": "d114-37"
213
+ "uid": "24d3-33"
246
214
  },
247
215
  {
248
- "uid": "d114-21"
216
+ "uid": "24d3-19"
249
217
  }
250
218
  ],
251
219
  "importedBy": [
252
220
  {
253
- "uid": "d114-35"
221
+ "uid": "24d3-31"
254
222
  }
255
223
  ]
256
224
  },
257
- "d114-33": {
225
+ "24d3-29": {
258
226
  "id": "/src/createMutation.ts",
259
227
  "moduleParts": {
260
- "index.production.js": "d114-34"
228
+ "index.production.js": "24d3-30"
261
229
  },
262
230
  "imported": [
263
231
  {
264
- "uid": "d114-37"
232
+ "uid": "24d3-33"
265
233
  },
266
234
  {
267
- "uid": "d114-19"
235
+ "uid": "24d3-17"
268
236
  }
269
237
  ],
270
238
  "importedBy": [
271
239
  {
272
- "uid": "d114-35"
240
+ "uid": "24d3-31"
273
241
  }
274
242
  ]
275
243
  },
276
- "d114-35": {
244
+ "24d3-31": {
277
245
  "id": "/src/index.ts",
278
246
  "moduleParts": {
279
- "index.production.js": "d114-36"
247
+ "index.production.js": "24d3-32"
280
248
  },
281
249
  "imported": [
282
250
  {
283
- "uid": "d114-23"
284
- },
285
- {
286
- "uid": "d114-25"
251
+ "uid": "24d3-21"
287
252
  },
288
253
  {
289
- "uid": "d114-27"
254
+ "uid": "24d3-23"
290
255
  },
291
256
  {
292
- "uid": "d114-29"
257
+ "uid": "24d3-25"
293
258
  },
294
259
  {
295
- "uid": "d114-31"
260
+ "uid": "24d3-27"
296
261
  },
297
262
  {
298
- "uid": "d114-33"
263
+ "uid": "24d3-29"
299
264
  },
300
265
  {
301
- "uid": "d114-19"
266
+ "uid": "24d3-17"
302
267
  }
303
268
  ],
304
269
  "importedBy": [],
305
270
  "isEntry": true
306
271
  },
307
- "d114-37": {
272
+ "24d3-33": {
308
273
  "id": "@tanstack/react-query",
309
274
  "moduleParts": {},
310
275
  "imported": [],
311
276
  "importedBy": [
312
277
  {
313
- "uid": "d114-23"
314
- },
315
- {
316
- "uid": "d114-25"
278
+ "uid": "24d3-21"
317
279
  },
318
280
  {
319
- "uid": "d114-27"
281
+ "uid": "24d3-23"
320
282
  },
321
283
  {
322
- "uid": "d114-29"
284
+ "uid": "24d3-25"
323
285
  },
324
286
  {
325
- "uid": "d114-31"
287
+ "uid": "24d3-27"
326
288
  },
327
289
  {
328
- "uid": "d114-33"
290
+ "uid": "24d3-29"
329
291
  },
330
292
  {
331
- "uid": "d114-19"
293
+ "uid": "24d3-17"
332
294
  }
333
295
  ],
334
296
  "isExternal": true
@@ -4,32 +4,33 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactQueryKit = {}, global.ReactQuery));
5
5
  })(this, (function (exports, reactQuery) { 'use strict';
6
6
 
7
- const useCompatibeQueryClient = (options, queryClient) => // @ts-ignore
8
- reactQuery.useQueryClient(options != null && options.context ? {
9
- context: options.context
10
- } : queryClient);
11
- const withMiddlewares = (hook, defaultOptions, type) => {
12
- const {
13
- use = [],
14
- ...restOptions
15
- } = defaultOptions;
7
+ const useCompatibeQueryClient = (options, queryClient) => {
8
+ return reactQuery.useQueryClient( // compatible with ReactQuery v4
9
+ // @ts-ignore
10
+ options != null && options.context ? {
11
+ context: options.context
12
+ } : queryClient);
13
+ };
14
+ const withMiddleware = (hook, defaultOptions, type) => {
16
15
  return function useMiddleware(options, queryClient) {
17
16
  const client = useCompatibeQueryClient(options, queryClient);
17
+ const [middleware, opts] = [client.getDefaultOptions()[type], defaultOptions, options].reduce((acc, item = {}) => {
18
+ const [middleware, opts] = acc;
19
+ const {
20
+ use = [],
21
+ ...rest
22
+ } = item;
23
+ return [[...middleware, ...use], { ...opts,
24
+ ...rest
25
+ }];
26
+ }, [[], {}]);
18
27
  let next = hook;
19
- const {
20
- use: configUse = [],
21
- ...configOptions
22
- } = client.getDefaultOptions()[type] || {};
23
- const middleware = configUse.concat(use);
24
28
 
25
29
  for (let i = middleware.length; i--;) {
26
30
  next = middleware[i](next);
27
31
  }
28
32
 
29
- return next({ ...configOptions,
30
- ...restOptions,
31
- ...options
32
- }, queryClient);
33
+ return next(opts, queryClient);
33
34
  };
34
35
  };
35
36
  const getQueryKey = (primaryKey, variables) => {
@@ -38,7 +39,9 @@
38
39
 
39
40
  function createBaseQuery(defaultOptions, useRQHook, overrideOptions) {
40
41
  const {
41
- primaryKey
42
+ primaryKey,
43
+ queryFn,
44
+ queryKeyHashFn
42
45
  } = defaultOptions;
43
46
 
44
47
  {
@@ -55,15 +58,15 @@
55
58
  const getFetchOptions = variables => {
56
59
  return {
57
60
  queryKey: getKey(variables),
58
- queryFn: defaultOptions.queryFn,
59
- queryKeyHashFn: defaultOptions.queryKeyHashFn,
61
+ queryFn,
62
+ queryKeyHashFn,
60
63
  getPreviousPageParam: defaultOptions.getPreviousPageParam,
61
64
  getNextPageParam: defaultOptions.getNextPageParam,
62
65
  initialPageParam: defaultOptions.initialPageParam
63
66
  };
64
67
  };
65
68
 
66
- const useGeneratedQuery = (options, queryClient) => {
69
+ const useBaseHook = (options, queryClient) => {
67
70
  const client = useCompatibeQueryClient(options, queryClient);
68
71
  const {
69
72
  enabled,
@@ -73,45 +76,30 @@
73
76
  ...overrideOptions
74
77
  };
75
78
  const queryKey = getKey(variables);
76
- const result = useRQHook({ ...mergedOptions,
79
+ return Object.assign(useRQHook({ ...mergedOptions,
77
80
  enabled: typeof enabled === 'function' ? enabled(client.getQueryData(queryKey), variables) : enabled,
78
81
  queryKey
79
- }, client);
80
- return Object.assign(result, {
82
+ }, client), {
81
83
  queryKey: queryKey,
82
84
  variables,
83
85
  setData: (updater, setDataOptions) => client.setQueryData(queryKey, updater, setDataOptions)
84
86
  });
85
87
  };
86
88
 
87
- return Object.assign(withMiddlewares(useGeneratedQuery, defaultOptions, 'queries'), {
89
+ return Object.assign(withMiddleware(useBaseHook, defaultOptions, 'queries'), {
88
90
  getPrimaryKey,
89
91
  getKey,
90
- queryFn: defaultOptions.queryFn,
91
- queryKeyHashFn: defaultOptions.queryKeyHashFn,
92
+ queryFn,
93
+ queryKeyHashFn,
92
94
  getFetchOptions
93
95
  });
94
96
  }
95
97
 
96
- function createQuery(options) {
98
+ const createQuery = options => {
97
99
  return createBaseQuery(options, reactQuery.useQuery);
98
- }
99
-
100
- function createImmutableQuery(options) {
101
- return createBaseQuery(options, reactQuery.useQuery, {
102
- refetchInterval: false,
103
- refetchOnMount: false,
104
- refetchOnReconnect: false,
105
- refetchOnWindowFocus: false,
106
- staleTime: Infinity,
107
- gcTime: Infinity,
108
- // compatible with ReactQuery v4
109
- // @ts-ignore
110
- cacheTime: Infinity
111
- });
112
- }
100
+ };
113
101
 
114
- function createSuspenseQuery(options) {
102
+ const createSuspenseQuery = options => {
115
103
  return createBaseQuery(options, reactQuery.useQuery, {
116
104
  enabled: true,
117
105
  suspense: true,
@@ -120,13 +108,13 @@
120
108
  // @ts-ignore
121
109
  useErrorBoundary: true
122
110
  });
123
- }
111
+ };
124
112
 
125
- function createInfiniteQuery(options) {
113
+ const createInfiniteQuery = options => {
126
114
  return createBaseQuery(options, reactQuery.useInfiniteQuery);
127
- }
115
+ };
128
116
 
129
- function createSuspenseInfiniteQuery(options) {
117
+ const createSuspenseInfiniteQuery = options => {
130
118
  return createBaseQuery(options, reactQuery.useInfiniteQuery, {
131
119
  enabled: true,
132
120
  suspense: true,
@@ -135,18 +123,17 @@
135
123
  // @ts-ignore
136
124
  useErrorBoundary: true
137
125
  });
138
- }
126
+ };
139
127
 
140
- function createMutation(defaultOptions) {
128
+ const createMutation = defaultOptions => {
141
129
  const getKey = () => defaultOptions.mutationKey;
142
130
 
143
- return Object.assign(withMiddlewares(reactQuery.useMutation, defaultOptions, 'mutations'), {
131
+ return Object.assign(withMiddleware(reactQuery.useMutation, defaultOptions, 'mutations'), {
144
132
  getKey,
145
133
  mutationFn: defaultOptions.mutationFn
146
134
  });
147
- }
135
+ };
148
136
 
149
- exports.createImmutableQuery = createImmutableQuery;
150
137
  exports.createInfiniteQuery = createInfiniteQuery;
151
138
  exports.createMutation = createMutation;
152
139
  exports.createQuery = createQuery;