@uipath/common 1.196.0 → 1.197.0-preview.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catch-error.js +32 -0
- package/dist/error-handler.d.ts +25 -0
- package/dist/formatter.d.ts +6 -0
- package/dist/index.browser.d.ts +7 -1
- package/dist/index.browser.js +341 -1495
- package/dist/index.d.ts +3 -1
- package/dist/index.js +281 -1510
- package/dist/interactivity-context.d.ts +7 -7
- package/dist/output-sink.d.ts +3 -1
- package/dist/package-metadata-options.d.ts +2 -0
- package/dist/package-metadata-options.js +7 -1
- package/dist/preview.d.ts +53 -0
- package/dist/sdk-user-agent.d.ts +14 -1
- package/dist/sdk-user-agent.js +59 -42
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/telemetry-config.d.ts +5 -0
- package/dist/telemetry/telemetry-init.d.ts +1 -6
- package/package.json +30 -8
- package/dist/jsonpath.d.ts +0 -11
package/dist/index.browser.js
CHANGED
|
@@ -20790,6 +20790,7 @@ var CONSOLE_FALLBACK = {
|
|
|
20790
20790
|
writeLog: (str) => process.stdout.write(str),
|
|
20791
20791
|
capabilities: {
|
|
20792
20792
|
isInteractive: false,
|
|
20793
|
+
canReadInput: false,
|
|
20793
20794
|
supportsColor: false,
|
|
20794
20795
|
outputWidth: 80
|
|
20795
20796
|
}
|
|
@@ -20927,7 +20928,7 @@ function format2(first, ...rest) {
|
|
|
20927
20928
|
});
|
|
20928
20929
|
const extra = rest.slice(i);
|
|
20929
20930
|
if (extra.length > 0) {
|
|
20930
|
-
return result
|
|
20931
|
+
return `${result} ${extra.map(String).join(" ")}`;
|
|
20931
20932
|
}
|
|
20932
20933
|
return result;
|
|
20933
20934
|
}
|
|
@@ -21038,27 +21039,54 @@ var NETWORK_ERROR_CODES = new Set([
|
|
|
21038
21039
|
"ENETUNREACH",
|
|
21039
21040
|
"EAI_FAIL"
|
|
21040
21041
|
]);
|
|
21041
|
-
|
|
21042
|
-
|
|
21043
|
-
|
|
21044
|
-
|
|
21045
|
-
|
|
21046
|
-
|
|
21047
|
-
|
|
21048
|
-
|
|
21049
|
-
|
|
21050
|
-
|
|
21051
|
-
|
|
21052
|
-
|
|
21053
|
-
|
|
21054
|
-
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21042
|
+
var TLS_ERROR_CODES = new Set([
|
|
21043
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
21044
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
21045
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
21046
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
21047
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
21048
|
+
"CERT_HAS_EXPIRED",
|
|
21049
|
+
"CERT_UNTRUSTED",
|
|
21050
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
21051
|
+
]);
|
|
21052
|
+
var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
|
|
21053
|
+
var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
|
|
21054
|
+
function describeConnectivityError(error) {
|
|
21055
|
+
let current = error;
|
|
21056
|
+
for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
|
|
21057
|
+
const cur = current;
|
|
21058
|
+
const code2 = typeof cur.code === "string" ? cur.code : undefined;
|
|
21059
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
21060
|
+
if (code2 && TLS_ERROR_CODES.has(code2)) {
|
|
21061
|
+
return {
|
|
21062
|
+
code: code2,
|
|
21063
|
+
kind: "tls",
|
|
21064
|
+
message: message ?? code2,
|
|
21065
|
+
instructions: TLS_INSTRUCTIONS
|
|
21066
|
+
};
|
|
21067
|
+
}
|
|
21068
|
+
if (code2 && NETWORK_ERROR_CODES.has(code2)) {
|
|
21069
|
+
return {
|
|
21070
|
+
code: code2,
|
|
21071
|
+
kind: "network",
|
|
21072
|
+
message: message ?? code2,
|
|
21073
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
21074
|
+
};
|
|
21058
21075
|
}
|
|
21076
|
+
current = cur.cause;
|
|
21059
21077
|
}
|
|
21060
21078
|
return;
|
|
21061
21079
|
}
|
|
21080
|
+
function parseHttpStatusFromMessage(message) {
|
|
21081
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
21082
|
+
if (!match)
|
|
21083
|
+
return;
|
|
21084
|
+
const status = Number(match[1]);
|
|
21085
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
21086
|
+
}
|
|
21087
|
+
function isHtmlDocument(body) {
|
|
21088
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
21089
|
+
}
|
|
21062
21090
|
function retryHintForRetryAfter(seconds) {
|
|
21063
21091
|
if (seconds <= 1) {
|
|
21064
21092
|
return "RetryAfter1Second";
|
|
@@ -21099,15 +21127,28 @@ function classifyError(status, error) {
|
|
|
21099
21127
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
21100
21128
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
21101
21129
|
}
|
|
21102
|
-
|
|
21103
|
-
|
|
21130
|
+
const connectivity = describeConnectivityError(error);
|
|
21131
|
+
if (connectivity) {
|
|
21132
|
+
return {
|
|
21133
|
+
errorCode: "network_error",
|
|
21134
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
21135
|
+
};
|
|
21104
21136
|
}
|
|
21105
21137
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
21106
21138
|
}
|
|
21139
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
21140
|
+
if (extractedMessage) {
|
|
21141
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
21142
|
+
}
|
|
21143
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
21144
|
+
}
|
|
21107
21145
|
async function extractErrorDetails(error, options) {
|
|
21108
21146
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
21109
21147
|
const response = err.response;
|
|
21110
|
-
const
|
|
21148
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21149
|
+
const explicitStatus = err.status ?? response?.status;
|
|
21150
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
21151
|
+
const status = explicitStatus ?? inferredStatus;
|
|
21111
21152
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
21112
21153
|
let rawBody;
|
|
21113
21154
|
let extractedMessage;
|
|
@@ -21142,7 +21183,6 @@ async function extractErrorDetails(error, options) {
|
|
|
21142
21183
|
}
|
|
21143
21184
|
}
|
|
21144
21185
|
}
|
|
21145
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21146
21186
|
let message;
|
|
21147
21187
|
let result = "Failure";
|
|
21148
21188
|
const classification = classifyError(status, error);
|
|
@@ -21156,10 +21196,10 @@ async function extractErrorDetails(error, options) {
|
|
|
21156
21196
|
} else if (status === 405) {
|
|
21157
21197
|
message = DEFAULT_405;
|
|
21158
21198
|
} else if (status === 400 || status === 422) {
|
|
21159
|
-
message =
|
|
21199
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21160
21200
|
result = "ValidationError";
|
|
21161
21201
|
} else if (status === 429) {
|
|
21162
|
-
message =
|
|
21202
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21163
21203
|
} else if (extractedMessage) {
|
|
21164
21204
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
21165
21205
|
message = rawMessage;
|
|
@@ -21167,7 +21207,9 @@ async function extractErrorDetails(error, options) {
|
|
|
21167
21207
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
21168
21208
|
}
|
|
21169
21209
|
} else if (status) {
|
|
21170
|
-
if (
|
|
21210
|
+
if (inferredStatus !== undefined) {
|
|
21211
|
+
message = rawMessage;
|
|
21212
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
21171
21213
|
const statusText = response.statusText;
|
|
21172
21214
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
21173
21215
|
} else {
|
|
@@ -21176,6 +21218,12 @@ async function extractErrorDetails(error, options) {
|
|
|
21176
21218
|
} else {
|
|
21177
21219
|
message = rawMessage;
|
|
21178
21220
|
}
|
|
21221
|
+
if (status === undefined) {
|
|
21222
|
+
const connectivity = describeConnectivityError(error);
|
|
21223
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
21224
|
+
message = `${message}: ${connectivity.message}`;
|
|
21225
|
+
}
|
|
21226
|
+
}
|
|
21179
21227
|
let details = rawMessage;
|
|
21180
21228
|
if (rawBody) {
|
|
21181
21229
|
if (parsedBody) {
|
|
@@ -21322,6 +21370,10 @@ function instructionsFor(ctx, err) {
|
|
|
21322
21370
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
21323
21371
|
return "Orchestrator returned a server error — retry; if it persists, check service status";
|
|
21324
21372
|
}
|
|
21373
|
+
const connectivity = describeConnectivityError(err);
|
|
21374
|
+
if (connectivity) {
|
|
21375
|
+
return connectivity.instructions;
|
|
21376
|
+
}
|
|
21325
21377
|
return GENERIC;
|
|
21326
21378
|
}
|
|
21327
21379
|
}
|
|
@@ -21331,1473 +21383,6 @@ var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
|
|
|
21331
21383
|
function isGuid(value) {
|
|
21332
21384
|
return GUID_REGEX.test(value);
|
|
21333
21385
|
}
|
|
21334
|
-
// ../../node_modules/jsonpath-plus/dist/index-browser-esm.js
|
|
21335
|
-
class Hooks {
|
|
21336
|
-
add(name, callback, first) {
|
|
21337
|
-
if (typeof arguments[0] != "string") {
|
|
21338
|
-
for (let name2 in arguments[0]) {
|
|
21339
|
-
this.add(name2, arguments[0][name2], arguments[1]);
|
|
21340
|
-
}
|
|
21341
|
-
} else {
|
|
21342
|
-
(Array.isArray(name) ? name : [name]).forEach(function(name2) {
|
|
21343
|
-
this[name2] = this[name2] || [];
|
|
21344
|
-
if (callback) {
|
|
21345
|
-
this[name2][first ? "unshift" : "push"](callback);
|
|
21346
|
-
}
|
|
21347
|
-
}, this);
|
|
21348
|
-
}
|
|
21349
|
-
}
|
|
21350
|
-
run(name, env2) {
|
|
21351
|
-
this[name] = this[name] || [];
|
|
21352
|
-
this[name].forEach(function(callback) {
|
|
21353
|
-
callback.call(env2 && env2.context ? env2.context : env2, env2);
|
|
21354
|
-
});
|
|
21355
|
-
}
|
|
21356
|
-
}
|
|
21357
|
-
|
|
21358
|
-
class Plugins {
|
|
21359
|
-
constructor(jsep) {
|
|
21360
|
-
this.jsep = jsep;
|
|
21361
|
-
this.registered = {};
|
|
21362
|
-
}
|
|
21363
|
-
register() {
|
|
21364
|
-
for (var _len = arguments.length, plugins = new Array(_len), _key = 0;_key < _len; _key++) {
|
|
21365
|
-
plugins[_key] = arguments[_key];
|
|
21366
|
-
}
|
|
21367
|
-
plugins.forEach((plugin) => {
|
|
21368
|
-
if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
|
|
21369
|
-
throw new Error("Invalid JSEP plugin format");
|
|
21370
|
-
}
|
|
21371
|
-
if (this.registered[plugin.name]) {
|
|
21372
|
-
return;
|
|
21373
|
-
}
|
|
21374
|
-
plugin.init(this.jsep);
|
|
21375
|
-
this.registered[plugin.name] = plugin;
|
|
21376
|
-
});
|
|
21377
|
-
}
|
|
21378
|
-
}
|
|
21379
|
-
|
|
21380
|
-
class Jsep {
|
|
21381
|
-
static get version() {
|
|
21382
|
-
return "1.4.0";
|
|
21383
|
-
}
|
|
21384
|
-
static toString() {
|
|
21385
|
-
return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
|
|
21386
|
-
}
|
|
21387
|
-
static addUnaryOp(op_name) {
|
|
21388
|
-
Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
|
|
21389
|
-
Jsep.unary_ops[op_name] = 1;
|
|
21390
|
-
return Jsep;
|
|
21391
|
-
}
|
|
21392
|
-
static addBinaryOp(op_name, precedence, isRightAssociative) {
|
|
21393
|
-
Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
|
|
21394
|
-
Jsep.binary_ops[op_name] = precedence;
|
|
21395
|
-
if (isRightAssociative) {
|
|
21396
|
-
Jsep.right_associative.add(op_name);
|
|
21397
|
-
} else {
|
|
21398
|
-
Jsep.right_associative.delete(op_name);
|
|
21399
|
-
}
|
|
21400
|
-
return Jsep;
|
|
21401
|
-
}
|
|
21402
|
-
static addIdentifierChar(char) {
|
|
21403
|
-
Jsep.additional_identifier_chars.add(char);
|
|
21404
|
-
return Jsep;
|
|
21405
|
-
}
|
|
21406
|
-
static addLiteral(literal_name, literal_value) {
|
|
21407
|
-
Jsep.literals[literal_name] = literal_value;
|
|
21408
|
-
return Jsep;
|
|
21409
|
-
}
|
|
21410
|
-
static removeUnaryOp(op_name) {
|
|
21411
|
-
delete Jsep.unary_ops[op_name];
|
|
21412
|
-
if (op_name.length === Jsep.max_unop_len) {
|
|
21413
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
21414
|
-
}
|
|
21415
|
-
return Jsep;
|
|
21416
|
-
}
|
|
21417
|
-
static removeAllUnaryOps() {
|
|
21418
|
-
Jsep.unary_ops = {};
|
|
21419
|
-
Jsep.max_unop_len = 0;
|
|
21420
|
-
return Jsep;
|
|
21421
|
-
}
|
|
21422
|
-
static removeIdentifierChar(char) {
|
|
21423
|
-
Jsep.additional_identifier_chars.delete(char);
|
|
21424
|
-
return Jsep;
|
|
21425
|
-
}
|
|
21426
|
-
static removeBinaryOp(op_name) {
|
|
21427
|
-
delete Jsep.binary_ops[op_name];
|
|
21428
|
-
if (op_name.length === Jsep.max_binop_len) {
|
|
21429
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
21430
|
-
}
|
|
21431
|
-
Jsep.right_associative.delete(op_name);
|
|
21432
|
-
return Jsep;
|
|
21433
|
-
}
|
|
21434
|
-
static removeAllBinaryOps() {
|
|
21435
|
-
Jsep.binary_ops = {};
|
|
21436
|
-
Jsep.max_binop_len = 0;
|
|
21437
|
-
return Jsep;
|
|
21438
|
-
}
|
|
21439
|
-
static removeLiteral(literal_name) {
|
|
21440
|
-
delete Jsep.literals[literal_name];
|
|
21441
|
-
return Jsep;
|
|
21442
|
-
}
|
|
21443
|
-
static removeAllLiterals() {
|
|
21444
|
-
Jsep.literals = {};
|
|
21445
|
-
return Jsep;
|
|
21446
|
-
}
|
|
21447
|
-
get char() {
|
|
21448
|
-
return this.expr.charAt(this.index);
|
|
21449
|
-
}
|
|
21450
|
-
get code() {
|
|
21451
|
-
return this.expr.charCodeAt(this.index);
|
|
21452
|
-
}
|
|
21453
|
-
constructor(expr) {
|
|
21454
|
-
this.expr = expr;
|
|
21455
|
-
this.index = 0;
|
|
21456
|
-
}
|
|
21457
|
-
static parse(expr) {
|
|
21458
|
-
return new Jsep(expr).parse();
|
|
21459
|
-
}
|
|
21460
|
-
static getMaxKeyLen(obj) {
|
|
21461
|
-
return Math.max(0, ...Object.keys(obj).map((k) => k.length));
|
|
21462
|
-
}
|
|
21463
|
-
static isDecimalDigit(ch) {
|
|
21464
|
-
return ch >= 48 && ch <= 57;
|
|
21465
|
-
}
|
|
21466
|
-
static binaryPrecedence(op_val) {
|
|
21467
|
-
return Jsep.binary_ops[op_val] || 0;
|
|
21468
|
-
}
|
|
21469
|
-
static isIdentifierStart(ch) {
|
|
21470
|
-
return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
|
|
21471
|
-
}
|
|
21472
|
-
static isIdentifierPart(ch) {
|
|
21473
|
-
return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
|
|
21474
|
-
}
|
|
21475
|
-
throwError(message) {
|
|
21476
|
-
const error = new Error(message + " at character " + this.index);
|
|
21477
|
-
error.index = this.index;
|
|
21478
|
-
error.description = message;
|
|
21479
|
-
throw error;
|
|
21480
|
-
}
|
|
21481
|
-
runHook(name, node) {
|
|
21482
|
-
if (Jsep.hooks[name]) {
|
|
21483
|
-
const env2 = {
|
|
21484
|
-
context: this,
|
|
21485
|
-
node
|
|
21486
|
-
};
|
|
21487
|
-
Jsep.hooks.run(name, env2);
|
|
21488
|
-
return env2.node;
|
|
21489
|
-
}
|
|
21490
|
-
return node;
|
|
21491
|
-
}
|
|
21492
|
-
searchHook(name) {
|
|
21493
|
-
if (Jsep.hooks[name]) {
|
|
21494
|
-
const env2 = {
|
|
21495
|
-
context: this
|
|
21496
|
-
};
|
|
21497
|
-
Jsep.hooks[name].find(function(callback) {
|
|
21498
|
-
callback.call(env2.context, env2);
|
|
21499
|
-
return env2.node;
|
|
21500
|
-
});
|
|
21501
|
-
return env2.node;
|
|
21502
|
-
}
|
|
21503
|
-
}
|
|
21504
|
-
gobbleSpaces() {
|
|
21505
|
-
let ch = this.code;
|
|
21506
|
-
while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
|
|
21507
|
-
ch = this.expr.charCodeAt(++this.index);
|
|
21508
|
-
}
|
|
21509
|
-
this.runHook("gobble-spaces");
|
|
21510
|
-
}
|
|
21511
|
-
parse() {
|
|
21512
|
-
this.runHook("before-all");
|
|
21513
|
-
const nodes = this.gobbleExpressions();
|
|
21514
|
-
const node = nodes.length === 1 ? nodes[0] : {
|
|
21515
|
-
type: Jsep.COMPOUND,
|
|
21516
|
-
body: nodes
|
|
21517
|
-
};
|
|
21518
|
-
return this.runHook("after-all", node);
|
|
21519
|
-
}
|
|
21520
|
-
gobbleExpressions(untilICode) {
|
|
21521
|
-
let nodes = [], ch_i, node;
|
|
21522
|
-
while (this.index < this.expr.length) {
|
|
21523
|
-
ch_i = this.code;
|
|
21524
|
-
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
21525
|
-
this.index++;
|
|
21526
|
-
} else {
|
|
21527
|
-
if (node = this.gobbleExpression()) {
|
|
21528
|
-
nodes.push(node);
|
|
21529
|
-
} else if (this.index < this.expr.length) {
|
|
21530
|
-
if (ch_i === untilICode) {
|
|
21531
|
-
break;
|
|
21532
|
-
}
|
|
21533
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
21534
|
-
}
|
|
21535
|
-
}
|
|
21536
|
-
}
|
|
21537
|
-
return nodes;
|
|
21538
|
-
}
|
|
21539
|
-
gobbleExpression() {
|
|
21540
|
-
const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
21541
|
-
this.gobbleSpaces();
|
|
21542
|
-
return this.runHook("after-expression", node);
|
|
21543
|
-
}
|
|
21544
|
-
gobbleBinaryOp() {
|
|
21545
|
-
this.gobbleSpaces();
|
|
21546
|
-
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
21547
|
-
let tc_len = to_check.length;
|
|
21548
|
-
while (tc_len > 0) {
|
|
21549
|
-
if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
|
|
21550
|
-
this.index += tc_len;
|
|
21551
|
-
return to_check;
|
|
21552
|
-
}
|
|
21553
|
-
to_check = to_check.substr(0, --tc_len);
|
|
21554
|
-
}
|
|
21555
|
-
return false;
|
|
21556
|
-
}
|
|
21557
|
-
gobbleBinaryExpression() {
|
|
21558
|
-
let node, biop, prec, stack, biop_info, left, right, i2, cur_biop;
|
|
21559
|
-
left = this.gobbleToken();
|
|
21560
|
-
if (!left) {
|
|
21561
|
-
return left;
|
|
21562
|
-
}
|
|
21563
|
-
biop = this.gobbleBinaryOp();
|
|
21564
|
-
if (!biop) {
|
|
21565
|
-
return left;
|
|
21566
|
-
}
|
|
21567
|
-
biop_info = {
|
|
21568
|
-
value: biop,
|
|
21569
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
21570
|
-
right_a: Jsep.right_associative.has(biop)
|
|
21571
|
-
};
|
|
21572
|
-
right = this.gobbleToken();
|
|
21573
|
-
if (!right) {
|
|
21574
|
-
this.throwError("Expected expression after " + biop);
|
|
21575
|
-
}
|
|
21576
|
-
stack = [left, biop_info, right];
|
|
21577
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
21578
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
21579
|
-
if (prec === 0) {
|
|
21580
|
-
this.index -= biop.length;
|
|
21581
|
-
break;
|
|
21582
|
-
}
|
|
21583
|
-
biop_info = {
|
|
21584
|
-
value: biop,
|
|
21585
|
-
prec,
|
|
21586
|
-
right_a: Jsep.right_associative.has(biop)
|
|
21587
|
-
};
|
|
21588
|
-
cur_biop = biop;
|
|
21589
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
21590
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
21591
|
-
right = stack.pop();
|
|
21592
|
-
biop = stack.pop().value;
|
|
21593
|
-
left = stack.pop();
|
|
21594
|
-
node = {
|
|
21595
|
-
type: Jsep.BINARY_EXP,
|
|
21596
|
-
operator: biop,
|
|
21597
|
-
left,
|
|
21598
|
-
right
|
|
21599
|
-
};
|
|
21600
|
-
stack.push(node);
|
|
21601
|
-
}
|
|
21602
|
-
node = this.gobbleToken();
|
|
21603
|
-
if (!node) {
|
|
21604
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
21605
|
-
}
|
|
21606
|
-
stack.push(biop_info, node);
|
|
21607
|
-
}
|
|
21608
|
-
i2 = stack.length - 1;
|
|
21609
|
-
node = stack[i2];
|
|
21610
|
-
while (i2 > 1) {
|
|
21611
|
-
node = {
|
|
21612
|
-
type: Jsep.BINARY_EXP,
|
|
21613
|
-
operator: stack[i2 - 1].value,
|
|
21614
|
-
left: stack[i2 - 2],
|
|
21615
|
-
right: node
|
|
21616
|
-
};
|
|
21617
|
-
i2 -= 2;
|
|
21618
|
-
}
|
|
21619
|
-
return node;
|
|
21620
|
-
}
|
|
21621
|
-
gobbleToken() {
|
|
21622
|
-
let ch, to_check, tc_len, node;
|
|
21623
|
-
this.gobbleSpaces();
|
|
21624
|
-
node = this.searchHook("gobble-token");
|
|
21625
|
-
if (node) {
|
|
21626
|
-
return this.runHook("after-token", node);
|
|
21627
|
-
}
|
|
21628
|
-
ch = this.code;
|
|
21629
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
21630
|
-
return this.gobbleNumericLiteral();
|
|
21631
|
-
}
|
|
21632
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
21633
|
-
node = this.gobbleStringLiteral();
|
|
21634
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
21635
|
-
node = this.gobbleArray();
|
|
21636
|
-
} else {
|
|
21637
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
21638
|
-
tc_len = to_check.length;
|
|
21639
|
-
while (tc_len > 0) {
|
|
21640
|
-
if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
|
|
21641
|
-
this.index += tc_len;
|
|
21642
|
-
const argument = this.gobbleToken();
|
|
21643
|
-
if (!argument) {
|
|
21644
|
-
this.throwError("missing unaryOp argument");
|
|
21645
|
-
}
|
|
21646
|
-
return this.runHook("after-token", {
|
|
21647
|
-
type: Jsep.UNARY_EXP,
|
|
21648
|
-
operator: to_check,
|
|
21649
|
-
argument,
|
|
21650
|
-
prefix: true
|
|
21651
|
-
});
|
|
21652
|
-
}
|
|
21653
|
-
to_check = to_check.substr(0, --tc_len);
|
|
21654
|
-
}
|
|
21655
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
21656
|
-
node = this.gobbleIdentifier();
|
|
21657
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
21658
|
-
node = {
|
|
21659
|
-
type: Jsep.LITERAL,
|
|
21660
|
-
value: Jsep.literals[node.name],
|
|
21661
|
-
raw: node.name
|
|
21662
|
-
};
|
|
21663
|
-
} else if (node.name === Jsep.this_str) {
|
|
21664
|
-
node = {
|
|
21665
|
-
type: Jsep.THIS_EXP
|
|
21666
|
-
};
|
|
21667
|
-
}
|
|
21668
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
21669
|
-
node = this.gobbleGroup();
|
|
21670
|
-
}
|
|
21671
|
-
}
|
|
21672
|
-
if (!node) {
|
|
21673
|
-
return this.runHook("after-token", false);
|
|
21674
|
-
}
|
|
21675
|
-
node = this.gobbleTokenProperty(node);
|
|
21676
|
-
return this.runHook("after-token", node);
|
|
21677
|
-
}
|
|
21678
|
-
gobbleTokenProperty(node) {
|
|
21679
|
-
this.gobbleSpaces();
|
|
21680
|
-
let ch = this.code;
|
|
21681
|
-
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
21682
|
-
let optional;
|
|
21683
|
-
if (ch === Jsep.QUMARK_CODE) {
|
|
21684
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
21685
|
-
break;
|
|
21686
|
-
}
|
|
21687
|
-
optional = true;
|
|
21688
|
-
this.index += 2;
|
|
21689
|
-
this.gobbleSpaces();
|
|
21690
|
-
ch = this.code;
|
|
21691
|
-
}
|
|
21692
|
-
this.index++;
|
|
21693
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
21694
|
-
node = {
|
|
21695
|
-
type: Jsep.MEMBER_EXP,
|
|
21696
|
-
computed: true,
|
|
21697
|
-
object: node,
|
|
21698
|
-
property: this.gobbleExpression()
|
|
21699
|
-
};
|
|
21700
|
-
if (!node.property) {
|
|
21701
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
21702
|
-
}
|
|
21703
|
-
this.gobbleSpaces();
|
|
21704
|
-
ch = this.code;
|
|
21705
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
21706
|
-
this.throwError("Unclosed [");
|
|
21707
|
-
}
|
|
21708
|
-
this.index++;
|
|
21709
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
21710
|
-
node = {
|
|
21711
|
-
type: Jsep.CALL_EXP,
|
|
21712
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
21713
|
-
callee: node
|
|
21714
|
-
};
|
|
21715
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
21716
|
-
if (optional) {
|
|
21717
|
-
this.index--;
|
|
21718
|
-
}
|
|
21719
|
-
this.gobbleSpaces();
|
|
21720
|
-
node = {
|
|
21721
|
-
type: Jsep.MEMBER_EXP,
|
|
21722
|
-
computed: false,
|
|
21723
|
-
object: node,
|
|
21724
|
-
property: this.gobbleIdentifier()
|
|
21725
|
-
};
|
|
21726
|
-
}
|
|
21727
|
-
if (optional) {
|
|
21728
|
-
node.optional = true;
|
|
21729
|
-
}
|
|
21730
|
-
this.gobbleSpaces();
|
|
21731
|
-
ch = this.code;
|
|
21732
|
-
}
|
|
21733
|
-
return node;
|
|
21734
|
-
}
|
|
21735
|
-
gobbleNumericLiteral() {
|
|
21736
|
-
let number = "", ch, chCode;
|
|
21737
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
21738
|
-
number += this.expr.charAt(this.index++);
|
|
21739
|
-
}
|
|
21740
|
-
if (this.code === Jsep.PERIOD_CODE) {
|
|
21741
|
-
number += this.expr.charAt(this.index++);
|
|
21742
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
21743
|
-
number += this.expr.charAt(this.index++);
|
|
21744
|
-
}
|
|
21745
|
-
}
|
|
21746
|
-
ch = this.char;
|
|
21747
|
-
if (ch === "e" || ch === "E") {
|
|
21748
|
-
number += this.expr.charAt(this.index++);
|
|
21749
|
-
ch = this.char;
|
|
21750
|
-
if (ch === "+" || ch === "-") {
|
|
21751
|
-
number += this.expr.charAt(this.index++);
|
|
21752
|
-
}
|
|
21753
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
21754
|
-
number += this.expr.charAt(this.index++);
|
|
21755
|
-
}
|
|
21756
|
-
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
21757
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
21758
|
-
}
|
|
21759
|
-
}
|
|
21760
|
-
chCode = this.code;
|
|
21761
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
21762
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
21763
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
21764
|
-
this.throwError("Unexpected period");
|
|
21765
|
-
}
|
|
21766
|
-
return {
|
|
21767
|
-
type: Jsep.LITERAL,
|
|
21768
|
-
value: parseFloat(number),
|
|
21769
|
-
raw: number
|
|
21770
|
-
};
|
|
21771
|
-
}
|
|
21772
|
-
gobbleStringLiteral() {
|
|
21773
|
-
let str = "";
|
|
21774
|
-
const startIndex = this.index;
|
|
21775
|
-
const quote = this.expr.charAt(this.index++);
|
|
21776
|
-
let closed = false;
|
|
21777
|
-
while (this.index < this.expr.length) {
|
|
21778
|
-
let ch = this.expr.charAt(this.index++);
|
|
21779
|
-
if (ch === quote) {
|
|
21780
|
-
closed = true;
|
|
21781
|
-
break;
|
|
21782
|
-
} else if (ch === "\\") {
|
|
21783
|
-
ch = this.expr.charAt(this.index++);
|
|
21784
|
-
switch (ch) {
|
|
21785
|
-
case "n":
|
|
21786
|
-
str += `
|
|
21787
|
-
`;
|
|
21788
|
-
break;
|
|
21789
|
-
case "r":
|
|
21790
|
-
str += "\r";
|
|
21791
|
-
break;
|
|
21792
|
-
case "t":
|
|
21793
|
-
str += "\t";
|
|
21794
|
-
break;
|
|
21795
|
-
case "b":
|
|
21796
|
-
str += "\b";
|
|
21797
|
-
break;
|
|
21798
|
-
case "f":
|
|
21799
|
-
str += "\f";
|
|
21800
|
-
break;
|
|
21801
|
-
case "v":
|
|
21802
|
-
str += "\v";
|
|
21803
|
-
break;
|
|
21804
|
-
default:
|
|
21805
|
-
str += ch;
|
|
21806
|
-
}
|
|
21807
|
-
} else {
|
|
21808
|
-
str += ch;
|
|
21809
|
-
}
|
|
21810
|
-
}
|
|
21811
|
-
if (!closed) {
|
|
21812
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
21813
|
-
}
|
|
21814
|
-
return {
|
|
21815
|
-
type: Jsep.LITERAL,
|
|
21816
|
-
value: str,
|
|
21817
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
21818
|
-
};
|
|
21819
|
-
}
|
|
21820
|
-
gobbleIdentifier() {
|
|
21821
|
-
let ch = this.code, start = this.index;
|
|
21822
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
21823
|
-
this.index++;
|
|
21824
|
-
} else {
|
|
21825
|
-
this.throwError("Unexpected " + this.char);
|
|
21826
|
-
}
|
|
21827
|
-
while (this.index < this.expr.length) {
|
|
21828
|
-
ch = this.code;
|
|
21829
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
21830
|
-
this.index++;
|
|
21831
|
-
} else {
|
|
21832
|
-
break;
|
|
21833
|
-
}
|
|
21834
|
-
}
|
|
21835
|
-
return {
|
|
21836
|
-
type: Jsep.IDENTIFIER,
|
|
21837
|
-
name: this.expr.slice(start, this.index)
|
|
21838
|
-
};
|
|
21839
|
-
}
|
|
21840
|
-
gobbleArguments(termination) {
|
|
21841
|
-
const args = [];
|
|
21842
|
-
let closed = false;
|
|
21843
|
-
let separator_count = 0;
|
|
21844
|
-
while (this.index < this.expr.length) {
|
|
21845
|
-
this.gobbleSpaces();
|
|
21846
|
-
let ch_i = this.code;
|
|
21847
|
-
if (ch_i === termination) {
|
|
21848
|
-
closed = true;
|
|
21849
|
-
this.index++;
|
|
21850
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
21851
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
21852
|
-
}
|
|
21853
|
-
break;
|
|
21854
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
21855
|
-
this.index++;
|
|
21856
|
-
separator_count++;
|
|
21857
|
-
if (separator_count !== args.length) {
|
|
21858
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
21859
|
-
this.throwError("Unexpected token ,");
|
|
21860
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
21861
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
21862
|
-
args.push(null);
|
|
21863
|
-
}
|
|
21864
|
-
}
|
|
21865
|
-
}
|
|
21866
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
21867
|
-
this.throwError("Expected comma");
|
|
21868
|
-
} else {
|
|
21869
|
-
const node = this.gobbleExpression();
|
|
21870
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
21871
|
-
this.throwError("Expected comma");
|
|
21872
|
-
}
|
|
21873
|
-
args.push(node);
|
|
21874
|
-
}
|
|
21875
|
-
}
|
|
21876
|
-
if (!closed) {
|
|
21877
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
21878
|
-
}
|
|
21879
|
-
return args;
|
|
21880
|
-
}
|
|
21881
|
-
gobbleGroup() {
|
|
21882
|
-
this.index++;
|
|
21883
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
21884
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
21885
|
-
this.index++;
|
|
21886
|
-
if (nodes.length === 1) {
|
|
21887
|
-
return nodes[0];
|
|
21888
|
-
} else if (!nodes.length) {
|
|
21889
|
-
return false;
|
|
21890
|
-
} else {
|
|
21891
|
-
return {
|
|
21892
|
-
type: Jsep.SEQUENCE_EXP,
|
|
21893
|
-
expressions: nodes
|
|
21894
|
-
};
|
|
21895
|
-
}
|
|
21896
|
-
} else {
|
|
21897
|
-
this.throwError("Unclosed (");
|
|
21898
|
-
}
|
|
21899
|
-
}
|
|
21900
|
-
gobbleArray() {
|
|
21901
|
-
this.index++;
|
|
21902
|
-
return {
|
|
21903
|
-
type: Jsep.ARRAY_EXP,
|
|
21904
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
21905
|
-
};
|
|
21906
|
-
}
|
|
21907
|
-
}
|
|
21908
|
-
var hooks = new Hooks;
|
|
21909
|
-
Object.assign(Jsep, {
|
|
21910
|
-
hooks,
|
|
21911
|
-
plugins: new Plugins(Jsep),
|
|
21912
|
-
COMPOUND: "Compound",
|
|
21913
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
21914
|
-
IDENTIFIER: "Identifier",
|
|
21915
|
-
MEMBER_EXP: "MemberExpression",
|
|
21916
|
-
LITERAL: "Literal",
|
|
21917
|
-
THIS_EXP: "ThisExpression",
|
|
21918
|
-
CALL_EXP: "CallExpression",
|
|
21919
|
-
UNARY_EXP: "UnaryExpression",
|
|
21920
|
-
BINARY_EXP: "BinaryExpression",
|
|
21921
|
-
ARRAY_EXP: "ArrayExpression",
|
|
21922
|
-
TAB_CODE: 9,
|
|
21923
|
-
LF_CODE: 10,
|
|
21924
|
-
CR_CODE: 13,
|
|
21925
|
-
SPACE_CODE: 32,
|
|
21926
|
-
PERIOD_CODE: 46,
|
|
21927
|
-
COMMA_CODE: 44,
|
|
21928
|
-
SQUOTE_CODE: 39,
|
|
21929
|
-
DQUOTE_CODE: 34,
|
|
21930
|
-
OPAREN_CODE: 40,
|
|
21931
|
-
CPAREN_CODE: 41,
|
|
21932
|
-
OBRACK_CODE: 91,
|
|
21933
|
-
CBRACK_CODE: 93,
|
|
21934
|
-
QUMARK_CODE: 63,
|
|
21935
|
-
SEMCOL_CODE: 59,
|
|
21936
|
-
COLON_CODE: 58,
|
|
21937
|
-
unary_ops: {
|
|
21938
|
-
"-": 1,
|
|
21939
|
-
"!": 1,
|
|
21940
|
-
"~": 1,
|
|
21941
|
-
"+": 1
|
|
21942
|
-
},
|
|
21943
|
-
binary_ops: {
|
|
21944
|
-
"||": 1,
|
|
21945
|
-
"??": 1,
|
|
21946
|
-
"&&": 2,
|
|
21947
|
-
"|": 3,
|
|
21948
|
-
"^": 4,
|
|
21949
|
-
"&": 5,
|
|
21950
|
-
"==": 6,
|
|
21951
|
-
"!=": 6,
|
|
21952
|
-
"===": 6,
|
|
21953
|
-
"!==": 6,
|
|
21954
|
-
"<": 7,
|
|
21955
|
-
">": 7,
|
|
21956
|
-
"<=": 7,
|
|
21957
|
-
">=": 7,
|
|
21958
|
-
"<<": 8,
|
|
21959
|
-
">>": 8,
|
|
21960
|
-
">>>": 8,
|
|
21961
|
-
"+": 9,
|
|
21962
|
-
"-": 9,
|
|
21963
|
-
"*": 10,
|
|
21964
|
-
"/": 10,
|
|
21965
|
-
"%": 10,
|
|
21966
|
-
"**": 11
|
|
21967
|
-
},
|
|
21968
|
-
right_associative: new Set(["**"]),
|
|
21969
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
21970
|
-
literals: {
|
|
21971
|
-
true: true,
|
|
21972
|
-
false: false,
|
|
21973
|
-
null: null
|
|
21974
|
-
},
|
|
21975
|
-
this_str: "this"
|
|
21976
|
-
});
|
|
21977
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
21978
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
21979
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
21980
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
21981
|
-
});
|
|
21982
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
21983
|
-
jsep[m] = Jsep[m];
|
|
21984
|
-
});
|
|
21985
|
-
jsep.Jsep = Jsep;
|
|
21986
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
21987
|
-
var ternary = {
|
|
21988
|
-
name: "ternary",
|
|
21989
|
-
init(jsep2) {
|
|
21990
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env2) {
|
|
21991
|
-
if (env2.node && this.code === jsep2.QUMARK_CODE) {
|
|
21992
|
-
this.index++;
|
|
21993
|
-
const test = env2.node;
|
|
21994
|
-
const consequent = this.gobbleExpression();
|
|
21995
|
-
if (!consequent) {
|
|
21996
|
-
this.throwError("Expected expression");
|
|
21997
|
-
}
|
|
21998
|
-
this.gobbleSpaces();
|
|
21999
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
22000
|
-
this.index++;
|
|
22001
|
-
const alternate = this.gobbleExpression();
|
|
22002
|
-
if (!alternate) {
|
|
22003
|
-
this.throwError("Expected expression");
|
|
22004
|
-
}
|
|
22005
|
-
env2.node = {
|
|
22006
|
-
type: CONDITIONAL_EXP,
|
|
22007
|
-
test,
|
|
22008
|
-
consequent,
|
|
22009
|
-
alternate
|
|
22010
|
-
};
|
|
22011
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
22012
|
-
let newTest = test;
|
|
22013
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
22014
|
-
newTest = newTest.right;
|
|
22015
|
-
}
|
|
22016
|
-
env2.node.test = newTest.right;
|
|
22017
|
-
newTest.right = env2.node;
|
|
22018
|
-
env2.node = test;
|
|
22019
|
-
}
|
|
22020
|
-
} else {
|
|
22021
|
-
this.throwError("Expected :");
|
|
22022
|
-
}
|
|
22023
|
-
}
|
|
22024
|
-
});
|
|
22025
|
-
}
|
|
22026
|
-
};
|
|
22027
|
-
jsep.plugins.register(ternary);
|
|
22028
|
-
var FSLASH_CODE = 47;
|
|
22029
|
-
var BSLASH_CODE = 92;
|
|
22030
|
-
var index = {
|
|
22031
|
-
name: "regex",
|
|
22032
|
-
init(jsep2) {
|
|
22033
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env2) {
|
|
22034
|
-
if (this.code === FSLASH_CODE) {
|
|
22035
|
-
const patternIndex = ++this.index;
|
|
22036
|
-
let inCharSet = false;
|
|
22037
|
-
while (this.index < this.expr.length) {
|
|
22038
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
22039
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
22040
|
-
let flags = "";
|
|
22041
|
-
while (++this.index < this.expr.length) {
|
|
22042
|
-
const code2 = this.code;
|
|
22043
|
-
if (code2 >= 97 && code2 <= 122 || code2 >= 65 && code2 <= 90 || code2 >= 48 && code2 <= 57) {
|
|
22044
|
-
flags += this.char;
|
|
22045
|
-
} else {
|
|
22046
|
-
break;
|
|
22047
|
-
}
|
|
22048
|
-
}
|
|
22049
|
-
let value;
|
|
22050
|
-
try {
|
|
22051
|
-
value = new RegExp(pattern, flags);
|
|
22052
|
-
} catch (e) {
|
|
22053
|
-
this.throwError(e.message);
|
|
22054
|
-
}
|
|
22055
|
-
env2.node = {
|
|
22056
|
-
type: jsep2.LITERAL,
|
|
22057
|
-
value,
|
|
22058
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
22059
|
-
};
|
|
22060
|
-
env2.node = this.gobbleTokenProperty(env2.node);
|
|
22061
|
-
return env2.node;
|
|
22062
|
-
}
|
|
22063
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
22064
|
-
inCharSet = true;
|
|
22065
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
22066
|
-
inCharSet = false;
|
|
22067
|
-
}
|
|
22068
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
22069
|
-
}
|
|
22070
|
-
this.throwError("Unclosed Regex");
|
|
22071
|
-
}
|
|
22072
|
-
});
|
|
22073
|
-
}
|
|
22074
|
-
};
|
|
22075
|
-
var PLUS_CODE = 43;
|
|
22076
|
-
var MINUS_CODE = 45;
|
|
22077
|
-
var plugin = {
|
|
22078
|
-
name: "assignment",
|
|
22079
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
22080
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
22081
|
-
assignmentPrecedence: 0.9,
|
|
22082
|
-
init(jsep2) {
|
|
22083
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
22084
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
22085
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env2) {
|
|
22086
|
-
const code2 = this.code;
|
|
22087
|
-
if (plugin.updateOperators.some((c) => c === code2 && c === this.expr.charCodeAt(this.index + 1))) {
|
|
22088
|
-
this.index += 2;
|
|
22089
|
-
env2.node = {
|
|
22090
|
-
type: "UpdateExpression",
|
|
22091
|
-
operator: code2 === PLUS_CODE ? "++" : "--",
|
|
22092
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
22093
|
-
prefix: true
|
|
22094
|
-
};
|
|
22095
|
-
if (!env2.node.argument || !updateNodeTypes.includes(env2.node.argument.type)) {
|
|
22096
|
-
this.throwError(`Unexpected ${env2.node.operator}`);
|
|
22097
|
-
}
|
|
22098
|
-
}
|
|
22099
|
-
});
|
|
22100
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env2) {
|
|
22101
|
-
if (env2.node) {
|
|
22102
|
-
const code2 = this.code;
|
|
22103
|
-
if (plugin.updateOperators.some((c) => c === code2 && c === this.expr.charCodeAt(this.index + 1))) {
|
|
22104
|
-
if (!updateNodeTypes.includes(env2.node.type)) {
|
|
22105
|
-
this.throwError(`Unexpected ${env2.node.operator}`);
|
|
22106
|
-
}
|
|
22107
|
-
this.index += 2;
|
|
22108
|
-
env2.node = {
|
|
22109
|
-
type: "UpdateExpression",
|
|
22110
|
-
operator: code2 === PLUS_CODE ? "++" : "--",
|
|
22111
|
-
argument: env2.node,
|
|
22112
|
-
prefix: false
|
|
22113
|
-
};
|
|
22114
|
-
}
|
|
22115
|
-
}
|
|
22116
|
-
});
|
|
22117
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env2) {
|
|
22118
|
-
if (env2.node) {
|
|
22119
|
-
updateBinariesToAssignments(env2.node);
|
|
22120
|
-
}
|
|
22121
|
-
});
|
|
22122
|
-
function updateBinariesToAssignments(node) {
|
|
22123
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
22124
|
-
node.type = "AssignmentExpression";
|
|
22125
|
-
updateBinariesToAssignments(node.left);
|
|
22126
|
-
updateBinariesToAssignments(node.right);
|
|
22127
|
-
} else if (!node.operator) {
|
|
22128
|
-
Object.values(node).forEach((val) => {
|
|
22129
|
-
if (val && typeof val === "object") {
|
|
22130
|
-
updateBinariesToAssignments(val);
|
|
22131
|
-
}
|
|
22132
|
-
});
|
|
22133
|
-
}
|
|
22134
|
-
}
|
|
22135
|
-
}
|
|
22136
|
-
};
|
|
22137
|
-
jsep.plugins.register(index, plugin);
|
|
22138
|
-
jsep.addUnaryOp("typeof");
|
|
22139
|
-
jsep.addUnaryOp("void");
|
|
22140
|
-
jsep.addLiteral("null", null);
|
|
22141
|
-
jsep.addLiteral("undefined", undefined);
|
|
22142
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
22143
|
-
var SafeEval = {
|
|
22144
|
-
evalAst(ast, subs) {
|
|
22145
|
-
switch (ast.type) {
|
|
22146
|
-
case "BinaryExpression":
|
|
22147
|
-
case "LogicalExpression":
|
|
22148
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
22149
|
-
case "Compound":
|
|
22150
|
-
return SafeEval.evalCompound(ast, subs);
|
|
22151
|
-
case "ConditionalExpression":
|
|
22152
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
22153
|
-
case "Identifier":
|
|
22154
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
22155
|
-
case "Literal":
|
|
22156
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
22157
|
-
case "MemberExpression":
|
|
22158
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
22159
|
-
case "UnaryExpression":
|
|
22160
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
22161
|
-
case "ArrayExpression":
|
|
22162
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
22163
|
-
case "CallExpression":
|
|
22164
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
22165
|
-
case "AssignmentExpression":
|
|
22166
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
22167
|
-
default:
|
|
22168
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
22169
|
-
}
|
|
22170
|
-
},
|
|
22171
|
-
evalBinaryExpression(ast, subs) {
|
|
22172
|
-
const result = {
|
|
22173
|
-
"||": (a, b) => a || b(),
|
|
22174
|
-
"&&": (a, b) => a && b(),
|
|
22175
|
-
"|": (a, b) => a | b(),
|
|
22176
|
-
"^": (a, b) => a ^ b(),
|
|
22177
|
-
"&": (a, b) => a & b(),
|
|
22178
|
-
"==": (a, b) => a == b(),
|
|
22179
|
-
"!=": (a, b) => a != b(),
|
|
22180
|
-
"===": (a, b) => a === b(),
|
|
22181
|
-
"!==": (a, b) => a !== b(),
|
|
22182
|
-
"<": (a, b) => a < b(),
|
|
22183
|
-
">": (a, b) => a > b(),
|
|
22184
|
-
"<=": (a, b) => a <= b(),
|
|
22185
|
-
">=": (a, b) => a >= b(),
|
|
22186
|
-
"<<": (a, b) => a << b(),
|
|
22187
|
-
">>": (a, b) => a >> b(),
|
|
22188
|
-
">>>": (a, b) => a >>> b(),
|
|
22189
|
-
"+": (a, b) => a + b(),
|
|
22190
|
-
"-": (a, b) => a - b(),
|
|
22191
|
-
"*": (a, b) => a * b(),
|
|
22192
|
-
"/": (a, b) => a / b(),
|
|
22193
|
-
"%": (a, b) => a % b()
|
|
22194
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
22195
|
-
return result;
|
|
22196
|
-
},
|
|
22197
|
-
evalCompound(ast, subs) {
|
|
22198
|
-
let last;
|
|
22199
|
-
for (let i2 = 0;i2 < ast.body.length; i2++) {
|
|
22200
|
-
if (ast.body[i2].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i2].name) && ast.body[i2 + 1] && ast.body[i2 + 1].type === "AssignmentExpression") {
|
|
22201
|
-
i2 += 1;
|
|
22202
|
-
}
|
|
22203
|
-
const expr = ast.body[i2];
|
|
22204
|
-
last = SafeEval.evalAst(expr, subs);
|
|
22205
|
-
}
|
|
22206
|
-
return last;
|
|
22207
|
-
},
|
|
22208
|
-
evalConditionalExpression(ast, subs) {
|
|
22209
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
22210
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
22211
|
-
}
|
|
22212
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
22213
|
-
},
|
|
22214
|
-
evalIdentifier(ast, subs) {
|
|
22215
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
22216
|
-
return subs[ast.name];
|
|
22217
|
-
}
|
|
22218
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
22219
|
-
},
|
|
22220
|
-
evalLiteral(ast) {
|
|
22221
|
-
return ast.value;
|
|
22222
|
-
},
|
|
22223
|
-
evalMemberExpression(ast, subs) {
|
|
22224
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
22225
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
22226
|
-
if (obj === undefined || obj === null) {
|
|
22227
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
22228
|
-
}
|
|
22229
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
22230
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
22231
|
-
}
|
|
22232
|
-
const result = obj[prop];
|
|
22233
|
-
if (typeof result === "function") {
|
|
22234
|
-
return result.bind(obj);
|
|
22235
|
-
}
|
|
22236
|
-
return result;
|
|
22237
|
-
},
|
|
22238
|
-
evalUnaryExpression(ast, subs) {
|
|
22239
|
-
const result = {
|
|
22240
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
22241
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
22242
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
22243
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
22244
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
22245
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
22246
|
-
}[ast.operator](ast.argument);
|
|
22247
|
-
return result;
|
|
22248
|
-
},
|
|
22249
|
-
evalArrayExpression(ast, subs) {
|
|
22250
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
22251
|
-
},
|
|
22252
|
-
evalCallExpression(ast, subs) {
|
|
22253
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
22254
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
22255
|
-
if (func === Function) {
|
|
22256
|
-
throw new Error("Function constructor is disabled");
|
|
22257
|
-
}
|
|
22258
|
-
return func(...args);
|
|
22259
|
-
},
|
|
22260
|
-
evalAssignmentExpression(ast, subs) {
|
|
22261
|
-
if (ast.left.type !== "Identifier") {
|
|
22262
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
22263
|
-
}
|
|
22264
|
-
const id = ast.left.name;
|
|
22265
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
22266
|
-
subs[id] = value;
|
|
22267
|
-
return subs[id];
|
|
22268
|
-
}
|
|
22269
|
-
};
|
|
22270
|
-
|
|
22271
|
-
class SafeScript {
|
|
22272
|
-
constructor(expr) {
|
|
22273
|
-
this.code = expr;
|
|
22274
|
-
this.ast = jsep(this.code);
|
|
22275
|
-
}
|
|
22276
|
-
runInNewContext(context) {
|
|
22277
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
22278
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
22279
|
-
}
|
|
22280
|
-
}
|
|
22281
|
-
function push(arr, item) {
|
|
22282
|
-
arr = arr.slice();
|
|
22283
|
-
arr.push(item);
|
|
22284
|
-
return arr;
|
|
22285
|
-
}
|
|
22286
|
-
function unshift(item, arr) {
|
|
22287
|
-
arr = arr.slice();
|
|
22288
|
-
arr.unshift(item);
|
|
22289
|
-
return arr;
|
|
22290
|
-
}
|
|
22291
|
-
|
|
22292
|
-
class NewError extends Error {
|
|
22293
|
-
constructor(value) {
|
|
22294
|
-
super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
|
|
22295
|
-
this.avoidNew = true;
|
|
22296
|
-
this.value = value;
|
|
22297
|
-
this.name = "NewError";
|
|
22298
|
-
}
|
|
22299
|
-
}
|
|
22300
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
22301
|
-
if (!(this instanceof JSONPath)) {
|
|
22302
|
-
try {
|
|
22303
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
22304
|
-
} catch (e) {
|
|
22305
|
-
if (!e.avoidNew) {
|
|
22306
|
-
throw e;
|
|
22307
|
-
}
|
|
22308
|
-
return e.value;
|
|
22309
|
-
}
|
|
22310
|
-
}
|
|
22311
|
-
if (typeof opts === "string") {
|
|
22312
|
-
otherTypeCallback = callback;
|
|
22313
|
-
callback = obj;
|
|
22314
|
-
obj = expr;
|
|
22315
|
-
expr = opts;
|
|
22316
|
-
opts = null;
|
|
22317
|
-
}
|
|
22318
|
-
const optObj = opts && typeof opts === "object";
|
|
22319
|
-
opts = opts || {};
|
|
22320
|
-
this.json = opts.json || obj;
|
|
22321
|
-
this.path = opts.path || expr;
|
|
22322
|
-
this.resultType = opts.resultType || "value";
|
|
22323
|
-
this.flatten = opts.flatten || false;
|
|
22324
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
22325
|
-
this.sandbox = opts.sandbox || {};
|
|
22326
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
22327
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
22328
|
-
this.parent = opts.parent || null;
|
|
22329
|
-
this.parentProperty = opts.parentProperty || null;
|
|
22330
|
-
this.callback = opts.callback || callback || null;
|
|
22331
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
22332
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
22333
|
-
};
|
|
22334
|
-
if (opts.autostart !== false) {
|
|
22335
|
-
const args = {
|
|
22336
|
-
path: optObj ? opts.path : expr
|
|
22337
|
-
};
|
|
22338
|
-
if (!optObj) {
|
|
22339
|
-
args.json = obj;
|
|
22340
|
-
} else if ("json" in opts) {
|
|
22341
|
-
args.json = opts.json;
|
|
22342
|
-
}
|
|
22343
|
-
const ret = this.evaluate(args);
|
|
22344
|
-
if (!ret || typeof ret !== "object") {
|
|
22345
|
-
throw new NewError(ret);
|
|
22346
|
-
}
|
|
22347
|
-
return ret;
|
|
22348
|
-
}
|
|
22349
|
-
}
|
|
22350
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
22351
|
-
let currParent = this.parent, currParentProperty = this.parentProperty;
|
|
22352
|
-
let {
|
|
22353
|
-
flatten,
|
|
22354
|
-
wrap
|
|
22355
|
-
} = this;
|
|
22356
|
-
this.currResultType = this.resultType;
|
|
22357
|
-
this.currEval = this.eval;
|
|
22358
|
-
this.currSandbox = this.sandbox;
|
|
22359
|
-
callback = callback || this.callback;
|
|
22360
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
22361
|
-
json = json || this.json;
|
|
22362
|
-
expr = expr || this.path;
|
|
22363
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
22364
|
-
if (!expr.path && expr.path !== "") {
|
|
22365
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
22366
|
-
}
|
|
22367
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
22368
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
22369
|
-
}
|
|
22370
|
-
({
|
|
22371
|
-
json
|
|
22372
|
-
} = expr);
|
|
22373
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
22374
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
22375
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
22376
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
22377
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
22378
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
22379
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
22380
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
22381
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
22382
|
-
expr = expr.path;
|
|
22383
|
-
}
|
|
22384
|
-
currParent = currParent || null;
|
|
22385
|
-
currParentProperty = currParentProperty || null;
|
|
22386
|
-
if (Array.isArray(expr)) {
|
|
22387
|
-
expr = JSONPath.toPathString(expr);
|
|
22388
|
-
}
|
|
22389
|
-
if (!expr && expr !== "" || !json) {
|
|
22390
|
-
return;
|
|
22391
|
-
}
|
|
22392
|
-
const exprList = JSONPath.toPathArray(expr);
|
|
22393
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
22394
|
-
exprList.shift();
|
|
22395
|
-
}
|
|
22396
|
-
this._hasParentSelector = null;
|
|
22397
|
-
const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
22398
|
-
return ea && !ea.isParentSelector;
|
|
22399
|
-
});
|
|
22400
|
-
if (!result.length) {
|
|
22401
|
-
return wrap ? [] : undefined;
|
|
22402
|
-
}
|
|
22403
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
22404
|
-
return this._getPreferredOutput(result[0]);
|
|
22405
|
-
}
|
|
22406
|
-
return result.reduce((rslt, ea) => {
|
|
22407
|
-
const valOrPath = this._getPreferredOutput(ea);
|
|
22408
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
22409
|
-
rslt = rslt.concat(valOrPath);
|
|
22410
|
-
} else {
|
|
22411
|
-
rslt.push(valOrPath);
|
|
22412
|
-
}
|
|
22413
|
-
return rslt;
|
|
22414
|
-
}, []);
|
|
22415
|
-
};
|
|
22416
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
22417
|
-
const resultType = this.currResultType;
|
|
22418
|
-
switch (resultType) {
|
|
22419
|
-
case "all": {
|
|
22420
|
-
const path = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
22421
|
-
ea.pointer = JSONPath.toPointer(path);
|
|
22422
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
22423
|
-
return ea;
|
|
22424
|
-
}
|
|
22425
|
-
case "value":
|
|
22426
|
-
case "parent":
|
|
22427
|
-
case "parentProperty":
|
|
22428
|
-
return ea[resultType];
|
|
22429
|
-
case "path":
|
|
22430
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
22431
|
-
case "pointer":
|
|
22432
|
-
return JSONPath.toPointer(ea.path);
|
|
22433
|
-
default:
|
|
22434
|
-
throw new TypeError("Unknown result type");
|
|
22435
|
-
}
|
|
22436
|
-
};
|
|
22437
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
22438
|
-
if (callback) {
|
|
22439
|
-
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
22440
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
22441
|
-
callback(preferredOutput, type, fullRetObj);
|
|
22442
|
-
}
|
|
22443
|
-
};
|
|
22444
|
-
JSONPath.prototype._trace = function(expr, val, path, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
22445
|
-
let retObj;
|
|
22446
|
-
if (!expr.length) {
|
|
22447
|
-
retObj = {
|
|
22448
|
-
path,
|
|
22449
|
-
value: val,
|
|
22450
|
-
parent,
|
|
22451
|
-
parentProperty: parentPropName,
|
|
22452
|
-
hasArrExpr
|
|
22453
|
-
};
|
|
22454
|
-
this._handleCallback(retObj, callback, "value");
|
|
22455
|
-
return retObj;
|
|
22456
|
-
}
|
|
22457
|
-
const loc = expr[0], x = expr.slice(1);
|
|
22458
|
-
const ret = [];
|
|
22459
|
-
function addRet(elems) {
|
|
22460
|
-
if (Array.isArray(elems)) {
|
|
22461
|
-
elems.forEach((t) => {
|
|
22462
|
-
ret.push(t);
|
|
22463
|
-
});
|
|
22464
|
-
} else {
|
|
22465
|
-
ret.push(elems);
|
|
22466
|
-
}
|
|
22467
|
-
}
|
|
22468
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
22469
|
-
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr));
|
|
22470
|
-
} else if (loc === "*") {
|
|
22471
|
-
this._walk(val, (m) => {
|
|
22472
|
-
addRet(this._trace(x, val[m], push(path, m), val, m, callback, true, true));
|
|
22473
|
-
});
|
|
22474
|
-
} else if (loc === "..") {
|
|
22475
|
-
addRet(this._trace(x, val, path, parent, parentPropName, callback, hasArrExpr));
|
|
22476
|
-
this._walk(val, (m) => {
|
|
22477
|
-
if (typeof val[m] === "object") {
|
|
22478
|
-
addRet(this._trace(expr.slice(), val[m], push(path, m), val, m, callback, true));
|
|
22479
|
-
}
|
|
22480
|
-
});
|
|
22481
|
-
} else if (loc === "^") {
|
|
22482
|
-
this._hasParentSelector = true;
|
|
22483
|
-
return {
|
|
22484
|
-
path: path.slice(0, -1),
|
|
22485
|
-
expr: x,
|
|
22486
|
-
isParentSelector: true
|
|
22487
|
-
};
|
|
22488
|
-
} else if (loc === "~") {
|
|
22489
|
-
retObj = {
|
|
22490
|
-
path: push(path, loc),
|
|
22491
|
-
value: parentPropName,
|
|
22492
|
-
parent,
|
|
22493
|
-
parentProperty: null
|
|
22494
|
-
};
|
|
22495
|
-
this._handleCallback(retObj, callback, "property");
|
|
22496
|
-
return retObj;
|
|
22497
|
-
} else if (loc === "$") {
|
|
22498
|
-
addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));
|
|
22499
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
22500
|
-
addRet(this._slice(loc, x, val, path, parent, parentPropName, callback));
|
|
22501
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
22502
|
-
if (this.currEval === false) {
|
|
22503
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
22504
|
-
}
|
|
22505
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
22506
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
22507
|
-
if (nested) {
|
|
22508
|
-
this._walk(val, (m) => {
|
|
22509
|
-
const npath = [nested[2]];
|
|
22510
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
22511
|
-
const filterResults = this._trace(npath, nvalue, path, parent, parentPropName, callback, true);
|
|
22512
|
-
if (filterResults.length > 0) {
|
|
22513
|
-
addRet(this._trace(x, val[m], push(path, m), val, m, callback, true));
|
|
22514
|
-
}
|
|
22515
|
-
});
|
|
22516
|
-
} else {
|
|
22517
|
-
this._walk(val, (m) => {
|
|
22518
|
-
if (this._eval(safeLoc, val[m], m, path, parent, parentPropName)) {
|
|
22519
|
-
addRet(this._trace(x, val[m], push(path, m), val, m, callback, true));
|
|
22520
|
-
}
|
|
22521
|
-
});
|
|
22522
|
-
}
|
|
22523
|
-
} else if (loc[0] === "(") {
|
|
22524
|
-
if (this.currEval === false) {
|
|
22525
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
22526
|
-
}
|
|
22527
|
-
addRet(this._trace(unshift(this._eval(loc, val, path.at(-1), path.slice(0, -1), parent, parentPropName), x), val, path, parent, parentPropName, callback, hasArrExpr));
|
|
22528
|
-
} else if (loc[0] === "@") {
|
|
22529
|
-
let addType = false;
|
|
22530
|
-
const valueType = loc.slice(1, -2);
|
|
22531
|
-
switch (valueType) {
|
|
22532
|
-
case "scalar":
|
|
22533
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
22534
|
-
addType = true;
|
|
22535
|
-
}
|
|
22536
|
-
break;
|
|
22537
|
-
case "boolean":
|
|
22538
|
-
case "string":
|
|
22539
|
-
case "undefined":
|
|
22540
|
-
case "function":
|
|
22541
|
-
if (typeof val === valueType) {
|
|
22542
|
-
addType = true;
|
|
22543
|
-
}
|
|
22544
|
-
break;
|
|
22545
|
-
case "integer":
|
|
22546
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
22547
|
-
addType = true;
|
|
22548
|
-
}
|
|
22549
|
-
break;
|
|
22550
|
-
case "number":
|
|
22551
|
-
if (Number.isFinite(val)) {
|
|
22552
|
-
addType = true;
|
|
22553
|
-
}
|
|
22554
|
-
break;
|
|
22555
|
-
case "nonFinite":
|
|
22556
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
22557
|
-
addType = true;
|
|
22558
|
-
}
|
|
22559
|
-
break;
|
|
22560
|
-
case "object":
|
|
22561
|
-
if (val && typeof val === valueType) {
|
|
22562
|
-
addType = true;
|
|
22563
|
-
}
|
|
22564
|
-
break;
|
|
22565
|
-
case "array":
|
|
22566
|
-
if (Array.isArray(val)) {
|
|
22567
|
-
addType = true;
|
|
22568
|
-
}
|
|
22569
|
-
break;
|
|
22570
|
-
case "other":
|
|
22571
|
-
addType = this.currOtherTypeCallback(val, path, parent, parentPropName);
|
|
22572
|
-
break;
|
|
22573
|
-
case "null":
|
|
22574
|
-
if (val === null) {
|
|
22575
|
-
addType = true;
|
|
22576
|
-
}
|
|
22577
|
-
break;
|
|
22578
|
-
default:
|
|
22579
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
22580
|
-
}
|
|
22581
|
-
if (addType) {
|
|
22582
|
-
retObj = {
|
|
22583
|
-
path,
|
|
22584
|
-
value: val,
|
|
22585
|
-
parent,
|
|
22586
|
-
parentProperty: parentPropName
|
|
22587
|
-
};
|
|
22588
|
-
this._handleCallback(retObj, callback, "value");
|
|
22589
|
-
return retObj;
|
|
22590
|
-
}
|
|
22591
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
22592
|
-
const locProp = loc.slice(1);
|
|
22593
|
-
addRet(this._trace(x, val[locProp], push(path, locProp), val, locProp, callback, hasArrExpr, true));
|
|
22594
|
-
} else if (loc.includes(",")) {
|
|
22595
|
-
const parts = loc.split(",");
|
|
22596
|
-
for (const part of parts) {
|
|
22597
|
-
addRet(this._trace(unshift(part, x), val, path, parent, parentPropName, callback, true));
|
|
22598
|
-
}
|
|
22599
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
22600
|
-
addRet(this._trace(x, val[loc], push(path, loc), val, loc, callback, hasArrExpr, true));
|
|
22601
|
-
}
|
|
22602
|
-
if (this._hasParentSelector) {
|
|
22603
|
-
for (let t = 0;t < ret.length; t++) {
|
|
22604
|
-
const rett = ret[t];
|
|
22605
|
-
if (rett && rett.isParentSelector) {
|
|
22606
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
22607
|
-
if (Array.isArray(tmp)) {
|
|
22608
|
-
ret[t] = tmp[0];
|
|
22609
|
-
const tl = tmp.length;
|
|
22610
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
22611
|
-
t++;
|
|
22612
|
-
ret.splice(t, 0, tmp[tt]);
|
|
22613
|
-
}
|
|
22614
|
-
} else {
|
|
22615
|
-
ret[t] = tmp;
|
|
22616
|
-
}
|
|
22617
|
-
}
|
|
22618
|
-
}
|
|
22619
|
-
}
|
|
22620
|
-
return ret;
|
|
22621
|
-
};
|
|
22622
|
-
JSONPath.prototype._walk = function(val, f) {
|
|
22623
|
-
if (Array.isArray(val)) {
|
|
22624
|
-
const n = val.length;
|
|
22625
|
-
for (let i2 = 0;i2 < n; i2++) {
|
|
22626
|
-
f(i2);
|
|
22627
|
-
}
|
|
22628
|
-
} else if (val && typeof val === "object") {
|
|
22629
|
-
Object.keys(val).forEach((m) => {
|
|
22630
|
-
f(m);
|
|
22631
|
-
});
|
|
22632
|
-
}
|
|
22633
|
-
};
|
|
22634
|
-
JSONPath.prototype._slice = function(loc, expr, val, path, parent, parentPropName, callback) {
|
|
22635
|
-
if (!Array.isArray(val)) {
|
|
22636
|
-
return;
|
|
22637
|
-
}
|
|
22638
|
-
const len2 = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
22639
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len2;
|
|
22640
|
-
start = start < 0 ? Math.max(0, start + len2) : Math.min(len2, start);
|
|
22641
|
-
end = end < 0 ? Math.max(0, end + len2) : Math.min(len2, end);
|
|
22642
|
-
const ret = [];
|
|
22643
|
-
for (let i2 = start;i2 < end; i2 += step) {
|
|
22644
|
-
const tmp = this._trace(unshift(i2, expr), val, path, parent, parentPropName, callback, true);
|
|
22645
|
-
tmp.forEach((t) => {
|
|
22646
|
-
ret.push(t);
|
|
22647
|
-
});
|
|
22648
|
-
}
|
|
22649
|
-
return ret;
|
|
22650
|
-
};
|
|
22651
|
-
JSONPath.prototype._eval = function(code2, _v, _vname, path, parent, parentPropName) {
|
|
22652
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
22653
|
-
this.currSandbox._$_parent = parent;
|
|
22654
|
-
this.currSandbox._$_property = _vname;
|
|
22655
|
-
this.currSandbox._$_root = this.json;
|
|
22656
|
-
this.currSandbox._$_v = _v;
|
|
22657
|
-
const containsPath = code2.includes("@path");
|
|
22658
|
-
if (containsPath) {
|
|
22659
|
-
this.currSandbox._$_path = JSONPath.toPathString(path.concat([_vname]));
|
|
22660
|
-
}
|
|
22661
|
-
const scriptCacheKey = this.currEval + "Script:" + code2;
|
|
22662
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
22663
|
-
let script = code2.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
22664
|
-
if (containsPath) {
|
|
22665
|
-
script = script.replaceAll("@path", "_$_path");
|
|
22666
|
-
}
|
|
22667
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
22668
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
22669
|
-
} else if (this.currEval === "native") {
|
|
22670
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
22671
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
22672
|
-
const CurrEval = this.currEval;
|
|
22673
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
22674
|
-
} else if (typeof this.currEval === "function") {
|
|
22675
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
22676
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
22677
|
-
};
|
|
22678
|
-
} else {
|
|
22679
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
22680
|
-
}
|
|
22681
|
-
}
|
|
22682
|
-
try {
|
|
22683
|
-
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
22684
|
-
} catch (e) {
|
|
22685
|
-
if (this.ignoreEvalErrors) {
|
|
22686
|
-
return false;
|
|
22687
|
-
}
|
|
22688
|
-
throw new Error("jsonPath: " + e.message + ": " + code2);
|
|
22689
|
-
}
|
|
22690
|
-
};
|
|
22691
|
-
JSONPath.cache = {};
|
|
22692
|
-
JSONPath.toPathString = function(pathArr) {
|
|
22693
|
-
const x = pathArr, n = x.length;
|
|
22694
|
-
let p = "$";
|
|
22695
|
-
for (let i2 = 1;i2 < n; i2++) {
|
|
22696
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i2])) {
|
|
22697
|
-
p += /^[0-9*]+$/u.test(x[i2]) ? "[" + x[i2] + "]" : "['" + x[i2] + "']";
|
|
22698
|
-
}
|
|
22699
|
-
}
|
|
22700
|
-
return p;
|
|
22701
|
-
};
|
|
22702
|
-
JSONPath.toPointer = function(pointer) {
|
|
22703
|
-
const x = pointer, n = x.length;
|
|
22704
|
-
let p = "";
|
|
22705
|
-
for (let i2 = 1;i2 < n; i2++) {
|
|
22706
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i2])) {
|
|
22707
|
-
p += "/" + x[i2].toString().replaceAll("~", "~0").replaceAll("/", "~1");
|
|
22708
|
-
}
|
|
22709
|
-
}
|
|
22710
|
-
return p;
|
|
22711
|
-
};
|
|
22712
|
-
JSONPath.toPathArray = function(expr) {
|
|
22713
|
-
const {
|
|
22714
|
-
cache
|
|
22715
|
-
} = JSONPath;
|
|
22716
|
-
if (cache[expr]) {
|
|
22717
|
-
return cache[expr].concat();
|
|
22718
|
-
}
|
|
22719
|
-
const subx = [];
|
|
22720
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
22721
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
22722
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
22723
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
22724
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
22725
|
-
return ";" + ups.split("").join(";") + ";";
|
|
22726
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
22727
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
22728
|
-
const match = exp.match(/#(\d+)/u);
|
|
22729
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
22730
|
-
});
|
|
22731
|
-
cache[expr] = exprList;
|
|
22732
|
-
return cache[expr].concat();
|
|
22733
|
-
};
|
|
22734
|
-
JSONPath.prototype.safeVm = {
|
|
22735
|
-
Script: SafeScript
|
|
22736
|
-
};
|
|
22737
|
-
var moveToAnotherArray = function(source, target, conditionCb) {
|
|
22738
|
-
const il = source.length;
|
|
22739
|
-
for (let i2 = 0;i2 < il; i2++) {
|
|
22740
|
-
const item = source[i2];
|
|
22741
|
-
if (conditionCb(item)) {
|
|
22742
|
-
target.push(source.splice(i2--, 1)[0]);
|
|
22743
|
-
}
|
|
22744
|
-
}
|
|
22745
|
-
};
|
|
22746
|
-
|
|
22747
|
-
class Script {
|
|
22748
|
-
constructor(expr) {
|
|
22749
|
-
this.code = expr;
|
|
22750
|
-
}
|
|
22751
|
-
runInNewContext(context) {
|
|
22752
|
-
let expr = this.code;
|
|
22753
|
-
const keys = Object.keys(context);
|
|
22754
|
-
const funcs = [];
|
|
22755
|
-
moveToAnotherArray(keys, funcs, (key) => {
|
|
22756
|
-
return typeof context[key] === "function";
|
|
22757
|
-
});
|
|
22758
|
-
const values = keys.map((vr) => {
|
|
22759
|
-
return context[vr];
|
|
22760
|
-
});
|
|
22761
|
-
const funcString = funcs.reduce((s, func) => {
|
|
22762
|
-
let fString = context[func].toString();
|
|
22763
|
-
if (!/function/u.test(fString)) {
|
|
22764
|
-
fString = "function " + fString;
|
|
22765
|
-
}
|
|
22766
|
-
return "var " + func + "=" + fString + ";" + s;
|
|
22767
|
-
}, "");
|
|
22768
|
-
expr = funcString + expr;
|
|
22769
|
-
if (!/(['"])use strict\1/u.test(expr) && !keys.includes("arguments")) {
|
|
22770
|
-
expr = "var arguments = undefined;" + expr;
|
|
22771
|
-
}
|
|
22772
|
-
expr = expr.replace(/;\s*$/u, "");
|
|
22773
|
-
const lastStatementEnd = expr.lastIndexOf(";");
|
|
22774
|
-
const code2 = lastStatementEnd !== -1 ? expr.slice(0, lastStatementEnd + 1) + " return " + expr.slice(lastStatementEnd + 1) : " return " + expr;
|
|
22775
|
-
return new Function(...keys, code2)(...values);
|
|
22776
|
-
}
|
|
22777
|
-
}
|
|
22778
|
-
JSONPath.prototype.vm = {
|
|
22779
|
-
Script
|
|
22780
|
-
};
|
|
22781
|
-
|
|
22782
|
-
// src/jsonpath.ts
|
|
22783
|
-
function evaluateJsonPath(data, expression) {
|
|
22784
|
-
const results = JSONPath({
|
|
22785
|
-
path: expression,
|
|
22786
|
-
json: data
|
|
22787
|
-
});
|
|
22788
|
-
if (results.length === 0) {
|
|
22789
|
-
return "";
|
|
22790
|
-
}
|
|
22791
|
-
return results.map((v) => v !== null && typeof v === "object" ? JSON.stringify(v) : String(v ?? "")).join(`
|
|
22792
|
-
`);
|
|
22793
|
-
}
|
|
22794
|
-
|
|
22795
|
-
class JsonPathError extends Error {
|
|
22796
|
-
constructor(message) {
|
|
22797
|
-
super(message);
|
|
22798
|
-
this.name = "JsonPathError";
|
|
22799
|
-
}
|
|
22800
|
-
}
|
|
22801
21386
|
// src/logger.ts
|
|
22802
21387
|
import { getFileSystem } from "@uipath/filesystem";
|
|
22803
21388
|
var logFilePathSlot = singleton("logFilePath");
|
|
@@ -23104,10 +21689,14 @@ function getOutputFilter() {
|
|
|
23104
21689
|
}
|
|
23105
21690
|
// src/package-metadata-options.ts
|
|
23106
21691
|
function registerPackageMetadataOptions(command) {
|
|
23107
|
-
return command.option("--repository-url <url>", "Source repository URL (recorded in the package for traceability)").option("--repository-commit <sha>", "Source repository commit hash (recorded in the package for traceability)").option("--repository-branch <branch>", "Source repository branch").option("--repository-type <type>", "Source repository type (defaults to 'git' when --repository-url is set)").option("--release-notes <text>", "Release notes for the package").option("--project-url <url>", "Automation Hub idea URL");
|
|
21692
|
+
return command.option("--author <author>", "Package author").option("--description <text>", "Package description").option("--repository-url <url>", "Source repository URL (recorded in the package for traceability)").option("--repository-commit <sha>", "Source repository commit hash (recorded in the package for traceability)").option("--repository-branch <branch>", "Source repository branch").option("--repository-type <type>", "Source repository type (defaults to 'git' when --repository-url is set)").option("--release-notes <text>", "Release notes for the package").option("--project-url <url>", "Automation Hub idea URL");
|
|
23108
21693
|
}
|
|
23109
21694
|
function mapPackageMetadataOptions(opts) {
|
|
23110
21695
|
const fields = {};
|
|
21696
|
+
if (opts.author !== undefined)
|
|
21697
|
+
fields.author = opts.author;
|
|
21698
|
+
if (opts.description !== undefined)
|
|
21699
|
+
fields.description = opts.description;
|
|
23111
21700
|
if (opts.releaseNotes !== undefined)
|
|
23112
21701
|
fields.releaseNotes = opts.releaseNotes;
|
|
23113
21702
|
if (opts.projectUrl !== undefined)
|
|
@@ -23628,10 +22217,257 @@ var ScreenLogger;
|
|
|
23628
22217
|
}
|
|
23629
22218
|
ScreenLogger.progress = progress;
|
|
23630
22219
|
})(ScreenLogger ||= {});
|
|
22220
|
+
// src/telemetry/global-telemetry-properties.ts
|
|
22221
|
+
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
22222
|
+
function getGlobalTelemetryProperties() {
|
|
22223
|
+
return telemetryPropsSlot.get();
|
|
22224
|
+
}
|
|
22225
|
+
|
|
22226
|
+
// src/telemetry/telemetry-config.ts
|
|
22227
|
+
function isTelemetryDisabled() {
|
|
22228
|
+
const value = process.env.UIPATH_TELEMETRY_DISABLED;
|
|
22229
|
+
return value === "1" || value === "true";
|
|
22230
|
+
}
|
|
22231
|
+
|
|
22232
|
+
// src/sdk-user-agent.ts
|
|
22233
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
22234
|
+
var CODING_AGENT_HEADER = "x-coding-agent-info";
|
|
22235
|
+
var AGENT_PROPERTY = "agent";
|
|
22236
|
+
var CODING_AGENT_PROPERTY = "CodingAgent";
|
|
22237
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
22238
|
+
function userAgentPatchKey(userAgent) {
|
|
22239
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
22240
|
+
}
|
|
22241
|
+
function codingAgentPatchKey() {
|
|
22242
|
+
return Symbol.for("@uipath/common/sdk-coding-agent");
|
|
22243
|
+
}
|
|
22244
|
+
function splitUserAgentTokens(value) {
|
|
22245
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
22246
|
+
}
|
|
22247
|
+
function appendUserAgentToken(value, userAgent) {
|
|
22248
|
+
const tokens = splitUserAgentTokens(value);
|
|
22249
|
+
const seen = new Set(tokens);
|
|
22250
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
22251
|
+
if (!seen.has(token)) {
|
|
22252
|
+
tokens.push(token);
|
|
22253
|
+
seen.add(token);
|
|
22254
|
+
}
|
|
22255
|
+
}
|
|
22256
|
+
return tokens.join(" ");
|
|
22257
|
+
}
|
|
22258
|
+
function getEffectiveUserAgent(userAgent) {
|
|
22259
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
22260
|
+
}
|
|
22261
|
+
function getHeaderName(headers, headerName) {
|
|
22262
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
22263
|
+
}
|
|
22264
|
+
function getSdkAgentInfo() {
|
|
22265
|
+
if (isTelemetryDisabled()) {
|
|
22266
|
+
return;
|
|
22267
|
+
}
|
|
22268
|
+
const agent = getGlobalTelemetryProperties()?.[AGENT_PROPERTY];
|
|
22269
|
+
return agent === undefined ? undefined : String(agent);
|
|
22270
|
+
}
|
|
22271
|
+
function getSdkUserAgentToken(pkg) {
|
|
22272
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
22273
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
22274
|
+
}
|
|
22275
|
+
function setSdkUserAgentHostToken(token) {
|
|
22276
|
+
if (token === undefined) {
|
|
22277
|
+
sdkUserAgentHostToken.clear();
|
|
22278
|
+
return;
|
|
22279
|
+
}
|
|
22280
|
+
sdkUserAgentHostToken.set(token);
|
|
22281
|
+
}
|
|
22282
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
22283
|
+
const result = { ...headers ?? {} };
|
|
22284
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
22285
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
22286
|
+
return result;
|
|
22287
|
+
}
|
|
22288
|
+
function addSdkCodingAgentHeader(headers, agent = getSdkAgentInfo()) {
|
|
22289
|
+
const result = { ...headers ?? {} };
|
|
22290
|
+
if (agent === undefined) {
|
|
22291
|
+
return result;
|
|
22292
|
+
}
|
|
22293
|
+
const headerName = getHeaderName(result, CODING_AGENT_HEADER);
|
|
22294
|
+
result[headerName ?? CODING_AGENT_HEADER] = JSON.stringify({
|
|
22295
|
+
[CODING_AGENT_PROPERTY]: agent
|
|
22296
|
+
});
|
|
22297
|
+
return result;
|
|
22298
|
+
}
|
|
22299
|
+
function asHeaderRecord(headers) {
|
|
22300
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
22301
|
+
}
|
|
22302
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
22303
|
+
return async (requestContext) => {
|
|
22304
|
+
const initWithHeaders = {
|
|
22305
|
+
...requestContext.init,
|
|
22306
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
22307
|
+
};
|
|
22308
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
22309
|
+
...requestContext,
|
|
22310
|
+
init: initWithHeaders
|
|
22311
|
+
}) : initOverrides;
|
|
22312
|
+
return {
|
|
22313
|
+
...override ?? {},
|
|
22314
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
22315
|
+
};
|
|
22316
|
+
};
|
|
22317
|
+
}
|
|
22318
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
22319
|
+
const prototype = BaseApiClass.prototype;
|
|
22320
|
+
if (prototype[patchKey]) {
|
|
22321
|
+
return;
|
|
22322
|
+
}
|
|
22323
|
+
if (typeof prototype.request !== "function") {
|
|
22324
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
22325
|
+
}
|
|
22326
|
+
const originalRequest = prototype.request;
|
|
22327
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
22328
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
22329
|
+
};
|
|
22330
|
+
Object.defineProperty(prototype, patchKey, {
|
|
22331
|
+
value: true
|
|
22332
|
+
});
|
|
22333
|
+
}
|
|
22334
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
22335
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
22336
|
+
}
|
|
22337
|
+
function installSdkCodingAgentHeader(BaseApiClass) {
|
|
22338
|
+
installRequestHeaderForwarding(BaseApiClass, codingAgentPatchKey(), (headers) => addSdkCodingAgentHeader(headers));
|
|
22339
|
+
}
|
|
22340
|
+
// src/telemetry/browser-context-storage.ts
|
|
22341
|
+
class BrowserContextStorage {
|
|
22342
|
+
contextStack = [];
|
|
22343
|
+
run(context, fn) {
|
|
22344
|
+
this.contextStack.push(context);
|
|
22345
|
+
try {
|
|
22346
|
+
const result = fn();
|
|
22347
|
+
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
|
22348
|
+
return result.finally(() => {
|
|
22349
|
+
this.contextStack.pop();
|
|
22350
|
+
});
|
|
22351
|
+
}
|
|
22352
|
+
this.contextStack.pop();
|
|
22353
|
+
return result;
|
|
22354
|
+
} catch (error) {
|
|
22355
|
+
this.contextStack.pop();
|
|
22356
|
+
throw error;
|
|
22357
|
+
}
|
|
22358
|
+
}
|
|
22359
|
+
getContext() {
|
|
22360
|
+
return this.contextStack.length > 0 ? this.contextStack[this.contextStack.length - 1] : undefined;
|
|
22361
|
+
}
|
|
22362
|
+
}
|
|
22363
|
+
// src/telemetry/console-telemetry-provider.ts
|
|
22364
|
+
class ConsoleTelemetryProvider {
|
|
22365
|
+
async trackEvent(eventName, _properties) {
|
|
22366
|
+
console.debug(`[Telemetry] Event: ${eventName}`);
|
|
22367
|
+
}
|
|
22368
|
+
async trackException(error, _properties) {
|
|
22369
|
+
console.error(`[Telemetry] Exception: ${error.message}`);
|
|
22370
|
+
}
|
|
22371
|
+
async trackRequest(name, duration, success, _properties) {
|
|
22372
|
+
console.debug(`[Telemetry] Request: ${name} (${duration}ms, ${success ? "ok" : "fail"})`);
|
|
22373
|
+
}
|
|
22374
|
+
async trackDependency(name, type, duration, success, _properties) {
|
|
22375
|
+
console.debug(`[Telemetry] Dependency: ${name} [${type}] (${duration}ms, ${success ? "ok" : "fail"})`);
|
|
22376
|
+
}
|
|
22377
|
+
}
|
|
23631
22378
|
// src/telemetry/telemetry-events.ts
|
|
23632
22379
|
var CommonTelemetryEvents = {
|
|
23633
22380
|
Error: "uip.error"
|
|
23634
22381
|
};
|
|
22382
|
+
// src/telemetry/telemetry-service.ts
|
|
22383
|
+
class TelemetryService {
|
|
22384
|
+
telemetryProvider;
|
|
22385
|
+
contextStorage;
|
|
22386
|
+
operationId;
|
|
22387
|
+
defaultProperties;
|
|
22388
|
+
constructor(telemetryProvider, contextStorage) {
|
|
22389
|
+
this.telemetryProvider = telemetryProvider;
|
|
22390
|
+
this.contextStorage = contextStorage;
|
|
22391
|
+
}
|
|
22392
|
+
setOperationId(operationId) {
|
|
22393
|
+
this.operationId = operationId;
|
|
22394
|
+
}
|
|
22395
|
+
setProvider(provider) {
|
|
22396
|
+
this.telemetryProvider = provider;
|
|
22397
|
+
}
|
|
22398
|
+
setDefaultProperties(properties) {
|
|
22399
|
+
this.defaultProperties = properties === undefined ? undefined : { ...this.defaultProperties, ...properties };
|
|
22400
|
+
}
|
|
22401
|
+
trackEvent(name, properties) {
|
|
22402
|
+
const context = this.getCurrentContext();
|
|
22403
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
22404
|
+
this.telemetryProvider.trackEvent(name, enrichedProperties);
|
|
22405
|
+
}
|
|
22406
|
+
trackException(error, properties) {
|
|
22407
|
+
const context = this.getCurrentContext();
|
|
22408
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
22409
|
+
this.telemetryProvider.trackException(error, enrichedProperties);
|
|
22410
|
+
}
|
|
22411
|
+
async trackRequest(name, fn, properties) {
|
|
22412
|
+
const context = {
|
|
22413
|
+
operationId: this.operationId ?? this.generateId(),
|
|
22414
|
+
id: this.generateId()
|
|
22415
|
+
};
|
|
22416
|
+
const startTime = performance.now();
|
|
22417
|
+
try {
|
|
22418
|
+
const result = await this.contextStorage.run(context, fn);
|
|
22419
|
+
const durationMs = performance.now() - startTime;
|
|
22420
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, context);
|
|
22421
|
+
await this.telemetryProvider.trackRequest(name, durationMs, true, enrichedProperties);
|
|
22422
|
+
return result;
|
|
22423
|
+
} catch (error) {
|
|
22424
|
+
const durationMs = performance.now() - startTime;
|
|
22425
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
22426
|
+
const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, context);
|
|
22427
|
+
await this.telemetryProvider.trackRequest(name, durationMs, false, enrichedProperties);
|
|
22428
|
+
throw error;
|
|
22429
|
+
}
|
|
22430
|
+
}
|
|
22431
|
+
async trackDependencyOperation(name, type, fn, properties) {
|
|
22432
|
+
const parentContext = this.getCurrentContext();
|
|
22433
|
+
if (!parentContext) {
|
|
22434
|
+
throw new Error("trackDependencyOperation must be called within a trackRequest block.");
|
|
22435
|
+
}
|
|
22436
|
+
const childContext = {
|
|
22437
|
+
operationId: parentContext.operationId,
|
|
22438
|
+
parentId: parentContext.id,
|
|
22439
|
+
id: this.generateId()
|
|
22440
|
+
};
|
|
22441
|
+
const startTime = performance.now();
|
|
22442
|
+
try {
|
|
22443
|
+
const result = await this.contextStorage.run(childContext, fn);
|
|
22444
|
+
const durationMs = performance.now() - startTime;
|
|
22445
|
+
const enrichedProperties = this.enrichPropertiesWithContext(properties, childContext);
|
|
22446
|
+
await this.telemetryProvider.trackDependency(name, type, durationMs, true, enrichedProperties);
|
|
22447
|
+
return result;
|
|
22448
|
+
} catch (error) {
|
|
22449
|
+
const durationMs = performance.now() - startTime;
|
|
22450
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
22451
|
+
const enrichedProperties = this.enrichPropertiesWithContext({ ...properties, errorMessage: err.message }, childContext);
|
|
22452
|
+
await this.telemetryProvider.trackDependency(name, type, durationMs, false, enrichedProperties);
|
|
22453
|
+
throw error;
|
|
22454
|
+
}
|
|
22455
|
+
}
|
|
22456
|
+
getCurrentContext() {
|
|
22457
|
+
return this.contextStorage.getContext();
|
|
22458
|
+
}
|
|
22459
|
+
enrichPropertiesWithContext(properties, context) {
|
|
22460
|
+
return {
|
|
22461
|
+
...getGlobalTelemetryProperties(),
|
|
22462
|
+
...this.defaultProperties,
|
|
22463
|
+
...properties,
|
|
22464
|
+
...context
|
|
22465
|
+
};
|
|
22466
|
+
}
|
|
22467
|
+
generateId() {
|
|
22468
|
+
return crypto.randomUUID().replaceAll("-", "");
|
|
22469
|
+
}
|
|
22470
|
+
}
|
|
23635
22471
|
// src/tool-provider.ts
|
|
23636
22472
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
23637
22473
|
function setPackagerFactoryProvider(provider) {
|
|
@@ -23647,6 +22483,7 @@ async function ensurePackagerFactory(verb) {
|
|
|
23647
22483
|
export {
|
|
23648
22484
|
withCompleter,
|
|
23649
22485
|
singleton,
|
|
22486
|
+
setSdkUserAgentHostToken,
|
|
23650
22487
|
setPackagerFactoryProvider,
|
|
23651
22488
|
setOutputFormatExplicit,
|
|
23652
22489
|
setOutputFormat,
|
|
@@ -23674,8 +22511,11 @@ export {
|
|
|
23674
22511
|
isGuid,
|
|
23675
22512
|
isFailureStatus,
|
|
23676
22513
|
instructionsFor,
|
|
22514
|
+
installSdkUserAgentHeader,
|
|
22515
|
+
installSdkCodingAgentHeader,
|
|
23677
22516
|
installConsoleGuard,
|
|
23678
22517
|
hashContent,
|
|
22518
|
+
getSdkUserAgentToken,
|
|
23679
22519
|
getOutputSink,
|
|
23680
22520
|
getOutputFormatExplicit,
|
|
23681
22521
|
getOutputFormat,
|
|
@@ -23689,8 +22529,8 @@ export {
|
|
|
23689
22529
|
extractErrorMessage,
|
|
23690
22530
|
extractErrorDetails,
|
|
23691
22531
|
extractCommandHelp,
|
|
23692
|
-
evaluateJsonPath,
|
|
23693
22532
|
ensurePackagerFactory,
|
|
22533
|
+
describeConnectivityError,
|
|
23694
22534
|
createPollAbortController,
|
|
23695
22535
|
configureLogger,
|
|
23696
22536
|
collectCommands,
|
|
@@ -23698,13 +22538,15 @@ export {
|
|
|
23698
22538
|
buildOrchestratorUrl,
|
|
23699
22539
|
buildActionCenterTaskUrl,
|
|
23700
22540
|
buildActionCenterInboxUrl,
|
|
22541
|
+
addSdkUserAgentHeader,
|
|
22542
|
+
addSdkCodingAgentHeader,
|
|
23701
22543
|
UIPATH_HOME_DIR,
|
|
22544
|
+
TelemetryService,
|
|
23702
22545
|
ScreenLogger,
|
|
23703
22546
|
PollOutcome,
|
|
23704
22547
|
POLL_DEFAULTS,
|
|
23705
22548
|
MIN_INTERVAL_MS,
|
|
23706
22549
|
LogLevel,
|
|
23707
|
-
JsonPathError,
|
|
23708
22550
|
ErrorDecision,
|
|
23709
22551
|
DEFAULT_REDIRECT_URI,
|
|
23710
22552
|
DEFAULT_PAGE_SIZE,
|
|
@@ -23712,8 +22554,12 @@ export {
|
|
|
23712
22554
|
DEFAULT_FETCH_TIMEOUT_MS,
|
|
23713
22555
|
DEFAULT_BASE_URL,
|
|
23714
22556
|
DEFAULT_AUTH_TIMEOUT_MS,
|
|
22557
|
+
ConsoleTelemetryProvider,
|
|
23715
22558
|
CommonTelemetryEvents,
|
|
23716
22559
|
CONFIG_FILENAME,
|
|
22560
|
+
BrowserContextStorage,
|
|
23717
22561
|
BACKOFF_DEFAULTS,
|
|
23718
22562
|
AUTH_FILENAME
|
|
23719
22563
|
};
|
|
22564
|
+
|
|
22565
|
+
//# debugId=D3F1D2DAD96E966264756E2164756E21
|