@robohall/react-query-factory 2.1.5 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ function wrapGetNextPageParam(getNextPageParam, shouldFetchNextPage, crawlOption
64
64
  }
65
65
  function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shouldFetchNextPage, reduce) {
66
66
  return async (params, crawlOptions, context) => {
67
- var _a, _b, _c, _d;
67
+ var _a, _b, _c;
68
68
  if ((_a = context.signal) == null ? void 0 : _a.aborted) {
69
69
  if (reduce) throw new DOMException("Aborted", "AbortError");
70
70
  return [];
@@ -74,10 +74,10 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
74
74
  if (isAsyncIterable(initialResult)) {
75
75
  const pages2 = [];
76
76
  let acc2 = void 0;
77
- for await (const page of initialResult) {
77
+ for await (const page2 of initialResult) {
78
78
  if ((_b = context.signal) == null ? void 0 : _b.aborted) break;
79
- pages2.push(page);
80
- if (reduce) acc2 = reduce(acc2, page);
79
+ pages2.push(page2);
80
+ if (reduce) acc2 = reduce(acc2, page2);
81
81
  if (!shouldFetchNextPage(acc2, crawlOptions)) break;
82
82
  }
83
83
  if (reduce) {
@@ -90,9 +90,8 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
90
90
  const pageParams = [];
91
91
  let currentParam = initialPageParam;
92
92
  let acc = void 0;
93
- let nextResult = initialResult;
93
+ let page = await initialResult;
94
94
  while (true) {
95
- const page = await nextResult;
96
95
  pages.push(page);
97
96
  pageParams.push(currentParam);
98
97
  if (reduce) acc = reduce(acc, page);
@@ -102,9 +101,8 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
102
101
  const nextParam = getNextPageParam(page, pages, currentParam, pageParams);
103
102
  if (nextParam == null) break;
104
103
  currentParam = nextParam;
105
- if ((_d = context.signal) == null ? void 0 : _d.aborted) break;
106
104
  ctx.pageParam = currentParam;
107
- nextResult = queryFn(params, ctx);
105
+ page = await queryFn(params, ctx);
108
106
  }
109
107
  if (reduce) {
110
108
  if (acc === void 0) throw new DOMException("Aborted", "AbortError");
@@ -115,7 +113,7 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
115
113
  }
116
114
  function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNextPage, reduce) {
117
115
  return async (params, crawlOptions, context) => {
118
- var _a, _b, _c, _d;
116
+ var _a, _b, _c;
119
117
  if ((_a = context.signal) == null ? void 0 : _a.aborted)
120
118
  throw new DOMException("Aborted", "AbortError");
121
119
  const ctx = { ...context, pageParam: context.pageParam };
@@ -125,11 +123,11 @@ function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNext
125
123
  const startParam = context.pageParam;
126
124
  let acc2 = void 0;
127
125
  let nextBatchParam2 = null;
128
- for await (const page of initialResult) {
126
+ for await (const page2 of initialResult) {
129
127
  if ((_b = context.signal) == null ? void 0 : _b.aborted) break;
130
- pages2.push(page);
131
- acc2 = reduce(acc2, page);
132
- const nextParam = getNextPageParam(page, pages2, startParam, [
128
+ pages2.push(page2);
129
+ acc2 = reduce(acc2, page2);
130
+ const nextParam = getNextPageParam(page2, pages2, startParam, [
133
131
  startParam
134
132
  ]);
135
133
  nextBatchParam2 = nextParam != null ? nextParam : null;
@@ -144,9 +142,8 @@ function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNext
144
142
  let currentParam = context.pageParam;
145
143
  let acc = void 0;
146
144
  let nextBatchParam = null;
147
- let nextResult = initialResult;
145
+ let page = await initialResult;
148
146
  while (true) {
149
- const page = await nextResult;
150
147
  pages.push(page);
151
148
  pageParams.push(currentParam);
152
149
  acc = reduce(acc, page);
@@ -156,9 +153,8 @@ function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNext
156
153
  if (nextParam == null) break;
157
154
  if (!shouldFetchNextPage(acc, crawlOptions)) break;
158
155
  currentParam = nextParam;
159
- if ((_d = context.signal) == null ? void 0 : _d.aborted) break;
160
156
  ctx.pageParam = currentParam;
161
- nextResult = queryFn(params, ctx);
157
+ page = await queryFn(params, ctx);
162
158
  }
163
159
  if (acc === void 0) throw new DOMException("Aborted", "AbortError");
164
160
  return { data: acc, nextPageParam: nextBatchParam };
package/dist/index.mjs CHANGED
@@ -38,7 +38,7 @@ function wrapGetNextPageParam(getNextPageParam, shouldFetchNextPage, crawlOption
38
38
  }
39
39
  function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shouldFetchNextPage, reduce) {
40
40
  return async (params, crawlOptions, context) => {
41
- var _a, _b, _c, _d;
41
+ var _a, _b, _c;
42
42
  if ((_a = context.signal) == null ? void 0 : _a.aborted) {
43
43
  if (reduce) throw new DOMException("Aborted", "AbortError");
44
44
  return [];
@@ -48,10 +48,10 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
48
48
  if (isAsyncIterable(initialResult)) {
49
49
  const pages2 = [];
50
50
  let acc2 = void 0;
51
- for await (const page of initialResult) {
51
+ for await (const page2 of initialResult) {
52
52
  if ((_b = context.signal) == null ? void 0 : _b.aborted) break;
53
- pages2.push(page);
54
- if (reduce) acc2 = reduce(acc2, page);
53
+ pages2.push(page2);
54
+ if (reduce) acc2 = reduce(acc2, page2);
55
55
  if (!shouldFetchNextPage(acc2, crawlOptions)) break;
56
56
  }
57
57
  if (reduce) {
@@ -64,9 +64,8 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
64
64
  const pageParams = [];
65
65
  let currentParam = initialPageParam;
66
66
  let acc = void 0;
67
- let nextResult = initialResult;
67
+ let page = await initialResult;
68
68
  while (true) {
69
- const page = await nextResult;
70
69
  pages.push(page);
71
70
  pageParams.push(currentParam);
72
71
  if (reduce) acc = reduce(acc, page);
@@ -76,9 +75,8 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
76
75
  const nextParam = getNextPageParam(page, pages, currentParam, pageParams);
77
76
  if (nextParam == null) break;
78
77
  currentParam = nextParam;
79
- if ((_d = context.signal) == null ? void 0 : _d.aborted) break;
80
78
  ctx.pageParam = currentParam;
81
- nextResult = queryFn(params, ctx);
79
+ page = await queryFn(params, ctx);
82
80
  }
83
81
  if (reduce) {
84
82
  if (acc === void 0) throw new DOMException("Aborted", "AbortError");
@@ -89,7 +87,7 @@ function buildCrawlingQueryFn(queryFn, getNextPageParam, initialPageParam, shoul
89
87
  }
90
88
  function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNextPage, reduce) {
91
89
  return async (params, crawlOptions, context) => {
92
- var _a, _b, _c, _d;
90
+ var _a, _b, _c;
93
91
  if ((_a = context.signal) == null ? void 0 : _a.aborted)
94
92
  throw new DOMException("Aborted", "AbortError");
95
93
  const ctx = { ...context, pageParam: context.pageParam };
@@ -99,11 +97,11 @@ function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNext
99
97
  const startParam = context.pageParam;
100
98
  let acc2 = void 0;
101
99
  let nextBatchParam2 = null;
102
- for await (const page of initialResult) {
100
+ for await (const page2 of initialResult) {
103
101
  if ((_b = context.signal) == null ? void 0 : _b.aborted) break;
104
- pages2.push(page);
105
- acc2 = reduce(acc2, page);
106
- const nextParam = getNextPageParam(page, pages2, startParam, [
102
+ pages2.push(page2);
103
+ acc2 = reduce(acc2, page2);
104
+ const nextParam = getNextPageParam(page2, pages2, startParam, [
107
105
  startParam
108
106
  ]);
109
107
  nextBatchParam2 = nextParam != null ? nextParam : null;
@@ -118,9 +116,8 @@ function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNext
118
116
  let currentParam = context.pageParam;
119
117
  let acc = void 0;
120
118
  let nextBatchParam = null;
121
- let nextResult = initialResult;
119
+ let page = await initialResult;
122
120
  while (true) {
123
- const page = await nextResult;
124
121
  pages.push(page);
125
122
  pageParams.push(currentParam);
126
123
  acc = reduce(acc, page);
@@ -130,9 +127,8 @@ function buildInfiniteCrawlingQueryFn(queryFn, getNextPageParam, shouldFetchNext
130
127
  if (nextParam == null) break;
131
128
  if (!shouldFetchNextPage(acc, crawlOptions)) break;
132
129
  currentParam = nextParam;
133
- if ((_d = context.signal) == null ? void 0 : _d.aborted) break;
134
130
  ctx.pageParam = currentParam;
135
- nextResult = queryFn(params, ctx);
131
+ page = await queryFn(params, ctx);
136
132
  }
137
133
  if (acc === void 0) throw new DOMException("Aborted", "AbortError");
138
134
  return { data: acc, nextPageParam: nextBatchParam };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robohall/react-query-factory",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "A factory abstraction for TanStack Query (React Query) with composable keys, crawling support, and automatic infinite query generation",
5
5
  "author": "Robert Hall",
6
6
  "license": "MIT",