@uipath/apms-tool 1.196.0 → 1.197.0-preview.60

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/dist/index.js +701 -1736
  2. package/dist/tool.js +702 -1736
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -21247,7 +21247,7 @@ var {
21247
21247
  var package_default = {
21248
21248
  name: "@uipath/apms-tool",
21249
21249
  license: "MIT",
21250
- version: "1.196.0",
21250
+ version: "1.197.0-preview.60",
21251
21251
  description: "CLI plugin for the UiPath Access Policy Management Service.",
21252
21252
  private: false,
21253
21253
  repository: {
@@ -21273,7 +21273,7 @@ var package_default = {
21273
21273
  "dist"
21274
21274
  ],
21275
21275
  scripts: {
21276
- build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander && bun build ./src/index.ts --outdir dist --format esm --target node",
21276
+ build: "bun build ./src/tool.ts --outdir dist --format esm --target node --external commander --sourcemap=linked && bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked",
21277
21277
  package: "bun run build && bun pm pack",
21278
21278
  lint: "biome check .",
21279
21279
  "lint:fix": "biome check --write .",
@@ -21321,6 +21321,12 @@ function singleton(ctorOrName) {
21321
21321
  };
21322
21322
  }
21323
21323
 
21324
+ // ../../common/src/telemetry/global-telemetry-properties.ts
21325
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
21326
+ function getGlobalTelemetryProperties() {
21327
+ return telemetryPropsSlot.get();
21328
+ }
21329
+
21324
21330
  // ../../common/src/sdk-user-agent.ts
21325
21331
  var USER_AGENT_HEADER = "User-Agent";
21326
21332
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
@@ -21344,8 +21350,8 @@ function appendUserAgentToken(value, userAgent) {
21344
21350
  function getEffectiveUserAgent(userAgent) {
21345
21351
  return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
21346
21352
  }
21347
- function isHeadersLike(headers) {
21348
- return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
21353
+ function getHeaderName(headers, headerName) {
21354
+ return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
21349
21355
  }
21350
21356
  function getSdkUserAgentToken(pkg) {
21351
21357
  const packageName = pkg.name.replace(/^@uipath\//, "");
@@ -21353,59 +21359,31 @@ function getSdkUserAgentToken(pkg) {
21353
21359
  }
21354
21360
  function addSdkUserAgentHeader(headers, userAgent) {
21355
21361
  const result = { ...headers ?? {} };
21356
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
21357
- const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
21358
- if (headerName) {
21359
- result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
21360
- } else {
21361
- result[USER_AGENT_HEADER] = effectiveUserAgent;
21362
- }
21362
+ const headerName = getHeaderName(result, USER_AGENT_HEADER);
21363
+ result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
21363
21364
  return result;
21364
21365
  }
21365
- function withSdkUserAgentHeader(headers, userAgent) {
21366
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
21367
- if (isHeadersLike(headers)) {
21368
- headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
21369
- return headers;
21370
- }
21371
- if (Array.isArray(headers)) {
21372
- const result = headers.map((entry) => {
21373
- const [key, value] = entry;
21374
- return [key, value];
21375
- });
21376
- const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
21377
- if (headerIndex >= 0) {
21378
- const [key, value] = result[headerIndex];
21379
- result[headerIndex] = [
21380
- key,
21381
- appendUserAgentToken(value, effectiveUserAgent)
21382
- ];
21383
- } else {
21384
- result.push([USER_AGENT_HEADER, effectiveUserAgent]);
21385
- }
21386
- return result;
21387
- }
21388
- return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
21366
+ function asHeaderRecord(headers) {
21367
+ return typeof headers === "object" && headers !== null ? { ...headers } : {};
21389
21368
  }
21390
- function withUserAgentInitOverride(initOverrides, userAgent) {
21369
+ function withForwardedHeadersInitOverride(initOverrides, forward) {
21391
21370
  return async (requestContext) => {
21392
- const initWithUserAgent = {
21371
+ const initWithHeaders = {
21393
21372
  ...requestContext.init,
21394
- headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
21373
+ headers: forward(asHeaderRecord(requestContext.init.headers))
21395
21374
  };
21396
21375
  const override = typeof initOverrides === "function" ? await initOverrides({
21397
21376
  ...requestContext,
21398
- init: initWithUserAgent
21377
+ init: initWithHeaders
21399
21378
  }) : initOverrides;
21400
21379
  return {
21401
21380
  ...override ?? {},
21402
- headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
21381
+ headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
21403
21382
  };
21404
21383
  };
21405
21384
  }
21406
- function installSdkUserAgentHeader(BaseApiClass, userAgent) {
21385
+ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
21407
21386
  const prototype = BaseApiClass.prototype;
21408
- const patchKey = userAgentPatchKey(userAgent);
21409
21387
  if (prototype[patchKey]) {
21410
21388
  return;
21411
21389
  }
@@ -21413,13 +21391,16 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
21413
21391
  throw new Error("Generated BaseAPI request function not found.");
21414
21392
  }
21415
21393
  const originalRequest = prototype.request;
21416
- prototype.request = function requestWithUserAgent(context, initOverrides) {
21417
- return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
21394
+ prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
21395
+ return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
21418
21396
  };
21419
21397
  Object.defineProperty(prototype, patchKey, {
21420
21398
  value: true
21421
21399
  });
21422
21400
  }
21401
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
21402
+ installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
21403
+ }
21423
21404
 
21424
21405
  // ../apms-sdk/generated/src/runtime.ts
21425
21406
  var BASE_PATH = "http://localhost:35599".replace(/\/+$/, "");
@@ -21674,7 +21655,7 @@ class VoidApiResponse {
21674
21655
  var package_default2 = {
21675
21656
  name: "@uipath/apms-sdk",
21676
21657
  license: "MIT",
21677
- version: "1.196.0",
21658
+ version: "1.197.0",
21678
21659
  description: "SDK for the UiPath Access Policy Management Service API.",
21679
21660
  repository: {
21680
21661
  type: "git",
@@ -21704,7 +21685,7 @@ var package_default2 = {
21704
21685
  ],
21705
21686
  private: true,
21706
21687
  scripts: {
21707
- build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
21688
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
21708
21689
  generate: "bun run src/scripts/generate-sdk.ts",
21709
21690
  lint: "biome check ."
21710
21691
  },
@@ -22745,6 +22726,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
22745
22726
  }
22746
22727
  return url.pathname.length > 1 ? url.origin : baseUrl;
22747
22728
  };
22729
+ var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
22730
+ const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
22731
+ if (isExternalAppAuth)
22732
+ return requestedScopes;
22733
+ return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
22734
+ };
22748
22735
  var resolveConfigAsync = async ({
22749
22736
  customAuthority,
22750
22737
  customClientId,
@@ -22775,7 +22762,7 @@ var resolveConfigAsync = async ({
22775
22762
  clientSecret = fileAuth.clientSecret;
22776
22763
  }
22777
22764
  const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
22778
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
22765
+ const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
22779
22766
  return {
22780
22767
  clientId,
22781
22768
  clientSecret,
@@ -22790,6 +22777,76 @@ var resolveConfigAsync = async ({
22790
22777
  init_constants();
22791
22778
  // ../../auth/src/loginStatus.ts
22792
22779
  init_src();
22780
+
22781
+ // ../../auth/src/authProfile.ts
22782
+ init_src();
22783
+ init_constants();
22784
+ var DEFAULT_AUTH_PROFILE = "default";
22785
+ var PROFILE_DIR = "profiles";
22786
+ var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
22787
+ var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
22788
+ var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
22789
+ var globalSlot2 = globalThis;
22790
+ function isAuthProfileStorage(value) {
22791
+ return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
22792
+ }
22793
+ function createProfileStorage() {
22794
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
22795
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
22796
+ return {
22797
+ getStore: () => {
22798
+ return;
22799
+ },
22800
+ run: (_store, fn) => fn()
22801
+ };
22802
+ }
22803
+ return new mod.AsyncLocalStorage;
22804
+ }
22805
+ function getProfileStorage() {
22806
+ const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
22807
+ if (isAuthProfileStorage(existing)) {
22808
+ return existing;
22809
+ }
22810
+ const storage = createProfileStorage();
22811
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
22812
+ return storage;
22813
+ }
22814
+ var profileStorage = getProfileStorage();
22815
+
22816
+ class AuthProfileValidationError extends Error {
22817
+ constructor(message) {
22818
+ super(message);
22819
+ this.name = "AuthProfileValidationError";
22820
+ }
22821
+ }
22822
+ function normalizeAuthProfileName(profile) {
22823
+ if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
22824
+ return;
22825
+ }
22826
+ if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
22827
+ throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
22828
+ }
22829
+ return profile;
22830
+ }
22831
+ function getActiveAuthProfile() {
22832
+ const scopedState = profileStorage.getStore();
22833
+ if (scopedState !== undefined) {
22834
+ return scopedState.profile;
22835
+ }
22836
+ return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
22837
+ }
22838
+ function resolveAuthProfileFilePath(profile) {
22839
+ const normalized = normalizeAuthProfileName(profile);
22840
+ if (normalized === undefined) {
22841
+ throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
22842
+ }
22843
+ const fs7 = getFileSystem();
22844
+ return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
22845
+ }
22846
+ function getActiveAuthProfileFilePath() {
22847
+ const profile = getActiveAuthProfile();
22848
+ return profile ? resolveAuthProfileFilePath(profile) : undefined;
22849
+ }
22793
22850
  // ../../auth/src/utils/jwt.ts
22794
22851
  class InvalidIssuerError extends Error {
22795
22852
  expected;
@@ -22918,23 +22975,74 @@ var readAuthFromEnv = () => {
22918
22975
  organizationId,
22919
22976
  tenantName,
22920
22977
  tenantId,
22921
- expiration
22978
+ expiration,
22979
+ source: "env" /* Env */
22922
22980
  };
22923
22981
  };
22924
22982
 
22983
+ // ../../auth/src/refreshCircuitBreaker.ts
22984
+ init_src();
22985
+ var BREAKER_SUFFIX = ".refresh-state";
22986
+ var BACKOFF_BASE_MS = 60000;
22987
+ var BACKOFF_CAP_MS = 60 * 60 * 1000;
22988
+ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
22989
+ async function refreshTokenFingerprint(refreshToken) {
22990
+ const bytes = new TextEncoder().encode(refreshToken);
22991
+ if (globalThis.crypto?.subtle) {
22992
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
22993
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
22994
+ }
22995
+ const { createHash } = await import("node:crypto");
22996
+ return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
22997
+ }
22998
+ function breakerPathFor(authPath) {
22999
+ return `${authPath}${BREAKER_SUFFIX}`;
23000
+ }
23001
+ async function loadRefreshBreaker(authPath) {
23002
+ const fs7 = getFileSystem();
23003
+ try {
23004
+ const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
23005
+ if (!content)
23006
+ return {};
23007
+ const parsed = JSON.parse(content);
23008
+ return parsed && typeof parsed === "object" ? parsed : {};
23009
+ } catch {
23010
+ return {};
23011
+ }
23012
+ }
23013
+ async function saveRefreshBreaker(authPath, state) {
23014
+ try {
23015
+ const fs7 = getFileSystem();
23016
+ const path3 = breakerPathFor(authPath);
23017
+ await fs7.mkdir(fs7.path.dirname(path3));
23018
+ const tempPath = `${path3}.tmp`;
23019
+ await fs7.writeFile(tempPath, JSON.stringify(state));
23020
+ await fs7.rename(tempPath, path3);
23021
+ } catch {}
23022
+ }
23023
+ async function clearRefreshBreaker(authPath) {
23024
+ const fs7 = getFileSystem();
23025
+ const path3 = breakerPathFor(authPath);
23026
+ try {
23027
+ if (await fs7.exists(path3)) {
23028
+ await fs7.rm(path3);
23029
+ }
23030
+ } catch {}
23031
+ }
23032
+ function nextBackoffMs(attempts) {
23033
+ const shift = Math.max(0, attempts - 1);
23034
+ return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
23035
+ }
23036
+ function shouldSurface(state, nowMs) {
23037
+ if (state.lastSurfacedAtMs === undefined)
23038
+ return true;
23039
+ return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
23040
+ }
23041
+
22925
23042
  // ../../auth/src/robotClientFallback.ts
22926
23043
  init_src();
22927
23044
  var DEFAULT_TIMEOUT_MS = 1000;
22928
23045
  var CLOSE_TIMEOUT_MS = 500;
22929
- var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
22930
- var printNoticeOnce = () => {
22931
- const slot = globalThis;
22932
- if (slot[NOTICE_SENTINEL])
22933
- return;
22934
- slot[NOTICE_SENTINEL] = true;
22935
- catchError(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
22936
- `));
22937
- };
22938
23046
  var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
22939
23047
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
22940
23048
  var PIPE_NAME_MAX_LENGTH = 103;
@@ -23050,7 +23158,6 @@ var tryRobotClientFallback = async (options = {}) => {
23050
23158
  issuerFromToken = issClaim;
23051
23159
  }
23052
23160
  }
23053
- printNoticeOnce();
23054
23161
  return {
23055
23162
  accessToken,
23056
23163
  baseUrl: parsedUrl.baseUrl,
@@ -23275,18 +23382,327 @@ var saveEnvFileAsync = async ({
23275
23382
  };
23276
23383
 
23277
23384
  // ../../auth/src/loginStatus.ts
23278
- function normalizeTokenRefreshFailure() {
23279
- return "stored refresh token is invalid or expired";
23385
+ var getLoginStatusAsync = async (options = {}) => {
23386
+ return getLoginStatusWithDeps(options);
23387
+ };
23388
+ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
23389
+ const {
23390
+ resolveEnvFilePath = resolveEnvFilePathAsync,
23391
+ loadEnvFile = loadEnvFileAsync,
23392
+ saveEnvFile = saveEnvFileAsync,
23393
+ getFs = getFileSystem,
23394
+ refreshToken: refreshTokenFn = refreshAccessToken,
23395
+ resolveConfig = resolveConfigAsync,
23396
+ robotFallback = tryRobotClientFallback,
23397
+ loadBreaker = loadRefreshBreaker,
23398
+ saveBreaker = saveRefreshBreaker,
23399
+ clearBreaker = clearRefreshBreaker
23400
+ } = deps;
23401
+ if (isRobotAuthEnforced()) {
23402
+ return resolveRobotEnforcedStatus(robotFallback);
23403
+ }
23404
+ if (isEnvAuthEnabled()) {
23405
+ return readAuthFromEnv();
23406
+ }
23407
+ const activeProfile = getActiveAuthProfile();
23408
+ const activeProfileFilePath = getActiveAuthProfileFilePath();
23409
+ const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
23410
+ const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
23411
+ const { ensureTokenValidityMinutes } = options;
23412
+ const { absolutePath } = await resolveEnvFilePath(envFilePath);
23413
+ if (absolutePath === undefined) {
23414
+ if (usingActiveProfile) {
23415
+ return {
23416
+ loginStatus: "Not logged in",
23417
+ hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
23418
+ };
23419
+ }
23420
+ return resolveBorrowedRobotStatus(robotFallback);
23421
+ }
23422
+ const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
23423
+ if ("status" in loaded) {
23424
+ return loaded.status;
23425
+ }
23426
+ const { credentials } = loaded;
23427
+ const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
23428
+ const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
23429
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
23430
+ let tokens = {
23431
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
23432
+ refreshToken: credentials.UIPATH_REFRESH_TOKEN,
23433
+ expiration,
23434
+ lockReleaseFailed: false
23435
+ };
23436
+ const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
23437
+ if (expiration && expiration <= outerThreshold && refreshToken) {
23438
+ const refreshed = await attemptRefresh({
23439
+ absolutePath,
23440
+ credentials,
23441
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
23442
+ refreshToken,
23443
+ expiration,
23444
+ ensureTokenValidityMinutes,
23445
+ getFs,
23446
+ loadEnvFile,
23447
+ saveEnvFile,
23448
+ refreshFn: refreshTokenFn,
23449
+ resolveConfig,
23450
+ loadBreaker,
23451
+ saveBreaker,
23452
+ clearBreaker,
23453
+ globalHint
23454
+ });
23455
+ if (refreshed.kind === "terminal") {
23456
+ return refreshed.status;
23457
+ }
23458
+ tokens = refreshed.tokens;
23459
+ }
23460
+ return buildFileStatus(tokens, credentials, globalHint);
23461
+ };
23462
+ async function resolveRobotEnforcedStatus(robotFallback) {
23463
+ if (isEnvAuthEnabled()) {
23464
+ throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
23465
+ }
23466
+ const robotCreds = await robotFallback({ force: true });
23467
+ if (!robotCreds) {
23468
+ return {
23469
+ loginStatus: "Not logged in",
23470
+ 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.`
23471
+ };
23472
+ }
23473
+ return buildRobotStatus(robotCreds);
23280
23474
  }
23281
- function normalizeTokenRefreshUnavailableFailure() {
23282
- return "token refresh failed before authentication completed";
23475
+ async function resolveBorrowedRobotStatus(robotFallback) {
23476
+ const robotCreds = await robotFallback();
23477
+ return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
23283
23478
  }
23284
- function errorMessage(error) {
23285
- return error instanceof Error ? error.message : String(error);
23479
+ async function loadFileCredentials(loadEnvFile, absolutePath) {
23480
+ let credentials;
23481
+ try {
23482
+ credentials = await loadEnvFile({ envPath: absolutePath });
23483
+ } catch (error) {
23484
+ if (isFileNotFoundError(error)) {
23485
+ return { status: { loginStatus: "Not logged in" } };
23486
+ }
23487
+ throw error;
23488
+ }
23489
+ if (!credentials.UIPATH_ACCESS_TOKEN) {
23490
+ return { status: { loginStatus: "Not logged in" } };
23491
+ }
23492
+ return { credentials };
23493
+ }
23494
+ async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
23495
+ const fs7 = getFs();
23496
+ const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
23497
+ if (absolutePath === globalPath)
23498
+ return;
23499
+ if (!await fs7.exists(globalPath))
23500
+ return;
23501
+ try {
23502
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
23503
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
23504
+ return;
23505
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
23506
+ if (globalExp && globalExp <= new Date)
23507
+ return;
23508
+ 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.`;
23509
+ } catch {
23510
+ return;
23511
+ }
23286
23512
  }
23287
23513
  function computeExpirationThreshold(ensureTokenValidityMinutes) {
23288
23514
  return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
23289
23515
  }
23516
+ async function attemptRefresh(ctx) {
23517
+ const shortCircuit = await circuitBreakerShortCircuit(ctx);
23518
+ if (shortCircuit) {
23519
+ return { kind: "terminal", status: shortCircuit };
23520
+ }
23521
+ let release;
23522
+ try {
23523
+ release = await ctx.getFs().acquireLock(ctx.absolutePath);
23524
+ } catch (error) {
23525
+ return {
23526
+ kind: "terminal",
23527
+ status: await lockAcquireFailureStatus(ctx, error)
23528
+ };
23529
+ }
23530
+ let lockedFailure;
23531
+ let lockReleaseFailed = false;
23532
+ let success;
23533
+ try {
23534
+ const outcome = await runRefreshLocked({
23535
+ absolutePath: ctx.absolutePath,
23536
+ refreshToken: ctx.refreshToken,
23537
+ customAuthority: ctx.credentials.UIPATH_URL,
23538
+ ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
23539
+ loadEnvFile: ctx.loadEnvFile,
23540
+ saveEnvFile: ctx.saveEnvFile,
23541
+ refreshFn: ctx.refreshFn,
23542
+ resolveConfig: ctx.resolveConfig,
23543
+ loadBreaker: ctx.loadBreaker,
23544
+ saveBreaker: ctx.saveBreaker,
23545
+ clearBreaker: ctx.clearBreaker
23546
+ });
23547
+ if (outcome.kind === "fail") {
23548
+ lockedFailure = outcome.status;
23549
+ } else {
23550
+ success = outcome;
23551
+ }
23552
+ } finally {
23553
+ try {
23554
+ await release();
23555
+ } catch {
23556
+ lockReleaseFailed = true;
23557
+ }
23558
+ }
23559
+ if (lockedFailure) {
23560
+ const globalHint = await ctx.globalHint();
23561
+ const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
23562
+ return {
23563
+ kind: "terminal",
23564
+ status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
23565
+ };
23566
+ }
23567
+ return {
23568
+ kind: "refreshed",
23569
+ tokens: {
23570
+ accessToken: success?.accessToken,
23571
+ refreshToken: success?.refreshToken,
23572
+ expiration: success?.expiration,
23573
+ tokenRefresh: success?.tokenRefresh,
23574
+ persistenceWarning: success?.persistenceWarning,
23575
+ lockReleaseFailed
23576
+ }
23577
+ };
23578
+ }
23579
+ async function buildFileStatus(tokens, credentials, globalHint) {
23580
+ const result = {
23581
+ loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
23582
+ accessToken: tokens.accessToken,
23583
+ refreshToken: tokens.refreshToken,
23584
+ baseUrl: credentials.UIPATH_URL,
23585
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
23586
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
23587
+ tenantName: credentials.UIPATH_TENANT_NAME,
23588
+ tenantId: credentials.UIPATH_TENANT_ID,
23589
+ expiration: tokens.expiration,
23590
+ source: "file" /* File */,
23591
+ ...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
23592
+ ...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
23593
+ ...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
23594
+ };
23595
+ if (result.loginStatus === "Expired") {
23596
+ const hint = await globalHint();
23597
+ if (hint) {
23598
+ result.hint = hint;
23599
+ }
23600
+ }
23601
+ return result;
23602
+ }
23603
+ function buildRobotStatus(robotCreds) {
23604
+ return {
23605
+ loginStatus: "Logged in",
23606
+ accessToken: robotCreds.accessToken,
23607
+ baseUrl: robotCreds.baseUrl,
23608
+ organizationName: robotCreds.organizationName,
23609
+ organizationId: robotCreds.organizationId,
23610
+ tenantName: robotCreds.tenantName,
23611
+ tenantId: robotCreds.tenantId,
23612
+ issuer: robotCreds.issuer,
23613
+ expiration: getTokenExpiration(robotCreds.accessToken),
23614
+ source: "robot" /* Robot */
23615
+ };
23616
+ }
23617
+ var isFileNotFoundError = (error) => {
23618
+ if (!(error instanceof Object))
23619
+ return false;
23620
+ return error.code === "ENOENT";
23621
+ };
23622
+ async function circuitBreakerShortCircuit(ctx) {
23623
+ const {
23624
+ absolutePath,
23625
+ refreshToken,
23626
+ accessToken,
23627
+ credentials,
23628
+ expiration,
23629
+ loadBreaker,
23630
+ saveBreaker,
23631
+ clearBreaker
23632
+ } = ctx;
23633
+ const fingerprint = await refreshTokenFingerprint(refreshToken);
23634
+ const breaker = await loadBreaker(absolutePath).catch(() => ({}));
23635
+ if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
23636
+ await clearBreaker(absolutePath);
23637
+ breaker.deadTokenFp = undefined;
23638
+ }
23639
+ const nowMs = Date.now();
23640
+ const tokenIsDead = breaker.deadTokenFp === fingerprint;
23641
+ const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
23642
+ if (!tokenIsDead && !inBackoff)
23643
+ return;
23644
+ const globalHint = await ctx.globalHint();
23645
+ const suppressed = !shouldSurface(breaker, nowMs);
23646
+ if (!suppressed) {
23647
+ await saveBreaker(absolutePath, {
23648
+ ...breaker,
23649
+ lastSurfacedAtMs: nowMs
23650
+ });
23651
+ }
23652
+ 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>.";
23653
+ const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
23654
+ return {
23655
+ loginStatus: globalHint ? "Expired" : "Refresh Failed",
23656
+ ...globalHint ? {
23657
+ accessToken,
23658
+ refreshToken,
23659
+ baseUrl: credentials.UIPATH_URL,
23660
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
23661
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
23662
+ tenantName: credentials.UIPATH_TENANT_NAME,
23663
+ tenantId: credentials.UIPATH_TENANT_ID,
23664
+ expiration,
23665
+ source: "file" /* File */
23666
+ } : {},
23667
+ hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
23668
+ refreshCircuitOpen: true,
23669
+ refreshTelemetrySuppressed: suppressed,
23670
+ tokenRefresh: { attempted: false, success: false }
23671
+ };
23672
+ }
23673
+ async function lockAcquireFailureStatus(ctx, error) {
23674
+ const msg = errorMessage(error);
23675
+ const globalHint = await ctx.globalHint();
23676
+ if (globalHint) {
23677
+ return {
23678
+ loginStatus: "Expired",
23679
+ accessToken: ctx.accessToken,
23680
+ refreshToken: ctx.refreshToken,
23681
+ baseUrl: ctx.credentials.UIPATH_URL,
23682
+ organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
23683
+ organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
23684
+ tenantName: ctx.credentials.UIPATH_TENANT_NAME,
23685
+ tenantId: ctx.credentials.UIPATH_TENANT_ID,
23686
+ expiration: ctx.expiration,
23687
+ source: "file" /* File */,
23688
+ hint: globalHint,
23689
+ tokenRefresh: {
23690
+ attempted: false,
23691
+ success: false,
23692
+ errorMessage: `lock acquisition failed: ${msg}`
23693
+ }
23694
+ };
23695
+ }
23696
+ return {
23697
+ loginStatus: "Refresh Failed",
23698
+ 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.",
23699
+ tokenRefresh: {
23700
+ attempted: false,
23701
+ success: false,
23702
+ errorMessage: `lock acquisition failed: ${msg}`
23703
+ }
23704
+ };
23705
+ }
23290
23706
  async function runRefreshLocked(inputs) {
23291
23707
  const {
23292
23708
  absolutePath,
@@ -23296,7 +23712,10 @@ async function runRefreshLocked(inputs) {
23296
23712
  loadEnvFile,
23297
23713
  saveEnvFile,
23298
23714
  refreshFn,
23299
- resolveConfig
23715
+ resolveConfig,
23716
+ loadBreaker,
23717
+ saveBreaker,
23718
+ clearBreaker
23300
23719
  } = inputs;
23301
23720
  const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
23302
23721
  let fresh;
@@ -23319,6 +23738,7 @@ async function runRefreshLocked(inputs) {
23319
23738
  const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
23320
23739
  const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
23321
23740
  if (freshAccess && freshExp && freshExp > expirationThreshold) {
23741
+ await clearBreaker(absolutePath);
23322
23742
  return {
23323
23743
  kind: "ok",
23324
23744
  accessToken: freshAccess,
@@ -23342,8 +23762,21 @@ async function runRefreshLocked(inputs) {
23342
23762
  refreshedRefresh = refreshed.refreshToken;
23343
23763
  } catch (error) {
23344
23764
  const isOAuthFailure = isTokenRefreshOAuthFailure(error);
23345
- 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.";
23765
+ 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.";
23346
23766
  const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
23767
+ const fp = await refreshTokenFingerprint(tokenForIdP);
23768
+ if (isOAuthFailure) {
23769
+ await saveBreaker(absolutePath, { deadTokenFp: fp });
23770
+ } else {
23771
+ const prior = await loadBreaker(absolutePath).catch(() => ({}));
23772
+ const attempts = (prior.attempts ?? 0) + 1;
23773
+ await saveBreaker(absolutePath, {
23774
+ ...prior,
23775
+ deadTokenFp: undefined,
23776
+ attempts,
23777
+ backoffUntilMs: Date.now() + nextBackoffMs(attempts)
23778
+ });
23779
+ }
23347
23780
  return {
23348
23781
  kind: "fail",
23349
23782
  status: {
@@ -23372,6 +23805,7 @@ async function runRefreshLocked(inputs) {
23372
23805
  }
23373
23806
  };
23374
23807
  }
23808
+ await clearBreaker(absolutePath);
23375
23809
  try {
23376
23810
  await saveEnvFile({
23377
23811
  envPath: absolutePath,
@@ -23404,231 +23838,42 @@ async function runRefreshLocked(inputs) {
23404
23838
  };
23405
23839
  }
23406
23840
  }
23407
- var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
23408
- const {
23409
- resolveEnvFilePath = resolveEnvFilePathAsync,
23410
- loadEnvFile = loadEnvFileAsync,
23411
- saveEnvFile = saveEnvFileAsync,
23412
- getFs = getFileSystem,
23413
- refreshToken: refreshTokenFn = refreshAccessToken,
23414
- resolveConfig = resolveConfigAsync,
23415
- robotFallback = tryRobotClientFallback
23416
- } = deps;
23417
- if (isRobotAuthEnforced()) {
23418
- if (isEnvAuthEnabled()) {
23419
- throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
23420
- }
23421
- const robotCreds = await robotFallback({ force: true });
23422
- if (!robotCreds) {
23423
- return {
23424
- loginStatus: "Not logged in",
23425
- 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.`
23426
- };
23427
- }
23428
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
23429
- return {
23430
- loginStatus: "Logged in",
23431
- accessToken: robotCreds.accessToken,
23432
- baseUrl: robotCreds.baseUrl,
23433
- organizationName: robotCreds.organizationName,
23434
- organizationId: robotCreds.organizationId,
23435
- tenantName: robotCreds.tenantName,
23436
- tenantId: robotCreds.tenantId,
23437
- issuer: robotCreds.issuer,
23438
- expiration: expiration2,
23439
- source: "robot" /* Robot */
23440
- };
23441
- }
23442
- if (isEnvAuthEnabled()) {
23443
- return readAuthFromEnv();
23444
- }
23445
- const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
23446
- const { absolutePath } = await resolveEnvFilePath(envFilePath);
23447
- if (absolutePath === undefined) {
23448
- const robotCreds = await robotFallback();
23449
- if (robotCreds) {
23450
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
23451
- const status = {
23452
- loginStatus: "Logged in",
23453
- accessToken: robotCreds.accessToken,
23454
- baseUrl: robotCreds.baseUrl,
23455
- organizationName: robotCreds.organizationName,
23456
- organizationId: robotCreds.organizationId,
23457
- tenantName: robotCreds.tenantName,
23458
- tenantId: robotCreds.tenantId,
23459
- issuer: robotCreds.issuer,
23460
- expiration: expiration2,
23461
- source: "robot" /* Robot */
23462
- };
23463
- return status;
23464
- }
23465
- return { loginStatus: "Not logged in" };
23466
- }
23467
- let credentials;
23468
- try {
23469
- credentials = await loadEnvFile({ envPath: absolutePath });
23470
- } catch (error) {
23471
- if (isFileNotFoundError(error)) {
23472
- return { loginStatus: "Not logged in" };
23473
- }
23474
- throw error;
23475
- }
23476
- if (!credentials.UIPATH_ACCESS_TOKEN) {
23477
- return { loginStatus: "Not logged in" };
23478
- }
23479
- let accessToken = credentials.UIPATH_ACCESS_TOKEN;
23480
- let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
23481
- let expiration = getTokenExpiration(accessToken);
23482
- let persistenceWarning;
23483
- let lockReleaseFailed = false;
23484
- let tokenRefresh;
23485
- const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
23486
- const tryGlobalCredsHint = async () => {
23487
- const fs7 = getFs();
23488
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
23489
- if (absolutePath === globalPath)
23490
- return;
23491
- if (!await fs7.exists(globalPath))
23492
- return;
23493
- try {
23494
- const globalCreds = await loadEnvFile({ envPath: globalPath });
23495
- if (!globalCreds.UIPATH_ACCESS_TOKEN)
23496
- return;
23497
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
23498
- if (globalExp && globalExp <= new Date)
23499
- return;
23500
- 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.`;
23501
- } catch {
23502
- return;
23503
- }
23504
- };
23505
- if (expiration && expiration <= outerThreshold && refreshToken) {
23506
- let release;
23507
- try {
23508
- release = await getFs().acquireLock(absolutePath);
23509
- } catch (error) {
23510
- const msg = errorMessage(error);
23511
- const globalHint = await tryGlobalCredsHint();
23512
- if (globalHint) {
23513
- return {
23514
- loginStatus: "Expired",
23515
- accessToken,
23516
- refreshToken,
23517
- baseUrl: credentials.UIPATH_URL,
23518
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
23519
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
23520
- tenantName: credentials.UIPATH_TENANT_NAME,
23521
- tenantId: credentials.UIPATH_TENANT_ID,
23522
- expiration,
23523
- source: "file" /* File */,
23524
- hint: globalHint,
23525
- tokenRefresh: {
23526
- attempted: false,
23527
- success: false,
23528
- errorMessage: `lock acquisition failed: ${msg}`
23529
- }
23530
- };
23531
- }
23532
- return {
23533
- loginStatus: "Refresh Failed",
23534
- 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.",
23535
- tokenRefresh: {
23536
- attempted: false,
23537
- success: false,
23538
- errorMessage: `lock acquisition failed: ${msg}`
23539
- }
23540
- };
23541
- }
23542
- let lockedFailure;
23543
- try {
23544
- const outcome = await runRefreshLocked({
23545
- absolutePath,
23546
- refreshToken,
23547
- customAuthority: credentials.UIPATH_URL,
23548
- ensureTokenValidityMinutes,
23549
- loadEnvFile,
23550
- saveEnvFile,
23551
- refreshFn: refreshTokenFn,
23552
- resolveConfig
23553
- });
23554
- if (outcome.kind === "fail") {
23555
- lockedFailure = outcome.status;
23556
- } else {
23557
- accessToken = outcome.accessToken;
23558
- refreshToken = outcome.refreshToken;
23559
- expiration = outcome.expiration;
23560
- tokenRefresh = outcome.tokenRefresh;
23561
- if (outcome.persistenceWarning) {
23562
- persistenceWarning = outcome.persistenceWarning;
23563
- }
23564
- }
23565
- } finally {
23566
- try {
23567
- await release();
23568
- } catch {
23569
- lockReleaseFailed = true;
23570
- }
23571
- }
23572
- if (lockedFailure) {
23573
- const globalHint = await tryGlobalCredsHint();
23574
- const base = globalHint ? {
23575
- ...lockedFailure,
23576
- loginStatus: "Expired",
23577
- hint: globalHint
23578
- } : lockedFailure;
23579
- return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
23580
- }
23581
- }
23582
- const result = {
23583
- loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
23584
- accessToken,
23585
- refreshToken,
23586
- baseUrl: credentials.UIPATH_URL,
23587
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
23588
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
23589
- tenantName: credentials.UIPATH_TENANT_NAME,
23590
- tenantId: credentials.UIPATH_TENANT_ID,
23591
- expiration,
23592
- source: "file" /* File */,
23593
- ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
23594
- ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
23595
- ...tokenRefresh ? { tokenRefresh } : {}
23596
- };
23597
- if (result.loginStatus === "Expired") {
23598
- const globalHint = await tryGlobalCredsHint();
23599
- if (globalHint) {
23600
- result.hint = globalHint;
23601
- }
23602
- }
23603
- return result;
23604
- };
23605
- var isFileNotFoundError = (error) => {
23606
- if (!(error instanceof Object))
23607
- return false;
23608
- return error.code === "ENOENT";
23609
- };
23610
- var getLoginStatusAsync = async (options = {}) => {
23611
- return getLoginStatusWithDeps(options);
23612
- };
23613
- // ../../auth/src/interactive.ts
23614
- init_src();
23615
- // ../../auth/src/logout.ts
23616
- init_src();
23617
-
23618
- // ../../auth/src/index.ts
23619
- init_server();
23620
-
23621
- // ../apms-sdk/src/client-factory.ts
23622
- var STRIP_PREFIX_RE = /\/accesspolicy_\/api\/(?:accessPolicy\/)?organization\/[^/]+/;
23623
- function rewriteApmsUrl(url) {
23624
- return url.replace(STRIP_PREFIX_RE, "/accesspolicy_");
23625
- }
23626
- async function resolveConfig(options) {
23627
- const status = await getLoginStatusAsync({
23628
- ensureTokenValidityMinutes: options?.loginValidity
23629
- });
23630
- if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
23631
- throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
23841
+ function normalizeTokenRefreshFailure() {
23842
+ return "stored refresh token is invalid or expired";
23843
+ }
23844
+ function normalizeTokenRefreshUnavailableFailure() {
23845
+ return "token refresh failed before authentication completed";
23846
+ }
23847
+ function errorMessage(error) {
23848
+ return error instanceof Error ? error.message : String(error);
23849
+ }
23850
+ // ../../auth/src/interactive.ts
23851
+ init_src();
23852
+
23853
+ // ../../auth/src/selectTenant.ts
23854
+ var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
23855
+ var INVALID_TENANT_CODE = "INVALID_TENANT";
23856
+ var TENANT_SELECTION_CODES = new Set([
23857
+ TENANT_SELECTION_REQUIRED_CODE,
23858
+ INVALID_TENANT_CODE
23859
+ ]);
23860
+ // ../../auth/src/logout.ts
23861
+ init_src();
23862
+
23863
+ // ../../auth/src/index.ts
23864
+ init_server();
23865
+
23866
+ // ../apms-sdk/src/client-factory.ts
23867
+ var STRIP_PREFIX_RE = /\/accesspolicy_\/api\/(?:accessPolicy\/)?organization\/[^/]+/;
23868
+ function rewriteApmsUrl(url) {
23869
+ return url.replace(STRIP_PREFIX_RE, "/accesspolicy_");
23870
+ }
23871
+ async function resolveConfig(options) {
23872
+ const status = await getLoginStatusAsync({
23873
+ ensureTokenValidityMinutes: options?.loginValidity
23874
+ });
23875
+ if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
23876
+ throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
23632
23877
  }
23633
23878
  if (!status.organizationId) {
23634
23879
  throw new Error("Organization ID not available. Ensure you are logged in with an organization context.");
@@ -23708,27 +23953,54 @@ var NETWORK_ERROR_CODES = new Set([
23708
23953
  "ENETUNREACH",
23709
23954
  "EAI_FAIL"
23710
23955
  ]);
23711
- function isHtmlDocument(body) {
23712
- return /^\s*(<!doctype html|<html\b)/i.test(body);
23713
- }
23714
- function extractNetworkErrorCode(error) {
23715
- if (error === null || typeof error !== "object") {
23716
- return;
23717
- }
23718
- const err = error;
23719
- const code = typeof err.code === "string" ? err.code : undefined;
23720
- if (code && NETWORK_ERROR_CODES.has(code)) {
23721
- return code;
23722
- }
23723
- const cause = err.cause;
23724
- if (cause !== null && typeof cause === "object") {
23725
- const causeCode = cause.code;
23726
- if (typeof causeCode === "string" && NETWORK_ERROR_CODES.has(causeCode)) {
23727
- return causeCode;
23956
+ var TLS_ERROR_CODES = new Set([
23957
+ "SELF_SIGNED_CERT_IN_CHAIN",
23958
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
23959
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
23960
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
23961
+ "UNABLE_TO_GET_ISSUER_CERT",
23962
+ "CERT_HAS_EXPIRED",
23963
+ "CERT_UNTRUSTED",
23964
+ "ERR_TLS_CERT_ALTNAME_INVALID"
23965
+ ]);
23966
+ 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.";
23967
+ 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.";
23968
+ function describeConnectivityError(error) {
23969
+ let current = error;
23970
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
23971
+ const cur = current;
23972
+ const code = typeof cur.code === "string" ? cur.code : undefined;
23973
+ const message = typeof cur.message === "string" ? cur.message : undefined;
23974
+ if (code && TLS_ERROR_CODES.has(code)) {
23975
+ return {
23976
+ code,
23977
+ kind: "tls",
23978
+ message: message ?? code,
23979
+ instructions: TLS_INSTRUCTIONS
23980
+ };
23981
+ }
23982
+ if (code && NETWORK_ERROR_CODES.has(code)) {
23983
+ return {
23984
+ code,
23985
+ kind: "network",
23986
+ message: message ?? code,
23987
+ instructions: NETWORK_INSTRUCTIONS
23988
+ };
23728
23989
  }
23990
+ current = cur.cause;
23729
23991
  }
23730
23992
  return;
23731
23993
  }
23994
+ function parseHttpStatusFromMessage(message) {
23995
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
23996
+ if (!match)
23997
+ return;
23998
+ const status = Number(match[1]);
23999
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
24000
+ }
24001
+ function isHtmlDocument(body) {
24002
+ return /^\s*(<!doctype html|<html\b)/i.test(body);
24003
+ }
23732
24004
  function retryHintForRetryAfter(seconds) {
23733
24005
  if (seconds <= 1) {
23734
24006
  return "RetryAfter1Second";
@@ -23769,15 +24041,28 @@ function classifyError(status, error) {
23769
24041
  if (status !== undefined && status >= 500 && status < 600) {
23770
24042
  return { errorCode: "server_error", retry: "RetryLater" };
23771
24043
  }
23772
- if (extractNetworkErrorCode(error)) {
23773
- return { errorCode: "network_error", retry: "RetryLater" };
24044
+ const connectivity = describeConnectivityError(error);
24045
+ if (connectivity) {
24046
+ return {
24047
+ errorCode: "network_error",
24048
+ retry: connectivity.kind === "tls" ? "RetryWillNotFix" : "RetryLater"
24049
+ };
23774
24050
  }
23775
24051
  return { errorCode: "unknown_error", retry: "RetryWillNotFix" };
23776
24052
  }
24053
+ function formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus) {
24054
+ if (extractedMessage) {
24055
+ return `HTTP ${status}: ${extractedMessage}`;
24056
+ }
24057
+ return inferredStatus !== undefined ? rawMessage : `HTTP ${status}: ${rawMessage}`;
24058
+ }
23777
24059
  async function extractErrorDetails(error, options) {
23778
24060
  const err = error !== null && error !== undefined && typeof error === "object" ? error : {};
23779
24061
  const response = err.response;
23780
- const status = err.status ?? response?.status;
24062
+ const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
24063
+ const explicitStatus = err.status ?? response?.status;
24064
+ const inferredStatus = explicitStatus === undefined ? parseHttpStatusFromMessage(rawMessage) : undefined;
24065
+ const status = explicitStatus ?? inferredStatus;
23781
24066
  const isSuccessfulResponse = status !== undefined && status >= 200 && status < 300;
23782
24067
  let rawBody;
23783
24068
  let extractedMessage;
@@ -23812,7 +24097,6 @@ async function extractErrorDetails(error, options) {
23812
24097
  }
23813
24098
  }
23814
24099
  }
23815
- const rawMessage = typeof err.message === "string" ? err.message : "Unknown error";
23816
24100
  let message;
23817
24101
  let result = "Failure";
23818
24102
  const classification = classifyError(status, error);
@@ -23826,10 +24110,10 @@ async function extractErrorDetails(error, options) {
23826
24110
  } else if (status === 405) {
23827
24111
  message = DEFAULT_405;
23828
24112
  } else if (status === 400 || status === 422) {
23829
- message = extractedMessage ? `HTTP ${status}: ${extractedMessage}` : `HTTP ${status}: ${rawMessage}`;
24113
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
23830
24114
  result = "ValidationError";
23831
24115
  } else if (status === 429) {
23832
- message = extractedMessage ? `HTTP ${status}: ${extractedMessage}` : `HTTP ${status}: ${rawMessage}`;
24116
+ message = formatHttpStatusMessage(status, rawMessage, extractedMessage, inferredStatus);
23833
24117
  } else if (extractedMessage) {
23834
24118
  if (isSuccessfulResponse && rawMessage !== "Unknown error") {
23835
24119
  message = rawMessage;
@@ -23837,7 +24121,9 @@ async function extractErrorDetails(error, options) {
23837
24121
  message = status ? `HTTP ${status}: ${extractedMessage}` : extractedMessage;
23838
24122
  }
23839
24123
  } else if (status) {
23840
- if (rawMessage === "Unknown error" && response) {
24124
+ if (inferredStatus !== undefined) {
24125
+ message = rawMessage;
24126
+ } else if (rawMessage === "Unknown error" && response) {
23841
24127
  const statusText = response.statusText;
23842
24128
  message = statusText ? `HTTP ${status} ${statusText}` : `HTTP ${status} - request failed`;
23843
24129
  } else {
@@ -23846,6 +24132,12 @@ async function extractErrorDetails(error, options) {
23846
24132
  } else {
23847
24133
  message = rawMessage;
23848
24134
  }
24135
+ if (status === undefined) {
24136
+ const connectivity = describeConnectivityError(error);
24137
+ if (connectivity && connectivity.message !== message && !message.includes(connectivity.message)) {
24138
+ message = `${message}: ${connectivity.message}`;
24139
+ }
24140
+ }
23849
24141
  let details = rawMessage;
23850
24142
  if (rawBody) {
23851
24143
  if (parsedBody) {
@@ -23967,6 +24259,7 @@ var CONSOLE_FALLBACK = {
23967
24259
  writeLog: (str) => process.stdout.write(str),
23968
24260
  capabilities: {
23969
24261
  isInteractive: false,
24262
+ canReadInput: false,
23970
24263
  supportsColor: false,
23971
24264
  outputWidth: 80
23972
24265
  }
@@ -28972,12 +29265,6 @@ class NodeContextStorage {
28972
29265
  return this.storage.getStore();
28973
29266
  }
28974
29267
  }
28975
- // ../../common/src/telemetry/global-telemetry-properties.ts
28976
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
28977
- function getGlobalTelemetryProperties() {
28978
- return telemetryPropsSlot.get();
28979
- }
28980
-
28981
29268
  // ../../common/src/telemetry/telemetry-service.ts
28982
29269
  class TelemetryService {
28983
29270
  telemetryProvider;
@@ -29167,6 +29454,29 @@ function isPlainRecord(value) {
29167
29454
  const prototype = Object.getPrototypeOf(value);
29168
29455
  return prototype === Object.prototype || prototype === null;
29169
29456
  }
29457
+ function extractPagedRows(value) {
29458
+ if (Array.isArray(value) || !isPlainRecord(value))
29459
+ return null;
29460
+ const entries = Object.values(value);
29461
+ if (entries.length === 0)
29462
+ return null;
29463
+ let rows = null;
29464
+ let hasScalarSibling = false;
29465
+ for (const entry of entries) {
29466
+ if (Array.isArray(entry)) {
29467
+ if (rows !== null)
29468
+ return null;
29469
+ rows = entry;
29470
+ } else if (entry !== null && typeof entry === "object") {
29471
+ return null;
29472
+ } else {
29473
+ hasScalarSibling = true;
29474
+ }
29475
+ }
29476
+ if (rows === null || !hasScalarSibling)
29477
+ return null;
29478
+ return rows;
29479
+ }
29170
29480
  function toLowerCamelCaseKey(key) {
29171
29481
  if (!key)
29172
29482
  return key;
@@ -29231,7 +29541,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
29231
29541
  break;
29232
29542
  case "plain": {
29233
29543
  if ("Data" in data && data.Data != null) {
29234
- const items = Array.isArray(data.Data) ? data.Data : [data.Data];
29544
+ const pagedRows = extractPagedRows(data.Data);
29545
+ const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
29235
29546
  items.forEach((item) => {
29236
29547
  const values = Object.values(item).map((v) => v ?? "").join("\t");
29237
29548
  logFn(values);
@@ -29243,10 +29554,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
29243
29554
  break;
29244
29555
  }
29245
29556
  default: {
29246
- if ("Data" in data && data.Data != null && !(Array.isArray(data.Data) && data.Data.length === 0)) {
29557
+ const hasData = "Data" in data && data.Data != null;
29558
+ const pagedRows = hasData ? extractPagedRows(data.Data) : null;
29559
+ const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
29560
+ if (hasData && !(rows !== null && rows.length === 0)) {
29247
29561
  const logValue = data.Log;
29248
- if (Array.isArray(data.Data)) {
29249
- printResizableTable(data.Data, logFn, logValue);
29562
+ if (rows !== null) {
29563
+ printResizableTable(rows, logFn, logValue);
29250
29564
  } else {
29251
29565
  printVerticalTable(data.Data, logFn, logValue);
29252
29566
  }
@@ -29434,6 +29748,44 @@ function defaultErrorCodeForResult(result) {
29434
29748
  return "unknown_error";
29435
29749
  }
29436
29750
  }
29751
+ function parseHttpStatusFromMessage2(message) {
29752
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
29753
+ if (!match)
29754
+ return;
29755
+ const status = Number(match[1]);
29756
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
29757
+ }
29758
+ function defaultErrorCodeForHttpStatus(status) {
29759
+ if (status === undefined)
29760
+ return;
29761
+ if (status === 400 || status === 409 || status === 422) {
29762
+ return "invalid_argument";
29763
+ }
29764
+ if (status === 401)
29765
+ return "authentication_required";
29766
+ if (status === 403)
29767
+ return "permission_denied";
29768
+ if (status === 404)
29769
+ return "not_found";
29770
+ if (status === 405)
29771
+ return "method_not_allowed";
29772
+ if (status === 408)
29773
+ return "timeout";
29774
+ if (status === 429)
29775
+ return "rate_limited";
29776
+ if (status >= 500 && status < 600)
29777
+ return "server_error";
29778
+ return;
29779
+ }
29780
+ function defaultErrorCodeForFailure(data) {
29781
+ if (data.Result === RESULTS.Failure) {
29782
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
29783
+ const errorCode2 = defaultErrorCodeForHttpStatus(status);
29784
+ if (errorCode2)
29785
+ return errorCode2;
29786
+ }
29787
+ return defaultErrorCodeForResult(data.Result);
29788
+ }
29437
29789
  function defaultRetryForErrorCode(errorCode2) {
29438
29790
  switch (errorCode2) {
29439
29791
  case "network_error":
@@ -29463,16 +29815,19 @@ var OutputFormatter;
29463
29815
  OutputFormatter.success = success;
29464
29816
  function error(data) {
29465
29817
  data.Log ??= getLogFilePath() || undefined;
29466
- data.ErrorCode ??= defaultErrorCodeForResult(data.Result);
29818
+ data.ErrorCode ??= defaultErrorCodeForFailure(data);
29467
29819
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
29468
29820
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
29469
- telemetry.trackEvent(CommonTelemetryEvents.Error, {
29470
- result: data.Result,
29471
- errorCode: data.ErrorCode,
29472
- retry: data.Retry,
29473
- message: data.Message
29474
- });
29475
- logOutput(normalizeOutputKeys(data), getOutputFormat());
29821
+ const { SuppressTelemetry, ...envelope } = data;
29822
+ if (!SuppressTelemetry) {
29823
+ telemetry.trackEvent(CommonTelemetryEvents.Error, {
29824
+ result: data.Result,
29825
+ errorCode: data.ErrorCode,
29826
+ retry: data.Retry,
29827
+ message: data.Message
29828
+ });
29829
+ }
29830
+ logOutput(normalizeOutputKeys(envelope), getOutputFormat());
29476
29831
  }
29477
29832
  OutputFormatter.error = error;
29478
29833
  function emitList(code, items, opts) {
@@ -29762,1409 +30117,6 @@ var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
29762
30117
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
29763
30118
  // ../../common/src/interactivity-context.ts
29764
30119
  var modeSlot = singleton("InteractivityMode");
29765
- // ../../../node_modules/jsonpath-plus/dist/index-node-esm.js
29766
- import vm from "vm";
29767
-
29768
- class Hooks {
29769
- add(name, callback, first) {
29770
- if (typeof arguments[0] != "string") {
29771
- for (let name2 in arguments[0]) {
29772
- this.add(name2, arguments[0][name2], arguments[1]);
29773
- }
29774
- } else {
29775
- (Array.isArray(name) ? name : [name]).forEach(function(name2) {
29776
- this[name2] = this[name2] || [];
29777
- if (callback) {
29778
- this[name2][first ? "unshift" : "push"](callback);
29779
- }
29780
- }, this);
29781
- }
29782
- }
29783
- run(name, env) {
29784
- this[name] = this[name] || [];
29785
- this[name].forEach(function(callback) {
29786
- callback.call(env && env.context ? env.context : env, env);
29787
- });
29788
- }
29789
- }
29790
-
29791
- class Plugins {
29792
- constructor(jsep) {
29793
- this.jsep = jsep;
29794
- this.registered = {};
29795
- }
29796
- register(...plugins) {
29797
- plugins.forEach((plugin) => {
29798
- if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
29799
- throw new Error("Invalid JSEP plugin format");
29800
- }
29801
- if (this.registered[plugin.name]) {
29802
- return;
29803
- }
29804
- plugin.init(this.jsep);
29805
- this.registered[plugin.name] = plugin;
29806
- });
29807
- }
29808
- }
29809
-
29810
- class Jsep {
29811
- static get version() {
29812
- return "1.4.0";
29813
- }
29814
- static toString() {
29815
- return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
29816
- }
29817
- static addUnaryOp(op_name) {
29818
- Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
29819
- Jsep.unary_ops[op_name] = 1;
29820
- return Jsep;
29821
- }
29822
- static addBinaryOp(op_name, precedence, isRightAssociative) {
29823
- Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
29824
- Jsep.binary_ops[op_name] = precedence;
29825
- if (isRightAssociative) {
29826
- Jsep.right_associative.add(op_name);
29827
- } else {
29828
- Jsep.right_associative.delete(op_name);
29829
- }
29830
- return Jsep;
29831
- }
29832
- static addIdentifierChar(char) {
29833
- Jsep.additional_identifier_chars.add(char);
29834
- return Jsep;
29835
- }
29836
- static addLiteral(literal_name, literal_value) {
29837
- Jsep.literals[literal_name] = literal_value;
29838
- return Jsep;
29839
- }
29840
- static removeUnaryOp(op_name) {
29841
- delete Jsep.unary_ops[op_name];
29842
- if (op_name.length === Jsep.max_unop_len) {
29843
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
29844
- }
29845
- return Jsep;
29846
- }
29847
- static removeAllUnaryOps() {
29848
- Jsep.unary_ops = {};
29849
- Jsep.max_unop_len = 0;
29850
- return Jsep;
29851
- }
29852
- static removeIdentifierChar(char) {
29853
- Jsep.additional_identifier_chars.delete(char);
29854
- return Jsep;
29855
- }
29856
- static removeBinaryOp(op_name) {
29857
- delete Jsep.binary_ops[op_name];
29858
- if (op_name.length === Jsep.max_binop_len) {
29859
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
29860
- }
29861
- Jsep.right_associative.delete(op_name);
29862
- return Jsep;
29863
- }
29864
- static removeAllBinaryOps() {
29865
- Jsep.binary_ops = {};
29866
- Jsep.max_binop_len = 0;
29867
- return Jsep;
29868
- }
29869
- static removeLiteral(literal_name) {
29870
- delete Jsep.literals[literal_name];
29871
- return Jsep;
29872
- }
29873
- static removeAllLiterals() {
29874
- Jsep.literals = {};
29875
- return Jsep;
29876
- }
29877
- get char() {
29878
- return this.expr.charAt(this.index);
29879
- }
29880
- get code() {
29881
- return this.expr.charCodeAt(this.index);
29882
- }
29883
- constructor(expr) {
29884
- this.expr = expr;
29885
- this.index = 0;
29886
- }
29887
- static parse(expr) {
29888
- return new Jsep(expr).parse();
29889
- }
29890
- static getMaxKeyLen(obj) {
29891
- return Math.max(0, ...Object.keys(obj).map((k) => k.length));
29892
- }
29893
- static isDecimalDigit(ch) {
29894
- return ch >= 48 && ch <= 57;
29895
- }
29896
- static binaryPrecedence(op_val) {
29897
- return Jsep.binary_ops[op_val] || 0;
29898
- }
29899
- static isIdentifierStart(ch) {
29900
- 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));
29901
- }
29902
- static isIdentifierPart(ch) {
29903
- return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
29904
- }
29905
- throwError(message) {
29906
- const error = new Error(message + " at character " + this.index);
29907
- error.index = this.index;
29908
- error.description = message;
29909
- throw error;
29910
- }
29911
- runHook(name, node) {
29912
- if (Jsep.hooks[name]) {
29913
- const env = {
29914
- context: this,
29915
- node
29916
- };
29917
- Jsep.hooks.run(name, env);
29918
- return env.node;
29919
- }
29920
- return node;
29921
- }
29922
- searchHook(name) {
29923
- if (Jsep.hooks[name]) {
29924
- const env = {
29925
- context: this
29926
- };
29927
- Jsep.hooks[name].find(function(callback) {
29928
- callback.call(env.context, env);
29929
- return env.node;
29930
- });
29931
- return env.node;
29932
- }
29933
- }
29934
- gobbleSpaces() {
29935
- let ch = this.code;
29936
- while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
29937
- ch = this.expr.charCodeAt(++this.index);
29938
- }
29939
- this.runHook("gobble-spaces");
29940
- }
29941
- parse() {
29942
- this.runHook("before-all");
29943
- const nodes = this.gobbleExpressions();
29944
- const node = nodes.length === 1 ? nodes[0] : {
29945
- type: Jsep.COMPOUND,
29946
- body: nodes
29947
- };
29948
- return this.runHook("after-all", node);
29949
- }
29950
- gobbleExpressions(untilICode) {
29951
- let nodes = [], ch_i, node;
29952
- while (this.index < this.expr.length) {
29953
- ch_i = this.code;
29954
- if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
29955
- this.index++;
29956
- } else {
29957
- if (node = this.gobbleExpression()) {
29958
- nodes.push(node);
29959
- } else if (this.index < this.expr.length) {
29960
- if (ch_i === untilICode) {
29961
- break;
29962
- }
29963
- this.throwError('Unexpected "' + this.char + '"');
29964
- }
29965
- }
29966
- }
29967
- return nodes;
29968
- }
29969
- gobbleExpression() {
29970
- const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
29971
- this.gobbleSpaces();
29972
- return this.runHook("after-expression", node);
29973
- }
29974
- gobbleBinaryOp() {
29975
- this.gobbleSpaces();
29976
- let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
29977
- let tc_len = to_check.length;
29978
- while (tc_len > 0) {
29979
- 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)))) {
29980
- this.index += tc_len;
29981
- return to_check;
29982
- }
29983
- to_check = to_check.substr(0, --tc_len);
29984
- }
29985
- return false;
29986
- }
29987
- gobbleBinaryExpression() {
29988
- let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
29989
- left = this.gobbleToken();
29990
- if (!left) {
29991
- return left;
29992
- }
29993
- biop = this.gobbleBinaryOp();
29994
- if (!biop) {
29995
- return left;
29996
- }
29997
- biop_info = {
29998
- value: biop,
29999
- prec: Jsep.binaryPrecedence(biop),
30000
- right_a: Jsep.right_associative.has(biop)
30001
- };
30002
- right = this.gobbleToken();
30003
- if (!right) {
30004
- this.throwError("Expected expression after " + biop);
30005
- }
30006
- stack = [left, biop_info, right];
30007
- while (biop = this.gobbleBinaryOp()) {
30008
- prec = Jsep.binaryPrecedence(biop);
30009
- if (prec === 0) {
30010
- this.index -= biop.length;
30011
- break;
30012
- }
30013
- biop_info = {
30014
- value: biop,
30015
- prec,
30016
- right_a: Jsep.right_associative.has(biop)
30017
- };
30018
- cur_biop = biop;
30019
- const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
30020
- while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
30021
- right = stack.pop();
30022
- biop = stack.pop().value;
30023
- left = stack.pop();
30024
- node = {
30025
- type: Jsep.BINARY_EXP,
30026
- operator: biop,
30027
- left,
30028
- right
30029
- };
30030
- stack.push(node);
30031
- }
30032
- node = this.gobbleToken();
30033
- if (!node) {
30034
- this.throwError("Expected expression after " + cur_biop);
30035
- }
30036
- stack.push(biop_info, node);
30037
- }
30038
- i = stack.length - 1;
30039
- node = stack[i];
30040
- while (i > 1) {
30041
- node = {
30042
- type: Jsep.BINARY_EXP,
30043
- operator: stack[i - 1].value,
30044
- left: stack[i - 2],
30045
- right: node
30046
- };
30047
- i -= 2;
30048
- }
30049
- return node;
30050
- }
30051
- gobbleToken() {
30052
- let ch, to_check, tc_len, node;
30053
- this.gobbleSpaces();
30054
- node = this.searchHook("gobble-token");
30055
- if (node) {
30056
- return this.runHook("after-token", node);
30057
- }
30058
- ch = this.code;
30059
- if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
30060
- return this.gobbleNumericLiteral();
30061
- }
30062
- if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
30063
- node = this.gobbleStringLiteral();
30064
- } else if (ch === Jsep.OBRACK_CODE) {
30065
- node = this.gobbleArray();
30066
- } else {
30067
- to_check = this.expr.substr(this.index, Jsep.max_unop_len);
30068
- tc_len = to_check.length;
30069
- while (tc_len > 0) {
30070
- 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)))) {
30071
- this.index += tc_len;
30072
- const argument = this.gobbleToken();
30073
- if (!argument) {
30074
- this.throwError("missing unaryOp argument");
30075
- }
30076
- return this.runHook("after-token", {
30077
- type: Jsep.UNARY_EXP,
30078
- operator: to_check,
30079
- argument,
30080
- prefix: true
30081
- });
30082
- }
30083
- to_check = to_check.substr(0, --tc_len);
30084
- }
30085
- if (Jsep.isIdentifierStart(ch)) {
30086
- node = this.gobbleIdentifier();
30087
- if (Jsep.literals.hasOwnProperty(node.name)) {
30088
- node = {
30089
- type: Jsep.LITERAL,
30090
- value: Jsep.literals[node.name],
30091
- raw: node.name
30092
- };
30093
- } else if (node.name === Jsep.this_str) {
30094
- node = {
30095
- type: Jsep.THIS_EXP
30096
- };
30097
- }
30098
- } else if (ch === Jsep.OPAREN_CODE) {
30099
- node = this.gobbleGroup();
30100
- }
30101
- }
30102
- if (!node) {
30103
- return this.runHook("after-token", false);
30104
- }
30105
- node = this.gobbleTokenProperty(node);
30106
- return this.runHook("after-token", node);
30107
- }
30108
- gobbleTokenProperty(node) {
30109
- this.gobbleSpaces();
30110
- let ch = this.code;
30111
- while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
30112
- let optional;
30113
- if (ch === Jsep.QUMARK_CODE) {
30114
- if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
30115
- break;
30116
- }
30117
- optional = true;
30118
- this.index += 2;
30119
- this.gobbleSpaces();
30120
- ch = this.code;
30121
- }
30122
- this.index++;
30123
- if (ch === Jsep.OBRACK_CODE) {
30124
- node = {
30125
- type: Jsep.MEMBER_EXP,
30126
- computed: true,
30127
- object: node,
30128
- property: this.gobbleExpression()
30129
- };
30130
- if (!node.property) {
30131
- this.throwError('Unexpected "' + this.char + '"');
30132
- }
30133
- this.gobbleSpaces();
30134
- ch = this.code;
30135
- if (ch !== Jsep.CBRACK_CODE) {
30136
- this.throwError("Unclosed [");
30137
- }
30138
- this.index++;
30139
- } else if (ch === Jsep.OPAREN_CODE) {
30140
- node = {
30141
- type: Jsep.CALL_EXP,
30142
- arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
30143
- callee: node
30144
- };
30145
- } else if (ch === Jsep.PERIOD_CODE || optional) {
30146
- if (optional) {
30147
- this.index--;
30148
- }
30149
- this.gobbleSpaces();
30150
- node = {
30151
- type: Jsep.MEMBER_EXP,
30152
- computed: false,
30153
- object: node,
30154
- property: this.gobbleIdentifier()
30155
- };
30156
- }
30157
- if (optional) {
30158
- node.optional = true;
30159
- }
30160
- this.gobbleSpaces();
30161
- ch = this.code;
30162
- }
30163
- return node;
30164
- }
30165
- gobbleNumericLiteral() {
30166
- let number = "", ch, chCode;
30167
- while (Jsep.isDecimalDigit(this.code)) {
30168
- number += this.expr.charAt(this.index++);
30169
- }
30170
- if (this.code === Jsep.PERIOD_CODE) {
30171
- number += this.expr.charAt(this.index++);
30172
- while (Jsep.isDecimalDigit(this.code)) {
30173
- number += this.expr.charAt(this.index++);
30174
- }
30175
- }
30176
- ch = this.char;
30177
- if (ch === "e" || ch === "E") {
30178
- number += this.expr.charAt(this.index++);
30179
- ch = this.char;
30180
- if (ch === "+" || ch === "-") {
30181
- number += this.expr.charAt(this.index++);
30182
- }
30183
- while (Jsep.isDecimalDigit(this.code)) {
30184
- number += this.expr.charAt(this.index++);
30185
- }
30186
- if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
30187
- this.throwError("Expected exponent (" + number + this.char + ")");
30188
- }
30189
- }
30190
- chCode = this.code;
30191
- if (Jsep.isIdentifierStart(chCode)) {
30192
- this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
30193
- } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
30194
- this.throwError("Unexpected period");
30195
- }
30196
- return {
30197
- type: Jsep.LITERAL,
30198
- value: parseFloat(number),
30199
- raw: number
30200
- };
30201
- }
30202
- gobbleStringLiteral() {
30203
- let str = "";
30204
- const startIndex = this.index;
30205
- const quote = this.expr.charAt(this.index++);
30206
- let closed = false;
30207
- while (this.index < this.expr.length) {
30208
- let ch = this.expr.charAt(this.index++);
30209
- if (ch === quote) {
30210
- closed = true;
30211
- break;
30212
- } else if (ch === "\\") {
30213
- ch = this.expr.charAt(this.index++);
30214
- switch (ch) {
30215
- case "n":
30216
- str += `
30217
- `;
30218
- break;
30219
- case "r":
30220
- str += "\r";
30221
- break;
30222
- case "t":
30223
- str += "\t";
30224
- break;
30225
- case "b":
30226
- str += "\b";
30227
- break;
30228
- case "f":
30229
- str += "\f";
30230
- break;
30231
- case "v":
30232
- str += "\v";
30233
- break;
30234
- default:
30235
- str += ch;
30236
- }
30237
- } else {
30238
- str += ch;
30239
- }
30240
- }
30241
- if (!closed) {
30242
- this.throwError('Unclosed quote after "' + str + '"');
30243
- }
30244
- return {
30245
- type: Jsep.LITERAL,
30246
- value: str,
30247
- raw: this.expr.substring(startIndex, this.index)
30248
- };
30249
- }
30250
- gobbleIdentifier() {
30251
- let ch = this.code, start = this.index;
30252
- if (Jsep.isIdentifierStart(ch)) {
30253
- this.index++;
30254
- } else {
30255
- this.throwError("Unexpected " + this.char);
30256
- }
30257
- while (this.index < this.expr.length) {
30258
- ch = this.code;
30259
- if (Jsep.isIdentifierPart(ch)) {
30260
- this.index++;
30261
- } else {
30262
- break;
30263
- }
30264
- }
30265
- return {
30266
- type: Jsep.IDENTIFIER,
30267
- name: this.expr.slice(start, this.index)
30268
- };
30269
- }
30270
- gobbleArguments(termination) {
30271
- const args = [];
30272
- let closed = false;
30273
- let separator_count = 0;
30274
- while (this.index < this.expr.length) {
30275
- this.gobbleSpaces();
30276
- let ch_i = this.code;
30277
- if (ch_i === termination) {
30278
- closed = true;
30279
- this.index++;
30280
- if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
30281
- this.throwError("Unexpected token " + String.fromCharCode(termination));
30282
- }
30283
- break;
30284
- } else if (ch_i === Jsep.COMMA_CODE) {
30285
- this.index++;
30286
- separator_count++;
30287
- if (separator_count !== args.length) {
30288
- if (termination === Jsep.CPAREN_CODE) {
30289
- this.throwError("Unexpected token ,");
30290
- } else if (termination === Jsep.CBRACK_CODE) {
30291
- for (let arg = args.length;arg < separator_count; arg++) {
30292
- args.push(null);
30293
- }
30294
- }
30295
- }
30296
- } else if (args.length !== separator_count && separator_count !== 0) {
30297
- this.throwError("Expected comma");
30298
- } else {
30299
- const node = this.gobbleExpression();
30300
- if (!node || node.type === Jsep.COMPOUND) {
30301
- this.throwError("Expected comma");
30302
- }
30303
- args.push(node);
30304
- }
30305
- }
30306
- if (!closed) {
30307
- this.throwError("Expected " + String.fromCharCode(termination));
30308
- }
30309
- return args;
30310
- }
30311
- gobbleGroup() {
30312
- this.index++;
30313
- let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
30314
- if (this.code === Jsep.CPAREN_CODE) {
30315
- this.index++;
30316
- if (nodes.length === 1) {
30317
- return nodes[0];
30318
- } else if (!nodes.length) {
30319
- return false;
30320
- } else {
30321
- return {
30322
- type: Jsep.SEQUENCE_EXP,
30323
- expressions: nodes
30324
- };
30325
- }
30326
- } else {
30327
- this.throwError("Unclosed (");
30328
- }
30329
- }
30330
- gobbleArray() {
30331
- this.index++;
30332
- return {
30333
- type: Jsep.ARRAY_EXP,
30334
- elements: this.gobbleArguments(Jsep.CBRACK_CODE)
30335
- };
30336
- }
30337
- }
30338
- var hooks = new Hooks;
30339
- Object.assign(Jsep, {
30340
- hooks,
30341
- plugins: new Plugins(Jsep),
30342
- COMPOUND: "Compound",
30343
- SEQUENCE_EXP: "SequenceExpression",
30344
- IDENTIFIER: "Identifier",
30345
- MEMBER_EXP: "MemberExpression",
30346
- LITERAL: "Literal",
30347
- THIS_EXP: "ThisExpression",
30348
- CALL_EXP: "CallExpression",
30349
- UNARY_EXP: "UnaryExpression",
30350
- BINARY_EXP: "BinaryExpression",
30351
- ARRAY_EXP: "ArrayExpression",
30352
- TAB_CODE: 9,
30353
- LF_CODE: 10,
30354
- CR_CODE: 13,
30355
- SPACE_CODE: 32,
30356
- PERIOD_CODE: 46,
30357
- COMMA_CODE: 44,
30358
- SQUOTE_CODE: 39,
30359
- DQUOTE_CODE: 34,
30360
- OPAREN_CODE: 40,
30361
- CPAREN_CODE: 41,
30362
- OBRACK_CODE: 91,
30363
- CBRACK_CODE: 93,
30364
- QUMARK_CODE: 63,
30365
- SEMCOL_CODE: 59,
30366
- COLON_CODE: 58,
30367
- unary_ops: {
30368
- "-": 1,
30369
- "!": 1,
30370
- "~": 1,
30371
- "+": 1
30372
- },
30373
- binary_ops: {
30374
- "||": 1,
30375
- "??": 1,
30376
- "&&": 2,
30377
- "|": 3,
30378
- "^": 4,
30379
- "&": 5,
30380
- "==": 6,
30381
- "!=": 6,
30382
- "===": 6,
30383
- "!==": 6,
30384
- "<": 7,
30385
- ">": 7,
30386
- "<=": 7,
30387
- ">=": 7,
30388
- "<<": 8,
30389
- ">>": 8,
30390
- ">>>": 8,
30391
- "+": 9,
30392
- "-": 9,
30393
- "*": 10,
30394
- "/": 10,
30395
- "%": 10,
30396
- "**": 11
30397
- },
30398
- right_associative: new Set(["**"]),
30399
- additional_identifier_chars: new Set(["$", "_"]),
30400
- literals: {
30401
- true: true,
30402
- false: false,
30403
- null: null
30404
- },
30405
- this_str: "this"
30406
- });
30407
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
30408
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
30409
- var jsep = (expr) => new Jsep(expr).parse();
30410
- var stdClassProps = Object.getOwnPropertyNames(class Test {
30411
- });
30412
- Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
30413
- jsep[m] = Jsep[m];
30414
- });
30415
- jsep.Jsep = Jsep;
30416
- var CONDITIONAL_EXP = "ConditionalExpression";
30417
- var ternary = {
30418
- name: "ternary",
30419
- init(jsep2) {
30420
- jsep2.hooks.add("after-expression", function gobbleTernary(env) {
30421
- if (env.node && this.code === jsep2.QUMARK_CODE) {
30422
- this.index++;
30423
- const test = env.node;
30424
- const consequent = this.gobbleExpression();
30425
- if (!consequent) {
30426
- this.throwError("Expected expression");
30427
- }
30428
- this.gobbleSpaces();
30429
- if (this.code === jsep2.COLON_CODE) {
30430
- this.index++;
30431
- const alternate = this.gobbleExpression();
30432
- if (!alternate) {
30433
- this.throwError("Expected expression");
30434
- }
30435
- env.node = {
30436
- type: CONDITIONAL_EXP,
30437
- test,
30438
- consequent,
30439
- alternate
30440
- };
30441
- if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
30442
- let newTest = test;
30443
- while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
30444
- newTest = newTest.right;
30445
- }
30446
- env.node.test = newTest.right;
30447
- newTest.right = env.node;
30448
- env.node = test;
30449
- }
30450
- } else {
30451
- this.throwError("Expected :");
30452
- }
30453
- }
30454
- });
30455
- }
30456
- };
30457
- jsep.plugins.register(ternary);
30458
- var FSLASH_CODE = 47;
30459
- var BSLASH_CODE = 92;
30460
- var index = {
30461
- name: "regex",
30462
- init(jsep2) {
30463
- jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
30464
- if (this.code === FSLASH_CODE) {
30465
- const patternIndex = ++this.index;
30466
- let inCharSet = false;
30467
- while (this.index < this.expr.length) {
30468
- if (this.code === FSLASH_CODE && !inCharSet) {
30469
- const pattern = this.expr.slice(patternIndex, this.index);
30470
- let flags = "";
30471
- while (++this.index < this.expr.length) {
30472
- const code = this.code;
30473
- if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
30474
- flags += this.char;
30475
- } else {
30476
- break;
30477
- }
30478
- }
30479
- let value;
30480
- try {
30481
- value = new RegExp(pattern, flags);
30482
- } catch (e) {
30483
- this.throwError(e.message);
30484
- }
30485
- env.node = {
30486
- type: jsep2.LITERAL,
30487
- value,
30488
- raw: this.expr.slice(patternIndex - 1, this.index)
30489
- };
30490
- env.node = this.gobbleTokenProperty(env.node);
30491
- return env.node;
30492
- }
30493
- if (this.code === jsep2.OBRACK_CODE) {
30494
- inCharSet = true;
30495
- } else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
30496
- inCharSet = false;
30497
- }
30498
- this.index += this.code === BSLASH_CODE ? 2 : 1;
30499
- }
30500
- this.throwError("Unclosed Regex");
30501
- }
30502
- });
30503
- }
30504
- };
30505
- var PLUS_CODE = 43;
30506
- var MINUS_CODE = 45;
30507
- var plugin = {
30508
- name: "assignment",
30509
- assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
30510
- updateOperators: [PLUS_CODE, MINUS_CODE],
30511
- assignmentPrecedence: 0.9,
30512
- init(jsep2) {
30513
- const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
30514
- plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
30515
- jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
30516
- const code = this.code;
30517
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
30518
- this.index += 2;
30519
- env.node = {
30520
- type: "UpdateExpression",
30521
- operator: code === PLUS_CODE ? "++" : "--",
30522
- argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
30523
- prefix: true
30524
- };
30525
- if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
30526
- this.throwError(`Unexpected ${env.node.operator}`);
30527
- }
30528
- }
30529
- });
30530
- jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
30531
- if (env.node) {
30532
- const code = this.code;
30533
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
30534
- if (!updateNodeTypes.includes(env.node.type)) {
30535
- this.throwError(`Unexpected ${env.node.operator}`);
30536
- }
30537
- this.index += 2;
30538
- env.node = {
30539
- type: "UpdateExpression",
30540
- operator: code === PLUS_CODE ? "++" : "--",
30541
- argument: env.node,
30542
- prefix: false
30543
- };
30544
- }
30545
- }
30546
- });
30547
- jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
30548
- if (env.node) {
30549
- updateBinariesToAssignments(env.node);
30550
- }
30551
- });
30552
- function updateBinariesToAssignments(node) {
30553
- if (plugin.assignmentOperators.has(node.operator)) {
30554
- node.type = "AssignmentExpression";
30555
- updateBinariesToAssignments(node.left);
30556
- updateBinariesToAssignments(node.right);
30557
- } else if (!node.operator) {
30558
- Object.values(node).forEach((val) => {
30559
- if (val && typeof val === "object") {
30560
- updateBinariesToAssignments(val);
30561
- }
30562
- });
30563
- }
30564
- }
30565
- }
30566
- };
30567
- jsep.plugins.register(index, plugin);
30568
- jsep.addUnaryOp("typeof");
30569
- jsep.addUnaryOp("void");
30570
- jsep.addLiteral("null", null);
30571
- jsep.addLiteral("undefined", undefined);
30572
- var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
30573
- var SafeEval = {
30574
- evalAst(ast, subs) {
30575
- switch (ast.type) {
30576
- case "BinaryExpression":
30577
- case "LogicalExpression":
30578
- return SafeEval.evalBinaryExpression(ast, subs);
30579
- case "Compound":
30580
- return SafeEval.evalCompound(ast, subs);
30581
- case "ConditionalExpression":
30582
- return SafeEval.evalConditionalExpression(ast, subs);
30583
- case "Identifier":
30584
- return SafeEval.evalIdentifier(ast, subs);
30585
- case "Literal":
30586
- return SafeEval.evalLiteral(ast, subs);
30587
- case "MemberExpression":
30588
- return SafeEval.evalMemberExpression(ast, subs);
30589
- case "UnaryExpression":
30590
- return SafeEval.evalUnaryExpression(ast, subs);
30591
- case "ArrayExpression":
30592
- return SafeEval.evalArrayExpression(ast, subs);
30593
- case "CallExpression":
30594
- return SafeEval.evalCallExpression(ast, subs);
30595
- case "AssignmentExpression":
30596
- return SafeEval.evalAssignmentExpression(ast, subs);
30597
- default:
30598
- throw SyntaxError("Unexpected expression", ast);
30599
- }
30600
- },
30601
- evalBinaryExpression(ast, subs) {
30602
- const result = {
30603
- "||": (a, b) => a || b(),
30604
- "&&": (a, b) => a && b(),
30605
- "|": (a, b) => a | b(),
30606
- "^": (a, b) => a ^ b(),
30607
- "&": (a, b) => a & b(),
30608
- "==": (a, b) => a == b(),
30609
- "!=": (a, b) => a != b(),
30610
- "===": (a, b) => a === b(),
30611
- "!==": (a, b) => a !== b(),
30612
- "<": (a, b) => a < b(),
30613
- ">": (a, b) => a > b(),
30614
- "<=": (a, b) => a <= b(),
30615
- ">=": (a, b) => a >= b(),
30616
- "<<": (a, b) => a << b(),
30617
- ">>": (a, b) => a >> b(),
30618
- ">>>": (a, b) => a >>> b(),
30619
- "+": (a, b) => a + b(),
30620
- "-": (a, b) => a - b(),
30621
- "*": (a, b) => a * b(),
30622
- "/": (a, b) => a / b(),
30623
- "%": (a, b) => a % b()
30624
- }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
30625
- return result;
30626
- },
30627
- evalCompound(ast, subs) {
30628
- let last;
30629
- for (let i = 0;i < ast.body.length; i++) {
30630
- if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
30631
- i += 1;
30632
- }
30633
- const expr = ast.body[i];
30634
- last = SafeEval.evalAst(expr, subs);
30635
- }
30636
- return last;
30637
- },
30638
- evalConditionalExpression(ast, subs) {
30639
- if (SafeEval.evalAst(ast.test, subs)) {
30640
- return SafeEval.evalAst(ast.consequent, subs);
30641
- }
30642
- return SafeEval.evalAst(ast.alternate, subs);
30643
- },
30644
- evalIdentifier(ast, subs) {
30645
- if (Object.hasOwn(subs, ast.name)) {
30646
- return subs[ast.name];
30647
- }
30648
- throw ReferenceError(`${ast.name} is not defined`);
30649
- },
30650
- evalLiteral(ast) {
30651
- return ast.value;
30652
- },
30653
- evalMemberExpression(ast, subs) {
30654
- const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
30655
- const obj = SafeEval.evalAst(ast.object, subs);
30656
- if (obj === undefined || obj === null) {
30657
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
30658
- }
30659
- if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
30660
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
30661
- }
30662
- const result = obj[prop];
30663
- if (typeof result === "function") {
30664
- return result.bind(obj);
30665
- }
30666
- return result;
30667
- },
30668
- evalUnaryExpression(ast, subs) {
30669
- const result = {
30670
- "-": (a) => -SafeEval.evalAst(a, subs),
30671
- "!": (a) => !SafeEval.evalAst(a, subs),
30672
- "~": (a) => ~SafeEval.evalAst(a, subs),
30673
- "+": (a) => +SafeEval.evalAst(a, subs),
30674
- typeof: (a) => typeof SafeEval.evalAst(a, subs),
30675
- void: (a) => void SafeEval.evalAst(a, subs)
30676
- }[ast.operator](ast.argument);
30677
- return result;
30678
- },
30679
- evalArrayExpression(ast, subs) {
30680
- return ast.elements.map((el) => SafeEval.evalAst(el, subs));
30681
- },
30682
- evalCallExpression(ast, subs) {
30683
- const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
30684
- const func = SafeEval.evalAst(ast.callee, subs);
30685
- if (func === Function) {
30686
- throw new Error("Function constructor is disabled");
30687
- }
30688
- return func(...args);
30689
- },
30690
- evalAssignmentExpression(ast, subs) {
30691
- if (ast.left.type !== "Identifier") {
30692
- throw SyntaxError("Invalid left-hand side in assignment");
30693
- }
30694
- const id = ast.left.name;
30695
- const value = SafeEval.evalAst(ast.right, subs);
30696
- subs[id] = value;
30697
- return subs[id];
30698
- }
30699
- };
30700
-
30701
- class SafeScript {
30702
- constructor(expr) {
30703
- this.code = expr;
30704
- this.ast = jsep(this.code);
30705
- }
30706
- runInNewContext(context) {
30707
- const keyMap = Object.assign(Object.create(null), context);
30708
- return SafeEval.evalAst(this.ast, keyMap);
30709
- }
30710
- }
30711
- function push(arr, item) {
30712
- arr = arr.slice();
30713
- arr.push(item);
30714
- return arr;
30715
- }
30716
- function unshift(item, arr) {
30717
- arr = arr.slice();
30718
- arr.unshift(item);
30719
- return arr;
30720
- }
30721
-
30722
- class NewError extends Error {
30723
- constructor(value) {
30724
- super('JSONPath should not be called with "new" (it prevents return ' + "of (unwrapped) scalar values)");
30725
- this.avoidNew = true;
30726
- this.value = value;
30727
- this.name = "NewError";
30728
- }
30729
- }
30730
- function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
30731
- if (!(this instanceof JSONPath)) {
30732
- try {
30733
- return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
30734
- } catch (e) {
30735
- if (!e.avoidNew) {
30736
- throw e;
30737
- }
30738
- return e.value;
30739
- }
30740
- }
30741
- if (typeof opts === "string") {
30742
- otherTypeCallback = callback;
30743
- callback = obj;
30744
- obj = expr;
30745
- expr = opts;
30746
- opts = null;
30747
- }
30748
- const optObj = opts && typeof opts === "object";
30749
- opts = opts || {};
30750
- this.json = opts.json || obj;
30751
- this.path = opts.path || expr;
30752
- this.resultType = opts.resultType || "value";
30753
- this.flatten = opts.flatten || false;
30754
- this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
30755
- this.sandbox = opts.sandbox || {};
30756
- this.eval = opts.eval === undefined ? "safe" : opts.eval;
30757
- this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
30758
- this.parent = opts.parent || null;
30759
- this.parentProperty = opts.parentProperty || null;
30760
- this.callback = opts.callback || callback || null;
30761
- this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
30762
- throw new TypeError("You must supply an otherTypeCallback callback option " + "with the @other() operator.");
30763
- };
30764
- if (opts.autostart !== false) {
30765
- const args = {
30766
- path: optObj ? opts.path : expr
30767
- };
30768
- if (!optObj) {
30769
- args.json = obj;
30770
- } else if ("json" in opts) {
30771
- args.json = opts.json;
30772
- }
30773
- const ret = this.evaluate(args);
30774
- if (!ret || typeof ret !== "object") {
30775
- throw new NewError(ret);
30776
- }
30777
- return ret;
30778
- }
30779
- }
30780
- JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
30781
- let currParent = this.parent, currParentProperty = this.parentProperty;
30782
- let {
30783
- flatten,
30784
- wrap
30785
- } = this;
30786
- this.currResultType = this.resultType;
30787
- this.currEval = this.eval;
30788
- this.currSandbox = this.sandbox;
30789
- callback = callback || this.callback;
30790
- this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
30791
- json = json || this.json;
30792
- expr = expr || this.path;
30793
- if (expr && typeof expr === "object" && !Array.isArray(expr)) {
30794
- if (!expr.path && expr.path !== "") {
30795
- throw new TypeError('You must supply a "path" property when providing an object ' + "argument to JSONPath.evaluate().");
30796
- }
30797
- if (!Object.hasOwn(expr, "json")) {
30798
- throw new TypeError('You must supply a "json" property when providing an object ' + "argument to JSONPath.evaluate().");
30799
- }
30800
- ({
30801
- json
30802
- } = expr);
30803
- flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
30804
- this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
30805
- this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
30806
- wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
30807
- this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
30808
- callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
30809
- this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
30810
- currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
30811
- currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
30812
- expr = expr.path;
30813
- }
30814
- currParent = currParent || null;
30815
- currParentProperty = currParentProperty || null;
30816
- if (Array.isArray(expr)) {
30817
- expr = JSONPath.toPathString(expr);
30818
- }
30819
- if (!expr && expr !== "" || !json) {
30820
- return;
30821
- }
30822
- const exprList = JSONPath.toPathArray(expr);
30823
- if (exprList[0] === "$" && exprList.length > 1) {
30824
- exprList.shift();
30825
- }
30826
- this._hasParentSelector = null;
30827
- const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
30828
- return ea && !ea.isParentSelector;
30829
- });
30830
- if (!result.length) {
30831
- return wrap ? [] : undefined;
30832
- }
30833
- if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
30834
- return this._getPreferredOutput(result[0]);
30835
- }
30836
- return result.reduce((rslt, ea) => {
30837
- const valOrPath = this._getPreferredOutput(ea);
30838
- if (flatten && Array.isArray(valOrPath)) {
30839
- rslt = rslt.concat(valOrPath);
30840
- } else {
30841
- rslt.push(valOrPath);
30842
- }
30843
- return rslt;
30844
- }, []);
30845
- };
30846
- JSONPath.prototype._getPreferredOutput = function(ea) {
30847
- const resultType = this.currResultType;
30848
- switch (resultType) {
30849
- case "all": {
30850
- const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
30851
- ea.pointer = JSONPath.toPointer(path3);
30852
- ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
30853
- return ea;
30854
- }
30855
- case "value":
30856
- case "parent":
30857
- case "parentProperty":
30858
- return ea[resultType];
30859
- case "path":
30860
- return JSONPath.toPathString(ea[resultType]);
30861
- case "pointer":
30862
- return JSONPath.toPointer(ea.path);
30863
- default:
30864
- throw new TypeError("Unknown result type");
30865
- }
30866
- };
30867
- JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
30868
- if (callback) {
30869
- const preferredOutput = this._getPreferredOutput(fullRetObj);
30870
- fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
30871
- callback(preferredOutput, type, fullRetObj);
30872
- }
30873
- };
30874
- JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
30875
- let retObj;
30876
- if (!expr.length) {
30877
- retObj = {
30878
- path: path3,
30879
- value: val,
30880
- parent,
30881
- parentProperty: parentPropName,
30882
- hasArrExpr
30883
- };
30884
- this._handleCallback(retObj, callback, "value");
30885
- return retObj;
30886
- }
30887
- const loc = expr[0], x = expr.slice(1);
30888
- const ret = [];
30889
- function addRet(elems) {
30890
- if (Array.isArray(elems)) {
30891
- elems.forEach((t) => {
30892
- ret.push(t);
30893
- });
30894
- } else {
30895
- ret.push(elems);
30896
- }
30897
- }
30898
- if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
30899
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
30900
- } else if (loc === "*") {
30901
- this._walk(val, (m) => {
30902
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
30903
- });
30904
- } else if (loc === "..") {
30905
- addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
30906
- this._walk(val, (m) => {
30907
- if (typeof val[m] === "object") {
30908
- addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
30909
- }
30910
- });
30911
- } else if (loc === "^") {
30912
- this._hasParentSelector = true;
30913
- return {
30914
- path: path3.slice(0, -1),
30915
- expr: x,
30916
- isParentSelector: true
30917
- };
30918
- } else if (loc === "~") {
30919
- retObj = {
30920
- path: push(path3, loc),
30921
- value: parentPropName,
30922
- parent,
30923
- parentProperty: null
30924
- };
30925
- this._handleCallback(retObj, callback, "property");
30926
- return retObj;
30927
- } else if (loc === "$") {
30928
- addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
30929
- } else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
30930
- addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
30931
- } else if (loc.indexOf("?(") === 0) {
30932
- if (this.currEval === false) {
30933
- throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
30934
- }
30935
- const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
30936
- const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
30937
- if (nested) {
30938
- this._walk(val, (m) => {
30939
- const npath = [nested[2]];
30940
- const nvalue = nested[1] ? val[m][nested[1]] : val[m];
30941
- const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
30942
- if (filterResults.length > 0) {
30943
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
30944
- }
30945
- });
30946
- } else {
30947
- this._walk(val, (m) => {
30948
- if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
30949
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
30950
- }
30951
- });
30952
- }
30953
- } else if (loc[0] === "(") {
30954
- if (this.currEval === false) {
30955
- throw new Error("Eval [(expr)] prevented in JSONPath expression.");
30956
- }
30957
- addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
30958
- } else if (loc[0] === "@") {
30959
- let addType = false;
30960
- const valueType = loc.slice(1, -2);
30961
- switch (valueType) {
30962
- case "scalar":
30963
- if (!val || !["object", "function"].includes(typeof val)) {
30964
- addType = true;
30965
- }
30966
- break;
30967
- case "boolean":
30968
- case "string":
30969
- case "undefined":
30970
- case "function":
30971
- if (typeof val === valueType) {
30972
- addType = true;
30973
- }
30974
- break;
30975
- case "integer":
30976
- if (Number.isFinite(val) && !(val % 1)) {
30977
- addType = true;
30978
- }
30979
- break;
30980
- case "number":
30981
- if (Number.isFinite(val)) {
30982
- addType = true;
30983
- }
30984
- break;
30985
- case "nonFinite":
30986
- if (typeof val === "number" && !Number.isFinite(val)) {
30987
- addType = true;
30988
- }
30989
- break;
30990
- case "object":
30991
- if (val && typeof val === valueType) {
30992
- addType = true;
30993
- }
30994
- break;
30995
- case "array":
30996
- if (Array.isArray(val)) {
30997
- addType = true;
30998
- }
30999
- break;
31000
- case "other":
31001
- addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
31002
- break;
31003
- case "null":
31004
- if (val === null) {
31005
- addType = true;
31006
- }
31007
- break;
31008
- default:
31009
- throw new TypeError("Unknown value type " + valueType);
31010
- }
31011
- if (addType) {
31012
- retObj = {
31013
- path: path3,
31014
- value: val,
31015
- parent,
31016
- parentProperty: parentPropName
31017
- };
31018
- this._handleCallback(retObj, callback, "value");
31019
- return retObj;
31020
- }
31021
- } else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
31022
- const locProp = loc.slice(1);
31023
- addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
31024
- } else if (loc.includes(",")) {
31025
- const parts = loc.split(",");
31026
- for (const part of parts) {
31027
- addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
31028
- }
31029
- } else if (!literalPriority && val && Object.hasOwn(val, loc)) {
31030
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
31031
- }
31032
- if (this._hasParentSelector) {
31033
- for (let t = 0;t < ret.length; t++) {
31034
- const rett = ret[t];
31035
- if (rett && rett.isParentSelector) {
31036
- const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
31037
- if (Array.isArray(tmp)) {
31038
- ret[t] = tmp[0];
31039
- const tl = tmp.length;
31040
- for (let tt = 1;tt < tl; tt++) {
31041
- t++;
31042
- ret.splice(t, 0, tmp[tt]);
31043
- }
31044
- } else {
31045
- ret[t] = tmp;
31046
- }
31047
- }
31048
- }
31049
- }
31050
- return ret;
31051
- };
31052
- JSONPath.prototype._walk = function(val, f) {
31053
- if (Array.isArray(val)) {
31054
- const n = val.length;
31055
- for (let i = 0;i < n; i++) {
31056
- f(i);
31057
- }
31058
- } else if (val && typeof val === "object") {
31059
- Object.keys(val).forEach((m) => {
31060
- f(m);
31061
- });
31062
- }
31063
- };
31064
- JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
31065
- if (!Array.isArray(val)) {
31066
- return;
31067
- }
31068
- const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
31069
- let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
31070
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
31071
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
31072
- const ret = [];
31073
- for (let i = start;i < end; i += step) {
31074
- const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
31075
- tmp.forEach((t) => {
31076
- ret.push(t);
31077
- });
31078
- }
31079
- return ret;
31080
- };
31081
- JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
31082
- this.currSandbox._$_parentProperty = parentPropName;
31083
- this.currSandbox._$_parent = parent;
31084
- this.currSandbox._$_property = _vname;
31085
- this.currSandbox._$_root = this.json;
31086
- this.currSandbox._$_v = _v;
31087
- const containsPath = code.includes("@path");
31088
- if (containsPath) {
31089
- this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
31090
- }
31091
- const scriptCacheKey = this.currEval + "Script:" + code;
31092
- if (!JSONPath.cache[scriptCacheKey]) {
31093
- let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
31094
- if (containsPath) {
31095
- script = script.replaceAll("@path", "_$_path");
31096
- }
31097
- if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
31098
- JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
31099
- } else if (this.currEval === "native") {
31100
- JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
31101
- } else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
31102
- const CurrEval = this.currEval;
31103
- JSONPath.cache[scriptCacheKey] = new CurrEval(script);
31104
- } else if (typeof this.currEval === "function") {
31105
- JSONPath.cache[scriptCacheKey] = {
31106
- runInNewContext: (context) => this.currEval(script, context)
31107
- };
31108
- } else {
31109
- throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
31110
- }
31111
- }
31112
- try {
31113
- return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
31114
- } catch (e) {
31115
- if (this.ignoreEvalErrors) {
31116
- return false;
31117
- }
31118
- throw new Error("jsonPath: " + e.message + ": " + code);
31119
- }
31120
- };
31121
- JSONPath.cache = {};
31122
- JSONPath.toPathString = function(pathArr) {
31123
- const x = pathArr, n = x.length;
31124
- let p = "$";
31125
- for (let i = 1;i < n; i++) {
31126
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
31127
- p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
31128
- }
31129
- }
31130
- return p;
31131
- };
31132
- JSONPath.toPointer = function(pointer) {
31133
- const x = pointer, n = x.length;
31134
- let p = "";
31135
- for (let i = 1;i < n; i++) {
31136
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
31137
- p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
31138
- }
31139
- }
31140
- return p;
31141
- };
31142
- JSONPath.toPathArray = function(expr) {
31143
- const {
31144
- cache
31145
- } = JSONPath;
31146
- if (cache[expr]) {
31147
- return cache[expr].concat();
31148
- }
31149
- const subx = [];
31150
- const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
31151
- return "[#" + (subx.push($1) - 1) + "]";
31152
- }).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
31153
- return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
31154
- }).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
31155
- return ";" + ups.split("").join(";") + ";";
31156
- }).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
31157
- const exprList = normalized.split(";").map(function(exp) {
31158
- const match = exp.match(/#(\d+)/u);
31159
- return !match || !match[1] ? exp : subx[match[1]];
31160
- });
31161
- cache[expr] = exprList;
31162
- return cache[expr].concat();
31163
- };
31164
- JSONPath.prototype.safeVm = {
31165
- Script: SafeScript
31166
- };
31167
- JSONPath.prototype.vm = vm;
31168
30120
  // ../../common/src/polling/types.ts
31169
30121
  var PollOutcome = {
31170
30122
  Completed: "completed",
@@ -31199,6 +30151,17 @@ var FAILURE_STATUSES = new Set([
31199
30151
  "canceled",
31200
30152
  "stopped"
31201
30153
  ]);
30154
+ // ../../common/src/preview.ts
30155
+ var previewSlot = singleton("PreviewBuild");
30156
+ function isPreviewBuild() {
30157
+ return previewSlot.get(false) ?? false;
30158
+ }
30159
+ Command.prototype.previewCommand = function(nameAndArgs, opts) {
30160
+ if (isPreviewBuild()) {
30161
+ return this.command(nameAndArgs, opts);
30162
+ }
30163
+ return new Command(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
30164
+ };
31202
30165
  // ../../common/src/screen-logger.ts
31203
30166
  var ScreenLogger;
31204
30167
  ((ScreenLogger) => {
@@ -32351,3 +31314,5 @@ var program2 = new Command;
32351
31314
  program2.name(metadata.commandPrefix).description(metadata.description).version(metadata.version);
32352
31315
  await registerCommands(program2);
32353
31316
  program2.parse(process.argv);
31317
+
31318
+ //# debugId=D78438686282DB8E64756E2164756E21