@uipath/oms-commands 1.204.0-preview.255 → 1.205.0-preview.256

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 (3) hide show
  1. package/README.md +11 -11
  2. package/dist/index.js +142 -30
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -14,25 +14,25 @@ uip admin
14
14
  │ ├── regions
15
15
  │ │ └── list
16
16
  │ ├── operation
17
- │ │ └── get <operationId>
17
+ │ │ └── get <operation-id>
18
18
  │ └── services # org-level services are auto-provisioned with the org
19
19
  │ ├── list [--service <type>] [--status <status>] [--region <region>]
20
20
  │ └── list-available
21
21
  └── tenants
22
22
  ├── list [--filter <fragment>] [--service <type>] [--status <status>] [--environment <env>] [--include-services]
23
- ├── get <tenantId>
23
+ ├── get [tenant-id]
24
24
  ├── create [--file <path> | --name --region --environment]
25
- ├── update <tenantId> [--file <path> | --name | --region | --environment]
26
- ├── delete <tenantId> # soft-delete only
27
- ├── enable <tenantId>
28
- ├── disable <tenantId> [--reason <text>]
25
+ ├── update [tenant-id] [--file <path> | --name | --region | --environment]
26
+ ├── delete [tenant-id] # soft-delete only
27
+ ├── enable [tenant-id]
28
+ ├── disable [tenant-id] [--reason <text>]
29
29
  └── services
30
- ├── list <tenantId> [--service <type>] [--region <region>]
30
+ ├── list [--tenant-id <guid>] [--service <type>] [--region <region>]
31
31
  ├── list-available --region <Region>
32
- ├── add <tenantId> [--file <path> | --service <type>]
33
- ├── remove <tenantId> [--file <path> | --service <type>] # soft-remove only
34
- ├── enable <tenantId> --service <type>
35
- └── disable <tenantId> --service <type>
32
+ ├── add [--tenant-id <guid>] [--file <path> | --service <type>]
33
+ ├── remove [--tenant-id <guid>] [--file <path> | --service <type>] # soft-remove only
34
+ ├── enable [--tenant-id <guid>] --service <type>
35
+ └── disable [--tenant-id <guid>] --service <type>
36
36
  ```
37
37
 
38
38
  ## Subjects
package/dist/index.js CHANGED
@@ -2278,6 +2278,16 @@ class NodeFileSystem {
2278
2278
  async rename(oldPath, newPath) {
2279
2279
  await fs.rename(oldPath, newPath);
2280
2280
  }
2281
+ async isSymbolicLink(filePath) {
2282
+ try {
2283
+ return (await fs.lstat(filePath)).isSymbolicLink();
2284
+ } catch (error) {
2285
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
2286
+ return false;
2287
+ }
2288
+ throw error;
2289
+ }
2290
+ }
2281
2291
  async realpath(filePath) {
2282
2292
  try {
2283
2293
  return await fs.realpath(filePath);
@@ -3313,7 +3323,7 @@ function setGlobalLogFilePath(path2) {
3313
3323
  function getGlobalLogFilePath() {
3314
3324
  return logFilePathSlot.get("");
3315
3325
  }
3316
- var DEFAULT_LOG_LEVEL = 3 /* ERROR */;
3326
+ var DEFAULT_LOG_LEVEL = 2 /* WARN */;
3317
3327
 
3318
3328
  class SimpleLogger {
3319
3329
  __brand = "SimpleLogger";
@@ -3580,7 +3590,9 @@ var ErrorDimensions = {
3580
3590
  Result: "Result",
3581
3591
  ErrorCode: "ErrorCode",
3582
3592
  Retry: "Retry",
3583
- ErrorMessage: "ErrorMessage"
3593
+ ErrorMessage: "ErrorMessage",
3594
+ HttpStatus: "HttpStatus",
3595
+ UpstreamErrorCode: "UpstreamErrorCode"
3584
3596
  };
3585
3597
  var AuthDimensions = {
3586
3598
  AuthenticationMethod: "AuthenticationMethod",
@@ -4568,7 +4580,9 @@ var CLI_ERROR_CODES = [
4568
4580
  "timeout",
4569
4581
  "server_error",
4570
4582
  "method_not_allowed",
4583
+ "not_supported",
4571
4584
  "configuration_error",
4585
+ "execution_failed",
4572
4586
  "unknown_error"
4573
4587
  ];
4574
4588
  var RETRY_HINTS = [
@@ -5525,7 +5539,9 @@ var OutputFormatter;
5525
5539
  [ErrorDimensions.Result]: data.Result,
5526
5540
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
5527
5541
  [ErrorDimensions.Retry]: data.Retry,
5528
- [ErrorDimensions.ErrorMessage]: data.Message
5542
+ [ErrorDimensions.ErrorMessage]: data.Message,
5543
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
5544
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
5529
5545
  });
5530
5546
  }
5531
5547
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -7257,7 +7273,7 @@ var package_default = {
7257
7273
  name: "@uipath/oms-sdk",
7258
7274
  author: "UiPath",
7259
7275
  license: "SEE LICENSE IN LICENSE.txt",
7260
- version: "1.204.0",
7276
+ version: "1.205.0",
7261
7277
  description: "SDK for the UiPath Organization Management Service API.",
7262
7278
  repository: {
7263
7279
  type: "git",
@@ -11791,22 +11807,12 @@ var resolveConfigAsync = async ({
11791
11807
  baseUrl = DEFAULT_BASE_URL;
11792
11808
  }
11793
11809
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
11794
- let clientId = customClientId;
11795
- if (!clientId && fileAuth.clientId) {
11796
- clientId = fileAuth.clientId;
11797
- }
11798
- if (!clientId) {
11799
- clientId = DEFAULT_CLIENT_ID;
11800
- }
11801
- let clientSecret = customClientSecret;
11802
- if (!clientSecret && fileAuth.clientSecret) {
11803
- clientSecret = fileAuth.clientSecret;
11804
- }
11805
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
11810
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
11811
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
11806
11812
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
11807
11813
  return {
11808
11814
  clientId,
11809
- clientSecret,
11815
+ clientSecret: customClientSecret,
11810
11816
  scopes,
11811
11817
  baseUrl,
11812
11818
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -11980,6 +11986,16 @@ var resolveIdentityType = (claims, authFlow, email) => {
11980
11986
  }
11981
11987
  return;
11982
11988
  };
11989
+ var resolveApplicationSubtype = (claims, authFlow) => {
11990
+ switch (asString(claims?.sub_type)) {
11991
+ case "service.external":
11992
+ return "External";
11993
+ case "service.internal":
11994
+ return "Internal";
11995
+ default:
11996
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
11997
+ }
11998
+ };
11983
11999
  var looksLikeEmail = (value) => value?.includes("@") ?? false;
11984
12000
  var pickEmail = (claims) => {
11985
12001
  for (const candidate of [claims?.email, claims?.preferred_username]) {
@@ -12021,6 +12037,12 @@ var resolveSessionIdentity = (accessToken, authFlow) => {
12021
12037
  const clientId = asString(claims?.client_id);
12022
12038
  if (clientId)
12023
12039
  identity.clientId = clientId;
12040
+ const subType = asString(claims?.sub_type);
12041
+ if (subType)
12042
+ identity.subType = subType;
12043
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
12044
+ if (applicationSubtype)
12045
+ identity.applicationSubtype = applicationSubtype;
12024
12046
  return identity;
12025
12047
  };
12026
12048
  var readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
@@ -12313,6 +12335,40 @@ var tryRobotClientFallback = async (options = {}) => {
12313
12335
  }
12314
12336
  };
12315
12337
 
12338
+ // ../../auth/src/tenantSelection.ts
12339
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
12340
+ var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
12341
+ var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
12342
+ var describeNonJsonResponse = (organizationId, response, parseError) => {
12343
+ if (response.redirected) {
12344
+ 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}`;
12345
+ }
12346
+ const contentType = response.headers.get("content-type") ?? "unknown";
12347
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
12348
+ };
12349
+ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
12350
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
12351
+ const response = await fetch(url, {
12352
+ headers: {
12353
+ Authorization: `Bearer ${accessToken}`
12354
+ },
12355
+ ...signal ? { signal } : {}
12356
+ });
12357
+ if (!response.ok) {
12358
+ if (response.status === 401) {
12359
+ 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);
12360
+ }
12361
+ const errorText = await response.text();
12362
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
12363
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
12364
+ }
12365
+ const [parseError, data] = await catchError2(response.json());
12366
+ if (parseError) {
12367
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
12368
+ }
12369
+ return data;
12370
+ };
12371
+
12316
12372
  // ../../auth/src/tokenRefresh.ts
12317
12373
  var TOKEN_REFRESH_REAUTHENTICATE_MESSAGE = "Token refresh failed. Run 'uip login' to re-authenticate.";
12318
12374
 
@@ -12525,6 +12581,8 @@ var saveEnvFileAsync = async ({
12525
12581
  };
12526
12582
 
12527
12583
  // ../../auth/src/loginStatus.ts
12584
+ var defaultRobotTenantIdCache = new Map;
12585
+ var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
12528
12586
  var getLoginStatusAsync = async (options = {}) => {
12529
12587
  return getLoginStatusWithDeps(options);
12530
12588
  };
@@ -12537,12 +12595,20 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
12537
12595
  refreshToken: refreshTokenFn = refreshAccessToken,
12538
12596
  resolveConfig = resolveConfigAsync,
12539
12597
  robotFallback = tryRobotClientFallback,
12598
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
12599
+ robotTenantIdCache = defaultRobotTenantIdCache,
12600
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
12540
12601
  loadBreaker = loadRefreshBreaker,
12541
12602
  saveBreaker = saveRefreshBreaker,
12542
12603
  clearBreaker = clearRefreshBreaker
12543
12604
  } = deps;
12605
+ const robotDeps = {
12606
+ fetchTenantsAndOrgs,
12607
+ cache: robotTenantIdCache,
12608
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
12609
+ };
12544
12610
  if (isRobotAuthEnforced()) {
12545
- return resolveRobotEnforcedStatus(robotFallback);
12611
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
12546
12612
  }
12547
12613
  if (isEnvAuthEnabled()) {
12548
12614
  return readAuthFromEnv();
@@ -12560,7 +12626,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
12560
12626
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
12561
12627
  };
12562
12628
  }
12563
- return resolveBorrowedRobotStatus(robotFallback);
12629
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
12564
12630
  }
12565
12631
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
12566
12632
  if ("status" in loaded) {
@@ -12602,7 +12668,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
12602
12668
  }
12603
12669
  return buildFileStatus(tokens, credentials, globalHint);
12604
12670
  };
12605
- async function resolveRobotEnforcedStatus(robotFallback) {
12671
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
12606
12672
  if (isEnvAuthEnabled()) {
12607
12673
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
12608
12674
  }
@@ -12613,11 +12679,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
12613
12679
  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.`
12614
12680
  };
12615
12681
  }
12616
- return buildRobotStatus(robotCreds);
12682
+ return buildRobotStatus(robotCreds, deps);
12617
12683
  }
12618
- async function resolveBorrowedRobotStatus(robotFallback) {
12684
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
12619
12685
  const robotCreds = await robotFallback();
12620
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
12686
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
12621
12687
  }
12622
12688
  async function loadFileCredentials(loadEnvFile, absolutePath) {
12623
12689
  let credentials;
@@ -12752,9 +12818,10 @@ function identityFields(accessToken, credentials) {
12752
12818
  ...scopes ? { scopes } : {}
12753
12819
  };
12754
12820
  }
12755
- function buildRobotStatus(robotCreds) {
12821
+ async function buildRobotStatus(robotCreds, deps) {
12756
12822
  const identity = resolveSessionIdentity(robotCreds.accessToken);
12757
12823
  const scopes = readTokenScopes(robotCreds.accessToken);
12824
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
12758
12825
  return {
12759
12826
  loginStatus: "Logged in",
12760
12827
  accessToken: robotCreds.accessToken,
@@ -12762,14 +12829,62 @@ function buildRobotStatus(robotCreds) {
12762
12829
  organizationName: robotCreds.organizationName,
12763
12830
  organizationId: robotCreds.organizationId,
12764
12831
  tenantName: robotCreds.tenantName,
12765
- tenantId: robotCreds.tenantId,
12832
+ tenantId: tenant.tenantId,
12766
12833
  issuer: robotCreds.issuer,
12767
12834
  expiration: getTokenExpiration(robotCreds.accessToken),
12768
12835
  source: "robot" /* Robot */,
12836
+ ...tenant.hint ? { hint: tenant.hint } : {},
12769
12837
  ...identity ? { identity } : {},
12770
12838
  ...scopes ? { scopes } : {}
12771
12839
  };
12772
12840
  }
12841
+ async function resolveRobotTenantId(robotCreds, deps) {
12842
+ const { baseUrl, accessToken, tenantName } = robotCreds;
12843
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
12844
+ if (!tenantName || !organization) {
12845
+ return {};
12846
+ }
12847
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
12848
+ let pending = deps.cache.get(key);
12849
+ if (!pending) {
12850
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
12851
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
12852
+ if (!settled.tenantId) {
12853
+ deps.cache.delete(key);
12854
+ }
12855
+ return settled;
12856
+ });
12857
+ deps.cache.set(key, pending);
12858
+ }
12859
+ return pending;
12860
+ }
12861
+ async function lookupRobotTenantId(target, deps) {
12862
+ const { baseUrl, accessToken, organization, tenantName } = target;
12863
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
12864
+ if (error) {
12865
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
12866
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
12867
+ }
12868
+ const rows = data?.tenants;
12869
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
12870
+ const wantedName = decodePathSegment(tenantName);
12871
+ const wanted = wantedName.toLowerCase();
12872
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
12873
+ if (!match) {
12874
+ const names = tenants.map((tenant) => tenant.name).join(", ");
12875
+ return {
12876
+ hint: `The Robot session targets tenant '${tenantName}', but ` + `organization '${organization}' lists no tenant of that name` + `${names ? ` (available: ${names})` : ""}. Commands that need ` + `the tenant id will fail until it can be resolved.`
12877
+ };
12878
+ }
12879
+ return { tenantId: match.id };
12880
+ }
12881
+ function tenantLookupFailureHint(tenantName, reason) {
12882
+ return `Could not resolve the id of tenant '${tenantName}' from the ` + `Robot session: ${reason} Commands that need the tenant id will ` + `fail until it can be resolved.`;
12883
+ }
12884
+ function decodePathSegment(segment) {
12885
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
12886
+ return error ? segment : decoded;
12887
+ }
12773
12888
  var isFileNotFoundError = (error) => {
12774
12889
  if (!(error instanceof Object))
12775
12890
  return false;
@@ -13005,9 +13120,6 @@ function normalizeTokenRefreshUnavailableFailure() {
13005
13120
  function errorMessage(error) {
13006
13121
  return error instanceof Error ? error.message : String(error);
13007
13122
  }
13008
- // ../../auth/src/tenantSelection.ts
13009
- var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
13010
-
13011
13123
  // ../../auth/src/selectTenant.ts
13012
13124
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
13013
13125
  var INVALID_TENANT_CODE = "INVALID_TENANT";
@@ -13334,7 +13446,7 @@ var registerRegionsCommands = (organizations) => {
13334
13446
  };
13335
13447
  var registerOperationCommands = (organizations) => {
13336
13448
  const operation = organizations.command("operation").description("Inspect async operations on the caller's organization.");
13337
- withLoginValidity(operation.command("get").description("Return the status of an async OMS operation by id (e.g. service provisioning).").argument("<operationId>", "Operation UUID returned from a previous async call.").examples(OPERATION_EXAMPLES)).trackedAction(processContext, async (operationId, options) => {
13449
+ withLoginValidity(operation.command("get").description("Return the status of an async OMS operation by id (e.g. service provisioning).").argument("<operation-id>", "Operation UUID returned from a previous async call.").examples(OPERATION_EXAMPLES)).trackedAction(processContext, async (operationId, options) => {
13338
13450
  const client = await getOrgApi(options);
13339
13451
  if (!client)
13340
13452
  return;
@@ -14255,4 +14367,4 @@ export {
14255
14367
  registerCommands
14256
14368
  };
14257
14369
 
14258
- //# debugId=524DFDD8274B077164756E2164756E21
14370
+ //# debugId=602CD6C1C34E187D64756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/oms-commands",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.204.0-preview.255",
5
+ "version": "1.205.0-preview.256",
6
6
  "description": "Admin CLI commands for the UiPath Organization Management Service. Library composed by admin-tool, not a standalone CLI tool.",
7
7
  "private": false,
8
8
  "repository": {
@@ -26,5 +26,5 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "gitHead": "699c58dabb59414557755a8933bcbe40aa420df3"
29
+ "gitHead": "63740c6cbb7ff282fa9118cc16a148eb030b245f"
30
30
  }