@uipath/functions-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.
Files changed (2) hide show
  1. package/dist/tool.js +889 -3247
  2. package/package.json +2 -2
package/dist/tool.js CHANGED
@@ -4,7 +4,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
  var package_default = {
5
5
  name: "@uipath/functions-tool",
6
6
  license: "MIT",
7
- version: "1.196.0",
7
+ version: "1.197.0-preview.59",
8
8
  description: "UiPath CLI tool for JS/TS and Python Functions — thin passthrough to uipath-functions / uipath",
9
9
  keywords: [
10
10
  "uipcli-tool",
@@ -90,7 +90,6 @@ import { execFile as execFile5 } from "node:child_process";
90
90
  import process7 from "node:process";
91
91
  import { execFileSync as execFileSync2 } from "node:child_process";
92
92
  import { AsyncLocalStorage } from "node:async_hooks";
93
- import vm from "vm";
94
93
  var __create = Object.create;
95
94
  var __getProtoOf = Object.getPrototypeOf;
96
95
  var __defProp = Object.defineProperty;
@@ -3003,6 +3002,18 @@ var NETWORK_ERROR_CODES = new Set([
3003
3002
  "ENETUNREACH",
3004
3003
  "EAI_FAIL"
3005
3004
  ]);
3005
+ var TLS_ERROR_CODES = new Set([
3006
+ "SELF_SIGNED_CERT_IN_CHAIN",
3007
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
3008
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
3009
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
3010
+ "UNABLE_TO_GET_ISSUER_CERT",
3011
+ "CERT_HAS_EXPIRED",
3012
+ "CERT_UNTRUSTED",
3013
+ "ERR_TLS_CERT_ALTNAME_INVALID"
3014
+ ]);
3015
+ 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.";
3016
+ 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.";
3006
3017
  var import__ = __toESM(require_commander(), 1);
3007
3018
  var {
3008
3019
  program,
@@ -3071,6 +3082,7 @@ var CONSOLE_FALLBACK = {
3071
3082
  writeLog: (str) => process.stdout.write(str),
3072
3083
  capabilities: {
3073
3084
  isInteractive: false,
3085
+ canReadInput: false,
3074
3086
  supportsColor: false,
3075
3087
  outputWidth: 80
3076
3088
  }
@@ -8253,6 +8265,29 @@ function isPlainRecord(value) {
8253
8265
  const prototype = Object.getPrototypeOf(value);
8254
8266
  return prototype === Object.prototype || prototype === null;
8255
8267
  }
8268
+ function extractPagedRows(value) {
8269
+ if (Array.isArray(value) || !isPlainRecord(value))
8270
+ return null;
8271
+ const entries = Object.values(value);
8272
+ if (entries.length === 0)
8273
+ return null;
8274
+ let rows = null;
8275
+ let hasScalarSibling = false;
8276
+ for (const entry of entries) {
8277
+ if (Array.isArray(entry)) {
8278
+ if (rows !== null)
8279
+ return null;
8280
+ rows = entry;
8281
+ } else if (entry !== null && typeof entry === "object") {
8282
+ return null;
8283
+ } else {
8284
+ hasScalarSibling = true;
8285
+ }
8286
+ }
8287
+ if (rows === null || !hasScalarSibling)
8288
+ return null;
8289
+ return rows;
8290
+ }
8256
8291
  function toLowerCamelCaseKey(key) {
8257
8292
  if (!key)
8258
8293
  return key;
@@ -8317,7 +8352,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
8317
8352
  break;
8318
8353
  case "plain": {
8319
8354
  if ("Data" in data && data.Data != null) {
8320
- const items = Array.isArray(data.Data) ? data.Data : [data.Data];
8355
+ const pagedRows = extractPagedRows(data.Data);
8356
+ const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
8321
8357
  items.forEach((item) => {
8322
8358
  const values = Object.values(item).map((v) => v ?? "").join("\t");
8323
8359
  logFn(values);
@@ -8329,10 +8365,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
8329
8365
  break;
8330
8366
  }
8331
8367
  default: {
8332
- if ("Data" in data && data.Data != null && !(Array.isArray(data.Data) && data.Data.length === 0)) {
8368
+ const hasData = "Data" in data && data.Data != null;
8369
+ const pagedRows = hasData ? extractPagedRows(data.Data) : null;
8370
+ const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
8371
+ if (hasData && !(rows !== null && rows.length === 0)) {
8333
8372
  const logValue = data.Log;
8334
- if (Array.isArray(data.Data)) {
8335
- printResizableTable(data.Data, logFn, logValue);
8373
+ if (rows !== null) {
8374
+ printResizableTable(rows, logFn, logValue);
8336
8375
  } else {
8337
8376
  printVerticalTable(data.Data, logFn, logValue);
8338
8377
  }
@@ -8520,6 +8559,44 @@ function defaultErrorCodeForResult(result) {
8520
8559
  return "unknown_error";
8521
8560
  }
8522
8561
  }
8562
+ function parseHttpStatusFromMessage2(message) {
8563
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
8564
+ if (!match)
8565
+ return;
8566
+ const status = Number(match[1]);
8567
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
8568
+ }
8569
+ function defaultErrorCodeForHttpStatus(status) {
8570
+ if (status === undefined)
8571
+ return;
8572
+ if (status === 400 || status === 409 || status === 422) {
8573
+ return "invalid_argument";
8574
+ }
8575
+ if (status === 401)
8576
+ return "authentication_required";
8577
+ if (status === 403)
8578
+ return "permission_denied";
8579
+ if (status === 404)
8580
+ return "not_found";
8581
+ if (status === 405)
8582
+ return "method_not_allowed";
8583
+ if (status === 408)
8584
+ return "timeout";
8585
+ if (status === 429)
8586
+ return "rate_limited";
8587
+ if (status >= 500 && status < 600)
8588
+ return "server_error";
8589
+ return;
8590
+ }
8591
+ function defaultErrorCodeForFailure(data) {
8592
+ if (data.Result === RESULTS.Failure) {
8593
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
8594
+ const errorCode = defaultErrorCodeForHttpStatus(status);
8595
+ if (errorCode)
8596
+ return errorCode;
8597
+ }
8598
+ return defaultErrorCodeForResult(data.Result);
8599
+ }
8523
8600
  function defaultRetryForErrorCode(errorCode) {
8524
8601
  switch (errorCode) {
8525
8602
  case "network_error":
@@ -8549,16 +8626,19 @@ var OutputFormatter;
8549
8626
  OutputFormatter2.success = success;
8550
8627
  function error(data) {
8551
8628
  data.Log ??= getLogFilePath() || undefined;
8552
- data.ErrorCode ??= defaultErrorCodeForResult(data.Result);
8629
+ data.ErrorCode ??= defaultErrorCodeForFailure(data);
8553
8630
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
8554
8631
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
8555
- telemetry.trackEvent(CommonTelemetryEvents.Error, {
8556
- result: data.Result,
8557
- errorCode: data.ErrorCode,
8558
- retry: data.Retry,
8559
- message: data.Message
8560
- });
8561
- logOutput(normalizeOutputKeys(data), getOutputFormat());
8632
+ const { SuppressTelemetry, ...envelope } = data;
8633
+ if (!SuppressTelemetry) {
8634
+ telemetry.trackEvent(CommonTelemetryEvents.Error, {
8635
+ result: data.Result,
8636
+ errorCode: data.ErrorCode,
8637
+ retry: data.Retry,
8638
+ message: data.Message
8639
+ });
8640
+ }
8641
+ logOutput(normalizeOutputKeys(envelope), getOutputFormat());
8562
8642
  }
8563
8643
  OutputFormatter2.error = error;
8564
8644
  function emitList(code, items, opts) {
@@ -8841,1406 +8921,6 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
8841
8921
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
8842
8922
  var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
8843
8923
  var modeSlot = singleton("InteractivityMode");
8844
- class Hooks {
8845
- add(name, callback, first) {
8846
- if (typeof arguments[0] != "string") {
8847
- for (let name2 in arguments[0]) {
8848
- this.add(name2, arguments[0][name2], arguments[1]);
8849
- }
8850
- } else {
8851
- (Array.isArray(name) ? name : [name]).forEach(function(name2) {
8852
- this[name2] = this[name2] || [];
8853
- if (callback) {
8854
- this[name2][first ? "unshift" : "push"](callback);
8855
- }
8856
- }, this);
8857
- }
8858
- }
8859
- run(name, env) {
8860
- this[name] = this[name] || [];
8861
- this[name].forEach(function(callback) {
8862
- callback.call(env && env.context ? env.context : env, env);
8863
- });
8864
- }
8865
- }
8866
-
8867
- class Plugins {
8868
- constructor(jsep) {
8869
- this.jsep = jsep;
8870
- this.registered = {};
8871
- }
8872
- register(...plugins) {
8873
- plugins.forEach((plugin) => {
8874
- if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
8875
- throw new Error("Invalid JSEP plugin format");
8876
- }
8877
- if (this.registered[plugin.name]) {
8878
- return;
8879
- }
8880
- plugin.init(this.jsep);
8881
- this.registered[plugin.name] = plugin;
8882
- });
8883
- }
8884
- }
8885
-
8886
- class Jsep {
8887
- static get version() {
8888
- return "1.4.0";
8889
- }
8890
- static toString() {
8891
- return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
8892
- }
8893
- static addUnaryOp(op_name) {
8894
- Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
8895
- Jsep.unary_ops[op_name] = 1;
8896
- return Jsep;
8897
- }
8898
- static addBinaryOp(op_name, precedence, isRightAssociative) {
8899
- Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
8900
- Jsep.binary_ops[op_name] = precedence;
8901
- if (isRightAssociative) {
8902
- Jsep.right_associative.add(op_name);
8903
- } else {
8904
- Jsep.right_associative.delete(op_name);
8905
- }
8906
- return Jsep;
8907
- }
8908
- static addIdentifierChar(char) {
8909
- Jsep.additional_identifier_chars.add(char);
8910
- return Jsep;
8911
- }
8912
- static addLiteral(literal_name, literal_value) {
8913
- Jsep.literals[literal_name] = literal_value;
8914
- return Jsep;
8915
- }
8916
- static removeUnaryOp(op_name) {
8917
- delete Jsep.unary_ops[op_name];
8918
- if (op_name.length === Jsep.max_unop_len) {
8919
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
8920
- }
8921
- return Jsep;
8922
- }
8923
- static removeAllUnaryOps() {
8924
- Jsep.unary_ops = {};
8925
- Jsep.max_unop_len = 0;
8926
- return Jsep;
8927
- }
8928
- static removeIdentifierChar(char) {
8929
- Jsep.additional_identifier_chars.delete(char);
8930
- return Jsep;
8931
- }
8932
- static removeBinaryOp(op_name) {
8933
- delete Jsep.binary_ops[op_name];
8934
- if (op_name.length === Jsep.max_binop_len) {
8935
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
8936
- }
8937
- Jsep.right_associative.delete(op_name);
8938
- return Jsep;
8939
- }
8940
- static removeAllBinaryOps() {
8941
- Jsep.binary_ops = {};
8942
- Jsep.max_binop_len = 0;
8943
- return Jsep;
8944
- }
8945
- static removeLiteral(literal_name) {
8946
- delete Jsep.literals[literal_name];
8947
- return Jsep;
8948
- }
8949
- static removeAllLiterals() {
8950
- Jsep.literals = {};
8951
- return Jsep;
8952
- }
8953
- get char() {
8954
- return this.expr.charAt(this.index);
8955
- }
8956
- get code() {
8957
- return this.expr.charCodeAt(this.index);
8958
- }
8959
- constructor(expr) {
8960
- this.expr = expr;
8961
- this.index = 0;
8962
- }
8963
- static parse(expr) {
8964
- return new Jsep(expr).parse();
8965
- }
8966
- static getMaxKeyLen(obj) {
8967
- return Math.max(0, ...Object.keys(obj).map((k) => k.length));
8968
- }
8969
- static isDecimalDigit(ch) {
8970
- return ch >= 48 && ch <= 57;
8971
- }
8972
- static binaryPrecedence(op_val) {
8973
- return Jsep.binary_ops[op_val] || 0;
8974
- }
8975
- static isIdentifierStart(ch) {
8976
- 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));
8977
- }
8978
- static isIdentifierPart(ch) {
8979
- return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
8980
- }
8981
- throwError(message) {
8982
- const error = new Error(message + " at character " + this.index);
8983
- error.index = this.index;
8984
- error.description = message;
8985
- throw error;
8986
- }
8987
- runHook(name, node) {
8988
- if (Jsep.hooks[name]) {
8989
- const env = {
8990
- context: this,
8991
- node
8992
- };
8993
- Jsep.hooks.run(name, env);
8994
- return env.node;
8995
- }
8996
- return node;
8997
- }
8998
- searchHook(name) {
8999
- if (Jsep.hooks[name]) {
9000
- const env = {
9001
- context: this
9002
- };
9003
- Jsep.hooks[name].find(function(callback) {
9004
- callback.call(env.context, env);
9005
- return env.node;
9006
- });
9007
- return env.node;
9008
- }
9009
- }
9010
- gobbleSpaces() {
9011
- let ch = this.code;
9012
- while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
9013
- ch = this.expr.charCodeAt(++this.index);
9014
- }
9015
- this.runHook("gobble-spaces");
9016
- }
9017
- parse() {
9018
- this.runHook("before-all");
9019
- const nodes = this.gobbleExpressions();
9020
- const node = nodes.length === 1 ? nodes[0] : {
9021
- type: Jsep.COMPOUND,
9022
- body: nodes
9023
- };
9024
- return this.runHook("after-all", node);
9025
- }
9026
- gobbleExpressions(untilICode) {
9027
- let nodes = [], ch_i, node;
9028
- while (this.index < this.expr.length) {
9029
- ch_i = this.code;
9030
- if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
9031
- this.index++;
9032
- } else {
9033
- if (node = this.gobbleExpression()) {
9034
- nodes.push(node);
9035
- } else if (this.index < this.expr.length) {
9036
- if (ch_i === untilICode) {
9037
- break;
9038
- }
9039
- this.throwError('Unexpected "' + this.char + '"');
9040
- }
9041
- }
9042
- }
9043
- return nodes;
9044
- }
9045
- gobbleExpression() {
9046
- const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
9047
- this.gobbleSpaces();
9048
- return this.runHook("after-expression", node);
9049
- }
9050
- gobbleBinaryOp() {
9051
- this.gobbleSpaces();
9052
- let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
9053
- let tc_len = to_check.length;
9054
- while (tc_len > 0) {
9055
- 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)))) {
9056
- this.index += tc_len;
9057
- return to_check;
9058
- }
9059
- to_check = to_check.substr(0, --tc_len);
9060
- }
9061
- return false;
9062
- }
9063
- gobbleBinaryExpression() {
9064
- let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
9065
- left = this.gobbleToken();
9066
- if (!left) {
9067
- return left;
9068
- }
9069
- biop = this.gobbleBinaryOp();
9070
- if (!biop) {
9071
- return left;
9072
- }
9073
- biop_info = {
9074
- value: biop,
9075
- prec: Jsep.binaryPrecedence(biop),
9076
- right_a: Jsep.right_associative.has(biop)
9077
- };
9078
- right = this.gobbleToken();
9079
- if (!right) {
9080
- this.throwError("Expected expression after " + biop);
9081
- }
9082
- stack = [left, biop_info, right];
9083
- while (biop = this.gobbleBinaryOp()) {
9084
- prec = Jsep.binaryPrecedence(biop);
9085
- if (prec === 0) {
9086
- this.index -= biop.length;
9087
- break;
9088
- }
9089
- biop_info = {
9090
- value: biop,
9091
- prec,
9092
- right_a: Jsep.right_associative.has(biop)
9093
- };
9094
- cur_biop = biop;
9095
- const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
9096
- while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
9097
- right = stack.pop();
9098
- biop = stack.pop().value;
9099
- left = stack.pop();
9100
- node = {
9101
- type: Jsep.BINARY_EXP,
9102
- operator: biop,
9103
- left,
9104
- right
9105
- };
9106
- stack.push(node);
9107
- }
9108
- node = this.gobbleToken();
9109
- if (!node) {
9110
- this.throwError("Expected expression after " + cur_biop);
9111
- }
9112
- stack.push(biop_info, node);
9113
- }
9114
- i = stack.length - 1;
9115
- node = stack[i];
9116
- while (i > 1) {
9117
- node = {
9118
- type: Jsep.BINARY_EXP,
9119
- operator: stack[i - 1].value,
9120
- left: stack[i - 2],
9121
- right: node
9122
- };
9123
- i -= 2;
9124
- }
9125
- return node;
9126
- }
9127
- gobbleToken() {
9128
- let ch, to_check, tc_len, node;
9129
- this.gobbleSpaces();
9130
- node = this.searchHook("gobble-token");
9131
- if (node) {
9132
- return this.runHook("after-token", node);
9133
- }
9134
- ch = this.code;
9135
- if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
9136
- return this.gobbleNumericLiteral();
9137
- }
9138
- if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
9139
- node = this.gobbleStringLiteral();
9140
- } else if (ch === Jsep.OBRACK_CODE) {
9141
- node = this.gobbleArray();
9142
- } else {
9143
- to_check = this.expr.substr(this.index, Jsep.max_unop_len);
9144
- tc_len = to_check.length;
9145
- while (tc_len > 0) {
9146
- 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)))) {
9147
- this.index += tc_len;
9148
- const argument = this.gobbleToken();
9149
- if (!argument) {
9150
- this.throwError("missing unaryOp argument");
9151
- }
9152
- return this.runHook("after-token", {
9153
- type: Jsep.UNARY_EXP,
9154
- operator: to_check,
9155
- argument,
9156
- prefix: true
9157
- });
9158
- }
9159
- to_check = to_check.substr(0, --tc_len);
9160
- }
9161
- if (Jsep.isIdentifierStart(ch)) {
9162
- node = this.gobbleIdentifier();
9163
- if (Jsep.literals.hasOwnProperty(node.name)) {
9164
- node = {
9165
- type: Jsep.LITERAL,
9166
- value: Jsep.literals[node.name],
9167
- raw: node.name
9168
- };
9169
- } else if (node.name === Jsep.this_str) {
9170
- node = {
9171
- type: Jsep.THIS_EXP
9172
- };
9173
- }
9174
- } else if (ch === Jsep.OPAREN_CODE) {
9175
- node = this.gobbleGroup();
9176
- }
9177
- }
9178
- if (!node) {
9179
- return this.runHook("after-token", false);
9180
- }
9181
- node = this.gobbleTokenProperty(node);
9182
- return this.runHook("after-token", node);
9183
- }
9184
- gobbleTokenProperty(node) {
9185
- this.gobbleSpaces();
9186
- let ch = this.code;
9187
- while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
9188
- let optional;
9189
- if (ch === Jsep.QUMARK_CODE) {
9190
- if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
9191
- break;
9192
- }
9193
- optional = true;
9194
- this.index += 2;
9195
- this.gobbleSpaces();
9196
- ch = this.code;
9197
- }
9198
- this.index++;
9199
- if (ch === Jsep.OBRACK_CODE) {
9200
- node = {
9201
- type: Jsep.MEMBER_EXP,
9202
- computed: true,
9203
- object: node,
9204
- property: this.gobbleExpression()
9205
- };
9206
- if (!node.property) {
9207
- this.throwError('Unexpected "' + this.char + '"');
9208
- }
9209
- this.gobbleSpaces();
9210
- ch = this.code;
9211
- if (ch !== Jsep.CBRACK_CODE) {
9212
- this.throwError("Unclosed [");
9213
- }
9214
- this.index++;
9215
- } else if (ch === Jsep.OPAREN_CODE) {
9216
- node = {
9217
- type: Jsep.CALL_EXP,
9218
- arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
9219
- callee: node
9220
- };
9221
- } else if (ch === Jsep.PERIOD_CODE || optional) {
9222
- if (optional) {
9223
- this.index--;
9224
- }
9225
- this.gobbleSpaces();
9226
- node = {
9227
- type: Jsep.MEMBER_EXP,
9228
- computed: false,
9229
- object: node,
9230
- property: this.gobbleIdentifier()
9231
- };
9232
- }
9233
- if (optional) {
9234
- node.optional = true;
9235
- }
9236
- this.gobbleSpaces();
9237
- ch = this.code;
9238
- }
9239
- return node;
9240
- }
9241
- gobbleNumericLiteral() {
9242
- let number = "", ch, chCode;
9243
- while (Jsep.isDecimalDigit(this.code)) {
9244
- number += this.expr.charAt(this.index++);
9245
- }
9246
- if (this.code === Jsep.PERIOD_CODE) {
9247
- number += this.expr.charAt(this.index++);
9248
- while (Jsep.isDecimalDigit(this.code)) {
9249
- number += this.expr.charAt(this.index++);
9250
- }
9251
- }
9252
- ch = this.char;
9253
- if (ch === "e" || ch === "E") {
9254
- number += this.expr.charAt(this.index++);
9255
- ch = this.char;
9256
- if (ch === "+" || ch === "-") {
9257
- number += this.expr.charAt(this.index++);
9258
- }
9259
- while (Jsep.isDecimalDigit(this.code)) {
9260
- number += this.expr.charAt(this.index++);
9261
- }
9262
- if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
9263
- this.throwError("Expected exponent (" + number + this.char + ")");
9264
- }
9265
- }
9266
- chCode = this.code;
9267
- if (Jsep.isIdentifierStart(chCode)) {
9268
- this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
9269
- } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
9270
- this.throwError("Unexpected period");
9271
- }
9272
- return {
9273
- type: Jsep.LITERAL,
9274
- value: parseFloat(number),
9275
- raw: number
9276
- };
9277
- }
9278
- gobbleStringLiteral() {
9279
- let str = "";
9280
- const startIndex = this.index;
9281
- const quote = this.expr.charAt(this.index++);
9282
- let closed = false;
9283
- while (this.index < this.expr.length) {
9284
- let ch = this.expr.charAt(this.index++);
9285
- if (ch === quote) {
9286
- closed = true;
9287
- break;
9288
- } else if (ch === "\\") {
9289
- ch = this.expr.charAt(this.index++);
9290
- switch (ch) {
9291
- case "n":
9292
- str += `
9293
- `;
9294
- break;
9295
- case "r":
9296
- str += "\r";
9297
- break;
9298
- case "t":
9299
- str += "\t";
9300
- break;
9301
- case "b":
9302
- str += "\b";
9303
- break;
9304
- case "f":
9305
- str += "\f";
9306
- break;
9307
- case "v":
9308
- str += "\v";
9309
- break;
9310
- default:
9311
- str += ch;
9312
- }
9313
- } else {
9314
- str += ch;
9315
- }
9316
- }
9317
- if (!closed) {
9318
- this.throwError('Unclosed quote after "' + str + '"');
9319
- }
9320
- return {
9321
- type: Jsep.LITERAL,
9322
- value: str,
9323
- raw: this.expr.substring(startIndex, this.index)
9324
- };
9325
- }
9326
- gobbleIdentifier() {
9327
- let ch = this.code, start = this.index;
9328
- if (Jsep.isIdentifierStart(ch)) {
9329
- this.index++;
9330
- } else {
9331
- this.throwError("Unexpected " + this.char);
9332
- }
9333
- while (this.index < this.expr.length) {
9334
- ch = this.code;
9335
- if (Jsep.isIdentifierPart(ch)) {
9336
- this.index++;
9337
- } else {
9338
- break;
9339
- }
9340
- }
9341
- return {
9342
- type: Jsep.IDENTIFIER,
9343
- name: this.expr.slice(start, this.index)
9344
- };
9345
- }
9346
- gobbleArguments(termination) {
9347
- const args = [];
9348
- let closed = false;
9349
- let separator_count = 0;
9350
- while (this.index < this.expr.length) {
9351
- this.gobbleSpaces();
9352
- let ch_i = this.code;
9353
- if (ch_i === termination) {
9354
- closed = true;
9355
- this.index++;
9356
- if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
9357
- this.throwError("Unexpected token " + String.fromCharCode(termination));
9358
- }
9359
- break;
9360
- } else if (ch_i === Jsep.COMMA_CODE) {
9361
- this.index++;
9362
- separator_count++;
9363
- if (separator_count !== args.length) {
9364
- if (termination === Jsep.CPAREN_CODE) {
9365
- this.throwError("Unexpected token ,");
9366
- } else if (termination === Jsep.CBRACK_CODE) {
9367
- for (let arg = args.length;arg < separator_count; arg++) {
9368
- args.push(null);
9369
- }
9370
- }
9371
- }
9372
- } else if (args.length !== separator_count && separator_count !== 0) {
9373
- this.throwError("Expected comma");
9374
- } else {
9375
- const node = this.gobbleExpression();
9376
- if (!node || node.type === Jsep.COMPOUND) {
9377
- this.throwError("Expected comma");
9378
- }
9379
- args.push(node);
9380
- }
9381
- }
9382
- if (!closed) {
9383
- this.throwError("Expected " + String.fromCharCode(termination));
9384
- }
9385
- return args;
9386
- }
9387
- gobbleGroup() {
9388
- this.index++;
9389
- let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
9390
- if (this.code === Jsep.CPAREN_CODE) {
9391
- this.index++;
9392
- if (nodes.length === 1) {
9393
- return nodes[0];
9394
- } else if (!nodes.length) {
9395
- return false;
9396
- } else {
9397
- return {
9398
- type: Jsep.SEQUENCE_EXP,
9399
- expressions: nodes
9400
- };
9401
- }
9402
- } else {
9403
- this.throwError("Unclosed (");
9404
- }
9405
- }
9406
- gobbleArray() {
9407
- this.index++;
9408
- return {
9409
- type: Jsep.ARRAY_EXP,
9410
- elements: this.gobbleArguments(Jsep.CBRACK_CODE)
9411
- };
9412
- }
9413
- }
9414
- var hooks = new Hooks;
9415
- Object.assign(Jsep, {
9416
- hooks,
9417
- plugins: new Plugins(Jsep),
9418
- COMPOUND: "Compound",
9419
- SEQUENCE_EXP: "SequenceExpression",
9420
- IDENTIFIER: "Identifier",
9421
- MEMBER_EXP: "MemberExpression",
9422
- LITERAL: "Literal",
9423
- THIS_EXP: "ThisExpression",
9424
- CALL_EXP: "CallExpression",
9425
- UNARY_EXP: "UnaryExpression",
9426
- BINARY_EXP: "BinaryExpression",
9427
- ARRAY_EXP: "ArrayExpression",
9428
- TAB_CODE: 9,
9429
- LF_CODE: 10,
9430
- CR_CODE: 13,
9431
- SPACE_CODE: 32,
9432
- PERIOD_CODE: 46,
9433
- COMMA_CODE: 44,
9434
- SQUOTE_CODE: 39,
9435
- DQUOTE_CODE: 34,
9436
- OPAREN_CODE: 40,
9437
- CPAREN_CODE: 41,
9438
- OBRACK_CODE: 91,
9439
- CBRACK_CODE: 93,
9440
- QUMARK_CODE: 63,
9441
- SEMCOL_CODE: 59,
9442
- COLON_CODE: 58,
9443
- unary_ops: {
9444
- "-": 1,
9445
- "!": 1,
9446
- "~": 1,
9447
- "+": 1
9448
- },
9449
- binary_ops: {
9450
- "||": 1,
9451
- "??": 1,
9452
- "&&": 2,
9453
- "|": 3,
9454
- "^": 4,
9455
- "&": 5,
9456
- "==": 6,
9457
- "!=": 6,
9458
- "===": 6,
9459
- "!==": 6,
9460
- "<": 7,
9461
- ">": 7,
9462
- "<=": 7,
9463
- ">=": 7,
9464
- "<<": 8,
9465
- ">>": 8,
9466
- ">>>": 8,
9467
- "+": 9,
9468
- "-": 9,
9469
- "*": 10,
9470
- "/": 10,
9471
- "%": 10,
9472
- "**": 11
9473
- },
9474
- right_associative: new Set(["**"]),
9475
- additional_identifier_chars: new Set(["$", "_"]),
9476
- literals: {
9477
- true: true,
9478
- false: false,
9479
- null: null
9480
- },
9481
- this_str: "this"
9482
- });
9483
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
9484
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
9485
- var jsep = (expr) => new Jsep(expr).parse();
9486
- var stdClassProps = Object.getOwnPropertyNames(class Test {
9487
- });
9488
- Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
9489
- jsep[m] = Jsep[m];
9490
- });
9491
- jsep.Jsep = Jsep;
9492
- var CONDITIONAL_EXP = "ConditionalExpression";
9493
- var ternary = {
9494
- name: "ternary",
9495
- init(jsep2) {
9496
- jsep2.hooks.add("after-expression", function gobbleTernary(env) {
9497
- if (env.node && this.code === jsep2.QUMARK_CODE) {
9498
- this.index++;
9499
- const test = env.node;
9500
- const consequent = this.gobbleExpression();
9501
- if (!consequent) {
9502
- this.throwError("Expected expression");
9503
- }
9504
- this.gobbleSpaces();
9505
- if (this.code === jsep2.COLON_CODE) {
9506
- this.index++;
9507
- const alternate = this.gobbleExpression();
9508
- if (!alternate) {
9509
- this.throwError("Expected expression");
9510
- }
9511
- env.node = {
9512
- type: CONDITIONAL_EXP,
9513
- test,
9514
- consequent,
9515
- alternate
9516
- };
9517
- if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
9518
- let newTest = test;
9519
- while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
9520
- newTest = newTest.right;
9521
- }
9522
- env.node.test = newTest.right;
9523
- newTest.right = env.node;
9524
- env.node = test;
9525
- }
9526
- } else {
9527
- this.throwError("Expected :");
9528
- }
9529
- }
9530
- });
9531
- }
9532
- };
9533
- jsep.plugins.register(ternary);
9534
- var FSLASH_CODE = 47;
9535
- var BSLASH_CODE = 92;
9536
- var index = {
9537
- name: "regex",
9538
- init(jsep2) {
9539
- jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
9540
- if (this.code === FSLASH_CODE) {
9541
- const patternIndex = ++this.index;
9542
- let inCharSet = false;
9543
- while (this.index < this.expr.length) {
9544
- if (this.code === FSLASH_CODE && !inCharSet) {
9545
- const pattern = this.expr.slice(patternIndex, this.index);
9546
- let flags = "";
9547
- while (++this.index < this.expr.length) {
9548
- const code = this.code;
9549
- if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
9550
- flags += this.char;
9551
- } else {
9552
- break;
9553
- }
9554
- }
9555
- let value;
9556
- try {
9557
- value = new RegExp(pattern, flags);
9558
- } catch (e) {
9559
- this.throwError(e.message);
9560
- }
9561
- env.node = {
9562
- type: jsep2.LITERAL,
9563
- value,
9564
- raw: this.expr.slice(patternIndex - 1, this.index)
9565
- };
9566
- env.node = this.gobbleTokenProperty(env.node);
9567
- return env.node;
9568
- }
9569
- if (this.code === jsep2.OBRACK_CODE) {
9570
- inCharSet = true;
9571
- } else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
9572
- inCharSet = false;
9573
- }
9574
- this.index += this.code === BSLASH_CODE ? 2 : 1;
9575
- }
9576
- this.throwError("Unclosed Regex");
9577
- }
9578
- });
9579
- }
9580
- };
9581
- var PLUS_CODE = 43;
9582
- var MINUS_CODE = 45;
9583
- var plugin = {
9584
- name: "assignment",
9585
- assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
9586
- updateOperators: [PLUS_CODE, MINUS_CODE],
9587
- assignmentPrecedence: 0.9,
9588
- init(jsep2) {
9589
- const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
9590
- plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
9591
- jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
9592
- const code = this.code;
9593
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
9594
- this.index += 2;
9595
- env.node = {
9596
- type: "UpdateExpression",
9597
- operator: code === PLUS_CODE ? "++" : "--",
9598
- argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
9599
- prefix: true
9600
- };
9601
- if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
9602
- this.throwError(`Unexpected ${env.node.operator}`);
9603
- }
9604
- }
9605
- });
9606
- jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
9607
- if (env.node) {
9608
- const code = this.code;
9609
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
9610
- if (!updateNodeTypes.includes(env.node.type)) {
9611
- this.throwError(`Unexpected ${env.node.operator}`);
9612
- }
9613
- this.index += 2;
9614
- env.node = {
9615
- type: "UpdateExpression",
9616
- operator: code === PLUS_CODE ? "++" : "--",
9617
- argument: env.node,
9618
- prefix: false
9619
- };
9620
- }
9621
- }
9622
- });
9623
- jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
9624
- if (env.node) {
9625
- updateBinariesToAssignments(env.node);
9626
- }
9627
- });
9628
- function updateBinariesToAssignments(node) {
9629
- if (plugin.assignmentOperators.has(node.operator)) {
9630
- node.type = "AssignmentExpression";
9631
- updateBinariesToAssignments(node.left);
9632
- updateBinariesToAssignments(node.right);
9633
- } else if (!node.operator) {
9634
- Object.values(node).forEach((val) => {
9635
- if (val && typeof val === "object") {
9636
- updateBinariesToAssignments(val);
9637
- }
9638
- });
9639
- }
9640
- }
9641
- }
9642
- };
9643
- jsep.plugins.register(index, plugin);
9644
- jsep.addUnaryOp("typeof");
9645
- jsep.addUnaryOp("void");
9646
- jsep.addLiteral("null", null);
9647
- jsep.addLiteral("undefined", undefined);
9648
- var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
9649
- var SafeEval = {
9650
- evalAst(ast, subs) {
9651
- switch (ast.type) {
9652
- case "BinaryExpression":
9653
- case "LogicalExpression":
9654
- return SafeEval.evalBinaryExpression(ast, subs);
9655
- case "Compound":
9656
- return SafeEval.evalCompound(ast, subs);
9657
- case "ConditionalExpression":
9658
- return SafeEval.evalConditionalExpression(ast, subs);
9659
- case "Identifier":
9660
- return SafeEval.evalIdentifier(ast, subs);
9661
- case "Literal":
9662
- return SafeEval.evalLiteral(ast, subs);
9663
- case "MemberExpression":
9664
- return SafeEval.evalMemberExpression(ast, subs);
9665
- case "UnaryExpression":
9666
- return SafeEval.evalUnaryExpression(ast, subs);
9667
- case "ArrayExpression":
9668
- return SafeEval.evalArrayExpression(ast, subs);
9669
- case "CallExpression":
9670
- return SafeEval.evalCallExpression(ast, subs);
9671
- case "AssignmentExpression":
9672
- return SafeEval.evalAssignmentExpression(ast, subs);
9673
- default:
9674
- throw SyntaxError("Unexpected expression", ast);
9675
- }
9676
- },
9677
- evalBinaryExpression(ast, subs) {
9678
- const result = {
9679
- "||": (a, b) => a || b(),
9680
- "&&": (a, b) => a && b(),
9681
- "|": (a, b) => a | b(),
9682
- "^": (a, b) => a ^ b(),
9683
- "&": (a, b) => a & b(),
9684
- "==": (a, b) => a == b(),
9685
- "!=": (a, b) => a != b(),
9686
- "===": (a, b) => a === b(),
9687
- "!==": (a, b) => a !== b(),
9688
- "<": (a, b) => a < b(),
9689
- ">": (a, b) => a > b(),
9690
- "<=": (a, b) => a <= b(),
9691
- ">=": (a, b) => a >= b(),
9692
- "<<": (a, b) => a << b(),
9693
- ">>": (a, b) => a >> b(),
9694
- ">>>": (a, b) => a >>> b(),
9695
- "+": (a, b) => a + b(),
9696
- "-": (a, b) => a - b(),
9697
- "*": (a, b) => a * b(),
9698
- "/": (a, b) => a / b(),
9699
- "%": (a, b) => a % b()
9700
- }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
9701
- return result;
9702
- },
9703
- evalCompound(ast, subs) {
9704
- let last;
9705
- for (let i = 0;i < ast.body.length; i++) {
9706
- if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
9707
- i += 1;
9708
- }
9709
- const expr = ast.body[i];
9710
- last = SafeEval.evalAst(expr, subs);
9711
- }
9712
- return last;
9713
- },
9714
- evalConditionalExpression(ast, subs) {
9715
- if (SafeEval.evalAst(ast.test, subs)) {
9716
- return SafeEval.evalAst(ast.consequent, subs);
9717
- }
9718
- return SafeEval.evalAst(ast.alternate, subs);
9719
- },
9720
- evalIdentifier(ast, subs) {
9721
- if (Object.hasOwn(subs, ast.name)) {
9722
- return subs[ast.name];
9723
- }
9724
- throw ReferenceError(`${ast.name} is not defined`);
9725
- },
9726
- evalLiteral(ast) {
9727
- return ast.value;
9728
- },
9729
- evalMemberExpression(ast, subs) {
9730
- const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
9731
- const obj = SafeEval.evalAst(ast.object, subs);
9732
- if (obj === undefined || obj === null) {
9733
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
9734
- }
9735
- if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
9736
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
9737
- }
9738
- const result = obj[prop];
9739
- if (typeof result === "function") {
9740
- return result.bind(obj);
9741
- }
9742
- return result;
9743
- },
9744
- evalUnaryExpression(ast, subs) {
9745
- const result = {
9746
- "-": (a) => -SafeEval.evalAst(a, subs),
9747
- "!": (a) => !SafeEval.evalAst(a, subs),
9748
- "~": (a) => ~SafeEval.evalAst(a, subs),
9749
- "+": (a) => +SafeEval.evalAst(a, subs),
9750
- typeof: (a) => typeof SafeEval.evalAst(a, subs),
9751
- void: (a) => void SafeEval.evalAst(a, subs)
9752
- }[ast.operator](ast.argument);
9753
- return result;
9754
- },
9755
- evalArrayExpression(ast, subs) {
9756
- return ast.elements.map((el) => SafeEval.evalAst(el, subs));
9757
- },
9758
- evalCallExpression(ast, subs) {
9759
- const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
9760
- const func = SafeEval.evalAst(ast.callee, subs);
9761
- if (func === Function) {
9762
- throw new Error("Function constructor is disabled");
9763
- }
9764
- return func(...args);
9765
- },
9766
- evalAssignmentExpression(ast, subs) {
9767
- if (ast.left.type !== "Identifier") {
9768
- throw SyntaxError("Invalid left-hand side in assignment");
9769
- }
9770
- const id = ast.left.name;
9771
- const value = SafeEval.evalAst(ast.right, subs);
9772
- subs[id] = value;
9773
- return subs[id];
9774
- }
9775
- };
9776
-
9777
- class SafeScript {
9778
- constructor(expr) {
9779
- this.code = expr;
9780
- this.ast = jsep(this.code);
9781
- }
9782
- runInNewContext(context) {
9783
- const keyMap = Object.assign(Object.create(null), context);
9784
- return SafeEval.evalAst(this.ast, keyMap);
9785
- }
9786
- }
9787
- function push(arr, item) {
9788
- arr = arr.slice();
9789
- arr.push(item);
9790
- return arr;
9791
- }
9792
- function unshift(item, arr) {
9793
- arr = arr.slice();
9794
- arr.unshift(item);
9795
- return arr;
9796
- }
9797
-
9798
- class NewError extends Error {
9799
- constructor(value) {
9800
- super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');
9801
- this.avoidNew = true;
9802
- this.value = value;
9803
- this.name = "NewError";
9804
- }
9805
- }
9806
- function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
9807
- if (!(this instanceof JSONPath)) {
9808
- try {
9809
- return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
9810
- } catch (e) {
9811
- if (!e.avoidNew) {
9812
- throw e;
9813
- }
9814
- return e.value;
9815
- }
9816
- }
9817
- if (typeof opts === "string") {
9818
- otherTypeCallback = callback;
9819
- callback = obj;
9820
- obj = expr;
9821
- expr = opts;
9822
- opts = null;
9823
- }
9824
- const optObj = opts && typeof opts === "object";
9825
- opts = opts || {};
9826
- this.json = opts.json || obj;
9827
- this.path = opts.path || expr;
9828
- this.resultType = opts.resultType || "value";
9829
- this.flatten = opts.flatten || false;
9830
- this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
9831
- this.sandbox = opts.sandbox || {};
9832
- this.eval = opts.eval === undefined ? "safe" : opts.eval;
9833
- this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
9834
- this.parent = opts.parent || null;
9835
- this.parentProperty = opts.parentProperty || null;
9836
- this.callback = opts.callback || callback || null;
9837
- this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
9838
- throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
9839
- };
9840
- if (opts.autostart !== false) {
9841
- const args = {
9842
- path: optObj ? opts.path : expr
9843
- };
9844
- if (!optObj) {
9845
- args.json = obj;
9846
- } else if ("json" in opts) {
9847
- args.json = opts.json;
9848
- }
9849
- const ret = this.evaluate(args);
9850
- if (!ret || typeof ret !== "object") {
9851
- throw new NewError(ret);
9852
- }
9853
- return ret;
9854
- }
9855
- }
9856
- JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
9857
- let currParent = this.parent, currParentProperty = this.parentProperty;
9858
- let {
9859
- flatten,
9860
- wrap
9861
- } = this;
9862
- this.currResultType = this.resultType;
9863
- this.currEval = this.eval;
9864
- this.currSandbox = this.sandbox;
9865
- callback = callback || this.callback;
9866
- this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
9867
- json = json || this.json;
9868
- expr = expr || this.path;
9869
- if (expr && typeof expr === "object" && !Array.isArray(expr)) {
9870
- if (!expr.path && expr.path !== "") {
9871
- throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
9872
- }
9873
- if (!Object.hasOwn(expr, "json")) {
9874
- throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
9875
- }
9876
- ({
9877
- json
9878
- } = expr);
9879
- flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
9880
- this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
9881
- this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
9882
- wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
9883
- this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
9884
- callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
9885
- this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
9886
- currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
9887
- currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
9888
- expr = expr.path;
9889
- }
9890
- currParent = currParent || null;
9891
- currParentProperty = currParentProperty || null;
9892
- if (Array.isArray(expr)) {
9893
- expr = JSONPath.toPathString(expr);
9894
- }
9895
- if (!expr && expr !== "" || !json) {
9896
- return;
9897
- }
9898
- const exprList = JSONPath.toPathArray(expr);
9899
- if (exprList[0] === "$" && exprList.length > 1) {
9900
- exprList.shift();
9901
- }
9902
- this._hasParentSelector = null;
9903
- const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
9904
- return ea && !ea.isParentSelector;
9905
- });
9906
- if (!result.length) {
9907
- return wrap ? [] : undefined;
9908
- }
9909
- if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
9910
- return this._getPreferredOutput(result[0]);
9911
- }
9912
- return result.reduce((rslt, ea) => {
9913
- const valOrPath = this._getPreferredOutput(ea);
9914
- if (flatten && Array.isArray(valOrPath)) {
9915
- rslt = rslt.concat(valOrPath);
9916
- } else {
9917
- rslt.push(valOrPath);
9918
- }
9919
- return rslt;
9920
- }, []);
9921
- };
9922
- JSONPath.prototype._getPreferredOutput = function(ea) {
9923
- const resultType = this.currResultType;
9924
- switch (resultType) {
9925
- case "all": {
9926
- const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
9927
- ea.pointer = JSONPath.toPointer(path3);
9928
- ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
9929
- return ea;
9930
- }
9931
- case "value":
9932
- case "parent":
9933
- case "parentProperty":
9934
- return ea[resultType];
9935
- case "path":
9936
- return JSONPath.toPathString(ea[resultType]);
9937
- case "pointer":
9938
- return JSONPath.toPointer(ea.path);
9939
- default:
9940
- throw new TypeError("Unknown result type");
9941
- }
9942
- };
9943
- JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
9944
- if (callback) {
9945
- const preferredOutput = this._getPreferredOutput(fullRetObj);
9946
- fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
9947
- callback(preferredOutput, type, fullRetObj);
9948
- }
9949
- };
9950
- JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
9951
- let retObj;
9952
- if (!expr.length) {
9953
- retObj = {
9954
- path: path3,
9955
- value: val,
9956
- parent,
9957
- parentProperty: parentPropName,
9958
- hasArrExpr
9959
- };
9960
- this._handleCallback(retObj, callback, "value");
9961
- return retObj;
9962
- }
9963
- const loc = expr[0], x = expr.slice(1);
9964
- const ret = [];
9965
- function addRet(elems) {
9966
- if (Array.isArray(elems)) {
9967
- elems.forEach((t) => {
9968
- ret.push(t);
9969
- });
9970
- } else {
9971
- ret.push(elems);
9972
- }
9973
- }
9974
- if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
9975
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
9976
- } else if (loc === "*") {
9977
- this._walk(val, (m) => {
9978
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
9979
- });
9980
- } else if (loc === "..") {
9981
- addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
9982
- this._walk(val, (m) => {
9983
- if (typeof val[m] === "object") {
9984
- addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
9985
- }
9986
- });
9987
- } else if (loc === "^") {
9988
- this._hasParentSelector = true;
9989
- return {
9990
- path: path3.slice(0, -1),
9991
- expr: x,
9992
- isParentSelector: true
9993
- };
9994
- } else if (loc === "~") {
9995
- retObj = {
9996
- path: push(path3, loc),
9997
- value: parentPropName,
9998
- parent,
9999
- parentProperty: null
10000
- };
10001
- this._handleCallback(retObj, callback, "property");
10002
- return retObj;
10003
- } else if (loc === "$") {
10004
- addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
10005
- } else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
10006
- addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
10007
- } else if (loc.indexOf("?(") === 0) {
10008
- if (this.currEval === false) {
10009
- throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
10010
- }
10011
- const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
10012
- const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
10013
- if (nested) {
10014
- this._walk(val, (m) => {
10015
- const npath = [nested[2]];
10016
- const nvalue = nested[1] ? val[m][nested[1]] : val[m];
10017
- const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
10018
- if (filterResults.length > 0) {
10019
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
10020
- }
10021
- });
10022
- } else {
10023
- this._walk(val, (m) => {
10024
- if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
10025
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
10026
- }
10027
- });
10028
- }
10029
- } else if (loc[0] === "(") {
10030
- if (this.currEval === false) {
10031
- throw new Error("Eval [(expr)] prevented in JSONPath expression.");
10032
- }
10033
- addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
10034
- } else if (loc[0] === "@") {
10035
- let addType = false;
10036
- const valueType = loc.slice(1, -2);
10037
- switch (valueType) {
10038
- case "scalar":
10039
- if (!val || !["object", "function"].includes(typeof val)) {
10040
- addType = true;
10041
- }
10042
- break;
10043
- case "boolean":
10044
- case "string":
10045
- case "undefined":
10046
- case "function":
10047
- if (typeof val === valueType) {
10048
- addType = true;
10049
- }
10050
- break;
10051
- case "integer":
10052
- if (Number.isFinite(val) && !(val % 1)) {
10053
- addType = true;
10054
- }
10055
- break;
10056
- case "number":
10057
- if (Number.isFinite(val)) {
10058
- addType = true;
10059
- }
10060
- break;
10061
- case "nonFinite":
10062
- if (typeof val === "number" && !Number.isFinite(val)) {
10063
- addType = true;
10064
- }
10065
- break;
10066
- case "object":
10067
- if (val && typeof val === valueType) {
10068
- addType = true;
10069
- }
10070
- break;
10071
- case "array":
10072
- if (Array.isArray(val)) {
10073
- addType = true;
10074
- }
10075
- break;
10076
- case "other":
10077
- addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
10078
- break;
10079
- case "null":
10080
- if (val === null) {
10081
- addType = true;
10082
- }
10083
- break;
10084
- default:
10085
- throw new TypeError("Unknown value type " + valueType);
10086
- }
10087
- if (addType) {
10088
- retObj = {
10089
- path: path3,
10090
- value: val,
10091
- parent,
10092
- parentProperty: parentPropName
10093
- };
10094
- this._handleCallback(retObj, callback, "value");
10095
- return retObj;
10096
- }
10097
- } else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
10098
- const locProp = loc.slice(1);
10099
- addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
10100
- } else if (loc.includes(",")) {
10101
- const parts = loc.split(",");
10102
- for (const part of parts) {
10103
- addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
10104
- }
10105
- } else if (!literalPriority && val && Object.hasOwn(val, loc)) {
10106
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
10107
- }
10108
- if (this._hasParentSelector) {
10109
- for (let t = 0;t < ret.length; t++) {
10110
- const rett = ret[t];
10111
- if (rett && rett.isParentSelector) {
10112
- const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
10113
- if (Array.isArray(tmp)) {
10114
- ret[t] = tmp[0];
10115
- const tl = tmp.length;
10116
- for (let tt = 1;tt < tl; tt++) {
10117
- t++;
10118
- ret.splice(t, 0, tmp[tt]);
10119
- }
10120
- } else {
10121
- ret[t] = tmp;
10122
- }
10123
- }
10124
- }
10125
- }
10126
- return ret;
10127
- };
10128
- JSONPath.prototype._walk = function(val, f) {
10129
- if (Array.isArray(val)) {
10130
- const n = val.length;
10131
- for (let i = 0;i < n; i++) {
10132
- f(i);
10133
- }
10134
- } else if (val && typeof val === "object") {
10135
- Object.keys(val).forEach((m) => {
10136
- f(m);
10137
- });
10138
- }
10139
- };
10140
- JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
10141
- if (!Array.isArray(val)) {
10142
- return;
10143
- }
10144
- const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
10145
- let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
10146
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
10147
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
10148
- const ret = [];
10149
- for (let i = start;i < end; i += step) {
10150
- const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
10151
- tmp.forEach((t) => {
10152
- ret.push(t);
10153
- });
10154
- }
10155
- return ret;
10156
- };
10157
- JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
10158
- this.currSandbox._$_parentProperty = parentPropName;
10159
- this.currSandbox._$_parent = parent;
10160
- this.currSandbox._$_property = _vname;
10161
- this.currSandbox._$_root = this.json;
10162
- this.currSandbox._$_v = _v;
10163
- const containsPath = code.includes("@path");
10164
- if (containsPath) {
10165
- this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
10166
- }
10167
- const scriptCacheKey = this.currEval + "Script:" + code;
10168
- if (!JSONPath.cache[scriptCacheKey]) {
10169
- let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
10170
- if (containsPath) {
10171
- script = script.replaceAll("@path", "_$_path");
10172
- }
10173
- if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
10174
- JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
10175
- } else if (this.currEval === "native") {
10176
- JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
10177
- } else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
10178
- const CurrEval = this.currEval;
10179
- JSONPath.cache[scriptCacheKey] = new CurrEval(script);
10180
- } else if (typeof this.currEval === "function") {
10181
- JSONPath.cache[scriptCacheKey] = {
10182
- runInNewContext: (context) => this.currEval(script, context)
10183
- };
10184
- } else {
10185
- throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
10186
- }
10187
- }
10188
- try {
10189
- return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
10190
- } catch (e) {
10191
- if (this.ignoreEvalErrors) {
10192
- return false;
10193
- }
10194
- throw new Error("jsonPath: " + e.message + ": " + code);
10195
- }
10196
- };
10197
- JSONPath.cache = {};
10198
- JSONPath.toPathString = function(pathArr) {
10199
- const x = pathArr, n = x.length;
10200
- let p = "$";
10201
- for (let i = 1;i < n; i++) {
10202
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
10203
- p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
10204
- }
10205
- }
10206
- return p;
10207
- };
10208
- JSONPath.toPointer = function(pointer) {
10209
- const x = pointer, n = x.length;
10210
- let p = "";
10211
- for (let i = 1;i < n; i++) {
10212
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
10213
- p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
10214
- }
10215
- }
10216
- return p;
10217
- };
10218
- JSONPath.toPathArray = function(expr) {
10219
- const {
10220
- cache
10221
- } = JSONPath;
10222
- if (cache[expr]) {
10223
- return cache[expr].concat();
10224
- }
10225
- const subx = [];
10226
- const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
10227
- return "[#" + (subx.push($1) - 1) + "]";
10228
- }).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
10229
- return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
10230
- }).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
10231
- return ";" + ups.split("").join(";") + ";";
10232
- }).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
10233
- const exprList = normalized.split(";").map(function(exp) {
10234
- const match = exp.match(/#(\d+)/u);
10235
- return !match || !match[1] ? exp : subx[match[1]];
10236
- });
10237
- cache[expr] = exprList;
10238
- return cache[expr].concat();
10239
- };
10240
- JSONPath.prototype.safeVm = {
10241
- Script: SafeScript
10242
- };
10243
- JSONPath.prototype.vm = vm;
10244
8924
  function warnDeprecatedOptionAlias(deprecatedFlag, preferredFlag) {
10245
8925
  getOutputSink().writeErr(`[WARN] ${deprecatedFlag} is deprecated. Use ${preferredFlag} instead.
10246
8926
  `);
@@ -10287,6 +8967,16 @@ var FAILURE_STATUSES = new Set([
10287
8967
  "canceled",
10288
8968
  "stopped"
10289
8969
  ]);
8970
+ var previewSlot = singleton("PreviewBuild");
8971
+ function isPreviewBuild() {
8972
+ return previewSlot.get(false) ?? false;
8973
+ }
8974
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
8975
+ if (isPreviewBuild()) {
8976
+ return this.command(nameAndArgs, opts);
8977
+ }
8978
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
8979
+ };
10290
8980
  var ScreenLogger;
10291
8981
  ((ScreenLogger2) => {
10292
8982
  function progress(message) {
@@ -11135,7 +9825,6 @@ import { execFile as execFile53 } from "node:child_process";
11135
9825
  import process73 from "node:process";
11136
9826
  import { execFileSync as execFileSync22 } from "node:child_process";
11137
9827
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
11138
- import vm2 from "vm";
11139
9828
  import { createRequire as createRequire22 } from "module";
11140
9829
  var __create3 = Object.create;
11141
9830
  var __getProtoOf3 = Object.getPrototypeOf;
@@ -12565,11 +11254,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
12565
11254
  };
12566
11255
  this._checkNumberOfArguments();
12567
11256
  const processedArgs = [];
12568
- this.registeredArguments.forEach((declaredArg, index2) => {
11257
+ this.registeredArguments.forEach((declaredArg, index) => {
12569
11258
  let value = declaredArg.defaultValue;
12570
11259
  if (declaredArg.variadic) {
12571
- if (index2 < this.args.length) {
12572
- value = this.args.slice(index2);
11260
+ if (index < this.args.length) {
11261
+ value = this.args.slice(index);
12573
11262
  if (declaredArg.parseArg) {
12574
11263
  value = value.reduce((processed, v) => {
12575
11264
  return myParseArg(declaredArg, v, processed);
@@ -12578,13 +11267,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
12578
11267
  } else if (value === undefined) {
12579
11268
  value = [];
12580
11269
  }
12581
- } else if (index2 < this.args.length) {
12582
- value = this.args[index2];
11270
+ } else if (index < this.args.length) {
11271
+ value = this.args[index];
12583
11272
  if (declaredArg.parseArg) {
12584
11273
  value = myParseArg(declaredArg, value, declaredArg.defaultValue);
12585
11274
  }
12586
11275
  }
12587
- processedArgs[index2] = value;
11276
+ processedArgs[index] = value;
12588
11277
  });
12589
11278
  this.processedArgs = processedArgs;
12590
11279
  }
@@ -12596,16 +11285,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
12596
11285
  }
12597
11286
  _chainOrCallHooks(promise, event) {
12598
11287
  let result = promise;
12599
- const hooks2 = [];
11288
+ const hooks = [];
12600
11289
  this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
12601
11290
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
12602
- hooks2.push({ hookedCommand, callback });
11291
+ hooks.push({ hookedCommand, callback });
12603
11292
  });
12604
11293
  });
12605
11294
  if (event === "postAction") {
12606
- hooks2.reverse();
11295
+ hooks.reverse();
12607
11296
  }
12608
- hooks2.forEach((hookDetail) => {
11297
+ hooks.forEach((hookDetail) => {
12609
11298
  result = this._chainOrCall(result, () => {
12610
11299
  return hookDetail.callback(hookDetail.hookedCommand, this);
12611
11300
  });
@@ -12791,10 +11480,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
12791
11480
  }
12792
11481
  }
12793
11482
  if (/^--[^=]+=/.test(arg)) {
12794
- const index2 = arg.indexOf("=");
12795
- const option = this._findOption(arg.slice(0, index2));
11483
+ const index = arg.indexOf("=");
11484
+ const option = this._findOption(arg.slice(0, index));
12796
11485
  if (option && (option.required || option.optional)) {
12797
- this.emit(`option:${option.name()}`, arg.slice(index2 + 1));
11486
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
12798
11487
  continue;
12799
11488
  }
12800
11489
  }
@@ -13277,6 +11966,10 @@ function singleton2(ctorOrName) {
13277
11966
  }
13278
11967
  };
13279
11968
  }
11969
+ var telemetryPropsSlot2 = singleton2("TelemetryDefaultProps");
11970
+ function getGlobalTelemetryProperties2() {
11971
+ return telemetryPropsSlot2.get();
11972
+ }
13280
11973
  var USER_AGENT_HEADER = "User-Agent";
13281
11974
  var sdkUserAgentHostToken2 = singleton2("SdkUserAgentHostToken");
13282
11975
  function userAgentPatchKey(userAgent) {
@@ -13299,8 +11992,8 @@ function appendUserAgentToken(value, userAgent) {
13299
11992
  function getEffectiveUserAgent(userAgent) {
13300
11993
  return appendUserAgentToken(sdkUserAgentHostToken2.get(), userAgent);
13301
11994
  }
13302
- function isHeadersLike(headers) {
13303
- return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
11995
+ function getHeaderName(headers, headerName) {
11996
+ return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
13304
11997
  }
13305
11998
  function getSdkUserAgentToken(pkg) {
13306
11999
  const packageName = pkg.name.replace(/^@uipath\//, "");
@@ -13308,59 +12001,31 @@ function getSdkUserAgentToken(pkg) {
13308
12001
  }
13309
12002
  function addSdkUserAgentHeader(headers, userAgent) {
13310
12003
  const result = { ...headers ?? {} };
13311
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
13312
- const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
13313
- if (headerName) {
13314
- result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
13315
- } else {
13316
- result[USER_AGENT_HEADER] = effectiveUserAgent;
13317
- }
12004
+ const headerName = getHeaderName(result, USER_AGENT_HEADER);
12005
+ result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
13318
12006
  return result;
13319
12007
  }
13320
- function withSdkUserAgentHeader(headers, userAgent) {
13321
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
13322
- if (isHeadersLike(headers)) {
13323
- headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
13324
- return headers;
13325
- }
13326
- if (Array.isArray(headers)) {
13327
- const result = headers.map((entry) => {
13328
- const [key, value] = entry;
13329
- return [key, value];
13330
- });
13331
- const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
13332
- if (headerIndex >= 0) {
13333
- const [key, value] = result[headerIndex];
13334
- result[headerIndex] = [
13335
- key,
13336
- appendUserAgentToken(value, effectiveUserAgent)
13337
- ];
13338
- } else {
13339
- result.push([USER_AGENT_HEADER, effectiveUserAgent]);
13340
- }
13341
- return result;
13342
- }
13343
- return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
12008
+ function asHeaderRecord(headers) {
12009
+ return typeof headers === "object" && headers !== null ? { ...headers } : {};
13344
12010
  }
13345
- function withUserAgentInitOverride(initOverrides, userAgent) {
12011
+ function withForwardedHeadersInitOverride(initOverrides, forward) {
13346
12012
  return async (requestContext) => {
13347
- const initWithUserAgent = {
12013
+ const initWithHeaders = {
13348
12014
  ...requestContext.init,
13349
- headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
12015
+ headers: forward(asHeaderRecord(requestContext.init.headers))
13350
12016
  };
13351
12017
  const override = typeof initOverrides === "function" ? await initOverrides({
13352
12018
  ...requestContext,
13353
- init: initWithUserAgent
12019
+ init: initWithHeaders
13354
12020
  }) : initOverrides;
13355
12021
  return {
13356
12022
  ...override ?? {},
13357
- headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
12023
+ headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
13358
12024
  };
13359
12025
  };
13360
12026
  }
13361
- function installSdkUserAgentHeader(BaseApiClass, userAgent) {
12027
+ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
13362
12028
  const prototype = BaseApiClass.prototype;
13363
- const patchKey = userAgentPatchKey(userAgent);
13364
12029
  if (prototype[patchKey]) {
13365
12030
  return;
13366
12031
  }
@@ -13368,13 +12033,16 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
13368
12033
  throw new Error("Generated BaseAPI request function not found.");
13369
12034
  }
13370
12035
  const originalRequest = prototype.request;
13371
- prototype.request = function requestWithUserAgent(context, initOverrides) {
13372
- return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
12036
+ prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
12037
+ return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
13373
12038
  };
13374
12039
  Object.defineProperty(prototype, patchKey, {
13375
12040
  value: true
13376
12041
  });
13377
12042
  }
12043
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
12044
+ installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
12045
+ }
13378
12046
  var BASE_PATH = "https://alpha.uipath.com/uipattycyrhx/abizon_1/automationsolutions_".replace(/\/+$/, "");
13379
12047
 
13380
12048
  class Configuration {
@@ -13596,7 +12264,7 @@ function querystringSingleKey(key, value, keyPrefix = "") {
13596
12264
  var package_default2 = {
13597
12265
  name: "@uipath/solution-sdk",
13598
12266
  license: "MIT",
13599
- version: "1.196.0",
12267
+ version: "1.197.0-preview.59",
13600
12268
  repository: {
13601
12269
  type: "git",
13602
12270
  url: "https://github.com/UiPath/cli.git",
@@ -13627,7 +12295,7 @@ var package_default2 = {
13627
12295
  ],
13628
12296
  private: false,
13629
12297
  scripts: {
13630
- build: "bun build ./src/index.ts --outdir dist --format esm --target node && bun build ./src/scripts/generate-sdk.ts --outdir dist/scripts --format esm --target node && tsc -p tsconfig.build.json --noCheck",
12298
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && bun build ./src/scripts/generate-sdk.ts --outdir dist/scripts --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
13631
12299
  generate: "bun run src/scripts/generate-sdk.ts",
13632
12300
  lint: "biome check .",
13633
12301
  test: "vitest run",
@@ -14445,6 +13113,18 @@ var NETWORK_ERROR_CODES2 = new Set([
14445
13113
  "ENETUNREACH",
14446
13114
  "EAI_FAIL"
14447
13115
  ]);
13116
+ var TLS_ERROR_CODES2 = new Set([
13117
+ "SELF_SIGNED_CERT_IN_CHAIN",
13118
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
13119
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
13120
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
13121
+ "UNABLE_TO_GET_ISSUER_CERT",
13122
+ "CERT_HAS_EXPIRED",
13123
+ "CERT_UNTRUSTED",
13124
+ "ERR_TLS_CERT_ALTNAME_INVALID"
13125
+ ]);
13126
+ var TLS_INSTRUCTIONS2 = "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.";
13127
+ var NETWORK_INSTRUCTIONS2 = "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.";
14448
13128
  var import__2 = __toESM3(require_commander2(), 1);
14449
13129
  var {
14450
13130
  program: program2,
@@ -14485,6 +13165,7 @@ var CONSOLE_FALLBACK2 = {
14485
13165
  writeLog: (str) => process.stdout.write(str),
14486
13166
  capabilities: {
14487
13167
  isInteractive: false,
13168
+ canReadInput: false,
14488
13169
  supportsColor: false,
14489
13170
  outputWidth: 80
14490
13171
  }
@@ -15291,18 +13972,18 @@ var TokenParser2 = class _TokenParser2 {
15291
13972
  }
15292
13973
  parseSliceExpression() {
15293
13974
  const parts = [null, null, null];
15294
- let index2 = 0;
13975
+ let index = 0;
15295
13976
  let current = this.lookaheadToken(0);
15296
- while (current.type != "Rbracket" && index2 < 3) {
13977
+ while (current.type != "Rbracket" && index < 3) {
15297
13978
  if (current.type === "Colon") {
15298
- index2++;
15299
- if (index2 === 3) {
13979
+ index++;
13980
+ if (index === 3) {
15300
13981
  this.errorToken(this.lookaheadToken(0), "Syntax error, too many colons in slice expression");
15301
13982
  }
15302
13983
  this.advance();
15303
13984
  } else if (current.type === "Number") {
15304
13985
  const part = this.lookaheadToken(0).value;
15305
- parts[index2] = part;
13986
+ parts[index] = part;
15306
13987
  this.advance();
15307
13988
  } else {
15308
13989
  const next = this.lookaheadToken(0);
@@ -15459,11 +14140,11 @@ var Text2 = class _Text2 {
15459
14140
  static compare(left, right) {
15460
14141
  const leftCp = left.codePoints;
15461
14142
  const rightCp = right.codePoints;
15462
- for (let index2 = 0;index2 < Math.min(leftCp.length, rightCp.length); index2++) {
15463
- if (leftCp[index2] === rightCp[index2]) {
14143
+ for (let index = 0;index < Math.min(leftCp.length, rightCp.length); index++) {
14144
+ if (leftCp[index] === rightCp[index]) {
15464
14145
  continue;
15465
14146
  }
15466
- return leftCp[index2] - rightCp[index2] > 0 ? 1 : -1;
14147
+ return leftCp[index] - rightCp[index] > 0 ? 1 : -1;
15467
14148
  }
15468
14149
  return leftCp.length - rightCp.length > 0 ? 1 : -1;
15469
14150
  }
@@ -16123,7 +14804,7 @@ var Runtime2 = class {
16123
14804
  };
16124
14805
  functionZip = (array) => {
16125
14806
  const length = Math.min(...array.map((arr) => arr.length));
16126
- const result = Array(length).fill(null).map((_, index2) => array.map((arr) => arr[index2]));
14807
+ const result = Array(length).fill(null).map((_, index) => array.map((arr) => arr[index]));
16127
14808
  return result;
16128
14809
  };
16129
14810
  };
@@ -16219,8 +14900,8 @@ var TreeInterpreter2 = class _TreeInterpreter2 {
16219
14900
  if (!Array.isArray(value)) {
16220
14901
  return null;
16221
14902
  }
16222
- const index2 = node.value < 0 ? value.length + node.value : node.value;
16223
- return value[index2] ?? null;
14903
+ const index = node.value < 0 ? value.length + node.value : node.value;
14904
+ return value[index] ?? null;
16224
14905
  }
16225
14906
  case "Slice": {
16226
14907
  if (!Array.isArray(value) && typeof value !== "string") {
@@ -16492,8 +15173,8 @@ var require_common2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
16492
15173
  function extend(target, source) {
16493
15174
  if (source) {
16494
15175
  const sourceKeys = Object.keys(source);
16495
- for (let index2 = 0, length = sourceKeys.length;index2 < length; index2 += 1) {
16496
- const key = sourceKeys[index2];
15176
+ for (let index = 0, length = sourceKeys.length;index < length; index += 1) {
15177
+ const key = sourceKeys[index];
16497
15178
  target[key] = source[key];
16498
15179
  }
16499
15180
  }
@@ -16712,8 +15393,8 @@ var require_schema2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
16712
15393
  } else
16713
15394
  result[type.kind][type.tag] = result["fallback"][type.tag] = type;
16714
15395
  }
16715
- for (let index2 = 0, length = arguments.length;index2 < length; index2 += 1)
16716
- arguments[index2].forEach(collectType);
15396
+ for (let index = 0, length = arguments.length;index < length; index += 1)
15397
+ arguments[index].forEach(collectType);
16717
15398
  return result;
16718
15399
  }
16719
15400
  function Schema2(definition) {
@@ -16874,21 +15555,21 @@ var require_int2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
16874
15555
  if (data === null)
16875
15556
  return false;
16876
15557
  const max = data.length;
16877
- let index2 = 0;
15558
+ let index = 0;
16878
15559
  let hasDigits = false;
16879
15560
  if (!max)
16880
15561
  return false;
16881
- let ch = data[index2];
15562
+ let ch = data[index];
16882
15563
  if (ch === "-" || ch === "+")
16883
- ch = data[++index2];
15564
+ ch = data[++index];
16884
15565
  if (ch === "0") {
16885
- if (index2 + 1 === max)
15566
+ if (index + 1 === max)
16886
15567
  return true;
16887
- ch = data[++index2];
15568
+ ch = data[++index];
16888
15569
  if (ch === "b") {
16889
- index2++;
16890
- for (;index2 < max; index2++) {
16891
- ch = data[index2];
15570
+ index++;
15571
+ for (;index < max; index++) {
15572
+ ch = data[index];
16892
15573
  if (ch !== "0" && ch !== "1")
16893
15574
  return false;
16894
15575
  hasDigits = true;
@@ -16896,26 +15577,26 @@ var require_int2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
16896
15577
  return hasDigits && Number.isFinite(parseYamlInteger(data));
16897
15578
  }
16898
15579
  if (ch === "x") {
16899
- index2++;
16900
- for (;index2 < max; index2++) {
16901
- if (!isHexCode(data.charCodeAt(index2)))
15580
+ index++;
15581
+ for (;index < max; index++) {
15582
+ if (!isHexCode(data.charCodeAt(index)))
16902
15583
  return false;
16903
15584
  hasDigits = true;
16904
15585
  }
16905
15586
  return hasDigits && Number.isFinite(parseYamlInteger(data));
16906
15587
  }
16907
15588
  if (ch === "o") {
16908
- index2++;
16909
- for (;index2 < max; index2++) {
16910
- if (!isOctCode(data.charCodeAt(index2)))
15589
+ index++;
15590
+ for (;index < max; index++) {
15591
+ if (!isOctCode(data.charCodeAt(index)))
16911
15592
  return false;
16912
15593
  hasDigits = true;
16913
15594
  }
16914
15595
  return hasDigits && Number.isFinite(parseYamlInteger(data));
16915
15596
  }
16916
15597
  }
16917
- for (;index2 < max; index2++) {
16918
- if (!isDecCode(data.charCodeAt(index2)))
15598
+ for (;index < max; index++) {
15599
+ if (!isDecCode(data.charCodeAt(index)))
16919
15600
  return false;
16920
15601
  hasDigits = true;
16921
15602
  }
@@ -17228,8 +15909,8 @@ var require_omap2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17228
15909
  return true;
17229
15910
  const objectKeys = [];
17230
15911
  const object = data;
17231
- for (let index2 = 0, length = object.length;index2 < length; index2 += 1) {
17232
- const pair = object[index2];
15912
+ for (let index = 0, length = object.length;index < length; index += 1) {
15913
+ const pair = object[index];
17233
15914
  let pairHasKey = false;
17234
15915
  if (_toString.call(pair) !== "[object Object]")
17235
15916
  return false;
@@ -17266,14 +15947,14 @@ var require_pairs2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17266
15947
  return true;
17267
15948
  const object = data;
17268
15949
  const result = new Array(object.length);
17269
- for (let index2 = 0, length = object.length;index2 < length; index2 += 1) {
17270
- const pair = object[index2];
15950
+ for (let index = 0, length = object.length;index < length; index += 1) {
15951
+ const pair = object[index];
17271
15952
  if (_toString.call(pair) !== "[object Object]")
17272
15953
  return false;
17273
15954
  const keys = Object.keys(pair);
17274
15955
  if (keys.length !== 1)
17275
15956
  return false;
17276
- result[index2] = [keys[0], pair[keys[0]]];
15957
+ result[index] = [keys[0], pair[keys[0]]];
17277
15958
  }
17278
15959
  return true;
17279
15960
  }
@@ -17282,10 +15963,10 @@ var require_pairs2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17282
15963
  return [];
17283
15964
  const object = data;
17284
15965
  const result = new Array(object.length);
17285
- for (let index2 = 0, length = object.length;index2 < length; index2 += 1) {
17286
- const pair = object[index2];
15966
+ for (let index = 0, length = object.length;index < length; index += 1) {
15967
+ const pair = object[index];
17287
15968
  const keys = Object.keys(pair);
17288
- result[index2] = [keys[0], pair[keys[0]]];
15969
+ result[index] = [keys[0], pair[keys[0]]];
17289
15970
  }
17290
15971
  return result;
17291
15972
  }
@@ -17511,8 +16192,8 @@ var require_loader2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17511
16192
  return;
17512
16193
  const parent = transactions[transactions.length - 1];
17513
16194
  const names = Object.keys(transaction);
17514
- for (let index2 = 0, length = names.length;index2 < length; index2 += 1) {
17515
- const name = names[index2];
16195
+ for (let index = 0, length = names.length;index < length; index += 1) {
16196
+ const name = names[index];
17516
16197
  if (!_hasOwnProperty.call(parent, name))
17517
16198
  parent[name] = transaction[name];
17518
16199
  }
@@ -17520,12 +16201,12 @@ var require_loader2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17520
16201
  function rollbackAnchorTransaction(state) {
17521
16202
  const transaction = state.anchorMapTransactions.pop();
17522
16203
  const names = Object.keys(transaction);
17523
- for (let index2 = names.length - 1;index2 >= 0; index2 -= 1) {
17524
- const entry = transaction[names[index2]];
16204
+ for (let index = names.length - 1;index >= 0; index -= 1) {
16205
+ const entry = transaction[names[index]];
17525
16206
  if (entry.existed)
17526
- state.anchorMap[names[index2]] = entry.value;
16207
+ state.anchorMap[names[index]] = entry.value;
17527
16208
  else
17528
- delete state.anchorMap[names[index2]];
16209
+ delete state.anchorMap[names[index]];
17529
16210
  }
17530
16211
  }
17531
16212
  function snapshotState(state) {
@@ -17608,8 +16289,8 @@ var require_loader2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17608
16289
  if (!common.isObject(source))
17609
16290
  throwError(state, "cannot merge mappings; the provided source object is unacceptable");
17610
16291
  const sourceKeys = Object.keys(source);
17611
- for (let index2 = 0, quantity = sourceKeys.length;index2 < quantity; index2 += 1) {
17612
- const key = sourceKeys[index2];
16292
+ for (let index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
16293
+ const key = sourceKeys[index];
17613
16294
  if (!_hasOwnProperty.call(destination, key)) {
17614
16295
  setProperty(destination, key, source[key]);
17615
16296
  overridableKeys[key] = true;
@@ -17619,11 +16300,11 @@ var require_loader2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17619
16300
  function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
17620
16301
  if (Array.isArray(keyNode)) {
17621
16302
  keyNode = Array.prototype.slice.call(keyNode);
17622
- for (let index2 = 0, quantity = keyNode.length;index2 < quantity; index2 += 1) {
17623
- if (Array.isArray(keyNode[index2]))
16303
+ for (let index = 0, quantity = keyNode.length;index < quantity; index += 1) {
16304
+ if (Array.isArray(keyNode[index]))
17624
16305
  throwError(state, "nested arrays are not supported inside keys");
17625
- if (typeof keyNode === "object" && _class(keyNode[index2]) === "[object Object]")
17626
- keyNode[index2] = "[object Object]";
16306
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]")
16307
+ keyNode[index] = "[object Object]";
17627
16308
  }
17628
16309
  }
17629
16310
  if (typeof keyNode === "object" && _class(keyNode) === "[object Object]")
@@ -17636,8 +16317,8 @@ var require_loader2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
17636
16317
  if (valueNode.length > state.maxMergeSeqLength)
17637
16318
  throwError(state, "merge sequence length exceeded maxMergeSeqLength (" + state.maxMergeSeqLength + ")");
17638
16319
  const seen = /* @__PURE__ */ new Set;
17639
- for (let index2 = 0, quantity = valueNode.length;index2 < quantity; index2 += 1) {
17640
- const src = valueNode[index2];
16320
+ for (let index = 0, quantity = valueNode.length;index < quantity; index += 1) {
16321
+ const src = valueNode[index];
17641
16322
  if (seen.has(src))
17642
16323
  continue;
17643
16324
  seen.add(src);
@@ -18555,8 +17236,8 @@ var require_loader2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18555
17236
  const documents = loadDocuments(input, options);
18556
17237
  if (typeof iterator !== "function")
18557
17238
  return documents;
18558
- for (let index2 = 0, length = documents.length;index2 < length; index2 += 1)
18559
- iterator(documents[index2]);
17239
+ for (let index = 0, length = documents.length;index < length; index += 1)
17240
+ iterator(documents[index]);
18560
17241
  }
18561
17242
  function load2(input, options) {
18562
17243
  const documents = loadDocuments(input, options);
@@ -18640,8 +17321,8 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18640
17321
  return {};
18641
17322
  const result = {};
18642
17323
  const keys = Object.keys(map);
18643
- for (let index2 = 0, length = keys.length;index2 < length; index2 += 1) {
18644
- let tag = keys[index2];
17324
+ for (let index = 0, length = keys.length;index < length; index += 1) {
17325
+ let tag = keys[index];
18645
17326
  let style = String(map[tag]);
18646
17327
  if (tag.slice(0, 2) === "!!")
18647
17328
  tag = "tag:yaml.org,2002:" + tag.slice(2);
@@ -18721,8 +17402,8 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18721
17402
  ` + common.repeat(" ", state.indent * level);
18722
17403
  }
18723
17404
  function testImplicitResolving(state, str) {
18724
- for (let index2 = 0, length = state.implicitTypes.length;index2 < length; index2 += 1)
18725
- if (state.implicitTypes[index2].resolve(str))
17405
+ for (let index = 0, length = state.implicitTypes.length;index < length; index += 1)
17406
+ if (state.implicitTypes[index].resolve(str))
18726
17407
  return true;
18727
17408
  return false;
18728
17409
  }
@@ -18921,10 +17602,10 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18921
17602
  function writeFlowSequence(state, level, object) {
18922
17603
  let _result = "";
18923
17604
  const _tag = state.tag;
18924
- for (let index2 = 0, length = object.length;index2 < length; index2 += 1) {
18925
- let value = object[index2];
17605
+ for (let index = 0, length = object.length;index < length; index += 1) {
17606
+ let value = object[index];
18926
17607
  if (state.replacer)
18927
- value = state.replacer.call(object, String(index2), value);
17608
+ value = state.replacer.call(object, String(index), value);
18928
17609
  if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
18929
17610
  if (_result !== "")
18930
17611
  _result += "," + (!state.condenseFlow ? " " : "");
@@ -18937,10 +17618,10 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18937
17618
  function writeBlockSequence(state, level, object, compact) {
18938
17619
  let _result = "";
18939
17620
  const _tag = state.tag;
18940
- for (let index2 = 0, length = object.length;index2 < length; index2 += 1) {
18941
- let value = object[index2];
17621
+ for (let index = 0, length = object.length;index < length; index += 1) {
17622
+ let value = object[index];
18942
17623
  if (state.replacer)
18943
- value = state.replacer.call(object, String(index2), value);
17624
+ value = state.replacer.call(object, String(index), value);
18944
17625
  if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
18945
17626
  if (!compact || _result !== "")
18946
17627
  _result += generateNextLine(state, level);
@@ -18958,13 +17639,13 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18958
17639
  let _result = "";
18959
17640
  const _tag = state.tag;
18960
17641
  const objectKeyList = Object.keys(object);
18961
- for (let index2 = 0, length = objectKeyList.length;index2 < length; index2 += 1) {
17642
+ for (let index = 0, length = objectKeyList.length;index < length; index += 1) {
18962
17643
  let pairBuffer = "";
18963
17644
  if (_result !== "")
18964
17645
  pairBuffer += ", ";
18965
17646
  if (state.condenseFlow)
18966
17647
  pairBuffer += '"';
18967
- const objectKey = objectKeyList[index2];
17648
+ const objectKey = objectKeyList[index];
18968
17649
  let objectValue = object[objectKey];
18969
17650
  if (state.replacer)
18970
17651
  objectValue = state.replacer.call(object, objectKey, objectValue);
@@ -18991,11 +17672,11 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
18991
17672
  objectKeyList.sort(state.sortKeys);
18992
17673
  else if (state.sortKeys)
18993
17674
  throw new YAMLException2("sortKeys must be a boolean or a function");
18994
- for (let index2 = 0, length = objectKeyList.length;index2 < length; index2 += 1) {
17675
+ for (let index = 0, length = objectKeyList.length;index < length; index += 1) {
18995
17676
  let pairBuffer = "";
18996
17677
  if (!compact || _result !== "")
18997
17678
  pairBuffer += generateNextLine(state, level);
18998
- const objectKey = objectKeyList[index2];
17679
+ const objectKey = objectKeyList[index];
18999
17680
  let objectValue = object[objectKey];
19000
17681
  if (state.replacer)
19001
17682
  objectValue = state.replacer.call(object, objectKey, objectValue);
@@ -19024,8 +17705,8 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
19024
17705
  }
19025
17706
  function detectType(state, object, explicit) {
19026
17707
  const typeList = explicit ? state.explicitTypes : state.implicitTypes;
19027
- for (let index2 = 0, length = typeList.length;index2 < length; index2 += 1) {
19028
- const type = typeList[index2];
17708
+ for (let index = 0, length = typeList.length;index < length; index += 1) {
17709
+ const type = typeList[index];
19029
17710
  if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
19030
17711
  if (explicit)
19031
17712
  if (type.multi && type.representName)
@@ -19124,16 +17805,16 @@ var require_dumper2 = /* @__PURE__ */ __commonJSMin2((exports, module) => {
19124
17805
  const duplicatesIndexes = [];
19125
17806
  inspectNode(object, objects, duplicatesIndexes);
19126
17807
  const length = duplicatesIndexes.length;
19127
- for (let index2 = 0;index2 < length; index2 += 1)
19128
- state.duplicates.push(objects[duplicatesIndexes[index2]]);
17808
+ for (let index = 0;index < length; index += 1)
17809
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
19129
17810
  state.usedDuplicates = new Array(length);
19130
17811
  }
19131
17812
  function inspectNode(object, objects, duplicatesIndexes) {
19132
17813
  if (object !== null && typeof object === "object") {
19133
- const index2 = objects.indexOf(object);
19134
- if (index2 !== -1) {
19135
- if (duplicatesIndexes.indexOf(index2) === -1)
19136
- duplicatesIndexes.push(index2);
17814
+ const index = objects.indexOf(object);
17815
+ if (index !== -1) {
17816
+ if (duplicatesIndexes.indexOf(index) === -1)
17817
+ duplicatesIndexes.push(index);
19137
17818
  } else {
19138
17819
  objects.push(object);
19139
17820
  if (Array.isArray(object))
@@ -19473,10 +18154,6 @@ class NodeContextStorage2 {
19473
18154
  return this.storage.getStore();
19474
18155
  }
19475
18156
  }
19476
- var telemetryPropsSlot2 = singleton2("TelemetryDefaultProps");
19477
- function getGlobalTelemetryProperties2() {
19478
- return telemetryPropsSlot2.get();
19479
- }
19480
18157
 
19481
18158
  class TelemetryService2 {
19482
18159
  telemetryProvider;
@@ -19662,6 +18339,29 @@ function isPlainRecord2(value) {
19662
18339
  const prototype = Object.getPrototypeOf(value);
19663
18340
  return prototype === Object.prototype || prototype === null;
19664
18341
  }
18342
+ function extractPagedRows2(value) {
18343
+ if (Array.isArray(value) || !isPlainRecord2(value))
18344
+ return null;
18345
+ const entries = Object.values(value);
18346
+ if (entries.length === 0)
18347
+ return null;
18348
+ let rows = null;
18349
+ let hasScalarSibling = false;
18350
+ for (const entry of entries) {
18351
+ if (Array.isArray(entry)) {
18352
+ if (rows !== null)
18353
+ return null;
18354
+ rows = entry;
18355
+ } else if (entry !== null && typeof entry === "object") {
18356
+ return null;
18357
+ } else {
18358
+ hasScalarSibling = true;
18359
+ }
18360
+ }
18361
+ if (rows === null || !hasScalarSibling)
18362
+ return null;
18363
+ return rows;
18364
+ }
19665
18365
  function toLowerCamelCaseKey2(key) {
19666
18366
  if (!key)
19667
18367
  return key;
@@ -19726,7 +18426,8 @@ function printOutput2(data, format = "json", logFn, asciiSafe = false) {
19726
18426
  break;
19727
18427
  case "plain": {
19728
18428
  if ("Data" in data && data.Data != null) {
19729
- const items = Array.isArray(data.Data) ? data.Data : [data.Data];
18429
+ const pagedRows = extractPagedRows2(data.Data);
18430
+ const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
19730
18431
  items.forEach((item) => {
19731
18432
  const values = Object.values(item).map((v) => v ?? "").join("\t");
19732
18433
  logFn(values);
@@ -19738,10 +18439,13 @@ function printOutput2(data, format = "json", logFn, asciiSafe = false) {
19738
18439
  break;
19739
18440
  }
19740
18441
  default: {
19741
- if ("Data" in data && data.Data != null && !(Array.isArray(data.Data) && data.Data.length === 0)) {
18442
+ const hasData = "Data" in data && data.Data != null;
18443
+ const pagedRows = hasData ? extractPagedRows2(data.Data) : null;
18444
+ const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
18445
+ if (hasData && !(rows !== null && rows.length === 0)) {
19742
18446
  const logValue = data.Log;
19743
- if (Array.isArray(data.Data)) {
19744
- printResizableTable2(data.Data, logFn, logValue);
18447
+ if (rows !== null) {
18448
+ printResizableTable2(rows, logFn, logValue);
19745
18449
  } else {
19746
18450
  printVerticalTable2(data.Data, logFn, logValue);
19747
18451
  }
@@ -19930,6 +18634,44 @@ function defaultErrorCodeForResult2(result) {
19930
18634
  return "unknown_error";
19931
18635
  }
19932
18636
  }
18637
+ function parseHttpStatusFromMessage(message) {
18638
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
18639
+ if (!match)
18640
+ return;
18641
+ const status = Number(match[1]);
18642
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
18643
+ }
18644
+ function defaultErrorCodeForHttpStatus2(status) {
18645
+ if (status === undefined)
18646
+ return;
18647
+ if (status === 400 || status === 409 || status === 422) {
18648
+ return "invalid_argument";
18649
+ }
18650
+ if (status === 401)
18651
+ return "authentication_required";
18652
+ if (status === 403)
18653
+ return "permission_denied";
18654
+ if (status === 404)
18655
+ return "not_found";
18656
+ if (status === 405)
18657
+ return "method_not_allowed";
18658
+ if (status === 408)
18659
+ return "timeout";
18660
+ if (status === 429)
18661
+ return "rate_limited";
18662
+ if (status >= 500 && status < 600)
18663
+ return "server_error";
18664
+ return;
18665
+ }
18666
+ function defaultErrorCodeForFailure2(data) {
18667
+ if (data.Result === RESULTS2.Failure) {
18668
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage(data.Message);
18669
+ const errorCode = defaultErrorCodeForHttpStatus2(status);
18670
+ if (errorCode)
18671
+ return errorCode;
18672
+ }
18673
+ return defaultErrorCodeForResult2(data.Result);
18674
+ }
19933
18675
  function defaultRetryForErrorCode2(errorCode) {
19934
18676
  switch (errorCode) {
19935
18677
  case "network_error":
@@ -19959,16 +18701,19 @@ var OutputFormatter2;
19959
18701
  OutputFormatter3.success = success;
19960
18702
  function error(data) {
19961
18703
  data.Log ??= getLogFilePath2() || undefined;
19962
- data.ErrorCode ??= defaultErrorCodeForResult2(data.Result);
18704
+ data.ErrorCode ??= defaultErrorCodeForFailure2(data);
19963
18705
  data.Retry ??= defaultRetryForErrorCode2(data.ErrorCode);
19964
18706
  process.exitCode = EXIT_CODES2[data.Result] ?? 1;
19965
- telemetry2.trackEvent(CommonTelemetryEvents2.Error, {
19966
- result: data.Result,
19967
- errorCode: data.ErrorCode,
19968
- retry: data.Retry,
19969
- message: data.Message
19970
- });
19971
- logOutput2(normalizeOutputKeys2(data), getOutputFormat2());
18707
+ const { SuppressTelemetry, ...envelope } = data;
18708
+ if (!SuppressTelemetry) {
18709
+ telemetry2.trackEvent(CommonTelemetryEvents2.Error, {
18710
+ result: data.Result,
18711
+ errorCode: data.ErrorCode,
18712
+ retry: data.Retry,
18713
+ message: data.Message
18714
+ });
18715
+ }
18716
+ logOutput2(normalizeOutputKeys2(envelope), getOutputFormat2());
19972
18717
  }
19973
18718
  OutputFormatter3.error = error;
19974
18719
  function emitList(code, items, opts) {
@@ -20243,1407 +18988,6 @@ var guardInstalledSlot2 = singleton2("ConsoleGuardInstalled");
20243
18988
  var savedOriginalsSlot2 = singleton2("ConsoleGuardOriginals");
20244
18989
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
20245
18990
  var modeSlot2 = singleton2("InteractivityMode");
20246
-
20247
- class Hooks2 {
20248
- add(name, callback, first) {
20249
- if (typeof arguments[0] != "string") {
20250
- for (let name2 in arguments[0]) {
20251
- this.add(name2, arguments[0][name2], arguments[1]);
20252
- }
20253
- } else {
20254
- (Array.isArray(name) ? name : [name]).forEach(function(name2) {
20255
- this[name2] = this[name2] || [];
20256
- if (callback) {
20257
- this[name2][first ? "unshift" : "push"](callback);
20258
- }
20259
- }, this);
20260
- }
20261
- }
20262
- run(name, env) {
20263
- this[name] = this[name] || [];
20264
- this[name].forEach(function(callback) {
20265
- callback.call(env && env.context ? env.context : env, env);
20266
- });
20267
- }
20268
- }
20269
-
20270
- class Plugins2 {
20271
- constructor(jsep2) {
20272
- this.jsep = jsep2;
20273
- this.registered = {};
20274
- }
20275
- register(...plugins) {
20276
- plugins.forEach((plugin2) => {
20277
- if (typeof plugin2 !== "object" || !plugin2.name || !plugin2.init) {
20278
- throw new Error("Invalid JSEP plugin format");
20279
- }
20280
- if (this.registered[plugin2.name]) {
20281
- return;
20282
- }
20283
- plugin2.init(this.jsep);
20284
- this.registered[plugin2.name] = plugin2;
20285
- });
20286
- }
20287
- }
20288
-
20289
- class Jsep2 {
20290
- static get version() {
20291
- return "1.4.0";
20292
- }
20293
- static toString() {
20294
- return "JavaScript Expression Parser (JSEP) v" + Jsep2.version;
20295
- }
20296
- static addUnaryOp(op_name) {
20297
- Jsep2.max_unop_len = Math.max(op_name.length, Jsep2.max_unop_len);
20298
- Jsep2.unary_ops[op_name] = 1;
20299
- return Jsep2;
20300
- }
20301
- static addBinaryOp(op_name, precedence, isRightAssociative) {
20302
- Jsep2.max_binop_len = Math.max(op_name.length, Jsep2.max_binop_len);
20303
- Jsep2.binary_ops[op_name] = precedence;
20304
- if (isRightAssociative) {
20305
- Jsep2.right_associative.add(op_name);
20306
- } else {
20307
- Jsep2.right_associative.delete(op_name);
20308
- }
20309
- return Jsep2;
20310
- }
20311
- static addIdentifierChar(char) {
20312
- Jsep2.additional_identifier_chars.add(char);
20313
- return Jsep2;
20314
- }
20315
- static addLiteral(literal_name, literal_value) {
20316
- Jsep2.literals[literal_name] = literal_value;
20317
- return Jsep2;
20318
- }
20319
- static removeUnaryOp(op_name) {
20320
- delete Jsep2.unary_ops[op_name];
20321
- if (op_name.length === Jsep2.max_unop_len) {
20322
- Jsep2.max_unop_len = Jsep2.getMaxKeyLen(Jsep2.unary_ops);
20323
- }
20324
- return Jsep2;
20325
- }
20326
- static removeAllUnaryOps() {
20327
- Jsep2.unary_ops = {};
20328
- Jsep2.max_unop_len = 0;
20329
- return Jsep2;
20330
- }
20331
- static removeIdentifierChar(char) {
20332
- Jsep2.additional_identifier_chars.delete(char);
20333
- return Jsep2;
20334
- }
20335
- static removeBinaryOp(op_name) {
20336
- delete Jsep2.binary_ops[op_name];
20337
- if (op_name.length === Jsep2.max_binop_len) {
20338
- Jsep2.max_binop_len = Jsep2.getMaxKeyLen(Jsep2.binary_ops);
20339
- }
20340
- Jsep2.right_associative.delete(op_name);
20341
- return Jsep2;
20342
- }
20343
- static removeAllBinaryOps() {
20344
- Jsep2.binary_ops = {};
20345
- Jsep2.max_binop_len = 0;
20346
- return Jsep2;
20347
- }
20348
- static removeLiteral(literal_name) {
20349
- delete Jsep2.literals[literal_name];
20350
- return Jsep2;
20351
- }
20352
- static removeAllLiterals() {
20353
- Jsep2.literals = {};
20354
- return Jsep2;
20355
- }
20356
- get char() {
20357
- return this.expr.charAt(this.index);
20358
- }
20359
- get code() {
20360
- return this.expr.charCodeAt(this.index);
20361
- }
20362
- constructor(expr) {
20363
- this.expr = expr;
20364
- this.index = 0;
20365
- }
20366
- static parse(expr) {
20367
- return new Jsep2(expr).parse();
20368
- }
20369
- static getMaxKeyLen(obj) {
20370
- return Math.max(0, ...Object.keys(obj).map((k) => k.length));
20371
- }
20372
- static isDecimalDigit(ch) {
20373
- return ch >= 48 && ch <= 57;
20374
- }
20375
- static binaryPrecedence(op_val) {
20376
- return Jsep2.binary_ops[op_val] || 0;
20377
- }
20378
- static isIdentifierStart(ch) {
20379
- return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !Jsep2.binary_ops[String.fromCharCode(ch)] || Jsep2.additional_identifier_chars.has(String.fromCharCode(ch));
20380
- }
20381
- static isIdentifierPart(ch) {
20382
- return Jsep2.isIdentifierStart(ch) || Jsep2.isDecimalDigit(ch);
20383
- }
20384
- throwError(message) {
20385
- const error = new Error(message + " at character " + this.index);
20386
- error.index = this.index;
20387
- error.description = message;
20388
- throw error;
20389
- }
20390
- runHook(name, node) {
20391
- if (Jsep2.hooks[name]) {
20392
- const env = {
20393
- context: this,
20394
- node
20395
- };
20396
- Jsep2.hooks.run(name, env);
20397
- return env.node;
20398
- }
20399
- return node;
20400
- }
20401
- searchHook(name) {
20402
- if (Jsep2.hooks[name]) {
20403
- const env = {
20404
- context: this
20405
- };
20406
- Jsep2.hooks[name].find(function(callback) {
20407
- callback.call(env.context, env);
20408
- return env.node;
20409
- });
20410
- return env.node;
20411
- }
20412
- }
20413
- gobbleSpaces() {
20414
- let ch = this.code;
20415
- while (ch === Jsep2.SPACE_CODE || ch === Jsep2.TAB_CODE || ch === Jsep2.LF_CODE || ch === Jsep2.CR_CODE) {
20416
- ch = this.expr.charCodeAt(++this.index);
20417
- }
20418
- this.runHook("gobble-spaces");
20419
- }
20420
- parse() {
20421
- this.runHook("before-all");
20422
- const nodes = this.gobbleExpressions();
20423
- const node = nodes.length === 1 ? nodes[0] : {
20424
- type: Jsep2.COMPOUND,
20425
- body: nodes
20426
- };
20427
- return this.runHook("after-all", node);
20428
- }
20429
- gobbleExpressions(untilICode) {
20430
- let nodes = [], ch_i, node;
20431
- while (this.index < this.expr.length) {
20432
- ch_i = this.code;
20433
- if (ch_i === Jsep2.SEMCOL_CODE || ch_i === Jsep2.COMMA_CODE) {
20434
- this.index++;
20435
- } else {
20436
- if (node = this.gobbleExpression()) {
20437
- nodes.push(node);
20438
- } else if (this.index < this.expr.length) {
20439
- if (ch_i === untilICode) {
20440
- break;
20441
- }
20442
- this.throwError('Unexpected "' + this.char + '"');
20443
- }
20444
- }
20445
- }
20446
- return nodes;
20447
- }
20448
- gobbleExpression() {
20449
- const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
20450
- this.gobbleSpaces();
20451
- return this.runHook("after-expression", node);
20452
- }
20453
- gobbleBinaryOp() {
20454
- this.gobbleSpaces();
20455
- let to_check = this.expr.substr(this.index, Jsep2.max_binop_len);
20456
- let tc_len = to_check.length;
20457
- while (tc_len > 0) {
20458
- if (Jsep2.binary_ops.hasOwnProperty(to_check) && (!Jsep2.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep2.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
20459
- this.index += tc_len;
20460
- return to_check;
20461
- }
20462
- to_check = to_check.substr(0, --tc_len);
20463
- }
20464
- return false;
20465
- }
20466
- gobbleBinaryExpression() {
20467
- let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
20468
- left = this.gobbleToken();
20469
- if (!left) {
20470
- return left;
20471
- }
20472
- biop = this.gobbleBinaryOp();
20473
- if (!biop) {
20474
- return left;
20475
- }
20476
- biop_info = {
20477
- value: biop,
20478
- prec: Jsep2.binaryPrecedence(biop),
20479
- right_a: Jsep2.right_associative.has(biop)
20480
- };
20481
- right = this.gobbleToken();
20482
- if (!right) {
20483
- this.throwError("Expected expression after " + biop);
20484
- }
20485
- stack = [left, biop_info, right];
20486
- while (biop = this.gobbleBinaryOp()) {
20487
- prec = Jsep2.binaryPrecedence(biop);
20488
- if (prec === 0) {
20489
- this.index -= biop.length;
20490
- break;
20491
- }
20492
- biop_info = {
20493
- value: biop,
20494
- prec,
20495
- right_a: Jsep2.right_associative.has(biop)
20496
- };
20497
- cur_biop = biop;
20498
- const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
20499
- while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
20500
- right = stack.pop();
20501
- biop = stack.pop().value;
20502
- left = stack.pop();
20503
- node = {
20504
- type: Jsep2.BINARY_EXP,
20505
- operator: biop,
20506
- left,
20507
- right
20508
- };
20509
- stack.push(node);
20510
- }
20511
- node = this.gobbleToken();
20512
- if (!node) {
20513
- this.throwError("Expected expression after " + cur_biop);
20514
- }
20515
- stack.push(biop_info, node);
20516
- }
20517
- i = stack.length - 1;
20518
- node = stack[i];
20519
- while (i > 1) {
20520
- node = {
20521
- type: Jsep2.BINARY_EXP,
20522
- operator: stack[i - 1].value,
20523
- left: stack[i - 2],
20524
- right: node
20525
- };
20526
- i -= 2;
20527
- }
20528
- return node;
20529
- }
20530
- gobbleToken() {
20531
- let ch, to_check, tc_len, node;
20532
- this.gobbleSpaces();
20533
- node = this.searchHook("gobble-token");
20534
- if (node) {
20535
- return this.runHook("after-token", node);
20536
- }
20537
- ch = this.code;
20538
- if (Jsep2.isDecimalDigit(ch) || ch === Jsep2.PERIOD_CODE) {
20539
- return this.gobbleNumericLiteral();
20540
- }
20541
- if (ch === Jsep2.SQUOTE_CODE || ch === Jsep2.DQUOTE_CODE) {
20542
- node = this.gobbleStringLiteral();
20543
- } else if (ch === Jsep2.OBRACK_CODE) {
20544
- node = this.gobbleArray();
20545
- } else {
20546
- to_check = this.expr.substr(this.index, Jsep2.max_unop_len);
20547
- tc_len = to_check.length;
20548
- while (tc_len > 0) {
20549
- if (Jsep2.unary_ops.hasOwnProperty(to_check) && (!Jsep2.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep2.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
20550
- this.index += tc_len;
20551
- const argument = this.gobbleToken();
20552
- if (!argument) {
20553
- this.throwError("missing unaryOp argument");
20554
- }
20555
- return this.runHook("after-token", {
20556
- type: Jsep2.UNARY_EXP,
20557
- operator: to_check,
20558
- argument,
20559
- prefix: true
20560
- });
20561
- }
20562
- to_check = to_check.substr(0, --tc_len);
20563
- }
20564
- if (Jsep2.isIdentifierStart(ch)) {
20565
- node = this.gobbleIdentifier();
20566
- if (Jsep2.literals.hasOwnProperty(node.name)) {
20567
- node = {
20568
- type: Jsep2.LITERAL,
20569
- value: Jsep2.literals[node.name],
20570
- raw: node.name
20571
- };
20572
- } else if (node.name === Jsep2.this_str) {
20573
- node = {
20574
- type: Jsep2.THIS_EXP
20575
- };
20576
- }
20577
- } else if (ch === Jsep2.OPAREN_CODE) {
20578
- node = this.gobbleGroup();
20579
- }
20580
- }
20581
- if (!node) {
20582
- return this.runHook("after-token", false);
20583
- }
20584
- node = this.gobbleTokenProperty(node);
20585
- return this.runHook("after-token", node);
20586
- }
20587
- gobbleTokenProperty(node) {
20588
- this.gobbleSpaces();
20589
- let ch = this.code;
20590
- while (ch === Jsep2.PERIOD_CODE || ch === Jsep2.OBRACK_CODE || ch === Jsep2.OPAREN_CODE || ch === Jsep2.QUMARK_CODE) {
20591
- let optional;
20592
- if (ch === Jsep2.QUMARK_CODE) {
20593
- if (this.expr.charCodeAt(this.index + 1) !== Jsep2.PERIOD_CODE) {
20594
- break;
20595
- }
20596
- optional = true;
20597
- this.index += 2;
20598
- this.gobbleSpaces();
20599
- ch = this.code;
20600
- }
20601
- this.index++;
20602
- if (ch === Jsep2.OBRACK_CODE) {
20603
- node = {
20604
- type: Jsep2.MEMBER_EXP,
20605
- computed: true,
20606
- object: node,
20607
- property: this.gobbleExpression()
20608
- };
20609
- if (!node.property) {
20610
- this.throwError('Unexpected "' + this.char + '"');
20611
- }
20612
- this.gobbleSpaces();
20613
- ch = this.code;
20614
- if (ch !== Jsep2.CBRACK_CODE) {
20615
- this.throwError("Unclosed [");
20616
- }
20617
- this.index++;
20618
- } else if (ch === Jsep2.OPAREN_CODE) {
20619
- node = {
20620
- type: Jsep2.CALL_EXP,
20621
- arguments: this.gobbleArguments(Jsep2.CPAREN_CODE),
20622
- callee: node
20623
- };
20624
- } else if (ch === Jsep2.PERIOD_CODE || optional) {
20625
- if (optional) {
20626
- this.index--;
20627
- }
20628
- this.gobbleSpaces();
20629
- node = {
20630
- type: Jsep2.MEMBER_EXP,
20631
- computed: false,
20632
- object: node,
20633
- property: this.gobbleIdentifier()
20634
- };
20635
- }
20636
- if (optional) {
20637
- node.optional = true;
20638
- }
20639
- this.gobbleSpaces();
20640
- ch = this.code;
20641
- }
20642
- return node;
20643
- }
20644
- gobbleNumericLiteral() {
20645
- let number = "", ch, chCode;
20646
- while (Jsep2.isDecimalDigit(this.code)) {
20647
- number += this.expr.charAt(this.index++);
20648
- }
20649
- if (this.code === Jsep2.PERIOD_CODE) {
20650
- number += this.expr.charAt(this.index++);
20651
- while (Jsep2.isDecimalDigit(this.code)) {
20652
- number += this.expr.charAt(this.index++);
20653
- }
20654
- }
20655
- ch = this.char;
20656
- if (ch === "e" || ch === "E") {
20657
- number += this.expr.charAt(this.index++);
20658
- ch = this.char;
20659
- if (ch === "+" || ch === "-") {
20660
- number += this.expr.charAt(this.index++);
20661
- }
20662
- while (Jsep2.isDecimalDigit(this.code)) {
20663
- number += this.expr.charAt(this.index++);
20664
- }
20665
- if (!Jsep2.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
20666
- this.throwError("Expected exponent (" + number + this.char + ")");
20667
- }
20668
- }
20669
- chCode = this.code;
20670
- if (Jsep2.isIdentifierStart(chCode)) {
20671
- this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
20672
- } else if (chCode === Jsep2.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep2.PERIOD_CODE) {
20673
- this.throwError("Unexpected period");
20674
- }
20675
- return {
20676
- type: Jsep2.LITERAL,
20677
- value: parseFloat(number),
20678
- raw: number
20679
- };
20680
- }
20681
- gobbleStringLiteral() {
20682
- let str = "";
20683
- const startIndex = this.index;
20684
- const quote = this.expr.charAt(this.index++);
20685
- let closed = false;
20686
- while (this.index < this.expr.length) {
20687
- let ch = this.expr.charAt(this.index++);
20688
- if (ch === quote) {
20689
- closed = true;
20690
- break;
20691
- } else if (ch === "\\") {
20692
- ch = this.expr.charAt(this.index++);
20693
- switch (ch) {
20694
- case "n":
20695
- str += `
20696
- `;
20697
- break;
20698
- case "r":
20699
- str += "\r";
20700
- break;
20701
- case "t":
20702
- str += "\t";
20703
- break;
20704
- case "b":
20705
- str += "\b";
20706
- break;
20707
- case "f":
20708
- str += "\f";
20709
- break;
20710
- case "v":
20711
- str += "\v";
20712
- break;
20713
- default:
20714
- str += ch;
20715
- }
20716
- } else {
20717
- str += ch;
20718
- }
20719
- }
20720
- if (!closed) {
20721
- this.throwError('Unclosed quote after "' + str + '"');
20722
- }
20723
- return {
20724
- type: Jsep2.LITERAL,
20725
- value: str,
20726
- raw: this.expr.substring(startIndex, this.index)
20727
- };
20728
- }
20729
- gobbleIdentifier() {
20730
- let ch = this.code, start = this.index;
20731
- if (Jsep2.isIdentifierStart(ch)) {
20732
- this.index++;
20733
- } else {
20734
- this.throwError("Unexpected " + this.char);
20735
- }
20736
- while (this.index < this.expr.length) {
20737
- ch = this.code;
20738
- if (Jsep2.isIdentifierPart(ch)) {
20739
- this.index++;
20740
- } else {
20741
- break;
20742
- }
20743
- }
20744
- return {
20745
- type: Jsep2.IDENTIFIER,
20746
- name: this.expr.slice(start, this.index)
20747
- };
20748
- }
20749
- gobbleArguments(termination) {
20750
- const args = [];
20751
- let closed = false;
20752
- let separator_count = 0;
20753
- while (this.index < this.expr.length) {
20754
- this.gobbleSpaces();
20755
- let ch_i = this.code;
20756
- if (ch_i === termination) {
20757
- closed = true;
20758
- this.index++;
20759
- if (termination === Jsep2.CPAREN_CODE && separator_count && separator_count >= args.length) {
20760
- this.throwError("Unexpected token " + String.fromCharCode(termination));
20761
- }
20762
- break;
20763
- } else if (ch_i === Jsep2.COMMA_CODE) {
20764
- this.index++;
20765
- separator_count++;
20766
- if (separator_count !== args.length) {
20767
- if (termination === Jsep2.CPAREN_CODE) {
20768
- this.throwError("Unexpected token ,");
20769
- } else if (termination === Jsep2.CBRACK_CODE) {
20770
- for (let arg = args.length;arg < separator_count; arg++) {
20771
- args.push(null);
20772
- }
20773
- }
20774
- }
20775
- } else if (args.length !== separator_count && separator_count !== 0) {
20776
- this.throwError("Expected comma");
20777
- } else {
20778
- const node = this.gobbleExpression();
20779
- if (!node || node.type === Jsep2.COMPOUND) {
20780
- this.throwError("Expected comma");
20781
- }
20782
- args.push(node);
20783
- }
20784
- }
20785
- if (!closed) {
20786
- this.throwError("Expected " + String.fromCharCode(termination));
20787
- }
20788
- return args;
20789
- }
20790
- gobbleGroup() {
20791
- this.index++;
20792
- let nodes = this.gobbleExpressions(Jsep2.CPAREN_CODE);
20793
- if (this.code === Jsep2.CPAREN_CODE) {
20794
- this.index++;
20795
- if (nodes.length === 1) {
20796
- return nodes[0];
20797
- } else if (!nodes.length) {
20798
- return false;
20799
- } else {
20800
- return {
20801
- type: Jsep2.SEQUENCE_EXP,
20802
- expressions: nodes
20803
- };
20804
- }
20805
- } else {
20806
- this.throwError("Unclosed (");
20807
- }
20808
- }
20809
- gobbleArray() {
20810
- this.index++;
20811
- return {
20812
- type: Jsep2.ARRAY_EXP,
20813
- elements: this.gobbleArguments(Jsep2.CBRACK_CODE)
20814
- };
20815
- }
20816
- }
20817
- var hooks2 = new Hooks2;
20818
- Object.assign(Jsep2, {
20819
- hooks: hooks2,
20820
- plugins: new Plugins2(Jsep2),
20821
- COMPOUND: "Compound",
20822
- SEQUENCE_EXP: "SequenceExpression",
20823
- IDENTIFIER: "Identifier",
20824
- MEMBER_EXP: "MemberExpression",
20825
- LITERAL: "Literal",
20826
- THIS_EXP: "ThisExpression",
20827
- CALL_EXP: "CallExpression",
20828
- UNARY_EXP: "UnaryExpression",
20829
- BINARY_EXP: "BinaryExpression",
20830
- ARRAY_EXP: "ArrayExpression",
20831
- TAB_CODE: 9,
20832
- LF_CODE: 10,
20833
- CR_CODE: 13,
20834
- SPACE_CODE: 32,
20835
- PERIOD_CODE: 46,
20836
- COMMA_CODE: 44,
20837
- SQUOTE_CODE: 39,
20838
- DQUOTE_CODE: 34,
20839
- OPAREN_CODE: 40,
20840
- CPAREN_CODE: 41,
20841
- OBRACK_CODE: 91,
20842
- CBRACK_CODE: 93,
20843
- QUMARK_CODE: 63,
20844
- SEMCOL_CODE: 59,
20845
- COLON_CODE: 58,
20846
- unary_ops: {
20847
- "-": 1,
20848
- "!": 1,
20849
- "~": 1,
20850
- "+": 1
20851
- },
20852
- binary_ops: {
20853
- "||": 1,
20854
- "??": 1,
20855
- "&&": 2,
20856
- "|": 3,
20857
- "^": 4,
20858
- "&": 5,
20859
- "==": 6,
20860
- "!=": 6,
20861
- "===": 6,
20862
- "!==": 6,
20863
- "<": 7,
20864
- ">": 7,
20865
- "<=": 7,
20866
- ">=": 7,
20867
- "<<": 8,
20868
- ">>": 8,
20869
- ">>>": 8,
20870
- "+": 9,
20871
- "-": 9,
20872
- "*": 10,
20873
- "/": 10,
20874
- "%": 10,
20875
- "**": 11
20876
- },
20877
- right_associative: new Set(["**"]),
20878
- additional_identifier_chars: new Set(["$", "_"]),
20879
- literals: {
20880
- true: true,
20881
- false: false,
20882
- null: null
20883
- },
20884
- this_str: "this"
20885
- });
20886
- Jsep2.max_unop_len = Jsep2.getMaxKeyLen(Jsep2.unary_ops);
20887
- Jsep2.max_binop_len = Jsep2.getMaxKeyLen(Jsep2.binary_ops);
20888
- var jsep2 = (expr) => new Jsep2(expr).parse();
20889
- var stdClassProps2 = Object.getOwnPropertyNames(class Test2 {
20890
- });
20891
- Object.getOwnPropertyNames(Jsep2).filter((prop) => !stdClassProps2.includes(prop) && jsep2[prop] === undefined).forEach((m) => {
20892
- jsep2[m] = Jsep2[m];
20893
- });
20894
- jsep2.Jsep = Jsep2;
20895
- var CONDITIONAL_EXP2 = "ConditionalExpression";
20896
- var ternary2 = {
20897
- name: "ternary",
20898
- init(jsep22) {
20899
- jsep22.hooks.add("after-expression", function gobbleTernary(env) {
20900
- if (env.node && this.code === jsep22.QUMARK_CODE) {
20901
- this.index++;
20902
- const test = env.node;
20903
- const consequent = this.gobbleExpression();
20904
- if (!consequent) {
20905
- this.throwError("Expected expression");
20906
- }
20907
- this.gobbleSpaces();
20908
- if (this.code === jsep22.COLON_CODE) {
20909
- this.index++;
20910
- const alternate = this.gobbleExpression();
20911
- if (!alternate) {
20912
- this.throwError("Expected expression");
20913
- }
20914
- env.node = {
20915
- type: CONDITIONAL_EXP2,
20916
- test,
20917
- consequent,
20918
- alternate
20919
- };
20920
- if (test.operator && jsep22.binary_ops[test.operator] <= 0.9) {
20921
- let newTest = test;
20922
- while (newTest.right.operator && jsep22.binary_ops[newTest.right.operator] <= 0.9) {
20923
- newTest = newTest.right;
20924
- }
20925
- env.node.test = newTest.right;
20926
- newTest.right = env.node;
20927
- env.node = test;
20928
- }
20929
- } else {
20930
- this.throwError("Expected :");
20931
- }
20932
- }
20933
- });
20934
- }
20935
- };
20936
- jsep2.plugins.register(ternary2);
20937
- var FSLASH_CODE2 = 47;
20938
- var BSLASH_CODE2 = 92;
20939
- var index2 = {
20940
- name: "regex",
20941
- init(jsep22) {
20942
- jsep22.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
20943
- if (this.code === FSLASH_CODE2) {
20944
- const patternIndex = ++this.index;
20945
- let inCharSet = false;
20946
- while (this.index < this.expr.length) {
20947
- if (this.code === FSLASH_CODE2 && !inCharSet) {
20948
- const pattern = this.expr.slice(patternIndex, this.index);
20949
- let flags = "";
20950
- while (++this.index < this.expr.length) {
20951
- const code = this.code;
20952
- if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
20953
- flags += this.char;
20954
- } else {
20955
- break;
20956
- }
20957
- }
20958
- let value;
20959
- try {
20960
- value = new RegExp(pattern, flags);
20961
- } catch (e) {
20962
- this.throwError(e.message);
20963
- }
20964
- env.node = {
20965
- type: jsep22.LITERAL,
20966
- value,
20967
- raw: this.expr.slice(patternIndex - 1, this.index)
20968
- };
20969
- env.node = this.gobbleTokenProperty(env.node);
20970
- return env.node;
20971
- }
20972
- if (this.code === jsep22.OBRACK_CODE) {
20973
- inCharSet = true;
20974
- } else if (inCharSet && this.code === jsep22.CBRACK_CODE) {
20975
- inCharSet = false;
20976
- }
20977
- this.index += this.code === BSLASH_CODE2 ? 2 : 1;
20978
- }
20979
- this.throwError("Unclosed Regex");
20980
- }
20981
- });
20982
- }
20983
- };
20984
- var PLUS_CODE2 = 43;
20985
- var MINUS_CODE2 = 45;
20986
- var plugin2 = {
20987
- name: "assignment",
20988
- assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
20989
- updateOperators: [PLUS_CODE2, MINUS_CODE2],
20990
- assignmentPrecedence: 0.9,
20991
- init(jsep22) {
20992
- const updateNodeTypes = [jsep22.IDENTIFIER, jsep22.MEMBER_EXP];
20993
- plugin2.assignmentOperators.forEach((op) => jsep22.addBinaryOp(op, plugin2.assignmentPrecedence, true));
20994
- jsep22.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
20995
- const code = this.code;
20996
- if (plugin2.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
20997
- this.index += 2;
20998
- env.node = {
20999
- type: "UpdateExpression",
21000
- operator: code === PLUS_CODE2 ? "++" : "--",
21001
- argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
21002
- prefix: true
21003
- };
21004
- if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
21005
- this.throwError(`Unexpected ${env.node.operator}`);
21006
- }
21007
- }
21008
- });
21009
- jsep22.hooks.add("after-token", function gobbleUpdatePostfix(env) {
21010
- if (env.node) {
21011
- const code = this.code;
21012
- if (plugin2.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
21013
- if (!updateNodeTypes.includes(env.node.type)) {
21014
- this.throwError(`Unexpected ${env.node.operator}`);
21015
- }
21016
- this.index += 2;
21017
- env.node = {
21018
- type: "UpdateExpression",
21019
- operator: code === PLUS_CODE2 ? "++" : "--",
21020
- argument: env.node,
21021
- prefix: false
21022
- };
21023
- }
21024
- }
21025
- });
21026
- jsep22.hooks.add("after-expression", function gobbleAssignment(env) {
21027
- if (env.node) {
21028
- updateBinariesToAssignments(env.node);
21029
- }
21030
- });
21031
- function updateBinariesToAssignments(node) {
21032
- if (plugin2.assignmentOperators.has(node.operator)) {
21033
- node.type = "AssignmentExpression";
21034
- updateBinariesToAssignments(node.left);
21035
- updateBinariesToAssignments(node.right);
21036
- } else if (!node.operator) {
21037
- Object.values(node).forEach((val) => {
21038
- if (val && typeof val === "object") {
21039
- updateBinariesToAssignments(val);
21040
- }
21041
- });
21042
- }
21043
- }
21044
- }
21045
- };
21046
- jsep2.plugins.register(index2, plugin2);
21047
- jsep2.addUnaryOp("typeof");
21048
- jsep2.addUnaryOp("void");
21049
- jsep2.addLiteral("null", null);
21050
- jsep2.addLiteral("undefined", undefined);
21051
- var BLOCKED_PROTO_PROPERTIES2 = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
21052
- var SafeEval2 = {
21053
- evalAst(ast, subs) {
21054
- switch (ast.type) {
21055
- case "BinaryExpression":
21056
- case "LogicalExpression":
21057
- return SafeEval2.evalBinaryExpression(ast, subs);
21058
- case "Compound":
21059
- return SafeEval2.evalCompound(ast, subs);
21060
- case "ConditionalExpression":
21061
- return SafeEval2.evalConditionalExpression(ast, subs);
21062
- case "Identifier":
21063
- return SafeEval2.evalIdentifier(ast, subs);
21064
- case "Literal":
21065
- return SafeEval2.evalLiteral(ast, subs);
21066
- case "MemberExpression":
21067
- return SafeEval2.evalMemberExpression(ast, subs);
21068
- case "UnaryExpression":
21069
- return SafeEval2.evalUnaryExpression(ast, subs);
21070
- case "ArrayExpression":
21071
- return SafeEval2.evalArrayExpression(ast, subs);
21072
- case "CallExpression":
21073
- return SafeEval2.evalCallExpression(ast, subs);
21074
- case "AssignmentExpression":
21075
- return SafeEval2.evalAssignmentExpression(ast, subs);
21076
- default:
21077
- throw SyntaxError("Unexpected expression", ast);
21078
- }
21079
- },
21080
- evalBinaryExpression(ast, subs) {
21081
- const result = {
21082
- "||": (a, b) => a || b(),
21083
- "&&": (a, b) => a && b(),
21084
- "|": (a, b) => a | b(),
21085
- "^": (a, b) => a ^ b(),
21086
- "&": (a, b) => a & b(),
21087
- "==": (a, b) => a == b(),
21088
- "!=": (a, b) => a != b(),
21089
- "===": (a, b) => a === b(),
21090
- "!==": (a, b) => a !== b(),
21091
- "<": (a, b) => a < b(),
21092
- ">": (a, b) => a > b(),
21093
- "<=": (a, b) => a <= b(),
21094
- ">=": (a, b) => a >= b(),
21095
- "<<": (a, b) => a << b(),
21096
- ">>": (a, b) => a >> b(),
21097
- ">>>": (a, b) => a >>> b(),
21098
- "+": (a, b) => a + b(),
21099
- "-": (a, b) => a - b(),
21100
- "*": (a, b) => a * b(),
21101
- "/": (a, b) => a / b(),
21102
- "%": (a, b) => a % b()
21103
- }[ast.operator](SafeEval2.evalAst(ast.left, subs), () => SafeEval2.evalAst(ast.right, subs));
21104
- return result;
21105
- },
21106
- evalCompound(ast, subs) {
21107
- let last;
21108
- for (let i = 0;i < ast.body.length; i++) {
21109
- if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
21110
- i += 1;
21111
- }
21112
- const expr = ast.body[i];
21113
- last = SafeEval2.evalAst(expr, subs);
21114
- }
21115
- return last;
21116
- },
21117
- evalConditionalExpression(ast, subs) {
21118
- if (SafeEval2.evalAst(ast.test, subs)) {
21119
- return SafeEval2.evalAst(ast.consequent, subs);
21120
- }
21121
- return SafeEval2.evalAst(ast.alternate, subs);
21122
- },
21123
- evalIdentifier(ast, subs) {
21124
- if (Object.hasOwn(subs, ast.name)) {
21125
- return subs[ast.name];
21126
- }
21127
- throw ReferenceError(`${ast.name} is not defined`);
21128
- },
21129
- evalLiteral(ast) {
21130
- return ast.value;
21131
- },
21132
- evalMemberExpression(ast, subs) {
21133
- const prop = String(ast.computed ? SafeEval2.evalAst(ast.property) : ast.property.name);
21134
- const obj = SafeEval2.evalAst(ast.object, subs);
21135
- if (obj === undefined || obj === null) {
21136
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
21137
- }
21138
- if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES2.has(prop)) {
21139
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
21140
- }
21141
- const result = obj[prop];
21142
- if (typeof result === "function") {
21143
- return result.bind(obj);
21144
- }
21145
- return result;
21146
- },
21147
- evalUnaryExpression(ast, subs) {
21148
- const result = {
21149
- "-": (a) => -SafeEval2.evalAst(a, subs),
21150
- "!": (a) => !SafeEval2.evalAst(a, subs),
21151
- "~": (a) => ~SafeEval2.evalAst(a, subs),
21152
- "+": (a) => +SafeEval2.evalAst(a, subs),
21153
- typeof: (a) => typeof SafeEval2.evalAst(a, subs),
21154
- void: (a) => void SafeEval2.evalAst(a, subs)
21155
- }[ast.operator](ast.argument);
21156
- return result;
21157
- },
21158
- evalArrayExpression(ast, subs) {
21159
- return ast.elements.map((el) => SafeEval2.evalAst(el, subs));
21160
- },
21161
- evalCallExpression(ast, subs) {
21162
- const args = ast.arguments.map((arg) => SafeEval2.evalAst(arg, subs));
21163
- const func = SafeEval2.evalAst(ast.callee, subs);
21164
- if (func === Function) {
21165
- throw new Error("Function constructor is disabled");
21166
- }
21167
- return func(...args);
21168
- },
21169
- evalAssignmentExpression(ast, subs) {
21170
- if (ast.left.type !== "Identifier") {
21171
- throw SyntaxError("Invalid left-hand side in assignment");
21172
- }
21173
- const id = ast.left.name;
21174
- const value = SafeEval2.evalAst(ast.right, subs);
21175
- subs[id] = value;
21176
- return subs[id];
21177
- }
21178
- };
21179
-
21180
- class SafeScript2 {
21181
- constructor(expr) {
21182
- this.code = expr;
21183
- this.ast = jsep2(this.code);
21184
- }
21185
- runInNewContext(context) {
21186
- const keyMap = Object.assign(Object.create(null), context);
21187
- return SafeEval2.evalAst(this.ast, keyMap);
21188
- }
21189
- }
21190
- function push2(arr, item) {
21191
- arr = arr.slice();
21192
- arr.push(item);
21193
- return arr;
21194
- }
21195
- function unshift2(item, arr) {
21196
- arr = arr.slice();
21197
- arr.unshift(item);
21198
- return arr;
21199
- }
21200
-
21201
- class NewError2 extends Error {
21202
- constructor(value) {
21203
- super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
21204
- this.avoidNew = true;
21205
- this.value = value;
21206
- this.name = "NewError";
21207
- }
21208
- }
21209
- function JSONPath2(opts, expr, obj, callback, otherTypeCallback) {
21210
- if (!(this instanceof JSONPath2)) {
21211
- try {
21212
- return new JSONPath2(opts, expr, obj, callback, otherTypeCallback);
21213
- } catch (e) {
21214
- if (!e.avoidNew) {
21215
- throw e;
21216
- }
21217
- return e.value;
21218
- }
21219
- }
21220
- if (typeof opts === "string") {
21221
- otherTypeCallback = callback;
21222
- callback = obj;
21223
- obj = expr;
21224
- expr = opts;
21225
- opts = null;
21226
- }
21227
- const optObj = opts && typeof opts === "object";
21228
- opts = opts || {};
21229
- this.json = opts.json || obj;
21230
- this.path = opts.path || expr;
21231
- this.resultType = opts.resultType || "value";
21232
- this.flatten = opts.flatten || false;
21233
- this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
21234
- this.sandbox = opts.sandbox || {};
21235
- this.eval = opts.eval === undefined ? "safe" : opts.eval;
21236
- this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
21237
- this.parent = opts.parent || null;
21238
- this.parentProperty = opts.parentProperty || null;
21239
- this.callback = opts.callback || callback || null;
21240
- this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
21241
- throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
21242
- };
21243
- if (opts.autostart !== false) {
21244
- const args = {
21245
- path: optObj ? opts.path : expr
21246
- };
21247
- if (!optObj) {
21248
- args.json = obj;
21249
- } else if ("json" in opts) {
21250
- args.json = opts.json;
21251
- }
21252
- const ret = this.evaluate(args);
21253
- if (!ret || typeof ret !== "object") {
21254
- throw new NewError2(ret);
21255
- }
21256
- return ret;
21257
- }
21258
- }
21259
- JSONPath2.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
21260
- let currParent = this.parent, currParentProperty = this.parentProperty;
21261
- let {
21262
- flatten,
21263
- wrap
21264
- } = this;
21265
- this.currResultType = this.resultType;
21266
- this.currEval = this.eval;
21267
- this.currSandbox = this.sandbox;
21268
- callback = callback || this.callback;
21269
- this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
21270
- json = json || this.json;
21271
- expr = expr || this.path;
21272
- if (expr && typeof expr === "object" && !Array.isArray(expr)) {
21273
- if (!expr.path && expr.path !== "") {
21274
- throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
21275
- }
21276
- if (!Object.hasOwn(expr, "json")) {
21277
- throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
21278
- }
21279
- ({
21280
- json
21281
- } = expr);
21282
- flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
21283
- this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
21284
- this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
21285
- wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
21286
- this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
21287
- callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
21288
- this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
21289
- currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
21290
- currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
21291
- expr = expr.path;
21292
- }
21293
- currParent = currParent || null;
21294
- currParentProperty = currParentProperty || null;
21295
- if (Array.isArray(expr)) {
21296
- expr = JSONPath2.toPathString(expr);
21297
- }
21298
- if (!expr && expr !== "" || !json) {
21299
- return;
21300
- }
21301
- const exprList = JSONPath2.toPathArray(expr);
21302
- if (exprList[0] === "$" && exprList.length > 1) {
21303
- exprList.shift();
21304
- }
21305
- this._hasParentSelector = null;
21306
- const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
21307
- return ea && !ea.isParentSelector;
21308
- });
21309
- if (!result.length) {
21310
- return wrap ? [] : undefined;
21311
- }
21312
- if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
21313
- return this._getPreferredOutput(result[0]);
21314
- }
21315
- return result.reduce((rslt, ea) => {
21316
- const valOrPath = this._getPreferredOutput(ea);
21317
- if (flatten && Array.isArray(valOrPath)) {
21318
- rslt = rslt.concat(valOrPath);
21319
- } else {
21320
- rslt.push(valOrPath);
21321
- }
21322
- return rslt;
21323
- }, []);
21324
- };
21325
- JSONPath2.prototype._getPreferredOutput = function(ea) {
21326
- const resultType = this.currResultType;
21327
- switch (resultType) {
21328
- case "all": {
21329
- const path32 = Array.isArray(ea.path) ? ea.path : JSONPath2.toPathArray(ea.path);
21330
- ea.pointer = JSONPath2.toPointer(path32);
21331
- ea.path = typeof ea.path === "string" ? ea.path : JSONPath2.toPathString(ea.path);
21332
- return ea;
21333
- }
21334
- case "value":
21335
- case "parent":
21336
- case "parentProperty":
21337
- return ea[resultType];
21338
- case "path":
21339
- return JSONPath2.toPathString(ea[resultType]);
21340
- case "pointer":
21341
- return JSONPath2.toPointer(ea.path);
21342
- default:
21343
- throw new TypeError("Unknown result type");
21344
- }
21345
- };
21346
- JSONPath2.prototype._handleCallback = function(fullRetObj, callback, type) {
21347
- if (callback) {
21348
- const preferredOutput = this._getPreferredOutput(fullRetObj);
21349
- fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath2.toPathString(fullRetObj.path);
21350
- callback(preferredOutput, type, fullRetObj);
21351
- }
21352
- };
21353
- JSONPath2.prototype._trace = function(expr, val, path32, parent, parentPropName, callback, hasArrExpr, literalPriority) {
21354
- let retObj;
21355
- if (!expr.length) {
21356
- retObj = {
21357
- path: path32,
21358
- value: val,
21359
- parent,
21360
- parentProperty: parentPropName,
21361
- hasArrExpr
21362
- };
21363
- this._handleCallback(retObj, callback, "value");
21364
- return retObj;
21365
- }
21366
- const loc = expr[0], x = expr.slice(1);
21367
- const ret = [];
21368
- function addRet(elems) {
21369
- if (Array.isArray(elems)) {
21370
- elems.forEach((t) => {
21371
- ret.push(t);
21372
- });
21373
- } else {
21374
- ret.push(elems);
21375
- }
21376
- }
21377
- if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
21378
- addRet(this._trace(x, val[loc], push2(path32, loc), val, loc, callback, hasArrExpr));
21379
- } else if (loc === "*") {
21380
- this._walk(val, (m) => {
21381
- addRet(this._trace(x, val[m], push2(path32, m), val, m, callback, true, true));
21382
- });
21383
- } else if (loc === "..") {
21384
- addRet(this._trace(x, val, path32, parent, parentPropName, callback, hasArrExpr));
21385
- this._walk(val, (m) => {
21386
- if (typeof val[m] === "object") {
21387
- addRet(this._trace(expr.slice(), val[m], push2(path32, m), val, m, callback, true));
21388
- }
21389
- });
21390
- } else if (loc === "^") {
21391
- this._hasParentSelector = true;
21392
- return {
21393
- path: path32.slice(0, -1),
21394
- expr: x,
21395
- isParentSelector: true
21396
- };
21397
- } else if (loc === "~") {
21398
- retObj = {
21399
- path: push2(path32, loc),
21400
- value: parentPropName,
21401
- parent,
21402
- parentProperty: null
21403
- };
21404
- this._handleCallback(retObj, callback, "property");
21405
- return retObj;
21406
- } else if (loc === "$") {
21407
- addRet(this._trace(x, val, path32, null, null, callback, hasArrExpr));
21408
- } else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
21409
- addRet(this._slice(loc, x, val, path32, parent, parentPropName, callback));
21410
- } else if (loc.indexOf("?(") === 0) {
21411
- if (this.currEval === false) {
21412
- throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
21413
- }
21414
- const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
21415
- const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
21416
- if (nested) {
21417
- this._walk(val, (m) => {
21418
- const npath = [nested[2]];
21419
- const nvalue = nested[1] ? val[m][nested[1]] : val[m];
21420
- const filterResults = this._trace(npath, nvalue, path32, parent, parentPropName, callback, true);
21421
- if (filterResults.length > 0) {
21422
- addRet(this._trace(x, val[m], push2(path32, m), val, m, callback, true));
21423
- }
21424
- });
21425
- } else {
21426
- this._walk(val, (m) => {
21427
- if (this._eval(safeLoc, val[m], m, path32, parent, parentPropName)) {
21428
- addRet(this._trace(x, val[m], push2(path32, m), val, m, callback, true));
21429
- }
21430
- });
21431
- }
21432
- } else if (loc[0] === "(") {
21433
- if (this.currEval === false) {
21434
- throw new Error("Eval [(expr)] prevented in JSONPath expression.");
21435
- }
21436
- addRet(this._trace(unshift2(this._eval(loc, val, path32.at(-1), path32.slice(0, -1), parent, parentPropName), x), val, path32, parent, parentPropName, callback, hasArrExpr));
21437
- } else if (loc[0] === "@") {
21438
- let addType = false;
21439
- const valueType = loc.slice(1, -2);
21440
- switch (valueType) {
21441
- case "scalar":
21442
- if (!val || !["object", "function"].includes(typeof val)) {
21443
- addType = true;
21444
- }
21445
- break;
21446
- case "boolean":
21447
- case "string":
21448
- case "undefined":
21449
- case "function":
21450
- if (typeof val === valueType) {
21451
- addType = true;
21452
- }
21453
- break;
21454
- case "integer":
21455
- if (Number.isFinite(val) && !(val % 1)) {
21456
- addType = true;
21457
- }
21458
- break;
21459
- case "number":
21460
- if (Number.isFinite(val)) {
21461
- addType = true;
21462
- }
21463
- break;
21464
- case "nonFinite":
21465
- if (typeof val === "number" && !Number.isFinite(val)) {
21466
- addType = true;
21467
- }
21468
- break;
21469
- case "object":
21470
- if (val && typeof val === valueType) {
21471
- addType = true;
21472
- }
21473
- break;
21474
- case "array":
21475
- if (Array.isArray(val)) {
21476
- addType = true;
21477
- }
21478
- break;
21479
- case "other":
21480
- addType = this.currOtherTypeCallback(val, path32, parent, parentPropName);
21481
- break;
21482
- case "null":
21483
- if (val === null) {
21484
- addType = true;
21485
- }
21486
- break;
21487
- default:
21488
- throw new TypeError("Unknown value type " + valueType);
21489
- }
21490
- if (addType) {
21491
- retObj = {
21492
- path: path32,
21493
- value: val,
21494
- parent,
21495
- parentProperty: parentPropName
21496
- };
21497
- this._handleCallback(retObj, callback, "value");
21498
- return retObj;
21499
- }
21500
- } else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
21501
- const locProp = loc.slice(1);
21502
- addRet(this._trace(x, val[locProp], push2(path32, locProp), val, locProp, callback, hasArrExpr, true));
21503
- } else if (loc.includes(",")) {
21504
- const parts = loc.split(",");
21505
- for (const part of parts) {
21506
- addRet(this._trace(unshift2(part, x), val, path32, parent, parentPropName, callback, true));
21507
- }
21508
- } else if (!literalPriority && val && Object.hasOwn(val, loc)) {
21509
- addRet(this._trace(x, val[loc], push2(path32, loc), val, loc, callback, hasArrExpr, true));
21510
- }
21511
- if (this._hasParentSelector) {
21512
- for (let t = 0;t < ret.length; t++) {
21513
- const rett = ret[t];
21514
- if (rett && rett.isParentSelector) {
21515
- const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
21516
- if (Array.isArray(tmp)) {
21517
- ret[t] = tmp[0];
21518
- const tl = tmp.length;
21519
- for (let tt = 1;tt < tl; tt++) {
21520
- t++;
21521
- ret.splice(t, 0, tmp[tt]);
21522
- }
21523
- } else {
21524
- ret[t] = tmp;
21525
- }
21526
- }
21527
- }
21528
- }
21529
- return ret;
21530
- };
21531
- JSONPath2.prototype._walk = function(val, f) {
21532
- if (Array.isArray(val)) {
21533
- const n = val.length;
21534
- for (let i = 0;i < n; i++) {
21535
- f(i);
21536
- }
21537
- } else if (val && typeof val === "object") {
21538
- Object.keys(val).forEach((m) => {
21539
- f(m);
21540
- });
21541
- }
21542
- };
21543
- JSONPath2.prototype._slice = function(loc, expr, val, path32, parent, parentPropName, callback) {
21544
- if (!Array.isArray(val)) {
21545
- return;
21546
- }
21547
- const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
21548
- let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
21549
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
21550
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
21551
- const ret = [];
21552
- for (let i = start;i < end; i += step) {
21553
- const tmp = this._trace(unshift2(i, expr), val, path32, parent, parentPropName, callback, true);
21554
- tmp.forEach((t) => {
21555
- ret.push(t);
21556
- });
21557
- }
21558
- return ret;
21559
- };
21560
- JSONPath2.prototype._eval = function(code, _v, _vname, path32, parent, parentPropName) {
21561
- this.currSandbox._$_parentProperty = parentPropName;
21562
- this.currSandbox._$_parent = parent;
21563
- this.currSandbox._$_property = _vname;
21564
- this.currSandbox._$_root = this.json;
21565
- this.currSandbox._$_v = _v;
21566
- const containsPath = code.includes("@path");
21567
- if (containsPath) {
21568
- this.currSandbox._$_path = JSONPath2.toPathString(path32.concat([_vname]));
21569
- }
21570
- const scriptCacheKey = this.currEval + "Script:" + code;
21571
- if (!JSONPath2.cache[scriptCacheKey]) {
21572
- let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
21573
- if (containsPath) {
21574
- script = script.replaceAll("@path", "_$_path");
21575
- }
21576
- if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
21577
- JSONPath2.cache[scriptCacheKey] = new this.safeVm.Script(script);
21578
- } else if (this.currEval === "native") {
21579
- JSONPath2.cache[scriptCacheKey] = new this.vm.Script(script);
21580
- } else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
21581
- const CurrEval = this.currEval;
21582
- JSONPath2.cache[scriptCacheKey] = new CurrEval(script);
21583
- } else if (typeof this.currEval === "function") {
21584
- JSONPath2.cache[scriptCacheKey] = {
21585
- runInNewContext: (context) => this.currEval(script, context)
21586
- };
21587
- } else {
21588
- throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
21589
- }
21590
- }
21591
- try {
21592
- return JSONPath2.cache[scriptCacheKey].runInNewContext(this.currSandbox);
21593
- } catch (e) {
21594
- if (this.ignoreEvalErrors) {
21595
- return false;
21596
- }
21597
- throw new Error("jsonPath: " + e.message + ": " + code);
21598
- }
21599
- };
21600
- JSONPath2.cache = {};
21601
- JSONPath2.toPathString = function(pathArr) {
21602
- const x = pathArr, n = x.length;
21603
- let p = "$";
21604
- for (let i = 1;i < n; i++) {
21605
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
21606
- p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
21607
- }
21608
- }
21609
- return p;
21610
- };
21611
- JSONPath2.toPointer = function(pointer) {
21612
- const x = pointer, n = x.length;
21613
- let p = "";
21614
- for (let i = 1;i < n; i++) {
21615
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
21616
- p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
21617
- }
21618
- }
21619
- return p;
21620
- };
21621
- JSONPath2.toPathArray = function(expr) {
21622
- const {
21623
- cache
21624
- } = JSONPath2;
21625
- if (cache[expr]) {
21626
- return cache[expr].concat();
21627
- }
21628
- const subx = [];
21629
- const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
21630
- return "[#" + (subx.push($1) - 1) + "]";
21631
- }).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
21632
- return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
21633
- }).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
21634
- return ";" + ups.split("").join(";") + ";";
21635
- }).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
21636
- const exprList = normalized.split(";").map(function(exp) {
21637
- const match = exp.match(/#(\d+)/u);
21638
- return !match || !match[1] ? exp : subx[match[1]];
21639
- });
21640
- cache[expr] = exprList;
21641
- return cache[expr].concat();
21642
- };
21643
- JSONPath2.prototype.safeVm = {
21644
- Script: SafeScript2
21645
- };
21646
- JSONPath2.prototype.vm = vm2;
21647
18991
  var PollOutcome2 = {
21648
18992
  Completed: "completed",
21649
18993
  Timeout: "timeout",
@@ -21674,6 +19018,16 @@ var FAILURE_STATUSES2 = new Set([
21674
19018
  "canceled",
21675
19019
  "stopped"
21676
19020
  ]);
19021
+ var previewSlot2 = singleton2("PreviewBuild");
19022
+ function isPreviewBuild2() {
19023
+ return previewSlot2.get(false) ?? false;
19024
+ }
19025
+ Command2.prototype.previewCommand = function(nameAndArgs, opts) {
19026
+ if (isPreviewBuild2()) {
19027
+ return this.command(nameAndArgs, opts);
19028
+ }
19029
+ return new Command2(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
19030
+ };
21677
19031
  var ScreenLogger2;
21678
19032
  ((ScreenLogger3) => {
21679
19033
  function progress(message) {
@@ -21929,17 +19283,17 @@ async function readSolutionManifest(fs72, solutionFile) {
21929
19283
  ];
21930
19284
  }
21931
19285
  const projects = [];
21932
- for (const [index22, project] of parsed.Projects.entries()) {
19286
+ for (const [index, project] of parsed.Projects.entries()) {
21933
19287
  if (!isRecord(project)) {
21934
19288
  return [
21935
- new Error(`Invalid solution file: Projects[${index22}] must be an object.`),
19289
+ new Error(`Invalid solution file: Projects[${index}] must be an object.`),
21936
19290
  null
21937
19291
  ];
21938
19292
  }
21939
19293
  const projectRelativePath = readString(project.ProjectRelativePath);
21940
19294
  if (!projectRelativePath) {
21941
19295
  return [
21942
- new Error(`Invalid solution file: Projects[${index22}] is missing ProjectRelativePath. Use 'uip solution project add' to repair the manifest.`),
19296
+ new Error(`Invalid solution file: Projects[${index}] is missing ProjectRelativePath. Use 'uip solution project add' to repair the manifest.`),
21943
19297
  null
21944
19298
  ];
21945
19299
  }
@@ -21987,9 +19341,11 @@ function buildOptedOutInstructions(projectDir) {
21987
19341
  `);
21988
19342
  }
21989
19343
  var require2 = createRequire22("/");
19344
+ var _a;
21990
19345
  var Worker;
19346
+ var isMarkedAsUntransferable;
21991
19347
  try {
21992
- Worker = require2("worker_threads").Worker;
19348
+ _a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
21993
19349
  } catch (e) {}
21994
19350
  var u8 = Uint8Array;
21995
19351
  var u16 = Uint16Array;
@@ -23655,11 +21011,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
23655
21011
  };
23656
21012
  this._checkNumberOfArguments();
23657
21013
  const processedArgs = [];
23658
- this.registeredArguments.forEach((declaredArg, index3) => {
21014
+ this.registeredArguments.forEach((declaredArg, index) => {
23659
21015
  let value = declaredArg.defaultValue;
23660
21016
  if (declaredArg.variadic) {
23661
- if (index3 < this.args.length) {
23662
- value = this.args.slice(index3);
21017
+ if (index < this.args.length) {
21018
+ value = this.args.slice(index);
23663
21019
  if (declaredArg.parseArg) {
23664
21020
  value = value.reduce((processed, v) => {
23665
21021
  return myParseArg(declaredArg, v, processed);
@@ -23668,13 +21024,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
23668
21024
  } else if (value === undefined) {
23669
21025
  value = [];
23670
21026
  }
23671
- } else if (index3 < this.args.length) {
23672
- value = this.args[index3];
21027
+ } else if (index < this.args.length) {
21028
+ value = this.args[index];
23673
21029
  if (declaredArg.parseArg) {
23674
21030
  value = myParseArg(declaredArg, value, declaredArg.defaultValue);
23675
21031
  }
23676
21032
  }
23677
- processedArgs[index3] = value;
21033
+ processedArgs[index] = value;
23678
21034
  });
23679
21035
  this.processedArgs = processedArgs;
23680
21036
  }
@@ -23686,16 +21042,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
23686
21042
  }
23687
21043
  _chainOrCallHooks(promise, event) {
23688
21044
  let result = promise;
23689
- const hooks3 = [];
21045
+ const hooks = [];
23690
21046
  this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => {
23691
21047
  hookedCommand._lifeCycleHooks[event].forEach((callback) => {
23692
- hooks3.push({ hookedCommand, callback });
21048
+ hooks.push({ hookedCommand, callback });
23693
21049
  });
23694
21050
  });
23695
21051
  if (event === "postAction") {
23696
- hooks3.reverse();
21052
+ hooks.reverse();
23697
21053
  }
23698
- hooks3.forEach((hookDetail) => {
21054
+ hooks.forEach((hookDetail) => {
23699
21055
  result = this._chainOrCall(result, () => {
23700
21056
  return hookDetail.callback(hookDetail.hookedCommand, this);
23701
21057
  });
@@ -23874,10 +21230,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
23874
21230
  }
23875
21231
  }
23876
21232
  if (/^--[^=]+=/.test(arg)) {
23877
- const index3 = arg.indexOf("=");
23878
- const option = this._findOption(arg.slice(0, index3));
21233
+ const index = arg.indexOf("=");
21234
+ const option = this._findOption(arg.slice(0, index));
23879
21235
  if (option && (option.required || option.optional)) {
23880
- this.emit(`option:${option.name()}`, arg.slice(index3 + 1));
21236
+ this.emit(`option:${option.name()}`, arg.slice(index + 1));
23881
21237
  continue;
23882
21238
  }
23883
21239
  }
@@ -24916,7 +22272,7 @@ function serveDeno(cwd, port, aggregatorPath) {
24916
22272
  ...existsSync5(join7(cwd, ".env")) ? ["--env-file=.env"] : [],
24917
22273
  denoEntryPath
24918
22274
  ];
24919
- const deno = process.platform === "win32" ? "deno.exe" : "deno";
22275
+ const deno = process.env.DENO_BINARY ?? (process.platform === "win32" ? "deno.exe" : "deno");
24920
22276
  const proc = spawn(deno, denoArgs, {
24921
22277
  cwd,
24922
22278
  env: { ...process.env, HTTP_SERVER_LISTEN_PORT: String(port) },
@@ -38570,8 +35926,8 @@ var require_Subscription = __commonJS4((exports) => {
38570
35926
  if (_parentOrParents instanceof Subscription2) {
38571
35927
  _parentOrParents.remove(this);
38572
35928
  } else if (_parentOrParents !== null) {
38573
- for (var index3 = 0;index3 < _parentOrParents.length; ++index3) {
38574
- var parent_1 = _parentOrParents[index3];
35929
+ for (var index = 0;index < _parentOrParents.length; ++index) {
35930
+ var parent_1 = _parentOrParents[index];
38575
35931
  parent_1.remove(this);
38576
35932
  }
38577
35933
  }
@@ -38586,10 +35942,10 @@ var require_Subscription = __commonJS4((exports) => {
38586
35942
  }
38587
35943
  }
38588
35944
  if (isArray_1.isArray(_subscriptions)) {
38589
- var index3 = -1;
35945
+ var index = -1;
38590
35946
  var len = _subscriptions.length;
38591
- while (++index3 < len) {
38592
- var sub3 = _subscriptions[index3];
35947
+ while (++index < len) {
35948
+ var sub3 = _subscriptions[index];
38593
35949
  if (isObject_1.isObject(sub3)) {
38594
35950
  try {
38595
35951
  sub3.unsubscribe();
@@ -39985,13 +37341,13 @@ var require_AsyncAction = __commonJS4((exports) => {
39985
37341
  var id = this.id;
39986
37342
  var scheduler = this.scheduler;
39987
37343
  var actions = scheduler.actions;
39988
- var index3 = actions.indexOf(this);
37344
+ var index = actions.indexOf(this);
39989
37345
  this.work = null;
39990
37346
  this.state = null;
39991
37347
  this.pending = false;
39992
37348
  this.scheduler = null;
39993
- if (index3 !== -1) {
39994
- actions.splice(index3, 1);
37349
+ if (index !== -1) {
37350
+ actions.splice(index, 1);
39995
37351
  }
39996
37352
  if (id != null) {
39997
37353
  this.id = this.recycleAsyncId(scheduler, id, null);
@@ -40797,17 +38153,17 @@ var require_AsapScheduler = __commonJS4((exports) => {
40797
38153
  this.scheduled = undefined;
40798
38154
  var actions = this.actions;
40799
38155
  var error;
40800
- var index3 = -1;
38156
+ var index = -1;
40801
38157
  var count = actions.length;
40802
38158
  action = action || actions.shift();
40803
38159
  do {
40804
38160
  if (error = action.execute(action.state, action.delay)) {
40805
38161
  break;
40806
38162
  }
40807
- } while (++index3 < count && (action = actions.shift()));
38163
+ } while (++index < count && (action = actions.shift()));
40808
38164
  this.active = false;
40809
38165
  if (error) {
40810
- while (++index3 < count && (action = actions.shift())) {
38166
+ while (++index < count && (action = actions.shift())) {
40811
38167
  action.unsubscribe();
40812
38168
  }
40813
38169
  throw error;
@@ -40922,17 +38278,17 @@ var require_AnimationFrameScheduler = __commonJS4((exports) => {
40922
38278
  this.scheduled = undefined;
40923
38279
  var actions = this.actions;
40924
38280
  var error;
40925
- var index3 = -1;
38281
+ var index = -1;
40926
38282
  var count = actions.length;
40927
38283
  action = action || actions.shift();
40928
38284
  do {
40929
38285
  if (error = action.execute(action.state, action.delay)) {
40930
38286
  break;
40931
38287
  }
40932
- } while (++index3 < count && (action = actions.shift()));
38288
+ } while (++index < count && (action = actions.shift()));
40933
38289
  this.active = false;
40934
38290
  if (error) {
40935
- while (++index3 < count && (action = actions.shift())) {
38291
+ while (++index < count && (action = actions.shift())) {
40936
38292
  action.unsubscribe();
40937
38293
  }
40938
38294
  throw error;
@@ -41012,16 +38368,16 @@ var require_VirtualTimeScheduler = __commonJS4((exports) => {
41012
38368
  exports.VirtualTimeScheduler = VirtualTimeScheduler;
41013
38369
  var VirtualAction = function(_super) {
41014
38370
  __extends(VirtualAction2, _super);
41015
- function VirtualAction2(scheduler, work, index3) {
41016
- if (index3 === undefined) {
41017
- index3 = scheduler.index += 1;
38371
+ function VirtualAction2(scheduler, work, index) {
38372
+ if (index === undefined) {
38373
+ index = scheduler.index += 1;
41018
38374
  }
41019
38375
  var _this = _super.call(this, scheduler, work) || this;
41020
38376
  _this.scheduler = scheduler;
41021
38377
  _this.work = work;
41022
- _this.index = index3;
38378
+ _this.index = index;
41023
38379
  _this.active = true;
41024
- _this.index = scheduler.index = index3;
38380
+ _this.index = scheduler.index = index;
41025
38381
  return _this;
41026
38382
  }
41027
38383
  VirtualAction2.prototype.schedule = function(state, delay) {
@@ -42112,9 +39468,9 @@ var require_mergeMap = __commonJS4((exports) => {
42112
39468
  };
42113
39469
  MergeMapSubscriber2.prototype._tryNext = function(value) {
42114
39470
  var result;
42115
- var index3 = this.index++;
39471
+ var index = this.index++;
42116
39472
  try {
42117
- result = this.project(value, index3);
39473
+ result = this.project(value, index);
42118
39474
  } catch (err2) {
42119
39475
  this.destination.error(err2);
42120
39476
  return;
@@ -42664,12 +40020,12 @@ var require_pairs3 = __commonJS4((exports) => {
42664
40020
  }
42665
40021
  exports.pairs = pairs;
42666
40022
  function dispatch(state) {
42667
- var { keys, index: index3, subscriber, subscription, obj } = state;
40023
+ var { keys, index, subscriber, subscription, obj } = state;
42668
40024
  if (!subscriber.closed) {
42669
- if (index3 < keys.length) {
42670
- var key = keys[index3];
40025
+ if (index < keys.length) {
40026
+ var key = keys[index];
42671
40027
  subscriber.next([key, obj[key]]);
42672
- subscription.add(this.schedule({ keys, index: index3 + 1, subscriber, subscription, obj }));
40028
+ subscription.add(this.schedule({ keys, index: index + 1, subscriber, subscription, obj }));
42673
40029
  } else {
42674
40030
  subscriber.complete();
42675
40031
  }
@@ -42872,18 +40228,18 @@ var require_range = __commonJS4((exports) => {
42872
40228
  count = start;
42873
40229
  start = 0;
42874
40230
  }
42875
- var index3 = 0;
40231
+ var index = 0;
42876
40232
  var current = start;
42877
40233
  if (scheduler) {
42878
40234
  return scheduler.schedule(dispatch, 0, {
42879
- index: index3,
40235
+ index,
42880
40236
  count,
42881
40237
  start,
42882
40238
  subscriber
42883
40239
  });
42884
40240
  } else {
42885
40241
  do {
42886
- if (index3++ >= count) {
40242
+ if (index++ >= count) {
42887
40243
  subscriber.complete();
42888
40244
  break;
42889
40245
  }
@@ -42898,8 +40254,8 @@ var require_range = __commonJS4((exports) => {
42898
40254
  }
42899
40255
  exports.range = range;
42900
40256
  function dispatch(state) {
42901
- var { start, index: index3, count, subscriber } = state;
42902
- if (index3 >= count) {
40257
+ var { start, index, count, subscriber } = state;
40258
+ if (index >= count) {
42903
40259
  subscriber.complete();
42904
40260
  return;
42905
40261
  }
@@ -42907,7 +40263,7 @@ var require_range = __commonJS4((exports) => {
42907
40263
  if (subscriber.closed) {
42908
40264
  return;
42909
40265
  }
42910
- state.index = index3 + 1;
40266
+ state.index = index + 1;
42911
40267
  state.start = start + 1;
42912
40268
  this.schedule(state);
42913
40269
  }
@@ -42943,14 +40299,14 @@ var require_timer = __commonJS4((exports) => {
42943
40299
  }
42944
40300
  exports.timer = timer;
42945
40301
  function dispatch(state) {
42946
- var { index: index3, period, subscriber } = state;
42947
- subscriber.next(index3);
40302
+ var { index, period, subscriber } = state;
40303
+ subscriber.next(index);
42948
40304
  if (subscriber.closed) {
42949
40305
  return;
42950
40306
  } else if (period === -1) {
42951
40307
  return subscriber.complete();
42952
40308
  }
42953
- state.index = index3 + 1;
40309
+ state.index = index + 1;
42954
40310
  this.schedule(state, period);
42955
40311
  }
42956
40312
  });
@@ -45896,16 +43252,34 @@ var require_dist = __commonJS4((exports) => {
45896
43252
  exports.RobotProxyConstructor = RobotProxyConstructor;
45897
43253
  __exportStar(require_agent(), exports);
45898
43254
  });
43255
+ var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => {
43256
+ switch (char) {
43257
+ case "&":
43258
+ return "&amp;";
43259
+ case "<":
43260
+ return "&lt;";
43261
+ case ">":
43262
+ return "&gt;";
43263
+ case '"':
43264
+ return "&quot;";
43265
+ case "'":
43266
+ return "&#39;";
43267
+ default:
43268
+ return char;
43269
+ }
43270
+ });
45899
43271
  var getBaseHtml = ({ title, message, type }) => {
45900
43272
  const icon = type === "success" ? "✓" : "✕";
45901
43273
  const iconClass = type === "success" ? "icon-success" : "icon-error";
43274
+ const safeTitle = escapeHtml(title);
43275
+ const safeMessage = escapeHtml(message);
45902
43276
  return `
45903
43277
  <!DOCTYPE html>
45904
43278
  <html lang="en">
45905
43279
  <head>
45906
43280
  <meta charset="UTF-8">
45907
43281
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
45908
- <title>${title} - UiPath CLI</title>
43282
+ <title>${safeTitle} - UiPath CLI</title>
45909
43283
  <link rel="preconnect" href="https://fonts.googleapis.com">
45910
43284
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
45911
43285
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400&family=Poppins:wght@600&display=swap" rel="stylesheet">
@@ -46031,8 +43405,8 @@ var getBaseHtml = ({ title, message, type }) => {
46031
43405
  </div>
46032
43406
  </div>
46033
43407
  <div class="icon ${iconClass}">${icon}</div>
46034
- <h1>${title}</h1>
46035
- <p>${message}</p>
43408
+ <h1>${safeTitle}</h1>
43409
+ <p>${safeMessage}</p>
46036
43410
  <div class="footer">You can close this window</div>
46037
43411
  </div>
46038
43412
  </div>
@@ -46229,6 +43603,13 @@ class NodeAuthStrategy {
46229
43603
  if (c > 31 && (c < 128 || c > 159))
46230
43604
  safeUrl += ch;
46231
43605
  }
43606
+ if (opts?.noBrowser) {
43607
+ if (!opts.onAuthUrl) {
43608
+ throw new Error("Headless login (noBrowser) requires an onAuthUrl handler to surface the authorize URL, but none was provided.");
43609
+ }
43610
+ opts.onAuthUrl(safeUrl);
43611
+ return;
43612
+ }
46232
43613
  const [openError] = await catchError3(fs72.utils.open(url));
46233
43614
  if (!openError)
46234
43615
  return;
@@ -46305,6 +43686,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
46305
43686
  }
46306
43687
  return url.pathname.length > 1 ? url.origin : baseUrl;
46307
43688
  };
43689
+ var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
43690
+ const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
43691
+ if (isExternalAppAuth)
43692
+ return requestedScopes;
43693
+ return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
43694
+ };
46308
43695
  var resolveConfigAsync = async ({
46309
43696
  customAuthority,
46310
43697
  customClientId,
@@ -46335,7 +43722,7 @@ var resolveConfigAsync = async ({
46335
43722
  clientSecret = fileAuth.clientSecret;
46336
43723
  }
46337
43724
  const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
46338
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
43725
+ const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
46339
43726
  return {
46340
43727
  clientId,
46341
43728
  clientSecret,
@@ -46906,6 +44293,74 @@ class Configuration3 {
46906
44293
  Object.freeze(Configuration3.prototype);
46907
44294
  var retry = Symbol();
46908
44295
  init_src();
44296
+ init_src();
44297
+ init_constants();
44298
+ var DEFAULT_AUTH_PROFILE = "default";
44299
+ var PROFILE_DIR = "profiles";
44300
+ var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
44301
+ var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
44302
+ var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
44303
+ var globalSlot2 = globalThis;
44304
+ function isAuthProfileStorage(value) {
44305
+ return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
44306
+ }
44307
+ function createProfileStorage() {
44308
+ const [error, mod3] = catchError3(() => __require5("node:async_hooks"));
44309
+ if (error || typeof mod3?.AsyncLocalStorage !== "function") {
44310
+ return {
44311
+ getStore: () => {
44312
+ return;
44313
+ },
44314
+ run: (_store, fn) => fn()
44315
+ };
44316
+ }
44317
+ return new mod3.AsyncLocalStorage;
44318
+ }
44319
+ function getProfileStorage() {
44320
+ const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
44321
+ if (isAuthProfileStorage(existing)) {
44322
+ return existing;
44323
+ }
44324
+ const storage = createProfileStorage();
44325
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
44326
+ return storage;
44327
+ }
44328
+ var profileStorage = getProfileStorage();
44329
+
44330
+ class AuthProfileValidationError extends Error {
44331
+ constructor(message) {
44332
+ super(message);
44333
+ this.name = "AuthProfileValidationError";
44334
+ }
44335
+ }
44336
+ function normalizeAuthProfileName(profile) {
44337
+ if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
44338
+ return;
44339
+ }
44340
+ if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
44341
+ throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
44342
+ }
44343
+ return profile;
44344
+ }
44345
+ function getActiveAuthProfile() {
44346
+ const scopedState = profileStorage.getStore();
44347
+ if (scopedState !== undefined) {
44348
+ return scopedState.profile;
44349
+ }
44350
+ return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
44351
+ }
44352
+ function resolveAuthProfileFilePath(profile) {
44353
+ const normalized = normalizeAuthProfileName(profile);
44354
+ if (normalized === undefined) {
44355
+ throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
44356
+ }
44357
+ const fs72 = getFileSystem5();
44358
+ return fs72.path.join(fs72.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
44359
+ }
44360
+ function getActiveAuthProfileFilePath() {
44361
+ const profile = getActiveAuthProfile();
44362
+ return profile ? resolveAuthProfileFilePath(profile) : undefined;
44363
+ }
46909
44364
 
46910
44365
  class InvalidIssuerError extends Error {
46911
44366
  expected;
@@ -47032,21 +44487,70 @@ var readAuthFromEnv = () => {
47032
44487
  organizationId,
47033
44488
  tenantName,
47034
44489
  tenantId,
47035
- expiration
44490
+ expiration,
44491
+ source: "env"
47036
44492
  };
47037
44493
  };
47038
44494
  init_src();
44495
+ var BREAKER_SUFFIX = ".refresh-state";
44496
+ var BACKOFF_BASE_MS = 60000;
44497
+ var BACKOFF_CAP_MS = 3600000;
44498
+ var SURFACE_WINDOW_MS = 3600000;
44499
+ async function refreshTokenFingerprint(refreshToken) {
44500
+ const bytes = new TextEncoder().encode(refreshToken);
44501
+ if (globalThis.crypto?.subtle) {
44502
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
44503
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
44504
+ }
44505
+ const { createHash: createHash2 } = await import("node:crypto");
44506
+ return createHash2("sha256").update(refreshToken).digest("hex").slice(0, 16);
44507
+ }
44508
+ function breakerPathFor(authPath) {
44509
+ return `${authPath}${BREAKER_SUFFIX}`;
44510
+ }
44511
+ async function loadRefreshBreaker(authPath) {
44512
+ const fs72 = getFileSystem5();
44513
+ try {
44514
+ const content = await fs72.readFile(breakerPathFor(authPath), "utf-8");
44515
+ if (!content)
44516
+ return {};
44517
+ const parsed = JSON.parse(content);
44518
+ return parsed && typeof parsed === "object" ? parsed : {};
44519
+ } catch {
44520
+ return {};
44521
+ }
44522
+ }
44523
+ async function saveRefreshBreaker(authPath, state) {
44524
+ try {
44525
+ const fs72 = getFileSystem5();
44526
+ const path32 = breakerPathFor(authPath);
44527
+ await fs72.mkdir(fs72.path.dirname(path32));
44528
+ const tempPath = `${path32}.tmp`;
44529
+ await fs72.writeFile(tempPath, JSON.stringify(state));
44530
+ await fs72.rename(tempPath, path32);
44531
+ } catch {}
44532
+ }
44533
+ async function clearRefreshBreaker(authPath) {
44534
+ const fs72 = getFileSystem5();
44535
+ const path32 = breakerPathFor(authPath);
44536
+ try {
44537
+ if (await fs72.exists(path32)) {
44538
+ await fs72.rm(path32);
44539
+ }
44540
+ } catch {}
44541
+ }
44542
+ function nextBackoffMs(attempts) {
44543
+ const shift = Math.max(0, attempts - 1);
44544
+ return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
44545
+ }
44546
+ function shouldSurface(state, nowMs) {
44547
+ if (state.lastSurfacedAtMs === undefined)
44548
+ return true;
44549
+ return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
44550
+ }
44551
+ init_src();
47039
44552
  var DEFAULT_TIMEOUT_MS = 1000;
47040
44553
  var CLOSE_TIMEOUT_MS = 500;
47041
- var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
47042
- var printNoticeOnce = () => {
47043
- const slot = globalThis;
47044
- if (slot[NOTICE_SENTINEL])
47045
- return;
47046
- slot[NOTICE_SENTINEL] = true;
47047
- catchError3(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
47048
- `));
47049
- };
47050
44554
  var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
47051
44555
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
47052
44556
  var PIPE_NAME_MAX_LENGTH = 103;
@@ -47162,7 +44666,6 @@ var tryRobotClientFallback = async (options = {}) => {
47162
44666
  issuerFromToken = issClaim;
47163
44667
  }
47164
44668
  }
47165
- printNoticeOnce();
47166
44669
  return {
47167
44670
  accessToken,
47168
44671
  baseUrl: parsedUrl.baseUrl,
@@ -47385,19 +44888,329 @@ var LoginStatusSource;
47385
44888
  ((LoginStatusSource2) => {
47386
44889
  LoginStatusSource2["File"] = "file";
47387
44890
  LoginStatusSource2["Robot"] = "robot";
44891
+ LoginStatusSource2["Env"] = "env";
47388
44892
  })(LoginStatusSource ||= {});
47389
- function normalizeTokenRefreshFailure() {
47390
- return "stored refresh token is invalid or expired";
44893
+ var getLoginStatusAsync = async (options = {}) => {
44894
+ return getLoginStatusWithDeps(options);
44895
+ };
44896
+ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
44897
+ const {
44898
+ resolveEnvFilePath = resolveEnvFilePathAsync,
44899
+ loadEnvFile = loadEnvFileAsync,
44900
+ saveEnvFile = saveEnvFileAsync,
44901
+ getFs = getFileSystem5,
44902
+ refreshToken: refreshTokenFn = refreshAccessToken,
44903
+ resolveConfig = resolveConfigAsync,
44904
+ robotFallback = tryRobotClientFallback,
44905
+ loadBreaker = loadRefreshBreaker,
44906
+ saveBreaker = saveRefreshBreaker,
44907
+ clearBreaker = clearRefreshBreaker
44908
+ } = deps;
44909
+ if (isRobotAuthEnforced()) {
44910
+ return resolveRobotEnforcedStatus(robotFallback);
44911
+ }
44912
+ if (isEnvAuthEnabled()) {
44913
+ return readAuthFromEnv();
44914
+ }
44915
+ const activeProfile = getActiveAuthProfile();
44916
+ const activeProfileFilePath = getActiveAuthProfileFilePath();
44917
+ const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
44918
+ const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
44919
+ const { ensureTokenValidityMinutes } = options;
44920
+ const { absolutePath } = await resolveEnvFilePath(envFilePath);
44921
+ if (absolutePath === undefined) {
44922
+ if (usingActiveProfile) {
44923
+ return {
44924
+ loginStatus: "Not logged in",
44925
+ hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
44926
+ };
44927
+ }
44928
+ return resolveBorrowedRobotStatus(robotFallback);
44929
+ }
44930
+ const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
44931
+ if ("status" in loaded) {
44932
+ return loaded.status;
44933
+ }
44934
+ const { credentials } = loaded;
44935
+ const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
44936
+ const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
44937
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
44938
+ let tokens = {
44939
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
44940
+ refreshToken: credentials.UIPATH_REFRESH_TOKEN,
44941
+ expiration,
44942
+ lockReleaseFailed: false
44943
+ };
44944
+ const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
44945
+ if (expiration && expiration <= outerThreshold && refreshToken) {
44946
+ const refreshed = await attemptRefresh({
44947
+ absolutePath,
44948
+ credentials,
44949
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
44950
+ refreshToken,
44951
+ expiration,
44952
+ ensureTokenValidityMinutes,
44953
+ getFs,
44954
+ loadEnvFile,
44955
+ saveEnvFile,
44956
+ refreshFn: refreshTokenFn,
44957
+ resolveConfig,
44958
+ loadBreaker,
44959
+ saveBreaker,
44960
+ clearBreaker,
44961
+ globalHint
44962
+ });
44963
+ if (refreshed.kind === "terminal") {
44964
+ return refreshed.status;
44965
+ }
44966
+ tokens = refreshed.tokens;
44967
+ }
44968
+ return buildFileStatus(tokens, credentials, globalHint);
44969
+ };
44970
+ async function resolveRobotEnforcedStatus(robotFallback) {
44971
+ if (isEnvAuthEnabled()) {
44972
+ throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true are mutually exclusive. Unset one of them and re-run.`);
44973
+ }
44974
+ const robotCreds = await robotFallback({ force: true });
44975
+ if (!robotCreds) {
44976
+ return {
44977
+ loginStatus: "Not logged in",
44978
+ 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.`
44979
+ };
44980
+ }
44981
+ return buildRobotStatus(robotCreds);
47391
44982
  }
47392
- function normalizeTokenRefreshUnavailableFailure() {
47393
- return "token refresh failed before authentication completed";
44983
+ async function resolveBorrowedRobotStatus(robotFallback) {
44984
+ const robotCreds = await robotFallback();
44985
+ return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
47394
44986
  }
47395
- function errorMessage(error) {
47396
- return error instanceof Error ? error.message : String(error);
44987
+ async function loadFileCredentials(loadEnvFile, absolutePath) {
44988
+ let credentials;
44989
+ try {
44990
+ credentials = await loadEnvFile({ envPath: absolutePath });
44991
+ } catch (error) {
44992
+ if (isFileNotFoundError(error)) {
44993
+ return { status: { loginStatus: "Not logged in" } };
44994
+ }
44995
+ throw error;
44996
+ }
44997
+ if (!credentials.UIPATH_ACCESS_TOKEN) {
44998
+ return { status: { loginStatus: "Not logged in" } };
44999
+ }
45000
+ return { credentials };
45001
+ }
45002
+ async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
45003
+ const fs72 = getFs();
45004
+ const globalPath = fs72.path.join(fs72.env.homedir(), envFilePath);
45005
+ if (absolutePath === globalPath)
45006
+ return;
45007
+ if (!await fs72.exists(globalPath))
45008
+ return;
45009
+ try {
45010
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
45011
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
45012
+ return;
45013
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
45014
+ if (globalExp && globalExp <= new Date)
45015
+ return;
45016
+ 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.`;
45017
+ } catch {
45018
+ return;
45019
+ }
47397
45020
  }
47398
45021
  function computeExpirationThreshold(ensureTokenValidityMinutes) {
47399
45022
  return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
47400
45023
  }
45024
+ async function attemptRefresh(ctx) {
45025
+ const shortCircuit = await circuitBreakerShortCircuit(ctx);
45026
+ if (shortCircuit) {
45027
+ return { kind: "terminal", status: shortCircuit };
45028
+ }
45029
+ let release;
45030
+ try {
45031
+ release = await ctx.getFs().acquireLock(ctx.absolutePath);
45032
+ } catch (error) {
45033
+ return {
45034
+ kind: "terminal",
45035
+ status: await lockAcquireFailureStatus(ctx, error)
45036
+ };
45037
+ }
45038
+ let lockedFailure;
45039
+ let lockReleaseFailed = false;
45040
+ let success;
45041
+ try {
45042
+ const outcome = await runRefreshLocked({
45043
+ absolutePath: ctx.absolutePath,
45044
+ refreshToken: ctx.refreshToken,
45045
+ customAuthority: ctx.credentials.UIPATH_URL,
45046
+ ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
45047
+ loadEnvFile: ctx.loadEnvFile,
45048
+ saveEnvFile: ctx.saveEnvFile,
45049
+ refreshFn: ctx.refreshFn,
45050
+ resolveConfig: ctx.resolveConfig,
45051
+ loadBreaker: ctx.loadBreaker,
45052
+ saveBreaker: ctx.saveBreaker,
45053
+ clearBreaker: ctx.clearBreaker
45054
+ });
45055
+ if (outcome.kind === "fail") {
45056
+ lockedFailure = outcome.status;
45057
+ } else {
45058
+ success = outcome;
45059
+ }
45060
+ } finally {
45061
+ try {
45062
+ await release();
45063
+ } catch {
45064
+ lockReleaseFailed = true;
45065
+ }
45066
+ }
45067
+ if (lockedFailure) {
45068
+ const globalHint = await ctx.globalHint();
45069
+ const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
45070
+ return {
45071
+ kind: "terminal",
45072
+ status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
45073
+ };
45074
+ }
45075
+ return {
45076
+ kind: "refreshed",
45077
+ tokens: {
45078
+ accessToken: success?.accessToken,
45079
+ refreshToken: success?.refreshToken,
45080
+ expiration: success?.expiration,
45081
+ tokenRefresh: success?.tokenRefresh,
45082
+ persistenceWarning: success?.persistenceWarning,
45083
+ lockReleaseFailed
45084
+ }
45085
+ };
45086
+ }
45087
+ async function buildFileStatus(tokens, credentials, globalHint) {
45088
+ const result = {
45089
+ loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
45090
+ accessToken: tokens.accessToken,
45091
+ refreshToken: tokens.refreshToken,
45092
+ baseUrl: credentials.UIPATH_URL,
45093
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
45094
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
45095
+ tenantName: credentials.UIPATH_TENANT_NAME,
45096
+ tenantId: credentials.UIPATH_TENANT_ID,
45097
+ expiration: tokens.expiration,
45098
+ source: "file",
45099
+ ...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
45100
+ ...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
45101
+ ...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
45102
+ };
45103
+ if (result.loginStatus === "Expired") {
45104
+ const hint = await globalHint();
45105
+ if (hint) {
45106
+ result.hint = hint;
45107
+ }
45108
+ }
45109
+ return result;
45110
+ }
45111
+ function buildRobotStatus(robotCreds) {
45112
+ return {
45113
+ loginStatus: "Logged in",
45114
+ accessToken: robotCreds.accessToken,
45115
+ baseUrl: robotCreds.baseUrl,
45116
+ organizationName: robotCreds.organizationName,
45117
+ organizationId: robotCreds.organizationId,
45118
+ tenantName: robotCreds.tenantName,
45119
+ tenantId: robotCreds.tenantId,
45120
+ issuer: robotCreds.issuer,
45121
+ expiration: getTokenExpiration(robotCreds.accessToken),
45122
+ source: "robot"
45123
+ };
45124
+ }
45125
+ var isFileNotFoundError = (error) => {
45126
+ if (!(error instanceof Object))
45127
+ return false;
45128
+ return error.code === "ENOENT";
45129
+ };
45130
+ async function circuitBreakerShortCircuit(ctx) {
45131
+ const {
45132
+ absolutePath,
45133
+ refreshToken,
45134
+ accessToken,
45135
+ credentials,
45136
+ expiration,
45137
+ loadBreaker,
45138
+ saveBreaker,
45139
+ clearBreaker
45140
+ } = ctx;
45141
+ const fingerprint = await refreshTokenFingerprint(refreshToken);
45142
+ const breaker = await loadBreaker(absolutePath).catch(() => ({}));
45143
+ if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
45144
+ await clearBreaker(absolutePath);
45145
+ breaker.deadTokenFp = undefined;
45146
+ }
45147
+ const nowMs = Date.now();
45148
+ const tokenIsDead = breaker.deadTokenFp === fingerprint;
45149
+ const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
45150
+ if (!tokenIsDead && !inBackoff)
45151
+ return;
45152
+ const globalHint = await ctx.globalHint();
45153
+ const suppressed = !shouldSurface(breaker, nowMs);
45154
+ if (!suppressed) {
45155
+ await saveBreaker(absolutePath, {
45156
+ ...breaker,
45157
+ lastSurfacedAtMs: nowMs
45158
+ });
45159
+ }
45160
+ 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>.";
45161
+ const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
45162
+ return {
45163
+ loginStatus: globalHint ? "Expired" : "Refresh Failed",
45164
+ ...globalHint ? {
45165
+ accessToken,
45166
+ refreshToken,
45167
+ baseUrl: credentials.UIPATH_URL,
45168
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
45169
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
45170
+ tenantName: credentials.UIPATH_TENANT_NAME,
45171
+ tenantId: credentials.UIPATH_TENANT_ID,
45172
+ expiration,
45173
+ source: "file"
45174
+ } : {},
45175
+ hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
45176
+ refreshCircuitOpen: true,
45177
+ refreshTelemetrySuppressed: suppressed,
45178
+ tokenRefresh: { attempted: false, success: false }
45179
+ };
45180
+ }
45181
+ async function lockAcquireFailureStatus(ctx, error) {
45182
+ const msg = errorMessage(error);
45183
+ const globalHint = await ctx.globalHint();
45184
+ if (globalHint) {
45185
+ return {
45186
+ loginStatus: "Expired",
45187
+ accessToken: ctx.accessToken,
45188
+ refreshToken: ctx.refreshToken,
45189
+ baseUrl: ctx.credentials.UIPATH_URL,
45190
+ organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
45191
+ organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
45192
+ tenantName: ctx.credentials.UIPATH_TENANT_NAME,
45193
+ tenantId: ctx.credentials.UIPATH_TENANT_ID,
45194
+ expiration: ctx.expiration,
45195
+ source: "file",
45196
+ hint: globalHint,
45197
+ tokenRefresh: {
45198
+ attempted: false,
45199
+ success: false,
45200
+ errorMessage: `lock acquisition failed: ${msg}`
45201
+ }
45202
+ };
45203
+ }
45204
+ return {
45205
+ loginStatus: "Refresh Failed",
45206
+ 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.",
45207
+ tokenRefresh: {
45208
+ attempted: false,
45209
+ success: false,
45210
+ errorMessage: `lock acquisition failed: ${msg}`
45211
+ }
45212
+ };
45213
+ }
47401
45214
  async function runRefreshLocked(inputs) {
47402
45215
  const {
47403
45216
  absolutePath,
@@ -47407,7 +45220,10 @@ async function runRefreshLocked(inputs) {
47407
45220
  loadEnvFile,
47408
45221
  saveEnvFile,
47409
45222
  refreshFn,
47410
- resolveConfig
45223
+ resolveConfig,
45224
+ loadBreaker,
45225
+ saveBreaker,
45226
+ clearBreaker
47411
45227
  } = inputs;
47412
45228
  const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
47413
45229
  let fresh;
@@ -47430,6 +45246,7 @@ async function runRefreshLocked(inputs) {
47430
45246
  const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
47431
45247
  const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
47432
45248
  if (freshAccess && freshExp && freshExp > expirationThreshold) {
45249
+ await clearBreaker(absolutePath);
47433
45250
  return {
47434
45251
  kind: "ok",
47435
45252
  accessToken: freshAccess,
@@ -47453,8 +45270,21 @@ async function runRefreshLocked(inputs) {
47453
45270
  refreshedRefresh = refreshed.refreshToken;
47454
45271
  } catch (error) {
47455
45272
  const isOAuthFailure = isTokenRefreshOAuthFailure(error);
47456
- 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.";
45273
+ 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.";
47457
45274
  const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
45275
+ const fp = await refreshTokenFingerprint(tokenForIdP);
45276
+ if (isOAuthFailure) {
45277
+ await saveBreaker(absolutePath, { deadTokenFp: fp });
45278
+ } else {
45279
+ const prior = await loadBreaker(absolutePath).catch(() => ({}));
45280
+ const attempts = (prior.attempts ?? 0) + 1;
45281
+ await saveBreaker(absolutePath, {
45282
+ ...prior,
45283
+ deadTokenFp: undefined,
45284
+ attempts,
45285
+ backoffUntilMs: Date.now() + nextBackoffMs(attempts)
45286
+ });
45287
+ }
47458
45288
  return {
47459
45289
  kind: "fail",
47460
45290
  status: {
@@ -47483,6 +45313,7 @@ async function runRefreshLocked(inputs) {
47483
45313
  }
47484
45314
  };
47485
45315
  }
45316
+ await clearBreaker(absolutePath);
47486
45317
  try {
47487
45318
  await saveEnvFile({
47488
45319
  envPath: absolutePath,
@@ -47515,212 +45346,15 @@ async function runRefreshLocked(inputs) {
47515
45346
  };
47516
45347
  }
47517
45348
  }
47518
- var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
47519
- const {
47520
- resolveEnvFilePath = resolveEnvFilePathAsync,
47521
- loadEnvFile = loadEnvFileAsync,
47522
- saveEnvFile = saveEnvFileAsync,
47523
- getFs = getFileSystem5,
47524
- refreshToken: refreshTokenFn = refreshAccessToken,
47525
- resolveConfig = resolveConfigAsync,
47526
- robotFallback = tryRobotClientFallback
47527
- } = deps;
47528
- if (isRobotAuthEnforced()) {
47529
- if (isEnvAuthEnabled()) {
47530
- throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true are mutually exclusive. Unset one of them and re-run.`);
47531
- }
47532
- const robotCreds = await robotFallback({ force: true });
47533
- if (!robotCreds) {
47534
- return {
47535
- loginStatus: "Not logged in",
47536
- 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.`
47537
- };
47538
- }
47539
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
47540
- return {
47541
- loginStatus: "Logged in",
47542
- accessToken: robotCreds.accessToken,
47543
- baseUrl: robotCreds.baseUrl,
47544
- organizationName: robotCreds.organizationName,
47545
- organizationId: robotCreds.organizationId,
47546
- tenantName: robotCreds.tenantName,
47547
- tenantId: robotCreds.tenantId,
47548
- issuer: robotCreds.issuer,
47549
- expiration: expiration2,
47550
- source: "robot"
47551
- };
47552
- }
47553
- if (isEnvAuthEnabled()) {
47554
- return readAuthFromEnv();
47555
- }
47556
- const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
47557
- const { absolutePath } = await resolveEnvFilePath(envFilePath);
47558
- if (absolutePath === undefined) {
47559
- const robotCreds = await robotFallback();
47560
- if (robotCreds) {
47561
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
47562
- const status = {
47563
- loginStatus: "Logged in",
47564
- accessToken: robotCreds.accessToken,
47565
- baseUrl: robotCreds.baseUrl,
47566
- organizationName: robotCreds.organizationName,
47567
- organizationId: robotCreds.organizationId,
47568
- tenantName: robotCreds.tenantName,
47569
- tenantId: robotCreds.tenantId,
47570
- issuer: robotCreds.issuer,
47571
- expiration: expiration2,
47572
- source: "robot"
47573
- };
47574
- return status;
47575
- }
47576
- return { loginStatus: "Not logged in" };
47577
- }
47578
- let credentials;
47579
- try {
47580
- credentials = await loadEnvFile({ envPath: absolutePath });
47581
- } catch (error) {
47582
- if (isFileNotFoundError(error)) {
47583
- return { loginStatus: "Not logged in" };
47584
- }
47585
- throw error;
47586
- }
47587
- if (!credentials.UIPATH_ACCESS_TOKEN) {
47588
- return { loginStatus: "Not logged in" };
47589
- }
47590
- let accessToken = credentials.UIPATH_ACCESS_TOKEN;
47591
- let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
47592
- let expiration = getTokenExpiration(accessToken);
47593
- let persistenceWarning;
47594
- let lockReleaseFailed = false;
47595
- let tokenRefresh;
47596
- const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
47597
- const tryGlobalCredsHint = async () => {
47598
- const fs72 = getFs();
47599
- const globalPath = fs72.path.join(fs72.env.homedir(), envFilePath);
47600
- if (absolutePath === globalPath)
47601
- return;
47602
- if (!await fs72.exists(globalPath))
47603
- return;
47604
- try {
47605
- const globalCreds = await loadEnvFile({ envPath: globalPath });
47606
- if (!globalCreds.UIPATH_ACCESS_TOKEN)
47607
- return;
47608
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
47609
- if (globalExp && globalExp <= new Date)
47610
- return;
47611
- 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.`;
47612
- } catch {
47613
- return;
47614
- }
47615
- };
47616
- if (expiration && expiration <= outerThreshold && refreshToken) {
47617
- let release;
47618
- try {
47619
- release = await getFs().acquireLock(absolutePath);
47620
- } catch (error) {
47621
- const msg = errorMessage(error);
47622
- const globalHint = await tryGlobalCredsHint();
47623
- if (globalHint) {
47624
- return {
47625
- loginStatus: "Expired",
47626
- accessToken,
47627
- refreshToken,
47628
- baseUrl: credentials.UIPATH_URL,
47629
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
47630
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
47631
- tenantName: credentials.UIPATH_TENANT_NAME,
47632
- tenantId: credentials.UIPATH_TENANT_ID,
47633
- expiration,
47634
- source: "file",
47635
- hint: globalHint,
47636
- tokenRefresh: {
47637
- attempted: false,
47638
- success: false,
47639
- errorMessage: `lock acquisition failed: ${msg}`
47640
- }
47641
- };
47642
- }
47643
- return {
47644
- loginStatus: "Refresh Failed",
47645
- 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.",
47646
- tokenRefresh: {
47647
- attempted: false,
47648
- success: false,
47649
- errorMessage: `lock acquisition failed: ${msg}`
47650
- }
47651
- };
47652
- }
47653
- let lockedFailure;
47654
- try {
47655
- const outcome = await runRefreshLocked({
47656
- absolutePath,
47657
- refreshToken,
47658
- customAuthority: credentials.UIPATH_URL,
47659
- ensureTokenValidityMinutes,
47660
- loadEnvFile,
47661
- saveEnvFile,
47662
- refreshFn: refreshTokenFn,
47663
- resolveConfig
47664
- });
47665
- if (outcome.kind === "fail") {
47666
- lockedFailure = outcome.status;
47667
- } else {
47668
- accessToken = outcome.accessToken;
47669
- refreshToken = outcome.refreshToken;
47670
- expiration = outcome.expiration;
47671
- tokenRefresh = outcome.tokenRefresh;
47672
- if (outcome.persistenceWarning) {
47673
- persistenceWarning = outcome.persistenceWarning;
47674
- }
47675
- }
47676
- } finally {
47677
- try {
47678
- await release();
47679
- } catch {
47680
- lockReleaseFailed = true;
47681
- }
47682
- }
47683
- if (lockedFailure) {
47684
- const globalHint = await tryGlobalCredsHint();
47685
- const base = globalHint ? {
47686
- ...lockedFailure,
47687
- loginStatus: "Expired",
47688
- hint: globalHint
47689
- } : lockedFailure;
47690
- return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
47691
- }
47692
- }
47693
- const result = {
47694
- loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
47695
- accessToken,
47696
- refreshToken,
47697
- baseUrl: credentials.UIPATH_URL,
47698
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
47699
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
47700
- tenantName: credentials.UIPATH_TENANT_NAME,
47701
- tenantId: credentials.UIPATH_TENANT_ID,
47702
- expiration,
47703
- source: "file",
47704
- ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
47705
- ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
47706
- ...tokenRefresh ? { tokenRefresh } : {}
47707
- };
47708
- if (result.loginStatus === "Expired") {
47709
- const globalHint = await tryGlobalCredsHint();
47710
- if (globalHint) {
47711
- result.hint = globalHint;
47712
- }
47713
- }
47714
- return result;
47715
- };
47716
- var isFileNotFoundError = (error) => {
47717
- if (!(error instanceof Object))
47718
- return false;
47719
- return error.code === "ENOENT";
47720
- };
47721
- var getLoginStatusAsync = async (options = {}) => {
47722
- return getLoginStatusWithDeps(options);
47723
- };
45349
+ function normalizeTokenRefreshFailure() {
45350
+ return "stored refresh token is invalid or expired";
45351
+ }
45352
+ function normalizeTokenRefreshUnavailableFailure() {
45353
+ return "token refresh failed before authentication completed";
45354
+ }
45355
+ function errorMessage(error) {
45356
+ return error instanceof Error ? error.message : String(error);
45357
+ }
47724
45358
  var getAuthEnv = async (options = {}) => {
47725
45359
  const authEnv = {};
47726
45360
  let status;
@@ -47750,6 +45384,12 @@ var getAuthEnv = async (options = {}) => {
47750
45384
  return { authEnv, loginStatus: status };
47751
45385
  };
47752
45386
  init_src();
45387
+ var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
45388
+ var INVALID_TENANT_CODE = "INVALID_TENANT";
45389
+ var TENANT_SELECTION_CODES = new Set([
45390
+ TENANT_SELECTION_REQUIRED_CODE,
45391
+ INVALID_TENANT_CODE
45392
+ ]);
47753
45393
  init_src();
47754
45394
  init_server();
47755
45395
 
@@ -48197,3 +45837,5 @@ export {
48197
45837
  registerCommands,
48198
45838
  metadata
48199
45839
  };
45840
+
45841
+ //# debugId=7979A26770B8927364756E2164756E21