@dereekb/util 13.2.2 → 13.3.0

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.
@@ -2205,6 +2205,22 @@ function iterateFetchPages(config) {
2205
2205
  }
2206
2206
  return searchParams;
2207
2207
  }
2208
+ /**
2209
+ * Creates a URL query string from the input objects.
2210
+ *
2211
+ * Equivalent to `makeUrlSearchParams(...).toString()`, but respects the
2212
+ * {@link MakeUrlSearchParamsOptions.usePercentEncoding} option to produce
2213
+ * RFC 3986 percent-encoded output (`%20` for spaces) instead of the
2214
+ * `application/x-www-form-urlencoded` default (`+` for spaces).
2215
+ *
2216
+ * @param input - objects to encode as query parameters
2217
+ * @param options - encoding options
2218
+ * @returns the encoded query string (without a leading `?`)
2219
+ */ function makeUrlSearchParamsString(input, options) {
2220
+ var params = makeUrlSearchParams(input, options);
2221
+ var str = params.toString();
2222
+ return (options === null || options === void 0 ? void 0 : options.useUrlSearchSpaceHandling) ? str.replace(/\+/g, '%20') : str;
2223
+ }
2208
2224
  /**
2209
2225
  * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
2210
2226
  */ function mergeMakeUrlSearchParamsOptions(options) {
@@ -2652,6 +2668,7 @@ exports.iterateFetchPagesByEachItem = iterateFetchPagesByEachItem;
2652
2668
  exports.iterateFetchPagesByItems = iterateFetchPagesByItems;
2653
2669
  exports.makeFileForFetch = makeFileForFetch;
2654
2670
  exports.makeUrlSearchParams = makeUrlSearchParams;
2671
+ exports.makeUrlSearchParamsString = makeUrlSearchParamsString;
2655
2672
  exports.mergeMakeUrlSearchParamsOptions = mergeMakeUrlSearchParamsOptions;
2656
2673
  exports.mergeRequestHeaders = mergeRequestHeaders;
2657
2674
  exports.mergeRequestInits = mergeRequestInits;
@@ -2203,6 +2203,22 @@ function iterateFetchPages(config) {
2203
2203
  }
2204
2204
  return searchParams;
2205
2205
  }
2206
+ /**
2207
+ * Creates a URL query string from the input objects.
2208
+ *
2209
+ * Equivalent to `makeUrlSearchParams(...).toString()`, but respects the
2210
+ * {@link MakeUrlSearchParamsOptions.usePercentEncoding} option to produce
2211
+ * RFC 3986 percent-encoded output (`%20` for spaces) instead of the
2212
+ * `application/x-www-form-urlencoded` default (`+` for spaces).
2213
+ *
2214
+ * @param input - objects to encode as query parameters
2215
+ * @param options - encoding options
2216
+ * @returns the encoded query string (without a leading `?`)
2217
+ */ function makeUrlSearchParamsString(input, options) {
2218
+ var params = makeUrlSearchParams(input, options);
2219
+ var str = params.toString();
2220
+ return (options === null || options === void 0 ? void 0 : options.useUrlSearchSpaceHandling) ? str.replace(/\+/g, '%20') : str;
2221
+ }
2206
2222
  /**
2207
2223
  * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
2208
2224
  */ function mergeMakeUrlSearchParamsOptions(options) {
@@ -2616,4 +2632,4 @@ var fetchJsonRequestInit = fetchJsonRequestInitFunction();
2616
2632
  }
2617
2633
  });
2618
2634
 
2619
- 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, mergeMakeUrlSearchParamsOptions, mergeRequestHeaders, mergeRequestInits, parseFetchFileResponse, queryParamsToSearchParams, rateLimitedFetchHandler, requireOkResponse, returnNullHandleFetchJsonParseErrorFunction, throwJsonResponseParseErrorFunction };
2635
+ 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 };
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@dereekb/util/fetch",
3
- "version": "13.2.2",
3
+ "version": "13.3.0",
4
4
  "peerDependencies": {
5
- "@dereekb/util": "13.2.2",
5
+ "@dereekb/util": "13.3.0",
6
6
  "make-error": "^1.3.0",
7
7
  "fast-content-type-parse": "^3.0.0"
8
8
  },
@@ -13,6 +13,23 @@ export interface MakeUrlSearchParamsOptions {
13
13
  * Defaults to true.
14
14
  */
15
15
  readonly filterEmptyValues?: boolean;
16
+ /**
17
+ * Whether to encode spaces as `%20` instead of `+` in the output string.
18
+ *
19
+ * `URLSearchParams.toString()` uses `application/x-www-form-urlencoded` encoding,
20
+ * which represents spaces as `+`. However, `URL.search` and `decodeURIComponent()`
21
+ * encode spaces as `%20`. This mismatch means that consumers like Angular's router
22
+ * that use `decodeURIComponent()` will not decode `+` back to a space, corrupting
23
+ * values (e.g., `"openid profile"` becomes `"openid+profile"`).
24
+ *
25
+ * Set to `true` when building redirect URLs or any URL that will be decoded with
26
+ * `decodeURIComponent()` rather than form-data parsing.
27
+ *
28
+ * Defaults to false.
29
+ *
30
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams#interaction_with_url.searchparams | MDN: Interaction with URL.searchParams}
31
+ */
32
+ readonly useUrlSearchSpaceHandling?: boolean;
16
33
  }
17
34
  /**
18
35
  * Creates URLSearchParams from the input objects. The input objects are merged together.
@@ -22,6 +39,19 @@ export interface MakeUrlSearchParamsOptions {
22
39
  * @returns
23
40
  */
24
41
  export declare function makeUrlSearchParams(input: Maybe<ArrayOrValue<Maybe<object | Record<string, string | number>>>>, options?: Maybe<MakeUrlSearchParamsOptions>): URLSearchParams;
42
+ /**
43
+ * Creates a URL query string from the input objects.
44
+ *
45
+ * Equivalent to `makeUrlSearchParams(...).toString()`, but respects the
46
+ * {@link MakeUrlSearchParamsOptions.usePercentEncoding} option to produce
47
+ * RFC 3986 percent-encoded output (`%20` for spaces) instead of the
48
+ * `application/x-www-form-urlencoded` default (`+` for spaces).
49
+ *
50
+ * @param input - objects to encode as query parameters
51
+ * @param options - encoding options
52
+ * @returns the encoded query string (without a leading `?`)
53
+ */
54
+ export declare function makeUrlSearchParamsString(input: Maybe<ArrayOrValue<Maybe<object | Record<string, string | number>>>>, options?: Maybe<MakeUrlSearchParamsOptions>): string;
25
55
  /**
26
56
  * Merges an array of MakeUrlSearchParamsOptions into a single MakeUrlSearchParamsOptions value.
27
57
  */
package/index.cjs.js CHANGED
@@ -4024,6 +4024,62 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?([0-9]+)\.?([0-9][0-9])$/;
4024
4024
  return chainMapSameFunctions(transformFunctions);
4025
4025
  }
4026
4026
 
4027
+ /**
4028
+ * Encodes a number as a radix-36 string.
4029
+ *
4030
+ * Uses digits 0-9 and lowercase letters a-z, producing compact representations
4031
+ * that are useful for URL-safe identifiers and short codes.
4032
+ *
4033
+ * @param number - The number to encode. Should be a non-negative integer for consistent results.
4034
+ * @returns The radix-36 encoded string representation.
4035
+ *
4036
+ * @example
4037
+ * ```ts
4038
+ * encodeRadix36Number(0); // '0'
4039
+ * encodeRadix36Number(35); // 'z'
4040
+ * encodeRadix36Number(100); // '2s'
4041
+ * ```
4042
+ */ function encodeRadix36Number(number) {
4043
+ return number.toString(36);
4044
+ }
4045
+ /**
4046
+ * Decodes a radix-36 encoded string back to a number.
4047
+ *
4048
+ * Parses a string containing digits 0-9 and letters a-z (case-insensitive)
4049
+ * as a base-36 number.
4050
+ *
4051
+ * @param encoded - The radix-36 encoded string to decode.
4052
+ * @returns The decoded numeric value. Returns `NaN` if the input is not a valid radix-36 string.
4053
+ *
4054
+ * @example
4055
+ * ```ts
4056
+ * decodeRadix36Number('0'); // 0
4057
+ * decodeRadix36Number('z'); // 35
4058
+ * decodeRadix36Number('2s'); // 100
4059
+ * ```
4060
+ */ function decodeRadix36Number(encoded) {
4061
+ return parseInt(encoded, 36);
4062
+ }
4063
+ /**
4064
+ * Pattern that matches strings containing only hexadecimal characters (0-9, a-f, A-F).
4065
+ */ var HEX_PATTERN = /^[0-9a-fA-F]+$/;
4066
+ /**
4067
+ * Checks whether the input string contains only valid hexadecimal characters.
4068
+ *
4069
+ * @example
4070
+ * ```ts
4071
+ * isHex('a1b2c3'); // true
4072
+ * isHex('FF00AA'); // true
4073
+ * isHex('hello'); // false
4074
+ * isHex(''); // false
4075
+ * ```
4076
+ *
4077
+ * @param value - The string to check.
4078
+ * @returns True if the string is non-empty and contains only hex characters.
4079
+ */ function isHex(value) {
4080
+ return HEX_PATTERN.test(value);
4081
+ }
4082
+
4027
4083
  /**
4028
4084
  * Reduces an array of numbers to its maximum value.
4029
4085
  *
@@ -5277,9 +5333,9 @@ function arrayToObject(values, keyFn) {
5277
5333
  /**
5278
5334
  * Default comma joiner character used by comma-related string functions.
5279
5335
  */ var COMMA_JOINER = ',';
5280
- function caseInsensitiveString(input) {
5281
- return input === null || input === void 0 ? void 0 : input.toLocaleLowerCase();
5282
- }
5336
+ /**
5337
+ * Default space joiner character used by space-related string functions.
5338
+ */ var SPACE_JOINER = ' ';
5283
5339
  function joinStrings(input) {
5284
5340
  var joiner = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : COMMA_JOINER, trim = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
5285
5341
  if (input == null) {
@@ -5293,26 +5349,103 @@ function joinStrings(input) {
5293
5349
  }
5294
5350
  return array.filter(Boolean).join(joiner);
5295
5351
  }
5296
- function joinStringsWithCommas(input) {
5297
- var trim = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
5298
- return joinStrings(input, COMMA_JOINER, trim);
5352
+ /**
5353
+ * Splits a string like {@link String.prototype.split}, but joins overflow segments back together
5354
+ * instead of discarding them. Useful when you only want to split on the first N-1 occurrences.
5355
+ *
5356
+ * @param input - string to split
5357
+ * @param separator - delimiter to split on
5358
+ * @param limit - maximum number of resulting segments; overflow segments are rejoined with the separator
5359
+ * @returns array of string segments, with length at most equal to limit
5360
+ */ function splitJoinRemainder(input, separator, limit) {
5361
+ var split = input.split(separator);
5362
+ var components = [];
5363
+ if (split.length > 1) {
5364
+ var hasItemsToMerge = split.length > limit;
5365
+ var stopIndex = hasItemsToMerge ? limit - 1 : split.length;
5366
+ for(var i = 0; i < stopIndex; i += 1){
5367
+ components.push(split[i]);
5368
+ }
5369
+ if (hasItemsToMerge) {
5370
+ components.push(split.slice(stopIndex).join(separator));
5371
+ }
5372
+ } else {
5373
+ components.push(split[0]);
5374
+ }
5375
+ return components;
5299
5376
  }
5300
- function splitCommaSeparatedString(input) {
5301
- var mapFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function(x) {
5302
- return x;
5377
+ /**
5378
+ * Creates a {@link JoinStringsInstance} that joins arrays of strings using the configured delimiter.
5379
+ *
5380
+ * @example
5381
+ * ```ts
5382
+ * const joinWithPipe = joinStringsInstance({ joiner: '|' });
5383
+ * joinWithPipe(['a', 'b']); // 'a|b'
5384
+ * joinWithPipe(null); // null
5385
+ * ```
5386
+ *
5387
+ * @param config - configuration for the delimiter and default trim behavior
5388
+ * @returns a new callable {@link JoinStringsInstance}
5389
+ */ function joinStringsInstance(config) {
5390
+ var joiner = config.joiner, _config_trimByDefault = config.trimByDefault, trimByDefault = _config_trimByDefault === void 0 ? false : _config_trimByDefault;
5391
+ var fn = function fn(input) {
5392
+ var trim = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : trimByDefault;
5393
+ return joinStrings(input, joiner, trim);
5303
5394
  };
5304
- var splits = input.split(COMMA_JOINER);
5305
- return splits.map(function(x) {
5306
- return mapFn(x.trim());
5307
- });
5395
+ fn.joiner = joiner;
5396
+ fn.trimByDefault = trimByDefault;
5397
+ return fn;
5308
5398
  }
5309
5399
  /**
5310
- * Splits a comma-separated string into a Set of unique trimmed string values.
5400
+ * Creates a {@link StringSplitJoinInstance} that splits and joins strings using the configured delimiter.
5311
5401
  *
5312
- * @param input - comma-separated string to split, or null/undefined
5313
- * @returns a Set of unique string values; empty Set if input is null/undefined
5314
- */ function splitCommaSeparatedStringToSet(input) {
5315
- return new Set(input != null ? splitCommaSeparatedString(input) : []);
5402
+ * @example
5403
+ * ```ts
5404
+ * const pipeSplitJoin = stringSplitJoinInstance({ joiner: '|' });
5405
+ * pipeSplitJoin.joinStrings(['a', 'b']); // 'a|b'
5406
+ * pipeSplitJoin.splitStrings('a|b'); // ['a', 'b']
5407
+ * ```
5408
+ *
5409
+ * @param config - configuration for the delimiter and default trim behavior
5410
+ * @returns a new {@link StringSplitJoinInstance}
5411
+ */ function stringSplitJoinInstance(config) {
5412
+ var joiner = config.joiner;
5413
+ var joinStrings = joinStringsInstance(config);
5414
+ var splitStrings = function splitStrings(input) {
5415
+ var mapFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function(x) {
5416
+ return x;
5417
+ };
5418
+ var splits = input.split(joiner);
5419
+ return splits.map(function(x) {
5420
+ return mapFn(x.trim());
5421
+ });
5422
+ };
5423
+ return {
5424
+ joiner: joiner,
5425
+ trimByDefault: joinStrings.trimByDefault,
5426
+ joinStrings: joinStrings,
5427
+ splitStrings: splitStrings,
5428
+ splitStringsToSet: function splitStringsToSet(input) {
5429
+ return new Set(input != null ? splitStrings(input) : []);
5430
+ },
5431
+ splitJoinRemainder: function splitJoinRemainder1(input, limit) {
5432
+ return splitJoinRemainder(input, joiner, limit);
5433
+ }
5434
+ };
5435
+ }
5436
+ /**
5437
+ * Global {@link StringSplitJoinInstance} that uses commas as the delimiter.
5438
+ */ var COMMA_STRING_SPLIT_JOIN = stringSplitJoinInstance({
5439
+ joiner: COMMA_JOINER
5440
+ });
5441
+ /**
5442
+ * Global {@link StringSplitJoinInstance} that uses spaces as the delimiter, with trimming enabled by default.
5443
+ */ var SPACE_STRING_SPLIT_JOIN = stringSplitJoinInstance({
5444
+ joiner: SPACE_JOINER,
5445
+ trimByDefault: true
5446
+ });
5447
+ function caseInsensitiveString(input) {
5448
+ return input === null || input === void 0 ? void 0 : input.toLocaleLowerCase();
5316
5449
  }
5317
5450
  /**
5318
5451
  * Adds a plus prefix to the input value and converts it to a string. If the value is negative or 0, no prefix is added.
@@ -5346,34 +5479,6 @@ function splitCommaSeparatedString(input) {
5346
5479
  */ function lowercaseFirstLetter(value) {
5347
5480
  return value.charAt(0).toLowerCase() + value.slice(1);
5348
5481
  }
5349
- /**
5350
- * Splits a string like {@link String.prototype.split}, but joins overflow segments back together
5351
- * instead of discarding them. Useful when you only want to split on the first N-1 occurrences.
5352
- *
5353
- * @param input - string to split
5354
- * @param separator - delimiter to split on
5355
- * @param limit - maximum number of resulting segments; overflow segments are rejoined with the separator
5356
- * @returns array of string segments, with length at most equal to limit
5357
- */ function splitJoinRemainder(input, separator, limit) {
5358
- var split = input.split(separator);
5359
- var components = [];
5360
- if (split.length > 1) {
5361
- var hasItemsToMerge = split.length > limit;
5362
- var stopIndex = hasItemsToMerge ? limit - 1 : split.length;
5363
- for(var i = 0; i < stopIndex; i += 1){
5364
- components.push(split[i]);
5365
- }
5366
- if (hasItemsToMerge) {
5367
- components.push(split.slice(stopIndex).join(separator));
5368
- }
5369
- } else {
5370
- components.push(split[0]);
5371
- }
5372
- return components;
5373
- }
5374
- /**
5375
- * Default space joiner character used by space-related string functions.
5376
- */ var SPACE_JOINER = ' ';
5377
5482
  /**
5378
5483
  * Splits the input string into a first name and last name tuple using a space as the delimiter.
5379
5484
  * If the name contains more than one space, the remainder is treated as the last name.
@@ -5381,10 +5486,7 @@ function splitCommaSeparatedString(input) {
5381
5486
  * @param input - full name string to split
5382
5487
  * @returns a tuple of [firstName, lastName], where lastName includes all text after the first space
5383
5488
  */ function splitJoinNameString(input) {
5384
- return splitJoinRemainder(input, SPACE_JOINER, 2);
5385
- }
5386
- function joinStringsWithSpaces(input) {
5387
- return joinStrings(input, SPACE_JOINER, true);
5489
+ return SPACE_STRING_SPLIT_JOIN.splitJoinRemainder(input, 2);
5388
5490
  }
5389
5491
  /**
5390
5492
  * Creates a string that repeats the given string a specified number of times.
@@ -5455,6 +5557,41 @@ function joinStringsWithSpaces(input) {
5455
5557
  */ function simplifyWhitespace(input) {
5456
5558
  return input.split(/\r?\n/).filter(Boolean).map(flattenWhitespace).join('\n');
5457
5559
  }
5560
+ // MARK: Compat
5561
+ /**
5562
+ * Joins an array of strings into a single string using commas. Does not trim empty values by default.
5563
+ *
5564
+ * Delegates to {@link COMMA_STRING_SPLIT_JOIN}.
5565
+ *
5566
+ * @param input string or array of strings
5567
+ * @param trim whether or not to trim the strings before joining. Defaults to false.
5568
+ * @returns joined string, or null/undefined if the input is null/undefined
5569
+ */ var joinStringsWithCommas = COMMA_STRING_SPLIT_JOIN.joinStrings;
5570
+ /**
5571
+ * Splits a comma-separated string into an array of strings.
5572
+ *
5573
+ * Delegates to {@link COMMA_STRING_SPLIT_JOIN}.
5574
+ *
5575
+ * @param input string to split
5576
+ * @param mapFn function to map each split string to a value
5577
+ * @returns array of strings
5578
+ */ var splitCommaSeparatedString = COMMA_STRING_SPLIT_JOIN.splitStrings;
5579
+ /**
5580
+ * Splits a comma-separated string into a Set of unique trimmed string values.
5581
+ *
5582
+ * Delegates to {@link COMMA_STRING_SPLIT_JOIN}.
5583
+ *
5584
+ * @param input - comma-separated string to split, or null/undefined
5585
+ * @returns a Set of unique string values; empty Set if input is null/undefined
5586
+ */ var splitCommaSeparatedStringToSet = COMMA_STRING_SPLIT_JOIN.splitStringsToSet;
5587
+ /**
5588
+ * Joins one or more strings together with spaces. Extra spaces are trimmed from the values.
5589
+ *
5590
+ * Delegates to {@link SPACE_STRING_SPLIT_JOIN}.
5591
+ *
5592
+ * @param input string or array of strings
5593
+ * @returns joined string, or null/undefined if the input is null/undefined
5594
+ */ var joinStringsWithSpaces = SPACE_STRING_SPLIT_JOIN.joinStrings;
5458
5595
 
5459
5596
  /**
5460
5597
  * Maps each value in an iterable through a function and returns the results as an array.
@@ -8980,10 +9117,13 @@ function _unsupported_iterable_to_array$f(o, minLen) {
8980
9117
  * @param input - The string to analyze as a URL.
8981
9118
  * @returns An object containing parsed URL components and validation flags.
8982
9119
  */ function websiteUrlDetails(input) {
9120
+ var _readPortNumber;
8983
9121
  var noHttp = removeHttpFromUrl(input);
8984
9122
  var splitPair = websiteDomainAndPathPairFromWebsiteUrl(noHttp);
8985
9123
  var domain = splitPair.domain, websitePath = splitPair.path;
8986
9124
  var pathHasWebsiteDomain = hasWebsiteDomain(domain);
9125
+ var inputHasPortNumber = hasPortNumber(input);
9126
+ var portNumber = inputHasPortNumber ? (_readPortNumber = readPortNumber(input)) !== null && _readPortNumber !== void 0 ? _readPortNumber : undefined : undefined;
8987
9127
  var _splitStringAtFirstCharacterOccurence = _sliced_to_array$c(splitStringAtFirstCharacterOccurence(splitPair.path, '?'), 2), path = _splitStringAtFirstCharacterOccurence[0], query = _splitStringAtFirstCharacterOccurence[1]; // everything after the query is ignored
8988
9128
  var isWebsiteUrl = pathHasWebsiteDomain && isSlashPathFolder(path + '/');
8989
9129
  var inputHasHttpPrefix = hasHttpPrefix(input);
@@ -8992,6 +9132,8 @@ function _unsupported_iterable_to_array$f(o, minLen) {
8992
9132
  isWebsiteUrl: isWebsiteUrl,
8993
9133
  hasWebsiteDomain: pathHasWebsiteDomain,
8994
9134
  hasHttpPrefix: inputHasHttpPrefix,
9135
+ hasPortNumber: inputHasPortNumber,
9136
+ portNumber: portNumber,
8995
9137
  splitPair: splitPair,
8996
9138
  domain: domain,
8997
9139
  websitePath: websitePath,
@@ -9028,6 +9170,9 @@ function _unsupported_iterable_to_array$f(o, minLen) {
9028
9170
  */ function websiteUrlFromPaths(basePath, paths, defaultProtocol) {
9029
9171
  var _readWebsiteProtocol;
9030
9172
  var protocol = (_readWebsiteProtocol = readWebsiteProtocol(basePath)) !== null && _readWebsiteProtocol !== void 0 ? _readWebsiteProtocol : defaultProtocol;
9173
+ if (!basePath) {
9174
+ return mergeSlashPaths(asArray(paths));
9175
+ }
9031
9176
  var baseWebUrl = removeWebProtocolPrefix(baseWebsiteUrl(basePath)); // remove prefix to prevent issues with slash paths
9032
9177
  var webUrl = mergeSlashPaths([
9033
9178
  baseWebUrl
@@ -9706,6 +9851,23 @@ function toReadableError(inputError) {
9706
9851
  return ((typeof input === "undefined" ? "undefined" : _type_of$9(input)) === 'object' ? input.message : input) || input;
9707
9852
  }
9708
9853
 
9854
+ /**
9855
+ * Returns true if the buffer appears to have the markings of a valid PDF.
9856
+ *
9857
+ * Checks for two structural markers defined by the PDF specification (ISO 32000):
9858
+ * - `%PDF-` header at the start of the buffer, which identifies the file as a PDF document.
9859
+ * - `%%EOF` marker somewhere in the buffer, which signals the end of a PDF file.
9860
+ *
9861
+ * This is a lightweight heuristic check, not a full validation. A buffer that passes
9862
+ * this check is not guaranteed to be a well-formed or uncorrupted PDF — it only confirms
9863
+ * the expected start/end markers are present.
9864
+ *
9865
+ * @param buffer - Buffer-like object to check. Only requires the `lastIndexOf` method.
9866
+ * @returns true if both PDF markers are found in the expected positions.
9867
+ */ function bufferHasValidPdfMarkings(buffer) {
9868
+ return buffer.lastIndexOf('%PDF-') === 0 && buffer.lastIndexOf('%%EOF') > -1;
9869
+ }
9870
+
9709
9871
  function _array_like_to_array$e(arr, len) {
9710
9872
  if (len == null || len > arr.length) len = arr.length;
9711
9873
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -12218,6 +12380,9 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
12218
12380
  /**
12219
12381
  * Number of minutes in an hour.
12220
12382
  */ var MINUTES_IN_HOUR = 60;
12383
+ /**
12384
+ * Number of seconds in an hour.
12385
+ */ var SECONDS_IN_HOUR = MINUTES_IN_HOUR * SECONDS_IN_MINUTE;
12221
12386
  /**
12222
12387
  * Number of milliseconds in a second.
12223
12388
  */ var MS_IN_SECOND = 1000;
@@ -19644,6 +19809,108 @@ function _ts_generator(thisArg, body) {
19644
19809
  return root;
19645
19810
  }
19646
19811
 
19812
+ // MARK: Mapped Types
19813
+ /**
19814
+ * Default prefix used for encrypted field names.
19815
+ */ var DEFAULT_ENCRYPTED_FIELD_PREFIX = '$';
19816
+ // MARK: Factory
19817
+ /**
19818
+ * Creates a selective field encryptor that encrypts/decrypts specific fields on an object.
19819
+ *
19820
+ * Each encrypted field's value is JSON.stringified before encryption and JSON.parsed after
19821
+ * decryption, so fields can hold any JSON-serializable value (not just strings).
19822
+ *
19823
+ * @example
19824
+ * ```ts
19825
+ * const encryptor = selectiveFieldEncryptor({
19826
+ * provider: myEncryptionProvider,
19827
+ * fields: ['client_secret'] as const
19828
+ * });
19829
+ *
19830
+ * const encrypted = encryptor.encrypt({ client_id: 'abc', client_secret: 's3cret' });
19831
+ * // encrypted => { client_id: 'abc', $client_secret: '<ciphertext>' }
19832
+ *
19833
+ * const decrypted = encryptor.decrypt(encrypted);
19834
+ * // decrypted => { client_id: 'abc', client_secret: 's3cret' }
19835
+ * ```
19836
+ *
19837
+ * @param config - Encryption configuration specifying provider, fields, and optional prefix.
19838
+ * @returns A selective field encryptor instance.
19839
+ */ function selectiveFieldEncryptor(config) {
19840
+ var provider = config.provider, fields = config.fields, prefixInput = config.prefix;
19841
+ var prefix = prefixInput !== null && prefixInput !== void 0 ? prefixInput : DEFAULT_ENCRYPTED_FIELD_PREFIX;
19842
+ var fieldSet = new Set(fields);
19843
+ var result = {
19844
+ encrypt: function encrypt(input) {
19845
+ var output = {};
19846
+ var inputRecord = input;
19847
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19848
+ try {
19849
+ for(var _iterator = Object.keys(inputRecord)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19850
+ var key = _step.value;
19851
+ if (fieldSet.has(key)) {
19852
+ var json = JSON.stringify(inputRecord[key]);
19853
+ output["".concat(prefix).concat(key)] = provider.encrypt(json);
19854
+ } else {
19855
+ output[key] = inputRecord[key];
19856
+ }
19857
+ }
19858
+ } catch (err) {
19859
+ _didIteratorError = true;
19860
+ _iteratorError = err;
19861
+ } finally{
19862
+ try {
19863
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
19864
+ _iterator.return();
19865
+ }
19866
+ } finally{
19867
+ if (_didIteratorError) {
19868
+ throw _iteratorError;
19869
+ }
19870
+ }
19871
+ }
19872
+ return output;
19873
+ },
19874
+ decrypt: function decrypt(input) {
19875
+ var output = {};
19876
+ var inputRecord = input;
19877
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19878
+ try {
19879
+ for(var _iterator = Object.keys(inputRecord)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19880
+ var key = _step.value;
19881
+ var handled = false;
19882
+ if (key.startsWith(prefix)) {
19883
+ var originalKey = key.slice(prefix.length);
19884
+ if (fieldSet.has(originalKey)) {
19885
+ var decrypted = provider.decrypt(inputRecord[key]);
19886
+ output[originalKey] = JSON.parse(decrypted);
19887
+ handled = true;
19888
+ }
19889
+ }
19890
+ if (!handled) {
19891
+ output[key] = inputRecord[key];
19892
+ }
19893
+ }
19894
+ } catch (err) {
19895
+ _didIteratorError = true;
19896
+ _iteratorError = err;
19897
+ } finally{
19898
+ try {
19899
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
19900
+ _iterator.return();
19901
+ }
19902
+ } finally{
19903
+ if (_didIteratorError) {
19904
+ throw _iteratorError;
19905
+ }
19906
+ }
19907
+ }
19908
+ return output;
19909
+ }
19910
+ };
19911
+ return result;
19912
+ }
19913
+
19647
19914
  exports.ALL_DOUBLE_SLASHES_REGEX = ALL_DOUBLE_SLASHES_REGEX;
19648
19915
  exports.ALL_SLASHES_REGEX = ALL_SLASHES_REGEX;
19649
19916
  exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX;
@@ -19666,12 +19933,14 @@ exports.AssertionIssueHandler = AssertionIssueHandler;
19666
19933
  exports.BooleanStringKeyArrayUtility = BooleanStringKeyArrayUtility;
19667
19934
  exports.CATCH_ALL_HANDLE_RESULT_KEY = CATCH_ALL_HANDLE_RESULT_KEY;
19668
19935
  exports.COMMA_JOINER = COMMA_JOINER;
19936
+ exports.COMMA_STRING_SPLIT_JOIN = COMMA_STRING_SPLIT_JOIN;
19669
19937
  exports.CSV_MIME_TYPE = CSV_MIME_TYPE;
19670
19938
  exports.CUT_VALUE_TO_ZERO_PRECISION = CUT_VALUE_TO_ZERO_PRECISION;
19671
19939
  exports.DASH_CHARACTER_PREFIX_INSTANCE = DASH_CHARACTER_PREFIX_INSTANCE;
19672
19940
  exports.DATE_NOW_VALUE = DATE_NOW_VALUE;
19673
19941
  exports.DAYS_IN_YEAR = DAYS_IN_YEAR;
19674
19942
  exports.DEFAULT_CUT_STRING_END_TEXT = DEFAULT_CUT_STRING_END_TEXT;
19943
+ exports.DEFAULT_ENCRYPTED_FIELD_PREFIX = DEFAULT_ENCRYPTED_FIELD_PREFIX;
19675
19944
  exports.DEFAULT_LAT_LNG_STRING_VALUE = DEFAULT_LAT_LNG_STRING_VALUE;
19676
19945
  exports.DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG = DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG;
19677
19946
  exports.DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG = DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG;
@@ -19701,6 +19970,7 @@ exports.GIF_MIME_TYPE = GIF_MIME_TYPE;
19701
19970
  exports.HAS_PORT_NUMBER_REGEX = HAS_PORT_NUMBER_REGEX;
19702
19971
  exports.HAS_WEBSITE_DOMAIN_NAME_REGEX = HAS_WEBSITE_DOMAIN_NAME_REGEX;
19703
19972
  exports.HEIF_MIME_TYPE = HEIF_MIME_TYPE;
19973
+ exports.HEX_PATTERN = HEX_PATTERN;
19704
19974
  exports.HOURS_IN_DAY = HOURS_IN_DAY;
19705
19975
  exports.HTML_MIME_TYPE = HTML_MIME_TYPE;
19706
19976
  exports.HTTP_OR_HTTPS_REGEX = HTTP_OR_HTTPS_REGEX;
@@ -19756,6 +20026,7 @@ exports.RAW_MIME_TYPE = RAW_MIME_TYPE;
19756
20026
  exports.REGEX_SPECIAL_CHARACTERS = REGEX_SPECIAL_CHARACTERS;
19757
20027
  exports.REGEX_SPECIAL_CHARACTERS_SET = REGEX_SPECIAL_CHARACTERS_SET;
19758
20028
  exports.RelationChange = RelationChange;
20029
+ exports.SECONDS_IN_HOUR = SECONDS_IN_HOUR;
19759
20030
  exports.SECONDS_IN_MINUTE = SECONDS_IN_MINUTE;
19760
20031
  exports.SHARED_MEMORY_STORAGE = SHARED_MEMORY_STORAGE;
19761
20032
  exports.SLASH_PATH_FILE_TYPE_SEPARATOR = SLASH_PATH_FILE_TYPE_SEPARATOR;
@@ -19764,6 +20035,7 @@ exports.SORT_VALUE_EQUAL = SORT_VALUE_EQUAL;
19764
20035
  exports.SORT_VALUE_GREATER_THAN = SORT_VALUE_GREATER_THAN;
19765
20036
  exports.SORT_VALUE_LESS_THAN = SORT_VALUE_LESS_THAN;
19766
20037
  exports.SPACE_JOINER = SPACE_JOINER;
20038
+ exports.SPACE_STRING_SPLIT_JOIN = SPACE_STRING_SPLIT_JOIN;
19767
20039
  exports.SPLIT_STRING_TREE_NODE_ROOT_VALUE = SPLIT_STRING_TREE_NODE_ROOT_VALUE;
19768
20040
  exports.SVG_MIME_TYPE = SVG_MIME_TYPE;
19769
20041
  exports.ServerErrorResponse = ServerErrorResponse;
@@ -19866,6 +20138,7 @@ exports.boundNumber = boundNumber;
19866
20138
  exports.boundNumberFunction = boundNumberFunction;
19867
20139
  exports.boundToRectangle = boundToRectangle;
19868
20140
  exports.breadthFirstExploreTreeTraversalFactoryFunction = breadthFirstExploreTreeTraversalFactoryFunction;
20141
+ exports.bufferHasValidPdfMarkings = bufferHasValidPdfMarkings;
19869
20142
  exports.build = build;
19870
20143
  exports.cachedGetter = cachedGetter;
19871
20144
  exports.calculateExpirationDate = calculateExpirationDate;
@@ -19936,6 +20209,7 @@ exports.decisionFunction = decisionFunction;
19936
20209
  exports.decodeHashedValues = decodeHashedValues;
19937
20210
  exports.decodeHashedValuesWithDecodeMap = decodeHashedValuesWithDecodeMap;
19938
20211
  exports.decodeModelKeyTypePair = decodeModelKeyTypePair;
20212
+ exports.decodeRadix36Number = decodeRadix36Number;
19939
20213
  exports.defaultFilterFromPOJOFunctionNoCopy = defaultFilterFromPOJOFunctionNoCopy;
19940
20214
  exports.defaultForwardFunctionFactory = defaultForwardFunctionFactory;
19941
20215
  exports.defaultLatLngPoint = defaultLatLngPoint;
@@ -19952,6 +20226,7 @@ exports.e164PhoneNumberFromE164PhoneNumberExtensionPair = e164PhoneNumberFromE16
19952
20226
  exports.enabledDaysFromDaysOfWeek = enabledDaysFromDaysOfWeek;
19953
20227
  exports.encodeBitwiseSet = encodeBitwiseSet;
19954
20228
  exports.encodeModelKeyTypePair = encodeModelKeyTypePair;
20229
+ exports.encodeRadix36Number = encodeRadix36Number;
19955
20230
  exports.errorMessageContainsString = errorMessageContainsString;
19956
20231
  exports.errorMessageContainsStringFunction = errorMessageContainsStringFunction;
19957
20232
  exports.escapeStringCharactersFunction = escapeStringCharactersFunction;
@@ -20118,6 +20393,7 @@ exports.isEvenNumber = isEvenNumber;
20118
20393
  exports.isFalseBooleanKeyArray = isFalseBooleanKeyArray;
20119
20394
  exports.isFinalPage = isFinalPage;
20120
20395
  exports.isGetter = isGetter;
20396
+ exports.isHex = isHex;
20121
20397
  exports.isISO8601DateString = isISO8601DateString;
20122
20398
  exports.isISO8601DayString = isISO8601DayString;
20123
20399
  exports.isISO8601DayStringStart = isISO8601DayStringStart;
@@ -20191,6 +20467,7 @@ exports.iterate = iterate;
20191
20467
  exports.iterateFilteredPages = iterateFilteredPages;
20192
20468
  exports.joinHostAndPort = joinHostAndPort;
20193
20469
  exports.joinStrings = joinStrings;
20470
+ exports.joinStringsInstance = joinStringsInstance;
20194
20471
  exports.joinStringsWithCommas = joinStringsWithCommas;
20195
20472
  exports.joinStringsWithSpaces = joinStringsWithSpaces;
20196
20473
  exports.keepCharactersAfterFirstCharacterOccurence = keepCharactersAfterFirstCharacterOccurence;
@@ -20450,6 +20727,7 @@ exports.safeEqualityComparatorFunction = safeEqualityComparatorFunction;
20450
20727
  exports.safeFindBestIndexMatch = safeFindBestIndexMatch;
20451
20728
  exports.searchStringFilterFunction = searchStringFilterFunction;
20452
20729
  exports.secondsToMinutesAndSeconds = secondsToMinutesAndSeconds;
20730
+ exports.selectiveFieldEncryptor = selectiveFieldEncryptor;
20453
20731
  exports.separateValues = separateValues;
20454
20732
  exports.separateValuesToSets = separateValuesToSets;
20455
20733
  exports.sequentialIncrementingNumberStringModelIdFactory = sequentialIncrementingNumberStringModelIdFactory;
@@ -20513,6 +20791,7 @@ exports.stringContains = stringContains;
20513
20791
  exports.stringFactoryFromFactory = stringFactoryFromFactory;
20514
20792
  exports.stringFromDateFactory = stringFromDateFactory;
20515
20793
  exports.stringFromTimeFactory = stringFromTimeFactory;
20794
+ exports.stringSplitJoinInstance = stringSplitJoinInstance;
20516
20795
  exports.stringToBoolean = stringToBoolean;
20517
20796
  exports.stringToLowercaseFunction = stringToLowercaseFunction;
20518
20797
  exports.stringToUppercaseFunction = stringToUppercaseFunction;