@magda/org-tree 2.0.0-alpha.0 → 2.0.0-alpha.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.
@@ -621,14 +621,15 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
621
621
  var undefined;
622
622
 
623
623
  /** Used as the semantic version number. */
624
- var VERSION = '4.17.15';
624
+ var VERSION = '4.17.21';
625
625
 
626
626
  /** Used as the size to enable large array optimizations. */
627
627
  var LARGE_ARRAY_SIZE = 200;
628
628
 
629
629
  /** Error message constants. */
630
630
  var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
631
- FUNC_ERROR_TEXT = 'Expected a function';
631
+ FUNC_ERROR_TEXT = 'Expected a function',
632
+ INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
632
633
 
633
634
  /** Used to stand-in for `undefined` hash values. */
634
635
  var HASH_UNDEFINED = '__lodash_hash_undefined__';
@@ -761,10 +762,11 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
761
762
  var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
762
763
  reHasRegExpChar = RegExp(reRegExpChar.source);
763
764
 
764
- /** Used to match leading and trailing whitespace. */
765
- var reTrim = /^\s+|\s+$/g,
766
- reTrimStart = /^\s+/,
767
- reTrimEnd = /\s+$/;
765
+ /** Used to match leading whitespace. */
766
+ var reTrimStart = /^\s+/;
767
+
768
+ /** Used to match a single whitespace character. */
769
+ var reWhitespace = /\s/;
768
770
 
769
771
  /** Used to match wrap detail comments. */
770
772
  var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
@@ -774,6 +776,18 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
774
776
  /** Used to match words composed of alphanumeric characters. */
775
777
  var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
776
778
 
779
+ /**
780
+ * Used to validate the `validate` option in `_.template` variable.
781
+ *
782
+ * Forbids characters which could potentially change the meaning of the function argument definition:
783
+ * - "()," (modification of function parameters)
784
+ * - "=" (default value)
785
+ * - "[]{}" (destructuring of function parameters)
786
+ * - "/" (beginning of a comment)
787
+ * - whitespace
788
+ */
789
+ var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
790
+
777
791
  /** Used to match backslashes in property paths. */
778
792
  var reEscapeChar = /\\(\\)?/g;
779
793
 
@@ -1602,6 +1616,19 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
1602
1616
  });
1603
1617
  }
1604
1618
 
1619
+ /**
1620
+ * The base implementation of `_.trim`.
1621
+ *
1622
+ * @private
1623
+ * @param {string} string The string to trim.
1624
+ * @returns {string} Returns the trimmed string.
1625
+ */
1626
+ function baseTrim(string) {
1627
+ return string
1628
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
1629
+ : string;
1630
+ }
1631
+
1605
1632
  /**
1606
1633
  * The base implementation of `_.unary` without support for storing metadata.
1607
1634
  *
@@ -1935,6 +1962,21 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
1935
1962
  : asciiToArray(string);
1936
1963
  }
1937
1964
 
1965
+ /**
1966
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
1967
+ * character of `string`.
1968
+ *
1969
+ * @private
1970
+ * @param {string} string The string to inspect.
1971
+ * @returns {number} Returns the index of the last non-whitespace character.
1972
+ */
1973
+ function trimmedEndIndex(string) {
1974
+ var index = string.length;
1975
+
1976
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
1977
+ return index;
1978
+ }
1979
+
1938
1980
  /**
1939
1981
  * Used by `_.unescape` to convert HTML entities to characters.
1940
1982
  *
@@ -4328,8 +4370,21 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
4328
4370
  * @returns {Array} Returns the new sorted array.
4329
4371
  */
4330
4372
  function baseOrderBy(collection, iteratees, orders) {
4373
+ if (iteratees.length) {
4374
+ iteratees = arrayMap(iteratees, function(iteratee) {
4375
+ if (isArray(iteratee)) {
4376
+ return function(value) {
4377
+ return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee);
4378
+ }
4379
+ }
4380
+ return iteratee;
4381
+ });
4382
+ } else {
4383
+ iteratees = [identity];
4384
+ }
4385
+
4331
4386
  var index = -1;
4332
- iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
4387
+ iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
4333
4388
 
4334
4389
  var result = baseMap(collection, function(value, key, collection) {
4335
4390
  var criteria = arrayMap(iteratees, function(iteratee) {
@@ -4586,6 +4641,10 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
4586
4641
  var key = toKey(path[index]),
4587
4642
  newValue = value;
4588
4643
 
4644
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
4645
+ return object;
4646
+ }
4647
+
4589
4648
  if (index != lastIndex) {
4590
4649
  var objValue = nested[key];
4591
4650
  newValue = customizer ? customizer(objValue, key, nested) : undefined;
@@ -4738,11 +4797,14 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
4738
4797
  * into `array`.
4739
4798
  */
4740
4799
  function baseSortedIndexBy(array, value, iteratee, retHighest) {
4741
- value = iteratee(value);
4742
-
4743
4800
  var low = 0,
4744
- high = array == null ? 0 : array.length,
4745
- valIsNaN = value !== value,
4801
+ high = array == null ? 0 : array.length;
4802
+ if (high === 0) {
4803
+ return 0;
4804
+ }
4805
+
4806
+ value = iteratee(value);
4807
+ var valIsNaN = value !== value,
4746
4808
  valIsNull = value === null,
4747
4809
  valIsSymbol = isSymbol(value),
4748
4810
  valIsUndefined = value === undefined;
@@ -6227,10 +6289,11 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
6227
6289
  if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
6228
6290
  return false;
6229
6291
  }
6230
- // Assume cyclic values are equal.
6231
- var stacked = stack.get(array);
6232
- if (stacked && stack.get(other)) {
6233
- return stacked == other;
6292
+ // Check that cyclic values are equal.
6293
+ var arrStacked = stack.get(array);
6294
+ var othStacked = stack.get(other);
6295
+ if (arrStacked && othStacked) {
6296
+ return arrStacked == other && othStacked == array;
6234
6297
  }
6235
6298
  var index = -1,
6236
6299
  result = true,
@@ -6392,10 +6455,11 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
6392
6455
  return false;
6393
6456
  }
6394
6457
  }
6395
- // Assume cyclic values are equal.
6396
- var stacked = stack.get(object);
6397
- if (stacked && stack.get(other)) {
6398
- return stacked == other;
6458
+ // Check that cyclic values are equal.
6459
+ var objStacked = stack.get(object);
6460
+ var othStacked = stack.get(other);
6461
+ if (objStacked && othStacked) {
6462
+ return objStacked == other && othStacked == object;
6399
6463
  }
6400
6464
  var result = true;
6401
6465
  stack.set(object, other);
@@ -9776,6 +9840,10 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
9776
9840
  * // The `_.property` iteratee shorthand.
9777
9841
  * _.filter(users, 'active');
9778
9842
  * // => objects for ['barney']
9843
+ *
9844
+ * // Combining several predicates using `_.overEvery` or `_.overSome`.
9845
+ * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]]));
9846
+ * // => objects for ['fred', 'barney']
9779
9847
  */
9780
9848
  function filter(collection, predicate) {
9781
9849
  var func = isArray(collection) ? arrayFilter : baseFilter;
@@ -10525,15 +10593,15 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
10525
10593
  * var users = [
10526
10594
  * { 'user': 'fred', 'age': 48 },
10527
10595
  * { 'user': 'barney', 'age': 36 },
10528
- * { 'user': 'fred', 'age': 40 },
10596
+ * { 'user': 'fred', 'age': 30 },
10529
10597
  * { 'user': 'barney', 'age': 34 }
10530
10598
  * ];
10531
10599
  *
10532
10600
  * _.sortBy(users, [function(o) { return o.user; }]);
10533
- * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
10601
+ * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]]
10534
10602
  *
10535
10603
  * _.sortBy(users, ['user', 'age']);
10536
- * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
10604
+ * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
10537
10605
  */
10538
10606
  var sortBy = baseRest(function(collection, iteratees) {
10539
10607
  if (collection == null) {
@@ -13077,7 +13145,7 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
13077
13145
  if (typeof value != 'string') {
13078
13146
  return value === 0 ? value : +value;
13079
13147
  }
13080
- value = value.replace(reTrim, '');
13148
+ value = baseTrim(value);
13081
13149
  var isBinary = reIsBinary.test(value);
13082
13150
  return (isBinary || reIsOctal.test(value))
13083
13151
  ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
@@ -15408,11 +15476,11 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
15408
15476
 
15409
15477
  // Use a sourceURL for easier debugging.
15410
15478
  // The sourceURL gets injected into the source that's eval-ed, so be careful
15411
- // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
15412
- // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
15479
+ // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
15480
+ // and escape the comment, thus injecting code that gets evaled.
15413
15481
  var sourceURL = '//# sourceURL=' +
15414
15482
  (hasOwnProperty.call(options, 'sourceURL')
15415
- ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
15483
+ ? (options.sourceURL + '').replace(/\s/g, ' ')
15416
15484
  : ('lodash.templateSources[' + (++templateCounter) + ']')
15417
15485
  ) + '\n';
15418
15486
 
@@ -15445,12 +15513,16 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
15445
15513
 
15446
15514
  // If `variable` is not specified wrap a with-statement around the generated
15447
15515
  // code to add the data object to the top of the scope chain.
15448
- // Like with sourceURL, we take care to not check the option's prototype,
15449
- // as this configuration is a code injection vector.
15450
15516
  var variable = hasOwnProperty.call(options, 'variable') && options.variable;
15451
15517
  if (!variable) {
15452
15518
  source = 'with (obj) {\n' + source + '\n}\n';
15453
15519
  }
15520
+ // Throw an error if a forbidden character was found in `variable`, to prevent
15521
+ // potential command injection attacks.
15522
+ else if (reForbiddenIdentifierChars.test(variable)) {
15523
+ throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
15524
+ }
15525
+
15454
15526
  // Cleanup code by stripping empty strings.
15455
15527
  source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
15456
15528
  .replace(reEmptyStringMiddle, '$1')
@@ -15564,7 +15636,7 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
15564
15636
  function trim(string, chars, guard) {
15565
15637
  string = toString(string);
15566
15638
  if (string && (guard || chars === undefined)) {
15567
- return string.replace(reTrim, '');
15639
+ return baseTrim(string);
15568
15640
  }
15569
15641
  if (!string || !(chars = baseToString(chars))) {
15570
15642
  return string;
@@ -15599,7 +15671,7 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
15599
15671
  function trimEnd(string, chars, guard) {
15600
15672
  string = toString(string);
15601
15673
  if (string && (guard || chars === undefined)) {
15602
- return string.replace(reTrimEnd, '');
15674
+ return string.slice(0, trimmedEndIndex(string) + 1);
15603
15675
  }
15604
15676
  if (!string || !(chars = baseToString(chars))) {
15605
15677
  return string;
@@ -16153,6 +16225,9 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16153
16225
  * values against any array or object value, respectively. See `_.isEqual`
16154
16226
  * for a list of supported value comparisons.
16155
16227
  *
16228
+ * **Note:** Multiple values can be checked by combining several matchers
16229
+ * using `_.overSome`
16230
+ *
16156
16231
  * @static
16157
16232
  * @memberOf _
16158
16233
  * @since 3.0.0
@@ -16168,6 +16243,10 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16168
16243
  *
16169
16244
  * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
16170
16245
  * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
16246
+ *
16247
+ * // Checking for several possible values
16248
+ * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
16249
+ * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
16171
16250
  */
16172
16251
  function matches(source) {
16173
16252
  return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
@@ -16182,6 +16261,9 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16182
16261
  * `srcValue` values against any array or object value, respectively. See
16183
16262
  * `_.isEqual` for a list of supported value comparisons.
16184
16263
  *
16264
+ * **Note:** Multiple values can be checked by combining several matchers
16265
+ * using `_.overSome`
16266
+ *
16185
16267
  * @static
16186
16268
  * @memberOf _
16187
16269
  * @since 3.2.0
@@ -16198,6 +16280,10 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16198
16280
  *
16199
16281
  * _.find(objects, _.matchesProperty('a', 4));
16200
16282
  * // => { 'a': 4, 'b': 5, 'c': 6 }
16283
+ *
16284
+ * // Checking for several possible values
16285
+ * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)]));
16286
+ * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
16201
16287
  */
16202
16288
  function matchesProperty(path, srcValue) {
16203
16289
  return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
@@ -16421,6 +16507,10 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16421
16507
  * Creates a function that checks if **all** of the `predicates` return
16422
16508
  * truthy when invoked with the arguments it receives.
16423
16509
  *
16510
+ * Following shorthands are possible for providing predicates.
16511
+ * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16512
+ * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16513
+ *
16424
16514
  * @static
16425
16515
  * @memberOf _
16426
16516
  * @since 4.0.0
@@ -16447,6 +16537,10 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16447
16537
  * Creates a function that checks if **any** of the `predicates` return
16448
16538
  * truthy when invoked with the arguments it receives.
16449
16539
  *
16540
+ * Following shorthands are possible for providing predicates.
16541
+ * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate.
16542
+ * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them.
16543
+ *
16450
16544
  * @static
16451
16545
  * @memberOf _
16452
16546
  * @since 4.0.0
@@ -16466,6 +16560,9 @@ function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName =
16466
16560
  *
16467
16561
  * func(NaN);
16468
16562
  * // => false
16563
+ *
16564
+ * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }])
16565
+ * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]])
16469
16566
  */
16470
16567
  var overSome = createOver(arraySome);
16471
16568
 
@@ -17799,7 +17896,7 @@ exports.escapeIdentifier = escapeIdentifier;
17799
17896
  function getTableColumnName(columnName, tableRef = "", useLowerCaseColumnName = false) {
17800
17897
  const id = [
17801
17898
  tableRef,
17802
- useLowerCaseColumnName ? columnName.toLowerCase : useLowerCaseColumnName
17899
+ useLowerCaseColumnName ? columnName.toLowerCase() : columnName
17803
17900
  ]
17804
17901
  .filter((item) => item)
17805
17902
  .join(".");
@@ -18046,7 +18143,7 @@ class AuthDecision {
18046
18143
  }
18047
18144
  }
18048
18145
  toSql(config) {
18049
- return sql_syntax_1.default.joinWithOr(this.toAspectQueryGroups(config.prefixes).map((item) => item.toSql(config)));
18146
+ return sql_syntax_1.default.joinWithOr(this.toAspectQueryGroups(config.prefixes).map((item) => item.toSql(config))).roundBracket();
18050
18147
  }
18051
18148
  }
18052
18149
  exports.default = AuthDecision;
@@ -18378,9 +18475,13 @@ class NestedSetModelQueryer {
18378
18475
  * @returns {Promise<NodeRecord[]>}
18379
18476
  * @memberof NestedSetModelQueryer
18380
18477
  */
18381
- getNodes(nodesQuery = {}, fields = null, client = null) {
18478
+ getNodes(nodesQuery = {}, fields = null, client = null, authDecision = AuthDecision_1.UnconditionalTrueDecision) {
18382
18479
  return __awaiter(this, void 0, void 0, function* () {
18480
+ const authConditions = authDecision.toSql({
18481
+ prefixes: ["input.authObject.orgUnit"] });
18482
+
18383
18483
  const clauses = [
18484
+ authConditions,
18384
18485
  nodesQuery.name ?
18385
18486
  sql_syntax_1.sqls`"name" = ${nodesQuery.name}` :
18386
18487
  sql_syntax_1.default.empty,
@@ -18421,7 +18522,7 @@ class NestedSetModelQueryer {
18421
18522
  }
18422
18523
  /**
18423
18524
  * Get the root node of the tree
18424
- * Return null if empty tree
18525
+ * Return null if empty tree or the user has no access to the root node
18425
18526
  *
18426
18527
  * @param {string[]} [fields=null] Selected Fields; If null, use this.defaultSelectFieldList
18427
18528
  * @param {pg.Client} [client=null] Optional pg client; Use supplied client connection for query rather than a random connection from Pool
@@ -18458,7 +18559,7 @@ class NestedSetModelQueryer {
18458
18559
  return __awaiter(this, void 0, void 0, function* () {
18459
18560
  const authConditions = authDecision.toSql({
18460
18561
  prefixes: ["input.authObject.orgUnit"],
18461
- tableRef: "Children" });
18562
+ tableRef: "children" });
18462
18563
 
18463
18564
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18464
18565
  const conditions = [
@@ -18491,7 +18592,7 @@ class NestedSetModelQueryer {
18491
18592
  return __awaiter(this, void 0, void 0, function* () {
18492
18593
  const authConditions = authDecision.toSql({
18493
18594
  prefixes: ["input.authObject.orgUnit"],
18494
- tableRef: "Parents" });
18595
+ tableRef: "parents" });
18495
18596
 
18496
18597
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18497
18598
  const conditions = [
@@ -18522,7 +18623,7 @@ class NestedSetModelQueryer {
18522
18623
  return __awaiter(this, void 0, void 0, function* () {
18523
18624
  const authConditions = authDecision.toSql({
18524
18625
  prefixes: ["input.authObject.orgUnit"],
18525
- tableRef: "Children" });
18626
+ tableRef: "children" });
18526
18627
 
18527
18628
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18528
18629
  const result = yield (client ? client : this.pool).query(...sql_syntax_1.sqls`SELECT ${this.selectFields("Children", fields)}
@@ -18556,7 +18657,7 @@ class NestedSetModelQueryer {
18556
18657
  return __awaiter(this, void 0, void 0, function* () {
18557
18658
  const authConditions = authDecision.toSql({
18558
18659
  prefixes: ["input.authObject.orgUnit"],
18559
- tableRef: "Parents" });
18660
+ tableRef: "parents" });
18560
18661
 
18561
18662
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18562
18663
  const result = yield (client ? client : this.pool).query(...sql_syntax_1.sqls`SELECT ${this.selectFields("Parents", fields)}
@@ -18618,7 +18719,7 @@ class NestedSetModelQueryer {
18618
18719
  return __awaiter(this, void 0, void 0, function* () {
18619
18720
  const authConditions = authDecision.toSql({
18620
18721
  prefixes: ["input.authObject.orgUnit"],
18621
- tableRef: "Parents" });
18722
+ tableRef: "parents" });
18622
18723
 
18623
18724
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18624
18725
  const result = yield this.pool.query(...sql_syntax_1.sqls`SELECT COUNT(Parents.id) AS level
@@ -18679,7 +18780,7 @@ class NestedSetModelQueryer {
18679
18780
  return __awaiter(this, void 0, void 0, function* () {
18680
18781
  const authConditions = authDecision.toSql({
18681
18782
  prefixes: ["input.authObject.orgUnit"],
18682
- tableRef: "Children" });
18783
+ tableRef: "children" });
18683
18784
 
18684
18785
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18685
18786
  const result = yield this.pool.query(...sql_syntax_1.sqls`SELECT ${this.selectFields("Children")}
@@ -18704,7 +18805,7 @@ class NestedSetModelQueryer {
18704
18805
  return __awaiter(this, void 0, void 0, function* () {
18705
18806
  const authConditions = authDecision.toSql({
18706
18807
  prefixes: ["input.authObject.orgUnit"],
18707
- tableRef: "Children" });
18808
+ tableRef: "children" });
18708
18809
 
18709
18810
  const tbl = SQLUtils_1.escapeIdentifier(this.tableName);
18710
18811
  const result = yield this.pool.query(...sql_syntax_1.sqls`SELECT ${this.selectFields("Children")}
@@ -18720,9 +18821,11 @@ class NestedSetModelQueryer {
18720
18821
  }
18721
18822
  /**
18722
18823
  * Get all nodes on the top to down path between the `higherNode` to the `lowerNode`
18723
- * Sort from higher level nodes to lower level node
18724
- * If a path doesn't exist, null will be returned
18725
- * If you pass a lower node to the `higherNodeId` and a higher node to `lowerNodeId`, null will be returned
18824
+ * Sort from higher level nodes to lower level node.
18825
+ * Result will include `higherNode` and the `lowerNode`.
18826
+ * If `higherNode` and the `lowerNode` is the same node, an array contains the single node will be return.
18827
+ * If a path doesn't exist, empty array (`[]`) will be returned
18828
+ * If you pass a lower node to the `higherNodeId` and a higher node to `lowerNodeId`, empty array will be returned
18726
18829
  *
18727
18830
  * @param {string} higherNodeId
18728
18831
  * @param {string} lowerNodeId
@@ -18730,6 +18833,7 @@ class NestedSetModelQueryer {
18730
18833
  * @memberof NestedSetModelQueryer
18731
18834
  */
18732
18835
  getTopDownPathBetween(higherNodeId, lowerNodeId, authDecision = AuthDecision_1.UnconditionalTrueDecision) {
18836
+ var _a;
18733
18837
  return __awaiter(this, void 0, void 0, function* () {
18734
18838
  const authConditions = authDecision.toSql({
18735
18839
  prefixes: ["input.authObject.orgUnit"],
@@ -18745,9 +18849,12 @@ class NestedSetModelQueryer {
18745
18849
  sql_syntax_1.default.empty :
18746
18850
  sql_syntax_1.sqls` AND ${authConditions}`}
18747
18851
  ORDER BY (t2.right-t2.left) DESC`.toQuery());
18748
- if (!result || !result.rows || !result.rows.length)
18749
- return tsmonad_1.Maybe.nothing();
18750
- return tsmonad_1.Maybe.just(result.rows);
18852
+ if (!((_a = result === null || result === void 0 ? void 0 : result.rows) === null || _a === void 0 ? void 0 : _a.length)) {
18853
+ return [];
18854
+ } else
18855
+ {
18856
+ return result.rows;
18857
+ }
18751
18858
  });
18752
18859
  }
18753
18860
  /**
@@ -19369,10 +19476,13 @@ class AspectQueryValue {
19369
19476
  switch (typeof value) {
19370
19477
  case "number":
19371
19478
  this.postgresType = sql_syntax_1.sqls `NUMERIC`;
19479
+ break;
19372
19480
  case "boolean":
19373
19481
  this.postgresType = sql_syntax_1.sqls `BOOL`;
19482
+ break;
19374
19483
  case "string":
19375
19484
  this.postgresType = sql_syntax_1.sqls `TEXT`;
19485
+ break;
19376
19486
  default:
19377
19487
  throw new Error("getPostgresValueTypeCastStr: unsupported data type: `${" +
19378
19488
  typeof value +
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": "2.0.0-alpha.0",
4
+ "version": "2.0.0-alpha.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": "^2.0.0-alpha.0",
18
- "@magda/scripts": "^2.0.0-alpha.0",
19
- "@magda/typescript-common": "^2.0.0-alpha.0",
17
+ "@magda/authorization-api": "^2.0.0-alpha.1",
18
+ "@magda/scripts": "^2.0.0-alpha.1",
19
+ "@magda/typescript-common": "^2.0.0-alpha.1",
20
20
  "fs-extra": "^2.1.2",
21
21
  "webpack": "^4.41.2",
22
22
  "webpack-cli": "^3.3.10"