@uipath/resourcecatalog-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 +895 -1930
- package/dist/tool.js +880 -1914
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -13521,8 +13521,8 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
13521
13521
|
if (_parentOrParents instanceof Subscription2) {
|
|
13522
13522
|
_parentOrParents.remove(this);
|
|
13523
13523
|
} else if (_parentOrParents !== null) {
|
|
13524
|
-
for (var
|
|
13525
|
-
var parent_1 = _parentOrParents[
|
|
13524
|
+
for (var index = 0;index < _parentOrParents.length; ++index) {
|
|
13525
|
+
var parent_1 = _parentOrParents[index];
|
|
13526
13526
|
parent_1.remove(this);
|
|
13527
13527
|
}
|
|
13528
13528
|
}
|
|
@@ -13537,10 +13537,10 @@ var require_Subscription = __commonJS((exports) => {
|
|
|
13537
13537
|
}
|
|
13538
13538
|
}
|
|
13539
13539
|
if (isArray_1.isArray(_subscriptions)) {
|
|
13540
|
-
var
|
|
13540
|
+
var index = -1;
|
|
13541
13541
|
var len = _subscriptions.length;
|
|
13542
|
-
while (++
|
|
13543
|
-
var sub2 = _subscriptions[
|
|
13542
|
+
while (++index < len) {
|
|
13543
|
+
var sub2 = _subscriptions[index];
|
|
13544
13544
|
if (isObject_1.isObject(sub2)) {
|
|
13545
13545
|
try {
|
|
13546
13546
|
sub2.unsubscribe();
|
|
@@ -14970,13 +14970,13 @@ var require_AsyncAction = __commonJS((exports) => {
|
|
|
14970
14970
|
var id = this.id;
|
|
14971
14971
|
var scheduler = this.scheduler;
|
|
14972
14972
|
var actions = scheduler.actions;
|
|
14973
|
-
var
|
|
14973
|
+
var index = actions.indexOf(this);
|
|
14974
14974
|
this.work = null;
|
|
14975
14975
|
this.state = null;
|
|
14976
14976
|
this.pending = false;
|
|
14977
14977
|
this.scheduler = null;
|
|
14978
|
-
if (
|
|
14979
|
-
actions.splice(
|
|
14978
|
+
if (index !== -1) {
|
|
14979
|
+
actions.splice(index, 1);
|
|
14980
14980
|
}
|
|
14981
14981
|
if (id != null) {
|
|
14982
14982
|
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
@@ -15820,17 +15820,17 @@ var require_AsapScheduler = __commonJS((exports) => {
|
|
|
15820
15820
|
this.scheduled = undefined;
|
|
15821
15821
|
var actions = this.actions;
|
|
15822
15822
|
var error;
|
|
15823
|
-
var
|
|
15823
|
+
var index = -1;
|
|
15824
15824
|
var count = actions.length;
|
|
15825
15825
|
action = action || actions.shift();
|
|
15826
15826
|
do {
|
|
15827
15827
|
if (error = action.execute(action.state, action.delay)) {
|
|
15828
15828
|
break;
|
|
15829
15829
|
}
|
|
15830
|
-
} while (++
|
|
15830
|
+
} while (++index < count && (action = actions.shift()));
|
|
15831
15831
|
this.active = false;
|
|
15832
15832
|
if (error) {
|
|
15833
|
-
while (++
|
|
15833
|
+
while (++index < count && (action = actions.shift())) {
|
|
15834
15834
|
action.unsubscribe();
|
|
15835
15835
|
}
|
|
15836
15836
|
throw error;
|
|
@@ -15953,17 +15953,17 @@ var require_AnimationFrameScheduler = __commonJS((exports) => {
|
|
|
15953
15953
|
this.scheduled = undefined;
|
|
15954
15954
|
var actions = this.actions;
|
|
15955
15955
|
var error;
|
|
15956
|
-
var
|
|
15956
|
+
var index = -1;
|
|
15957
15957
|
var count = actions.length;
|
|
15958
15958
|
action = action || actions.shift();
|
|
15959
15959
|
do {
|
|
15960
15960
|
if (error = action.execute(action.state, action.delay)) {
|
|
15961
15961
|
break;
|
|
15962
15962
|
}
|
|
15963
|
-
} while (++
|
|
15963
|
+
} while (++index < count && (action = actions.shift()));
|
|
15964
15964
|
this.active = false;
|
|
15965
15965
|
if (error) {
|
|
15966
|
-
while (++
|
|
15966
|
+
while (++index < count && (action = actions.shift())) {
|
|
15967
15967
|
action.unsubscribe();
|
|
15968
15968
|
}
|
|
15969
15969
|
throw error;
|
|
@@ -16047,16 +16047,16 @@ var require_VirtualTimeScheduler = __commonJS((exports) => {
|
|
|
16047
16047
|
exports.VirtualTimeScheduler = VirtualTimeScheduler;
|
|
16048
16048
|
var VirtualAction = function(_super) {
|
|
16049
16049
|
__extends(VirtualAction2, _super);
|
|
16050
|
-
function VirtualAction2(scheduler, work,
|
|
16051
|
-
if (
|
|
16052
|
-
|
|
16050
|
+
function VirtualAction2(scheduler, work, index) {
|
|
16051
|
+
if (index === undefined) {
|
|
16052
|
+
index = scheduler.index += 1;
|
|
16053
16053
|
}
|
|
16054
16054
|
var _this = _super.call(this, scheduler, work) || this;
|
|
16055
16055
|
_this.scheduler = scheduler;
|
|
16056
16056
|
_this.work = work;
|
|
16057
|
-
_this.index =
|
|
16057
|
+
_this.index = index;
|
|
16058
16058
|
_this.active = true;
|
|
16059
|
-
_this.index = scheduler.index =
|
|
16059
|
+
_this.index = scheduler.index = index;
|
|
16060
16060
|
return _this;
|
|
16061
16061
|
}
|
|
16062
16062
|
VirtualAction2.prototype.schedule = function(state, delay) {
|
|
@@ -17203,9 +17203,9 @@ var require_mergeMap = __commonJS((exports) => {
|
|
|
17203
17203
|
};
|
|
17204
17204
|
MergeMapSubscriber2.prototype._tryNext = function(value) {
|
|
17205
17205
|
var result;
|
|
17206
|
-
var
|
|
17206
|
+
var index = this.index++;
|
|
17207
17207
|
try {
|
|
17208
|
-
result = this.project(value,
|
|
17208
|
+
result = this.project(value, index);
|
|
17209
17209
|
} catch (err) {
|
|
17210
17210
|
this.destination.error(err);
|
|
17211
17211
|
return;
|
|
@@ -17785,12 +17785,12 @@ var require_pairs2 = __commonJS((exports) => {
|
|
|
17785
17785
|
}
|
|
17786
17786
|
exports.pairs = pairs;
|
|
17787
17787
|
function dispatch(state) {
|
|
17788
|
-
var { keys, index
|
|
17788
|
+
var { keys, index, subscriber, subscription, obj } = state;
|
|
17789
17789
|
if (!subscriber.closed) {
|
|
17790
|
-
if (
|
|
17791
|
-
var key = keys[
|
|
17790
|
+
if (index < keys.length) {
|
|
17791
|
+
var key = keys[index];
|
|
17792
17792
|
subscriber.next([key, obj[key]]);
|
|
17793
|
-
subscription.add(this.schedule({ keys, index:
|
|
17793
|
+
subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
|
|
17794
17794
|
} else {
|
|
17795
17795
|
subscriber.complete();
|
|
17796
17796
|
}
|
|
@@ -18003,18 +18003,18 @@ var require_range = __commonJS((exports) => {
|
|
|
18003
18003
|
count = start;
|
|
18004
18004
|
start = 0;
|
|
18005
18005
|
}
|
|
18006
|
-
var
|
|
18006
|
+
var index = 0;
|
|
18007
18007
|
var current = start;
|
|
18008
18008
|
if (scheduler) {
|
|
18009
18009
|
return scheduler.schedule(dispatch, 0, {
|
|
18010
|
-
index
|
|
18010
|
+
index,
|
|
18011
18011
|
count,
|
|
18012
18012
|
start,
|
|
18013
18013
|
subscriber
|
|
18014
18014
|
});
|
|
18015
18015
|
} else {
|
|
18016
18016
|
do {
|
|
18017
|
-
if (
|
|
18017
|
+
if (index++ >= count) {
|
|
18018
18018
|
subscriber.complete();
|
|
18019
18019
|
break;
|
|
18020
18020
|
}
|
|
@@ -18029,8 +18029,8 @@ var require_range = __commonJS((exports) => {
|
|
|
18029
18029
|
}
|
|
18030
18030
|
exports.range = range;
|
|
18031
18031
|
function dispatch(state) {
|
|
18032
|
-
var { start, index
|
|
18033
|
-
if (
|
|
18032
|
+
var { start, index, count, subscriber } = state;
|
|
18033
|
+
if (index >= count) {
|
|
18034
18034
|
subscriber.complete();
|
|
18035
18035
|
return;
|
|
18036
18036
|
}
|
|
@@ -18038,7 +18038,7 @@ var require_range = __commonJS((exports) => {
|
|
|
18038
18038
|
if (subscriber.closed) {
|
|
18039
18039
|
return;
|
|
18040
18040
|
}
|
|
18041
|
-
state.index =
|
|
18041
|
+
state.index = index + 1;
|
|
18042
18042
|
state.start = start + 1;
|
|
18043
18043
|
this.schedule(state);
|
|
18044
18044
|
}
|
|
@@ -18076,14 +18076,14 @@ var require_timer = __commonJS((exports) => {
|
|
|
18076
18076
|
}
|
|
18077
18077
|
exports.timer = timer;
|
|
18078
18078
|
function dispatch(state) {
|
|
18079
|
-
var { index
|
|
18080
|
-
subscriber.next(
|
|
18079
|
+
var { index, period, subscriber } = state;
|
|
18080
|
+
subscriber.next(index);
|
|
18081
18081
|
if (subscriber.closed) {
|
|
18082
18082
|
return;
|
|
18083
18083
|
} else if (period === -1) {
|
|
18084
18084
|
return subscriber.complete();
|
|
18085
18085
|
}
|
|
18086
|
-
state.index =
|
|
18086
|
+
state.index = index + 1;
|
|
18087
18087
|
this.schedule(state, period);
|
|
18088
18088
|
}
|
|
18089
18089
|
});
|
|
@@ -21247,7 +21247,7 @@ var {
|
|
|
21247
21247
|
var package_default = {
|
|
21248
21248
|
name: "@uipath/resourcecatalog-tool",
|
|
21249
21249
|
license: "MIT",
|
|
21250
|
-
version: "1.
|
|
21250
|
+
version: "1.197.0-preview.59",
|
|
21251
21251
|
description: "CLI plugin for the UiPath Resource Catalog Service.",
|
|
21252
21252
|
private: false,
|
|
21253
21253
|
repository: {
|
|
@@ -21273,7 +21273,7 @@ var package_default = {
|
|
|
21273
21273
|
"dist"
|
|
21274
21274
|
],
|
|
21275
21275
|
scripts: {
|
|
21276
|
-
build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander && bun build ./src/index.ts --outdir dist --format esm --target node",
|
|
21276
|
+
build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander --sourcemap=linked && bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked",
|
|
21277
21277
|
package: "bun run build && bun pm pack",
|
|
21278
21278
|
lint: "biome check .",
|
|
21279
21279
|
"lint:fix": "biome check --write .",
|
|
@@ -21336,27 +21336,54 @@ var NETWORK_ERROR_CODES = new Set([
|
|
|
21336
21336
|
"ENETUNREACH",
|
|
21337
21337
|
"EAI_FAIL"
|
|
21338
21338
|
]);
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21347
|
-
|
|
21348
|
-
|
|
21349
|
-
|
|
21350
|
-
|
|
21351
|
-
|
|
21352
|
-
|
|
21353
|
-
|
|
21354
|
-
|
|
21355
|
-
|
|
21339
|
+
var TLS_ERROR_CODES = new Set([
|
|
21340
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
21341
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
21342
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
21343
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
21344
|
+
"UNABLE_TO_GET_ISSUER_CERT",
|
|
21345
|
+
"CERT_HAS_EXPIRED",
|
|
21346
|
+
"CERT_UNTRUSTED",
|
|
21347
|
+
"ERR_TLS_CERT_ALTNAME_INVALID"
|
|
21348
|
+
]);
|
|
21349
|
+
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.";
|
|
21350
|
+
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.";
|
|
21351
|
+
function describeConnectivityError(error) {
|
|
21352
|
+
let current = error;
|
|
21353
|
+
for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
|
|
21354
|
+
const cur = current;
|
|
21355
|
+
const code = typeof cur.code === "string" ? cur.code : undefined;
|
|
21356
|
+
const message = typeof cur.message === "string" ? cur.message : undefined;
|
|
21357
|
+
if (code && TLS_ERROR_CODES.has(code)) {
|
|
21358
|
+
return {
|
|
21359
|
+
code,
|
|
21360
|
+
kind: "tls",
|
|
21361
|
+
message: message ?? code,
|
|
21362
|
+
instructions: TLS_INSTRUCTIONS
|
|
21363
|
+
};
|
|
21364
|
+
}
|
|
21365
|
+
if (code && NETWORK_ERROR_CODES.has(code)) {
|
|
21366
|
+
return {
|
|
21367
|
+
code,
|
|
21368
|
+
kind: "network",
|
|
21369
|
+
message: message ?? code,
|
|
21370
|
+
instructions: NETWORK_INSTRUCTIONS
|
|
21371
|
+
};
|
|
21356
21372
|
}
|
|
21373
|
+
current = cur.cause;
|
|
21357
21374
|
}
|
|
21358
21375
|
return;
|
|
21359
21376
|
}
|
|
21377
|
+
function parseHttpStatusFromMessage(message) {
|
|
21378
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
21379
|
+
if (!match)
|
|
21380
|
+
return;
|
|
21381
|
+
const status = Number(match[1]);
|
|
21382
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
21383
|
+
}
|
|
21384
|
+
function isHtmlDocument(body) {
|
|
21385
|
+
return /^\s*(<!doctype html|<html\b)/i.test(body);
|
|
21386
|
+
}
|
|
21360
21387
|
function retryHintForRetryAfter(seconds) {
|
|
21361
21388
|
if (seconds <= 1) {
|
|
21362
21389
|
return "RetryAfter1Second";
|
|
@@ -21397,15 +21424,28 @@ function classifyError(status, error) {
|
|
|
21397
21424
|
if (status !== undefined && status >= 500 && status < 600) {
|
|
21398
21425
|
return { errorCode: "server_error", retry: "RetryLater" };
|
|
21399
21426
|
}
|
|
21400
|
-
|
|
21401
|
-
|
|
21427
|
+
const connectivity = describeConnectivityError(error);
|
|
21428
|
+
if (connectivity) {
|
|
21429
|
+
return {
|
|
21430
|
+
errorCode: "network_error",
|
|
21431
|
+
retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
|
|
21432
|
+
};
|
|
21402
21433
|
}
|
|
21403
21434
|
return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
|
|
21404
21435
|
}
|
|
21436
|
+
function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
|
|
21437
|
+
if (extractedMessage) {
|
|
21438
|
+
return `HTTP ${status}: ${extractedMessage}`;
|
|
21439
|
+
}
|
|
21440
|
+
return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
|
|
21441
|
+
}
|
|
21405
21442
|
async function extractErrorDetails(error, options) {
|
|
21406
21443
|
const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
|
|
21407
21444
|
const response = err.response;
|
|
21408
|
-
const
|
|
21445
|
+
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21446
|
+
const explicitStatus = err.status ?? response?.status;
|
|
21447
|
+
const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
|
|
21448
|
+
const status = explicitStatus ?? inferredStatus;
|
|
21409
21449
|
const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
|
|
21410
21450
|
let rawBody;
|
|
21411
21451
|
let extractedMessage;
|
|
@@ -21440,7 +21480,6 @@ async function extractErrorDetails(error, options) {
|
|
|
21440
21480
|
}
|
|
21441
21481
|
}
|
|
21442
21482
|
}
|
|
21443
|
-
const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
|
|
21444
21483
|
let message;
|
|
21445
21484
|
let result = "Failure";
|
|
21446
21485
|
const classification = classifyError(status, error);
|
|
@@ -21454,10 +21493,10 @@ async function extractErrorDetails(error, options) {
|
|
|
21454
21493
|
} else if (status === 405) {
|
|
21455
21494
|
message = DEFAULT_405;
|
|
21456
21495
|
} else if (status === 400 || status === 422) {
|
|
21457
|
-
message =
|
|
21496
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21458
21497
|
result = "ValidationError";
|
|
21459
21498
|
} else if (status === 429) {
|
|
21460
|
-
message =
|
|
21499
|
+
message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
|
|
21461
21500
|
} else if (extractedMessage) {
|
|
21462
21501
|
if (isSuccessfulResponse && rawMessage !== "Unknown error") {
|
|
21463
21502
|
message = rawMessage;
|
|
@@ -21465,7 +21504,9 @@ async function extractErrorDetails(error, options) {
|
|
|
21465
21504
|
message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
|
|
21466
21505
|
}
|
|
21467
21506
|
} else if (status) {
|
|
21468
|
-
if (
|
|
21507
|
+
if (inferredStatus !== undefined) {
|
|
21508
|
+
message = rawMessage;
|
|
21509
|
+
} else if (rawMessage === "Unknown error" && response) {
|
|
21469
21510
|
const statusText = response.statusText;
|
|
21470
21511
|
message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
|
|
21471
21512
|
} else {
|
|
@@ -21474,6 +21515,12 @@ async function extractErrorDetails(error, options) {
|
|
|
21474
21515
|
} else {
|
|
21475
21516
|
message = rawMessage;
|
|
21476
21517
|
}
|
|
21518
|
+
if (status === undefined) {
|
|
21519
|
+
const connectivity = describeConnectivityError(error);
|
|
21520
|
+
if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
|
|
21521
|
+
message = `${message}: ${connectivity.message}`;
|
|
21522
|
+
}
|
|
21523
|
+
}
|
|
21477
21524
|
let details = rawMessage;
|
|
21478
21525
|
if (rawBody) {
|
|
21479
21526
|
if (parsedBody) {
|
|
@@ -21625,6 +21672,7 @@ var CONSOLE_FALLBACK = {
|
|
|
21625
21672
|
writeLog: (str) => process.stdout.write(str),
|
|
21626
21673
|
capabilities: {
|
|
21627
21674
|
isInteractive: false,
|
|
21675
|
+
canReadInput: false,
|
|
21628
21676
|
supportsColor: false,
|
|
21629
21677
|
outputWidth: 80
|
|
21630
21678
|
}
|
|
@@ -26825,6 +26873,29 @@ function isPlainRecord(value) {
|
|
|
26825
26873
|
const prototype = Object.getPrototypeOf(value);
|
|
26826
26874
|
return prototype === Object.prototype || prototype === null;
|
|
26827
26875
|
}
|
|
26876
|
+
function extractPagedRows(value) {
|
|
26877
|
+
if (Array.isArray(value) || !isPlainRecord(value))
|
|
26878
|
+
return null;
|
|
26879
|
+
const entries = Object.values(value);
|
|
26880
|
+
if (entries.length === 0)
|
|
26881
|
+
return null;
|
|
26882
|
+
let rows = null;
|
|
26883
|
+
let hasScalarSibling = false;
|
|
26884
|
+
for (const entry of entries) {
|
|
26885
|
+
if (Array.isArray(entry)) {
|
|
26886
|
+
if (rows !== null)
|
|
26887
|
+
return null;
|
|
26888
|
+
rows = entry;
|
|
26889
|
+
} else if (entry !== null && typeof entry === "object") {
|
|
26890
|
+
return null;
|
|
26891
|
+
} else {
|
|
26892
|
+
hasScalarSibling = true;
|
|
26893
|
+
}
|
|
26894
|
+
}
|
|
26895
|
+
if (rows === null || !hasScalarSibling)
|
|
26896
|
+
return null;
|
|
26897
|
+
return rows;
|
|
26898
|
+
}
|
|
26828
26899
|
function toLowerCamelCaseKey(key) {
|
|
26829
26900
|
if (!key)
|
|
26830
26901
|
return key;
|
|
@@ -26889,7 +26960,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
26889
26960
|
break;
|
|
26890
26961
|
case "plain": {
|
|
26891
26962
|
if ("Data" in data && data.Data != null) {
|
|
26892
|
-
const
|
|
26963
|
+
const pagedRows = extractPagedRows(data.Data);
|
|
26964
|
+
const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
|
|
26893
26965
|
items.forEach((item) => {
|
|
26894
26966
|
const values = Object.values(item).map((v) => v ?? "").join("\t");
|
|
26895
26967
|
logFn(values);
|
|
@@ -26901,10 +26973,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
|
|
|
26901
26973
|
break;
|
|
26902
26974
|
}
|
|
26903
26975
|
default: {
|
|
26904
|
-
|
|
26976
|
+
const hasData = "Data" in data && data.Data != null;
|
|
26977
|
+
const pagedRows = hasData ? extractPagedRows(data.Data) : null;
|
|
26978
|
+
const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
|
|
26979
|
+
if (hasData && !(rows !== null && rows.length === 0)) {
|
|
26905
26980
|
const logValue = data.Log;
|
|
26906
|
-
if (
|
|
26907
|
-
printResizableTable(
|
|
26981
|
+
if (rows !== null) {
|
|
26982
|
+
printResizableTable(rows, logFn, logValue);
|
|
26908
26983
|
} else {
|
|
26909
26984
|
printVerticalTable(data.Data, logFn, logValue);
|
|
26910
26985
|
}
|
|
@@ -27092,6 +27167,44 @@ function defaultErrorCodeForResult(result) {
|
|
|
27092
27167
|
return "unknown_error";
|
|
27093
27168
|
}
|
|
27094
27169
|
}
|
|
27170
|
+
function parseHttpStatusFromMessage2(message) {
|
|
27171
|
+
const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
|
|
27172
|
+
if (!match)
|
|
27173
|
+
return;
|
|
27174
|
+
const status = Number(match[1]);
|
|
27175
|
+
return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
|
|
27176
|
+
}
|
|
27177
|
+
function defaultErrorCodeForHttpStatus(status) {
|
|
27178
|
+
if (status === undefined)
|
|
27179
|
+
return;
|
|
27180
|
+
if (status === 400 || status === 409 || status === 422) {
|
|
27181
|
+
return "invalid_argument";
|
|
27182
|
+
}
|
|
27183
|
+
if (status === 401)
|
|
27184
|
+
return "authentication_required";
|
|
27185
|
+
if (status === 403)
|
|
27186
|
+
return "permission_denied";
|
|
27187
|
+
if (status === 404)
|
|
27188
|
+
return "not_found";
|
|
27189
|
+
if (status === 405)
|
|
27190
|
+
return "method_not_allowed";
|
|
27191
|
+
if (status === 408)
|
|
27192
|
+
return "timeout";
|
|
27193
|
+
if (status === 429)
|
|
27194
|
+
return "rate_limited";
|
|
27195
|
+
if (status >= 500 && status < 600)
|
|
27196
|
+
return "server_error";
|
|
27197
|
+
return;
|
|
27198
|
+
}
|
|
27199
|
+
function defaultErrorCodeForFailure(data) {
|
|
27200
|
+
if (data.Result === RESULTS.Failure) {
|
|
27201
|
+
const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
|
|
27202
|
+
const errorCode = defaultErrorCodeForHttpStatus(status);
|
|
27203
|
+
if (errorCode)
|
|
27204
|
+
return errorCode;
|
|
27205
|
+
}
|
|
27206
|
+
return defaultErrorCodeForResult(data.Result);
|
|
27207
|
+
}
|
|
27095
27208
|
function defaultRetryForErrorCode(errorCode) {
|
|
27096
27209
|
switch (errorCode) {
|
|
27097
27210
|
case "network_error":
|
|
@@ -27121,16 +27234,19 @@ var OutputFormatter;
|
|
|
27121
27234
|
OutputFormatter.success = success;
|
|
27122
27235
|
function error(data) {
|
|
27123
27236
|
data.Log ??= getLogFilePath() || undefined;
|
|
27124
|
-
data.ErrorCode ??=
|
|
27237
|
+
data.ErrorCode ??= defaultErrorCodeForFailure(data);
|
|
27125
27238
|
data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
|
|
27126
27239
|
process.exitCode = EXIT_CODES[data.Result] ?? 1;
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27240
|
+
const { SuppressTelemetry, ...envelope } = data;
|
|
27241
|
+
if (!SuppressTelemetry) {
|
|
27242
|
+
telemetry.trackEvent(CommonTelemetryEvents.Error, {
|
|
27243
|
+
result: data.Result,
|
|
27244
|
+
errorCode: data.ErrorCode,
|
|
27245
|
+
retry: data.Retry,
|
|
27246
|
+
message: data.Message
|
|
27247
|
+
});
|
|
27248
|
+
}
|
|
27249
|
+
logOutput(normalizeOutputKeys(envelope), getOutputFormat());
|
|
27134
27250
|
}
|
|
27135
27251
|
OutputFormatter.error = error;
|
|
27136
27252
|
function emitList(code, items, opts) {
|
|
@@ -27421,1661 +27537,244 @@ var DEFAULT_PAGE_SIZE = 50;
|
|
|
27421
27537
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
27422
27538
|
// ../../common/src/interactivity-context.ts
|
|
27423
27539
|
var modeSlot = singleton("InteractivityMode");
|
|
27424
|
-
//
|
|
27425
|
-
|
|
27426
|
-
|
|
27427
|
-
|
|
27428
|
-
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27540
|
+
// ../../common/src/option-aliases.ts
|
|
27541
|
+
function resolveDeprecatedOptionAlias({
|
|
27542
|
+
preferredValue,
|
|
27543
|
+
deprecatedValue,
|
|
27544
|
+
preferredFlag,
|
|
27545
|
+
deprecatedFlag
|
|
27546
|
+
}) {
|
|
27547
|
+
const hasPreferred = preferredValue !== undefined;
|
|
27548
|
+
const hasDeprecated = deprecatedValue !== undefined;
|
|
27549
|
+
if (hasPreferred && hasDeprecated) {
|
|
27550
|
+
return {
|
|
27551
|
+
value: undefined,
|
|
27552
|
+
usedDeprecated: true,
|
|
27553
|
+
error: {
|
|
27554
|
+
message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
|
|
27555
|
+
instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
|
|
27432
27556
|
}
|
|
27433
|
-
}
|
|
27434
|
-
(Array.isArray(name) ? name : [name]).forEach(function(name2) {
|
|
27435
|
-
this[name2] = this[name2] || [];
|
|
27436
|
-
if (callback) {
|
|
27437
|
-
this[name2][first ? "unshift" : "push"](callback);
|
|
27438
|
-
}
|
|
27439
|
-
}, this);
|
|
27440
|
-
}
|
|
27441
|
-
}
|
|
27442
|
-
run(name, env) {
|
|
27443
|
-
this[name] = this[name] || [];
|
|
27444
|
-
this[name].forEach(function(callback) {
|
|
27445
|
-
callback.call(env && env.context ? env.context : env, env);
|
|
27446
|
-
});
|
|
27557
|
+
};
|
|
27447
27558
|
}
|
|
27559
|
+
return {
|
|
27560
|
+
value: hasPreferred ? preferredValue : deprecatedValue,
|
|
27561
|
+
usedDeprecated: hasDeprecated
|
|
27562
|
+
};
|
|
27448
27563
|
}
|
|
27449
|
-
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
|
|
27454
|
-
|
|
27455
|
-
|
|
27456
|
-
|
|
27457
|
-
|
|
27458
|
-
|
|
27459
|
-
|
|
27460
|
-
|
|
27461
|
-
|
|
27462
|
-
|
|
27463
|
-
|
|
27464
|
-
this.registered[plugin.name] = plugin;
|
|
27465
|
-
});
|
|
27466
|
-
}
|
|
27564
|
+
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
27565
|
+
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
27566
|
+
`);
|
|
27567
|
+
}
|
|
27568
|
+
var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
|
|
27569
|
+
function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
|
|
27570
|
+
return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
|
|
27571
|
+
warnDeprecatedTenantOption(tenant);
|
|
27572
|
+
return tenant;
|
|
27573
|
+
});
|
|
27574
|
+
}
|
|
27575
|
+
function warnDeprecatedTenantOption(tenant) {
|
|
27576
|
+
if (tenant === undefined)
|
|
27577
|
+
return;
|
|
27578
|
+
warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
|
|
27467
27579
|
}
|
|
27580
|
+
// ../../common/src/polling/types.ts
|
|
27581
|
+
var PollOutcome = {
|
|
27582
|
+
Completed: "completed",
|
|
27583
|
+
Timeout: "timeout",
|
|
27584
|
+
Interrupted: "interrupted",
|
|
27585
|
+
Aborted: "aborted",
|
|
27586
|
+
Failed: "failed"
|
|
27587
|
+
};
|
|
27468
27588
|
|
|
27469
|
-
|
|
27470
|
-
|
|
27471
|
-
|
|
27472
|
-
|
|
27473
|
-
|
|
27474
|
-
|
|
27589
|
+
// ../../common/src/polling/poll-failure-mapping.ts
|
|
27590
|
+
var REASON_BY_OUTCOME = {
|
|
27591
|
+
[PollOutcome.Timeout]: "poll_timeout",
|
|
27592
|
+
[PollOutcome.Failed]: "poll_failed",
|
|
27593
|
+
[PollOutcome.Interrupted]: "poll_failed",
|
|
27594
|
+
[PollOutcome.Aborted]: "poll_aborted"
|
|
27595
|
+
};
|
|
27596
|
+
// ../../common/src/polling/terminal-statuses.ts
|
|
27597
|
+
var TERMINAL_STATUSES = new Set([
|
|
27598
|
+
"completed",
|
|
27599
|
+
"successful",
|
|
27600
|
+
"faulted",
|
|
27601
|
+
"failed",
|
|
27602
|
+
"cancelled",
|
|
27603
|
+
"canceled",
|
|
27604
|
+
"stopped",
|
|
27605
|
+
"finished"
|
|
27606
|
+
]);
|
|
27607
|
+
var FAILURE_STATUSES = new Set([
|
|
27608
|
+
"faulted",
|
|
27609
|
+
"failed",
|
|
27610
|
+
"cancelled",
|
|
27611
|
+
"canceled",
|
|
27612
|
+
"stopped"
|
|
27613
|
+
]);
|
|
27614
|
+
// ../../common/src/preview.ts
|
|
27615
|
+
var previewSlot = singleton("PreviewBuild");
|
|
27616
|
+
function isPreviewBuild() {
|
|
27617
|
+
return previewSlot.get(false) ?? false;
|
|
27618
|
+
}
|
|
27619
|
+
Command.prototype.previewCommand = function(nameAndArgs, opts) {
|
|
27620
|
+
if (isPreviewBuild()) {
|
|
27621
|
+
return this.command(nameAndArgs, opts);
|
|
27475
27622
|
}
|
|
27476
|
-
|
|
27477
|
-
|
|
27478
|
-
|
|
27479
|
-
|
|
27623
|
+
return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
|
|
27624
|
+
};
|
|
27625
|
+
// ../../common/src/screen-logger.ts
|
|
27626
|
+
var ScreenLogger;
|
|
27627
|
+
((ScreenLogger) => {
|
|
27628
|
+
function progress(message) {
|
|
27629
|
+
getOutputSink().writeErr(`${message}
|
|
27630
|
+
`);
|
|
27480
27631
|
}
|
|
27481
|
-
|
|
27482
|
-
|
|
27483
|
-
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
|
|
27487
|
-
|
|
27632
|
+
ScreenLogger.progress = progress;
|
|
27633
|
+
})(ScreenLogger ||= {});
|
|
27634
|
+
// ../../common/src/sdk-user-agent.ts
|
|
27635
|
+
var USER_AGENT_HEADER = "User-Agent";
|
|
27636
|
+
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
27637
|
+
function userAgentPatchKey(userAgent) {
|
|
27638
|
+
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
27639
|
+
}
|
|
27640
|
+
function splitUserAgentTokens(value) {
|
|
27641
|
+
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
27642
|
+
}
|
|
27643
|
+
function appendUserAgentToken(value, userAgent) {
|
|
27644
|
+
const tokens = splitUserAgentTokens(value);
|
|
27645
|
+
const seen = new Set(tokens);
|
|
27646
|
+
for (const token of splitUserAgentTokens(userAgent)) {
|
|
27647
|
+
if (!seen.has(token)) {
|
|
27648
|
+
tokens.push(token);
|
|
27649
|
+
seen.add(token);
|
|
27488
27650
|
}
|
|
27489
|
-
return Jsep;
|
|
27490
|
-
}
|
|
27491
|
-
static addIdentifierChar(char) {
|
|
27492
|
-
Jsep.additional_identifier_chars.add(char);
|
|
27493
|
-
return Jsep;
|
|
27494
27651
|
}
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
|
|
27652
|
+
return tokens.join(" ");
|
|
27653
|
+
}
|
|
27654
|
+
function getEffectiveUserAgent(userAgent) {
|
|
27655
|
+
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
27656
|
+
}
|
|
27657
|
+
function getHeaderName(headers, headerName) {
|
|
27658
|
+
return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
|
|
27659
|
+
}
|
|
27660
|
+
function getSdkUserAgentToken(pkg) {
|
|
27661
|
+
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
27662
|
+
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
27663
|
+
}
|
|
27664
|
+
function addSdkUserAgentHeader(headers, userAgent) {
|
|
27665
|
+
const result = { ...headers ?? {} };
|
|
27666
|
+
const headerName = getHeaderName(result, USER_AGENT_HEADER);
|
|
27667
|
+
result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
|
|
27668
|
+
return result;
|
|
27669
|
+
}
|
|
27670
|
+
function asHeaderRecord(headers) {
|
|
27671
|
+
return typeof headers === "object" && headers !== null ? { ...headers } : {};
|
|
27672
|
+
}
|
|
27673
|
+
function withForwardedHeadersInitOverride(initOverrides, forward) {
|
|
27674
|
+
return async (requestContext) => {
|
|
27675
|
+
const initWithHeaders = {
|
|
27676
|
+
...requestContext.init,
|
|
27677
|
+
headers: forward(asHeaderRecord(requestContext.init.headers))
|
|
27678
|
+
};
|
|
27679
|
+
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
27680
|
+
...requestContext,
|
|
27681
|
+
init: initWithHeaders
|
|
27682
|
+
}) : initOverrides;
|
|
27683
|
+
return {
|
|
27684
|
+
...override ?? {},
|
|
27685
|
+
headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
|
|
27686
|
+
};
|
|
27687
|
+
};
|
|
27688
|
+
}
|
|
27689
|
+
function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
|
|
27690
|
+
const prototype = BaseApiClass.prototype;
|
|
27691
|
+
if (prototype[patchKey]) {
|
|
27692
|
+
return;
|
|
27498
27693
|
}
|
|
27499
|
-
|
|
27500
|
-
|
|
27501
|
-
if (op_name.length === Jsep.max_unop_len) {
|
|
27502
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
27503
|
-
}
|
|
27504
|
-
return Jsep;
|
|
27694
|
+
if (typeof prototype.request !== "function") {
|
|
27695
|
+
throw new Error("Generated BaseAPI request function not found.");
|
|
27505
27696
|
}
|
|
27506
|
-
|
|
27507
|
-
|
|
27508
|
-
|
|
27509
|
-
|
|
27697
|
+
const originalRequest = prototype.request;
|
|
27698
|
+
prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
|
|
27699
|
+
return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
|
|
27700
|
+
};
|
|
27701
|
+
Object.defineProperty(prototype, patchKey, {
|
|
27702
|
+
value: true
|
|
27703
|
+
});
|
|
27704
|
+
}
|
|
27705
|
+
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
27706
|
+
installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
|
|
27707
|
+
}
|
|
27708
|
+
// ../../common/src/tool-provider.ts
|
|
27709
|
+
var factorySlot = singleton("PackagerFactoryProvider");
|
|
27710
|
+
// ../resourcecatalog-sdk/generated/src/runtime.ts
|
|
27711
|
+
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
27712
|
+
|
|
27713
|
+
class Configuration {
|
|
27714
|
+
configuration;
|
|
27715
|
+
constructor(configuration = {}) {
|
|
27716
|
+
this.configuration = configuration;
|
|
27510
27717
|
}
|
|
27511
|
-
|
|
27512
|
-
|
|
27513
|
-
return Jsep;
|
|
27718
|
+
set config(configuration) {
|
|
27719
|
+
this.configuration = configuration;
|
|
27514
27720
|
}
|
|
27515
|
-
|
|
27516
|
-
|
|
27517
|
-
if (op_name.length === Jsep.max_binop_len) {
|
|
27518
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
27519
|
-
}
|
|
27520
|
-
Jsep.right_associative.delete(op_name);
|
|
27521
|
-
return Jsep;
|
|
27721
|
+
get basePath() {
|
|
27722
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
27522
27723
|
}
|
|
27523
|
-
|
|
27524
|
-
|
|
27525
|
-
Jsep.max_binop_len = 0;
|
|
27526
|
-
return Jsep;
|
|
27724
|
+
get fetchApi() {
|
|
27725
|
+
return this.configuration.fetchApi;
|
|
27527
27726
|
}
|
|
27528
|
-
|
|
27529
|
-
|
|
27530
|
-
return Jsep;
|
|
27727
|
+
get middleware() {
|
|
27728
|
+
return this.configuration.middleware || [];
|
|
27531
27729
|
}
|
|
27532
|
-
|
|
27533
|
-
|
|
27534
|
-
return Jsep;
|
|
27730
|
+
get queryParamsStringify() {
|
|
27731
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
27535
27732
|
}
|
|
27536
|
-
get
|
|
27537
|
-
return this.
|
|
27733
|
+
get username() {
|
|
27734
|
+
return this.configuration.username;
|
|
27538
27735
|
}
|
|
27539
|
-
get
|
|
27540
|
-
return this.
|
|
27736
|
+
get password() {
|
|
27737
|
+
return this.configuration.password;
|
|
27541
27738
|
}
|
|
27542
|
-
|
|
27543
|
-
|
|
27544
|
-
|
|
27739
|
+
get apiKey() {
|
|
27740
|
+
const apiKey = this.configuration.apiKey;
|
|
27741
|
+
if (apiKey) {
|
|
27742
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
27743
|
+
}
|
|
27744
|
+
return;
|
|
27545
27745
|
}
|
|
27546
|
-
|
|
27547
|
-
|
|
27746
|
+
get accessToken() {
|
|
27747
|
+
const accessToken = this.configuration.accessToken;
|
|
27748
|
+
if (accessToken) {
|
|
27749
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
27750
|
+
}
|
|
27751
|
+
return;
|
|
27548
27752
|
}
|
|
27549
|
-
|
|
27550
|
-
return
|
|
27753
|
+
get headers() {
|
|
27754
|
+
return this.configuration.headers;
|
|
27551
27755
|
}
|
|
27552
|
-
|
|
27553
|
-
return
|
|
27756
|
+
get credentials() {
|
|
27757
|
+
return this.configuration.credentials;
|
|
27554
27758
|
}
|
|
27555
|
-
|
|
27556
|
-
|
|
27759
|
+
}
|
|
27760
|
+
var DefaultConfig = new Configuration;
|
|
27761
|
+
|
|
27762
|
+
class BaseAPI {
|
|
27763
|
+
configuration;
|
|
27764
|
+
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
27765
|
+
middleware;
|
|
27766
|
+
constructor(configuration = DefaultConfig) {
|
|
27767
|
+
this.configuration = configuration;
|
|
27768
|
+
this.middleware = configuration.middleware;
|
|
27557
27769
|
}
|
|
27558
|
-
|
|
27559
|
-
|
|
27770
|
+
withMiddleware(...middlewares) {
|
|
27771
|
+
const next = this.clone();
|
|
27772
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
27773
|
+
return next;
|
|
27560
27774
|
}
|
|
27561
|
-
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
throwError(message) {
|
|
27565
|
-
const error = new Error(message + " at character " + this.index);
|
|
27566
|
-
error.index = this.index;
|
|
27567
|
-
error.description = message;
|
|
27568
|
-
throw error;
|
|
27569
|
-
}
|
|
27570
|
-
runHook(name, node) {
|
|
27571
|
-
if (Jsep.hooks[name]) {
|
|
27572
|
-
const env = {
|
|
27573
|
-
context: this,
|
|
27574
|
-
node
|
|
27575
|
-
};
|
|
27576
|
-
Jsep.hooks.run(name, env);
|
|
27577
|
-
return env.node;
|
|
27578
|
-
}
|
|
27579
|
-
return node;
|
|
27580
|
-
}
|
|
27581
|
-
searchHook(name) {
|
|
27582
|
-
if (Jsep.hooks[name]) {
|
|
27583
|
-
const env = {
|
|
27584
|
-
context: this
|
|
27585
|
-
};
|
|
27586
|
-
Jsep.hooks[name].find(function(callback) {
|
|
27587
|
-
callback.call(env.context, env);
|
|
27588
|
-
return env.node;
|
|
27589
|
-
});
|
|
27590
|
-
return env.node;
|
|
27591
|
-
}
|
|
27592
|
-
}
|
|
27593
|
-
gobbleSpaces() {
|
|
27594
|
-
let ch = this.code;
|
|
27595
|
-
while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
|
|
27596
|
-
ch = this.expr.charCodeAt(++this.index);
|
|
27597
|
-
}
|
|
27598
|
-
this.runHook("gobble-spaces");
|
|
27599
|
-
}
|
|
27600
|
-
parse() {
|
|
27601
|
-
this.runHook("before-all");
|
|
27602
|
-
const nodes = this.gobbleExpressions();
|
|
27603
|
-
const node = nodes.length === 1 ? nodes[0] : {
|
|
27604
|
-
type: Jsep.COMPOUND,
|
|
27605
|
-
body: nodes
|
|
27606
|
-
};
|
|
27607
|
-
return this.runHook("after-all", node);
|
|
27608
|
-
}
|
|
27609
|
-
gobbleExpressions(untilICode) {
|
|
27610
|
-
let nodes = [], ch_i, node;
|
|
27611
|
-
while (this.index < this.expr.length) {
|
|
27612
|
-
ch_i = this.code;
|
|
27613
|
-
if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
|
|
27614
|
-
this.index++;
|
|
27615
|
-
} else {
|
|
27616
|
-
if (node = this.gobbleExpression()) {
|
|
27617
|
-
nodes.push(node);
|
|
27618
|
-
} else if (this.index < this.expr.length) {
|
|
27619
|
-
if (ch_i === untilICode) {
|
|
27620
|
-
break;
|
|
27621
|
-
}
|
|
27622
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
27623
|
-
}
|
|
27624
|
-
}
|
|
27625
|
-
}
|
|
27626
|
-
return nodes;
|
|
27627
|
-
}
|
|
27628
|
-
gobbleExpression() {
|
|
27629
|
-
const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
27630
|
-
this.gobbleSpaces();
|
|
27631
|
-
return this.runHook("after-expression", node);
|
|
27632
|
-
}
|
|
27633
|
-
gobbleBinaryOp() {
|
|
27634
|
-
this.gobbleSpaces();
|
|
27635
|
-
let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
|
|
27636
|
-
let tc_len = to_check.length;
|
|
27637
|
-
while (tc_len > 0) {
|
|
27638
|
-
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)))) {
|
|
27639
|
-
this.index += tc_len;
|
|
27640
|
-
return to_check;
|
|
27641
|
-
}
|
|
27642
|
-
to_check = to_check.substr(0, --tc_len);
|
|
27643
|
-
}
|
|
27644
|
-
return false;
|
|
27645
|
-
}
|
|
27646
|
-
gobbleBinaryExpression() {
|
|
27647
|
-
let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
|
|
27648
|
-
left = this.gobbleToken();
|
|
27649
|
-
if (!left) {
|
|
27650
|
-
return left;
|
|
27651
|
-
}
|
|
27652
|
-
biop = this.gobbleBinaryOp();
|
|
27653
|
-
if (!biop) {
|
|
27654
|
-
return left;
|
|
27655
|
-
}
|
|
27656
|
-
biop_info = {
|
|
27657
|
-
value: biop,
|
|
27658
|
-
prec: Jsep.binaryPrecedence(biop),
|
|
27659
|
-
right_a: Jsep.right_associative.has(biop)
|
|
27660
|
-
};
|
|
27661
|
-
right = this.gobbleToken();
|
|
27662
|
-
if (!right) {
|
|
27663
|
-
this.throwError("Expected expression after " + biop);
|
|
27664
|
-
}
|
|
27665
|
-
stack = [left, biop_info, right];
|
|
27666
|
-
while (biop = this.gobbleBinaryOp()) {
|
|
27667
|
-
prec = Jsep.binaryPrecedence(biop);
|
|
27668
|
-
if (prec === 0) {
|
|
27669
|
-
this.index -= biop.length;
|
|
27670
|
-
break;
|
|
27671
|
-
}
|
|
27672
|
-
biop_info = {
|
|
27673
|
-
value: biop,
|
|
27674
|
-
prec,
|
|
27675
|
-
right_a: Jsep.right_associative.has(biop)
|
|
27676
|
-
};
|
|
27677
|
-
cur_biop = biop;
|
|
27678
|
-
const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
|
|
27679
|
-
while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
|
|
27680
|
-
right = stack.pop();
|
|
27681
|
-
biop = stack.pop().value;
|
|
27682
|
-
left = stack.pop();
|
|
27683
|
-
node = {
|
|
27684
|
-
type: Jsep.BINARY_EXP,
|
|
27685
|
-
operator: biop,
|
|
27686
|
-
left,
|
|
27687
|
-
right
|
|
27688
|
-
};
|
|
27689
|
-
stack.push(node);
|
|
27690
|
-
}
|
|
27691
|
-
node = this.gobbleToken();
|
|
27692
|
-
if (!node) {
|
|
27693
|
-
this.throwError("Expected expression after " + cur_biop);
|
|
27694
|
-
}
|
|
27695
|
-
stack.push(biop_info, node);
|
|
27696
|
-
}
|
|
27697
|
-
i = stack.length - 1;
|
|
27698
|
-
node = stack[i];
|
|
27699
|
-
while (i > 1) {
|
|
27700
|
-
node = {
|
|
27701
|
-
type: Jsep.BINARY_EXP,
|
|
27702
|
-
operator: stack[i - 1].value,
|
|
27703
|
-
left: stack[i - 2],
|
|
27704
|
-
right: node
|
|
27705
|
-
};
|
|
27706
|
-
i -= 2;
|
|
27707
|
-
}
|
|
27708
|
-
return node;
|
|
27709
|
-
}
|
|
27710
|
-
gobbleToken() {
|
|
27711
|
-
let ch, to_check, tc_len, node;
|
|
27712
|
-
this.gobbleSpaces();
|
|
27713
|
-
node = this.searchHook("gobble-token");
|
|
27714
|
-
if (node) {
|
|
27715
|
-
return this.runHook("after-token", node);
|
|
27716
|
-
}
|
|
27717
|
-
ch = this.code;
|
|
27718
|
-
if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
|
|
27719
|
-
return this.gobbleNumericLiteral();
|
|
27720
|
-
}
|
|
27721
|
-
if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
|
|
27722
|
-
node = this.gobbleStringLiteral();
|
|
27723
|
-
} else if (ch === Jsep.OBRACK_CODE) {
|
|
27724
|
-
node = this.gobbleArray();
|
|
27725
|
-
} else {
|
|
27726
|
-
to_check = this.expr.substr(this.index, Jsep.max_unop_len);
|
|
27727
|
-
tc_len = to_check.length;
|
|
27728
|
-
while (tc_len > 0) {
|
|
27729
|
-
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)))) {
|
|
27730
|
-
this.index += tc_len;
|
|
27731
|
-
const argument = this.gobbleToken();
|
|
27732
|
-
if (!argument) {
|
|
27733
|
-
this.throwError("missing unaryOp argument");
|
|
27734
|
-
}
|
|
27735
|
-
return this.runHook("after-token", {
|
|
27736
|
-
type: Jsep.UNARY_EXP,
|
|
27737
|
-
operator: to_check,
|
|
27738
|
-
argument,
|
|
27739
|
-
prefix: true
|
|
27740
|
-
});
|
|
27741
|
-
}
|
|
27742
|
-
to_check = to_check.substr(0, --tc_len);
|
|
27743
|
-
}
|
|
27744
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
27745
|
-
node = this.gobbleIdentifier();
|
|
27746
|
-
if (Jsep.literals.hasOwnProperty(node.name)) {
|
|
27747
|
-
node = {
|
|
27748
|
-
type: Jsep.LITERAL,
|
|
27749
|
-
value: Jsep.literals[node.name],
|
|
27750
|
-
raw: node.name
|
|
27751
|
-
};
|
|
27752
|
-
} else if (node.name === Jsep.this_str) {
|
|
27753
|
-
node = {
|
|
27754
|
-
type: Jsep.THIS_EXP
|
|
27755
|
-
};
|
|
27756
|
-
}
|
|
27757
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
27758
|
-
node = this.gobbleGroup();
|
|
27759
|
-
}
|
|
27760
|
-
}
|
|
27761
|
-
if (!node) {
|
|
27762
|
-
return this.runHook("after-token", false);
|
|
27763
|
-
}
|
|
27764
|
-
node = this.gobbleTokenProperty(node);
|
|
27765
|
-
return this.runHook("after-token", node);
|
|
27766
|
-
}
|
|
27767
|
-
gobbleTokenProperty(node) {
|
|
27768
|
-
this.gobbleSpaces();
|
|
27769
|
-
let ch = this.code;
|
|
27770
|
-
while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
|
|
27771
|
-
let optional;
|
|
27772
|
-
if (ch === Jsep.QUMARK_CODE) {
|
|
27773
|
-
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
|
|
27774
|
-
break;
|
|
27775
|
-
}
|
|
27776
|
-
optional = true;
|
|
27777
|
-
this.index += 2;
|
|
27778
|
-
this.gobbleSpaces();
|
|
27779
|
-
ch = this.code;
|
|
27780
|
-
}
|
|
27781
|
-
this.index++;
|
|
27782
|
-
if (ch === Jsep.OBRACK_CODE) {
|
|
27783
|
-
node = {
|
|
27784
|
-
type: Jsep.MEMBER_EXP,
|
|
27785
|
-
computed: true,
|
|
27786
|
-
object: node,
|
|
27787
|
-
property: this.gobbleExpression()
|
|
27788
|
-
};
|
|
27789
|
-
if (!node.property) {
|
|
27790
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
27791
|
-
}
|
|
27792
|
-
this.gobbleSpaces();
|
|
27793
|
-
ch = this.code;
|
|
27794
|
-
if (ch !== Jsep.CBRACK_CODE) {
|
|
27795
|
-
this.throwError("Unclosed [");
|
|
27796
|
-
}
|
|
27797
|
-
this.index++;
|
|
27798
|
-
} else if (ch === Jsep.OPAREN_CODE) {
|
|
27799
|
-
node = {
|
|
27800
|
-
type: Jsep.CALL_EXP,
|
|
27801
|
-
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
27802
|
-
callee: node
|
|
27803
|
-
};
|
|
27804
|
-
} else if (ch === Jsep.PERIOD_CODE || optional) {
|
|
27805
|
-
if (optional) {
|
|
27806
|
-
this.index--;
|
|
27807
|
-
}
|
|
27808
|
-
this.gobbleSpaces();
|
|
27809
|
-
node = {
|
|
27810
|
-
type: Jsep.MEMBER_EXP,
|
|
27811
|
-
computed: false,
|
|
27812
|
-
object: node,
|
|
27813
|
-
property: this.gobbleIdentifier()
|
|
27814
|
-
};
|
|
27815
|
-
}
|
|
27816
|
-
if (optional) {
|
|
27817
|
-
node.optional = true;
|
|
27818
|
-
}
|
|
27819
|
-
this.gobbleSpaces();
|
|
27820
|
-
ch = this.code;
|
|
27821
|
-
}
|
|
27822
|
-
return node;
|
|
27823
|
-
}
|
|
27824
|
-
gobbleNumericLiteral() {
|
|
27825
|
-
let number = "", ch, chCode;
|
|
27826
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
27827
|
-
number += this.expr.charAt(this.index++);
|
|
27828
|
-
}
|
|
27829
|
-
if (this.code === Jsep.PERIOD_CODE) {
|
|
27830
|
-
number += this.expr.charAt(this.index++);
|
|
27831
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
27832
|
-
number += this.expr.charAt(this.index++);
|
|
27833
|
-
}
|
|
27834
|
-
}
|
|
27835
|
-
ch = this.char;
|
|
27836
|
-
if (ch === "e" || ch === "E") {
|
|
27837
|
-
number += this.expr.charAt(this.index++);
|
|
27838
|
-
ch = this.char;
|
|
27839
|
-
if (ch === "+" || ch === "-") {
|
|
27840
|
-
number += this.expr.charAt(this.index++);
|
|
27841
|
-
}
|
|
27842
|
-
while (Jsep.isDecimalDigit(this.code)) {
|
|
27843
|
-
number += this.expr.charAt(this.index++);
|
|
27844
|
-
}
|
|
27845
|
-
if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
|
|
27846
|
-
this.throwError("Expected exponent (" + number + this.char + ")");
|
|
27847
|
-
}
|
|
27848
|
-
}
|
|
27849
|
-
chCode = this.code;
|
|
27850
|
-
if (Jsep.isIdentifierStart(chCode)) {
|
|
27851
|
-
this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
|
|
27852
|
-
} else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
|
|
27853
|
-
this.throwError("Unexpected period");
|
|
27854
|
-
}
|
|
27855
|
-
return {
|
|
27856
|
-
type: Jsep.LITERAL,
|
|
27857
|
-
value: parseFloat(number),
|
|
27858
|
-
raw: number
|
|
27859
|
-
};
|
|
27860
|
-
}
|
|
27861
|
-
gobbleStringLiteral() {
|
|
27862
|
-
let str = "";
|
|
27863
|
-
const startIndex = this.index;
|
|
27864
|
-
const quote = this.expr.charAt(this.index++);
|
|
27865
|
-
let closed = false;
|
|
27866
|
-
while (this.index < this.expr.length) {
|
|
27867
|
-
let ch = this.expr.charAt(this.index++);
|
|
27868
|
-
if (ch === quote) {
|
|
27869
|
-
closed = true;
|
|
27870
|
-
break;
|
|
27871
|
-
} else if (ch === "\\") {
|
|
27872
|
-
ch = this.expr.charAt(this.index++);
|
|
27873
|
-
switch (ch) {
|
|
27874
|
-
case "n":
|
|
27875
|
-
str += `
|
|
27876
|
-
`;
|
|
27877
|
-
break;
|
|
27878
|
-
case "r":
|
|
27879
|
-
str += "\r";
|
|
27880
|
-
break;
|
|
27881
|
-
case "t":
|
|
27882
|
-
str += "\t";
|
|
27883
|
-
break;
|
|
27884
|
-
case "b":
|
|
27885
|
-
str += "\b";
|
|
27886
|
-
break;
|
|
27887
|
-
case "f":
|
|
27888
|
-
str += "\f";
|
|
27889
|
-
break;
|
|
27890
|
-
case "v":
|
|
27891
|
-
str += "\v";
|
|
27892
|
-
break;
|
|
27893
|
-
default:
|
|
27894
|
-
str += ch;
|
|
27895
|
-
}
|
|
27896
|
-
} else {
|
|
27897
|
-
str += ch;
|
|
27898
|
-
}
|
|
27899
|
-
}
|
|
27900
|
-
if (!closed) {
|
|
27901
|
-
this.throwError('Unclosed quote after "' + str + '"');
|
|
27902
|
-
}
|
|
27903
|
-
return {
|
|
27904
|
-
type: Jsep.LITERAL,
|
|
27905
|
-
value: str,
|
|
27906
|
-
raw: this.expr.substring(startIndex, this.index)
|
|
27907
|
-
};
|
|
27908
|
-
}
|
|
27909
|
-
gobbleIdentifier() {
|
|
27910
|
-
let ch = this.code, start = this.index;
|
|
27911
|
-
if (Jsep.isIdentifierStart(ch)) {
|
|
27912
|
-
this.index++;
|
|
27913
|
-
} else {
|
|
27914
|
-
this.throwError("Unexpected " + this.char);
|
|
27915
|
-
}
|
|
27916
|
-
while (this.index < this.expr.length) {
|
|
27917
|
-
ch = this.code;
|
|
27918
|
-
if (Jsep.isIdentifierPart(ch)) {
|
|
27919
|
-
this.index++;
|
|
27920
|
-
} else {
|
|
27921
|
-
break;
|
|
27922
|
-
}
|
|
27923
|
-
}
|
|
27924
|
-
return {
|
|
27925
|
-
type: Jsep.IDENTIFIER,
|
|
27926
|
-
name: this.expr.slice(start, this.index)
|
|
27927
|
-
};
|
|
27928
|
-
}
|
|
27929
|
-
gobbleArguments(termination) {
|
|
27930
|
-
const args = [];
|
|
27931
|
-
let closed = false;
|
|
27932
|
-
let separator_count = 0;
|
|
27933
|
-
while (this.index < this.expr.length) {
|
|
27934
|
-
this.gobbleSpaces();
|
|
27935
|
-
let ch_i = this.code;
|
|
27936
|
-
if (ch_i === termination) {
|
|
27937
|
-
closed = true;
|
|
27938
|
-
this.index++;
|
|
27939
|
-
if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
|
|
27940
|
-
this.throwError("Unexpected token " + String.fromCharCode(termination));
|
|
27941
|
-
}
|
|
27942
|
-
break;
|
|
27943
|
-
} else if (ch_i === Jsep.COMMA_CODE) {
|
|
27944
|
-
this.index++;
|
|
27945
|
-
separator_count++;
|
|
27946
|
-
if (separator_count !== args.length) {
|
|
27947
|
-
if (termination === Jsep.CPAREN_CODE) {
|
|
27948
|
-
this.throwError("Unexpected token ,");
|
|
27949
|
-
} else if (termination === Jsep.CBRACK_CODE) {
|
|
27950
|
-
for (let arg = args.length;arg < separator_count; arg++) {
|
|
27951
|
-
args.push(null);
|
|
27952
|
-
}
|
|
27953
|
-
}
|
|
27954
|
-
}
|
|
27955
|
-
} else if (args.length !== separator_count && separator_count !== 0) {
|
|
27956
|
-
this.throwError("Expected comma");
|
|
27957
|
-
} else {
|
|
27958
|
-
const node = this.gobbleExpression();
|
|
27959
|
-
if (!node || node.type === Jsep.COMPOUND) {
|
|
27960
|
-
this.throwError("Expected comma");
|
|
27961
|
-
}
|
|
27962
|
-
args.push(node);
|
|
27963
|
-
}
|
|
27964
|
-
}
|
|
27965
|
-
if (!closed) {
|
|
27966
|
-
this.throwError("Expected " + String.fromCharCode(termination));
|
|
27967
|
-
}
|
|
27968
|
-
return args;
|
|
27969
|
-
}
|
|
27970
|
-
gobbleGroup() {
|
|
27971
|
-
this.index++;
|
|
27972
|
-
let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
27973
|
-
if (this.code === Jsep.CPAREN_CODE) {
|
|
27974
|
-
this.index++;
|
|
27975
|
-
if (nodes.length === 1) {
|
|
27976
|
-
return nodes[0];
|
|
27977
|
-
} else if (!nodes.length) {
|
|
27978
|
-
return false;
|
|
27979
|
-
} else {
|
|
27980
|
-
return {
|
|
27981
|
-
type: Jsep.SEQUENCE_EXP,
|
|
27982
|
-
expressions: nodes
|
|
27983
|
-
};
|
|
27984
|
-
}
|
|
27985
|
-
} else {
|
|
27986
|
-
this.throwError("Unclosed (");
|
|
27987
|
-
}
|
|
27988
|
-
}
|
|
27989
|
-
gobbleArray() {
|
|
27990
|
-
this.index++;
|
|
27991
|
-
return {
|
|
27992
|
-
type: Jsep.ARRAY_EXP,
|
|
27993
|
-
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
27994
|
-
};
|
|
27995
|
-
}
|
|
27996
|
-
}
|
|
27997
|
-
var hooks = new Hooks;
|
|
27998
|
-
Object.assign(Jsep, {
|
|
27999
|
-
hooks,
|
|
28000
|
-
plugins: new Plugins(Jsep),
|
|
28001
|
-
COMPOUND: "Compound",
|
|
28002
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
28003
|
-
IDENTIFIER: "Identifier",
|
|
28004
|
-
MEMBER_EXP: "MemberExpression",
|
|
28005
|
-
LITERAL: "Literal",
|
|
28006
|
-
THIS_EXP: "ThisExpression",
|
|
28007
|
-
CALL_EXP: "CallExpression",
|
|
28008
|
-
UNARY_EXP: "UnaryExpression",
|
|
28009
|
-
BINARY_EXP: "BinaryExpression",
|
|
28010
|
-
ARRAY_EXP: "ArrayExpression",
|
|
28011
|
-
TAB_CODE: 9,
|
|
28012
|
-
LF_CODE: 10,
|
|
28013
|
-
CR_CODE: 13,
|
|
28014
|
-
SPACE_CODE: 32,
|
|
28015
|
-
PERIOD_CODE: 46,
|
|
28016
|
-
COMMA_CODE: 44,
|
|
28017
|
-
SQUOTE_CODE: 39,
|
|
28018
|
-
DQUOTE_CODE: 34,
|
|
28019
|
-
OPAREN_CODE: 40,
|
|
28020
|
-
CPAREN_CODE: 41,
|
|
28021
|
-
OBRACK_CODE: 91,
|
|
28022
|
-
CBRACK_CODE: 93,
|
|
28023
|
-
QUMARK_CODE: 63,
|
|
28024
|
-
SEMCOL_CODE: 59,
|
|
28025
|
-
COLON_CODE: 58,
|
|
28026
|
-
unary_ops: {
|
|
28027
|
-
"-": 1,
|
|
28028
|
-
"!": 1,
|
|
28029
|
-
"~": 1,
|
|
28030
|
-
"+": 1
|
|
28031
|
-
},
|
|
28032
|
-
binary_ops: {
|
|
28033
|
-
"||": 1,
|
|
28034
|
-
"??": 1,
|
|
28035
|
-
"&&": 2,
|
|
28036
|
-
"|": 3,
|
|
28037
|
-
"^": 4,
|
|
28038
|
-
"&": 5,
|
|
28039
|
-
"==": 6,
|
|
28040
|
-
"!=": 6,
|
|
28041
|
-
"===": 6,
|
|
28042
|
-
"!==": 6,
|
|
28043
|
-
"<": 7,
|
|
28044
|
-
">": 7,
|
|
28045
|
-
"<=": 7,
|
|
28046
|
-
">=": 7,
|
|
28047
|
-
"<<": 8,
|
|
28048
|
-
">>": 8,
|
|
28049
|
-
">>>": 8,
|
|
28050
|
-
"+": 9,
|
|
28051
|
-
"-": 9,
|
|
28052
|
-
"*": 10,
|
|
28053
|
-
"/": 10,
|
|
28054
|
-
"%": 10,
|
|
28055
|
-
"**": 11
|
|
28056
|
-
},
|
|
28057
|
-
right_associative: new Set(["**"]),
|
|
28058
|
-
additional_identifier_chars: new Set(["$", "_"]),
|
|
28059
|
-
literals: {
|
|
28060
|
-
true: true,
|
|
28061
|
-
false: false,
|
|
28062
|
-
null: null
|
|
28063
|
-
},
|
|
28064
|
-
this_str: "this"
|
|
28065
|
-
});
|
|
28066
|
-
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
28067
|
-
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
28068
|
-
var jsep = (expr) => new Jsep(expr).parse();
|
|
28069
|
-
var stdClassProps = Object.getOwnPropertyNames(class Test {
|
|
28070
|
-
});
|
|
28071
|
-
Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
|
|
28072
|
-
jsep[m] = Jsep[m];
|
|
28073
|
-
});
|
|
28074
|
-
jsep.Jsep = Jsep;
|
|
28075
|
-
var CONDITIONAL_EXP = "ConditionalExpression";
|
|
28076
|
-
var ternary = {
|
|
28077
|
-
name: "ternary",
|
|
28078
|
-
init(jsep2) {
|
|
28079
|
-
jsep2.hooks.add("after-expression", function gobbleTernary(env) {
|
|
28080
|
-
if (env.node && this.code === jsep2.QUMARK_CODE) {
|
|
28081
|
-
this.index++;
|
|
28082
|
-
const test = env.node;
|
|
28083
|
-
const consequent = this.gobbleExpression();
|
|
28084
|
-
if (!consequent) {
|
|
28085
|
-
this.throwError("Expected expression");
|
|
28086
|
-
}
|
|
28087
|
-
this.gobbleSpaces();
|
|
28088
|
-
if (this.code === jsep2.COLON_CODE) {
|
|
28089
|
-
this.index++;
|
|
28090
|
-
const alternate = this.gobbleExpression();
|
|
28091
|
-
if (!alternate) {
|
|
28092
|
-
this.throwError("Expected expression");
|
|
28093
|
-
}
|
|
28094
|
-
env.node = {
|
|
28095
|
-
type: CONDITIONAL_EXP,
|
|
28096
|
-
test,
|
|
28097
|
-
consequent,
|
|
28098
|
-
alternate
|
|
28099
|
-
};
|
|
28100
|
-
if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
|
|
28101
|
-
let newTest = test;
|
|
28102
|
-
while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
|
|
28103
|
-
newTest = newTest.right;
|
|
28104
|
-
}
|
|
28105
|
-
env.node.test = newTest.right;
|
|
28106
|
-
newTest.right = env.node;
|
|
28107
|
-
env.node = test;
|
|
28108
|
-
}
|
|
28109
|
-
} else {
|
|
28110
|
-
this.throwError("Expected :");
|
|
28111
|
-
}
|
|
28112
|
-
}
|
|
28113
|
-
});
|
|
28114
|
-
}
|
|
28115
|
-
};
|
|
28116
|
-
jsep.plugins.register(ternary);
|
|
28117
|
-
var FSLASH_CODE = 47;
|
|
28118
|
-
var BSLASH_CODE = 92;
|
|
28119
|
-
var index = {
|
|
28120
|
-
name: "regex",
|
|
28121
|
-
init(jsep2) {
|
|
28122
|
-
jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
|
|
28123
|
-
if (this.code === FSLASH_CODE) {
|
|
28124
|
-
const patternIndex = ++this.index;
|
|
28125
|
-
let inCharSet = false;
|
|
28126
|
-
while (this.index < this.expr.length) {
|
|
28127
|
-
if (this.code === FSLASH_CODE && !inCharSet) {
|
|
28128
|
-
const pattern = this.expr.slice(patternIndex, this.index);
|
|
28129
|
-
let flags = "";
|
|
28130
|
-
while (++this.index < this.expr.length) {
|
|
28131
|
-
const code = this.code;
|
|
28132
|
-
if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
28133
|
-
flags += this.char;
|
|
28134
|
-
} else {
|
|
28135
|
-
break;
|
|
28136
|
-
}
|
|
28137
|
-
}
|
|
28138
|
-
let value;
|
|
28139
|
-
try {
|
|
28140
|
-
value = new RegExp(pattern, flags);
|
|
28141
|
-
} catch (e) {
|
|
28142
|
-
this.throwError(e.message);
|
|
28143
|
-
}
|
|
28144
|
-
env.node = {
|
|
28145
|
-
type: jsep2.LITERAL,
|
|
28146
|
-
value,
|
|
28147
|
-
raw: this.expr.slice(patternIndex - 1, this.index)
|
|
28148
|
-
};
|
|
28149
|
-
env.node = this.gobbleTokenProperty(env.node);
|
|
28150
|
-
return env.node;
|
|
28151
|
-
}
|
|
28152
|
-
if (this.code === jsep2.OBRACK_CODE) {
|
|
28153
|
-
inCharSet = true;
|
|
28154
|
-
} else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
|
|
28155
|
-
inCharSet = false;
|
|
28156
|
-
}
|
|
28157
|
-
this.index += this.code === BSLASH_CODE ? 2 : 1;
|
|
28158
|
-
}
|
|
28159
|
-
this.throwError("Unclosed Regex");
|
|
28160
|
-
}
|
|
28161
|
-
});
|
|
28162
|
-
}
|
|
28163
|
-
};
|
|
28164
|
-
var PLUS_CODE = 43;
|
|
28165
|
-
var MINUS_CODE = 45;
|
|
28166
|
-
var plugin = {
|
|
28167
|
-
name: "assignment",
|
|
28168
|
-
assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
|
|
28169
|
-
updateOperators: [PLUS_CODE, MINUS_CODE],
|
|
28170
|
-
assignmentPrecedence: 0.9,
|
|
28171
|
-
init(jsep2) {
|
|
28172
|
-
const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
|
|
28173
|
-
plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
|
|
28174
|
-
jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
|
|
28175
|
-
const code = this.code;
|
|
28176
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
28177
|
-
this.index += 2;
|
|
28178
|
-
env.node = {
|
|
28179
|
-
type: "UpdateExpression",
|
|
28180
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
28181
|
-
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
28182
|
-
prefix: true
|
|
28183
|
-
};
|
|
28184
|
-
if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
|
|
28185
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
28186
|
-
}
|
|
28187
|
-
}
|
|
28188
|
-
});
|
|
28189
|
-
jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
|
|
28190
|
-
if (env.node) {
|
|
28191
|
-
const code = this.code;
|
|
28192
|
-
if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
|
|
28193
|
-
if (!updateNodeTypes.includes(env.node.type)) {
|
|
28194
|
-
this.throwError(`Unexpected ${env.node.operator}`);
|
|
28195
|
-
}
|
|
28196
|
-
this.index += 2;
|
|
28197
|
-
env.node = {
|
|
28198
|
-
type: "UpdateExpression",
|
|
28199
|
-
operator: code === PLUS_CODE ? "++" : "--",
|
|
28200
|
-
argument: env.node,
|
|
28201
|
-
prefix: false
|
|
28202
|
-
};
|
|
28203
|
-
}
|
|
28204
|
-
}
|
|
28205
|
-
});
|
|
28206
|
-
jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
|
|
28207
|
-
if (env.node) {
|
|
28208
|
-
updateBinariesToAssignments(env.node);
|
|
28209
|
-
}
|
|
28210
|
-
});
|
|
28211
|
-
function updateBinariesToAssignments(node) {
|
|
28212
|
-
if (plugin.assignmentOperators.has(node.operator)) {
|
|
28213
|
-
node.type = "AssignmentExpression";
|
|
28214
|
-
updateBinariesToAssignments(node.left);
|
|
28215
|
-
updateBinariesToAssignments(node.right);
|
|
28216
|
-
} else if (!node.operator) {
|
|
28217
|
-
Object.values(node).forEach((val) => {
|
|
28218
|
-
if (val && typeof val === "object") {
|
|
28219
|
-
updateBinariesToAssignments(val);
|
|
28220
|
-
}
|
|
28221
|
-
});
|
|
28222
|
-
}
|
|
28223
|
-
}
|
|
28224
|
-
}
|
|
28225
|
-
};
|
|
28226
|
-
jsep.plugins.register(index, plugin);
|
|
28227
|
-
jsep.addUnaryOp("typeof");
|
|
28228
|
-
jsep.addUnaryOp("void");
|
|
28229
|
-
jsep.addLiteral("null", null);
|
|
28230
|
-
jsep.addLiteral("undefined", undefined);
|
|
28231
|
-
var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
|
|
28232
|
-
var SafeEval = {
|
|
28233
|
-
evalAst(ast, subs) {
|
|
28234
|
-
switch (ast.type) {
|
|
28235
|
-
case "BinaryExpression":
|
|
28236
|
-
case "LogicalExpression":
|
|
28237
|
-
return SafeEval.evalBinaryExpression(ast, subs);
|
|
28238
|
-
case "Compound":
|
|
28239
|
-
return SafeEval.evalCompound(ast, subs);
|
|
28240
|
-
case "ConditionalExpression":
|
|
28241
|
-
return SafeEval.evalConditionalExpression(ast, subs);
|
|
28242
|
-
case "Identifier":
|
|
28243
|
-
return SafeEval.evalIdentifier(ast, subs);
|
|
28244
|
-
case "Literal":
|
|
28245
|
-
return SafeEval.evalLiteral(ast, subs);
|
|
28246
|
-
case "MemberExpression":
|
|
28247
|
-
return SafeEval.evalMemberExpression(ast, subs);
|
|
28248
|
-
case "UnaryExpression":
|
|
28249
|
-
return SafeEval.evalUnaryExpression(ast, subs);
|
|
28250
|
-
case "ArrayExpression":
|
|
28251
|
-
return SafeEval.evalArrayExpression(ast, subs);
|
|
28252
|
-
case "CallExpression":
|
|
28253
|
-
return SafeEval.evalCallExpression(ast, subs);
|
|
28254
|
-
case "AssignmentExpression":
|
|
28255
|
-
return SafeEval.evalAssignmentExpression(ast, subs);
|
|
28256
|
-
default:
|
|
28257
|
-
throw SyntaxError("Unexpected expression", ast);
|
|
28258
|
-
}
|
|
28259
|
-
},
|
|
28260
|
-
evalBinaryExpression(ast, subs) {
|
|
28261
|
-
const result = {
|
|
28262
|
-
"||": (a, b) => a || b(),
|
|
28263
|
-
"&&": (a, b) => a && b(),
|
|
28264
|
-
"|": (a, b) => a | b(),
|
|
28265
|
-
"^": (a, b) => a ^ b(),
|
|
28266
|
-
"&": (a, b) => a & b(),
|
|
28267
|
-
"==": (a, b) => a == b(),
|
|
28268
|
-
"!=": (a, b) => a != b(),
|
|
28269
|
-
"===": (a, b) => a === b(),
|
|
28270
|
-
"!==": (a, b) => a !== b(),
|
|
28271
|
-
"<": (a, b) => a < b(),
|
|
28272
|
-
">": (a, b) => a > b(),
|
|
28273
|
-
"<=": (a, b) => a <= b(),
|
|
28274
|
-
">=": (a, b) => a >= b(),
|
|
28275
|
-
"<<": (a, b) => a << b(),
|
|
28276
|
-
">>": (a, b) => a >> b(),
|
|
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
|
-
}[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
|
|
28284
|
-
return result;
|
|
28285
|
-
},
|
|
28286
|
-
evalCompound(ast, subs) {
|
|
28287
|
-
let last;
|
|
28288
|
-
for (let i = 0;i < ast.body.length; i++) {
|
|
28289
|
-
if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
|
|
28290
|
-
i += 1;
|
|
28291
|
-
}
|
|
28292
|
-
const expr = ast.body[i];
|
|
28293
|
-
last = SafeEval.evalAst(expr, subs);
|
|
28294
|
-
}
|
|
28295
|
-
return last;
|
|
28296
|
-
},
|
|
28297
|
-
evalConditionalExpression(ast, subs) {
|
|
28298
|
-
if (SafeEval.evalAst(ast.test, subs)) {
|
|
28299
|
-
return SafeEval.evalAst(ast.consequent, subs);
|
|
28300
|
-
}
|
|
28301
|
-
return SafeEval.evalAst(ast.alternate, subs);
|
|
28302
|
-
},
|
|
28303
|
-
evalIdentifier(ast, subs) {
|
|
28304
|
-
if (Object.hasOwn(subs, ast.name)) {
|
|
28305
|
-
return subs[ast.name];
|
|
28306
|
-
}
|
|
28307
|
-
throw ReferenceError(`${ast.name} is not defined`);
|
|
28308
|
-
},
|
|
28309
|
-
evalLiteral(ast) {
|
|
28310
|
-
return ast.value;
|
|
28311
|
-
},
|
|
28312
|
-
evalMemberExpression(ast, subs) {
|
|
28313
|
-
const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
|
|
28314
|
-
const obj = SafeEval.evalAst(ast.object, subs);
|
|
28315
|
-
if (obj === undefined || obj === null) {
|
|
28316
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
28317
|
-
}
|
|
28318
|
-
if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
|
|
28319
|
-
throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
|
|
28320
|
-
}
|
|
28321
|
-
const result = obj[prop];
|
|
28322
|
-
if (typeof result === "function") {
|
|
28323
|
-
return result.bind(obj);
|
|
28324
|
-
}
|
|
28325
|
-
return result;
|
|
28326
|
-
},
|
|
28327
|
-
evalUnaryExpression(ast, subs) {
|
|
28328
|
-
const result = {
|
|
28329
|
-
"-": (a) => -SafeEval.evalAst(a, subs),
|
|
28330
|
-
"!": (a) => !SafeEval.evalAst(a, subs),
|
|
28331
|
-
"~": (a) => ~SafeEval.evalAst(a, subs),
|
|
28332
|
-
"+": (a) => +SafeEval.evalAst(a, subs),
|
|
28333
|
-
typeof: (a) => typeof SafeEval.evalAst(a, subs),
|
|
28334
|
-
void: (a) => void SafeEval.evalAst(a, subs)
|
|
28335
|
-
}[ast.operator](ast.argument);
|
|
28336
|
-
return result;
|
|
28337
|
-
},
|
|
28338
|
-
evalArrayExpression(ast, subs) {
|
|
28339
|
-
return ast.elements.map((el) => SafeEval.evalAst(el, subs));
|
|
28340
|
-
},
|
|
28341
|
-
evalCallExpression(ast, subs) {
|
|
28342
|
-
const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
|
|
28343
|
-
const func = SafeEval.evalAst(ast.callee, subs);
|
|
28344
|
-
if (func === Function) {
|
|
28345
|
-
throw new Error("Function constructor is disabled");
|
|
28346
|
-
}
|
|
28347
|
-
return func(...args);
|
|
28348
|
-
},
|
|
28349
|
-
evalAssignmentExpression(ast, subs) {
|
|
28350
|
-
if (ast.left.type !== "Identifier") {
|
|
28351
|
-
throw SyntaxError("Invalid left-hand side in assignment");
|
|
28352
|
-
}
|
|
28353
|
-
const id = ast.left.name;
|
|
28354
|
-
const value = SafeEval.evalAst(ast.right, subs);
|
|
28355
|
-
subs[id] = value;
|
|
28356
|
-
return subs[id];
|
|
28357
|
-
}
|
|
28358
|
-
};
|
|
28359
|
-
|
|
28360
|
-
class SafeScript {
|
|
28361
|
-
constructor(expr) {
|
|
28362
|
-
this.code = expr;
|
|
28363
|
-
this.ast = jsep(this.code);
|
|
28364
|
-
}
|
|
28365
|
-
runInNewContext(context) {
|
|
28366
|
-
const keyMap = Object.assign(Object.create(null), context);
|
|
28367
|
-
return SafeEval.evalAst(this.ast, keyMap);
|
|
28368
|
-
}
|
|
28369
|
-
}
|
|
28370
|
-
function push(arr, item) {
|
|
28371
|
-
arr = arr.slice();
|
|
28372
|
-
arr.push(item);
|
|
28373
|
-
return arr;
|
|
28374
|
-
}
|
|
28375
|
-
function unshift(item, arr) {
|
|
28376
|
-
arr = arr.slice();
|
|
28377
|
-
arr.unshift(item);
|
|
28378
|
-
return arr;
|
|
28379
|
-
}
|
|
28380
|
-
|
|
28381
|
-
class NewError extends Error {
|
|
28382
|
-
constructor(value) {
|
|
28383
|
-
super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
|
|
28384
|
-
this.avoidNew = true;
|
|
28385
|
-
this.value = value;
|
|
28386
|
-
this.name = "NewError";
|
|
28387
|
-
}
|
|
28388
|
-
}
|
|
28389
|
-
function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
|
|
28390
|
-
if (!(this instanceof JSONPath)) {
|
|
28391
|
-
try {
|
|
28392
|
-
return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
|
|
28393
|
-
} catch (e) {
|
|
28394
|
-
if (!e.avoidNew) {
|
|
28395
|
-
throw e;
|
|
28396
|
-
}
|
|
28397
|
-
return e.value;
|
|
28398
|
-
}
|
|
28399
|
-
}
|
|
28400
|
-
if (typeof opts === "string") {
|
|
28401
|
-
otherTypeCallback = callback;
|
|
28402
|
-
callback = obj;
|
|
28403
|
-
obj = expr;
|
|
28404
|
-
expr = opts;
|
|
28405
|
-
opts = null;
|
|
28406
|
-
}
|
|
28407
|
-
const optObj = opts && typeof opts === "object";
|
|
28408
|
-
opts = opts || {};
|
|
28409
|
-
this.json = opts.json || obj;
|
|
28410
|
-
this.path = opts.path || expr;
|
|
28411
|
-
this.resultType = opts.resultType || "value";
|
|
28412
|
-
this.flatten = opts.flatten || false;
|
|
28413
|
-
this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
|
|
28414
|
-
this.sandbox = opts.sandbox || {};
|
|
28415
|
-
this.eval = opts.eval === undefined ? "safe" : opts.eval;
|
|
28416
|
-
this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
|
|
28417
|
-
this.parent = opts.parent || null;
|
|
28418
|
-
this.parentProperty = opts.parentProperty || null;
|
|
28419
|
-
this.callback = opts.callback || callback || null;
|
|
28420
|
-
this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
|
|
28421
|
-
throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
|
|
28422
|
-
};
|
|
28423
|
-
if (opts.autostart !== false) {
|
|
28424
|
-
const args = {
|
|
28425
|
-
path: optObj ? opts.path : expr
|
|
28426
|
-
};
|
|
28427
|
-
if (!optObj) {
|
|
28428
|
-
args.json = obj;
|
|
28429
|
-
} else if ("json" in opts) {
|
|
28430
|
-
args.json = opts.json;
|
|
28431
|
-
}
|
|
28432
|
-
const ret = this.evaluate(args);
|
|
28433
|
-
if (!ret || typeof ret !== "object") {
|
|
28434
|
-
throw new NewError(ret);
|
|
28435
|
-
}
|
|
28436
|
-
return ret;
|
|
28437
|
-
}
|
|
28438
|
-
}
|
|
28439
|
-
JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
|
|
28440
|
-
let currParent = this.parent, currParentProperty = this.parentProperty;
|
|
28441
|
-
let {
|
|
28442
|
-
flatten,
|
|
28443
|
-
wrap
|
|
28444
|
-
} = this;
|
|
28445
|
-
this.currResultType = this.resultType;
|
|
28446
|
-
this.currEval = this.eval;
|
|
28447
|
-
this.currSandbox = this.sandbox;
|
|
28448
|
-
callback = callback || this.callback;
|
|
28449
|
-
this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
|
|
28450
|
-
json = json || this.json;
|
|
28451
|
-
expr = expr || this.path;
|
|
28452
|
-
if (expr && typeof expr === "object" && !Array.isArray(expr)) {
|
|
28453
|
-
if (!expr.path && expr.path !== "") {
|
|
28454
|
-
throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
28455
|
-
}
|
|
28456
|
-
if (!Object.hasOwn(expr, "json")) {
|
|
28457
|
-
throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
|
|
28458
|
-
}
|
|
28459
|
-
({
|
|
28460
|
-
json
|
|
28461
|
-
} = expr);
|
|
28462
|
-
flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
|
|
28463
|
-
this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
|
|
28464
|
-
this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
|
|
28465
|
-
wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
|
|
28466
|
-
this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
|
|
28467
|
-
callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
|
|
28468
|
-
this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
|
|
28469
|
-
currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
|
|
28470
|
-
currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
|
|
28471
|
-
expr = expr.path;
|
|
28472
|
-
}
|
|
28473
|
-
currParent = currParent || null;
|
|
28474
|
-
currParentProperty = currParentProperty || null;
|
|
28475
|
-
if (Array.isArray(expr)) {
|
|
28476
|
-
expr = JSONPath.toPathString(expr);
|
|
28477
|
-
}
|
|
28478
|
-
if (!expr && expr !== "" || !json) {
|
|
28479
|
-
return;
|
|
28480
|
-
}
|
|
28481
|
-
const exprList = JSONPath.toPathArray(expr);
|
|
28482
|
-
if (exprList[0] === "$" && exprList.length > 1) {
|
|
28483
|
-
exprList.shift();
|
|
28484
|
-
}
|
|
28485
|
-
this._hasParentSelector = null;
|
|
28486
|
-
const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
|
|
28487
|
-
return ea && !ea.isParentSelector;
|
|
28488
|
-
});
|
|
28489
|
-
if (!result.length) {
|
|
28490
|
-
return wrap ? [] : undefined;
|
|
28491
|
-
}
|
|
28492
|
-
if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
|
|
28493
|
-
return this._getPreferredOutput(result[0]);
|
|
28494
|
-
}
|
|
28495
|
-
return result.reduce((rslt, ea) => {
|
|
28496
|
-
const valOrPath = this._getPreferredOutput(ea);
|
|
28497
|
-
if (flatten && Array.isArray(valOrPath)) {
|
|
28498
|
-
rslt = rslt.concat(valOrPath);
|
|
28499
|
-
} else {
|
|
28500
|
-
rslt.push(valOrPath);
|
|
28501
|
-
}
|
|
28502
|
-
return rslt;
|
|
28503
|
-
}, []);
|
|
28504
|
-
};
|
|
28505
|
-
JSONPath.prototype._getPreferredOutput = function(ea) {
|
|
28506
|
-
const resultType = this.currResultType;
|
|
28507
|
-
switch (resultType) {
|
|
28508
|
-
case "all": {
|
|
28509
|
-
const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
|
|
28510
|
-
ea.pointer = JSONPath.toPointer(path3);
|
|
28511
|
-
ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
|
|
28512
|
-
return ea;
|
|
28513
|
-
}
|
|
28514
|
-
case "value":
|
|
28515
|
-
case "parent":
|
|
28516
|
-
case "parentProperty":
|
|
28517
|
-
return ea[resultType];
|
|
28518
|
-
case "path":
|
|
28519
|
-
return JSONPath.toPathString(ea[resultType]);
|
|
28520
|
-
case "pointer":
|
|
28521
|
-
return JSONPath.toPointer(ea.path);
|
|
28522
|
-
default:
|
|
28523
|
-
throw new TypeError("Unknown result type");
|
|
28524
|
-
}
|
|
28525
|
-
};
|
|
28526
|
-
JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
|
|
28527
|
-
if (callback) {
|
|
28528
|
-
const preferredOutput = this._getPreferredOutput(fullRetObj);
|
|
28529
|
-
fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
|
|
28530
|
-
callback(preferredOutput, type, fullRetObj);
|
|
28531
|
-
}
|
|
28532
|
-
};
|
|
28533
|
-
JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
|
|
28534
|
-
let retObj;
|
|
28535
|
-
if (!expr.length) {
|
|
28536
|
-
retObj = {
|
|
28537
|
-
path: path3,
|
|
28538
|
-
value: val,
|
|
28539
|
-
parent,
|
|
28540
|
-
parentProperty: parentPropName,
|
|
28541
|
-
hasArrExpr
|
|
28542
|
-
};
|
|
28543
|
-
this._handleCallback(retObj, callback, "value");
|
|
28544
|
-
return retObj;
|
|
28545
|
-
}
|
|
28546
|
-
const loc = expr[0], x = expr.slice(1);
|
|
28547
|
-
const ret = [];
|
|
28548
|
-
function addRet(elems) {
|
|
28549
|
-
if (Array.isArray(elems)) {
|
|
28550
|
-
elems.forEach((t) => {
|
|
28551
|
-
ret.push(t);
|
|
28552
|
-
});
|
|
28553
|
-
} else {
|
|
28554
|
-
ret.push(elems);
|
|
28555
|
-
}
|
|
28556
|
-
}
|
|
28557
|
-
if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
|
|
28558
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
|
|
28559
|
-
} else if (loc === "*") {
|
|
28560
|
-
this._walk(val, (m) => {
|
|
28561
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
|
|
28562
|
-
});
|
|
28563
|
-
} else if (loc === "..") {
|
|
28564
|
-
addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
28565
|
-
this._walk(val, (m) => {
|
|
28566
|
-
if (typeof val[m] === "object") {
|
|
28567
|
-
addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
|
|
28568
|
-
}
|
|
28569
|
-
});
|
|
28570
|
-
} else if (loc === "^") {
|
|
28571
|
-
this._hasParentSelector = true;
|
|
28572
|
-
return {
|
|
28573
|
-
path: path3.slice(0, -1),
|
|
28574
|
-
expr: x,
|
|
28575
|
-
isParentSelector: true
|
|
28576
|
-
};
|
|
28577
|
-
} else if (loc === "~") {
|
|
28578
|
-
retObj = {
|
|
28579
|
-
path: push(path3, loc),
|
|
28580
|
-
value: parentPropName,
|
|
28581
|
-
parent,
|
|
28582
|
-
parentProperty: null
|
|
28583
|
-
};
|
|
28584
|
-
this._handleCallback(retObj, callback, "property");
|
|
28585
|
-
return retObj;
|
|
28586
|
-
} else if (loc === "$") {
|
|
28587
|
-
addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
|
|
28588
|
-
} else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
|
|
28589
|
-
addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
|
|
28590
|
-
} else if (loc.indexOf("?(") === 0) {
|
|
28591
|
-
if (this.currEval === false) {
|
|
28592
|
-
throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
28593
|
-
}
|
|
28594
|
-
const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
|
|
28595
|
-
const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
|
|
28596
|
-
if (nested) {
|
|
28597
|
-
this._walk(val, (m) => {
|
|
28598
|
-
const npath = [nested[2]];
|
|
28599
|
-
const nvalue = nested[1] ? val[m][nested[1]] : val[m];
|
|
28600
|
-
const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
|
|
28601
|
-
if (filterResults.length > 0) {
|
|
28602
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
28603
|
-
}
|
|
28604
|
-
});
|
|
28605
|
-
} else {
|
|
28606
|
-
this._walk(val, (m) => {
|
|
28607
|
-
if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
|
|
28608
|
-
addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
|
|
28609
|
-
}
|
|
28610
|
-
});
|
|
28611
|
-
}
|
|
28612
|
-
} else if (loc[0] === "(") {
|
|
28613
|
-
if (this.currEval === false) {
|
|
28614
|
-
throw new Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
28615
|
-
}
|
|
28616
|
-
addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
|
|
28617
|
-
} else if (loc[0] === "@") {
|
|
28618
|
-
let addType = false;
|
|
28619
|
-
const valueType = loc.slice(1, -2);
|
|
28620
|
-
switch (valueType) {
|
|
28621
|
-
case "scalar":
|
|
28622
|
-
if (!val || !["object", "function"].includes(typeof val)) {
|
|
28623
|
-
addType = true;
|
|
28624
|
-
}
|
|
28625
|
-
break;
|
|
28626
|
-
case "boolean":
|
|
28627
|
-
case "string":
|
|
28628
|
-
case "undefined":
|
|
28629
|
-
case "function":
|
|
28630
|
-
if (typeof val === valueType) {
|
|
28631
|
-
addType = true;
|
|
28632
|
-
}
|
|
28633
|
-
break;
|
|
28634
|
-
case "integer":
|
|
28635
|
-
if (Number.isFinite(val) && !(val % 1)) {
|
|
28636
|
-
addType = true;
|
|
28637
|
-
}
|
|
28638
|
-
break;
|
|
28639
|
-
case "number":
|
|
28640
|
-
if (Number.isFinite(val)) {
|
|
28641
|
-
addType = true;
|
|
28642
|
-
}
|
|
28643
|
-
break;
|
|
28644
|
-
case "nonFinite":
|
|
28645
|
-
if (typeof val === "number" && !Number.isFinite(val)) {
|
|
28646
|
-
addType = true;
|
|
28647
|
-
}
|
|
28648
|
-
break;
|
|
28649
|
-
case "object":
|
|
28650
|
-
if (val && typeof val === valueType) {
|
|
28651
|
-
addType = true;
|
|
28652
|
-
}
|
|
28653
|
-
break;
|
|
28654
|
-
case "array":
|
|
28655
|
-
if (Array.isArray(val)) {
|
|
28656
|
-
addType = true;
|
|
28657
|
-
}
|
|
28658
|
-
break;
|
|
28659
|
-
case "other":
|
|
28660
|
-
addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
|
|
28661
|
-
break;
|
|
28662
|
-
case "null":
|
|
28663
|
-
if (val === null) {
|
|
28664
|
-
addType = true;
|
|
28665
|
-
}
|
|
28666
|
-
break;
|
|
28667
|
-
default:
|
|
28668
|
-
throw new TypeError("Unknown value type " + valueType);
|
|
28669
|
-
}
|
|
28670
|
-
if (addType) {
|
|
28671
|
-
retObj = {
|
|
28672
|
-
path: path3,
|
|
28673
|
-
value: val,
|
|
28674
|
-
parent,
|
|
28675
|
-
parentProperty: parentPropName
|
|
28676
|
-
};
|
|
28677
|
-
this._handleCallback(retObj, callback, "value");
|
|
28678
|
-
return retObj;
|
|
28679
|
-
}
|
|
28680
|
-
} else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
|
|
28681
|
-
const locProp = loc.slice(1);
|
|
28682
|
-
addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
|
|
28683
|
-
} else if (loc.includes(",")) {
|
|
28684
|
-
const parts = loc.split(",");
|
|
28685
|
-
for (const part of parts) {
|
|
28686
|
-
addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
|
|
28687
|
-
}
|
|
28688
|
-
} else if (!literalPriority && val && Object.hasOwn(val, loc)) {
|
|
28689
|
-
addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
|
|
28690
|
-
}
|
|
28691
|
-
if (this._hasParentSelector) {
|
|
28692
|
-
for (let t = 0;t < ret.length; t++) {
|
|
28693
|
-
const rett = ret[t];
|
|
28694
|
-
if (rett && rett.isParentSelector) {
|
|
28695
|
-
const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
|
|
28696
|
-
if (Array.isArray(tmp)) {
|
|
28697
|
-
ret[t] = tmp[0];
|
|
28698
|
-
const tl = tmp.length;
|
|
28699
|
-
for (let tt = 1;tt < tl; tt++) {
|
|
28700
|
-
t++;
|
|
28701
|
-
ret.splice(t, 0, tmp[tt]);
|
|
28702
|
-
}
|
|
28703
|
-
} else {
|
|
28704
|
-
ret[t] = tmp;
|
|
28705
|
-
}
|
|
28706
|
-
}
|
|
28707
|
-
}
|
|
28708
|
-
}
|
|
28709
|
-
return ret;
|
|
28710
|
-
};
|
|
28711
|
-
JSONPath.prototype._walk = function(val, f) {
|
|
28712
|
-
if (Array.isArray(val)) {
|
|
28713
|
-
const n = val.length;
|
|
28714
|
-
for (let i = 0;i < n; i++) {
|
|
28715
|
-
f(i);
|
|
28716
|
-
}
|
|
28717
|
-
} else if (val && typeof val === "object") {
|
|
28718
|
-
Object.keys(val).forEach((m) => {
|
|
28719
|
-
f(m);
|
|
28720
|
-
});
|
|
28721
|
-
}
|
|
28722
|
-
};
|
|
28723
|
-
JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
|
|
28724
|
-
if (!Array.isArray(val)) {
|
|
28725
|
-
return;
|
|
28726
|
-
}
|
|
28727
|
-
const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
|
|
28728
|
-
let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
|
|
28729
|
-
start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
|
|
28730
|
-
end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
|
|
28731
|
-
const ret = [];
|
|
28732
|
-
for (let i = start;i < end; i += step) {
|
|
28733
|
-
const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
|
|
28734
|
-
tmp.forEach((t) => {
|
|
28735
|
-
ret.push(t);
|
|
28736
|
-
});
|
|
28737
|
-
}
|
|
28738
|
-
return ret;
|
|
28739
|
-
};
|
|
28740
|
-
JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
|
|
28741
|
-
this.currSandbox._$_parentProperty = parentPropName;
|
|
28742
|
-
this.currSandbox._$_parent = parent;
|
|
28743
|
-
this.currSandbox._$_property = _vname;
|
|
28744
|
-
this.currSandbox._$_root = this.json;
|
|
28745
|
-
this.currSandbox._$_v = _v;
|
|
28746
|
-
const containsPath = code.includes("@path");
|
|
28747
|
-
if (containsPath) {
|
|
28748
|
-
this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
|
|
28749
|
-
}
|
|
28750
|
-
const scriptCacheKey = this.currEval + "Script:" + code;
|
|
28751
|
-
if (!JSONPath.cache[scriptCacheKey]) {
|
|
28752
|
-
let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
|
|
28753
|
-
if (containsPath) {
|
|
28754
|
-
script = script.replaceAll("@path", "_$_path");
|
|
28755
|
-
}
|
|
28756
|
-
if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
|
|
28757
|
-
JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
|
|
28758
|
-
} else if (this.currEval === "native") {
|
|
28759
|
-
JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
|
|
28760
|
-
} else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
28761
|
-
const CurrEval = this.currEval;
|
|
28762
|
-
JSONPath.cache[scriptCacheKey] = new CurrEval(script);
|
|
28763
|
-
} else if (typeof this.currEval === "function") {
|
|
28764
|
-
JSONPath.cache[scriptCacheKey] = {
|
|
28765
|
-
runInNewContext: (context) => this.currEval(script, context)
|
|
28766
|
-
};
|
|
28767
|
-
} else {
|
|
28768
|
-
throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
28769
|
-
}
|
|
28770
|
-
}
|
|
28771
|
-
try {
|
|
28772
|
-
return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
|
|
28773
|
-
} catch (e) {
|
|
28774
|
-
if (this.ignoreEvalErrors) {
|
|
28775
|
-
return false;
|
|
28776
|
-
}
|
|
28777
|
-
throw new Error("jsonPath: " + e.message + ": " + code);
|
|
28778
|
-
}
|
|
28779
|
-
};
|
|
28780
|
-
JSONPath.cache = {};
|
|
28781
|
-
JSONPath.toPathString = function(pathArr) {
|
|
28782
|
-
const x = pathArr, n = x.length;
|
|
28783
|
-
let p = "$";
|
|
28784
|
-
for (let i = 1;i < n; i++) {
|
|
28785
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
28786
|
-
p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
|
|
28787
|
-
}
|
|
28788
|
-
}
|
|
28789
|
-
return p;
|
|
28790
|
-
};
|
|
28791
|
-
JSONPath.toPointer = function(pointer) {
|
|
28792
|
-
const x = pointer, n = x.length;
|
|
28793
|
-
let p = "";
|
|
28794
|
-
for (let i = 1;i < n; i++) {
|
|
28795
|
-
if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
|
|
28796
|
-
p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
|
|
28797
|
-
}
|
|
28798
|
-
}
|
|
28799
|
-
return p;
|
|
28800
|
-
};
|
|
28801
|
-
JSONPath.toPathArray = function(expr) {
|
|
28802
|
-
const {
|
|
28803
|
-
cache
|
|
28804
|
-
} = JSONPath;
|
|
28805
|
-
if (cache[expr]) {
|
|
28806
|
-
return cache[expr].concat();
|
|
28807
|
-
}
|
|
28808
|
-
const subx = [];
|
|
28809
|
-
const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
|
|
28810
|
-
return "[#" + (subx.push($1) - 1) + "]";
|
|
28811
|
-
}).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
|
|
28812
|
-
return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
28813
|
-
}).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
|
|
28814
|
-
return ";" + ups.split("").join(";") + ";";
|
|
28815
|
-
}).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
|
|
28816
|
-
const exprList = normalized.split(";").map(function(exp) {
|
|
28817
|
-
const match = exp.match(/#(\d+)/u);
|
|
28818
|
-
return !match || !match[1] ? exp : subx[match[1]];
|
|
28819
|
-
});
|
|
28820
|
-
cache[expr] = exprList;
|
|
28821
|
-
return cache[expr].concat();
|
|
28822
|
-
};
|
|
28823
|
-
JSONPath.prototype.safeVm = {
|
|
28824
|
-
Script: SafeScript
|
|
28825
|
-
};
|
|
28826
|
-
JSONPath.prototype.vm = vm;
|
|
28827
|
-
// ../../common/src/option-aliases.ts
|
|
28828
|
-
function resolveDeprecatedOptionAlias({
|
|
28829
|
-
preferredValue,
|
|
28830
|
-
deprecatedValue,
|
|
28831
|
-
preferredFlag,
|
|
28832
|
-
deprecatedFlag
|
|
28833
|
-
}) {
|
|
28834
|
-
const hasPreferred = preferredValue !== undefined;
|
|
28835
|
-
const hasDeprecated = deprecatedValue !== undefined;
|
|
28836
|
-
if (hasPreferred && hasDeprecated) {
|
|
28837
|
-
return {
|
|
28838
|
-
value: undefined,
|
|
28839
|
-
usedDeprecated: true,
|
|
28840
|
-
error: {
|
|
28841
|
-
message: `${deprecatedFlag} and ${preferredFlag} are aliases. Use only ${preferredFlag}.`,
|
|
28842
|
-
instructions: `Replace ${deprecatedFlag} with ${preferredFlag}.`
|
|
28843
|
-
}
|
|
28844
|
-
};
|
|
28845
|
-
}
|
|
28846
|
-
return {
|
|
28847
|
-
value: hasPreferred ? preferredValue : deprecatedValue,
|
|
28848
|
-
usedDeprecated: hasDeprecated
|
|
28849
|
-
};
|
|
28850
|
-
}
|
|
28851
|
-
function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
|
|
28852
|
-
getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
|
|
28853
|
-
`);
|
|
28854
|
-
}
|
|
28855
|
-
var TENANT_SWITCH_COMMAND = "uip login tenant set <tenant>";
|
|
28856
|
-
function createHiddenDeprecatedTenantOption(flags = "-t, --tenant <tenant-name>") {
|
|
28857
|
-
return new Option(flags, `Tenant name. Deprecated; use ${TENANT_SWITCH_COMMAND} to switch active tenants.`).hideHelp().argParser((tenant) => {
|
|
28858
|
-
warnDeprecatedTenantOption(tenant);
|
|
28859
|
-
return tenant;
|
|
28860
|
-
});
|
|
28861
|
-
}
|
|
28862
|
-
function warnDeprecatedTenantOption(tenant) {
|
|
28863
|
-
if (tenant === undefined)
|
|
28864
|
-
return;
|
|
28865
|
-
warnDeprecatedOptionAlias("--tenant", TENANT_SWITCH_COMMAND);
|
|
28866
|
-
}
|
|
28867
|
-
// ../../common/src/polling/types.ts
|
|
28868
|
-
var PollOutcome = {
|
|
28869
|
-
Completed: "completed",
|
|
28870
|
-
Timeout: "timeout",
|
|
28871
|
-
Interrupted: "interrupted",
|
|
28872
|
-
Aborted: "aborted",
|
|
28873
|
-
Failed: "failed"
|
|
28874
|
-
};
|
|
28875
|
-
|
|
28876
|
-
// ../../common/src/polling/poll-failure-mapping.ts
|
|
28877
|
-
var REASON_BY_OUTCOME = {
|
|
28878
|
-
[PollOutcome.Timeout]: "poll_timeout",
|
|
28879
|
-
[PollOutcome.Failed]: "poll_failed",
|
|
28880
|
-
[PollOutcome.Interrupted]: "poll_failed",
|
|
28881
|
-
[PollOutcome.Aborted]: "poll_aborted"
|
|
28882
|
-
};
|
|
28883
|
-
// ../../common/src/polling/terminal-statuses.ts
|
|
28884
|
-
var TERMINAL_STATUSES = new Set([
|
|
28885
|
-
"completed",
|
|
28886
|
-
"successful",
|
|
28887
|
-
"faulted",
|
|
28888
|
-
"failed",
|
|
28889
|
-
"cancelled",
|
|
28890
|
-
"canceled",
|
|
28891
|
-
"stopped",
|
|
28892
|
-
"finished"
|
|
28893
|
-
]);
|
|
28894
|
-
var FAILURE_STATUSES = new Set([
|
|
28895
|
-
"faulted",
|
|
28896
|
-
"failed",
|
|
28897
|
-
"cancelled",
|
|
28898
|
-
"canceled",
|
|
28899
|
-
"stopped"
|
|
28900
|
-
]);
|
|
28901
|
-
// ../../common/src/screen-logger.ts
|
|
28902
|
-
var ScreenLogger;
|
|
28903
|
-
((ScreenLogger) => {
|
|
28904
|
-
function progress(message) {
|
|
28905
|
-
getOutputSink().writeErr(`${message}
|
|
28906
|
-
`);
|
|
28907
|
-
}
|
|
28908
|
-
ScreenLogger.progress = progress;
|
|
28909
|
-
})(ScreenLogger ||= {});
|
|
28910
|
-
// ../../common/src/sdk-user-agent.ts
|
|
28911
|
-
var USER_AGENT_HEADER = "User-Agent";
|
|
28912
|
-
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
28913
|
-
function userAgentPatchKey(userAgent) {
|
|
28914
|
-
return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
|
|
28915
|
-
}
|
|
28916
|
-
function splitUserAgentTokens(value) {
|
|
28917
|
-
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
28918
|
-
}
|
|
28919
|
-
function appendUserAgentToken(value, userAgent) {
|
|
28920
|
-
const tokens = splitUserAgentTokens(value);
|
|
28921
|
-
const seen = new Set(tokens);
|
|
28922
|
-
for (const token of splitUserAgentTokens(userAgent)) {
|
|
28923
|
-
if (!seen.has(token)) {
|
|
28924
|
-
tokens.push(token);
|
|
28925
|
-
seen.add(token);
|
|
28926
|
-
}
|
|
28927
|
-
}
|
|
28928
|
-
return tokens.join(" ");
|
|
28929
|
-
}
|
|
28930
|
-
function getEffectiveUserAgent(userAgent) {
|
|
28931
|
-
return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
|
|
28932
|
-
}
|
|
28933
|
-
function isHeadersLike(headers) {
|
|
28934
|
-
return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
|
|
28935
|
-
}
|
|
28936
|
-
function getSdkUserAgentToken(pkg) {
|
|
28937
|
-
const packageName = pkg.name.replace(/^@uipath\//, "");
|
|
28938
|
-
return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
|
|
28939
|
-
}
|
|
28940
|
-
function addSdkUserAgentHeader(headers, userAgent) {
|
|
28941
|
-
const result = { ...headers ?? {} };
|
|
28942
|
-
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
28943
|
-
const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
28944
|
-
if (headerName) {
|
|
28945
|
-
result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
|
|
28946
|
-
} else {
|
|
28947
|
-
result[USER_AGENT_HEADER] = effectiveUserAgent;
|
|
28948
|
-
}
|
|
28949
|
-
return result;
|
|
28950
|
-
}
|
|
28951
|
-
function withSdkUserAgentHeader(headers, userAgent) {
|
|
28952
|
-
const effectiveUserAgent = getEffectiveUserAgent(userAgent);
|
|
28953
|
-
if (isHeadersLike(headers)) {
|
|
28954
|
-
headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
|
|
28955
|
-
return headers;
|
|
28956
|
-
}
|
|
28957
|
-
if (Array.isArray(headers)) {
|
|
28958
|
-
const result = headers.map((entry) => {
|
|
28959
|
-
const [key, value] = entry;
|
|
28960
|
-
return [key, value];
|
|
28961
|
-
});
|
|
28962
|
-
const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
|
|
28963
|
-
if (headerIndex >= 0) {
|
|
28964
|
-
const [key, value] = result[headerIndex];
|
|
28965
|
-
result[headerIndex] = [
|
|
28966
|
-
key,
|
|
28967
|
-
appendUserAgentToken(value, effectiveUserAgent)
|
|
28968
|
-
];
|
|
28969
|
-
} else {
|
|
28970
|
-
result.push([USER_AGENT_HEADER, effectiveUserAgent]);
|
|
28971
|
-
}
|
|
28972
|
-
return result;
|
|
28973
|
-
}
|
|
28974
|
-
return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
|
|
28975
|
-
}
|
|
28976
|
-
function withUserAgentInitOverride(initOverrides, userAgent) {
|
|
28977
|
-
return async (requestContext) => {
|
|
28978
|
-
const initWithUserAgent = {
|
|
28979
|
-
...requestContext.init,
|
|
28980
|
-
headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
|
|
28981
|
-
};
|
|
28982
|
-
const override = typeof initOverrides === "function" ? await initOverrides({
|
|
28983
|
-
...requestContext,
|
|
28984
|
-
init: initWithUserAgent
|
|
28985
|
-
}) : initOverrides;
|
|
28986
|
-
return {
|
|
28987
|
-
...override ?? {},
|
|
28988
|
-
headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
|
|
28989
|
-
};
|
|
28990
|
-
};
|
|
28991
|
-
}
|
|
28992
|
-
function installSdkUserAgentHeader(BaseApiClass, userAgent) {
|
|
28993
|
-
const prototype = BaseApiClass.prototype;
|
|
28994
|
-
const patchKey = userAgentPatchKey(userAgent);
|
|
28995
|
-
if (prototype[patchKey]) {
|
|
28996
|
-
return;
|
|
28997
|
-
}
|
|
28998
|
-
if (typeof prototype.request !== "function") {
|
|
28999
|
-
throw new Error("Generated BaseAPI request function not found.");
|
|
29000
|
-
}
|
|
29001
|
-
const originalRequest = prototype.request;
|
|
29002
|
-
prototype.request = function requestWithUserAgent(context, initOverrides) {
|
|
29003
|
-
return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
|
|
29004
|
-
};
|
|
29005
|
-
Object.defineProperty(prototype, patchKey, {
|
|
29006
|
-
value: true
|
|
29007
|
-
});
|
|
29008
|
-
}
|
|
29009
|
-
// ../../common/src/tool-provider.ts
|
|
29010
|
-
var factorySlot = singleton("PackagerFactoryProvider");
|
|
29011
|
-
// ../resourcecatalog-sdk/generated/src/runtime.ts
|
|
29012
|
-
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
29013
|
-
|
|
29014
|
-
class Configuration {
|
|
29015
|
-
configuration;
|
|
29016
|
-
constructor(configuration = {}) {
|
|
29017
|
-
this.configuration = configuration;
|
|
29018
|
-
}
|
|
29019
|
-
set config(configuration) {
|
|
29020
|
-
this.configuration = configuration;
|
|
29021
|
-
}
|
|
29022
|
-
get basePath() {
|
|
29023
|
-
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
29024
|
-
}
|
|
29025
|
-
get fetchApi() {
|
|
29026
|
-
return this.configuration.fetchApi;
|
|
29027
|
-
}
|
|
29028
|
-
get middleware() {
|
|
29029
|
-
return this.configuration.middleware || [];
|
|
29030
|
-
}
|
|
29031
|
-
get queryParamsStringify() {
|
|
29032
|
-
return this.configuration.queryParamsStringify || querystring;
|
|
29033
|
-
}
|
|
29034
|
-
get username() {
|
|
29035
|
-
return this.configuration.username;
|
|
29036
|
-
}
|
|
29037
|
-
get password() {
|
|
29038
|
-
return this.configuration.password;
|
|
29039
|
-
}
|
|
29040
|
-
get apiKey() {
|
|
29041
|
-
const apiKey = this.configuration.apiKey;
|
|
29042
|
-
if (apiKey) {
|
|
29043
|
-
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
29044
|
-
}
|
|
29045
|
-
return;
|
|
29046
|
-
}
|
|
29047
|
-
get accessToken() {
|
|
29048
|
-
const accessToken = this.configuration.accessToken;
|
|
29049
|
-
if (accessToken) {
|
|
29050
|
-
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
29051
|
-
}
|
|
29052
|
-
return;
|
|
29053
|
-
}
|
|
29054
|
-
get headers() {
|
|
29055
|
-
return this.configuration.headers;
|
|
29056
|
-
}
|
|
29057
|
-
get credentials() {
|
|
29058
|
-
return this.configuration.credentials;
|
|
29059
|
-
}
|
|
29060
|
-
}
|
|
29061
|
-
var DefaultConfig = new Configuration;
|
|
29062
|
-
|
|
29063
|
-
class BaseAPI {
|
|
29064
|
-
configuration;
|
|
29065
|
-
static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
|
|
29066
|
-
middleware;
|
|
29067
|
-
constructor(configuration = DefaultConfig) {
|
|
29068
|
-
this.configuration = configuration;
|
|
29069
|
-
this.middleware = configuration.middleware;
|
|
29070
|
-
}
|
|
29071
|
-
withMiddleware(...middlewares) {
|
|
29072
|
-
const next = this.clone();
|
|
29073
|
-
next.middleware = next.middleware.concat(...middlewares);
|
|
29074
|
-
return next;
|
|
29075
|
-
}
|
|
29076
|
-
withPreMiddleware(...preMiddlewares) {
|
|
29077
|
-
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
29078
|
-
return this.withMiddleware(...middlewares);
|
|
27775
|
+
withPreMiddleware(...preMiddlewares) {
|
|
27776
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
27777
|
+
return this.withMiddleware(...middlewares);
|
|
29079
27778
|
}
|
|
29080
27779
|
withPostMiddleware(...postMiddlewares) {
|
|
29081
27780
|
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
@@ -29261,7 +27960,7 @@ class VoidApiResponse {
|
|
|
29261
27960
|
var package_default2 = {
|
|
29262
27961
|
name: "@uipath/resourcecatalog-sdk",
|
|
29263
27962
|
license: "MIT",
|
|
29264
|
-
version: "1.
|
|
27963
|
+
version: "1.197.0",
|
|
29265
27964
|
description: "SDK for the UiPath Resource Catalog Service API.",
|
|
29266
27965
|
repository: {
|
|
29267
27966
|
type: "git",
|
|
@@ -29290,7 +27989,7 @@ var package_default2 = {
|
|
|
29290
27989
|
],
|
|
29291
27990
|
private: true,
|
|
29292
27991
|
scripts: {
|
|
29293
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
|
|
27992
|
+
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
29294
27993
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
29295
27994
|
lint: "biome check ."
|
|
29296
27995
|
},
|
|
@@ -30693,6 +29392,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
|
|
|
30693
29392
|
}
|
|
30694
29393
|
return url.pathname.length > 1 ? url.origin : baseUrl;
|
|
30695
29394
|
};
|
|
29395
|
+
var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
|
|
29396
|
+
const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
|
|
29397
|
+
if (isExternalAppAuth)
|
|
29398
|
+
return requestedScopes;
|
|
29399
|
+
return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
|
|
29400
|
+
};
|
|
30696
29401
|
var resolveConfigAsync = async ({
|
|
30697
29402
|
customAuthority,
|
|
30698
29403
|
customClientId,
|
|
@@ -30723,7 +29428,7 @@ var resolveConfigAsync = async ({
|
|
|
30723
29428
|
clientSecret = fileAuth.clientSecret;
|
|
30724
29429
|
}
|
|
30725
29430
|
const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
|
|
30726
|
-
const scopes =
|
|
29431
|
+
const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
|
|
30727
29432
|
return {
|
|
30728
29433
|
clientId,
|
|
30729
29434
|
clientSecret,
|
|
@@ -30738,6 +29443,76 @@ var resolveConfigAsync = async ({
|
|
|
30738
29443
|
init_constants();
|
|
30739
29444
|
// ../../auth/src/loginStatus.ts
|
|
30740
29445
|
init_src();
|
|
29446
|
+
|
|
29447
|
+
// ../../auth/src/authProfile.ts
|
|
29448
|
+
init_src();
|
|
29449
|
+
init_constants();
|
|
29450
|
+
var DEFAULT_AUTH_PROFILE = "default";
|
|
29451
|
+
var PROFILE_DIR = "profiles";
|
|
29452
|
+
var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
29453
|
+
var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
|
|
29454
|
+
var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
|
|
29455
|
+
var globalSlot2 = globalThis;
|
|
29456
|
+
function isAuthProfileStorage(value) {
|
|
29457
|
+
return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
|
|
29458
|
+
}
|
|
29459
|
+
function createProfileStorage() {
|
|
29460
|
+
const [error, mod2] = catchError2(() => __require("node:async_hooks"));
|
|
29461
|
+
if (error || typeof mod2?.AsyncLocalStorage !== "function") {
|
|
29462
|
+
return {
|
|
29463
|
+
getStore: () => {
|
|
29464
|
+
return;
|
|
29465
|
+
},
|
|
29466
|
+
run: (_store, fn) => fn()
|
|
29467
|
+
};
|
|
29468
|
+
}
|
|
29469
|
+
return new mod2.AsyncLocalStorage;
|
|
29470
|
+
}
|
|
29471
|
+
function getProfileStorage() {
|
|
29472
|
+
const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
|
|
29473
|
+
if (isAuthProfileStorage(existing)) {
|
|
29474
|
+
return existing;
|
|
29475
|
+
}
|
|
29476
|
+
const storage = createProfileStorage();
|
|
29477
|
+
globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
|
|
29478
|
+
return storage;
|
|
29479
|
+
}
|
|
29480
|
+
var profileStorage = getProfileStorage();
|
|
29481
|
+
|
|
29482
|
+
class AuthProfileValidationError extends Error {
|
|
29483
|
+
constructor(message) {
|
|
29484
|
+
super(message);
|
|
29485
|
+
this.name = "AuthProfileValidationError";
|
|
29486
|
+
}
|
|
29487
|
+
}
|
|
29488
|
+
function normalizeAuthProfileName(profile) {
|
|
29489
|
+
if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
|
|
29490
|
+
return;
|
|
29491
|
+
}
|
|
29492
|
+
if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
|
|
29493
|
+
throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
|
|
29494
|
+
}
|
|
29495
|
+
return profile;
|
|
29496
|
+
}
|
|
29497
|
+
function getActiveAuthProfile() {
|
|
29498
|
+
const scopedState = profileStorage.getStore();
|
|
29499
|
+
if (scopedState !== undefined) {
|
|
29500
|
+
return scopedState.profile;
|
|
29501
|
+
}
|
|
29502
|
+
return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
|
|
29503
|
+
}
|
|
29504
|
+
function resolveAuthProfileFilePath(profile) {
|
|
29505
|
+
const normalized = normalizeAuthProfileName(profile);
|
|
29506
|
+
if (normalized === undefined) {
|
|
29507
|
+
throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
|
|
29508
|
+
}
|
|
29509
|
+
const fs7 = getFileSystem();
|
|
29510
|
+
return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
|
|
29511
|
+
}
|
|
29512
|
+
function getActiveAuthProfileFilePath() {
|
|
29513
|
+
const profile = getActiveAuthProfile();
|
|
29514
|
+
return profile ? resolveAuthProfileFilePath(profile) : undefined;
|
|
29515
|
+
}
|
|
30741
29516
|
// ../../auth/src/utils/jwt.ts
|
|
30742
29517
|
class InvalidIssuerError extends Error {
|
|
30743
29518
|
expected;
|
|
@@ -30866,23 +29641,74 @@ var readAuthFromEnv = () => {
|
|
|
30866
29641
|
organizationId,
|
|
30867
29642
|
tenantName,
|
|
30868
29643
|
tenantId,
|
|
30869
|
-
expiration
|
|
29644
|
+
expiration,
|
|
29645
|
+
source: "env" /* Env */
|
|
30870
29646
|
};
|
|
30871
29647
|
};
|
|
30872
29648
|
|
|
29649
|
+
// ../../auth/src/refreshCircuitBreaker.ts
|
|
29650
|
+
init_src();
|
|
29651
|
+
var BREAKER_SUFFIX = ".refresh-state";
|
|
29652
|
+
var BACKOFF_BASE_MS = 60000;
|
|
29653
|
+
var BACKOFF_CAP_MS = 60 * 60 * 1000;
|
|
29654
|
+
var SURFACE_WINDOW_MS = 60 * 60 * 1000;
|
|
29655
|
+
async function refreshTokenFingerprint(refreshToken) {
|
|
29656
|
+
const bytes = new TextEncoder().encode(refreshToken);
|
|
29657
|
+
if (globalThis.crypto?.subtle) {
|
|
29658
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
29659
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
|
|
29660
|
+
}
|
|
29661
|
+
const { createHash } = await import("node:crypto");
|
|
29662
|
+
return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
|
|
29663
|
+
}
|
|
29664
|
+
function breakerPathFor(authPath) {
|
|
29665
|
+
return `${authPath}${BREAKER_SUFFIX}`;
|
|
29666
|
+
}
|
|
29667
|
+
async function loadRefreshBreaker(authPath) {
|
|
29668
|
+
const fs7 = getFileSystem();
|
|
29669
|
+
try {
|
|
29670
|
+
const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
|
|
29671
|
+
if (!content)
|
|
29672
|
+
return {};
|
|
29673
|
+
const parsed = JSON.parse(content);
|
|
29674
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
29675
|
+
} catch {
|
|
29676
|
+
return {};
|
|
29677
|
+
}
|
|
29678
|
+
}
|
|
29679
|
+
async function saveRefreshBreaker(authPath, state) {
|
|
29680
|
+
try {
|
|
29681
|
+
const fs7 = getFileSystem();
|
|
29682
|
+
const path3 = breakerPathFor(authPath);
|
|
29683
|
+
await fs7.mkdir(fs7.path.dirname(path3));
|
|
29684
|
+
const tempPath = `${path3}.tmp`;
|
|
29685
|
+
await fs7.writeFile(tempPath, JSON.stringify(state));
|
|
29686
|
+
await fs7.rename(tempPath, path3);
|
|
29687
|
+
} catch {}
|
|
29688
|
+
}
|
|
29689
|
+
async function clearRefreshBreaker(authPath) {
|
|
29690
|
+
const fs7 = getFileSystem();
|
|
29691
|
+
const path3 = breakerPathFor(authPath);
|
|
29692
|
+
try {
|
|
29693
|
+
if (await fs7.exists(path3)) {
|
|
29694
|
+
await fs7.rm(path3);
|
|
29695
|
+
}
|
|
29696
|
+
} catch {}
|
|
29697
|
+
}
|
|
29698
|
+
function nextBackoffMs(attempts) {
|
|
29699
|
+
const shift = Math.max(0, attempts - 1);
|
|
29700
|
+
return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
|
|
29701
|
+
}
|
|
29702
|
+
function shouldSurface(state, nowMs) {
|
|
29703
|
+
if (state.lastSurfacedAtMs === undefined)
|
|
29704
|
+
return true;
|
|
29705
|
+
return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
|
|
29706
|
+
}
|
|
29707
|
+
|
|
30873
29708
|
// ../../auth/src/robotClientFallback.ts
|
|
30874
29709
|
init_src();
|
|
30875
29710
|
var DEFAULT_TIMEOUT_MS = 1000;
|
|
30876
29711
|
var CLOSE_TIMEOUT_MS = 500;
|
|
30877
|
-
var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
|
|
30878
|
-
var printNoticeOnce = () => {
|
|
30879
|
-
const slot = globalThis;
|
|
30880
|
-
if (slot[NOTICE_SENTINEL])
|
|
30881
|
-
return;
|
|
30882
|
-
slot[NOTICE_SENTINEL] = true;
|
|
30883
|
-
catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
|
|
30884
|
-
`));
|
|
30885
|
-
};
|
|
30886
29712
|
var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
|
|
30887
29713
|
var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
|
|
30888
29714
|
var PIPE_NAME_MAX_LENGTH = 103;
|
|
@@ -30998,7 +29824,6 @@ var tryRobotClientFallback = async (options = {}) => {
|
|
|
30998
29824
|
issuerFromToken = issClaim;
|
|
30999
29825
|
}
|
|
31000
29826
|
}
|
|
31001
|
-
printNoticeOnce();
|
|
31002
29827
|
return {
|
|
31003
29828
|
accessToken,
|
|
31004
29829
|
baseUrl: parsedUrl.baseUrl,
|
|
@@ -31223,18 +30048,327 @@ var saveEnvFileAsync = async ({
|
|
|
31223
30048
|
};
|
|
31224
30049
|
|
|
31225
30050
|
// ../../auth/src/loginStatus.ts
|
|
31226
|
-
|
|
31227
|
-
return
|
|
30051
|
+
var getLoginStatusAsync = async (options = {}) => {
|
|
30052
|
+
return getLoginStatusWithDeps(options);
|
|
30053
|
+
};
|
|
30054
|
+
var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
|
|
30055
|
+
const {
|
|
30056
|
+
resolveEnvFilePath = resolveEnvFilePathAsync,
|
|
30057
|
+
loadEnvFile = loadEnvFileAsync,
|
|
30058
|
+
saveEnvFile = saveEnvFileAsync,
|
|
30059
|
+
getFs = getFileSystem,
|
|
30060
|
+
refreshToken: refreshTokenFn = refreshAccessToken,
|
|
30061
|
+
resolveConfig = resolveConfigAsync,
|
|
30062
|
+
robotFallback = tryRobotClientFallback,
|
|
30063
|
+
loadBreaker = loadRefreshBreaker,
|
|
30064
|
+
saveBreaker = saveRefreshBreaker,
|
|
30065
|
+
clearBreaker = clearRefreshBreaker
|
|
30066
|
+
} = deps;
|
|
30067
|
+
if (isRobotAuthEnforced()) {
|
|
30068
|
+
return resolveRobotEnforcedStatus(robotFallback);
|
|
30069
|
+
}
|
|
30070
|
+
if (isEnvAuthEnabled()) {
|
|
30071
|
+
return readAuthFromEnv();
|
|
30072
|
+
}
|
|
30073
|
+
const activeProfile = getActiveAuthProfile();
|
|
30074
|
+
const activeProfileFilePath = getActiveAuthProfileFilePath();
|
|
30075
|
+
const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
|
|
30076
|
+
const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
|
|
30077
|
+
const { ensureTokenValidityMinutes } = options;
|
|
30078
|
+
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
30079
|
+
if (absolutePath === undefined) {
|
|
30080
|
+
if (usingActiveProfile) {
|
|
30081
|
+
return {
|
|
30082
|
+
loginStatus: "Not logged in",
|
|
30083
|
+
hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
|
|
30084
|
+
};
|
|
30085
|
+
}
|
|
30086
|
+
return resolveBorrowedRobotStatus(robotFallback);
|
|
30087
|
+
}
|
|
30088
|
+
const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
|
|
30089
|
+
if ("status" in loaded) {
|
|
30090
|
+
return loaded.status;
|
|
30091
|
+
}
|
|
30092
|
+
const { credentials } = loaded;
|
|
30093
|
+
const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
|
|
30094
|
+
const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
|
|
30095
|
+
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
30096
|
+
let tokens = {
|
|
30097
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
30098
|
+
refreshToken: credentials.UIPATH_REFRESH_TOKEN,
|
|
30099
|
+
expiration,
|
|
30100
|
+
lockReleaseFailed: false
|
|
30101
|
+
};
|
|
30102
|
+
const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
30103
|
+
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
30104
|
+
const refreshed = await attemptRefresh({
|
|
30105
|
+
absolutePath,
|
|
30106
|
+
credentials,
|
|
30107
|
+
accessToken: credentials.UIPATH_ACCESS_TOKEN,
|
|
30108
|
+
refreshToken,
|
|
30109
|
+
expiration,
|
|
30110
|
+
ensureTokenValidityMinutes,
|
|
30111
|
+
getFs,
|
|
30112
|
+
loadEnvFile,
|
|
30113
|
+
saveEnvFile,
|
|
30114
|
+
refreshFn: refreshTokenFn,
|
|
30115
|
+
resolveConfig,
|
|
30116
|
+
loadBreaker,
|
|
30117
|
+
saveBreaker,
|
|
30118
|
+
clearBreaker,
|
|
30119
|
+
globalHint
|
|
30120
|
+
});
|
|
30121
|
+
if (refreshed.kind === "terminal") {
|
|
30122
|
+
return refreshed.status;
|
|
30123
|
+
}
|
|
30124
|
+
tokens = refreshed.tokens;
|
|
30125
|
+
}
|
|
30126
|
+
return buildFileStatus(tokens, credentials, globalHint);
|
|
30127
|
+
};
|
|
30128
|
+
async function resolveRobotEnforcedStatus(robotFallback) {
|
|
30129
|
+
if (isEnvAuthEnabled()) {
|
|
30130
|
+
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
30131
|
+
}
|
|
30132
|
+
const robotCreds = await robotFallback({ force: true });
|
|
30133
|
+
if (!robotCreds) {
|
|
30134
|
+
return {
|
|
30135
|
+
loginStatus: "Not logged in",
|
|
30136
|
+
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.`
|
|
30137
|
+
};
|
|
30138
|
+
}
|
|
30139
|
+
return buildRobotStatus(robotCreds);
|
|
31228
30140
|
}
|
|
31229
|
-
function
|
|
31230
|
-
|
|
30141
|
+
async function resolveBorrowedRobotStatus(robotFallback) {
|
|
30142
|
+
const robotCreds = await robotFallback();
|
|
30143
|
+
return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
|
|
31231
30144
|
}
|
|
31232
|
-
function
|
|
31233
|
-
|
|
30145
|
+
async function loadFileCredentials(loadEnvFile, absolutePath) {
|
|
30146
|
+
let credentials;
|
|
30147
|
+
try {
|
|
30148
|
+
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
30149
|
+
} catch (error) {
|
|
30150
|
+
if (isFileNotFoundError(error)) {
|
|
30151
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
30152
|
+
}
|
|
30153
|
+
throw error;
|
|
30154
|
+
}
|
|
30155
|
+
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
30156
|
+
return { status: { loginStatus: "Not logged in" } };
|
|
30157
|
+
}
|
|
30158
|
+
return { credentials };
|
|
30159
|
+
}
|
|
30160
|
+
async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
|
|
30161
|
+
const fs7 = getFs();
|
|
30162
|
+
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
30163
|
+
if (absolutePath === globalPath)
|
|
30164
|
+
return;
|
|
30165
|
+
if (!await fs7.exists(globalPath))
|
|
30166
|
+
return;
|
|
30167
|
+
try {
|
|
30168
|
+
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
30169
|
+
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
30170
|
+
return;
|
|
30171
|
+
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
30172
|
+
if (globalExp && globalExp <= new Date)
|
|
30173
|
+
return;
|
|
30174
|
+
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.`;
|
|
30175
|
+
} catch {
|
|
30176
|
+
return;
|
|
30177
|
+
}
|
|
31234
30178
|
}
|
|
31235
30179
|
function computeExpirationThreshold(ensureTokenValidityMinutes) {
|
|
31236
30180
|
return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
|
|
31237
30181
|
}
|
|
30182
|
+
async function attemptRefresh(ctx) {
|
|
30183
|
+
const shortCircuit = await circuitBreakerShortCircuit(ctx);
|
|
30184
|
+
if (shortCircuit) {
|
|
30185
|
+
return { kind: "terminal", status: shortCircuit };
|
|
30186
|
+
}
|
|
30187
|
+
let release;
|
|
30188
|
+
try {
|
|
30189
|
+
release = await ctx.getFs().acquireLock(ctx.absolutePath);
|
|
30190
|
+
} catch (error) {
|
|
30191
|
+
return {
|
|
30192
|
+
kind: "terminal",
|
|
30193
|
+
status: await lockAcquireFailureStatus(ctx, error)
|
|
30194
|
+
};
|
|
30195
|
+
}
|
|
30196
|
+
let lockedFailure;
|
|
30197
|
+
let lockReleaseFailed = false;
|
|
30198
|
+
let success;
|
|
30199
|
+
try {
|
|
30200
|
+
const outcome = await runRefreshLocked({
|
|
30201
|
+
absolutePath: ctx.absolutePath,
|
|
30202
|
+
refreshToken: ctx.refreshToken,
|
|
30203
|
+
customAuthority: ctx.credentials.UIPATH_URL,
|
|
30204
|
+
ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
|
|
30205
|
+
loadEnvFile: ctx.loadEnvFile,
|
|
30206
|
+
saveEnvFile: ctx.saveEnvFile,
|
|
30207
|
+
refreshFn: ctx.refreshFn,
|
|
30208
|
+
resolveConfig: ctx.resolveConfig,
|
|
30209
|
+
loadBreaker: ctx.loadBreaker,
|
|
30210
|
+
saveBreaker: ctx.saveBreaker,
|
|
30211
|
+
clearBreaker: ctx.clearBreaker
|
|
30212
|
+
});
|
|
30213
|
+
if (outcome.kind === "fail") {
|
|
30214
|
+
lockedFailure = outcome.status;
|
|
30215
|
+
} else {
|
|
30216
|
+
success = outcome;
|
|
30217
|
+
}
|
|
30218
|
+
} finally {
|
|
30219
|
+
try {
|
|
30220
|
+
await release();
|
|
30221
|
+
} catch {
|
|
30222
|
+
lockReleaseFailed = true;
|
|
30223
|
+
}
|
|
30224
|
+
}
|
|
30225
|
+
if (lockedFailure) {
|
|
30226
|
+
const globalHint = await ctx.globalHint();
|
|
30227
|
+
const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
|
|
30228
|
+
return {
|
|
30229
|
+
kind: "terminal",
|
|
30230
|
+
status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
|
|
30231
|
+
};
|
|
30232
|
+
}
|
|
30233
|
+
return {
|
|
30234
|
+
kind: "refreshed",
|
|
30235
|
+
tokens: {
|
|
30236
|
+
accessToken: success?.accessToken,
|
|
30237
|
+
refreshToken: success?.refreshToken,
|
|
30238
|
+
expiration: success?.expiration,
|
|
30239
|
+
tokenRefresh: success?.tokenRefresh,
|
|
30240
|
+
persistenceWarning: success?.persistenceWarning,
|
|
30241
|
+
lockReleaseFailed
|
|
30242
|
+
}
|
|
30243
|
+
};
|
|
30244
|
+
}
|
|
30245
|
+
async function buildFileStatus(tokens, credentials, globalHint) {
|
|
30246
|
+
const result = {
|
|
30247
|
+
loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
|
|
30248
|
+
accessToken: tokens.accessToken,
|
|
30249
|
+
refreshToken: tokens.refreshToken,
|
|
30250
|
+
baseUrl: credentials.UIPATH_URL,
|
|
30251
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
30252
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
30253
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
30254
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
30255
|
+
expiration: tokens.expiration,
|
|
30256
|
+
source: "file" /* File */,
|
|
30257
|
+
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
30258
|
+
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
30259
|
+
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
30260
|
+
};
|
|
30261
|
+
if (result.loginStatus === "Expired") {
|
|
30262
|
+
const hint = await globalHint();
|
|
30263
|
+
if (hint) {
|
|
30264
|
+
result.hint = hint;
|
|
30265
|
+
}
|
|
30266
|
+
}
|
|
30267
|
+
return result;
|
|
30268
|
+
}
|
|
30269
|
+
function buildRobotStatus(robotCreds) {
|
|
30270
|
+
return {
|
|
30271
|
+
loginStatus: "Logged in",
|
|
30272
|
+
accessToken: robotCreds.accessToken,
|
|
30273
|
+
baseUrl: robotCreds.baseUrl,
|
|
30274
|
+
organizationName: robotCreds.organizationName,
|
|
30275
|
+
organizationId: robotCreds.organizationId,
|
|
30276
|
+
tenantName: robotCreds.tenantName,
|
|
30277
|
+
tenantId: robotCreds.tenantId,
|
|
30278
|
+
issuer: robotCreds.issuer,
|
|
30279
|
+
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
30280
|
+
source: "robot" /* Robot */
|
|
30281
|
+
};
|
|
30282
|
+
}
|
|
30283
|
+
var isFileNotFoundError = (error) => {
|
|
30284
|
+
if (!(error instanceof Object))
|
|
30285
|
+
return false;
|
|
30286
|
+
return error.code === "ENOENT";
|
|
30287
|
+
};
|
|
30288
|
+
async function circuitBreakerShortCircuit(ctx) {
|
|
30289
|
+
const {
|
|
30290
|
+
absolutePath,
|
|
30291
|
+
refreshToken,
|
|
30292
|
+
accessToken,
|
|
30293
|
+
credentials,
|
|
30294
|
+
expiration,
|
|
30295
|
+
loadBreaker,
|
|
30296
|
+
saveBreaker,
|
|
30297
|
+
clearBreaker
|
|
30298
|
+
} = ctx;
|
|
30299
|
+
const fingerprint = await refreshTokenFingerprint(refreshToken);
|
|
30300
|
+
const breaker = await loadBreaker(absolutePath).catch(() => ({}));
|
|
30301
|
+
if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
|
|
30302
|
+
await clearBreaker(absolutePath);
|
|
30303
|
+
breaker.deadTokenFp = undefined;
|
|
30304
|
+
}
|
|
30305
|
+
const nowMs = Date.now();
|
|
30306
|
+
const tokenIsDead = breaker.deadTokenFp === fingerprint;
|
|
30307
|
+
const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
|
|
30308
|
+
if (!tokenIsDead && !inBackoff)
|
|
30309
|
+
return;
|
|
30310
|
+
const globalHint = await ctx.globalHint();
|
|
30311
|
+
const suppressed = !shouldSurface(breaker, nowMs);
|
|
30312
|
+
if (!suppressed) {
|
|
30313
|
+
await saveBreaker(absolutePath, {
|
|
30314
|
+
...breaker,
|
|
30315
|
+
lastSurfacedAtMs: nowMs
|
|
30316
|
+
});
|
|
30317
|
+
}
|
|
30318
|
+
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>.";
|
|
30319
|
+
const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
|
|
30320
|
+
return {
|
|
30321
|
+
loginStatus: globalHint ? "Expired" : "Refresh Failed",
|
|
30322
|
+
...globalHint ? {
|
|
30323
|
+
accessToken,
|
|
30324
|
+
refreshToken,
|
|
30325
|
+
baseUrl: credentials.UIPATH_URL,
|
|
30326
|
+
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
30327
|
+
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
30328
|
+
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
30329
|
+
tenantId: credentials.UIPATH_TENANT_ID,
|
|
30330
|
+
expiration,
|
|
30331
|
+
source: "file" /* File */
|
|
30332
|
+
} : {},
|
|
30333
|
+
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
30334
|
+
refreshCircuitOpen: true,
|
|
30335
|
+
refreshTelemetrySuppressed: suppressed,
|
|
30336
|
+
tokenRefresh: { attempted: false, success: false }
|
|
30337
|
+
};
|
|
30338
|
+
}
|
|
30339
|
+
async function lockAcquireFailureStatus(ctx, error) {
|
|
30340
|
+
const msg = errorMessage(error);
|
|
30341
|
+
const globalHint = await ctx.globalHint();
|
|
30342
|
+
if (globalHint) {
|
|
30343
|
+
return {
|
|
30344
|
+
loginStatus: "Expired",
|
|
30345
|
+
accessToken: ctx.accessToken,
|
|
30346
|
+
refreshToken: ctx.refreshToken,
|
|
30347
|
+
baseUrl: ctx.credentials.UIPATH_URL,
|
|
30348
|
+
organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
|
|
30349
|
+
organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
|
|
30350
|
+
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
30351
|
+
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
30352
|
+
expiration: ctx.expiration,
|
|
30353
|
+
source: "file" /* File */,
|
|
30354
|
+
hint: globalHint,
|
|
30355
|
+
tokenRefresh: {
|
|
30356
|
+
attempted: false,
|
|
30357
|
+
success: false,
|
|
30358
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
30359
|
+
}
|
|
30360
|
+
};
|
|
30361
|
+
}
|
|
30362
|
+
return {
|
|
30363
|
+
loginStatus: "Refresh Failed",
|
|
30364
|
+
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.",
|
|
30365
|
+
tokenRefresh: {
|
|
30366
|
+
attempted: false,
|
|
30367
|
+
success: false,
|
|
30368
|
+
errorMessage: `lock acquisition failed: ${msg}`
|
|
30369
|
+
}
|
|
30370
|
+
};
|
|
30371
|
+
}
|
|
31238
30372
|
async function runRefreshLocked(inputs) {
|
|
31239
30373
|
const {
|
|
31240
30374
|
absolutePath,
|
|
@@ -31244,7 +30378,10 @@ async function runRefreshLocked(inputs) {
|
|
|
31244
30378
|
loadEnvFile,
|
|
31245
30379
|
saveEnvFile,
|
|
31246
30380
|
refreshFn,
|
|
31247
|
-
resolveConfig
|
|
30381
|
+
resolveConfig,
|
|
30382
|
+
loadBreaker,
|
|
30383
|
+
saveBreaker,
|
|
30384
|
+
clearBreaker
|
|
31248
30385
|
} = inputs;
|
|
31249
30386
|
const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
31250
30387
|
let fresh;
|
|
@@ -31267,6 +30404,7 @@ async function runRefreshLocked(inputs) {
|
|
|
31267
30404
|
const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
|
|
31268
30405
|
const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
|
|
31269
30406
|
if (freshAccess && freshExp && freshExp > expirationThreshold) {
|
|
30407
|
+
await clearBreaker(absolutePath);
|
|
31270
30408
|
return {
|
|
31271
30409
|
kind: "ok",
|
|
31272
30410
|
accessToken: freshAccess,
|
|
@@ -31290,8 +30428,21 @@ async function runRefreshLocked(inputs) {
|
|
|
31290
30428
|
refreshedRefresh = refreshed.refreshToken;
|
|
31291
30429
|
} catch (error) {
|
|
31292
30430
|
const isOAuthFailure = isTokenRefreshOAuthFailure(error);
|
|
31293
|
-
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.";
|
|
30431
|
+
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.";
|
|
31294
30432
|
const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
|
|
30433
|
+
const fp = await refreshTokenFingerprint(tokenForIdP);
|
|
30434
|
+
if (isOAuthFailure) {
|
|
30435
|
+
await saveBreaker(absolutePath, { deadTokenFp: fp });
|
|
30436
|
+
} else {
|
|
30437
|
+
const prior = await loadBreaker(absolutePath).catch(() => ({}));
|
|
30438
|
+
const attempts = (prior.attempts ?? 0) + 1;
|
|
30439
|
+
await saveBreaker(absolutePath, {
|
|
30440
|
+
...prior,
|
|
30441
|
+
deadTokenFp: undefined,
|
|
30442
|
+
attempts,
|
|
30443
|
+
backoffUntilMs: Date.now() + nextBackoffMs(attempts)
|
|
30444
|
+
});
|
|
30445
|
+
}
|
|
31295
30446
|
return {
|
|
31296
30447
|
kind: "fail",
|
|
31297
30448
|
status: {
|
|
@@ -31320,6 +30471,7 @@ async function runRefreshLocked(inputs) {
|
|
|
31320
30471
|
}
|
|
31321
30472
|
};
|
|
31322
30473
|
}
|
|
30474
|
+
await clearBreaker(absolutePath);
|
|
31323
30475
|
try {
|
|
31324
30476
|
await saveEnvFile({
|
|
31325
30477
|
envPath: absolutePath,
|
|
@@ -31352,214 +30504,25 @@ async function runRefreshLocked(inputs) {
|
|
|
31352
30504
|
};
|
|
31353
30505
|
}
|
|
31354
30506
|
}
|
|
31355
|
-
|
|
31356
|
-
|
|
31357
|
-
|
|
31358
|
-
|
|
31359
|
-
|
|
31360
|
-
|
|
31361
|
-
|
|
31362
|
-
|
|
31363
|
-
|
|
31364
|
-
} = deps;
|
|
31365
|
-
if (isRobotAuthEnforced()) {
|
|
31366
|
-
if (isEnvAuthEnabled()) {
|
|
31367
|
-
throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
|
|
31368
|
-
}
|
|
31369
|
-
const robotCreds = await robotFallback({ force: true });
|
|
31370
|
-
if (!robotCreds) {
|
|
31371
|
-
return {
|
|
31372
|
-
loginStatus: "Not logged in",
|
|
31373
|
-
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.`
|
|
31374
|
-
};
|
|
31375
|
-
}
|
|
31376
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
31377
|
-
return {
|
|
31378
|
-
loginStatus: "Logged in",
|
|
31379
|
-
accessToken: robotCreds.accessToken,
|
|
31380
|
-
baseUrl: robotCreds.baseUrl,
|
|
31381
|
-
organizationName: robotCreds.organizationName,
|
|
31382
|
-
organizationId: robotCreds.organizationId,
|
|
31383
|
-
tenantName: robotCreds.tenantName,
|
|
31384
|
-
tenantId: robotCreds.tenantId,
|
|
31385
|
-
issuer: robotCreds.issuer,
|
|
31386
|
-
expiration: expiration2,
|
|
31387
|
-
source: "robot" /* Robot */
|
|
31388
|
-
};
|
|
31389
|
-
}
|
|
31390
|
-
if (isEnvAuthEnabled()) {
|
|
31391
|
-
return readAuthFromEnv();
|
|
31392
|
-
}
|
|
31393
|
-
const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
|
|
31394
|
-
const { absolutePath } = await resolveEnvFilePath(envFilePath);
|
|
31395
|
-
if (absolutePath === undefined) {
|
|
31396
|
-
const robotCreds = await robotFallback();
|
|
31397
|
-
if (robotCreds) {
|
|
31398
|
-
const expiration2 = getTokenExpiration(robotCreds.accessToken);
|
|
31399
|
-
const status = {
|
|
31400
|
-
loginStatus: "Logged in",
|
|
31401
|
-
accessToken: robotCreds.accessToken,
|
|
31402
|
-
baseUrl: robotCreds.baseUrl,
|
|
31403
|
-
organizationName: robotCreds.organizationName,
|
|
31404
|
-
organizationId: robotCreds.organizationId,
|
|
31405
|
-
tenantName: robotCreds.tenantName,
|
|
31406
|
-
tenantId: robotCreds.tenantId,
|
|
31407
|
-
issuer: robotCreds.issuer,
|
|
31408
|
-
expiration: expiration2,
|
|
31409
|
-
source: "robot" /* Robot */
|
|
31410
|
-
};
|
|
31411
|
-
return status;
|
|
31412
|
-
}
|
|
31413
|
-
return { loginStatus: "Not logged in" };
|
|
31414
|
-
}
|
|
31415
|
-
let credentials;
|
|
31416
|
-
try {
|
|
31417
|
-
credentials = await loadEnvFile({ envPath: absolutePath });
|
|
31418
|
-
} catch (error) {
|
|
31419
|
-
if (isFileNotFoundError(error)) {
|
|
31420
|
-
return { loginStatus: "Not logged in" };
|
|
31421
|
-
}
|
|
31422
|
-
throw error;
|
|
31423
|
-
}
|
|
31424
|
-
if (!credentials.UIPATH_ACCESS_TOKEN) {
|
|
31425
|
-
return { loginStatus: "Not logged in" };
|
|
31426
|
-
}
|
|
31427
|
-
let accessToken = credentials.UIPATH_ACCESS_TOKEN;
|
|
31428
|
-
let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
|
|
31429
|
-
let expiration = getTokenExpiration(accessToken);
|
|
31430
|
-
let persistenceWarning;
|
|
31431
|
-
let lockReleaseFailed = false;
|
|
31432
|
-
let tokenRefresh;
|
|
31433
|
-
const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
|
|
31434
|
-
const tryGlobalCredsHint = async () => {
|
|
31435
|
-
const fs7 = getFs();
|
|
31436
|
-
const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
|
|
31437
|
-
if (absolutePath === globalPath)
|
|
31438
|
-
return;
|
|
31439
|
-
if (!await fs7.exists(globalPath))
|
|
31440
|
-
return;
|
|
31441
|
-
try {
|
|
31442
|
-
const globalCreds = await loadEnvFile({ envPath: globalPath });
|
|
31443
|
-
if (!globalCreds.UIPATH_ACCESS_TOKEN)
|
|
31444
|
-
return;
|
|
31445
|
-
const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
|
|
31446
|
-
if (globalExp && globalExp <= new Date)
|
|
31447
|
-
return;
|
|
31448
|
-
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.`;
|
|
31449
|
-
} catch {
|
|
31450
|
-
return;
|
|
31451
|
-
}
|
|
31452
|
-
};
|
|
31453
|
-
if (expiration && expiration <= outerThreshold && refreshToken) {
|
|
31454
|
-
let release;
|
|
31455
|
-
try {
|
|
31456
|
-
release = await getFs().acquireLock(absolutePath);
|
|
31457
|
-
} catch (error) {
|
|
31458
|
-
const msg = errorMessage(error);
|
|
31459
|
-
const globalHint = await tryGlobalCredsHint();
|
|
31460
|
-
if (globalHint) {
|
|
31461
|
-
return {
|
|
31462
|
-
loginStatus: "Expired",
|
|
31463
|
-
accessToken,
|
|
31464
|
-
refreshToken,
|
|
31465
|
-
baseUrl: credentials.UIPATH_URL,
|
|
31466
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
31467
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
31468
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
31469
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
31470
|
-
expiration,
|
|
31471
|
-
source: "file" /* File */,
|
|
31472
|
-
hint: globalHint,
|
|
31473
|
-
tokenRefresh: {
|
|
31474
|
-
attempted: false,
|
|
31475
|
-
success: false,
|
|
31476
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
31477
|
-
}
|
|
31478
|
-
};
|
|
31479
|
-
}
|
|
31480
|
-
return {
|
|
31481
|
-
loginStatus: "Refresh Failed",
|
|
31482
|
-
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.",
|
|
31483
|
-
tokenRefresh: {
|
|
31484
|
-
attempted: false,
|
|
31485
|
-
success: false,
|
|
31486
|
-
errorMessage: `lock acquisition failed: ${msg}`
|
|
31487
|
-
}
|
|
31488
|
-
};
|
|
31489
|
-
}
|
|
31490
|
-
let lockedFailure;
|
|
31491
|
-
try {
|
|
31492
|
-
const outcome = await runRefreshLocked({
|
|
31493
|
-
absolutePath,
|
|
31494
|
-
refreshToken,
|
|
31495
|
-
customAuthority: credentials.UIPATH_URL,
|
|
31496
|
-
ensureTokenValidityMinutes,
|
|
31497
|
-
loadEnvFile,
|
|
31498
|
-
saveEnvFile,
|
|
31499
|
-
refreshFn: refreshTokenFn,
|
|
31500
|
-
resolveConfig
|
|
31501
|
-
});
|
|
31502
|
-
if (outcome.kind === "fail") {
|
|
31503
|
-
lockedFailure = outcome.status;
|
|
31504
|
-
} else {
|
|
31505
|
-
accessToken = outcome.accessToken;
|
|
31506
|
-
refreshToken = outcome.refreshToken;
|
|
31507
|
-
expiration = outcome.expiration;
|
|
31508
|
-
tokenRefresh = outcome.tokenRefresh;
|
|
31509
|
-
if (outcome.persistenceWarning) {
|
|
31510
|
-
persistenceWarning = outcome.persistenceWarning;
|
|
31511
|
-
}
|
|
31512
|
-
}
|
|
31513
|
-
} finally {
|
|
31514
|
-
try {
|
|
31515
|
-
await release();
|
|
31516
|
-
} catch {
|
|
31517
|
-
lockReleaseFailed = true;
|
|
31518
|
-
}
|
|
31519
|
-
}
|
|
31520
|
-
if (lockedFailure) {
|
|
31521
|
-
const globalHint = await tryGlobalCredsHint();
|
|
31522
|
-
const base = globalHint ? {
|
|
31523
|
-
...lockedFailure,
|
|
31524
|
-
loginStatus: "Expired",
|
|
31525
|
-
hint: globalHint
|
|
31526
|
-
} : lockedFailure;
|
|
31527
|
-
return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
|
|
31528
|
-
}
|
|
31529
|
-
}
|
|
31530
|
-
const result = {
|
|
31531
|
-
loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
|
|
31532
|
-
accessToken,
|
|
31533
|
-
refreshToken,
|
|
31534
|
-
baseUrl: credentials.UIPATH_URL,
|
|
31535
|
-
organizationName: credentials.UIPATH_ORGANIZATION_NAME,
|
|
31536
|
-
organizationId: credentials.UIPATH_ORGANIZATION_ID,
|
|
31537
|
-
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
31538
|
-
tenantId: credentials.UIPATH_TENANT_ID,
|
|
31539
|
-
expiration,
|
|
31540
|
-
source: "file" /* File */,
|
|
31541
|
-
...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
|
|
31542
|
-
...lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
31543
|
-
...tokenRefresh ? { tokenRefresh } : {}
|
|
31544
|
-
};
|
|
31545
|
-
if (result.loginStatus === "Expired") {
|
|
31546
|
-
const globalHint = await tryGlobalCredsHint();
|
|
31547
|
-
if (globalHint) {
|
|
31548
|
-
result.hint = globalHint;
|
|
31549
|
-
}
|
|
31550
|
-
}
|
|
31551
|
-
return result;
|
|
31552
|
-
};
|
|
31553
|
-
var isFileNotFoundError = (error) => {
|
|
31554
|
-
if (!(error instanceof Object))
|
|
31555
|
-
return false;
|
|
31556
|
-
return error.code === "ENOENT";
|
|
31557
|
-
};
|
|
31558
|
-
var getLoginStatusAsync = async (options = {}) => {
|
|
31559
|
-
return getLoginStatusWithDeps(options);
|
|
31560
|
-
};
|
|
30507
|
+
function normalizeTokenRefreshFailure() {
|
|
30508
|
+
return "stored refresh token is invalid or expired";
|
|
30509
|
+
}
|
|
30510
|
+
function normalizeTokenRefreshUnavailableFailure() {
|
|
30511
|
+
return "token refresh failed before authentication completed";
|
|
30512
|
+
}
|
|
30513
|
+
function errorMessage(error) {
|
|
30514
|
+
return error instanceof Error ? error.message : String(error);
|
|
30515
|
+
}
|
|
31561
30516
|
// ../../auth/src/interactive.ts
|
|
31562
30517
|
init_src();
|
|
30518
|
+
|
|
30519
|
+
// ../../auth/src/selectTenant.ts
|
|
30520
|
+
var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
|
|
30521
|
+
var INVALID_TENANT_CODE = "INVALID_TENANT";
|
|
30522
|
+
var TENANT_SELECTION_CODES = new Set([
|
|
30523
|
+
TENANT_SELECTION_REQUIRED_CODE,
|
|
30524
|
+
INVALID_TENANT_CODE
|
|
30525
|
+
]);
|
|
31563
30526
|
// ../../auth/src/logout.ts
|
|
31564
30527
|
init_src();
|
|
31565
30528
|
|
|
@@ -31834,3 +30797,5 @@ var program2 = new Command;
|
|
|
31834
30797
|
program2.name(metadata.commandPrefix).description(metadata.description).version(metadata.version);
|
|
31835
30798
|
await registerCommands(program2);
|
|
31836
30799
|
program2.parse(process.argv);
|
|
30800
|
+
|
|
30801
|
+
//# debugId=911A3A3039B0B4E964756E2164756E21
|