@uipath/platform-tool 1.201.0-preview.115 → 1.201.0-preview.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Command,
4
4
  metadata,
5
5
  registerCommands
6
- } from "./tool-vzbz8v00.js";
6
+ } from "./tool-j5abzeps.js";
7
7
  import"./tool-9qecd4wb.js";
8
8
  import"./tool-nnna1hq7.js";
9
9
  import"./tool-5arsyj36.js";
@@ -27188,7 +27188,7 @@ var require_dist2 = __commonJS((exports) => {
27188
27188
  var package_default = {
27189
27189
  name: "@uipath/platform-tool",
27190
27190
  license: "MIT",
27191
- version: "1.201.0-preview.115",
27191
+ version: "1.201.0-preview.121",
27192
27192
  description: "Manage UiPath platform-level resources such as tenant licensing.",
27193
27193
  type: "module",
27194
27194
  main: "./dist/tool.js",
@@ -28498,6 +28498,16 @@ var getAuthContext = async (options = {}) => {
28498
28498
  };
28499
28499
  };
28500
28500
  // ../auth/src/tenantSelection.ts
28501
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
28502
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
28503
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
28504
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
28505
+ if (response.redirected) {
28506
+ return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
28507
+ }
28508
+ const contentType = response.headers.get("content-type") ?? "unknown";
28509
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
28510
+ };
28501
28511
  var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId) => {
28502
28512
  const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
28503
28513
  const response = await fetch(url, {
@@ -28507,12 +28517,16 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
28507
28517
  });
28508
28518
  if (!response.ok) {
28509
28519
  if (response.status === 401) {
28510
- throw new Error("Unauthorized: Invalid or expired access token");
28520
+ throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
28511
28521
  }
28512
28522
  const errorText = await response.text();
28513
- throw new Error(`Failed to get tenants and organizations: ${response.status} ${errorText}`);
28523
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
28524
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
28525
+ }
28526
+ const [parseError, data] = await catchError(response.json());
28527
+ if (parseError) {
28528
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
28514
28529
  }
28515
- const data = await response.json();
28516
28530
  return data;
28517
28531
  };
28518
28532
 
@@ -28580,17 +28594,18 @@ var TLS_ERROR_CODES = new Set([
28580
28594
  ]);
28581
28595
  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.";
28582
28596
  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.";
28597
+ var LOCAL_PERMISSION_ERROR_CODES = new Set(["EACCES", "EPERM", "EROFS"]);
28598
+ var LOCAL_PERMISSION_MESSAGE_PATTERN = /\b(EACCES|EPERM|EROFS)\b/;
28599
+ function localPermissionInstructions(code, path) {
28600
+ const target = path !== undefined ? `'${path}'` : "a local file or resource";
28601
+ if (code === "EROFS") {
28602
+ return `The filesystem containing ${target} is read-only (EROFS), so the ` + "CLI could not write to it. This is a local environment problem, " + "not a UiPath service error — retrying will not help. Use a " + "writable location, or give this environment write access to the " + "path.";
28603
+ }
28604
+ const remedy = process.platform === "win32" ? "Re-run from an elevated terminal, close any program holding " + "the file open, or grant your user access to the path." : "Grant this user (or the sandbox the command runs in) access " + "to the path, or run the command outside the sandbox.";
28605
+ return `The operating system denied access to ${target} (${code}). This is ` + "a local permission problem, not a UiPath service error — retrying " + `without a permission change will not help. ${remedy}`;
28606
+ }
28583
28607
  function describeConnectivityError(error) {
28584
- const queue = [error];
28585
- const seen = new Set;
28586
- for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
28587
- const current = queue.shift();
28588
- if (current === null || typeof current !== "object")
28589
- continue;
28590
- if (seen.has(current))
28591
- continue;
28592
- seen.add(current);
28593
- const cur = current;
28608
+ for (const cur of walkErrorGraph(error)) {
28594
28609
  const code = typeof cur.code === "string" ? cur.code : undefined;
28595
28610
  const message = typeof cur.message === "string" ? cur.message : undefined;
28596
28611
  if (code && TLS_ERROR_CODES.has(code)) {
@@ -28609,6 +28624,49 @@ function describeConnectivityError(error) {
28609
28624
  instructions: NETWORK_INSTRUCTIONS
28610
28625
  };
28611
28626
  }
28627
+ }
28628
+ return;
28629
+ }
28630
+ function describePermissionError(error) {
28631
+ for (const cur of walkErrorGraph(error)) {
28632
+ const message = typeof cur.message === "string" ? cur.message : undefined;
28633
+ const code = matchLocalPermissionCode(cur.code, message);
28634
+ if (!code)
28635
+ continue;
28636
+ const path = localPermissionPath(cur.path, message);
28637
+ return {
28638
+ code,
28639
+ message: message ?? code,
28640
+ ...path !== undefined ? { path } : {},
28641
+ instructions: localPermissionInstructions(code, path)
28642
+ };
28643
+ }
28644
+ return;
28645
+ }
28646
+ function matchLocalPermissionCode(code, message) {
28647
+ if (typeof code === "string" && LOCAL_PERMISSION_ERROR_CODES.has(code)) {
28648
+ return code;
28649
+ }
28650
+ const match = message ? LOCAL_PERMISSION_MESSAGE_PATTERN.exec(message) : null;
28651
+ return match ? match[1] : undefined;
28652
+ }
28653
+ function localPermissionPath(path, message) {
28654
+ if (typeof path === "string")
28655
+ return path;
28656
+ return message ? /'([^']+)'/.exec(message)?.[1] : undefined;
28657
+ }
28658
+ function* walkErrorGraph(error) {
28659
+ const queue = [error];
28660
+ const seen = new Set;
28661
+ for (let steps = 0;queue.length > 0 && steps < 32; steps++) {
28662
+ const current = queue.shift();
28663
+ if (current === null || typeof current !== "object")
28664
+ continue;
28665
+ if (seen.has(current))
28666
+ continue;
28667
+ seen.add(current);
28668
+ const cur = current;
28669
+ yield cur;
28612
28670
  if (cur.cause !== undefined)
28613
28671
  queue.push(cur.cause);
28614
28672
  if (Array.isArray(cur.errors))
@@ -28669,6 +28727,12 @@ function classifyError(status, error) {
28669
28727
  if (status !== undefined && status >= 500 && status < 600) {
28670
28728
  return { errorCode: "server_error", retry: "RetryLater" };
28671
28729
  }
28730
+ if (status === undefined && describePermissionError(error)) {
28731
+ return {
28732
+ errorCode: "local_permission_denied",
28733
+ retry: "RetryWillNotFix"
28734
+ };
28735
+ }
28672
28736
  const connectivity = describeConnectivityError(error);
28673
28737
  if (connectivity) {
28674
28738
  return {
@@ -28771,6 +28835,16 @@ async function extractErrorDetails(error, options) {
28771
28835
  message = `${message}: ${connectivity.message}`;
28772
28836
  }
28773
28837
  }
28838
+ const permission = status === undefined ? describePermissionError(error) : undefined;
28839
+ if (permission) {
28840
+ if (permission.message !== message && !message.includes(permission.message)) {
28841
+ message = `${message}: ${permission.message}`;
28842
+ }
28843
+ if (!message.includes(permission.instructions)) {
28844
+ const punctuated = message.endsWith(".") ? message : `${message}.`;
28845
+ message = `${punctuated} ${permission.instructions}`;
28846
+ }
28847
+ }
28774
28848
  let details = rawMessage;
28775
28849
  if (rawBody) {
28776
28850
  if (parsedBody) {
@@ -28810,6 +28884,9 @@ async function extractErrorDetails(error, options) {
28810
28884
  if (parsedBody?.traceId && typeof parsedBody.traceId === "string") {
28811
28885
  context.traceId = parsedBody.traceId;
28812
28886
  }
28887
+ if (permission?.path !== undefined) {
28888
+ context.path = permission.path;
28889
+ }
28813
28890
  if (status === 429) {
28814
28891
  const resp = response;
28815
28892
  const headersObj = resp?.headers;
@@ -30043,6 +30120,7 @@ var CLI_ERROR_CODES = [
30043
30120
  "invalid_argument",
30044
30121
  "authentication_required",
30045
30122
  "permission_denied",
30123
+ "local_permission_denied",
30046
30124
  "not_found",
30047
30125
  "rate_limited",
30048
30126
  "network_error",
@@ -30083,19 +30161,32 @@ class Pagination {
30083
30161
  Offset;
30084
30162
  Total;
30085
30163
  HasMore;
30164
+ NextPage;
30086
30165
  constructor({
30087
30166
  returned,
30088
30167
  limit,
30089
30168
  offset,
30090
- total
30169
+ total,
30170
+ hasMore,
30171
+ nextPage
30091
30172
  }) {
30092
30173
  this.Returned = returned;
30093
30174
  this.Limit = limit;
30094
30175
  this.Offset = offset;
30095
30176
  this.Total = total;
30096
- this.HasMore = total === undefined ? returned === limit : offset + returned < total;
30177
+ this.HasMore = hasMore ?? derivePaginationHasMore(returned, limit, offset, total, nextPage);
30178
+ this.NextPage = nextPage;
30097
30179
  }
30098
30180
  }
30181
+ function derivePaginationHasMore(returned, limit, offset, total, nextPage) {
30182
+ if (nextPage) {
30183
+ return true;
30184
+ }
30185
+ if (total === undefined) {
30186
+ return returned >= limit;
30187
+ }
30188
+ return (offset ?? 0) + returned < total;
30189
+ }
30099
30190
 
30100
30191
  class SuccessOutput {
30101
30192
  Result = RESULTS.Success;
@@ -30499,12 +30590,16 @@ function defaultErrorCodeForHttpStatus(status) {
30499
30590
  return "server_error";
30500
30591
  return;
30501
30592
  }
30593
+ var LOCAL_PERMISSION_TEXT_PATTERN = /(?:\b|\()(?:EACCES|EPERM|EROFS)(?::\s|\))/;
30502
30594
  function defaultErrorCodeForFailure(data) {
30503
30595
  if (data.Result === RESULTS.Failure) {
30504
30596
  const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
30505
30597
  const errorCode2 = defaultErrorCodeForHttpStatus(status);
30506
30598
  if (errorCode2)
30507
30599
  return errorCode2;
30600
+ if (status === undefined && (LOCAL_PERMISSION_TEXT_PATTERN.test(data.Message) || LOCAL_PERMISSION_TEXT_PATTERN.test(data.Instructions))) {
30601
+ return "local_permission_denied";
30602
+ }
30508
30603
  }
30509
30604
  return defaultErrorCodeForResult(data.Result);
30510
30605
  }
@@ -31065,11 +31160,10 @@ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
31065
31160
  function installSdkUserAgentHeader(BaseApiClass, userAgent) {
31066
31161
  installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
31067
31162
  }
31068
- // ../common/src/tool-provider.ts
31069
- var factorySlot = singleton("PackagerFactoryProvider");
31070
- var moduleSlot = singleton("ToolModuleProvider");
31071
31163
  // ../common/src/telemetry/ship-succeeded.ts
31072
31164
  var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
31165
+ // ../common/src/tool-provider.ts
31166
+ var factorySlot = singleton("PackagerFactoryProvider");
31073
31167
  // src/utils/epoch.ts
31074
31168
  var toMs = (n) => {
31075
31169
  if (typeof n !== "number" || !Number.isFinite(n) || n <= 0)
@@ -31458,7 +31552,7 @@ async function resolveLoginAndTenants() {
31458
31552
  processContext.exit(1);
31459
31553
  return null;
31460
31554
  }
31461
- const [tenantsErr, tenantsResp] = await catchError2(fetchTenantsAndOrganizations(status.baseUrl, status.accessToken, accountId));
31555
+ const [tenantsErr, tenantsResp] = await catchError2(fetchTenantsAndOrganizations(status.baseUrl, status.accessToken, status.organizationName || accountId));
31462
31556
  if (tenantsErr || !tenantsResp) {
31463
31557
  OutputFormatter.error({
31464
31558
  Result: RESULTS.Failure,
@@ -34030,4 +34124,4 @@ var registerCommands = async (program2) => {
34030
34124
 
34031
34125
  export { Command, metadata, registerCommands };
34032
34126
 
34033
- //# debugId=BCE47D95AD84036A64756E2164756E21
34127
+ //# debugId=20F0514E0E33F24164756E2164756E21
package/dist/tool.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  metadata,
3
3
  registerCommands
4
- } from "./tool-vzbz8v00.js";
4
+ } from "./tool-j5abzeps.js";
5
5
  import"./tool-9qecd4wb.js";
6
6
  import"./tool-nnna1hq7.js";
7
7
  import"./tool-5arsyj36.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/platform-tool",
3
3
  "license": "MIT",
4
- "version": "1.201.0-preview.115",
4
+ "version": "1.201.0-preview.121",
5
5
  "description": "Manage UiPath platform-level resources such as tenant licensing.",
6
6
  "type": "module",
7
7
  "main": "./dist/tool.js",
@@ -20,5 +20,5 @@
20
20
  "publishConfig": {
21
21
  "registry": "https://registry.npmjs.org/"
22
22
  },
23
- "gitHead": "f1086b73654d7728cb71f280588b3e0c77d535fc"
23
+ "gitHead": "c70ccfc0b12e637441d67df1d212b71d7784b5f8"
24
24
  }