@ventlio/tanstack-query 0.2.48 → 0.2.50
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.mjs +18 -5
- package/dist/index.mjs.map +1 -1
- package/dist/queries/useGetRequest.js +3 -4
- package/dist/queries/useGetRequest.js.map +1 -1
- package/dist/request/buildFormData.js +15 -1
- package/dist/request/buildFormData.js.map +1 -1
- package/package.json +1 -1
- package/src/queries/useGetRequest.ts +3 -4
- package/src/request/buildFormData.ts +20 -1
package/dist/index.mjs
CHANGED
|
@@ -117,7 +117,21 @@ const buildFormData = (body) => {
|
|
|
117
117
|
const formData = new FormData();
|
|
118
118
|
const bodyKeys = Object.keys(body);
|
|
119
119
|
bodyKeys.forEach((key) => {
|
|
120
|
-
|
|
120
|
+
const inputValue = body[key];
|
|
121
|
+
// if inputValue is array and the first item is array, append everything to the
|
|
122
|
+
if (inputValue instanceof Array && inputValue.length > 0) {
|
|
123
|
+
// append all files
|
|
124
|
+
for (const file of inputValue) {
|
|
125
|
+
formData.append(key, file);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// else if inputValue is Object upload it as blob
|
|
129
|
+
else if (inputValue instanceof Object) {
|
|
130
|
+
formData.append(key, new Blob([JSON.stringify(inputValue)], {
|
|
131
|
+
type: 'application/json',
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
formData.append(key, inputValue);
|
|
121
135
|
});
|
|
122
136
|
return formData;
|
|
123
137
|
};
|
|
@@ -304,10 +318,9 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
|
|
|
304
318
|
}
|
|
305
319
|
};
|
|
306
320
|
const constructPaginationLink = (link, pageNumber) => {
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const queryParams = new URLSearchParams(queryStrings ?? '');
|
|
321
|
+
const [pathname, queryString] = link.split('?');
|
|
322
|
+
const queryParams = new URLSearchParams(queryString);
|
|
323
|
+
const oldPage = Number(queryParams.get('page'));
|
|
311
324
|
queryParams.set('page', pageNumber);
|
|
312
325
|
link = pathname + '?' + queryParams.toString();
|
|
313
326
|
// only update page when pagination number changed
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -71,10 +71,9 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
const constructPaginationLink = (link, pageNumber) => {
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const queryParams = new URLSearchParams(queryStrings ?? '');
|
|
74
|
+
const [pathname, queryString] = link.split('?');
|
|
75
|
+
const queryParams = new URLSearchParams(queryString);
|
|
76
|
+
const oldPage = Number(queryParams.get('page'));
|
|
78
77
|
queryParams.set('page', pageNumber);
|
|
79
78
|
link = pathname + '?' + queryParams.toString();
|
|
80
79
|
// only update page when pagination number changed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -4,7 +4,21 @@ const buildFormData = (body) => {
|
|
|
4
4
|
const formData = new FormData();
|
|
5
5
|
const bodyKeys = Object.keys(body);
|
|
6
6
|
bodyKeys.forEach((key) => {
|
|
7
|
-
|
|
7
|
+
const inputValue = body[key];
|
|
8
|
+
// if inputValue is array and the first item is array, append everything to the
|
|
9
|
+
if (inputValue instanceof Array && inputValue.length > 0) {
|
|
10
|
+
// append all files
|
|
11
|
+
for (const file of inputValue) {
|
|
12
|
+
formData.append(key, file);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// else if inputValue is Object upload it as blob
|
|
16
|
+
else if (inputValue instanceof Object) {
|
|
17
|
+
formData.append(key, new Blob([JSON.stringify(inputValue)], {
|
|
18
|
+
type: 'application/json',
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
formData.append(key, inputValue);
|
|
8
22
|
});
|
|
9
23
|
return formData;
|
|
10
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFormData.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildFormData.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -119,11 +119,10 @@ export const useGetRequest = <TResponse extends Record<string, any>>({
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
const constructPaginationLink = (link: string, pageNumber: number) => {
|
|
122
|
-
const
|
|
123
|
-
const
|
|
122
|
+
const [pathname, queryString] = link.split('?');
|
|
123
|
+
const queryParams = new URLSearchParams(queryString);
|
|
124
124
|
|
|
125
|
-
const
|
|
126
|
-
const queryParams = new URLSearchParams(queryStrings ?? '');
|
|
125
|
+
const oldPage = Number(queryParams.get('page'));
|
|
127
126
|
|
|
128
127
|
queryParams.set('page', pageNumber as any);
|
|
129
128
|
|
|
@@ -4,7 +4,26 @@ export const buildFormData = (body: Record<string, any>) => {
|
|
|
4
4
|
const bodyKeys = Object.keys(body);
|
|
5
5
|
|
|
6
6
|
bodyKeys.forEach((key) => {
|
|
7
|
-
|
|
7
|
+
const inputValue = body[key];
|
|
8
|
+
|
|
9
|
+
// if inputValue is array and the first item is array, append everything to the
|
|
10
|
+
if (inputValue instanceof Array && inputValue.length > 0) {
|
|
11
|
+
// append all files
|
|
12
|
+
for (const file of inputValue) {
|
|
13
|
+
formData.append(key, file);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// else if inputValue is Object upload it as blob
|
|
17
|
+
else if (inputValue instanceof Object) {
|
|
18
|
+
formData.append(
|
|
19
|
+
key,
|
|
20
|
+
new Blob([JSON.stringify(inputValue)], {
|
|
21
|
+
type: 'application/json',
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
formData.append(key, inputValue);
|
|
8
27
|
});
|
|
9
28
|
|
|
10
29
|
return formData;
|