@dereekb/util 13.4.0 → 13.4.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/fetch/index.cjs.js +191 -109
  2. package/fetch/index.esm.js +191 -109
  3. package/fetch/package.json +2 -2
  4. package/fetch/src/lib/error.d.ts +6 -0
  5. package/fetch/src/lib/fetch.d.ts +37 -0
  6. package/fetch/src/lib/fetch.file.d.ts +7 -5
  7. package/fetch/src/lib/fetch.limit.d.ts +7 -0
  8. package/fetch/src/lib/fetch.url.d.ts +6 -3
  9. package/fetch/src/lib/json.d.ts +12 -1
  10. package/fetch/src/lib/timeout.d.ts +8 -0
  11. package/fetch/src/lib/url.d.ts +33 -0
  12. package/index.cjs.js +1419 -778
  13. package/index.esm.js +1419 -779
  14. package/package.json +1 -1
  15. package/src/lib/array/array.boolean.d.ts +7 -0
  16. package/src/lib/array/array.filter.d.ts +4 -4
  17. package/src/lib/array/array.index.d.ts +3 -1
  18. package/src/lib/array/array.indexed.d.ts +9 -3
  19. package/src/lib/array/array.limit.d.ts +2 -0
  20. package/src/lib/assertion/assert.d.ts +3 -0
  21. package/src/lib/assertion/assert.error.d.ts +6 -0
  22. package/src/lib/boolean.d.ts +3 -0
  23. package/src/lib/date/expires.d.ts +3 -3
  24. package/src/lib/date/minute.d.ts +14 -8
  25. package/src/lib/date/time.d.ts +3 -0
  26. package/src/lib/error/error.server.d.ts +1 -0
  27. package/src/lib/file/pdf.d.ts +1 -1
  28. package/src/lib/getter/getter.cache.d.ts +1 -1
  29. package/src/lib/grouping.d.ts +11 -2
  30. package/src/lib/map/map.key.d.ts +1 -1
  31. package/src/lib/model/model.d.ts +14 -9
  32. package/src/lib/number/dollar.d.ts +8 -0
  33. package/src/lib/number/number.d.ts +4 -0
  34. package/src/lib/object/object.d.ts +3 -0
  35. package/src/lib/object/object.equal.d.ts +2 -2
  36. package/src/lib/object/object.filter.pojo.d.ts +7 -0
  37. package/src/lib/object/object.filter.tuple.d.ts +2 -0
  38. package/src/lib/object/object.map.d.ts +1 -1
  39. package/src/lib/path/path.d.ts +4 -2
  40. package/src/lib/promise/poll.d.ts +3 -0
  41. package/src/lib/promise/promise.d.ts +19 -7
  42. package/src/lib/promise/promise.loop.d.ts +27 -9
  43. package/src/lib/relation/relation.d.ts +12 -0
  44. package/src/lib/service/handler.config.d.ts +3 -1
  45. package/src/lib/service/handler.d.ts +6 -2
  46. package/src/lib/service/typed.service.d.ts +3 -1
  47. package/src/lib/set/set.d.ts +32 -19
  48. package/src/lib/set/set.hashset.d.ts +3 -1
  49. package/src/lib/sort.d.ts +11 -0
  50. package/src/lib/storage/storage.error.d.ts +3 -0
  51. package/src/lib/storage/storage.memory.d.ts +7 -0
  52. package/src/lib/storage/storage.object.d.ts +5 -0
  53. package/src/lib/string/dencoder.d.ts +4 -1
  54. package/src/lib/string/mimetype.d.ts +57 -19
  55. package/src/lib/string/transform.d.ts +10 -1
  56. package/src/lib/string/tree.d.ts +18 -6
  57. package/src/lib/string/url.d.ts +57 -19
  58. package/src/lib/tree/tree.d.ts +12 -4
  59. package/src/lib/tree/tree.flatten.d.ts +3 -1
  60. package/src/lib/value/address.d.ts +24 -7
  61. package/src/lib/value/bound.d.ts +3 -0
  62. package/src/lib/value/build.d.ts +3 -0
  63. package/src/lib/value/comparator.d.ts +4 -0
  64. package/src/lib/value/cron.d.ts +1 -0
  65. package/src/lib/value/decision.d.ts +3 -0
  66. package/src/lib/value/equal.d.ts +3 -0
  67. package/src/lib/value/indexed.d.ts +4 -0
  68. package/src/lib/value/label.d.ts +1 -0
  69. package/src/lib/value/map.d.ts +9 -0
  70. package/src/lib/value/maybe.d.ts +13 -0
  71. package/src/lib/value/modifier.d.ts +9 -0
  72. package/src/lib/value/point.d.ts +3 -0
  73. package/src/lib/value/url.d.ts +1 -0
  74. package/src/lib/value/vector.d.ts +5 -0
  75. package/test/index.cjs.js +29 -6
  76. package/test/index.esm.js +29 -6
  77. package/test/package.json +2 -2
  78. package/test/src/lib/jest/jest.fail.d.ts +3 -3
  79. package/test/src/lib/shared/shared.d.ts +7 -1
  80. package/test/src/lib/shared/shared.fail.d.ts +8 -2
  81. package/test/src/lib/shared/shared.wrap.d.ts +1 -0
@@ -81,9 +81,8 @@ function _is_native_reflect_construct$3() {
81
81
  function FetchRequestFactoryError(error) {
82
82
  _class_call_check$3(this, FetchRequestFactoryError);
83
83
  var _this;
84
- var _error_message;
85
84
  _this = _call_super$3(this, FetchRequestFactoryError, [
86
- "Fetch request failed to build due to an unexpected error: ".concat((typeof error === "undefined" ? "undefined" : _type_of$5(error)) === 'object' ? (_error_message = error.message) !== null && _error_message !== void 0 ? _error_message : '' : error)
85
+ "Fetch request failed to build due to an unexpected error: ".concat((typeof error === "undefined" ? "undefined" : _type_of$5(error)) === 'object' ? error.message : error)
87
86
  ]), _define_property$5(_this, "error", void 0);
88
87
  _this.error = error;
89
88
  return _this;
@@ -113,7 +112,12 @@ var FetchResponseError = /*#__PURE__*/ function(BaseError) {
113
112
  }
114
113
  return FetchResponseError;
115
114
  }(BaseError);
116
- function requireOkResponse(responsePromise) {
115
+ /**
116
+ * Asserts that the fetch response has an ok status code, throwing a FetchResponseError if it does not.
117
+ *
118
+ * @param responsePromise - promise resolving to the fetch Response to validate
119
+ * @returns a promise resolving to the Response if the status is ok
120
+ */ function requireOkResponse(responsePromise) {
117
121
  return responsePromise.then(function(response) {
118
122
  if (!response.ok) {
119
123
  throw new FetchResponseError(response);
@@ -242,7 +246,14 @@ var FetchTimeoutError = /*#__PURE__*/ function(BaseError) {
242
246
  }
243
247
  return FetchTimeoutError;
244
248
  }(BaseError);
245
- function fetchTimeout(inputFetch) {
249
+ /**
250
+ * Wraps a fetch function to add automatic timeout/abort support. If a timeout value
251
+ * is present on the RequestInit or Request and no abort signal is already provided,
252
+ * an AbortController is created to abort the request after the specified duration.
253
+ *
254
+ * @param inputFetch - the fetch function to wrap with timeout behavior
255
+ * @returns a wrapped fetch function that enforces timeouts via AbortController
256
+ */ function fetchTimeout(inputFetch) {
246
257
  return function(input, init) {
247
258
  var _ref;
248
259
  var controller;
@@ -268,7 +279,7 @@ function fetchTimeout(inputFetch) {
268
279
  };
269
280
  }
270
281
 
271
- function _array_like_to_array$2(arr, len) {
282
+ function _array_like_to_array$3(arr, len) {
272
283
  if (len == null || len > arr.length) len = arr.length;
273
284
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
274
285
  return arr2;
@@ -387,19 +398,19 @@ function _object_spread_props$2(target, source) {
387
398
  return target;
388
399
  }
389
400
  function _sliced_to_array$2(arr, i) {
390
- return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
401
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$2();
391
402
  }
392
403
  function _type_of$3(obj) {
393
404
  "@swc/helpers - typeof";
394
405
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
395
406
  }
396
- function _unsupported_iterable_to_array$2(o, minLen) {
407
+ function _unsupported_iterable_to_array$3(o, minLen) {
397
408
  if (!o) return;
398
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
409
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
399
410
  var n = Object.prototype.toString.call(o).slice(8, -1);
400
411
  if (n === "Object" && o.constructor) n = o.constructor.name;
401
412
  if (n === "Map" || n === "Set") return Array.from(n);
402
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
413
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
403
414
  }
404
415
  function _ts_generator$4(thisArg, body) {
405
416
  var f, y, t, _ = {
@@ -507,7 +518,7 @@ function _ts_generator$4(thisArg, body) {
507
518
  * @returns
508
519
  */ function fetchService(config) {
509
520
  var inputMakeFetch = config.makeFetch, makeRequest = config.makeRequest, baseRequest = config.baseRequest;
510
- var factory = {
521
+ return {
511
522
  fetchRequestFactory: function fetchRequestFactory1(config) {
512
523
  return fetchRequestFactory(_object_spread$3({
513
524
  makeRequest: makeRequest,
@@ -524,10 +535,10 @@ function _ts_generator$4(thisArg, body) {
524
535
  },
525
536
  makeRequest: config.makeRequest
526
537
  };
527
- return factory;
528
538
  }
529
539
  /**
530
540
  * Default FetchHabdler
541
+ *
531
542
  * @param request
532
543
  * @param makeFetch
533
544
  * @returns
@@ -585,7 +596,13 @@ function _ts_generator$4(thisArg, body) {
585
596
  */ var DEFAULT_FETCH_REQUEST_FACTORY = function DEFAULT_FETCH_REQUEST_FACTORY(input, init) {
586
597
  return new Request(input, init);
587
598
  };
588
- function fetchRequestFactory(config) {
599
+ /**
600
+ * Creates a FetchRequestFactory that builds Request objects by applying base URL resolution,
601
+ * base request init merging, timeout configuration, and custom request init transformations.
602
+ *
603
+ * @param config - configuration for URL resolution, base request defaults, timeout, and request init transformations
604
+ * @returns a FetchRequestFactory that produces fully configured Request objects
605
+ */ function fetchRequestFactory(config) {
589
606
  var _config_makeRequest = config.makeRequest, makeRequest = _config_makeRequest === void 0 ? DEFAULT_FETCH_REQUEST_FACTORY : _config_makeRequest, inputBaseUrl = config.baseUrl, inputBaseRequest = config.baseRequest, timeout = config.timeout, requestInitFactory = config.requestInitFactory, _config_useBaseUrlForConfiguredFetchRequests = config.useBaseUrlForConfiguredFetchRequests, useBaseUrlForConfiguredFetchRequests = _config_useBaseUrlForConfiguredFetchRequests === void 0 ? false : _config_useBaseUrlForConfiguredFetchRequests, _config_forceBaseUrlForWebsiteUrlWithPrefix = config.forceBaseUrlForWebsiteUrlWithPrefix, forceBaseUrlForWebsiteUrlWithPrefix = _config_forceBaseUrlForWebsiteUrlWithPrefix === void 0 ? useBaseUrlForConfiguredFetchRequests : _config_forceBaseUrlForWebsiteUrlWithPrefix;
590
607
  var baseUrl = inputBaseUrl ? new URL(removeTrailingSlashes(inputBaseUrl)) : undefined;
591
608
  var buildUrl = baseUrl ? function(url) {
@@ -704,7 +721,7 @@ function fetchRequestFactory(config) {
704
721
  if (inputBaseRequest != null || timeout != null) {
705
722
  var computeBaseRequest = function computeBaseRequest() {
706
723
  return _async_to_generator$4(function() {
707
- var computedBaseRequest, baseRequest;
724
+ var computedBaseRequest;
708
725
  return _ts_generator$4(this, function(_state) {
709
726
  switch(_state.label){
710
727
  case 0:
@@ -714,12 +731,11 @@ function fetchRequestFactory(config) {
714
731
  ];
715
732
  case 1:
716
733
  computedBaseRequest = _state.sent();
717
- baseRequest = timeout ? _object_spread_props$2(_object_spread$3({}, computedBaseRequest), {
718
- timeout: timeout
719
- }) : computedBaseRequest;
720
734
  return [
721
735
  2,
722
- baseRequest
736
+ timeout ? _object_spread_props$2(_object_spread$3({}, computedBaseRequest), {
737
+ timeout: timeout
738
+ }) : computedBaseRequest
723
739
  ];
724
740
  }
725
741
  });
@@ -827,11 +843,18 @@ function fetchRequestFactory(config) {
827
843
  })();
828
844
  };
829
845
  }
830
- function mergeRequestInits(base, requestInit) {
846
+ /**
847
+ * Merges two RequestInit objects, combining their headers and spreading remaining properties
848
+ * so that values from the second init override the base.
849
+ *
850
+ * @param base - the base RequestInit to merge onto
851
+ * @param requestInit - optional RequestInit whose values override the base
852
+ * @returns the merged RequestInit
853
+ */ function mergeRequestInits(base, requestInit) {
831
854
  if (requestInit) {
832
855
  var headers = mergeRequestHeaders([
833
856
  base.headers,
834
- requestInit === null || requestInit === void 0 ? void 0 : requestInit.headers
857
+ requestInit.headers
835
858
  ]);
836
859
  return _object_spread_props$2(_object_spread$3({}, base, requestInit), {
837
860
  headers: headers
@@ -840,7 +863,13 @@ function mergeRequestInits(base, requestInit) {
840
863
  return base;
841
864
  }
842
865
  }
843
- function mergeRequestHeaders(inputHeadersArray) {
866
+ /**
867
+ * Merges an array of HeadersInit values into a single array of key-value tuples.
868
+ * Later headers override earlier ones on a per-key basis while preserving multi-value support.
869
+ *
870
+ * @param inputHeadersArray - array of HeadersInit values to merge, where later entries take precedence
871
+ * @returns an array of [key, value] tuples representing the merged headers
872
+ */ function mergeRequestHeaders(inputHeadersArray) {
844
873
  var headersMap = multiValueMapBuilder();
845
874
  filterMaybeArrayValues(inputHeadersArray).forEach(function(headers) {
846
875
  var tuples = headersToHeadersTuple(headers);
@@ -858,7 +887,13 @@ function mergeRequestHeaders(inputHeadersArray) {
858
887
  });
859
888
  return headersMap.tuples();
860
889
  }
861
- function headersToHeadersTuple(headers) {
890
+ /**
891
+ * Converts a HeadersInit value (tuple array, Headers object, or plain object) into
892
+ * a normalized array of [key, value] tuples.
893
+ *
894
+ * @param headers - the HeadersInit value to convert
895
+ * @returns an array of [key, value] string tuples
896
+ */ function headersToHeadersTuple(headers) {
862
897
  var tuples = [];
863
898
  if (Array.isArray(headers)) {
864
899
  // use as tuples
@@ -877,7 +912,13 @@ function headersToHeadersTuple(headers) {
877
912
  }
878
913
  return tuples;
879
914
  }
880
- function isFetchRequest(input) {
915
+ /**
916
+ * Type guard that checks whether the given input is a fetch Request object
917
+ * by testing for the presence of a url property.
918
+ *
919
+ * @param input - the value to test
920
+ * @returns true if the input is a Request
921
+ */ function isFetchRequest(input) {
881
922
  return Boolean(input.url);
882
923
  }
883
924
 
@@ -1012,8 +1053,8 @@ function _ts_generator$3(thisArg, body) {
1012
1053
  /**
1013
1054
  * Creates a File object from the given input.
1014
1055
  *
1015
- * @example
1016
- * makeFileForFetch({ content: pdfBuffer, fileName: 'doc.pdf', mimeType: 'application/pdf' })
1056
+ * @param input - configuration containing the file content, name, optional MIME type, and last modified timestamp
1057
+ * @returns a File object constructed from the provided input
1017
1058
  */ function makeFileForFetch(input) {
1018
1059
  var options = {};
1019
1060
  if (input.mimeType) {
@@ -1094,7 +1135,11 @@ function fetchFileFromUrl(input, safe) {
1094
1135
  }
1095
1136
  /**
1096
1137
  * @deprecated Use makeFileForFetch() with FormData and context.fetch() instead.
1097
- */ function fetchUploadFile(input) {
1138
+ *
1139
+ * @param input - configuration containing the upload URL, fetch function, HTTP method, and file body
1140
+ * @returns a promise resolving to the fetch Response
1141
+ */ // eslint-disable-next-line @typescript-eslint/no-deprecated
1142
+ function fetchUploadFile(input) {
1098
1143
  var _input_method;
1099
1144
  var inputFetch = input.fetch, url = input.url, inputBody = input.body;
1100
1145
  var useFetch = inputFetch !== null && inputFetch !== void 0 ? inputFetch : fetch;
@@ -1235,7 +1280,13 @@ function _ts_generator$2(thisArg, body) {
1235
1280
  };
1236
1281
  }
1237
1282
  }
1238
- function rateLimitedFetchHandler(config) {
1283
+ /**
1284
+ * Creates a FetchHandler that enforces rate limiting via the provided PromiseRateLimiter and supports
1285
+ * automatic retry when the server signals throttling.
1286
+ *
1287
+ * @param config - configuration containing the rate limiter, retry settings, and response handler
1288
+ * @returns a RateLimitedFetchHandler that rate-limits outgoing requests and retries on throttle responses
1289
+ */ function rateLimitedFetchHandler(config) {
1239
1290
  var updateWithResponse = config.updateWithResponse, inputMaxRetries = config.maxRetries;
1240
1291
  var maxRetries = inputMaxRetries !== null && inputMaxRetries !== void 0 ? inputMaxRetries : 1;
1241
1292
  var _rateLimiter = config.rateLimiter;
@@ -1243,7 +1294,7 @@ function rateLimitedFetchHandler(config) {
1243
1294
  return _async_to_generator$2(function() {
1244
1295
  function tryFetch(retriesAttempted) {
1245
1296
  return _async_to_generator$2(function() {
1246
- var response, fetchResponseError, e, shouldRetry, _tmp;
1297
+ var response, fetchResponseError, e, shouldRetry;
1247
1298
  return _ts_generator$2(this, function(_state) {
1248
1299
  switch(_state.label){
1249
1300
  case 0:
@@ -1281,50 +1332,33 @@ function rateLimitedFetchHandler(config) {
1281
1332
  5
1282
1333
  ];
1283
1334
  case 5:
1284
- if (!response) return [
1285
- 3,
1286
- 7
1287
- ];
1288
1335
  return [
1289
1336
  4,
1290
1337
  updateWithResponse(response, fetchResponseError)
1291
1338
  ];
1292
1339
  case 6:
1293
- _tmp = _state.sent();
1294
- return [
1295
- 3,
1296
- 8
1297
- ];
1298
- case 7:
1299
- _tmp = false;
1300
- _state.label = 8;
1301
- case 8:
1302
- shouldRetry = _tmp;
1340
+ shouldRetry = _state.sent();
1303
1341
  if (!(shouldRetry && retriesAttempted < maxRetries)) return [
1304
1342
  3,
1305
- 10
1343
+ 8
1306
1344
  ];
1307
1345
  return [
1308
1346
  4,
1309
1347
  tryFetch(retriesAttempted + 1)
1310
1348
  ];
1311
- case 9:
1349
+ case 7:
1312
1350
  response = _state.sent();
1313
1351
  return [
1314
1352
  3,
1315
- 11
1353
+ 9
1316
1354
  ];
1317
- case 10:
1355
+ case 8:
1318
1356
  // re-throw the fetch response error if it exists and we cannot retry
1319
1357
  if (fetchResponseError != null) {
1320
1358
  throw fetchResponseError;
1321
1359
  }
1322
- _state.label = 11;
1323
- case 11:
1324
- // if response is null at this point but fetchResponseError is not, rethrow the error
1325
- if (response == null && fetchResponseError != null) {
1326
- throw fetchResponseError;
1327
- }
1360
+ _state.label = 9;
1361
+ case 9:
1328
1362
  return [
1329
1363
  2,
1330
1364
  response
@@ -1697,7 +1731,7 @@ var FetchPageLimitReachedError = /*#__PURE__*/ function(FetchRequestFactoryError
1697
1731
  };
1698
1732
  }
1699
1733
 
1700
- function _array_like_to_array$1(arr, len) {
1734
+ function _array_like_to_array$2(arr, len) {
1701
1735
  if (len == null || len > arr.length) len = arr.length;
1702
1736
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1703
1737
  return arr2;
@@ -1809,15 +1843,15 @@ function _object_spread_props$1(target, source) {
1809
1843
  return target;
1810
1844
  }
1811
1845
  function _sliced_to_array$1(arr, i) {
1812
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
1846
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$1();
1813
1847
  }
1814
- function _unsupported_iterable_to_array$1(o, minLen) {
1848
+ function _unsupported_iterable_to_array$2(o, minLen) {
1815
1849
  if (!o) return;
1816
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
1850
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
1817
1851
  var n = Object.prototype.toString.call(o).slice(8, -1);
1818
1852
  if (n === "Object" && o.constructor) n = o.constructor.name;
1819
1853
  if (n === "Map" || n === "Set") return Array.from(n);
1820
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
1854
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
1821
1855
  }
1822
1856
  function _ts_generator(thisArg, body) {
1823
1857
  var f, y, t, _ = {
@@ -1953,32 +1987,23 @@ function _ts_generator(thisArg, body) {
1953
1987
  iterateFetchPagesByItems(_object_spread_props$1(_object_spread$1({}, config), {
1954
1988
  iteratePageItems: function iteratePageItems(items, fetchPageResult, startIndex) {
1955
1989
  return _async_to_generator(function() {
1956
- var itemIndexPairs, performTasksResults;
1990
+ var itemIndexPairs;
1957
1991
  return _ts_generator(this, function(_state) {
1958
- switch(_state.label){
1959
- case 0:
1960
- itemIndexPairs = items.map(function(x, i) {
1961
- return [
1962
- x,
1963
- i + startIndex
1964
- ];
1965
- });
1966
- return [
1967
- 4,
1968
- performAsyncTasks(itemIndexPairs, function(param) {
1969
- var _param = _sliced_to_array$1(param, 2), item = _param[0], i = _param[1];
1970
- return iterateEachPageItem(item, i, fetchPageResult);
1971
- }, _object_spread$1({
1972
- sequential: true
1973
- }, iteratePerformTasksConfig))
1974
- ];
1975
- case 1:
1976
- performTasksResults = _state.sent();
1977
- return [
1978
- 2,
1979
- performTasksResults
1980
- ];
1981
- }
1992
+ itemIndexPairs = items.map(function(x, i) {
1993
+ return [
1994
+ x,
1995
+ i + startIndex
1996
+ ];
1997
+ });
1998
+ return [
1999
+ 2,
2000
+ performAsyncTasks(itemIndexPairs, function(param) {
2001
+ var _param = _sliced_to_array$1(param, 2), item = _param[0], i = _param[1];
2002
+ return iterateEachPageItem(item, i, fetchPageResult);
2003
+ }, _object_spread$1({
2004
+ sequential: true
2005
+ }, iteratePerformTasksConfig))
2006
+ ];
1982
2007
  });
1983
2008
  })();
1984
2009
  }
@@ -2185,12 +2210,37 @@ function iterateFetchPages(config) {
2185
2210
  })();
2186
2211
  }
2187
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_without_holes(arr) {
2219
+ if (Array.isArray(arr)) return _array_like_to_array$1(arr);
2220
+ }
2221
+ function _iterable_to_array(iter) {
2222
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
2223
+ }
2224
+ function _non_iterable_spread() {
2225
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2226
+ }
2227
+ function _to_consumable_array(arr) {
2228
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
2229
+ }
2230
+ function _unsupported_iterable_to_array$1(o, minLen) {
2231
+ if (!o) return;
2232
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
2233
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2234
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2235
+ if (n === "Map" || n === "Set") return Array.from(n);
2236
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
2237
+ }
2188
2238
  /**
2189
2239
  * Creates URLSearchParams from the input objects. The input objects are merged together.
2190
2240
  *
2191
- * @param input
2192
- * @param omitKeys
2193
- * @returns
2241
+ * @param input - one or more objects (or nullish values) whose key-value pairs become search parameters
2242
+ * @param options - optional configuration for filtering, omitting keys, and space encoding
2243
+ * @returns a URLSearchParams instance built from the merged and filtered input
2194
2244
  */ function makeUrlSearchParams(input, options) {
2195
2245
  var _ref = options !== null && options !== void 0 ? options : {}, omitKeys = _ref.omitKeys, filterValues = _ref.filterEmptyValues;
2196
2246
  var mergedInput = Array.isArray(input) ? mergeObjects(input) : input;
@@ -2221,6 +2271,9 @@ function iterateFetchPages(config) {
2221
2271
  }
2222
2272
  /**
2223
2273
  * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
2274
+ *
2275
+ * @param options - one or more options objects whose omitKeys sets are combined
2276
+ * @returns a single MakeUrlSearchParamsOptions with the union of all omitKeys
2224
2277
  */ function mergeMakeUrlSearchParamsOptions(options) {
2225
2278
  var omitKeys = new Set();
2226
2279
  useIterableOrValue(options, function(x) {
@@ -2231,7 +2284,7 @@ function iterateFetchPages(config) {
2231
2284
  }
2232
2285
  });
2233
2286
  return {
2234
- omitKeys: omitKeys.size > 0 ? Array.from(omitKeys) : undefined
2287
+ omitKeys: omitKeys.size > 0 ? _to_consumable_array(omitKeys) : undefined
2235
2288
  };
2236
2289
  }
2237
2290
 
@@ -2292,7 +2345,13 @@ function _unsupported_iterable_to_array(o, minLen) {
2292
2345
  if (n === "Map" || n === "Set") return Array.from(n);
2293
2346
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
2294
2347
  }
2295
- function fetchURL(input) {
2348
+ /**
2349
+ * Resolves a FetchURLInput to a URL string. Handles plain strings, URL objects, and
2350
+ * FetchURLConfiguration objects by appending query parameters when provided.
2351
+ *
2352
+ * @param input - a string, URL, or FetchURLConfiguration to resolve
2353
+ * @returns the resolved URL as a string
2354
+ */ function fetchURL(input) {
2296
2355
  var url;
2297
2356
  if (typeof input === 'string') {
2298
2357
  url = input;
@@ -2313,10 +2372,20 @@ function fetchURL(input) {
2313
2372
  }
2314
2373
  return url;
2315
2374
  }
2316
- function isURL(input) {
2375
+ /**
2376
+ * Type guard that checks whether the given value is a URL instance.
2377
+ *
2378
+ * @param input - the value to test
2379
+ * @returns true if the input is a URL instance
2380
+ */ function isURL(input) {
2317
2381
  return (typeof input === "undefined" ? "undefined" : _type_of$1(input)) === 'object' && _instanceof(input, URL);
2318
2382
  }
2319
- function isURLSearchParams(input) {
2383
+ /**
2384
+ * Type guard that checks whether the given value is a URLSearchParams instance.
2385
+ *
2386
+ * @param input - the value to test
2387
+ * @returns true if the input is a URLSearchParams instance
2388
+ */ function isURLSearchParams(input) {
2320
2389
  return (typeof input === "undefined" ? "undefined" : _type_of$1(input)) === 'object' && _instanceof(input, URLSearchParams);
2321
2390
  }
2322
2391
  /**
@@ -2344,7 +2413,13 @@ function isURLSearchParams(input) {
2344
2413
  });
2345
2414
  return paramTuples;
2346
2415
  }
2347
- function queryParamsToSearchParams(input) {
2416
+ /**
2417
+ * Converts a FetchURLQueryParamsInput value (URLSearchParams, string, iterable of tuples, or
2418
+ * params object) into a URLSearchParams instance.
2419
+ *
2420
+ * @param input - the query parameters input to convert
2421
+ * @returns a URLSearchParams instance representing the input
2422
+ */ function queryParamsToSearchParams(input) {
2348
2423
  var result;
2349
2424
  if (isURLSearchParams(input)) {
2350
2425
  // by url search params
@@ -2359,22 +2434,24 @@ function queryParamsToSearchParams(input) {
2359
2434
  }
2360
2435
  return result;
2361
2436
  }
2362
- function fetchURLSearchParamsObjectToURLSearchParams(input) {
2437
+ /**
2438
+ * Converts a FetchURLSearchParamsObject (a plain key-value record) into a URLSearchParams instance,
2439
+ * expanding array values into multiple entries for the same key and filtering out null/undefined values.
2440
+ *
2441
+ * @param input - the params object to convert
2442
+ * @returns a URLSearchParams instance representing the input object
2443
+ */ function fetchURLSearchParamsObjectToURLSearchParams(input) {
2363
2444
  var paramTuples = [];
2364
2445
  forEachKeyValue(input, {
2365
2446
  forEach: function forEach(tuple) {
2366
2447
  var _tuple = _sliced_to_array(tuple, 2), key = _tuple[0], values = _tuple[1];
2367
- // ignore null/undefined keys and values
2368
- if (key != null && values != null) {
2369
- var keyString = String(key);
2448
+ var keyString = String(key);
2449
+ if (values != null) {
2370
2450
  useIterableOrValue(values, function(x) {
2371
- // ignore null/undefined values
2372
- if (x != null) {
2373
- paramTuples.push([
2374
- keyString,
2375
- String(x)
2376
- ]);
2377
- }
2451
+ paramTuples.push([
2452
+ keyString,
2453
+ String(x)
2454
+ ]);
2378
2455
  });
2379
2456
  }
2380
2457
  }
@@ -2558,11 +2635,15 @@ var JsonResponseParseError = /*#__PURE__*/ function(Error1) {
2558
2635
  var throwJsonResponseParseErrorFunction = function throwJsonResponseParseErrorFunction(response) {
2559
2636
  throw new JsonResponseParseError(response);
2560
2637
  };
2561
- var returnNullHandleFetchJsonParseErrorFunction = function returnNullHandleFetchJsonParseErrorFunction(_) {
2638
+ var returnNullHandleFetchJsonParseErrorFunction = function returnNullHandleFetchJsonParseErrorFunction(_response) {
2562
2639
  return null;
2563
2640
  };
2564
2641
  /**
2565
2642
  * Creates a FetchJsonFunction from the input ConfiguredFetch.
2643
+ *
2644
+ * @param fetch - the configured fetch function to use for making HTTP requests
2645
+ * @param inputConfig - optional configuration or error handler for JSON parsing; when a function is provided it is used as the parse error handler
2646
+ * @returns a FetchJsonFunction that performs requests and parses JSON responses
2566
2647
  */ function fetchJsonFunction(fetch, inputConfig) {
2567
2648
  var _config_handleFetchJsonParseErrorFunction;
2568
2649
  var config;
@@ -2594,18 +2675,19 @@ var returnNullHandleFetchJsonParseErrorFunction = function returnNullHandleFetch
2594
2675
  });
2595
2676
  };
2596
2677
  }
2597
- function fetchJsonRequestInitFunction() {
2678
+ /**
2679
+ * Creates a {@link FetchJsonRequestInitFunction} that converts method/body inputs into a fully formed {@link RequestInit},
2680
+ * applying the configured default method and optional input mapping.
2681
+ *
2682
+ * @param config - optional configuration specifying the default HTTP method and an input mapping function
2683
+ * @returns a function that produces a {@link RequestInit} from a method string or {@link FetchJsonInput}
2684
+ */ function fetchJsonRequestInitFunction() {
2598
2685
  var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2599
2686
  var _config_defaultMethod = config.defaultMethod, defaultMethod = _config_defaultMethod === void 0 ? 'GET' : _config_defaultMethod, _config_mapFetchJsonInput = config.mapFetchJsonInput, mapFetchJsonInput = _config_mapFetchJsonInput === void 0 ? mapIdentityFunction() : _config_mapFetchJsonInput;
2600
2687
  return function() {
2601
2688
  var methodOrInput = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultMethod, body = arguments.length > 1 ? arguments[1] : void 0;
2602
- var _config_method;
2603
2689
  var config;
2604
- if (methodOrInput === null) {
2605
- config = {
2606
- method: defaultMethod
2607
- };
2608
- } else if (typeof methodOrInput === 'string') {
2690
+ if (typeof methodOrInput === 'string') {
2609
2691
  config = {
2610
2692
  method: methodOrInput,
2611
2693
  body: body
@@ -2615,7 +2697,7 @@ function fetchJsonRequestInitFunction() {
2615
2697
  }
2616
2698
  config = mapFetchJsonInput(config);
2617
2699
  var requestInit = _object_spread_props(_object_spread({}, config), {
2618
- method: (_config_method = config.method) !== null && _config_method !== void 0 ? _config_method : defaultMethod,
2700
+ method: config.method,
2619
2701
  body: fetchJsonBodyString(config.body)
2620
2702
  });
2621
2703
  return requestInit;
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "13.4.0",
3
+ "version": "13.4.2",
4
4
  "peerDependencies": {
5
- "@dereekb/util": "13.4.0",
5
+ "@dereekb/util": "13.4.2",
6
6
  "make-error": "^1.3.0",
7
7
  "fast-content-type-parse": "^3.0.0"
8
8
  },
@@ -17,4 +17,10 @@ export declare class FetchResponseError extends BaseError {
17
17
  readonly response: Response;
18
18
  constructor(response: Response);
19
19
  }
20
+ /**
21
+ * Asserts that the fetch response has an ok status code, throwing a FetchResponseError if it does not.
22
+ *
23
+ * @param responsePromise - promise resolving to the fetch Response to validate
24
+ * @returns a promise resolving to the Response if the status is ok
25
+ */
20
26
  export declare function requireOkResponse(responsePromise: Promise<Response>): Promise<Response>;
@@ -51,6 +51,7 @@ export interface ConfigureFetchInput extends FetchRequestFactoryInput {
51
51
  }
52
52
  /**
53
53
  * Default FetchHabdler
54
+ *
54
55
  * @param request
55
56
  * @param makeFetch
56
57
  * @returns
@@ -110,8 +111,44 @@ export type AbortControllerFactory = Factory<AbortController>;
110
111
  * @returns
111
112
  */
112
113
  export declare const DEFAULT_FETCH_REQUEST_FACTORY: FetchRequestFactory;
114
+ /**
115
+ * Creates a FetchRequestFactory that builds Request objects by applying base URL resolution,
116
+ * base request init merging, timeout configuration, and custom request init transformations.
117
+ *
118
+ * @param config - configuration for URL resolution, base request defaults, timeout, and request init transformations
119
+ * @returns a FetchRequestFactory that produces fully configured Request objects
120
+ */
113
121
  export declare function fetchRequestFactory(config: FetchRequestFactoryInput): FetchRequestFactory;
122
+ /**
123
+ * Merges two RequestInit objects, combining their headers and spreading remaining properties
124
+ * so that values from the second init override the base.
125
+ *
126
+ * @param base - the base RequestInit to merge onto
127
+ * @param requestInit - optional RequestInit whose values override the base
128
+ * @returns the merged RequestInit
129
+ */
114
130
  export declare function mergeRequestInits<T extends RequestInit>(base: T, requestInit?: T | undefined): T;
131
+ /**
132
+ * Merges an array of HeadersInit values into a single array of key-value tuples.
133
+ * Later headers override earlier ones on a per-key basis while preserving multi-value support.
134
+ *
135
+ * @param inputHeadersArray - array of HeadersInit values to merge, where later entries take precedence
136
+ * @returns an array of [key, value] tuples representing the merged headers
137
+ */
115
138
  export declare function mergeRequestHeaders(inputHeadersArray: Maybe<HeadersInit>[]): [string, string][];
139
+ /**
140
+ * Converts a HeadersInit value (tuple array, Headers object, or plain object) into
141
+ * a normalized array of [key, value] tuples.
142
+ *
143
+ * @param headers - the HeadersInit value to convert
144
+ * @returns an array of [key, value] string tuples
145
+ */
116
146
  export declare function headersToHeadersTuple(headers: HeadersInit): [string, string][];
147
+ /**
148
+ * Type guard that checks whether the given input is a fetch Request object
149
+ * by testing for the presence of a url property.
150
+ *
151
+ * @param input - the value to test
152
+ * @returns true if the input is a Request
153
+ */
117
154
  export declare function isFetchRequest(input: unknown): input is Request;