@dereekb/util 13.6.1 → 13.6.3
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/fetch/index.cjs.js +131 -20
- package/fetch/index.esm.js +131 -21
- package/fetch/package.json +2 -2
- package/fetch/src/lib/fetch.url.d.ts +29 -0
- package/package.json +1 -1
- package/test/package.json +2 -2
package/fetch/index.cjs.js
CHANGED
|
@@ -281,12 +281,12 @@ var FetchTimeoutError = /*#__PURE__*/ function(BaseError) {
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
-
function _array_like_to_array$
|
|
284
|
+
function _array_like_to_array$3(arr, len) {
|
|
285
285
|
if (len == null || len > arr.length) len = arr.length;
|
|
286
286
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
287
287
|
return arr2;
|
|
288
288
|
}
|
|
289
|
-
function _array_with_holes$
|
|
289
|
+
function _array_with_holes$3(arr) {
|
|
290
290
|
if (Array.isArray(arr)) return arr;
|
|
291
291
|
}
|
|
292
292
|
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -338,7 +338,7 @@ function _instanceof$1(left, right) {
|
|
|
338
338
|
return left instanceof right;
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
|
-
function _iterable_to_array_limit$
|
|
341
|
+
function _iterable_to_array_limit$3(arr, i) {
|
|
342
342
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
343
343
|
if (_i == null) return;
|
|
344
344
|
var _arr = [];
|
|
@@ -362,7 +362,7 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
362
362
|
}
|
|
363
363
|
return _arr;
|
|
364
364
|
}
|
|
365
|
-
function _non_iterable_rest$
|
|
365
|
+
function _non_iterable_rest$3() {
|
|
366
366
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
367
367
|
}
|
|
368
368
|
function _object_spread$3(target) {
|
|
@@ -399,20 +399,20 @@ function _object_spread_props$2(target, source) {
|
|
|
399
399
|
}
|
|
400
400
|
return target;
|
|
401
401
|
}
|
|
402
|
-
function _sliced_to_array$
|
|
403
|
-
return _array_with_holes$
|
|
402
|
+
function _sliced_to_array$3(arr, i) {
|
|
403
|
+
return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
|
|
404
404
|
}
|
|
405
405
|
function _type_of$3(obj) {
|
|
406
406
|
"@swc/helpers - typeof";
|
|
407
407
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
408
408
|
}
|
|
409
|
-
function _unsupported_iterable_to_array$
|
|
409
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
410
410
|
if (!o) return;
|
|
411
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
411
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
412
412
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
413
413
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
414
414
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
415
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
415
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
416
416
|
}
|
|
417
417
|
function _ts_generator$4(thisArg, body) {
|
|
418
418
|
var f, y, t, _ = {
|
|
@@ -877,7 +877,7 @@ function _ts_generator$4(thisArg, body) {
|
|
|
877
877
|
var tuples = headersToHeadersTuple(headers);
|
|
878
878
|
var visitedKeysSet = new Set();
|
|
879
879
|
tuples.forEach(function(param) {
|
|
880
|
-
var _param = _sliced_to_array$
|
|
880
|
+
var _param = _sliced_to_array$3(param, 2), key = _param[0], value = _param[1];
|
|
881
881
|
if (!visitedKeysSet.has(key)) {
|
|
882
882
|
headersMap.delete(key); // delete all existing values to "override" them
|
|
883
883
|
visitedKeysSet.add(key);
|
|
@@ -1733,12 +1733,12 @@ var FetchPageLimitReachedError = /*#__PURE__*/ function(FetchRequestFactoryError
|
|
|
1733
1733
|
};
|
|
1734
1734
|
}
|
|
1735
1735
|
|
|
1736
|
-
function _array_like_to_array$
|
|
1736
|
+
function _array_like_to_array$2(arr, len) {
|
|
1737
1737
|
if (len == null || len > arr.length) len = arr.length;
|
|
1738
1738
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1739
1739
|
return arr2;
|
|
1740
1740
|
}
|
|
1741
|
-
function _array_with_holes$
|
|
1741
|
+
function _array_with_holes$2(arr) {
|
|
1742
1742
|
if (Array.isArray(arr)) return arr;
|
|
1743
1743
|
}
|
|
1744
1744
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1783,7 +1783,7 @@ function _define_property$1(obj, key, value) {
|
|
|
1783
1783
|
}
|
|
1784
1784
|
return obj;
|
|
1785
1785
|
}
|
|
1786
|
-
function _iterable_to_array_limit$
|
|
1786
|
+
function _iterable_to_array_limit$2(arr, i) {
|
|
1787
1787
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1788
1788
|
if (_i == null) return;
|
|
1789
1789
|
var _arr = [];
|
|
@@ -1807,7 +1807,7 @@ function _iterable_to_array_limit$1(arr, i) {
|
|
|
1807
1807
|
}
|
|
1808
1808
|
return _arr;
|
|
1809
1809
|
}
|
|
1810
|
-
function _non_iterable_rest$
|
|
1810
|
+
function _non_iterable_rest$2() {
|
|
1811
1811
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1812
1812
|
}
|
|
1813
1813
|
function _object_spread$1(target) {
|
|
@@ -1844,16 +1844,16 @@ function _object_spread_props$1(target, source) {
|
|
|
1844
1844
|
}
|
|
1845
1845
|
return target;
|
|
1846
1846
|
}
|
|
1847
|
-
function _sliced_to_array$
|
|
1848
|
-
return _array_with_holes$
|
|
1847
|
+
function _sliced_to_array$2(arr, i) {
|
|
1848
|
+
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
1849
1849
|
}
|
|
1850
|
-
function _unsupported_iterable_to_array$
|
|
1850
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
1851
1851
|
if (!o) return;
|
|
1852
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
1852
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
1853
1853
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1854
1854
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1855
1855
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1856
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
1856
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
1857
1857
|
}
|
|
1858
1858
|
function _ts_generator(thisArg, body) {
|
|
1859
1859
|
var f, y, t, _ = {
|
|
@@ -2000,7 +2000,7 @@ function _ts_generator(thisArg, body) {
|
|
|
2000
2000
|
return [
|
|
2001
2001
|
2,
|
|
2002
2002
|
util.performAsyncTasks(itemIndexPairs, function(param) {
|
|
2003
|
-
var _param = _sliced_to_array$
|
|
2003
|
+
var _param = _sliced_to_array$2(param, 2), item = _param[0], i = _param[1];
|
|
2004
2004
|
return iterateEachPageItem(item, i, fetchPageResult);
|
|
2005
2005
|
}, _object_spread$1({
|
|
2006
2006
|
sequential: true
|
|
@@ -2212,6 +2212,52 @@ function iterateFetchPages(config) {
|
|
|
2212
2212
|
})();
|
|
2213
2213
|
}
|
|
2214
2214
|
|
|
2215
|
+
function _array_like_to_array$1(arr, len) {
|
|
2216
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2217
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2218
|
+
return arr2;
|
|
2219
|
+
}
|
|
2220
|
+
function _array_with_holes$1(arr) {
|
|
2221
|
+
if (Array.isArray(arr)) return arr;
|
|
2222
|
+
}
|
|
2223
|
+
function _iterable_to_array_limit$1(arr, i) {
|
|
2224
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2225
|
+
if (_i == null) return;
|
|
2226
|
+
var _arr = [];
|
|
2227
|
+
var _n = true;
|
|
2228
|
+
var _d = false;
|
|
2229
|
+
var _s, _e;
|
|
2230
|
+
try {
|
|
2231
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2232
|
+
_arr.push(_s.value);
|
|
2233
|
+
if (i && _arr.length === i) break;
|
|
2234
|
+
}
|
|
2235
|
+
} catch (err) {
|
|
2236
|
+
_d = true;
|
|
2237
|
+
_e = err;
|
|
2238
|
+
} finally{
|
|
2239
|
+
try {
|
|
2240
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2241
|
+
} finally{
|
|
2242
|
+
if (_d) throw _e;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
return _arr;
|
|
2246
|
+
}
|
|
2247
|
+
function _non_iterable_rest$1() {
|
|
2248
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2249
|
+
}
|
|
2250
|
+
function _sliced_to_array$1(arr, i) {
|
|
2251
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
2252
|
+
}
|
|
2253
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
2254
|
+
if (!o) return;
|
|
2255
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
2256
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2257
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2258
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2259
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
2260
|
+
}
|
|
2215
2261
|
/**
|
|
2216
2262
|
* Creates URLSearchParams from the input objects. The input objects are merged together.
|
|
2217
2263
|
*
|
|
@@ -2246,6 +2292,70 @@ function iterateFetchPages(config) {
|
|
|
2246
2292
|
var str = params.toString();
|
|
2247
2293
|
return (options === null || options === void 0 ? void 0 : options.useUrlSearchSpaceHandling) ? str.replace(/\+/g, '%20') : str;
|
|
2248
2294
|
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Updates or adds query parameters on an existing URL string.
|
|
2297
|
+
*
|
|
2298
|
+
* Parses the URL's existing query string, merges in the new parameters (new values
|
|
2299
|
+
* override existing keys), and returns the rebuilt URL. Respects all
|
|
2300
|
+
* {@link MakeUrlSearchParamsOptions} such as `omitKeys`, `filterEmptyValues`, and
|
|
2301
|
+
* `useUrlSearchSpaceHandling`.
|
|
2302
|
+
*
|
|
2303
|
+
* @example
|
|
2304
|
+
* ```typescript
|
|
2305
|
+
* // Add params to a URL with no query string
|
|
2306
|
+
* updateUrlSearchParams('https://example.com/form', { name: 'Alice', age: 30 });
|
|
2307
|
+
* // => 'https://example.com/form?name=Alice&age=30'
|
|
2308
|
+
*
|
|
2309
|
+
* // Override an existing param
|
|
2310
|
+
* updateUrlSearchParams('https://example.com?page=1&sort=asc', { page: 2 });
|
|
2311
|
+
* // => 'https://example.com?page=2&sort=asc'
|
|
2312
|
+
*
|
|
2313
|
+
* // Use percent-encoded spaces for redirect URLs
|
|
2314
|
+
* updateUrlSearchParams('https://example.com', { scope: 'openid profile' }, { useUrlSearchSpaceHandling: true });
|
|
2315
|
+
* // => 'https://example.com?scope=openid%20profile'
|
|
2316
|
+
* ```
|
|
2317
|
+
*
|
|
2318
|
+
* @param url - the URL string to update
|
|
2319
|
+
* @param params - new search parameters to merge into the URL
|
|
2320
|
+
* @param options - optional configuration for filtering, omitting keys, and space encoding
|
|
2321
|
+
* @returns the URL string with updated query parameters
|
|
2322
|
+
*/ function updateUrlSearchParams(url, params, options) {
|
|
2323
|
+
var _url_split = _sliced_to_array$1(url.split('?', 2), 2), basePath = _url_split[0], existingQuery = _url_split[1];
|
|
2324
|
+
var existingParams = existingQuery ? new URLSearchParams(existingQuery) : new URLSearchParams();
|
|
2325
|
+
var newParams = makeUrlSearchParams(params, options);
|
|
2326
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2327
|
+
try {
|
|
2328
|
+
// Merge: new params override existing
|
|
2329
|
+
for(var _iterator = newParams.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2330
|
+
var _step_value = _sliced_to_array$1(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
2331
|
+
existingParams.set(key, value);
|
|
2332
|
+
}
|
|
2333
|
+
} catch (err) {
|
|
2334
|
+
_didIteratorError = true;
|
|
2335
|
+
_iteratorError = err;
|
|
2336
|
+
} finally{
|
|
2337
|
+
try {
|
|
2338
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2339
|
+
_iterator.return();
|
|
2340
|
+
}
|
|
2341
|
+
} finally{
|
|
2342
|
+
if (_didIteratorError) {
|
|
2343
|
+
throw _iteratorError;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
// Apply omitKeys to the merged result
|
|
2348
|
+
if ((options === null || options === void 0 ? void 0 : options.omitKeys) != null) {
|
|
2349
|
+
util.useIterableOrValue(options.omitKeys, function(key) {
|
|
2350
|
+
return existingParams.delete(key);
|
|
2351
|
+
}, false);
|
|
2352
|
+
}
|
|
2353
|
+
var queryString = existingParams.toString();
|
|
2354
|
+
if (options === null || options === void 0 ? void 0 : options.useUrlSearchSpaceHandling) {
|
|
2355
|
+
queryString = queryString.replace(/\+/g, '%20');
|
|
2356
|
+
}
|
|
2357
|
+
return queryString ? "".concat(basePath, "?").concat(queryString) : basePath;
|
|
2358
|
+
}
|
|
2249
2359
|
/**
|
|
2250
2360
|
* Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
|
|
2251
2361
|
*
|
|
@@ -2735,3 +2845,4 @@ exports.rateLimitedFetchHandler = rateLimitedFetchHandler;
|
|
|
2735
2845
|
exports.requireOkResponse = requireOkResponse;
|
|
2736
2846
|
exports.returnNullHandleFetchJsonParseErrorFunction = returnNullHandleFetchJsonParseErrorFunction;
|
|
2737
2847
|
exports.throwJsonResponseParseErrorFunction = throwJsonResponseParseErrorFunction;
|
|
2848
|
+
exports.updateUrlSearchParams = updateUrlSearchParams;
|
package/fetch/index.esm.js
CHANGED
|
@@ -279,12 +279,12 @@ var FetchTimeoutError = /*#__PURE__*/ function(BaseError) {
|
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
function _array_like_to_array$
|
|
282
|
+
function _array_like_to_array$3(arr, len) {
|
|
283
283
|
if (len == null || len > arr.length) len = arr.length;
|
|
284
284
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
285
285
|
return arr2;
|
|
286
286
|
}
|
|
287
|
-
function _array_with_holes$
|
|
287
|
+
function _array_with_holes$3(arr) {
|
|
288
288
|
if (Array.isArray(arr)) return arr;
|
|
289
289
|
}
|
|
290
290
|
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -336,7 +336,7 @@ function _instanceof$1(left, right) {
|
|
|
336
336
|
return left instanceof right;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
function _iterable_to_array_limit$
|
|
339
|
+
function _iterable_to_array_limit$3(arr, i) {
|
|
340
340
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
341
341
|
if (_i == null) return;
|
|
342
342
|
var _arr = [];
|
|
@@ -360,7 +360,7 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
360
360
|
}
|
|
361
361
|
return _arr;
|
|
362
362
|
}
|
|
363
|
-
function _non_iterable_rest$
|
|
363
|
+
function _non_iterable_rest$3() {
|
|
364
364
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
365
365
|
}
|
|
366
366
|
function _object_spread$3(target) {
|
|
@@ -397,20 +397,20 @@ function _object_spread_props$2(target, source) {
|
|
|
397
397
|
}
|
|
398
398
|
return target;
|
|
399
399
|
}
|
|
400
|
-
function _sliced_to_array$
|
|
401
|
-
return _array_with_holes$
|
|
400
|
+
function _sliced_to_array$3(arr, i) {
|
|
401
|
+
return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
|
|
402
402
|
}
|
|
403
403
|
function _type_of$3(obj) {
|
|
404
404
|
"@swc/helpers - typeof";
|
|
405
405
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
406
406
|
}
|
|
407
|
-
function _unsupported_iterable_to_array$
|
|
407
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
408
408
|
if (!o) return;
|
|
409
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
409
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
410
410
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
411
411
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
412
412
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
413
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
413
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
414
414
|
}
|
|
415
415
|
function _ts_generator$4(thisArg, body) {
|
|
416
416
|
var f, y, t, _ = {
|
|
@@ -875,7 +875,7 @@ function _ts_generator$4(thisArg, body) {
|
|
|
875
875
|
var tuples = headersToHeadersTuple(headers);
|
|
876
876
|
var visitedKeysSet = new Set();
|
|
877
877
|
tuples.forEach(function(param) {
|
|
878
|
-
var _param = _sliced_to_array$
|
|
878
|
+
var _param = _sliced_to_array$3(param, 2), key = _param[0], value = _param[1];
|
|
879
879
|
if (!visitedKeysSet.has(key)) {
|
|
880
880
|
headersMap.delete(key); // delete all existing values to "override" them
|
|
881
881
|
visitedKeysSet.add(key);
|
|
@@ -1731,12 +1731,12 @@ var FetchPageLimitReachedError = /*#__PURE__*/ function(FetchRequestFactoryError
|
|
|
1731
1731
|
};
|
|
1732
1732
|
}
|
|
1733
1733
|
|
|
1734
|
-
function _array_like_to_array$
|
|
1734
|
+
function _array_like_to_array$2(arr, len) {
|
|
1735
1735
|
if (len == null || len > arr.length) len = arr.length;
|
|
1736
1736
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1737
1737
|
return arr2;
|
|
1738
1738
|
}
|
|
1739
|
-
function _array_with_holes$
|
|
1739
|
+
function _array_with_holes$2(arr) {
|
|
1740
1740
|
if (Array.isArray(arr)) return arr;
|
|
1741
1741
|
}
|
|
1742
1742
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1781,7 +1781,7 @@ function _define_property$1(obj, key, value) {
|
|
|
1781
1781
|
}
|
|
1782
1782
|
return obj;
|
|
1783
1783
|
}
|
|
1784
|
-
function _iterable_to_array_limit$
|
|
1784
|
+
function _iterable_to_array_limit$2(arr, i) {
|
|
1785
1785
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1786
1786
|
if (_i == null) return;
|
|
1787
1787
|
var _arr = [];
|
|
@@ -1805,7 +1805,7 @@ function _iterable_to_array_limit$1(arr, i) {
|
|
|
1805
1805
|
}
|
|
1806
1806
|
return _arr;
|
|
1807
1807
|
}
|
|
1808
|
-
function _non_iterable_rest$
|
|
1808
|
+
function _non_iterable_rest$2() {
|
|
1809
1809
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1810
1810
|
}
|
|
1811
1811
|
function _object_spread$1(target) {
|
|
@@ -1842,16 +1842,16 @@ function _object_spread_props$1(target, source) {
|
|
|
1842
1842
|
}
|
|
1843
1843
|
return target;
|
|
1844
1844
|
}
|
|
1845
|
-
function _sliced_to_array$
|
|
1846
|
-
return _array_with_holes$
|
|
1845
|
+
function _sliced_to_array$2(arr, i) {
|
|
1846
|
+
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
1847
1847
|
}
|
|
1848
|
-
function _unsupported_iterable_to_array$
|
|
1848
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
1849
1849
|
if (!o) return;
|
|
1850
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
1850
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
1851
1851
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1852
1852
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1853
1853
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1854
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
1854
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
1855
1855
|
}
|
|
1856
1856
|
function _ts_generator(thisArg, body) {
|
|
1857
1857
|
var f, y, t, _ = {
|
|
@@ -1998,7 +1998,7 @@ function _ts_generator(thisArg, body) {
|
|
|
1998
1998
|
return [
|
|
1999
1999
|
2,
|
|
2000
2000
|
performAsyncTasks(itemIndexPairs, function(param) {
|
|
2001
|
-
var _param = _sliced_to_array$
|
|
2001
|
+
var _param = _sliced_to_array$2(param, 2), item = _param[0], i = _param[1];
|
|
2002
2002
|
return iterateEachPageItem(item, i, fetchPageResult);
|
|
2003
2003
|
}, _object_spread$1({
|
|
2004
2004
|
sequential: true
|
|
@@ -2210,6 +2210,52 @@ function iterateFetchPages(config) {
|
|
|
2210
2210
|
})();
|
|
2211
2211
|
}
|
|
2212
2212
|
|
|
2213
|
+
function _array_like_to_array$1(arr, len) {
|
|
2214
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2215
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2216
|
+
return arr2;
|
|
2217
|
+
}
|
|
2218
|
+
function _array_with_holes$1(arr) {
|
|
2219
|
+
if (Array.isArray(arr)) return arr;
|
|
2220
|
+
}
|
|
2221
|
+
function _iterable_to_array_limit$1(arr, i) {
|
|
2222
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2223
|
+
if (_i == null) return;
|
|
2224
|
+
var _arr = [];
|
|
2225
|
+
var _n = true;
|
|
2226
|
+
var _d = false;
|
|
2227
|
+
var _s, _e;
|
|
2228
|
+
try {
|
|
2229
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2230
|
+
_arr.push(_s.value);
|
|
2231
|
+
if (i && _arr.length === i) break;
|
|
2232
|
+
}
|
|
2233
|
+
} catch (err) {
|
|
2234
|
+
_d = true;
|
|
2235
|
+
_e = err;
|
|
2236
|
+
} finally{
|
|
2237
|
+
try {
|
|
2238
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2239
|
+
} finally{
|
|
2240
|
+
if (_d) throw _e;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
return _arr;
|
|
2244
|
+
}
|
|
2245
|
+
function _non_iterable_rest$1() {
|
|
2246
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2247
|
+
}
|
|
2248
|
+
function _sliced_to_array$1(arr, i) {
|
|
2249
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
2250
|
+
}
|
|
2251
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
2252
|
+
if (!o) return;
|
|
2253
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
2254
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2255
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2256
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2257
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
2258
|
+
}
|
|
2213
2259
|
/**
|
|
2214
2260
|
* Creates URLSearchParams from the input objects. The input objects are merged together.
|
|
2215
2261
|
*
|
|
@@ -2244,6 +2290,70 @@ function iterateFetchPages(config) {
|
|
|
2244
2290
|
var str = params.toString();
|
|
2245
2291
|
return (options === null || options === void 0 ? void 0 : options.useUrlSearchSpaceHandling) ? str.replace(/\+/g, '%20') : str;
|
|
2246
2292
|
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Updates or adds query parameters on an existing URL string.
|
|
2295
|
+
*
|
|
2296
|
+
* Parses the URL's existing query string, merges in the new parameters (new values
|
|
2297
|
+
* override existing keys), and returns the rebuilt URL. Respects all
|
|
2298
|
+
* {@link MakeUrlSearchParamsOptions} such as `omitKeys`, `filterEmptyValues`, and
|
|
2299
|
+
* `useUrlSearchSpaceHandling`.
|
|
2300
|
+
*
|
|
2301
|
+
* @example
|
|
2302
|
+
* ```typescript
|
|
2303
|
+
* // Add params to a URL with no query string
|
|
2304
|
+
* updateUrlSearchParams('https://example.com/form', { name: 'Alice', age: 30 });
|
|
2305
|
+
* // => 'https://example.com/form?name=Alice&age=30'
|
|
2306
|
+
*
|
|
2307
|
+
* // Override an existing param
|
|
2308
|
+
* updateUrlSearchParams('https://example.com?page=1&sort=asc', { page: 2 });
|
|
2309
|
+
* // => 'https://example.com?page=2&sort=asc'
|
|
2310
|
+
*
|
|
2311
|
+
* // Use percent-encoded spaces for redirect URLs
|
|
2312
|
+
* updateUrlSearchParams('https://example.com', { scope: 'openid profile' }, { useUrlSearchSpaceHandling: true });
|
|
2313
|
+
* // => 'https://example.com?scope=openid%20profile'
|
|
2314
|
+
* ```
|
|
2315
|
+
*
|
|
2316
|
+
* @param url - the URL string to update
|
|
2317
|
+
* @param params - new search parameters to merge into the URL
|
|
2318
|
+
* @param options - optional configuration for filtering, omitting keys, and space encoding
|
|
2319
|
+
* @returns the URL string with updated query parameters
|
|
2320
|
+
*/ function updateUrlSearchParams(url, params, options) {
|
|
2321
|
+
var _url_split = _sliced_to_array$1(url.split('?', 2), 2), basePath = _url_split[0], existingQuery = _url_split[1];
|
|
2322
|
+
var existingParams = existingQuery ? new URLSearchParams(existingQuery) : new URLSearchParams();
|
|
2323
|
+
var newParams = makeUrlSearchParams(params, options);
|
|
2324
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2325
|
+
try {
|
|
2326
|
+
// Merge: new params override existing
|
|
2327
|
+
for(var _iterator = newParams.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2328
|
+
var _step_value = _sliced_to_array$1(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
2329
|
+
existingParams.set(key, value);
|
|
2330
|
+
}
|
|
2331
|
+
} catch (err) {
|
|
2332
|
+
_didIteratorError = true;
|
|
2333
|
+
_iteratorError = err;
|
|
2334
|
+
} finally{
|
|
2335
|
+
try {
|
|
2336
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2337
|
+
_iterator.return();
|
|
2338
|
+
}
|
|
2339
|
+
} finally{
|
|
2340
|
+
if (_didIteratorError) {
|
|
2341
|
+
throw _iteratorError;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
// Apply omitKeys to the merged result
|
|
2346
|
+
if ((options === null || options === void 0 ? void 0 : options.omitKeys) != null) {
|
|
2347
|
+
useIterableOrValue(options.omitKeys, function(key) {
|
|
2348
|
+
return existingParams.delete(key);
|
|
2349
|
+
}, false);
|
|
2350
|
+
}
|
|
2351
|
+
var queryString = existingParams.toString();
|
|
2352
|
+
if (options === null || options === void 0 ? void 0 : options.useUrlSearchSpaceHandling) {
|
|
2353
|
+
queryString = queryString.replace(/\+/g, '%20');
|
|
2354
|
+
}
|
|
2355
|
+
return queryString ? "".concat(basePath, "?").concat(queryString) : basePath;
|
|
2356
|
+
}
|
|
2247
2357
|
/**
|
|
2248
2358
|
* Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
|
|
2249
2359
|
*
|
|
@@ -2689,4 +2799,4 @@ var fetchJsonRequestInit = fetchJsonRequestInitFunction();
|
|
|
2689
2799
|
}
|
|
2690
2800
|
});
|
|
2691
2801
|
|
|
2692
|
-
export { DEFAULT_FETCH_HANDLER, DEFAULT_FETCH_REQUEST_FACTORY, FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchApiFetchService, fetchFileFromUrl, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, fetchUploadFile, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeFileForFetch, makeUrlSearchParams, makeUrlSearchParamsString, mergeMakeUrlSearchParamsOptions, mergeRequestHeaders, mergeRequestInits, parseFetchFileResponse, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
|
|
2802
|
+
export { DEFAULT_FETCH_HANDLER, DEFAULT_FETCH_REQUEST_FACTORY, FETCH_PAGE_FACTORY_DEFAULT_MAX_PAGE, FetchPageLimitReachedError, FetchPageNoNextPageError, FetchRequestFactoryError, FetchResponseError, FetchTimeoutError, JsonResponseParseError, configureFetch, fetchApiFetchService, fetchFileFromUrl, fetchJsonBodyString, fetchJsonFunction, fetchJsonRequestInit, fetchJsonRequestInitFunction, fetchOk, fetchPageFactory, fetchRequestFactory, fetchService, fetchTimeout, fetchURL, fetchURLQueryKeyValueStringTuples, fetchURLSearchParamsObjectToURLSearchParams, fetchUploadFile, headersToHeadersTuple, isFetchRequest, isURL, isURLSearchParams, iterateFetchPages, iterateFetchPagesByEachItem, iterateFetchPagesByItems, makeFileForFetch, makeUrlSearchParams, makeUrlSearchParamsString, mergeMakeUrlSearchParamsOptions, mergeRequestHeaders, mergeRequestInits, parseFetchFileResponse, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction, updateUrlSearchParams };
|
package/fetch/package.json
CHANGED
|
@@ -52,6 +52,35 @@ export declare function makeUrlSearchParams(input: Maybe<ArrayOrValue<Maybe<obje
|
|
|
52
52
|
* @returns the encoded query string (without a leading `?`)
|
|
53
53
|
*/
|
|
54
54
|
export declare function makeUrlSearchParamsString(input: Maybe<ArrayOrValue<Maybe<object | Record<string, string | number>>>>, options?: Maybe<MakeUrlSearchParamsOptions>): string;
|
|
55
|
+
/**
|
|
56
|
+
* Updates or adds query parameters on an existing URL string.
|
|
57
|
+
*
|
|
58
|
+
* Parses the URL's existing query string, merges in the new parameters (new values
|
|
59
|
+
* override existing keys), and returns the rebuilt URL. Respects all
|
|
60
|
+
* {@link MakeUrlSearchParamsOptions} such as `omitKeys`, `filterEmptyValues`, and
|
|
61
|
+
* `useUrlSearchSpaceHandling`.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Add params to a URL with no query string
|
|
66
|
+
* updateUrlSearchParams('https://example.com/form', { name: 'Alice', age: 30 });
|
|
67
|
+
* // => 'https://example.com/form?name=Alice&age=30'
|
|
68
|
+
*
|
|
69
|
+
* // Override an existing param
|
|
70
|
+
* updateUrlSearchParams('https://example.com?page=1&sort=asc', { page: 2 });
|
|
71
|
+
* // => 'https://example.com?page=2&sort=asc'
|
|
72
|
+
*
|
|
73
|
+
* // Use percent-encoded spaces for redirect URLs
|
|
74
|
+
* updateUrlSearchParams('https://example.com', { scope: 'openid profile' }, { useUrlSearchSpaceHandling: true });
|
|
75
|
+
* // => 'https://example.com?scope=openid%20profile'
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @param url - the URL string to update
|
|
79
|
+
* @param params - new search parameters to merge into the URL
|
|
80
|
+
* @param options - optional configuration for filtering, omitting keys, and space encoding
|
|
81
|
+
* @returns the URL string with updated query parameters
|
|
82
|
+
*/
|
|
83
|
+
export declare function updateUrlSearchParams(url: string, params: Maybe<ArrayOrValue<Maybe<object | Record<string, string | number>>>>, options?: Maybe<MakeUrlSearchParamsOptions>): string;
|
|
55
84
|
/**
|
|
56
85
|
* Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
|
|
57
86
|
*
|
package/package.json
CHANGED