@feathersjs/client 5.0.23 → 5.0.24

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.0.24](https://github.com/feathersjs/feathers/compare/v5.0.23...v5.0.24) (2024-03-13)
7
+
8
+ **Note:** Version bump only for package @feathersjs/client
9
+
6
10
  ## [5.0.23](https://github.com/feathersjs/feathers/compare/v5.0.22...v5.0.23) (2024-02-25)
7
11
 
8
12
  ### Bug Fixes
package/dist/feathers.js CHANGED
@@ -4579,15 +4579,18 @@ var isArray = Array.isArray;
4579
4579
 
4580
4580
  var defaults = {
4581
4581
  allowDots: false,
4582
+ allowEmptyArrays: false,
4582
4583
  allowPrototypes: false,
4583
4584
  allowSparse: false,
4584
4585
  arrayLimit: 20,
4585
4586
  charset: 'utf-8',
4586
4587
  charsetSentinel: false,
4587
4588
  comma: false,
4589
+ decodeDotInKeys: true,
4588
4590
  decoder: utils.decode,
4589
4591
  delimiter: '&',
4590
4592
  depth: 5,
4593
+ duplicates: 'combine',
4591
4594
  ignoreQueryPrefix: false,
4592
4595
  interpretNumericEntities: false,
4593
4596
  parameterLimit: 1000,
@@ -4675,9 +4678,10 @@ var parseValues = function parseQueryStringValues(str, options) {
4675
4678
  val = isArray(val) ? [val] : val;
4676
4679
  }
4677
4680
 
4678
- if (has.call(obj, key)) {
4681
+ var existing = has.call(obj, key);
4682
+ if (existing && options.duplicates === 'combine') {
4679
4683
  obj[key] = utils.combine(obj[key], val);
4680
- } else {
4684
+ } else if (!existing || options.duplicates === 'last') {
4681
4685
  obj[key] = val;
4682
4686
  }
4683
4687
  }
@@ -4693,24 +4697,25 @@ var parseObject = function (chain, val, options, valuesParsed) {
4693
4697
  var root = chain[i];
4694
4698
 
4695
4699
  if (root === '[]' && options.parseArrays) {
4696
- obj = [].concat(leaf);
4700
+ obj = options.allowEmptyArrays && leaf === '' ? [] : [].concat(leaf);
4697
4701
  } else {
4698
4702
  obj = options.plainObjects ? Object.create(null) : {};
4699
4703
  var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
4700
- var index = parseInt(cleanRoot, 10);
4701
- if (!options.parseArrays && cleanRoot === '') {
4704
+ var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, '.') : cleanRoot;
4705
+ var index = parseInt(decodedRoot, 10);
4706
+ if (!options.parseArrays && decodedRoot === '') {
4702
4707
  obj = { 0: leaf };
4703
4708
  } else if (
4704
4709
  !isNaN(index)
4705
- && root !== cleanRoot
4706
- && String(index) === cleanRoot
4710
+ && root !== decodedRoot
4711
+ && String(index) === decodedRoot
4707
4712
  && index >= 0
4708
4713
  && (options.parseArrays && index <= options.arrayLimit)
4709
4714
  ) {
4710
4715
  obj = [];
4711
4716
  obj[index] = leaf;
4712
- } else if (cleanRoot !== '__proto__') {
4713
- obj[cleanRoot] = leaf;
4717
+ } else if (decodedRoot !== '__proto__') {
4718
+ obj[decodedRoot] = leaf;
4714
4719
  }
4715
4720
  }
4716
4721
 
@@ -4779,7 +4784,15 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
4779
4784
  return defaults;
4780
4785
  }
4781
4786
 
4782
- if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
4787
+ if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
4788
+ throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
4789
+ }
4790
+
4791
+ if (typeof opts.decodeDotInKeys !== 'undefined' && typeof opts.decodeDotInKeys !== 'boolean') {
4792
+ throw new TypeError('`decodeDotInKeys` option can only be `true` or `false`, when provided');
4793
+ }
4794
+
4795
+ if (opts.decoder !== null && typeof opts.decoder !== 'undefined' && typeof opts.decoder !== 'function') {
4783
4796
  throw new TypeError('Decoder has to be a function.');
4784
4797
  }
4785
4798
 
@@ -4788,18 +4801,29 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
4788
4801
  }
4789
4802
  var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
4790
4803
 
4804
+ var duplicates = typeof opts.duplicates === 'undefined' ? defaults.duplicates : opts.duplicates;
4805
+
4806
+ if (duplicates !== 'combine' && duplicates !== 'first' && duplicates !== 'last') {
4807
+ throw new TypeError('The duplicates option must be either combine, first, or last');
4808
+ }
4809
+
4810
+ var allowDots = typeof opts.allowDots === 'undefined' ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
4811
+
4791
4812
  return {
4792
- allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
4813
+ allowDots: allowDots,
4814
+ allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
4793
4815
  allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
4794
4816
  allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
4795
4817
  arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
4796
4818
  charset: charset,
4797
4819
  charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
4798
4820
  comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
4821
+ decodeDotInKeys: typeof opts.decodeDotInKeys === 'boolean' ? opts.decodeDotInKeys : defaults.decodeDotInKeys,
4799
4822
  decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
4800
4823
  delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
4801
4824
  // eslint-disable-next-line no-implicit-coercion, no-extra-parens
4802
4825
  depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
4826
+ duplicates: duplicates,
4803
4827
  ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
4804
4828
  interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
4805
4829
  parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
@@ -4877,10 +4901,13 @@ var defaultFormat = formats['default'];
4877
4901
  var defaults = {
4878
4902
  addQueryPrefix: false,
4879
4903
  allowDots: false,
4904
+ allowEmptyArrays: false,
4905
+ arrayFormat: 'indices',
4880
4906
  charset: 'utf-8',
4881
4907
  charsetSentinel: false,
4882
4908
  delimiter: '&',
4883
4909
  encode: true,
4910
+ encodeDotInKeys: false,
4884
4911
  encoder: utils.encode,
4885
4912
  encodeValuesOnly: false,
4886
4913
  format: defaultFormat,
@@ -4909,8 +4936,10 @@ var stringify = function stringify(
4909
4936
  prefix,
4910
4937
  generateArrayPrefix,
4911
4938
  commaRoundTrip,
4939
+ allowEmptyArrays,
4912
4940
  strictNullHandling,
4913
4941
  skipNulls,
4942
+ encodeDotInKeys,
4914
4943
  encoder,
4915
4944
  filter,
4916
4945
  sort,
@@ -4992,7 +5021,13 @@ var stringify = function stringify(
4992
5021
  objKeys = sort ? keys.sort(sort) : keys;
4993
5022
  }
4994
5023
 
4995
- var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix;
5024
+ var encodedPrefix = encodeDotInKeys ? prefix.replace(/\./g, '%2E') : prefix;
5025
+
5026
+ var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + '[]' : encodedPrefix;
5027
+
5028
+ if (allowEmptyArrays && isArray(obj) && obj.length === 0) {
5029
+ return adjustedPrefix + '[]';
5030
+ }
4996
5031
 
4997
5032
  for (var j = 0; j < objKeys.length; ++j) {
4998
5033
  var key = objKeys[j];
@@ -5002,9 +5037,10 @@ var stringify = function stringify(
5002
5037
  continue;
5003
5038
  }
5004
5039
 
5040
+ var encodedKey = allowDots && encodeDotInKeys ? key.replace(/\./g, '%2E') : key;
5005
5041
  var keyPrefix = isArray(obj)
5006
- ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
5007
- : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
5042
+ ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix
5043
+ : adjustedPrefix + (allowDots ? '.' + encodedKey : '[' + encodedKey + ']');
5008
5044
 
5009
5045
  sideChannel.set(object, step);
5010
5046
  var valueSideChannel = getSideChannel();
@@ -5014,8 +5050,10 @@ var stringify = function stringify(
5014
5050
  keyPrefix,
5015
5051
  generateArrayPrefix,
5016
5052
  commaRoundTrip,
5053
+ allowEmptyArrays,
5017
5054
  strictNullHandling,
5018
5055
  skipNulls,
5056
+ encodeDotInKeys,
5019
5057
  generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder,
5020
5058
  filter,
5021
5059
  sort,
@@ -5037,6 +5075,14 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
5037
5075
  return defaults;
5038
5076
  }
5039
5077
 
5078
+ if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
5079
+ throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
5080
+ }
5081
+
5082
+ if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') {
5083
+ throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided');
5084
+ }
5085
+
5040
5086
  if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
5041
5087
  throw new TypeError('Encoder has to be a function.');
5042
5088
  }
@@ -5060,13 +5106,32 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
5060
5106
  filter = opts.filter;
5061
5107
  }
5062
5108
 
5109
+ var arrayFormat;
5110
+ if (opts.arrayFormat in arrayPrefixGenerators) {
5111
+ arrayFormat = opts.arrayFormat;
5112
+ } else if ('indices' in opts) {
5113
+ arrayFormat = opts.indices ? 'indices' : 'repeat';
5114
+ } else {
5115
+ arrayFormat = defaults.arrayFormat;
5116
+ }
5117
+
5118
+ if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
5119
+ throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
5120
+ }
5121
+
5122
+ var allowDots = typeof opts.allowDots === 'undefined' ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
5123
+
5063
5124
  return {
5064
5125
  addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
5065
- allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
5126
+ allowDots: allowDots,
5127
+ allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
5128
+ arrayFormat: arrayFormat,
5066
5129
  charset: charset,
5067
5130
  charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
5131
+ commaRoundTrip: opts.commaRoundTrip,
5068
5132
  delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
5069
5133
  encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
5134
+ encodeDotInKeys: typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
5070
5135
  encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
5071
5136
  encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
5072
5137
  filter: filter,
@@ -5100,20 +5165,8 @@ module.exports = function (object, opts) {
5100
5165
  return '';
5101
5166
  }
5102
5167
 
5103
- var arrayFormat;
5104
- if (opts && opts.arrayFormat in arrayPrefixGenerators) {
5105
- arrayFormat = opts.arrayFormat;
5106
- } else if (opts && 'indices' in opts) {
5107
- arrayFormat = opts.indices ? 'indices' : 'repeat';
5108
- } else {
5109
- arrayFormat = 'indices';
5110
- }
5111
-
5112
- var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
5113
- if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
5114
- throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
5115
- }
5116
- var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
5168
+ var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
5169
+ var commaRoundTrip = generateArrayPrefix === 'comma' && options.commaRoundTrip;
5117
5170
 
5118
5171
  if (!objKeys) {
5119
5172
  objKeys = Object.keys(obj);
@@ -5135,8 +5188,10 @@ module.exports = function (object, opts) {
5135
5188
  key,
5136
5189
  generateArrayPrefix,
5137
5190
  commaRoundTrip,
5191
+ options.allowEmptyArrays,
5138
5192
  options.strictNullHandling,
5139
5193
  options.skipNulls,
5194
+ options.encodeDotInKeys,
5140
5195
  options.encode ? options.encoder : null,
5141
5196
  options.filter,
5142
5197
  options.sort,
@@ -5449,9 +5504,7 @@ var gOPD = __webpack_require__(/*! gopd */ "../../node_modules/gopd/index.js");
5449
5504
  var $TypeError = __webpack_require__(/*! es-errors/type */ "../../node_modules/es-errors/type.js");
5450
5505
  var $floor = GetIntrinsic('%Math.floor%');
5451
5506
 
5452
- /** @typedef {(...args: unknown[]) => unknown} Func */
5453
-
5454
- /** @type {<T extends Func = Func>(fn: T, length: number, loose?: boolean) => T} */
5507
+ /** @type {import('.')} */
5455
5508
  module.exports = function setFunctionLength(fn, length) {
5456
5509
  if (typeof fn !== 'function') {
5457
5510
  throw new $TypeError('`fn` is not a function');
@@ -5516,42 +5569,54 @@ var $mapHas = callBound('Map.prototype.has', true);
5516
5569
  *
5517
5570
  * That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. By doing so, all the recently used nodes can be accessed relatively quickly.
5518
5571
  */
5572
+ /** @type {import('.').listGetNode} */
5519
5573
  var listGetNode = function (list, key) { // eslint-disable-line consistent-return
5520
- for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
5574
+ /** @type {typeof list | NonNullable<(typeof list)['next']>} */
5575
+ var prev = list;
5576
+ /** @type {(typeof list)['next']} */
5577
+ var curr;
5578
+ for (; (curr = prev.next) !== null; prev = curr) {
5521
5579
  if (curr.key === key) {
5522
5580
  prev.next = curr.next;
5523
- curr.next = list.next;
5581
+ // eslint-disable-next-line no-extra-parens
5582
+ curr.next = /** @type {NonNullable<typeof list.next>} */ (list.next);
5524
5583
  list.next = curr; // eslint-disable-line no-param-reassign
5525
5584
  return curr;
5526
5585
  }
5527
5586
  }
5528
5587
  };
5529
5588
 
5589
+ /** @type {import('.').listGet} */
5530
5590
  var listGet = function (objects, key) {
5531
5591
  var node = listGetNode(objects, key);
5532
5592
  return node && node.value;
5533
5593
  };
5594
+ /** @type {import('.').listSet} */
5534
5595
  var listSet = function (objects, key, value) {
5535
5596
  var node = listGetNode(objects, key);
5536
5597
  if (node) {
5537
5598
  node.value = value;
5538
5599
  } else {
5539
5600
  // Prepend the new node to the beginning of the list
5540
- objects.next = { // eslint-disable-line no-param-reassign
5601
+ objects.next = /** @type {import('.').ListNode<typeof value>} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens
5541
5602
  key: key,
5542
5603
  next: objects.next,
5543
5604
  value: value
5544
- };
5605
+ });
5545
5606
  }
5546
5607
  };
5608
+ /** @type {import('.').listHas} */
5547
5609
  var listHas = function (objects, key) {
5548
5610
  return !!listGetNode(objects, key);
5549
5611
  };
5550
5612
 
5613
+ /** @type {import('.')} */
5551
5614
  module.exports = function getSideChannel() {
5552
- var $wm;
5553
- var $m;
5554
- var $o;
5615
+ /** @type {WeakMap<object, unknown>} */ var $wm;
5616
+ /** @type {Map<object, unknown>} */ var $m;
5617
+ /** @type {import('.').RootNode<unknown>} */ var $o;
5618
+
5619
+ /** @type {import('.').Channel} */
5555
5620
  var channel = {
5556
5621
  assert: function (key) {
5557
5622
  if (!channel.has(key)) {