@uipath/solution-tool 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.
@@ -25,7 +25,7 @@ import {
25
25
  models_BindingsResourceType,
26
26
  readUipxProjects,
27
27
  syncAndLog
28
- } from "./packager-tool-pc4hb3pv.js";
28
+ } from "./packager-tool-bt0z25tw.js";
29
29
  import {
30
30
  ToolResult as ToolResult2,
31
31
  toolsFactoryRepository as toolsFactoryRepository2
@@ -41,7 +41,7 @@ import {
41
41
  logger,
42
42
  telemetry,
43
43
  unsupportedSolutionProjectType
44
- } from "./packager-tool-1x1cc4qh.js";
44
+ } from "./packager-tool-fjjh5veg.js";
45
45
 
46
46
  // ../filesystem/dist/index.js
47
47
  import fs from "node:fs";
@@ -3799,7 +3799,7 @@ function formatError(value) {
3799
3799
  function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
3800
3800
  var output = [];
3801
3801
  for (var i2 = 0, l = value.length;i2 < l; ++i2)
3802
- if (hasOwnProperty(value, String(i2)))
3802
+ if (hasOwnProperty2(value, String(i2)))
3803
3803
  output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i2), true));
3804
3804
  else
3805
3805
  output.push("");
@@ -3817,7 +3817,7 @@ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
3817
3817
  str = ctx.stylize("[Getter]", "special");
3818
3818
  else if (desc.set)
3819
3819
  str = ctx.stylize("[Setter]", "special");
3820
- if (!hasOwnProperty(visibleKeys, key))
3820
+ if (!hasOwnProperty2(visibleKeys, key))
3821
3821
  name = "[" + key + "]";
3822
3822
  if (!str)
3823
3823
  if (ctx.seen.indexOf(desc.value) < 0) {
@@ -3935,7 +3935,7 @@ function _extend(origin, add) {
3935
3935
  origin[keys[i2]] = add[keys[i2]];
3936
3936
  return origin;
3937
3937
  }
3938
- function hasOwnProperty(obj, prop) {
3938
+ function hasOwnProperty2(obj, prop) {
3939
3939
  return Object.prototype.hasOwnProperty.call(obj, prop);
3940
3940
  }
3941
3941
  function callbackifyOnRejected(reason, cb) {
@@ -9121,9 +9121,9 @@ var init_crypto = __esm2(() => {
9121
9121
  };
9122
9122
  });
9123
9123
  require_for_each = __commonJS2((exports, module) => {
9124
- var isCallable = require_is_callable(), toStr = Object.prototype.toString, hasOwnProperty2 = Object.prototype.hasOwnProperty, forEachArray = function(array, iterator, receiver) {
9124
+ var isCallable = require_is_callable(), toStr = Object.prototype.toString, hasOwnProperty22 = Object.prototype.hasOwnProperty, forEachArray = function(array, iterator, receiver) {
9125
9125
  for (var i2 = 0, len2 = array.length;i2 < len2; i2++)
9126
- if (hasOwnProperty2.call(array, i2))
9126
+ if (hasOwnProperty22.call(array, i2))
9127
9127
  if (receiver == null)
9128
9128
  iterator(array[i2], i2, array);
9129
9129
  else
@@ -9136,7 +9136,7 @@ var init_crypto = __esm2(() => {
9136
9136
  iterator.call(receiver, string.charAt(i2), i2, string);
9137
9137
  }, forEachObject = function(object, iterator, receiver) {
9138
9138
  for (var k in object)
9139
- if (hasOwnProperty2.call(object, k))
9139
+ if (hasOwnProperty22.call(object, k))
9140
9140
  if (receiver == null)
9141
9141
  iterator(object[k], k, object);
9142
9142
  else
@@ -24192,8 +24192,8 @@ var telemetryPropsSlot2 = singleton2("TelemetryDefaultProps");
24192
24192
  var sdkUserAgentHostToken2 = singleton2("SdkUserAgentHostToken");
24193
24193
  var package_default = {
24194
24194
  name: "@uipath/project-packager",
24195
- license: "MIT",
24196
- version: "1.202.0-preview.142",
24195
+ license: "SEE LICENSE IN LICENSE.txt",
24196
+ version: "1.202.0",
24197
24197
  description: "UiPath Project Packager - core library for packing individual UiPath projects",
24198
24198
  type: "module",
24199
24199
  main: "./dist/index.js",
@@ -29868,2074 +29868,1482 @@ var init_js_yaml = __esm3(() => {
29868
29868
  safeDump
29869
29869
  } = yaml);
29870
29870
  });
29871
- var exports_dist = {};
29872
- __export3(exports_dist, {
29873
- Scope: () => Scope,
29874
- TYPE_ANY: () => TYPE_ANY,
29875
- TYPE_ARRAY: () => TYPE_ARRAY,
29876
- TYPE_ARRAY_ARRAY: () => TYPE_ARRAY_ARRAY,
29877
- TYPE_ARRAY_NUMBER: () => TYPE_ARRAY_NUMBER,
29878
- TYPE_ARRAY_OBJECT: () => TYPE_ARRAY_OBJECT,
29879
- TYPE_ARRAY_STRING: () => TYPE_ARRAY_STRING,
29880
- TYPE_BOOLEAN: () => TYPE_BOOLEAN,
29881
- TYPE_EXPREF: () => TYPE_EXPREF,
29882
- TYPE_NULL: () => TYPE_NULL,
29883
- TYPE_NUMBER: () => TYPE_NUMBER,
29884
- TYPE_OBJECT: () => TYPE_OBJECT,
29885
- TYPE_STRING: () => TYPE_STRING,
29886
- TreeInterpreter: () => TreeInterpreter2,
29887
- clearCustomFunctions: () => clearCustomFunctions,
29888
- compile: () => compile,
29889
- default: () => jmespath,
29890
- getCustomFunctions: () => getCustomFunctions,
29891
- getRegisteredFunctions: () => getRegisteredFunctions,
29892
- isRegistered: () => isRegistered,
29893
- jmespath: () => jmespath,
29894
- register: () => register,
29895
- registerFunction: () => registerFunction,
29896
- search: () => search,
29897
- tokenize: () => tokenize,
29898
- unregisterFunction: () => unregisterFunction
29899
- });
29900
- function compile(expression, options) {
29901
- const nodeTree = Parser_default.parse(expression, options);
29902
- return nodeTree;
29903
- }
29904
- function tokenize(expression, options) {
29905
- return Lexer_default.tokenize(expression, options);
29906
- }
29907
- function search(data, expression, options) {
29908
- const nodeTree = Parser_default.parse(expression, options);
29909
- return TreeInterpreter_default.search(nodeTree, data);
29910
- }
29911
- function Scope() {
29912
- return new ScopeChain;
29913
- }
29914
- var isObject2 = (obj) => {
29915
- return obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
29916
- };
29917
- var strictDeepEqual = (first, second) => {
29918
- if (first === second) {
29919
- return true;
29920
- }
29921
- if (typeof first !== typeof second) {
29922
- return false;
29923
- }
29924
- if (Array.isArray(first) && Array.isArray(second)) {
29925
- if (first.length !== second.length) {
29926
- return false;
29927
- }
29928
- for (let i2 = 0;i2 < first.length; i2 += 1) {
29929
- if (!strictDeepEqual(first[i2], second[i2])) {
29930
- return false;
29931
- }
29932
- }
29933
- return true;
29934
- }
29935
- if (isObject2(first) && isObject2(second)) {
29936
- const firstEntries = Object.entries(first);
29937
- const secondKeys = new Set(Object.keys(second));
29938
- if (firstEntries.length !== secondKeys.size) {
29939
- return false;
29940
- }
29941
- for (const [key, value] of firstEntries) {
29942
- if (!strictDeepEqual(value, second[key])) {
29871
+ var require_jmespath = __commonJS3(function(exports) {
29872
+ (function(exports2) {
29873
+ function isArray2(obj) {
29874
+ if (obj !== null) {
29875
+ return Object.prototype.toString.call(obj) === "[object Array]";
29876
+ } else {
29943
29877
  return false;
29944
29878
  }
29945
- secondKeys.delete(key);
29946
- }
29947
- return secondKeys.size === 0;
29948
- }
29949
- return false;
29950
- };
29951
- var isFalse = (obj) => {
29952
- if (obj === null || obj === undefined || obj === false) {
29953
- return true;
29954
- }
29955
- if (typeof obj === "string") {
29956
- return obj === "";
29957
- }
29958
- if (typeof obj === "object") {
29959
- if (Array.isArray(obj)) {
29960
- return obj.length === 0;
29961
- }
29962
- if (obj === null) {
29963
- return true;
29964
- }
29965
- return Object.keys(obj).length === 0;
29966
- }
29967
- return false;
29968
- };
29969
- var isAlpha = (ch) => {
29970
- return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
29971
- };
29972
- var isNum = (ch) => {
29973
- return ch >= "0" && ch <= "9" || ch === "-";
29974
- };
29975
- var isAlphaNum = (ch) => {
29976
- return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_";
29977
- };
29978
- var ensureInteger = (value) => {
29979
- if (!(typeof value === "number") || Math.floor(value) !== value) {
29980
- throw new Error("invalid-value: expecting an integer.");
29981
- }
29982
- return value;
29983
- };
29984
- var ensurePositiveInteger = (value) => {
29985
- if (!(typeof value === "number") || value < 0 || Math.floor(value) !== value) {
29986
- throw new Error("invalid-value: expecting a non-negative integer.");
29987
- }
29988
- return value;
29989
- };
29990
- var ensureNumbers = (...operands) => {
29991
- for (let i2 = 0;i2 < operands.length; i2++) {
29992
- if (operands[i2] === null || operands[i2] === undefined) {
29993
- throw new Error("not-a-number: undefined");
29994
- }
29995
- if (typeof operands[i2] !== "number") {
29996
- throw new Error("not-a-number");
29997
29879
  }
29998
- }
29999
- };
30000
- var notZero = (n) => {
30001
- n = +n;
30002
- if (!n) {
30003
- throw new Error("not-a-number: divide by zero");
30004
- }
30005
- return n;
30006
- };
30007
- var add = (left, right) => {
30008
- ensureNumbers(left, right);
30009
- const result = left + right;
30010
- return result;
30011
- };
30012
- var sub = (left, right) => {
30013
- ensureNumbers(left, right);
30014
- const result = left - right;
30015
- return result;
30016
- };
30017
- var mul = (left, right) => {
30018
- ensureNumbers(left, right);
30019
- const result = left * right;
30020
- return result;
30021
- };
30022
- var divide = (left, right) => {
30023
- ensureNumbers(left, right);
30024
- const result = left / notZero(right);
30025
- return result;
30026
- };
30027
- var div = (left, right) => {
30028
- ensureNumbers(left, right);
30029
- const result = Math.floor(left / notZero(right));
30030
- return result;
30031
- };
30032
- var mod = (left, right) => {
30033
- ensureNumbers(left, right);
30034
- const result = left % right;
30035
- return result;
30036
- };
30037
- var findFirst = (subject, sub2, start, end) => {
30038
- if (!subject || !sub2) {
30039
- return null;
30040
- }
30041
- start = Math.max(ensureInteger(start = start || 0), 0);
30042
- end = Math.min(ensureInteger(end = end || subject.length), subject.length);
30043
- const offset = subject.slice(start, end).indexOf(sub2);
30044
- return offset === -1 ? null : offset + start;
30045
- };
30046
- var findLast = (subject, sub2, start, end) => {
30047
- if (!subject || !sub2) {
30048
- return null;
30049
- }
30050
- start = Math.max(ensureInteger(start = start || 0), 0);
30051
- end = Math.min(ensureInteger(end = end || subject.length), subject.length);
30052
- const offset = subject.slice(start, end).lastIndexOf(sub2);
30053
- const result = offset === -1 ? null : offset + start;
30054
- return result;
30055
- };
30056
- var lower = (subject) => subject.toLowerCase();
30057
- var ensurePadFuncParams = (name, width, padding) => {
30058
- padding = padding || " ";
30059
- if (padding.length > 1) {
30060
- throw new Error(`invalid value, ${name} expects its 'pad' parameter to be a valid string with a single codepoint`);
30061
- }
30062
- ensurePositiveInteger(width);
30063
- return padding;
30064
- };
30065
- var padLeft = (subject, width, padding) => {
30066
- padding = ensurePadFuncParams("pad_left", width, padding);
30067
- return subject && subject.padStart(width, padding) || "";
30068
- };
30069
- var padRight = (subject, width, padding) => {
30070
- padding = ensurePadFuncParams("pad_right", width, padding);
30071
- return subject && subject.padEnd(width, padding) || "";
30072
- };
30073
- var replace = (subject, string, by, count) => {
30074
- if (count === 0) {
30075
- return subject;
30076
- }
30077
- if (!count) {
30078
- return subject.split(string).join(by);
30079
- }
30080
- ensurePositiveInteger(count);
30081
- [...Array(count).keys()].map(() => subject = subject.replace(string, by));
30082
- return subject;
30083
- };
30084
- var split = (subject, search2, count) => {
30085
- if (subject.length == 0 && search2.length === 0) {
30086
- return [];
30087
- }
30088
- if (count === null || count === undefined) {
30089
- return subject.split(search2);
30090
- }
30091
- ensurePositiveInteger(count);
30092
- if (count === 0) {
30093
- return [subject];
30094
- }
30095
- const split2 = subject.split(search2);
30096
- return [...split2.slice(0, count), split2.slice(count).join(search2)];
30097
- };
30098
- var trim = (subject, chars) => {
30099
- return trimLeft(trimRight(subject, chars), chars);
30100
- };
30101
- var trimLeft = (subject, chars) => {
30102
- return trimImpl(subject, (list) => new RegExp(`^[${list}]*(.*?)`), chars);
30103
- };
30104
- var trimRight = (subject, chars) => {
30105
- return trimImpl(subject, (list) => new RegExp(`(.*?)[${list}]*$`), chars);
30106
- };
30107
- var trimImpl = (subject, regExper, chars) => {
30108
- const pattern = chars ? chars.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&") : "\\s…";
30109
- return subject.replace(regExper(pattern), "$1");
30110
- };
30111
- var upper = (subject) => subject.toUpperCase();
30112
- var basicTokens;
30113
- var operatorStartToken;
30114
- var skipChars;
30115
- var StreamLexer = class {
30116
- _current = 0;
30117
- _enable_legacy_literals = false;
30118
- tokenize(stream, options) {
30119
- const tokens = [];
30120
- this._current = 0;
30121
- this._enable_legacy_literals = options?.enable_legacy_literals || false;
30122
- let start;
30123
- let identifier;
30124
- let token;
30125
- while (this._current < stream.length) {
30126
- if (isAlpha(stream[this._current])) {
30127
- start = this._current;
30128
- identifier = this.consumeUnquotedIdentifier(stream);
30129
- tokens.push({
30130
- start,
30131
- type: "UnquotedIdentifier",
30132
- value: identifier
30133
- });
30134
- } else if (basicTokens[stream[this._current]] !== undefined) {
30135
- tokens.push({
30136
- start: this._current,
30137
- type: basicTokens[stream[this._current]],
30138
- value: stream[this._current]
30139
- });
30140
- this._current += 1;
30141
- } else if (stream[this._current] === "$") {
30142
- start = this._current;
30143
- if (this._current + 1 < stream.length && isAlpha(stream[this._current + 1])) {
30144
- this._current += 1;
30145
- identifier = this.consumeUnquotedIdentifier(stream);
30146
- tokens.push({
30147
- start,
30148
- type: "Variable",
30149
- value: identifier
30150
- });
30151
- } else {
30152
- tokens.push({
30153
- start,
30154
- type: "Root",
30155
- value: stream[this._current]
30156
- });
30157
- this._current += 1;
30158
- }
30159
- } else if (stream[this._current] === "-") {
30160
- if (this._current + 1 < stream.length && isNum(stream[this._current + 1])) {
30161
- const token2 = this.consumeNumber(stream);
30162
- token2 && tokens.push(token2);
30163
- } else {
30164
- const token2 = {
30165
- start: this._current,
30166
- type: "Minus",
30167
- value: "-"
30168
- };
30169
- tokens.push(token2);
30170
- this._current += 1;
30171
- }
30172
- } else if (isNum(stream[this._current])) {
30173
- token = this.consumeNumber(stream);
30174
- tokens.push(token);
30175
- } else if (stream[this._current] === "[") {
30176
- token = this.consumeLBracket(stream);
30177
- tokens.push(token);
30178
- } else if (stream[this._current] === '"') {
30179
- start = this._current;
30180
- identifier = this.consumeQuotedIdentifier(stream);
30181
- tokens.push({
30182
- start,
30183
- type: "QuotedIdentifier",
30184
- value: identifier
30185
- });
30186
- } else if (stream[this._current] === `'`) {
30187
- start = this._current;
30188
- identifier = this.consumeRawStringLiteral(stream);
30189
- tokens.push({
30190
- start,
30191
- type: "Literal",
30192
- value: identifier
30193
- });
30194
- } else if (stream[this._current] === "`") {
30195
- start = this._current;
30196
- const literal = this.consumeLiteral(stream);
30197
- tokens.push({
30198
- start,
30199
- type: "Literal",
30200
- value: literal
30201
- });
30202
- } else if (operatorStartToken[stream[this._current]] !== undefined) {
30203
- token = this.consumeOperator(stream);
30204
- token && tokens.push(token);
30205
- } else if (skipChars[stream[this._current]] !== undefined) {
30206
- this._current += 1;
29880
+ function isObject2(obj) {
29881
+ if (obj !== null) {
29882
+ return Object.prototype.toString.call(obj) === "[object Object]";
30207
29883
  } else {
30208
- const error = new Error(`Syntax error: unknown character: ${stream[this._current]}`);
30209
- error.name = "LexerError";
30210
- throw error;
29884
+ return false;
30211
29885
  }
30212
29886
  }
30213
- return tokens;
30214
- }
30215
- consumeUnquotedIdentifier(stream) {
30216
- const start = this._current;
30217
- this._current += 1;
30218
- while (this._current < stream.length && isAlphaNum(stream[this._current])) {
30219
- this._current += 1;
30220
- }
30221
- return stream.slice(start, this._current);
30222
- }
30223
- consumeQuotedIdentifier(stream) {
30224
- const start = this._current;
30225
- this._current += 1;
30226
- const maxLength = stream.length;
30227
- while (stream[this._current] !== '"' && this._current < maxLength) {
30228
- let current = this._current;
30229
- if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) {
30230
- current += 2;
30231
- } else {
30232
- current += 1;
29887
+ function strictDeepEqual(first, second) {
29888
+ if (first === second) {
29889
+ return true;
30233
29890
  }
30234
- this._current = current;
30235
- }
30236
- this._current += 1;
30237
- const [value, ok] = this.parseJSON(stream.slice(start, this._current));
30238
- if (!ok) {
30239
- const error = new Error(`syntax: unexpected end of JSON input`);
30240
- error.name = "LexerError";
30241
- throw error;
30242
- }
30243
- return value;
30244
- }
30245
- consumeRawStringLiteral(stream) {
30246
- const start = this._current;
30247
- this._current += 1;
30248
- const maxLength = stream.length;
30249
- while (stream[this._current] !== `'` && this._current < maxLength) {
30250
- let current = this._current;
30251
- if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === `'`)) {
30252
- current += 2;
30253
- } else {
30254
- current += 1;
30255
- }
30256
- this._current = current;
30257
- }
30258
- this._current += 1;
30259
- const literal = stream.slice(start + 1, this._current - 1);
30260
- return replace(replace(literal, `\\\\`, `\\`), `\\'`, `'`);
30261
- }
30262
- consumeNumber(stream) {
30263
- const start = this._current;
30264
- this._current += 1;
30265
- const maxLength = stream.length;
30266
- while (isNum(stream[this._current]) && this._current < maxLength) {
30267
- this._current += 1;
30268
- }
30269
- const value = parseInt(stream.slice(start, this._current), 10);
30270
- return { start, value, type: "Number" };
30271
- }
30272
- consumeLBracket(stream) {
30273
- const start = this._current;
30274
- this._current += 1;
30275
- if (stream[this._current] === "?") {
30276
- this._current += 1;
30277
- return { start, type: "Filter", value: "[?" };
30278
- }
30279
- if (stream[this._current] === "]") {
30280
- this._current += 1;
30281
- return { start, type: "Flatten", value: "[]" };
30282
- }
30283
- return { start, type: "Lbracket", value: "[" };
30284
- }
30285
- consumeOrElse(stream, peek, token, orElse) {
30286
- const start = this._current;
30287
- this._current += 1;
30288
- if (this._current < stream.length && stream[this._current] === peek) {
30289
- this._current += 1;
30290
- return {
30291
- start,
30292
- type: orElse,
30293
- value: stream.slice(start, this._current)
30294
- };
30295
- }
30296
- return { start, type: token, value: stream[start] };
30297
- }
30298
- consumeOperator(stream) {
30299
- const start = this._current;
30300
- const startingChar = stream[start];
30301
- switch (startingChar) {
30302
- case "!":
30303
- return this.consumeOrElse(stream, "=", "Not", "NE");
30304
- case "<":
30305
- return this.consumeOrElse(stream, "=", "LT", "LTE");
30306
- case ">":
30307
- return this.consumeOrElse(stream, "=", "GT", "GTE");
30308
- case "=":
30309
- return this.consumeOrElse(stream, "=", "Assign", "EQ");
30310
- case "&":
30311
- return this.consumeOrElse(stream, "&", "Expref", "And");
30312
- case "|":
30313
- return this.consumeOrElse(stream, "|", "Pipe", "Or");
30314
- case "/":
30315
- return this.consumeOrElse(stream, "/", "Divide", "Div");
30316
- }
30317
- }
30318
- consumeLiteral(stream) {
30319
- this._current += 1;
30320
- const start = this._current;
30321
- const maxLength = stream.length;
30322
- while (stream[this._current] !== "`" && this._current < maxLength) {
30323
- let current = this._current;
30324
- if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) {
30325
- current += 2;
30326
- } else {
30327
- current += 1;
29891
+ var firstType = Object.prototype.toString.call(first);
29892
+ if (firstType !== Object.prototype.toString.call(second)) {
29893
+ return false;
30328
29894
  }
30329
- this._current = current;
30330
- }
30331
- let literalString = stream.slice(start, this._current).trimStart();
30332
- literalString = literalString.replace("\\`", "`");
30333
- let literal = null;
30334
- let ok = false;
30335
- if (this.looksLikeJSON(literalString)) {
30336
- [literal, ok] = this.parseJSON(literalString);
30337
- }
30338
- if (!ok && this._enable_legacy_literals) {
30339
- [literal, ok] = this.parseJSON(`"${literalString}"`);
30340
- }
30341
- if (!ok) {
30342
- const error = new Error(`Syntax error: unexpected end of JSON input or invalid format for a JSON literal: ${stream[this._current]}`);
30343
- error.name = "LexerError";
30344
- throw error;
30345
- }
30346
- this._current += 1;
30347
- return literal;
30348
- }
30349
- looksLikeJSON(literalString) {
30350
- const startingChars = '[{"';
30351
- const jsonLiterals = ["true", "false", "null"];
30352
- const numberLooking = "-0123456789";
30353
- if (literalString === "") {
30354
- return false;
30355
- }
30356
- if (startingChars.includes(literalString[0])) {
30357
- return true;
30358
- }
30359
- if (jsonLiterals.includes(literalString)) {
30360
- return true;
30361
- }
30362
- if (numberLooking.includes(literalString[0])) {
30363
- const [_, ok] = this.parseJSON(literalString);
30364
- return ok;
30365
- }
30366
- return false;
30367
- }
30368
- parseJSON(text) {
30369
- try {
30370
- const json2 = JSON.parse(text);
30371
- return [json2, true];
30372
- } catch {
30373
- return [null, false];
30374
- }
30375
- }
30376
- };
30377
- var Lexer;
30378
- var Lexer_default;
30379
- var bindingPower;
30380
- var TokenParser = class _TokenParser {
30381
- index = 0;
30382
- tokens = [];
30383
- parse(expression, options) {
30384
- this.loadTokens(expression, options || { enable_legacy_literals: false });
30385
- this.index = 0;
30386
- const ast = this.expression(0);
30387
- if (this.lookahead(0) !== "EOF") {
30388
- const token = this.lookaheadToken(0);
30389
- this.errorToken(token, `Syntax error: unexpected token type: ${token.type}, value: ${token.value}`);
30390
- }
30391
- return ast;
30392
- }
30393
- loadTokens(expression, options) {
30394
- this.tokens = Lexer_default.tokenize(expression, options);
30395
- this.tokens.push({ type: "EOF", value: "", start: expression.length });
30396
- }
30397
- expression(rbp) {
30398
- const leftToken = this.lookaheadToken(0);
30399
- this.advance();
30400
- let left = this.nud(leftToken);
30401
- let currentTokenType = this.lookahead(0);
30402
- while (rbp < bindingPower[currentTokenType]) {
30403
- this.advance();
30404
- left = this.led(currentTokenType, left);
30405
- currentTokenType = this.lookahead(0);
30406
- }
30407
- return left;
30408
- }
30409
- lookahead(offset) {
30410
- return this.tokens[this.index + offset].type;
30411
- }
30412
- lookaheadToken(offset) {
30413
- return this.tokens[this.index + offset];
30414
- }
30415
- advance() {
30416
- this.index += 1;
30417
- }
30418
- nud(token) {
30419
- switch (token.type) {
30420
- case "Variable":
30421
- return { type: "Variable", name: token.value };
30422
- case "Literal":
30423
- return { type: "Literal", value: token.value };
30424
- case "UnquotedIdentifier": {
30425
- if (_TokenParser.isKeyword(token, "let") && this.lookahead(0) === "Variable") {
30426
- return this.parseLetExpression();
30427
- } else {
30428
- return { type: "Field", name: token.value };
29895
+ if (isArray2(first) === true) {
29896
+ if (first.length !== second.length) {
29897
+ return false;
30429
29898
  }
30430
- }
30431
- case "QuotedIdentifier":
30432
- if (this.lookahead(0) === "Lparen") {
30433
- throw new Error("Syntax error: quoted identifier not allowed for function names.");
30434
- } else {
30435
- return { type: "Field", name: token.value };
29899
+ for (var i2 = 0;i2 < first.length; i2++) {
29900
+ if (strictDeepEqual(first[i2], second[i2]) === false) {
29901
+ return false;
29902
+ }
30436
29903
  }
30437
- case "Not": {
30438
- const child = this.expression(bindingPower.Not);
30439
- return { type: "NotExpression", child };
30440
- }
30441
- case "Minus": {
30442
- const child = this.expression(bindingPower.Minus);
30443
- return {
30444
- type: "Unary",
30445
- operator: token.type,
30446
- operand: child
30447
- };
30448
- }
30449
- case "Plus": {
30450
- const child = this.expression(bindingPower.Plus);
30451
- return {
30452
- type: "Unary",
30453
- operator: token.type,
30454
- operand: child
30455
- };
29904
+ return true;
30456
29905
  }
30457
- case "Star": {
30458
- const left = { type: "Identity" };
30459
- return { type: "ValueProjection", left, right: this.parseProjectionRHS(bindingPower.Star) };
30460
- }
30461
- case "Filter":
30462
- return this.led(token.type, { type: "Identity" });
30463
- case "Lbrace":
30464
- return this.parseMultiselectHash();
30465
- case "Flatten": {
30466
- const left = {
30467
- type: "Flatten",
30468
- child: { type: "Identity" }
30469
- };
30470
- const right = this.parseProjectionRHS(bindingPower.Flatten);
30471
- return { type: "Projection", left, right };
30472
- }
30473
- case "Lbracket": {
30474
- if (this.lookahead(0) === "Number" || this.lookahead(0) === "Colon") {
30475
- const right = this.parseIndexExpression();
30476
- return this.projectIfSlice({ type: "Identity" }, right);
30477
- }
30478
- if (this.lookahead(0) === "Star" && this.lookahead(1) === "Rbracket") {
30479
- this.advance();
30480
- this.advance();
30481
- const right = this.parseProjectionRHS(bindingPower.Star);
30482
- return {
30483
- left: { type: "Identity" },
30484
- right,
30485
- type: "Projection"
30486
- };
29906
+ if (isObject2(first) === true) {
29907
+ var keysSeen = {};
29908
+ for (var key in first) {
29909
+ if (hasOwnProperty.call(first, key)) {
29910
+ if (strictDeepEqual(first[key], second[key]) === false) {
29911
+ return false;
29912
+ }
29913
+ keysSeen[key] = true;
29914
+ }
30487
29915
  }
30488
- return this.parseMultiselectList();
30489
- }
30490
- case "Current":
30491
- return { type: "Current" };
30492
- case "Root":
30493
- return { type: "Root" };
30494
- case "Expref": {
30495
- const child = this.expression(bindingPower.Expref);
30496
- return { type: "ExpressionReference", child };
29916
+ for (var key2 in second) {
29917
+ if (hasOwnProperty.call(second, key2)) {
29918
+ if (keysSeen[key2] !== true) {
29919
+ return false;
29920
+ }
29921
+ }
29922
+ }
29923
+ return true;
30497
29924
  }
30498
- case "Lparen": {
30499
- const expression = this.expression(0);
30500
- this.match("Rparen");
30501
- return expression;
29925
+ return false;
29926
+ }
29927
+ function isFalse(obj) {
29928
+ if (obj === "" || obj === false || obj === null) {
29929
+ return true;
29930
+ } else if (isArray2(obj) && obj.length === 0) {
29931
+ return true;
29932
+ } else if (isObject2(obj)) {
29933
+ for (var key in obj) {
29934
+ if (obj.hasOwnProperty(key)) {
29935
+ return false;
29936
+ }
29937
+ }
29938
+ return true;
29939
+ } else {
29940
+ return false;
30502
29941
  }
30503
- default:
30504
- this.errorToken(token);
30505
29942
  }
30506
- }
30507
- led(tokenName, left) {
30508
- switch (tokenName) {
30509
- case "Question": {
30510
- const trueExpr = this.expression(0);
30511
- this.match("Colon");
30512
- const falseExpr = this.expression(0);
30513
- return {
30514
- type: "Ternary",
30515
- condition: left,
30516
- trueExpr,
30517
- falseExpr
30518
- };
29943
+ function objValues(obj) {
29944
+ var keys = Object.keys(obj);
29945
+ var values = [];
29946
+ for (var i2 = 0;i2 < keys.length; i2++) {
29947
+ values.push(obj[keys[i2]]);
30519
29948
  }
30520
- case "Dot": {
30521
- const rbp = bindingPower.Dot;
30522
- if (this.lookahead(0) !== "Star") {
30523
- const right2 = this.parseDotRHS(rbp);
30524
- return { type: "Subexpression", left, right: right2 };
30525
- }
30526
- this.advance();
30527
- const right = this.parseProjectionRHS(rbp);
30528
- return { type: "ValueProjection", left, right };
30529
- }
30530
- case "Pipe": {
30531
- const right = this.expression(bindingPower.Pipe);
30532
- return { type: "Pipe", left, right };
30533
- }
30534
- case "Or": {
30535
- const right = this.expression(bindingPower.Or);
30536
- return { type: "OrExpression", left, right };
30537
- }
30538
- case "And": {
30539
- const right = this.expression(bindingPower.And);
30540
- return { type: "AndExpression", left, right };
30541
- }
30542
- case "Lparen": {
30543
- if (left.type !== "Field") {
30544
- throw new Error("Syntax error: expected a Field node");
30545
- }
30546
- const name = left.name;
30547
- const args = this.parseCommaSeparatedExpressionsUntilToken("Rparen");
30548
- const node = { name, type: "Function", children: args };
30549
- return node;
30550
- }
30551
- case "Filter": {
30552
- const condition = this.expression(0);
30553
- this.match("Rbracket");
30554
- const right = this.lookahead(0) === "Flatten" ? { type: "Identity" } : this.parseProjectionRHS(bindingPower.Filter);
30555
- return { type: "FilterProjection", left, right, condition };
30556
- }
30557
- case "Flatten": {
30558
- const leftNode = { type: "Flatten", child: left };
30559
- const right = this.parseProjectionRHS(bindingPower.Flatten);
30560
- return { type: "Projection", left: leftNode, right };
30561
- }
30562
- case "Assign": {
30563
- const leftNode = left;
30564
- const right = this.expression(0);
30565
- return {
30566
- type: "Binding",
30567
- variable: leftNode.name,
30568
- reference: right
30569
- };
29949
+ return values;
29950
+ }
29951
+ function merge2(a, b) {
29952
+ var merged = {};
29953
+ for (var key in a) {
29954
+ merged[key] = a[key];
30570
29955
  }
30571
- case "EQ":
30572
- case "NE":
30573
- case "GT":
30574
- case "GTE":
30575
- case "LT":
30576
- case "LTE":
30577
- return this.parseComparator(left, tokenName);
30578
- case "Plus":
30579
- case "Minus":
30580
- case "Multiply":
30581
- case "Star":
30582
- case "Divide":
30583
- case "Modulo":
30584
- case "Div":
30585
- return this.parseArithmetic(left, tokenName);
30586
- case "Lbracket": {
30587
- const token = this.lookaheadToken(0);
30588
- if (token.type === "Number" || token.type === "Colon") {
30589
- const right2 = this.parseIndexExpression();
30590
- return this.projectIfSlice(left, right2);
30591
- }
30592
- this.match("Star");
30593
- this.match("Rbracket");
30594
- const right = this.parseProjectionRHS(bindingPower.Star);
30595
- return { type: "Projection", left, right };
29956
+ for (var key2 in b) {
29957
+ merged[key2] = b[key2];
30596
29958
  }
30597
- default:
30598
- return this.errorToken(this.lookaheadToken(0));
29959
+ return merged;
30599
29960
  }
30600
- }
30601
- static isKeyword(token, keyword) {
30602
- return token.type === "UnquotedIdentifier" && token.value === keyword;
30603
- }
30604
- match(tokenType) {
30605
- if (this.lookahead(0) === tokenType) {
30606
- this.advance();
30607
- return;
29961
+ var trimLeft;
29962
+ if (typeof String.prototype.trimLeft === "function") {
29963
+ trimLeft = function(str2) {
29964
+ return str2.trimLeft();
29965
+ };
30608
29966
  } else {
30609
- const token = this.lookaheadToken(0);
30610
- this.errorToken(token, `Syntax error: expected ${tokenType}, got: ${token.type}`);
30611
- }
30612
- }
30613
- errorToken(token, message = "") {
30614
- const error = new Error(message || `Syntax error: invalid token (${token.type}): "${token.value}"`);
30615
- error.name = "ParserError";
30616
- throw error;
30617
- }
30618
- parseIndexExpression() {
30619
- if (this.lookahead(0) === "Colon" || this.lookahead(1) === "Colon") {
30620
- return this.parseSliceExpression();
30621
- }
30622
- const value = Number(this.lookaheadToken(0).value);
30623
- this.advance();
30624
- this.match("Rbracket");
30625
- return { type: "Index", value };
30626
- }
30627
- projectIfSlice(left, right) {
30628
- const indexExpr = {
30629
- type: "IndexExpression",
30630
- left,
30631
- right
30632
- };
30633
- if (right.type === "Slice") {
30634
- return {
30635
- left: indexExpr,
30636
- right: this.parseProjectionRHS(bindingPower.Star),
30637
- type: "Projection"
29967
+ trimLeft = function(str2) {
29968
+ return str2.match(/^\s*(.*)/)[1];
30638
29969
  };
30639
29970
  }
30640
- return indexExpr;
30641
- }
30642
- parseSliceExpression() {
30643
- const parts = [null, null, null];
30644
- let index = 0;
30645
- let current = this.lookaheadToken(0);
30646
- while (current.type != "Rbracket" && index < 3) {
30647
- if (current.type === "Colon") {
30648
- index++;
30649
- if (index === 3) {
30650
- this.errorToken(this.lookaheadToken(0), "Syntax error, too many colons in slice expression");
30651
- }
30652
- this.advance();
30653
- } else if (current.type === "Number") {
30654
- const part = this.lookaheadToken(0).value;
30655
- parts[index] = part;
30656
- this.advance();
30657
- } else {
30658
- const next = this.lookaheadToken(0);
30659
- this.errorToken(next, `Syntax error, unexpected token: ${next.value}(${next.type})`);
30660
- }
30661
- current = this.lookaheadToken(0);
30662
- }
30663
- this.match("Rbracket");
30664
- const [start, stop, step] = parts;
30665
- return { type: "Slice", start, stop, step };
30666
- }
30667
- parseLetExpression() {
30668
- const separated = this.parseCommaSeparatedExpressionsUntilKeyword("in");
30669
- const expression = this.expression(0);
30670
- const bindings = separated.map((binding2) => binding2);
30671
- return {
30672
- type: "LetExpression",
30673
- bindings,
30674
- expression
30675
- };
30676
- }
30677
- parseCommaSeparatedExpressionsUntilKeyword(keyword) {
30678
- return this.parseCommaSeparatedExpressionsUntil(() => {
30679
- return _TokenParser.isKeyword(this.lookaheadToken(0), keyword);
30680
- }, () => {
30681
- this.advance();
30682
- });
30683
- }
30684
- parseCommaSeparatedExpressionsUntilToken(token) {
30685
- return this.parseCommaSeparatedExpressionsUntil(() => {
30686
- return this.lookahead(0) === token;
30687
- }, () => {
30688
- return this.match(token);
30689
- });
30690
- }
30691
- parseCommaSeparatedExpressionsUntil(isEndToken, matchEndToken) {
30692
- const args = [];
30693
- let expression;
30694
- while (!isEndToken()) {
30695
- expression = this.expression(0);
30696
- if (this.lookahead(0) === "Comma") {
30697
- this.match("Comma");
30698
- }
30699
- args.push(expression);
30700
- }
30701
- matchEndToken();
30702
- return args;
30703
- }
30704
- parseComparator(left, comparator) {
30705
- const right = this.expression(bindingPower[comparator]);
30706
- return { type: "Comparator", name: comparator, left, right };
30707
- }
30708
- parseArithmetic(left, operator) {
30709
- const right = this.expression(bindingPower[operator]);
30710
- return { type: "Arithmetic", operator, left, right };
30711
- }
30712
- parseDotRHS(rbp) {
30713
- const lookahead = this.lookahead(0);
30714
- const exprTokens = ["UnquotedIdentifier", "QuotedIdentifier", "Star"];
30715
- if (exprTokens.includes(lookahead)) {
30716
- return this.expression(rbp);
30717
- }
30718
- if (lookahead === "Lbracket") {
30719
- this.match("Lbracket");
30720
- return this.parseMultiselectList();
30721
- }
30722
- if (lookahead === "Lbrace") {
30723
- this.match("Lbrace");
30724
- return this.parseMultiselectHash();
30725
- }
30726
- const token = this.lookaheadToken(0);
30727
- this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
30728
- }
30729
- parseProjectionRHS(rbp) {
30730
- if (bindingPower[this.lookahead(0)] < 10) {
30731
- return { type: "Identity" };
30732
- }
30733
- if (this.lookahead(0) === "Lbracket") {
30734
- return this.expression(rbp);
30735
- }
30736
- if (this.lookahead(0) === "Filter") {
30737
- return this.expression(rbp);
30738
- }
30739
- if (this.lookahead(0) === "Dot") {
30740
- this.match("Dot");
30741
- return this.parseDotRHS(rbp);
30742
- }
30743
- const token = this.lookaheadToken(0);
30744
- this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
30745
- }
30746
- parseMultiselectList() {
30747
- const expressions = [];
30748
- while (this.lookahead(0) !== "Rbracket") {
30749
- const expression = this.expression(0);
30750
- expressions.push(expression);
30751
- if (this.lookahead(0) === "Comma") {
30752
- this.match("Comma");
30753
- if (this.lookahead(0) === "Rbracket") {
30754
- throw new Error("Syntax error: unexpected token Rbracket");
30755
- }
30756
- }
30757
- }
30758
- this.match("Rbracket");
30759
- return { type: "MultiSelectList", children: expressions };
30760
- }
30761
- parseMultiselectHash() {
30762
- const pairs2 = [];
30763
- const identifierTypes = ["UnquotedIdentifier", "QuotedIdentifier"];
30764
- let keyToken;
30765
- let keyName;
30766
- let value;
30767
- for (;; ) {
30768
- keyToken = this.lookaheadToken(0);
30769
- if (!identifierTypes.includes(keyToken.type)) {
30770
- throw new Error(`Syntax error: expecting an identifier token, got: ${keyToken.type}`);
30771
- }
30772
- keyName = keyToken.value;
30773
- this.advance();
30774
- this.match("Colon");
30775
- value = this.expression(0);
30776
- pairs2.push({ value, type: "KeyValuePair", name: keyName });
30777
- if (this.lookahead(0) === "Comma") {
30778
- this.match("Comma");
30779
- } else if (this.lookahead(0) === "Rbrace") {
30780
- this.match("Rbrace");
30781
- break;
30782
- }
30783
- }
30784
- return { type: "MultiSelectHash", children: pairs2 };
30785
- }
30786
- };
30787
- var Parser;
30788
- var Parser_default;
30789
- var Text = class _Text {
30790
- _text;
30791
- constructor(text) {
30792
- this._text = text;
30793
- }
30794
- get string() {
30795
- return this._text;
30796
- }
30797
- get length() {
30798
- return this.codePoints.length;
30799
- }
30800
- compareTo(other) {
30801
- return _Text.compare(this, new _Text(other));
30802
- }
30803
- static get comparer() {
30804
- const stringComparer = (left, right) => {
30805
- return new _Text(left).compareTo(right);
30806
- };
30807
- return stringComparer;
30808
- }
30809
- static compare(left, right) {
30810
- const leftCp = left.codePoints;
30811
- const rightCp = right.codePoints;
30812
- for (let index = 0;index < Math.min(leftCp.length, rightCp.length); index++) {
30813
- if (leftCp[index] === rightCp[index]) {
30814
- continue;
30815
- }
30816
- return leftCp[index] - rightCp[index] > 0 ? 1 : -1;
30817
- }
30818
- return leftCp.length - rightCp.length > 0 ? 1 : -1;
30819
- }
30820
- reverse() {
30821
- return String.fromCodePoint(...this.codePoints.reverse());
30822
- }
30823
- get codePoints() {
30824
- const array = [...this._text].map((s) => s.codePointAt(0));
30825
- return array;
30826
- }
30827
- };
30828
- var createMathFunction = (mathFn) => ([value]) => mathFn(value);
30829
- var createStringFunction = (stringFn) => ([subject]) => stringFn(subject);
30830
- var createObjectFunction = (objFn) => ([obj]) => objFn(obj);
30831
- var Runtime = class {
30832
- _interpreter;
30833
- _functionTable;
30834
- _customFunctions = /* @__PURE__ */ new Set;
30835
- TYPE_NAME_TABLE = Object.freeze({
30836
- [0]: "number",
30837
- [1]: "any",
30838
- [2]: "string",
30839
- [3]: "array",
30840
- [4]: "object",
30841
- [5]: "boolean",
30842
- [6]: "expression",
30843
- [7]: "null",
30844
- [8]: "Array<number>",
30845
- [10]: "Array<object>",
30846
- [9]: "Array<string>",
30847
- [11]: "Array<Array<any>>"
30848
- });
30849
- constructor(interpreter) {
30850
- this._interpreter = interpreter;
30851
- this._functionTable = this.buildFunctionTable();
30852
- }
30853
- buildFunctionTable() {
30854
- return {
30855
- abs: { _func: createMathFunction(Math.abs), _signature: [{ types: [0] }] },
30856
- ceil: { _func: createMathFunction(Math.ceil), _signature: [{ types: [0] }] },
30857
- floor: { _func: createMathFunction(Math.floor), _signature: [{ types: [0] }] },
30858
- lower: { _func: createStringFunction(lower), _signature: [{ types: [2] }] },
30859
- upper: { _func: createStringFunction(upper), _signature: [{ types: [2] }] },
30860
- keys: { _func: createObjectFunction(Object.keys), _signature: [{ types: [4] }] },
30861
- values: { _func: createObjectFunction(Object.values), _signature: [{ types: [4] }] },
30862
- avg: { _func: this.functionAvg, _signature: [{ types: [8] }] },
30863
- contains: {
30864
- _func: this.functionContains,
30865
- _signature: [
30866
- { types: [2, 3] },
30867
- { types: [1] }
30868
- ]
29971
+ var TYPE_NUMBER = 0;
29972
+ var TYPE_ANY = 1;
29973
+ var TYPE_STRING = 2;
29974
+ var TYPE_ARRAY = 3;
29975
+ var TYPE_OBJECT = 4;
29976
+ var TYPE_BOOLEAN = 5;
29977
+ var TYPE_EXPREF = 6;
29978
+ var TYPE_NULL = 7;
29979
+ var TYPE_ARRAY_NUMBER = 8;
29980
+ var TYPE_ARRAY_STRING = 9;
29981
+ var TYPE_NAME_TABLE = {
29982
+ 0: "number",
29983
+ 1: "any",
29984
+ 2: "string",
29985
+ 3: "array",
29986
+ 4: "object",
29987
+ 5: "boolean",
29988
+ 6: "expression",
29989
+ 7: "null",
29990
+ 8: "Array<number>",
29991
+ 9: "Array<string>"
29992
+ };
29993
+ var TOK_EOF = "EOF";
29994
+ var TOK_UNQUOTEDIDENTIFIER = "UnquotedIdentifier";
29995
+ var TOK_QUOTEDIDENTIFIER = "QuotedIdentifier";
29996
+ var TOK_RBRACKET = "Rbracket";
29997
+ var TOK_RPAREN = "Rparen";
29998
+ var TOK_COMMA = "Comma";
29999
+ var TOK_COLON = "Colon";
30000
+ var TOK_RBRACE = "Rbrace";
30001
+ var TOK_NUMBER = "Number";
30002
+ var TOK_CURRENT = "Current";
30003
+ var TOK_EXPREF = "Expref";
30004
+ var TOK_PIPE = "Pipe";
30005
+ var TOK_OR = "Or";
30006
+ var TOK_AND = "And";
30007
+ var TOK_EQ = "EQ";
30008
+ var TOK_GT = "GT";
30009
+ var TOK_LT = "LT";
30010
+ var TOK_GTE = "GTE";
30011
+ var TOK_LTE = "LTE";
30012
+ var TOK_NE = "NE";
30013
+ var TOK_FLATTEN = "Flatten";
30014
+ var TOK_STAR = "Star";
30015
+ var TOK_FILTER = "Filter";
30016
+ var TOK_DOT = "Dot";
30017
+ var TOK_NOT = "Not";
30018
+ var TOK_LBRACE = "Lbrace";
30019
+ var TOK_LBRACKET = "Lbracket";
30020
+ var TOK_LPAREN = "Lparen";
30021
+ var TOK_LITERAL = "Literal";
30022
+ var basicTokens = {
30023
+ ".": TOK_DOT,
30024
+ "*": TOK_STAR,
30025
+ ",": TOK_COMMA,
30026
+ ":": TOK_COLON,
30027
+ "{": TOK_LBRACE,
30028
+ "}": TOK_RBRACE,
30029
+ "]": TOK_RBRACKET,
30030
+ "(": TOK_LPAREN,
30031
+ ")": TOK_RPAREN,
30032
+ "@": TOK_CURRENT
30033
+ };
30034
+ var operatorStartToken = {
30035
+ "<": true,
30036
+ ">": true,
30037
+ "=": true,
30038
+ "!": true
30039
+ };
30040
+ var skipChars = {
30041
+ " ": true,
30042
+ "\t": true,
30043
+ "\n": true
30044
+ };
30045
+ function isAlpha(ch) {
30046
+ return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
30047
+ }
30048
+ function isNum(ch) {
30049
+ return ch >= "0" && ch <= "9" || ch === "-";
30050
+ }
30051
+ function isAlphaNum(ch) {
30052
+ return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_";
30053
+ }
30054
+ function Lexer() {}
30055
+ Lexer.prototype = {
30056
+ tokenize: function(stream) {
30057
+ var tokens = [];
30058
+ this._current = 0;
30059
+ var start;
30060
+ var identifier;
30061
+ var token;
30062
+ while (this._current < stream.length) {
30063
+ if (isAlpha(stream[this._current])) {
30064
+ start = this._current;
30065
+ identifier = this._consumeUnquotedIdentifier(stream);
30066
+ tokens.push({
30067
+ type: TOK_UNQUOTEDIDENTIFIER,
30068
+ value: identifier,
30069
+ start
30070
+ });
30071
+ } else if (basicTokens[stream[this._current]] !== undefined) {
30072
+ tokens.push({
30073
+ type: basicTokens[stream[this._current]],
30074
+ value: stream[this._current],
30075
+ start: this._current
30076
+ });
30077
+ this._current++;
30078
+ } else if (isNum(stream[this._current])) {
30079
+ token = this._consumeNumber(stream);
30080
+ tokens.push(token);
30081
+ } else if (stream[this._current] === "[") {
30082
+ token = this._consumeLBracket(stream);
30083
+ tokens.push(token);
30084
+ } else if (stream[this._current] === '"') {
30085
+ start = this._current;
30086
+ identifier = this._consumeQuotedIdentifier(stream);
30087
+ tokens.push({
30088
+ type: TOK_QUOTEDIDENTIFIER,
30089
+ value: identifier,
30090
+ start
30091
+ });
30092
+ } else if (stream[this._current] === "'") {
30093
+ start = this._current;
30094
+ identifier = this._consumeRawStringLiteral(stream);
30095
+ tokens.push({
30096
+ type: TOK_LITERAL,
30097
+ value: identifier,
30098
+ start
30099
+ });
30100
+ } else if (stream[this._current] === "`") {
30101
+ start = this._current;
30102
+ var literal = this._consumeLiteral(stream);
30103
+ tokens.push({
30104
+ type: TOK_LITERAL,
30105
+ value: literal,
30106
+ start
30107
+ });
30108
+ } else if (operatorStartToken[stream[this._current]] !== undefined) {
30109
+ tokens.push(this._consumeOperator(stream));
30110
+ } else if (skipChars[stream[this._current]] !== undefined) {
30111
+ this._current++;
30112
+ } else if (stream[this._current] === "&") {
30113
+ start = this._current;
30114
+ this._current++;
30115
+ if (stream[this._current] === "&") {
30116
+ this._current++;
30117
+ tokens.push({ type: TOK_AND, value: "&&", start });
30118
+ } else {
30119
+ tokens.push({ type: TOK_EXPREF, value: "&", start });
30120
+ }
30121
+ } else if (stream[this._current] === "|") {
30122
+ start = this._current;
30123
+ this._current++;
30124
+ if (stream[this._current] === "|") {
30125
+ this._current++;
30126
+ tokens.push({ type: TOK_OR, value: "||", start });
30127
+ } else {
30128
+ tokens.push({ type: TOK_PIPE, value: "|", start });
30129
+ }
30130
+ } else {
30131
+ var error = new Error("Unknown character:" + stream[this._current]);
30132
+ error.name = "LexerError";
30133
+ throw error;
30134
+ }
30135
+ }
30136
+ return tokens;
30869
30137
  },
30870
- ends_with: {
30871
- _func: this.functionEndsWith,
30872
- _signature: [{ types: [2] }, { types: [2] }]
30138
+ _consumeUnquotedIdentifier: function(stream) {
30139
+ var start = this._current;
30140
+ this._current++;
30141
+ while (this._current < stream.length && isAlphaNum(stream[this._current])) {
30142
+ this._current++;
30143
+ }
30144
+ return stream.slice(start, this._current);
30873
30145
  },
30874
- find_first: {
30875
- _func: this.functionFindFirst,
30876
- _signature: [
30877
- { types: [2] },
30878
- { types: [2] },
30879
- { types: [0], optional: true },
30880
- { types: [0], optional: true }
30881
- ]
30146
+ _consumeQuotedIdentifier: function(stream) {
30147
+ var start = this._current;
30148
+ this._current++;
30149
+ var maxLength = stream.length;
30150
+ while (stream[this._current] !== '"' && this._current < maxLength) {
30151
+ var current = this._current;
30152
+ if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) {
30153
+ current += 2;
30154
+ } else {
30155
+ current++;
30156
+ }
30157
+ this._current = current;
30158
+ }
30159
+ this._current++;
30160
+ return JSON.parse(stream.slice(start, this._current));
30882
30161
  },
30883
- find_last: {
30884
- _func: this.functionFindLast,
30885
- _signature: [
30886
- { types: [2] },
30887
- { types: [2] },
30888
- { types: [0], optional: true },
30889
- { types: [0], optional: true }
30890
- ]
30162
+ _consumeRawStringLiteral: function(stream) {
30163
+ var start = this._current;
30164
+ this._current++;
30165
+ var maxLength = stream.length;
30166
+ while (stream[this._current] !== "'" && this._current < maxLength) {
30167
+ var current = this._current;
30168
+ if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "'")) {
30169
+ current += 2;
30170
+ } else {
30171
+ current++;
30172
+ }
30173
+ this._current = current;
30174
+ }
30175
+ this._current++;
30176
+ var literal = stream.slice(start + 1, this._current - 1);
30177
+ return literal.replace("\\'", "'");
30891
30178
  },
30892
- from_items: { _func: this.functionFromItems, _signature: [{ types: [11] }] },
30893
- group_by: {
30894
- _func: this.functionGroupBy,
30895
- _signature: [{ types: [3] }, { types: [6] }]
30179
+ _consumeNumber: function(stream) {
30180
+ var start = this._current;
30181
+ this._current++;
30182
+ var maxLength = stream.length;
30183
+ while (isNum(stream[this._current]) && this._current < maxLength) {
30184
+ this._current++;
30185
+ }
30186
+ var value = parseInt(stream.slice(start, this._current));
30187
+ return { type: TOK_NUMBER, value, start };
30896
30188
  },
30897
- items: { _func: this.functionItems, _signature: [{ types: [4] }] },
30898
- join: {
30899
- _func: this.functionJoin,
30900
- _signature: [{ types: [2] }, { types: [9] }]
30189
+ _consumeLBracket: function(stream) {
30190
+ var start = this._current;
30191
+ this._current++;
30192
+ if (stream[this._current] === "?") {
30193
+ this._current++;
30194
+ return { type: TOK_FILTER, value: "[?", start };
30195
+ } else if (stream[this._current] === "]") {
30196
+ this._current++;
30197
+ return { type: TOK_FLATTEN, value: "[]", start };
30198
+ } else {
30199
+ return { type: TOK_LBRACKET, value: "[", start };
30200
+ }
30901
30201
  },
30902
- length: {
30903
- _func: this.functionLength,
30904
- _signature: [{ types: [2, 3, 4] }]
30202
+ _consumeOperator: function(stream) {
30203
+ var start = this._current;
30204
+ var startingChar = stream[start];
30205
+ this._current++;
30206
+ if (startingChar === "!") {
30207
+ if (stream[this._current] === "=") {
30208
+ this._current++;
30209
+ return { type: TOK_NE, value: "!=", start };
30210
+ } else {
30211
+ return { type: TOK_NOT, value: "!", start };
30212
+ }
30213
+ } else if (startingChar === "<") {
30214
+ if (stream[this._current] === "=") {
30215
+ this._current++;
30216
+ return { type: TOK_LTE, value: "<=", start };
30217
+ } else {
30218
+ return { type: TOK_LT, value: "<", start };
30219
+ }
30220
+ } else if (startingChar === ">") {
30221
+ if (stream[this._current] === "=") {
30222
+ this._current++;
30223
+ return { type: TOK_GTE, value: ">=", start };
30224
+ } else {
30225
+ return { type: TOK_GT, value: ">", start };
30226
+ }
30227
+ } else if (startingChar === "=") {
30228
+ if (stream[this._current] === "=") {
30229
+ this._current++;
30230
+ return { type: TOK_EQ, value: "==", start };
30231
+ }
30232
+ }
30905
30233
  },
30906
- map: {
30907
- _func: this.functionMap,
30908
- _signature: [{ types: [6] }, { types: [3] }]
30234
+ _consumeLiteral: function(stream) {
30235
+ this._current++;
30236
+ var start = this._current;
30237
+ var maxLength = stream.length;
30238
+ var literal;
30239
+ while (stream[this._current] !== "`" && this._current < maxLength) {
30240
+ var current = this._current;
30241
+ if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) {
30242
+ current += 2;
30243
+ } else {
30244
+ current++;
30245
+ }
30246
+ this._current = current;
30247
+ }
30248
+ var literalString = trimLeft(stream.slice(start, this._current));
30249
+ literalString = literalString.replace("\\`", "`");
30250
+ if (this._looksLikeJSON(literalString)) {
30251
+ literal = JSON.parse(literalString);
30252
+ } else {
30253
+ literal = JSON.parse('"' + literalString + '"');
30254
+ }
30255
+ this._current++;
30256
+ return literal;
30909
30257
  },
30910
- max: {
30911
- _func: this.functionMax,
30912
- _signature: [{ types: [8, 9] }]
30258
+ _looksLikeJSON: function(literalString) {
30259
+ var startingChars = '[{"';
30260
+ var jsonLiterals = ["true", "false", "null"];
30261
+ var numberLooking = "-0123456789";
30262
+ if (literalString === "") {
30263
+ return false;
30264
+ } else if (startingChars.indexOf(literalString[0]) >= 0) {
30265
+ return true;
30266
+ } else if (jsonLiterals.indexOf(literalString) >= 0) {
30267
+ return true;
30268
+ } else if (numberLooking.indexOf(literalString[0]) >= 0) {
30269
+ try {
30270
+ JSON.parse(literalString);
30271
+ return true;
30272
+ } catch (ex) {
30273
+ return false;
30274
+ }
30275
+ } else {
30276
+ return false;
30277
+ }
30278
+ }
30279
+ };
30280
+ var bindingPower = {};
30281
+ bindingPower[TOK_EOF] = 0;
30282
+ bindingPower[TOK_UNQUOTEDIDENTIFIER] = 0;
30283
+ bindingPower[TOK_QUOTEDIDENTIFIER] = 0;
30284
+ bindingPower[TOK_RBRACKET] = 0;
30285
+ bindingPower[TOK_RPAREN] = 0;
30286
+ bindingPower[TOK_COMMA] = 0;
30287
+ bindingPower[TOK_RBRACE] = 0;
30288
+ bindingPower[TOK_NUMBER] = 0;
30289
+ bindingPower[TOK_CURRENT] = 0;
30290
+ bindingPower[TOK_EXPREF] = 0;
30291
+ bindingPower[TOK_PIPE] = 1;
30292
+ bindingPower[TOK_OR] = 2;
30293
+ bindingPower[TOK_AND] = 3;
30294
+ bindingPower[TOK_EQ] = 5;
30295
+ bindingPower[TOK_GT] = 5;
30296
+ bindingPower[TOK_LT] = 5;
30297
+ bindingPower[TOK_GTE] = 5;
30298
+ bindingPower[TOK_LTE] = 5;
30299
+ bindingPower[TOK_NE] = 5;
30300
+ bindingPower[TOK_FLATTEN] = 9;
30301
+ bindingPower[TOK_STAR] = 20;
30302
+ bindingPower[TOK_FILTER] = 21;
30303
+ bindingPower[TOK_DOT] = 40;
30304
+ bindingPower[TOK_NOT] = 45;
30305
+ bindingPower[TOK_LBRACE] = 50;
30306
+ bindingPower[TOK_LBRACKET] = 55;
30307
+ bindingPower[TOK_LPAREN] = 60;
30308
+ function Parser() {}
30309
+ Parser.prototype = {
30310
+ parse: function(expression) {
30311
+ this._loadTokens(expression);
30312
+ this.index = 0;
30313
+ var ast = this.expression(0);
30314
+ if (this._lookahead(0) !== TOK_EOF) {
30315
+ var t2 = this._lookaheadToken(0);
30316
+ var error = new Error("Unexpected token type: " + t2.type + ", value: " + t2.value);
30317
+ error.name = "ParserError";
30318
+ throw error;
30319
+ }
30320
+ return ast;
30913
30321
  },
30914
- max_by: {
30915
- _func: this.functionMaxBy,
30916
- _signature: [{ types: [3] }, { types: [6] }]
30322
+ _loadTokens: function(expression) {
30323
+ var lexer = new Lexer;
30324
+ var tokens = lexer.tokenize(expression);
30325
+ tokens.push({ type: TOK_EOF, value: "", start: expression.length });
30326
+ this.tokens = tokens;
30917
30327
  },
30918
- merge: { _func: this.functionMerge, _signature: [{ types: [4], variadic: true }] },
30919
- min: {
30920
- _func: this.functionMin,
30921
- _signature: [{ types: [8, 9] }]
30328
+ expression: function(rbp) {
30329
+ var leftToken = this._lookaheadToken(0);
30330
+ this._advance();
30331
+ var left = this.nud(leftToken);
30332
+ var currentToken = this._lookahead(0);
30333
+ while (rbp < bindingPower[currentToken]) {
30334
+ this._advance();
30335
+ left = this.led(currentToken, left);
30336
+ currentToken = this._lookahead(0);
30337
+ }
30338
+ return left;
30922
30339
  },
30923
- min_by: {
30924
- _func: this.functionMinBy,
30925
- _signature: [{ types: [3] }, { types: [6] }]
30340
+ _lookahead: function(number) {
30341
+ return this.tokens[this.index + number].type;
30926
30342
  },
30927
- not_null: { _func: this.functionNotNull, _signature: [{ types: [1], variadic: true }] },
30928
- pad_left: {
30929
- _func: this.functionPadLeft,
30930
- _signature: [
30931
- { types: [2] },
30932
- { types: [0] },
30933
- { types: [2], optional: true }
30934
- ]
30343
+ _lookaheadToken: function(number) {
30344
+ return this.tokens[this.index + number];
30935
30345
  },
30936
- pad_right: {
30937
- _func: this.functionPadRight,
30938
- _signature: [
30939
- { types: [2] },
30940
- { types: [0] },
30941
- { types: [2], optional: true }
30942
- ]
30346
+ _advance: function() {
30347
+ this.index++;
30943
30348
  },
30944
- replace: {
30945
- _func: this.functionReplace,
30946
- _signature: [
30947
- { types: [2] },
30948
- { types: [2] },
30949
- { types: [2] },
30950
- { types: [0], optional: true }
30951
- ]
30349
+ nud: function(token) {
30350
+ var left;
30351
+ var right;
30352
+ var expression;
30353
+ switch (token.type) {
30354
+ case TOK_LITERAL:
30355
+ return { type: "Literal", value: token.value };
30356
+ case TOK_UNQUOTEDIDENTIFIER:
30357
+ return { type: "Field", name: token.value };
30358
+ case TOK_QUOTEDIDENTIFIER:
30359
+ var node = { type: "Field", name: token.value };
30360
+ if (this._lookahead(0) === TOK_LPAREN) {
30361
+ throw new Error("Quoted identifier not allowed for function names.");
30362
+ }
30363
+ return node;
30364
+ case TOK_NOT:
30365
+ right = this.expression(bindingPower.Not);
30366
+ return { type: "NotExpression", children: [right] };
30367
+ case TOK_STAR:
30368
+ left = { type: "Identity" };
30369
+ right = null;
30370
+ if (this._lookahead(0) === TOK_RBRACKET) {
30371
+ right = { type: "Identity" };
30372
+ } else {
30373
+ right = this._parseProjectionRHS(bindingPower.Star);
30374
+ }
30375
+ return { type: "ValueProjection", children: [left, right] };
30376
+ case TOK_FILTER:
30377
+ return this.led(token.type, { type: "Identity" });
30378
+ case TOK_LBRACE:
30379
+ return this._parseMultiselectHash();
30380
+ case TOK_FLATTEN:
30381
+ left = { type: TOK_FLATTEN, children: [{ type: "Identity" }] };
30382
+ right = this._parseProjectionRHS(bindingPower.Flatten);
30383
+ return { type: "Projection", children: [left, right] };
30384
+ case TOK_LBRACKET:
30385
+ if (this._lookahead(0) === TOK_NUMBER || this._lookahead(0) === TOK_COLON) {
30386
+ right = this._parseIndexExpression();
30387
+ return this._projectIfSlice({ type: "Identity" }, right);
30388
+ } else if (this._lookahead(0) === TOK_STAR && this._lookahead(1) === TOK_RBRACKET) {
30389
+ this._advance();
30390
+ this._advance();
30391
+ right = this._parseProjectionRHS(bindingPower.Star);
30392
+ return {
30393
+ type: "Projection",
30394
+ children: [{ type: "Identity" }, right]
30395
+ };
30396
+ }
30397
+ return this._parseMultiselectList();
30398
+ case TOK_CURRENT:
30399
+ return { type: TOK_CURRENT };
30400
+ case TOK_EXPREF:
30401
+ expression = this.expression(bindingPower.Expref);
30402
+ return { type: "ExpressionReference", children: [expression] };
30403
+ case TOK_LPAREN:
30404
+ var args = [];
30405
+ while (this._lookahead(0) !== TOK_RPAREN) {
30406
+ if (this._lookahead(0) === TOK_CURRENT) {
30407
+ expression = { type: TOK_CURRENT };
30408
+ this._advance();
30409
+ } else {
30410
+ expression = this.expression(0);
30411
+ }
30412
+ args.push(expression);
30413
+ }
30414
+ this._match(TOK_RPAREN);
30415
+ return args[0];
30416
+ default:
30417
+ this._errorToken(token);
30418
+ }
30952
30419
  },
30953
- reverse: {
30954
- _func: this.functionReverse,
30955
- _signature: [{ types: [2, 3] }]
30420
+ led: function(tokenName, left) {
30421
+ var right;
30422
+ switch (tokenName) {
30423
+ case TOK_DOT:
30424
+ var rbp = bindingPower.Dot;
30425
+ if (this._lookahead(0) !== TOK_STAR) {
30426
+ right = this._parseDotRHS(rbp);
30427
+ return { type: "Subexpression", children: [left, right] };
30428
+ }
30429
+ this._advance();
30430
+ right = this._parseProjectionRHS(rbp);
30431
+ return { type: "ValueProjection", children: [left, right] };
30432
+ case TOK_PIPE:
30433
+ right = this.expression(bindingPower.Pipe);
30434
+ return { type: TOK_PIPE, children: [left, right] };
30435
+ case TOK_OR:
30436
+ right = this.expression(bindingPower.Or);
30437
+ return { type: "OrExpression", children: [left, right] };
30438
+ case TOK_AND:
30439
+ right = this.expression(bindingPower.And);
30440
+ return { type: "AndExpression", children: [left, right] };
30441
+ case TOK_LPAREN:
30442
+ var name = left.name;
30443
+ var args = [];
30444
+ var expression, node;
30445
+ while (this._lookahead(0) !== TOK_RPAREN) {
30446
+ if (this._lookahead(0) === TOK_CURRENT) {
30447
+ expression = { type: TOK_CURRENT };
30448
+ this._advance();
30449
+ } else {
30450
+ expression = this.expression(0);
30451
+ }
30452
+ if (this._lookahead(0) === TOK_COMMA) {
30453
+ this._match(TOK_COMMA);
30454
+ }
30455
+ args.push(expression);
30456
+ }
30457
+ this._match(TOK_RPAREN);
30458
+ node = { type: "Function", name, children: args };
30459
+ return node;
30460
+ case TOK_FILTER:
30461
+ var condition = this.expression(0);
30462
+ this._match(TOK_RBRACKET);
30463
+ if (this._lookahead(0) === TOK_FLATTEN) {
30464
+ right = { type: "Identity" };
30465
+ } else {
30466
+ right = this._parseProjectionRHS(bindingPower.Filter);
30467
+ }
30468
+ return { type: "FilterProjection", children: [left, right, condition] };
30469
+ case TOK_FLATTEN:
30470
+ var leftNode = { type: TOK_FLATTEN, children: [left] };
30471
+ var rightNode = this._parseProjectionRHS(bindingPower.Flatten);
30472
+ return { type: "Projection", children: [leftNode, rightNode] };
30473
+ case TOK_EQ:
30474
+ case TOK_NE:
30475
+ case TOK_GT:
30476
+ case TOK_GTE:
30477
+ case TOK_LT:
30478
+ case TOK_LTE:
30479
+ return this._parseComparator(left, tokenName);
30480
+ case TOK_LBRACKET:
30481
+ var token = this._lookaheadToken(0);
30482
+ if (token.type === TOK_NUMBER || token.type === TOK_COLON) {
30483
+ right = this._parseIndexExpression();
30484
+ return this._projectIfSlice(left, right);
30485
+ }
30486
+ this._match(TOK_STAR);
30487
+ this._match(TOK_RBRACKET);
30488
+ right = this._parseProjectionRHS(bindingPower.Star);
30489
+ return { type: "Projection", children: [left, right] };
30490
+ default:
30491
+ this._errorToken(this._lookaheadToken(0));
30492
+ }
30956
30493
  },
30957
- sort: {
30958
- _func: this.functionSort,
30959
- _signature: [{ types: [9, 8] }]
30494
+ _match: function(tokenType) {
30495
+ if (this._lookahead(0) === tokenType) {
30496
+ this._advance();
30497
+ } else {
30498
+ var t2 = this._lookaheadToken(0);
30499
+ var error = new Error("Expected " + tokenType + ", got: " + t2.type);
30500
+ error.name = "ParserError";
30501
+ throw error;
30502
+ }
30960
30503
  },
30961
- sort_by: {
30962
- _func: this.functionSortBy,
30963
- _signature: [{ types: [3] }, { types: [6] }]
30504
+ _errorToken: function(token) {
30505
+ var error = new Error("Invalid token (" + token.type + '): "' + token.value + '"');
30506
+ error.name = "ParserError";
30507
+ throw error;
30964
30508
  },
30965
- split: {
30966
- _func: this.functionSplit,
30967
- _signature: [
30968
- { types: [2] },
30969
- { types: [2] },
30970
- { types: [0], optional: true }
30971
- ]
30509
+ _parseIndexExpression: function() {
30510
+ if (this._lookahead(0) === TOK_COLON || this._lookahead(1) === TOK_COLON) {
30511
+ return this._parseSliceExpression();
30512
+ } else {
30513
+ var node = {
30514
+ type: "Index",
30515
+ value: this._lookaheadToken(0).value
30516
+ };
30517
+ this._advance();
30518
+ this._match(TOK_RBRACKET);
30519
+ return node;
30520
+ }
30972
30521
  },
30973
- starts_with: {
30974
- _func: this.functionStartsWith,
30975
- _signature: [{ types: [2] }, { types: [2] }]
30522
+ _projectIfSlice: function(left, right) {
30523
+ var indexExpr = { type: "IndexExpression", children: [left, right] };
30524
+ if (right.type === "Slice") {
30525
+ return {
30526
+ type: "Projection",
30527
+ children: [indexExpr, this._parseProjectionRHS(bindingPower.Star)]
30528
+ };
30529
+ } else {
30530
+ return indexExpr;
30531
+ }
30976
30532
  },
30977
- sum: { _func: this.functionSum, _signature: [{ types: [8] }] },
30978
- to_array: { _func: this.functionToArray, _signature: [{ types: [1] }] },
30979
- to_number: { _func: this.functionToNumber, _signature: [{ types: [1] }] },
30980
- to_string: { _func: this.functionToString, _signature: [{ types: [1] }] },
30981
- trim: {
30982
- _func: this.functionTrim,
30983
- _signature: [{ types: [2] }, { types: [2], optional: true }]
30533
+ _parseSliceExpression: function() {
30534
+ var parts = [null, null, null];
30535
+ var index = 0;
30536
+ var currentToken = this._lookahead(0);
30537
+ while (currentToken !== TOK_RBRACKET && index < 3) {
30538
+ if (currentToken === TOK_COLON) {
30539
+ index++;
30540
+ this._advance();
30541
+ } else if (currentToken === TOK_NUMBER) {
30542
+ parts[index] = this._lookaheadToken(0).value;
30543
+ this._advance();
30544
+ } else {
30545
+ var t2 = this._lookahead(0);
30546
+ var error = new Error("Syntax error, unexpected token: " + t2.value + "(" + t2.type + ")");
30547
+ error.name = "Parsererror";
30548
+ throw error;
30549
+ }
30550
+ currentToken = this._lookahead(0);
30551
+ }
30552
+ this._match(TOK_RBRACKET);
30553
+ return {
30554
+ type: "Slice",
30555
+ children: parts
30556
+ };
30984
30557
  },
30985
- trim_left: {
30986
- _func: this.functionTrimLeft,
30987
- _signature: [{ types: [2] }, { types: [2], optional: true }]
30558
+ _parseComparator: function(left, comparator) {
30559
+ var right = this.expression(bindingPower[comparator]);
30560
+ return { type: "Comparator", name: comparator, children: [left, right] };
30988
30561
  },
30989
- trim_right: {
30990
- _func: this.functionTrimRight,
30991
- _signature: [{ types: [2] }, { types: [2], optional: true }]
30562
+ _parseDotRHS: function(rbp) {
30563
+ var lookahead = this._lookahead(0);
30564
+ var exprTokens = [TOK_UNQUOTEDIDENTIFIER, TOK_QUOTEDIDENTIFIER, TOK_STAR];
30565
+ if (exprTokens.indexOf(lookahead) >= 0) {
30566
+ return this.expression(rbp);
30567
+ } else if (lookahead === TOK_LBRACKET) {
30568
+ this._match(TOK_LBRACKET);
30569
+ return this._parseMultiselectList();
30570
+ } else if (lookahead === TOK_LBRACE) {
30571
+ this._match(TOK_LBRACE);
30572
+ return this._parseMultiselectHash();
30573
+ }
30992
30574
  },
30993
- type: { _func: this.functionType, _signature: [{ types: [1] }] },
30994
- zip: { _func: this.functionZip, _signature: [{ types: [3], variadic: true }] }
30995
- };
30996
- }
30997
- registerFunction(name, customFunction, signature, options) {
30998
- const result = this._registerInternal(name, customFunction, signature, options);
30999
- if (!result.success) {
31000
- throw new Error(result.message);
31001
- }
31002
- }
31003
- _registerInternal(name, customFunction, signature, options = {}) {
31004
- if (!name || typeof name !== "string" || name.trim() === "") {
31005
- return {
31006
- success: false,
31007
- reason: "invalid-name",
31008
- message: "Function name must be a non-empty string"
31009
- };
31010
- }
31011
- try {
31012
- this.validateInputSignatures(name, signature);
31013
- } catch (error) {
31014
- return {
31015
- success: false,
31016
- reason: "invalid-signature",
31017
- message: error instanceof Error ? error.message : "Invalid function signature"
31018
- };
31019
- }
31020
- const { override = false, warn = false } = options;
31021
- const exists = name in this._functionTable;
31022
- if (exists && !override) {
31023
- return {
31024
- success: false,
31025
- reason: "already-exists",
31026
- message: `Function already defined: ${name}(). Use { override: true } to replace it.`
31027
- };
31028
- }
31029
- if (exists && override && warn) {
31030
- console.warn(`Warning: Overriding existing function: ${name}()`);
31031
- }
31032
- this._functionTable[name] = {
31033
- _func: customFunction.bind(this),
31034
- _signature: signature
31035
- };
31036
- this._customFunctions.add(name);
31037
- const message = exists ? `Function ${name}() overridden successfully` : `Function ${name}() registered successfully`;
31038
- return { success: true, message };
31039
- }
31040
- register(name, customFunction, signature, options = {}) {
31041
- return this._registerInternal(name, customFunction, signature, options);
31042
- }
31043
- unregister(name) {
31044
- if (!this._customFunctions.has(name)) {
31045
- return false;
31046
- }
31047
- delete this._functionTable[name];
31048
- this._customFunctions.delete(name);
31049
- return true;
31050
- }
31051
- isRegistered(name) {
31052
- return name in this._functionTable;
31053
- }
31054
- getRegistered() {
31055
- return Object.keys(this._functionTable);
31056
- }
31057
- getCustomFunctions() {
31058
- return Array.from(this._customFunctions);
31059
- }
31060
- clearCustomFunctions() {
31061
- for (const name of this._customFunctions) {
31062
- delete this._functionTable[name];
31063
- }
31064
- this._customFunctions.clear();
31065
- }
31066
- callFunction(name, resolvedArgs) {
31067
- const functionEntry = this._functionTable[name];
31068
- if (functionEntry === undefined) {
31069
- throw new Error(`Unknown function: ${name}()`);
31070
- }
31071
- this.validateArgs(name, resolvedArgs, functionEntry._signature);
31072
- return functionEntry._func.call(this, resolvedArgs);
31073
- }
31074
- validateInputSignatures(name, signature) {
31075
- for (let i2 = 0;i2 < signature.length; i2 += 1) {
31076
- if ("variadic" in signature[i2] && i2 !== signature.length - 1) {
31077
- throw new Error(`Invalid arity: ${name}() 'variadic' argument ${i2 + 1} must occur last`);
31078
- }
31079
- }
31080
- }
31081
- validateArgs(name, args, signature) {
31082
- this.validateInputSignatures(name, signature);
31083
- this.validateArity(name, args, signature);
31084
- this.validateTypes(name, args, signature);
31085
- }
31086
- validateArity(name, args, signature) {
31087
- const numberOfRequiredArgs = signature.filter((argSignature) => !(argSignature.optional ?? false)).length;
31088
- const lastArgIsVariadic = signature[signature.length - 1]?.variadic ?? false;
31089
- const tooFewArgs = args.length < numberOfRequiredArgs;
31090
- const tooManyArgs = args.length > signature.length;
31091
- if (lastArgIsVariadic && tooFewArgs || !lastArgIsVariadic && (tooFewArgs || tooManyArgs)) {
31092
- const tooFewModifier = tooFewArgs && (!lastArgIsVariadic && numberOfRequiredArgs > 1 || lastArgIsVariadic) ? "at least " : "";
31093
- const pluralized = signature.length > 1;
31094
- throw new Error(`Invalid arity: ${name}() takes ${tooFewModifier}${numberOfRequiredArgs} argument${pluralized && "s" || ""} but received ${args.length}`);
31095
- }
31096
- }
31097
- validateTypes(name, args, signature) {
31098
- for (let i2 = 0;i2 < signature.length; i2 += 1) {
31099
- const currentSpec = signature[i2].types;
31100
- const actualType = this.getTypeName(args[i2]);
31101
- if (actualType === undefined) {
31102
- continue;
31103
- }
31104
- const typeMatched = currentSpec.some((expectedType) => this.typeMatches(actualType, expectedType, args[i2]));
31105
- if (!typeMatched) {
31106
- const expected = currentSpec.map((typeId) => this.TYPE_NAME_TABLE[typeId]).join(" | ");
31107
- throw new Error(`Invalid type: ${name}() expected argument ${i2 + 1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead.`);
31108
- }
31109
- }
31110
- }
31111
- typeMatches(actual, expected, argValue) {
31112
- if (expected === 1) {
31113
- return true;
31114
- }
31115
- if (expected === 9 || expected === 8 || expected === 10 || expected === 11 || expected === 3) {
31116
- if (expected === 3) {
31117
- return actual === 3;
31118
- }
31119
- if (actual === 3) {
31120
- let subtype;
31121
- if (expected === 8) {
31122
- subtype = 0;
31123
- } else if (expected === 10) {
31124
- subtype = 4;
31125
- } else if (expected === 9) {
31126
- subtype = 2;
31127
- } else if (expected === 11) {
31128
- subtype = 3;
31129
- }
31130
- const array = argValue;
31131
- for (let i2 = 0;i2 < array.length; i2 += 1) {
31132
- const typeName = this.getTypeName(array[i2]);
31133
- if (typeName !== undefined && subtype !== undefined && !this.typeMatches(typeName, subtype, array[i2])) {
31134
- return false;
30575
+ _parseProjectionRHS: function(rbp) {
30576
+ var right;
30577
+ if (bindingPower[this._lookahead(0)] < 10) {
30578
+ right = { type: "Identity" };
30579
+ } else if (this._lookahead(0) === TOK_LBRACKET) {
30580
+ right = this.expression(rbp);
30581
+ } else if (this._lookahead(0) === TOK_FILTER) {
30582
+ right = this.expression(rbp);
30583
+ } else if (this._lookahead(0) === TOK_DOT) {
30584
+ this._match(TOK_DOT);
30585
+ right = this._parseDotRHS(rbp);
30586
+ } else {
30587
+ var t2 = this._lookaheadToken(0);
30588
+ var error = new Error("Sytanx error, unexpected token: " + t2.value + "(" + t2.type + ")");
30589
+ error.name = "ParserError";
30590
+ throw error;
30591
+ }
30592
+ return right;
30593
+ },
30594
+ _parseMultiselectList: function() {
30595
+ var expressions = [];
30596
+ while (this._lookahead(0) !== TOK_RBRACKET) {
30597
+ var expression = this.expression(0);
30598
+ expressions.push(expression);
30599
+ if (this._lookahead(0) === TOK_COMMA) {
30600
+ this._match(TOK_COMMA);
30601
+ if (this._lookahead(0) === TOK_RBRACKET) {
30602
+ throw new Error("Unexpected token Rbracket");
30603
+ }
31135
30604
  }
31136
30605
  }
31137
- return true;
31138
- }
31139
- } else {
31140
- return actual === expected;
31141
- }
31142
- return false;
31143
- }
31144
- getTypeName(obj) {
31145
- if (obj === null) {
31146
- return 7;
31147
- }
31148
- if (typeof obj === "string") {
31149
- return 2;
31150
- }
31151
- if (typeof obj === "number") {
31152
- return 0;
31153
- }
31154
- if (typeof obj === "boolean") {
31155
- return 5;
31156
- }
31157
- if (Array.isArray(obj)) {
31158
- return 3;
31159
- }
31160
- if (typeof obj === "object") {
31161
- if (obj.expref) {
31162
- return 6;
31163
- }
31164
- return 4;
31165
- }
31166
- return;
31167
- }
31168
- createKeyFunction(exprefNode, allowedTypes) {
31169
- const interpreter = this._interpreter;
31170
- const keyFunc = (x) => {
31171
- const current = interpreter.visit(exprefNode, x);
31172
- if (!allowedTypes.includes(this.getTypeName(current))) {
31173
- const msg = `Invalid type: expected one of (${allowedTypes.map((t2) => this.TYPE_NAME_TABLE[t2]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(current)]}`;
31174
- throw new Error(msg);
30606
+ this._match(TOK_RBRACKET);
30607
+ return { type: "MultiSelectList", children: expressions };
30608
+ },
30609
+ _parseMultiselectHash: function() {
30610
+ var pairs2 = [];
30611
+ var identifierTypes = [TOK_UNQUOTEDIDENTIFIER, TOK_QUOTEDIDENTIFIER];
30612
+ var keyToken, keyName, value, node;
30613
+ for (;; ) {
30614
+ keyToken = this._lookaheadToken(0);
30615
+ if (identifierTypes.indexOf(keyToken.type) < 0) {
30616
+ throw new Error("Expecting an identifier token, got: " + keyToken.type);
30617
+ }
30618
+ keyName = keyToken.value;
30619
+ this._advance();
30620
+ this._match(TOK_COLON);
30621
+ value = this.expression(0);
30622
+ node = { type: "KeyValuePair", name: keyName, value };
30623
+ pairs2.push(node);
30624
+ if (this._lookahead(0) === TOK_COMMA) {
30625
+ this._match(TOK_COMMA);
30626
+ } else if (this._lookahead(0) === TOK_RBRACE) {
30627
+ this._match(TOK_RBRACE);
30628
+ break;
30629
+ }
30630
+ }
30631
+ return { type: "MultiSelectHash", children: pairs2 };
31175
30632
  }
31176
- return current;
31177
30633
  };
31178
- return keyFunc;
31179
- }
31180
- functionAvg = ([inputArray]) => {
31181
- if (!inputArray || inputArray.length == 0) {
31182
- return null;
31183
- }
31184
- let sum = 0;
31185
- for (let i2 = 0;i2 < inputArray.length; i2 += 1) {
31186
- sum += inputArray[i2];
31187
- }
31188
- return sum / inputArray.length;
31189
- };
31190
- functionContains = ([
31191
- searchable,
31192
- searchValue
31193
- ]) => {
31194
- if (Array.isArray(searchable)) {
31195
- const array = searchable;
31196
- return array.includes(searchValue);
31197
- }
31198
- if (typeof searchable === "string") {
31199
- const text = searchable;
31200
- if (typeof searchValue === "string") {
31201
- return text.includes(searchValue);
31202
- }
31203
- }
31204
- return null;
31205
- };
31206
- functionEndsWith = (resolvedArgs) => {
31207
- const [searchStr, suffix] = resolvedArgs;
31208
- return searchStr.includes(suffix, searchStr.length - suffix.length);
31209
- };
31210
- functionFindFirst = this.createFindFunction(findFirst);
31211
- functionFindLast = this.createFindFunction(findLast);
31212
- createFindFunction(findFn) {
31213
- return (resolvedArgs) => {
31214
- const subject = resolvedArgs[0];
31215
- const search2 = resolvedArgs[1];
31216
- const start = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined;
31217
- const end = resolvedArgs.length > 3 ? resolvedArgs[3] : undefined;
31218
- return findFn(subject, search2, start, end);
31219
- };
31220
- }
31221
- functionFromItems = ([array]) => {
31222
- array.map((pair) => {
31223
- if (pair.length != 2 || typeof pair[0] !== "string") {
31224
- throw new Error("invalid value, each array must contain two elements, a pair of string and value");
31225
- }
31226
- });
31227
- return Object.fromEntries(array);
31228
- };
31229
- functionGroupBy = ([array, exprefNode]) => {
31230
- const keyFunction = this.createKeyFunction(exprefNode, [2]);
31231
- return array.reduce((acc, cur) => {
31232
- const k = keyFunction(cur ?? {});
31233
- const target = acc[k] = acc[k] || [];
31234
- target.push(cur);
31235
- return acc;
31236
- }, {});
31237
- };
31238
- functionItems = ([inputValue]) => {
31239
- return Object.entries(inputValue);
31240
- };
31241
- functionJoin = (resolvedArgs) => {
31242
- const [joinChar, listJoin] = resolvedArgs;
31243
- return listJoin.join(joinChar);
31244
- };
31245
- functionLength = ([inputValue]) => {
31246
- if (typeof inputValue === "string") {
31247
- return new Text(inputValue).length;
31248
- }
31249
- if (Array.isArray(inputValue)) {
31250
- return inputValue.length;
31251
- }
31252
- return Object.keys(inputValue).length;
31253
- };
31254
- functionMap = ([exprefNode, elements]) => {
31255
- if (!this._interpreter) {
31256
- return [];
31257
- }
31258
- const mapped = [];
31259
- const interpreter = this._interpreter;
31260
- for (let i2 = 0;i2 < elements.length; i2 += 1) {
31261
- mapped.push(interpreter.visit(exprefNode, elements[i2]));
31262
- }
31263
- return mapped;
31264
- };
31265
- functionMax = ([inputValue]) => {
31266
- if (!inputValue.length) {
31267
- return null;
31268
- }
31269
- const typeName = this.getTypeName(inputValue[0]);
31270
- if (typeName === 0) {
31271
- return Math.max(...inputValue);
31272
- }
31273
- const elements = inputValue;
31274
- let maxElement = elements[0];
31275
- for (let i2 = 1;i2 < elements.length; i2 += 1) {
31276
- if (maxElement.localeCompare(elements[i2]) < 0) {
31277
- maxElement = elements[i2];
31278
- }
31279
- }
31280
- return maxElement;
31281
- };
31282
- functionMaxBy = (resolvedArgs) => {
31283
- const exprefNode = resolvedArgs[1];
31284
- const resolvedArray = resolvedArgs[0];
31285
- const keyFunction = this.createKeyFunction(exprefNode, [0, 2]);
31286
- let maxNumber = -Infinity;
31287
- let maxRecord;
31288
- let current;
31289
- for (let i2 = 0;i2 < resolvedArray.length; i2 += 1) {
31290
- current = keyFunction && keyFunction(resolvedArray[i2]);
31291
- if (current !== undefined && current > maxNumber) {
31292
- maxNumber = current;
31293
- maxRecord = resolvedArray[i2];
31294
- }
31295
- }
31296
- return maxRecord || null;
31297
- };
31298
- functionMerge = (resolvedArgs) => {
31299
- let merged = {};
31300
- for (let i2 = 0;i2 < resolvedArgs.length; i2 += 1) {
31301
- const current = resolvedArgs[i2];
31302
- merged = Object.assign(merged, current);
31303
- }
31304
- return merged;
31305
- };
31306
- functionMin = ([inputValue]) => {
31307
- if (!inputValue.length) {
31308
- return null;
30634
+ function TreeInterpreter(runtime) {
30635
+ this.runtime = runtime;
31309
30636
  }
31310
- const typeName = this.getTypeName(inputValue[0]);
31311
- if (typeName === 0) {
31312
- return Math.min(...inputValue);
31313
- }
31314
- const elements = inputValue;
31315
- let minElement = elements[0];
31316
- for (let i2 = 1;i2 < elements.length; i2 += 1) {
31317
- if (elements[i2].localeCompare(minElement) < 0) {
31318
- minElement = elements[i2];
31319
- }
31320
- }
31321
- return minElement;
31322
- };
31323
- functionMinBy = (resolvedArgs) => {
31324
- const exprefNode = resolvedArgs[1];
31325
- const resolvedArray = resolvedArgs[0];
31326
- const keyFunction = this.createKeyFunction(exprefNode, [0, 2]);
31327
- let minNumber = Infinity;
31328
- let minRecord;
31329
- let current;
31330
- for (let i2 = 0;i2 < resolvedArray.length; i2 += 1) {
31331
- current = keyFunction && keyFunction(resolvedArray[i2]);
31332
- if (current !== undefined && current < minNumber) {
31333
- minNumber = current;
31334
- minRecord = resolvedArray[i2];
31335
- }
31336
- }
31337
- return minRecord || null;
31338
- };
31339
- functionNotNull = (resolvedArgs) => {
31340
- for (let i2 = 0;i2 < resolvedArgs.length; i2 += 1) {
31341
- if (this.getTypeName(resolvedArgs[i2]) !== 7) {
31342
- return resolvedArgs[i2];
31343
- }
31344
- }
31345
- return null;
31346
- };
31347
- functionPadLeft = this.createPadFunction(padLeft);
31348
- functionPadRight = this.createPadFunction(padRight);
31349
- createPadFunction(padFn) {
31350
- return (resolvedArgs) => {
31351
- const subject = resolvedArgs[0];
31352
- const width = resolvedArgs[1];
31353
- const padding = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined;
31354
- return padFn(subject, width, padding);
31355
- };
31356
- }
31357
- functionReplace = (resolvedArgs) => {
31358
- const subject = resolvedArgs[0];
31359
- const string = resolvedArgs[1];
31360
- const by = resolvedArgs[2];
31361
- return replace(subject, string, by, resolvedArgs.length > 3 ? resolvedArgs[3] : undefined);
31362
- };
31363
- functionSplit = (resolvedArgs) => {
31364
- const subject = resolvedArgs[0];
31365
- const search2 = resolvedArgs[1];
31366
- return split(subject, search2, resolvedArgs.length > 2 ? resolvedArgs[2] : undefined);
31367
- };
31368
- functionReverse = ([inputValue]) => {
31369
- const typeName = this.getTypeName(inputValue);
31370
- if (typeName === 2) {
31371
- return new Text(inputValue).reverse();
31372
- }
31373
- const reversedArray = inputValue.slice(0);
31374
- reversedArray.reverse();
31375
- return reversedArray;
31376
- };
31377
- functionSort = ([inputValue]) => {
31378
- if (inputValue.length == 0) {
31379
- return inputValue;
31380
- }
31381
- if (typeof inputValue[0] === "string") {
31382
- return [...inputValue].sort(Text.comparer);
31383
- }
31384
- return [...inputValue].sort();
31385
- };
31386
- functionSortBy = (resolvedArgs) => {
31387
- const sortedArray = resolvedArgs[0].slice(0);
31388
- if (sortedArray.length === 0) {
31389
- return sortedArray;
31390
- }
31391
- const interpreter = this._interpreter;
31392
- const exprefNode = resolvedArgs[1];
31393
- const requiredType = this.getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
31394
- if (requiredType !== undefined && ![0, 2].includes(requiredType)) {
31395
- throw new Error(`Invalid type: unexpected type (${this.TYPE_NAME_TABLE[requiredType]})`);
31396
- }
31397
- function throwInvalidTypeError(rt, item) {
31398
- throw new Error(`Invalid type: expected (${rt.TYPE_NAME_TABLE[requiredType]}), received ${rt.TYPE_NAME_TABLE[rt.getTypeName(item)]}`);
31399
- }
31400
- return sortedArray.sort((a, b) => {
31401
- const exprA = interpreter.visit(exprefNode, a);
31402
- const exprB = interpreter.visit(exprefNode, b);
31403
- if (this.getTypeName(exprA) !== requiredType) {
31404
- throwInvalidTypeError(this, exprA);
31405
- } else if (this.getTypeName(exprB) !== requiredType) {
31406
- throwInvalidTypeError(this, exprB);
31407
- }
31408
- if (requiredType === 2) {
31409
- return Text.comparer(exprA, exprB);
31410
- }
31411
- return exprA - exprB;
31412
- });
31413
- };
31414
- functionStartsWith = ([searchable, searchStr]) => {
31415
- return searchable.startsWith(searchStr);
31416
- };
31417
- functionSum = ([inputValue]) => {
31418
- return inputValue.reduce((x, y) => x + y, 0);
31419
- };
31420
- functionToArray = ([inputValue]) => {
31421
- if (this.getTypeName(inputValue) === 3) {
31422
- return inputValue;
31423
- }
31424
- return [inputValue];
31425
- };
31426
- functionToNumber = ([inputValue]) => {
31427
- const typeName = this.getTypeName(inputValue);
31428
- let convertedValue;
31429
- if (typeName === 0) {
31430
- return inputValue;
31431
- }
31432
- if (typeName === 2) {
31433
- convertedValue = +inputValue;
31434
- if (!isNaN(convertedValue)) {
31435
- return convertedValue;
31436
- }
31437
- }
31438
- return null;
31439
- };
31440
- functionToString = ([inputValue]) => {
31441
- if (this.getTypeName(inputValue) === 2) {
31442
- return inputValue;
31443
- }
31444
- return JSON.stringify(inputValue);
31445
- };
31446
- functionTrim = this.createTrimFunction(trim);
31447
- functionTrimLeft = this.createTrimFunction(trimLeft);
31448
- functionTrimRight = this.createTrimFunction(trimRight);
31449
- createTrimFunction(trimFn) {
31450
- return (resolvedArgs) => {
31451
- const subject = resolvedArgs[0];
31452
- const chars = resolvedArgs.length > 1 ? resolvedArgs[1] : undefined;
31453
- return trimFn(subject, chars);
31454
- };
31455
- }
31456
- functionType = ([inputValue]) => {
31457
- switch (this.getTypeName(inputValue)) {
31458
- case 0:
31459
- return "number";
31460
- case 2:
31461
- return "string";
31462
- case 3:
31463
- return "array";
31464
- case 4:
31465
- return "object";
31466
- case 5:
31467
- return "boolean";
31468
- case 7:
31469
- return "null";
31470
- default:
31471
- throw new Error("invalid-type");
31472
- }
31473
- };
31474
- functionZip = (array) => {
31475
- const length = Math.min(...array.map((arr) => arr.length));
31476
- const result = Array(length).fill(null).map((_, index) => array.map((arr) => arr[index]));
31477
- return result;
31478
- };
31479
- };
31480
- var ScopeChain = class _ScopeChain {
31481
- inner = undefined;
31482
- data = {};
31483
- get currentScopeData() {
31484
- return this.data;
31485
- }
31486
- withScope(data) {
31487
- const outer = new _ScopeChain;
31488
- outer.inner = this;
31489
- outer.data = data;
31490
- return outer;
31491
- }
31492
- getValue(identifier) {
31493
- if (Object.prototype.hasOwnProperty.call(this.data, identifier)) {
31494
- return this.data[identifier];
31495
- }
31496
- if (this.inner) {
31497
- return this.inner.getValue(identifier);
31498
- }
31499
- return null;
31500
- }
31501
- };
31502
- var emptyScopeChain;
31503
- var TreeInterpreter = class _TreeInterpreter {
31504
- runtime;
31505
- _rootValue = null;
31506
- _scope;
31507
- constructor() {
31508
- this.runtime = new Runtime(this);
31509
- this._scope = new ScopeChain;
31510
- }
31511
- withScope(scope) {
31512
- const interpreter = new _TreeInterpreter;
31513
- interpreter.runtime._functionTable = this.runtime._functionTable;
31514
- interpreter._rootValue = this._rootValue;
31515
- interpreter._scope = this._scope.withScope(scope);
31516
- return interpreter;
31517
- }
31518
- search(node, value) {
31519
- this._rootValue = value;
31520
- this._scope = emptyScopeChain;
31521
- return this.visit(node, value);
31522
- }
31523
- visit(node, value) {
31524
- switch (node.type) {
31525
- case "Ternary": {
31526
- const condition = this.visit(node.condition, value);
31527
- if (!isFalse(condition)) {
31528
- return this.visit(node.trueExpr, value);
31529
- }
31530
- return this.visit(node.falseExpr, value);
31531
- }
31532
- case "Field":
31533
- const identifier = node.name;
31534
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
31535
- return null;
31536
- }
31537
- return value[identifier] ?? null;
31538
- case "LetExpression": {
31539
- const { bindings, expression } = node;
31540
- let scope = {};
31541
- bindings.forEach((binding2) => {
31542
- const reference = this.visit(binding2, value);
31543
- scope = {
31544
- ...scope,
31545
- ...reference
31546
- };
31547
- });
31548
- return this.withScope(scope).visit(expression, value);
31549
- }
31550
- case "Binding": {
31551
- const { variable, reference } = node;
31552
- const result = this.visit(reference, value);
31553
- return { [variable]: result };
31554
- }
31555
- case "Variable": {
31556
- const variable = node.name;
31557
- if (!this._scope.getValue(variable) && !Object.prototype.hasOwnProperty.call(this._scope.currentScopeData, variable)) {
31558
- throw new Error(`Error referencing undefined variable ${variable}`);
30637
+ TreeInterpreter.prototype = {
30638
+ search: function(node, value) {
30639
+ return this.visit(node, value);
30640
+ },
30641
+ visit: function(node, value) {
30642
+ var matched, current, result, first, second, field, left, right, collected, i2;
30643
+ switch (node.type) {
30644
+ case "Field":
30645
+ if (value !== null && isObject2(value)) {
30646
+ field = value[node.name];
30647
+ if (field === undefined) {
30648
+ return null;
30649
+ } else {
30650
+ return field;
30651
+ }
30652
+ }
30653
+ return null;
30654
+ case "Subexpression":
30655
+ result = this.visit(node.children[0], value);
30656
+ for (i2 = 1;i2 < node.children.length; i2++) {
30657
+ result = this.visit(node.children[1], result);
30658
+ if (result === null) {
30659
+ return null;
30660
+ }
30661
+ }
30662
+ return result;
30663
+ case "IndexExpression":
30664
+ left = this.visit(node.children[0], value);
30665
+ right = this.visit(node.children[1], left);
30666
+ return right;
30667
+ case "Index":
30668
+ if (!isArray2(value)) {
30669
+ return null;
30670
+ }
30671
+ var index = node.value;
30672
+ if (index < 0) {
30673
+ index = value.length + index;
30674
+ }
30675
+ result = value[index];
30676
+ if (result === undefined) {
30677
+ result = null;
30678
+ }
30679
+ return result;
30680
+ case "Slice":
30681
+ if (!isArray2(value)) {
30682
+ return null;
30683
+ }
30684
+ var sliceParams = node.children.slice(0);
30685
+ var computed = this.computeSliceParams(value.length, sliceParams);
30686
+ var start = computed[0];
30687
+ var stop = computed[1];
30688
+ var step = computed[2];
30689
+ result = [];
30690
+ if (step > 0) {
30691
+ for (i2 = start;i2 < stop; i2 += step) {
30692
+ result.push(value[i2]);
30693
+ }
30694
+ } else {
30695
+ for (i2 = start;i2 > stop; i2 += step) {
30696
+ result.push(value[i2]);
30697
+ }
30698
+ }
30699
+ return result;
30700
+ case "Projection":
30701
+ var base = this.visit(node.children[0], value);
30702
+ if (!isArray2(base)) {
30703
+ return null;
30704
+ }
30705
+ collected = [];
30706
+ for (i2 = 0;i2 < base.length; i2++) {
30707
+ current = this.visit(node.children[1], base[i2]);
30708
+ if (current !== null) {
30709
+ collected.push(current);
30710
+ }
30711
+ }
30712
+ return collected;
30713
+ case "ValueProjection":
30714
+ base = this.visit(node.children[0], value);
30715
+ if (!isObject2(base)) {
30716
+ return null;
30717
+ }
30718
+ collected = [];
30719
+ var values = objValues(base);
30720
+ for (i2 = 0;i2 < values.length; i2++) {
30721
+ current = this.visit(node.children[1], values[i2]);
30722
+ if (current !== null) {
30723
+ collected.push(current);
30724
+ }
30725
+ }
30726
+ return collected;
30727
+ case "FilterProjection":
30728
+ base = this.visit(node.children[0], value);
30729
+ if (!isArray2(base)) {
30730
+ return null;
30731
+ }
30732
+ var filtered = [];
30733
+ var finalResults = [];
30734
+ for (i2 = 0;i2 < base.length; i2++) {
30735
+ matched = this.visit(node.children[2], base[i2]);
30736
+ if (!isFalse(matched)) {
30737
+ filtered.push(base[i2]);
30738
+ }
30739
+ }
30740
+ for (var j = 0;j < filtered.length; j++) {
30741
+ current = this.visit(node.children[1], filtered[j]);
30742
+ if (current !== null) {
30743
+ finalResults.push(current);
30744
+ }
30745
+ }
30746
+ return finalResults;
30747
+ case "Comparator":
30748
+ first = this.visit(node.children[0], value);
30749
+ second = this.visit(node.children[1], value);
30750
+ switch (node.name) {
30751
+ case TOK_EQ:
30752
+ result = strictDeepEqual(first, second);
30753
+ break;
30754
+ case TOK_NE:
30755
+ result = !strictDeepEqual(first, second);
30756
+ break;
30757
+ case TOK_GT:
30758
+ result = first > second;
30759
+ break;
30760
+ case TOK_GTE:
30761
+ result = first >= second;
30762
+ break;
30763
+ case TOK_LT:
30764
+ result = first < second;
30765
+ break;
30766
+ case TOK_LTE:
30767
+ result = first <= second;
30768
+ break;
30769
+ default:
30770
+ throw new Error("Unknown comparator: " + node.name);
30771
+ }
30772
+ return result;
30773
+ case TOK_FLATTEN:
30774
+ var original = this.visit(node.children[0], value);
30775
+ if (!isArray2(original)) {
30776
+ return null;
30777
+ }
30778
+ var merged = [];
30779
+ for (i2 = 0;i2 < original.length; i2++) {
30780
+ current = original[i2];
30781
+ if (isArray2(current)) {
30782
+ merged.push.apply(merged, current);
30783
+ } else {
30784
+ merged.push(current);
30785
+ }
30786
+ }
30787
+ return merged;
30788
+ case "Identity":
30789
+ return value;
30790
+ case "MultiSelectList":
30791
+ if (value === null) {
30792
+ return null;
30793
+ }
30794
+ collected = [];
30795
+ for (i2 = 0;i2 < node.children.length; i2++) {
30796
+ collected.push(this.visit(node.children[i2], value));
30797
+ }
30798
+ return collected;
30799
+ case "MultiSelectHash":
30800
+ if (value === null) {
30801
+ return null;
30802
+ }
30803
+ collected = {};
30804
+ var child;
30805
+ for (i2 = 0;i2 < node.children.length; i2++) {
30806
+ child = node.children[i2];
30807
+ collected[child.name] = this.visit(child.value, value);
30808
+ }
30809
+ return collected;
30810
+ case "OrExpression":
30811
+ matched = this.visit(node.children[0], value);
30812
+ if (isFalse(matched)) {
30813
+ matched = this.visit(node.children[1], value);
30814
+ }
30815
+ return matched;
30816
+ case "AndExpression":
30817
+ first = this.visit(node.children[0], value);
30818
+ if (isFalse(first) === true) {
30819
+ return first;
30820
+ }
30821
+ return this.visit(node.children[1], value);
30822
+ case "NotExpression":
30823
+ first = this.visit(node.children[0], value);
30824
+ return isFalse(first);
30825
+ case "Literal":
30826
+ return node.value;
30827
+ case TOK_PIPE:
30828
+ left = this.visit(node.children[0], value);
30829
+ return this.visit(node.children[1], left);
30830
+ case TOK_CURRENT:
30831
+ return value;
30832
+ case "Function":
30833
+ var resolvedArgs = [];
30834
+ for (i2 = 0;i2 < node.children.length; i2++) {
30835
+ resolvedArgs.push(this.visit(node.children[i2], value));
30836
+ }
30837
+ return this.runtime.callFunction(node.name, resolvedArgs);
30838
+ case "ExpressionReference":
30839
+ var refNode = node.children[0];
30840
+ refNode.jmespathType = TOK_EXPREF;
30841
+ return refNode;
30842
+ default:
30843
+ throw new Error("Unknown node type: " + node.type);
31559
30844
  }
31560
- return this._scope.getValue(variable);
31561
- }
31562
- case "IndexExpression":
31563
- return this.visit(node.right, this.visit(node.left, value));
31564
- case "Subexpression": {
31565
- const result = this.visit(node.left, value);
31566
- return result != null ? this.visit(node.right, result) ?? null : null;
31567
- }
31568
- case "Index": {
31569
- if (!Array.isArray(value)) {
31570
- return null;
30845
+ },
30846
+ computeSliceParams: function(arrayLength, sliceParams) {
30847
+ var start = sliceParams[0];
30848
+ var stop = sliceParams[1];
30849
+ var step = sliceParams[2];
30850
+ var computed = [null, null, null];
30851
+ if (step === null) {
30852
+ step = 1;
30853
+ } else if (step === 0) {
30854
+ var error = new Error("Invalid slice, step cannot be 0");
30855
+ error.name = "RuntimeError";
30856
+ throw error;
31571
30857
  }
31572
- const index = node.value < 0 ? value.length + node.value : node.value;
31573
- return value[index] ?? null;
31574
- }
31575
- case "Slice": {
31576
- if (!Array.isArray(value) && typeof value !== "string") {
31577
- return null;
30858
+ var stepValueNegative = step < 0 ? true : false;
30859
+ if (start === null) {
30860
+ start = stepValueNegative ? arrayLength - 1 : 0;
30861
+ } else {
30862
+ start = this.capSliceRange(arrayLength, start, step);
31578
30863
  }
31579
- const { start, stop, step } = this.computeSliceParams(value.length, node);
31580
- if (typeof value === "string") {
31581
- const chars = [...value];
31582
- const sliced = this.slice(chars, start, stop, step);
31583
- return sliced.join("");
30864
+ if (stop === null) {
30865
+ stop = stepValueNegative ? -1 : arrayLength;
31584
30866
  } else {
31585
- return this.slice(value, start, stop, step);
30867
+ stop = this.capSliceRange(arrayLength, stop, step);
31586
30868
  }
31587
- }
31588
- case "Projection": {
31589
- const { left, right } = node;
31590
- let allowString = false;
31591
- if (left.type === "IndexExpression" && left.right.type === "Slice") {
31592
- allowString = true;
30869
+ computed[0] = start;
30870
+ computed[1] = stop;
30871
+ computed[2] = step;
30872
+ return computed;
30873
+ },
30874
+ capSliceRange: function(arrayLength, actualValue, step) {
30875
+ if (actualValue < 0) {
30876
+ actualValue += arrayLength;
30877
+ if (actualValue < 0) {
30878
+ actualValue = step < 0 ? -1 : 0;
30879
+ }
30880
+ } else if (actualValue >= arrayLength) {
30881
+ actualValue = step < 0 ? arrayLength - 1 : arrayLength;
30882
+ }
30883
+ return actualValue;
30884
+ }
30885
+ };
30886
+ function Runtime(interpreter) {
30887
+ this._interpreter = interpreter;
30888
+ this.functionTable = {
30889
+ abs: { _func: this._functionAbs, _signature: [{ types: [TYPE_NUMBER] }] },
30890
+ avg: { _func: this._functionAvg, _signature: [{ types: [TYPE_ARRAY_NUMBER] }] },
30891
+ ceil: { _func: this._functionCeil, _signature: [{ types: [TYPE_NUMBER] }] },
30892
+ contains: {
30893
+ _func: this._functionContains,
30894
+ _signature: [
30895
+ { types: [TYPE_STRING, TYPE_ARRAY] },
30896
+ { types: [TYPE_ANY] }
30897
+ ]
30898
+ },
30899
+ ends_with: {
30900
+ _func: this._functionEndsWith,
30901
+ _signature: [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }]
30902
+ },
30903
+ floor: { _func: this._functionFloor, _signature: [{ types: [TYPE_NUMBER] }] },
30904
+ length: {
30905
+ _func: this._functionLength,
30906
+ _signature: [{ types: [TYPE_STRING, TYPE_ARRAY, TYPE_OBJECT] }]
30907
+ },
30908
+ map: {
30909
+ _func: this._functionMap,
30910
+ _signature: [{ types: [TYPE_EXPREF] }, { types: [TYPE_ARRAY] }]
30911
+ },
30912
+ max: {
30913
+ _func: this._functionMax,
30914
+ _signature: [{ types: [TYPE_ARRAY_NUMBER, TYPE_ARRAY_STRING] }]
30915
+ },
30916
+ merge: {
30917
+ _func: this._functionMerge,
30918
+ _signature: [{ types: [TYPE_OBJECT], variadic: true }]
30919
+ },
30920
+ max_by: {
30921
+ _func: this._functionMaxBy,
30922
+ _signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
30923
+ },
30924
+ sum: { _func: this._functionSum, _signature: [{ types: [TYPE_ARRAY_NUMBER] }] },
30925
+ starts_with: {
30926
+ _func: this._functionStartsWith,
30927
+ _signature: [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }]
30928
+ },
30929
+ min: {
30930
+ _func: this._functionMin,
30931
+ _signature: [{ types: [TYPE_ARRAY_NUMBER, TYPE_ARRAY_STRING] }]
30932
+ },
30933
+ min_by: {
30934
+ _func: this._functionMinBy,
30935
+ _signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
30936
+ },
30937
+ type: { _func: this._functionType, _signature: [{ types: [TYPE_ANY] }] },
30938
+ keys: { _func: this._functionKeys, _signature: [{ types: [TYPE_OBJECT] }] },
30939
+ values: { _func: this._functionValues, _signature: [{ types: [TYPE_OBJECT] }] },
30940
+ sort: { _func: this._functionSort, _signature: [{ types: [TYPE_ARRAY_STRING, TYPE_ARRAY_NUMBER] }] },
30941
+ sort_by: {
30942
+ _func: this._functionSortBy,
30943
+ _signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
30944
+ },
30945
+ join: {
30946
+ _func: this._functionJoin,
30947
+ _signature: [
30948
+ { types: [TYPE_STRING] },
30949
+ { types: [TYPE_ARRAY_STRING] }
30950
+ ]
30951
+ },
30952
+ reverse: {
30953
+ _func: this._functionReverse,
30954
+ _signature: [{ types: [TYPE_STRING, TYPE_ARRAY] }]
30955
+ },
30956
+ to_array: { _func: this._functionToArray, _signature: [{ types: [TYPE_ANY] }] },
30957
+ to_string: { _func: this._functionToString, _signature: [{ types: [TYPE_ANY] }] },
30958
+ to_number: { _func: this._functionToNumber, _signature: [{ types: [TYPE_ANY] }] },
30959
+ not_null: {
30960
+ _func: this._functionNotNull,
30961
+ _signature: [{ types: [TYPE_ANY], variadic: true }]
31593
30962
  }
31594
- const base = this.visit(left, value);
31595
- if (allowString && typeof base === "string") {
31596
- return this.visit(right, base);
30963
+ };
30964
+ }
30965
+ Runtime.prototype = {
30966
+ callFunction: function(name, resolvedArgs) {
30967
+ var functionEntry = this.functionTable[name];
30968
+ if (functionEntry === undefined) {
30969
+ throw new Error("Unknown function: " + name + "()");
31597
30970
  }
31598
- if (!Array.isArray(base)) {
31599
- return null;
30971
+ this._validateArgs(name, resolvedArgs, functionEntry._signature);
30972
+ return functionEntry._func.call(this, resolvedArgs);
30973
+ },
30974
+ _validateArgs: function(name, args, signature) {
30975
+ var pluralized;
30976
+ if (signature[signature.length - 1].variadic) {
30977
+ if (args.length < signature.length) {
30978
+ pluralized = signature.length === 1 ? " argument" : " arguments";
30979
+ throw new Error("ArgumentError: " + name + "() " + "takes at least" + signature.length + pluralized + " but received " + args.length);
30980
+ }
30981
+ } else if (args.length !== signature.length) {
30982
+ pluralized = signature.length === 1 ? " argument" : " arguments";
30983
+ throw new Error("ArgumentError: " + name + "() " + "takes " + signature.length + pluralized + " but received " + args.length);
30984
+ }
30985
+ var currentSpec;
30986
+ var actualType;
30987
+ var typeMatched;
30988
+ for (var i2 = 0;i2 < signature.length; i2++) {
30989
+ typeMatched = false;
30990
+ currentSpec = signature[i2].types;
30991
+ actualType = this._getTypeName(args[i2]);
30992
+ for (var j = 0;j < currentSpec.length; j++) {
30993
+ if (this._typeMatches(actualType, currentSpec[j], args[i2])) {
30994
+ typeMatched = true;
30995
+ break;
30996
+ }
30997
+ }
30998
+ if (!typeMatched) {
30999
+ var expected = currentSpec.map(function(typeIdentifier) {
31000
+ return TYPE_NAME_TABLE[typeIdentifier];
31001
+ }).join(",");
31002
+ throw new Error("TypeError: " + name + "() " + "expected argument " + (i2 + 1) + " to be type " + expected + " but received type " + TYPE_NAME_TABLE[actualType] + " instead.");
31003
+ }
31004
+ }
31005
+ },
31006
+ _typeMatches: function(actual, expected, argValue) {
31007
+ if (expected === TYPE_ANY) {
31008
+ return true;
31600
31009
  }
31601
- const collected = [];
31602
- for (const elem of base) {
31603
- const current = this.visit(right, elem);
31604
- if (current !== null) {
31605
- collected.push(current);
31010
+ if (expected === TYPE_ARRAY_STRING || expected === TYPE_ARRAY_NUMBER || expected === TYPE_ARRAY) {
31011
+ if (expected === TYPE_ARRAY) {
31012
+ return actual === TYPE_ARRAY;
31013
+ } else if (actual === TYPE_ARRAY) {
31014
+ var subtype;
31015
+ if (expected === TYPE_ARRAY_NUMBER) {
31016
+ subtype = TYPE_NUMBER;
31017
+ } else if (expected === TYPE_ARRAY_STRING) {
31018
+ subtype = TYPE_STRING;
31019
+ }
31020
+ for (var i2 = 0;i2 < argValue.length; i2++) {
31021
+ if (!this._typeMatches(this._getTypeName(argValue[i2]), subtype, argValue[i2])) {
31022
+ return false;
31023
+ }
31024
+ }
31025
+ return true;
31606
31026
  }
31027
+ } else {
31028
+ return actual === expected;
31607
31029
  }
31608
- return collected;
31609
- }
31610
- case "ValueProjection": {
31611
- const { left, right } = node;
31612
- const base = this.visit(left, value);
31613
- if (base === null || typeof base !== "object" || Array.isArray(base)) {
31614
- return null;
31030
+ },
31031
+ _getTypeName: function(obj) {
31032
+ switch (Object.prototype.toString.call(obj)) {
31033
+ case "[object String]":
31034
+ return TYPE_STRING;
31035
+ case "[object Number]":
31036
+ return TYPE_NUMBER;
31037
+ case "[object Array]":
31038
+ return TYPE_ARRAY;
31039
+ case "[object Boolean]":
31040
+ return TYPE_BOOLEAN;
31041
+ case "[object Null]":
31042
+ return TYPE_NULL;
31043
+ case "[object Object]":
31044
+ if (obj.jmespathType === TOK_EXPREF) {
31045
+ return TYPE_EXPREF;
31046
+ } else {
31047
+ return TYPE_OBJECT;
31048
+ }
31615
31049
  }
31616
- const collected = [];
31617
- const values = Object.values(base);
31618
- for (const elem of values) {
31619
- const current = this.visit(right, elem);
31620
- if (current !== null) {
31621
- collected.push(current);
31050
+ },
31051
+ _functionStartsWith: function(resolvedArgs) {
31052
+ return resolvedArgs[0].lastIndexOf(resolvedArgs[1]) === 0;
31053
+ },
31054
+ _functionEndsWith: function(resolvedArgs) {
31055
+ var searchStr = resolvedArgs[0];
31056
+ var suffix = resolvedArgs[1];
31057
+ return searchStr.indexOf(suffix, searchStr.length - suffix.length) !== -1;
31058
+ },
31059
+ _functionReverse: function(resolvedArgs) {
31060
+ var typeName = this._getTypeName(resolvedArgs[0]);
31061
+ if (typeName === TYPE_STRING) {
31062
+ var originalStr = resolvedArgs[0];
31063
+ var reversedStr = "";
31064
+ for (var i2 = originalStr.length - 1;i2 >= 0; i2--) {
31065
+ reversedStr += originalStr[i2];
31622
31066
  }
31067
+ return reversedStr;
31068
+ } else {
31069
+ var reversedArray = resolvedArgs[0].slice(0);
31070
+ reversedArray.reverse();
31071
+ return reversedArray;
31623
31072
  }
31624
- return collected;
31625
- }
31626
- case "FilterProjection": {
31627
- const { left, right, condition } = node;
31628
- const base = this.visit(left, value);
31629
- if (!Array.isArray(base)) {
31630
- return null;
31073
+ },
31074
+ _functionAbs: function(resolvedArgs) {
31075
+ return Math.abs(resolvedArgs[0]);
31076
+ },
31077
+ _functionCeil: function(resolvedArgs) {
31078
+ return Math.ceil(resolvedArgs[0]);
31079
+ },
31080
+ _functionAvg: function(resolvedArgs) {
31081
+ var sum = 0;
31082
+ var inputArray = resolvedArgs[0];
31083
+ for (var i2 = 0;i2 < inputArray.length; i2++) {
31084
+ sum += inputArray[i2];
31631
31085
  }
31632
- const results = [];
31633
- for (const elem of base) {
31634
- const matched = this.visit(condition, elem);
31635
- if (isFalse(matched)) {
31636
- continue;
31086
+ return sum / inputArray.length;
31087
+ },
31088
+ _functionContains: function(resolvedArgs) {
31089
+ return resolvedArgs[0].indexOf(resolvedArgs[1]) >= 0;
31090
+ },
31091
+ _functionFloor: function(resolvedArgs) {
31092
+ return Math.floor(resolvedArgs[0]);
31093
+ },
31094
+ _functionLength: function(resolvedArgs) {
31095
+ if (!isObject2(resolvedArgs[0])) {
31096
+ return resolvedArgs[0].length;
31097
+ } else {
31098
+ return Object.keys(resolvedArgs[0]).length;
31099
+ }
31100
+ },
31101
+ _functionMap: function(resolvedArgs) {
31102
+ var mapped = [];
31103
+ var interpreter = this._interpreter;
31104
+ var exprefNode = resolvedArgs[0];
31105
+ var elements = resolvedArgs[1];
31106
+ for (var i2 = 0;i2 < elements.length; i2++) {
31107
+ mapped.push(interpreter.visit(exprefNode, elements[i2]));
31108
+ }
31109
+ return mapped;
31110
+ },
31111
+ _functionMerge: function(resolvedArgs) {
31112
+ var merged = {};
31113
+ for (var i2 = 0;i2 < resolvedArgs.length; i2++) {
31114
+ var current = resolvedArgs[i2];
31115
+ for (var key in current) {
31116
+ merged[key] = current[key];
31637
31117
  }
31638
- const result = this.visit(right, elem);
31639
- if (result !== null) {
31640
- results.push(result);
31118
+ }
31119
+ return merged;
31120
+ },
31121
+ _functionMax: function(resolvedArgs) {
31122
+ if (resolvedArgs[0].length > 0) {
31123
+ var typeName = this._getTypeName(resolvedArgs[0][0]);
31124
+ if (typeName === TYPE_NUMBER) {
31125
+ return Math.max.apply(Math, resolvedArgs[0]);
31126
+ } else {
31127
+ var elements = resolvedArgs[0];
31128
+ var maxElement = elements[0];
31129
+ for (var i2 = 1;i2 < elements.length; i2++) {
31130
+ if (maxElement.localeCompare(elements[i2]) < 0) {
31131
+ maxElement = elements[i2];
31132
+ }
31133
+ }
31134
+ return maxElement;
31641
31135
  }
31136
+ } else {
31137
+ return null;
31642
31138
  }
31643
- return results;
31644
- }
31645
- case "Arithmetic": {
31646
- const first = this.visit(node.left, value);
31647
- const second = this.visit(node.right, value);
31648
- switch (node.operator) {
31649
- case "Plus":
31650
- return add(first, second);
31651
- case "Minus":
31652
- return sub(first, second);
31653
- case "Multiply":
31654
- case "Star":
31655
- return mul(first, second);
31656
- case "Divide":
31657
- return divide(first, second);
31658
- case "Modulo":
31659
- return mod(first, second);
31660
- case "Div":
31661
- return div(first, second);
31662
- default:
31663
- throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`);
31664
- }
31665
- }
31666
- case "Unary": {
31667
- const operand = this.visit(node.operand, value);
31668
- switch (node.operator) {
31669
- case "Plus":
31670
- ensureNumbers(operand);
31671
- return operand;
31672
- case "Minus":
31673
- ensureNumbers(operand);
31674
- return -operand;
31675
- default:
31676
- throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`);
31139
+ },
31140
+ _functionMin: function(resolvedArgs) {
31141
+ if (resolvedArgs[0].length > 0) {
31142
+ var typeName = this._getTypeName(resolvedArgs[0][0]);
31143
+ if (typeName === TYPE_NUMBER) {
31144
+ return Math.min.apply(Math, resolvedArgs[0]);
31145
+ } else {
31146
+ var elements = resolvedArgs[0];
31147
+ var minElement = elements[0];
31148
+ for (var i2 = 1;i2 < elements.length; i2++) {
31149
+ if (elements[i2].localeCompare(minElement) < 0) {
31150
+ minElement = elements[i2];
31151
+ }
31152
+ }
31153
+ return minElement;
31154
+ }
31155
+ } else {
31156
+ return null;
31677
31157
  }
31678
- }
31679
- case "Comparator": {
31680
- const first = this.visit(node.left, value);
31681
- const second = this.visit(node.right, value);
31682
- switch (node.name) {
31683
- case "EQ":
31684
- return strictDeepEqual(first, second);
31685
- case "NE":
31686
- return !strictDeepEqual(first, second);
31158
+ },
31159
+ _functionSum: function(resolvedArgs) {
31160
+ var sum = 0;
31161
+ var listToSum = resolvedArgs[0];
31162
+ for (var i2 = 0;i2 < listToSum.length; i2++) {
31163
+ sum += listToSum[i2];
31687
31164
  }
31688
- if (typeof first !== "number" || typeof second !== "number") {
31689
- return null;
31165
+ return sum;
31166
+ },
31167
+ _functionType: function(resolvedArgs) {
31168
+ switch (this._getTypeName(resolvedArgs[0])) {
31169
+ case TYPE_NUMBER:
31170
+ return "number";
31171
+ case TYPE_STRING:
31172
+ return "string";
31173
+ case TYPE_ARRAY:
31174
+ return "array";
31175
+ case TYPE_OBJECT:
31176
+ return "object";
31177
+ case TYPE_BOOLEAN:
31178
+ return "boolean";
31179
+ case TYPE_EXPREF:
31180
+ return "expref";
31181
+ case TYPE_NULL:
31182
+ return "null";
31690
31183
  }
31691
- switch (node.name) {
31692
- case "GT":
31693
- return first > second;
31694
- case "GTE":
31695
- return first >= second;
31696
- case "LT":
31697
- return first < second;
31698
- case "LTE":
31699
- return first <= second;
31184
+ },
31185
+ _functionKeys: function(resolvedArgs) {
31186
+ return Object.keys(resolvedArgs[0]);
31187
+ },
31188
+ _functionValues: function(resolvedArgs) {
31189
+ var obj = resolvedArgs[0];
31190
+ var keys = Object.keys(obj);
31191
+ var values = [];
31192
+ for (var i2 = 0;i2 < keys.length; i2++) {
31193
+ values.push(obj[keys[i2]]);
31194
+ }
31195
+ return values;
31196
+ },
31197
+ _functionJoin: function(resolvedArgs) {
31198
+ var joinChar = resolvedArgs[0];
31199
+ var listJoin = resolvedArgs[1];
31200
+ return listJoin.join(joinChar);
31201
+ },
31202
+ _functionToArray: function(resolvedArgs) {
31203
+ if (this._getTypeName(resolvedArgs[0]) === TYPE_ARRAY) {
31204
+ return resolvedArgs[0];
31205
+ } else {
31206
+ return [resolvedArgs[0]];
31700
31207
  }
31701
- }
31702
- case "Flatten": {
31703
- const original = this.visit(node.child, value);
31704
- return Array.isArray(original) ? original.flat() : null;
31705
- }
31706
- case "Root":
31707
- return this._rootValue;
31708
- case "MultiSelectList": {
31709
- const collected = [];
31710
- for (const child of node.children) {
31711
- collected.push(this.visit(child, value));
31208
+ },
31209
+ _functionToString: function(resolvedArgs) {
31210
+ if (this._getTypeName(resolvedArgs[0]) === TYPE_STRING) {
31211
+ return resolvedArgs[0];
31212
+ } else {
31213
+ return JSON.stringify(resolvedArgs[0]);
31712
31214
  }
31713
- return collected;
31714
- }
31715
- case "MultiSelectHash": {
31716
- const collected = {};
31717
- for (const child of node.children) {
31718
- collected[child.name] = this.visit(child.value, value);
31215
+ },
31216
+ _functionToNumber: function(resolvedArgs) {
31217
+ var typeName = this._getTypeName(resolvedArgs[0]);
31218
+ var convertedValue;
31219
+ if (typeName === TYPE_NUMBER) {
31220
+ return resolvedArgs[0];
31221
+ } else if (typeName === TYPE_STRING) {
31222
+ convertedValue = +resolvedArgs[0];
31223
+ if (!isNaN(convertedValue)) {
31224
+ return convertedValue;
31225
+ }
31719
31226
  }
31720
- return collected;
31721
- }
31722
- case "OrExpression": {
31723
- const result = this.visit(node.left, value);
31724
- if (isFalse(result)) {
31725
- return this.visit(node.right, value);
31227
+ return null;
31228
+ },
31229
+ _functionNotNull: function(resolvedArgs) {
31230
+ for (var i2 = 0;i2 < resolvedArgs.length; i2++) {
31231
+ if (this._getTypeName(resolvedArgs[i2]) !== TYPE_NULL) {
31232
+ return resolvedArgs[i2];
31233
+ }
31726
31234
  }
31727
- return result;
31728
- }
31729
- case "AndExpression": {
31730
- const result = this.visit(node.left, value);
31731
- if (isFalse(result)) {
31732
- return result;
31235
+ return null;
31236
+ },
31237
+ _functionSort: function(resolvedArgs) {
31238
+ var sortedArray = resolvedArgs[0].slice(0);
31239
+ sortedArray.sort();
31240
+ return sortedArray;
31241
+ },
31242
+ _functionSortBy: function(resolvedArgs) {
31243
+ var sortedArray = resolvedArgs[0].slice(0);
31244
+ if (sortedArray.length === 0) {
31245
+ return sortedArray;
31246
+ }
31247
+ var interpreter = this._interpreter;
31248
+ var exprefNode = resolvedArgs[1];
31249
+ var requiredType = this._getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
31250
+ if ([TYPE_NUMBER, TYPE_STRING].indexOf(requiredType) < 0) {
31251
+ throw new Error("TypeError");
31252
+ }
31253
+ var that = this;
31254
+ var decorated = [];
31255
+ for (var i2 = 0;i2 < sortedArray.length; i2++) {
31256
+ decorated.push([i2, sortedArray[i2]]);
31257
+ }
31258
+ decorated.sort(function(a, b) {
31259
+ var exprA = interpreter.visit(exprefNode, a[1]);
31260
+ var exprB = interpreter.visit(exprefNode, b[1]);
31261
+ if (that._getTypeName(exprA) !== requiredType) {
31262
+ throw new Error("TypeError: expected " + requiredType + ", received " + that._getTypeName(exprA));
31263
+ } else if (that._getTypeName(exprB) !== requiredType) {
31264
+ throw new Error("TypeError: expected " + requiredType + ", received " + that._getTypeName(exprB));
31265
+ }
31266
+ if (exprA > exprB) {
31267
+ return 1;
31268
+ } else if (exprA < exprB) {
31269
+ return -1;
31270
+ } else {
31271
+ return a[0] - b[0];
31272
+ }
31273
+ });
31274
+ for (var j = 0;j < decorated.length; j++) {
31275
+ sortedArray[j] = decorated[j][1];
31733
31276
  }
31734
- return this.visit(node.right, value);
31735
- }
31736
- case "NotExpression":
31737
- return isFalse(this.visit(node.child, value));
31738
- case "Literal":
31739
- return node.value;
31740
- case "Pipe":
31741
- return this.visit(node.right, this.visit(node.left, value));
31742
- case "Function": {
31743
- const args = [];
31744
- for (const child of node.children) {
31745
- args.push(this.visit(child, value));
31277
+ return sortedArray;
31278
+ },
31279
+ _functionMaxBy: function(resolvedArgs) {
31280
+ var exprefNode = resolvedArgs[1];
31281
+ var resolvedArray = resolvedArgs[0];
31282
+ var keyFunction = this.createKeyFunction(exprefNode, [TYPE_NUMBER, TYPE_STRING]);
31283
+ var maxNumber = -Infinity;
31284
+ var maxRecord;
31285
+ var current;
31286
+ for (var i2 = 0;i2 < resolvedArray.length; i2++) {
31287
+ current = keyFunction(resolvedArray[i2]);
31288
+ if (current > maxNumber) {
31289
+ maxNumber = current;
31290
+ maxRecord = resolvedArray[i2];
31291
+ }
31746
31292
  }
31747
- return this.runtime.callFunction(node.name, args);
31748
- }
31749
- case "ExpressionReference":
31750
- return {
31751
- expref: true,
31752
- ...node.child
31293
+ return maxRecord;
31294
+ },
31295
+ _functionMinBy: function(resolvedArgs) {
31296
+ var exprefNode = resolvedArgs[1];
31297
+ var resolvedArray = resolvedArgs[0];
31298
+ var keyFunction = this.createKeyFunction(exprefNode, [TYPE_NUMBER, TYPE_STRING]);
31299
+ var minNumber = Infinity;
31300
+ var minRecord;
31301
+ var current;
31302
+ for (var i2 = 0;i2 < resolvedArray.length; i2++) {
31303
+ current = keyFunction(resolvedArray[i2]);
31304
+ if (current < minNumber) {
31305
+ minNumber = current;
31306
+ minRecord = resolvedArray[i2];
31307
+ }
31308
+ }
31309
+ return minRecord;
31310
+ },
31311
+ createKeyFunction: function(exprefNode, allowedTypes) {
31312
+ var that = this;
31313
+ var interpreter = this._interpreter;
31314
+ var keyFunc = function(x) {
31315
+ var current = interpreter.visit(exprefNode, x);
31316
+ if (allowedTypes.indexOf(that._getTypeName(current)) < 0) {
31317
+ var msg = "TypeError: expected one of " + allowedTypes + ", received " + that._getTypeName(current);
31318
+ throw new Error(msg);
31319
+ }
31320
+ return current;
31753
31321
  };
31754
- case "Current":
31755
- case "Identity":
31756
- return value;
31757
- }
31758
- }
31759
- computeSliceParams(arrayLength, sliceNode) {
31760
- let { start, stop, step } = sliceNode;
31761
- if (step === null) {
31762
- step = 1;
31763
- } else if (step === 0) {
31764
- const error = new Error("Invalid value: slice step cannot be 0");
31765
- error.name = "RuntimeError";
31766
- throw error;
31767
- }
31768
- start = start === null ? step < 0 ? arrayLength - 1 : 0 : this.capSliceRange(arrayLength, start, step);
31769
- stop = stop === null ? step < 0 ? -1 : arrayLength : this.capSliceRange(arrayLength, stop, step);
31770
- return { start, stop, step };
31771
- }
31772
- capSliceRange(arrayLength, actualValue, step) {
31773
- let nextActualValue = actualValue;
31774
- if (nextActualValue < 0) {
31775
- nextActualValue += arrayLength;
31776
- if (nextActualValue < 0) {
31777
- nextActualValue = step < 0 ? -1 : 0;
31778
- }
31779
- } else if (nextActualValue >= arrayLength) {
31780
- nextActualValue = step < 0 ? arrayLength - 1 : arrayLength;
31781
- }
31782
- return nextActualValue;
31783
- }
31784
- slice(collection, start, end, step) {
31785
- const result = [];
31786
- if (step > 0) {
31787
- for (let i2 = start;i2 < end; i2 += step) {
31788
- result.push(collection[i2]);
31789
- }
31790
- } else {
31791
- for (let i2 = start;i2 > end; i2 += step) {
31792
- result.push(collection[i2]);
31793
- }
31794
- }
31795
- return result;
31796
- }
31797
- };
31798
- var TreeInterpreterInstance;
31799
- var TreeInterpreter_default;
31800
- var TYPE_ANY = 1;
31801
- var TYPE_ARRAY = 3;
31802
- var TYPE_ARRAY_ARRAY = 11;
31803
- var TYPE_ARRAY_NUMBER = 8;
31804
- var TYPE_ARRAY_OBJECT = 10;
31805
- var TYPE_ARRAY_STRING = 9;
31806
- var TYPE_BOOLEAN = 5;
31807
- var TYPE_EXPREF = 6;
31808
- var TYPE_NULL = 7;
31809
- var TYPE_NUMBER = 0;
31810
- var TYPE_OBJECT = 4;
31811
- var TYPE_STRING = 2;
31812
- var registerFunction = (functionName, customFunction, signature, options) => {
31813
- TreeInterpreter_default.runtime.registerFunction(functionName, customFunction, signature, options);
31814
- };
31815
- var register = (name, customFunction, signature, options) => {
31816
- return TreeInterpreter_default.runtime.register(name, customFunction, signature, options);
31817
- };
31818
- var unregisterFunction = (name) => {
31819
- return TreeInterpreter_default.runtime.unregister(name);
31820
- };
31821
- var isRegistered = (name) => {
31822
- return TreeInterpreter_default.runtime.isRegistered(name);
31823
- };
31824
- var getRegisteredFunctions = () => {
31825
- return TreeInterpreter_default.runtime.getRegistered();
31826
- };
31827
- var getCustomFunctions = () => {
31828
- return TreeInterpreter_default.runtime.getCustomFunctions();
31829
- };
31830
- var clearCustomFunctions = () => {
31831
- TreeInterpreter_default.runtime.clearCustomFunctions();
31832
- };
31833
- var TreeInterpreter2;
31834
- var jmespath;
31835
- var init_dist = __esm3(() => {
31836
- basicTokens = {
31837
- "(": "Lparen",
31838
- ")": "Rparen",
31839
- "*": "Star",
31840
- ",": "Comma",
31841
- ".": "Dot",
31842
- ":": "Colon",
31843
- "@": "Current",
31844
- "]": "Rbracket",
31845
- "{": "Lbrace",
31846
- "}": "Rbrace",
31847
- "+": "Plus",
31848
- "%": "Modulo",
31849
- "?": "Question",
31850
- "−": "Minus",
31851
- "×": "Multiply",
31852
- "÷": "Divide"
31853
- };
31854
- operatorStartToken = {
31855
- "!": true,
31856
- "<": true,
31857
- "=": true,
31858
- ">": true,
31859
- "&": true,
31860
- "|": true,
31861
- "/": true
31862
- };
31863
- skipChars = {
31864
- "\t": true,
31865
- "\n": true,
31866
- "\r": true,
31867
- " ": true
31868
- };
31869
- Lexer = new StreamLexer;
31870
- Lexer_default = Lexer;
31871
- bindingPower = {
31872
- ["EOF"]: 0,
31873
- ["Variable"]: 0,
31874
- ["UnquotedIdentifier"]: 0,
31875
- ["QuotedIdentifier"]: 0,
31876
- ["Rbracket"]: 0,
31877
- ["Rparen"]: 0,
31878
- ["Comma"]: 0,
31879
- ["Rbrace"]: 0,
31880
- ["Number"]: 0,
31881
- ["Current"]: 0,
31882
- ["Expref"]: 0,
31883
- ["Root"]: 0,
31884
- ["Assign"]: 1,
31885
- ["Pipe"]: 1,
31886
- ["Question"]: 2,
31887
- ["Or"]: 3,
31888
- ["And"]: 4,
31889
- ["EQ"]: 5,
31890
- ["GT"]: 5,
31891
- ["LT"]: 5,
31892
- ["GTE"]: 5,
31893
- ["LTE"]: 5,
31894
- ["NE"]: 5,
31895
- ["Minus"]: 6,
31896
- ["Plus"]: 6,
31897
- ["Div"]: 7,
31898
- ["Divide"]: 7,
31899
- ["Modulo"]: 7,
31900
- ["Multiply"]: 7,
31901
- ["Flatten"]: 9,
31902
- ["Star"]: 20,
31903
- ["Filter"]: 21,
31904
- ["Dot"]: 40,
31905
- ["Not"]: 45,
31906
- ["Lbrace"]: 50,
31907
- ["Lbracket"]: 55,
31908
- ["Lparen"]: 60
31909
- };
31910
- Parser = new TokenParser;
31911
- Parser_default = Parser;
31912
- emptyScopeChain = new ScopeChain;
31913
- TreeInterpreterInstance = new TreeInterpreter;
31914
- TreeInterpreter_default = TreeInterpreterInstance;
31915
- TreeInterpreter2 = TreeInterpreter_default;
31916
- jmespath = {
31917
- compile,
31918
- registerFunction,
31919
- register,
31920
- unregisterFunction,
31921
- isRegistered,
31922
- getRegisteredFunctions,
31923
- getCustomFunctions,
31924
- clearCustomFunctions,
31925
- search,
31926
- tokenize,
31927
- TreeInterpreter: TreeInterpreter2,
31928
- TYPE_ANY,
31929
- TYPE_ARRAY_NUMBER,
31930
- TYPE_ARRAY_STRING,
31931
- TYPE_ARRAY,
31932
- TYPE_BOOLEAN,
31933
- TYPE_EXPREF,
31934
- TYPE_NULL,
31935
- TYPE_NUMBER,
31936
- TYPE_OBJECT,
31937
- TYPE_STRING
31938
- };
31322
+ return keyFunc;
31323
+ }
31324
+ };
31325
+ function compile(stream) {
31326
+ var parser = new Parser;
31327
+ var ast = parser.parse(stream);
31328
+ return ast;
31329
+ }
31330
+ function tokenize(stream) {
31331
+ var lexer = new Lexer;
31332
+ return lexer.tokenize(stream);
31333
+ }
31334
+ function search(data, expression) {
31335
+ var parser = new Parser;
31336
+ var runtime = new Runtime;
31337
+ var interpreter = new TreeInterpreter(runtime);
31338
+ runtime._interpreter = interpreter;
31339
+ var node = parser.parse(expression);
31340
+ return interpreter.search(node, data);
31341
+ }
31342
+ exports2.tokenize = tokenize;
31343
+ exports2.compile = compile;
31344
+ exports2.search = search;
31345
+ exports2.strictDeepEqual = strictDeepEqual;
31346
+ })(typeof exports === "undefined" ? exports.jmespath = {} : exports);
31939
31347
  });
31940
31348
  var require_error2 = __commonJS3(function(exports) {
31941
31349
 
@@ -32259,10 +31667,10 @@ var require_help2 = __commonJS3(function(exports) {
32259
31667
  });
32260
31668
  output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
32261
31669
  }
32262
- const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub2) => sub2.helpGroup() || "Commands:");
31670
+ const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
32263
31671
  commandGroups.forEach((commands, group) => {
32264
- const commandList = commands.map((sub2) => {
32265
- return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub2)), helper.styleSubcommandDescription(helper.subcommandDescription(sub2)));
31672
+ const commandList = commands.map((sub) => {
31673
+ return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
32266
31674
  });
32267
31675
  output = output.concat(this.formatItemList(group, commandList, helper));
32268
31676
  });
@@ -34603,13 +34011,13 @@ function redactValueDetectors(value, maxLength = MAX_VALUE_LENGTH) {
34603
34011
  out = out.replace(EMAIL_PATTERN, (match) => `email#${pseudonymize(match)}`);
34604
34012
  out = out.replace(UUID_PATTERN, (match) => `uuid#${pseudonymize(match)}`);
34605
34013
  out = out.replace(HOST_PORT_PATTERN, (match) => {
34606
- const split2 = match.lastIndexOf(":");
34607
- const host = match.slice(0, split2);
34014
+ const split = match.lastIndexOf(":");
34015
+ const host = match.slice(0, split);
34608
34016
  const extension = host.slice(host.lastIndexOf(".") + 1).toLowerCase();
34609
34017
  if (SOURCE_FILE_EXTENSIONS2.has(extension)) {
34610
34018
  return match;
34611
34019
  }
34612
- return `host#${pseudonymize(host)}:${match.slice(split2 + 1)}`;
34020
+ return `host#${pseudonymize(host)}:${match.slice(split + 1)}`;
34613
34021
  });
34614
34022
  out = out.replace(PADDED_BASE64_PATTERN, () => REDACTED);
34615
34023
  out = out.replace(BASE64_WITH_PLUS_PATTERN, (match) => match.includes("+") ? REDACTED : match);
@@ -34790,8 +34198,8 @@ function setExitCode(code2) {
34790
34198
  process.exitCode = code2;
34791
34199
  }
34792
34200
  function createStorage3() {
34793
- const [error, mod2] = catchError3(() => __require("node:async_hooks"));
34794
- if (error || typeof mod2?.AsyncLocalStorage !== "function") {
34201
+ const [error, mod] = catchError3(() => __require("node:async_hooks"));
34202
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
34795
34203
  return {
34796
34204
  getStore: () => {
34797
34205
  return;
@@ -34799,7 +34207,7 @@ function createStorage3() {
34799
34207
  run: (_store, fn) => fn()
34800
34208
  };
34801
34209
  }
34802
- return new mod2.AsyncLocalStorage;
34210
+ return new mod.AsyncLocalStorage;
34803
34211
  }
34804
34212
  var storageSingleton2 = singleton3("OutputStorage");
34805
34213
  var sinkSlot2 = singleton3("OutputSink");
@@ -35014,13 +34422,13 @@ var jmespathSlot = singleton3("JmespathCodec");
35014
34422
  async function loadOutputCodecsAsync(needed) {
35015
34423
  const loads = [];
35016
34424
  if (needed.yaml && yamlSlot.get() === undefined) {
35017
- loads.push(Promise.resolve().then(() => (init_js_yaml(), exports_js_yaml)).then((mod2) => {
35018
- yamlSlot.set(mod2);
34425
+ loads.push(Promise.resolve().then(() => (init_js_yaml(), exports_js_yaml)).then((mod) => {
34426
+ yamlSlot.set(mod);
35019
34427
  }));
35020
34428
  }
35021
34429
  if (needed.filter && jmespathSlot.get() === undefined) {
35022
- loads.push(Promise.resolve().then(() => (init_dist(), exports_dist)).then((mod2) => {
35023
- jmespathSlot.set(mod2);
34430
+ loads.push(Promise.resolve().then(() => __toESM3(require_jmespath(), 1)).then((mod) => {
34431
+ jmespathSlot.set(mod);
35024
34432
  }));
35025
34433
  }
35026
34434
  await Promise.all(loads);
@@ -35775,8 +35183,8 @@ class TelemetryService {
35775
35183
  }
35776
35184
  var TIMINGS_ENV_VAR = "UIP_TIMINGS";
35777
35185
  function createStorage22() {
35778
- const [error, mod2] = catchError3(() => __require("node:async_hooks"));
35779
- if (error || typeof mod2?.AsyncLocalStorage !== "function") {
35186
+ const [error, mod] = catchError3(() => __require("node:async_hooks"));
35187
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
35780
35188
  return {
35781
35189
  getStore: () => {
35782
35190
  return;
@@ -35784,7 +35192,7 @@ function createStorage22() {
35784
35192
  run: (_store, fn) => fn()
35785
35193
  };
35786
35194
  }
35787
- return new mod2.AsyncLocalStorage;
35195
+ return new mod.AsyncLocalStorage;
35788
35196
  }
35789
35197
  var storageSlot2 = singleton3("TimingStorage");
35790
35198
  var stateSlot2 = singleton3("Timings");
@@ -37406,8 +36814,8 @@ var telemetryPropsSlot22 = singleton22("TelemetryDefaultProps");
37406
36814
  var sdkUserAgentHostToken22 = singleton22("SdkUserAgentHostToken");
37407
36815
  var package_default2 = {
37408
36816
  name: "@uipath/project-packager",
37409
- license: "MIT",
37410
- version: "1.202.0-preview.142",
36817
+ license: "SEE LICENSE IN LICENSE.txt",
36818
+ version: "1.202.0",
37411
36819
  description: "UiPath Project Packager - core library for packing individual UiPath projects",
37412
36820
  type: "module",
37413
36821
  main: "./dist/index.js",
@@ -39586,4 +38994,4 @@ async function packSolutionAsync(solutionPath, options) {
39586
38994
 
39587
38995
  export { SolutionPackOptions, isUnpackableProjectTypeError, ensurePackagerTools, createSolutionPackager, readSolutionFileAsUint8Array, resolveSdkLogLevel, applyAuthConnection, SOLUTION_PATH_INSTRUCTIONS, checkSolutionPathAsync, GOVERNANCE_OPTION_INSTRUCTIONS, validateGovernanceOptions, PackCommandService, packSolutionAsync };
39588
38996
 
39589
- //# debugId=A378C15026DA3C4C64756E2164756E21
38997
+ //# debugId=80AC280C64DA8B9E64756E2164756E21