@uipath/integrationservice-tool 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/index.js +2 -0
- package/dist/tool.js +878 -1908
- package/package.json +2 -2
package/dist/tool.js
CHANGED
|
@@ -13520,8 +13520,8 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
13520
13520
|
if (_parentOrParents instanceof Subscription2) {
|
|
13521
13521
|
_parentOrParents.remove(this);
|
|
13522
13522
|
} else if (_parentOrParents !== null) {
|
|
13523
|
-
for (var
|
|
13524
|
-
var parent_1 = _parentOrParents[
|
|
13523
|
+
for (var index = 0;index < _parentOrParents.length; ++index) {
|
|
13524
|
+
var parent_1 = _parentOrParents[index];
|
|
13525
13525
|
parent_1.remove(this);
|
|
13526
13526
|
}
|
|
13527
13527
|
}
|
|
@@ -13536,10 +13536,10 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
13536
13536
|
}
|
|
13537
13537
|
}
|
|
13538
13538
|
if (isArray_1.isArray(_subscriptions)) {
|
|
13539
|
-
var
|
|
13539
|
+
var index = -1;
|
|
13540
13540
|
var len = _subscriptions.length;
|
|
13541
|
-
while (++
|
|
13542
|
-
var sub2 = _subscriptions[
|
|
13541
|
+
while (++index < len) {
|
|
13542
|
+
var sub2 = _subscriptions[index];
|
|
13543
13543
|
if (isObject_1.isObject(sub2)) {
|
|
13544
13544
|
try {
|
|
13545
13545
|
sub2.unsubscribe();
|
|
@@ -14969,13 +14969,13 @@ var require_AsyncAction = __commonJS((exports) => {
|
|
|
14969
14969
|
var id = this.id;
|
|
14970
14970
|
var scheduler = this.scheduler;
|
|
14971
14971
|
var actions = scheduler.actions;
|
|
14972
|
-
var
|
|
14972
|
+
var index = actions.indexOf(this);
|
|
14973
14973
|
this.work = null;
|
|
14974
14974
|
this.state = null;
|
|
14975
14975
|
this.pending = false;
|
|
14976
14976
|
this.scheduler = null;
|
|
14977
|
-
if (
|
|
14978
|
-
actions.splice(
|
|
14977
|
+
if (index !== -1) {
|
|
14978
|
+
actions.splice(index, 1);
|
|
14979
14979
|
}
|
|
14980
14980
|
if (id != null) {
|
|
14981
14981
|
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
@@ -15819,17 +15819,17 @@ var require_AsapScheduler = __commonJS((exports) => {
|
|
|
15819
15819
|
this.scheduled = undefined;
|
|
15820
15820
|
var actions = this.actions;
|
|
15821
15821
|
var error;
|
|
15822
|
-
var
|
|
15822
|
+
var index = -1;
|
|
15823
15823
|
var count = actions.length;
|
|
15824
15824
|
action = action || actions.shift();
|
|
15825
15825
|
do {
|
|
15826
15826
|
if (error = action.execute(action.state, action.delay)) {
|
|
15827
15827
|
break;
|
|
15828
15828
|
}
|
|
15829
|
-
} while (++
|
|
15829
|
+
} while (++index < count && (action = actions.shift()));
|
|
15830
15830
|
this.active = false;
|
|
15831
15831
|
if (error) {
|
|
15832
|
-
while (++
|
|
15832
|
+
while (++index < count && (action = actions.shift())) {
|
|
15833
15833
|
action.unsubscribe();
|
|
15834
15834
|
}
|
|
15835
15835
|
throw error;
|
|
@@ -15952,17 +15952,17 @@ var require_AnimationFrameScheduler = __commonJS((exports) => {
|
|
|
15952
15952
|
this.scheduled = undefined;
|
|
15953
15953
|
var actions = this.actions;
|
|
15954
15954
|
var error;
|
|
15955
|
-
var
|
|
15955
|
+
var index = -1;
|
|
15956
15956
|
var count = actions.length;
|
|
15957
15957
|
action = action || actions.shift();
|
|
15958
15958
|
do {
|
|
15959
15959
|
if (error = action.execute(action.state, action.delay)) {
|
|
15960
15960
|
break;
|
|
15961
15961
|
}
|
|
15962
|
-
} while (++
|
|
15962
|
+
} while (++index < count && (action = actions.shift()));
|
|
15963
15963
|
this.active = false;
|
|
15964
15964
|
if (error) {
|
|
15965
|
-
while (++
|
|
15965
|
+
while (++index < count && (action = actions.shift())) {
|
|
15966
15966
|
action.unsubscribe();
|
|
15967
15967
|
}
|
|
15968
15968
|
throw error;
|
|
@@ -16046,16 +16046,16 @@ var require_VirtualTimeScheduler = __commonJS((exports) => {
|
|
|
16046
16046
|
exports.VirtualTimeScheduler = VirtualTimeScheduler;
|
|
16047
16047
|
var VirtualAction = function(_super) {
|
|
16048
16048
|
__extends(VirtualAction2, _super);
|
|
16049
|
-
function VirtualAction2(scheduler, work,
|
|
16050
|
-
if (
|
|
16051
|
-
|
|
16049
|
+
function VirtualAction2(scheduler, work, index) {
|
|
16050
|
+
if (index === undefined) {
|
|
16051
|
+
index = scheduler.index += 1;
|
|
16052
16052
|
}
|
|
16053
16053
|
var _this = _super.call(this, scheduler, work) || this;
|
|
16054
16054
|
_this.scheduler = scheduler;
|
|
16055
16055
|
_this.work = work;
|
|
16056
|
-
_this.index =
|
|
16056
|
+
_this.index = index;
|
|
16057
16057
|
_this.active = true;
|
|
16058
|
-
_this.index = scheduler.index =
|
|
16058
|
+
_this.index = scheduler.index = index;
|
|
16059
16059
|
return _this;
|
|
16060
16060
|
}
|
|
16061
16061
|
VirtualAction2.prototype.schedule = function(state, delay) {
|
|
@@ -17202,9 +17202,9 @@ var require_mergeMap = __commonJS((exports) => {
|
|
|
17202
17202
|
};
|
|
17203
17203
|
MergeMapSubscriber2.prototype._tryNext = function(value) {
|
|
17204
17204
|
var result;
|
|
17205
|
-
var
|
|
17205
|
+
var index = this.index++;
|
|
17206
17206
|
try {
|
|
17207
|
-
result = this.project(value,
|
|
17207
|
+
result = this.project(value, index);
|
|
17208
17208
|
} catch (err) {
|
|
17209
17209
|
this.destination.error(err);
|
|
17210
17210
|
return;
|
|
@@ -17784,12 +17784,12 @@ var require_pairs2 = __commonJS((exports) => {
|
|
|
17784
17784
|
}
|
|
17785
17785
|
exports.pairs = pairs;
|
|
17786
17786
|
function dispatch(state) {
|
|
17787
|
-
var { keys, index
|
|
17787
|
+
var { keys, index, subscriber, subscription, obj } = state;
|
|
17788
17788
|
if (!subscriber.closed) {
|
|
17789
|
-
if (
|
|
17790
|
-
var key = keys[
|
|
17789
|
+
if (index < keys.length) {
|
|
17790
|
+
var key = keys[index];
|
|
17791
17791
|
subscriber.next([key, obj[key]]);
|
|
17792
|
-
subscription.add(this.schedule({ keys, index:
|
|
17792
|
+
subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
|
|
17793
17793
|
} else {
|
|
17794
17794
|
subscriber.complete();
|
|
17795
17795
|
}
|
|
@@ -18002,18 +18002,18 @@ var require_range = __commonJS((exports) => {
|
|
|
18002
18002
|
count = start;
|
|
18003
18003
|
start = 0;
|
|
18004
18004
|
}
|
|
18005
|
-
var
|
|
18005
|
+
var index = 0;
|
|
18006
18006
|
var current = start;
|
|
18007
18007
|
if (scheduler) {
|
|
18008
18008
|
return scheduler.schedule(dispatch, 0, {
|
|
18009
|
-
index
|
|
18009
|
+
index,
|
|
18010
18010
|
count,
|
|
18011
18011
|
start,
|
|
18012
18012
|
subscriber
|
|
18013
18013
|
});
|
|
18014
18014
|
} else {
|
|
18015
18015
|
do {
|
|
18016
|
-
if (
|
|
18016
|
+
if (index++ >= count) {
|
|
18017
18017
|
subscriber.complete();
|
|
18018
18018
|
break;
|
|
18019
18019
|
}
|
|
@@ -18028,8 +18028,8 @@ var require_range = __commonJS((exports) => {
|
|
|
18028
18028
|
}
|
|
18029
18029
|
exports.range = range;
|
|
18030
18030
|
function dispatch(state) {
|
|
18031
|
-
var { start, index
|
|
18032
|
-
if (
|
|
18031
|
+
var { start, index, count, subscriber } = state;
|
|
18032
|
+
if (index >= count) {
|
|
18033
18033
|
subscriber.complete();
|
|
18034
18034
|
return;
|
|
18035
18035
|
}
|
|
@@ -18037,7 +18037,7 @@ var require_range = __commonJS((exports) => {
|
|
|
18037
18037
|
if (subscriber.closed) {
|
|
18038
18038
|
return;
|
|
18039
18039
|
}
|
|
18040
|
-
state.index =
|
|
18040
|
+
state.index = index + 1;
|
|
18041
18041
|
state.start = start + 1;
|
|
18042
18042
|
this.schedule(state);
|
|
18043
18043
|
}
|
|
@@ -18075,14 +18075,14 @@ var require_timer = __commonJS((exports) => {
|
|
|
18075
18075
|
}
|
|
18076
18076
|
exports.timer = timer;
|
|
18077
18077
|
function dispatch(state) {
|
|
18078
|
-
var { index
|
|
18079
|
-
subscriber.next(
|
|
18078
|
+
var { index, period, subscriber } = state;
|
|
18079
|
+
subscriber.next(index);
|
|
18080
18080
|
if (subscriber.closed) {
|
|
18081
18081
|
return;
|
|
18082
18082
|
} else if (period === -1) {
|
|
18083
18083
|
return subscriber.complete();
|
|
18084
18084
|
}
|
|
18085
|
-
state.index =
|
|
18085
|
+
state.index = index + 1;
|
|
18086
18086
|
this.schedule(state, period);
|
|
18087
18087
|
}
|
|
18088
18088
|
});
|
|
@@ -21230,7 +21230,7 @@ var init_server = __esm(() => {
|
|
|
21230
21230
|
var package_default = {
|
|
21231
21231
|
name: "@uipath/integrationservice-tool",
|
|
21232
21232
|
license: "MIT",
|
|
21233
|
-
version: "1.
|
|
21233
|
+
version: "1.197.0-preview.59",
|
|
21234
21234
|
description: "Manage Integration Service connectors, connections, and triggers.",
|
|
21235
21235
|
private: false,
|
|
21236
21236
|
repository: {
|
|
@@ -21321,27 +21321,54 @@ var NETWORK_ERROR_CODES = new Set([
|
|
|
21321
21321
|
"ENETUNREACH",
|
|
21322
21322
|
"EAI_FAIL"
|
|
21323
21323
|
]);
|
|
21324
|
-
|
|
21325
|
-
|
|
21326
|
-
|
|
21327
|
-
|
|
21328
|
-
|
|
21329
|
-
|
|
21330
|
-
|
|
21331
|
-
|
|
21332
|
-
|
|
21333
|
-
|
|
21334
|
-
|
|
21335
|
-
|
|
21336
|
-
|
|
21337
|
-
|
|
21338
|
-
|
|
21339
|
-
|
|
21340
|
-
|
|
21324
|
+
var TLS_ERROR_CODES = new Set([
|
|
21325
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
21326
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
21327
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
21328
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
21329
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
21330
|
+
"CERT_HAS_EXPIRED",
|
|
21331
|
+
"CERT_UNTRUSTED",
|
|
21332
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
21333
|
+
]);
|
|
21334
|
+
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.";
|
|
21335
|
+
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.";
|
|
21336
|
+
function describeConnectivityError(error) {
|
|
21337
|
+
let current = error;
|
|
21338
|
+
for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
|
|
21339
|
+
const cur = current;
|
|
21340
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
21341
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
21342
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
21343
|
+
return {
|
|
21344
|
+
code,
|
|
21345
|
+
kind: "tls",
|
|
21346
|
+
message: message ?? code,
|
|
21347
|
+
instructions: TLS_INSTRUCTIONS
|
|
21348
|
+
};
|
|
21349
|
+
}
|
|
21350
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
21351
|
+
return {
|
|
21352
|
+
code,
|
|
21353
|
+
kind: "network",
|
|
21354
|
+
message: message ?? code,
|
|
21355
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
21356
|
+
};
|
|
21341
21357
|
}
|
|
21358
|
+
current = cur.cause;
|
|
21342
21359
|
}
|
|
21343
21360
|
return;
|
|
21344
21361
|
}
|
|
21362
|
+
function parseHttpStatusFromMessage(message) {
|
|
21363
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
21364
|
+
if (!match)
|
|
21365
|
+
return;
|
|
21366
|
+
const status = Number(match[1]);
|
|
21367
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
21368
|
+
}
|
|
21369
|
+
function isHtmlDocument(body) {
|
|
21370
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
21371
|
+
}
|
|
21345
21372
|
function retryHintForRetryAfter(seconds) {
|
|
21346
21373
|
if (seconds <= 1) {
|
|
21347
21374
|
return "RetryAfter1Second";
|
|
@@ -21382,15 +21409,28 @@ function classifyError(status, error) {
|
|
|
21382
21409
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
21383
21410
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
21384
21411
|
}
|
|
21385
|
-
|
|
21386
|
-
|
|
21412
|
+
const connectivity = describeConnectivityError(error);
|
|
21413
|
+
if (connectivity) {
|
|
21414
|
+
return {
|
|
21415
|
+
errorCode: "network_error",
|
|
21416
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
21417
|
+
};
|
|
21387
21418
|
}
|
|
21388
21419
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
21389
21420
|
}
|
|
21421
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
21422
|
+
if (extractedMessage) {
|
|
21423
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
21424
|
+
}
|
|
21425
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
21426
|
+
}
|
|
21390
21427
|
async function extractErrorDetails(error, options) {
|
|
21391
21428
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
21392
21429
|
const response = err.response;
|
|
21393
|
-
const
|
|
21430
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21431
|
+
const explicitStatus = err.status ?? response?.status;
|
|
21432
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
21433
|
+
const status = explicitStatus ?? inferredStatus;
|
|
21394
21434
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
21395
21435
|
let rawBody;
|
|
21396
21436
|
let extractedMessage;
|
|
@@ -21425,7 +21465,6 @@ async function extractErrorDetails(error, options) {
|
|
|
21425
21465
|
}
|
|
21426
21466
|
}
|
|
21427
21467
|
}
|
|
21428
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21429
21468
|
let message;
|
|
21430
21469
|
let result = "Failure";
|
|
21431
21470
|
const classification = classifyError(status, error);
|
|
@@ -21439,10 +21478,10 @@ async function extractErrorDetails(error, options) {
|
|
|
21439
21478
|
} else if (status === 405) {
|
|
21440
21479
|
message = DEFAULT_405;
|
|
21441
21480
|
} else if (status === 400 || status === 422) {
|
|
21442
|
-
message =
|
|
21481
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21443
21482
|
result = "ValidationError";
|
|
21444
21483
|
} else if (status === 429) {
|
|
21445
|
-
message =
|
|
21484
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21446
21485
|
} else if (extractedMessage) {
|
|
21447
21486
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
21448
21487
|
message = rawMessage;
|
|
@@ -21450,7 +21489,9 @@ async function extractErrorDetails(error, options) {
|
|
|
21450
21489
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
21451
21490
|
}
|
|
21452
21491
|
} else if (status) {
|
|
21453
|
-
if (
|
|
21492
|
+
if (inferredStatus !== undefined) {
|
|
21493
|
+
message = rawMessage;
|
|
21494
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
21454
21495
|
const statusText = response.statusText;
|
|
21455
21496
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
21456
21497
|
} else {
|
|
@@ -21459,6 +21500,12 @@ async function extractErrorDetails(error, options) {
|
|
|
21459
21500
|
} else {
|
|
21460
21501
|
message = rawMessage;
|
|
21461
21502
|
}
|
|
21503
|
+
if (status === undefined) {
|
|
21504
|
+
const connectivity = describeConnectivityError(error);
|
|
21505
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
21506
|
+
message = `${message}: ${connectivity.message}`;
|
|
21507
|
+
}
|
|
21508
|
+
}
|
|
21462
21509
|
let details = rawMessage;
|
|
21463
21510
|
if (rawBody) {
|
|
21464
21511
|
if (parsedBody) {
|
|
@@ -21626,6 +21673,7 @@ var CONSOLE_FALLBACK = {
|
|
|
21626
21673
|
writeLog: (str) => process.stdout.write(str),
|
|
21627
21674
|
capabilities: {
|
|
21628
21675
|
isInteractive: false,
|
|
21676
|
+
canReadInput: false,
|
|
21629
21677
|
supportsColor: false,
|
|
21630
21678
|
outputWidth: 80
|
|
21631
21679
|
}
|
|
@@ -26826,6 +26874,29 @@ function isPlainRecord(value) {
|
|
|
26826
26874
|
const prototype = Object.getPrototypeOf(value);
|
|
26827
26875
|
return prototype === Object.prototype || prototype === null;
|
|
26828
26876
|
}
|
|
26877
|
+
function extractPagedRows(value) {
|
|
26878
|
+
if (Array.isArray(value) || !isPlainRecord(value))
|
|
26879
|
+
return null;
|
|
26880
|
+
const entries = Object.values(value);
|
|
26881
|
+
if (entries.length === 0)
|
|
26882
|
+
return null;
|
|
26883
|
+
let rows = null;
|
|
26884
|
+
let hasScalarSibling = false;
|
|
26885
|
+
for (const entry of entries) {
|
|
26886
|
+
if (Array.isArray(entry)) {
|
|
26887
|
+
if (rows !== null)
|
|
26888
|
+
return null;
|
|
26889
|
+
rows = entry;
|
|
26890
|
+
} else if (entry !== null && typeof entry === "object") {
|
|
26891
|
+
return null;
|
|
26892
|
+
} else {
|
|
26893
|
+
hasScalarSibling = true;
|
|
26894
|
+
}
|
|
26895
|
+
}
|
|
26896
|
+
if (rows === null || !hasScalarSibling)
|
|
26897
|
+
return null;
|
|
26898
|
+
return rows;
|
|
26899
|
+
}
|
|
26829
26900
|
function toLowerCamelCaseKey(key) {
|
|
26830
26901
|
if (!key)
|
|
26831
26902
|
return key;
|
|
@@ -26890,7 +26961,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
26890
26961
|
break;
|
|
26891
26962
|
case "plain": {
|
|
26892
26963
|
if ("Data" in data && data.Data != null) {
|
|
26893
|
-
const
|
|
26964
|
+
const pagedRows = extractPagedRows(data.Data);
|
|
26965
|
+
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
26894
26966
|
items.forEach((item) => {
|
|
26895
26967
|
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
26896
26968
|
logFn(values);
|
|
@@ -26902,10 +26974,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
26902
26974
|
break;
|
|
26903
26975
|
}
|
|
26904
26976
|
default: {
|
|
26905
|
-
|
|
26977
|
+
const hasData = "Data" in data && data.Data != null;
|
|
26978
|
+
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
26979
|
+
const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
26980
|
+
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
26906
26981
|
const logValue = data.Log;
|
|
26907
|
-
if (
|
|
26908
|
-
printResizableTable(
|
|
26982
|
+
if (rows !== null) {
|
|
26983
|
+
printResizableTable(rows, logFn, logValue);
|
|
26909
26984
|
} else {
|
|
26910
26985
|
printVerticalTable(data.Data, logFn, logValue);
|
|
26911
26986
|
}
|
|
@@ -27093,6 +27168,44 @@ function defaultErrorCodeForResult(result) {
|
|
|
27093
27168
|
return "unknown_error";
|
|
27094
27169
|
}
|
|
27095
27170
|
}
|
|
27171
|
+
function parseHttpStatusFromMessage2(message) {
|
|
27172
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
27173
|
+
if (!match)
|
|
27174
|
+
return;
|
|
27175
|
+
const status = Number(match[1]);
|
|
27176
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
27177
|
+
}
|
|
27178
|
+
function defaultErrorCodeForHttpStatus(status) {
|
|
27179
|
+
if (status === undefined)
|
|
27180
|
+
return;
|
|
27181
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
27182
|
+
return "invalid_argument";
|
|
27183
|
+
}
|
|
27184
|
+
if (status === 401)
|
|
27185
|
+
return "authentication_required";
|
|
27186
|
+
if (status === 403)
|
|
27187
|
+
return "permission_denied";
|
|
27188
|
+
if (status === 404)
|
|
27189
|
+
return "not_found";
|
|
27190
|
+
if (status === 405)
|
|
27191
|
+
return "method_not_allowed";
|
|
27192
|
+
if (status === 408)
|
|
27193
|
+
return "timeout";
|
|
27194
|
+
if (status === 429)
|
|
27195
|
+
return "rate_limited";
|
|
27196
|
+
if (status >= 500 && status < 600)
|
|
27197
|
+
return "server_error";
|
|
27198
|
+
return;
|
|
27199
|
+
}
|
|
27200
|
+
function defaultErrorCodeForFailure(data) {
|
|
27201
|
+
if (data.Result === RESULTS.Failure) {
|
|
27202
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
27203
|
+
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
27204
|
+
if (errorCode)
|
|
27205
|
+
return errorCode;
|
|
27206
|
+
}
|
|
27207
|
+
return defaultErrorCodeForResult(data.Result);
|
|
27208
|
+
}
|
|
27096
27209
|
function defaultRetryForErrorCode(errorCode) {
|
|
27097
27210
|
switch (errorCode) {
|
|
27098
27211
|
case "network_error":
|
|
@@ -27122,16 +27235,19 @@ var OutputFormatter;
|
|
|
27122
27235
|
OutputFormatter.success = success;
|
|
27123
27236
|
function error(data) {
|
|
27124
27237
|
data.Log ??= getLogFilePath() || undefined;
|
|
27125
|
-
data.ErrorCode ??=
|
|
27238
|
+
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
27126
27239
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
27127
27240
|
process.exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27241
|
+
const { SuppressTelemetry, ...envelope } = data;
|
|
27242
|
+
if (!SuppressTelemetry) {
|
|
27243
|
+
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
27244
|
+
result: data.Result,
|
|
27245
|
+
errorCode: data.ErrorCode,
|
|
27246
|
+
retry: data.Retry,
|
|
27247
|
+
message: data.Message
|
|
27248
|
+
});
|
|
27249
|
+
}
|
|
27250
|
+
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
27135
27251
|
}
|
|
27136
27252
|
OutputFormatter.error = error;
|
|
27137
27253
|
function emitList(code, items, opts) {
|
|
@@ -27436,1583 +27552,180 @@ var UIPATH_HOME_DIR = ".uipath";
|
|
|
27436
27552
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
27437
27553
|
// ../common/src/interactivity-context.ts
|
|
27438
27554
|
var modeSlot = singleton("InteractivityMode");
|
|
27439
|
-
//
|
|
27440
|
-
|
|
27441
|
-
|
|
27442
|
-
|
|
27443
|
-
|
|
27444
|
-
|
|
27445
|
-
|
|
27446
|
-
|
|
27555
|
+
// ../common/src/option-aliases.ts
|
|
27556
|
+
function resolveDeprecatedOptionAlias({
|
|
27557
|
+
preferredValue,
|
|
27558
|
+
deprecatedValue,
|
|
27559
|
+
preferredFlag,
|
|
27560
|
+
deprecatedFlag
|
|
27561
|
+
}) {
|
|
27562
|
+
const hasPreferred = preferredValue !== undefined;
|
|
27563
|
+
const hasDeprecated = deprecatedValue !== undefined;
|
|
27564
|
+
if (hasPreferred && hasDeprecated) {
|
|
27565
|
+
return {
|
|
27566
|
+
value: undefined,
|
|
27567
|
+
usedDeprecated: true,
|
|
27568
|
+
error: {
|
|
27569
|
+
message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
|
|
27570
|
+
instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
|
|
27447
27571
|
}
|
|
27448
|
-
}
|
|
27449
|
-
(Array.isArray(name) ? name : [name]).forEach(function(name2) {
|
|
27450
|
-
this[name2] = this[name2] || [];
|
|
27451
|
-
if (callback) {
|
|
27452
|
-
this[name2][first ? "unshift" : "push"](callback);
|
|
27453
|
-
}
|
|
27454
|
-
}, this);
|
|
27455
|
-
}
|
|
27456
|
-
}
|
|
27457
|
-
run(name, env) {
|
|
27458
|
-
this[name] = this[name] || [];
|
|
27459
|
-
this[name].forEach(function(callback) {
|
|
27460
|
-
callback.call(env && env.context ? env.context : env, env);
|
|
27461
|
-
});
|
|
27572
|
+
};
|
|
27462
27573
|
}
|
|
27574
|
+
return {
|
|
27575
|
+
value: hasPreferred ? preferredValue : deprecatedValue,
|
|
27576
|
+
usedDeprecated: hasDeprecated
|
|
27577
|
+
};
|
|
27463
27578
|
}
|
|
27464
|
-
|
|
27465
|
-
|
|
27466
|
-
|
|
27467
|
-
this.jsep = jsep;
|
|
27468
|
-
this.registered = {};
|
|
27469
|
-
}
|
|
27470
|
-
register(...plugins) {
|
|
27471
|
-
plugins.forEach((plugin) => {
|
|
27472
|
-
if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
|
|
27473
|
-
throw new Error("Invalid JSEP plugin format");
|
|
27474
|
-
}
|
|
27475
|
-
if (this.registered[plugin.name]) {
|
|
27476
|
-
return;
|
|
27477
|
-
}
|
|
27478
|
-
plugin.init(this.jsep);
|
|
27479
|
-
this.registered[plugin.name] = plugin;
|
|
27480
|
-
});
|
|
27481
|
-
}
|
|
27579
|
+
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
27580
|
+
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
27581
|
+
`);
|
|
27482
27582
|
}
|
|
27483
|
-
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
|
|
27487
|
-
|
|
27488
|
-
|
|
27489
|
-
|
|
27490
|
-
|
|
27491
|
-
|
|
27492
|
-
|
|
27493
|
-
|
|
27494
|
-
|
|
27583
|
+
var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
|
|
27584
|
+
function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
|
|
27585
|
+
return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
|
|
27586
|
+
warnDeprecatedTenantOption(tenant);
|
|
27587
|
+
return tenant;
|
|
27588
|
+
});
|
|
27589
|
+
}
|
|
27590
|
+
function warnDeprecatedTenantOption(tenant) {
|
|
27591
|
+
if (tenant === undefined)
|
|
27592
|
+
return;
|
|
27593
|
+
warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
|
|
27594
|
+
}
|
|
27595
|
+
// ../common/src/option-validators.ts
|
|
27596
|
+
function parsePositiveInteger(raw) {
|
|
27597
|
+
return parseSafeInteger(raw, 1);
|
|
27598
|
+
}
|
|
27599
|
+
function parseSafeInteger(raw, min) {
|
|
27600
|
+
const normalized = raw.trim();
|
|
27601
|
+
if (!/^\d+$/.test(normalized)) {
|
|
27602
|
+
return;
|
|
27495
27603
|
}
|
|
27496
|
-
|
|
27497
|
-
|
|
27498
|
-
|
|
27499
|
-
if (isRightAssociative) {
|
|
27500
|
-
Jsep.right_associative.add(op_name);
|
|
27501
|
-
} else {
|
|
27502
|
-
Jsep.right_associative.delete(op_name);
|
|
27503
|
-
}
|
|
27504
|
-
return Jsep;
|
|
27604
|
+
const parsed = Number(normalized);
|
|
27605
|
+
if (!Number.isSafeInteger(parsed) || parsed < min) {
|
|
27606
|
+
return;
|
|
27505
27607
|
}
|
|
27506
|
-
|
|
27507
|
-
|
|
27508
|
-
|
|
27608
|
+
return parsed;
|
|
27609
|
+
}
|
|
27610
|
+
// ../common/src/polling/format-utils.ts
|
|
27611
|
+
function msToDuration(ms) {
|
|
27612
|
+
if (!Number.isFinite(ms) || ms < 0) {
|
|
27613
|
+
return "00:00:00";
|
|
27509
27614
|
}
|
|
27510
|
-
|
|
27511
|
-
|
|
27512
|
-
|
|
27615
|
+
const totalSec = Math.floor(ms / 1000);
|
|
27616
|
+
const h = Math.floor(totalSec / 3600);
|
|
27617
|
+
const m = Math.floor(totalSec % 3600 / 60);
|
|
27618
|
+
const s = totalSec % 60;
|
|
27619
|
+
return [h, m, s].map((v) => String(v).padStart(2, "0")).join(":");
|
|
27620
|
+
}
|
|
27621
|
+
// ../common/src/polling/types.ts
|
|
27622
|
+
var PollOutcome = {
|
|
27623
|
+
Completed: "completed",
|
|
27624
|
+
Timeout: "timeout",
|
|
27625
|
+
Interrupted: "interrupted",
|
|
27626
|
+
Aborted: "aborted",
|
|
27627
|
+
Failed: "failed"
|
|
27628
|
+
};
|
|
27629
|
+
var ErrorDecision = {
|
|
27630
|
+
Abort: "abort"
|
|
27631
|
+
};
|
|
27632
|
+
var POLL_DEFAULTS = {
|
|
27633
|
+
intervalMs: 5000,
|
|
27634
|
+
timeoutMs: 1800000,
|
|
27635
|
+
maxConsecutiveErrors: 3,
|
|
27636
|
+
logIntervalMs: 30000,
|
|
27637
|
+
logPrefix: "wait"
|
|
27638
|
+
};
|
|
27639
|
+
var BACKOFF_DEFAULTS = {
|
|
27640
|
+
initialMs: 1000,
|
|
27641
|
+
multiplier: 2,
|
|
27642
|
+
maxMs: 30000,
|
|
27643
|
+
jitter: 0.5
|
|
27644
|
+
};
|
|
27645
|
+
var MIN_INTERVAL_MS = 100;
|
|
27646
|
+
|
|
27647
|
+
// ../common/src/polling/poll-failure-mapping.ts
|
|
27648
|
+
var REASON_BY_OUTCOME = {
|
|
27649
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
27650
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
27651
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
27652
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
27653
|
+
};
|
|
27654
|
+
// ../common/src/polling/poll-until.ts
|
|
27655
|
+
function resolveIntervalFn(options) {
|
|
27656
|
+
if (typeof options.intervalMs === "function") {
|
|
27657
|
+
return options.intervalMs;
|
|
27513
27658
|
}
|
|
27514
|
-
|
|
27515
|
-
|
|
27516
|
-
|
|
27517
|
-
|
|
27659
|
+
const staticInterval = options.intervalMs ?? POLL_DEFAULTS.intervalMs;
|
|
27660
|
+
return () => staticInterval;
|
|
27661
|
+
}
|
|
27662
|
+
function resolveBackoffFn(options) {
|
|
27663
|
+
if (!options.backoff)
|
|
27664
|
+
return;
|
|
27665
|
+
const config = options.backoff === true ? { ...BACKOFF_DEFAULTS } : {
|
|
27666
|
+
initialMs: options.backoff.initialMs ?? BACKOFF_DEFAULTS.initialMs,
|
|
27667
|
+
multiplier: options.backoff.multiplier ?? BACKOFF_DEFAULTS.multiplier,
|
|
27668
|
+
maxMs: options.backoff.maxMs ?? BACKOFF_DEFAULTS.maxMs,
|
|
27669
|
+
jitter: Math.min(1, Math.max(0, options.backoff.jitter ?? BACKOFF_DEFAULTS.jitter))
|
|
27670
|
+
};
|
|
27671
|
+
return (errorCount) => {
|
|
27672
|
+
const exponent = Math.min(errorCount - 1, 30);
|
|
27673
|
+
const raw = Math.min(config.initialMs * config.multiplier ** exponent, config.maxMs);
|
|
27674
|
+
if (config.jitter > 0) {
|
|
27675
|
+
const jitterAmount = raw * config.jitter;
|
|
27676
|
+
return raw - jitterAmount * Math.random();
|
|
27518
27677
|
}
|
|
27519
|
-
return
|
|
27520
|
-
}
|
|
27521
|
-
|
|
27522
|
-
|
|
27523
|
-
|
|
27524
|
-
|
|
27525
|
-
|
|
27526
|
-
static removeIdentifierChar(char) {
|
|
27527
|
-
Jsep.additional_identifier_chars.delete(char);
|
|
27528
|
-
return Jsep;
|
|
27529
|
-
}
|
|
27530
|
-
static removeBinaryOp(op_name) {
|
|
27531
|
-
delete Jsep.binary_ops[op_name];
|
|
27532
|
-
if (op_name.length === Jsep.max_binop_len) {
|
|
27533
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
27678
|
+
return raw;
|
|
27679
|
+
};
|
|
27680
|
+
}
|
|
27681
|
+
function clampInterval(raw, label, prefix) {
|
|
27682
|
+
if (!Number.isFinite(raw) || Number.isNaN(raw)) {
|
|
27683
|
+
if (label) {
|
|
27684
|
+
logger.warn(`[${prefix}] ${label} — intervalMs returned ${raw}, falling back to ${POLL_DEFAULTS.intervalMs}ms`);
|
|
27534
27685
|
}
|
|
27535
|
-
|
|
27536
|
-
return Jsep;
|
|
27537
|
-
}
|
|
27538
|
-
static removeAllBinaryOps() {
|
|
27539
|
-
Jsep.binary_ops = {};
|
|
27540
|
-
Jsep.max_binop_len = 0;
|
|
27541
|
-
return Jsep;
|
|
27542
|
-
}
|
|
27543
|
-
static removeLiteral(literal_name) {
|
|
27544
|
-
delete Jsep.literals[literal_name];
|
|
27545
|
-
return Jsep;
|
|
27546
|
-
}
|
|
27547
|
-
static removeAllLiterals() {
|
|
27548
|
-
Jsep.literals = {};
|
|
27549
|
-
return Jsep;
|
|
27550
|
-
}
|
|
27551
|
-
get char() {
|
|
27552
|
-
return this.expr.charAt(this.index);
|
|
27553
|
-
}
|
|
27554
|
-
get code() {
|
|
27555
|
-
return this.expr.charCodeAt(this.index);
|
|
27556
|
-
}
|
|
27557
|
-
constructor(expr) {
|
|
27558
|
-
this.expr = expr;
|
|
27559
|
-
this.index = 0;
|
|
27560
|
-
}
|
|
27561
|
-
static parse(expr) {
|
|
27562
|
-
return new Jsep(expr).parse();
|
|
27563
|
-
}
|
|
27564
|
-
static getMaxKeyLen(obj) {
|
|
27565
|
-
return Math.max(0, ...Object.keys(obj).map((k) => k.length));
|
|
27566
|
-
}
|
|
27567
|
-
static isDecimalDigit(ch) {
|
|
27568
|
-
return ch >= 48 && ch <= 57;
|
|
27569
|
-
}
|
|
27570
|
-
static binaryPrecedence(op_val) {
|
|
27571
|
-
return Jsep.binary_ops[op_val] || 0;
|
|
27572
|
-
}
|
|
27573
|
-
static isIdentifierStart(ch) {
|
|
27574
|
-
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));
|
|
27575
|
-
}
|
|
27576
|
-
static isIdentifierPart(ch) {
|
|
27577
|
-
return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
|
|
27578
|
-
}
|
|
27579
|
-
throwError(message) {
|
|
27580
|
-
const error = new Error(message + " at character " + this.index);
|
|
27581
|
-
error.index = this.index;
|
|
27582
|
-
error.description = message;
|
|
27583
|
-
throw error;
|
|
27686
|
+
return POLL_DEFAULTS.intervalMs;
|
|
27584
27687
|
}
|
|
27585
|
-
|
|
27586
|
-
if (
|
|
27587
|
-
|
|
27588
|
-
context: this,
|
|
27589
|
-
node
|
|
27590
|
-
};
|
|
27591
|
-
Jsep.hooks.run(name, env);
|
|
27592
|
-
return env.node;
|
|
27688
|
+
if (raw < MIN_INTERVAL_MS) {
|
|
27689
|
+
if (label) {
|
|
27690
|
+
logger.warn(`[${prefix}] ${label} — intervalMs ${raw}ms clamped to minimum ${MIN_INTERVAL_MS}ms`);
|
|
27593
27691
|
}
|
|
27594
|
-
return
|
|
27692
|
+
return MIN_INTERVAL_MS;
|
|
27595
27693
|
}
|
|
27596
|
-
|
|
27597
|
-
|
|
27598
|
-
|
|
27599
|
-
|
|
27600
|
-
|
|
27601
|
-
|
|
27602
|
-
callback.call(env.context, env);
|
|
27603
|
-
return env.node;
|
|
27604
|
-
});
|
|
27605
|
-
return env.node;
|
|
27606
|
-
}
|
|
27694
|
+
return raw;
|
|
27695
|
+
}
|
|
27696
|
+
function abortError(signal) {
|
|
27697
|
+
const reason = signal.reason;
|
|
27698
|
+
if (reason instanceof Error && reason.name === "AbortError") {
|
|
27699
|
+
return reason;
|
|
27607
27700
|
}
|
|
27608
|
-
|
|
27609
|
-
|
|
27610
|
-
|
|
27611
|
-
|
|
27701
|
+
const msg = reason instanceof Error ? reason.message : typeof reason === "string" || typeof reason === "number" ? String(reason) : "Aborted";
|
|
27702
|
+
const err = new Error(msg);
|
|
27703
|
+
err.name = "AbortError";
|
|
27704
|
+
return err;
|
|
27705
|
+
}
|
|
27706
|
+
function interruptibleSleep(ms, signal) {
|
|
27707
|
+
return new Promise((resolve2, reject) => {
|
|
27708
|
+
if (signal?.aborted) {
|
|
27709
|
+
reject(abortError(signal));
|
|
27710
|
+
return;
|
|
27612
27711
|
}
|
|
27613
|
-
|
|
27614
|
-
|
|
27615
|
-
|
|
27616
|
-
|
|
27617
|
-
const nodes = this.gobbleExpressions();
|
|
27618
|
-
const node = nodes.length === 1 ? nodes[0] : {
|
|
27619
|
-
type: Jsep.COMPOUND,
|
|
27620
|
-
body: nodes
|
|
27621
|
-
};
|
|
27622
|
-
return this.runHook("after-all", node);
|
|
27623
|
-
}
|
|
27624
|
-
gobbleExpressions(untilICode) {
|
|
27625
|
-
let nodes = [], ch_i, node;
|
|
27626
|
-
while (this.index < this.expr.length) {
|
|
27627
|
-
ch_i = this.code;
|
|
27628
|
-
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
27629
|
-
this.index++;
|
|
27630
|
-
} else {
|
|
27631
|
-
if (node = this.gobbleExpression()) {
|
|
27632
|
-
nodes.push(node);
|
|
27633
|
-
} else if (this.index < this.expr.length) {
|
|
27634
|
-
if (ch_i === untilICode) {
|
|
27635
|
-
break;
|
|
27636
|
-
}
|
|
27637
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
27638
|
-
}
|
|
27712
|
+
let onAbort;
|
|
27713
|
+
const cleanup = () => {
|
|
27714
|
+
if (onAbort) {
|
|
27715
|
+
signal?.removeEventListener("abort", onAbort);
|
|
27639
27716
|
}
|
|
27640
|
-
}
|
|
27641
|
-
|
|
27642
|
-
|
|
27643
|
-
|
|
27644
|
-
|
|
27645
|
-
|
|
27646
|
-
|
|
27647
|
-
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
|
|
27651
|
-
|
|
27652
|
-
while (tc_len > 0) {
|
|
27653
|
-
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)))) {
|
|
27654
|
-
this.index += tc_len;
|
|
27655
|
-
return to_check;
|
|
27656
|
-
}
|
|
27657
|
-
to_check = to_check.substr(0, --tc_len);
|
|
27658
|
-
}
|
|
27659
|
-
return false;
|
|
27660
|
-
}
|
|
27661
|
-
gobbleBinaryExpression() {
|
|
27662
|
-
let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
|
|
27663
|
-
left = this.gobbleToken();
|
|
27664
|
-
if (!left) {
|
|
27665
|
-
return left;
|
|
27666
|
-
}
|
|
27667
|
-
biop = this.gobbleBinaryOp();
|
|
27668
|
-
if (!biop) {
|
|
27669
|
-
return left;
|
|
27670
|
-
}
|
|
27671
|
-
biop_info = {
|
|
27672
|
-
value: biop,
|
|
27673
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
27674
|
-
right_a: Jsep.right_associative.has(biop)
|
|
27675
|
-
};
|
|
27676
|
-
right = this.gobbleToken();
|
|
27677
|
-
if (!right) {
|
|
27678
|
-
this.throwError("Expected expression after " + biop);
|
|
27679
|
-
}
|
|
27680
|
-
stack = [left, biop_info, right];
|
|
27681
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
27682
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
27683
|
-
if (prec === 0) {
|
|
27684
|
-
this.index -= biop.length;
|
|
27685
|
-
break;
|
|
27686
|
-
}
|
|
27687
|
-
biop_info = {
|
|
27688
|
-
value: biop,
|
|
27689
|
-
prec,
|
|
27690
|
-
right_a: Jsep.right_associative.has(biop)
|
|
27691
|
-
};
|
|
27692
|
-
cur_biop = biop;
|
|
27693
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
27694
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
27695
|
-
right = stack.pop();
|
|
27696
|
-
biop = stack.pop().value;
|
|
27697
|
-
left = stack.pop();
|
|
27698
|
-
node = {
|
|
27699
|
-
type: Jsep.BINARY_EXP,
|
|
27700
|
-
operator: biop,
|
|
27701
|
-
left,
|
|
27702
|
-
right
|
|
27703
|
-
};
|
|
27704
|
-
stack.push(node);
|
|
27705
|
-
}
|
|
27706
|
-
node = this.gobbleToken();
|
|
27707
|
-
if (!node) {
|
|
27708
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
27709
|
-
}
|
|
27710
|
-
stack.push(biop_info, node);
|
|
27711
|
-
}
|
|
27712
|
-
i = stack.length - 1;
|
|
27713
|
-
node = stack[i];
|
|
27714
|
-
while (i > 1) {
|
|
27715
|
-
node = {
|
|
27716
|
-
type: Jsep.BINARY_EXP,
|
|
27717
|
-
operator: stack[i - 1].value,
|
|
27718
|
-
left: stack[i - 2],
|
|
27719
|
-
right: node
|
|
27720
|
-
};
|
|
27721
|
-
i -= 2;
|
|
27722
|
-
}
|
|
27723
|
-
return node;
|
|
27724
|
-
}
|
|
27725
|
-
gobbleToken() {
|
|
27726
|
-
let ch, to_check, tc_len, node;
|
|
27727
|
-
this.gobbleSpaces();
|
|
27728
|
-
node = this.searchHook("gobble-token");
|
|
27729
|
-
if (node) {
|
|
27730
|
-
return this.runHook("after-token", node);
|
|
27731
|
-
}
|
|
27732
|
-
ch = this.code;
|
|
27733
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
27734
|
-
return this.gobbleNumericLiteral();
|
|
27735
|
-
}
|
|
27736
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
27737
|
-
node = this.gobbleStringLiteral();
|
|
27738
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
27739
|
-
node = this.gobbleArray();
|
|
27740
|
-
} else {
|
|
27741
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
27742
|
-
tc_len = to_check.length;
|
|
27743
|
-
while (tc_len > 0) {
|
|
27744
|
-
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)))) {
|
|
27745
|
-
this.index += tc_len;
|
|
27746
|
-
const argument = this.gobbleToken();
|
|
27747
|
-
if (!argument) {
|
|
27748
|
-
this.throwError("missing unaryOp argument");
|
|
27749
|
-
}
|
|
27750
|
-
return this.runHook("after-token", {
|
|
27751
|
-
type: Jsep.UNARY_EXP,
|
|
27752
|
-
operator: to_check,
|
|
27753
|
-
argument,
|
|
27754
|
-
prefix: true
|
|
27755
|
-
});
|
|
27756
|
-
}
|
|
27757
|
-
to_check = to_check.substr(0, --tc_len);
|
|
27758
|
-
}
|
|
27759
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
27760
|
-
node = this.gobbleIdentifier();
|
|
27761
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
27762
|
-
node = {
|
|
27763
|
-
type: Jsep.LITERAL,
|
|
27764
|
-
value: Jsep.literals[node.name],
|
|
27765
|
-
raw: node.name
|
|
27766
|
-
};
|
|
27767
|
-
} else if (node.name === Jsep.this_str) {
|
|
27768
|
-
node = {
|
|
27769
|
-
type: Jsep.THIS_EXP
|
|
27770
|
-
};
|
|
27771
|
-
}
|
|
27772
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
27773
|
-
node = this.gobbleGroup();
|
|
27774
|
-
}
|
|
27775
|
-
}
|
|
27776
|
-
if (!node) {
|
|
27777
|
-
return this.runHook("after-token", false);
|
|
27778
|
-
}
|
|
27779
|
-
node = this.gobbleTokenProperty(node);
|
|
27780
|
-
return this.runHook("after-token", node);
|
|
27781
|
-
}
|
|
27782
|
-
gobbleTokenProperty(node) {
|
|
27783
|
-
this.gobbleSpaces();
|
|
27784
|
-
let ch = this.code;
|
|
27785
|
-
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
27786
|
-
let optional;
|
|
27787
|
-
if (ch === Jsep.QUMARK_CODE) {
|
|
27788
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
27789
|
-
break;
|
|
27790
|
-
}
|
|
27791
|
-
optional = true;
|
|
27792
|
-
this.index += 2;
|
|
27793
|
-
this.gobbleSpaces();
|
|
27794
|
-
ch = this.code;
|
|
27795
|
-
}
|
|
27796
|
-
this.index++;
|
|
27797
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
27798
|
-
node = {
|
|
27799
|
-
type: Jsep.MEMBER_EXP,
|
|
27800
|
-
computed: true,
|
|
27801
|
-
object: node,
|
|
27802
|
-
property: this.gobbleExpression()
|
|
27803
|
-
};
|
|
27804
|
-
if (!node.property) {
|
|
27805
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
27806
|
-
}
|
|
27807
|
-
this.gobbleSpaces();
|
|
27808
|
-
ch = this.code;
|
|
27809
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
27810
|
-
this.throwError("Unclosed [");
|
|
27811
|
-
}
|
|
27812
|
-
this.index++;
|
|
27813
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
27814
|
-
node = {
|
|
27815
|
-
type: Jsep.CALL_EXP,
|
|
27816
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
27817
|
-
callee: node
|
|
27818
|
-
};
|
|
27819
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
27820
|
-
if (optional) {
|
|
27821
|
-
this.index--;
|
|
27822
|
-
}
|
|
27823
|
-
this.gobbleSpaces();
|
|
27824
|
-
node = {
|
|
27825
|
-
type: Jsep.MEMBER_EXP,
|
|
27826
|
-
computed: false,
|
|
27827
|
-
object: node,
|
|
27828
|
-
property: this.gobbleIdentifier()
|
|
27829
|
-
};
|
|
27830
|
-
}
|
|
27831
|
-
if (optional) {
|
|
27832
|
-
node.optional = true;
|
|
27833
|
-
}
|
|
27834
|
-
this.gobbleSpaces();
|
|
27835
|
-
ch = this.code;
|
|
27836
|
-
}
|
|
27837
|
-
return node;
|
|
27838
|
-
}
|
|
27839
|
-
gobbleNumericLiteral() {
|
|
27840
|
-
let number = "", ch, chCode;
|
|
27841
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
27842
|
-
number += this.expr.charAt(this.index++);
|
|
27843
|
-
}
|
|
27844
|
-
if (this.code === Jsep.PERIOD_CODE) {
|
|
27845
|
-
number += this.expr.charAt(this.index++);
|
|
27846
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
27847
|
-
number += this.expr.charAt(this.index++);
|
|
27848
|
-
}
|
|
27849
|
-
}
|
|
27850
|
-
ch = this.char;
|
|
27851
|
-
if (ch === "e" || ch === "E") {
|
|
27852
|
-
number += this.expr.charAt(this.index++);
|
|
27853
|
-
ch = this.char;
|
|
27854
|
-
if (ch === "+" || ch === "-") {
|
|
27855
|
-
number += this.expr.charAt(this.index++);
|
|
27856
|
-
}
|
|
27857
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
27858
|
-
number += this.expr.charAt(this.index++);
|
|
27859
|
-
}
|
|
27860
|
-
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
27861
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
27862
|
-
}
|
|
27863
|
-
}
|
|
27864
|
-
chCode = this.code;
|
|
27865
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
27866
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
27867
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
27868
|
-
this.throwError("Unexpected period");
|
|
27869
|
-
}
|
|
27870
|
-
return {
|
|
27871
|
-
type: Jsep.LITERAL,
|
|
27872
|
-
value: parseFloat(number),
|
|
27873
|
-
raw: number
|
|
27874
|
-
};
|
|
27875
|
-
}
|
|
27876
|
-
gobbleStringLiteral() {
|
|
27877
|
-
let str = "";
|
|
27878
|
-
const startIndex = this.index;
|
|
27879
|
-
const quote = this.expr.charAt(this.index++);
|
|
27880
|
-
let closed = false;
|
|
27881
|
-
while (this.index < this.expr.length) {
|
|
27882
|
-
let ch = this.expr.charAt(this.index++);
|
|
27883
|
-
if (ch === quote) {
|
|
27884
|
-
closed = true;
|
|
27885
|
-
break;
|
|
27886
|
-
} else if (ch === "\\") {
|
|
27887
|
-
ch = this.expr.charAt(this.index++);
|
|
27888
|
-
switch (ch) {
|
|
27889
|
-
case "n":
|
|
27890
|
-
str += `
|
|
27891
|
-
`;
|
|
27892
|
-
break;
|
|
27893
|
-
case "r":
|
|
27894
|
-
str += "\r";
|
|
27895
|
-
break;
|
|
27896
|
-
case "t":
|
|
27897
|
-
str += "\t";
|
|
27898
|
-
break;
|
|
27899
|
-
case "b":
|
|
27900
|
-
str += "\b";
|
|
27901
|
-
break;
|
|
27902
|
-
case "f":
|
|
27903
|
-
str += "\f";
|
|
27904
|
-
break;
|
|
27905
|
-
case "v":
|
|
27906
|
-
str += "\v";
|
|
27907
|
-
break;
|
|
27908
|
-
default:
|
|
27909
|
-
str += ch;
|
|
27910
|
-
}
|
|
27911
|
-
} else {
|
|
27912
|
-
str += ch;
|
|
27913
|
-
}
|
|
27914
|
-
}
|
|
27915
|
-
if (!closed) {
|
|
27916
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
27917
|
-
}
|
|
27918
|
-
return {
|
|
27919
|
-
type: Jsep.LITERAL,
|
|
27920
|
-
value: str,
|
|
27921
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
27922
|
-
};
|
|
27923
|
-
}
|
|
27924
|
-
gobbleIdentifier() {
|
|
27925
|
-
let ch = this.code, start = this.index;
|
|
27926
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
27927
|
-
this.index++;
|
|
27928
|
-
} else {
|
|
27929
|
-
this.throwError("Unexpected " + this.char);
|
|
27930
|
-
}
|
|
27931
|
-
while (this.index < this.expr.length) {
|
|
27932
|
-
ch = this.code;
|
|
27933
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
27934
|
-
this.index++;
|
|
27935
|
-
} else {
|
|
27936
|
-
break;
|
|
27937
|
-
}
|
|
27938
|
-
}
|
|
27939
|
-
return {
|
|
27940
|
-
type: Jsep.IDENTIFIER,
|
|
27941
|
-
name: this.expr.slice(start, this.index)
|
|
27942
|
-
};
|
|
27943
|
-
}
|
|
27944
|
-
gobbleArguments(termination) {
|
|
27945
|
-
const args = [];
|
|
27946
|
-
let closed = false;
|
|
27947
|
-
let separator_count = 0;
|
|
27948
|
-
while (this.index < this.expr.length) {
|
|
27949
|
-
this.gobbleSpaces();
|
|
27950
|
-
let ch_i = this.code;
|
|
27951
|
-
if (ch_i === termination) {
|
|
27952
|
-
closed = true;
|
|
27953
|
-
this.index++;
|
|
27954
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
27955
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
27956
|
-
}
|
|
27957
|
-
break;
|
|
27958
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
27959
|
-
this.index++;
|
|
27960
|
-
separator_count++;
|
|
27961
|
-
if (separator_count !== args.length) {
|
|
27962
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
27963
|
-
this.throwError("Unexpected token ,");
|
|
27964
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
27965
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
27966
|
-
args.push(null);
|
|
27967
|
-
}
|
|
27968
|
-
}
|
|
27969
|
-
}
|
|
27970
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
27971
|
-
this.throwError("Expected comma");
|
|
27972
|
-
} else {
|
|
27973
|
-
const node = this.gobbleExpression();
|
|
27974
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
27975
|
-
this.throwError("Expected comma");
|
|
27976
|
-
}
|
|
27977
|
-
args.push(node);
|
|
27978
|
-
}
|
|
27979
|
-
}
|
|
27980
|
-
if (!closed) {
|
|
27981
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
27982
|
-
}
|
|
27983
|
-
return args;
|
|
27984
|
-
}
|
|
27985
|
-
gobbleGroup() {
|
|
27986
|
-
this.index++;
|
|
27987
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
27988
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
27989
|
-
this.index++;
|
|
27990
|
-
if (nodes.length === 1) {
|
|
27991
|
-
return nodes[0];
|
|
27992
|
-
} else if (!nodes.length) {
|
|
27993
|
-
return false;
|
|
27994
|
-
} else {
|
|
27995
|
-
return {
|
|
27996
|
-
type: Jsep.SEQUENCE_EXP,
|
|
27997
|
-
expressions: nodes
|
|
27998
|
-
};
|
|
27999
|
-
}
|
|
28000
|
-
} else {
|
|
28001
|
-
this.throwError("Unclosed (");
|
|
28002
|
-
}
|
|
28003
|
-
}
|
|
28004
|
-
gobbleArray() {
|
|
28005
|
-
this.index++;
|
|
28006
|
-
return {
|
|
28007
|
-
type: Jsep.ARRAY_EXP,
|
|
28008
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
28009
|
-
};
|
|
28010
|
-
}
|
|
28011
|
-
}
|
|
28012
|
-
var hooks = new Hooks;
|
|
28013
|
-
Object.assign(Jsep, {
|
|
28014
|
-
hooks,
|
|
28015
|
-
plugins: new Plugins(Jsep),
|
|
28016
|
-
COMPOUND: "Compound",
|
|
28017
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
28018
|
-
IDENTIFIER: "Identifier",
|
|
28019
|
-
MEMBER_EXP: "MemberExpression",
|
|
28020
|
-
LITERAL: "Literal",
|
|
28021
|
-
THIS_EXP: "ThisExpression",
|
|
28022
|
-
CALL_EXP: "CallExpression",
|
|
28023
|
-
UNARY_EXP: "UnaryExpression",
|
|
28024
|
-
BINARY_EXP: "BinaryExpression",
|
|
28025
|
-
ARRAY_EXP: "ArrayExpression",
|
|
28026
|
-
TAB_CODE: 9,
|
|
28027
|
-
LF_CODE: 10,
|
|
28028
|
-
CR_CODE: 13,
|
|
28029
|
-
SPACE_CODE: 32,
|
|
28030
|
-
PERIOD_CODE: 46,
|
|
28031
|
-
COMMA_CODE: 44,
|
|
28032
|
-
SQUOTE_CODE: 39,
|
|
28033
|
-
DQUOTE_CODE: 34,
|
|
28034
|
-
OPAREN_CODE: 40,
|
|
28035
|
-
CPAREN_CODE: 41,
|
|
28036
|
-
OBRACK_CODE: 91,
|
|
28037
|
-
CBRACK_CODE: 93,
|
|
28038
|
-
QUMARK_CODE: 63,
|
|
28039
|
-
SEMCOL_CODE: 59,
|
|
28040
|
-
COLON_CODE: 58,
|
|
28041
|
-
unary_ops: {
|
|
28042
|
-
"-": 1,
|
|
28043
|
-
"!": 1,
|
|
28044
|
-
"~": 1,
|
|
28045
|
-
"+": 1
|
|
28046
|
-
},
|
|
28047
|
-
binary_ops: {
|
|
28048
|
-
"||": 1,
|
|
28049
|
-
"??": 1,
|
|
28050
|
-
"&&": 2,
|
|
28051
|
-
"|": 3,
|
|
28052
|
-
"^": 4,
|
|
28053
|
-
"&": 5,
|
|
28054
|
-
"==": 6,
|
|
28055
|
-
"!=": 6,
|
|
28056
|
-
"===": 6,
|
|
28057
|
-
"!==": 6,
|
|
28058
|
-
"<": 7,
|
|
28059
|
-
">": 7,
|
|
28060
|
-
"<=": 7,
|
|
28061
|
-
">=": 7,
|
|
28062
|
-
"<<": 8,
|
|
28063
|
-
">>": 8,
|
|
28064
|
-
">>>": 8,
|
|
28065
|
-
"+": 9,
|
|
28066
|
-
"-": 9,
|
|
28067
|
-
"*": 10,
|
|
28068
|
-
"/": 10,
|
|
28069
|
-
"%": 10,
|
|
28070
|
-
"**": 11
|
|
28071
|
-
},
|
|
28072
|
-
right_associative: new Set(["**"]),
|
|
28073
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
28074
|
-
literals: {
|
|
28075
|
-
true: true,
|
|
28076
|
-
false: false,
|
|
28077
|
-
null: null
|
|
28078
|
-
},
|
|
28079
|
-
this_str: "this"
|
|
28080
|
-
});
|
|
28081
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
28082
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
28083
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
28084
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
28085
|
-
});
|
|
28086
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
28087
|
-
jsep[m] = Jsep[m];
|
|
28088
|
-
});
|
|
28089
|
-
jsep.Jsep = Jsep;
|
|
28090
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
28091
|
-
var ternary = {
|
|
28092
|
-
name: "ternary",
|
|
28093
|
-
init(jsep2) {
|
|
28094
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env) {
|
|
28095
|
-
if (env.node && this.code === jsep2.QUMARK_CODE) {
|
|
28096
|
-
this.index++;
|
|
28097
|
-
const test = env.node;
|
|
28098
|
-
const consequent = this.gobbleExpression();
|
|
28099
|
-
if (!consequent) {
|
|
28100
|
-
this.throwError("Expected expression");
|
|
28101
|
-
}
|
|
28102
|
-
this.gobbleSpaces();
|
|
28103
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
28104
|
-
this.index++;
|
|
28105
|
-
const alternate = this.gobbleExpression();
|
|
28106
|
-
if (!alternate) {
|
|
28107
|
-
this.throwError("Expected expression");
|
|
28108
|
-
}
|
|
28109
|
-
env.node = {
|
|
28110
|
-
type: CONDITIONAL_EXP,
|
|
28111
|
-
test,
|
|
28112
|
-
consequent,
|
|
28113
|
-
alternate
|
|
28114
|
-
};
|
|
28115
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
28116
|
-
let newTest = test;
|
|
28117
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
28118
|
-
newTest = newTest.right;
|
|
28119
|
-
}
|
|
28120
|
-
env.node.test = newTest.right;
|
|
28121
|
-
newTest.right = env.node;
|
|
28122
|
-
env.node = test;
|
|
28123
|
-
}
|
|
28124
|
-
} else {
|
|
28125
|
-
this.throwError("Expected :");
|
|
28126
|
-
}
|
|
28127
|
-
}
|
|
28128
|
-
});
|
|
28129
|
-
}
|
|
28130
|
-
};
|
|
28131
|
-
jsep.plugins.register(ternary);
|
|
28132
|
-
var FSLASH_CODE = 47;
|
|
28133
|
-
var BSLASH_CODE = 92;
|
|
28134
|
-
var index = {
|
|
28135
|
-
name: "regex",
|
|
28136
|
-
init(jsep2) {
|
|
28137
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
|
|
28138
|
-
if (this.code === FSLASH_CODE) {
|
|
28139
|
-
const patternIndex = ++this.index;
|
|
28140
|
-
let inCharSet = false;
|
|
28141
|
-
while (this.index < this.expr.length) {
|
|
28142
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
28143
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
28144
|
-
let flags = "";
|
|
28145
|
-
while (++this.index < this.expr.length) {
|
|
28146
|
-
const code = this.code;
|
|
28147
|
-
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
28148
|
-
flags += this.char;
|
|
28149
|
-
} else {
|
|
28150
|
-
break;
|
|
28151
|
-
}
|
|
28152
|
-
}
|
|
28153
|
-
let value;
|
|
28154
|
-
try {
|
|
28155
|
-
value = new RegExp(pattern, flags);
|
|
28156
|
-
} catch (e) {
|
|
28157
|
-
this.throwError(e.message);
|
|
28158
|
-
}
|
|
28159
|
-
env.node = {
|
|
28160
|
-
type: jsep2.LITERAL,
|
|
28161
|
-
value,
|
|
28162
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
28163
|
-
};
|
|
28164
|
-
env.node = this.gobbleTokenProperty(env.node);
|
|
28165
|
-
return env.node;
|
|
28166
|
-
}
|
|
28167
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
28168
|
-
inCharSet = true;
|
|
28169
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
28170
|
-
inCharSet = false;
|
|
28171
|
-
}
|
|
28172
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
28173
|
-
}
|
|
28174
|
-
this.throwError("Unclosed Regex");
|
|
28175
|
-
}
|
|
28176
|
-
});
|
|
28177
|
-
}
|
|
28178
|
-
};
|
|
28179
|
-
var PLUS_CODE = 43;
|
|
28180
|
-
var MINUS_CODE = 45;
|
|
28181
|
-
var plugin = {
|
|
28182
|
-
name: "assignment",
|
|
28183
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
28184
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
28185
|
-
assignmentPrecedence: 0.9,
|
|
28186
|
-
init(jsep2) {
|
|
28187
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
28188
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
28189
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
|
|
28190
|
-
const code = this.code;
|
|
28191
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
28192
|
-
this.index += 2;
|
|
28193
|
-
env.node = {
|
|
28194
|
-
type: "UpdateExpression",
|
|
28195
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
28196
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
28197
|
-
prefix: true
|
|
28198
|
-
};
|
|
28199
|
-
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
28200
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
28201
|
-
}
|
|
28202
|
-
}
|
|
28203
|
-
});
|
|
28204
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
|
|
28205
|
-
if (env.node) {
|
|
28206
|
-
const code = this.code;
|
|
28207
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
28208
|
-
if (!updateNodeTypes.includes(env.node.type)) {
|
|
28209
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
28210
|
-
}
|
|
28211
|
-
this.index += 2;
|
|
28212
|
-
env.node = {
|
|
28213
|
-
type: "UpdateExpression",
|
|
28214
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
28215
|
-
argument: env.node,
|
|
28216
|
-
prefix: false
|
|
28217
|
-
};
|
|
28218
|
-
}
|
|
28219
|
-
}
|
|
28220
|
-
});
|
|
28221
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
|
|
28222
|
-
if (env.node) {
|
|
28223
|
-
updateBinariesToAssignments(env.node);
|
|
28224
|
-
}
|
|
28225
|
-
});
|
|
28226
|
-
function updateBinariesToAssignments(node) {
|
|
28227
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
28228
|
-
node.type = "AssignmentExpression";
|
|
28229
|
-
updateBinariesToAssignments(node.left);
|
|
28230
|
-
updateBinariesToAssignments(node.right);
|
|
28231
|
-
} else if (!node.operator) {
|
|
28232
|
-
Object.values(node).forEach((val) => {
|
|
28233
|
-
if (val && typeof val === "object") {
|
|
28234
|
-
updateBinariesToAssignments(val);
|
|
28235
|
-
}
|
|
28236
|
-
});
|
|
28237
|
-
}
|
|
28238
|
-
}
|
|
28239
|
-
}
|
|
28240
|
-
};
|
|
28241
|
-
jsep.plugins.register(index, plugin);
|
|
28242
|
-
jsep.addUnaryOp("typeof");
|
|
28243
|
-
jsep.addUnaryOp("void");
|
|
28244
|
-
jsep.addLiteral("null", null);
|
|
28245
|
-
jsep.addLiteral("undefined", undefined);
|
|
28246
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
28247
|
-
var SafeEval = {
|
|
28248
|
-
evalAst(ast, subs) {
|
|
28249
|
-
switch (ast.type) {
|
|
28250
|
-
case "BinaryExpression":
|
|
28251
|
-
case "LogicalExpression":
|
|
28252
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
28253
|
-
case "Compound":
|
|
28254
|
-
return SafeEval.evalCompound(ast, subs);
|
|
28255
|
-
case "ConditionalExpression":
|
|
28256
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
28257
|
-
case "Identifier":
|
|
28258
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
28259
|
-
case "Literal":
|
|
28260
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
28261
|
-
case "MemberExpression":
|
|
28262
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
28263
|
-
case "UnaryExpression":
|
|
28264
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
28265
|
-
case "ArrayExpression":
|
|
28266
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
28267
|
-
case "CallExpression":
|
|
28268
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
28269
|
-
case "AssignmentExpression":
|
|
28270
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
28271
|
-
default:
|
|
28272
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
28273
|
-
}
|
|
28274
|
-
},
|
|
28275
|
-
evalBinaryExpression(ast, subs) {
|
|
28276
|
-
const result = {
|
|
28277
|
-
"||": (a, b) => a || b(),
|
|
28278
|
-
"&&": (a, b) => a && b(),
|
|
28279
|
-
"|": (a, b) => a | b(),
|
|
28280
|
-
"^": (a, b) => a ^ b(),
|
|
28281
|
-
"&": (a, b) => a & b(),
|
|
28282
|
-
"==": (a, b) => a == b(),
|
|
28283
|
-
"!=": (a, b) => a != b(),
|
|
28284
|
-
"===": (a, b) => a === b(),
|
|
28285
|
-
"!==": (a, b) => a !== b(),
|
|
28286
|
-
"<": (a, b) => a < b(),
|
|
28287
|
-
">": (a, b) => a > b(),
|
|
28288
|
-
"<=": (a, b) => a <= b(),
|
|
28289
|
-
">=": (a, b) => a >= b(),
|
|
28290
|
-
"<<": (a, b) => a << b(),
|
|
28291
|
-
">>": (a, b) => a >> b(),
|
|
28292
|
-
">>>": (a, b) => a >>> b(),
|
|
28293
|
-
"+": (a, b) => a + b(),
|
|
28294
|
-
"-": (a, b) => a - b(),
|
|
28295
|
-
"*": (a, b) => a * b(),
|
|
28296
|
-
"/": (a, b) => a / b(),
|
|
28297
|
-
"%": (a, b) => a % b()
|
|
28298
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
28299
|
-
return result;
|
|
28300
|
-
},
|
|
28301
|
-
evalCompound(ast, subs) {
|
|
28302
|
-
let last;
|
|
28303
|
-
for (let i = 0;i < ast.body.length; i++) {
|
|
28304
|
-
if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
|
|
28305
|
-
i += 1;
|
|
28306
|
-
}
|
|
28307
|
-
const expr = ast.body[i];
|
|
28308
|
-
last = SafeEval.evalAst(expr, subs);
|
|
28309
|
-
}
|
|
28310
|
-
return last;
|
|
28311
|
-
},
|
|
28312
|
-
evalConditionalExpression(ast, subs) {
|
|
28313
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
28314
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
28315
|
-
}
|
|
28316
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
28317
|
-
},
|
|
28318
|
-
evalIdentifier(ast, subs) {
|
|
28319
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
28320
|
-
return subs[ast.name];
|
|
28321
|
-
}
|
|
28322
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
28323
|
-
},
|
|
28324
|
-
evalLiteral(ast) {
|
|
28325
|
-
return ast.value;
|
|
28326
|
-
},
|
|
28327
|
-
evalMemberExpression(ast, subs) {
|
|
28328
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
28329
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
28330
|
-
if (obj === undefined || obj === null) {
|
|
28331
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
28332
|
-
}
|
|
28333
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
28334
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
28335
|
-
}
|
|
28336
|
-
const result = obj[prop];
|
|
28337
|
-
if (typeof result === "function") {
|
|
28338
|
-
return result.bind(obj);
|
|
28339
|
-
}
|
|
28340
|
-
return result;
|
|
28341
|
-
},
|
|
28342
|
-
evalUnaryExpression(ast, subs) {
|
|
28343
|
-
const result = {
|
|
28344
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
28345
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
28346
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
28347
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
28348
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
28349
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
28350
|
-
}[ast.operator](ast.argument);
|
|
28351
|
-
return result;
|
|
28352
|
-
},
|
|
28353
|
-
evalArrayExpression(ast, subs) {
|
|
28354
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
28355
|
-
},
|
|
28356
|
-
evalCallExpression(ast, subs) {
|
|
28357
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
28358
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
28359
|
-
if (func === Function) {
|
|
28360
|
-
throw new Error("Function constructor is disabled");
|
|
28361
|
-
}
|
|
28362
|
-
return func(...args);
|
|
28363
|
-
},
|
|
28364
|
-
evalAssignmentExpression(ast, subs) {
|
|
28365
|
-
if (ast.left.type !== "Identifier") {
|
|
28366
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
28367
|
-
}
|
|
28368
|
-
const id = ast.left.name;
|
|
28369
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
28370
|
-
subs[id] = value;
|
|
28371
|
-
return subs[id];
|
|
28372
|
-
}
|
|
28373
|
-
};
|
|
28374
|
-
|
|
28375
|
-
class SafeScript {
|
|
28376
|
-
constructor(expr) {
|
|
28377
|
-
this.code = expr;
|
|
28378
|
-
this.ast = jsep(this.code);
|
|
28379
|
-
}
|
|
28380
|
-
runInNewContext(context) {
|
|
28381
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
28382
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
28383
|
-
}
|
|
28384
|
-
}
|
|
28385
|
-
function push(arr, item) {
|
|
28386
|
-
arr = arr.slice();
|
|
28387
|
-
arr.push(item);
|
|
28388
|
-
return arr;
|
|
28389
|
-
}
|
|
28390
|
-
function unshift(item, arr) {
|
|
28391
|
-
arr = arr.slice();
|
|
28392
|
-
arr.unshift(item);
|
|
28393
|
-
return arr;
|
|
28394
|
-
}
|
|
28395
|
-
|
|
28396
|
-
class NewError extends Error {
|
|
28397
|
-
constructor(value) {
|
|
28398
|
-
super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
|
|
28399
|
-
this.avoidNew = true;
|
|
28400
|
-
this.value = value;
|
|
28401
|
-
this.name = "NewError";
|
|
28402
|
-
}
|
|
28403
|
-
}
|
|
28404
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
28405
|
-
if (!(this instanceof JSONPath)) {
|
|
28406
|
-
try {
|
|
28407
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
28408
|
-
} catch (e) {
|
|
28409
|
-
if (!e.avoidNew) {
|
|
28410
|
-
throw e;
|
|
28411
|
-
}
|
|
28412
|
-
return e.value;
|
|
28413
|
-
}
|
|
28414
|
-
}
|
|
28415
|
-
if (typeof opts === "string") {
|
|
28416
|
-
otherTypeCallback = callback;
|
|
28417
|
-
callback = obj;
|
|
28418
|
-
obj = expr;
|
|
28419
|
-
expr = opts;
|
|
28420
|
-
opts = null;
|
|
28421
|
-
}
|
|
28422
|
-
const optObj = opts && typeof opts === "object";
|
|
28423
|
-
opts = opts || {};
|
|
28424
|
-
this.json = opts.json || obj;
|
|
28425
|
-
this.path = opts.path || expr;
|
|
28426
|
-
this.resultType = opts.resultType || "value";
|
|
28427
|
-
this.flatten = opts.flatten || false;
|
|
28428
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
28429
|
-
this.sandbox = opts.sandbox || {};
|
|
28430
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
28431
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
28432
|
-
this.parent = opts.parent || null;
|
|
28433
|
-
this.parentProperty = opts.parentProperty || null;
|
|
28434
|
-
this.callback = opts.callback || callback || null;
|
|
28435
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
28436
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
28437
|
-
};
|
|
28438
|
-
if (opts.autostart !== false) {
|
|
28439
|
-
const args = {
|
|
28440
|
-
path: optObj ? opts.path : expr
|
|
28441
|
-
};
|
|
28442
|
-
if (!optObj) {
|
|
28443
|
-
args.json = obj;
|
|
28444
|
-
} else if ("json" in opts) {
|
|
28445
|
-
args.json = opts.json;
|
|
28446
|
-
}
|
|
28447
|
-
const ret = this.evaluate(args);
|
|
28448
|
-
if (!ret || typeof ret !== "object") {
|
|
28449
|
-
throw new NewError(ret);
|
|
28450
|
-
}
|
|
28451
|
-
return ret;
|
|
28452
|
-
}
|
|
28453
|
-
}
|
|
28454
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
28455
|
-
let currParent = this.parent, currParentProperty = this.parentProperty;
|
|
28456
|
-
let {
|
|
28457
|
-
flatten,
|
|
28458
|
-
wrap
|
|
28459
|
-
} = this;
|
|
28460
|
-
this.currResultType = this.resultType;
|
|
28461
|
-
this.currEval = this.eval;
|
|
28462
|
-
this.currSandbox = this.sandbox;
|
|
28463
|
-
callback = callback || this.callback;
|
|
28464
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
28465
|
-
json = json || this.json;
|
|
28466
|
-
expr = expr || this.path;
|
|
28467
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
28468
|
-
if (!expr.path && expr.path !== "") {
|
|
28469
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
28470
|
-
}
|
|
28471
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
28472
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
28473
|
-
}
|
|
28474
|
-
({
|
|
28475
|
-
json
|
|
28476
|
-
} = expr);
|
|
28477
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
28478
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
28479
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
28480
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
28481
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
28482
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
28483
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
28484
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
28485
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
28486
|
-
expr = expr.path;
|
|
28487
|
-
}
|
|
28488
|
-
currParent = currParent || null;
|
|
28489
|
-
currParentProperty = currParentProperty || null;
|
|
28490
|
-
if (Array.isArray(expr)) {
|
|
28491
|
-
expr = JSONPath.toPathString(expr);
|
|
28492
|
-
}
|
|
28493
|
-
if (!expr && expr !== "" || !json) {
|
|
28494
|
-
return;
|
|
28495
|
-
}
|
|
28496
|
-
const exprList = JSONPath.toPathArray(expr);
|
|
28497
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
28498
|
-
exprList.shift();
|
|
28499
|
-
}
|
|
28500
|
-
this._hasParentSelector = null;
|
|
28501
|
-
const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
28502
|
-
return ea && !ea.isParentSelector;
|
|
28503
|
-
});
|
|
28504
|
-
if (!result.length) {
|
|
28505
|
-
return wrap ? [] : undefined;
|
|
28506
|
-
}
|
|
28507
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
28508
|
-
return this._getPreferredOutput(result[0]);
|
|
28509
|
-
}
|
|
28510
|
-
return result.reduce((rslt, ea) => {
|
|
28511
|
-
const valOrPath = this._getPreferredOutput(ea);
|
|
28512
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
28513
|
-
rslt = rslt.concat(valOrPath);
|
|
28514
|
-
} else {
|
|
28515
|
-
rslt.push(valOrPath);
|
|
28516
|
-
}
|
|
28517
|
-
return rslt;
|
|
28518
|
-
}, []);
|
|
28519
|
-
};
|
|
28520
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
28521
|
-
const resultType = this.currResultType;
|
|
28522
|
-
switch (resultType) {
|
|
28523
|
-
case "all": {
|
|
28524
|
-
const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
28525
|
-
ea.pointer = JSONPath.toPointer(path3);
|
|
28526
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
28527
|
-
return ea;
|
|
28528
|
-
}
|
|
28529
|
-
case "value":
|
|
28530
|
-
case "parent":
|
|
28531
|
-
case "parentProperty":
|
|
28532
|
-
return ea[resultType];
|
|
28533
|
-
case "path":
|
|
28534
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
28535
|
-
case "pointer":
|
|
28536
|
-
return JSONPath.toPointer(ea.path);
|
|
28537
|
-
default:
|
|
28538
|
-
throw new TypeError("Unknown result type");
|
|
28539
|
-
}
|
|
28540
|
-
};
|
|
28541
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
28542
|
-
if (callback) {
|
|
28543
|
-
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
28544
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
28545
|
-
callback(preferredOutput, type, fullRetObj);
|
|
28546
|
-
}
|
|
28547
|
-
};
|
|
28548
|
-
JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
28549
|
-
let retObj;
|
|
28550
|
-
if (!expr.length) {
|
|
28551
|
-
retObj = {
|
|
28552
|
-
path: path3,
|
|
28553
|
-
value: val,
|
|
28554
|
-
parent,
|
|
28555
|
-
parentProperty: parentPropName,
|
|
28556
|
-
hasArrExpr
|
|
28557
|
-
};
|
|
28558
|
-
this._handleCallback(retObj, callback, "value");
|
|
28559
|
-
return retObj;
|
|
28560
|
-
}
|
|
28561
|
-
const loc = expr[0], x = expr.slice(1);
|
|
28562
|
-
const ret = [];
|
|
28563
|
-
function addRet(elems) {
|
|
28564
|
-
if (Array.isArray(elems)) {
|
|
28565
|
-
elems.forEach((t) => {
|
|
28566
|
-
ret.push(t);
|
|
28567
|
-
});
|
|
28568
|
-
} else {
|
|
28569
|
-
ret.push(elems);
|
|
28570
|
-
}
|
|
28571
|
-
}
|
|
28572
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
28573
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
|
|
28574
|
-
} else if (loc === "*") {
|
|
28575
|
-
this._walk(val, (m) => {
|
|
28576
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
|
|
28577
|
-
});
|
|
28578
|
-
} else if (loc === "..") {
|
|
28579
|
-
addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
28580
|
-
this._walk(val, (m) => {
|
|
28581
|
-
if (typeof val[m] === "object") {
|
|
28582
|
-
addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
|
|
28583
|
-
}
|
|
28584
|
-
});
|
|
28585
|
-
} else if (loc === "^") {
|
|
28586
|
-
this._hasParentSelector = true;
|
|
28587
|
-
return {
|
|
28588
|
-
path: path3.slice(0, -1),
|
|
28589
|
-
expr: x,
|
|
28590
|
-
isParentSelector: true
|
|
28591
|
-
};
|
|
28592
|
-
} else if (loc === "~") {
|
|
28593
|
-
retObj = {
|
|
28594
|
-
path: push(path3, loc),
|
|
28595
|
-
value: parentPropName,
|
|
28596
|
-
parent,
|
|
28597
|
-
parentProperty: null
|
|
28598
|
-
};
|
|
28599
|
-
this._handleCallback(retObj, callback, "property");
|
|
28600
|
-
return retObj;
|
|
28601
|
-
} else if (loc === "$") {
|
|
28602
|
-
addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
|
|
28603
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
28604
|
-
addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
|
|
28605
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
28606
|
-
if (this.currEval === false) {
|
|
28607
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
28608
|
-
}
|
|
28609
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
28610
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
28611
|
-
if (nested) {
|
|
28612
|
-
this._walk(val, (m) => {
|
|
28613
|
-
const npath = [nested[2]];
|
|
28614
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
28615
|
-
const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
|
|
28616
|
-
if (filterResults.length > 0) {
|
|
28617
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
28618
|
-
}
|
|
28619
|
-
});
|
|
28620
|
-
} else {
|
|
28621
|
-
this._walk(val, (m) => {
|
|
28622
|
-
if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
|
|
28623
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
28624
|
-
}
|
|
28625
|
-
});
|
|
28626
|
-
}
|
|
28627
|
-
} else if (loc[0] === "(") {
|
|
28628
|
-
if (this.currEval === false) {
|
|
28629
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
28630
|
-
}
|
|
28631
|
-
addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
28632
|
-
} else if (loc[0] === "@") {
|
|
28633
|
-
let addType = false;
|
|
28634
|
-
const valueType = loc.slice(1, -2);
|
|
28635
|
-
switch (valueType) {
|
|
28636
|
-
case "scalar":
|
|
28637
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
28638
|
-
addType = true;
|
|
28639
|
-
}
|
|
28640
|
-
break;
|
|
28641
|
-
case "boolean":
|
|
28642
|
-
case "string":
|
|
28643
|
-
case "undefined":
|
|
28644
|
-
case "function":
|
|
28645
|
-
if (typeof val === valueType) {
|
|
28646
|
-
addType = true;
|
|
28647
|
-
}
|
|
28648
|
-
break;
|
|
28649
|
-
case "integer":
|
|
28650
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
28651
|
-
addType = true;
|
|
28652
|
-
}
|
|
28653
|
-
break;
|
|
28654
|
-
case "number":
|
|
28655
|
-
if (Number.isFinite(val)) {
|
|
28656
|
-
addType = true;
|
|
28657
|
-
}
|
|
28658
|
-
break;
|
|
28659
|
-
case "nonFinite":
|
|
28660
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
28661
|
-
addType = true;
|
|
28662
|
-
}
|
|
28663
|
-
break;
|
|
28664
|
-
case "object":
|
|
28665
|
-
if (val && typeof val === valueType) {
|
|
28666
|
-
addType = true;
|
|
28667
|
-
}
|
|
28668
|
-
break;
|
|
28669
|
-
case "array":
|
|
28670
|
-
if (Array.isArray(val)) {
|
|
28671
|
-
addType = true;
|
|
28672
|
-
}
|
|
28673
|
-
break;
|
|
28674
|
-
case "other":
|
|
28675
|
-
addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
|
|
28676
|
-
break;
|
|
28677
|
-
case "null":
|
|
28678
|
-
if (val === null) {
|
|
28679
|
-
addType = true;
|
|
28680
|
-
}
|
|
28681
|
-
break;
|
|
28682
|
-
default:
|
|
28683
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
28684
|
-
}
|
|
28685
|
-
if (addType) {
|
|
28686
|
-
retObj = {
|
|
28687
|
-
path: path3,
|
|
28688
|
-
value: val,
|
|
28689
|
-
parent,
|
|
28690
|
-
parentProperty: parentPropName
|
|
28691
|
-
};
|
|
28692
|
-
this._handleCallback(retObj, callback, "value");
|
|
28693
|
-
return retObj;
|
|
28694
|
-
}
|
|
28695
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
28696
|
-
const locProp = loc.slice(1);
|
|
28697
|
-
addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
|
|
28698
|
-
} else if (loc.includes(",")) {
|
|
28699
|
-
const parts = loc.split(",");
|
|
28700
|
-
for (const part of parts) {
|
|
28701
|
-
addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
|
|
28702
|
-
}
|
|
28703
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
28704
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
|
|
28705
|
-
}
|
|
28706
|
-
if (this._hasParentSelector) {
|
|
28707
|
-
for (let t = 0;t < ret.length; t++) {
|
|
28708
|
-
const rett = ret[t];
|
|
28709
|
-
if (rett && rett.isParentSelector) {
|
|
28710
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
28711
|
-
if (Array.isArray(tmp)) {
|
|
28712
|
-
ret[t] = tmp[0];
|
|
28713
|
-
const tl = tmp.length;
|
|
28714
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
28715
|
-
t++;
|
|
28716
|
-
ret.splice(t, 0, tmp[tt]);
|
|
28717
|
-
}
|
|
28718
|
-
} else {
|
|
28719
|
-
ret[t] = tmp;
|
|
28720
|
-
}
|
|
28721
|
-
}
|
|
28722
|
-
}
|
|
28723
|
-
}
|
|
28724
|
-
return ret;
|
|
28725
|
-
};
|
|
28726
|
-
JSONPath.prototype._walk = function(val, f) {
|
|
28727
|
-
if (Array.isArray(val)) {
|
|
28728
|
-
const n = val.length;
|
|
28729
|
-
for (let i = 0;i < n; i++) {
|
|
28730
|
-
f(i);
|
|
28731
|
-
}
|
|
28732
|
-
} else if (val && typeof val === "object") {
|
|
28733
|
-
Object.keys(val).forEach((m) => {
|
|
28734
|
-
f(m);
|
|
28735
|
-
});
|
|
28736
|
-
}
|
|
28737
|
-
};
|
|
28738
|
-
JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
|
|
28739
|
-
if (!Array.isArray(val)) {
|
|
28740
|
-
return;
|
|
28741
|
-
}
|
|
28742
|
-
const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
28743
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
28744
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
28745
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
28746
|
-
const ret = [];
|
|
28747
|
-
for (let i = start;i < end; i += step) {
|
|
28748
|
-
const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
|
|
28749
|
-
tmp.forEach((t) => {
|
|
28750
|
-
ret.push(t);
|
|
28751
|
-
});
|
|
28752
|
-
}
|
|
28753
|
-
return ret;
|
|
28754
|
-
};
|
|
28755
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
|
|
28756
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
28757
|
-
this.currSandbox._$_parent = parent;
|
|
28758
|
-
this.currSandbox._$_property = _vname;
|
|
28759
|
-
this.currSandbox._$_root = this.json;
|
|
28760
|
-
this.currSandbox._$_v = _v;
|
|
28761
|
-
const containsPath = code.includes("@path");
|
|
28762
|
-
if (containsPath) {
|
|
28763
|
-
this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
|
|
28764
|
-
}
|
|
28765
|
-
const scriptCacheKey = this.currEval + "Script:" + code;
|
|
28766
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
28767
|
-
let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
28768
|
-
if (containsPath) {
|
|
28769
|
-
script = script.replaceAll("@path", "_$_path");
|
|
28770
|
-
}
|
|
28771
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
28772
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
28773
|
-
} else if (this.currEval === "native") {
|
|
28774
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
28775
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
28776
|
-
const CurrEval = this.currEval;
|
|
28777
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
28778
|
-
} else if (typeof this.currEval === "function") {
|
|
28779
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
28780
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
28781
|
-
};
|
|
28782
|
-
} else {
|
|
28783
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
28784
|
-
}
|
|
28785
|
-
}
|
|
28786
|
-
try {
|
|
28787
|
-
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
28788
|
-
} catch (e) {
|
|
28789
|
-
if (this.ignoreEvalErrors) {
|
|
28790
|
-
return false;
|
|
28791
|
-
}
|
|
28792
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
28793
|
-
}
|
|
28794
|
-
};
|
|
28795
|
-
JSONPath.cache = {};
|
|
28796
|
-
JSONPath.toPathString = function(pathArr) {
|
|
28797
|
-
const x = pathArr, n = x.length;
|
|
28798
|
-
let p = "$";
|
|
28799
|
-
for (let i = 1;i < n; i++) {
|
|
28800
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
28801
|
-
p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
28802
|
-
}
|
|
28803
|
-
}
|
|
28804
|
-
return p;
|
|
28805
|
-
};
|
|
28806
|
-
JSONPath.toPointer = function(pointer) {
|
|
28807
|
-
const x = pointer, n = x.length;
|
|
28808
|
-
let p = "";
|
|
28809
|
-
for (let i = 1;i < n; i++) {
|
|
28810
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
28811
|
-
p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
|
|
28812
|
-
}
|
|
28813
|
-
}
|
|
28814
|
-
return p;
|
|
28815
|
-
};
|
|
28816
|
-
JSONPath.toPathArray = function(expr) {
|
|
28817
|
-
const {
|
|
28818
|
-
cache
|
|
28819
|
-
} = JSONPath;
|
|
28820
|
-
if (cache[expr]) {
|
|
28821
|
-
return cache[expr].concat();
|
|
28822
|
-
}
|
|
28823
|
-
const subx = [];
|
|
28824
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
28825
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
28826
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
28827
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
28828
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
28829
|
-
return ";" + ups.split("").join(";") + ";";
|
|
28830
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
28831
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
28832
|
-
const match = exp.match(/#(\d+)/u);
|
|
28833
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
28834
|
-
});
|
|
28835
|
-
cache[expr] = exprList;
|
|
28836
|
-
return cache[expr].concat();
|
|
28837
|
-
};
|
|
28838
|
-
JSONPath.prototype.safeVm = {
|
|
28839
|
-
Script: SafeScript
|
|
28840
|
-
};
|
|
28841
|
-
JSONPath.prototype.vm = vm;
|
|
28842
|
-
// ../common/src/option-aliases.ts
|
|
28843
|
-
function resolveDeprecatedOptionAlias({
|
|
28844
|
-
preferredValue,
|
|
28845
|
-
deprecatedValue,
|
|
28846
|
-
preferredFlag,
|
|
28847
|
-
deprecatedFlag
|
|
28848
|
-
}) {
|
|
28849
|
-
const hasPreferred = preferredValue !== undefined;
|
|
28850
|
-
const hasDeprecated = deprecatedValue !== undefined;
|
|
28851
|
-
if (hasPreferred && hasDeprecated) {
|
|
28852
|
-
return {
|
|
28853
|
-
value: undefined,
|
|
28854
|
-
usedDeprecated: true,
|
|
28855
|
-
error: {
|
|
28856
|
-
message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
|
|
28857
|
-
instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
|
|
28858
|
-
}
|
|
28859
|
-
};
|
|
28860
|
-
}
|
|
28861
|
-
return {
|
|
28862
|
-
value: hasPreferred ? preferredValue : deprecatedValue,
|
|
28863
|
-
usedDeprecated: hasDeprecated
|
|
28864
|
-
};
|
|
28865
|
-
}
|
|
28866
|
-
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
28867
|
-
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
28868
|
-
`);
|
|
28869
|
-
}
|
|
28870
|
-
var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
|
|
28871
|
-
function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
|
|
28872
|
-
return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
|
|
28873
|
-
warnDeprecatedTenantOption(tenant);
|
|
28874
|
-
return tenant;
|
|
28875
|
-
});
|
|
28876
|
-
}
|
|
28877
|
-
function warnDeprecatedTenantOption(tenant) {
|
|
28878
|
-
if (tenant === undefined)
|
|
28879
|
-
return;
|
|
28880
|
-
warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
|
|
28881
|
-
}
|
|
28882
|
-
// ../common/src/option-validators.ts
|
|
28883
|
-
function parsePositiveInteger(raw) {
|
|
28884
|
-
return parseSafeInteger(raw, 1);
|
|
28885
|
-
}
|
|
28886
|
-
function parseSafeInteger(raw, min) {
|
|
28887
|
-
const normalized = raw.trim();
|
|
28888
|
-
if (!/^\d+$/.test(normalized)) {
|
|
28889
|
-
return;
|
|
28890
|
-
}
|
|
28891
|
-
const parsed = Number(normalized);
|
|
28892
|
-
if (!Number.isSafeInteger(parsed) || parsed < min) {
|
|
28893
|
-
return;
|
|
28894
|
-
}
|
|
28895
|
-
return parsed;
|
|
28896
|
-
}
|
|
28897
|
-
// ../common/src/polling/format-utils.ts
|
|
28898
|
-
function msToDuration(ms) {
|
|
28899
|
-
if (!Number.isFinite(ms) || ms < 0) {
|
|
28900
|
-
return "00:00:00";
|
|
28901
|
-
}
|
|
28902
|
-
const totalSec = Math.floor(ms / 1000);
|
|
28903
|
-
const h = Math.floor(totalSec / 3600);
|
|
28904
|
-
const m = Math.floor(totalSec % 3600 / 60);
|
|
28905
|
-
const s = totalSec % 60;
|
|
28906
|
-
return [h, m, s].map((v) => String(v).padStart(2, "0")).join(":");
|
|
28907
|
-
}
|
|
28908
|
-
// ../common/src/polling/types.ts
|
|
28909
|
-
var PollOutcome = {
|
|
28910
|
-
Completed: "completed",
|
|
28911
|
-
Timeout: "timeout",
|
|
28912
|
-
Interrupted: "interrupted",
|
|
28913
|
-
Aborted: "aborted",
|
|
28914
|
-
Failed: "failed"
|
|
28915
|
-
};
|
|
28916
|
-
var ErrorDecision = {
|
|
28917
|
-
Abort: "abort"
|
|
28918
|
-
};
|
|
28919
|
-
var POLL_DEFAULTS = {
|
|
28920
|
-
intervalMs: 5000,
|
|
28921
|
-
timeoutMs: 1800000,
|
|
28922
|
-
maxConsecutiveErrors: 3,
|
|
28923
|
-
logIntervalMs: 30000,
|
|
28924
|
-
logPrefix: "wait"
|
|
28925
|
-
};
|
|
28926
|
-
var BACKOFF_DEFAULTS = {
|
|
28927
|
-
initialMs: 1000,
|
|
28928
|
-
multiplier: 2,
|
|
28929
|
-
maxMs: 30000,
|
|
28930
|
-
jitter: 0.5
|
|
28931
|
-
};
|
|
28932
|
-
var MIN_INTERVAL_MS = 100;
|
|
28933
|
-
|
|
28934
|
-
// ../common/src/polling/poll-failure-mapping.ts
|
|
28935
|
-
var REASON_BY_OUTCOME = {
|
|
28936
|
-
[PollOutcome.Timeout]: "poll_timeout",
|
|
28937
|
-
[PollOutcome.Failed]: "poll_failed",
|
|
28938
|
-
[PollOutcome.Interrupted]: "poll_failed",
|
|
28939
|
-
[PollOutcome.Aborted]: "poll_aborted"
|
|
28940
|
-
};
|
|
28941
|
-
// ../common/src/polling/poll-until.ts
|
|
28942
|
-
function resolveIntervalFn(options) {
|
|
28943
|
-
if (typeof options.intervalMs === "function") {
|
|
28944
|
-
return options.intervalMs;
|
|
28945
|
-
}
|
|
28946
|
-
const staticInterval = options.intervalMs ?? POLL_DEFAULTS.intervalMs;
|
|
28947
|
-
return () => staticInterval;
|
|
28948
|
-
}
|
|
28949
|
-
function resolveBackoffFn(options) {
|
|
28950
|
-
if (!options.backoff)
|
|
28951
|
-
return;
|
|
28952
|
-
const config = options.backoff === true ? { ...BACKOFF_DEFAULTS } : {
|
|
28953
|
-
initialMs: options.backoff.initialMs ?? BACKOFF_DEFAULTS.initialMs,
|
|
28954
|
-
multiplier: options.backoff.multiplier ?? BACKOFF_DEFAULTS.multiplier,
|
|
28955
|
-
maxMs: options.backoff.maxMs ?? BACKOFF_DEFAULTS.maxMs,
|
|
28956
|
-
jitter: Math.min(1, Math.max(0, options.backoff.jitter ?? BACKOFF_DEFAULTS.jitter))
|
|
28957
|
-
};
|
|
28958
|
-
return (errorCount) => {
|
|
28959
|
-
const exponent = Math.min(errorCount - 1, 30);
|
|
28960
|
-
const raw = Math.min(config.initialMs * config.multiplier ** exponent, config.maxMs);
|
|
28961
|
-
if (config.jitter > 0) {
|
|
28962
|
-
const jitterAmount = raw * config.jitter;
|
|
28963
|
-
return raw - jitterAmount * Math.random();
|
|
28964
|
-
}
|
|
28965
|
-
return raw;
|
|
28966
|
-
};
|
|
28967
|
-
}
|
|
28968
|
-
function clampInterval(raw, label, prefix) {
|
|
28969
|
-
if (!Number.isFinite(raw) || Number.isNaN(raw)) {
|
|
28970
|
-
if (label) {
|
|
28971
|
-
logger.warn(`[${prefix}] ${label} — intervalMs returned ${raw}, falling back to ${POLL_DEFAULTS.intervalMs}ms`);
|
|
28972
|
-
}
|
|
28973
|
-
return POLL_DEFAULTS.intervalMs;
|
|
28974
|
-
}
|
|
28975
|
-
if (raw < MIN_INTERVAL_MS) {
|
|
28976
|
-
if (label) {
|
|
28977
|
-
logger.warn(`[${prefix}] ${label} — intervalMs ${raw}ms clamped to minimum ${MIN_INTERVAL_MS}ms`);
|
|
28978
|
-
}
|
|
28979
|
-
return MIN_INTERVAL_MS;
|
|
28980
|
-
}
|
|
28981
|
-
return raw;
|
|
28982
|
-
}
|
|
28983
|
-
function abortError(signal) {
|
|
28984
|
-
const reason = signal.reason;
|
|
28985
|
-
if (reason instanceof Error && reason.name === "AbortError") {
|
|
28986
|
-
return reason;
|
|
28987
|
-
}
|
|
28988
|
-
const msg = reason instanceof Error ? reason.message : typeof reason === "string" || typeof reason === "number" ? String(reason) : "Aborted";
|
|
28989
|
-
const err = new Error(msg);
|
|
28990
|
-
err.name = "AbortError";
|
|
28991
|
-
return err;
|
|
28992
|
-
}
|
|
28993
|
-
function interruptibleSleep(ms, signal) {
|
|
28994
|
-
return new Promise((resolve2, reject) => {
|
|
28995
|
-
if (signal?.aborted) {
|
|
28996
|
-
reject(abortError(signal));
|
|
28997
|
-
return;
|
|
28998
|
-
}
|
|
28999
|
-
let onAbort;
|
|
29000
|
-
const cleanup = () => {
|
|
29001
|
-
if (onAbort) {
|
|
29002
|
-
signal?.removeEventListener("abort", onAbort);
|
|
29003
|
-
}
|
|
29004
|
-
};
|
|
29005
|
-
const timer = setTimeout(() => {
|
|
29006
|
-
cleanup();
|
|
29007
|
-
resolve2();
|
|
29008
|
-
}, ms);
|
|
29009
|
-
if (signal) {
|
|
29010
|
-
onAbort = () => {
|
|
29011
|
-
clearTimeout(timer);
|
|
29012
|
-
cleanup();
|
|
29013
|
-
reject(abortError(signal));
|
|
29014
|
-
};
|
|
29015
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
27717
|
+
};
|
|
27718
|
+
const timer = setTimeout(() => {
|
|
27719
|
+
cleanup();
|
|
27720
|
+
resolve2();
|
|
27721
|
+
}, ms);
|
|
27722
|
+
if (signal) {
|
|
27723
|
+
onAbort = () => {
|
|
27724
|
+
clearTimeout(timer);
|
|
27725
|
+
cleanup();
|
|
27726
|
+
reject(abortError(signal));
|
|
27727
|
+
};
|
|
27728
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
29016
27729
|
}
|
|
29017
27730
|
});
|
|
29018
27731
|
}
|
|
@@ -29336,6 +28049,17 @@ var FAILURE_STATUSES = new Set([
|
|
|
29336
28049
|
"canceled",
|
|
29337
28050
|
"stopped"
|
|
29338
28051
|
]);
|
|
28052
|
+
// ../common/src/preview.ts
|
|
28053
|
+
var previewSlot = singleton("PreviewBuild");
|
|
28054
|
+
function isPreviewBuild() {
|
|
28055
|
+
return previewSlot.get(false) ?? false;
|
|
28056
|
+
}
|
|
28057
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
28058
|
+
if (isPreviewBuild()) {
|
|
28059
|
+
return this.command(nameAndArgs, opts);
|
|
28060
|
+
}
|
|
28061
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
28062
|
+
};
|
|
29339
28063
|
// ../common/src/screen-logger.ts
|
|
29340
28064
|
var ScreenLogger;
|
|
29341
28065
|
((ScreenLogger) => {
|
|
@@ -29368,8 +28092,8 @@ function appendUserAgentToken(value, userAgent) {
|
|
|
29368
28092
|
function getEffectiveUserAgent(userAgent) {
|
|
29369
28093
|
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
29370
28094
|
}
|
|
29371
|
-
function
|
|
29372
|
-
return
|
|
28095
|
+
function getHeaderName(headers, headerName) {
|
|
28096
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
29373
28097
|
}
|
|
29374
28098
|
function getSdkUserAgentToken(pkg) {
|
|
29375
28099
|
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
@@ -29377,59 +28101,31 @@ function getSdkUserAgentToken(pkg) {
|
|
|
29377
28101
|
}
|
|
29378
28102
|
function addSdkUserAgentHeader(headers, userAgent) {
|
|
29379
28103
|
const result = { ...headers ?? {} };
|
|
29380
|
-
const
|
|
29381
|
-
|
|
29382
|
-
if (headerName) {
|
|
29383
|
-
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
29384
|
-
} else {
|
|
29385
|
-
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
29386
|
-
}
|
|
28104
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
28105
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
29387
28106
|
return result;
|
|
29388
28107
|
}
|
|
29389
|
-
function
|
|
29390
|
-
|
|
29391
|
-
if (isHeadersLike(headers)) {
|
|
29392
|
-
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
29393
|
-
return headers;
|
|
29394
|
-
}
|
|
29395
|
-
if (Array.isArray(headers)) {
|
|
29396
|
-
const result = headers.map((entry) => {
|
|
29397
|
-
const [key, value] = entry;
|
|
29398
|
-
return [key, value];
|
|
29399
|
-
});
|
|
29400
|
-
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
29401
|
-
if (headerIndex >= 0) {
|
|
29402
|
-
const [key, value] = result[headerIndex];
|
|
29403
|
-
result[headerIndex] = [
|
|
29404
|
-
key,
|
|
29405
|
-
appendUserAgentToken(value, effectiveUserAgent)
|
|
29406
|
-
];
|
|
29407
|
-
} else {
|
|
29408
|
-
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
29409
|
-
}
|
|
29410
|
-
return result;
|
|
29411
|
-
}
|
|
29412
|
-
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
28108
|
+
function asHeaderRecord(headers) {
|
|
28109
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
29413
28110
|
}
|
|
29414
|
-
function
|
|
28111
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
29415
28112
|
return async (requestContext) => {
|
|
29416
|
-
const
|
|
28113
|
+
const initWithHeaders = {
|
|
29417
28114
|
...requestContext.init,
|
|
29418
|
-
headers:
|
|
28115
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
29419
28116
|
};
|
|
29420
28117
|
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
29421
28118
|
...requestContext,
|
|
29422
|
-
init:
|
|
28119
|
+
init: initWithHeaders
|
|
29423
28120
|
}) : initOverrides;
|
|
29424
28121
|
return {
|
|
29425
28122
|
...override ?? {},
|
|
29426
|
-
headers:
|
|
28123
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
29427
28124
|
};
|
|
29428
28125
|
};
|
|
29429
28126
|
}
|
|
29430
|
-
function
|
|
28127
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
29431
28128
|
const prototype = BaseApiClass.prototype;
|
|
29432
|
-
const patchKey = userAgentPatchKey(userAgent);
|
|
29433
28129
|
if (prototype[patchKey]) {
|
|
29434
28130
|
return;
|
|
29435
28131
|
}
|
|
@@ -29437,13 +28133,16 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
|
29437
28133
|
throw new Error("Generated BaseAPI request function not found.");
|
|
29438
28134
|
}
|
|
29439
28135
|
const originalRequest = prototype.request;
|
|
29440
|
-
prototype.request = function
|
|
29441
|
-
return originalRequest.call(this, context,
|
|
28136
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
28137
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
29442
28138
|
};
|
|
29443
28139
|
Object.defineProperty(prototype, patchKey, {
|
|
29444
28140
|
value: true
|
|
29445
28141
|
});
|
|
29446
28142
|
}
|
|
28143
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
28144
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
28145
|
+
}
|
|
29447
28146
|
// ../common/src/tool-provider.ts
|
|
29448
28147
|
var factorySlot = singleton("PackagerFactoryProvider");
|
|
29449
28148
|
// ../integrationservice-sdk/generated/connections/src/runtime.ts
|
|
@@ -29976,7 +28675,7 @@ class TextApiResponse {
|
|
|
29976
28675
|
var package_default2 = {
|
|
29977
28676
|
name: "@uipath/integrationservice-sdk",
|
|
29978
28677
|
license: "MIT",
|
|
29979
|
-
version: "1.
|
|
28678
|
+
version: "1.197.0-preview.59",
|
|
29980
28679
|
repository: {
|
|
29981
28680
|
type: "git",
|
|
29982
28681
|
url: "https://github.com/UiPath/cli.git",
|
|
@@ -30003,7 +28702,7 @@ var package_default2 = {
|
|
|
30003
28702
|
"dist"
|
|
30004
28703
|
],
|
|
30005
28704
|
scripts: {
|
|
30006
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
28705
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
30007
28706
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
30008
28707
|
lint: "biome check .",
|
|
30009
28708
|
test: "vitest run",
|
|
@@ -35759,6 +34458,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
35759
34458
|
}
|
|
35760
34459
|
return url.pathname.length > 1 ? url.origin : baseUrl;
|
|
35761
34460
|
};
|
|
34461
|
+
var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
|
|
34462
|
+
const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
|
|
34463
|
+
if (isExternalAppAuth)
|
|
34464
|
+
return requestedScopes;
|
|
34465
|
+
return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
|
|
34466
|
+
};
|
|
35762
34467
|
var resolveConfigAsync = async ({
|
|
35763
34468
|
customAuthority,
|
|
35764
34469
|
customClientId,
|
|
@@ -35789,7 +34494,7 @@ var resolveConfigAsync = async ({
|
|
|
35789
34494
|
clientSecret = fileAuth.clientSecret;
|
|
35790
34495
|
}
|
|
35791
34496
|
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
35792
|
-
const scopes =
|
|
34497
|
+
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
35793
34498
|
return {
|
|
35794
34499
|
clientId,
|
|
35795
34500
|
clientSecret,
|
|
@@ -35804,6 +34509,76 @@ var resolveConfigAsync = async ({
|
|
|
35804
34509
|
init_constants();
|
|
35805
34510
|
// ../auth/src/loginStatus.ts
|
|
35806
34511
|
init_src();
|
|
34512
|
+
|
|
34513
|
+
// ../auth/src/authProfile.ts
|
|
34514
|
+
init_src();
|
|
34515
|
+
init_constants();
|
|
34516
|
+
var DEFAULT_AUTH_PROFILE = "default";
|
|
34517
|
+
var PROFILE_DIR = "profiles";
|
|
34518
|
+
var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
34519
|
+
var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
|
|
34520
|
+
var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
|
|
34521
|
+
var globalSlot2 = globalThis;
|
|
34522
|
+
function isAuthProfileStorage(value) {
|
|
34523
|
+
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
34524
|
+
}
|
|
34525
|
+
function createProfileStorage() {
|
|
34526
|
+
const [error, mod2] = catchError2(() => __require("node:async_hooks"));
|
|
34527
|
+
if (error || typeof mod2?.AsyncLocalStorage !== "function") {
|
|
34528
|
+
return {
|
|
34529
|
+
getStore: () => {
|
|
34530
|
+
return;
|
|
34531
|
+
},
|
|
34532
|
+
run: (_store, fn) => fn()
|
|
34533
|
+
};
|
|
34534
|
+
}
|
|
34535
|
+
return new mod2.AsyncLocalStorage;
|
|
34536
|
+
}
|
|
34537
|
+
function getProfileStorage() {
|
|
34538
|
+
const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
|
|
34539
|
+
if (isAuthProfileStorage(existing)) {
|
|
34540
|
+
return existing;
|
|
34541
|
+
}
|
|
34542
|
+
const storage = createProfileStorage();
|
|
34543
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
34544
|
+
return storage;
|
|
34545
|
+
}
|
|
34546
|
+
var profileStorage = getProfileStorage();
|
|
34547
|
+
|
|
34548
|
+
class AuthProfileValidationError extends Error {
|
|
34549
|
+
constructor(message) {
|
|
34550
|
+
super(message);
|
|
34551
|
+
this.name = "AuthProfileValidationError";
|
|
34552
|
+
}
|
|
34553
|
+
}
|
|
34554
|
+
function normalizeAuthProfileName(profile) {
|
|
34555
|
+
if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
|
|
34556
|
+
return;
|
|
34557
|
+
}
|
|
34558
|
+
if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
|
|
34559
|
+
throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
|
|
34560
|
+
}
|
|
34561
|
+
return profile;
|
|
34562
|
+
}
|
|
34563
|
+
function getActiveAuthProfile() {
|
|
34564
|
+
const scopedState = profileStorage.getStore();
|
|
34565
|
+
if (scopedState !== undefined) {
|
|
34566
|
+
return scopedState.profile;
|
|
34567
|
+
}
|
|
34568
|
+
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
34569
|
+
}
|
|
34570
|
+
function resolveAuthProfileFilePath(profile) {
|
|
34571
|
+
const normalized = normalizeAuthProfileName(profile);
|
|
34572
|
+
if (normalized === undefined) {
|
|
34573
|
+
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
34574
|
+
}
|
|
34575
|
+
const fs7 = getFileSystem();
|
|
34576
|
+
return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR2, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
34577
|
+
}
|
|
34578
|
+
function getActiveAuthProfileFilePath() {
|
|
34579
|
+
const profile = getActiveAuthProfile();
|
|
34580
|
+
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
34581
|
+
}
|
|
35807
34582
|
// ../auth/src/utils/jwt.ts
|
|
35808
34583
|
class InvalidIssuerError extends Error {
|
|
35809
34584
|
expected;
|
|
@@ -35932,23 +34707,74 @@ var readAuthFromEnv = () => {
|
|
|
35932
34707
|
organizationId,
|
|
35933
34708
|
tenantName,
|
|
35934
34709
|
tenantId,
|
|
35935
|
-
expiration
|
|
34710
|
+
expiration,
|
|
34711
|
+
source: "env" /* Env */
|
|
35936
34712
|
};
|
|
35937
34713
|
};
|
|
35938
34714
|
|
|
34715
|
+
// ../auth/src/refreshCircuitBreaker.ts
|
|
34716
|
+
init_src();
|
|
34717
|
+
var BREAKER_SUFFIX = ".refresh-state";
|
|
34718
|
+
var BACKOFF_BASE_MS = 60000;
|
|
34719
|
+
var BACKOFF_CAP_MS = 60 * 60 * 1000;
|
|
34720
|
+
var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
34721
|
+
async function refreshTokenFingerprint(refreshToken) {
|
|
34722
|
+
const bytes = new TextEncoder().encode(refreshToken);
|
|
34723
|
+
if (globalThis.crypto?.subtle) {
|
|
34724
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
34725
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
34726
|
+
}
|
|
34727
|
+
const { createHash } = await import("node:crypto");
|
|
34728
|
+
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
34729
|
+
}
|
|
34730
|
+
function breakerPathFor(authPath) {
|
|
34731
|
+
return `${authPath}${BREAKER_SUFFIX}`;
|
|
34732
|
+
}
|
|
34733
|
+
async function loadRefreshBreaker(authPath) {
|
|
34734
|
+
const fs7 = getFileSystem();
|
|
34735
|
+
try {
|
|
34736
|
+
const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
|
|
34737
|
+
if (!content)
|
|
34738
|
+
return {};
|
|
34739
|
+
const parsed = JSON.parse(content);
|
|
34740
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
34741
|
+
} catch {
|
|
34742
|
+
return {};
|
|
34743
|
+
}
|
|
34744
|
+
}
|
|
34745
|
+
async function saveRefreshBreaker(authPath, state) {
|
|
34746
|
+
try {
|
|
34747
|
+
const fs7 = getFileSystem();
|
|
34748
|
+
const path3 = breakerPathFor(authPath);
|
|
34749
|
+
await fs7.mkdir(fs7.path.dirname(path3));
|
|
34750
|
+
const tempPath = `${path3}.tmp`;
|
|
34751
|
+
await fs7.writeFile(tempPath, JSON.stringify(state));
|
|
34752
|
+
await fs7.rename(tempPath, path3);
|
|
34753
|
+
} catch {}
|
|
34754
|
+
}
|
|
34755
|
+
async function clearRefreshBreaker(authPath) {
|
|
34756
|
+
const fs7 = getFileSystem();
|
|
34757
|
+
const path3 = breakerPathFor(authPath);
|
|
34758
|
+
try {
|
|
34759
|
+
if (await fs7.exists(path3)) {
|
|
34760
|
+
await fs7.rm(path3);
|
|
34761
|
+
}
|
|
34762
|
+
} catch {}
|
|
34763
|
+
}
|
|
34764
|
+
function nextBackoffMs(attempts) {
|
|
34765
|
+
const shift = Math.max(0, attempts - 1);
|
|
34766
|
+
return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
|
|
34767
|
+
}
|
|
34768
|
+
function shouldSurface(state, nowMs) {
|
|
34769
|
+
if (state.lastSurfacedAtMs === undefined)
|
|
34770
|
+
return true;
|
|
34771
|
+
return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
|
|
34772
|
+
}
|
|
34773
|
+
|
|
35939
34774
|
// ../auth/src/robotClientFallback.ts
|
|
35940
34775
|
init_src();
|
|
35941
34776
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
35942
34777
|
var CLOSE_TIMEOUT_MS = 500;
|
|
35943
|
-
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
35944
|
-
var printNoticeOnce = () => {
|
|
35945
|
-
const slot = globalThis;
|
|
35946
|
-
if (slot[NOTICE_SENTINEL])
|
|
35947
|
-
return;
|
|
35948
|
-
slot[NOTICE_SENTINEL] = true;
|
|
35949
|
-
catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
35950
|
-
`));
|
|
35951
|
-
};
|
|
35952
34778
|
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
35953
34779
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
35954
34780
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
@@ -36064,7 +34890,6 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
36064
34890
|
issuerFromToken = issClaim;
|
|
36065
34891
|
}
|
|
36066
34892
|
}
|
|
36067
|
-
printNoticeOnce();
|
|
36068
34893
|
return {
|
|
36069
34894
|
accessToken,
|
|
36070
34895
|
baseUrl: parsedUrl.baseUrl,
|
|
@@ -36289,18 +35114,327 @@ var saveEnvFileAsync = async ({
|
|
|
36289
35114
|
};
|
|
36290
35115
|
|
|
36291
35116
|
// ../auth/src/loginStatus.ts
|
|
36292
|
-
|
|
36293
|
-
return
|
|
35117
|
+
var getLoginStatusAsync = async (options = {}) => {
|
|
35118
|
+
return getLoginStatusWithDeps(options);
|
|
35119
|
+
};
|
|
35120
|
+
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
35121
|
+
const {
|
|
35122
|
+
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
35123
|
+
loadEnvFile = loadEnvFileAsync,
|
|
35124
|
+
saveEnvFile = saveEnvFileAsync,
|
|
35125
|
+
getFs = getFileSystem,
|
|
35126
|
+
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
35127
|
+
resolveConfig: resolveConfig2 = resolveConfigAsync,
|
|
35128
|
+
robotFallback = tryRobotClientFallback,
|
|
35129
|
+
loadBreaker = loadRefreshBreaker,
|
|
35130
|
+
saveBreaker = saveRefreshBreaker,
|
|
35131
|
+
clearBreaker = clearRefreshBreaker
|
|
35132
|
+
} = deps;
|
|
35133
|
+
if (isRobotAuthEnforced()) {
|
|
35134
|
+
return resolveRobotEnforcedStatus(robotFallback);
|
|
35135
|
+
}
|
|
35136
|
+
if (isEnvAuthEnabled()) {
|
|
35137
|
+
return readAuthFromEnv();
|
|
35138
|
+
}
|
|
35139
|
+
const activeProfile = getActiveAuthProfile();
|
|
35140
|
+
const activeProfileFilePath = getActiveAuthProfileFilePath();
|
|
35141
|
+
const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
|
|
35142
|
+
const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
|
|
35143
|
+
const { ensureTokenValidityMinutes } = options;
|
|
35144
|
+
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
35145
|
+
if (absolutePath === undefined) {
|
|
35146
|
+
if (usingActiveProfile) {
|
|
35147
|
+
return {
|
|
35148
|
+
loginStatus: "Not logged in",
|
|
35149
|
+
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
35150
|
+
};
|
|
35151
|
+
}
|
|
35152
|
+
return resolveBorrowedRobotStatus(robotFallback);
|
|
35153
|
+
}
|
|
35154
|
+
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
35155
|
+
if ("status" in loaded) {
|
|
35156
|
+
return loaded.status;
|
|
35157
|
+
}
|
|
35158
|
+
const { credentials } = loaded;
|
|
35159
|
+
const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
|
|
35160
|
+
const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
|
|
35161
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
35162
|
+
let tokens = {
|
|
35163
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
35164
|
+
refreshToken: credentials.UIPATH_REFRESH_TOKEN,
|
|
35165
|
+
expiration,
|
|
35166
|
+
lockReleaseFailed: false
|
|
35167
|
+
};
|
|
35168
|
+
const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
35169
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
35170
|
+
const refreshed = await attemptRefresh({
|
|
35171
|
+
absolutePath,
|
|
35172
|
+
credentials,
|
|
35173
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
35174
|
+
refreshToken,
|
|
35175
|
+
expiration,
|
|
35176
|
+
ensureTokenValidityMinutes,
|
|
35177
|
+
getFs,
|
|
35178
|
+
loadEnvFile,
|
|
35179
|
+
saveEnvFile,
|
|
35180
|
+
refreshFn: refreshTokenFn,
|
|
35181
|
+
resolveConfig: resolveConfig2,
|
|
35182
|
+
loadBreaker,
|
|
35183
|
+
saveBreaker,
|
|
35184
|
+
clearBreaker,
|
|
35185
|
+
globalHint
|
|
35186
|
+
});
|
|
35187
|
+
if (refreshed.kind === "terminal") {
|
|
35188
|
+
return refreshed.status;
|
|
35189
|
+
}
|
|
35190
|
+
tokens = refreshed.tokens;
|
|
35191
|
+
}
|
|
35192
|
+
return buildFileStatus(tokens, credentials, globalHint);
|
|
35193
|
+
};
|
|
35194
|
+
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
35195
|
+
if (isEnvAuthEnabled()) {
|
|
35196
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
35197
|
+
}
|
|
35198
|
+
const robotCreds = await robotFallback({ force: true });
|
|
35199
|
+
if (!robotCreds) {
|
|
35200
|
+
return {
|
|
35201
|
+
loginStatus: "Not logged in",
|
|
35202
|
+
hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
|
|
35203
|
+
};
|
|
35204
|
+
}
|
|
35205
|
+
return buildRobotStatus(robotCreds);
|
|
36294
35206
|
}
|
|
36295
|
-
function
|
|
36296
|
-
|
|
35207
|
+
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
35208
|
+
const robotCreds = await robotFallback();
|
|
35209
|
+
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
36297
35210
|
}
|
|
36298
|
-
function
|
|
36299
|
-
|
|
35211
|
+
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
35212
|
+
let credentials;
|
|
35213
|
+
try {
|
|
35214
|
+
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
35215
|
+
} catch (error) {
|
|
35216
|
+
if (isFileNotFoundError(error)) {
|
|
35217
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
35218
|
+
}
|
|
35219
|
+
throw error;
|
|
35220
|
+
}
|
|
35221
|
+
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
35222
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
35223
|
+
}
|
|
35224
|
+
return { credentials };
|
|
35225
|
+
}
|
|
35226
|
+
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
35227
|
+
const fs7 = getFs();
|
|
35228
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
35229
|
+
if (absolutePath === globalPath)
|
|
35230
|
+
return;
|
|
35231
|
+
if (!await fs7.exists(globalPath))
|
|
35232
|
+
return;
|
|
35233
|
+
try {
|
|
35234
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
35235
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
35236
|
+
return;
|
|
35237
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
35238
|
+
if (globalExp && globalExp <= new Date)
|
|
35239
|
+
return;
|
|
35240
|
+
return `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
|
|
35241
|
+
} catch {
|
|
35242
|
+
return;
|
|
35243
|
+
}
|
|
36300
35244
|
}
|
|
36301
35245
|
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
36302
35246
|
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
36303
35247
|
}
|
|
35248
|
+
async function attemptRefresh(ctx) {
|
|
35249
|
+
const shortCircuit = await circuitBreakerShortCircuit(ctx);
|
|
35250
|
+
if (shortCircuit) {
|
|
35251
|
+
return { kind: "terminal", status: shortCircuit };
|
|
35252
|
+
}
|
|
35253
|
+
let release;
|
|
35254
|
+
try {
|
|
35255
|
+
release = await ctx.getFs().acquireLock(ctx.absolutePath);
|
|
35256
|
+
} catch (error) {
|
|
35257
|
+
return {
|
|
35258
|
+
kind: "terminal",
|
|
35259
|
+
status: await lockAcquireFailureStatus(ctx, error)
|
|
35260
|
+
};
|
|
35261
|
+
}
|
|
35262
|
+
let lockedFailure;
|
|
35263
|
+
let lockReleaseFailed = false;
|
|
35264
|
+
let success;
|
|
35265
|
+
try {
|
|
35266
|
+
const outcome = await runRefreshLocked({
|
|
35267
|
+
absolutePath: ctx.absolutePath,
|
|
35268
|
+
refreshToken: ctx.refreshToken,
|
|
35269
|
+
customAuthority: ctx.credentials.UIPATH_URL,
|
|
35270
|
+
ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
|
|
35271
|
+
loadEnvFile: ctx.loadEnvFile,
|
|
35272
|
+
saveEnvFile: ctx.saveEnvFile,
|
|
35273
|
+
refreshFn: ctx.refreshFn,
|
|
35274
|
+
resolveConfig: ctx.resolveConfig,
|
|
35275
|
+
loadBreaker: ctx.loadBreaker,
|
|
35276
|
+
saveBreaker: ctx.saveBreaker,
|
|
35277
|
+
clearBreaker: ctx.clearBreaker
|
|
35278
|
+
});
|
|
35279
|
+
if (outcome.kind === "fail") {
|
|
35280
|
+
lockedFailure = outcome.status;
|
|
35281
|
+
} else {
|
|
35282
|
+
success = outcome;
|
|
35283
|
+
}
|
|
35284
|
+
} finally {
|
|
35285
|
+
try {
|
|
35286
|
+
await release();
|
|
35287
|
+
} catch {
|
|
35288
|
+
lockReleaseFailed = true;
|
|
35289
|
+
}
|
|
35290
|
+
}
|
|
35291
|
+
if (lockedFailure) {
|
|
35292
|
+
const globalHint = await ctx.globalHint();
|
|
35293
|
+
const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
|
|
35294
|
+
return {
|
|
35295
|
+
kind: "terminal",
|
|
35296
|
+
status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
|
|
35297
|
+
};
|
|
35298
|
+
}
|
|
35299
|
+
return {
|
|
35300
|
+
kind: "refreshed",
|
|
35301
|
+
tokens: {
|
|
35302
|
+
accessToken: success?.accessToken,
|
|
35303
|
+
refreshToken: success?.refreshToken,
|
|
35304
|
+
expiration: success?.expiration,
|
|
35305
|
+
tokenRefresh: success?.tokenRefresh,
|
|
35306
|
+
persistenceWarning: success?.persistenceWarning,
|
|
35307
|
+
lockReleaseFailed
|
|
35308
|
+
}
|
|
35309
|
+
};
|
|
35310
|
+
}
|
|
35311
|
+
async function buildFileStatus(tokens, credentials, globalHint) {
|
|
35312
|
+
const result = {
|
|
35313
|
+
loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
|
|
35314
|
+
accessToken: tokens.accessToken,
|
|
35315
|
+
refreshToken: tokens.refreshToken,
|
|
35316
|
+
baseUrl: credentials.UIPATH_URL,
|
|
35317
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
35318
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
35319
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
35320
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
35321
|
+
expiration: tokens.expiration,
|
|
35322
|
+
source: "file" /* File */,
|
|
35323
|
+
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
35324
|
+
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
35325
|
+
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
35326
|
+
};
|
|
35327
|
+
if (result.loginStatus === "Expired") {
|
|
35328
|
+
const hint = await globalHint();
|
|
35329
|
+
if (hint) {
|
|
35330
|
+
result.hint = hint;
|
|
35331
|
+
}
|
|
35332
|
+
}
|
|
35333
|
+
return result;
|
|
35334
|
+
}
|
|
35335
|
+
function buildRobotStatus(robotCreds) {
|
|
35336
|
+
return {
|
|
35337
|
+
loginStatus: "Logged in",
|
|
35338
|
+
accessToken: robotCreds.accessToken,
|
|
35339
|
+
baseUrl: robotCreds.baseUrl,
|
|
35340
|
+
organizationName: robotCreds.organizationName,
|
|
35341
|
+
organizationId: robotCreds.organizationId,
|
|
35342
|
+
tenantName: robotCreds.tenantName,
|
|
35343
|
+
tenantId: robotCreds.tenantId,
|
|
35344
|
+
issuer: robotCreds.issuer,
|
|
35345
|
+
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
35346
|
+
source: "robot" /* Robot */
|
|
35347
|
+
};
|
|
35348
|
+
}
|
|
35349
|
+
var isFileNotFoundError = (error) => {
|
|
35350
|
+
if (!(error instanceof Object))
|
|
35351
|
+
return false;
|
|
35352
|
+
return error.code === "ENOENT";
|
|
35353
|
+
};
|
|
35354
|
+
async function circuitBreakerShortCircuit(ctx) {
|
|
35355
|
+
const {
|
|
35356
|
+
absolutePath,
|
|
35357
|
+
refreshToken,
|
|
35358
|
+
accessToken,
|
|
35359
|
+
credentials,
|
|
35360
|
+
expiration,
|
|
35361
|
+
loadBreaker,
|
|
35362
|
+
saveBreaker,
|
|
35363
|
+
clearBreaker
|
|
35364
|
+
} = ctx;
|
|
35365
|
+
const fingerprint = await refreshTokenFingerprint(refreshToken);
|
|
35366
|
+
const breaker = await loadBreaker(absolutePath).catch(() => ({}));
|
|
35367
|
+
if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
|
|
35368
|
+
await clearBreaker(absolutePath);
|
|
35369
|
+
breaker.deadTokenFp = undefined;
|
|
35370
|
+
}
|
|
35371
|
+
const nowMs = Date.now();
|
|
35372
|
+
const tokenIsDead = breaker.deadTokenFp === fingerprint;
|
|
35373
|
+
const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
|
|
35374
|
+
if (!tokenIsDead && !inBackoff)
|
|
35375
|
+
return;
|
|
35376
|
+
const globalHint = await ctx.globalHint();
|
|
35377
|
+
const suppressed = !shouldSurface(breaker, nowMs);
|
|
35378
|
+
if (!suppressed) {
|
|
35379
|
+
await saveBreaker(absolutePath, {
|
|
35380
|
+
...breaker,
|
|
35381
|
+
lastSurfacedAtMs: nowMs
|
|
35382
|
+
});
|
|
35383
|
+
}
|
|
35384
|
+
const deadHint = "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired. In a non-interactive context, authenticate with: uip login --client-id <id> --client-secret <secret> -t <tenant>.";
|
|
35385
|
+
const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
|
|
35386
|
+
return {
|
|
35387
|
+
loginStatus: globalHint ? "Expired" : "Refresh Failed",
|
|
35388
|
+
...globalHint ? {
|
|
35389
|
+
accessToken,
|
|
35390
|
+
refreshToken,
|
|
35391
|
+
baseUrl: credentials.UIPATH_URL,
|
|
35392
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
35393
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
35394
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
35395
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
35396
|
+
expiration,
|
|
35397
|
+
source: "file" /* File */
|
|
35398
|
+
} : {},
|
|
35399
|
+
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
35400
|
+
refreshCircuitOpen: true,
|
|
35401
|
+
refreshTelemetrySuppressed: suppressed,
|
|
35402
|
+
tokenRefresh: { attempted: false, success: false }
|
|
35403
|
+
};
|
|
35404
|
+
}
|
|
35405
|
+
async function lockAcquireFailureStatus(ctx, error) {
|
|
35406
|
+
const msg = errorMessage(error);
|
|
35407
|
+
const globalHint = await ctx.globalHint();
|
|
35408
|
+
if (globalHint) {
|
|
35409
|
+
return {
|
|
35410
|
+
loginStatus: "Expired",
|
|
35411
|
+
accessToken: ctx.accessToken,
|
|
35412
|
+
refreshToken: ctx.refreshToken,
|
|
35413
|
+
baseUrl: ctx.credentials.UIPATH_URL,
|
|
35414
|
+
organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
|
|
35415
|
+
organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
|
|
35416
|
+
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
35417
|
+
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
35418
|
+
expiration: ctx.expiration,
|
|
35419
|
+
source: "file" /* File */,
|
|
35420
|
+
hint: globalHint,
|
|
35421
|
+
tokenRefresh: {
|
|
35422
|
+
attempted: false,
|
|
35423
|
+
success: false,
|
|
35424
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
35425
|
+
}
|
|
35426
|
+
};
|
|
35427
|
+
}
|
|
35428
|
+
return {
|
|
35429
|
+
loginStatus: "Refresh Failed",
|
|
35430
|
+
hint: "Could not acquire the auth-file lock — too many concurrent `uip` processes, or a permission issue on the auth directory. Retry, or run 'uip login' to re-authenticate.",
|
|
35431
|
+
tokenRefresh: {
|
|
35432
|
+
attempted: false,
|
|
35433
|
+
success: false,
|
|
35434
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
35435
|
+
}
|
|
35436
|
+
};
|
|
35437
|
+
}
|
|
36304
35438
|
async function runRefreshLocked(inputs) {
|
|
36305
35439
|
const {
|
|
36306
35440
|
absolutePath,
|
|
@@ -36310,7 +35444,10 @@ async function runRefreshLocked(inputs) {
|
|
|
36310
35444
|
loadEnvFile,
|
|
36311
35445
|
saveEnvFile,
|
|
36312
35446
|
refreshFn,
|
|
36313
|
-
resolveConfig: resolveConfig2
|
|
35447
|
+
resolveConfig: resolveConfig2,
|
|
35448
|
+
loadBreaker,
|
|
35449
|
+
saveBreaker,
|
|
35450
|
+
clearBreaker
|
|
36314
35451
|
} = inputs;
|
|
36315
35452
|
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
36316
35453
|
let fresh;
|
|
@@ -36333,6 +35470,7 @@ async function runRefreshLocked(inputs) {
|
|
|
36333
35470
|
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
36334
35471
|
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
36335
35472
|
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
35473
|
+
await clearBreaker(absolutePath);
|
|
36336
35474
|
return {
|
|
36337
35475
|
kind: "ok",
|
|
36338
35476
|
accessToken: freshAccess,
|
|
@@ -36356,8 +35494,21 @@ async function runRefreshLocked(inputs) {
|
|
|
36356
35494
|
refreshedRefresh = refreshed.refreshToken;
|
|
36357
35495
|
} catch (error) {
|
|
36358
35496
|
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
36359
|
-
const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
|
|
35497
|
+
const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired. In a non-interactive context, authenticate with: uip login --client-id <id> --client-secret <secret> -t <tenant>." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
|
|
36360
35498
|
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
35499
|
+
const fp = await refreshTokenFingerprint(tokenForIdP);
|
|
35500
|
+
if (isOAuthFailure) {
|
|
35501
|
+
await saveBreaker(absolutePath, { deadTokenFp: fp });
|
|
35502
|
+
} else {
|
|
35503
|
+
const prior = await loadBreaker(absolutePath).catch(() => ({}));
|
|
35504
|
+
const attempts = (prior.attempts ?? 0) + 1;
|
|
35505
|
+
await saveBreaker(absolutePath, {
|
|
35506
|
+
...prior,
|
|
35507
|
+
deadTokenFp: undefined,
|
|
35508
|
+
attempts,
|
|
35509
|
+
backoffUntilMs: Date.now() + nextBackoffMs(attempts)
|
|
35510
|
+
});
|
|
35511
|
+
}
|
|
36361
35512
|
return {
|
|
36362
35513
|
kind: "fail",
|
|
36363
35514
|
status: {
|
|
@@ -36386,6 +35537,7 @@ async function runRefreshLocked(inputs) {
|
|
|
36386
35537
|
}
|
|
36387
35538
|
};
|
|
36388
35539
|
}
|
|
35540
|
+
await clearBreaker(absolutePath);
|
|
36389
35541
|
try {
|
|
36390
35542
|
await saveEnvFile({
|
|
36391
35543
|
envPath: absolutePath,
|
|
@@ -36418,212 +35570,15 @@ async function runRefreshLocked(inputs) {
|
|
|
36418
35570
|
};
|
|
36419
35571
|
}
|
|
36420
35572
|
}
|
|
36421
|
-
|
|
36422
|
-
|
|
36423
|
-
|
|
36424
|
-
|
|
36425
|
-
|
|
36426
|
-
|
|
36427
|
-
|
|
36428
|
-
|
|
36429
|
-
|
|
36430
|
-
} = deps;
|
|
36431
|
-
if (isRobotAuthEnforced()) {
|
|
36432
|
-
if (isEnvAuthEnabled()) {
|
|
36433
|
-
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
36434
|
-
}
|
|
36435
|
-
const robotCreds = await robotFallback({ force: true });
|
|
36436
|
-
if (!robotCreds) {
|
|
36437
|
-
return {
|
|
36438
|
-
loginStatus: "Not logged in",
|
|
36439
|
-
hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
|
|
36440
|
-
};
|
|
36441
|
-
}
|
|
36442
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
36443
|
-
return {
|
|
36444
|
-
loginStatus: "Logged in",
|
|
36445
|
-
accessToken: robotCreds.accessToken,
|
|
36446
|
-
baseUrl: robotCreds.baseUrl,
|
|
36447
|
-
organizationName: robotCreds.organizationName,
|
|
36448
|
-
organizationId: robotCreds.organizationId,
|
|
36449
|
-
tenantName: robotCreds.tenantName,
|
|
36450
|
-
tenantId: robotCreds.tenantId,
|
|
36451
|
-
issuer: robotCreds.issuer,
|
|
36452
|
-
expiration: expiration2,
|
|
36453
|
-
source: "robot" /* Robot */
|
|
36454
|
-
};
|
|
36455
|
-
}
|
|
36456
|
-
if (isEnvAuthEnabled()) {
|
|
36457
|
-
return readAuthFromEnv();
|
|
36458
|
-
}
|
|
36459
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
36460
|
-
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
36461
|
-
if (absolutePath === undefined) {
|
|
36462
|
-
const robotCreds = await robotFallback();
|
|
36463
|
-
if (robotCreds) {
|
|
36464
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
36465
|
-
const status = {
|
|
36466
|
-
loginStatus: "Logged in",
|
|
36467
|
-
accessToken: robotCreds.accessToken,
|
|
36468
|
-
baseUrl: robotCreds.baseUrl,
|
|
36469
|
-
organizationName: robotCreds.organizationName,
|
|
36470
|
-
organizationId: robotCreds.organizationId,
|
|
36471
|
-
tenantName: robotCreds.tenantName,
|
|
36472
|
-
tenantId: robotCreds.tenantId,
|
|
36473
|
-
issuer: robotCreds.issuer,
|
|
36474
|
-
expiration: expiration2,
|
|
36475
|
-
source: "robot" /* Robot */
|
|
36476
|
-
};
|
|
36477
|
-
return status;
|
|
36478
|
-
}
|
|
36479
|
-
return { loginStatus: "Not logged in" };
|
|
36480
|
-
}
|
|
36481
|
-
let credentials;
|
|
36482
|
-
try {
|
|
36483
|
-
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
36484
|
-
} catch (error) {
|
|
36485
|
-
if (isFileNotFoundError(error)) {
|
|
36486
|
-
return { loginStatus: "Not logged in" };
|
|
36487
|
-
}
|
|
36488
|
-
throw error;
|
|
36489
|
-
}
|
|
36490
|
-
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
36491
|
-
return { loginStatus: "Not logged in" };
|
|
36492
|
-
}
|
|
36493
|
-
let accessToken = credentials.UIPATH_ACCESS_TOKEN;
|
|
36494
|
-
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
36495
|
-
let expiration = getTokenExpiration(accessToken);
|
|
36496
|
-
let persistenceWarning;
|
|
36497
|
-
let lockReleaseFailed = false;
|
|
36498
|
-
let tokenRefresh;
|
|
36499
|
-
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
36500
|
-
const tryGlobalCredsHint = async () => {
|
|
36501
|
-
const fs7 = getFs();
|
|
36502
|
-
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
36503
|
-
if (absolutePath === globalPath)
|
|
36504
|
-
return;
|
|
36505
|
-
if (!await fs7.exists(globalPath))
|
|
36506
|
-
return;
|
|
36507
|
-
try {
|
|
36508
|
-
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
36509
|
-
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
36510
|
-
return;
|
|
36511
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
36512
|
-
if (globalExp && globalExp <= new Date)
|
|
36513
|
-
return;
|
|
36514
|
-
return `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
|
|
36515
|
-
} catch {
|
|
36516
|
-
return;
|
|
36517
|
-
}
|
|
36518
|
-
};
|
|
36519
|
-
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
36520
|
-
let release;
|
|
36521
|
-
try {
|
|
36522
|
-
release = await getFs().acquireLock(absolutePath);
|
|
36523
|
-
} catch (error) {
|
|
36524
|
-
const msg = errorMessage(error);
|
|
36525
|
-
const globalHint = await tryGlobalCredsHint();
|
|
36526
|
-
if (globalHint) {
|
|
36527
|
-
return {
|
|
36528
|
-
loginStatus: "Expired",
|
|
36529
|
-
accessToken,
|
|
36530
|
-
refreshToken,
|
|
36531
|
-
baseUrl: credentials.UIPATH_URL,
|
|
36532
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
36533
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
36534
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
36535
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
36536
|
-
expiration,
|
|
36537
|
-
source: "file" /* File */,
|
|
36538
|
-
hint: globalHint,
|
|
36539
|
-
tokenRefresh: {
|
|
36540
|
-
attempted: false,
|
|
36541
|
-
success: false,
|
|
36542
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
36543
|
-
}
|
|
36544
|
-
};
|
|
36545
|
-
}
|
|
36546
|
-
return {
|
|
36547
|
-
loginStatus: "Refresh Failed",
|
|
36548
|
-
hint: "Could not acquire the auth-file lock — too many concurrent `uip` processes, or a permission issue on the auth directory. Retry, or run 'uip login' to re-authenticate.",
|
|
36549
|
-
tokenRefresh: {
|
|
36550
|
-
attempted: false,
|
|
36551
|
-
success: false,
|
|
36552
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
36553
|
-
}
|
|
36554
|
-
};
|
|
36555
|
-
}
|
|
36556
|
-
let lockedFailure;
|
|
36557
|
-
try {
|
|
36558
|
-
const outcome = await runRefreshLocked({
|
|
36559
|
-
absolutePath,
|
|
36560
|
-
refreshToken,
|
|
36561
|
-
customAuthority: credentials.UIPATH_URL,
|
|
36562
|
-
ensureTokenValidityMinutes,
|
|
36563
|
-
loadEnvFile,
|
|
36564
|
-
saveEnvFile,
|
|
36565
|
-
refreshFn: refreshTokenFn,
|
|
36566
|
-
resolveConfig: resolveConfig2
|
|
36567
|
-
});
|
|
36568
|
-
if (outcome.kind === "fail") {
|
|
36569
|
-
lockedFailure = outcome.status;
|
|
36570
|
-
} else {
|
|
36571
|
-
accessToken = outcome.accessToken;
|
|
36572
|
-
refreshToken = outcome.refreshToken;
|
|
36573
|
-
expiration = outcome.expiration;
|
|
36574
|
-
tokenRefresh = outcome.tokenRefresh;
|
|
36575
|
-
if (outcome.persistenceWarning) {
|
|
36576
|
-
persistenceWarning = outcome.persistenceWarning;
|
|
36577
|
-
}
|
|
36578
|
-
}
|
|
36579
|
-
} finally {
|
|
36580
|
-
try {
|
|
36581
|
-
await release();
|
|
36582
|
-
} catch {
|
|
36583
|
-
lockReleaseFailed = true;
|
|
36584
|
-
}
|
|
36585
|
-
}
|
|
36586
|
-
if (lockedFailure) {
|
|
36587
|
-
const globalHint = await tryGlobalCredsHint();
|
|
36588
|
-
const base = globalHint ? {
|
|
36589
|
-
...lockedFailure,
|
|
36590
|
-
loginStatus: "Expired",
|
|
36591
|
-
hint: globalHint
|
|
36592
|
-
} : lockedFailure;
|
|
36593
|
-
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
36594
|
-
}
|
|
36595
|
-
}
|
|
36596
|
-
const result = {
|
|
36597
|
-
loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
|
|
36598
|
-
accessToken,
|
|
36599
|
-
refreshToken,
|
|
36600
|
-
baseUrl: credentials.UIPATH_URL,
|
|
36601
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
36602
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
36603
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
36604
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
36605
|
-
expiration,
|
|
36606
|
-
source: "file" /* File */,
|
|
36607
|
-
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
36608
|
-
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
36609
|
-
...tokenRefresh ? { tokenRefresh } : {}
|
|
36610
|
-
};
|
|
36611
|
-
if (result.loginStatus === "Expired") {
|
|
36612
|
-
const globalHint = await tryGlobalCredsHint();
|
|
36613
|
-
if (globalHint) {
|
|
36614
|
-
result.hint = globalHint;
|
|
36615
|
-
}
|
|
36616
|
-
}
|
|
36617
|
-
return result;
|
|
36618
|
-
};
|
|
36619
|
-
var isFileNotFoundError = (error) => {
|
|
36620
|
-
if (!(error instanceof Object))
|
|
36621
|
-
return false;
|
|
36622
|
-
return error.code === "ENOENT";
|
|
36623
|
-
};
|
|
36624
|
-
var getLoginStatusAsync = async (options = {}) => {
|
|
36625
|
-
return getLoginStatusWithDeps(options);
|
|
36626
|
-
};
|
|
35573
|
+
function normalizeTokenRefreshFailure() {
|
|
35574
|
+
return "stored refresh token is invalid or expired";
|
|
35575
|
+
}
|
|
35576
|
+
function normalizeTokenRefreshUnavailableFailure() {
|
|
35577
|
+
return "token refresh failed before authentication completed";
|
|
35578
|
+
}
|
|
35579
|
+
function errorMessage(error) {
|
|
35580
|
+
return error instanceof Error ? error.message : String(error);
|
|
35581
|
+
}
|
|
36627
35582
|
|
|
36628
35583
|
// ../auth/src/authContext.ts
|
|
36629
35584
|
var getAuthContext = async (options = {}) => {
|
|
@@ -36677,6 +35632,14 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
36677
35632
|
const data = await response.json();
|
|
36678
35633
|
return data;
|
|
36679
35634
|
};
|
|
35635
|
+
|
|
35636
|
+
// ../auth/src/selectTenant.ts
|
|
35637
|
+
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
35638
|
+
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
35639
|
+
var TENANT_SELECTION_CODES = new Set([
|
|
35640
|
+
TENANT_SELECTION_REQUIRED_CODE,
|
|
35641
|
+
INVALID_TENANT_CODE
|
|
35642
|
+
]);
|
|
36680
35643
|
// ../auth/src/logout.ts
|
|
36681
35644
|
init_src();
|
|
36682
35645
|
|
|
@@ -36855,6 +35818,8 @@ function folderOverride(folderKey) {
|
|
|
36855
35818
|
}
|
|
36856
35819
|
});
|
|
36857
35820
|
}
|
|
35821
|
+
// ../integrationservice-sdk/src/dap/essential-config.ts
|
|
35822
|
+
var JIT_INPUT_OPERATIONS = new Set(["create", "update", "replace"]);
|
|
36858
35823
|
// ../integrationservice-sdk/src/dap/filter-builder/workflow-value.ts
|
|
36859
35824
|
class WorkflowValue {
|
|
36860
35825
|
isLiteral;
|
|
@@ -37075,7 +36040,7 @@ class CeqlHelper {
|
|
|
37075
36040
|
if (fieldType.isSame(ClrTypeMock.Enum)) {
|
|
37076
36041
|
value = CeqlHelper._getCeqlValueFromEnumValue(value);
|
|
37077
36042
|
}
|
|
37078
|
-
const expression = value == null ? StringExtensions.empty : value.isLiteral ? value.value :
|
|
36043
|
+
const expression = value == null ? StringExtensions.empty : value.isLiteral ? value.value : `\${${String(value.value)}}`;
|
|
37079
36044
|
const valueExpression = CeqlHelper._isStringValue(fieldType) ? `'${String(expression).replace(/'/g, "''")}'` : `${expression}`;
|
|
37080
36045
|
return CeqlHelper._composeSingleValueExpression(field, op, valueExpression);
|
|
37081
36046
|
}
|
|
@@ -37446,6 +36411,9 @@ async function basePath(tenantName) {
|
|
|
37446
36411
|
async function buildPath(parts, tenantName) {
|
|
37447
36412
|
return fs7.path.join(await basePath(tenantName), ...parts);
|
|
37448
36413
|
}
|
|
36414
|
+
function sanitizeObjectNameForFile(objectName) {
|
|
36415
|
+
return objectName.replace(/[<>:"/\\|?*]/g, "_");
|
|
36416
|
+
}
|
|
37449
36417
|
async function readJson(filePath, ttlMs) {
|
|
37450
36418
|
const [err, raw] = await catchError(fs7.readFile(filePath, "utf-8"));
|
|
37451
36419
|
if (err || raw === null)
|
|
@@ -37551,14 +36519,14 @@ async function readSchema(connectorKey, connectionId, objectName, tenantName) {
|
|
|
37551
36519
|
return readJson(await buildPath([
|
|
37552
36520
|
connectorKey,
|
|
37553
36521
|
resolveCacheKey(connectionId),
|
|
37554
|
-
`${objectName}.schema.json`
|
|
36522
|
+
`${sanitizeObjectNameForFile(objectName)}.schema.json`
|
|
37555
36523
|
], tenantName), TTL.schema);
|
|
37556
36524
|
}
|
|
37557
36525
|
async function writeSchema(connectorKey, connectionId, objectName, schema, tenantName) {
|
|
37558
36526
|
await writeJson(await buildPath([
|
|
37559
36527
|
connectorKey,
|
|
37560
36528
|
resolveCacheKey(connectionId),
|
|
37561
|
-
`${objectName}.schema.json`
|
|
36529
|
+
`${sanitizeObjectNameForFile(objectName)}.schema.json`
|
|
37562
36530
|
], tenantName), schema);
|
|
37563
36531
|
}
|
|
37564
36532
|
async function readTriggerObjects(connectorKey, connectionId, operation, tenantName) {
|
|
@@ -37573,7 +36541,7 @@ async function readTriggerMetadata(connectorKey, connectionId, operation, object
|
|
|
37573
36541
|
connectionId,
|
|
37574
36542
|
"triggers",
|
|
37575
36543
|
operation,
|
|
37576
|
-
`${objectName}.metadata.json`
|
|
36544
|
+
`${sanitizeObjectNameForFile(objectName)}.metadata.json`
|
|
37577
36545
|
], tenantName), TTL.triggerMetadata);
|
|
37578
36546
|
}
|
|
37579
36547
|
async function writeTriggerMetadata(connectorKey, connectionId, operation, objectName, metadata, tenantName) {
|
|
@@ -37582,7 +36550,7 @@ async function writeTriggerMetadata(connectorKey, connectionId, operation, objec
|
|
|
37582
36550
|
connectionId,
|
|
37583
36551
|
"triggers",
|
|
37584
36552
|
operation,
|
|
37585
|
-
`${objectName}.metadata.json`
|
|
36553
|
+
`${sanitizeObjectNameForFile(objectName)}.metadata.json`
|
|
37586
36554
|
], tenantName), metadata);
|
|
37587
36555
|
}
|
|
37588
36556
|
|
|
@@ -39489,7 +38457,7 @@ function pruneFieldsForMethod(fields, httpMethod) {
|
|
|
39489
38457
|
for (const [key, fieldDef] of Object.entries(fields)) {
|
|
39490
38458
|
const def = fieldDef;
|
|
39491
38459
|
const methodInfo = def.method?.[httpMethod];
|
|
39492
|
-
if (
|
|
38460
|
+
if (methodInfo?.request !== true) {
|
|
39493
38461
|
out[key] = fieldDef;
|
|
39494
38462
|
}
|
|
39495
38463
|
}
|
|
@@ -40427,3 +39395,5 @@ export {
|
|
|
40427
39395
|
registerCommands,
|
|
40428
39396
|
metadata
|
|
40429
39397
|
};
|
|
39398
|
+
|
|
39399
|
+
//# debugId=09BFDC1323D3538264756E2164756E21
|