@uipath/maestro-sdk 1.204.0 → 1.205.0-preview.258

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.
@@ -876,6 +876,16 @@ class NodeFileSystem {
876
876
  async rename(oldPath, newPath) {
877
877
  await fs6.rename(oldPath, newPath);
878
878
  }
879
+ async isSymbolicLink(filePath) {
880
+ try {
881
+ return (await fs6.lstat(filePath)).isSymbolicLink();
882
+ } catch (error) {
883
+ if (this.isEnoent(error) || this.hasErrnoCode(error, "ENOTDIR")) {
884
+ return false;
885
+ }
886
+ throw error;
887
+ }
888
+ }
879
889
  async realpath(filePath) {
880
890
  try {
881
891
  return await fs6.realpath(filePath);
@@ -1935,7 +1945,7 @@ function getGlobalLogFilePath() {
1935
1945
  function getLogFilePath() {
1936
1946
  return logger.getLogFilePath();
1937
1947
  }
1938
- var logFilePathSlot, DEFAULT_LOG_LEVEL = 3 /* ERROR */, SimpleLogger, loggerSingleton, logger;
1948
+ var logFilePathSlot, DEFAULT_LOG_LEVEL = 2 /* WARN */, SimpleLogger, loggerSingleton, logger;
1939
1949
  var init_logger = __esm(() => {
1940
1950
  init_src();
1941
1951
  init_catch_error();
@@ -6823,7 +6833,9 @@ var init_telemetry_dimensions = __esm(() => {
6823
6833
  Result: "Result",
6824
6834
  ErrorCode: "ErrorCode",
6825
6835
  Retry: "Retry",
6826
- ErrorMessage: "ErrorMessage"
6836
+ ErrorMessage: "ErrorMessage",
6837
+ HttpStatus: "HttpStatus",
6838
+ UpstreamErrorCode: "UpstreamErrorCode"
6827
6839
  };
6828
6840
  AuthDimensions = {
6829
6841
  AuthenticationMethod: "AuthenticationMethod",
@@ -8788,7 +8800,9 @@ var init_formatter = __esm(() => {
8788
8800
  "timeout",
8789
8801
  "server_error",
8790
8802
  "method_not_allowed",
8803
+ "not_supported",
8791
8804
  "configuration_error",
8805
+ "execution_failed",
8792
8806
  "unknown_error"
8793
8807
  ];
8794
8808
  RETRY_HINTS = [
@@ -8902,7 +8916,9 @@ var init_formatter = __esm(() => {
8902
8916
  [ErrorDimensions.Result]: data.Result,
8903
8917
  [ErrorDimensions.ErrorCode]: data.ErrorCode,
8904
8918
  [ErrorDimensions.Retry]: data.Retry,
8905
- [ErrorDimensions.ErrorMessage]: data.Message
8919
+ [ErrorDimensions.ErrorMessage]: data.Message,
8920
+ [ErrorDimensions.HttpStatus]: data.Context?.httpStatus?.toString(),
8921
+ [ErrorDimensions.UpstreamErrorCode]: data.Context?.errorCode
8906
8922
  });
8907
8923
  }
8908
8924
  logOutput(normalizeOutputKeys(envelope), getOutputFormat());
@@ -11635,6 +11651,9 @@ async function hashContent(content) {
11635
11651
  throw new Error("Unable to compute SHA-256 hash in this environment.");
11636
11652
  }
11637
11653
 
11654
+ // ../common/src/entity-field-rules.ts
11655
+ var init_entity_field_rules = () => {};
11656
+
11638
11657
  // ../common/src/entity-name-rules.ts
11639
11658
  var RESERVED_SQL_KEYWORDS_LOWER, RESERVED_FIELD_NAMES_LOWER, RESERVED_KEYWORDS_LOWER;
11640
11659
  var init_entity_name_rules = __esm(() => {
@@ -11869,6 +11888,17 @@ var init_host_global_options = __esm(() => {
11869
11888
  BOOLEAN_FLAGS = new Set(HOST_GLOBAL_FLAGS);
11870
11889
  });
11871
11890
 
11891
+ // ../common/src/http-status.ts
11892
+ function httpStatusOf(error) {
11893
+ if (!error || typeof error !== "object") {
11894
+ return;
11895
+ }
11896
+ if ("response" in error && error.response && typeof error.response === "object" && "status" in error.response && typeof error.response.status === "number") {
11897
+ return error.response.status;
11898
+ }
11899
+ return "status" in error && typeof error.status === "number" ? error.status : undefined;
11900
+ }
11901
+
11872
11902
  // ../common/src/interactivity-context.ts
11873
11903
  var modeSlot, interactiveFlagSlot;
11874
11904
  var init_interactivity_context = __esm(() => {
@@ -11878,6 +11908,11 @@ var init_interactivity_context = __esm(() => {
11878
11908
  interactiveFlagSlot = singleton("InteractiveFlag");
11879
11909
  });
11880
11910
 
11911
+ // ../common/src/json-option.ts
11912
+ var init_json_option = __esm(() => {
11913
+ init_src();
11914
+ });
11915
+
11881
11916
  // ../common/src/mime-types.ts
11882
11917
  var MIME_TYPES_BY_EXTENSION;
11883
11918
  var init_mime_types = __esm(() => {
@@ -11919,9 +11954,15 @@ var init_mime_types = __esm(() => {
11919
11954
  // ../common/src/option-aliases.ts
11920
11955
  var init_option_aliases = __esm(() => {
11921
11956
  init_esm();
11957
+ init_formatter();
11922
11958
  init_output_context();
11923
11959
  });
11924
11960
 
11961
+ // ../common/src/option-groups.ts
11962
+ var init_option_groups = __esm(() => {
11963
+ init_formatter();
11964
+ });
11965
+
11925
11966
  // ../common/src/option-validators.ts
11926
11967
  function parseLimit(raw, _previous) {
11927
11968
  return parseBoundedInt(raw, "--limit", { min: 1, max: 1e4 });
@@ -12111,6 +12152,11 @@ var init_sdk_user_agent = __esm(() => {
12111
12152
  AGENT_PROPERTY = BaseDimensions.Agent;
12112
12153
  sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
12113
12154
  });
12155
+
12156
+ // ../common/src/shell-quote.ts
12157
+ function quoteForShell(value) {
12158
+ return `'${value.replace(/'/g, "'\\''")}'`;
12159
+ }
12114
12160
  // ../common/src/stdin.ts
12115
12161
  async function readStdin() {
12116
12162
  if (process.stdin.isTTY) {
@@ -12167,6 +12213,7 @@ var init_src2 = __esm(() => {
12167
12213
  init_completer();
12168
12214
  init_confirmation();
12169
12215
  init_constants();
12216
+ init_entity_field_rules();
12170
12217
  init_entity_name_rules();
12171
12218
  init_error_handler();
12172
12219
  init_error_instructions();
@@ -12174,9 +12221,11 @@ var init_src2 = __esm(() => {
12174
12221
  init_guid();
12175
12222
  init_host_global_options();
12176
12223
  init_interactivity_context();
12224
+ init_json_option();
12177
12225
  init_logger();
12178
12226
  init_mime_types();
12179
12227
  init_option_aliases();
12228
+ init_option_groups();
12180
12229
  init_option_validators();
12181
12230
  init_output_codecs();
12182
12231
  init_output_context();
@@ -12283,22 +12332,12 @@ var DEFAULT_CLIENT_ID = "36dea5b8-e8bb-423d-8e7b-c808df8f1c00", AUTH_FILE_CONFIG
12283
12332
  baseUrl = DEFAULT_BASE_URL;
12284
12333
  }
12285
12334
  baseUrl = normalizeAndValidateBaseUrl(baseUrl);
12286
- let clientId = customClientId;
12287
- if (!clientId && fileAuth.clientId) {
12288
- clientId = fileAuth.clientId;
12289
- }
12290
- if (!clientId) {
12291
- clientId = DEFAULT_CLIENT_ID;
12292
- }
12293
- let clientSecret = customClientSecret;
12294
- if (!clientSecret && fileAuth.clientSecret) {
12295
- clientSecret = fileAuth.clientSecret;
12296
- }
12297
- const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(clientSecret) || Boolean(customClientAssertion));
12335
+ const clientId = customClientId || DEFAULT_CLIENT_ID;
12336
+ const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
12298
12337
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
12299
12338
  return {
12300
12339
  clientId,
12301
- clientSecret,
12340
+ clientSecret: customClientSecret,
12302
12341
  scopes,
12303
12342
  baseUrl,
12304
12343
  authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
@@ -12495,6 +12534,15 @@ var parseAuthFlow = (value) => value === "authorization_code" || value === "clie
12495
12534
  return "Application";
12496
12535
  }
12497
12536
  return;
12537
+ }, resolveApplicationSubtype = (claims, authFlow) => {
12538
+ switch (asString(claims?.sub_type)) {
12539
+ case "service.external":
12540
+ return "External";
12541
+ case "service.internal":
12542
+ return "Internal";
12543
+ default:
12544
+ return authFlow === "client_credentials" || authFlow === "federated_credentials" ? "External" : undefined;
12545
+ }
12498
12546
  }, looksLikeEmail = (value) => value?.includes("@") ?? false, pickEmail = (claims) => {
12499
12547
  for (const candidate of [claims?.email, claims?.preferred_username]) {
12500
12548
  const value = asString(candidate);
@@ -12532,6 +12580,12 @@ var parseAuthFlow = (value) => value === "authorization_code" || value === "clie
12532
12580
  const clientId = asString(claims?.client_id);
12533
12581
  if (clientId)
12534
12582
  identity.clientId = clientId;
12583
+ const subType = asString(claims?.sub_type);
12584
+ if (subType)
12585
+ identity.subType = subType;
12586
+ const applicationSubtype = resolveApplicationSubtype(claims, authFlow);
12587
+ if (applicationSubtype)
12588
+ identity.applicationSubtype = applicationSubtype;
12535
12589
  return identity;
12536
12590
  }, readTokenScopes = (accessToken) => accessToken ? pickScopes(decodeClaims(accessToken)) : undefined;
12537
12591
  var init_sessionIdentity = __esm(() => {
@@ -12820,6 +12874,39 @@ var init_robotClientFallback = __esm(() => {
12820
12874
  ROBOT_CLIENT_LOADER_KEY = Symbol.for("@uipath/auth/RobotClientLoader");
12821
12875
  });
12822
12876
 
12877
+ // ../auth/src/tenantSelection.ts
12878
+ var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.", organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`, IDENTIFIER_STATUSES, describeNonJsonResponse = (organizationId, response, parseError) => {
12879
+ if (response.redirected) {
12880
+ 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}`;
12881
+ }
12882
+ const contentType = response.headers.get("content-type") ?? "unknown";
12883
+ return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
12884
+ }, fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId, signal) => {
12885
+ const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
12886
+ const response = await fetch(url, {
12887
+ headers: {
12888
+ Authorization: `Bearer ${accessToken}`
12889
+ },
12890
+ ...signal ? { signal } : {}
12891
+ });
12892
+ if (!response.ok) {
12893
+ if (response.status === 401) {
12894
+ 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);
12895
+ }
12896
+ const errorText = await response.text();
12897
+ const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
12898
+ throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
12899
+ }
12900
+ const [parseError, data] = await catchError2(response.json());
12901
+ if (parseError) {
12902
+ throw new Error(describeNonJsonResponse(organizationId, response, parseError));
12903
+ }
12904
+ return data;
12905
+ };
12906
+ var init_tenantSelection = __esm(() => {
12907
+ IDENTIFIER_STATUSES = new Set([400, 403, 404]);
12908
+ });
12909
+
12823
12910
  // ../auth/src/tokenRefresh.ts
12824
12911
  function isTokenRefreshOAuthFailure(error) {
12825
12912
  return error instanceof TokenRefreshOAuthError;
@@ -13031,7 +13118,7 @@ var init_envFile = __esm(() => {
13031
13118
  });
13032
13119
 
13033
13120
  // ../auth/src/loginStatus.ts
13034
- async function resolveRobotEnforcedStatus(robotFallback) {
13121
+ async function resolveRobotEnforcedStatus(robotFallback, deps) {
13035
13122
  if (isEnvAuthEnabled()) {
13036
13123
  throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
13037
13124
  }
@@ -13042,11 +13129,11 @@ async function resolveRobotEnforcedStatus(robotFallback) {
13042
13129
  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.`
13043
13130
  };
13044
13131
  }
13045
- return buildRobotStatus(robotCreds);
13132
+ return buildRobotStatus(robotCreds, deps);
13046
13133
  }
13047
- async function resolveBorrowedRobotStatus(robotFallback) {
13134
+ async function resolveBorrowedRobotStatus(robotFallback, deps) {
13048
13135
  const robotCreds = await robotFallback();
13049
- return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
13136
+ return robotCreds ? buildRobotStatus(robotCreds, deps) : { loginStatus: "Not logged in" };
13050
13137
  }
13051
13138
  async function loadFileCredentials(loadEnvFile, absolutePath) {
13052
13139
  let credentials;
@@ -13181,9 +13268,10 @@ function identityFields(accessToken, credentials) {
13181
13268
  ...scopes ? { scopes } : {}
13182
13269
  };
13183
13270
  }
13184
- function buildRobotStatus(robotCreds) {
13271
+ async function buildRobotStatus(robotCreds, deps) {
13185
13272
  const identity = resolveSessionIdentity(robotCreds.accessToken);
13186
13273
  const scopes = readTokenScopes(robotCreds.accessToken);
13274
+ const tenant = robotCreds.tenantId ? { tenantId: robotCreds.tenantId } : await resolveRobotTenantId(robotCreds, deps);
13187
13275
  return {
13188
13276
  loginStatus: "Logged in",
13189
13277
  accessToken: robotCreds.accessToken,
@@ -13191,14 +13279,62 @@ function buildRobotStatus(robotCreds) {
13191
13279
  organizationName: robotCreds.organizationName,
13192
13280
  organizationId: robotCreds.organizationId,
13193
13281
  tenantName: robotCreds.tenantName,
13194
- tenantId: robotCreds.tenantId,
13282
+ tenantId: tenant.tenantId,
13195
13283
  issuer: robotCreds.issuer,
13196
13284
  expiration: getTokenExpiration(robotCreds.accessToken),
13197
13285
  source: "robot" /* Robot */,
13286
+ ...tenant.hint ? { hint: tenant.hint } : {},
13198
13287
  ...identity ? { identity } : {},
13199
13288
  ...scopes ? { scopes } : {}
13200
13289
  };
13201
13290
  }
13291
+ async function resolveRobotTenantId(robotCreds, deps) {
13292
+ const { baseUrl, accessToken, tenantName } = robotCreds;
13293
+ const organization = robotCreds.organizationName ?? robotCreds.organizationId;
13294
+ if (!tenantName || !organization) {
13295
+ return {};
13296
+ }
13297
+ const key = `${baseUrl}|${organization}|${tenantName}|${accessToken}`;
13298
+ let pending = deps.cache.get(key);
13299
+ if (!pending) {
13300
+ pending = catchError2(lookupRobotTenantId({ baseUrl, accessToken, organization, tenantName }, deps)).then(([error, resolution]) => {
13301
+ const settled = error ? { hint: tenantLookupFailureHint(tenantName, error.message) } : resolution;
13302
+ if (!settled.tenantId) {
13303
+ deps.cache.delete(key);
13304
+ }
13305
+ return settled;
13306
+ });
13307
+ deps.cache.set(key, pending);
13308
+ }
13309
+ return pending;
13310
+ }
13311
+ async function lookupRobotTenantId(target, deps) {
13312
+ const { baseUrl, accessToken, organization, tenantName } = target;
13313
+ const [error, data] = await catchError2(deps.fetchTenantsAndOrgs(baseUrl, accessToken, organization, AbortSignal.timeout(deps.lookupTimeoutMs)));
13314
+ if (error) {
13315
+ const reason = error.name === "TimeoutError" ? `the tenant list did not answer within ${deps.lookupTimeoutMs} ms.` : error.message;
13316
+ return { hint: tenantLookupFailureHint(tenantName, reason) };
13317
+ }
13318
+ const rows = data?.tenants;
13319
+ const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
13320
+ const wantedName = decodePathSegment(tenantName);
13321
+ const wanted = wantedName.toLowerCase();
13322
+ const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
13323
+ if (!match) {
13324
+ const names = tenants.map((tenant) => tenant.name).join(", ");
13325
+ return {
13326
+ 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.`
13327
+ };
13328
+ }
13329
+ return { tenantId: match.id };
13330
+ }
13331
+ function tenantLookupFailureHint(tenantName, reason) {
13332
+ 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.`;
13333
+ }
13334
+ function decodePathSegment(segment) {
13335
+ const [error, decoded] = catchError2(() => decodeURIComponent(segment));
13336
+ return error ? segment : decoded;
13337
+ }
13202
13338
  async function circuitBreakerShortCircuit(ctx) {
13203
13339
  const {
13204
13340
  absolutePath,
@@ -13429,7 +13565,7 @@ function normalizeTokenRefreshUnavailableFailure() {
13429
13565
  function errorMessage(error) {
13430
13566
  return error instanceof Error ? error.message : String(error);
13431
13567
  }
13432
- var getLoginStatusAsync = async (options = {}) => {
13568
+ var defaultRobotTenantIdCache, ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000, getLoginStatusAsync = async (options = {}) => {
13433
13569
  return getLoginStatusWithDeps(options);
13434
13570
  }, getLoginStatusWithDeps = async (options = {}, deps = {}) => {
13435
13571
  const {
@@ -13440,12 +13576,20 @@ var getLoginStatusAsync = async (options = {}) => {
13440
13576
  refreshToken: refreshTokenFn = refreshAccessToken,
13441
13577
  resolveConfig = resolveConfigAsync,
13442
13578
  robotFallback = tryRobotClientFallback,
13579
+ fetchTenantsAndOrgs = fetchTenantsAndOrganizations,
13580
+ robotTenantIdCache = defaultRobotTenantIdCache,
13581
+ robotTenantLookupTimeoutMs = ROBOT_TENANT_LOOKUP_TIMEOUT_MS,
13443
13582
  loadBreaker = loadRefreshBreaker,
13444
13583
  saveBreaker = saveRefreshBreaker,
13445
13584
  clearBreaker = clearRefreshBreaker
13446
13585
  } = deps;
13586
+ const robotDeps = {
13587
+ fetchTenantsAndOrgs,
13588
+ cache: robotTenantIdCache,
13589
+ lookupTimeoutMs: robotTenantLookupTimeoutMs
13590
+ };
13447
13591
  if (isRobotAuthEnforced()) {
13448
- return resolveRobotEnforcedStatus(robotFallback);
13592
+ return resolveRobotEnforcedStatus(robotFallback, robotDeps);
13449
13593
  }
13450
13594
  if (isEnvAuthEnabled()) {
13451
13595
  return readAuthFromEnv();
@@ -13463,7 +13607,7 @@ var getLoginStatusAsync = async (options = {}) => {
13463
13607
  hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
13464
13608
  };
13465
13609
  }
13466
- return resolveBorrowedRobotStatus(robotFallback);
13610
+ return resolveBorrowedRobotStatus(robotFallback, robotDeps);
13467
13611
  }
13468
13612
  const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
13469
13613
  if ("status" in loaded) {
@@ -13517,9 +13661,11 @@ var init_loginStatus = __esm(() => {
13517
13661
  init_refreshCircuitBreaker();
13518
13662
  init_robotClientFallback();
13519
13663
  init_sessionIdentity();
13664
+ init_tenantSelection();
13520
13665
  init_tokenRefresh();
13521
13666
  init_envFile();
13522
13667
  init_jwt();
13668
+ defaultRobotTenantIdCache = new Map;
13523
13669
  });
13524
13670
 
13525
13671
  // ../auth/src/authContext.ts
@@ -13581,12 +13727,6 @@ var init_federatedCredentials = __esm(() => {
13581
13727
  init_tokenGrant();
13582
13728
  });
13583
13729
 
13584
- // ../auth/src/tenantSelection.ts
13585
- var IDENTIFIER_STATUSES;
13586
- var init_tenantSelection = __esm(() => {
13587
- IDENTIFIER_STATUSES = new Set([400, 403, 404]);
13588
- });
13589
-
13590
13730
  // ../auth/src/selectTenant.ts
13591
13731
  var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED", INVALID_TENANT_CODE = "INVALID_TENANT", TENANT_SELECTION_CODES;
13592
13732
  var init_selectTenant = __esm(() => {
@@ -13957,4 +14097,4 @@ export {
13957
14097
  withPimsCall
13958
14098
  };
13959
14099
 
13960
- //# debugId=8057F8DA1DFCADF664756E2164756E21
14100
+ //# debugId=1566DC037AAA984664756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/maestro-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.204.0",
5
+ "version": "1.205.0-preview.258",
6
6
  "description": "SDK for the UiPath Maestro (PIMS) API — process instance management.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -103,5 +103,5 @@
103
103
  "files": [
104
104
  "dist"
105
105
  ],
106
- "gitHead": "699c58dabb59414557755a8933bcbe40aa420df3"
106
+ "gitHead": "8f629ee9fa89abf94f197436a60cb3b9620f8b27"
107
107
  }