@magda/org-tree 1.2.0 → 1.2.1

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.
@@ -1089,14 +1089,15 @@ exports.default = NestedSetModelQueryer;
1089
1089
  var undefined;
1090
1090
 
1091
1091
  /** Used as the semantic version number. */
1092
- var VERSION = '4.17.15';
1092
+ var VERSION = '4.17.21';
1093
1093
 
1094
1094
  /** Used as the size to enable large array optimizations. */
1095
1095
  var LARGE_ARRAY_SIZE = 200;
1096
1096
 
1097
1097
  /** Error message constants. */
1098
1098
  var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
1099
- FUNC_ERROR_TEXT = 'Expected a function';
1099
+ FUNC_ERROR_TEXT = 'Expected a function',
1100
+ INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
1100
1101
 
1101
1102
  /** Used to stand-in for `undefined` hash values. */
1102
1103
  var HASH_UNDEFINED = '__lodash_hash_undefined__';
@@ -1229,10 +1230,11 @@ exports.default = NestedSetModelQueryer;
1229
1230
  var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
1230
1231
  reHasRegExpChar = RegExp(reRegExpChar.source);
1231
1232
 
1232
- /** Used to match leading and trailing whitespace. */
1233
- var reTrim = /^\s+|\s+$/g,
1234
- reTrimStart = /^\s+/,
1235
- reTrimEnd = /\s+$/;
1233
+ /** Used to match leading whitespace. */
1234
+ var reTrimStart = /^\s+/;
1235
+
1236
+ /** Used to match a single whitespace character. */
1237
+ var reWhitespace = /\s/;
1236
1238
 
1237
1239
  /** Used to match wrap detail comments. */
1238
1240
  var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
@@ -1242,6 +1244,18 @@ exports.default = NestedSetModelQueryer;
1242
1244
  /** Used to match words composed of alphanumeric characters. */
1243
1245
  var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
1244
1246
 
1247
+ /**
1248
+ * Used to validate the `validate` option in `_.template` variable.
1249
+ *
1250
+ * Forbids characters which could potentially change the meaning of the function argument definition:
1251
+ * - "()," (modification of function parameters)
1252
+ * - "=" (default value)
1253
+ * - "[]{}" (destructuring of function parameters)
1254
+ * - "/" (beginning of a comment)
1255
+ * - whitespace
1256
+ */
1257
+ var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
1258
+
1245
1259
  /** Used to match backslashes in property paths. */
1246
1260
  var reEscapeChar = /\\(\\)?/g;
1247
1261
 
@@ -2070,6 +2084,19 @@ exports.default = NestedSetModelQueryer;
2070
2084
  });
2071
2085
  }
2072
2086
 
2087
+ /**
2088
+ * The base implementation of `_.trim`.
2089
+ *
2090
+ * @private
2091
+ * @param {string} string The string to trim.
2092
+ * @returns {string} Returns the trimmed string.
2093
+ */
2094
+ function baseTrim(string) {
2095
+ return string
2096
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
2097
+ : string;
2098
+ }
2099
+
2073
2100
  /**
2074
2101
  * The base implementation of `_.unary` without support for storing metadata.
2075
2102
  *
@@ -2403,6 +2430,21 @@ exports.default = NestedSetModelQueryer;
2403
2430
  : asciiToArray(string);
2404
2431
  }
2405
2432
 
2433
+ /**
2434
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
2435
+ * character of `string`.
2436
+ *
2437
+ * @private
2438
+ * @param {string} string The string to inspect.
2439
+ * @returns {number} Returns the index of the last non-whitespace character.
2440
+ */
2441
+ function trimmedEndIndex(string) {
2442
+ var index = string.length;
2443
+
2444
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
2445
+ return index;
2446
+ }
2447
+
2406
2448
  /**
2407
2449
  * Used by `_.unescape` to convert HTML entities to characters.
2408
2450
  *
@@ -4796,8 +4838,21 @@ exports.default = NestedSetModelQueryer;
4796
4838
  * @returns {Array} Returns the new sorted array.
4797
4839
  */
4798
4840
  function baseOrderBy(collection, iteratees, orders) {
4841
+ if (iteratees.length) {
4842
+ iteratees = arrayMap(iteratees, function(iteratee) {
4843
+ if (isArray(iteratee)) {
4844
+ return function(value) {
4845
+ return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
4846
+ }
4847
+ }
4848
+ return iteratee;
4849
+ });
4850
+ } else {
4851
+ iteratees = [identity];
4852
+ }
4853
+
4799
4854
  var index = -1;
4800
- iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
4855
+ iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
4801
4856
 
4802
4857
  var result = baseMap(collection, function(value, key, collection) {
4803
4858
  var criteria = arrayMap(iteratees, function(iteratee) {
@@ -5054,6 +5109,10 @@ exports.default = NestedSetModelQueryer;
5054
5109
  var key = toKey(path[index]),
5055
5110
  newValue = value;
5056
5111
 
5112
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
5113
+ return object;
5114
+ }
5115
+
5057
5116
  if (index != lastIndex) {
5058
5117
  var objValue = nested[key];
5059
5118
  newValue = customizer ? customizer(objValue, key, nested) : undefined;
@@ -5206,11 +5265,14 @@ exports.default = NestedSetModelQueryer;
5206
5265
  * into `array`.
5207
5266
  */
5208
5267
  function baseSortedIndexBy(array, value, iteratee, retHighest) {
5209
- value = iteratee(value);
5210
-
5211
5268
  var low = 0,
5212
- high = array == null ? 0 : array.length,
5213
- valIsNaN = value !== value,
5269
+ high = array == null ? 0 : array.length;
5270
+ if (high === 0) {
5271
+ return 0;
5272
+ }
5273
+
5274
+ value = iteratee(value);
5275
+ var valIsNaN = value !== value,
5214
5276
  valIsNull = value === null,
5215
5277
  valIsSymbol = isSymbol(value),
5216
5278
  valIsUndefined = value === undefined;
@@ -6695,10 +6757,11 @@ exports.default = NestedSetModelQueryer;
6695
6757
  if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
6696
6758
  return false;
6697
6759
  }
6698
- // Assume cyclic values are equal.
6699
- var stacked = stack.get(array);
6700
- if (stacked && stack.get(other)) {
6701
- return stacked == other;
6760
+ // Check that cyclic values are equal.
6761
+ var arrStacked = stack.get(array);
6762
+ var othStacked = stack.get(other);
6763
+ if (arrStacked && othStacked) {
6764
+ return arrStacked == other && othStacked == array;
6702
6765
  }
6703
6766
  var index = -1,
6704
6767
  result = true,
@@ -6860,10 +6923,11 @@ exports.default = NestedSetModelQueryer;
6860
6923
  return false;
6861
6924
  }
6862
6925
  }
6863
- // Assume cyclic values are equal.
6864
- var stacked = stack.get(object);
6865
- if (stacked && stack.get(other)) {
6866
- return stacked == other;
6926
+ // Check that cyclic values are equal.
6927
+ var objStacked = stack.get(object);
6928
+ var othStacked = stack.get(other);
6929
+ if (objStacked && othStacked) {
6930
+ return objStacked == other && othStacked == object;
6867
6931
  }
6868
6932
  var result = true;
6869
6933
  stack.set(object, other);
@@ -10244,6 +10308,10 @@ exports.default = NestedSetModelQueryer;
10244
10308
  * // The `_.property` iteratee shorthand.
10245
10309
  * _.filter(users, 'active');
10246
10310
  * // => objects for ['barney']
10311
+ *
10312
+ * // Combining several predicates using `_.overEvery` or `_.overSome`.
10313
+ * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
10314
+ * // => objects for ['fred', 'barney']
10247
10315
  */
10248
10316
  function filter(collection, predicate) {
10249
10317
  var func = isArray(collection) ? arrayFilter : baseFilter;
@@ -10993,15 +11061,15 @@ exports.default = NestedSetModelQueryer;
10993
11061
  * var users = [
10994
11062
  * { 'user': 'fred', 'age': 48 },
10995
11063
  * { 'user': 'barney', 'age': 36 },
10996
- * { 'user': 'fred', 'age': 40 },
11064
+ * { 'user': 'fred', 'age': 30 },
10997
11065
  * { 'user': 'barney', 'age': 34 }
10998
11066
  * ];
10999
11067
  *
11000
11068
  * _.sortBy(users, [function(o) { return o.user; }]);
11001
- * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
11069
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
11002
11070
  *
11003
11071
  * _.sortBy(users, ['user', 'age']);
11004
- * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
11072
+ * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
11005
11073
  */
11006
11074
  var sortBy = baseRest(function(collection, iteratees) {
11007
11075
  if (collection == null) {
@@ -13545,7 +13613,7 @@ exports.default = NestedSetModelQueryer;
13545
13613
  if (typeof value != 'string') {
13546
13614
  return value === 0 ? value : +value;
13547
13615
  }
13548
- value = value.replace(reTrim, '');
13616
+ value = baseTrim(value);
13549
13617
  var isBinary = reIsBinary.test(value);
13550
13618
  return (isBinary || reIsOctal.test(value))
13551
13619
  ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
@@ -15876,11 +15944,11 @@ exports.default = NestedSetModelQueryer;
15876
15944
 
15877
15945
  // Use a sourceURL for easier debugging.
15878
15946
  // The sourceURL gets injected into the source that's eval-ed, so be careful
15879
- // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
15880
- // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
15947
+ // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
15948
+ // and escape the comment, thus injecting code that gets evaled.
15881
15949
  var sourceURL = '//# sourceURL=' +
15882
15950
  (hasOwnProperty.call(options, 'sourceURL')
15883
- ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
15951
+ ? (options.sourceURL + '').replace(/\s/g, ' ')
15884
15952
  : ('lodash.templateSources[' + (++templateCounter) + ']')
15885
15953
  ) + '\n';
15886
15954
 
@@ -15913,12 +15981,16 @@ exports.default = NestedSetModelQueryer;
15913
15981
 
15914
15982
  // If `variable` is not specified wrap a with-statement around the generated
15915
15983
  // code to add the data object to the top of the scope chain.
15916
- // Like with sourceURL, we take care to not check the option's prototype,
15917
- // as this configuration is a code injection vector.
15918
15984
  var variable = hasOwnProperty.call(options, 'variable') && options.variable;
15919
15985
  if (!variable) {
15920
15986
  source = 'with (obj) {\n' + source + '\n}\n';
15921
15987
  }
15988
+ // Throw an error if a forbidden character was found in `variable`, to prevent
15989
+ // potential command injection attacks.
15990
+ else if (reForbiddenIdentifierChars.test(variable)) {
15991
+ throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
15992
+ }
15993
+
15922
15994
  // Cleanup code by stripping empty strings.
15923
15995
  source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
15924
15996
  .replace(reEmptyStringMiddle, '$1')
@@ -16032,7 +16104,7 @@ exports.default = NestedSetModelQueryer;
16032
16104
  function trim(string, chars, guard) {
16033
16105
  string = toString(string);
16034
16106
  if (string && (guard || chars === undefined)) {
16035
- return string.replace(reTrim, '');
16107
+ return baseTrim(string);
16036
16108
  }
16037
16109
  if (!string || !(chars = baseToString(chars))) {
16038
16110
  return string;
@@ -16067,7 +16139,7 @@ exports.default = NestedSetModelQueryer;
16067
16139
  function trimEnd(string, chars, guard) {
16068
16140
  string = toString(string);
16069
16141
  if (string && (guard || chars === undefined)) {
16070
- return string.replace(reTrimEnd, '');
16142
+ return string.slice(0, trimmedEndIndex(string) + 1);
16071
16143
  }
16072
16144
  if (!string || !(chars = baseToString(chars))) {
16073
16145
  return string;
@@ -16621,6 +16693,9 @@ exports.default = NestedSetModelQueryer;
16621
16693
  * values against any array or object value, respectively. See `_.isEqual`
16622
16694
  * for a list of supported value comparisons.
16623
16695
  *
16696
+ * **Note:** Multiple values can be checked by combining several matchers
16697
+ * using `_.overSome`
16698
+ *
16624
16699
  * @static
16625
16700
  * @memberOf _
16626
16701
  * @since 3.0.0
@@ -16636,6 +16711,10 @@ exports.default = NestedSetModelQueryer;
16636
16711
  *
16637
16712
  * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
16638
16713
  * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
16714
+ *
16715
+ * // Checking for several possible values
16716
+ * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
16717
+ * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
16639
16718
  */
16640
16719
  function matches(source) {
16641
16720
  return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
@@ -16650,6 +16729,9 @@ exports.default = NestedSetModelQueryer;
16650
16729
  * `srcValue` values against any array or object value, respectively. See
16651
16730
  * `_.isEqual` for a list of supported value comparisons.
16652
16731
  *
16732
+ * **Note:** Multiple values can be checked by combining several matchers
16733
+ * using `_.overSome`
16734
+ *
16653
16735
  * @static
16654
16736
  * @memberOf _
16655
16737
  * @since 3.2.0
@@ -16666,6 +16748,10 @@ exports.default = NestedSetModelQueryer;
16666
16748
  *
16667
16749
  * _.find(objects, _.matchesProperty('a', 4));
16668
16750
  * // => { 'a': 4, 'b': 5, 'c': 6 }
16751
+ *
16752
+ * // Checking for several possible values
16753
+ * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
16754
+ * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
16669
16755
  */
16670
16756
  function matchesProperty(path, srcValue) {
16671
16757
  return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
@@ -16889,6 +16975,10 @@ exports.default = NestedSetModelQueryer;
16889
16975
  * Creates a function that checks if **all** of the `predicates` return
16890
16976
  * truthy when invoked with the arguments it receives.
16891
16977
  *
16978
+ * Following shorthands are possible for providing predicates.
16979
+ * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16980
+ * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16981
+ *
16892
16982
  * @static
16893
16983
  * @memberOf _
16894
16984
  * @since 4.0.0
@@ -16915,6 +17005,10 @@ exports.default = NestedSetModelQueryer;
16915
17005
  * Creates a function that checks if **any** of the `predicates` return
16916
17006
  * truthy when invoked with the arguments it receives.
16917
17007
  *
17008
+ * Following shorthands are possible for providing predicates.
17009
+ * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
17010
+ * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
17011
+ *
16918
17012
  * @static
16919
17013
  * @memberOf _
16920
17014
  * @since 4.0.0
@@ -16934,6 +17028,9 @@ exports.default = NestedSetModelQueryer;
16934
17028
  *
16935
17029
  * func(NaN);
16936
17030
  * // => false
17031
+ *
17032
+ * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
17033
+ * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
16937
17034
  */
16938
17035
  var overSome = createOver(arraySome);
16939
17036
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@magda/org-tree",
3
3
  "description": "MAGDA Organizational Hierarchy Management Utilities",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "bin": {
6
6
  "org-tree": "./bin/org-tree/org-tree.js"
7
7
  },
@@ -14,9 +14,9 @@
14
14
  "author": "",
15
15
  "license": "Apache-2.0",
16
16
  "devDependencies": {
17
- "@magda/authorization-api": "^1.2.0",
18
- "@magda/scripts": "^1.2.0",
19
- "@magda/typescript-common": "^1.2.0",
17
+ "@magda/authorization-api": "^1.2.1",
18
+ "@magda/scripts": "^1.2.1",
19
+ "@magda/typescript-common": "^1.2.1",
20
20
  "fs-extra": "^2.1.2",
21
21
  "webpack": "^4.41.2",
22
22
  "webpack-cli": "^3.3.10"