@uipath/integrationservice-sdk 1.202.0-preview.142 → 1.202.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.
package/dist/index.js CHANGED
@@ -10449,7 +10449,7 @@ var init__Symbol = __esm(() => {
10449
10449
 
10450
10450
  // ../../node_modules/lodash-es/_getRawTag.js
10451
10451
  function getRawTag(value) {
10452
- var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
10452
+ var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
10453
10453
  try {
10454
10454
  value[symToStringTag] = undefined;
10455
10455
  var unmasked = true;
@@ -10464,11 +10464,11 @@ function getRawTag(value) {
10464
10464
  }
10465
10465
  return result;
10466
10466
  }
10467
- var objectProto, hasOwnProperty, nativeObjectToString, symToStringTag, _getRawTag_default;
10467
+ var objectProto, hasOwnProperty2, nativeObjectToString, symToStringTag, _getRawTag_default;
10468
10468
  var init__getRawTag = __esm(() => {
10469
10469
  init__Symbol();
10470
10470
  objectProto = Object.prototype;
10471
- hasOwnProperty = objectProto.hasOwnProperty;
10471
+ hasOwnProperty2 = objectProto.hasOwnProperty;
10472
10472
  nativeObjectToString = objectProto.toString;
10473
10473
  symToStringTag = _Symbol_default ? _Symbol_default.toStringTag : undefined;
10474
10474
  _getRawTag_default = getRawTag;
@@ -10575,7 +10575,7 @@ function baseIsNative(value) {
10575
10575
  var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
10576
10576
  return pattern.test(_toSource_default(value));
10577
10577
  }
10578
- var reRegExpChar, reIsHostCtor, funcProto2, objectProto3, funcToString2, hasOwnProperty2, reIsNative, _baseIsNative_default;
10578
+ var reRegExpChar, reIsHostCtor, funcProto2, objectProto3, funcToString2, hasOwnProperty3, reIsNative, _baseIsNative_default;
10579
10579
  var init__baseIsNative = __esm(() => {
10580
10580
  init_isFunction();
10581
10581
  init__isMasked();
@@ -10586,8 +10586,8 @@ var init__baseIsNative = __esm(() => {
10586
10586
  funcProto2 = Function.prototype;
10587
10587
  objectProto3 = Object.prototype;
10588
10588
  funcToString2 = funcProto2.toString;
10589
- hasOwnProperty2 = objectProto3.hasOwnProperty;
10590
- reIsNative = RegExp("^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
10589
+ hasOwnProperty3 = objectProto3.hasOwnProperty;
10590
+ reIsNative = RegExp("^" + funcToString2.call(hasOwnProperty3).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
10591
10591
  _baseIsNative_default = baseIsNative;
10592
10592
  });
10593
10593
 
@@ -10649,26 +10649,26 @@ function hashGet(key) {
10649
10649
  var result = data[key];
10650
10650
  return result === HASH_UNDEFINED ? undefined : result;
10651
10651
  }
10652
- return hasOwnProperty3.call(data, key) ? data[key] : undefined;
10652
+ return hasOwnProperty4.call(data, key) ? data[key] : undefined;
10653
10653
  }
10654
- var HASH_UNDEFINED = "__lodash_hash_undefined__", objectProto4, hasOwnProperty3, _hashGet_default;
10654
+ var HASH_UNDEFINED = "__lodash_hash_undefined__", objectProto4, hasOwnProperty4, _hashGet_default;
10655
10655
  var init__hashGet = __esm(() => {
10656
10656
  init__nativeCreate();
10657
10657
  objectProto4 = Object.prototype;
10658
- hasOwnProperty3 = objectProto4.hasOwnProperty;
10658
+ hasOwnProperty4 = objectProto4.hasOwnProperty;
10659
10659
  _hashGet_default = hashGet;
10660
10660
  });
10661
10661
 
10662
10662
  // ../../node_modules/lodash-es/_hashHas.js
10663
10663
  function hashHas(key) {
10664
10664
  var data = this.__data__;
10665
- return _nativeCreate_default ? data[key] !== undefined : hasOwnProperty4.call(data, key);
10665
+ return _nativeCreate_default ? data[key] !== undefined : hasOwnProperty5.call(data, key);
10666
10666
  }
10667
- var objectProto5, hasOwnProperty4, _hashHas_default;
10667
+ var objectProto5, hasOwnProperty5, _hashHas_default;
10668
10668
  var init__hashHas = __esm(() => {
10669
10669
  init__nativeCreate();
10670
10670
  objectProto5 = Object.prototype;
10671
- hasOwnProperty4 = objectProto5.hasOwnProperty;
10671
+ hasOwnProperty5 = objectProto5.hasOwnProperty;
10672
10672
  _hashHas_default = hashHas;
10673
10673
  });
10674
10674
 
@@ -11172,17 +11172,17 @@ var init__baseIsArguments = __esm(() => {
11172
11172
  });
11173
11173
 
11174
11174
  // ../../node_modules/lodash-es/isArguments.js
11175
- var objectProto6, hasOwnProperty5, propertyIsEnumerable, isArguments, isArguments_default;
11175
+ var objectProto6, hasOwnProperty6, propertyIsEnumerable, isArguments, isArguments_default;
11176
11176
  var init_isArguments = __esm(() => {
11177
11177
  init__baseIsArguments();
11178
11178
  init_isObjectLike();
11179
11179
  objectProto6 = Object.prototype;
11180
- hasOwnProperty5 = objectProto6.hasOwnProperty;
11180
+ hasOwnProperty6 = objectProto6.hasOwnProperty;
11181
11181
  propertyIsEnumerable = objectProto6.propertyIsEnumerable;
11182
11182
  isArguments = _baseIsArguments_default(function() {
11183
11183
  return arguments;
11184
11184
  }()) ? _baseIsArguments_default : function(value) {
11185
- return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
11185
+ return isObjectLike_default(value) && hasOwnProperty6.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
11186
11186
  };
11187
11187
  isArguments_default = isArguments;
11188
11188
  });
@@ -11818,13 +11818,13 @@ var init_isTypedArray = __esm(() => {
11818
11818
  function arrayLikeKeys(value, inherited) {
11819
11819
  var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? _baseTimes_default(value.length, String) : [], length = result.length;
11820
11820
  for (var key in value) {
11821
- if ((inherited || hasOwnProperty6.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || _isIndex_default(key, length)))) {
11821
+ if ((inherited || hasOwnProperty7.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || _isIndex_default(key, length)))) {
11822
11822
  result.push(key);
11823
11823
  }
11824
11824
  }
11825
11825
  return result;
11826
11826
  }
11827
- var objectProto7, hasOwnProperty6, _arrayLikeKeys_default;
11827
+ var objectProto7, hasOwnProperty7, _arrayLikeKeys_default;
11828
11828
  var init__arrayLikeKeys = __esm(() => {
11829
11829
  init__baseTimes();
11830
11830
  init_isArguments();
@@ -11833,7 +11833,7 @@ var init__arrayLikeKeys = __esm(() => {
11833
11833
  init__isIndex();
11834
11834
  init_isTypedArray();
11835
11835
  objectProto7 = Object.prototype;
11836
- hasOwnProperty6 = objectProto7.hasOwnProperty;
11836
+ hasOwnProperty7 = objectProto7.hasOwnProperty;
11837
11837
  _arrayLikeKeys_default = arrayLikeKeys;
11838
11838
  });
11839
11839
 
@@ -11874,18 +11874,18 @@ function baseKeys(object) {
11874
11874
  }
11875
11875
  var result = [];
11876
11876
  for (var key in Object(object)) {
11877
- if (hasOwnProperty7.call(object, key) && key != "constructor") {
11877
+ if (hasOwnProperty8.call(object, key) && key != "constructor") {
11878
11878
  result.push(key);
11879
11879
  }
11880
11880
  }
11881
11881
  return result;
11882
11882
  }
11883
- var objectProto9, hasOwnProperty7, _baseKeys_default;
11883
+ var objectProto9, hasOwnProperty8, _baseKeys_default;
11884
11884
  var init__baseKeys = __esm(() => {
11885
11885
  init__isPrototype();
11886
11886
  init__nativeKeys();
11887
11887
  objectProto9 = Object.prototype;
11888
- hasOwnProperty7 = objectProto9.hasOwnProperty;
11888
+ hasOwnProperty8 = objectProto9.hasOwnProperty;
11889
11889
  _baseKeys_default = baseKeys;
11890
11890
  });
11891
11891
 
@@ -12282,7 +12282,7 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
12282
12282
  var index = objLength;
12283
12283
  while (index--) {
12284
12284
  var key = objProps[index];
12285
- if (!(isPartial ? key in other : hasOwnProperty8.call(other, key))) {
12285
+ if (!(isPartial ? key in other : hasOwnProperty9.call(other, key))) {
12286
12286
  return false;
12287
12287
  }
12288
12288
  }
@@ -12317,11 +12317,11 @@ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
12317
12317
  stack["delete"](other);
12318
12318
  return result;
12319
12319
  }
12320
- var COMPARE_PARTIAL_FLAG3 = 1, objectProto11, hasOwnProperty8, _equalObjects_default;
12320
+ var COMPARE_PARTIAL_FLAG3 = 1, objectProto11, hasOwnProperty9, _equalObjects_default;
12321
12321
  var init__equalObjects = __esm(() => {
12322
12322
  init__getAllKeys();
12323
12323
  objectProto11 = Object.prototype;
12324
- hasOwnProperty8 = objectProto11.hasOwnProperty;
12324
+ hasOwnProperty9 = objectProto11.hasOwnProperty;
12325
12325
  _equalObjects_default = equalObjects;
12326
12326
  });
12327
12327
 
@@ -12418,7 +12418,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
12418
12418
  return objIsArr || isTypedArray_default(object) ? _equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : _equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
12419
12419
  }
12420
12420
  if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
12421
- var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other, "__wrapped__");
12421
+ var objIsWrapped = objIsObj && hasOwnProperty10.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty10.call(other, "__wrapped__");
12422
12422
  if (objIsWrapped || othIsWrapped) {
12423
12423
  var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
12424
12424
  stack || (stack = new _Stack_default);
@@ -12431,7 +12431,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
12431
12431
  stack || (stack = new _Stack_default);
12432
12432
  return _equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
12433
12433
  }
12434
- var COMPARE_PARTIAL_FLAG4 = 1, argsTag3 = "[object Arguments]", arrayTag2 = "[object Array]", objectTag3 = "[object Object]", objectProto12, hasOwnProperty9, _baseIsEqualDeep_default;
12434
+ var COMPARE_PARTIAL_FLAG4 = 1, argsTag3 = "[object Arguments]", arrayTag2 = "[object Array]", objectTag3 = "[object Object]", objectProto12, hasOwnProperty10, _baseIsEqualDeep_default;
12435
12435
  var init__baseIsEqualDeep = __esm(() => {
12436
12436
  init__Stack();
12437
12437
  init__equalArrays();
@@ -12442,7 +12442,7 @@ var init__baseIsEqualDeep = __esm(() => {
12442
12442
  init_isBuffer();
12443
12443
  init_isTypedArray();
12444
12444
  objectProto12 = Object.prototype;
12445
- hasOwnProperty9 = objectProto12.hasOwnProperty;
12445
+ hasOwnProperty10 = objectProto12.hasOwnProperty;
12446
12446
  _baseIsEqualDeep_default = baseIsEqualDeep;
12447
12447
  });
12448
12448
 
@@ -12706,14 +12706,14 @@ var init__createAggregator = __esm(() => {
12706
12706
  });
12707
12707
 
12708
12708
  // ../../node_modules/lodash-es/groupBy.js
12709
- var objectProto13, hasOwnProperty10, groupBy, groupBy_default;
12709
+ var objectProto13, hasOwnProperty11, groupBy, groupBy_default;
12710
12710
  var init_groupBy = __esm(() => {
12711
12711
  init__baseAssignValue();
12712
12712
  init__createAggregator();
12713
12713
  objectProto13 = Object.prototype;
12714
- hasOwnProperty10 = objectProto13.hasOwnProperty;
12714
+ hasOwnProperty11 = objectProto13.hasOwnProperty;
12715
12715
  groupBy = _createAggregator_default(function(result, value, key) {
12716
- if (hasOwnProperty10.call(result, key)) {
12716
+ if (hasOwnProperty11.call(result, key)) {
12717
12717
  result[key].push(value);
12718
12718
  } else {
12719
12719
  _baseAssignValue_default(result, key, [value]);
@@ -14085,7 +14085,7 @@ function pick(obj, keys2) {
14085
14085
  return a;
14086
14086
  }, {});
14087
14087
  }
14088
- function hasOwnProperty11(obj, prop) {
14088
+ function hasOwnProperty12(obj, prop) {
14089
14089
  return Object.prototype.hasOwnProperty.call(obj, prop);
14090
14090
  }
14091
14091
  function validateWeekSettings(settings) {
@@ -14229,7 +14229,7 @@ function asNumber(value) {
14229
14229
  function normalizeObject(obj, normalizer) {
14230
14230
  const normalized = {};
14231
14231
  for (const u in obj) {
14232
- if (hasOwnProperty11(obj, u)) {
14232
+ if (hasOwnProperty12(obj, u)) {
14233
14233
  const v = obj[u];
14234
14234
  if (v === undefined || v === null)
14235
14235
  continue;
@@ -15120,7 +15120,7 @@ function match(input, regex, handlers) {
15120
15120
  const all = {};
15121
15121
  let matchIndex = 1;
15122
15122
  for (const i in handlers) {
15123
- if (hasOwnProperty11(handlers, i)) {
15123
+ if (hasOwnProperty12(handlers, i)) {
15124
15124
  const h = handlers[i], groups = h.groups ? h.groups + 1 : 1;
15125
15125
  if (!h.literal && h.token) {
15126
15126
  all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
@@ -15242,7 +15242,7 @@ class TokenParser {
15242
15242
  return { input, tokens: this.tokens, invalidReason: this.invalidReason };
15243
15243
  } else {
15244
15244
  const [rawMatches, matches] = match(input, this.regex, this.handlers), [result, zone, specificOffset] = matches ? dateTimeFromMatches(matches) : [null, null, undefined];
15245
- if (hasOwnProperty11(matches, "a") && hasOwnProperty11(matches, "H")) {
15245
+ if (hasOwnProperty12(matches, "a") && hasOwnProperty12(matches, "H")) {
15246
15246
  throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
15247
15247
  }
15248
15248
  return {
@@ -16428,7 +16428,7 @@ var init_luxon = __esm(() => {
16428
16428
  return this;
16429
16429
  const dur = Duration.fromDurationLike(duration), result = {};
16430
16430
  for (const k of orderedUnits$1) {
16431
- if (hasOwnProperty11(dur.values, k) || hasOwnProperty11(this.values, k)) {
16431
+ if (hasOwnProperty12(dur.values, k) || hasOwnProperty12(this.values, k)) {
16432
16432
  result[k] = dur.get(k) + this.get(k);
16433
16433
  }
16434
16434
  }
@@ -61084,2006 +61084,1483 @@ var init_js_yaml = __esm(() => {
61084
61084
  } = yaml);
61085
61085
  });
61086
61086
 
61087
- // ../../node_modules/@jmespath-community/jmespath/dist/index.mjs
61088
- var exports_dist2 = {};
61089
- __export(exports_dist2, {
61090
- Scope: () => Scope,
61091
- TYPE_ANY: () => TYPE_ANY,
61092
- TYPE_ARRAY: () => TYPE_ARRAY,
61093
- TYPE_ARRAY_ARRAY: () => TYPE_ARRAY_ARRAY,
61094
- TYPE_ARRAY_NUMBER: () => TYPE_ARRAY_NUMBER,
61095
- TYPE_ARRAY_OBJECT: () => TYPE_ARRAY_OBJECT,
61096
- TYPE_ARRAY_STRING: () => TYPE_ARRAY_STRING,
61097
- TYPE_BOOLEAN: () => TYPE_BOOLEAN,
61098
- TYPE_EXPREF: () => TYPE_EXPREF,
61099
- TYPE_NULL: () => TYPE_NULL,
61100
- TYPE_NUMBER: () => TYPE_NUMBER,
61101
- TYPE_OBJECT: () => TYPE_OBJECT,
61102
- TYPE_STRING: () => TYPE_STRING,
61103
- TreeInterpreter: () => TreeInterpreter2,
61104
- clearCustomFunctions: () => clearCustomFunctions,
61105
- compile: () => compile,
61106
- default: () => jmespath,
61107
- getCustomFunctions: () => getCustomFunctions,
61108
- getRegisteredFunctions: () => getRegisteredFunctions,
61109
- isRegistered: () => isRegistered,
61110
- jmespath: () => jmespath,
61111
- register: () => register,
61112
- registerFunction: () => registerFunction,
61113
- search: () => search,
61114
- tokenize: () => tokenize,
61115
- unregisterFunction: () => unregisterFunction
61116
- });
61117
- function compile(expression, options) {
61118
- const nodeTree = Parser_default.parse(expression, options);
61119
- return nodeTree;
61120
- }
61121
- function tokenize(expression, options) {
61122
- return Lexer_default.tokenize(expression, options);
61123
- }
61124
- function search(data, expression, options) {
61125
- const nodeTree = Parser_default.parse(expression, options);
61126
- return TreeInterpreter_default.search(nodeTree, data);
61127
- }
61128
- function Scope() {
61129
- return new ScopeChain;
61130
- }
61131
- var isObject3 = (obj) => {
61132
- return obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
61133
- }, strictDeepEqual = (first, second) => {
61134
- if (first === second) {
61135
- return true;
61136
- }
61137
- if (typeof first !== typeof second) {
61138
- return false;
61139
- }
61140
- if (Array.isArray(first) && Array.isArray(second)) {
61141
- if (first.length !== second.length) {
61142
- return false;
61143
- }
61144
- for (let i2 = 0;i2 < first.length; i2 += 1) {
61145
- if (!strictDeepEqual(first[i2], second[i2])) {
61146
- return false;
61147
- }
61148
- }
61149
- return true;
61150
- }
61151
- if (isObject3(first) && isObject3(second)) {
61152
- const firstEntries = Object.entries(first);
61153
- const secondKeys = new Set(Object.keys(second));
61154
- if (firstEntries.length !== secondKeys.size) {
61155
- return false;
61156
- }
61157
- for (const [key, value] of firstEntries) {
61158
- if (!strictDeepEqual(value, second[key])) {
61087
+ // ../../node_modules/jmespath/jmespath.js
61088
+ var require_jmespath = __commonJS(function(exports) {
61089
+ (function(exports2) {
61090
+ function isArray2(obj) {
61091
+ if (obj !== null) {
61092
+ return Object.prototype.toString.call(obj) === "[object Array]";
61093
+ } else {
61159
61094
  return false;
61160
61095
  }
61161
- secondKeys.delete(key);
61162
- }
61163
- return secondKeys.size === 0;
61164
- }
61165
- return false;
61166
- }, isFalse = (obj) => {
61167
- if (obj === null || obj === undefined || obj === false) {
61168
- return true;
61169
- }
61170
- if (typeof obj === "string") {
61171
- return obj === "";
61172
- }
61173
- if (typeof obj === "object") {
61174
- if (Array.isArray(obj)) {
61175
- return obj.length === 0;
61176
- }
61177
- if (obj === null) {
61178
- return true;
61179
61096
  }
61180
- return Object.keys(obj).length === 0;
61181
- }
61182
- return false;
61183
- }, isAlpha = (ch) => {
61184
- return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
61185
- }, isNum = (ch) => {
61186
- return ch >= "0" && ch <= "9" || ch === "-";
61187
- }, isAlphaNum = (ch) => {
61188
- return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_";
61189
- }, ensureInteger = (value) => {
61190
- if (!(typeof value === "number") || Math.floor(value) !== value) {
61191
- throw new Error("invalid-value: expecting an integer.");
61192
- }
61193
- return value;
61194
- }, ensurePositiveInteger = (value) => {
61195
- if (!(typeof value === "number") || value < 0 || Math.floor(value) !== value) {
61196
- throw new Error("invalid-value: expecting a non-negative integer.");
61197
- }
61198
- return value;
61199
- }, ensureNumbers = (...operands) => {
61200
- for (let i2 = 0;i2 < operands.length; i2++) {
61201
- if (operands[i2] === null || operands[i2] === undefined) {
61202
- throw new Error("not-a-number: undefined");
61203
- }
61204
- if (typeof operands[i2] !== "number") {
61205
- throw new Error("not-a-number");
61206
- }
61207
- }
61208
- }, notZero = (n2) => {
61209
- n2 = +n2;
61210
- if (!n2) {
61211
- throw new Error("not-a-number: divide by zero");
61212
- }
61213
- return n2;
61214
- }, add = (left, right) => {
61215
- ensureNumbers(left, right);
61216
- const result = left + right;
61217
- return result;
61218
- }, sub = (left, right) => {
61219
- ensureNumbers(left, right);
61220
- const result = left - right;
61221
- return result;
61222
- }, mul = (left, right) => {
61223
- ensureNumbers(left, right);
61224
- const result = left * right;
61225
- return result;
61226
- }, divide = (left, right) => {
61227
- ensureNumbers(left, right);
61228
- const result = left / notZero(right);
61229
- return result;
61230
- }, div = (left, right) => {
61231
- ensureNumbers(left, right);
61232
- const result = Math.floor(left / notZero(right));
61233
- return result;
61234
- }, mod = (left, right) => {
61235
- ensureNumbers(left, right);
61236
- const result = left % right;
61237
- return result;
61238
- }, findFirst = (subject, sub2, start, end) => {
61239
- if (!subject || !sub2) {
61240
- return null;
61241
- }
61242
- start = Math.max(ensureInteger(start = start || 0), 0);
61243
- end = Math.min(ensureInteger(end = end || subject.length), subject.length);
61244
- const offset2 = subject.slice(start, end).indexOf(sub2);
61245
- return offset2 === -1 ? null : offset2 + start;
61246
- }, findLast = (subject, sub2, start, end) => {
61247
- if (!subject || !sub2) {
61248
- return null;
61249
- }
61250
- start = Math.max(ensureInteger(start = start || 0), 0);
61251
- end = Math.min(ensureInteger(end = end || subject.length), subject.length);
61252
- const offset2 = subject.slice(start, end).lastIndexOf(sub2);
61253
- const result = offset2 === -1 ? null : offset2 + start;
61254
- return result;
61255
- }, lower = (subject) => subject.toLowerCase(), ensurePadFuncParams = (name, width, padding) => {
61256
- padding = padding || " ";
61257
- if (padding.length > 1) {
61258
- throw new Error(`invalid value, ${name} expects its 'pad' parameter to be a valid string with a single codepoint`);
61259
- }
61260
- ensurePositiveInteger(width);
61261
- return padding;
61262
- }, padLeft = (subject, width, padding) => {
61263
- padding = ensurePadFuncParams("pad_left", width, padding);
61264
- return subject && subject.padStart(width, padding) || "";
61265
- }, padRight = (subject, width, padding) => {
61266
- padding = ensurePadFuncParams("pad_right", width, padding);
61267
- return subject && subject.padEnd(width, padding) || "";
61268
- }, replace = (subject, string4, by, count) => {
61269
- if (count === 0) {
61270
- return subject;
61271
- }
61272
- if (!count) {
61273
- return subject.split(string4).join(by);
61274
- }
61275
- ensurePositiveInteger(count);
61276
- [...Array(count).keys()].map(() => subject = subject.replace(string4, by));
61277
- return subject;
61278
- }, split = (subject, search2, count) => {
61279
- if (subject.length == 0 && search2.length === 0) {
61280
- return [];
61281
- }
61282
- if (count === null || count === undefined) {
61283
- return subject.split(search2);
61284
- }
61285
- ensurePositiveInteger(count);
61286
- if (count === 0) {
61287
- return [subject];
61288
- }
61289
- const split2 = subject.split(search2);
61290
- return [...split2.slice(0, count), split2.slice(count).join(search2)];
61291
- }, trim2 = (subject, chars) => {
61292
- return trimLeft(trimRight(subject, chars), chars);
61293
- }, trimLeft = (subject, chars) => {
61294
- return trimImpl(subject, (list) => new RegExp(`^[${list}]*(.*?)`), chars);
61295
- }, trimRight = (subject, chars) => {
61296
- return trimImpl(subject, (list) => new RegExp(`(.*?)[${list}]*$`), chars);
61297
- }, trimImpl = (subject, regExper, chars) => {
61298
- const pattern = chars ? chars.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&") : "\\s…";
61299
- return subject.replace(regExper(pattern), "$1");
61300
- }, upper = (subject) => subject.toUpperCase(), basicTokens, operatorStartToken, skipChars, StreamLexer = class {
61301
- _current = 0;
61302
- _enable_legacy_literals = false;
61303
- tokenize(stream, options) {
61304
- const tokens = [];
61305
- this._current = 0;
61306
- this._enable_legacy_literals = options?.enable_legacy_literals || false;
61307
- let start;
61308
- let identifier;
61309
- let token;
61310
- while (this._current < stream.length) {
61311
- if (isAlpha(stream[this._current])) {
61312
- start = this._current;
61313
- identifier = this.consumeUnquotedIdentifier(stream);
61314
- tokens.push({
61315
- start,
61316
- type: "UnquotedIdentifier",
61317
- value: identifier
61318
- });
61319
- } else if (basicTokens[stream[this._current]] !== undefined) {
61320
- tokens.push({
61321
- start: this._current,
61322
- type: basicTokens[stream[this._current]],
61323
- value: stream[this._current]
61324
- });
61325
- this._current += 1;
61326
- } else if (stream[this._current] === "$") {
61327
- start = this._current;
61328
- if (this._current + 1 < stream.length && isAlpha(stream[this._current + 1])) {
61329
- this._current += 1;
61330
- identifier = this.consumeUnquotedIdentifier(stream);
61331
- tokens.push({
61332
- start,
61333
- type: "Variable",
61334
- value: identifier
61335
- });
61336
- } else {
61337
- tokens.push({
61338
- start,
61339
- type: "Root",
61340
- value: stream[this._current]
61341
- });
61342
- this._current += 1;
61343
- }
61344
- } else if (stream[this._current] === "-") {
61345
- if (this._current + 1 < stream.length && isNum(stream[this._current + 1])) {
61346
- const token2 = this.consumeNumber(stream);
61347
- token2 && tokens.push(token2);
61348
- } else {
61349
- const token2 = {
61350
- start: this._current,
61351
- type: "Minus",
61352
- value: "-"
61353
- };
61354
- tokens.push(token2);
61355
- this._current += 1;
61356
- }
61357
- } else if (isNum(stream[this._current])) {
61358
- token = this.consumeNumber(stream);
61359
- tokens.push(token);
61360
- } else if (stream[this._current] === "[") {
61361
- token = this.consumeLBracket(stream);
61362
- tokens.push(token);
61363
- } else if (stream[this._current] === '"') {
61364
- start = this._current;
61365
- identifier = this.consumeQuotedIdentifier(stream);
61366
- tokens.push({
61367
- start,
61368
- type: "QuotedIdentifier",
61369
- value: identifier
61370
- });
61371
- } else if (stream[this._current] === `'`) {
61372
- start = this._current;
61373
- identifier = this.consumeRawStringLiteral(stream);
61374
- tokens.push({
61375
- start,
61376
- type: "Literal",
61377
- value: identifier
61378
- });
61379
- } else if (stream[this._current] === "`") {
61380
- start = this._current;
61381
- const literal2 = this.consumeLiteral(stream);
61382
- tokens.push({
61383
- start,
61384
- type: "Literal",
61385
- value: literal2
61386
- });
61387
- } else if (operatorStartToken[stream[this._current]] !== undefined) {
61388
- token = this.consumeOperator(stream);
61389
- token && tokens.push(token);
61390
- } else if (skipChars[stream[this._current]] !== undefined) {
61391
- this._current += 1;
61097
+ function isObject3(obj) {
61098
+ if (obj !== null) {
61099
+ return Object.prototype.toString.call(obj) === "[object Object]";
61392
61100
  } else {
61393
- const error46 = new Error(`Syntax error: unknown character: ${stream[this._current]}`);
61394
- error46.name = "LexerError";
61395
- throw error46;
61101
+ return false;
61396
61102
  }
61397
61103
  }
61398
- return tokens;
61399
- }
61400
- consumeUnquotedIdentifier(stream) {
61401
- const start = this._current;
61402
- this._current += 1;
61403
- while (this._current < stream.length && isAlphaNum(stream[this._current])) {
61404
- this._current += 1;
61405
- }
61406
- return stream.slice(start, this._current);
61407
- }
61408
- consumeQuotedIdentifier(stream) {
61409
- const start = this._current;
61410
- this._current += 1;
61411
- const maxLength = stream.length;
61412
- while (stream[this._current] !== '"' && this._current < maxLength) {
61413
- let current = this._current;
61414
- if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) {
61415
- current += 2;
61416
- } else {
61417
- current += 1;
61104
+ function strictDeepEqual(first, second) {
61105
+ if (first === second) {
61106
+ return true;
61418
61107
  }
61419
- this._current = current;
61420
- }
61421
- this._current += 1;
61422
- const [value, ok] = this.parseJSON(stream.slice(start, this._current));
61423
- if (!ok) {
61424
- const error46 = new Error(`syntax: unexpected end of JSON input`);
61425
- error46.name = "LexerError";
61426
- throw error46;
61427
- }
61428
- return value;
61429
- }
61430
- consumeRawStringLiteral(stream) {
61431
- const start = this._current;
61432
- this._current += 1;
61433
- const maxLength = stream.length;
61434
- while (stream[this._current] !== `'` && this._current < maxLength) {
61435
- let current = this._current;
61436
- if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === `'`)) {
61437
- current += 2;
61438
- } else {
61439
- current += 1;
61440
- }
61441
- this._current = current;
61442
- }
61443
- this._current += 1;
61444
- const literal2 = stream.slice(start + 1, this._current - 1);
61445
- return replace(replace(literal2, `\\\\`, `\\`), `\\'`, `'`);
61446
- }
61447
- consumeNumber(stream) {
61448
- const start = this._current;
61449
- this._current += 1;
61450
- const maxLength = stream.length;
61451
- while (isNum(stream[this._current]) && this._current < maxLength) {
61452
- this._current += 1;
61453
- }
61454
- const value = parseInt(stream.slice(start, this._current), 10);
61455
- return { start, value, type: "Number" };
61456
- }
61457
- consumeLBracket(stream) {
61458
- const start = this._current;
61459
- this._current += 1;
61460
- if (stream[this._current] === "?") {
61461
- this._current += 1;
61462
- return { start, type: "Filter", value: "[?" };
61463
- }
61464
- if (stream[this._current] === "]") {
61465
- this._current += 1;
61466
- return { start, type: "Flatten", value: "[]" };
61467
- }
61468
- return { start, type: "Lbracket", value: "[" };
61469
- }
61470
- consumeOrElse(stream, peek, token, orElse) {
61471
- const start = this._current;
61472
- this._current += 1;
61473
- if (this._current < stream.length && stream[this._current] === peek) {
61474
- this._current += 1;
61475
- return {
61476
- start,
61477
- type: orElse,
61478
- value: stream.slice(start, this._current)
61479
- };
61480
- }
61481
- return { start, type: token, value: stream[start] };
61482
- }
61483
- consumeOperator(stream) {
61484
- const start = this._current;
61485
- const startingChar = stream[start];
61486
- switch (startingChar) {
61487
- case "!":
61488
- return this.consumeOrElse(stream, "=", "Not", "NE");
61489
- case "<":
61490
- return this.consumeOrElse(stream, "=", "LT", "LTE");
61491
- case ">":
61492
- return this.consumeOrElse(stream, "=", "GT", "GTE");
61493
- case "=":
61494
- return this.consumeOrElse(stream, "=", "Assign", "EQ");
61495
- case "&":
61496
- return this.consumeOrElse(stream, "&", "Expref", "And");
61497
- case "|":
61498
- return this.consumeOrElse(stream, "|", "Pipe", "Or");
61499
- case "/":
61500
- return this.consumeOrElse(stream, "/", "Divide", "Div");
61501
- }
61502
- }
61503
- consumeLiteral(stream) {
61504
- this._current += 1;
61505
- const start = this._current;
61506
- const maxLength = stream.length;
61507
- while (stream[this._current] !== "`" && this._current < maxLength) {
61508
- let current = this._current;
61509
- if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) {
61510
- current += 2;
61511
- } else {
61512
- current += 1;
61108
+ var firstType = Object.prototype.toString.call(first);
61109
+ if (firstType !== Object.prototype.toString.call(second)) {
61110
+ return false;
61513
61111
  }
61514
- this._current = current;
61515
- }
61516
- let literalString = stream.slice(start, this._current).trimStart();
61517
- literalString = literalString.replace("\\`", "`");
61518
- let literal2 = null;
61519
- let ok = false;
61520
- if (this.looksLikeJSON(literalString)) {
61521
- [literal2, ok] = this.parseJSON(literalString);
61522
- }
61523
- if (!ok && this._enable_legacy_literals) {
61524
- [literal2, ok] = this.parseJSON(`"${literalString}"`);
61525
- }
61526
- if (!ok) {
61527
- const error46 = new Error(`Syntax error: unexpected end of JSON input or invalid format for a JSON literal: ${stream[this._current]}`);
61528
- error46.name = "LexerError";
61529
- throw error46;
61530
- }
61531
- this._current += 1;
61532
- return literal2;
61533
- }
61534
- looksLikeJSON(literalString) {
61535
- const startingChars = '[{"';
61536
- const jsonLiterals = ["true", "false", "null"];
61537
- const numberLooking = "-0123456789";
61538
- if (literalString === "") {
61539
- return false;
61540
- }
61541
- if (startingChars.includes(literalString[0])) {
61542
- return true;
61543
- }
61544
- if (jsonLiterals.includes(literalString)) {
61545
- return true;
61546
- }
61547
- if (numberLooking.includes(literalString[0])) {
61548
- const [_, ok] = this.parseJSON(literalString);
61549
- return ok;
61550
- }
61551
- return false;
61552
- }
61553
- parseJSON(text) {
61554
- try {
61555
- const json3 = JSON.parse(text);
61556
- return [json3, true];
61557
- } catch {
61558
- return [null, false];
61559
- }
61560
- }
61561
- }, Lexer, Lexer_default, bindingPower, TokenParser2 = class _TokenParser {
61562
- index = 0;
61563
- tokens = [];
61564
- parse(expression, options) {
61565
- this.loadTokens(expression, options || { enable_legacy_literals: false });
61566
- this.index = 0;
61567
- const ast = this.expression(0);
61568
- if (this.lookahead(0) !== "EOF") {
61569
- const token = this.lookaheadToken(0);
61570
- this.errorToken(token, `Syntax error: unexpected token type: ${token.type}, value: ${token.value}`);
61571
- }
61572
- return ast;
61573
- }
61574
- loadTokens(expression, options) {
61575
- this.tokens = Lexer_default.tokenize(expression, options);
61576
- this.tokens.push({ type: "EOF", value: "", start: expression.length });
61577
- }
61578
- expression(rbp) {
61579
- const leftToken = this.lookaheadToken(0);
61580
- this.advance();
61581
- let left = this.nud(leftToken);
61582
- let currentTokenType = this.lookahead(0);
61583
- while (rbp < bindingPower[currentTokenType]) {
61584
- this.advance();
61585
- left = this.led(currentTokenType, left);
61586
- currentTokenType = this.lookahead(0);
61587
- }
61588
- return left;
61589
- }
61590
- lookahead(offset2) {
61591
- return this.tokens[this.index + offset2].type;
61592
- }
61593
- lookaheadToken(offset2) {
61594
- return this.tokens[this.index + offset2];
61595
- }
61596
- advance() {
61597
- this.index += 1;
61598
- }
61599
- nud(token) {
61600
- switch (token.type) {
61601
- case "Variable":
61602
- return { type: "Variable", name: token.value };
61603
- case "Literal":
61604
- return { type: "Literal", value: token.value };
61605
- case "UnquotedIdentifier": {
61606
- if (_TokenParser.isKeyword(token, "let") && this.lookahead(0) === "Variable") {
61607
- return this.parseLetExpression();
61608
- } else {
61609
- return { type: "Field", name: token.value };
61112
+ if (isArray2(first) === true) {
61113
+ if (first.length !== second.length) {
61114
+ return false;
61610
61115
  }
61611
- }
61612
- case "QuotedIdentifier":
61613
- if (this.lookahead(0) === "Lparen") {
61614
- throw new Error("Syntax error: quoted identifier not allowed for function names.");
61615
- } else {
61616
- return { type: "Field", name: token.value };
61116
+ for (var i2 = 0;i2 < first.length; i2++) {
61117
+ if (strictDeepEqual(first[i2], second[i2]) === false) {
61118
+ return false;
61119
+ }
61617
61120
  }
61618
- case "Not": {
61619
- const child = this.expression(bindingPower.Not);
61620
- return { type: "NotExpression", child };
61621
- }
61622
- case "Minus": {
61623
- const child = this.expression(bindingPower.Minus);
61624
- return {
61625
- type: "Unary",
61626
- operator: token.type,
61627
- operand: child
61628
- };
61629
- }
61630
- case "Plus": {
61631
- const child = this.expression(bindingPower.Plus);
61632
- return {
61633
- type: "Unary",
61634
- operator: token.type,
61635
- operand: child
61636
- };
61121
+ return true;
61637
61122
  }
61638
- case "Star": {
61639
- const left = { type: "Identity" };
61640
- return { type: "ValueProjection", left, right: this.parseProjectionRHS(bindingPower.Star) };
61641
- }
61642
- case "Filter":
61643
- return this.led(token.type, { type: "Identity" });
61644
- case "Lbrace":
61645
- return this.parseMultiselectHash();
61646
- case "Flatten": {
61647
- const left = {
61648
- type: "Flatten",
61649
- child: { type: "Identity" }
61650
- };
61651
- const right = this.parseProjectionRHS(bindingPower.Flatten);
61652
- return { type: "Projection", left, right };
61653
- }
61654
- case "Lbracket": {
61655
- if (this.lookahead(0) === "Number" || this.lookahead(0) === "Colon") {
61656
- const right = this.parseIndexExpression();
61657
- return this.projectIfSlice({ type: "Identity" }, right);
61658
- }
61659
- if (this.lookahead(0) === "Star" && this.lookahead(1) === "Rbracket") {
61660
- this.advance();
61661
- this.advance();
61662
- const right = this.parseProjectionRHS(bindingPower.Star);
61663
- return {
61664
- left: { type: "Identity" },
61665
- right,
61666
- type: "Projection"
61667
- };
61123
+ if (isObject3(first) === true) {
61124
+ var keysSeen = {};
61125
+ for (var key in first) {
61126
+ if (hasOwnProperty.call(first, key)) {
61127
+ if (strictDeepEqual(first[key], second[key]) === false) {
61128
+ return false;
61129
+ }
61130
+ keysSeen[key] = true;
61131
+ }
61668
61132
  }
61669
- return this.parseMultiselectList();
61670
- }
61671
- case "Current":
61672
- return { type: "Current" };
61673
- case "Root":
61674
- return { type: "Root" };
61675
- case "Expref": {
61676
- const child = this.expression(bindingPower.Expref);
61677
- return { type: "ExpressionReference", child };
61133
+ for (var key2 in second) {
61134
+ if (hasOwnProperty.call(second, key2)) {
61135
+ if (keysSeen[key2] !== true) {
61136
+ return false;
61137
+ }
61138
+ }
61139
+ }
61140
+ return true;
61678
61141
  }
61679
- case "Lparen": {
61680
- const expression = this.expression(0);
61681
- this.match("Rparen");
61682
- return expression;
61142
+ return false;
61143
+ }
61144
+ function isFalse(obj) {
61145
+ if (obj === "" || obj === false || obj === null) {
61146
+ return true;
61147
+ } else if (isArray2(obj) && obj.length === 0) {
61148
+ return true;
61149
+ } else if (isObject3(obj)) {
61150
+ for (var key in obj) {
61151
+ if (obj.hasOwnProperty(key)) {
61152
+ return false;
61153
+ }
61154
+ }
61155
+ return true;
61156
+ } else {
61157
+ return false;
61683
61158
  }
61684
- default:
61685
- this.errorToken(token);
61686
61159
  }
61687
- }
61688
- led(tokenName, left) {
61689
- switch (tokenName) {
61690
- case "Question": {
61691
- const trueExpr = this.expression(0);
61692
- this.match("Colon");
61693
- const falseExpr = this.expression(0);
61694
- return {
61695
- type: "Ternary",
61696
- condition: left,
61697
- trueExpr,
61698
- falseExpr
61699
- };
61160
+ function objValues(obj) {
61161
+ var keys2 = Object.keys(obj);
61162
+ var values = [];
61163
+ for (var i2 = 0;i2 < keys2.length; i2++) {
61164
+ values.push(obj[keys2[i2]]);
61700
61165
  }
61701
- case "Dot": {
61702
- const rbp = bindingPower.Dot;
61703
- if (this.lookahead(0) !== "Star") {
61704
- const right2 = this.parseDotRHS(rbp);
61705
- return { type: "Subexpression", left, right: right2 };
61706
- }
61707
- this.advance();
61708
- const right = this.parseProjectionRHS(rbp);
61709
- return { type: "ValueProjection", left, right };
61710
- }
61711
- case "Pipe": {
61712
- const right = this.expression(bindingPower.Pipe);
61713
- return { type: "Pipe", left, right };
61714
- }
61715
- case "Or": {
61716
- const right = this.expression(bindingPower.Or);
61717
- return { type: "OrExpression", left, right };
61718
- }
61719
- case "And": {
61720
- const right = this.expression(bindingPower.And);
61721
- return { type: "AndExpression", left, right };
61722
- }
61723
- case "Lparen": {
61724
- if (left.type !== "Field") {
61725
- throw new Error("Syntax error: expected a Field node");
61726
- }
61727
- const name = left.name;
61728
- const args = this.parseCommaSeparatedExpressionsUntilToken("Rparen");
61729
- const node = { name, type: "Function", children: args };
61730
- return node;
61731
- }
61732
- case "Filter": {
61733
- const condition = this.expression(0);
61734
- this.match("Rbracket");
61735
- const right = this.lookahead(0) === "Flatten" ? { type: "Identity" } : this.parseProjectionRHS(bindingPower.Filter);
61736
- return { type: "FilterProjection", left, right, condition };
61737
- }
61738
- case "Flatten": {
61739
- const leftNode = { type: "Flatten", child: left };
61740
- const right = this.parseProjectionRHS(bindingPower.Flatten);
61741
- return { type: "Projection", left: leftNode, right };
61742
- }
61743
- case "Assign": {
61744
- const leftNode = left;
61745
- const right = this.expression(0);
61746
- return {
61747
- type: "Binding",
61748
- variable: leftNode.name,
61749
- reference: right
61750
- };
61166
+ return values;
61167
+ }
61168
+ function merge3(a, b) {
61169
+ var merged = {};
61170
+ for (var key in a) {
61171
+ merged[key] = a[key];
61751
61172
  }
61752
- case "EQ":
61753
- case "NE":
61754
- case "GT":
61755
- case "GTE":
61756
- case "LT":
61757
- case "LTE":
61758
- return this.parseComparator(left, tokenName);
61759
- case "Plus":
61760
- case "Minus":
61761
- case "Multiply":
61762
- case "Star":
61763
- case "Divide":
61764
- case "Modulo":
61765
- case "Div":
61766
- return this.parseArithmetic(left, tokenName);
61767
- case "Lbracket": {
61768
- const token = this.lookaheadToken(0);
61769
- if (token.type === "Number" || token.type === "Colon") {
61770
- const right2 = this.parseIndexExpression();
61771
- return this.projectIfSlice(left, right2);
61772
- }
61773
- this.match("Star");
61774
- this.match("Rbracket");
61775
- const right = this.parseProjectionRHS(bindingPower.Star);
61776
- return { type: "Projection", left, right };
61173
+ for (var key2 in b) {
61174
+ merged[key2] = b[key2];
61777
61175
  }
61778
- default:
61779
- return this.errorToken(this.lookaheadToken(0));
61176
+ return merged;
61780
61177
  }
61781
- }
61782
- static isKeyword(token, keyword) {
61783
- return token.type === "UnquotedIdentifier" && token.value === keyword;
61784
- }
61785
- match(tokenType) {
61786
- if (this.lookahead(0) === tokenType) {
61787
- this.advance();
61788
- return;
61178
+ var trimLeft;
61179
+ if (typeof String.prototype.trimLeft === "function") {
61180
+ trimLeft = function(str2) {
61181
+ return str2.trimLeft();
61182
+ };
61789
61183
  } else {
61790
- const token = this.lookaheadToken(0);
61791
- this.errorToken(token, `Syntax error: expected ${tokenType}, got: ${token.type}`);
61792
- }
61793
- }
61794
- errorToken(token, message = "") {
61795
- const error46 = new Error(message || `Syntax error: invalid token (${token.type}): "${token.value}"`);
61796
- error46.name = "ParserError";
61797
- throw error46;
61798
- }
61799
- parseIndexExpression() {
61800
- if (this.lookahead(0) === "Colon" || this.lookahead(1) === "Colon") {
61801
- return this.parseSliceExpression();
61802
- }
61803
- const value = Number(this.lookaheadToken(0).value);
61804
- this.advance();
61805
- this.match("Rbracket");
61806
- return { type: "Index", value };
61807
- }
61808
- projectIfSlice(left, right) {
61809
- const indexExpr = {
61810
- type: "IndexExpression",
61811
- left,
61812
- right
61813
- };
61814
- if (right.type === "Slice") {
61815
- return {
61816
- left: indexExpr,
61817
- right: this.parseProjectionRHS(bindingPower.Star),
61818
- type: "Projection"
61184
+ trimLeft = function(str2) {
61185
+ return str2.match(/^\s*(.*)/)[1];
61819
61186
  };
61820
61187
  }
61821
- return indexExpr;
61822
- }
61823
- parseSliceExpression() {
61824
- const parts = [null, null, null];
61825
- let index = 0;
61826
- let current = this.lookaheadToken(0);
61827
- while (current.type != "Rbracket" && index < 3) {
61828
- if (current.type === "Colon") {
61829
- index++;
61830
- if (index === 3) {
61831
- this.errorToken(this.lookaheadToken(0), "Syntax error, too many colons in slice expression");
61832
- }
61833
- this.advance();
61834
- } else if (current.type === "Number") {
61835
- const part = this.lookaheadToken(0).value;
61836
- parts[index] = part;
61837
- this.advance();
61838
- } else {
61839
- const next = this.lookaheadToken(0);
61840
- this.errorToken(next, `Syntax error, unexpected token: ${next.value}(${next.type})`);
61841
- }
61842
- current = this.lookaheadToken(0);
61843
- }
61844
- this.match("Rbracket");
61845
- const [start, stop, step] = parts;
61846
- return { type: "Slice", start, stop, step };
61847
- }
61848
- parseLetExpression() {
61849
- const separated = this.parseCommaSeparatedExpressionsUntilKeyword("in");
61850
- const expression = this.expression(0);
61851
- const bindings = separated.map((binding) => binding);
61852
- return {
61853
- type: "LetExpression",
61854
- bindings,
61855
- expression
61188
+ var TYPE_NUMBER = 0;
61189
+ var TYPE_ANY = 1;
61190
+ var TYPE_STRING = 2;
61191
+ var TYPE_ARRAY = 3;
61192
+ var TYPE_OBJECT = 4;
61193
+ var TYPE_BOOLEAN = 5;
61194
+ var TYPE_EXPREF = 6;
61195
+ var TYPE_NULL = 7;
61196
+ var TYPE_ARRAY_NUMBER = 8;
61197
+ var TYPE_ARRAY_STRING = 9;
61198
+ var TYPE_NAME_TABLE = {
61199
+ 0: "number",
61200
+ 1: "any",
61201
+ 2: "string",
61202
+ 3: "array",
61203
+ 4: "object",
61204
+ 5: "boolean",
61205
+ 6: "expression",
61206
+ 7: "null",
61207
+ 8: "Array<number>",
61208
+ 9: "Array<string>"
61856
61209
  };
61857
- }
61858
- parseCommaSeparatedExpressionsUntilKeyword(keyword) {
61859
- return this.parseCommaSeparatedExpressionsUntil(() => {
61860
- return _TokenParser.isKeyword(this.lookaheadToken(0), keyword);
61861
- }, () => {
61862
- this.advance();
61863
- });
61864
- }
61865
- parseCommaSeparatedExpressionsUntilToken(token) {
61866
- return this.parseCommaSeparatedExpressionsUntil(() => {
61867
- return this.lookahead(0) === token;
61868
- }, () => {
61869
- return this.match(token);
61870
- });
61871
- }
61872
- parseCommaSeparatedExpressionsUntil(isEndToken, matchEndToken) {
61873
- const args = [];
61874
- let expression;
61875
- while (!isEndToken()) {
61876
- expression = this.expression(0);
61877
- if (this.lookahead(0) === "Comma") {
61878
- this.match("Comma");
61879
- }
61880
- args.push(expression);
61881
- }
61882
- matchEndToken();
61883
- return args;
61884
- }
61885
- parseComparator(left, comparator) {
61886
- const right = this.expression(bindingPower[comparator]);
61887
- return { type: "Comparator", name: comparator, left, right };
61888
- }
61889
- parseArithmetic(left, operator) {
61890
- const right = this.expression(bindingPower[operator]);
61891
- return { type: "Arithmetic", operator, left, right };
61892
- }
61893
- parseDotRHS(rbp) {
61894
- const lookahead = this.lookahead(0);
61895
- const exprTokens = ["UnquotedIdentifier", "QuotedIdentifier", "Star"];
61896
- if (exprTokens.includes(lookahead)) {
61897
- return this.expression(rbp);
61898
- }
61899
- if (lookahead === "Lbracket") {
61900
- this.match("Lbracket");
61901
- return this.parseMultiselectList();
61902
- }
61903
- if (lookahead === "Lbrace") {
61904
- this.match("Lbrace");
61905
- return this.parseMultiselectHash();
61906
- }
61907
- const token = this.lookaheadToken(0);
61908
- this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
61909
- }
61910
- parseProjectionRHS(rbp) {
61911
- if (bindingPower[this.lookahead(0)] < 10) {
61912
- return { type: "Identity" };
61913
- }
61914
- if (this.lookahead(0) === "Lbracket") {
61915
- return this.expression(rbp);
61916
- }
61917
- if (this.lookahead(0) === "Filter") {
61918
- return this.expression(rbp);
61919
- }
61920
- if (this.lookahead(0) === "Dot") {
61921
- this.match("Dot");
61922
- return this.parseDotRHS(rbp);
61923
- }
61924
- const token = this.lookaheadToken(0);
61925
- this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
61926
- }
61927
- parseMultiselectList() {
61928
- const expressions = [];
61929
- while (this.lookahead(0) !== "Rbracket") {
61930
- const expression = this.expression(0);
61931
- expressions.push(expression);
61932
- if (this.lookahead(0) === "Comma") {
61933
- this.match("Comma");
61934
- if (this.lookahead(0) === "Rbracket") {
61935
- throw new Error("Syntax error: unexpected token Rbracket");
61936
- }
61937
- }
61938
- }
61939
- this.match("Rbracket");
61940
- return { type: "MultiSelectList", children: expressions };
61941
- }
61942
- parseMultiselectHash() {
61943
- const pairs2 = [];
61944
- const identifierTypes = ["UnquotedIdentifier", "QuotedIdentifier"];
61945
- let keyToken;
61946
- let keyName;
61947
- let value;
61948
- for (;; ) {
61949
- keyToken = this.lookaheadToken(0);
61950
- if (!identifierTypes.includes(keyToken.type)) {
61951
- throw new Error(`Syntax error: expecting an identifier token, got: ${keyToken.type}`);
61952
- }
61953
- keyName = keyToken.value;
61954
- this.advance();
61955
- this.match("Colon");
61956
- value = this.expression(0);
61957
- pairs2.push({ value, type: "KeyValuePair", name: keyName });
61958
- if (this.lookahead(0) === "Comma") {
61959
- this.match("Comma");
61960
- } else if (this.lookahead(0) === "Rbrace") {
61961
- this.match("Rbrace");
61962
- break;
61963
- }
61964
- }
61965
- return { type: "MultiSelectHash", children: pairs2 };
61966
- }
61967
- }, Parser, Parser_default, Text = class _Text {
61968
- _text;
61969
- constructor(text) {
61970
- this._text = text;
61971
- }
61972
- get string() {
61973
- return this._text;
61974
- }
61975
- get length() {
61976
- return this.codePoints.length;
61977
- }
61978
- compareTo(other) {
61979
- return _Text.compare(this, new _Text(other));
61980
- }
61981
- static get comparer() {
61982
- const stringComparer = (left, right) => {
61983
- return new _Text(left).compareTo(right);
61210
+ var TOK_EOF = "EOF";
61211
+ var TOK_UNQUOTEDIDENTIFIER = "UnquotedIdentifier";
61212
+ var TOK_QUOTEDIDENTIFIER = "QuotedIdentifier";
61213
+ var TOK_RBRACKET = "Rbracket";
61214
+ var TOK_RPAREN = "Rparen";
61215
+ var TOK_COMMA = "Comma";
61216
+ var TOK_COLON = "Colon";
61217
+ var TOK_RBRACE = "Rbrace";
61218
+ var TOK_NUMBER = "Number";
61219
+ var TOK_CURRENT = "Current";
61220
+ var TOK_EXPREF = "Expref";
61221
+ var TOK_PIPE = "Pipe";
61222
+ var TOK_OR = "Or";
61223
+ var TOK_AND = "And";
61224
+ var TOK_EQ = "EQ";
61225
+ var TOK_GT = "GT";
61226
+ var TOK_LT = "LT";
61227
+ var TOK_GTE = "GTE";
61228
+ var TOK_LTE = "LTE";
61229
+ var TOK_NE = "NE";
61230
+ var TOK_FLATTEN = "Flatten";
61231
+ var TOK_STAR = "Star";
61232
+ var TOK_FILTER = "Filter";
61233
+ var TOK_DOT = "Dot";
61234
+ var TOK_NOT = "Not";
61235
+ var TOK_LBRACE = "Lbrace";
61236
+ var TOK_LBRACKET = "Lbracket";
61237
+ var TOK_LPAREN = "Lparen";
61238
+ var TOK_LITERAL = "Literal";
61239
+ var basicTokens = {
61240
+ ".": TOK_DOT,
61241
+ "*": TOK_STAR,
61242
+ ",": TOK_COMMA,
61243
+ ":": TOK_COLON,
61244
+ "{": TOK_LBRACE,
61245
+ "}": TOK_RBRACE,
61246
+ "]": TOK_RBRACKET,
61247
+ "(": TOK_LPAREN,
61248
+ ")": TOK_RPAREN,
61249
+ "@": TOK_CURRENT
61984
61250
  };
61985
- return stringComparer;
61986
- }
61987
- static compare(left, right) {
61988
- const leftCp = left.codePoints;
61989
- const rightCp = right.codePoints;
61990
- for (let index = 0;index < Math.min(leftCp.length, rightCp.length); index++) {
61991
- if (leftCp[index] === rightCp[index]) {
61992
- continue;
61993
- }
61994
- return leftCp[index] - rightCp[index] > 0 ? 1 : -1;
61995
- }
61996
- return leftCp.length - rightCp.length > 0 ? 1 : -1;
61997
- }
61998
- reverse() {
61999
- return String.fromCodePoint(...this.codePoints.reverse());
62000
- }
62001
- get codePoints() {
62002
- const array2 = [...this._text].map((s2) => s2.codePointAt(0));
62003
- return array2;
62004
- }
62005
- }, createMathFunction = (mathFn) => ([value]) => mathFn(value), createStringFunction = (stringFn) => ([subject]) => stringFn(subject), createObjectFunction = (objFn) => ([obj]) => objFn(obj), Runtime = class {
62006
- _interpreter;
62007
- _functionTable;
62008
- _customFunctions = /* @__PURE__ */ new Set;
62009
- TYPE_NAME_TABLE = Object.freeze({
62010
- [0]: "number",
62011
- [1]: "any",
62012
- [2]: "string",
62013
- [3]: "array",
62014
- [4]: "object",
62015
- [5]: "boolean",
62016
- [6]: "expression",
62017
- [7]: "null",
62018
- [8]: "Array<number>",
62019
- [10]: "Array<object>",
62020
- [9]: "Array<string>",
62021
- [11]: "Array<Array<any>>"
62022
- });
62023
- constructor(interpreter) {
62024
- this._interpreter = interpreter;
62025
- this._functionTable = this.buildFunctionTable();
62026
- }
62027
- buildFunctionTable() {
62028
- return {
62029
- abs: { _func: createMathFunction(Math.abs), _signature: [{ types: [0] }] },
62030
- ceil: { _func: createMathFunction(Math.ceil), _signature: [{ types: [0] }] },
62031
- floor: { _func: createMathFunction(Math.floor), _signature: [{ types: [0] }] },
62032
- lower: { _func: createStringFunction(lower), _signature: [{ types: [2] }] },
62033
- upper: { _func: createStringFunction(upper), _signature: [{ types: [2] }] },
62034
- keys: { _func: createObjectFunction(Object.keys), _signature: [{ types: [4] }] },
62035
- values: { _func: createObjectFunction(Object.values), _signature: [{ types: [4] }] },
62036
- avg: { _func: this.functionAvg, _signature: [{ types: [8] }] },
62037
- contains: {
62038
- _func: this.functionContains,
62039
- _signature: [
62040
- { types: [2, 3] },
62041
- { types: [1] }
62042
- ]
61251
+ var operatorStartToken = {
61252
+ "<": true,
61253
+ ">": true,
61254
+ "=": true,
61255
+ "!": true
61256
+ };
61257
+ var skipChars = {
61258
+ " ": true,
61259
+ "\t": true,
61260
+ "\n": true
61261
+ };
61262
+ function isAlpha(ch) {
61263
+ return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
61264
+ }
61265
+ function isNum(ch) {
61266
+ return ch >= "0" && ch <= "9" || ch === "-";
61267
+ }
61268
+ function isAlphaNum(ch) {
61269
+ return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_";
61270
+ }
61271
+ function Lexer() {}
61272
+ Lexer.prototype = {
61273
+ tokenize: function(stream) {
61274
+ var tokens = [];
61275
+ this._current = 0;
61276
+ var start;
61277
+ var identifier;
61278
+ var token;
61279
+ while (this._current < stream.length) {
61280
+ if (isAlpha(stream[this._current])) {
61281
+ start = this._current;
61282
+ identifier = this._consumeUnquotedIdentifier(stream);
61283
+ tokens.push({
61284
+ type: TOK_UNQUOTEDIDENTIFIER,
61285
+ value: identifier,
61286
+ start
61287
+ });
61288
+ } else if (basicTokens[stream[this._current]] !== undefined) {
61289
+ tokens.push({
61290
+ type: basicTokens[stream[this._current]],
61291
+ value: stream[this._current],
61292
+ start: this._current
61293
+ });
61294
+ this._current++;
61295
+ } else if (isNum(stream[this._current])) {
61296
+ token = this._consumeNumber(stream);
61297
+ tokens.push(token);
61298
+ } else if (stream[this._current] === "[") {
61299
+ token = this._consumeLBracket(stream);
61300
+ tokens.push(token);
61301
+ } else if (stream[this._current] === '"') {
61302
+ start = this._current;
61303
+ identifier = this._consumeQuotedIdentifier(stream);
61304
+ tokens.push({
61305
+ type: TOK_QUOTEDIDENTIFIER,
61306
+ value: identifier,
61307
+ start
61308
+ });
61309
+ } else if (stream[this._current] === "'") {
61310
+ start = this._current;
61311
+ identifier = this._consumeRawStringLiteral(stream);
61312
+ tokens.push({
61313
+ type: TOK_LITERAL,
61314
+ value: identifier,
61315
+ start
61316
+ });
61317
+ } else if (stream[this._current] === "`") {
61318
+ start = this._current;
61319
+ var literal2 = this._consumeLiteral(stream);
61320
+ tokens.push({
61321
+ type: TOK_LITERAL,
61322
+ value: literal2,
61323
+ start
61324
+ });
61325
+ } else if (operatorStartToken[stream[this._current]] !== undefined) {
61326
+ tokens.push(this._consumeOperator(stream));
61327
+ } else if (skipChars[stream[this._current]] !== undefined) {
61328
+ this._current++;
61329
+ } else if (stream[this._current] === "&") {
61330
+ start = this._current;
61331
+ this._current++;
61332
+ if (stream[this._current] === "&") {
61333
+ this._current++;
61334
+ tokens.push({ type: TOK_AND, value: "&&", start });
61335
+ } else {
61336
+ tokens.push({ type: TOK_EXPREF, value: "&", start });
61337
+ }
61338
+ } else if (stream[this._current] === "|") {
61339
+ start = this._current;
61340
+ this._current++;
61341
+ if (stream[this._current] === "|") {
61342
+ this._current++;
61343
+ tokens.push({ type: TOK_OR, value: "||", start });
61344
+ } else {
61345
+ tokens.push({ type: TOK_PIPE, value: "|", start });
61346
+ }
61347
+ } else {
61348
+ var error46 = new Error("Unknown character:" + stream[this._current]);
61349
+ error46.name = "LexerError";
61350
+ throw error46;
61351
+ }
61352
+ }
61353
+ return tokens;
62043
61354
  },
62044
- ends_with: {
62045
- _func: this.functionEndsWith,
62046
- _signature: [{ types: [2] }, { types: [2] }]
61355
+ _consumeUnquotedIdentifier: function(stream) {
61356
+ var start = this._current;
61357
+ this._current++;
61358
+ while (this._current < stream.length && isAlphaNum(stream[this._current])) {
61359
+ this._current++;
61360
+ }
61361
+ return stream.slice(start, this._current);
62047
61362
  },
62048
- find_first: {
62049
- _func: this.functionFindFirst,
62050
- _signature: [
62051
- { types: [2] },
62052
- { types: [2] },
62053
- { types: [0], optional: true },
62054
- { types: [0], optional: true }
62055
- ]
61363
+ _consumeQuotedIdentifier: function(stream) {
61364
+ var start = this._current;
61365
+ this._current++;
61366
+ var maxLength = stream.length;
61367
+ while (stream[this._current] !== '"' && this._current < maxLength) {
61368
+ var current = this._current;
61369
+ if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) {
61370
+ current += 2;
61371
+ } else {
61372
+ current++;
61373
+ }
61374
+ this._current = current;
61375
+ }
61376
+ this._current++;
61377
+ return JSON.parse(stream.slice(start, this._current));
62056
61378
  },
62057
- find_last: {
62058
- _func: this.functionFindLast,
62059
- _signature: [
62060
- { types: [2] },
62061
- { types: [2] },
62062
- { types: [0], optional: true },
62063
- { types: [0], optional: true }
62064
- ]
61379
+ _consumeRawStringLiteral: function(stream) {
61380
+ var start = this._current;
61381
+ this._current++;
61382
+ var maxLength = stream.length;
61383
+ while (stream[this._current] !== "'" && this._current < maxLength) {
61384
+ var current = this._current;
61385
+ if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "'")) {
61386
+ current += 2;
61387
+ } else {
61388
+ current++;
61389
+ }
61390
+ this._current = current;
61391
+ }
61392
+ this._current++;
61393
+ var literal2 = stream.slice(start + 1, this._current - 1);
61394
+ return literal2.replace("\\'", "'");
62065
61395
  },
62066
- from_items: { _func: this.functionFromItems, _signature: [{ types: [11] }] },
62067
- group_by: {
62068
- _func: this.functionGroupBy,
62069
- _signature: [{ types: [3] }, { types: [6] }]
61396
+ _consumeNumber: function(stream) {
61397
+ var start = this._current;
61398
+ this._current++;
61399
+ var maxLength = stream.length;
61400
+ while (isNum(stream[this._current]) && this._current < maxLength) {
61401
+ this._current++;
61402
+ }
61403
+ var value = parseInt(stream.slice(start, this._current));
61404
+ return { type: TOK_NUMBER, value, start };
62070
61405
  },
62071
- items: { _func: this.functionItems, _signature: [{ types: [4] }] },
62072
- join: {
62073
- _func: this.functionJoin,
62074
- _signature: [{ types: [2] }, { types: [9] }]
61406
+ _consumeLBracket: function(stream) {
61407
+ var start = this._current;
61408
+ this._current++;
61409
+ if (stream[this._current] === "?") {
61410
+ this._current++;
61411
+ return { type: TOK_FILTER, value: "[?", start };
61412
+ } else if (stream[this._current] === "]") {
61413
+ this._current++;
61414
+ return { type: TOK_FLATTEN, value: "[]", start };
61415
+ } else {
61416
+ return { type: TOK_LBRACKET, value: "[", start };
61417
+ }
62075
61418
  },
62076
- length: {
62077
- _func: this.functionLength,
62078
- _signature: [{ types: [2, 3, 4] }]
61419
+ _consumeOperator: function(stream) {
61420
+ var start = this._current;
61421
+ var startingChar = stream[start];
61422
+ this._current++;
61423
+ if (startingChar === "!") {
61424
+ if (stream[this._current] === "=") {
61425
+ this._current++;
61426
+ return { type: TOK_NE, value: "!=", start };
61427
+ } else {
61428
+ return { type: TOK_NOT, value: "!", start };
61429
+ }
61430
+ } else if (startingChar === "<") {
61431
+ if (stream[this._current] === "=") {
61432
+ this._current++;
61433
+ return { type: TOK_LTE, value: "<=", start };
61434
+ } else {
61435
+ return { type: TOK_LT, value: "<", start };
61436
+ }
61437
+ } else if (startingChar === ">") {
61438
+ if (stream[this._current] === "=") {
61439
+ this._current++;
61440
+ return { type: TOK_GTE, value: ">=", start };
61441
+ } else {
61442
+ return { type: TOK_GT, value: ">", start };
61443
+ }
61444
+ } else if (startingChar === "=") {
61445
+ if (stream[this._current] === "=") {
61446
+ this._current++;
61447
+ return { type: TOK_EQ, value: "==", start };
61448
+ }
61449
+ }
62079
61450
  },
62080
- map: {
62081
- _func: this.functionMap,
62082
- _signature: [{ types: [6] }, { types: [3] }]
61451
+ _consumeLiteral: function(stream) {
61452
+ this._current++;
61453
+ var start = this._current;
61454
+ var maxLength = stream.length;
61455
+ var literal2;
61456
+ while (stream[this._current] !== "`" && this._current < maxLength) {
61457
+ var current = this._current;
61458
+ if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) {
61459
+ current += 2;
61460
+ } else {
61461
+ current++;
61462
+ }
61463
+ this._current = current;
61464
+ }
61465
+ var literalString = trimLeft(stream.slice(start, this._current));
61466
+ literalString = literalString.replace("\\`", "`");
61467
+ if (this._looksLikeJSON(literalString)) {
61468
+ literal2 = JSON.parse(literalString);
61469
+ } else {
61470
+ literal2 = JSON.parse('"' + literalString + '"');
61471
+ }
61472
+ this._current++;
61473
+ return literal2;
62083
61474
  },
62084
- max: {
62085
- _func: this.functionMax,
62086
- _signature: [{ types: [8, 9] }]
61475
+ _looksLikeJSON: function(literalString) {
61476
+ var startingChars = '[{"';
61477
+ var jsonLiterals = ["true", "false", "null"];
61478
+ var numberLooking = "-0123456789";
61479
+ if (literalString === "") {
61480
+ return false;
61481
+ } else if (startingChars.indexOf(literalString[0]) >= 0) {
61482
+ return true;
61483
+ } else if (jsonLiterals.indexOf(literalString) >= 0) {
61484
+ return true;
61485
+ } else if (numberLooking.indexOf(literalString[0]) >= 0) {
61486
+ try {
61487
+ JSON.parse(literalString);
61488
+ return true;
61489
+ } catch (ex) {
61490
+ return false;
61491
+ }
61492
+ } else {
61493
+ return false;
61494
+ }
61495
+ }
61496
+ };
61497
+ var bindingPower = {};
61498
+ bindingPower[TOK_EOF] = 0;
61499
+ bindingPower[TOK_UNQUOTEDIDENTIFIER] = 0;
61500
+ bindingPower[TOK_QUOTEDIDENTIFIER] = 0;
61501
+ bindingPower[TOK_RBRACKET] = 0;
61502
+ bindingPower[TOK_RPAREN] = 0;
61503
+ bindingPower[TOK_COMMA] = 0;
61504
+ bindingPower[TOK_RBRACE] = 0;
61505
+ bindingPower[TOK_NUMBER] = 0;
61506
+ bindingPower[TOK_CURRENT] = 0;
61507
+ bindingPower[TOK_EXPREF] = 0;
61508
+ bindingPower[TOK_PIPE] = 1;
61509
+ bindingPower[TOK_OR] = 2;
61510
+ bindingPower[TOK_AND] = 3;
61511
+ bindingPower[TOK_EQ] = 5;
61512
+ bindingPower[TOK_GT] = 5;
61513
+ bindingPower[TOK_LT] = 5;
61514
+ bindingPower[TOK_GTE] = 5;
61515
+ bindingPower[TOK_LTE] = 5;
61516
+ bindingPower[TOK_NE] = 5;
61517
+ bindingPower[TOK_FLATTEN] = 9;
61518
+ bindingPower[TOK_STAR] = 20;
61519
+ bindingPower[TOK_FILTER] = 21;
61520
+ bindingPower[TOK_DOT] = 40;
61521
+ bindingPower[TOK_NOT] = 45;
61522
+ bindingPower[TOK_LBRACE] = 50;
61523
+ bindingPower[TOK_LBRACKET] = 55;
61524
+ bindingPower[TOK_LPAREN] = 60;
61525
+ function Parser() {}
61526
+ Parser.prototype = {
61527
+ parse: function(expression) {
61528
+ this._loadTokens(expression);
61529
+ this.index = 0;
61530
+ var ast = this.expression(0);
61531
+ if (this._lookahead(0) !== TOK_EOF) {
61532
+ var t = this._lookaheadToken(0);
61533
+ var error46 = new Error("Unexpected token type: " + t.type + ", value: " + t.value);
61534
+ error46.name = "ParserError";
61535
+ throw error46;
61536
+ }
61537
+ return ast;
62087
61538
  },
62088
- max_by: {
62089
- _func: this.functionMaxBy,
62090
- _signature: [{ types: [3] }, { types: [6] }]
61539
+ _loadTokens: function(expression) {
61540
+ var lexer = new Lexer;
61541
+ var tokens = lexer.tokenize(expression);
61542
+ tokens.push({ type: TOK_EOF, value: "", start: expression.length });
61543
+ this.tokens = tokens;
62091
61544
  },
62092
- merge: { _func: this.functionMerge, _signature: [{ types: [4], variadic: true }] },
62093
- min: {
62094
- _func: this.functionMin,
62095
- _signature: [{ types: [8, 9] }]
61545
+ expression: function(rbp) {
61546
+ var leftToken = this._lookaheadToken(0);
61547
+ this._advance();
61548
+ var left = this.nud(leftToken);
61549
+ var currentToken = this._lookahead(0);
61550
+ while (rbp < bindingPower[currentToken]) {
61551
+ this._advance();
61552
+ left = this.led(currentToken, left);
61553
+ currentToken = this._lookahead(0);
61554
+ }
61555
+ return left;
62096
61556
  },
62097
- min_by: {
62098
- _func: this.functionMinBy,
62099
- _signature: [{ types: [3] }, { types: [6] }]
61557
+ _lookahead: function(number4) {
61558
+ return this.tokens[this.index + number4].type;
62100
61559
  },
62101
- not_null: { _func: this.functionNotNull, _signature: [{ types: [1], variadic: true }] },
62102
- pad_left: {
62103
- _func: this.functionPadLeft,
62104
- _signature: [
62105
- { types: [2] },
62106
- { types: [0] },
62107
- { types: [2], optional: true }
62108
- ]
61560
+ _lookaheadToken: function(number4) {
61561
+ return this.tokens[this.index + number4];
62109
61562
  },
62110
- pad_right: {
62111
- _func: this.functionPadRight,
62112
- _signature: [
62113
- { types: [2] },
62114
- { types: [0] },
62115
- { types: [2], optional: true }
62116
- ]
61563
+ _advance: function() {
61564
+ this.index++;
62117
61565
  },
62118
- replace: {
62119
- _func: this.functionReplace,
62120
- _signature: [
62121
- { types: [2] },
62122
- { types: [2] },
62123
- { types: [2] },
62124
- { types: [0], optional: true }
62125
- ]
61566
+ nud: function(token) {
61567
+ var left;
61568
+ var right;
61569
+ var expression;
61570
+ switch (token.type) {
61571
+ case TOK_LITERAL:
61572
+ return { type: "Literal", value: token.value };
61573
+ case TOK_UNQUOTEDIDENTIFIER:
61574
+ return { type: "Field", name: token.value };
61575
+ case TOK_QUOTEDIDENTIFIER:
61576
+ var node = { type: "Field", name: token.value };
61577
+ if (this._lookahead(0) === TOK_LPAREN) {
61578
+ throw new Error("Quoted identifier not allowed for function names.");
61579
+ }
61580
+ return node;
61581
+ case TOK_NOT:
61582
+ right = this.expression(bindingPower.Not);
61583
+ return { type: "NotExpression", children: [right] };
61584
+ case TOK_STAR:
61585
+ left = { type: "Identity" };
61586
+ right = null;
61587
+ if (this._lookahead(0) === TOK_RBRACKET) {
61588
+ right = { type: "Identity" };
61589
+ } else {
61590
+ right = this._parseProjectionRHS(bindingPower.Star);
61591
+ }
61592
+ return { type: "ValueProjection", children: [left, right] };
61593
+ case TOK_FILTER:
61594
+ return this.led(token.type, { type: "Identity" });
61595
+ case TOK_LBRACE:
61596
+ return this._parseMultiselectHash();
61597
+ case TOK_FLATTEN:
61598
+ left = { type: TOK_FLATTEN, children: [{ type: "Identity" }] };
61599
+ right = this._parseProjectionRHS(bindingPower.Flatten);
61600
+ return { type: "Projection", children: [left, right] };
61601
+ case TOK_LBRACKET:
61602
+ if (this._lookahead(0) === TOK_NUMBER || this._lookahead(0) === TOK_COLON) {
61603
+ right = this._parseIndexExpression();
61604
+ return this._projectIfSlice({ type: "Identity" }, right);
61605
+ } else if (this._lookahead(0) === TOK_STAR && this._lookahead(1) === TOK_RBRACKET) {
61606
+ this._advance();
61607
+ this._advance();
61608
+ right = this._parseProjectionRHS(bindingPower.Star);
61609
+ return {
61610
+ type: "Projection",
61611
+ children: [{ type: "Identity" }, right]
61612
+ };
61613
+ }
61614
+ return this._parseMultiselectList();
61615
+ case TOK_CURRENT:
61616
+ return { type: TOK_CURRENT };
61617
+ case TOK_EXPREF:
61618
+ expression = this.expression(bindingPower.Expref);
61619
+ return { type: "ExpressionReference", children: [expression] };
61620
+ case TOK_LPAREN:
61621
+ var args = [];
61622
+ while (this._lookahead(0) !== TOK_RPAREN) {
61623
+ if (this._lookahead(0) === TOK_CURRENT) {
61624
+ expression = { type: TOK_CURRENT };
61625
+ this._advance();
61626
+ } else {
61627
+ expression = this.expression(0);
61628
+ }
61629
+ args.push(expression);
61630
+ }
61631
+ this._match(TOK_RPAREN);
61632
+ return args[0];
61633
+ default:
61634
+ this._errorToken(token);
61635
+ }
62126
61636
  },
62127
- reverse: {
62128
- _func: this.functionReverse,
62129
- _signature: [{ types: [2, 3] }]
61637
+ led: function(tokenName, left) {
61638
+ var right;
61639
+ switch (tokenName) {
61640
+ case TOK_DOT:
61641
+ var rbp = bindingPower.Dot;
61642
+ if (this._lookahead(0) !== TOK_STAR) {
61643
+ right = this._parseDotRHS(rbp);
61644
+ return { type: "Subexpression", children: [left, right] };
61645
+ }
61646
+ this._advance();
61647
+ right = this._parseProjectionRHS(rbp);
61648
+ return { type: "ValueProjection", children: [left, right] };
61649
+ case TOK_PIPE:
61650
+ right = this.expression(bindingPower.Pipe);
61651
+ return { type: TOK_PIPE, children: [left, right] };
61652
+ case TOK_OR:
61653
+ right = this.expression(bindingPower.Or);
61654
+ return { type: "OrExpression", children: [left, right] };
61655
+ case TOK_AND:
61656
+ right = this.expression(bindingPower.And);
61657
+ return { type: "AndExpression", children: [left, right] };
61658
+ case TOK_LPAREN:
61659
+ var name = left.name;
61660
+ var args = [];
61661
+ var expression, node;
61662
+ while (this._lookahead(0) !== TOK_RPAREN) {
61663
+ if (this._lookahead(0) === TOK_CURRENT) {
61664
+ expression = { type: TOK_CURRENT };
61665
+ this._advance();
61666
+ } else {
61667
+ expression = this.expression(0);
61668
+ }
61669
+ if (this._lookahead(0) === TOK_COMMA) {
61670
+ this._match(TOK_COMMA);
61671
+ }
61672
+ args.push(expression);
61673
+ }
61674
+ this._match(TOK_RPAREN);
61675
+ node = { type: "Function", name, children: args };
61676
+ return node;
61677
+ case TOK_FILTER:
61678
+ var condition = this.expression(0);
61679
+ this._match(TOK_RBRACKET);
61680
+ if (this._lookahead(0) === TOK_FLATTEN) {
61681
+ right = { type: "Identity" };
61682
+ } else {
61683
+ right = this._parseProjectionRHS(bindingPower.Filter);
61684
+ }
61685
+ return { type: "FilterProjection", children: [left, right, condition] };
61686
+ case TOK_FLATTEN:
61687
+ var leftNode = { type: TOK_FLATTEN, children: [left] };
61688
+ var rightNode = this._parseProjectionRHS(bindingPower.Flatten);
61689
+ return { type: "Projection", children: [leftNode, rightNode] };
61690
+ case TOK_EQ:
61691
+ case TOK_NE:
61692
+ case TOK_GT:
61693
+ case TOK_GTE:
61694
+ case TOK_LT:
61695
+ case TOK_LTE:
61696
+ return this._parseComparator(left, tokenName);
61697
+ case TOK_LBRACKET:
61698
+ var token = this._lookaheadToken(0);
61699
+ if (token.type === TOK_NUMBER || token.type === TOK_COLON) {
61700
+ right = this._parseIndexExpression();
61701
+ return this._projectIfSlice(left, right);
61702
+ }
61703
+ this._match(TOK_STAR);
61704
+ this._match(TOK_RBRACKET);
61705
+ right = this._parseProjectionRHS(bindingPower.Star);
61706
+ return { type: "Projection", children: [left, right] };
61707
+ default:
61708
+ this._errorToken(this._lookaheadToken(0));
61709
+ }
62130
61710
  },
62131
- sort: {
62132
- _func: this.functionSort,
62133
- _signature: [{ types: [9, 8] }]
61711
+ _match: function(tokenType) {
61712
+ if (this._lookahead(0) === tokenType) {
61713
+ this._advance();
61714
+ } else {
61715
+ var t = this._lookaheadToken(0);
61716
+ var error46 = new Error("Expected " + tokenType + ", got: " + t.type);
61717
+ error46.name = "ParserError";
61718
+ throw error46;
61719
+ }
62134
61720
  },
62135
- sort_by: {
62136
- _func: this.functionSortBy,
62137
- _signature: [{ types: [3] }, { types: [6] }]
61721
+ _errorToken: function(token) {
61722
+ var error46 = new Error("Invalid token (" + token.type + '): "' + token.value + '"');
61723
+ error46.name = "ParserError";
61724
+ throw error46;
62138
61725
  },
62139
- split: {
62140
- _func: this.functionSplit,
62141
- _signature: [
62142
- { types: [2] },
62143
- { types: [2] },
62144
- { types: [0], optional: true }
62145
- ]
61726
+ _parseIndexExpression: function() {
61727
+ if (this._lookahead(0) === TOK_COLON || this._lookahead(1) === TOK_COLON) {
61728
+ return this._parseSliceExpression();
61729
+ } else {
61730
+ var node = {
61731
+ type: "Index",
61732
+ value: this._lookaheadToken(0).value
61733
+ };
61734
+ this._advance();
61735
+ this._match(TOK_RBRACKET);
61736
+ return node;
61737
+ }
62146
61738
  },
62147
- starts_with: {
62148
- _func: this.functionStartsWith,
62149
- _signature: [{ types: [2] }, { types: [2] }]
61739
+ _projectIfSlice: function(left, right) {
61740
+ var indexExpr = { type: "IndexExpression", children: [left, right] };
61741
+ if (right.type === "Slice") {
61742
+ return {
61743
+ type: "Projection",
61744
+ children: [indexExpr, this._parseProjectionRHS(bindingPower.Star)]
61745
+ };
61746
+ } else {
61747
+ return indexExpr;
61748
+ }
62150
61749
  },
62151
- sum: { _func: this.functionSum, _signature: [{ types: [8] }] },
62152
- to_array: { _func: this.functionToArray, _signature: [{ types: [1] }] },
62153
- to_number: { _func: this.functionToNumber, _signature: [{ types: [1] }] },
62154
- to_string: { _func: this.functionToString, _signature: [{ types: [1] }] },
62155
- trim: {
62156
- _func: this.functionTrim,
62157
- _signature: [{ types: [2] }, { types: [2], optional: true }]
61750
+ _parseSliceExpression: function() {
61751
+ var parts = [null, null, null];
61752
+ var index = 0;
61753
+ var currentToken = this._lookahead(0);
61754
+ while (currentToken !== TOK_RBRACKET && index < 3) {
61755
+ if (currentToken === TOK_COLON) {
61756
+ index++;
61757
+ this._advance();
61758
+ } else if (currentToken === TOK_NUMBER) {
61759
+ parts[index] = this._lookaheadToken(0).value;
61760
+ this._advance();
61761
+ } else {
61762
+ var t = this._lookahead(0);
61763
+ var error46 = new Error("Syntax error, unexpected token: " + t.value + "(" + t.type + ")");
61764
+ error46.name = "Parsererror";
61765
+ throw error46;
61766
+ }
61767
+ currentToken = this._lookahead(0);
61768
+ }
61769
+ this._match(TOK_RBRACKET);
61770
+ return {
61771
+ type: "Slice",
61772
+ children: parts
61773
+ };
62158
61774
  },
62159
- trim_left: {
62160
- _func: this.functionTrimLeft,
62161
- _signature: [{ types: [2] }, { types: [2], optional: true }]
61775
+ _parseComparator: function(left, comparator) {
61776
+ var right = this.expression(bindingPower[comparator]);
61777
+ return { type: "Comparator", name: comparator, children: [left, right] };
62162
61778
  },
62163
- trim_right: {
62164
- _func: this.functionTrimRight,
62165
- _signature: [{ types: [2] }, { types: [2], optional: true }]
61779
+ _parseDotRHS: function(rbp) {
61780
+ var lookahead = this._lookahead(0);
61781
+ var exprTokens = [TOK_UNQUOTEDIDENTIFIER, TOK_QUOTEDIDENTIFIER, TOK_STAR];
61782
+ if (exprTokens.indexOf(lookahead) >= 0) {
61783
+ return this.expression(rbp);
61784
+ } else if (lookahead === TOK_LBRACKET) {
61785
+ this._match(TOK_LBRACKET);
61786
+ return this._parseMultiselectList();
61787
+ } else if (lookahead === TOK_LBRACE) {
61788
+ this._match(TOK_LBRACE);
61789
+ return this._parseMultiselectHash();
61790
+ }
62166
61791
  },
62167
- type: { _func: this.functionType, _signature: [{ types: [1] }] },
62168
- zip: { _func: this.functionZip, _signature: [{ types: [3], variadic: true }] }
62169
- };
62170
- }
62171
- registerFunction(name, customFunction, signature, options) {
62172
- const result = this._registerInternal(name, customFunction, signature, options);
62173
- if (!result.success) {
62174
- throw new Error(result.message);
62175
- }
62176
- }
62177
- _registerInternal(name, customFunction, signature, options = {}) {
62178
- if (!name || typeof name !== "string" || name.trim() === "") {
62179
- return {
62180
- success: false,
62181
- reason: "invalid-name",
62182
- message: "Function name must be a non-empty string"
62183
- };
62184
- }
62185
- try {
62186
- this.validateInputSignatures(name, signature);
62187
- } catch (error46) {
62188
- return {
62189
- success: false,
62190
- reason: "invalid-signature",
62191
- message: error46 instanceof Error ? error46.message : "Invalid function signature"
62192
- };
62193
- }
62194
- const { override = false, warn = false } = options;
62195
- const exists2 = name in this._functionTable;
62196
- if (exists2 && !override) {
62197
- return {
62198
- success: false,
62199
- reason: "already-exists",
62200
- message: `Function already defined: ${name}(). Use { override: true } to replace it.`
62201
- };
62202
- }
62203
- if (exists2 && override && warn) {
62204
- console.warn(`Warning: Overriding existing function: ${name}()`);
62205
- }
62206
- this._functionTable[name] = {
62207
- _func: customFunction.bind(this),
62208
- _signature: signature
62209
- };
62210
- this._customFunctions.add(name);
62211
- const message = exists2 ? `Function ${name}() overridden successfully` : `Function ${name}() registered successfully`;
62212
- return { success: true, message };
62213
- }
62214
- register(name, customFunction, signature, options = {}) {
62215
- return this._registerInternal(name, customFunction, signature, options);
62216
- }
62217
- unregister(name) {
62218
- if (!this._customFunctions.has(name)) {
62219
- return false;
62220
- }
62221
- delete this._functionTable[name];
62222
- this._customFunctions.delete(name);
62223
- return true;
62224
- }
62225
- isRegistered(name) {
62226
- return name in this._functionTable;
62227
- }
62228
- getRegistered() {
62229
- return Object.keys(this._functionTable);
62230
- }
62231
- getCustomFunctions() {
62232
- return Array.from(this._customFunctions);
62233
- }
62234
- clearCustomFunctions() {
62235
- for (const name of this._customFunctions) {
62236
- delete this._functionTable[name];
62237
- }
62238
- this._customFunctions.clear();
62239
- }
62240
- callFunction(name, resolvedArgs) {
62241
- const functionEntry = this._functionTable[name];
62242
- if (functionEntry === undefined) {
62243
- throw new Error(`Unknown function: ${name}()`);
62244
- }
62245
- this.validateArgs(name, resolvedArgs, functionEntry._signature);
62246
- return functionEntry._func.call(this, resolvedArgs);
62247
- }
62248
- validateInputSignatures(name, signature) {
62249
- for (let i2 = 0;i2 < signature.length; i2 += 1) {
62250
- if ("variadic" in signature[i2] && i2 !== signature.length - 1) {
62251
- throw new Error(`Invalid arity: ${name}() 'variadic' argument ${i2 + 1} must occur last`);
62252
- }
62253
- }
62254
- }
62255
- validateArgs(name, args, signature) {
62256
- this.validateInputSignatures(name, signature);
62257
- this.validateArity(name, args, signature);
62258
- this.validateTypes(name, args, signature);
62259
- }
62260
- validateArity(name, args, signature) {
62261
- const numberOfRequiredArgs = signature.filter((argSignature) => !(argSignature.optional ?? false)).length;
62262
- const lastArgIsVariadic = signature[signature.length - 1]?.variadic ?? false;
62263
- const tooFewArgs = args.length < numberOfRequiredArgs;
62264
- const tooManyArgs = args.length > signature.length;
62265
- if (lastArgIsVariadic && tooFewArgs || !lastArgIsVariadic && (tooFewArgs || tooManyArgs)) {
62266
- const tooFewModifier = tooFewArgs && (!lastArgIsVariadic && numberOfRequiredArgs > 1 || lastArgIsVariadic) ? "at least " : "";
62267
- const pluralized = signature.length > 1;
62268
- throw new Error(`Invalid arity: ${name}() takes ${tooFewModifier}${numberOfRequiredArgs} argument${pluralized && "s" || ""} but received ${args.length}`);
62269
- }
62270
- }
62271
- validateTypes(name, args, signature) {
62272
- for (let i2 = 0;i2 < signature.length; i2 += 1) {
62273
- const currentSpec = signature[i2].types;
62274
- const actualType = this.getTypeName(args[i2]);
62275
- if (actualType === undefined) {
62276
- continue;
62277
- }
62278
- const typeMatched = currentSpec.some((expectedType) => this.typeMatches(actualType, expectedType, args[i2]));
62279
- if (!typeMatched) {
62280
- const expected = currentSpec.map((typeId) => this.TYPE_NAME_TABLE[typeId]).join(" | ");
62281
- throw new Error(`Invalid type: ${name}() expected argument ${i2 + 1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead.`);
62282
- }
62283
- }
62284
- }
62285
- typeMatches(actual, expected, argValue) {
62286
- if (expected === 1) {
62287
- return true;
62288
- }
62289
- if (expected === 9 || expected === 8 || expected === 10 || expected === 11 || expected === 3) {
62290
- if (expected === 3) {
62291
- return actual === 3;
62292
- }
62293
- if (actual === 3) {
62294
- let subtype;
62295
- if (expected === 8) {
62296
- subtype = 0;
62297
- } else if (expected === 10) {
62298
- subtype = 4;
62299
- } else if (expected === 9) {
62300
- subtype = 2;
62301
- } else if (expected === 11) {
62302
- subtype = 3;
62303
- }
62304
- const array2 = argValue;
62305
- for (let i2 = 0;i2 < array2.length; i2 += 1) {
62306
- const typeName = this.getTypeName(array2[i2]);
62307
- if (typeName !== undefined && subtype !== undefined && !this.typeMatches(typeName, subtype, array2[i2])) {
62308
- return false;
61792
+ _parseProjectionRHS: function(rbp) {
61793
+ var right;
61794
+ if (bindingPower[this._lookahead(0)] < 10) {
61795
+ right = { type: "Identity" };
61796
+ } else if (this._lookahead(0) === TOK_LBRACKET) {
61797
+ right = this.expression(rbp);
61798
+ } else if (this._lookahead(0) === TOK_FILTER) {
61799
+ right = this.expression(rbp);
61800
+ } else if (this._lookahead(0) === TOK_DOT) {
61801
+ this._match(TOK_DOT);
61802
+ right = this._parseDotRHS(rbp);
61803
+ } else {
61804
+ var t = this._lookaheadToken(0);
61805
+ var error46 = new Error("Sytanx error, unexpected token: " + t.value + "(" + t.type + ")");
61806
+ error46.name = "ParserError";
61807
+ throw error46;
61808
+ }
61809
+ return right;
61810
+ },
61811
+ _parseMultiselectList: function() {
61812
+ var expressions = [];
61813
+ while (this._lookahead(0) !== TOK_RBRACKET) {
61814
+ var expression = this.expression(0);
61815
+ expressions.push(expression);
61816
+ if (this._lookahead(0) === TOK_COMMA) {
61817
+ this._match(TOK_COMMA);
61818
+ if (this._lookahead(0) === TOK_RBRACKET) {
61819
+ throw new Error("Unexpected token Rbracket");
61820
+ }
62309
61821
  }
62310
61822
  }
62311
- return true;
62312
- }
62313
- } else {
62314
- return actual === expected;
62315
- }
62316
- return false;
62317
- }
62318
- getTypeName(obj) {
62319
- if (obj === null) {
62320
- return 7;
62321
- }
62322
- if (typeof obj === "string") {
62323
- return 2;
62324
- }
62325
- if (typeof obj === "number") {
62326
- return 0;
62327
- }
62328
- if (typeof obj === "boolean") {
62329
- return 5;
62330
- }
62331
- if (Array.isArray(obj)) {
62332
- return 3;
62333
- }
62334
- if (typeof obj === "object") {
62335
- if (obj.expref) {
62336
- return 6;
62337
- }
62338
- return 4;
62339
- }
62340
- return;
62341
- }
62342
- createKeyFunction(exprefNode, allowedTypes) {
62343
- const interpreter = this._interpreter;
62344
- const keyFunc = (x) => {
62345
- const current = interpreter.visit(exprefNode, x);
62346
- if (!allowedTypes.includes(this.getTypeName(current))) {
62347
- const msg = `Invalid type: expected one of (${allowedTypes.map((t) => this.TYPE_NAME_TABLE[t]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(current)]}`;
62348
- throw new Error(msg);
62349
- }
62350
- return current;
62351
- };
62352
- return keyFunc;
62353
- }
62354
- functionAvg = ([inputArray]) => {
62355
- if (!inputArray || inputArray.length == 0) {
62356
- return null;
62357
- }
62358
- let sum = 0;
62359
- for (let i2 = 0;i2 < inputArray.length; i2 += 1) {
62360
- sum += inputArray[i2];
62361
- }
62362
- return sum / inputArray.length;
62363
- };
62364
- functionContains = ([
62365
- searchable,
62366
- searchValue
62367
- ]) => {
62368
- if (Array.isArray(searchable)) {
62369
- const array2 = searchable;
62370
- return array2.includes(searchValue);
62371
- }
62372
- if (typeof searchable === "string") {
62373
- const text = searchable;
62374
- if (typeof searchValue === "string") {
62375
- return text.includes(searchValue);
62376
- }
62377
- }
62378
- return null;
62379
- };
62380
- functionEndsWith = (resolvedArgs) => {
62381
- const [searchStr, suffix] = resolvedArgs;
62382
- return searchStr.includes(suffix, searchStr.length - suffix.length);
62383
- };
62384
- functionFindFirst = this.createFindFunction(findFirst);
62385
- functionFindLast = this.createFindFunction(findLast);
62386
- createFindFunction(findFn) {
62387
- return (resolvedArgs) => {
62388
- const subject = resolvedArgs[0];
62389
- const search2 = resolvedArgs[1];
62390
- const start = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined;
62391
- const end = resolvedArgs.length > 3 ? resolvedArgs[3] : undefined;
62392
- return findFn(subject, search2, start, end);
62393
- };
62394
- }
62395
- functionFromItems = ([array2]) => {
62396
- array2.map((pair) => {
62397
- if (pair.length != 2 || typeof pair[0] !== "string") {
62398
- throw new Error("invalid value, each array must contain two elements, a pair of string and value");
62399
- }
62400
- });
62401
- return Object.fromEntries(array2);
62402
- };
62403
- functionGroupBy = ([array2, exprefNode]) => {
62404
- const keyFunction = this.createKeyFunction(exprefNode, [2]);
62405
- return array2.reduce((acc, cur) => {
62406
- const k = keyFunction(cur ?? {});
62407
- const target = acc[k] = acc[k] || [];
62408
- target.push(cur);
62409
- return acc;
62410
- }, {});
62411
- };
62412
- functionItems = ([inputValue]) => {
62413
- return Object.entries(inputValue);
62414
- };
62415
- functionJoin = (resolvedArgs) => {
62416
- const [joinChar, listJoin] = resolvedArgs;
62417
- return listJoin.join(joinChar);
62418
- };
62419
- functionLength = ([inputValue]) => {
62420
- if (typeof inputValue === "string") {
62421
- return new Text(inputValue).length;
62422
- }
62423
- if (Array.isArray(inputValue)) {
62424
- return inputValue.length;
62425
- }
62426
- return Object.keys(inputValue).length;
62427
- };
62428
- functionMap = ([exprefNode, elements]) => {
62429
- if (!this._interpreter) {
62430
- return [];
62431
- }
62432
- const mapped = [];
62433
- const interpreter = this._interpreter;
62434
- for (let i2 = 0;i2 < elements.length; i2 += 1) {
62435
- mapped.push(interpreter.visit(exprefNode, elements[i2]));
62436
- }
62437
- return mapped;
62438
- };
62439
- functionMax = ([inputValue]) => {
62440
- if (!inputValue.length) {
62441
- return null;
62442
- }
62443
- const typeName = this.getTypeName(inputValue[0]);
62444
- if (typeName === 0) {
62445
- return Math.max(...inputValue);
62446
- }
62447
- const elements = inputValue;
62448
- let maxElement = elements[0];
62449
- for (let i2 = 1;i2 < elements.length; i2 += 1) {
62450
- if (maxElement.localeCompare(elements[i2]) < 0) {
62451
- maxElement = elements[i2];
62452
- }
62453
- }
62454
- return maxElement;
62455
- };
62456
- functionMaxBy = (resolvedArgs) => {
62457
- const exprefNode = resolvedArgs[1];
62458
- const resolvedArray = resolvedArgs[0];
62459
- const keyFunction = this.createKeyFunction(exprefNode, [0, 2]);
62460
- let maxNumber = -Infinity;
62461
- let maxRecord;
62462
- let current;
62463
- for (let i2 = 0;i2 < resolvedArray.length; i2 += 1) {
62464
- current = keyFunction && keyFunction(resolvedArray[i2]);
62465
- if (current !== undefined && current > maxNumber) {
62466
- maxNumber = current;
62467
- maxRecord = resolvedArray[i2];
62468
- }
62469
- }
62470
- return maxRecord || null;
62471
- };
62472
- functionMerge = (resolvedArgs) => {
62473
- let merged = {};
62474
- for (let i2 = 0;i2 < resolvedArgs.length; i2 += 1) {
62475
- const current = resolvedArgs[i2];
62476
- merged = Object.assign(merged, current);
62477
- }
62478
- return merged;
62479
- };
62480
- functionMin = ([inputValue]) => {
62481
- if (!inputValue.length) {
62482
- return null;
62483
- }
62484
- const typeName = this.getTypeName(inputValue[0]);
62485
- if (typeName === 0) {
62486
- return Math.min(...inputValue);
62487
- }
62488
- const elements = inputValue;
62489
- let minElement = elements[0];
62490
- for (let i2 = 1;i2 < elements.length; i2 += 1) {
62491
- if (elements[i2].localeCompare(minElement) < 0) {
62492
- minElement = elements[i2];
62493
- }
62494
- }
62495
- return minElement;
62496
- };
62497
- functionMinBy = (resolvedArgs) => {
62498
- const exprefNode = resolvedArgs[1];
62499
- const resolvedArray = resolvedArgs[0];
62500
- const keyFunction = this.createKeyFunction(exprefNode, [0, 2]);
62501
- let minNumber = Infinity;
62502
- let minRecord;
62503
- let current;
62504
- for (let i2 = 0;i2 < resolvedArray.length; i2 += 1) {
62505
- current = keyFunction && keyFunction(resolvedArray[i2]);
62506
- if (current !== undefined && current < minNumber) {
62507
- minNumber = current;
62508
- minRecord = resolvedArray[i2];
62509
- }
62510
- }
62511
- return minRecord || null;
62512
- };
62513
- functionNotNull = (resolvedArgs) => {
62514
- for (let i2 = 0;i2 < resolvedArgs.length; i2 += 1) {
62515
- if (this.getTypeName(resolvedArgs[i2]) !== 7) {
62516
- return resolvedArgs[i2];
62517
- }
62518
- }
62519
- return null;
62520
- };
62521
- functionPadLeft = this.createPadFunction(padLeft);
62522
- functionPadRight = this.createPadFunction(padRight);
62523
- createPadFunction(padFn) {
62524
- return (resolvedArgs) => {
62525
- const subject = resolvedArgs[0];
62526
- const width = resolvedArgs[1];
62527
- const padding = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined;
62528
- return padFn(subject, width, padding);
62529
- };
62530
- }
62531
- functionReplace = (resolvedArgs) => {
62532
- const subject = resolvedArgs[0];
62533
- const string4 = resolvedArgs[1];
62534
- const by = resolvedArgs[2];
62535
- return replace(subject, string4, by, resolvedArgs.length > 3 ? resolvedArgs[3] : undefined);
62536
- };
62537
- functionSplit = (resolvedArgs) => {
62538
- const subject = resolvedArgs[0];
62539
- const search2 = resolvedArgs[1];
62540
- return split(subject, search2, resolvedArgs.length > 2 ? resolvedArgs[2] : undefined);
62541
- };
62542
- functionReverse = ([inputValue]) => {
62543
- const typeName = this.getTypeName(inputValue);
62544
- if (typeName === 2) {
62545
- return new Text(inputValue).reverse();
62546
- }
62547
- const reversedArray = inputValue.slice(0);
62548
- reversedArray.reverse();
62549
- return reversedArray;
62550
- };
62551
- functionSort = ([inputValue]) => {
62552
- if (inputValue.length == 0) {
62553
- return inputValue;
62554
- }
62555
- if (typeof inputValue[0] === "string") {
62556
- return [...inputValue].sort(Text.comparer);
62557
- }
62558
- return [...inputValue].sort();
62559
- };
62560
- functionSortBy = (resolvedArgs) => {
62561
- const sortedArray = resolvedArgs[0].slice(0);
62562
- if (sortedArray.length === 0) {
62563
- return sortedArray;
62564
- }
62565
- const interpreter = this._interpreter;
62566
- const exprefNode = resolvedArgs[1];
62567
- const requiredType = this.getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
62568
- if (requiredType !== undefined && ![0, 2].includes(requiredType)) {
62569
- throw new Error(`Invalid type: unexpected type (${this.TYPE_NAME_TABLE[requiredType]})`);
62570
- }
62571
- function throwInvalidTypeError(rt, item) {
62572
- throw new Error(`Invalid type: expected (${rt.TYPE_NAME_TABLE[requiredType]}), received ${rt.TYPE_NAME_TABLE[rt.getTypeName(item)]}`);
62573
- }
62574
- return sortedArray.sort((a, b) => {
62575
- const exprA = interpreter.visit(exprefNode, a);
62576
- const exprB = interpreter.visit(exprefNode, b);
62577
- if (this.getTypeName(exprA) !== requiredType) {
62578
- throwInvalidTypeError(this, exprA);
62579
- } else if (this.getTypeName(exprB) !== requiredType) {
62580
- throwInvalidTypeError(this, exprB);
62581
- }
62582
- if (requiredType === 2) {
62583
- return Text.comparer(exprA, exprB);
62584
- }
62585
- return exprA - exprB;
62586
- });
62587
- };
62588
- functionStartsWith = ([searchable, searchStr]) => {
62589
- return searchable.startsWith(searchStr);
62590
- };
62591
- functionSum = ([inputValue]) => {
62592
- return inputValue.reduce((x, y) => x + y, 0);
62593
- };
62594
- functionToArray = ([inputValue]) => {
62595
- if (this.getTypeName(inputValue) === 3) {
62596
- return inputValue;
62597
- }
62598
- return [inputValue];
62599
- };
62600
- functionToNumber = ([inputValue]) => {
62601
- const typeName = this.getTypeName(inputValue);
62602
- let convertedValue;
62603
- if (typeName === 0) {
62604
- return inputValue;
62605
- }
62606
- if (typeName === 2) {
62607
- convertedValue = +inputValue;
62608
- if (!isNaN(convertedValue)) {
62609
- return convertedValue;
61823
+ this._match(TOK_RBRACKET);
61824
+ return { type: "MultiSelectList", children: expressions };
61825
+ },
61826
+ _parseMultiselectHash: function() {
61827
+ var pairs2 = [];
61828
+ var identifierTypes = [TOK_UNQUOTEDIDENTIFIER, TOK_QUOTEDIDENTIFIER];
61829
+ var keyToken, keyName, value, node;
61830
+ for (;; ) {
61831
+ keyToken = this._lookaheadToken(0);
61832
+ if (identifierTypes.indexOf(keyToken.type) < 0) {
61833
+ throw new Error("Expecting an identifier token, got: " + keyToken.type);
61834
+ }
61835
+ keyName = keyToken.value;
61836
+ this._advance();
61837
+ this._match(TOK_COLON);
61838
+ value = this.expression(0);
61839
+ node = { type: "KeyValuePair", name: keyName, value };
61840
+ pairs2.push(node);
61841
+ if (this._lookahead(0) === TOK_COMMA) {
61842
+ this._match(TOK_COMMA);
61843
+ } else if (this._lookahead(0) === TOK_RBRACE) {
61844
+ this._match(TOK_RBRACE);
61845
+ break;
61846
+ }
61847
+ }
61848
+ return { type: "MultiSelectHash", children: pairs2 };
62610
61849
  }
62611
- }
62612
- return null;
62613
- };
62614
- functionToString = ([inputValue]) => {
62615
- if (this.getTypeName(inputValue) === 2) {
62616
- return inputValue;
62617
- }
62618
- return JSON.stringify(inputValue);
62619
- };
62620
- functionTrim = this.createTrimFunction(trim2);
62621
- functionTrimLeft = this.createTrimFunction(trimLeft);
62622
- functionTrimRight = this.createTrimFunction(trimRight);
62623
- createTrimFunction(trimFn) {
62624
- return (resolvedArgs) => {
62625
- const subject = resolvedArgs[0];
62626
- const chars = resolvedArgs.length > 1 ? resolvedArgs[1] : undefined;
62627
- return trimFn(subject, chars);
62628
61850
  };
62629
- }
62630
- functionType = ([inputValue]) => {
62631
- switch (this.getTypeName(inputValue)) {
62632
- case 0:
62633
- return "number";
62634
- case 2:
62635
- return "string";
62636
- case 3:
62637
- return "array";
62638
- case 4:
62639
- return "object";
62640
- case 5:
62641
- return "boolean";
62642
- case 7:
62643
- return "null";
62644
- default:
62645
- throw new Error("invalid-type");
62646
- }
62647
- };
62648
- functionZip = (array2) => {
62649
- const length = Math.min(...array2.map((arr) => arr.length));
62650
- const result = Array(length).fill(null).map((_, index) => array2.map((arr) => arr[index]));
62651
- return result;
62652
- };
62653
- }, ScopeChain = class _ScopeChain {
62654
- inner = undefined;
62655
- data = {};
62656
- get currentScopeData() {
62657
- return this.data;
62658
- }
62659
- withScope(data) {
62660
- const outer = new _ScopeChain;
62661
- outer.inner = this;
62662
- outer.data = data;
62663
- return outer;
62664
- }
62665
- getValue(identifier) {
62666
- if (Object.prototype.hasOwnProperty.call(this.data, identifier)) {
62667
- return this.data[identifier];
62668
- }
62669
- if (this.inner) {
62670
- return this.inner.getValue(identifier);
61851
+ function TreeInterpreter(runtime2) {
61852
+ this.runtime = runtime2;
62671
61853
  }
62672
- return null;
62673
- }
62674
- }, emptyScopeChain, TreeInterpreter = class _TreeInterpreter {
62675
- runtime;
62676
- _rootValue = null;
62677
- _scope;
62678
- constructor() {
62679
- this.runtime = new Runtime(this);
62680
- this._scope = new ScopeChain;
62681
- }
62682
- withScope(scope) {
62683
- const interpreter = new _TreeInterpreter;
62684
- interpreter.runtime._functionTable = this.runtime._functionTable;
62685
- interpreter._rootValue = this._rootValue;
62686
- interpreter._scope = this._scope.withScope(scope);
62687
- return interpreter;
62688
- }
62689
- search(node, value) {
62690
- this._rootValue = value;
62691
- this._scope = emptyScopeChain;
62692
- return this.visit(node, value);
62693
- }
62694
- visit(node, value) {
62695
- switch (node.type) {
62696
- case "Ternary": {
62697
- const condition = this.visit(node.condition, value);
62698
- if (!isFalse(condition)) {
62699
- return this.visit(node.trueExpr, value);
62700
- }
62701
- return this.visit(node.falseExpr, value);
62702
- }
62703
- case "Field":
62704
- const identifier = node.name;
62705
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
62706
- return null;
61854
+ TreeInterpreter.prototype = {
61855
+ search: function(node, value) {
61856
+ return this.visit(node, value);
61857
+ },
61858
+ visit: function(node, value) {
61859
+ var matched, current, result, first, second, field, left, right, collected, i2;
61860
+ switch (node.type) {
61861
+ case "Field":
61862
+ if (value !== null && isObject3(value)) {
61863
+ field = value[node.name];
61864
+ if (field === undefined) {
61865
+ return null;
61866
+ } else {
61867
+ return field;
61868
+ }
61869
+ }
61870
+ return null;
61871
+ case "Subexpression":
61872
+ result = this.visit(node.children[0], value);
61873
+ for (i2 = 1;i2 < node.children.length; i2++) {
61874
+ result = this.visit(node.children[1], result);
61875
+ if (result === null) {
61876
+ return null;
61877
+ }
61878
+ }
61879
+ return result;
61880
+ case "IndexExpression":
61881
+ left = this.visit(node.children[0], value);
61882
+ right = this.visit(node.children[1], left);
61883
+ return right;
61884
+ case "Index":
61885
+ if (!isArray2(value)) {
61886
+ return null;
61887
+ }
61888
+ var index = node.value;
61889
+ if (index < 0) {
61890
+ index = value.length + index;
61891
+ }
61892
+ result = value[index];
61893
+ if (result === undefined) {
61894
+ result = null;
61895
+ }
61896
+ return result;
61897
+ case "Slice":
61898
+ if (!isArray2(value)) {
61899
+ return null;
61900
+ }
61901
+ var sliceParams = node.children.slice(0);
61902
+ var computed = this.computeSliceParams(value.length, sliceParams);
61903
+ var start = computed[0];
61904
+ var stop = computed[1];
61905
+ var step = computed[2];
61906
+ result = [];
61907
+ if (step > 0) {
61908
+ for (i2 = start;i2 < stop; i2 += step) {
61909
+ result.push(value[i2]);
61910
+ }
61911
+ } else {
61912
+ for (i2 = start;i2 > stop; i2 += step) {
61913
+ result.push(value[i2]);
61914
+ }
61915
+ }
61916
+ return result;
61917
+ case "Projection":
61918
+ var base = this.visit(node.children[0], value);
61919
+ if (!isArray2(base)) {
61920
+ return null;
61921
+ }
61922
+ collected = [];
61923
+ for (i2 = 0;i2 < base.length; i2++) {
61924
+ current = this.visit(node.children[1], base[i2]);
61925
+ if (current !== null) {
61926
+ collected.push(current);
61927
+ }
61928
+ }
61929
+ return collected;
61930
+ case "ValueProjection":
61931
+ base = this.visit(node.children[0], value);
61932
+ if (!isObject3(base)) {
61933
+ return null;
61934
+ }
61935
+ collected = [];
61936
+ var values = objValues(base);
61937
+ for (i2 = 0;i2 < values.length; i2++) {
61938
+ current = this.visit(node.children[1], values[i2]);
61939
+ if (current !== null) {
61940
+ collected.push(current);
61941
+ }
61942
+ }
61943
+ return collected;
61944
+ case "FilterProjection":
61945
+ base = this.visit(node.children[0], value);
61946
+ if (!isArray2(base)) {
61947
+ return null;
61948
+ }
61949
+ var filtered = [];
61950
+ var finalResults = [];
61951
+ for (i2 = 0;i2 < base.length; i2++) {
61952
+ matched = this.visit(node.children[2], base[i2]);
61953
+ if (!isFalse(matched)) {
61954
+ filtered.push(base[i2]);
61955
+ }
61956
+ }
61957
+ for (var j = 0;j < filtered.length; j++) {
61958
+ current = this.visit(node.children[1], filtered[j]);
61959
+ if (current !== null) {
61960
+ finalResults.push(current);
61961
+ }
61962
+ }
61963
+ return finalResults;
61964
+ case "Comparator":
61965
+ first = this.visit(node.children[0], value);
61966
+ second = this.visit(node.children[1], value);
61967
+ switch (node.name) {
61968
+ case TOK_EQ:
61969
+ result = strictDeepEqual(first, second);
61970
+ break;
61971
+ case TOK_NE:
61972
+ result = !strictDeepEqual(first, second);
61973
+ break;
61974
+ case TOK_GT:
61975
+ result = first > second;
61976
+ break;
61977
+ case TOK_GTE:
61978
+ result = first >= second;
61979
+ break;
61980
+ case TOK_LT:
61981
+ result = first < second;
61982
+ break;
61983
+ case TOK_LTE:
61984
+ result = first <= second;
61985
+ break;
61986
+ default:
61987
+ throw new Error("Unknown comparator: " + node.name);
61988
+ }
61989
+ return result;
61990
+ case TOK_FLATTEN:
61991
+ var original = this.visit(node.children[0], value);
61992
+ if (!isArray2(original)) {
61993
+ return null;
61994
+ }
61995
+ var merged = [];
61996
+ for (i2 = 0;i2 < original.length; i2++) {
61997
+ current = original[i2];
61998
+ if (isArray2(current)) {
61999
+ merged.push.apply(merged, current);
62000
+ } else {
62001
+ merged.push(current);
62002
+ }
62003
+ }
62004
+ return merged;
62005
+ case "Identity":
62006
+ return value;
62007
+ case "MultiSelectList":
62008
+ if (value === null) {
62009
+ return null;
62010
+ }
62011
+ collected = [];
62012
+ for (i2 = 0;i2 < node.children.length; i2++) {
62013
+ collected.push(this.visit(node.children[i2], value));
62014
+ }
62015
+ return collected;
62016
+ case "MultiSelectHash":
62017
+ if (value === null) {
62018
+ return null;
62019
+ }
62020
+ collected = {};
62021
+ var child;
62022
+ for (i2 = 0;i2 < node.children.length; i2++) {
62023
+ child = node.children[i2];
62024
+ collected[child.name] = this.visit(child.value, value);
62025
+ }
62026
+ return collected;
62027
+ case "OrExpression":
62028
+ matched = this.visit(node.children[0], value);
62029
+ if (isFalse(matched)) {
62030
+ matched = this.visit(node.children[1], value);
62031
+ }
62032
+ return matched;
62033
+ case "AndExpression":
62034
+ first = this.visit(node.children[0], value);
62035
+ if (isFalse(first) === true) {
62036
+ return first;
62037
+ }
62038
+ return this.visit(node.children[1], value);
62039
+ case "NotExpression":
62040
+ first = this.visit(node.children[0], value);
62041
+ return isFalse(first);
62042
+ case "Literal":
62043
+ return node.value;
62044
+ case TOK_PIPE:
62045
+ left = this.visit(node.children[0], value);
62046
+ return this.visit(node.children[1], left);
62047
+ case TOK_CURRENT:
62048
+ return value;
62049
+ case "Function":
62050
+ var resolvedArgs = [];
62051
+ for (i2 = 0;i2 < node.children.length; i2++) {
62052
+ resolvedArgs.push(this.visit(node.children[i2], value));
62053
+ }
62054
+ return this.runtime.callFunction(node.name, resolvedArgs);
62055
+ case "ExpressionReference":
62056
+ var refNode = node.children[0];
62057
+ refNode.jmespathType = TOK_EXPREF;
62058
+ return refNode;
62059
+ default:
62060
+ throw new Error("Unknown node type: " + node.type);
62707
62061
  }
62708
- return value[identifier] ?? null;
62709
- case "LetExpression": {
62710
- const { bindings, expression } = node;
62711
- let scope = {};
62712
- bindings.forEach((binding) => {
62713
- const reference = this.visit(binding, value);
62714
- scope = {
62715
- ...scope,
62716
- ...reference
62717
- };
62718
- });
62719
- return this.withScope(scope).visit(expression, value);
62720
- }
62721
- case "Binding": {
62722
- const { variable, reference } = node;
62723
- const result = this.visit(reference, value);
62724
- return { [variable]: result };
62725
- }
62726
- case "Variable": {
62727
- const variable = node.name;
62728
- if (!this._scope.getValue(variable) && !Object.prototype.hasOwnProperty.call(this._scope.currentScopeData, variable)) {
62729
- throw new Error(`Error referencing undefined variable ${variable}`);
62062
+ },
62063
+ computeSliceParams: function(arrayLength, sliceParams) {
62064
+ var start = sliceParams[0];
62065
+ var stop = sliceParams[1];
62066
+ var step = sliceParams[2];
62067
+ var computed = [null, null, null];
62068
+ if (step === null) {
62069
+ step = 1;
62070
+ } else if (step === 0) {
62071
+ var error46 = new Error("Invalid slice, step cannot be 0");
62072
+ error46.name = "RuntimeError";
62073
+ throw error46;
62074
+ }
62075
+ var stepValueNegative = step < 0 ? true : false;
62076
+ if (start === null) {
62077
+ start = stepValueNegative ? arrayLength - 1 : 0;
62078
+ } else {
62079
+ start = this.capSliceRange(arrayLength, start, step);
62730
62080
  }
62731
- return this._scope.getValue(variable);
62732
- }
62733
- case "IndexExpression":
62734
- return this.visit(node.right, this.visit(node.left, value));
62735
- case "Subexpression": {
62736
- const result = this.visit(node.left, value);
62737
- return result != null ? this.visit(node.right, result) ?? null : null;
62738
- }
62739
- case "Index": {
62740
- if (!Array.isArray(value)) {
62741
- return null;
62081
+ if (stop === null) {
62082
+ stop = stepValueNegative ? -1 : arrayLength;
62083
+ } else {
62084
+ stop = this.capSliceRange(arrayLength, stop, step);
62742
62085
  }
62743
- const index = node.value < 0 ? value.length + node.value : node.value;
62744
- return value[index] ?? null;
62086
+ computed[0] = start;
62087
+ computed[1] = stop;
62088
+ computed[2] = step;
62089
+ return computed;
62090
+ },
62091
+ capSliceRange: function(arrayLength, actualValue, step) {
62092
+ if (actualValue < 0) {
62093
+ actualValue += arrayLength;
62094
+ if (actualValue < 0) {
62095
+ actualValue = step < 0 ? -1 : 0;
62096
+ }
62097
+ } else if (actualValue >= arrayLength) {
62098
+ actualValue = step < 0 ? arrayLength - 1 : arrayLength;
62099
+ }
62100
+ return actualValue;
62745
62101
  }
62746
- case "Slice": {
62747
- if (!Array.isArray(value) && typeof value !== "string") {
62748
- return null;
62102
+ };
62103
+ function Runtime(interpreter) {
62104
+ this._interpreter = interpreter;
62105
+ this.functionTable = {
62106
+ abs: { _func: this._functionAbs, _signature: [{ types: [TYPE_NUMBER] }] },
62107
+ avg: { _func: this._functionAvg, _signature: [{ types: [TYPE_ARRAY_NUMBER] }] },
62108
+ ceil: { _func: this._functionCeil, _signature: [{ types: [TYPE_NUMBER] }] },
62109
+ contains: {
62110
+ _func: this._functionContains,
62111
+ _signature: [
62112
+ { types: [TYPE_STRING, TYPE_ARRAY] },
62113
+ { types: [TYPE_ANY] }
62114
+ ]
62115
+ },
62116
+ ends_with: {
62117
+ _func: this._functionEndsWith,
62118
+ _signature: [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }]
62119
+ },
62120
+ floor: { _func: this._functionFloor, _signature: [{ types: [TYPE_NUMBER] }] },
62121
+ length: {
62122
+ _func: this._functionLength,
62123
+ _signature: [{ types: [TYPE_STRING, TYPE_ARRAY, TYPE_OBJECT] }]
62124
+ },
62125
+ map: {
62126
+ _func: this._functionMap,
62127
+ _signature: [{ types: [TYPE_EXPREF] }, { types: [TYPE_ARRAY] }]
62128
+ },
62129
+ max: {
62130
+ _func: this._functionMax,
62131
+ _signature: [{ types: [TYPE_ARRAY_NUMBER, TYPE_ARRAY_STRING] }]
62132
+ },
62133
+ merge: {
62134
+ _func: this._functionMerge,
62135
+ _signature: [{ types: [TYPE_OBJECT], variadic: true }]
62136
+ },
62137
+ max_by: {
62138
+ _func: this._functionMaxBy,
62139
+ _signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
62140
+ },
62141
+ sum: { _func: this._functionSum, _signature: [{ types: [TYPE_ARRAY_NUMBER] }] },
62142
+ starts_with: {
62143
+ _func: this._functionStartsWith,
62144
+ _signature: [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }]
62145
+ },
62146
+ min: {
62147
+ _func: this._functionMin,
62148
+ _signature: [{ types: [TYPE_ARRAY_NUMBER, TYPE_ARRAY_STRING] }]
62149
+ },
62150
+ min_by: {
62151
+ _func: this._functionMinBy,
62152
+ _signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
62153
+ },
62154
+ type: { _func: this._functionType, _signature: [{ types: [TYPE_ANY] }] },
62155
+ keys: { _func: this._functionKeys, _signature: [{ types: [TYPE_OBJECT] }] },
62156
+ values: { _func: this._functionValues, _signature: [{ types: [TYPE_OBJECT] }] },
62157
+ sort: { _func: this._functionSort, _signature: [{ types: [TYPE_ARRAY_STRING, TYPE_ARRAY_NUMBER] }] },
62158
+ sort_by: {
62159
+ _func: this._functionSortBy,
62160
+ _signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
62161
+ },
62162
+ join: {
62163
+ _func: this._functionJoin,
62164
+ _signature: [
62165
+ { types: [TYPE_STRING] },
62166
+ { types: [TYPE_ARRAY_STRING] }
62167
+ ]
62168
+ },
62169
+ reverse: {
62170
+ _func: this._functionReverse,
62171
+ _signature: [{ types: [TYPE_STRING, TYPE_ARRAY] }]
62172
+ },
62173
+ to_array: { _func: this._functionToArray, _signature: [{ types: [TYPE_ANY] }] },
62174
+ to_string: { _func: this._functionToString, _signature: [{ types: [TYPE_ANY] }] },
62175
+ to_number: { _func: this._functionToNumber, _signature: [{ types: [TYPE_ANY] }] },
62176
+ not_null: {
62177
+ _func: this._functionNotNull,
62178
+ _signature: [{ types: [TYPE_ANY], variadic: true }]
62749
62179
  }
62750
- const { start, stop, step } = this.computeSliceParams(value.length, node);
62751
- if (typeof value === "string") {
62752
- const chars = [...value];
62753
- const sliced = this.slice(chars, start, stop, step);
62754
- return sliced.join("");
62755
- } else {
62756
- return this.slice(value, start, stop, step);
62180
+ };
62181
+ }
62182
+ Runtime.prototype = {
62183
+ callFunction: function(name, resolvedArgs) {
62184
+ var functionEntry = this.functionTable[name];
62185
+ if (functionEntry === undefined) {
62186
+ throw new Error("Unknown function: " + name + "()");
62757
62187
  }
62758
- }
62759
- case "Projection": {
62760
- const { left, right } = node;
62761
- let allowString = false;
62762
- if (left.type === "IndexExpression" && left.right.type === "Slice") {
62763
- allowString = true;
62188
+ this._validateArgs(name, resolvedArgs, functionEntry._signature);
62189
+ return functionEntry._func.call(this, resolvedArgs);
62190
+ },
62191
+ _validateArgs: function(name, args, signature) {
62192
+ var pluralized;
62193
+ if (signature[signature.length - 1].variadic) {
62194
+ if (args.length < signature.length) {
62195
+ pluralized = signature.length === 1 ? " argument" : " arguments";
62196
+ throw new Error("ArgumentError: " + name + "() " + "takes at least" + signature.length + pluralized + " but received " + args.length);
62197
+ }
62198
+ } else if (args.length !== signature.length) {
62199
+ pluralized = signature.length === 1 ? " argument" : " arguments";
62200
+ throw new Error("ArgumentError: " + name + "() " + "takes " + signature.length + pluralized + " but received " + args.length);
62201
+ }
62202
+ var currentSpec;
62203
+ var actualType;
62204
+ var typeMatched;
62205
+ for (var i2 = 0;i2 < signature.length; i2++) {
62206
+ typeMatched = false;
62207
+ currentSpec = signature[i2].types;
62208
+ actualType = this._getTypeName(args[i2]);
62209
+ for (var j = 0;j < currentSpec.length; j++) {
62210
+ if (this._typeMatches(actualType, currentSpec[j], args[i2])) {
62211
+ typeMatched = true;
62212
+ break;
62213
+ }
62214
+ }
62215
+ if (!typeMatched) {
62216
+ var expected = currentSpec.map(function(typeIdentifier) {
62217
+ return TYPE_NAME_TABLE[typeIdentifier];
62218
+ }).join(",");
62219
+ throw new Error("TypeError: " + name + "() " + "expected argument " + (i2 + 1) + " to be type " + expected + " but received type " + TYPE_NAME_TABLE[actualType] + " instead.");
62220
+ }
62764
62221
  }
62765
- const base = this.visit(left, value);
62766
- if (allowString && typeof base === "string") {
62767
- return this.visit(right, base);
62222
+ },
62223
+ _typeMatches: function(actual, expected, argValue) {
62224
+ if (expected === TYPE_ANY) {
62225
+ return true;
62768
62226
  }
62769
- if (!Array.isArray(base)) {
62770
- return null;
62227
+ if (expected === TYPE_ARRAY_STRING || expected === TYPE_ARRAY_NUMBER || expected === TYPE_ARRAY) {
62228
+ if (expected === TYPE_ARRAY) {
62229
+ return actual === TYPE_ARRAY;
62230
+ } else if (actual === TYPE_ARRAY) {
62231
+ var subtype;
62232
+ if (expected === TYPE_ARRAY_NUMBER) {
62233
+ subtype = TYPE_NUMBER;
62234
+ } else if (expected === TYPE_ARRAY_STRING) {
62235
+ subtype = TYPE_STRING;
62236
+ }
62237
+ for (var i2 = 0;i2 < argValue.length; i2++) {
62238
+ if (!this._typeMatches(this._getTypeName(argValue[i2]), subtype, argValue[i2])) {
62239
+ return false;
62240
+ }
62241
+ }
62242
+ return true;
62243
+ }
62244
+ } else {
62245
+ return actual === expected;
62246
+ }
62247
+ },
62248
+ _getTypeName: function(obj) {
62249
+ switch (Object.prototype.toString.call(obj)) {
62250
+ case "[object String]":
62251
+ return TYPE_STRING;
62252
+ case "[object Number]":
62253
+ return TYPE_NUMBER;
62254
+ case "[object Array]":
62255
+ return TYPE_ARRAY;
62256
+ case "[object Boolean]":
62257
+ return TYPE_BOOLEAN;
62258
+ case "[object Null]":
62259
+ return TYPE_NULL;
62260
+ case "[object Object]":
62261
+ if (obj.jmespathType === TOK_EXPREF) {
62262
+ return TYPE_EXPREF;
62263
+ } else {
62264
+ return TYPE_OBJECT;
62265
+ }
62771
62266
  }
62772
- const collected = [];
62773
- for (const elem of base) {
62774
- const current = this.visit(right, elem);
62775
- if (current !== null) {
62776
- collected.push(current);
62267
+ },
62268
+ _functionStartsWith: function(resolvedArgs) {
62269
+ return resolvedArgs[0].lastIndexOf(resolvedArgs[1]) === 0;
62270
+ },
62271
+ _functionEndsWith: function(resolvedArgs) {
62272
+ var searchStr = resolvedArgs[0];
62273
+ var suffix = resolvedArgs[1];
62274
+ return searchStr.indexOf(suffix, searchStr.length - suffix.length) !== -1;
62275
+ },
62276
+ _functionReverse: function(resolvedArgs) {
62277
+ var typeName = this._getTypeName(resolvedArgs[0]);
62278
+ if (typeName === TYPE_STRING) {
62279
+ var originalStr = resolvedArgs[0];
62280
+ var reversedStr = "";
62281
+ for (var i2 = originalStr.length - 1;i2 >= 0; i2--) {
62282
+ reversedStr += originalStr[i2];
62777
62283
  }
62284
+ return reversedStr;
62285
+ } else {
62286
+ var reversedArray = resolvedArgs[0].slice(0);
62287
+ reversedArray.reverse();
62288
+ return reversedArray;
62778
62289
  }
62779
- return collected;
62780
- }
62781
- case "ValueProjection": {
62782
- const { left, right } = node;
62783
- const base = this.visit(left, value);
62784
- if (base === null || typeof base !== "object" || Array.isArray(base)) {
62785
- return null;
62290
+ },
62291
+ _functionAbs: function(resolvedArgs) {
62292
+ return Math.abs(resolvedArgs[0]);
62293
+ },
62294
+ _functionCeil: function(resolvedArgs) {
62295
+ return Math.ceil(resolvedArgs[0]);
62296
+ },
62297
+ _functionAvg: function(resolvedArgs) {
62298
+ var sum = 0;
62299
+ var inputArray = resolvedArgs[0];
62300
+ for (var i2 = 0;i2 < inputArray.length; i2++) {
62301
+ sum += inputArray[i2];
62302
+ }
62303
+ return sum / inputArray.length;
62304
+ },
62305
+ _functionContains: function(resolvedArgs) {
62306
+ return resolvedArgs[0].indexOf(resolvedArgs[1]) >= 0;
62307
+ },
62308
+ _functionFloor: function(resolvedArgs) {
62309
+ return Math.floor(resolvedArgs[0]);
62310
+ },
62311
+ _functionLength: function(resolvedArgs) {
62312
+ if (!isObject3(resolvedArgs[0])) {
62313
+ return resolvedArgs[0].length;
62314
+ } else {
62315
+ return Object.keys(resolvedArgs[0]).length;
62786
62316
  }
62787
- const collected = [];
62788
- const values = Object.values(base);
62789
- for (const elem of values) {
62790
- const current = this.visit(right, elem);
62791
- if (current !== null) {
62792
- collected.push(current);
62317
+ },
62318
+ _functionMap: function(resolvedArgs) {
62319
+ var mapped = [];
62320
+ var interpreter = this._interpreter;
62321
+ var exprefNode = resolvedArgs[0];
62322
+ var elements = resolvedArgs[1];
62323
+ for (var i2 = 0;i2 < elements.length; i2++) {
62324
+ mapped.push(interpreter.visit(exprefNode, elements[i2]));
62325
+ }
62326
+ return mapped;
62327
+ },
62328
+ _functionMerge: function(resolvedArgs) {
62329
+ var merged = {};
62330
+ for (var i2 = 0;i2 < resolvedArgs.length; i2++) {
62331
+ var current = resolvedArgs[i2];
62332
+ for (var key in current) {
62333
+ merged[key] = current[key];
62793
62334
  }
62794
62335
  }
62795
- return collected;
62796
- }
62797
- case "FilterProjection": {
62798
- const { left, right, condition } = node;
62799
- const base = this.visit(left, value);
62800
- if (!Array.isArray(base)) {
62336
+ return merged;
62337
+ },
62338
+ _functionMax: function(resolvedArgs) {
62339
+ if (resolvedArgs[0].length > 0) {
62340
+ var typeName = this._getTypeName(resolvedArgs[0][0]);
62341
+ if (typeName === TYPE_NUMBER) {
62342
+ return Math.max.apply(Math, resolvedArgs[0]);
62343
+ } else {
62344
+ var elements = resolvedArgs[0];
62345
+ var maxElement = elements[0];
62346
+ for (var i2 = 1;i2 < elements.length; i2++) {
62347
+ if (maxElement.localeCompare(elements[i2]) < 0) {
62348
+ maxElement = elements[i2];
62349
+ }
62350
+ }
62351
+ return maxElement;
62352
+ }
62353
+ } else {
62801
62354
  return null;
62802
62355
  }
62803
- const results = [];
62804
- for (const elem of base) {
62805
- const matched = this.visit(condition, elem);
62806
- if (isFalse(matched)) {
62807
- continue;
62808
- }
62809
- const result = this.visit(right, elem);
62810
- if (result !== null) {
62811
- results.push(result);
62356
+ },
62357
+ _functionMin: function(resolvedArgs) {
62358
+ if (resolvedArgs[0].length > 0) {
62359
+ var typeName = this._getTypeName(resolvedArgs[0][0]);
62360
+ if (typeName === TYPE_NUMBER) {
62361
+ return Math.min.apply(Math, resolvedArgs[0]);
62362
+ } else {
62363
+ var elements = resolvedArgs[0];
62364
+ var minElement = elements[0];
62365
+ for (var i2 = 1;i2 < elements.length; i2++) {
62366
+ if (elements[i2].localeCompare(minElement) < 0) {
62367
+ minElement = elements[i2];
62368
+ }
62369
+ }
62370
+ return minElement;
62812
62371
  }
62372
+ } else {
62373
+ return null;
62813
62374
  }
62814
- return results;
62815
- }
62816
- case "Arithmetic": {
62817
- const first = this.visit(node.left, value);
62818
- const second = this.visit(node.right, value);
62819
- switch (node.operator) {
62820
- case "Plus":
62821
- return add(first, second);
62822
- case "Minus":
62823
- return sub(first, second);
62824
- case "Multiply":
62825
- case "Star":
62826
- return mul(first, second);
62827
- case "Divide":
62828
- return divide(first, second);
62829
- case "Modulo":
62830
- return mod(first, second);
62831
- case "Div":
62832
- return div(first, second);
62833
- default:
62834
- throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`);
62835
- }
62836
- }
62837
- case "Unary": {
62838
- const operand = this.visit(node.operand, value);
62839
- switch (node.operator) {
62840
- case "Plus":
62841
- ensureNumbers(operand);
62842
- return operand;
62843
- case "Minus":
62844
- ensureNumbers(operand);
62845
- return -operand;
62846
- default:
62847
- throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`);
62375
+ },
62376
+ _functionSum: function(resolvedArgs) {
62377
+ var sum = 0;
62378
+ var listToSum = resolvedArgs[0];
62379
+ for (var i2 = 0;i2 < listToSum.length; i2++) {
62380
+ sum += listToSum[i2];
62848
62381
  }
62849
- }
62850
- case "Comparator": {
62851
- const first = this.visit(node.left, value);
62852
- const second = this.visit(node.right, value);
62853
- switch (node.name) {
62854
- case "EQ":
62855
- return strictDeepEqual(first, second);
62856
- case "NE":
62857
- return !strictDeepEqual(first, second);
62382
+ return sum;
62383
+ },
62384
+ _functionType: function(resolvedArgs) {
62385
+ switch (this._getTypeName(resolvedArgs[0])) {
62386
+ case TYPE_NUMBER:
62387
+ return "number";
62388
+ case TYPE_STRING:
62389
+ return "string";
62390
+ case TYPE_ARRAY:
62391
+ return "array";
62392
+ case TYPE_OBJECT:
62393
+ return "object";
62394
+ case TYPE_BOOLEAN:
62395
+ return "boolean";
62396
+ case TYPE_EXPREF:
62397
+ return "expref";
62398
+ case TYPE_NULL:
62399
+ return "null";
62858
62400
  }
62859
- if (typeof first !== "number" || typeof second !== "number") {
62860
- return null;
62401
+ },
62402
+ _functionKeys: function(resolvedArgs) {
62403
+ return Object.keys(resolvedArgs[0]);
62404
+ },
62405
+ _functionValues: function(resolvedArgs) {
62406
+ var obj = resolvedArgs[0];
62407
+ var keys2 = Object.keys(obj);
62408
+ var values = [];
62409
+ for (var i2 = 0;i2 < keys2.length; i2++) {
62410
+ values.push(obj[keys2[i2]]);
62411
+ }
62412
+ return values;
62413
+ },
62414
+ _functionJoin: function(resolvedArgs) {
62415
+ var joinChar = resolvedArgs[0];
62416
+ var listJoin = resolvedArgs[1];
62417
+ return listJoin.join(joinChar);
62418
+ },
62419
+ _functionToArray: function(resolvedArgs) {
62420
+ if (this._getTypeName(resolvedArgs[0]) === TYPE_ARRAY) {
62421
+ return resolvedArgs[0];
62422
+ } else {
62423
+ return [resolvedArgs[0]];
62861
62424
  }
62862
- switch (node.name) {
62863
- case "GT":
62864
- return first > second;
62865
- case "GTE":
62866
- return first >= second;
62867
- case "LT":
62868
- return first < second;
62869
- case "LTE":
62870
- return first <= second;
62425
+ },
62426
+ _functionToString: function(resolvedArgs) {
62427
+ if (this._getTypeName(resolvedArgs[0]) === TYPE_STRING) {
62428
+ return resolvedArgs[0];
62429
+ } else {
62430
+ return JSON.stringify(resolvedArgs[0]);
62871
62431
  }
62872
- }
62873
- case "Flatten": {
62874
- const original = this.visit(node.child, value);
62875
- return Array.isArray(original) ? original.flat() : null;
62876
- }
62877
- case "Root":
62878
- return this._rootValue;
62879
- case "MultiSelectList": {
62880
- const collected = [];
62881
- for (const child of node.children) {
62882
- collected.push(this.visit(child, value));
62432
+ },
62433
+ _functionToNumber: function(resolvedArgs) {
62434
+ var typeName = this._getTypeName(resolvedArgs[0]);
62435
+ var convertedValue;
62436
+ if (typeName === TYPE_NUMBER) {
62437
+ return resolvedArgs[0];
62438
+ } else if (typeName === TYPE_STRING) {
62439
+ convertedValue = +resolvedArgs[0];
62440
+ if (!isNaN(convertedValue)) {
62441
+ return convertedValue;
62442
+ }
62883
62443
  }
62884
- return collected;
62885
- }
62886
- case "MultiSelectHash": {
62887
- const collected = {};
62888
- for (const child of node.children) {
62889
- collected[child.name] = this.visit(child.value, value);
62444
+ return null;
62445
+ },
62446
+ _functionNotNull: function(resolvedArgs) {
62447
+ for (var i2 = 0;i2 < resolvedArgs.length; i2++) {
62448
+ if (this._getTypeName(resolvedArgs[i2]) !== TYPE_NULL) {
62449
+ return resolvedArgs[i2];
62450
+ }
62890
62451
  }
62891
- return collected;
62892
- }
62893
- case "OrExpression": {
62894
- const result = this.visit(node.left, value);
62895
- if (isFalse(result)) {
62896
- return this.visit(node.right, value);
62452
+ return null;
62453
+ },
62454
+ _functionSort: function(resolvedArgs) {
62455
+ var sortedArray = resolvedArgs[0].slice(0);
62456
+ sortedArray.sort();
62457
+ return sortedArray;
62458
+ },
62459
+ _functionSortBy: function(resolvedArgs) {
62460
+ var sortedArray = resolvedArgs[0].slice(0);
62461
+ if (sortedArray.length === 0) {
62462
+ return sortedArray;
62463
+ }
62464
+ var interpreter = this._interpreter;
62465
+ var exprefNode = resolvedArgs[1];
62466
+ var requiredType = this._getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
62467
+ if ([TYPE_NUMBER, TYPE_STRING].indexOf(requiredType) < 0) {
62468
+ throw new Error("TypeError");
62469
+ }
62470
+ var that = this;
62471
+ var decorated = [];
62472
+ for (var i2 = 0;i2 < sortedArray.length; i2++) {
62473
+ decorated.push([i2, sortedArray[i2]]);
62474
+ }
62475
+ decorated.sort(function(a, b) {
62476
+ var exprA = interpreter.visit(exprefNode, a[1]);
62477
+ var exprB = interpreter.visit(exprefNode, b[1]);
62478
+ if (that._getTypeName(exprA) !== requiredType) {
62479
+ throw new Error("TypeError: expected " + requiredType + ", received " + that._getTypeName(exprA));
62480
+ } else if (that._getTypeName(exprB) !== requiredType) {
62481
+ throw new Error("TypeError: expected " + requiredType + ", received " + that._getTypeName(exprB));
62482
+ }
62483
+ if (exprA > exprB) {
62484
+ return 1;
62485
+ } else if (exprA < exprB) {
62486
+ return -1;
62487
+ } else {
62488
+ return a[0] - b[0];
62489
+ }
62490
+ });
62491
+ for (var j = 0;j < decorated.length; j++) {
62492
+ sortedArray[j] = decorated[j][1];
62897
62493
  }
62898
- return result;
62899
- }
62900
- case "AndExpression": {
62901
- const result = this.visit(node.left, value);
62902
- if (isFalse(result)) {
62903
- return result;
62494
+ return sortedArray;
62495
+ },
62496
+ _functionMaxBy: function(resolvedArgs) {
62497
+ var exprefNode = resolvedArgs[1];
62498
+ var resolvedArray = resolvedArgs[0];
62499
+ var keyFunction = this.createKeyFunction(exprefNode, [TYPE_NUMBER, TYPE_STRING]);
62500
+ var maxNumber = -Infinity;
62501
+ var maxRecord;
62502
+ var current;
62503
+ for (var i2 = 0;i2 < resolvedArray.length; i2++) {
62504
+ current = keyFunction(resolvedArray[i2]);
62505
+ if (current > maxNumber) {
62506
+ maxNumber = current;
62507
+ maxRecord = resolvedArray[i2];
62508
+ }
62904
62509
  }
62905
- return this.visit(node.right, value);
62906
- }
62907
- case "NotExpression":
62908
- return isFalse(this.visit(node.child, value));
62909
- case "Literal":
62910
- return node.value;
62911
- case "Pipe":
62912
- return this.visit(node.right, this.visit(node.left, value));
62913
- case "Function": {
62914
- const args = [];
62915
- for (const child of node.children) {
62916
- args.push(this.visit(child, value));
62510
+ return maxRecord;
62511
+ },
62512
+ _functionMinBy: function(resolvedArgs) {
62513
+ var exprefNode = resolvedArgs[1];
62514
+ var resolvedArray = resolvedArgs[0];
62515
+ var keyFunction = this.createKeyFunction(exprefNode, [TYPE_NUMBER, TYPE_STRING]);
62516
+ var minNumber = Infinity;
62517
+ var minRecord;
62518
+ var current;
62519
+ for (var i2 = 0;i2 < resolvedArray.length; i2++) {
62520
+ current = keyFunction(resolvedArray[i2]);
62521
+ if (current < minNumber) {
62522
+ minNumber = current;
62523
+ minRecord = resolvedArray[i2];
62524
+ }
62917
62525
  }
62918
- return this.runtime.callFunction(node.name, args);
62919
- }
62920
- case "ExpressionReference":
62921
- return {
62922
- expref: true,
62923
- ...node.child
62526
+ return minRecord;
62527
+ },
62528
+ createKeyFunction: function(exprefNode, allowedTypes) {
62529
+ var that = this;
62530
+ var interpreter = this._interpreter;
62531
+ var keyFunc = function(x) {
62532
+ var current = interpreter.visit(exprefNode, x);
62533
+ if (allowedTypes.indexOf(that._getTypeName(current)) < 0) {
62534
+ var msg = "TypeError: expected one of " + allowedTypes + ", received " + that._getTypeName(current);
62535
+ throw new Error(msg);
62536
+ }
62537
+ return current;
62924
62538
  };
62925
- case "Current":
62926
- case "Identity":
62927
- return value;
62928
- }
62929
- }
62930
- computeSliceParams(arrayLength, sliceNode) {
62931
- let { start, stop, step } = sliceNode;
62932
- if (step === null) {
62933
- step = 1;
62934
- } else if (step === 0) {
62935
- const error46 = new Error("Invalid value: slice step cannot be 0");
62936
- error46.name = "RuntimeError";
62937
- throw error46;
62938
- }
62939
- start = start === null ? step < 0 ? arrayLength - 1 : 0 : this.capSliceRange(arrayLength, start, step);
62940
- stop = stop === null ? step < 0 ? -1 : arrayLength : this.capSliceRange(arrayLength, stop, step);
62941
- return { start, stop, step };
62942
- }
62943
- capSliceRange(arrayLength, actualValue, step) {
62944
- let nextActualValue = actualValue;
62945
- if (nextActualValue < 0) {
62946
- nextActualValue += arrayLength;
62947
- if (nextActualValue < 0) {
62948
- nextActualValue = step < 0 ? -1 : 0;
62949
- }
62950
- } else if (nextActualValue >= arrayLength) {
62951
- nextActualValue = step < 0 ? arrayLength - 1 : arrayLength;
62952
- }
62953
- return nextActualValue;
62954
- }
62955
- slice(collection, start, end, step) {
62956
- const result = [];
62957
- if (step > 0) {
62958
- for (let i2 = start;i2 < end; i2 += step) {
62959
- result.push(collection[i2]);
62539
+ return keyFunc;
62960
62540
  }
62961
- } else {
62962
- for (let i2 = start;i2 > end; i2 += step) {
62963
- result.push(collection[i2]);
62964
- }
62965
- }
62966
- return result;
62967
- }
62968
- }, TreeInterpreterInstance, TreeInterpreter_default, TYPE_ANY = 1, TYPE_ARRAY = 3, TYPE_ARRAY_ARRAY = 11, TYPE_ARRAY_NUMBER = 8, TYPE_ARRAY_OBJECT = 10, TYPE_ARRAY_STRING = 9, TYPE_BOOLEAN = 5, TYPE_EXPREF = 6, TYPE_NULL = 7, TYPE_NUMBER = 0, TYPE_OBJECT = 4, TYPE_STRING = 2, registerFunction = (functionName, customFunction, signature, options) => {
62969
- TreeInterpreter_default.runtime.registerFunction(functionName, customFunction, signature, options);
62970
- }, register = (name, customFunction, signature, options) => {
62971
- return TreeInterpreter_default.runtime.register(name, customFunction, signature, options);
62972
- }, unregisterFunction = (name) => {
62973
- return TreeInterpreter_default.runtime.unregister(name);
62974
- }, isRegistered = (name) => {
62975
- return TreeInterpreter_default.runtime.isRegistered(name);
62976
- }, getRegisteredFunctions = () => {
62977
- return TreeInterpreter_default.runtime.getRegistered();
62978
- }, getCustomFunctions = () => {
62979
- return TreeInterpreter_default.runtime.getCustomFunctions();
62980
- }, clearCustomFunctions = () => {
62981
- TreeInterpreter_default.runtime.clearCustomFunctions();
62982
- }, TreeInterpreter2, jmespath;
62983
- var init_dist2 = __esm(() => {
62984
- basicTokens = {
62985
- "(": "Lparen",
62986
- ")": "Rparen",
62987
- "*": "Star",
62988
- ",": "Comma",
62989
- ".": "Dot",
62990
- ":": "Colon",
62991
- "@": "Current",
62992
- "]": "Rbracket",
62993
- "{": "Lbrace",
62994
- "}": "Rbrace",
62995
- "+": "Plus",
62996
- "%": "Modulo",
62997
- "?": "Question",
62998
- "−": "Minus",
62999
- "×": "Multiply",
63000
- "÷": "Divide"
63001
- };
63002
- operatorStartToken = {
63003
- "!": true,
63004
- "<": true,
63005
- "=": true,
63006
- ">": true,
63007
- "&": true,
63008
- "|": true,
63009
- "/": true
63010
- };
63011
- skipChars = {
63012
- "\t": true,
63013
- "\n": true,
63014
- "\r": true,
63015
- " ": true
63016
- };
63017
- Lexer = new StreamLexer;
63018
- Lexer_default = Lexer;
63019
- bindingPower = {
63020
- ["EOF"]: 0,
63021
- ["Variable"]: 0,
63022
- ["UnquotedIdentifier"]: 0,
63023
- ["QuotedIdentifier"]: 0,
63024
- ["Rbracket"]: 0,
63025
- ["Rparen"]: 0,
63026
- ["Comma"]: 0,
63027
- ["Rbrace"]: 0,
63028
- ["Number"]: 0,
63029
- ["Current"]: 0,
63030
- ["Expref"]: 0,
63031
- ["Root"]: 0,
63032
- ["Assign"]: 1,
63033
- ["Pipe"]: 1,
63034
- ["Question"]: 2,
63035
- ["Or"]: 3,
63036
- ["And"]: 4,
63037
- ["EQ"]: 5,
63038
- ["GT"]: 5,
63039
- ["LT"]: 5,
63040
- ["GTE"]: 5,
63041
- ["LTE"]: 5,
63042
- ["NE"]: 5,
63043
- ["Minus"]: 6,
63044
- ["Plus"]: 6,
63045
- ["Div"]: 7,
63046
- ["Divide"]: 7,
63047
- ["Modulo"]: 7,
63048
- ["Multiply"]: 7,
63049
- ["Flatten"]: 9,
63050
- ["Star"]: 20,
63051
- ["Filter"]: 21,
63052
- ["Dot"]: 40,
63053
- ["Not"]: 45,
63054
- ["Lbrace"]: 50,
63055
- ["Lbracket"]: 55,
63056
- ["Lparen"]: 60
63057
- };
63058
- Parser = new TokenParser2;
63059
- Parser_default = Parser;
63060
- emptyScopeChain = new ScopeChain;
63061
- TreeInterpreterInstance = new TreeInterpreter;
63062
- TreeInterpreter_default = TreeInterpreterInstance;
63063
- TreeInterpreter2 = TreeInterpreter_default;
63064
- jmespath = {
63065
- compile,
63066
- registerFunction,
63067
- register,
63068
- unregisterFunction,
63069
- isRegistered,
63070
- getRegisteredFunctions,
63071
- getCustomFunctions,
63072
- clearCustomFunctions,
63073
- search,
63074
- tokenize,
63075
- TreeInterpreter: TreeInterpreter2,
63076
- TYPE_ANY,
63077
- TYPE_ARRAY_NUMBER,
63078
- TYPE_ARRAY_STRING,
63079
- TYPE_ARRAY,
63080
- TYPE_BOOLEAN,
63081
- TYPE_EXPREF,
63082
- TYPE_NULL,
63083
- TYPE_NUMBER,
63084
- TYPE_OBJECT,
63085
- TYPE_STRING
63086
- };
62541
+ };
62542
+ function compile(stream) {
62543
+ var parser = new Parser;
62544
+ var ast = parser.parse(stream);
62545
+ return ast;
62546
+ }
62547
+ function tokenize(stream) {
62548
+ var lexer = new Lexer;
62549
+ return lexer.tokenize(stream);
62550
+ }
62551
+ function search(data, expression) {
62552
+ var parser = new Parser;
62553
+ var runtime2 = new Runtime;
62554
+ var interpreter = new TreeInterpreter(runtime2);
62555
+ runtime2._interpreter = interpreter;
62556
+ var node = parser.parse(expression);
62557
+ return interpreter.search(node, data);
62558
+ }
62559
+ exports2.tokenize = tokenize;
62560
+ exports2.compile = compile;
62561
+ exports2.search = search;
62562
+ exports2.strictDeepEqual = strictDeepEqual;
62563
+ })(typeof exports === "undefined" ? exports.jmespath = {} : exports);
63087
62564
  });
63088
62565
 
63089
62566
  // ../../node_modules/commander/lib/error.js
@@ -63412,10 +62889,10 @@ var require_help = __commonJS(function(exports) {
63412
62889
  });
63413
62890
  output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
63414
62891
  }
63415
- const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub2) => sub2.helpGroup() || "Commands:");
62892
+ const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
63416
62893
  commandGroups.forEach((commands, group) => {
63417
- const commandList = commands.map((sub2) => {
63418
- return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub2)), helper.styleSubcommandDescription(helper.subcommandDescription(sub2)));
62894
+ const commandList = commands.map((sub) => {
62895
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
63419
62896
  });
63420
62897
  output = output.concat(this.formatItemList(group, commandList, helper));
63421
62898
  });
@@ -65858,8 +65335,8 @@ class TextApiResponse2 {
65858
65335
  // package.json
65859
65336
  var package_default = {
65860
65337
  name: "@uipath/integrationservice-sdk",
65861
- license: "MIT",
65862
- version: "1.202.0-preview.142",
65338
+ license: "SEE LICENSE IN LICENSE.txt",
65339
+ version: "1.202.0",
65863
65340
  repository: {
65864
65341
  type: "git",
65865
65342
  url: "https://github.com/UiPath/cli.git",
@@ -88061,13 +87538,13 @@ var jmespathSlot = singleton("JmespathCodec");
88061
87538
  async function loadOutputCodecsAsync(needed) {
88062
87539
  const loads = [];
88063
87540
  if (needed.yaml && yamlSlot.get() === undefined) {
88064
- loads.push(Promise.resolve().then(() => (init_js_yaml(), exports_js_yaml)).then((mod2) => {
88065
- yamlSlot.set(mod2);
87541
+ loads.push(Promise.resolve().then(() => (init_js_yaml(), exports_js_yaml)).then((mod) => {
87542
+ yamlSlot.set(mod);
88066
87543
  }));
88067
87544
  }
88068
87545
  if (needed.filter && jmespathSlot.get() === undefined) {
88069
- loads.push(Promise.resolve().then(() => (init_dist2(), exports_dist2)).then((mod2) => {
88070
- jmespathSlot.set(mod2);
87546
+ loads.push(Promise.resolve().then(() => __toESM(require_jmespath(), 1)).then((mod) => {
87547
+ jmespathSlot.set(mod);
88071
87548
  }));
88072
87549
  }
88073
87550
  await Promise.all(loads);
@@ -88818,8 +88295,8 @@ class TelemetryService2 {
88818
88295
  // ../common/src/timings.ts
88819
88296
  var TIMINGS_ENV_VAR = "UIP_TIMINGS";
88820
88297
  function createStorage2() {
88821
- const [error46, mod2] = catchError3(() => __require("node:async_hooks"));
88822
- if (error46 || typeof mod2?.AsyncLocalStorage !== "function") {
88298
+ const [error46, mod] = catchError3(() => __require("node:async_hooks"));
88299
+ if (error46 || typeof mod?.AsyncLocalStorage !== "function") {
88823
88300
  return {
88824
88301
  getStore: () => {
88825
88302
  return;
@@ -88827,7 +88304,7 @@ function createStorage2() {
88827
88304
  run: (_store, fn) => fn()
88828
88305
  };
88829
88306
  }
88830
- return new mod2.AsyncLocalStorage;
88307
+ return new mod.AsyncLocalStorage;
88831
88308
  }
88832
88309
  var storageSlot = singleton("TimingStorage");
88833
88310
  var stateSlot = singleton("Timings");
@@ -91941,4 +91418,4 @@ export {
91941
91418
  validateRequiredParameters
91942
91419
  };
91943
91420
 
91944
- //# debugId=D6EEF25B6210049864756E2164756E21
91421
+ //# debugId=EEC283D1A95DBB9E64756E2164756E21