@uipath/test-manager-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/tool.js CHANGED
@@ -13520,8 +13520,8 @@ var require_Subscription = __commonJS((exports) => {
13520
13520
  if (_parentOrParents instanceof Subscription2) {
13521
13521
  _parentOrParents.remove(this);
13522
13522
  } else if (_parentOrParents !== null) {
13523
- for (var index2 = 0;index2 < _parentOrParents.length; ++index2) {
13524
- var parent_1 = _parentOrParents[index2];
13523
+ for (var index = 0;index < _parentOrParents.length; ++index) {
13524
+ var parent_1 = _parentOrParents[index];
13525
13525
  parent_1.remove(this);
13526
13526
  }
13527
13527
  }
@@ -13536,10 +13536,10 @@ var require_Subscription = __commonJS((exports) => {
13536
13536
  }
13537
13537
  }
13538
13538
  if (isArray_1.isArray(_subscriptions)) {
13539
- var index2 = -1;
13539
+ var index = -1;
13540
13540
  var len = _subscriptions.length;
13541
- while (++index2 < len) {
13542
- var sub2 = _subscriptions[index2];
13541
+ while (++index < len) {
13542
+ var sub2 = _subscriptions[index];
13543
13543
  if (isObject_1.isObject(sub2)) {
13544
13544
  try {
13545
13545
  sub2.unsubscribe();
@@ -14969,13 +14969,13 @@ var require_AsyncAction = __commonJS((exports) => {
14969
14969
  var id = this.id;
14970
14970
  var scheduler = this.scheduler;
14971
14971
  var actions = scheduler.actions;
14972
- var index2 = actions.indexOf(this);
14972
+ var index = actions.indexOf(this);
14973
14973
  this.work = null;
14974
14974
  this.state = null;
14975
14975
  this.pending = false;
14976
14976
  this.scheduler = null;
14977
- if (index2 !== -1) {
14978
- actions.splice(index2, 1);
14977
+ if (index !== -1) {
14978
+ actions.splice(index, 1);
14979
14979
  }
14980
14980
  if (id != null) {
14981
14981
  this.id = this.recycleAsyncId(scheduler, id, null);
@@ -15819,17 +15819,17 @@ var require_AsapScheduler = __commonJS((exports) => {
15819
15819
  this.scheduled = undefined;
15820
15820
  var actions = this.actions;
15821
15821
  var error;
15822
- var index2 = -1;
15822
+ var index = -1;
15823
15823
  var count = actions.length;
15824
15824
  action = action || actions.shift();
15825
15825
  do {
15826
15826
  if (error = action.execute(action.state, action.delay)) {
15827
15827
  break;
15828
15828
  }
15829
- } while (++index2 < count && (action = actions.shift()));
15829
+ } while (++index < count && (action = actions.shift()));
15830
15830
  this.active = false;
15831
15831
  if (error) {
15832
- while (++index2 < count && (action = actions.shift())) {
15832
+ while (++index < count && (action = actions.shift())) {
15833
15833
  action.unsubscribe();
15834
15834
  }
15835
15835
  throw error;
@@ -15952,17 +15952,17 @@ var require_AnimationFrameScheduler = __commonJS((exports) => {
15952
15952
  this.scheduled = undefined;
15953
15953
  var actions = this.actions;
15954
15954
  var error;
15955
- var index2 = -1;
15955
+ var index = -1;
15956
15956
  var count = actions.length;
15957
15957
  action = action || actions.shift();
15958
15958
  do {
15959
15959
  if (error = action.execute(action.state, action.delay)) {
15960
15960
  break;
15961
15961
  }
15962
- } while (++index2 < count && (action = actions.shift()));
15962
+ } while (++index < count && (action = actions.shift()));
15963
15963
  this.active = false;
15964
15964
  if (error) {
15965
- while (++index2 < count && (action = actions.shift())) {
15965
+ while (++index < count && (action = actions.shift())) {
15966
15966
  action.unsubscribe();
15967
15967
  }
15968
15968
  throw error;
@@ -16046,16 +16046,16 @@ var require_VirtualTimeScheduler = __commonJS((exports) => {
16046
16046
  exports.VirtualTimeScheduler = VirtualTimeScheduler;
16047
16047
  var VirtualAction = function(_super) {
16048
16048
  __extends(VirtualAction2, _super);
16049
- function VirtualAction2(scheduler, work, index2) {
16050
- if (index2 === undefined) {
16051
- index2 = scheduler.index += 1;
16049
+ function VirtualAction2(scheduler, work, index) {
16050
+ if (index === undefined) {
16051
+ index = scheduler.index += 1;
16052
16052
  }
16053
16053
  var _this = _super.call(this, scheduler, work) || this;
16054
16054
  _this.scheduler = scheduler;
16055
16055
  _this.work = work;
16056
- _this.index = index2;
16056
+ _this.index = index;
16057
16057
  _this.active = true;
16058
- _this.index = scheduler.index = index2;
16058
+ _this.index = scheduler.index = index;
16059
16059
  return _this;
16060
16060
  }
16061
16061
  VirtualAction2.prototype.schedule = function(state, delay) {
@@ -17202,9 +17202,9 @@ var require_mergeMap = __commonJS((exports) => {
17202
17202
  };
17203
17203
  MergeMapSubscriber2.prototype._tryNext = function(value) {
17204
17204
  var result;
17205
- var index2 = this.index++;
17205
+ var index = this.index++;
17206
17206
  try {
17207
- result = this.project(value, index2);
17207
+ result = this.project(value, index);
17208
17208
  } catch (err) {
17209
17209
  this.destination.error(err);
17210
17210
  return;
@@ -17784,12 +17784,12 @@ var require_pairs2 = __commonJS((exports) => {
17784
17784
  }
17785
17785
  exports.pairs = pairs;
17786
17786
  function dispatch(state) {
17787
- var { keys, index: index2, subscriber, subscription, obj } = state;
17787
+ var { keys, index, subscriber, subscription, obj } = state;
17788
17788
  if (!subscriber.closed) {
17789
- if (index2 < keys.length) {
17790
- var key = keys[index2];
17789
+ if (index < keys.length) {
17790
+ var key = keys[index];
17791
17791
  subscriber.next([key, obj[key]]);
17792
- subscription.add(this.schedule({ keys, index: index2 + 1, subscriber, subscription, obj }));
17792
+ subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
17793
17793
  } else {
17794
17794
  subscriber.complete();
17795
17795
  }
@@ -18002,18 +18002,18 @@ var require_range = __commonJS((exports) => {
18002
18002
  count = start;
18003
18003
  start = 0;
18004
18004
  }
18005
- var index2 = 0;
18005
+ var index = 0;
18006
18006
  var current = start;
18007
18007
  if (scheduler) {
18008
18008
  return scheduler.schedule(dispatch, 0, {
18009
- index: index2,
18009
+ index,
18010
18010
  count,
18011
18011
  start,
18012
18012
  subscriber
18013
18013
  });
18014
18014
  } else {
18015
18015
  do {
18016
- if (index2++ >= count) {
18016
+ if (index++ >= count) {
18017
18017
  subscriber.complete();
18018
18018
  break;
18019
18019
  }
@@ -18028,8 +18028,8 @@ var require_range = __commonJS((exports) => {
18028
18028
  }
18029
18029
  exports.range = range;
18030
18030
  function dispatch(state) {
18031
- var { start, index: index2, count, subscriber } = state;
18032
- if (index2 >= count) {
18031
+ var { start, index, count, subscriber } = state;
18032
+ if (index >= count) {
18033
18033
  subscriber.complete();
18034
18034
  return;
18035
18035
  }
@@ -18037,7 +18037,7 @@ var require_range = __commonJS((exports) => {
18037
18037
  if (subscriber.closed) {
18038
18038
  return;
18039
18039
  }
18040
- state.index = index2 + 1;
18040
+ state.index = index + 1;
18041
18041
  state.start = start + 1;
18042
18042
  this.schedule(state);
18043
18043
  }
@@ -18075,14 +18075,14 @@ var require_timer = __commonJS((exports) => {
18075
18075
  }
18076
18076
  exports.timer = timer;
18077
18077
  function dispatch(state) {
18078
- var { index: index2, period, subscriber } = state;
18079
- subscriber.next(index2);
18078
+ var { index, period, subscriber } = state;
18079
+ subscriber.next(index);
18080
18080
  if (subscriber.closed) {
18081
18081
  return;
18082
18082
  } else if (period === -1) {
18083
18083
  return subscriber.complete();
18084
18084
  }
18085
- state.index = index2 + 1;
18085
+ state.index = index + 1;
18086
18086
  this.schedule(state, period);
18087
18087
  }
18088
18088
  });
@@ -21230,7 +21230,7 @@ var init_server = __esm(() => {
21230
21230
  var package_default = {
21231
21231
  name: "@uipath/test-manager-tool",
21232
21232
  license: "MIT",
21233
- version: "1.196.0",
21233
+ version: "1.197.0-preview.59",
21234
21234
  description: "Manage test cases, test sets, executions, and results.",
21235
21235
  private: false,
21236
21236
  repository: {
@@ -21322,27 +21322,54 @@ var NETWORK_ERROR_CODES = new Set([
21322
21322
  "ENETUNREACH",
21323
21323
  "EAI_FAIL"
21324
21324
  ]);
21325
- function isHtmlDocument(body) {
21326
- return /^\s*(<!doctype html|<html\b)/i.test(body);
21327
- }
21328
- function extractNetworkErrorCode(error) {
21329
- if (error === null || typeof error !== "object") {
21330
- return;
21331
- }
21332
- const err = error;
21333
- const code = typeof err.code === "string" ? err.code : undefined;
21334
- if (code && NETWORK_ERROR_CODES.has(code)) {
21335
- return code;
21336
- }
21337
- const cause = err.cause;
21338
- if (cause !== null && typeof cause === "object") {
21339
- const causeCode = cause.code;
21340
- if (typeof causeCode === "string" && NETWORK_ERROR_CODES.has(causeCode)) {
21341
- return causeCode;
21325
+ var TLS_ERROR_CODES = new Set([
21326
+ "SELF_SIGNED_CERT_IN_CHAIN",
21327
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
21328
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
21329
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
21330
+ "UNABLE_TO_GET_ISSUER_CERT",
21331
+ "CERT_HAS_EXPIRED",
21332
+ "CERT_UNTRUSTED",
21333
+ "ERR_TLS_CERT_ALTNAME_INVALID"
21334
+ ]);
21335
+ 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.";
21336
+ 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.";
21337
+ function describeConnectivityError(error) {
21338
+ let current = error;
21339
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
21340
+ const cur = current;
21341
+ const code = typeof cur.code === "string" ? cur.code : undefined;
21342
+ const message = typeof cur.message === "string" ? cur.message : undefined;
21343
+ if (code && TLS_ERROR_CODES.has(code)) {
21344
+ return {
21345
+ code,
21346
+ kind: "tls",
21347
+ message: message ?? code,
21348
+ instructions: TLS_INSTRUCTIONS
21349
+ };
21342
21350
  }
21351
+ if (code && NETWORK_ERROR_CODES.has(code)) {
21352
+ return {
21353
+ code,
21354
+ kind: "network",
21355
+ message: message ?? code,
21356
+ instructions: NETWORK_INSTRUCTIONS
21357
+ };
21358
+ }
21359
+ current = cur.cause;
21343
21360
  }
21344
21361
  return;
21345
21362
  }
21363
+ function parseHttpStatusFromMessage(message) {
21364
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
21365
+ if (!match)
21366
+ return;
21367
+ const status = Number(match[1]);
21368
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
21369
+ }
21370
+ function isHtmlDocument(body) {
21371
+ return /^\s*(<!doctype html|<html\b)/i.test(body);
21372
+ }
21346
21373
  function retryHintForRetryAfter(seconds) {
21347
21374
  if (seconds <= 1) {
21348
21375
  return "RetryAfter1Second";
@@ -21383,15 +21410,28 @@ function classifyError(status, error) {
21383
21410
  if (status !== undefined && status >= 500 && status < 600) {
21384
21411
  return { errorCode: "server_error", retry: "RetryLater" };
21385
21412
  }
21386
- if (extractNetworkErrorCode(error)) {
21387
- return { errorCode: "network_error", retry: "RetryLater" };
21413
+ const connectivity = describeConnectivityError(error);
21414
+ if (connectivity) {
21415
+ return {
21416
+ errorCode: "network_error",
21417
+ retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
21418
+ };
21388
21419
  }
21389
21420
  return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
21390
21421
  }
21422
+ function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
21423
+ if (extractedMessage) {
21424
+ return `HTTP ${status}: ${extractedMessage}`;
21425
+ }
21426
+ return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
21427
+ }
21391
21428
  async function extractErrorDetails(error, options) {
21392
21429
  const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
21393
21430
  const response = err.response;
21394
- const status = err.status ?? response?.status;
21431
+ const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
21432
+ const explicitStatus = err.status ?? response?.status;
21433
+ const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
21434
+ const status = explicitStatus ?? inferredStatus;
21395
21435
  const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
21396
21436
  let rawBody;
21397
21437
  let extractedMessage;
@@ -21426,7 +21466,6 @@ async function extractErrorDetails(error, options) {
21426
21466
  }
21427
21467
  }
21428
21468
  }
21429
- const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
21430
21469
  let message;
21431
21470
  let result = "Failure";
21432
21471
  const classification = classifyError(status, error);
@@ -21440,10 +21479,10 @@ async function extractErrorDetails(error, options) {
21440
21479
  } else if (status === 405) {
21441
21480
  message = DEFAULT_405;
21442
21481
  } else if (status === 400 || status === 422) {
21443
- message = extractedMessage ? `HTTP ${status}: ${extractedMessage}` : `HTTP ${status}: ${rawMessage}`;
21482
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
21444
21483
  result = "ValidationError";
21445
21484
  } else if (status === 429) {
21446
- message = extractedMessage ? `HTTP ${status}: ${extractedMessage}` : `HTTP ${status}: ${rawMessage}`;
21485
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
21447
21486
  } else if (extractedMessage) {
21448
21487
  if (isSuccessfulResponse && rawMessage !== "Unknown error") {
21449
21488
  message = rawMessage;
@@ -21451,7 +21490,9 @@ async function extractErrorDetails(error, options) {
21451
21490
  message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
21452
21491
  }
21453
21492
  } else if (status) {
21454
- if (rawMessage === "Unknown error" && response) {
21493
+ if (inferredStatus !== undefined) {
21494
+ message = rawMessage;
21495
+ } else if (rawMessage === "Unknown error" && response) {
21455
21496
  const statusText = response.statusText;
21456
21497
  message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
21457
21498
  } else {
@@ -21460,6 +21501,12 @@ async function extractErrorDetails(error, options) {
21460
21501
  } else {
21461
21502
  message = rawMessage;
21462
21503
  }
21504
+ if (status === undefined) {
21505
+ const connectivity = describeConnectivityError(error);
21506
+ if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
21507
+ message = `${message}: ${connectivity.message}`;
21508
+ }
21509
+ }
21463
21510
  let details = rawMessage;
21464
21511
  if (rawBody) {
21465
21512
  if (parsedBody) {
@@ -21623,6 +21670,7 @@ var CONSOLE_FALLBACK = {
21623
21670
  writeLog: (str) => process.stdout.write(str),
21624
21671
  capabilities: {
21625
21672
  isInteractive: false,
21673
+ canReadInput: false,
21626
21674
  supportsColor: false,
21627
21675
  outputWidth: 80
21628
21676
  }
@@ -26750,6 +26798,12 @@ class TelemetryService {
26750
26798
  // ../common/src/telemetry/node-appinsights-telemetry-provider.ts
26751
26799
  var providerSlot = singleton("TelemetryProvider");
26752
26800
 
26801
+ // ../common/src/telemetry/telemetry-config.ts
26802
+ function isTelemetryDisabled() {
26803
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
26804
+ return value === "1" || value === "true";
26805
+ }
26806
+
26753
26807
  // ../common/src/telemetry/telemetry-init.ts
26754
26808
  var telemetryInstanceSlot = singleton("TelemetryService");
26755
26809
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
@@ -26847,6 +26901,29 @@ function isPlainRecord(value) {
26847
26901
  const prototype = Object.getPrototypeOf(value);
26848
26902
  return prototype === Object.prototype || prototype === null;
26849
26903
  }
26904
+ function extractPagedRows(value) {
26905
+ if (Array.isArray(value) || !isPlainRecord(value))
26906
+ return null;
26907
+ const entries = Object.values(value);
26908
+ if (entries.length === 0)
26909
+ return null;
26910
+ let rows = null;
26911
+ let hasScalarSibling = false;
26912
+ for (const entry of entries) {
26913
+ if (Array.isArray(entry)) {
26914
+ if (rows !== null)
26915
+ return null;
26916
+ rows = entry;
26917
+ } else if (entry !== null && typeof entry === "object") {
26918
+ return null;
26919
+ } else {
26920
+ hasScalarSibling = true;
26921
+ }
26922
+ }
26923
+ if (rows === null || !hasScalarSibling)
26924
+ return null;
26925
+ return rows;
26926
+ }
26850
26927
  function toLowerCamelCaseKey(key) {
26851
26928
  if (!key)
26852
26929
  return key;
@@ -26911,7 +26988,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
26911
26988
  break;
26912
26989
  case "plain": {
26913
26990
  if ("Data" in data && data.Data != null) {
26914
- const items = Array.isArray(data.Data) ? data.Data : [data.Data];
26991
+ const pagedRows = extractPagedRows(data.Data);
26992
+ const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
26915
26993
  items.forEach((item) => {
26916
26994
  const values = Object.values(item).map((v) => v ?? "").join("\t");
26917
26995
  logFn(values);
@@ -26923,10 +27001,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
26923
27001
  break;
26924
27002
  }
26925
27003
  default: {
26926
- if ("Data" in data && data.Data != null && !(Array.isArray(data.Data) && data.Data.length === 0)) {
27004
+ const hasData = "Data" in data && data.Data != null;
27005
+ const pagedRows = hasData ? extractPagedRows(data.Data) : null;
27006
+ const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
27007
+ if (hasData && !(rows !== null && rows.length === 0)) {
26927
27008
  const logValue = data.Log;
26928
- if (Array.isArray(data.Data)) {
26929
- printResizableTable(data.Data, logFn, logValue);
27009
+ if (rows !== null) {
27010
+ printResizableTable(rows, logFn, logValue);
26930
27011
  } else {
26931
27012
  printVerticalTable(data.Data, logFn, logValue);
26932
27013
  }
@@ -27114,6 +27195,44 @@ function defaultErrorCodeForResult(result) {
27114
27195
  return "unknown_error";
27115
27196
  }
27116
27197
  }
27198
+ function parseHttpStatusFromMessage2(message) {
27199
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
27200
+ if (!match)
27201
+ return;
27202
+ const status = Number(match[1]);
27203
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
27204
+ }
27205
+ function defaultErrorCodeForHttpStatus(status) {
27206
+ if (status === undefined)
27207
+ return;
27208
+ if (status === 400 || status === 409 || status === 422) {
27209
+ return "invalid_argument";
27210
+ }
27211
+ if (status === 401)
27212
+ return "authentication_required";
27213
+ if (status === 403)
27214
+ return "permission_denied";
27215
+ if (status === 404)
27216
+ return "not_found";
27217
+ if (status === 405)
27218
+ return "method_not_allowed";
27219
+ if (status === 408)
27220
+ return "timeout";
27221
+ if (status === 429)
27222
+ return "rate_limited";
27223
+ if (status >= 500 && status < 600)
27224
+ return "server_error";
27225
+ return;
27226
+ }
27227
+ function defaultErrorCodeForFailure(data) {
27228
+ if (data.Result === RESULTS.Failure) {
27229
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
27230
+ const errorCode = defaultErrorCodeForHttpStatus(status);
27231
+ if (errorCode)
27232
+ return errorCode;
27233
+ }
27234
+ return defaultErrorCodeForResult(data.Result);
27235
+ }
27117
27236
  function defaultRetryForErrorCode(errorCode) {
27118
27237
  switch (errorCode) {
27119
27238
  case "network_error":
@@ -27143,16 +27262,19 @@ var OutputFormatter;
27143
27262
  OutputFormatter.success = success;
27144
27263
  function error(data) {
27145
27264
  data.Log ??= getLogFilePath() || undefined;
27146
- data.ErrorCode ??= defaultErrorCodeForResult(data.Result);
27265
+ data.ErrorCode ??= defaultErrorCodeForFailure(data);
27147
27266
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
27148
27267
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
27149
- telemetry.trackEvent(CommonTelemetryEvents.Error, {
27150
- result: data.Result,
27151
- errorCode: data.ErrorCode,
27152
- retry: data.Retry,
27153
- message: data.Message
27154
- });
27155
- logOutput(normalizeOutputKeys(data), getOutputFormat());
27268
+ const { SuppressTelemetry, ...envelope } = data;
27269
+ if (!SuppressTelemetry) {
27270
+ telemetry.trackEvent(CommonTelemetryEvents.Error, {
27271
+ result: data.Result,
27272
+ errorCode: data.ErrorCode,
27273
+ retry: data.Retry,
27274
+ message: data.Message
27275
+ });
27276
+ }
27277
+ logOutput(normalizeOutputKeys(envelope), getOutputFormat());
27156
27278
  }
27157
27279
  OutputFormatter.error = error;
27158
27280
  function emitList(code, items, opts) {
@@ -27493,1415 +27615,16 @@ function instructionsFor(ctx, err) {
27493
27615
  if (status !== undefined && status >= 500 && status < 600) {
27494
27616
  return "Orchestrator returned a server error — retry; if it persists, check service status";
27495
27617
  }
27618
+ const connectivity = describeConnectivityError(err);
27619
+ if (connectivity) {
27620
+ return connectivity.instructions;
27621
+ }
27496
27622
  return GENERIC;
27497
27623
  }
27498
27624
  }
27499
27625
  }
27500
27626
  // ../common/src/interactivity-context.ts
27501
27627
  var modeSlot = singleton("InteractivityMode");
27502
- // ../../node_modules/jsonpath-plus/dist/index-node-esm.js
27503
- import vm from "vm";
27504
-
27505
- class Hooks {
27506
- add(name, callback, first) {
27507
- if (typeof arguments[0] != "string") {
27508
- for (let name2 in arguments[0]) {
27509
- this.add(name2, arguments[0][name2], arguments[1]);
27510
- }
27511
- } else {
27512
- (Array.isArray(name) ? name : [name]).forEach(function(name2) {
27513
- this[name2] = this[name2] || [];
27514
- if (callback) {
27515
- this[name2][first ? "unshift" : "push"](callback);
27516
- }
27517
- }, this);
27518
- }
27519
- }
27520
- run(name, env) {
27521
- this[name] = this[name] || [];
27522
- this[name].forEach(function(callback) {
27523
- callback.call(env && env.context ? env.context : env, env);
27524
- });
27525
- }
27526
- }
27527
-
27528
- class Plugins {
27529
- constructor(jsep) {
27530
- this.jsep = jsep;
27531
- this.registered = {};
27532
- }
27533
- register(...plugins) {
27534
- plugins.forEach((plugin) => {
27535
- if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
27536
- throw new Error("Invalid JSEP plugin format");
27537
- }
27538
- if (this.registered[plugin.name]) {
27539
- return;
27540
- }
27541
- plugin.init(this.jsep);
27542
- this.registered[plugin.name] = plugin;
27543
- });
27544
- }
27545
- }
27546
-
27547
- class Jsep {
27548
- static get version() {
27549
- return "1.4.0";
27550
- }
27551
- static toString() {
27552
- return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
27553
- }
27554
- static addUnaryOp(op_name) {
27555
- Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
27556
- Jsep.unary_ops[op_name] = 1;
27557
- return Jsep;
27558
- }
27559
- static addBinaryOp(op_name, precedence, isRightAssociative) {
27560
- Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
27561
- Jsep.binary_ops[op_name] = precedence;
27562
- if (isRightAssociative) {
27563
- Jsep.right_associative.add(op_name);
27564
- } else {
27565
- Jsep.right_associative.delete(op_name);
27566
- }
27567
- return Jsep;
27568
- }
27569
- static addIdentifierChar(char) {
27570
- Jsep.additional_identifier_chars.add(char);
27571
- return Jsep;
27572
- }
27573
- static addLiteral(literal_name, literal_value) {
27574
- Jsep.literals[literal_name] = literal_value;
27575
- return Jsep;
27576
- }
27577
- static removeUnaryOp(op_name) {
27578
- delete Jsep.unary_ops[op_name];
27579
- if (op_name.length === Jsep.max_unop_len) {
27580
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
27581
- }
27582
- return Jsep;
27583
- }
27584
- static removeAllUnaryOps() {
27585
- Jsep.unary_ops = {};
27586
- Jsep.max_unop_len = 0;
27587
- return Jsep;
27588
- }
27589
- static removeIdentifierChar(char) {
27590
- Jsep.additional_identifier_chars.delete(char);
27591
- return Jsep;
27592
- }
27593
- static removeBinaryOp(op_name) {
27594
- delete Jsep.binary_ops[op_name];
27595
- if (op_name.length === Jsep.max_binop_len) {
27596
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
27597
- }
27598
- Jsep.right_associative.delete(op_name);
27599
- return Jsep;
27600
- }
27601
- static removeAllBinaryOps() {
27602
- Jsep.binary_ops = {};
27603
- Jsep.max_binop_len = 0;
27604
- return Jsep;
27605
- }
27606
- static removeLiteral(literal_name) {
27607
- delete Jsep.literals[literal_name];
27608
- return Jsep;
27609
- }
27610
- static removeAllLiterals() {
27611
- Jsep.literals = {};
27612
- return Jsep;
27613
- }
27614
- get char() {
27615
- return this.expr.charAt(this.index);
27616
- }
27617
- get code() {
27618
- return this.expr.charCodeAt(this.index);
27619
- }
27620
- constructor(expr) {
27621
- this.expr = expr;
27622
- this.index = 0;
27623
- }
27624
- static parse(expr) {
27625
- return new Jsep(expr).parse();
27626
- }
27627
- static getMaxKeyLen(obj) {
27628
- return Math.max(0, ...Object.keys(obj).map((k) => k.length));
27629
- }
27630
- static isDecimalDigit(ch) {
27631
- return ch >= 48 && ch <= 57;
27632
- }
27633
- static binaryPrecedence(op_val) {
27634
- return Jsep.binary_ops[op_val] || 0;
27635
- }
27636
- static isIdentifierStart(ch) {
27637
- return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
27638
- }
27639
- static isIdentifierPart(ch) {
27640
- return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
27641
- }
27642
- throwError(message) {
27643
- const error = new Error(message + " at character " + this.index);
27644
- error.index = this.index;
27645
- error.description = message;
27646
- throw error;
27647
- }
27648
- runHook(name, node) {
27649
- if (Jsep.hooks[name]) {
27650
- const env = {
27651
- context: this,
27652
- node
27653
- };
27654
- Jsep.hooks.run(name, env);
27655
- return env.node;
27656
- }
27657
- return node;
27658
- }
27659
- searchHook(name) {
27660
- if (Jsep.hooks[name]) {
27661
- const env = {
27662
- context: this
27663
- };
27664
- Jsep.hooks[name].find(function(callback) {
27665
- callback.call(env.context, env);
27666
- return env.node;
27667
- });
27668
- return env.node;
27669
- }
27670
- }
27671
- gobbleSpaces() {
27672
- let ch = this.code;
27673
- while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
27674
- ch = this.expr.charCodeAt(++this.index);
27675
- }
27676
- this.runHook("gobble-spaces");
27677
- }
27678
- parse() {
27679
- this.runHook("before-all");
27680
- const nodes = this.gobbleExpressions();
27681
- const node = nodes.length === 1 ? nodes[0] : {
27682
- type: Jsep.COMPOUND,
27683
- body: nodes
27684
- };
27685
- return this.runHook("after-all", node);
27686
- }
27687
- gobbleExpressions(untilICode) {
27688
- let nodes = [], ch_i, node;
27689
- while (this.index < this.expr.length) {
27690
- ch_i = this.code;
27691
- if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
27692
- this.index++;
27693
- } else {
27694
- if (node = this.gobbleExpression()) {
27695
- nodes.push(node);
27696
- } else if (this.index < this.expr.length) {
27697
- if (ch_i === untilICode) {
27698
- break;
27699
- }
27700
- this.throwError('Unexpected "' + this.char + '"');
27701
- }
27702
- }
27703
- }
27704
- return nodes;
27705
- }
27706
- gobbleExpression() {
27707
- const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
27708
- this.gobbleSpaces();
27709
- return this.runHook("after-expression", node);
27710
- }
27711
- gobbleBinaryOp() {
27712
- this.gobbleSpaces();
27713
- let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
27714
- let tc_len = to_check.length;
27715
- while (tc_len > 0) {
27716
- 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)))) {
27717
- this.index += tc_len;
27718
- return to_check;
27719
- }
27720
- to_check = to_check.substr(0, --tc_len);
27721
- }
27722
- return false;
27723
- }
27724
- gobbleBinaryExpression() {
27725
- let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
27726
- left = this.gobbleToken();
27727
- if (!left) {
27728
- return left;
27729
- }
27730
- biop = this.gobbleBinaryOp();
27731
- if (!biop) {
27732
- return left;
27733
- }
27734
- biop_info = {
27735
- value: biop,
27736
- prec: Jsep.binaryPrecedence(biop),
27737
- right_a: Jsep.right_associative.has(biop)
27738
- };
27739
- right = this.gobbleToken();
27740
- if (!right) {
27741
- this.throwError("Expected expression after " + biop);
27742
- }
27743
- stack = [left, biop_info, right];
27744
- while (biop = this.gobbleBinaryOp()) {
27745
- prec = Jsep.binaryPrecedence(biop);
27746
- if (prec === 0) {
27747
- this.index -= biop.length;
27748
- break;
27749
- }
27750
- biop_info = {
27751
- value: biop,
27752
- prec,
27753
- right_a: Jsep.right_associative.has(biop)
27754
- };
27755
- cur_biop = biop;
27756
- const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
27757
- while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
27758
- right = stack.pop();
27759
- biop = stack.pop().value;
27760
- left = stack.pop();
27761
- node = {
27762
- type: Jsep.BINARY_EXP,
27763
- operator: biop,
27764
- left,
27765
- right
27766
- };
27767
- stack.push(node);
27768
- }
27769
- node = this.gobbleToken();
27770
- if (!node) {
27771
- this.throwError("Expected expression after " + cur_biop);
27772
- }
27773
- stack.push(biop_info, node);
27774
- }
27775
- i = stack.length - 1;
27776
- node = stack[i];
27777
- while (i > 1) {
27778
- node = {
27779
- type: Jsep.BINARY_EXP,
27780
- operator: stack[i - 1].value,
27781
- left: stack[i - 2],
27782
- right: node
27783
- };
27784
- i -= 2;
27785
- }
27786
- return node;
27787
- }
27788
- gobbleToken() {
27789
- let ch, to_check, tc_len, node;
27790
- this.gobbleSpaces();
27791
- node = this.searchHook("gobble-token");
27792
- if (node) {
27793
- return this.runHook("after-token", node);
27794
- }
27795
- ch = this.code;
27796
- if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
27797
- return this.gobbleNumericLiteral();
27798
- }
27799
- if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
27800
- node = this.gobbleStringLiteral();
27801
- } else if (ch === Jsep.OBRACK_CODE) {
27802
- node = this.gobbleArray();
27803
- } else {
27804
- to_check = this.expr.substr(this.index, Jsep.max_unop_len);
27805
- tc_len = to_check.length;
27806
- while (tc_len > 0) {
27807
- 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)))) {
27808
- this.index += tc_len;
27809
- const argument = this.gobbleToken();
27810
- if (!argument) {
27811
- this.throwError("missing unaryOp argument");
27812
- }
27813
- return this.runHook("after-token", {
27814
- type: Jsep.UNARY_EXP,
27815
- operator: to_check,
27816
- argument,
27817
- prefix: true
27818
- });
27819
- }
27820
- to_check = to_check.substr(0, --tc_len);
27821
- }
27822
- if (Jsep.isIdentifierStart(ch)) {
27823
- node = this.gobbleIdentifier();
27824
- if (Jsep.literals.hasOwnProperty(node.name)) {
27825
- node = {
27826
- type: Jsep.LITERAL,
27827
- value: Jsep.literals[node.name],
27828
- raw: node.name
27829
- };
27830
- } else if (node.name === Jsep.this_str) {
27831
- node = {
27832
- type: Jsep.THIS_EXP
27833
- };
27834
- }
27835
- } else if (ch === Jsep.OPAREN_CODE) {
27836
- node = this.gobbleGroup();
27837
- }
27838
- }
27839
- if (!node) {
27840
- return this.runHook("after-token", false);
27841
- }
27842
- node = this.gobbleTokenProperty(node);
27843
- return this.runHook("after-token", node);
27844
- }
27845
- gobbleTokenProperty(node) {
27846
- this.gobbleSpaces();
27847
- let ch = this.code;
27848
- while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
27849
- let optional;
27850
- if (ch === Jsep.QUMARK_CODE) {
27851
- if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
27852
- break;
27853
- }
27854
- optional = true;
27855
- this.index += 2;
27856
- this.gobbleSpaces();
27857
- ch = this.code;
27858
- }
27859
- this.index++;
27860
- if (ch === Jsep.OBRACK_CODE) {
27861
- node = {
27862
- type: Jsep.MEMBER_EXP,
27863
- computed: true,
27864
- object: node,
27865
- property: this.gobbleExpression()
27866
- };
27867
- if (!node.property) {
27868
- this.throwError('Unexpected "' + this.char + '"');
27869
- }
27870
- this.gobbleSpaces();
27871
- ch = this.code;
27872
- if (ch !== Jsep.CBRACK_CODE) {
27873
- this.throwError("Unclosed [");
27874
- }
27875
- this.index++;
27876
- } else if (ch === Jsep.OPAREN_CODE) {
27877
- node = {
27878
- type: Jsep.CALL_EXP,
27879
- arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
27880
- callee: node
27881
- };
27882
- } else if (ch === Jsep.PERIOD_CODE || optional) {
27883
- if (optional) {
27884
- this.index--;
27885
- }
27886
- this.gobbleSpaces();
27887
- node = {
27888
- type: Jsep.MEMBER_EXP,
27889
- computed: false,
27890
- object: node,
27891
- property: this.gobbleIdentifier()
27892
- };
27893
- }
27894
- if (optional) {
27895
- node.optional = true;
27896
- }
27897
- this.gobbleSpaces();
27898
- ch = this.code;
27899
- }
27900
- return node;
27901
- }
27902
- gobbleNumericLiteral() {
27903
- let number = "", ch, chCode;
27904
- while (Jsep.isDecimalDigit(this.code)) {
27905
- number += this.expr.charAt(this.index++);
27906
- }
27907
- if (this.code === Jsep.PERIOD_CODE) {
27908
- number += this.expr.charAt(this.index++);
27909
- while (Jsep.isDecimalDigit(this.code)) {
27910
- number += this.expr.charAt(this.index++);
27911
- }
27912
- }
27913
- ch = this.char;
27914
- if (ch === "e" || ch === "E") {
27915
- number += this.expr.charAt(this.index++);
27916
- ch = this.char;
27917
- if (ch === "+" || ch === "-") {
27918
- number += this.expr.charAt(this.index++);
27919
- }
27920
- while (Jsep.isDecimalDigit(this.code)) {
27921
- number += this.expr.charAt(this.index++);
27922
- }
27923
- if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
27924
- this.throwError("Expected exponent (" + number + this.char + ")");
27925
- }
27926
- }
27927
- chCode = this.code;
27928
- if (Jsep.isIdentifierStart(chCode)) {
27929
- this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
27930
- } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
27931
- this.throwError("Unexpected period");
27932
- }
27933
- return {
27934
- type: Jsep.LITERAL,
27935
- value: parseFloat(number),
27936
- raw: number
27937
- };
27938
- }
27939
- gobbleStringLiteral() {
27940
- let str = "";
27941
- const startIndex = this.index;
27942
- const quote = this.expr.charAt(this.index++);
27943
- let closed = false;
27944
- while (this.index < this.expr.length) {
27945
- let ch = this.expr.charAt(this.index++);
27946
- if (ch === quote) {
27947
- closed = true;
27948
- break;
27949
- } else if (ch === "\\") {
27950
- ch = this.expr.charAt(this.index++);
27951
- switch (ch) {
27952
- case "n":
27953
- str += `
27954
- `;
27955
- break;
27956
- case "r":
27957
- str += "\r";
27958
- break;
27959
- case "t":
27960
- str += "\t";
27961
- break;
27962
- case "b":
27963
- str += "\b";
27964
- break;
27965
- case "f":
27966
- str += "\f";
27967
- break;
27968
- case "v":
27969
- str += "\v";
27970
- break;
27971
- default:
27972
- str += ch;
27973
- }
27974
- } else {
27975
- str += ch;
27976
- }
27977
- }
27978
- if (!closed) {
27979
- this.throwError('Unclosed quote after "' + str + '"');
27980
- }
27981
- return {
27982
- type: Jsep.LITERAL,
27983
- value: str,
27984
- raw: this.expr.substring(startIndex, this.index)
27985
- };
27986
- }
27987
- gobbleIdentifier() {
27988
- let ch = this.code, start = this.index;
27989
- if (Jsep.isIdentifierStart(ch)) {
27990
- this.index++;
27991
- } else {
27992
- this.throwError("Unexpected " + this.char);
27993
- }
27994
- while (this.index < this.expr.length) {
27995
- ch = this.code;
27996
- if (Jsep.isIdentifierPart(ch)) {
27997
- this.index++;
27998
- } else {
27999
- break;
28000
- }
28001
- }
28002
- return {
28003
- type: Jsep.IDENTIFIER,
28004
- name: this.expr.slice(start, this.index)
28005
- };
28006
- }
28007
- gobbleArguments(termination) {
28008
- const args = [];
28009
- let closed = false;
28010
- let separator_count = 0;
28011
- while (this.index < this.expr.length) {
28012
- this.gobbleSpaces();
28013
- let ch_i = this.code;
28014
- if (ch_i === termination) {
28015
- closed = true;
28016
- this.index++;
28017
- if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
28018
- this.throwError("Unexpected token " + String.fromCharCode(termination));
28019
- }
28020
- break;
28021
- } else if (ch_i === Jsep.COMMA_CODE) {
28022
- this.index++;
28023
- separator_count++;
28024
- if (separator_count !== args.length) {
28025
- if (termination === Jsep.CPAREN_CODE) {
28026
- this.throwError("Unexpected token ,");
28027
- } else if (termination === Jsep.CBRACK_CODE) {
28028
- for (let arg = args.length;arg < separator_count; arg++) {
28029
- args.push(null);
28030
- }
28031
- }
28032
- }
28033
- } else if (args.length !== separator_count && separator_count !== 0) {
28034
- this.throwError("Expected comma");
28035
- } else {
28036
- const node = this.gobbleExpression();
28037
- if (!node || node.type === Jsep.COMPOUND) {
28038
- this.throwError("Expected comma");
28039
- }
28040
- args.push(node);
28041
- }
28042
- }
28043
- if (!closed) {
28044
- this.throwError("Expected " + String.fromCharCode(termination));
28045
- }
28046
- return args;
28047
- }
28048
- gobbleGroup() {
28049
- this.index++;
28050
- let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
28051
- if (this.code === Jsep.CPAREN_CODE) {
28052
- this.index++;
28053
- if (nodes.length === 1) {
28054
- return nodes[0];
28055
- } else if (!nodes.length) {
28056
- return false;
28057
- } else {
28058
- return {
28059
- type: Jsep.SEQUENCE_EXP,
28060
- expressions: nodes
28061
- };
28062
- }
28063
- } else {
28064
- this.throwError("Unclosed (");
28065
- }
28066
- }
28067
- gobbleArray() {
28068
- this.index++;
28069
- return {
28070
- type: Jsep.ARRAY_EXP,
28071
- elements: this.gobbleArguments(Jsep.CBRACK_CODE)
28072
- };
28073
- }
28074
- }
28075
- var hooks = new Hooks;
28076
- Object.assign(Jsep, {
28077
- hooks,
28078
- plugins: new Plugins(Jsep),
28079
- COMPOUND: "Compound",
28080
- SEQUENCE_EXP: "SequenceExpression",
28081
- IDENTIFIER: "Identifier",
28082
- MEMBER_EXP: "MemberExpression",
28083
- LITERAL: "Literal",
28084
- THIS_EXP: "ThisExpression",
28085
- CALL_EXP: "CallExpression",
28086
- UNARY_EXP: "UnaryExpression",
28087
- BINARY_EXP: "BinaryExpression",
28088
- ARRAY_EXP: "ArrayExpression",
28089
- TAB_CODE: 9,
28090
- LF_CODE: 10,
28091
- CR_CODE: 13,
28092
- SPACE_CODE: 32,
28093
- PERIOD_CODE: 46,
28094
- COMMA_CODE: 44,
28095
- SQUOTE_CODE: 39,
28096
- DQUOTE_CODE: 34,
28097
- OPAREN_CODE: 40,
28098
- CPAREN_CODE: 41,
28099
- OBRACK_CODE: 91,
28100
- CBRACK_CODE: 93,
28101
- QUMARK_CODE: 63,
28102
- SEMCOL_CODE: 59,
28103
- COLON_CODE: 58,
28104
- unary_ops: {
28105
- "-": 1,
28106
- "!": 1,
28107
- "~": 1,
28108
- "+": 1
28109
- },
28110
- binary_ops: {
28111
- "||": 1,
28112
- "??": 1,
28113
- "&&": 2,
28114
- "|": 3,
28115
- "^": 4,
28116
- "&": 5,
28117
- "==": 6,
28118
- "!=": 6,
28119
- "===": 6,
28120
- "!==": 6,
28121
- "<": 7,
28122
- ">": 7,
28123
- "<=": 7,
28124
- ">=": 7,
28125
- "<<": 8,
28126
- ">>": 8,
28127
- ">>>": 8,
28128
- "+": 9,
28129
- "-": 9,
28130
- "*": 10,
28131
- "/": 10,
28132
- "%": 10,
28133
- "**": 11
28134
- },
28135
- right_associative: new Set(["**"]),
28136
- additional_identifier_chars: new Set(["$", "_"]),
28137
- literals: {
28138
- true: true,
28139
- false: false,
28140
- null: null
28141
- },
28142
- this_str: "this"
28143
- });
28144
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
28145
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
28146
- var jsep = (expr) => new Jsep(expr).parse();
28147
- var stdClassProps = Object.getOwnPropertyNames(class Test {
28148
- });
28149
- Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
28150
- jsep[m] = Jsep[m];
28151
- });
28152
- jsep.Jsep = Jsep;
28153
- var CONDITIONAL_EXP = "ConditionalExpression";
28154
- var ternary = {
28155
- name: "ternary",
28156
- init(jsep2) {
28157
- jsep2.hooks.add("after-expression", function gobbleTernary(env) {
28158
- if (env.node && this.code === jsep2.QUMARK_CODE) {
28159
- this.index++;
28160
- const test = env.node;
28161
- const consequent = this.gobbleExpression();
28162
- if (!consequent) {
28163
- this.throwError("Expected expression");
28164
- }
28165
- this.gobbleSpaces();
28166
- if (this.code === jsep2.COLON_CODE) {
28167
- this.index++;
28168
- const alternate = this.gobbleExpression();
28169
- if (!alternate) {
28170
- this.throwError("Expected expression");
28171
- }
28172
- env.node = {
28173
- type: CONDITIONAL_EXP,
28174
- test,
28175
- consequent,
28176
- alternate
28177
- };
28178
- if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
28179
- let newTest = test;
28180
- while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
28181
- newTest = newTest.right;
28182
- }
28183
- env.node.test = newTest.right;
28184
- newTest.right = env.node;
28185
- env.node = test;
28186
- }
28187
- } else {
28188
- this.throwError("Expected :");
28189
- }
28190
- }
28191
- });
28192
- }
28193
- };
28194
- jsep.plugins.register(ternary);
28195
- var FSLASH_CODE = 47;
28196
- var BSLASH_CODE = 92;
28197
- var index = {
28198
- name: "regex",
28199
- init(jsep2) {
28200
- jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
28201
- if (this.code === FSLASH_CODE) {
28202
- const patternIndex = ++this.index;
28203
- let inCharSet = false;
28204
- while (this.index < this.expr.length) {
28205
- if (this.code === FSLASH_CODE && !inCharSet) {
28206
- const pattern = this.expr.slice(patternIndex, this.index);
28207
- let flags = "";
28208
- while (++this.index < this.expr.length) {
28209
- const code = this.code;
28210
- if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
28211
- flags += this.char;
28212
- } else {
28213
- break;
28214
- }
28215
- }
28216
- let value;
28217
- try {
28218
- value = new RegExp(pattern, flags);
28219
- } catch (e) {
28220
- this.throwError(e.message);
28221
- }
28222
- env.node = {
28223
- type: jsep2.LITERAL,
28224
- value,
28225
- raw: this.expr.slice(patternIndex - 1, this.index)
28226
- };
28227
- env.node = this.gobbleTokenProperty(env.node);
28228
- return env.node;
28229
- }
28230
- if (this.code === jsep2.OBRACK_CODE) {
28231
- inCharSet = true;
28232
- } else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
28233
- inCharSet = false;
28234
- }
28235
- this.index += this.code === BSLASH_CODE ? 2 : 1;
28236
- }
28237
- this.throwError("Unclosed Regex");
28238
- }
28239
- });
28240
- }
28241
- };
28242
- var PLUS_CODE = 43;
28243
- var MINUS_CODE = 45;
28244
- var plugin = {
28245
- name: "assignment",
28246
- assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
28247
- updateOperators: [PLUS_CODE, MINUS_CODE],
28248
- assignmentPrecedence: 0.9,
28249
- init(jsep2) {
28250
- const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
28251
- plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
28252
- jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
28253
- const code = this.code;
28254
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
28255
- this.index += 2;
28256
- env.node = {
28257
- type: "UpdateExpression",
28258
- operator: code === PLUS_CODE ? "++" : "--",
28259
- argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
28260
- prefix: true
28261
- };
28262
- if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
28263
- this.throwError(`Unexpected ${env.node.operator}`);
28264
- }
28265
- }
28266
- });
28267
- jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
28268
- if (env.node) {
28269
- const code = this.code;
28270
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
28271
- if (!updateNodeTypes.includes(env.node.type)) {
28272
- this.throwError(`Unexpected ${env.node.operator}`);
28273
- }
28274
- this.index += 2;
28275
- env.node = {
28276
- type: "UpdateExpression",
28277
- operator: code === PLUS_CODE ? "++" : "--",
28278
- argument: env.node,
28279
- prefix: false
28280
- };
28281
- }
28282
- }
28283
- });
28284
- jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
28285
- if (env.node) {
28286
- updateBinariesToAssignments(env.node);
28287
- }
28288
- });
28289
- function updateBinariesToAssignments(node) {
28290
- if (plugin.assignmentOperators.has(node.operator)) {
28291
- node.type = "AssignmentExpression";
28292
- updateBinariesToAssignments(node.left);
28293
- updateBinariesToAssignments(node.right);
28294
- } else if (!node.operator) {
28295
- Object.values(node).forEach((val) => {
28296
- if (val && typeof val === "object") {
28297
- updateBinariesToAssignments(val);
28298
- }
28299
- });
28300
- }
28301
- }
28302
- }
28303
- };
28304
- jsep.plugins.register(index, plugin);
28305
- jsep.addUnaryOp("typeof");
28306
- jsep.addUnaryOp("void");
28307
- jsep.addLiteral("null", null);
28308
- jsep.addLiteral("undefined", undefined);
28309
- var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
28310
- var SafeEval = {
28311
- evalAst(ast, subs) {
28312
- switch (ast.type) {
28313
- case "BinaryExpression":
28314
- case "LogicalExpression":
28315
- return SafeEval.evalBinaryExpression(ast, subs);
28316
- case "Compound":
28317
- return SafeEval.evalCompound(ast, subs);
28318
- case "ConditionalExpression":
28319
- return SafeEval.evalConditionalExpression(ast, subs);
28320
- case "Identifier":
28321
- return SafeEval.evalIdentifier(ast, subs);
28322
- case "Literal":
28323
- return SafeEval.evalLiteral(ast, subs);
28324
- case "MemberExpression":
28325
- return SafeEval.evalMemberExpression(ast, subs);
28326
- case "UnaryExpression":
28327
- return SafeEval.evalUnaryExpression(ast, subs);
28328
- case "ArrayExpression":
28329
- return SafeEval.evalArrayExpression(ast, subs);
28330
- case "CallExpression":
28331
- return SafeEval.evalCallExpression(ast, subs);
28332
- case "AssignmentExpression":
28333
- return SafeEval.evalAssignmentExpression(ast, subs);
28334
- default:
28335
- throw SyntaxError("Unexpected expression", ast);
28336
- }
28337
- },
28338
- evalBinaryExpression(ast, subs) {
28339
- const result = {
28340
- "||": (a, b) => a || b(),
28341
- "&&": (a, b) => a && b(),
28342
- "|": (a, b) => a | b(),
28343
- "^": (a, b) => a ^ b(),
28344
- "&": (a, b) => a & b(),
28345
- "==": (a, b) => a == b(),
28346
- "!=": (a, b) => a != b(),
28347
- "===": (a, b) => a === b(),
28348
- "!==": (a, b) => a !== b(),
28349
- "<": (a, b) => a < b(),
28350
- ">": (a, b) => a > b(),
28351
- "<=": (a, b) => a <= b(),
28352
- ">=": (a, b) => a >= b(),
28353
- "<<": (a, b) => a << b(),
28354
- ">>": (a, b) => a >> b(),
28355
- ">>>": (a, b) => a >>> b(),
28356
- "+": (a, b) => a + b(),
28357
- "-": (a, b) => a - b(),
28358
- "*": (a, b) => a * b(),
28359
- "/": (a, b) => a / b(),
28360
- "%": (a, b) => a % b()
28361
- }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
28362
- return result;
28363
- },
28364
- evalCompound(ast, subs) {
28365
- let last;
28366
- for (let i = 0;i < ast.body.length; i++) {
28367
- if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
28368
- i += 1;
28369
- }
28370
- const expr = ast.body[i];
28371
- last = SafeEval.evalAst(expr, subs);
28372
- }
28373
- return last;
28374
- },
28375
- evalConditionalExpression(ast, subs) {
28376
- if (SafeEval.evalAst(ast.test, subs)) {
28377
- return SafeEval.evalAst(ast.consequent, subs);
28378
- }
28379
- return SafeEval.evalAst(ast.alternate, subs);
28380
- },
28381
- evalIdentifier(ast, subs) {
28382
- if (Object.hasOwn(subs, ast.name)) {
28383
- return subs[ast.name];
28384
- }
28385
- throw ReferenceError(`${ast.name} is not defined`);
28386
- },
28387
- evalLiteral(ast) {
28388
- return ast.value;
28389
- },
28390
- evalMemberExpression(ast, subs) {
28391
- const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
28392
- const obj = SafeEval.evalAst(ast.object, subs);
28393
- if (obj === undefined || obj === null) {
28394
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
28395
- }
28396
- if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
28397
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
28398
- }
28399
- const result = obj[prop];
28400
- if (typeof result === "function") {
28401
- return result.bind(obj);
28402
- }
28403
- return result;
28404
- },
28405
- evalUnaryExpression(ast, subs) {
28406
- const result = {
28407
- "-": (a) => -SafeEval.evalAst(a, subs),
28408
- "!": (a) => !SafeEval.evalAst(a, subs),
28409
- "~": (a) => ~SafeEval.evalAst(a, subs),
28410
- "+": (a) => +SafeEval.evalAst(a, subs),
28411
- typeof: (a) => typeof SafeEval.evalAst(a, subs),
28412
- void: (a) => void SafeEval.evalAst(a, subs)
28413
- }[ast.operator](ast.argument);
28414
- return result;
28415
- },
28416
- evalArrayExpression(ast, subs) {
28417
- return ast.elements.map((el) => SafeEval.evalAst(el, subs));
28418
- },
28419
- evalCallExpression(ast, subs) {
28420
- const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
28421
- const func = SafeEval.evalAst(ast.callee, subs);
28422
- if (func === Function) {
28423
- throw new Error("Function constructor is disabled");
28424
- }
28425
- return func(...args);
28426
- },
28427
- evalAssignmentExpression(ast, subs) {
28428
- if (ast.left.type !== "Identifier") {
28429
- throw SyntaxError("Invalid left-hand side in assignment");
28430
- }
28431
- const id = ast.left.name;
28432
- const value = SafeEval.evalAst(ast.right, subs);
28433
- subs[id] = value;
28434
- return subs[id];
28435
- }
28436
- };
28437
-
28438
- class SafeScript {
28439
- constructor(expr) {
28440
- this.code = expr;
28441
- this.ast = jsep(this.code);
28442
- }
28443
- runInNewContext(context) {
28444
- const keyMap = Object.assign(Object.create(null), context);
28445
- return SafeEval.evalAst(this.ast, keyMap);
28446
- }
28447
- }
28448
- function push(arr, item) {
28449
- arr = arr.slice();
28450
- arr.push(item);
28451
- return arr;
28452
- }
28453
- function unshift(item, arr) {
28454
- arr = arr.slice();
28455
- arr.unshift(item);
28456
- return arr;
28457
- }
28458
-
28459
- class NewError extends Error {
28460
- constructor(value) {
28461
- super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
28462
- this.avoidNew = true;
28463
- this.value = value;
28464
- this.name = "NewError";
28465
- }
28466
- }
28467
- function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
28468
- if (!(this instanceof JSONPath)) {
28469
- try {
28470
- return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
28471
- } catch (e) {
28472
- if (!e.avoidNew) {
28473
- throw e;
28474
- }
28475
- return e.value;
28476
- }
28477
- }
28478
- if (typeof opts === "string") {
28479
- otherTypeCallback = callback;
28480
- callback = obj;
28481
- obj = expr;
28482
- expr = opts;
28483
- opts = null;
28484
- }
28485
- const optObj = opts && typeof opts === "object";
28486
- opts = opts || {};
28487
- this.json = opts.json || obj;
28488
- this.path = opts.path || expr;
28489
- this.resultType = opts.resultType || "value";
28490
- this.flatten = opts.flatten || false;
28491
- this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
28492
- this.sandbox = opts.sandbox || {};
28493
- this.eval = opts.eval === undefined ? "safe" : opts.eval;
28494
- this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
28495
- this.parent = opts.parent || null;
28496
- this.parentProperty = opts.parentProperty || null;
28497
- this.callback = opts.callback || callback || null;
28498
- this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
28499
- throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
28500
- };
28501
- if (opts.autostart !== false) {
28502
- const args = {
28503
- path: optObj ? opts.path : expr
28504
- };
28505
- if (!optObj) {
28506
- args.json = obj;
28507
- } else if ("json" in opts) {
28508
- args.json = opts.json;
28509
- }
28510
- const ret = this.evaluate(args);
28511
- if (!ret || typeof ret !== "object") {
28512
- throw new NewError(ret);
28513
- }
28514
- return ret;
28515
- }
28516
- }
28517
- JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
28518
- let currParent = this.parent, currParentProperty = this.parentProperty;
28519
- let {
28520
- flatten,
28521
- wrap
28522
- } = this;
28523
- this.currResultType = this.resultType;
28524
- this.currEval = this.eval;
28525
- this.currSandbox = this.sandbox;
28526
- callback = callback || this.callback;
28527
- this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
28528
- json = json || this.json;
28529
- expr = expr || this.path;
28530
- if (expr && typeof expr === "object" && !Array.isArray(expr)) {
28531
- if (!expr.path && expr.path !== "") {
28532
- throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
28533
- }
28534
- if (!Object.hasOwn(expr, "json")) {
28535
- throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
28536
- }
28537
- ({
28538
- json
28539
- } = expr);
28540
- flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
28541
- this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
28542
- this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
28543
- wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
28544
- this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
28545
- callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
28546
- this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
28547
- currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
28548
- currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
28549
- expr = expr.path;
28550
- }
28551
- currParent = currParent || null;
28552
- currParentProperty = currParentProperty || null;
28553
- if (Array.isArray(expr)) {
28554
- expr = JSONPath.toPathString(expr);
28555
- }
28556
- if (!expr && expr !== "" || !json) {
28557
- return;
28558
- }
28559
- const exprList = JSONPath.toPathArray(expr);
28560
- if (exprList[0] === "$" && exprList.length > 1) {
28561
- exprList.shift();
28562
- }
28563
- this._hasParentSelector = null;
28564
- const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
28565
- return ea && !ea.isParentSelector;
28566
- });
28567
- if (!result.length) {
28568
- return wrap ? [] : undefined;
28569
- }
28570
- if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
28571
- return this._getPreferredOutput(result[0]);
28572
- }
28573
- return result.reduce((rslt, ea) => {
28574
- const valOrPath = this._getPreferredOutput(ea);
28575
- if (flatten && Array.isArray(valOrPath)) {
28576
- rslt = rslt.concat(valOrPath);
28577
- } else {
28578
- rslt.push(valOrPath);
28579
- }
28580
- return rslt;
28581
- }, []);
28582
- };
28583
- JSONPath.prototype._getPreferredOutput = function(ea) {
28584
- const resultType = this.currResultType;
28585
- switch (resultType) {
28586
- case "all": {
28587
- const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
28588
- ea.pointer = JSONPath.toPointer(path3);
28589
- ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
28590
- return ea;
28591
- }
28592
- case "value":
28593
- case "parent":
28594
- case "parentProperty":
28595
- return ea[resultType];
28596
- case "path":
28597
- return JSONPath.toPathString(ea[resultType]);
28598
- case "pointer":
28599
- return JSONPath.toPointer(ea.path);
28600
- default:
28601
- throw new TypeError("Unknown result type");
28602
- }
28603
- };
28604
- JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
28605
- if (callback) {
28606
- const preferredOutput = this._getPreferredOutput(fullRetObj);
28607
- fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
28608
- callback(preferredOutput, type, fullRetObj);
28609
- }
28610
- };
28611
- JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
28612
- let retObj;
28613
- if (!expr.length) {
28614
- retObj = {
28615
- path: path3,
28616
- value: val,
28617
- parent,
28618
- parentProperty: parentPropName,
28619
- hasArrExpr
28620
- };
28621
- this._handleCallback(retObj, callback, "value");
28622
- return retObj;
28623
- }
28624
- const loc = expr[0], x = expr.slice(1);
28625
- const ret = [];
28626
- function addRet(elems) {
28627
- if (Array.isArray(elems)) {
28628
- elems.forEach((t) => {
28629
- ret.push(t);
28630
- });
28631
- } else {
28632
- ret.push(elems);
28633
- }
28634
- }
28635
- if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
28636
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
28637
- } else if (loc === "*") {
28638
- this._walk(val, (m) => {
28639
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
28640
- });
28641
- } else if (loc === "..") {
28642
- addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
28643
- this._walk(val, (m) => {
28644
- if (typeof val[m] === "object") {
28645
- addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
28646
- }
28647
- });
28648
- } else if (loc === "^") {
28649
- this._hasParentSelector = true;
28650
- return {
28651
- path: path3.slice(0, -1),
28652
- expr: x,
28653
- isParentSelector: true
28654
- };
28655
- } else if (loc === "~") {
28656
- retObj = {
28657
- path: push(path3, loc),
28658
- value: parentPropName,
28659
- parent,
28660
- parentProperty: null
28661
- };
28662
- this._handleCallback(retObj, callback, "property");
28663
- return retObj;
28664
- } else if (loc === "$") {
28665
- addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
28666
- } else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
28667
- addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
28668
- } else if (loc.indexOf("?(") === 0) {
28669
- if (this.currEval === false) {
28670
- throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
28671
- }
28672
- const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
28673
- const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
28674
- if (nested) {
28675
- this._walk(val, (m) => {
28676
- const npath = [nested[2]];
28677
- const nvalue = nested[1] ? val[m][nested[1]] : val[m];
28678
- const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
28679
- if (filterResults.length > 0) {
28680
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
28681
- }
28682
- });
28683
- } else {
28684
- this._walk(val, (m) => {
28685
- if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
28686
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
28687
- }
28688
- });
28689
- }
28690
- } else if (loc[0] === "(") {
28691
- if (this.currEval === false) {
28692
- throw new Error("Eval [(expr)] prevented in JSONPath expression.");
28693
- }
28694
- addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
28695
- } else if (loc[0] === "@") {
28696
- let addType = false;
28697
- const valueType = loc.slice(1, -2);
28698
- switch (valueType) {
28699
- case "scalar":
28700
- if (!val || !["object", "function"].includes(typeof val)) {
28701
- addType = true;
28702
- }
28703
- break;
28704
- case "boolean":
28705
- case "string":
28706
- case "undefined":
28707
- case "function":
28708
- if (typeof val === valueType) {
28709
- addType = true;
28710
- }
28711
- break;
28712
- case "integer":
28713
- if (Number.isFinite(val) && !(val % 1)) {
28714
- addType = true;
28715
- }
28716
- break;
28717
- case "number":
28718
- if (Number.isFinite(val)) {
28719
- addType = true;
28720
- }
28721
- break;
28722
- case "nonFinite":
28723
- if (typeof val === "number" && !Number.isFinite(val)) {
28724
- addType = true;
28725
- }
28726
- break;
28727
- case "object":
28728
- if (val && typeof val === valueType) {
28729
- addType = true;
28730
- }
28731
- break;
28732
- case "array":
28733
- if (Array.isArray(val)) {
28734
- addType = true;
28735
- }
28736
- break;
28737
- case "other":
28738
- addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
28739
- break;
28740
- case "null":
28741
- if (val === null) {
28742
- addType = true;
28743
- }
28744
- break;
28745
- default:
28746
- throw new TypeError("Unknown value type " + valueType);
28747
- }
28748
- if (addType) {
28749
- retObj = {
28750
- path: path3,
28751
- value: val,
28752
- parent,
28753
- parentProperty: parentPropName
28754
- };
28755
- this._handleCallback(retObj, callback, "value");
28756
- return retObj;
28757
- }
28758
- } else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
28759
- const locProp = loc.slice(1);
28760
- addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
28761
- } else if (loc.includes(",")) {
28762
- const parts = loc.split(",");
28763
- for (const part of parts) {
28764
- addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
28765
- }
28766
- } else if (!literalPriority && val && Object.hasOwn(val, loc)) {
28767
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
28768
- }
28769
- if (this._hasParentSelector) {
28770
- for (let t = 0;t < ret.length; t++) {
28771
- const rett = ret[t];
28772
- if (rett && rett.isParentSelector) {
28773
- const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
28774
- if (Array.isArray(tmp)) {
28775
- ret[t] = tmp[0];
28776
- const tl = tmp.length;
28777
- for (let tt = 1;tt < tl; tt++) {
28778
- t++;
28779
- ret.splice(t, 0, tmp[tt]);
28780
- }
28781
- } else {
28782
- ret[t] = tmp;
28783
- }
28784
- }
28785
- }
28786
- }
28787
- return ret;
28788
- };
28789
- JSONPath.prototype._walk = function(val, f) {
28790
- if (Array.isArray(val)) {
28791
- const n = val.length;
28792
- for (let i = 0;i < n; i++) {
28793
- f(i);
28794
- }
28795
- } else if (val && typeof val === "object") {
28796
- Object.keys(val).forEach((m) => {
28797
- f(m);
28798
- });
28799
- }
28800
- };
28801
- JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
28802
- if (!Array.isArray(val)) {
28803
- return;
28804
- }
28805
- const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
28806
- let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
28807
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
28808
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
28809
- const ret = [];
28810
- for (let i = start;i < end; i += step) {
28811
- const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
28812
- tmp.forEach((t) => {
28813
- ret.push(t);
28814
- });
28815
- }
28816
- return ret;
28817
- };
28818
- JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
28819
- this.currSandbox._$_parentProperty = parentPropName;
28820
- this.currSandbox._$_parent = parent;
28821
- this.currSandbox._$_property = _vname;
28822
- this.currSandbox._$_root = this.json;
28823
- this.currSandbox._$_v = _v;
28824
- const containsPath = code.includes("@path");
28825
- if (containsPath) {
28826
- this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
28827
- }
28828
- const scriptCacheKey = this.currEval + "Script:" + code;
28829
- if (!JSONPath.cache[scriptCacheKey]) {
28830
- let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
28831
- if (containsPath) {
28832
- script = script.replaceAll("@path", "_$_path");
28833
- }
28834
- if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
28835
- JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
28836
- } else if (this.currEval === "native") {
28837
- JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
28838
- } else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
28839
- const CurrEval = this.currEval;
28840
- JSONPath.cache[scriptCacheKey] = new CurrEval(script);
28841
- } else if (typeof this.currEval === "function") {
28842
- JSONPath.cache[scriptCacheKey] = {
28843
- runInNewContext: (context) => this.currEval(script, context)
28844
- };
28845
- } else {
28846
- throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
28847
- }
28848
- }
28849
- try {
28850
- return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
28851
- } catch (e) {
28852
- if (this.ignoreEvalErrors) {
28853
- return false;
28854
- }
28855
- throw new Error("jsonPath: " + e.message + ": " + code);
28856
- }
28857
- };
28858
- JSONPath.cache = {};
28859
- JSONPath.toPathString = function(pathArr) {
28860
- const x = pathArr, n = x.length;
28861
- let p = "$";
28862
- for (let i = 1;i < n; i++) {
28863
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
28864
- p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
28865
- }
28866
- }
28867
- return p;
28868
- };
28869
- JSONPath.toPointer = function(pointer) {
28870
- const x = pointer, n = x.length;
28871
- let p = "";
28872
- for (let i = 1;i < n; i++) {
28873
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
28874
- p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
28875
- }
28876
- }
28877
- return p;
28878
- };
28879
- JSONPath.toPathArray = function(expr) {
28880
- const {
28881
- cache
28882
- } = JSONPath;
28883
- if (cache[expr]) {
28884
- return cache[expr].concat();
28885
- }
28886
- const subx = [];
28887
- const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
28888
- return "[#" + (subx.push($1) - 1) + "]";
28889
- }).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
28890
- return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
28891
- }).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
28892
- return ";" + ups.split("").join(";") + ";";
28893
- }).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
28894
- const exprList = normalized.split(";").map(function(exp) {
28895
- const match = exp.match(/#(\d+)/u);
28896
- return !match || !match[1] ? exp : subx[match[1]];
28897
- });
28898
- cache[expr] = exprList;
28899
- return cache[expr].concat();
28900
- };
28901
- JSONPath.prototype.safeVm = {
28902
- Script: SafeScript
28903
- };
28904
- JSONPath.prototype.vm = vm;
28905
27628
  // ../common/src/option-aliases.ts
28906
27629
  function resolveDeprecatedOptionAlias({
28907
27630
  preferredValue,
@@ -29384,6 +28107,17 @@ var FAILURE_STATUSES = new Set([
29384
28107
  "canceled",
29385
28108
  "stopped"
29386
28109
  ]);
28110
+ // ../common/src/preview.ts
28111
+ var previewSlot = singleton("PreviewBuild");
28112
+ function isPreviewBuild() {
28113
+ return previewSlot.get(false) ?? false;
28114
+ }
28115
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
28116
+ if (isPreviewBuild()) {
28117
+ return this.command(nameAndArgs, opts);
28118
+ }
28119
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
28120
+ };
29387
28121
  // ../common/src/screen-logger.ts
29388
28122
  var ScreenLogger;
29389
28123
  ((ScreenLogger) => {
@@ -29395,10 +28129,16 @@ var ScreenLogger;
29395
28129
  })(ScreenLogger ||= {});
29396
28130
  // ../common/src/sdk-user-agent.ts
29397
28131
  var USER_AGENT_HEADER = "User-Agent";
28132
+ var CODING_AGENT_HEADER = "x-coding-agent-info";
28133
+ var AGENT_PROPERTY = "agent";
28134
+ var CODING_AGENT_PROPERTY = "CodingAgent";
29398
28135
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
29399
28136
  function userAgentPatchKey(userAgent) {
29400
28137
  return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
29401
28138
  }
28139
+ function codingAgentPatchKey() {
28140
+ return Symbol.for("@uipath/common/sdk-coding-agent");
28141
+ }
29402
28142
  function splitUserAgentTokens(value) {
29403
28143
  return value?.trim().split(/\s+/).filter(Boolean) ?? [];
29404
28144
  }
@@ -29416,8 +28156,15 @@ function appendUserAgentToken(value, userAgent) {
29416
28156
  function getEffectiveUserAgent(userAgent) {
29417
28157
  return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
29418
28158
  }
29419
- function isHeadersLike(headers) {
29420
- return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
28159
+ function getHeaderName(headers, headerName) {
28160
+ return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
28161
+ }
28162
+ function getSdkAgentInfo() {
28163
+ if (isTelemetryDisabled()) {
28164
+ return;
28165
+ }
28166
+ const agent = getGlobalTelemetryProperties()?.[AGENT_PROPERTY];
28167
+ return agent === undefined ? undefined : String(agent);
29421
28168
  }
29422
28169
  function getSdkUserAgentToken(pkg) {
29423
28170
  const packageName = pkg.name.replace(/^@uipath\//, "");
@@ -29425,59 +28172,42 @@ function getSdkUserAgentToken(pkg) {
29425
28172
  }
29426
28173
  function addSdkUserAgentHeader(headers, userAgent) {
29427
28174
  const result = { ...headers ?? {} };
29428
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
29429
- const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
29430
- if (headerName) {
29431
- result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
29432
- } else {
29433
- result[USER_AGENT_HEADER] = effectiveUserAgent;
29434
- }
28175
+ const headerName = getHeaderName(result, USER_AGENT_HEADER);
28176
+ result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
29435
28177
  return result;
29436
28178
  }
29437
- function withSdkUserAgentHeader(headers, userAgent) {
29438
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
29439
- if (isHeadersLike(headers)) {
29440
- headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
29441
- return headers;
29442
- }
29443
- if (Array.isArray(headers)) {
29444
- const result = headers.map((entry) => {
29445
- const [key, value] = entry;
29446
- return [key, value];
29447
- });
29448
- const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
29449
- if (headerIndex >= 0) {
29450
- const [key, value] = result[headerIndex];
29451
- result[headerIndex] = [
29452
- key,
29453
- appendUserAgentToken(value, effectiveUserAgent)
29454
- ];
29455
- } else {
29456
- result.push([USER_AGENT_HEADER, effectiveUserAgent]);
29457
- }
28179
+ function addSdkCodingAgentHeader(headers, agent = getSdkAgentInfo()) {
28180
+ const result = { ...headers ?? {} };
28181
+ if (agent === undefined) {
29458
28182
  return result;
29459
28183
  }
29460
- return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
28184
+ const headerName = getHeaderName(result, CODING_AGENT_HEADER);
28185
+ result[headerName ?? CODING_AGENT_HEADER] = JSON.stringify({
28186
+ [CODING_AGENT_PROPERTY]: agent
28187
+ });
28188
+ return result;
29461
28189
  }
29462
- function withUserAgentInitOverride(initOverrides, userAgent) {
28190
+ function asHeaderRecord(headers) {
28191
+ return typeof headers === "object" && headers !== null ? { ...headers } : {};
28192
+ }
28193
+ function withForwardedHeadersInitOverride(initOverrides, forward) {
29463
28194
  return async (requestContext) => {
29464
- const initWithUserAgent = {
28195
+ const initWithHeaders = {
29465
28196
  ...requestContext.init,
29466
- headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
28197
+ headers: forward(asHeaderRecord(requestContext.init.headers))
29467
28198
  };
29468
28199
  const override = typeof initOverrides === "function" ? await initOverrides({
29469
28200
  ...requestContext,
29470
- init: initWithUserAgent
28201
+ init: initWithHeaders
29471
28202
  }) : initOverrides;
29472
28203
  return {
29473
28204
  ...override ?? {},
29474
- headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
28205
+ headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
29475
28206
  };
29476
28207
  };
29477
28208
  }
29478
- function installSdkUserAgentHeader(BaseApiClass, userAgent) {
28209
+ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
29479
28210
  const prototype = BaseApiClass.prototype;
29480
- const patchKey = userAgentPatchKey(userAgent);
29481
28211
  if (prototype[patchKey]) {
29482
28212
  return;
29483
28213
  }
@@ -29485,13 +28215,19 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
29485
28215
  throw new Error("Generated BaseAPI request function not found.");
29486
28216
  }
29487
28217
  const originalRequest = prototype.request;
29488
- prototype.request = function requestWithUserAgent(context, initOverrides) {
29489
- return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
28218
+ prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
28219
+ return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
29490
28220
  };
29491
28221
  Object.defineProperty(prototype, patchKey, {
29492
28222
  value: true
29493
28223
  });
29494
28224
  }
28225
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
28226
+ installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
28227
+ }
28228
+ function installSdkCodingAgentHeader(BaseApiClass) {
28229
+ installRequestHeaderForwarding(BaseApiClass, codingAgentPatchKey(), (headers) => addSdkCodingAgentHeader(headers));
28230
+ }
29495
28231
  // ../common/src/tool-provider.ts
29496
28232
  var factorySlot = singleton("PackagerFactoryProvider");
29497
28233
  // src/commands/attachment.ts
@@ -29788,7 +28524,7 @@ class TextApiResponse {
29788
28524
  var package_default2 = {
29789
28525
  name: "@uipath/test-manager-sdk",
29790
28526
  license: "MIT",
29791
- version: "1.196.0",
28527
+ version: "1.197.0",
29792
28528
  repository: {
29793
28529
  type: "git",
29794
28530
  url: "https://github.com/UiPath/cli.git",
@@ -29816,7 +28552,7 @@ var package_default2 = {
29816
28552
  ],
29817
28553
  private: true,
29818
28554
  scripts: {
29819
- build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
28555
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
29820
28556
  generate: "bun run src/scripts/generate-sdk.ts",
29821
28557
  lint: "biome check .",
29822
28558
  test: "vitest run",
@@ -29833,6 +28569,7 @@ var package_default2 = {
29833
28569
  // ../test-manager-sdk/src/user-agent.ts
29834
28570
  var SDK_USER_AGENT = getSdkUserAgentToken(package_default2);
29835
28571
  installSdkUserAgentHeader(BaseAPI, SDK_USER_AGENT);
28572
+ installSdkCodingAgentHeader(BaseAPI);
29836
28573
  // ../test-manager-sdk/generated/src/models/MicrosoftAspNetCoreJsonPatchOperationsOperation.ts
29837
28574
  function MicrosoftAspNetCoreJsonPatchOperationsOperationToJSON(json) {
29838
28575
  return MicrosoftAspNetCoreJsonPatchOperationsOperationToJSONTyped(json, false);
@@ -36360,6 +35097,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
36360
35097
  }
36361
35098
  return url.pathname.length > 1 ? url.origin : baseUrl;
36362
35099
  };
35100
+ var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
35101
+ const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
35102
+ if (isExternalAppAuth)
35103
+ return requestedScopes;
35104
+ return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
35105
+ };
36363
35106
  var resolveConfigAsync = async ({
36364
35107
  customAuthority,
36365
35108
  customClientId,
@@ -36390,7 +35133,7 @@ var resolveConfigAsync = async ({
36390
35133
  clientSecret = fileAuth.clientSecret;
36391
35134
  }
36392
35135
  const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
36393
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
35136
+ const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
36394
35137
  return {
36395
35138
  clientId,
36396
35139
  clientSecret,
@@ -36405,6 +35148,76 @@ var resolveConfigAsync = async ({
36405
35148
  init_constants();
36406
35149
  // ../auth/src/loginStatus.ts
36407
35150
  init_src();
35151
+
35152
+ // ../auth/src/authProfile.ts
35153
+ init_src();
35154
+ init_constants();
35155
+ var DEFAULT_AUTH_PROFILE = "default";
35156
+ var PROFILE_DIR = "profiles";
35157
+ var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
35158
+ var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
35159
+ var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
35160
+ var globalSlot2 = globalThis;
35161
+ function isAuthProfileStorage(value) {
35162
+ return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
35163
+ }
35164
+ function createProfileStorage() {
35165
+ const [error, mod2] = catchError2(() => __require("node:async_hooks"));
35166
+ if (error || typeof mod2?.AsyncLocalStorage !== "function") {
35167
+ return {
35168
+ getStore: () => {
35169
+ return;
35170
+ },
35171
+ run: (_store, fn) => fn()
35172
+ };
35173
+ }
35174
+ return new mod2.AsyncLocalStorage;
35175
+ }
35176
+ function getProfileStorage() {
35177
+ const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
35178
+ if (isAuthProfileStorage(existing)) {
35179
+ return existing;
35180
+ }
35181
+ const storage = createProfileStorage();
35182
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
35183
+ return storage;
35184
+ }
35185
+ var profileStorage = getProfileStorage();
35186
+
35187
+ class AuthProfileValidationError extends Error {
35188
+ constructor(message) {
35189
+ super(message);
35190
+ this.name = "AuthProfileValidationError";
35191
+ }
35192
+ }
35193
+ function normalizeAuthProfileName(profile) {
35194
+ if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
35195
+ return;
35196
+ }
35197
+ if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
35198
+ throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
35199
+ }
35200
+ return profile;
35201
+ }
35202
+ function getActiveAuthProfile() {
35203
+ const scopedState = profileStorage.getStore();
35204
+ if (scopedState !== undefined) {
35205
+ return scopedState.profile;
35206
+ }
35207
+ return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
35208
+ }
35209
+ function resolveAuthProfileFilePath(profile) {
35210
+ const normalized = normalizeAuthProfileName(profile);
35211
+ if (normalized === undefined) {
35212
+ throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
35213
+ }
35214
+ const fs7 = getFileSystem();
35215
+ return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
35216
+ }
35217
+ function getActiveAuthProfileFilePath() {
35218
+ const profile = getActiveAuthProfile();
35219
+ return profile ? resolveAuthProfileFilePath(profile) : undefined;
35220
+ }
36408
35221
  // ../auth/src/utils/jwt.ts
36409
35222
  class InvalidIssuerError extends Error {
36410
35223
  expected;
@@ -36533,23 +35346,74 @@ var readAuthFromEnv = () => {
36533
35346
  organizationId,
36534
35347
  tenantName,
36535
35348
  tenantId,
36536
- expiration
35349
+ expiration,
35350
+ source: "env" /* Env */
36537
35351
  };
36538
35352
  };
36539
35353
 
35354
+ // ../auth/src/refreshCircuitBreaker.ts
35355
+ init_src();
35356
+ var BREAKER_SUFFIX = ".refresh-state";
35357
+ var BACKOFF_BASE_MS = 60000;
35358
+ var BACKOFF_CAP_MS = 60 * 60 * 1000;
35359
+ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
35360
+ async function refreshTokenFingerprint(refreshToken) {
35361
+ const bytes = new TextEncoder().encode(refreshToken);
35362
+ if (globalThis.crypto?.subtle) {
35363
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
35364
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
35365
+ }
35366
+ const { createHash } = await import("node:crypto");
35367
+ return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
35368
+ }
35369
+ function breakerPathFor(authPath) {
35370
+ return `${authPath}${BREAKER_SUFFIX}`;
35371
+ }
35372
+ async function loadRefreshBreaker(authPath) {
35373
+ const fs7 = getFileSystem();
35374
+ try {
35375
+ const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
35376
+ if (!content)
35377
+ return {};
35378
+ const parsed = JSON.parse(content);
35379
+ return parsed && typeof parsed === "object" ? parsed : {};
35380
+ } catch {
35381
+ return {};
35382
+ }
35383
+ }
35384
+ async function saveRefreshBreaker(authPath, state) {
35385
+ try {
35386
+ const fs7 = getFileSystem();
35387
+ const path3 = breakerPathFor(authPath);
35388
+ await fs7.mkdir(fs7.path.dirname(path3));
35389
+ const tempPath = `${path3}.tmp`;
35390
+ await fs7.writeFile(tempPath, JSON.stringify(state));
35391
+ await fs7.rename(tempPath, path3);
35392
+ } catch {}
35393
+ }
35394
+ async function clearRefreshBreaker(authPath) {
35395
+ const fs7 = getFileSystem();
35396
+ const path3 = breakerPathFor(authPath);
35397
+ try {
35398
+ if (await fs7.exists(path3)) {
35399
+ await fs7.rm(path3);
35400
+ }
35401
+ } catch {}
35402
+ }
35403
+ function nextBackoffMs(attempts) {
35404
+ const shift = Math.max(0, attempts - 1);
35405
+ return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
35406
+ }
35407
+ function shouldSurface(state, nowMs) {
35408
+ if (state.lastSurfacedAtMs === undefined)
35409
+ return true;
35410
+ return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
35411
+ }
35412
+
36540
35413
  // ../auth/src/robotClientFallback.ts
36541
35414
  init_src();
36542
35415
  var DEFAULT_TIMEOUT_MS = 1000;
36543
35416
  var CLOSE_TIMEOUT_MS = 500;
36544
- var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
36545
- var printNoticeOnce = () => {
36546
- const slot = globalThis;
36547
- if (slot[NOTICE_SENTINEL])
36548
- return;
36549
- slot[NOTICE_SENTINEL] = true;
36550
- catchError2(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
36551
- `));
36552
- };
36553
35417
  var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
36554
35418
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
36555
35419
  var PIPE_NAME_MAX_LENGTH = 103;
@@ -36665,7 +35529,6 @@ var tryRobotClientFallback = async (options = {}) => {
36665
35529
  issuerFromToken = issClaim;
36666
35530
  }
36667
35531
  }
36668
- printNoticeOnce();
36669
35532
  return {
36670
35533
  accessToken,
36671
35534
  baseUrl: parsedUrl.baseUrl,
@@ -36890,18 +35753,327 @@ var saveEnvFileAsync = async ({
36890
35753
  };
36891
35754
 
36892
35755
  // ../auth/src/loginStatus.ts
36893
- function normalizeTokenRefreshFailure() {
36894
- return "stored refresh token is invalid or expired";
35756
+ var getLoginStatusAsync = async (options = {}) => {
35757
+ return getLoginStatusWithDeps(options);
35758
+ };
35759
+ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
35760
+ const {
35761
+ resolveEnvFilePath = resolveEnvFilePathAsync,
35762
+ loadEnvFile = loadEnvFileAsync,
35763
+ saveEnvFile = saveEnvFileAsync,
35764
+ getFs = getFileSystem,
35765
+ refreshToken: refreshTokenFn = refreshAccessToken,
35766
+ resolveConfig: resolveConfig2 = resolveConfigAsync,
35767
+ robotFallback = tryRobotClientFallback,
35768
+ loadBreaker = loadRefreshBreaker,
35769
+ saveBreaker = saveRefreshBreaker,
35770
+ clearBreaker = clearRefreshBreaker
35771
+ } = deps;
35772
+ if (isRobotAuthEnforced()) {
35773
+ return resolveRobotEnforcedStatus(robotFallback);
35774
+ }
35775
+ if (isEnvAuthEnabled()) {
35776
+ return readAuthFromEnv();
35777
+ }
35778
+ const activeProfile = getActiveAuthProfile();
35779
+ const activeProfileFilePath = getActiveAuthProfileFilePath();
35780
+ const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
35781
+ const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
35782
+ const { ensureTokenValidityMinutes } = options;
35783
+ const { absolutePath } = await resolveEnvFilePath(envFilePath);
35784
+ if (absolutePath === undefined) {
35785
+ if (usingActiveProfile) {
35786
+ return {
35787
+ loginStatus: "Not logged in",
35788
+ hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
35789
+ };
35790
+ }
35791
+ return resolveBorrowedRobotStatus(robotFallback);
35792
+ }
35793
+ const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
35794
+ if ("status" in loaded) {
35795
+ return loaded.status;
35796
+ }
35797
+ const { credentials } = loaded;
35798
+ const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
35799
+ const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
35800
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
35801
+ let tokens = {
35802
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
35803
+ refreshToken: credentials.UIPATH_REFRESH_TOKEN,
35804
+ expiration,
35805
+ lockReleaseFailed: false
35806
+ };
35807
+ const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
35808
+ if (expiration && expiration <= outerThreshold && refreshToken) {
35809
+ const refreshed = await attemptRefresh({
35810
+ absolutePath,
35811
+ credentials,
35812
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
35813
+ refreshToken,
35814
+ expiration,
35815
+ ensureTokenValidityMinutes,
35816
+ getFs,
35817
+ loadEnvFile,
35818
+ saveEnvFile,
35819
+ refreshFn: refreshTokenFn,
35820
+ resolveConfig: resolveConfig2,
35821
+ loadBreaker,
35822
+ saveBreaker,
35823
+ clearBreaker,
35824
+ globalHint
35825
+ });
35826
+ if (refreshed.kind === "terminal") {
35827
+ return refreshed.status;
35828
+ }
35829
+ tokens = refreshed.tokens;
35830
+ }
35831
+ return buildFileStatus(tokens, credentials, globalHint);
35832
+ };
35833
+ async function resolveRobotEnforcedStatus(robotFallback) {
35834
+ if (isEnvAuthEnabled()) {
35835
+ throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
35836
+ }
35837
+ const robotCreds = await robotFallback({ force: true });
35838
+ if (!robotCreds) {
35839
+ return {
35840
+ loginStatus: "Not logged in",
35841
+ 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.`
35842
+ };
35843
+ }
35844
+ return buildRobotStatus(robotCreds);
36895
35845
  }
36896
- function normalizeTokenRefreshUnavailableFailure() {
36897
- return "token refresh failed before authentication completed";
35846
+ async function resolveBorrowedRobotStatus(robotFallback) {
35847
+ const robotCreds = await robotFallback();
35848
+ return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
36898
35849
  }
36899
- function errorMessage(error) {
36900
- return error instanceof Error ? error.message : String(error);
35850
+ async function loadFileCredentials(loadEnvFile, absolutePath) {
35851
+ let credentials;
35852
+ try {
35853
+ credentials = await loadEnvFile({ envPath: absolutePath });
35854
+ } catch (error) {
35855
+ if (isFileNotFoundError(error)) {
35856
+ return { status: { loginStatus: "Not logged in" } };
35857
+ }
35858
+ throw error;
35859
+ }
35860
+ if (!credentials.UIPATH_ACCESS_TOKEN) {
35861
+ return { status: { loginStatus: "Not logged in" } };
35862
+ }
35863
+ return { credentials };
35864
+ }
35865
+ async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
35866
+ const fs7 = getFs();
35867
+ const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
35868
+ if (absolutePath === globalPath)
35869
+ return;
35870
+ if (!await fs7.exists(globalPath))
35871
+ return;
35872
+ try {
35873
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
35874
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
35875
+ return;
35876
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
35877
+ if (globalExp && globalExp <= new Date)
35878
+ return;
35879
+ 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.`;
35880
+ } catch {
35881
+ return;
35882
+ }
36901
35883
  }
36902
35884
  function computeExpirationThreshold(ensureTokenValidityMinutes) {
36903
35885
  return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
36904
35886
  }
35887
+ async function attemptRefresh(ctx) {
35888
+ const shortCircuit = await circuitBreakerShortCircuit(ctx);
35889
+ if (shortCircuit) {
35890
+ return { kind: "terminal", status: shortCircuit };
35891
+ }
35892
+ let release;
35893
+ try {
35894
+ release = await ctx.getFs().acquireLock(ctx.absolutePath);
35895
+ } catch (error) {
35896
+ return {
35897
+ kind: "terminal",
35898
+ status: await lockAcquireFailureStatus(ctx, error)
35899
+ };
35900
+ }
35901
+ let lockedFailure;
35902
+ let lockReleaseFailed = false;
35903
+ let success;
35904
+ try {
35905
+ const outcome = await runRefreshLocked({
35906
+ absolutePath: ctx.absolutePath,
35907
+ refreshToken: ctx.refreshToken,
35908
+ customAuthority: ctx.credentials.UIPATH_URL,
35909
+ ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
35910
+ loadEnvFile: ctx.loadEnvFile,
35911
+ saveEnvFile: ctx.saveEnvFile,
35912
+ refreshFn: ctx.refreshFn,
35913
+ resolveConfig: ctx.resolveConfig,
35914
+ loadBreaker: ctx.loadBreaker,
35915
+ saveBreaker: ctx.saveBreaker,
35916
+ clearBreaker: ctx.clearBreaker
35917
+ });
35918
+ if (outcome.kind === "fail") {
35919
+ lockedFailure = outcome.status;
35920
+ } else {
35921
+ success = outcome;
35922
+ }
35923
+ } finally {
35924
+ try {
35925
+ await release();
35926
+ } catch {
35927
+ lockReleaseFailed = true;
35928
+ }
35929
+ }
35930
+ if (lockedFailure) {
35931
+ const globalHint = await ctx.globalHint();
35932
+ const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
35933
+ return {
35934
+ kind: "terminal",
35935
+ status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
35936
+ };
35937
+ }
35938
+ return {
35939
+ kind: "refreshed",
35940
+ tokens: {
35941
+ accessToken: success?.accessToken,
35942
+ refreshToken: success?.refreshToken,
35943
+ expiration: success?.expiration,
35944
+ tokenRefresh: success?.tokenRefresh,
35945
+ persistenceWarning: success?.persistenceWarning,
35946
+ lockReleaseFailed
35947
+ }
35948
+ };
35949
+ }
35950
+ async function buildFileStatus(tokens, credentials, globalHint) {
35951
+ const result = {
35952
+ loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
35953
+ accessToken: tokens.accessToken,
35954
+ refreshToken: tokens.refreshToken,
35955
+ baseUrl: credentials.UIPATH_URL,
35956
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
35957
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
35958
+ tenantName: credentials.UIPATH_TENANT_NAME,
35959
+ tenantId: credentials.UIPATH_TENANT_ID,
35960
+ expiration: tokens.expiration,
35961
+ source: "file" /* File */,
35962
+ ...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
35963
+ ...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
35964
+ ...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
35965
+ };
35966
+ if (result.loginStatus === "Expired") {
35967
+ const hint = await globalHint();
35968
+ if (hint) {
35969
+ result.hint = hint;
35970
+ }
35971
+ }
35972
+ return result;
35973
+ }
35974
+ function buildRobotStatus(robotCreds) {
35975
+ return {
35976
+ loginStatus: "Logged in",
35977
+ accessToken: robotCreds.accessToken,
35978
+ baseUrl: robotCreds.baseUrl,
35979
+ organizationName: robotCreds.organizationName,
35980
+ organizationId: robotCreds.organizationId,
35981
+ tenantName: robotCreds.tenantName,
35982
+ tenantId: robotCreds.tenantId,
35983
+ issuer: robotCreds.issuer,
35984
+ expiration: getTokenExpiration(robotCreds.accessToken),
35985
+ source: "robot" /* Robot */
35986
+ };
35987
+ }
35988
+ var isFileNotFoundError = (error) => {
35989
+ if (!(error instanceof Object))
35990
+ return false;
35991
+ return error.code === "ENOENT";
35992
+ };
35993
+ async function circuitBreakerShortCircuit(ctx) {
35994
+ const {
35995
+ absolutePath,
35996
+ refreshToken,
35997
+ accessToken,
35998
+ credentials,
35999
+ expiration,
36000
+ loadBreaker,
36001
+ saveBreaker,
36002
+ clearBreaker
36003
+ } = ctx;
36004
+ const fingerprint = await refreshTokenFingerprint(refreshToken);
36005
+ const breaker = await loadBreaker(absolutePath).catch(() => ({}));
36006
+ if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
36007
+ await clearBreaker(absolutePath);
36008
+ breaker.deadTokenFp = undefined;
36009
+ }
36010
+ const nowMs = Date.now();
36011
+ const tokenIsDead = breaker.deadTokenFp === fingerprint;
36012
+ const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
36013
+ if (!tokenIsDead && !inBackoff)
36014
+ return;
36015
+ const globalHint = await ctx.globalHint();
36016
+ const suppressed = !shouldSurface(breaker, nowMs);
36017
+ if (!suppressed) {
36018
+ await saveBreaker(absolutePath, {
36019
+ ...breaker,
36020
+ lastSurfacedAtMs: nowMs
36021
+ });
36022
+ }
36023
+ 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>.";
36024
+ const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
36025
+ return {
36026
+ loginStatus: globalHint ? "Expired" : "Refresh Failed",
36027
+ ...globalHint ? {
36028
+ accessToken,
36029
+ refreshToken,
36030
+ baseUrl: credentials.UIPATH_URL,
36031
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
36032
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
36033
+ tenantName: credentials.UIPATH_TENANT_NAME,
36034
+ tenantId: credentials.UIPATH_TENANT_ID,
36035
+ expiration,
36036
+ source: "file" /* File */
36037
+ } : {},
36038
+ hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
36039
+ refreshCircuitOpen: true,
36040
+ refreshTelemetrySuppressed: suppressed,
36041
+ tokenRefresh: { attempted: false, success: false }
36042
+ };
36043
+ }
36044
+ async function lockAcquireFailureStatus(ctx, error) {
36045
+ const msg = errorMessage(error);
36046
+ const globalHint = await ctx.globalHint();
36047
+ if (globalHint) {
36048
+ return {
36049
+ loginStatus: "Expired",
36050
+ accessToken: ctx.accessToken,
36051
+ refreshToken: ctx.refreshToken,
36052
+ baseUrl: ctx.credentials.UIPATH_URL,
36053
+ organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
36054
+ organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
36055
+ tenantName: ctx.credentials.UIPATH_TENANT_NAME,
36056
+ tenantId: ctx.credentials.UIPATH_TENANT_ID,
36057
+ expiration: ctx.expiration,
36058
+ source: "file" /* File */,
36059
+ hint: globalHint,
36060
+ tokenRefresh: {
36061
+ attempted: false,
36062
+ success: false,
36063
+ errorMessage: `lock acquisition failed: ${msg}`
36064
+ }
36065
+ };
36066
+ }
36067
+ return {
36068
+ loginStatus: "Refresh Failed",
36069
+ 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.",
36070
+ tokenRefresh: {
36071
+ attempted: false,
36072
+ success: false,
36073
+ errorMessage: `lock acquisition failed: ${msg}`
36074
+ }
36075
+ };
36076
+ }
36905
36077
  async function runRefreshLocked(inputs) {
36906
36078
  const {
36907
36079
  absolutePath,
@@ -36911,7 +36083,10 @@ async function runRefreshLocked(inputs) {
36911
36083
  loadEnvFile,
36912
36084
  saveEnvFile,
36913
36085
  refreshFn,
36914
- resolveConfig: resolveConfig2
36086
+ resolveConfig: resolveConfig2,
36087
+ loadBreaker,
36088
+ saveBreaker,
36089
+ clearBreaker
36915
36090
  } = inputs;
36916
36091
  const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
36917
36092
  let fresh;
@@ -36934,6 +36109,7 @@ async function runRefreshLocked(inputs) {
36934
36109
  const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
36935
36110
  const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
36936
36111
  if (freshAccess && freshExp && freshExp > expirationThreshold) {
36112
+ await clearBreaker(absolutePath);
36937
36113
  return {
36938
36114
  kind: "ok",
36939
36115
  accessToken: freshAccess,
@@ -36957,8 +36133,21 @@ async function runRefreshLocked(inputs) {
36957
36133
  refreshedRefresh = refreshed.refreshToken;
36958
36134
  } catch (error) {
36959
36135
  const isOAuthFailure = isTokenRefreshOAuthFailure(error);
36960
- 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.";
36136
+ 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.";
36961
36137
  const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
36138
+ const fp = await refreshTokenFingerprint(tokenForIdP);
36139
+ if (isOAuthFailure) {
36140
+ await saveBreaker(absolutePath, { deadTokenFp: fp });
36141
+ } else {
36142
+ const prior = await loadBreaker(absolutePath).catch(() => ({}));
36143
+ const attempts = (prior.attempts ?? 0) + 1;
36144
+ await saveBreaker(absolutePath, {
36145
+ ...prior,
36146
+ deadTokenFp: undefined,
36147
+ attempts,
36148
+ backoffUntilMs: Date.now() + nextBackoffMs(attempts)
36149
+ });
36150
+ }
36962
36151
  return {
36963
36152
  kind: "fail",
36964
36153
  status: {
@@ -36987,6 +36176,7 @@ async function runRefreshLocked(inputs) {
36987
36176
  }
36988
36177
  };
36989
36178
  }
36179
+ await clearBreaker(absolutePath);
36990
36180
  try {
36991
36181
  await saveEnvFile({
36992
36182
  envPath: absolutePath,
@@ -37019,212 +36209,15 @@ async function runRefreshLocked(inputs) {
37019
36209
  };
37020
36210
  }
37021
36211
  }
37022
- var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
37023
- const {
37024
- resolveEnvFilePath = resolveEnvFilePathAsync,
37025
- loadEnvFile = loadEnvFileAsync,
37026
- saveEnvFile = saveEnvFileAsync,
37027
- getFs = getFileSystem,
37028
- refreshToken: refreshTokenFn = refreshAccessToken,
37029
- resolveConfig: resolveConfig2 = resolveConfigAsync,
37030
- robotFallback = tryRobotClientFallback
37031
- } = deps;
37032
- if (isRobotAuthEnforced()) {
37033
- if (isEnvAuthEnabled()) {
37034
- throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
37035
- }
37036
- const robotCreds = await robotFallback({ force: true });
37037
- if (!robotCreds) {
37038
- return {
37039
- loginStatus: "Not logged in",
37040
- 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.`
37041
- };
37042
- }
37043
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
37044
- return {
37045
- loginStatus: "Logged in",
37046
- accessToken: robotCreds.accessToken,
37047
- baseUrl: robotCreds.baseUrl,
37048
- organizationName: robotCreds.organizationName,
37049
- organizationId: robotCreds.organizationId,
37050
- tenantName: robotCreds.tenantName,
37051
- tenantId: robotCreds.tenantId,
37052
- issuer: robotCreds.issuer,
37053
- expiration: expiration2,
37054
- source: "robot" /* Robot */
37055
- };
37056
- }
37057
- if (isEnvAuthEnabled()) {
37058
- return readAuthFromEnv();
37059
- }
37060
- const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
37061
- const { absolutePath } = await resolveEnvFilePath(envFilePath);
37062
- if (absolutePath === undefined) {
37063
- const robotCreds = await robotFallback();
37064
- if (robotCreds) {
37065
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
37066
- const status = {
37067
- loginStatus: "Logged in",
37068
- accessToken: robotCreds.accessToken,
37069
- baseUrl: robotCreds.baseUrl,
37070
- organizationName: robotCreds.organizationName,
37071
- organizationId: robotCreds.organizationId,
37072
- tenantName: robotCreds.tenantName,
37073
- tenantId: robotCreds.tenantId,
37074
- issuer: robotCreds.issuer,
37075
- expiration: expiration2,
37076
- source: "robot" /* Robot */
37077
- };
37078
- return status;
37079
- }
37080
- return { loginStatus: "Not logged in" };
37081
- }
37082
- let credentials;
37083
- try {
37084
- credentials = await loadEnvFile({ envPath: absolutePath });
37085
- } catch (error) {
37086
- if (isFileNotFoundError(error)) {
37087
- return { loginStatus: "Not logged in" };
37088
- }
37089
- throw error;
37090
- }
37091
- if (!credentials.UIPATH_ACCESS_TOKEN) {
37092
- return { loginStatus: "Not logged in" };
37093
- }
37094
- let accessToken = credentials.UIPATH_ACCESS_TOKEN;
37095
- let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
37096
- let expiration = getTokenExpiration(accessToken);
37097
- let persistenceWarning;
37098
- let lockReleaseFailed = false;
37099
- let tokenRefresh;
37100
- const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
37101
- const tryGlobalCredsHint = async () => {
37102
- const fs7 = getFs();
37103
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
37104
- if (absolutePath === globalPath)
37105
- return;
37106
- if (!await fs7.exists(globalPath))
37107
- return;
37108
- try {
37109
- const globalCreds = await loadEnvFile({ envPath: globalPath });
37110
- if (!globalCreds.UIPATH_ACCESS_TOKEN)
37111
- return;
37112
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
37113
- if (globalExp && globalExp <= new Date)
37114
- return;
37115
- 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.`;
37116
- } catch {
37117
- return;
37118
- }
37119
- };
37120
- if (expiration && expiration <= outerThreshold && refreshToken) {
37121
- let release;
37122
- try {
37123
- release = await getFs().acquireLock(absolutePath);
37124
- } catch (error) {
37125
- const msg = errorMessage(error);
37126
- const globalHint = await tryGlobalCredsHint();
37127
- if (globalHint) {
37128
- return {
37129
- loginStatus: "Expired",
37130
- accessToken,
37131
- refreshToken,
37132
- baseUrl: credentials.UIPATH_URL,
37133
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
37134
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
37135
- tenantName: credentials.UIPATH_TENANT_NAME,
37136
- tenantId: credentials.UIPATH_TENANT_ID,
37137
- expiration,
37138
- source: "file" /* File */,
37139
- hint: globalHint,
37140
- tokenRefresh: {
37141
- attempted: false,
37142
- success: false,
37143
- errorMessage: `lock acquisition failed: ${msg}`
37144
- }
37145
- };
37146
- }
37147
- return {
37148
- loginStatus: "Refresh Failed",
37149
- 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.",
37150
- tokenRefresh: {
37151
- attempted: false,
37152
- success: false,
37153
- errorMessage: `lock acquisition failed: ${msg}`
37154
- }
37155
- };
37156
- }
37157
- let lockedFailure;
37158
- try {
37159
- const outcome = await runRefreshLocked({
37160
- absolutePath,
37161
- refreshToken,
37162
- customAuthority: credentials.UIPATH_URL,
37163
- ensureTokenValidityMinutes,
37164
- loadEnvFile,
37165
- saveEnvFile,
37166
- refreshFn: refreshTokenFn,
37167
- resolveConfig: resolveConfig2
37168
- });
37169
- if (outcome.kind === "fail") {
37170
- lockedFailure = outcome.status;
37171
- } else {
37172
- accessToken = outcome.accessToken;
37173
- refreshToken = outcome.refreshToken;
37174
- expiration = outcome.expiration;
37175
- tokenRefresh = outcome.tokenRefresh;
37176
- if (outcome.persistenceWarning) {
37177
- persistenceWarning = outcome.persistenceWarning;
37178
- }
37179
- }
37180
- } finally {
37181
- try {
37182
- await release();
37183
- } catch {
37184
- lockReleaseFailed = true;
37185
- }
37186
- }
37187
- if (lockedFailure) {
37188
- const globalHint = await tryGlobalCredsHint();
37189
- const base = globalHint ? {
37190
- ...lockedFailure,
37191
- loginStatus: "Expired",
37192
- hint: globalHint
37193
- } : lockedFailure;
37194
- return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
37195
- }
37196
- }
37197
- const result = {
37198
- loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
37199
- accessToken,
37200
- refreshToken,
37201
- baseUrl: credentials.UIPATH_URL,
37202
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
37203
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
37204
- tenantName: credentials.UIPATH_TENANT_NAME,
37205
- tenantId: credentials.UIPATH_TENANT_ID,
37206
- expiration,
37207
- source: "file" /* File */,
37208
- ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
37209
- ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
37210
- ...tokenRefresh ? { tokenRefresh } : {}
37211
- };
37212
- if (result.loginStatus === "Expired") {
37213
- const globalHint = await tryGlobalCredsHint();
37214
- if (globalHint) {
37215
- result.hint = globalHint;
37216
- }
37217
- }
37218
- return result;
37219
- };
37220
- var isFileNotFoundError = (error) => {
37221
- if (!(error instanceof Object))
37222
- return false;
37223
- return error.code === "ENOENT";
37224
- };
37225
- var getLoginStatusAsync = async (options = {}) => {
37226
- return getLoginStatusWithDeps(options);
37227
- };
36212
+ function normalizeTokenRefreshFailure() {
36213
+ return "stored refresh token is invalid or expired";
36214
+ }
36215
+ function normalizeTokenRefreshUnavailableFailure() {
36216
+ return "token refresh failed before authentication completed";
36217
+ }
36218
+ function errorMessage(error) {
36219
+ return error instanceof Error ? error.message : String(error);
36220
+ }
37228
36221
 
37229
36222
  // ../auth/src/authContext.ts
37230
36223
  var getAuthContext = async (options = {}) => {
@@ -37259,6 +36252,14 @@ var getAuthContext = async (options = {}) => {
37259
36252
  };
37260
36253
  // ../auth/src/interactive.ts
37261
36254
  init_src();
36255
+
36256
+ // ../auth/src/selectTenant.ts
36257
+ var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
36258
+ var INVALID_TENANT_CODE = "INVALID_TENANT";
36259
+ var TENANT_SELECTION_CODES = new Set([
36260
+ TENANT_SELECTION_REQUIRED_CODE,
36261
+ INVALID_TENANT_CODE
36262
+ ]);
37262
36263
  // ../auth/src/logout.ts
37263
36264
  init_src();
37264
36265
 
@@ -42644,7 +41645,7 @@ class TextApiResponse2 {
42644
41645
  var package_default3 = {
42645
41646
  name: "@uipath/orchestrator-sdk",
42646
41647
  license: "MIT",
42647
- version: "1.196.0",
41648
+ version: "1.197.0",
42648
41649
  repository: {
42649
41650
  type: "git",
42650
41651
  url: "https://github.com/UiPath/cli.git",
@@ -42678,7 +41679,7 @@ var package_default3 = {
42678
41679
  ],
42679
41680
  private: true,
42680
41681
  scripts: {
42681
- build: "bun build ./src/index.ts --outdir dist --format esm --target node && bun build ./src/index.browser.ts --outdir dist --format esm --target browser --external @uipath/auth --external @uipath/common && tsc -p tsconfig.build.json --noCheck",
41682
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && bun build ./src/index.browser.ts --outdir dist --format esm --target browser --external @uipath/auth --external @uipath/common --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
42682
41683
  generate: "bun run src/scripts/generate-sdk.ts",
42683
41684
  lint: "biome check .",
42684
41685
  test: "vitest run",
@@ -45003,7 +44004,7 @@ var TESTCASE_LIST_EXAMPLES = [
45003
44004
  Data: [
45004
44005
  {
45005
44006
  Id: "a1b2c3d4-0000-0000-0000-000000000001",
45006
- ObjKey: "DEMO:1",
44007
+ TestCaseKey: "DEMO:1",
45007
44008
  Name: "Login smoke",
45008
44009
  Version: "1.0.0",
45009
44010
  Description: "Logs in and out",
@@ -45012,7 +44013,7 @@ var TESTCASE_LIST_EXAMPLES = [
45012
44013
  },
45013
44014
  {
45014
44015
  Id: "a1b2c3d4-0000-0000-0000-000000000002",
45015
- ObjKey: "DEMO:2",
44016
+ TestCaseKey: "DEMO:2",
45016
44017
  Name: "Checkout",
45017
44018
  Version: "1.0.0",
45018
44019
  Description: "Purchase flow",
@@ -45537,7 +44538,16 @@ var registerTestcaseCommand = (program2) => {
45537
44538
  processContext.exit(1);
45538
44539
  return;
45539
44540
  }
45540
- OutputFormatter.success(new SuccessOutput("TestCasesList", rows));
44541
+ const outputRows = rows.map((tc) => ({
44542
+ Id: tc.id ?? "",
44543
+ TestCaseKey: tc.objKey ?? "",
44544
+ Name: tc.name ?? "",
44545
+ Version: tc.version ?? "",
44546
+ Description: tc.description ?? "",
44547
+ FeedId: tc.feedId ?? "",
44548
+ IsAutomated: tc.isAutomated ?? false
44549
+ }));
44550
+ OutputFormatter.success(new SuccessOutput("TestCasesList", outputRows));
45541
44551
  });
45542
44552
  testcaseCmd.command("list-result-history").description("List testcase log result history for a specific test case.").requiredOption("--project-key <key>", "Test Manager project key (e.g. DEMO)").requiredOption("--test-case-id <uuid>", "Test case UUID").option("--filter <text>", "Search test case logs by name").option("--only-failed", "Show only failed test case logs", false).addOption(new Option("--results <results...>", `Filter by results (space-separated: ${Object.values(UiPathTestManagementHubTestManagementAbstractionsDTOsResult).join(" ")})`).choices(Object.values(UiPathTestManagementHubTestManagementAbstractionsDTOsResult))).addOption(new Option("--statuses <statuses...>", `Filter by execution statuses (space-separated: ${Object.values(UiPathTestManagementHubCommonEnumsTestCaseLogExecutionStatus).join(" ")})`).choices(Object.values(UiPathTestManagementHubCommonEnumsTestCaseLogExecutionStatus))).addOption(new Option("--duration-period <period>", `Filter by duration period (${Object.values(UiPathTestManagementHubTestManagementAbstractionsEnumsDurationPeriod).join(", ")})`).choices(Object.values(UiPathTestManagementHubTestManagementAbstractionsEnumsDurationPeriod))).option("--limit <number>", "Number of results per page (default: 50)").option("--offset <number>", "Number of results to skip (default: 0)").addOption(new Option("--top <number>").hideHelp()).addOption(new Option("--skip <number>").hideHelp()).addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--log-level <level>", "Log verbosity: debug, info, warn, error", "Information").examples(TESTCASE_LIST_RESULT_HISTORY_EXAMPLES).trackedAction(processContext, async (options) => {
45543
44553
  const [authError, ctx] = await catchError(initializeContextWithProject(options));
@@ -47462,8 +46472,8 @@ function toLatestExecutionSummary(execution) {
47462
46472
  }
47463
46473
  async function fetchLatestExecutionSummaries(api, projectId, testSets) {
47464
46474
  const summaries = new Map;
47465
- for (let index2 = 0;index2 < testSets.length; index2 += LATEST_EXECUTION_SUMMARY_CONCURRENCY) {
47466
- const chunk = testSets.slice(index2, index2 + LATEST_EXECUTION_SUMMARY_CONCURRENCY);
46475
+ for (let index = 0;index < testSets.length; index += LATEST_EXECUTION_SUMMARY_CONCURRENCY) {
46476
+ const chunk = testSets.slice(index, index + LATEST_EXECUTION_SUMMARY_CONCURRENCY);
47467
46477
  await Promise.all(chunk.map(async (testSet) => {
47468
46478
  const testSetId = typeof testSet.id === "string" ? testSet.id : "";
47469
46479
  if (!testSetId)
@@ -47793,3 +46803,5 @@ export {
47793
46803
  registerCommands,
47794
46804
  metadata
47795
46805
  };
46806
+
46807
+ //# debugId=A66A2691D335585A64756E2164756E21