@uipath/gov-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.
- package/LICENSE.txt +3 -0
- package/dist/THIRD-PARTY-NOTICES.md +323 -0
- package/dist/tool.js +1420 -1943
- package/package.json +3 -3
package/dist/tool.js
CHANGED
|
@@ -4078,2006 +4078,1483 @@ var init_js_yaml = __esm(() => {
|
|
|
4078
4078
|
} = yaml);
|
|
4079
4079
|
});
|
|
4080
4080
|
|
|
4081
|
-
// ../../../node_modules
|
|
4082
|
-
var
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
TYPE_ARRAY_NUMBER: () => TYPE_ARRAY_NUMBER,
|
|
4089
|
-
TYPE_ARRAY_OBJECT: () => TYPE_ARRAY_OBJECT,
|
|
4090
|
-
TYPE_ARRAY_STRING: () => TYPE_ARRAY_STRING,
|
|
4091
|
-
TYPE_BOOLEAN: () => TYPE_BOOLEAN,
|
|
4092
|
-
TYPE_EXPREF: () => TYPE_EXPREF,
|
|
4093
|
-
TYPE_NULL: () => TYPE_NULL,
|
|
4094
|
-
TYPE_NUMBER: () => TYPE_NUMBER,
|
|
4095
|
-
TYPE_OBJECT: () => TYPE_OBJECT,
|
|
4096
|
-
TYPE_STRING: () => TYPE_STRING,
|
|
4097
|
-
TreeInterpreter: () => TreeInterpreter2,
|
|
4098
|
-
clearCustomFunctions: () => clearCustomFunctions,
|
|
4099
|
-
compile: () => compile,
|
|
4100
|
-
default: () => jmespath,
|
|
4101
|
-
getCustomFunctions: () => getCustomFunctions,
|
|
4102
|
-
getRegisteredFunctions: () => getRegisteredFunctions,
|
|
4103
|
-
isRegistered: () => isRegistered,
|
|
4104
|
-
jmespath: () => jmespath,
|
|
4105
|
-
register: () => register,
|
|
4106
|
-
registerFunction: () => registerFunction,
|
|
4107
|
-
search: () => search,
|
|
4108
|
-
tokenize: () => tokenize,
|
|
4109
|
-
unregisterFunction: () => unregisterFunction
|
|
4110
|
-
});
|
|
4111
|
-
function compile(expression, options) {
|
|
4112
|
-
const nodeTree = Parser_default.parse(expression, options);
|
|
4113
|
-
return nodeTree;
|
|
4114
|
-
}
|
|
4115
|
-
function tokenize(expression, options) {
|
|
4116
|
-
return Lexer_default.tokenize(expression, options);
|
|
4117
|
-
}
|
|
4118
|
-
function search(data, expression, options) {
|
|
4119
|
-
const nodeTree = Parser_default.parse(expression, options);
|
|
4120
|
-
return TreeInterpreter_default.search(nodeTree, data);
|
|
4121
|
-
}
|
|
4122
|
-
function Scope() {
|
|
4123
|
-
return new ScopeChain;
|
|
4124
|
-
}
|
|
4125
|
-
var isObject = (obj) => {
|
|
4126
|
-
return obj !== null && Object.prototype.toString.call(obj) === "[object Object]";
|
|
4127
|
-
}, strictDeepEqual = (first, second) => {
|
|
4128
|
-
if (first === second) {
|
|
4129
|
-
return true;
|
|
4130
|
-
}
|
|
4131
|
-
if (typeof first !== typeof second) {
|
|
4132
|
-
return false;
|
|
4133
|
-
}
|
|
4134
|
-
if (Array.isArray(first) && Array.isArray(second)) {
|
|
4135
|
-
if (first.length !== second.length) {
|
|
4136
|
-
return false;
|
|
4137
|
-
}
|
|
4138
|
-
for (let i = 0;i < first.length; i += 1) {
|
|
4139
|
-
if (!strictDeepEqual(first[i], second[i])) {
|
|
4140
|
-
return false;
|
|
4141
|
-
}
|
|
4142
|
-
}
|
|
4143
|
-
return true;
|
|
4144
|
-
}
|
|
4145
|
-
if (isObject(first) && isObject(second)) {
|
|
4146
|
-
const firstEntries = Object.entries(first);
|
|
4147
|
-
const secondKeys = new Set(Object.keys(second));
|
|
4148
|
-
if (firstEntries.length !== secondKeys.size) {
|
|
4149
|
-
return false;
|
|
4150
|
-
}
|
|
4151
|
-
for (const [key, value] of firstEntries) {
|
|
4152
|
-
if (!strictDeepEqual(value, second[key])) {
|
|
4081
|
+
// ../../../node_modules/jmespath/jmespath.js
|
|
4082
|
+
var require_jmespath = __commonJS(function(exports) {
|
|
4083
|
+
(function(exports2) {
|
|
4084
|
+
function isArray(obj) {
|
|
4085
|
+
if (obj !== null) {
|
|
4086
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
4087
|
+
} else {
|
|
4153
4088
|
return false;
|
|
4154
4089
|
}
|
|
4155
|
-
secondKeys.delete(key);
|
|
4156
|
-
}
|
|
4157
|
-
return secondKeys.size === 0;
|
|
4158
|
-
}
|
|
4159
|
-
return false;
|
|
4160
|
-
}, isFalse = (obj) => {
|
|
4161
|
-
if (obj === null || obj === undefined || obj === false) {
|
|
4162
|
-
return true;
|
|
4163
|
-
}
|
|
4164
|
-
if (typeof obj === "string") {
|
|
4165
|
-
return obj === "";
|
|
4166
|
-
}
|
|
4167
|
-
if (typeof obj === "object") {
|
|
4168
|
-
if (Array.isArray(obj)) {
|
|
4169
|
-
return obj.length === 0;
|
|
4170
|
-
}
|
|
4171
|
-
if (obj === null) {
|
|
4172
|
-
return true;
|
|
4173
|
-
}
|
|
4174
|
-
return Object.keys(obj).length === 0;
|
|
4175
|
-
}
|
|
4176
|
-
return false;
|
|
4177
|
-
}, isAlpha = (ch) => {
|
|
4178
|
-
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
|
|
4179
|
-
}, isNum = (ch) => {
|
|
4180
|
-
return ch >= "0" && ch <= "9" || ch === "-";
|
|
4181
|
-
}, isAlphaNum = (ch) => {
|
|
4182
|
-
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_";
|
|
4183
|
-
}, ensureInteger = (value) => {
|
|
4184
|
-
if (!(typeof value === "number") || Math.floor(value) !== value) {
|
|
4185
|
-
throw new Error("invalid-value: expecting an integer.");
|
|
4186
|
-
}
|
|
4187
|
-
return value;
|
|
4188
|
-
}, ensurePositiveInteger = (value) => {
|
|
4189
|
-
if (!(typeof value === "number") || value < 0 || Math.floor(value) !== value) {
|
|
4190
|
-
throw new Error("invalid-value: expecting a non-negative integer.");
|
|
4191
|
-
}
|
|
4192
|
-
return value;
|
|
4193
|
-
}, ensureNumbers = (...operands) => {
|
|
4194
|
-
for (let i = 0;i < operands.length; i++) {
|
|
4195
|
-
if (operands[i] === null || operands[i] === undefined) {
|
|
4196
|
-
throw new Error("not-a-number: undefined");
|
|
4197
|
-
}
|
|
4198
|
-
if (typeof operands[i] !== "number") {
|
|
4199
|
-
throw new Error("not-a-number");
|
|
4200
4090
|
}
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
if (!n) {
|
|
4205
|
-
throw new Error("not-a-number: divide by zero");
|
|
4206
|
-
}
|
|
4207
|
-
return n;
|
|
4208
|
-
}, add = (left, right) => {
|
|
4209
|
-
ensureNumbers(left, right);
|
|
4210
|
-
const result = left + right;
|
|
4211
|
-
return result;
|
|
4212
|
-
}, sub = (left, right) => {
|
|
4213
|
-
ensureNumbers(left, right);
|
|
4214
|
-
const result = left - right;
|
|
4215
|
-
return result;
|
|
4216
|
-
}, mul = (left, right) => {
|
|
4217
|
-
ensureNumbers(left, right);
|
|
4218
|
-
const result = left * right;
|
|
4219
|
-
return result;
|
|
4220
|
-
}, divide = (left, right) => {
|
|
4221
|
-
ensureNumbers(left, right);
|
|
4222
|
-
const result = left / notZero(right);
|
|
4223
|
-
return result;
|
|
4224
|
-
}, div = (left, right) => {
|
|
4225
|
-
ensureNumbers(left, right);
|
|
4226
|
-
const result = Math.floor(left / notZero(right));
|
|
4227
|
-
return result;
|
|
4228
|
-
}, mod = (left, right) => {
|
|
4229
|
-
ensureNumbers(left, right);
|
|
4230
|
-
const result = left % right;
|
|
4231
|
-
return result;
|
|
4232
|
-
}, findFirst = (subject, sub2, start, end) => {
|
|
4233
|
-
if (!subject || !sub2) {
|
|
4234
|
-
return null;
|
|
4235
|
-
}
|
|
4236
|
-
start = Math.max(ensureInteger(start = start || 0), 0);
|
|
4237
|
-
end = Math.min(ensureInteger(end = end || subject.length), subject.length);
|
|
4238
|
-
const offset = subject.slice(start, end).indexOf(sub2);
|
|
4239
|
-
return offset === -1 ? null : offset + start;
|
|
4240
|
-
}, findLast = (subject, sub2, start, end) => {
|
|
4241
|
-
if (!subject || !sub2) {
|
|
4242
|
-
return null;
|
|
4243
|
-
}
|
|
4244
|
-
start = Math.max(ensureInteger(start = start || 0), 0);
|
|
4245
|
-
end = Math.min(ensureInteger(end = end || subject.length), subject.length);
|
|
4246
|
-
const offset = subject.slice(start, end).lastIndexOf(sub2);
|
|
4247
|
-
const result = offset === -1 ? null : offset + start;
|
|
4248
|
-
return result;
|
|
4249
|
-
}, lower = (subject) => subject.toLowerCase(), ensurePadFuncParams = (name, width, padding) => {
|
|
4250
|
-
padding = padding || " ";
|
|
4251
|
-
if (padding.length > 1) {
|
|
4252
|
-
throw new Error(`invalid value, ${name} expects its 'pad' parameter to be a valid string with a single codepoint`);
|
|
4253
|
-
}
|
|
4254
|
-
ensurePositiveInteger(width);
|
|
4255
|
-
return padding;
|
|
4256
|
-
}, padLeft = (subject, width, padding) => {
|
|
4257
|
-
padding = ensurePadFuncParams("pad_left", width, padding);
|
|
4258
|
-
return subject && subject.padStart(width, padding) || "";
|
|
4259
|
-
}, padRight = (subject, width, padding) => {
|
|
4260
|
-
padding = ensurePadFuncParams("pad_right", width, padding);
|
|
4261
|
-
return subject && subject.padEnd(width, padding) || "";
|
|
4262
|
-
}, replace = (subject, string, by, count) => {
|
|
4263
|
-
if (count === 0) {
|
|
4264
|
-
return subject;
|
|
4265
|
-
}
|
|
4266
|
-
if (!count) {
|
|
4267
|
-
return subject.split(string).join(by);
|
|
4268
|
-
}
|
|
4269
|
-
ensurePositiveInteger(count);
|
|
4270
|
-
[...Array(count).keys()].map(() => subject = subject.replace(string, by));
|
|
4271
|
-
return subject;
|
|
4272
|
-
}, split = (subject, search2, count) => {
|
|
4273
|
-
if (subject.length == 0 && search2.length === 0) {
|
|
4274
|
-
return [];
|
|
4275
|
-
}
|
|
4276
|
-
if (count === null || count === undefined) {
|
|
4277
|
-
return subject.split(search2);
|
|
4278
|
-
}
|
|
4279
|
-
ensurePositiveInteger(count);
|
|
4280
|
-
if (count === 0) {
|
|
4281
|
-
return [subject];
|
|
4282
|
-
}
|
|
4283
|
-
const split2 = subject.split(search2);
|
|
4284
|
-
return [...split2.slice(0, count), split2.slice(count).join(search2)];
|
|
4285
|
-
}, trim = (subject, chars) => {
|
|
4286
|
-
return trimLeft(trimRight(subject, chars), chars);
|
|
4287
|
-
}, trimLeft = (subject, chars) => {
|
|
4288
|
-
return trimImpl(subject, (list) => new RegExp(`^[${list}]*(.*?)`), chars);
|
|
4289
|
-
}, trimRight = (subject, chars) => {
|
|
4290
|
-
return trimImpl(subject, (list) => new RegExp(`(.*?)[${list}]*$`), chars);
|
|
4291
|
-
}, trimImpl = (subject, regExper, chars) => {
|
|
4292
|
-
const pattern = chars ? chars.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&") : "\\s
";
|
|
4293
|
-
return subject.replace(regExper(pattern), "$1");
|
|
4294
|
-
}, upper = (subject) => subject.toUpperCase(), basicTokens, operatorStartToken, skipChars, StreamLexer = class {
|
|
4295
|
-
_current = 0;
|
|
4296
|
-
_enable_legacy_literals = false;
|
|
4297
|
-
tokenize(stream, options) {
|
|
4298
|
-
const tokens = [];
|
|
4299
|
-
this._current = 0;
|
|
4300
|
-
this._enable_legacy_literals = options?.enable_legacy_literals || false;
|
|
4301
|
-
let start;
|
|
4302
|
-
let identifier;
|
|
4303
|
-
let token;
|
|
4304
|
-
while (this._current < stream.length) {
|
|
4305
|
-
if (isAlpha(stream[this._current])) {
|
|
4306
|
-
start = this._current;
|
|
4307
|
-
identifier = this.consumeUnquotedIdentifier(stream);
|
|
4308
|
-
tokens.push({
|
|
4309
|
-
start,
|
|
4310
|
-
type: "UnquotedIdentifier",
|
|
4311
|
-
value: identifier
|
|
4312
|
-
});
|
|
4313
|
-
} else if (basicTokens[stream[this._current]] !== undefined) {
|
|
4314
|
-
tokens.push({
|
|
4315
|
-
start: this._current,
|
|
4316
|
-
type: basicTokens[stream[this._current]],
|
|
4317
|
-
value: stream[this._current]
|
|
4318
|
-
});
|
|
4319
|
-
this._current += 1;
|
|
4320
|
-
} else if (stream[this._current] === "$") {
|
|
4321
|
-
start = this._current;
|
|
4322
|
-
if (this._current + 1 < stream.length && isAlpha(stream[this._current + 1])) {
|
|
4323
|
-
this._current += 1;
|
|
4324
|
-
identifier = this.consumeUnquotedIdentifier(stream);
|
|
4325
|
-
tokens.push({
|
|
4326
|
-
start,
|
|
4327
|
-
type: "Variable",
|
|
4328
|
-
value: identifier
|
|
4329
|
-
});
|
|
4330
|
-
} else {
|
|
4331
|
-
tokens.push({
|
|
4332
|
-
start,
|
|
4333
|
-
type: "Root",
|
|
4334
|
-
value: stream[this._current]
|
|
4335
|
-
});
|
|
4336
|
-
this._current += 1;
|
|
4337
|
-
}
|
|
4338
|
-
} else if (stream[this._current] === "-") {
|
|
4339
|
-
if (this._current + 1 < stream.length && isNum(stream[this._current + 1])) {
|
|
4340
|
-
const token2 = this.consumeNumber(stream);
|
|
4341
|
-
token2 && tokens.push(token2);
|
|
4342
|
-
} else {
|
|
4343
|
-
const token2 = {
|
|
4344
|
-
start: this._current,
|
|
4345
|
-
type: "Minus",
|
|
4346
|
-
value: "-"
|
|
4347
|
-
};
|
|
4348
|
-
tokens.push(token2);
|
|
4349
|
-
this._current += 1;
|
|
4350
|
-
}
|
|
4351
|
-
} else if (isNum(stream[this._current])) {
|
|
4352
|
-
token = this.consumeNumber(stream);
|
|
4353
|
-
tokens.push(token);
|
|
4354
|
-
} else if (stream[this._current] === "[") {
|
|
4355
|
-
token = this.consumeLBracket(stream);
|
|
4356
|
-
tokens.push(token);
|
|
4357
|
-
} else if (stream[this._current] === '"') {
|
|
4358
|
-
start = this._current;
|
|
4359
|
-
identifier = this.consumeQuotedIdentifier(stream);
|
|
4360
|
-
tokens.push({
|
|
4361
|
-
start,
|
|
4362
|
-
type: "QuotedIdentifier",
|
|
4363
|
-
value: identifier
|
|
4364
|
-
});
|
|
4365
|
-
} else if (stream[this._current] === `'`) {
|
|
4366
|
-
start = this._current;
|
|
4367
|
-
identifier = this.consumeRawStringLiteral(stream);
|
|
4368
|
-
tokens.push({
|
|
4369
|
-
start,
|
|
4370
|
-
type: "Literal",
|
|
4371
|
-
value: identifier
|
|
4372
|
-
});
|
|
4373
|
-
} else if (stream[this._current] === "`") {
|
|
4374
|
-
start = this._current;
|
|
4375
|
-
const literal = this.consumeLiteral(stream);
|
|
4376
|
-
tokens.push({
|
|
4377
|
-
start,
|
|
4378
|
-
type: "Literal",
|
|
4379
|
-
value: literal
|
|
4380
|
-
});
|
|
4381
|
-
} else if (operatorStartToken[stream[this._current]] !== undefined) {
|
|
4382
|
-
token = this.consumeOperator(stream);
|
|
4383
|
-
token && tokens.push(token);
|
|
4384
|
-
} else if (skipChars[stream[this._current]] !== undefined) {
|
|
4385
|
-
this._current += 1;
|
|
4091
|
+
function isObject(obj) {
|
|
4092
|
+
if (obj !== null) {
|
|
4093
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
4386
4094
|
} else {
|
|
4387
|
-
|
|
4388
|
-
error.name = "LexerError";
|
|
4389
|
-
throw error;
|
|
4095
|
+
return false;
|
|
4390
4096
|
}
|
|
4391
4097
|
}
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
const start = this._current;
|
|
4396
|
-
this._current += 1;
|
|
4397
|
-
while (this._current < stream.length && isAlphaNum(stream[this._current])) {
|
|
4398
|
-
this._current += 1;
|
|
4399
|
-
}
|
|
4400
|
-
return stream.slice(start, this._current);
|
|
4401
|
-
}
|
|
4402
|
-
consumeQuotedIdentifier(stream) {
|
|
4403
|
-
const start = this._current;
|
|
4404
|
-
this._current += 1;
|
|
4405
|
-
const maxLength = stream.length;
|
|
4406
|
-
while (stream[this._current] !== '"' && this._current < maxLength) {
|
|
4407
|
-
let current = this._current;
|
|
4408
|
-
if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) {
|
|
4409
|
-
current += 2;
|
|
4410
|
-
} else {
|
|
4411
|
-
current += 1;
|
|
4098
|
+
function strictDeepEqual(first, second) {
|
|
4099
|
+
if (first === second) {
|
|
4100
|
+
return true;
|
|
4412
4101
|
}
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
const [value, ok] = this.parseJSON(stream.slice(start, this._current));
|
|
4417
|
-
if (!ok) {
|
|
4418
|
-
const error = new Error(`syntax: unexpected end of JSON input`);
|
|
4419
|
-
error.name = "LexerError";
|
|
4420
|
-
throw error;
|
|
4421
|
-
}
|
|
4422
|
-
return value;
|
|
4423
|
-
}
|
|
4424
|
-
consumeRawStringLiteral(stream) {
|
|
4425
|
-
const start = this._current;
|
|
4426
|
-
this._current += 1;
|
|
4427
|
-
const maxLength = stream.length;
|
|
4428
|
-
while (stream[this._current] !== `'` && this._current < maxLength) {
|
|
4429
|
-
let current = this._current;
|
|
4430
|
-
if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === `'`)) {
|
|
4431
|
-
current += 2;
|
|
4432
|
-
} else {
|
|
4433
|
-
current += 1;
|
|
4434
|
-
}
|
|
4435
|
-
this._current = current;
|
|
4436
|
-
}
|
|
4437
|
-
this._current += 1;
|
|
4438
|
-
const literal = stream.slice(start + 1, this._current - 1);
|
|
4439
|
-
return replace(replace(literal, `\\\\`, `\\`), `\\'`, `'`);
|
|
4440
|
-
}
|
|
4441
|
-
consumeNumber(stream) {
|
|
4442
|
-
const start = this._current;
|
|
4443
|
-
this._current += 1;
|
|
4444
|
-
const maxLength = stream.length;
|
|
4445
|
-
while (isNum(stream[this._current]) && this._current < maxLength) {
|
|
4446
|
-
this._current += 1;
|
|
4447
|
-
}
|
|
4448
|
-
const value = parseInt(stream.slice(start, this._current), 10);
|
|
4449
|
-
return { start, value, type: "Number" };
|
|
4450
|
-
}
|
|
4451
|
-
consumeLBracket(stream) {
|
|
4452
|
-
const start = this._current;
|
|
4453
|
-
this._current += 1;
|
|
4454
|
-
if (stream[this._current] === "?") {
|
|
4455
|
-
this._current += 1;
|
|
4456
|
-
return { start, type: "Filter", value: "[?" };
|
|
4457
|
-
}
|
|
4458
|
-
if (stream[this._current] === "]") {
|
|
4459
|
-
this._current += 1;
|
|
4460
|
-
return { start, type: "Flatten", value: "[]" };
|
|
4461
|
-
}
|
|
4462
|
-
return { start, type: "Lbracket", value: "[" };
|
|
4463
|
-
}
|
|
4464
|
-
consumeOrElse(stream, peek, token, orElse) {
|
|
4465
|
-
const start = this._current;
|
|
4466
|
-
this._current += 1;
|
|
4467
|
-
if (this._current < stream.length && stream[this._current] === peek) {
|
|
4468
|
-
this._current += 1;
|
|
4469
|
-
return {
|
|
4470
|
-
start,
|
|
4471
|
-
type: orElse,
|
|
4472
|
-
value: stream.slice(start, this._current)
|
|
4473
|
-
};
|
|
4474
|
-
}
|
|
4475
|
-
return { start, type: token, value: stream[start] };
|
|
4476
|
-
}
|
|
4477
|
-
consumeOperator(stream) {
|
|
4478
|
-
const start = this._current;
|
|
4479
|
-
const startingChar = stream[start];
|
|
4480
|
-
switch (startingChar) {
|
|
4481
|
-
case "!":
|
|
4482
|
-
return this.consumeOrElse(stream, "=", "Not", "NE");
|
|
4483
|
-
case "<":
|
|
4484
|
-
return this.consumeOrElse(stream, "=", "LT", "LTE");
|
|
4485
|
-
case ">":
|
|
4486
|
-
return this.consumeOrElse(stream, "=", "GT", "GTE");
|
|
4487
|
-
case "=":
|
|
4488
|
-
return this.consumeOrElse(stream, "=", "Assign", "EQ");
|
|
4489
|
-
case "&":
|
|
4490
|
-
return this.consumeOrElse(stream, "&", "Expref", "And");
|
|
4491
|
-
case "|":
|
|
4492
|
-
return this.consumeOrElse(stream, "|", "Pipe", "Or");
|
|
4493
|
-
case "/":
|
|
4494
|
-
return this.consumeOrElse(stream, "/", "Divide", "Div");
|
|
4495
|
-
}
|
|
4496
|
-
}
|
|
4497
|
-
consumeLiteral(stream) {
|
|
4498
|
-
this._current += 1;
|
|
4499
|
-
const start = this._current;
|
|
4500
|
-
const maxLength = stream.length;
|
|
4501
|
-
while (stream[this._current] !== "`" && this._current < maxLength) {
|
|
4502
|
-
let current = this._current;
|
|
4503
|
-
if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) {
|
|
4504
|
-
current += 2;
|
|
4505
|
-
} else {
|
|
4506
|
-
current += 1;
|
|
4102
|
+
var firstType = Object.prototype.toString.call(first);
|
|
4103
|
+
if (firstType !== Object.prototype.toString.call(second)) {
|
|
4104
|
+
return false;
|
|
4507
4105
|
}
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
literalString = literalString.replace("\\`", "`");
|
|
4512
|
-
let literal = null;
|
|
4513
|
-
let ok = false;
|
|
4514
|
-
if (this.looksLikeJSON(literalString)) {
|
|
4515
|
-
[literal, ok] = this.parseJSON(literalString);
|
|
4516
|
-
}
|
|
4517
|
-
if (!ok && this._enable_legacy_literals) {
|
|
4518
|
-
[literal, ok] = this.parseJSON(`"${literalString}"`);
|
|
4519
|
-
}
|
|
4520
|
-
if (!ok) {
|
|
4521
|
-
const error = new Error(`Syntax error: unexpected end of JSON input or invalid format for a JSON literal: ${stream[this._current]}`);
|
|
4522
|
-
error.name = "LexerError";
|
|
4523
|
-
throw error;
|
|
4524
|
-
}
|
|
4525
|
-
this._current += 1;
|
|
4526
|
-
return literal;
|
|
4527
|
-
}
|
|
4528
|
-
looksLikeJSON(literalString) {
|
|
4529
|
-
const startingChars = '[{"';
|
|
4530
|
-
const jsonLiterals = ["true", "false", "null"];
|
|
4531
|
-
const numberLooking = "-0123456789";
|
|
4532
|
-
if (literalString === "") {
|
|
4533
|
-
return false;
|
|
4534
|
-
}
|
|
4535
|
-
if (startingChars.includes(literalString[0])) {
|
|
4536
|
-
return true;
|
|
4537
|
-
}
|
|
4538
|
-
if (jsonLiterals.includes(literalString)) {
|
|
4539
|
-
return true;
|
|
4540
|
-
}
|
|
4541
|
-
if (numberLooking.includes(literalString[0])) {
|
|
4542
|
-
const [_, ok] = this.parseJSON(literalString);
|
|
4543
|
-
return ok;
|
|
4544
|
-
}
|
|
4545
|
-
return false;
|
|
4546
|
-
}
|
|
4547
|
-
parseJSON(text) {
|
|
4548
|
-
try {
|
|
4549
|
-
const json2 = JSON.parse(text);
|
|
4550
|
-
return [json2, true];
|
|
4551
|
-
} catch {
|
|
4552
|
-
return [null, false];
|
|
4553
|
-
}
|
|
4554
|
-
}
|
|
4555
|
-
}, Lexer, Lexer_default, bindingPower, TokenParser = class _TokenParser {
|
|
4556
|
-
index = 0;
|
|
4557
|
-
tokens = [];
|
|
4558
|
-
parse(expression, options) {
|
|
4559
|
-
this.loadTokens(expression, options || { enable_legacy_literals: false });
|
|
4560
|
-
this.index = 0;
|
|
4561
|
-
const ast = this.expression(0);
|
|
4562
|
-
if (this.lookahead(0) !== "EOF") {
|
|
4563
|
-
const token = this.lookaheadToken(0);
|
|
4564
|
-
this.errorToken(token, `Syntax error: unexpected token type: ${token.type}, value: ${token.value}`);
|
|
4565
|
-
}
|
|
4566
|
-
return ast;
|
|
4567
|
-
}
|
|
4568
|
-
loadTokens(expression, options) {
|
|
4569
|
-
this.tokens = Lexer_default.tokenize(expression, options);
|
|
4570
|
-
this.tokens.push({ type: "EOF", value: "", start: expression.length });
|
|
4571
|
-
}
|
|
4572
|
-
expression(rbp) {
|
|
4573
|
-
const leftToken = this.lookaheadToken(0);
|
|
4574
|
-
this.advance();
|
|
4575
|
-
let left = this.nud(leftToken);
|
|
4576
|
-
let currentTokenType = this.lookahead(0);
|
|
4577
|
-
while (rbp < bindingPower[currentTokenType]) {
|
|
4578
|
-
this.advance();
|
|
4579
|
-
left = this.led(currentTokenType, left);
|
|
4580
|
-
currentTokenType = this.lookahead(0);
|
|
4581
|
-
}
|
|
4582
|
-
return left;
|
|
4583
|
-
}
|
|
4584
|
-
lookahead(offset) {
|
|
4585
|
-
return this.tokens[this.index + offset].type;
|
|
4586
|
-
}
|
|
4587
|
-
lookaheadToken(offset) {
|
|
4588
|
-
return this.tokens[this.index + offset];
|
|
4589
|
-
}
|
|
4590
|
-
advance() {
|
|
4591
|
-
this.index += 1;
|
|
4592
|
-
}
|
|
4593
|
-
nud(token) {
|
|
4594
|
-
switch (token.type) {
|
|
4595
|
-
case "Variable":
|
|
4596
|
-
return { type: "Variable", name: token.value };
|
|
4597
|
-
case "Literal":
|
|
4598
|
-
return { type: "Literal", value: token.value };
|
|
4599
|
-
case "UnquotedIdentifier": {
|
|
4600
|
-
if (_TokenParser.isKeyword(token, "let") && this.lookahead(0) === "Variable") {
|
|
4601
|
-
return this.parseLetExpression();
|
|
4602
|
-
} else {
|
|
4603
|
-
return { type: "Field", name: token.value };
|
|
4106
|
+
if (isArray(first) === true) {
|
|
4107
|
+
if (first.length !== second.length) {
|
|
4108
|
+
return false;
|
|
4604
4109
|
}
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
} else {
|
|
4610
|
-
return { type: "Field", name: token.value };
|
|
4110
|
+
for (var i = 0;i < first.length; i++) {
|
|
4111
|
+
if (strictDeepEqual(first[i], second[i]) === false) {
|
|
4112
|
+
return false;
|
|
4113
|
+
}
|
|
4611
4114
|
}
|
|
4612
|
-
|
|
4613
|
-
const child = this.expression(bindingPower.Not);
|
|
4614
|
-
return { type: "NotExpression", child };
|
|
4615
|
-
}
|
|
4616
|
-
case "Minus": {
|
|
4617
|
-
const child = this.expression(bindingPower.Minus);
|
|
4618
|
-
return {
|
|
4619
|
-
type: "Unary",
|
|
4620
|
-
operator: token.type,
|
|
4621
|
-
operand: child
|
|
4622
|
-
};
|
|
4623
|
-
}
|
|
4624
|
-
case "Plus": {
|
|
4625
|
-
const child = this.expression(bindingPower.Plus);
|
|
4626
|
-
return {
|
|
4627
|
-
type: "Unary",
|
|
4628
|
-
operator: token.type,
|
|
4629
|
-
operand: child
|
|
4630
|
-
};
|
|
4631
|
-
}
|
|
4632
|
-
case "Star": {
|
|
4633
|
-
const left = { type: "Identity" };
|
|
4634
|
-
return { type: "ValueProjection", left, right: this.parseProjectionRHS(bindingPower.Star) };
|
|
4635
|
-
}
|
|
4636
|
-
case "Filter":
|
|
4637
|
-
return this.led(token.type, { type: "Identity" });
|
|
4638
|
-
case "Lbrace":
|
|
4639
|
-
return this.parseMultiselectHash();
|
|
4640
|
-
case "Flatten": {
|
|
4641
|
-
const left = {
|
|
4642
|
-
type: "Flatten",
|
|
4643
|
-
child: { type: "Identity" }
|
|
4644
|
-
};
|
|
4645
|
-
const right = this.parseProjectionRHS(bindingPower.Flatten);
|
|
4646
|
-
return { type: "Projection", left, right };
|
|
4115
|
+
return true;
|
|
4647
4116
|
}
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4117
|
+
if (isObject(first) === true) {
|
|
4118
|
+
var keysSeen = {};
|
|
4119
|
+
for (var key in first) {
|
|
4120
|
+
if (hasOwnProperty.call(first, key)) {
|
|
4121
|
+
if (strictDeepEqual(first[key], second[key]) === false) {
|
|
4122
|
+
return false;
|
|
4123
|
+
}
|
|
4124
|
+
keysSeen[key] = true;
|
|
4125
|
+
}
|
|
4652
4126
|
}
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
right,
|
|
4660
|
-
type: "Projection"
|
|
4661
|
-
};
|
|
4127
|
+
for (var key2 in second) {
|
|
4128
|
+
if (hasOwnProperty.call(second, key2)) {
|
|
4129
|
+
if (keysSeen[key2] !== true) {
|
|
4130
|
+
return false;
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4662
4133
|
}
|
|
4663
|
-
return
|
|
4664
|
-
}
|
|
4665
|
-
case "Current":
|
|
4666
|
-
return { type: "Current" };
|
|
4667
|
-
case "Root":
|
|
4668
|
-
return { type: "Root" };
|
|
4669
|
-
case "Expref": {
|
|
4670
|
-
const child = this.expression(bindingPower.Expref);
|
|
4671
|
-
return { type: "ExpressionReference", child };
|
|
4672
|
-
}
|
|
4673
|
-
case "Lparen": {
|
|
4674
|
-
const expression = this.expression(0);
|
|
4675
|
-
this.match("Rparen");
|
|
4676
|
-
return expression;
|
|
4134
|
+
return true;
|
|
4677
4135
|
}
|
|
4678
|
-
|
|
4679
|
-
this.errorToken(token);
|
|
4136
|
+
return false;
|
|
4680
4137
|
}
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
trueExpr,
|
|
4692
|
-
falseExpr
|
|
4693
|
-
};
|
|
4694
|
-
}
|
|
4695
|
-
case "Dot": {
|
|
4696
|
-
const rbp = bindingPower.Dot;
|
|
4697
|
-
if (this.lookahead(0) !== "Star") {
|
|
4698
|
-
const right2 = this.parseDotRHS(rbp);
|
|
4699
|
-
return { type: "Subexpression", left, right: right2 };
|
|
4138
|
+
function isFalse(obj) {
|
|
4139
|
+
if (obj === "" || obj === false || obj === null) {
|
|
4140
|
+
return true;
|
|
4141
|
+
} else if (isArray(obj) && obj.length === 0) {
|
|
4142
|
+
return true;
|
|
4143
|
+
} else if (isObject(obj)) {
|
|
4144
|
+
for (var key in obj) {
|
|
4145
|
+
if (obj.hasOwnProperty(key)) {
|
|
4146
|
+
return false;
|
|
4147
|
+
}
|
|
4700
4148
|
}
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
return
|
|
4704
|
-
}
|
|
4705
|
-
case "Pipe": {
|
|
4706
|
-
const right = this.expression(bindingPower.Pipe);
|
|
4707
|
-
return { type: "Pipe", left, right };
|
|
4708
|
-
}
|
|
4709
|
-
case "Or": {
|
|
4710
|
-
const right = this.expression(bindingPower.Or);
|
|
4711
|
-
return { type: "OrExpression", left, right };
|
|
4149
|
+
return true;
|
|
4150
|
+
} else {
|
|
4151
|
+
return false;
|
|
4712
4152
|
}
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4153
|
+
}
|
|
4154
|
+
function objValues(obj) {
|
|
4155
|
+
var keys = Object.keys(obj);
|
|
4156
|
+
var values = [];
|
|
4157
|
+
for (var i = 0;i < keys.length; i++) {
|
|
4158
|
+
values.push(obj[keys[i]]);
|
|
4716
4159
|
}
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
const node = { name, type: "Function", children: args };
|
|
4724
|
-
return node;
|
|
4725
|
-
}
|
|
4726
|
-
case "Filter": {
|
|
4727
|
-
const condition = this.expression(0);
|
|
4728
|
-
this.match("Rbracket");
|
|
4729
|
-
const right = this.lookahead(0) === "Flatten" ? { type: "Identity" } : this.parseProjectionRHS(bindingPower.Filter);
|
|
4730
|
-
return { type: "FilterProjection", left, right, condition };
|
|
4731
|
-
}
|
|
4732
|
-
case "Flatten": {
|
|
4733
|
-
const leftNode = { type: "Flatten", child: left };
|
|
4734
|
-
const right = this.parseProjectionRHS(bindingPower.Flatten);
|
|
4735
|
-
return { type: "Projection", left: leftNode, right };
|
|
4736
|
-
}
|
|
4737
|
-
case "Assign": {
|
|
4738
|
-
const leftNode = left;
|
|
4739
|
-
const right = this.expression(0);
|
|
4740
|
-
return {
|
|
4741
|
-
type: "Binding",
|
|
4742
|
-
variable: leftNode.name,
|
|
4743
|
-
reference: right
|
|
4744
|
-
};
|
|
4160
|
+
return values;
|
|
4161
|
+
}
|
|
4162
|
+
function merge2(a, b) {
|
|
4163
|
+
var merged = {};
|
|
4164
|
+
for (var key in a) {
|
|
4165
|
+
merged[key] = a[key];
|
|
4745
4166
|
}
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
case "GT":
|
|
4749
|
-
case "GTE":
|
|
4750
|
-
case "LT":
|
|
4751
|
-
case "LTE":
|
|
4752
|
-
return this.parseComparator(left, tokenName);
|
|
4753
|
-
case "Plus":
|
|
4754
|
-
case "Minus":
|
|
4755
|
-
case "Multiply":
|
|
4756
|
-
case "Star":
|
|
4757
|
-
case "Divide":
|
|
4758
|
-
case "Modulo":
|
|
4759
|
-
case "Div":
|
|
4760
|
-
return this.parseArithmetic(left, tokenName);
|
|
4761
|
-
case "Lbracket": {
|
|
4762
|
-
const token = this.lookaheadToken(0);
|
|
4763
|
-
if (token.type === "Number" || token.type === "Colon") {
|
|
4764
|
-
const right2 = this.parseIndexExpression();
|
|
4765
|
-
return this.projectIfSlice(left, right2);
|
|
4766
|
-
}
|
|
4767
|
-
this.match("Star");
|
|
4768
|
-
this.match("Rbracket");
|
|
4769
|
-
const right = this.parseProjectionRHS(bindingPower.Star);
|
|
4770
|
-
return { type: "Projection", left, right };
|
|
4167
|
+
for (var key2 in b) {
|
|
4168
|
+
merged[key2] = b[key2];
|
|
4771
4169
|
}
|
|
4772
|
-
|
|
4773
|
-
return this.errorToken(this.lookaheadToken(0));
|
|
4170
|
+
return merged;
|
|
4774
4171
|
}
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
if (this.lookahead(0) === tokenType) {
|
|
4781
|
-
this.advance();
|
|
4782
|
-
return;
|
|
4172
|
+
var trimLeft;
|
|
4173
|
+
if (typeof String.prototype.trimLeft === "function") {
|
|
4174
|
+
trimLeft = function(str2) {
|
|
4175
|
+
return str2.trimLeft();
|
|
4176
|
+
};
|
|
4783
4177
|
} else {
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
}
|
|
4787
|
-
}
|
|
4788
|
-
errorToken(token, message = "") {
|
|
4789
|
-
const error = new Error(message || `Syntax error: invalid token (${token.type}): "${token.value}"`);
|
|
4790
|
-
error.name = "ParserError";
|
|
4791
|
-
throw error;
|
|
4792
|
-
}
|
|
4793
|
-
parseIndexExpression() {
|
|
4794
|
-
if (this.lookahead(0) === "Colon" || this.lookahead(1) === "Colon") {
|
|
4795
|
-
return this.parseSliceExpression();
|
|
4796
|
-
}
|
|
4797
|
-
const value = Number(this.lookaheadToken(0).value);
|
|
4798
|
-
this.advance();
|
|
4799
|
-
this.match("Rbracket");
|
|
4800
|
-
return { type: "Index", value };
|
|
4801
|
-
}
|
|
4802
|
-
projectIfSlice(left, right) {
|
|
4803
|
-
const indexExpr = {
|
|
4804
|
-
type: "IndexExpression",
|
|
4805
|
-
left,
|
|
4806
|
-
right
|
|
4807
|
-
};
|
|
4808
|
-
if (right.type === "Slice") {
|
|
4809
|
-
return {
|
|
4810
|
-
left: indexExpr,
|
|
4811
|
-
right: this.parseProjectionRHS(bindingPower.Star),
|
|
4812
|
-
type: "Projection"
|
|
4178
|
+
trimLeft = function(str2) {
|
|
4179
|
+
return str2.match(/^\s*(.*)/)[1];
|
|
4813
4180
|
};
|
|
4814
4181
|
}
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
current = this.lookaheadToken(0);
|
|
4837
|
-
}
|
|
4838
|
-
this.match("Rbracket");
|
|
4839
|
-
const [start, stop, step] = parts;
|
|
4840
|
-
return { type: "Slice", start, stop, step };
|
|
4841
|
-
}
|
|
4842
|
-
parseLetExpression() {
|
|
4843
|
-
const separated = this.parseCommaSeparatedExpressionsUntilKeyword("in");
|
|
4844
|
-
const expression = this.expression(0);
|
|
4845
|
-
const bindings = separated.map((binding) => binding);
|
|
4846
|
-
return {
|
|
4847
|
-
type: "LetExpression",
|
|
4848
|
-
bindings,
|
|
4849
|
-
expression
|
|
4182
|
+
var TYPE_NUMBER = 0;
|
|
4183
|
+
var TYPE_ANY = 1;
|
|
4184
|
+
var TYPE_STRING = 2;
|
|
4185
|
+
var TYPE_ARRAY = 3;
|
|
4186
|
+
var TYPE_OBJECT = 4;
|
|
4187
|
+
var TYPE_BOOLEAN = 5;
|
|
4188
|
+
var TYPE_EXPREF = 6;
|
|
4189
|
+
var TYPE_NULL = 7;
|
|
4190
|
+
var TYPE_ARRAY_NUMBER = 8;
|
|
4191
|
+
var TYPE_ARRAY_STRING = 9;
|
|
4192
|
+
var TYPE_NAME_TABLE = {
|
|
4193
|
+
0: "number",
|
|
4194
|
+
1: "any",
|
|
4195
|
+
2: "string",
|
|
4196
|
+
3: "array",
|
|
4197
|
+
4: "object",
|
|
4198
|
+
5: "boolean",
|
|
4199
|
+
6: "expression",
|
|
4200
|
+
7: "null",
|
|
4201
|
+
8: "Array<number>",
|
|
4202
|
+
9: "Array<string>"
|
|
4850
4203
|
};
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
return this.expression(rbp);
|
|
4892
|
-
}
|
|
4893
|
-
if (lookahead === "Lbracket") {
|
|
4894
|
-
this.match("Lbracket");
|
|
4895
|
-
return this.parseMultiselectList();
|
|
4896
|
-
}
|
|
4897
|
-
if (lookahead === "Lbrace") {
|
|
4898
|
-
this.match("Lbrace");
|
|
4899
|
-
return this.parseMultiselectHash();
|
|
4900
|
-
}
|
|
4901
|
-
const token = this.lookaheadToken(0);
|
|
4902
|
-
this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
|
|
4903
|
-
}
|
|
4904
|
-
parseProjectionRHS(rbp) {
|
|
4905
|
-
if (bindingPower[this.lookahead(0)] < 10) {
|
|
4906
|
-
return { type: "Identity" };
|
|
4907
|
-
}
|
|
4908
|
-
if (this.lookahead(0) === "Lbracket") {
|
|
4909
|
-
return this.expression(rbp);
|
|
4910
|
-
}
|
|
4911
|
-
if (this.lookahead(0) === "Filter") {
|
|
4912
|
-
return this.expression(rbp);
|
|
4913
|
-
}
|
|
4914
|
-
if (this.lookahead(0) === "Dot") {
|
|
4915
|
-
this.match("Dot");
|
|
4916
|
-
return this.parseDotRHS(rbp);
|
|
4917
|
-
}
|
|
4918
|
-
const token = this.lookaheadToken(0);
|
|
4919
|
-
this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`);
|
|
4920
|
-
}
|
|
4921
|
-
parseMultiselectList() {
|
|
4922
|
-
const expressions = [];
|
|
4923
|
-
while (this.lookahead(0) !== "Rbracket") {
|
|
4924
|
-
const expression = this.expression(0);
|
|
4925
|
-
expressions.push(expression);
|
|
4926
|
-
if (this.lookahead(0) === "Comma") {
|
|
4927
|
-
this.match("Comma");
|
|
4928
|
-
if (this.lookahead(0) === "Rbracket") {
|
|
4929
|
-
throw new Error("Syntax error: unexpected token Rbracket");
|
|
4930
|
-
}
|
|
4931
|
-
}
|
|
4932
|
-
}
|
|
4933
|
-
this.match("Rbracket");
|
|
4934
|
-
return { type: "MultiSelectList", children: expressions };
|
|
4935
|
-
}
|
|
4936
|
-
parseMultiselectHash() {
|
|
4937
|
-
const pairs2 = [];
|
|
4938
|
-
const identifierTypes = ["UnquotedIdentifier", "QuotedIdentifier"];
|
|
4939
|
-
let keyToken;
|
|
4940
|
-
let keyName;
|
|
4941
|
-
let value;
|
|
4942
|
-
for (;; ) {
|
|
4943
|
-
keyToken = this.lookaheadToken(0);
|
|
4944
|
-
if (!identifierTypes.includes(keyToken.type)) {
|
|
4945
|
-
throw new Error(`Syntax error: expecting an identifier token, got: ${keyToken.type}`);
|
|
4946
|
-
}
|
|
4947
|
-
keyName = keyToken.value;
|
|
4948
|
-
this.advance();
|
|
4949
|
-
this.match("Colon");
|
|
4950
|
-
value = this.expression(0);
|
|
4951
|
-
pairs2.push({ value, type: "KeyValuePair", name: keyName });
|
|
4952
|
-
if (this.lookahead(0) === "Comma") {
|
|
4953
|
-
this.match("Comma");
|
|
4954
|
-
} else if (this.lookahead(0) === "Rbrace") {
|
|
4955
|
-
this.match("Rbrace");
|
|
4956
|
-
break;
|
|
4957
|
-
}
|
|
4958
|
-
}
|
|
4959
|
-
return { type: "MultiSelectHash", children: pairs2 };
|
|
4960
|
-
}
|
|
4961
|
-
}, Parser, Parser_default, Text = class _Text {
|
|
4962
|
-
_text;
|
|
4963
|
-
constructor(text) {
|
|
4964
|
-
this._text = text;
|
|
4965
|
-
}
|
|
4966
|
-
get string() {
|
|
4967
|
-
return this._text;
|
|
4968
|
-
}
|
|
4969
|
-
get length() {
|
|
4970
|
-
return this.codePoints.length;
|
|
4971
|
-
}
|
|
4972
|
-
compareTo(other) {
|
|
4973
|
-
return _Text.compare(this, new _Text(other));
|
|
4974
|
-
}
|
|
4975
|
-
static get comparer() {
|
|
4976
|
-
const stringComparer = (left, right) => {
|
|
4977
|
-
return new _Text(left).compareTo(right);
|
|
4204
|
+
var TOK_EOF = "EOF";
|
|
4205
|
+
var TOK_UNQUOTEDIDENTIFIER = "UnquotedIdentifier";
|
|
4206
|
+
var TOK_QUOTEDIDENTIFIER = "QuotedIdentifier";
|
|
4207
|
+
var TOK_RBRACKET = "Rbracket";
|
|
4208
|
+
var TOK_RPAREN = "Rparen";
|
|
4209
|
+
var TOK_COMMA = "Comma";
|
|
4210
|
+
var TOK_COLON = "Colon";
|
|
4211
|
+
var TOK_RBRACE = "Rbrace";
|
|
4212
|
+
var TOK_NUMBER = "Number";
|
|
4213
|
+
var TOK_CURRENT = "Current";
|
|
4214
|
+
var TOK_EXPREF = "Expref";
|
|
4215
|
+
var TOK_PIPE = "Pipe";
|
|
4216
|
+
var TOK_OR = "Or";
|
|
4217
|
+
var TOK_AND = "And";
|
|
4218
|
+
var TOK_EQ = "EQ";
|
|
4219
|
+
var TOK_GT = "GT";
|
|
4220
|
+
var TOK_LT = "LT";
|
|
4221
|
+
var TOK_GTE = "GTE";
|
|
4222
|
+
var TOK_LTE = "LTE";
|
|
4223
|
+
var TOK_NE = "NE";
|
|
4224
|
+
var TOK_FLATTEN = "Flatten";
|
|
4225
|
+
var TOK_STAR = "Star";
|
|
4226
|
+
var TOK_FILTER = "Filter";
|
|
4227
|
+
var TOK_DOT = "Dot";
|
|
4228
|
+
var TOK_NOT = "Not";
|
|
4229
|
+
var TOK_LBRACE = "Lbrace";
|
|
4230
|
+
var TOK_LBRACKET = "Lbracket";
|
|
4231
|
+
var TOK_LPAREN = "Lparen";
|
|
4232
|
+
var TOK_LITERAL = "Literal";
|
|
4233
|
+
var basicTokens = {
|
|
4234
|
+
".": TOK_DOT,
|
|
4235
|
+
"*": TOK_STAR,
|
|
4236
|
+
",": TOK_COMMA,
|
|
4237
|
+
":": TOK_COLON,
|
|
4238
|
+
"{": TOK_LBRACE,
|
|
4239
|
+
"}": TOK_RBRACE,
|
|
4240
|
+
"]": TOK_RBRACKET,
|
|
4241
|
+
"(": TOK_LPAREN,
|
|
4242
|
+
")": TOK_RPAREN,
|
|
4243
|
+
"@": TOK_CURRENT
|
|
4978
4244
|
};
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
}
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
4245
|
+
var operatorStartToken = {
|
|
4246
|
+
"<": true,
|
|
4247
|
+
">": true,
|
|
4248
|
+
"=": true,
|
|
4249
|
+
"!": true
|
|
4250
|
+
};
|
|
4251
|
+
var skipChars = {
|
|
4252
|
+
" ": true,
|
|
4253
|
+
"\t": true,
|
|
4254
|
+
"\n": true
|
|
4255
|
+
};
|
|
4256
|
+
function isAlpha(ch) {
|
|
4257
|
+
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
|
|
4258
|
+
}
|
|
4259
|
+
function isNum(ch) {
|
|
4260
|
+
return ch >= "0" && ch <= "9" || ch === "-";
|
|
4261
|
+
}
|
|
4262
|
+
function isAlphaNum(ch) {
|
|
4263
|
+
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_";
|
|
4264
|
+
}
|
|
4265
|
+
function Lexer() {}
|
|
4266
|
+
Lexer.prototype = {
|
|
4267
|
+
tokenize: function(stream) {
|
|
4268
|
+
var tokens = [];
|
|
4269
|
+
this._current = 0;
|
|
4270
|
+
var start;
|
|
4271
|
+
var identifier;
|
|
4272
|
+
var token;
|
|
4273
|
+
while (this._current < stream.length) {
|
|
4274
|
+
if (isAlpha(stream[this._current])) {
|
|
4275
|
+
start = this._current;
|
|
4276
|
+
identifier = this._consumeUnquotedIdentifier(stream);
|
|
4277
|
+
tokens.push({
|
|
4278
|
+
type: TOK_UNQUOTEDIDENTIFIER,
|
|
4279
|
+
value: identifier,
|
|
4280
|
+
start
|
|
4281
|
+
});
|
|
4282
|
+
} else if (basicTokens[stream[this._current]] !== undefined) {
|
|
4283
|
+
tokens.push({
|
|
4284
|
+
type: basicTokens[stream[this._current]],
|
|
4285
|
+
value: stream[this._current],
|
|
4286
|
+
start: this._current
|
|
4287
|
+
});
|
|
4288
|
+
this._current++;
|
|
4289
|
+
} else if (isNum(stream[this._current])) {
|
|
4290
|
+
token = this._consumeNumber(stream);
|
|
4291
|
+
tokens.push(token);
|
|
4292
|
+
} else if (stream[this._current] === "[") {
|
|
4293
|
+
token = this._consumeLBracket(stream);
|
|
4294
|
+
tokens.push(token);
|
|
4295
|
+
} else if (stream[this._current] === '"') {
|
|
4296
|
+
start = this._current;
|
|
4297
|
+
identifier = this._consumeQuotedIdentifier(stream);
|
|
4298
|
+
tokens.push({
|
|
4299
|
+
type: TOK_QUOTEDIDENTIFIER,
|
|
4300
|
+
value: identifier,
|
|
4301
|
+
start
|
|
4302
|
+
});
|
|
4303
|
+
} else if (stream[this._current] === "'") {
|
|
4304
|
+
start = this._current;
|
|
4305
|
+
identifier = this._consumeRawStringLiteral(stream);
|
|
4306
|
+
tokens.push({
|
|
4307
|
+
type: TOK_LITERAL,
|
|
4308
|
+
value: identifier,
|
|
4309
|
+
start
|
|
4310
|
+
});
|
|
4311
|
+
} else if (stream[this._current] === "`") {
|
|
4312
|
+
start = this._current;
|
|
4313
|
+
var literal = this._consumeLiteral(stream);
|
|
4314
|
+
tokens.push({
|
|
4315
|
+
type: TOK_LITERAL,
|
|
4316
|
+
value: literal,
|
|
4317
|
+
start
|
|
4318
|
+
});
|
|
4319
|
+
} else if (operatorStartToken[stream[this._current]] !== undefined) {
|
|
4320
|
+
tokens.push(this._consumeOperator(stream));
|
|
4321
|
+
} else if (skipChars[stream[this._current]] !== undefined) {
|
|
4322
|
+
this._current++;
|
|
4323
|
+
} else if (stream[this._current] === "&") {
|
|
4324
|
+
start = this._current;
|
|
4325
|
+
this._current++;
|
|
4326
|
+
if (stream[this._current] === "&") {
|
|
4327
|
+
this._current++;
|
|
4328
|
+
tokens.push({ type: TOK_AND, value: "&&", start });
|
|
4329
|
+
} else {
|
|
4330
|
+
tokens.push({ type: TOK_EXPREF, value: "&", start });
|
|
4331
|
+
}
|
|
4332
|
+
} else if (stream[this._current] === "|") {
|
|
4333
|
+
start = this._current;
|
|
4334
|
+
this._current++;
|
|
4335
|
+
if (stream[this._current] === "|") {
|
|
4336
|
+
this._current++;
|
|
4337
|
+
tokens.push({ type: TOK_OR, value: "||", start });
|
|
4338
|
+
} else {
|
|
4339
|
+
tokens.push({ type: TOK_PIPE, value: "|", start });
|
|
4340
|
+
}
|
|
4341
|
+
} else {
|
|
4342
|
+
var error = new Error("Unknown character:" + stream[this._current]);
|
|
4343
|
+
error.name = "LexerError";
|
|
4344
|
+
throw error;
|
|
4345
|
+
}
|
|
4346
|
+
}
|
|
4347
|
+
return tokens;
|
|
5069
4348
|
},
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
4349
|
+
_consumeUnquotedIdentifier: function(stream) {
|
|
4350
|
+
var start = this._current;
|
|
4351
|
+
this._current++;
|
|
4352
|
+
while (this._current < stream.length && isAlphaNum(stream[this._current])) {
|
|
4353
|
+
this._current++;
|
|
4354
|
+
}
|
|
4355
|
+
return stream.slice(start, this._current);
|
|
5073
4356
|
},
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
4357
|
+
_consumeQuotedIdentifier: function(stream) {
|
|
4358
|
+
var start = this._current;
|
|
4359
|
+
this._current++;
|
|
4360
|
+
var maxLength = stream.length;
|
|
4361
|
+
while (stream[this._current] !== '"' && this._current < maxLength) {
|
|
4362
|
+
var current = this._current;
|
|
4363
|
+
if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) {
|
|
4364
|
+
current += 2;
|
|
4365
|
+
} else {
|
|
4366
|
+
current++;
|
|
4367
|
+
}
|
|
4368
|
+
this._current = current;
|
|
4369
|
+
}
|
|
4370
|
+
this._current++;
|
|
4371
|
+
return JSON.parse(stream.slice(start, this._current));
|
|
5077
4372
|
},
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
4373
|
+
_consumeRawStringLiteral: function(stream) {
|
|
4374
|
+
var start = this._current;
|
|
4375
|
+
this._current++;
|
|
4376
|
+
var maxLength = stream.length;
|
|
4377
|
+
while (stream[this._current] !== "'" && this._current < maxLength) {
|
|
4378
|
+
var current = this._current;
|
|
4379
|
+
if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "'")) {
|
|
4380
|
+
current += 2;
|
|
4381
|
+
} else {
|
|
4382
|
+
current++;
|
|
4383
|
+
}
|
|
4384
|
+
this._current = current;
|
|
4385
|
+
}
|
|
4386
|
+
this._current++;
|
|
4387
|
+
var literal = stream.slice(start + 1, this._current - 1);
|
|
4388
|
+
return literal.replace("\\'", "'");
|
|
5081
4389
|
},
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
4390
|
+
_consumeNumber: function(stream) {
|
|
4391
|
+
var start = this._current;
|
|
4392
|
+
this._current++;
|
|
4393
|
+
var maxLength = stream.length;
|
|
4394
|
+
while (isNum(stream[this._current]) && this._current < maxLength) {
|
|
4395
|
+
this._current++;
|
|
4396
|
+
}
|
|
4397
|
+
var value = parseInt(stream.slice(start, this._current));
|
|
4398
|
+
return { type: TOK_NUMBER, value, start };
|
|
5085
4399
|
},
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
4400
|
+
_consumeLBracket: function(stream) {
|
|
4401
|
+
var start = this._current;
|
|
4402
|
+
this._current++;
|
|
4403
|
+
if (stream[this._current] === "?") {
|
|
4404
|
+
this._current++;
|
|
4405
|
+
return { type: TOK_FILTER, value: "[?", start };
|
|
4406
|
+
} else if (stream[this._current] === "]") {
|
|
4407
|
+
this._current++;
|
|
4408
|
+
return { type: TOK_FLATTEN, value: "[]", start };
|
|
4409
|
+
} else {
|
|
4410
|
+
return { type: TOK_LBRACKET, value: "[", start };
|
|
4411
|
+
}
|
|
5090
4412
|
},
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
4413
|
+
_consumeOperator: function(stream) {
|
|
4414
|
+
var start = this._current;
|
|
4415
|
+
var startingChar = stream[start];
|
|
4416
|
+
this._current++;
|
|
4417
|
+
if (startingChar === "!") {
|
|
4418
|
+
if (stream[this._current] === "=") {
|
|
4419
|
+
this._current++;
|
|
4420
|
+
return { type: TOK_NE, value: "!=", start };
|
|
4421
|
+
} else {
|
|
4422
|
+
return { type: TOK_NOT, value: "!", start };
|
|
4423
|
+
}
|
|
4424
|
+
} else if (startingChar === "<") {
|
|
4425
|
+
if (stream[this._current] === "=") {
|
|
4426
|
+
this._current++;
|
|
4427
|
+
return { type: TOK_LTE, value: "<=", start };
|
|
4428
|
+
} else {
|
|
4429
|
+
return { type: TOK_LT, value: "<", start };
|
|
4430
|
+
}
|
|
4431
|
+
} else if (startingChar === ">") {
|
|
4432
|
+
if (stream[this._current] === "=") {
|
|
4433
|
+
this._current++;
|
|
4434
|
+
return { type: TOK_GTE, value: ">=", start };
|
|
4435
|
+
} else {
|
|
4436
|
+
return { type: TOK_GT, value: ">", start };
|
|
4437
|
+
}
|
|
4438
|
+
} else if (startingChar === "=") {
|
|
4439
|
+
if (stream[this._current] === "=") {
|
|
4440
|
+
this._current++;
|
|
4441
|
+
return { type: TOK_EQ, value: "==", start };
|
|
4442
|
+
}
|
|
4443
|
+
}
|
|
5094
4444
|
},
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
4445
|
+
_consumeLiteral: function(stream) {
|
|
4446
|
+
this._current++;
|
|
4447
|
+
var start = this._current;
|
|
4448
|
+
var maxLength = stream.length;
|
|
4449
|
+
var literal;
|
|
4450
|
+
while (stream[this._current] !== "`" && this._current < maxLength) {
|
|
4451
|
+
var current = this._current;
|
|
4452
|
+
if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) {
|
|
4453
|
+
current += 2;
|
|
4454
|
+
} else {
|
|
4455
|
+
current++;
|
|
4456
|
+
}
|
|
4457
|
+
this._current = current;
|
|
4458
|
+
}
|
|
4459
|
+
var literalString = trimLeft(stream.slice(start, this._current));
|
|
4460
|
+
literalString = literalString.replace("\\`", "`");
|
|
4461
|
+
if (this._looksLikeJSON(literalString)) {
|
|
4462
|
+
literal = JSON.parse(literalString);
|
|
4463
|
+
} else {
|
|
4464
|
+
literal = JSON.parse('"' + literalString + '"');
|
|
4465
|
+
}
|
|
4466
|
+
this._current++;
|
|
4467
|
+
return literal;
|
|
5103
4468
|
},
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
]
|
|
4469
|
+
_looksLikeJSON: function(literalString) {
|
|
4470
|
+
var startingChars = '[{"';
|
|
4471
|
+
var jsonLiterals = ["true", "false", "null"];
|
|
4472
|
+
var numberLooking = "-0123456789";
|
|
4473
|
+
if (literalString === "") {
|
|
4474
|
+
return false;
|
|
4475
|
+
} else if (startingChars.indexOf(literalString[0]) >= 0) {
|
|
4476
|
+
return true;
|
|
4477
|
+
} else if (jsonLiterals.indexOf(literalString) >= 0) {
|
|
4478
|
+
return true;
|
|
4479
|
+
} else if (numberLooking.indexOf(literalString[0]) >= 0) {
|
|
4480
|
+
try {
|
|
4481
|
+
JSON.parse(literalString);
|
|
4482
|
+
return true;
|
|
4483
|
+
} catch (ex) {
|
|
4484
|
+
return false;
|
|
4485
|
+
}
|
|
4486
|
+
} else {
|
|
4487
|
+
return false;
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
};
|
|
4491
|
+
var bindingPower = {};
|
|
4492
|
+
bindingPower[TOK_EOF] = 0;
|
|
4493
|
+
bindingPower[TOK_UNQUOTEDIDENTIFIER] = 0;
|
|
4494
|
+
bindingPower[TOK_QUOTEDIDENTIFIER] = 0;
|
|
4495
|
+
bindingPower[TOK_RBRACKET] = 0;
|
|
4496
|
+
bindingPower[TOK_RPAREN] = 0;
|
|
4497
|
+
bindingPower[TOK_COMMA] = 0;
|
|
4498
|
+
bindingPower[TOK_RBRACE] = 0;
|
|
4499
|
+
bindingPower[TOK_NUMBER] = 0;
|
|
4500
|
+
bindingPower[TOK_CURRENT] = 0;
|
|
4501
|
+
bindingPower[TOK_EXPREF] = 0;
|
|
4502
|
+
bindingPower[TOK_PIPE] = 1;
|
|
4503
|
+
bindingPower[TOK_OR] = 2;
|
|
4504
|
+
bindingPower[TOK_AND] = 3;
|
|
4505
|
+
bindingPower[TOK_EQ] = 5;
|
|
4506
|
+
bindingPower[TOK_GT] = 5;
|
|
4507
|
+
bindingPower[TOK_LT] = 5;
|
|
4508
|
+
bindingPower[TOK_GTE] = 5;
|
|
4509
|
+
bindingPower[TOK_LTE] = 5;
|
|
4510
|
+
bindingPower[TOK_NE] = 5;
|
|
4511
|
+
bindingPower[TOK_FLATTEN] = 9;
|
|
4512
|
+
bindingPower[TOK_STAR] = 20;
|
|
4513
|
+
bindingPower[TOK_FILTER] = 21;
|
|
4514
|
+
bindingPower[TOK_DOT] = 40;
|
|
4515
|
+
bindingPower[TOK_NOT] = 45;
|
|
4516
|
+
bindingPower[TOK_LBRACE] = 50;
|
|
4517
|
+
bindingPower[TOK_LBRACKET] = 55;
|
|
4518
|
+
bindingPower[TOK_LPAREN] = 60;
|
|
4519
|
+
function Parser() {}
|
|
4520
|
+
Parser.prototype = {
|
|
4521
|
+
parse: function(expression) {
|
|
4522
|
+
this._loadTokens(expression);
|
|
4523
|
+
this.index = 0;
|
|
4524
|
+
var ast = this.expression(0);
|
|
4525
|
+
if (this._lookahead(0) !== TOK_EOF) {
|
|
4526
|
+
var t = this._lookaheadToken(0);
|
|
4527
|
+
var error = new Error("Unexpected token type: " + t.type + ", value: " + t.value);
|
|
4528
|
+
error.name = "ParserError";
|
|
4529
|
+
throw error;
|
|
4530
|
+
}
|
|
4531
|
+
return ast;
|
|
5111
4532
|
},
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
{ types: [2] },
|
|
5118
|
-
{ types: [0], optional: true }
|
|
5119
|
-
]
|
|
4533
|
+
_loadTokens: function(expression) {
|
|
4534
|
+
var lexer = new Lexer;
|
|
4535
|
+
var tokens = lexer.tokenize(expression);
|
|
4536
|
+
tokens.push({ type: TOK_EOF, value: "", start: expression.length });
|
|
4537
|
+
this.tokens = tokens;
|
|
5120
4538
|
},
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
4539
|
+
expression: function(rbp) {
|
|
4540
|
+
var leftToken = this._lookaheadToken(0);
|
|
4541
|
+
this._advance();
|
|
4542
|
+
var left = this.nud(leftToken);
|
|
4543
|
+
var currentToken = this._lookahead(0);
|
|
4544
|
+
while (rbp < bindingPower[currentToken]) {
|
|
4545
|
+
this._advance();
|
|
4546
|
+
left = this.led(currentToken, left);
|
|
4547
|
+
currentToken = this._lookahead(0);
|
|
4548
|
+
}
|
|
4549
|
+
return left;
|
|
5124
4550
|
},
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
_signature: [{ types: [9, 8] }]
|
|
4551
|
+
_lookahead: function(number) {
|
|
4552
|
+
return this.tokens[this.index + number].type;
|
|
5128
4553
|
},
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
_signature: [{ types: [3] }, { types: [6] }]
|
|
4554
|
+
_lookaheadToken: function(number) {
|
|
4555
|
+
return this.tokens[this.index + number];
|
|
5132
4556
|
},
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
_signature: [
|
|
5136
|
-
{ types: [2] },
|
|
5137
|
-
{ types: [2] },
|
|
5138
|
-
{ types: [0], optional: true }
|
|
5139
|
-
]
|
|
4557
|
+
_advance: function() {
|
|
4558
|
+
this.index++;
|
|
5140
4559
|
},
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
4560
|
+
nud: function(token) {
|
|
4561
|
+
var left;
|
|
4562
|
+
var right;
|
|
4563
|
+
var expression;
|
|
4564
|
+
switch (token.type) {
|
|
4565
|
+
case TOK_LITERAL:
|
|
4566
|
+
return { type: "Literal", value: token.value };
|
|
4567
|
+
case TOK_UNQUOTEDIDENTIFIER:
|
|
4568
|
+
return { type: "Field", name: token.value };
|
|
4569
|
+
case TOK_QUOTEDIDENTIFIER:
|
|
4570
|
+
var node = { type: "Field", name: token.value };
|
|
4571
|
+
if (this._lookahead(0) === TOK_LPAREN) {
|
|
4572
|
+
throw new Error("Quoted identifier not allowed for function names.");
|
|
4573
|
+
}
|
|
4574
|
+
return node;
|
|
4575
|
+
case TOK_NOT:
|
|
4576
|
+
right = this.expression(bindingPower.Not);
|
|
4577
|
+
return { type: "NotExpression", children: [right] };
|
|
4578
|
+
case TOK_STAR:
|
|
4579
|
+
left = { type: "Identity" };
|
|
4580
|
+
right = null;
|
|
4581
|
+
if (this._lookahead(0) === TOK_RBRACKET) {
|
|
4582
|
+
right = { type: "Identity" };
|
|
4583
|
+
} else {
|
|
4584
|
+
right = this._parseProjectionRHS(bindingPower.Star);
|
|
4585
|
+
}
|
|
4586
|
+
return { type: "ValueProjection", children: [left, right] };
|
|
4587
|
+
case TOK_FILTER:
|
|
4588
|
+
return this.led(token.type, { type: "Identity" });
|
|
4589
|
+
case TOK_LBRACE:
|
|
4590
|
+
return this._parseMultiselectHash();
|
|
4591
|
+
case TOK_FLATTEN:
|
|
4592
|
+
left = { type: TOK_FLATTEN, children: [{ type: "Identity" }] };
|
|
4593
|
+
right = this._parseProjectionRHS(bindingPower.Flatten);
|
|
4594
|
+
return { type: "Projection", children: [left, right] };
|
|
4595
|
+
case TOK_LBRACKET:
|
|
4596
|
+
if (this._lookahead(0) === TOK_NUMBER || this._lookahead(0) === TOK_COLON) {
|
|
4597
|
+
right = this._parseIndexExpression();
|
|
4598
|
+
return this._projectIfSlice({ type: "Identity" }, right);
|
|
4599
|
+
} else if (this._lookahead(0) === TOK_STAR && this._lookahead(1) === TOK_RBRACKET) {
|
|
4600
|
+
this._advance();
|
|
4601
|
+
this._advance();
|
|
4602
|
+
right = this._parseProjectionRHS(bindingPower.Star);
|
|
4603
|
+
return {
|
|
4604
|
+
type: "Projection",
|
|
4605
|
+
children: [{ type: "Identity" }, right]
|
|
4606
|
+
};
|
|
4607
|
+
}
|
|
4608
|
+
return this._parseMultiselectList();
|
|
4609
|
+
case TOK_CURRENT:
|
|
4610
|
+
return { type: TOK_CURRENT };
|
|
4611
|
+
case TOK_EXPREF:
|
|
4612
|
+
expression = this.expression(bindingPower.Expref);
|
|
4613
|
+
return { type: "ExpressionReference", children: [expression] };
|
|
4614
|
+
case TOK_LPAREN:
|
|
4615
|
+
var args = [];
|
|
4616
|
+
while (this._lookahead(0) !== TOK_RPAREN) {
|
|
4617
|
+
if (this._lookahead(0) === TOK_CURRENT) {
|
|
4618
|
+
expression = { type: TOK_CURRENT };
|
|
4619
|
+
this._advance();
|
|
4620
|
+
} else {
|
|
4621
|
+
expression = this.expression(0);
|
|
4622
|
+
}
|
|
4623
|
+
args.push(expression);
|
|
4624
|
+
}
|
|
4625
|
+
this._match(TOK_RPAREN);
|
|
4626
|
+
return args[0];
|
|
4627
|
+
default:
|
|
4628
|
+
this._errorToken(token);
|
|
4629
|
+
}
|
|
5144
4630
|
},
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
4631
|
+
led: function(tokenName, left) {
|
|
4632
|
+
var right;
|
|
4633
|
+
switch (tokenName) {
|
|
4634
|
+
case TOK_DOT:
|
|
4635
|
+
var rbp = bindingPower.Dot;
|
|
4636
|
+
if (this._lookahead(0) !== TOK_STAR) {
|
|
4637
|
+
right = this._parseDotRHS(rbp);
|
|
4638
|
+
return { type: "Subexpression", children: [left, right] };
|
|
4639
|
+
}
|
|
4640
|
+
this._advance();
|
|
4641
|
+
right = this._parseProjectionRHS(rbp);
|
|
4642
|
+
return { type: "ValueProjection", children: [left, right] };
|
|
4643
|
+
case TOK_PIPE:
|
|
4644
|
+
right = this.expression(bindingPower.Pipe);
|
|
4645
|
+
return { type: TOK_PIPE, children: [left, right] };
|
|
4646
|
+
case TOK_OR:
|
|
4647
|
+
right = this.expression(bindingPower.Or);
|
|
4648
|
+
return { type: "OrExpression", children: [left, right] };
|
|
4649
|
+
case TOK_AND:
|
|
4650
|
+
right = this.expression(bindingPower.And);
|
|
4651
|
+
return { type: "AndExpression", children: [left, right] };
|
|
4652
|
+
case TOK_LPAREN:
|
|
4653
|
+
var name = left.name;
|
|
4654
|
+
var args = [];
|
|
4655
|
+
var expression, node;
|
|
4656
|
+
while (this._lookahead(0) !== TOK_RPAREN) {
|
|
4657
|
+
if (this._lookahead(0) === TOK_CURRENT) {
|
|
4658
|
+
expression = { type: TOK_CURRENT };
|
|
4659
|
+
this._advance();
|
|
4660
|
+
} else {
|
|
4661
|
+
expression = this.expression(0);
|
|
4662
|
+
}
|
|
4663
|
+
if (this._lookahead(0) === TOK_COMMA) {
|
|
4664
|
+
this._match(TOK_COMMA);
|
|
4665
|
+
}
|
|
4666
|
+
args.push(expression);
|
|
4667
|
+
}
|
|
4668
|
+
this._match(TOK_RPAREN);
|
|
4669
|
+
node = { type: "Function", name, children: args };
|
|
4670
|
+
return node;
|
|
4671
|
+
case TOK_FILTER:
|
|
4672
|
+
var condition = this.expression(0);
|
|
4673
|
+
this._match(TOK_RBRACKET);
|
|
4674
|
+
if (this._lookahead(0) === TOK_FLATTEN) {
|
|
4675
|
+
right = { type: "Identity" };
|
|
4676
|
+
} else {
|
|
4677
|
+
right = this._parseProjectionRHS(bindingPower.Filter);
|
|
4678
|
+
}
|
|
4679
|
+
return { type: "FilterProjection", children: [left, right, condition] };
|
|
4680
|
+
case TOK_FLATTEN:
|
|
4681
|
+
var leftNode = { type: TOK_FLATTEN, children: [left] };
|
|
4682
|
+
var rightNode = this._parseProjectionRHS(bindingPower.Flatten);
|
|
4683
|
+
return { type: "Projection", children: [leftNode, rightNode] };
|
|
4684
|
+
case TOK_EQ:
|
|
4685
|
+
case TOK_NE:
|
|
4686
|
+
case TOK_GT:
|
|
4687
|
+
case TOK_GTE:
|
|
4688
|
+
case TOK_LT:
|
|
4689
|
+
case TOK_LTE:
|
|
4690
|
+
return this._parseComparator(left, tokenName);
|
|
4691
|
+
case TOK_LBRACKET:
|
|
4692
|
+
var token = this._lookaheadToken(0);
|
|
4693
|
+
if (token.type === TOK_NUMBER || token.type === TOK_COLON) {
|
|
4694
|
+
right = this._parseIndexExpression();
|
|
4695
|
+
return this._projectIfSlice(left, right);
|
|
4696
|
+
}
|
|
4697
|
+
this._match(TOK_STAR);
|
|
4698
|
+
this._match(TOK_RBRACKET);
|
|
4699
|
+
right = this._parseProjectionRHS(bindingPower.Star);
|
|
4700
|
+
return { type: "Projection", children: [left, right] };
|
|
4701
|
+
default:
|
|
4702
|
+
this._errorToken(this._lookaheadToken(0));
|
|
4703
|
+
}
|
|
5152
4704
|
},
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
4705
|
+
_match: function(tokenType) {
|
|
4706
|
+
if (this._lookahead(0) === tokenType) {
|
|
4707
|
+
this._advance();
|
|
4708
|
+
} else {
|
|
4709
|
+
var t = this._lookaheadToken(0);
|
|
4710
|
+
var error = new Error("Expected " + tokenType + ", got: " + t.type);
|
|
4711
|
+
error.name = "ParserError";
|
|
4712
|
+
throw error;
|
|
4713
|
+
}
|
|
5156
4714
|
},
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
4715
|
+
_errorToken: function(token) {
|
|
4716
|
+
var error = new Error("Invalid token (" + token.type + '): "' + token.value + '"');
|
|
4717
|
+
error.name = "ParserError";
|
|
4718
|
+
throw error;
|
|
5160
4719
|
},
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
if (!name || typeof name !== "string" || name.trim() === "") {
|
|
5173
|
-
return {
|
|
5174
|
-
success: false,
|
|
5175
|
-
reason: "invalid-name",
|
|
5176
|
-
message: "Function name must be a non-empty string"
|
|
5177
|
-
};
|
|
5178
|
-
}
|
|
5179
|
-
try {
|
|
5180
|
-
this.validateInputSignatures(name, signature);
|
|
5181
|
-
} catch (error) {
|
|
5182
|
-
return {
|
|
5183
|
-
success: false,
|
|
5184
|
-
reason: "invalid-signature",
|
|
5185
|
-
message: error instanceof Error ? error.message : "Invalid function signature"
|
|
5186
|
-
};
|
|
5187
|
-
}
|
|
5188
|
-
const { override = false, warn = false } = options;
|
|
5189
|
-
const exists = name in this._functionTable;
|
|
5190
|
-
if (exists && !override) {
|
|
5191
|
-
return {
|
|
5192
|
-
success: false,
|
|
5193
|
-
reason: "already-exists",
|
|
5194
|
-
message: `Function already defined: ${name}(). Use { override: true } to replace it.`
|
|
5195
|
-
};
|
|
5196
|
-
}
|
|
5197
|
-
if (exists && override && warn) {
|
|
5198
|
-
console.warn(`Warning: Overriding existing function: ${name}()`);
|
|
5199
|
-
}
|
|
5200
|
-
this._functionTable[name] = {
|
|
5201
|
-
_func: customFunction.bind(this),
|
|
5202
|
-
_signature: signature
|
|
5203
|
-
};
|
|
5204
|
-
this._customFunctions.add(name);
|
|
5205
|
-
const message = exists ? `Function ${name}() overridden successfully` : `Function ${name}() registered successfully`;
|
|
5206
|
-
return { success: true, message };
|
|
5207
|
-
}
|
|
5208
|
-
register(name, customFunction, signature, options = {}) {
|
|
5209
|
-
return this._registerInternal(name, customFunction, signature, options);
|
|
5210
|
-
}
|
|
5211
|
-
unregister(name) {
|
|
5212
|
-
if (!this._customFunctions.has(name)) {
|
|
5213
|
-
return false;
|
|
5214
|
-
}
|
|
5215
|
-
delete this._functionTable[name];
|
|
5216
|
-
this._customFunctions.delete(name);
|
|
5217
|
-
return true;
|
|
5218
|
-
}
|
|
5219
|
-
isRegistered(name) {
|
|
5220
|
-
return name in this._functionTable;
|
|
5221
|
-
}
|
|
5222
|
-
getRegistered() {
|
|
5223
|
-
return Object.keys(this._functionTable);
|
|
5224
|
-
}
|
|
5225
|
-
getCustomFunctions() {
|
|
5226
|
-
return Array.from(this._customFunctions);
|
|
5227
|
-
}
|
|
5228
|
-
clearCustomFunctions() {
|
|
5229
|
-
for (const name of this._customFunctions) {
|
|
5230
|
-
delete this._functionTable[name];
|
|
5231
|
-
}
|
|
5232
|
-
this._customFunctions.clear();
|
|
5233
|
-
}
|
|
5234
|
-
callFunction(name, resolvedArgs) {
|
|
5235
|
-
const functionEntry = this._functionTable[name];
|
|
5236
|
-
if (functionEntry === undefined) {
|
|
5237
|
-
throw new Error(`Unknown function: ${name}()`);
|
|
5238
|
-
}
|
|
5239
|
-
this.validateArgs(name, resolvedArgs, functionEntry._signature);
|
|
5240
|
-
return functionEntry._func.call(this, resolvedArgs);
|
|
5241
|
-
}
|
|
5242
|
-
validateInputSignatures(name, signature) {
|
|
5243
|
-
for (let i = 0;i < signature.length; i += 1) {
|
|
5244
|
-
if ("variadic" in signature[i] && i !== signature.length - 1) {
|
|
5245
|
-
throw new Error(`Invalid arity: ${name}() 'variadic' argument ${i + 1} must occur last`);
|
|
5246
|
-
}
|
|
5247
|
-
}
|
|
5248
|
-
}
|
|
5249
|
-
validateArgs(name, args, signature) {
|
|
5250
|
-
this.validateInputSignatures(name, signature);
|
|
5251
|
-
this.validateArity(name, args, signature);
|
|
5252
|
-
this.validateTypes(name, args, signature);
|
|
5253
|
-
}
|
|
5254
|
-
validateArity(name, args, signature) {
|
|
5255
|
-
const numberOfRequiredArgs = signature.filter((argSignature) => !(argSignature.optional ?? false)).length;
|
|
5256
|
-
const lastArgIsVariadic = signature[signature.length - 1]?.variadic ?? false;
|
|
5257
|
-
const tooFewArgs = args.length < numberOfRequiredArgs;
|
|
5258
|
-
const tooManyArgs = args.length > signature.length;
|
|
5259
|
-
if (lastArgIsVariadic && tooFewArgs || !lastArgIsVariadic && (tooFewArgs || tooManyArgs)) {
|
|
5260
|
-
const tooFewModifier = tooFewArgs && (!lastArgIsVariadic && numberOfRequiredArgs > 1 || lastArgIsVariadic) ? "at least " : "";
|
|
5261
|
-
const pluralized = signature.length > 1;
|
|
5262
|
-
throw new Error(`Invalid arity: ${name}() takes ${tooFewModifier}${numberOfRequiredArgs} argument${pluralized && "s" || ""} but received ${args.length}`);
|
|
5263
|
-
}
|
|
5264
|
-
}
|
|
5265
|
-
validateTypes(name, args, signature) {
|
|
5266
|
-
for (let i = 0;i < signature.length; i += 1) {
|
|
5267
|
-
const currentSpec = signature[i].types;
|
|
5268
|
-
const actualType = this.getTypeName(args[i]);
|
|
5269
|
-
if (actualType === undefined) {
|
|
5270
|
-
continue;
|
|
5271
|
-
}
|
|
5272
|
-
const typeMatched = currentSpec.some((expectedType) => this.typeMatches(actualType, expectedType, args[i]));
|
|
5273
|
-
if (!typeMatched) {
|
|
5274
|
-
const expected = currentSpec.map((typeId) => this.TYPE_NAME_TABLE[typeId]).join(" | ");
|
|
5275
|
-
throw new Error(`Invalid type: ${name}() expected argument ${i + 1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead.`);
|
|
5276
|
-
}
|
|
5277
|
-
}
|
|
5278
|
-
}
|
|
5279
|
-
typeMatches(actual, expected, argValue) {
|
|
5280
|
-
if (expected === 1) {
|
|
5281
|
-
return true;
|
|
5282
|
-
}
|
|
5283
|
-
if (expected === 9 || expected === 8 || expected === 10 || expected === 11 || expected === 3) {
|
|
5284
|
-
if (expected === 3) {
|
|
5285
|
-
return actual === 3;
|
|
5286
|
-
}
|
|
5287
|
-
if (actual === 3) {
|
|
5288
|
-
let subtype;
|
|
5289
|
-
if (expected === 8) {
|
|
5290
|
-
subtype = 0;
|
|
5291
|
-
} else if (expected === 10) {
|
|
5292
|
-
subtype = 4;
|
|
5293
|
-
} else if (expected === 9) {
|
|
5294
|
-
subtype = 2;
|
|
5295
|
-
} else if (expected === 11) {
|
|
5296
|
-
subtype = 3;
|
|
4720
|
+
_parseIndexExpression: function() {
|
|
4721
|
+
if (this._lookahead(0) === TOK_COLON || this._lookahead(1) === TOK_COLON) {
|
|
4722
|
+
return this._parseSliceExpression();
|
|
4723
|
+
} else {
|
|
4724
|
+
var node = {
|
|
4725
|
+
type: "Index",
|
|
4726
|
+
value: this._lookaheadToken(0).value
|
|
4727
|
+
};
|
|
4728
|
+
this._advance();
|
|
4729
|
+
this._match(TOK_RBRACKET);
|
|
4730
|
+
return node;
|
|
5297
4731
|
}
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
4732
|
+
},
|
|
4733
|
+
_projectIfSlice: function(left, right) {
|
|
4734
|
+
var indexExpr = { type: "IndexExpression", children: [left, right] };
|
|
4735
|
+
if (right.type === "Slice") {
|
|
4736
|
+
return {
|
|
4737
|
+
type: "Projection",
|
|
4738
|
+
children: [indexExpr, this._parseProjectionRHS(bindingPower.Star)]
|
|
4739
|
+
};
|
|
4740
|
+
} else {
|
|
4741
|
+
return indexExpr;
|
|
5304
4742
|
}
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
};
|
|
5406
|
-
functionItems = ([inputValue]) => {
|
|
5407
|
-
return Object.entries(inputValue);
|
|
5408
|
-
};
|
|
5409
|
-
functionJoin = (resolvedArgs) => {
|
|
5410
|
-
const [joinChar, listJoin] = resolvedArgs;
|
|
5411
|
-
return listJoin.join(joinChar);
|
|
5412
|
-
};
|
|
5413
|
-
functionLength = ([inputValue]) => {
|
|
5414
|
-
if (typeof inputValue === "string") {
|
|
5415
|
-
return new Text(inputValue).length;
|
|
5416
|
-
}
|
|
5417
|
-
if (Array.isArray(inputValue)) {
|
|
5418
|
-
return inputValue.length;
|
|
5419
|
-
}
|
|
5420
|
-
return Object.keys(inputValue).length;
|
|
5421
|
-
};
|
|
5422
|
-
functionMap = ([exprefNode, elements]) => {
|
|
5423
|
-
if (!this._interpreter) {
|
|
5424
|
-
return [];
|
|
5425
|
-
}
|
|
5426
|
-
const mapped = [];
|
|
5427
|
-
const interpreter = this._interpreter;
|
|
5428
|
-
for (let i = 0;i < elements.length; i += 1) {
|
|
5429
|
-
mapped.push(interpreter.visit(exprefNode, elements[i]));
|
|
5430
|
-
}
|
|
5431
|
-
return mapped;
|
|
5432
|
-
};
|
|
5433
|
-
functionMax = ([inputValue]) => {
|
|
5434
|
-
if (!inputValue.length) {
|
|
5435
|
-
return null;
|
|
5436
|
-
}
|
|
5437
|
-
const typeName = this.getTypeName(inputValue[0]);
|
|
5438
|
-
if (typeName === 0) {
|
|
5439
|
-
return Math.max(...inputValue);
|
|
5440
|
-
}
|
|
5441
|
-
const elements = inputValue;
|
|
5442
|
-
let maxElement = elements[0];
|
|
5443
|
-
for (let i = 1;i < elements.length; i += 1) {
|
|
5444
|
-
if (maxElement.localeCompare(elements[i]) < 0) {
|
|
5445
|
-
maxElement = elements[i];
|
|
5446
|
-
}
|
|
5447
|
-
}
|
|
5448
|
-
return maxElement;
|
|
5449
|
-
};
|
|
5450
|
-
functionMaxBy = (resolvedArgs) => {
|
|
5451
|
-
const exprefNode = resolvedArgs[1];
|
|
5452
|
-
const resolvedArray = resolvedArgs[0];
|
|
5453
|
-
const keyFunction = this.createKeyFunction(exprefNode, [0, 2]);
|
|
5454
|
-
let maxNumber = -Infinity;
|
|
5455
|
-
let maxRecord;
|
|
5456
|
-
let current;
|
|
5457
|
-
for (let i = 0;i < resolvedArray.length; i += 1) {
|
|
5458
|
-
current = keyFunction && keyFunction(resolvedArray[i]);
|
|
5459
|
-
if (current !== undefined && current > maxNumber) {
|
|
5460
|
-
maxNumber = current;
|
|
5461
|
-
maxRecord = resolvedArray[i];
|
|
5462
|
-
}
|
|
5463
|
-
}
|
|
5464
|
-
return maxRecord || null;
|
|
5465
|
-
};
|
|
5466
|
-
functionMerge = (resolvedArgs) => {
|
|
5467
|
-
let merged = {};
|
|
5468
|
-
for (let i = 0;i < resolvedArgs.length; i += 1) {
|
|
5469
|
-
const current = resolvedArgs[i];
|
|
5470
|
-
merged = Object.assign(merged, current);
|
|
5471
|
-
}
|
|
5472
|
-
return merged;
|
|
5473
|
-
};
|
|
5474
|
-
functionMin = ([inputValue]) => {
|
|
5475
|
-
if (!inputValue.length) {
|
|
5476
|
-
return null;
|
|
5477
|
-
}
|
|
5478
|
-
const typeName = this.getTypeName(inputValue[0]);
|
|
5479
|
-
if (typeName === 0) {
|
|
5480
|
-
return Math.min(...inputValue);
|
|
5481
|
-
}
|
|
5482
|
-
const elements = inputValue;
|
|
5483
|
-
let minElement = elements[0];
|
|
5484
|
-
for (let i = 1;i < elements.length; i += 1) {
|
|
5485
|
-
if (elements[i].localeCompare(minElement) < 0) {
|
|
5486
|
-
minElement = elements[i];
|
|
5487
|
-
}
|
|
5488
|
-
}
|
|
5489
|
-
return minElement;
|
|
5490
|
-
};
|
|
5491
|
-
functionMinBy = (resolvedArgs) => {
|
|
5492
|
-
const exprefNode = resolvedArgs[1];
|
|
5493
|
-
const resolvedArray = resolvedArgs[0];
|
|
5494
|
-
const keyFunction = this.createKeyFunction(exprefNode, [0, 2]);
|
|
5495
|
-
let minNumber = Infinity;
|
|
5496
|
-
let minRecord;
|
|
5497
|
-
let current;
|
|
5498
|
-
for (let i = 0;i < resolvedArray.length; i += 1) {
|
|
5499
|
-
current = keyFunction && keyFunction(resolvedArray[i]);
|
|
5500
|
-
if (current !== undefined && current < minNumber) {
|
|
5501
|
-
minNumber = current;
|
|
5502
|
-
minRecord = resolvedArray[i];
|
|
5503
|
-
}
|
|
5504
|
-
}
|
|
5505
|
-
return minRecord || null;
|
|
5506
|
-
};
|
|
5507
|
-
functionNotNull = (resolvedArgs) => {
|
|
5508
|
-
for (let i = 0;i < resolvedArgs.length; i += 1) {
|
|
5509
|
-
if (this.getTypeName(resolvedArgs[i]) !== 7) {
|
|
5510
|
-
return resolvedArgs[i];
|
|
4743
|
+
},
|
|
4744
|
+
_parseSliceExpression: function() {
|
|
4745
|
+
var parts = [null, null, null];
|
|
4746
|
+
var index = 0;
|
|
4747
|
+
var currentToken = this._lookahead(0);
|
|
4748
|
+
while (currentToken !== TOK_RBRACKET && index < 3) {
|
|
4749
|
+
if (currentToken === TOK_COLON) {
|
|
4750
|
+
index++;
|
|
4751
|
+
this._advance();
|
|
4752
|
+
} else if (currentToken === TOK_NUMBER) {
|
|
4753
|
+
parts[index] = this._lookaheadToken(0).value;
|
|
4754
|
+
this._advance();
|
|
4755
|
+
} else {
|
|
4756
|
+
var t = this._lookahead(0);
|
|
4757
|
+
var error = new Error("Syntax error, unexpected token: " + t.value + "(" + t.type + ")");
|
|
4758
|
+
error.name = "Parsererror";
|
|
4759
|
+
throw error;
|
|
4760
|
+
}
|
|
4761
|
+
currentToken = this._lookahead(0);
|
|
4762
|
+
}
|
|
4763
|
+
this._match(TOK_RBRACKET);
|
|
4764
|
+
return {
|
|
4765
|
+
type: "Slice",
|
|
4766
|
+
children: parts
|
|
4767
|
+
};
|
|
4768
|
+
},
|
|
4769
|
+
_parseComparator: function(left, comparator) {
|
|
4770
|
+
var right = this.expression(bindingPower[comparator]);
|
|
4771
|
+
return { type: "Comparator", name: comparator, children: [left, right] };
|
|
4772
|
+
},
|
|
4773
|
+
_parseDotRHS: function(rbp) {
|
|
4774
|
+
var lookahead = this._lookahead(0);
|
|
4775
|
+
var exprTokens = [TOK_UNQUOTEDIDENTIFIER, TOK_QUOTEDIDENTIFIER, TOK_STAR];
|
|
4776
|
+
if (exprTokens.indexOf(lookahead) >= 0) {
|
|
4777
|
+
return this.expression(rbp);
|
|
4778
|
+
} else if (lookahead === TOK_LBRACKET) {
|
|
4779
|
+
this._match(TOK_LBRACKET);
|
|
4780
|
+
return this._parseMultiselectList();
|
|
4781
|
+
} else if (lookahead === TOK_LBRACE) {
|
|
4782
|
+
this._match(TOK_LBRACE);
|
|
4783
|
+
return this._parseMultiselectHash();
|
|
4784
|
+
}
|
|
4785
|
+
},
|
|
4786
|
+
_parseProjectionRHS: function(rbp) {
|
|
4787
|
+
var right;
|
|
4788
|
+
if (bindingPower[this._lookahead(0)] < 10) {
|
|
4789
|
+
right = { type: "Identity" };
|
|
4790
|
+
} else if (this._lookahead(0) === TOK_LBRACKET) {
|
|
4791
|
+
right = this.expression(rbp);
|
|
4792
|
+
} else if (this._lookahead(0) === TOK_FILTER) {
|
|
4793
|
+
right = this.expression(rbp);
|
|
4794
|
+
} else if (this._lookahead(0) === TOK_DOT) {
|
|
4795
|
+
this._match(TOK_DOT);
|
|
4796
|
+
right = this._parseDotRHS(rbp);
|
|
4797
|
+
} else {
|
|
4798
|
+
var t = this._lookaheadToken(0);
|
|
4799
|
+
var error = new Error("Sytanx error, unexpected token: " + t.value + "(" + t.type + ")");
|
|
4800
|
+
error.name = "ParserError";
|
|
4801
|
+
throw error;
|
|
4802
|
+
}
|
|
4803
|
+
return right;
|
|
4804
|
+
},
|
|
4805
|
+
_parseMultiselectList: function() {
|
|
4806
|
+
var expressions = [];
|
|
4807
|
+
while (this._lookahead(0) !== TOK_RBRACKET) {
|
|
4808
|
+
var expression = this.expression(0);
|
|
4809
|
+
expressions.push(expression);
|
|
4810
|
+
if (this._lookahead(0) === TOK_COMMA) {
|
|
4811
|
+
this._match(TOK_COMMA);
|
|
4812
|
+
if (this._lookahead(0) === TOK_RBRACKET) {
|
|
4813
|
+
throw new Error("Unexpected token Rbracket");
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
this._match(TOK_RBRACKET);
|
|
4818
|
+
return { type: "MultiSelectList", children: expressions };
|
|
4819
|
+
},
|
|
4820
|
+
_parseMultiselectHash: function() {
|
|
4821
|
+
var pairs2 = [];
|
|
4822
|
+
var identifierTypes = [TOK_UNQUOTEDIDENTIFIER, TOK_QUOTEDIDENTIFIER];
|
|
4823
|
+
var keyToken, keyName, value, node;
|
|
4824
|
+
for (;; ) {
|
|
4825
|
+
keyToken = this._lookaheadToken(0);
|
|
4826
|
+
if (identifierTypes.indexOf(keyToken.type) < 0) {
|
|
4827
|
+
throw new Error("Expecting an identifier token, got: " + keyToken.type);
|
|
4828
|
+
}
|
|
4829
|
+
keyName = keyToken.value;
|
|
4830
|
+
this._advance();
|
|
4831
|
+
this._match(TOK_COLON);
|
|
4832
|
+
value = this.expression(0);
|
|
4833
|
+
node = { type: "KeyValuePair", name: keyName, value };
|
|
4834
|
+
pairs2.push(node);
|
|
4835
|
+
if (this._lookahead(0) === TOK_COMMA) {
|
|
4836
|
+
this._match(TOK_COMMA);
|
|
4837
|
+
} else if (this._lookahead(0) === TOK_RBRACE) {
|
|
4838
|
+
this._match(TOK_RBRACE);
|
|
4839
|
+
break;
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
return { type: "MultiSelectHash", children: pairs2 };
|
|
5511
4843
|
}
|
|
5512
|
-
}
|
|
5513
|
-
return null;
|
|
5514
|
-
};
|
|
5515
|
-
functionPadLeft = this.createPadFunction(padLeft);
|
|
5516
|
-
functionPadRight = this.createPadFunction(padRight);
|
|
5517
|
-
createPadFunction(padFn) {
|
|
5518
|
-
return (resolvedArgs) => {
|
|
5519
|
-
const subject = resolvedArgs[0];
|
|
5520
|
-
const width = resolvedArgs[1];
|
|
5521
|
-
const padding = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined;
|
|
5522
|
-
return padFn(subject, width, padding);
|
|
5523
4844
|
};
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
const subject = resolvedArgs[0];
|
|
5527
|
-
const string = resolvedArgs[1];
|
|
5528
|
-
const by = resolvedArgs[2];
|
|
5529
|
-
return replace(subject, string, by, resolvedArgs.length > 3 ? resolvedArgs[3] : undefined);
|
|
5530
|
-
};
|
|
5531
|
-
functionSplit = (resolvedArgs) => {
|
|
5532
|
-
const subject = resolvedArgs[0];
|
|
5533
|
-
const search2 = resolvedArgs[1];
|
|
5534
|
-
return split(subject, search2, resolvedArgs.length > 2 ? resolvedArgs[2] : undefined);
|
|
5535
|
-
};
|
|
5536
|
-
functionReverse = ([inputValue]) => {
|
|
5537
|
-
const typeName = this.getTypeName(inputValue);
|
|
5538
|
-
if (typeName === 2) {
|
|
5539
|
-
return new Text(inputValue).reverse();
|
|
5540
|
-
}
|
|
5541
|
-
const reversedArray = inputValue.slice(0);
|
|
5542
|
-
reversedArray.reverse();
|
|
5543
|
-
return reversedArray;
|
|
5544
|
-
};
|
|
5545
|
-
functionSort = ([inputValue]) => {
|
|
5546
|
-
if (inputValue.length == 0) {
|
|
5547
|
-
return inputValue;
|
|
5548
|
-
}
|
|
5549
|
-
if (typeof inputValue[0] === "string") {
|
|
5550
|
-
return [...inputValue].sort(Text.comparer);
|
|
5551
|
-
}
|
|
5552
|
-
return [...inputValue].sort();
|
|
5553
|
-
};
|
|
5554
|
-
functionSortBy = (resolvedArgs) => {
|
|
5555
|
-
const sortedArray = resolvedArgs[0].slice(0);
|
|
5556
|
-
if (sortedArray.length === 0) {
|
|
5557
|
-
return sortedArray;
|
|
5558
|
-
}
|
|
5559
|
-
const interpreter = this._interpreter;
|
|
5560
|
-
const exprefNode = resolvedArgs[1];
|
|
5561
|
-
const requiredType = this.getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
|
|
5562
|
-
if (requiredType !== undefined && ![0, 2].includes(requiredType)) {
|
|
5563
|
-
throw new Error(`Invalid type: unexpected type (${this.TYPE_NAME_TABLE[requiredType]})`);
|
|
5564
|
-
}
|
|
5565
|
-
function throwInvalidTypeError(rt, item) {
|
|
5566
|
-
throw new Error(`Invalid type: expected (${rt.TYPE_NAME_TABLE[requiredType]}), received ${rt.TYPE_NAME_TABLE[rt.getTypeName(item)]}`);
|
|
5567
|
-
}
|
|
5568
|
-
return sortedArray.sort((a, b) => {
|
|
5569
|
-
const exprA = interpreter.visit(exprefNode, a);
|
|
5570
|
-
const exprB = interpreter.visit(exprefNode, b);
|
|
5571
|
-
if (this.getTypeName(exprA) !== requiredType) {
|
|
5572
|
-
throwInvalidTypeError(this, exprA);
|
|
5573
|
-
} else if (this.getTypeName(exprB) !== requiredType) {
|
|
5574
|
-
throwInvalidTypeError(this, exprB);
|
|
5575
|
-
}
|
|
5576
|
-
if (requiredType === 2) {
|
|
5577
|
-
return Text.comparer(exprA, exprB);
|
|
5578
|
-
}
|
|
5579
|
-
return exprA - exprB;
|
|
5580
|
-
});
|
|
5581
|
-
};
|
|
5582
|
-
functionStartsWith = ([searchable, searchStr]) => {
|
|
5583
|
-
return searchable.startsWith(searchStr);
|
|
5584
|
-
};
|
|
5585
|
-
functionSum = ([inputValue]) => {
|
|
5586
|
-
return inputValue.reduce((x, y) => x + y, 0);
|
|
5587
|
-
};
|
|
5588
|
-
functionToArray = ([inputValue]) => {
|
|
5589
|
-
if (this.getTypeName(inputValue) === 3) {
|
|
5590
|
-
return inputValue;
|
|
4845
|
+
function TreeInterpreter(runtime) {
|
|
4846
|
+
this.runtime = runtime;
|
|
5591
4847
|
}
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
4848
|
+
TreeInterpreter.prototype = {
|
|
4849
|
+
search: function(node, value) {
|
|
4850
|
+
return this.visit(node, value);
|
|
4851
|
+
},
|
|
4852
|
+
visit: function(node, value) {
|
|
4853
|
+
var matched, current, result, first, second, field, left, right, collected, i;
|
|
4854
|
+
switch (node.type) {
|
|
4855
|
+
case "Field":
|
|
4856
|
+
if (value !== null && isObject(value)) {
|
|
4857
|
+
field = value[node.name];
|
|
4858
|
+
if (field === undefined) {
|
|
4859
|
+
return null;
|
|
4860
|
+
} else {
|
|
4861
|
+
return field;
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
return null;
|
|
4865
|
+
case "Subexpression":
|
|
4866
|
+
result = this.visit(node.children[0], value);
|
|
4867
|
+
for (i = 1;i < node.children.length; i++) {
|
|
4868
|
+
result = this.visit(node.children[1], result);
|
|
4869
|
+
if (result === null) {
|
|
4870
|
+
return null;
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
return result;
|
|
4874
|
+
case "IndexExpression":
|
|
4875
|
+
left = this.visit(node.children[0], value);
|
|
4876
|
+
right = this.visit(node.children[1], left);
|
|
4877
|
+
return right;
|
|
4878
|
+
case "Index":
|
|
4879
|
+
if (!isArray(value)) {
|
|
4880
|
+
return null;
|
|
4881
|
+
}
|
|
4882
|
+
var index = node.value;
|
|
4883
|
+
if (index < 0) {
|
|
4884
|
+
index = value.length + index;
|
|
4885
|
+
}
|
|
4886
|
+
result = value[index];
|
|
4887
|
+
if (result === undefined) {
|
|
4888
|
+
result = null;
|
|
4889
|
+
}
|
|
4890
|
+
return result;
|
|
4891
|
+
case "Slice":
|
|
4892
|
+
if (!isArray(value)) {
|
|
4893
|
+
return null;
|
|
4894
|
+
}
|
|
4895
|
+
var sliceParams = node.children.slice(0);
|
|
4896
|
+
var computed = this.computeSliceParams(value.length, sliceParams);
|
|
4897
|
+
var start = computed[0];
|
|
4898
|
+
var stop = computed[1];
|
|
4899
|
+
var step = computed[2];
|
|
4900
|
+
result = [];
|
|
4901
|
+
if (step > 0) {
|
|
4902
|
+
for (i = start;i < stop; i += step) {
|
|
4903
|
+
result.push(value[i]);
|
|
4904
|
+
}
|
|
4905
|
+
} else {
|
|
4906
|
+
for (i = start;i > stop; i += step) {
|
|
4907
|
+
result.push(value[i]);
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
return result;
|
|
4911
|
+
case "Projection":
|
|
4912
|
+
var base = this.visit(node.children[0], value);
|
|
4913
|
+
if (!isArray(base)) {
|
|
4914
|
+
return null;
|
|
4915
|
+
}
|
|
4916
|
+
collected = [];
|
|
4917
|
+
for (i = 0;i < base.length; i++) {
|
|
4918
|
+
current = this.visit(node.children[1], base[i]);
|
|
4919
|
+
if (current !== null) {
|
|
4920
|
+
collected.push(current);
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
return collected;
|
|
4924
|
+
case "ValueProjection":
|
|
4925
|
+
base = this.visit(node.children[0], value);
|
|
4926
|
+
if (!isObject(base)) {
|
|
4927
|
+
return null;
|
|
4928
|
+
}
|
|
4929
|
+
collected = [];
|
|
4930
|
+
var values = objValues(base);
|
|
4931
|
+
for (i = 0;i < values.length; i++) {
|
|
4932
|
+
current = this.visit(node.children[1], values[i]);
|
|
4933
|
+
if (current !== null) {
|
|
4934
|
+
collected.push(current);
|
|
4935
|
+
}
|
|
4936
|
+
}
|
|
4937
|
+
return collected;
|
|
4938
|
+
case "FilterProjection":
|
|
4939
|
+
base = this.visit(node.children[0], value);
|
|
4940
|
+
if (!isArray(base)) {
|
|
4941
|
+
return null;
|
|
4942
|
+
}
|
|
4943
|
+
var filtered = [];
|
|
4944
|
+
var finalResults = [];
|
|
4945
|
+
for (i = 0;i < base.length; i++) {
|
|
4946
|
+
matched = this.visit(node.children[2], base[i]);
|
|
4947
|
+
if (!isFalse(matched)) {
|
|
4948
|
+
filtered.push(base[i]);
|
|
4949
|
+
}
|
|
4950
|
+
}
|
|
4951
|
+
for (var j = 0;j < filtered.length; j++) {
|
|
4952
|
+
current = this.visit(node.children[1], filtered[j]);
|
|
4953
|
+
if (current !== null) {
|
|
4954
|
+
finalResults.push(current);
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
return finalResults;
|
|
4958
|
+
case "Comparator":
|
|
4959
|
+
first = this.visit(node.children[0], value);
|
|
4960
|
+
second = this.visit(node.children[1], value);
|
|
4961
|
+
switch (node.name) {
|
|
4962
|
+
case TOK_EQ:
|
|
4963
|
+
result = strictDeepEqual(first, second);
|
|
4964
|
+
break;
|
|
4965
|
+
case TOK_NE:
|
|
4966
|
+
result = !strictDeepEqual(first, second);
|
|
4967
|
+
break;
|
|
4968
|
+
case TOK_GT:
|
|
4969
|
+
result = first > second;
|
|
4970
|
+
break;
|
|
4971
|
+
case TOK_GTE:
|
|
4972
|
+
result = first >= second;
|
|
4973
|
+
break;
|
|
4974
|
+
case TOK_LT:
|
|
4975
|
+
result = first < second;
|
|
4976
|
+
break;
|
|
4977
|
+
case TOK_LTE:
|
|
4978
|
+
result = first <= second;
|
|
4979
|
+
break;
|
|
4980
|
+
default:
|
|
4981
|
+
throw new Error("Unknown comparator: " + node.name);
|
|
4982
|
+
}
|
|
4983
|
+
return result;
|
|
4984
|
+
case TOK_FLATTEN:
|
|
4985
|
+
var original = this.visit(node.children[0], value);
|
|
4986
|
+
if (!isArray(original)) {
|
|
4987
|
+
return null;
|
|
4988
|
+
}
|
|
4989
|
+
var merged = [];
|
|
4990
|
+
for (i = 0;i < original.length; i++) {
|
|
4991
|
+
current = original[i];
|
|
4992
|
+
if (isArray(current)) {
|
|
4993
|
+
merged.push.apply(merged, current);
|
|
4994
|
+
} else {
|
|
4995
|
+
merged.push(current);
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4998
|
+
return merged;
|
|
4999
|
+
case "Identity":
|
|
5000
|
+
return value;
|
|
5001
|
+
case "MultiSelectList":
|
|
5002
|
+
if (value === null) {
|
|
5003
|
+
return null;
|
|
5004
|
+
}
|
|
5005
|
+
collected = [];
|
|
5006
|
+
for (i = 0;i < node.children.length; i++) {
|
|
5007
|
+
collected.push(this.visit(node.children[i], value));
|
|
5008
|
+
}
|
|
5009
|
+
return collected;
|
|
5010
|
+
case "MultiSelectHash":
|
|
5011
|
+
if (value === null) {
|
|
5012
|
+
return null;
|
|
5013
|
+
}
|
|
5014
|
+
collected = {};
|
|
5015
|
+
var child;
|
|
5016
|
+
for (i = 0;i < node.children.length; i++) {
|
|
5017
|
+
child = node.children[i];
|
|
5018
|
+
collected[child.name] = this.visit(child.value, value);
|
|
5019
|
+
}
|
|
5020
|
+
return collected;
|
|
5021
|
+
case "OrExpression":
|
|
5022
|
+
matched = this.visit(node.children[0], value);
|
|
5023
|
+
if (isFalse(matched)) {
|
|
5024
|
+
matched = this.visit(node.children[1], value);
|
|
5025
|
+
}
|
|
5026
|
+
return matched;
|
|
5027
|
+
case "AndExpression":
|
|
5028
|
+
first = this.visit(node.children[0], value);
|
|
5029
|
+
if (isFalse(first) === true) {
|
|
5030
|
+
return first;
|
|
5031
|
+
}
|
|
5032
|
+
return this.visit(node.children[1], value);
|
|
5033
|
+
case "NotExpression":
|
|
5034
|
+
first = this.visit(node.children[0], value);
|
|
5035
|
+
return isFalse(first);
|
|
5036
|
+
case "Literal":
|
|
5037
|
+
return node.value;
|
|
5038
|
+
case TOK_PIPE:
|
|
5039
|
+
left = this.visit(node.children[0], value);
|
|
5040
|
+
return this.visit(node.children[1], left);
|
|
5041
|
+
case TOK_CURRENT:
|
|
5042
|
+
return value;
|
|
5043
|
+
case "Function":
|
|
5044
|
+
var resolvedArgs = [];
|
|
5045
|
+
for (i = 0;i < node.children.length; i++) {
|
|
5046
|
+
resolvedArgs.push(this.visit(node.children[i], value));
|
|
5047
|
+
}
|
|
5048
|
+
return this.runtime.callFunction(node.name, resolvedArgs);
|
|
5049
|
+
case "ExpressionReference":
|
|
5050
|
+
var refNode = node.children[0];
|
|
5051
|
+
refNode.jmespathType = TOK_EXPREF;
|
|
5052
|
+
return refNode;
|
|
5053
|
+
default:
|
|
5054
|
+
throw new Error("Unknown node type: " + node.type);
|
|
5055
|
+
}
|
|
5056
|
+
},
|
|
5057
|
+
computeSliceParams: function(arrayLength, sliceParams) {
|
|
5058
|
+
var start = sliceParams[0];
|
|
5059
|
+
var stop = sliceParams[1];
|
|
5060
|
+
var step = sliceParams[2];
|
|
5061
|
+
var computed = [null, null, null];
|
|
5062
|
+
if (step === null) {
|
|
5063
|
+
step = 1;
|
|
5064
|
+
} else if (step === 0) {
|
|
5065
|
+
var error = new Error("Invalid slice, step cannot be 0");
|
|
5066
|
+
error.name = "RuntimeError";
|
|
5067
|
+
throw error;
|
|
5068
|
+
}
|
|
5069
|
+
var stepValueNegative = step < 0 ? true : false;
|
|
5070
|
+
if (start === null) {
|
|
5071
|
+
start = stepValueNegative ? arrayLength - 1 : 0;
|
|
5072
|
+
} else {
|
|
5073
|
+
start = this.capSliceRange(arrayLength, start, step);
|
|
5074
|
+
}
|
|
5075
|
+
if (stop === null) {
|
|
5076
|
+
stop = stepValueNegative ? -1 : arrayLength;
|
|
5077
|
+
} else {
|
|
5078
|
+
stop = this.capSliceRange(arrayLength, stop, step);
|
|
5079
|
+
}
|
|
5080
|
+
computed[0] = start;
|
|
5081
|
+
computed[1] = stop;
|
|
5082
|
+
computed[2] = step;
|
|
5083
|
+
return computed;
|
|
5084
|
+
},
|
|
5085
|
+
capSliceRange: function(arrayLength, actualValue, step) {
|
|
5086
|
+
if (actualValue < 0) {
|
|
5087
|
+
actualValue += arrayLength;
|
|
5088
|
+
if (actualValue < 0) {
|
|
5089
|
+
actualValue = step < 0 ? -1 : 0;
|
|
5090
|
+
}
|
|
5091
|
+
} else if (actualValue >= arrayLength) {
|
|
5092
|
+
actualValue = step < 0 ? arrayLength - 1 : arrayLength;
|
|
5093
|
+
}
|
|
5094
|
+
return actualValue;
|
|
5604
5095
|
}
|
|
5605
|
-
}
|
|
5606
|
-
return null;
|
|
5607
|
-
};
|
|
5608
|
-
functionToString = ([inputValue]) => {
|
|
5609
|
-
if (this.getTypeName(inputValue) === 2) {
|
|
5610
|
-
return inputValue;
|
|
5611
|
-
}
|
|
5612
|
-
return JSON.stringify(inputValue);
|
|
5613
|
-
};
|
|
5614
|
-
functionTrim = this.createTrimFunction(trim);
|
|
5615
|
-
functionTrimLeft = this.createTrimFunction(trimLeft);
|
|
5616
|
-
functionTrimRight = this.createTrimFunction(trimRight);
|
|
5617
|
-
createTrimFunction(trimFn) {
|
|
5618
|
-
return (resolvedArgs) => {
|
|
5619
|
-
const subject = resolvedArgs[0];
|
|
5620
|
-
const chars = resolvedArgs.length > 1 ? resolvedArgs[1] : undefined;
|
|
5621
|
-
return trimFn(subject, chars);
|
|
5622
5096
|
};
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
},
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5097
|
+
function Runtime(interpreter) {
|
|
5098
|
+
this._interpreter = interpreter;
|
|
5099
|
+
this.functionTable = {
|
|
5100
|
+
abs: { _func: this._functionAbs, _signature: [{ types: [TYPE_NUMBER] }] },
|
|
5101
|
+
avg: { _func: this._functionAvg, _signature: [{ types: [TYPE_ARRAY_NUMBER] }] },
|
|
5102
|
+
ceil: { _func: this._functionCeil, _signature: [{ types: [TYPE_NUMBER] }] },
|
|
5103
|
+
contains: {
|
|
5104
|
+
_func: this._functionContains,
|
|
5105
|
+
_signature: [
|
|
5106
|
+
{ types: [TYPE_STRING, TYPE_ARRAY] },
|
|
5107
|
+
{ types: [TYPE_ANY] }
|
|
5108
|
+
]
|
|
5109
|
+
},
|
|
5110
|
+
ends_with: {
|
|
5111
|
+
_func: this._functionEndsWith,
|
|
5112
|
+
_signature: [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }]
|
|
5113
|
+
},
|
|
5114
|
+
floor: { _func: this._functionFloor, _signature: [{ types: [TYPE_NUMBER] }] },
|
|
5115
|
+
length: {
|
|
5116
|
+
_func: this._functionLength,
|
|
5117
|
+
_signature: [{ types: [TYPE_STRING, TYPE_ARRAY, TYPE_OBJECT] }]
|
|
5118
|
+
},
|
|
5119
|
+
map: {
|
|
5120
|
+
_func: this._functionMap,
|
|
5121
|
+
_signature: [{ types: [TYPE_EXPREF] }, { types: [TYPE_ARRAY] }]
|
|
5122
|
+
},
|
|
5123
|
+
max: {
|
|
5124
|
+
_func: this._functionMax,
|
|
5125
|
+
_signature: [{ types: [TYPE_ARRAY_NUMBER, TYPE_ARRAY_STRING] }]
|
|
5126
|
+
},
|
|
5127
|
+
merge: {
|
|
5128
|
+
_func: this._functionMerge,
|
|
5129
|
+
_signature: [{ types: [TYPE_OBJECT], variadic: true }]
|
|
5130
|
+
},
|
|
5131
|
+
max_by: {
|
|
5132
|
+
_func: this._functionMaxBy,
|
|
5133
|
+
_signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
|
|
5134
|
+
},
|
|
5135
|
+
sum: { _func: this._functionSum, _signature: [{ types: [TYPE_ARRAY_NUMBER] }] },
|
|
5136
|
+
starts_with: {
|
|
5137
|
+
_func: this._functionStartsWith,
|
|
5138
|
+
_signature: [{ types: [TYPE_STRING] }, { types: [TYPE_STRING] }]
|
|
5139
|
+
},
|
|
5140
|
+
min: {
|
|
5141
|
+
_func: this._functionMin,
|
|
5142
|
+
_signature: [{ types: [TYPE_ARRAY_NUMBER, TYPE_ARRAY_STRING] }]
|
|
5143
|
+
},
|
|
5144
|
+
min_by: {
|
|
5145
|
+
_func: this._functionMinBy,
|
|
5146
|
+
_signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
|
|
5147
|
+
},
|
|
5148
|
+
type: { _func: this._functionType, _signature: [{ types: [TYPE_ANY] }] },
|
|
5149
|
+
keys: { _func: this._functionKeys, _signature: [{ types: [TYPE_OBJECT] }] },
|
|
5150
|
+
values: { _func: this._functionValues, _signature: [{ types: [TYPE_OBJECT] }] },
|
|
5151
|
+
sort: { _func: this._functionSort, _signature: [{ types: [TYPE_ARRAY_STRING, TYPE_ARRAY_NUMBER] }] },
|
|
5152
|
+
sort_by: {
|
|
5153
|
+
_func: this._functionSortBy,
|
|
5154
|
+
_signature: [{ types: [TYPE_ARRAY] }, { types: [TYPE_EXPREF] }]
|
|
5155
|
+
},
|
|
5156
|
+
join: {
|
|
5157
|
+
_func: this._functionJoin,
|
|
5158
|
+
_signature: [
|
|
5159
|
+
{ types: [TYPE_STRING] },
|
|
5160
|
+
{ types: [TYPE_ARRAY_STRING] }
|
|
5161
|
+
]
|
|
5162
|
+
},
|
|
5163
|
+
reverse: {
|
|
5164
|
+
_func: this._functionReverse,
|
|
5165
|
+
_signature: [{ types: [TYPE_STRING, TYPE_ARRAY] }]
|
|
5166
|
+
},
|
|
5167
|
+
to_array: { _func: this._functionToArray, _signature: [{ types: [TYPE_ANY] }] },
|
|
5168
|
+
to_string: { _func: this._functionToString, _signature: [{ types: [TYPE_ANY] }] },
|
|
5169
|
+
to_number: { _func: this._functionToNumber, _signature: [{ types: [TYPE_ANY] }] },
|
|
5170
|
+
not_null: {
|
|
5171
|
+
_func: this._functionNotNull,
|
|
5172
|
+
_signature: [{ types: [TYPE_ANY], variadic: true }]
|
|
5173
|
+
}
|
|
5174
|
+
};
|
|
5665
5175
|
}
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
_scope;
|
|
5672
|
-
constructor() {
|
|
5673
|
-
this.runtime = new Runtime(this);
|
|
5674
|
-
this._scope = new ScopeChain;
|
|
5675
|
-
}
|
|
5676
|
-
withScope(scope) {
|
|
5677
|
-
const interpreter = new _TreeInterpreter;
|
|
5678
|
-
interpreter.runtime._functionTable = this.runtime._functionTable;
|
|
5679
|
-
interpreter._rootValue = this._rootValue;
|
|
5680
|
-
interpreter._scope = this._scope.withScope(scope);
|
|
5681
|
-
return interpreter;
|
|
5682
|
-
}
|
|
5683
|
-
search(node, value) {
|
|
5684
|
-
this._rootValue = value;
|
|
5685
|
-
this._scope = emptyScopeChain;
|
|
5686
|
-
return this.visit(node, value);
|
|
5687
|
-
}
|
|
5688
|
-
visit(node, value) {
|
|
5689
|
-
switch (node.type) {
|
|
5690
|
-
case "Ternary": {
|
|
5691
|
-
const condition = this.visit(node.condition, value);
|
|
5692
|
-
if (!isFalse(condition)) {
|
|
5693
|
-
return this.visit(node.trueExpr, value);
|
|
5176
|
+
Runtime.prototype = {
|
|
5177
|
+
callFunction: function(name, resolvedArgs) {
|
|
5178
|
+
var functionEntry = this.functionTable[name];
|
|
5179
|
+
if (functionEntry === undefined) {
|
|
5180
|
+
throw new Error("Unknown function: " + name + "()");
|
|
5694
5181
|
}
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5182
|
+
this._validateArgs(name, resolvedArgs, functionEntry._signature);
|
|
5183
|
+
return functionEntry._func.call(this, resolvedArgs);
|
|
5184
|
+
},
|
|
5185
|
+
_validateArgs: function(name, args, signature) {
|
|
5186
|
+
var pluralized;
|
|
5187
|
+
if (signature[signature.length - 1].variadic) {
|
|
5188
|
+
if (args.length < signature.length) {
|
|
5189
|
+
pluralized = signature.length === 1 ? " argument" : " arguments";
|
|
5190
|
+
throw new Error("ArgumentError: " + name + "() " + "takes at least" + signature.length + pluralized + " but received " + args.length);
|
|
5191
|
+
}
|
|
5192
|
+
} else if (args.length !== signature.length) {
|
|
5193
|
+
pluralized = signature.length === 1 ? " argument" : " arguments";
|
|
5194
|
+
throw new Error("ArgumentError: " + name + "() " + "takes " + signature.length + pluralized + " but received " + args.length);
|
|
5701
5195
|
}
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
const variable = node.name;
|
|
5722
|
-
if (!this._scope.getValue(variable) && !Object.prototype.hasOwnProperty.call(this._scope.currentScopeData, variable)) {
|
|
5723
|
-
throw new Error(`Error referencing undefined variable ${variable}`);
|
|
5196
|
+
var currentSpec;
|
|
5197
|
+
var actualType;
|
|
5198
|
+
var typeMatched;
|
|
5199
|
+
for (var i = 0;i < signature.length; i++) {
|
|
5200
|
+
typeMatched = false;
|
|
5201
|
+
currentSpec = signature[i].types;
|
|
5202
|
+
actualType = this._getTypeName(args[i]);
|
|
5203
|
+
for (var j = 0;j < currentSpec.length; j++) {
|
|
5204
|
+
if (this._typeMatches(actualType, currentSpec[j], args[i])) {
|
|
5205
|
+
typeMatched = true;
|
|
5206
|
+
break;
|
|
5207
|
+
}
|
|
5208
|
+
}
|
|
5209
|
+
if (!typeMatched) {
|
|
5210
|
+
var expected = currentSpec.map(function(typeIdentifier) {
|
|
5211
|
+
return TYPE_NAME_TABLE[typeIdentifier];
|
|
5212
|
+
}).join(",");
|
|
5213
|
+
throw new Error("TypeError: " + name + "() " + "expected argument " + (i + 1) + " to be type " + expected + " but received type " + TYPE_NAME_TABLE[actualType] + " instead.");
|
|
5214
|
+
}
|
|
5724
5215
|
}
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
case "Subexpression": {
|
|
5730
|
-
const result = this.visit(node.left, value);
|
|
5731
|
-
return result != null ? this.visit(node.right, result) ?? null : null;
|
|
5732
|
-
}
|
|
5733
|
-
case "Index": {
|
|
5734
|
-
if (!Array.isArray(value)) {
|
|
5735
|
-
return null;
|
|
5216
|
+
},
|
|
5217
|
+
_typeMatches: function(actual, expected, argValue) {
|
|
5218
|
+
if (expected === TYPE_ANY) {
|
|
5219
|
+
return true;
|
|
5736
5220
|
}
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5221
|
+
if (expected === TYPE_ARRAY_STRING || expected === TYPE_ARRAY_NUMBER || expected === TYPE_ARRAY) {
|
|
5222
|
+
if (expected === TYPE_ARRAY) {
|
|
5223
|
+
return actual === TYPE_ARRAY;
|
|
5224
|
+
} else if (actual === TYPE_ARRAY) {
|
|
5225
|
+
var subtype;
|
|
5226
|
+
if (expected === TYPE_ARRAY_NUMBER) {
|
|
5227
|
+
subtype = TYPE_NUMBER;
|
|
5228
|
+
} else if (expected === TYPE_ARRAY_STRING) {
|
|
5229
|
+
subtype = TYPE_STRING;
|
|
5230
|
+
}
|
|
5231
|
+
for (var i = 0;i < argValue.length; i++) {
|
|
5232
|
+
if (!this._typeMatches(this._getTypeName(argValue[i]), subtype, argValue[i])) {
|
|
5233
|
+
return false;
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
return true;
|
|
5237
|
+
}
|
|
5238
|
+
} else {
|
|
5239
|
+
return actual === expected;
|
|
5240
|
+
}
|
|
5241
|
+
},
|
|
5242
|
+
_getTypeName: function(obj) {
|
|
5243
|
+
switch (Object.prototype.toString.call(obj)) {
|
|
5244
|
+
case "[object String]":
|
|
5245
|
+
return TYPE_STRING;
|
|
5246
|
+
case "[object Number]":
|
|
5247
|
+
return TYPE_NUMBER;
|
|
5248
|
+
case "[object Array]":
|
|
5249
|
+
return TYPE_ARRAY;
|
|
5250
|
+
case "[object Boolean]":
|
|
5251
|
+
return TYPE_BOOLEAN;
|
|
5252
|
+
case "[object Null]":
|
|
5253
|
+
return TYPE_NULL;
|
|
5254
|
+
case "[object Object]":
|
|
5255
|
+
if (obj.jmespathType === TOK_EXPREF) {
|
|
5256
|
+
return TYPE_EXPREF;
|
|
5257
|
+
} else {
|
|
5258
|
+
return TYPE_OBJECT;
|
|
5259
|
+
}
|
|
5743
5260
|
}
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5261
|
+
},
|
|
5262
|
+
_functionStartsWith: function(resolvedArgs) {
|
|
5263
|
+
return resolvedArgs[0].lastIndexOf(resolvedArgs[1]) === 0;
|
|
5264
|
+
},
|
|
5265
|
+
_functionEndsWith: function(resolvedArgs) {
|
|
5266
|
+
var searchStr = resolvedArgs[0];
|
|
5267
|
+
var suffix = resolvedArgs[1];
|
|
5268
|
+
return searchStr.indexOf(suffix, searchStr.length - suffix.length) !== -1;
|
|
5269
|
+
},
|
|
5270
|
+
_functionReverse: function(resolvedArgs) {
|
|
5271
|
+
var typeName = this._getTypeName(resolvedArgs[0]);
|
|
5272
|
+
if (typeName === TYPE_STRING) {
|
|
5273
|
+
var originalStr = resolvedArgs[0];
|
|
5274
|
+
var reversedStr = "";
|
|
5275
|
+
for (var i = originalStr.length - 1;i >= 0; i--) {
|
|
5276
|
+
reversedStr += originalStr[i];
|
|
5277
|
+
}
|
|
5278
|
+
return reversedStr;
|
|
5749
5279
|
} else {
|
|
5750
|
-
|
|
5280
|
+
var reversedArray = resolvedArgs[0].slice(0);
|
|
5281
|
+
reversedArray.reverse();
|
|
5282
|
+
return reversedArray;
|
|
5751
5283
|
}
|
|
5752
|
-
}
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5284
|
+
},
|
|
5285
|
+
_functionAbs: function(resolvedArgs) {
|
|
5286
|
+
return Math.abs(resolvedArgs[0]);
|
|
5287
|
+
},
|
|
5288
|
+
_functionCeil: function(resolvedArgs) {
|
|
5289
|
+
return Math.ceil(resolvedArgs[0]);
|
|
5290
|
+
},
|
|
5291
|
+
_functionAvg: function(resolvedArgs) {
|
|
5292
|
+
var sum = 0;
|
|
5293
|
+
var inputArray = resolvedArgs[0];
|
|
5294
|
+
for (var i = 0;i < inputArray.length; i++) {
|
|
5295
|
+
sum += inputArray[i];
|
|
5758
5296
|
}
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5297
|
+
return sum / inputArray.length;
|
|
5298
|
+
},
|
|
5299
|
+
_functionContains: function(resolvedArgs) {
|
|
5300
|
+
return resolvedArgs[0].indexOf(resolvedArgs[1]) >= 0;
|
|
5301
|
+
},
|
|
5302
|
+
_functionFloor: function(resolvedArgs) {
|
|
5303
|
+
return Math.floor(resolvedArgs[0]);
|
|
5304
|
+
},
|
|
5305
|
+
_functionLength: function(resolvedArgs) {
|
|
5306
|
+
if (!isObject(resolvedArgs[0])) {
|
|
5307
|
+
return resolvedArgs[0].length;
|
|
5308
|
+
} else {
|
|
5309
|
+
return Object.keys(resolvedArgs[0]).length;
|
|
5762
5310
|
}
|
|
5763
|
-
|
|
5764
|
-
|
|
5311
|
+
},
|
|
5312
|
+
_functionMap: function(resolvedArgs) {
|
|
5313
|
+
var mapped = [];
|
|
5314
|
+
var interpreter = this._interpreter;
|
|
5315
|
+
var exprefNode = resolvedArgs[0];
|
|
5316
|
+
var elements = resolvedArgs[1];
|
|
5317
|
+
for (var i = 0;i < elements.length; i++) {
|
|
5318
|
+
mapped.push(interpreter.visit(exprefNode, elements[i]));
|
|
5765
5319
|
}
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5320
|
+
return mapped;
|
|
5321
|
+
},
|
|
5322
|
+
_functionMerge: function(resolvedArgs) {
|
|
5323
|
+
var merged = {};
|
|
5324
|
+
for (var i = 0;i < resolvedArgs.length; i++) {
|
|
5325
|
+
var current = resolvedArgs[i];
|
|
5326
|
+
for (var key in current) {
|
|
5327
|
+
merged[key] = current[key];
|
|
5771
5328
|
}
|
|
5772
5329
|
}
|
|
5773
|
-
return
|
|
5774
|
-
}
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5330
|
+
return merged;
|
|
5331
|
+
},
|
|
5332
|
+
_functionMax: function(resolvedArgs) {
|
|
5333
|
+
if (resolvedArgs[0].length > 0) {
|
|
5334
|
+
var typeName = this._getTypeName(resolvedArgs[0][0]);
|
|
5335
|
+
if (typeName === TYPE_NUMBER) {
|
|
5336
|
+
return Math.max.apply(Math, resolvedArgs[0]);
|
|
5337
|
+
} else {
|
|
5338
|
+
var elements = resolvedArgs[0];
|
|
5339
|
+
var maxElement = elements[0];
|
|
5340
|
+
for (var i = 1;i < elements.length; i++) {
|
|
5341
|
+
if (maxElement.localeCompare(elements[i]) < 0) {
|
|
5342
|
+
maxElement = elements[i];
|
|
5343
|
+
}
|
|
5344
|
+
}
|
|
5345
|
+
return maxElement;
|
|
5346
|
+
}
|
|
5347
|
+
} else {
|
|
5779
5348
|
return null;
|
|
5780
5349
|
}
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
if (
|
|
5786
|
-
|
|
5350
|
+
},
|
|
5351
|
+
_functionMin: function(resolvedArgs) {
|
|
5352
|
+
if (resolvedArgs[0].length > 0) {
|
|
5353
|
+
var typeName = this._getTypeName(resolvedArgs[0][0]);
|
|
5354
|
+
if (typeName === TYPE_NUMBER) {
|
|
5355
|
+
return Math.min.apply(Math, resolvedArgs[0]);
|
|
5356
|
+
} else {
|
|
5357
|
+
var elements = resolvedArgs[0];
|
|
5358
|
+
var minElement = elements[0];
|
|
5359
|
+
for (var i = 1;i < elements.length; i++) {
|
|
5360
|
+
if (elements[i].localeCompare(minElement) < 0) {
|
|
5361
|
+
minElement = elements[i];
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
5364
|
+
return minElement;
|
|
5787
5365
|
}
|
|
5788
|
-
}
|
|
5789
|
-
return collected;
|
|
5790
|
-
}
|
|
5791
|
-
case "FilterProjection": {
|
|
5792
|
-
const { left, right, condition } = node;
|
|
5793
|
-
const base = this.visit(left, value);
|
|
5794
|
-
if (!Array.isArray(base)) {
|
|
5366
|
+
} else {
|
|
5795
5367
|
return null;
|
|
5796
5368
|
}
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
const result = this.visit(right, elem);
|
|
5804
|
-
if (result !== null) {
|
|
5805
|
-
results.push(result);
|
|
5806
|
-
}
|
|
5369
|
+
},
|
|
5370
|
+
_functionSum: function(resolvedArgs) {
|
|
5371
|
+
var sum = 0;
|
|
5372
|
+
var listToSum = resolvedArgs[0];
|
|
5373
|
+
for (var i = 0;i < listToSum.length; i++) {
|
|
5374
|
+
sum += listToSum[i];
|
|
5807
5375
|
}
|
|
5808
|
-
return
|
|
5809
|
-
}
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
case
|
|
5815
|
-
return
|
|
5816
|
-
case
|
|
5817
|
-
return
|
|
5818
|
-
case
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
return div(first, second);
|
|
5827
|
-
default:
|
|
5828
|
-
throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`);
|
|
5376
|
+
return sum;
|
|
5377
|
+
},
|
|
5378
|
+
_functionType: function(resolvedArgs) {
|
|
5379
|
+
switch (this._getTypeName(resolvedArgs[0])) {
|
|
5380
|
+
case TYPE_NUMBER:
|
|
5381
|
+
return "number";
|
|
5382
|
+
case TYPE_STRING:
|
|
5383
|
+
return "string";
|
|
5384
|
+
case TYPE_ARRAY:
|
|
5385
|
+
return "array";
|
|
5386
|
+
case TYPE_OBJECT:
|
|
5387
|
+
return "object";
|
|
5388
|
+
case TYPE_BOOLEAN:
|
|
5389
|
+
return "boolean";
|
|
5390
|
+
case TYPE_EXPREF:
|
|
5391
|
+
return "expref";
|
|
5392
|
+
case TYPE_NULL:
|
|
5393
|
+
return "null";
|
|
5829
5394
|
}
|
|
5830
|
-
}
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
default:
|
|
5841
|
-
throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`);
|
|
5395
|
+
},
|
|
5396
|
+
_functionKeys: function(resolvedArgs) {
|
|
5397
|
+
return Object.keys(resolvedArgs[0]);
|
|
5398
|
+
},
|
|
5399
|
+
_functionValues: function(resolvedArgs) {
|
|
5400
|
+
var obj = resolvedArgs[0];
|
|
5401
|
+
var keys = Object.keys(obj);
|
|
5402
|
+
var values = [];
|
|
5403
|
+
for (var i = 0;i < keys.length; i++) {
|
|
5404
|
+
values.push(obj[keys[i]]);
|
|
5842
5405
|
}
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5406
|
+
return values;
|
|
5407
|
+
},
|
|
5408
|
+
_functionJoin: function(resolvedArgs) {
|
|
5409
|
+
var joinChar = resolvedArgs[0];
|
|
5410
|
+
var listJoin = resolvedArgs[1];
|
|
5411
|
+
return listJoin.join(joinChar);
|
|
5412
|
+
},
|
|
5413
|
+
_functionToArray: function(resolvedArgs) {
|
|
5414
|
+
if (this._getTypeName(resolvedArgs[0]) === TYPE_ARRAY) {
|
|
5415
|
+
return resolvedArgs[0];
|
|
5416
|
+
} else {
|
|
5417
|
+
return [resolvedArgs[0]];
|
|
5852
5418
|
}
|
|
5853
|
-
|
|
5854
|
-
|
|
5419
|
+
},
|
|
5420
|
+
_functionToString: function(resolvedArgs) {
|
|
5421
|
+
if (this._getTypeName(resolvedArgs[0]) === TYPE_STRING) {
|
|
5422
|
+
return resolvedArgs[0];
|
|
5423
|
+
} else {
|
|
5424
|
+
return JSON.stringify(resolvedArgs[0]);
|
|
5855
5425
|
}
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5426
|
+
},
|
|
5427
|
+
_functionToNumber: function(resolvedArgs) {
|
|
5428
|
+
var typeName = this._getTypeName(resolvedArgs[0]);
|
|
5429
|
+
var convertedValue;
|
|
5430
|
+
if (typeName === TYPE_NUMBER) {
|
|
5431
|
+
return resolvedArgs[0];
|
|
5432
|
+
} else if (typeName === TYPE_STRING) {
|
|
5433
|
+
convertedValue = +resolvedArgs[0];
|
|
5434
|
+
if (!isNaN(convertedValue)) {
|
|
5435
|
+
return convertedValue;
|
|
5436
|
+
}
|
|
5865
5437
|
}
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
case "MultiSelectList": {
|
|
5874
|
-
const collected = [];
|
|
5875
|
-
for (const child of node.children) {
|
|
5876
|
-
collected.push(this.visit(child, value));
|
|
5438
|
+
return null;
|
|
5439
|
+
},
|
|
5440
|
+
_functionNotNull: function(resolvedArgs) {
|
|
5441
|
+
for (var i = 0;i < resolvedArgs.length; i++) {
|
|
5442
|
+
if (this._getTypeName(resolvedArgs[i]) !== TYPE_NULL) {
|
|
5443
|
+
return resolvedArgs[i];
|
|
5444
|
+
}
|
|
5877
5445
|
}
|
|
5878
|
-
return
|
|
5879
|
-
}
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5446
|
+
return null;
|
|
5447
|
+
},
|
|
5448
|
+
_functionSort: function(resolvedArgs) {
|
|
5449
|
+
var sortedArray = resolvedArgs[0].slice(0);
|
|
5450
|
+
sortedArray.sort();
|
|
5451
|
+
return sortedArray;
|
|
5452
|
+
},
|
|
5453
|
+
_functionSortBy: function(resolvedArgs) {
|
|
5454
|
+
var sortedArray = resolvedArgs[0].slice(0);
|
|
5455
|
+
if (sortedArray.length === 0) {
|
|
5456
|
+
return sortedArray;
|
|
5884
5457
|
}
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
return this.visit(node.right, value);
|
|
5458
|
+
var interpreter = this._interpreter;
|
|
5459
|
+
var exprefNode = resolvedArgs[1];
|
|
5460
|
+
var requiredType = this._getTypeName(interpreter.visit(exprefNode, sortedArray[0]));
|
|
5461
|
+
if ([TYPE_NUMBER, TYPE_STRING].indexOf(requiredType) < 0) {
|
|
5462
|
+
throw new Error("TypeError");
|
|
5891
5463
|
}
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5464
|
+
var that = this;
|
|
5465
|
+
var decorated = [];
|
|
5466
|
+
for (var i = 0;i < sortedArray.length; i++) {
|
|
5467
|
+
decorated.push([i, sortedArray[i]]);
|
|
5468
|
+
}
|
|
5469
|
+
decorated.sort(function(a, b) {
|
|
5470
|
+
var exprA = interpreter.visit(exprefNode, a[1]);
|
|
5471
|
+
var exprB = interpreter.visit(exprefNode, b[1]);
|
|
5472
|
+
if (that._getTypeName(exprA) !== requiredType) {
|
|
5473
|
+
throw new Error("TypeError: expected " + requiredType + ", received " + that._getTypeName(exprA));
|
|
5474
|
+
} else if (that._getTypeName(exprB) !== requiredType) {
|
|
5475
|
+
throw new Error("TypeError: expected " + requiredType + ", received " + that._getTypeName(exprB));
|
|
5476
|
+
}
|
|
5477
|
+
if (exprA > exprB) {
|
|
5478
|
+
return 1;
|
|
5479
|
+
} else if (exprA < exprB) {
|
|
5480
|
+
return -1;
|
|
5481
|
+
} else {
|
|
5482
|
+
return a[0] - b[0];
|
|
5483
|
+
}
|
|
5484
|
+
});
|
|
5485
|
+
for (var j = 0;j < decorated.length; j++) {
|
|
5486
|
+
sortedArray[j] = decorated[j][1];
|
|
5898
5487
|
}
|
|
5899
|
-
return
|
|
5900
|
-
}
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5488
|
+
return sortedArray;
|
|
5489
|
+
},
|
|
5490
|
+
_functionMaxBy: function(resolvedArgs) {
|
|
5491
|
+
var exprefNode = resolvedArgs[1];
|
|
5492
|
+
var resolvedArray = resolvedArgs[0];
|
|
5493
|
+
var keyFunction = this.createKeyFunction(exprefNode, [TYPE_NUMBER, TYPE_STRING]);
|
|
5494
|
+
var maxNumber = -Infinity;
|
|
5495
|
+
var maxRecord;
|
|
5496
|
+
var current;
|
|
5497
|
+
for (var i = 0;i < resolvedArray.length; i++) {
|
|
5498
|
+
current = keyFunction(resolvedArray[i]);
|
|
5499
|
+
if (current > maxNumber) {
|
|
5500
|
+
maxNumber = current;
|
|
5501
|
+
maxRecord = resolvedArray[i];
|
|
5502
|
+
}
|
|
5911
5503
|
}
|
|
5912
|
-
return
|
|
5913
|
-
}
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5504
|
+
return maxRecord;
|
|
5505
|
+
},
|
|
5506
|
+
_functionMinBy: function(resolvedArgs) {
|
|
5507
|
+
var exprefNode = resolvedArgs[1];
|
|
5508
|
+
var resolvedArray = resolvedArgs[0];
|
|
5509
|
+
var keyFunction = this.createKeyFunction(exprefNode, [TYPE_NUMBER, TYPE_STRING]);
|
|
5510
|
+
var minNumber = Infinity;
|
|
5511
|
+
var minRecord;
|
|
5512
|
+
var current;
|
|
5513
|
+
for (var i = 0;i < resolvedArray.length; i++) {
|
|
5514
|
+
current = keyFunction(resolvedArray[i]);
|
|
5515
|
+
if (current < minNumber) {
|
|
5516
|
+
minNumber = current;
|
|
5517
|
+
minRecord = resolvedArray[i];
|
|
5518
|
+
}
|
|
5519
|
+
}
|
|
5520
|
+
return minRecord;
|
|
5521
|
+
},
|
|
5522
|
+
createKeyFunction: function(exprefNode, allowedTypes) {
|
|
5523
|
+
var that = this;
|
|
5524
|
+
var interpreter = this._interpreter;
|
|
5525
|
+
var keyFunc = function(x) {
|
|
5526
|
+
var current = interpreter.visit(exprefNode, x);
|
|
5527
|
+
if (allowedTypes.indexOf(that._getTypeName(current)) < 0) {
|
|
5528
|
+
var msg = "TypeError: expected one of " + allowedTypes + ", received " + that._getTypeName(current);
|
|
5529
|
+
throw new Error(msg);
|
|
5530
|
+
}
|
|
5531
|
+
return current;
|
|
5918
5532
|
};
|
|
5919
|
-
|
|
5920
|
-
case "Identity":
|
|
5921
|
-
return value;
|
|
5922
|
-
}
|
|
5923
|
-
}
|
|
5924
|
-
computeSliceParams(arrayLength, sliceNode) {
|
|
5925
|
-
let { start, stop, step } = sliceNode;
|
|
5926
|
-
if (step === null) {
|
|
5927
|
-
step = 1;
|
|
5928
|
-
} else if (step === 0) {
|
|
5929
|
-
const error = new Error("Invalid value: slice step cannot be 0");
|
|
5930
|
-
error.name = "RuntimeError";
|
|
5931
|
-
throw error;
|
|
5932
|
-
}
|
|
5933
|
-
start = start === null ? step < 0 ? arrayLength - 1 : 0 : this.capSliceRange(arrayLength, start, step);
|
|
5934
|
-
stop = stop === null ? step < 0 ? -1 : arrayLength : this.capSliceRange(arrayLength, stop, step);
|
|
5935
|
-
return { start, stop, step };
|
|
5936
|
-
}
|
|
5937
|
-
capSliceRange(arrayLength, actualValue, step) {
|
|
5938
|
-
let nextActualValue = actualValue;
|
|
5939
|
-
if (nextActualValue < 0) {
|
|
5940
|
-
nextActualValue += arrayLength;
|
|
5941
|
-
if (nextActualValue < 0) {
|
|
5942
|
-
nextActualValue = step < 0 ? -1 : 0;
|
|
5943
|
-
}
|
|
5944
|
-
} else if (nextActualValue >= arrayLength) {
|
|
5945
|
-
nextActualValue = step < 0 ? arrayLength - 1 : arrayLength;
|
|
5946
|
-
}
|
|
5947
|
-
return nextActualValue;
|
|
5948
|
-
}
|
|
5949
|
-
slice(collection, start, end, step) {
|
|
5950
|
-
const result = [];
|
|
5951
|
-
if (step > 0) {
|
|
5952
|
-
for (let i = start;i < end; i += step) {
|
|
5953
|
-
result.push(collection[i]);
|
|
5954
|
-
}
|
|
5955
|
-
} else {
|
|
5956
|
-
for (let i = start;i > end; i += step) {
|
|
5957
|
-
result.push(collection[i]);
|
|
5533
|
+
return keyFunc;
|
|
5958
5534
|
}
|
|
5959
|
-
}
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
}
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
}
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
}
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
",": "Comma",
|
|
5983
|
-
".": "Dot",
|
|
5984
|
-
":": "Colon",
|
|
5985
|
-
"@": "Current",
|
|
5986
|
-
"]": "Rbracket",
|
|
5987
|
-
"{": "Lbrace",
|
|
5988
|
-
"}": "Rbrace",
|
|
5989
|
-
"+": "Plus",
|
|
5990
|
-
"%": "Modulo",
|
|
5991
|
-
"?": "Question",
|
|
5992
|
-
"−": "Minus",
|
|
5993
|
-
"×": "Multiply",
|
|
5994
|
-
"÷": "Divide"
|
|
5995
|
-
};
|
|
5996
|
-
operatorStartToken = {
|
|
5997
|
-
"!": true,
|
|
5998
|
-
"<": true,
|
|
5999
|
-
"=": true,
|
|
6000
|
-
">": true,
|
|
6001
|
-
"&": true,
|
|
6002
|
-
"|": true,
|
|
6003
|
-
"/": true
|
|
6004
|
-
};
|
|
6005
|
-
skipChars = {
|
|
6006
|
-
"\t": true,
|
|
6007
|
-
"\n": true,
|
|
6008
|
-
"\r": true,
|
|
6009
|
-
" ": true
|
|
6010
|
-
};
|
|
6011
|
-
Lexer = new StreamLexer;
|
|
6012
|
-
Lexer_default = Lexer;
|
|
6013
|
-
bindingPower = {
|
|
6014
|
-
["EOF"]: 0,
|
|
6015
|
-
["Variable"]: 0,
|
|
6016
|
-
["UnquotedIdentifier"]: 0,
|
|
6017
|
-
["QuotedIdentifier"]: 0,
|
|
6018
|
-
["Rbracket"]: 0,
|
|
6019
|
-
["Rparen"]: 0,
|
|
6020
|
-
["Comma"]: 0,
|
|
6021
|
-
["Rbrace"]: 0,
|
|
6022
|
-
["Number"]: 0,
|
|
6023
|
-
["Current"]: 0,
|
|
6024
|
-
["Expref"]: 0,
|
|
6025
|
-
["Root"]: 0,
|
|
6026
|
-
["Assign"]: 1,
|
|
6027
|
-
["Pipe"]: 1,
|
|
6028
|
-
["Question"]: 2,
|
|
6029
|
-
["Or"]: 3,
|
|
6030
|
-
["And"]: 4,
|
|
6031
|
-
["EQ"]: 5,
|
|
6032
|
-
["GT"]: 5,
|
|
6033
|
-
["LT"]: 5,
|
|
6034
|
-
["GTE"]: 5,
|
|
6035
|
-
["LTE"]: 5,
|
|
6036
|
-
["NE"]: 5,
|
|
6037
|
-
["Minus"]: 6,
|
|
6038
|
-
["Plus"]: 6,
|
|
6039
|
-
["Div"]: 7,
|
|
6040
|
-
["Divide"]: 7,
|
|
6041
|
-
["Modulo"]: 7,
|
|
6042
|
-
["Multiply"]: 7,
|
|
6043
|
-
["Flatten"]: 9,
|
|
6044
|
-
["Star"]: 20,
|
|
6045
|
-
["Filter"]: 21,
|
|
6046
|
-
["Dot"]: 40,
|
|
6047
|
-
["Not"]: 45,
|
|
6048
|
-
["Lbrace"]: 50,
|
|
6049
|
-
["Lbracket"]: 55,
|
|
6050
|
-
["Lparen"]: 60
|
|
6051
|
-
};
|
|
6052
|
-
Parser = new TokenParser;
|
|
6053
|
-
Parser_default = Parser;
|
|
6054
|
-
emptyScopeChain = new ScopeChain;
|
|
6055
|
-
TreeInterpreterInstance = new TreeInterpreter;
|
|
6056
|
-
TreeInterpreter_default = TreeInterpreterInstance;
|
|
6057
|
-
TreeInterpreter2 = TreeInterpreter_default;
|
|
6058
|
-
jmespath = {
|
|
6059
|
-
compile,
|
|
6060
|
-
registerFunction,
|
|
6061
|
-
register,
|
|
6062
|
-
unregisterFunction,
|
|
6063
|
-
isRegistered,
|
|
6064
|
-
getRegisteredFunctions,
|
|
6065
|
-
getCustomFunctions,
|
|
6066
|
-
clearCustomFunctions,
|
|
6067
|
-
search,
|
|
6068
|
-
tokenize,
|
|
6069
|
-
TreeInterpreter: TreeInterpreter2,
|
|
6070
|
-
TYPE_ANY,
|
|
6071
|
-
TYPE_ARRAY_NUMBER,
|
|
6072
|
-
TYPE_ARRAY_STRING,
|
|
6073
|
-
TYPE_ARRAY,
|
|
6074
|
-
TYPE_BOOLEAN,
|
|
6075
|
-
TYPE_EXPREF,
|
|
6076
|
-
TYPE_NULL,
|
|
6077
|
-
TYPE_NUMBER,
|
|
6078
|
-
TYPE_OBJECT,
|
|
6079
|
-
TYPE_STRING
|
|
6080
|
-
};
|
|
5535
|
+
};
|
|
5536
|
+
function compile(stream) {
|
|
5537
|
+
var parser = new Parser;
|
|
5538
|
+
var ast = parser.parse(stream);
|
|
5539
|
+
return ast;
|
|
5540
|
+
}
|
|
5541
|
+
function tokenize(stream) {
|
|
5542
|
+
var lexer = new Lexer;
|
|
5543
|
+
return lexer.tokenize(stream);
|
|
5544
|
+
}
|
|
5545
|
+
function search(data, expression) {
|
|
5546
|
+
var parser = new Parser;
|
|
5547
|
+
var runtime = new Runtime;
|
|
5548
|
+
var interpreter = new TreeInterpreter(runtime);
|
|
5549
|
+
runtime._interpreter = interpreter;
|
|
5550
|
+
var node = parser.parse(expression);
|
|
5551
|
+
return interpreter.search(node, data);
|
|
5552
|
+
}
|
|
5553
|
+
exports2.tokenize = tokenize;
|
|
5554
|
+
exports2.compile = compile;
|
|
5555
|
+
exports2.search = search;
|
|
5556
|
+
exports2.strictDeepEqual = strictDeepEqual;
|
|
5557
|
+
})(typeof exports === "undefined" ? exports.jmespath = {} : exports);
|
|
6081
5558
|
});
|
|
6082
5559
|
|
|
6083
5560
|
// ../../../node_modules/commander/lib/error.js
|
|
@@ -6406,10 +5883,10 @@ var require_help = __commonJS(function(exports) {
|
|
|
6406
5883
|
});
|
|
6407
5884
|
output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
|
|
6408
5885
|
}
|
|
6409
|
-
const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (
|
|
5886
|
+
const commandGroups = this.groupItems(cmd.commands, helper.visibleCommands(cmd), (sub) => sub.helpGroup() || "Commands:");
|
|
6410
5887
|
commandGroups.forEach((commands, group) => {
|
|
6411
|
-
const commandList = commands.map((
|
|
6412
|
-
return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(
|
|
5888
|
+
const commandList = commands.map((sub) => {
|
|
5889
|
+
return callFormatItem(helper.styleSubcommandTerm(helper.subcommandTerm(sub)), helper.styleSubcommandDescription(helper.subcommandDescription(sub)));
|
|
6413
5890
|
});
|
|
6414
5891
|
output = output.concat(this.formatItemList(group, commandList, helper));
|
|
6415
5892
|
});
|
|
@@ -8175,8 +7652,8 @@ var require_commander = __commonJS(function(exports) {
|
|
|
8175
7652
|
// package.json
|
|
8176
7653
|
var package_default = {
|
|
8177
7654
|
name: "@uipath/gov-tool",
|
|
8178
|
-
license: "
|
|
8179
|
-
version: "1.202.0
|
|
7655
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
7656
|
+
version: "1.202.0",
|
|
8180
7657
|
description: "Manage UiPath governance — AOps policies, Access policies, and compliance packs.",
|
|
8181
7658
|
private: false,
|
|
8182
7659
|
repository: {
|
|
@@ -8581,7 +8058,7 @@ class VoidApiResponse {
|
|
|
8581
8058
|
// ../../admin/authz-sdk/package.json
|
|
8582
8059
|
var package_default2 = {
|
|
8583
8060
|
name: "@uipath/authz-sdk",
|
|
8584
|
-
license: "
|
|
8061
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
8585
8062
|
version: "1.202.0",
|
|
8586
8063
|
description: "SDK for the UiPath Authorization Service API.",
|
|
8587
8064
|
repository: {
|
|
@@ -11667,13 +11144,13 @@ var jmespathSlot = singleton("JmespathCodec");
|
|
|
11667
11144
|
async function loadOutputCodecsAsync(needed) {
|
|
11668
11145
|
const loads = [];
|
|
11669
11146
|
if (needed.yaml && yamlSlot.get() === undefined) {
|
|
11670
|
-
loads.push(Promise.resolve().then(() => (init_js_yaml(), exports_js_yaml)).then((
|
|
11671
|
-
yamlSlot.set(
|
|
11147
|
+
loads.push(Promise.resolve().then(() => (init_js_yaml(), exports_js_yaml)).then((mod) => {
|
|
11148
|
+
yamlSlot.set(mod);
|
|
11672
11149
|
}));
|
|
11673
11150
|
}
|
|
11674
11151
|
if (needed.filter && jmespathSlot.get() === undefined) {
|
|
11675
|
-
loads.push(Promise.resolve().then(() => (
|
|
11676
|
-
jmespathSlot.set(
|
|
11152
|
+
loads.push(Promise.resolve().then(() => __toESM(require_jmespath(), 1)).then((mod) => {
|
|
11153
|
+
jmespathSlot.set(mod);
|
|
11677
11154
|
}));
|
|
11678
11155
|
}
|
|
11679
11156
|
await Promise.all(loads);
|
|
@@ -12424,8 +11901,8 @@ class TelemetryService {
|
|
|
12424
11901
|
// ../../common/src/timings.ts
|
|
12425
11902
|
var TIMINGS_ENV_VAR = "UIP_TIMINGS";
|
|
12426
11903
|
function createStorage2() {
|
|
12427
|
-
const [error,
|
|
12428
|
-
if (error || typeof
|
|
11904
|
+
const [error, mod] = catchError2(() => __require("node:async_hooks"));
|
|
11905
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
12429
11906
|
return {
|
|
12430
11907
|
getStore: () => {
|
|
12431
11908
|
return;
|
|
@@ -12433,7 +11910,7 @@ function createStorage2() {
|
|
|
12433
11910
|
run: (_store, fn) => fn()
|
|
12434
11911
|
};
|
|
12435
11912
|
}
|
|
12436
|
-
return new
|
|
11913
|
+
return new mod.AsyncLocalStorage;
|
|
12437
11914
|
}
|
|
12438
11915
|
var storageSlot = singleton("TimingStorage");
|
|
12439
11916
|
var stateSlot = singleton("Timings");
|
|
@@ -14524,7 +14001,7 @@ class TextApiResponse {
|
|
|
14524
14001
|
// ../aops-policy-sdk/package.json
|
|
14525
14002
|
var package_default3 = {
|
|
14526
14003
|
name: "@uipath/aops-policy-sdk",
|
|
14527
|
-
license: "
|
|
14004
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
14528
14005
|
version: "1.202.0",
|
|
14529
14006
|
description: "SDK for the UiPath AOps Governance API — policy management and deployment.",
|
|
14530
14007
|
repository: {
|
|
@@ -22611,7 +22088,7 @@ class VoidApiResponse3 {
|
|
|
22611
22088
|
}
|
|
22612
22089
|
var package_default4 = {
|
|
22613
22090
|
name: "@uipath/compliance-packs-sdk",
|
|
22614
|
-
license: "
|
|
22091
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
22615
22092
|
version: "1.202.0",
|
|
22616
22093
|
description: "SDK for the UiPath Governance Server Compliance Packs API.",
|
|
22617
22094
|
repository: {
|
|
@@ -23396,8 +22873,8 @@ function isAuthProfileStorage2(value) {
|
|
|
23396
22873
|
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
23397
22874
|
}
|
|
23398
22875
|
function createProfileStorage2() {
|
|
23399
|
-
const [error,
|
|
23400
|
-
if (error || typeof
|
|
22876
|
+
const [error, mod] = catchError3(() => __require2("node:async_hooks"));
|
|
22877
|
+
if (error || typeof mod?.AsyncLocalStorage !== "function") {
|
|
23401
22878
|
return {
|
|
23402
22879
|
getStore: () => {
|
|
23403
22880
|
return;
|
|
@@ -23405,7 +22882,7 @@ function createProfileStorage2() {
|
|
|
23405
22882
|
run: (_store, fn) => fn()
|
|
23406
22883
|
};
|
|
23407
22884
|
}
|
|
23408
|
-
return new
|
|
22885
|
+
return new mod.AsyncLocalStorage;
|
|
23409
22886
|
}
|
|
23410
22887
|
function getProfileStorage2() {
|
|
23411
22888
|
const existing = globalSlot22[AUTH_PROFILE_STORAGE_KEY2];
|
|
@@ -23784,11 +23261,11 @@ var defaultLoadModule2 = async () => {
|
|
|
23784
23261
|
if (!hostLoader) {
|
|
23785
23262
|
return;
|
|
23786
23263
|
}
|
|
23787
|
-
const [error,
|
|
23788
|
-
if (error || !
|
|
23264
|
+
const [error, mod] = await catchError3(() => hostLoader());
|
|
23265
|
+
if (error || !mod) {
|
|
23789
23266
|
return;
|
|
23790
23267
|
}
|
|
23791
|
-
return
|
|
23268
|
+
return mod;
|
|
23792
23269
|
};
|
|
23793
23270
|
var tryRobotClientFallback2 = async (options = {}) => {
|
|
23794
23271
|
if (isBrowser2())
|
|
@@ -23807,10 +23284,10 @@ var tryRobotClientFallback2 = async (options = {}) => {
|
|
|
23807
23284
|
if (!await isRobotIpcAvailable()) {
|
|
23808
23285
|
return;
|
|
23809
23286
|
}
|
|
23810
|
-
const
|
|
23811
|
-
if (!
|
|
23287
|
+
const mod = await loadModule();
|
|
23288
|
+
if (!mod)
|
|
23812
23289
|
return;
|
|
23813
|
-
const [ctorError, proxy] = catchError3(() => new
|
|
23290
|
+
const [ctorError, proxy] = catchError3(() => new mod.RobotProxyConstructor);
|
|
23814
23291
|
if (ctorError || !proxy) {
|
|
23815
23292
|
return;
|
|
23816
23293
|
}
|
|
@@ -25035,4 +24512,4 @@ export {
|
|
|
25035
24512
|
registerCommands
|
|
25036
24513
|
};
|
|
25037
24514
|
|
|
25038
|
-
//# debugId=
|
|
24515
|
+
//# debugId=EB77F3D7124046CE64756E2164756E21
|