@uipath/common 1.197.0 → 1.198.0-preview.80

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.
@@ -45,15 +45,19 @@ export interface ConnectivityError {
45
45
  /** Actionable, user-facing remediation steps. */
46
46
  instructions: string;
47
47
  }
48
+ export declare function formatErrorChain(error: unknown): string;
48
49
  /**
49
- * Classify an outbound connectivity failure by walking the `cause` chain.
50
+ * Classify an outbound connectivity failure by walking the error graph.
50
51
  *
51
52
  * Node's native `fetch` wraps the real failure (a TLS or socket error) inside
52
53
  * a generic `TypeError: fetch failed`, so the useful code/message lives on
53
- * `error.cause` (sometimes nested deeper). This unwraps that chain and, when
54
- * it finds a known TLS or network code, returns the specific message plus
55
- * remediation steps. Returns `undefined` for anything that isn't a recognised
56
- * connectivity failure so callers can fall back to their normal handling.
54
+ * `error.cause` (sometimes nested deeper). When fetch races several addresses
55
+ * (IPv4/IPv6, or proxy fallbacks) it instead collects the per-attempt failures
56
+ * in an `AggregateError.errors` array so the code can hide there rather than
57
+ * on a single `.cause`. This walks both edges and, when it finds a known TLS
58
+ * or network code, returns the specific message plus remediation steps.
59
+ * Returns `undefined` for anything that isn't a recognised connectivity
60
+ * failure so callers can fall back to their normal handling.
57
61
  */
58
62
  export declare function describeConnectivityError(error: unknown): ConnectivityError | undefined;
59
63
  export declare function isHtmlDocument(body: string): boolean;
@@ -179,6 +179,7 @@ export declare namespace OutputFormatter {
179
179
  function emitList<T extends DataRecord>(code: string, items: T[], opts?: {
180
180
  emptyInstructions?: string;
181
181
  warning?: string;
182
+ pagination?: Pagination;
182
183
  }): void;
183
184
  /**
184
185
  * Log an informational/progress message to stderr.
@@ -21051,9 +21051,47 @@ var TLS_ERROR_CODES = new Set([
21051
21051
  ]);
21052
21052
  var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
21053
21053
  var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
21054
+ function formatErrorChain(error) {
21055
+ const lines = [];
21056
+ const seen = new Set;
21057
+ const visit = (value, depth) => {
21058
+ if (lines.length >= 32)
21059
+ return;
21060
+ const indent = " ".repeat(depth);
21061
+ if (value === null || typeof value !== "object") {
21062
+ lines.push(`${indent}${String(value)}`);
21063
+ return;
21064
+ }
21065
+ if (seen.has(value))
21066
+ return;
21067
+ seen.add(value);
21068
+ const cur = value;
21069
+ const name = typeof cur.name === "string" ? cur.name : "Error";
21070
+ const message = typeof cur.message === "string" ? cur.message : String(value);
21071
+ const code2 = typeof cur.code === "string" ? ` [${cur.code}]` : "";
21072
+ lines.push(`${indent}${name}: ${message}${code2}`);
21073
+ if (cur.cause !== undefined)
21074
+ visit(cur.cause, depth + 1);
21075
+ if (Array.isArray(cur.errors)) {
21076
+ for (const nested of cur.errors) {
21077
+ visit(nested, depth + 1);
21078
+ }
21079
+ }
21080
+ };
21081
+ visit(error, 0);
21082
+ return lines.join(`
21083
+ `);
21084
+ }
21054
21085
  function describeConnectivityError(error) {
21055
- let current = error;
21056
- for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
21086
+ const queue2 = [error];
21087
+ const seen = new Set;
21088
+ for (let steps = 0;queue2.length > 0 && steps < 32; steps++) {
21089
+ const current = queue2.shift();
21090
+ if (current === null || typeof current !== "object")
21091
+ continue;
21092
+ if (seen.has(current))
21093
+ continue;
21094
+ seen.add(current);
21057
21095
  const cur = current;
21058
21096
  const code2 = typeof cur.code === "string" ? cur.code : undefined;
21059
21097
  const message = typeof cur.message === "string" ? cur.message : undefined;
@@ -21073,7 +21111,10 @@ function describeConnectivityError(error) {
21073
21111
  instructions: NETWORK_INSTRUCTIONS
21074
21112
  };
21075
21113
  }
21076
- current = cur.cause;
21114
+ if (cur.cause !== undefined)
21115
+ queue2.push(cur.cause);
21116
+ if (Array.isArray(cur.errors))
21117
+ queue2.push(...cur.errors);
21077
21118
  }
21078
21119
  return;
21079
21120
  }
@@ -21668,6 +21709,7 @@ function buildActionCenterTaskUrl(baseUrl, org, tenant, taskId) {
21668
21709
  // src/output-format-context.ts
21669
21710
  var formatSlot = singleton("OutputFormat");
21670
21711
  var formatExplicitSlot = singleton("OutputFormatExplicit");
21712
+ var helpRequestedSlot = singleton("HelpRequested");
21671
21713
  var filterSlot = singleton("OutputFilter");
21672
21714
  function setOutputFormat(format4) {
21673
21715
  formatSlot.set(format4);
@@ -21681,6 +21723,12 @@ function setOutputFormatExplicit(explicit) {
21681
21723
  function getOutputFormatExplicit() {
21682
21724
  return formatExplicitSlot.get(false) ?? false;
21683
21725
  }
21726
+ function setHelpRequested(requested) {
21727
+ helpRequestedSlot.set(requested);
21728
+ }
21729
+ function getHelpRequested() {
21730
+ return helpRequestedSlot.get(false) ?? false;
21731
+ }
21684
21732
  function setOutputFilter(filter) {
21685
21733
  filterSlot.set(filter);
21686
21734
  }
@@ -23049,6 +23097,7 @@ export {
23049
23097
  setOutputFormatExplicit,
23050
23098
  setOutputFormat,
23051
23099
  setOutputFilter,
23100
+ setHelpRequested,
23052
23101
  setGlobalSink,
23053
23102
  setGlobalLogFilePath,
23054
23103
  runWithSink,
@@ -23087,10 +23136,12 @@ export {
23087
23136
  getOutputFormat,
23088
23137
  getOutputFilter,
23089
23138
  getLogFilePath,
23139
+ getHelpRequested,
23090
23140
  getGlobalLogFilePath,
23091
23141
  getConfiguredTelemetrySessionId,
23092
23142
  getCompleter,
23093
23143
  getCommandExamples,
23144
+ formatErrorChain,
23094
23145
  extractFormatFromArgs,
23095
23146
  extractErrorMessageSync,
23096
23147
  extractErrorMessage,
@@ -23135,4 +23186,4 @@ export {
23135
23186
  AUTH_FILENAME
23136
23187
  };
23137
23188
 
23138
- //# debugId=ACC353BBF445886C64756E2164756E21
23189
+ //# debugId=1ABA04740FFFD86664756E2164756E21
package/dist/index.js CHANGED
@@ -3022,9 +3022,47 @@ var TLS_ERROR_CODES = new Set([
3022
3022
  ]);
3023
3023
  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.";
3024
3024
  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.";
3025
+ function formatErrorChain(error) {
3026
+ const lines = [];
3027
+ const seen = new Set;
3028
+ const visit = (value, depth) => {
3029
+ if (lines.length >= 32)
3030
+ return;
3031
+ const indent = " ".repeat(depth);
3032
+ if (value === null || typeof value !== "object") {
3033
+ lines.push(`${indent}${String(value)}`);
3034
+ return;
3035
+ }
3036
+ if (seen.has(value))
3037
+ return;
3038
+ seen.add(value);
3039
+ const cur = value;
3040
+ const name = typeof cur.name === "string" ? cur.name : "Error";
3041
+ const message = typeof cur.message === "string" ? cur.message : String(value);
3042
+ const code = typeof cur.code === "string" ? ` [${cur.code}]` : "";
3043
+ lines.push(`${indent}${name}: ${message}${code}`);
3044
+ if (cur.cause !== undefined)
3045
+ visit(cur.cause, depth + 1);
3046
+ if (Array.isArray(cur.errors)) {
3047
+ for (const nested of cur.errors) {
3048
+ visit(nested, depth + 1);
3049
+ }
3050
+ }
3051
+ };
3052
+ visit(error, 0);
3053
+ return lines.join(`
3054
+ `);
3055
+ }
3025
3056
  function describeConnectivityError(error) {
3026
- let current = error;
3027
- for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
3057
+ const queue = [error];
3058
+ const seen = new Set;
3059
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
3060
+ const current = queue.shift();
3061
+ if (current === null || typeof current !== "object")
3062
+ continue;
3063
+ if (seen.has(current))
3064
+ continue;
3065
+ seen.add(current);
3028
3066
  const cur = current;
3029
3067
  const code = typeof cur.code === "string" ? cur.code : undefined;
3030
3068
  const message = typeof cur.message === "string" ? cur.message : undefined;
@@ -3044,7 +3082,10 @@ function describeConnectivityError(error) {
3044
3082
  instructions: NETWORK_INSTRUCTIONS
3045
3083
  };
3046
3084
  }
3047
- current = cur.cause;
3085
+ if (cur.cause !== undefined)
3086
+ queue.push(cur.cause);
3087
+ if (Array.isArray(cur.errors))
3088
+ queue.push(...cur.errors);
3048
3089
  }
3049
3090
  return;
3050
3091
  }
@@ -8456,6 +8497,7 @@ function configureLogger(config) {
8456
8497
  // src/output-format-context.ts
8457
8498
  var formatSlot = singleton("OutputFormat");
8458
8499
  var formatExplicitSlot = singleton("OutputFormatExplicit");
8500
+ var helpRequestedSlot = singleton("HelpRequested");
8459
8501
  var filterSlot = singleton("OutputFilter");
8460
8502
  function setOutputFormat(format) {
8461
8503
  formatSlot.set(format);
@@ -8469,6 +8511,12 @@ function setOutputFormatExplicit(explicit) {
8469
8511
  function getOutputFormatExplicit() {
8470
8512
  return formatExplicitSlot.get(false) ?? false;
8471
8513
  }
8514
+ function setHelpRequested(requested) {
8515
+ helpRequestedSlot.set(requested);
8516
+ }
8517
+ function getHelpRequested() {
8518
+ return helpRequestedSlot.get(false) ?? false;
8519
+ }
8472
8520
  function setOutputFilter(filter) {
8473
8521
  filterSlot.set(filter);
8474
8522
  }
@@ -10073,6 +10121,9 @@ var OutputFormatter;
10073
10121
  if (opts?.warning) {
10074
10122
  data.Warning = opts.warning;
10075
10123
  }
10124
+ if (opts?.pagination) {
10125
+ data.Pagination = opts.pagination;
10126
+ }
10076
10127
  success(data);
10077
10128
  }
10078
10129
  OutputFormatter.emitList = emitList;
@@ -10730,12 +10781,19 @@ function isGuid(value) {
10730
10781
  }
10731
10782
  // src/interactivity-context.ts
10732
10783
  var modeSlot = singleton("InteractivityMode");
10784
+ var interactiveFlagSlot = singleton("InteractiveFlag");
10733
10785
  function setInteractivityMode(mode) {
10734
10786
  modeSlot.set(mode);
10735
10787
  }
10736
10788
  function getInteractivityMode() {
10737
10789
  return modeSlot.get("auto") ?? "auto";
10738
10790
  }
10791
+ function setInteractiveFlag(passed) {
10792
+ interactiveFlagSlot.set(passed);
10793
+ }
10794
+ function wasInteractiveFlagPassed() {
10795
+ return interactiveFlagSlot.get(false) ?? false;
10796
+ }
10739
10797
  function canPrompt() {
10740
10798
  const mode = getInteractivityMode();
10741
10799
  if (mode === "always") {
@@ -11611,6 +11669,7 @@ async function ensurePackagerFactory(verb) {
11611
11669
  }
11612
11670
  export {
11613
11671
  withCompleter,
11672
+ wasInteractiveFlagPassed,
11614
11673
  warnDeprecatedTenantOption,
11615
11674
  warnDeprecatedOptionAlias,
11616
11675
  validateOutputFilter,
@@ -11628,6 +11687,8 @@ export {
11628
11687
  setOutputFormat,
11629
11688
  setOutputFilter,
11630
11689
  setInteractivityMode,
11690
+ setInteractiveFlag,
11691
+ setHelpRequested,
11631
11692
  setGlobalTelemetryProperties,
11632
11693
  setGlobalSink,
11633
11694
  setGlobalLogFilePath,
@@ -11683,11 +11744,13 @@ export {
11683
11744
  getOutputFilter,
11684
11745
  getLogFilePath,
11685
11746
  getInteractivityMode,
11747
+ getHelpRequested,
11686
11748
  getGlobalLogFilePath,
11687
11749
  getExecutionContextTelemetryProperties,
11688
11750
  getConfiguredTelemetrySessionId,
11689
11751
  getCompleter,
11690
11752
  getCommandExamples,
11753
+ formatErrorChain,
11691
11754
  extractFormatFromArgs,
11692
11755
  extractErrorMessageSync,
11693
11756
  extractErrorMessage,
@@ -11757,4 +11820,4 @@ export {
11757
11820
  ATTACHMENT_INSTRUCTIONS
11758
11821
  };
11759
11822
 
11760
- //# debugId=619EF92A7A37ECCD64756E2164756E21
11823
+ //# debugId=B968F19E94F17CAD64756E2164756E21
@@ -24,6 +24,13 @@ export type InteractivityMode = "never" | "auto" | "always";
24
24
  export declare function setInteractivityMode(mode: InteractivityMode): void;
25
25
  /** Get the current interactivity mode, defaulting to "auto". */
26
26
  export declare function getInteractivityMode(): InteractivityMode;
27
+ /**
28
+ * Record whether the global `--interactive` flag was explicitly passed on the
29
+ * command line. Called once at CLI startup, alongside {@link setInteractivityMode}.
30
+ */
31
+ export declare function setInteractiveFlag(passed: boolean): void;
32
+ /** True when the user explicitly passed `--interactive` (see {@link setInteractiveFlag}). */
33
+ export declare function wasInteractiveFlagPassed(): boolean;
27
34
  /**
28
35
  * True when the CLI may show an interactive prompt right now.
29
36
  *
@@ -27,6 +27,18 @@ export declare function setOutputFormatExplicit(explicit: boolean): void;
27
27
  * Defaults to false (i.e. resolved value is the default).
28
28
  */
29
29
  export declare function getOutputFormatExplicit(): boolean;
30
+ /**
31
+ * Record whether the user asked for help explicitly (`-h`/`--help`).
32
+ * Kept separate from the output format so that the help renderer can force
33
+ * the table layout without hijacking the format used for error output —
34
+ * errors always follow the real format (json by default). Set once at CLI
35
+ * startup.
36
+ */
37
+ export declare function setHelpRequested(requested: boolean): void;
38
+ /**
39
+ * True when `-h`/`--help` was passed on the command line. Defaults to false.
40
+ */
41
+ export declare function getHelpRequested(): boolean;
30
42
  /**
31
43
  * Set the process-wide output filter expression.
32
44
  * Called once at CLI startup after parsing the global --output-filter option.
@@ -38,5 +38,5 @@ export interface Singleton<T> {
38
38
  *
39
39
  * The key is auto-prefixed with `@uipath/common/`.
40
40
  */
41
- export declare function singleton<T>(ctor: abstract new (...args: any[]) => T): Singleton<T>;
41
+ export declare function singleton<T>(ctor: abstract new (...args: never[]) => T): Singleton<T>;
42
42
  export declare function singleton<T>(name: string): Singleton<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/common",
3
3
  "license": "MIT",
4
- "version": "1.197.0",
4
+ "version": "1.198.0-preview.80",
5
5
  "description": "Common infrastructure needed by uip tools.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -67,5 +67,5 @@
67
67
  "mihaigirleanu",
68
68
  "vlad-uipath"
69
69
  ],
70
- "gitHead": "56f68b263cec4ea1f2a39d738bd99ecf52f88fea"
70
+ "gitHead": "9b2c3c0f21a256d2f38dd28bc97e72e6f7b10a9c"
71
71
  }