@uipath/oms-commands 1.206.0-preview.301 → 1.207.0-preview.305

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 (2) hide show
  1. package/dist/index.js +350 -140
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2127,12 +2127,26 @@ class NodeFileSystem {
2127
2127
  throw error;
2128
2128
  }
2129
2129
  }
2130
- async writeFile(filePath, data) {
2130
+ async writeFile(filePath, data, options) {
2131
2131
  const dir = path.dirname(filePath);
2132
2132
  if (dir) {
2133
2133
  await fs.mkdir(dir, { recursive: true });
2134
2134
  }
2135
- await fs.writeFile(filePath, data);
2135
+ if (options?.mode === undefined || process.platform === "win32") {
2136
+ if (options?.exclusive) {
2137
+ await fs.writeFile(filePath, data, { flag: "wx" });
2138
+ } else {
2139
+ await fs.writeFile(filePath, data);
2140
+ }
2141
+ return;
2142
+ }
2143
+ const handle = await fs.open(filePath, options.exclusive ? "wx" : "w", options.mode);
2144
+ try {
2145
+ await handle.chmod(options.mode);
2146
+ await handle.writeFile(data);
2147
+ } finally {
2148
+ await handle.close();
2149
+ }
2136
2150
  }
2137
2151
  async appendFile(filePath, data) {
2138
2152
  const dir = path.dirname(filePath);
@@ -2167,7 +2181,8 @@ class NodeFileSystem {
2167
2181
  isDirectory: () => stats.isDirectory(),
2168
2182
  size: stats.size,
2169
2183
  mtimeMs: stats.mtimeMs,
2170
- ctimeMs: stats.ctimeMs
2184
+ ctimeMs: stats.ctimeMs,
2185
+ mode: stats.mode
2171
2186
  };
2172
2187
  } catch (error) {
2173
2188
  if (this.isEnoent(error))
@@ -2178,8 +2193,13 @@ class NodeFileSystem {
2178
2193
  async exists(filePath) {
2179
2194
  return existsSync(filePath);
2180
2195
  }
2181
- async mkdir(dirPath) {
2182
- await fs.mkdir(dirPath, { recursive: true });
2196
+ async mkdir(dirPath, options) {
2197
+ await fs.mkdir(dirPath, { recursive: true, mode: options?.mode });
2198
+ }
2199
+ async chmod(targetPath, mode) {
2200
+ if (process.platform === "win32")
2201
+ return;
2202
+ await fs.chmod(targetPath, mode);
2183
2203
  }
2184
2204
  async acquireLock(lockPath) {
2185
2205
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -2329,7 +2349,7 @@ class NodeFileSystem {
2329
2349
  async getTempDir() {
2330
2350
  return await fs.mkdtemp(path.join(os.tmpdir(), "uipath-fs-"));
2331
2351
  }
2332
- async copyDirectory(sourcePath, destPath) {
2352
+ async copyDirectory(sourcePath, destPath, options) {
2333
2353
  const sourceStats = await this.stat(sourcePath);
2334
2354
  if (!sourceStats) {
2335
2355
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -2346,7 +2366,9 @@ class NodeFileSystem {
2346
2366
  if (!entryStats)
2347
2367
  continue;
2348
2368
  if (entryStats.isDirectory()) {
2349
- await this.copyDirectory(srcEntry, destEntry);
2369
+ if (options?.skipDirectoryNames?.includes(entry))
2370
+ continue;
2371
+ await this.copyDirectory(srcEntry, destEntry, options);
2350
2372
  } else if (entryStats.isFile()) {
2351
2373
  const content = await this.readFile(srcEntry);
2352
2374
  if (content !== null) {
@@ -2409,13 +2431,15 @@ var ProjectDimensions = {
2409
2431
  SolutionKey: "SolutionKey",
2410
2432
  SolutionProjectKey: "SolutionProjectKey",
2411
2433
  SolutionIdentityStatus: "SolutionIdentityStatus",
2412
- PreviousSolutionKey: "PreviousSolutionKey"
2434
+ PreviousSolutionKey: "PreviousSolutionKey",
2435
+ PreviousProjectKey: "PreviousProjectKey"
2413
2436
  };
2414
2437
  var GUID_KEY_DIMENSIONS = new Set([
2415
2438
  ProjectDimensions.ProjectKey,
2416
2439
  ProjectDimensions.SolutionKey,
2417
2440
  ProjectDimensions.SolutionProjectKey,
2418
- ProjectDimensions.PreviousSolutionKey
2441
+ ProjectDimensions.PreviousSolutionKey,
2442
+ ProjectDimensions.PreviousProjectKey
2419
2443
  ]);
2420
2444
  var ShipDimensions = {
2421
2445
  ShipKind: "ShipKind",
@@ -2569,9 +2593,7 @@ async function withinProjectIdentityBudget(work, onTimeout) {
2569
2593
  }
2570
2594
  }
2571
2595
 
2572
- // ../../common/src/telemetry/pseudonymize.ts
2573
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2574
- var PSEUDONYM_HEX_LENGTH = 32;
2596
+ // ../../common/src/sha256.ts
2575
2597
  var SHA256_K = new Uint32Array([
2576
2598
  1116352408,
2577
2599
  1899447441,
@@ -2651,7 +2673,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
2651
2673
  function rotr(value, bits) {
2652
2674
  return (value >>> bits | value << 32 - bits) >>> 0;
2653
2675
  }
2654
- function sha256Hex(input) {
2676
+ function sha256Words(input) {
2655
2677
  const bytes = new TextEncoder().encode(input);
2656
2678
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
2657
2679
  const buffer = new Uint8Array(paddedLength);
@@ -2707,12 +2729,19 @@ function sha256Hex(input) {
2707
2729
  state[6] = state[6] + g >>> 0;
2708
2730
  state[7] = state[7] + h >>> 0;
2709
2731
  }
2732
+ return state;
2733
+ }
2734
+ function sha256Hex(input) {
2710
2735
  let hex = "";
2711
- for (const word of state) {
2736
+ for (const word of sha256Words(input)) {
2712
2737
  hex += word.toString(16).padStart(8, "0");
2713
2738
  }
2714
2739
  return hex;
2715
2740
  }
2741
+
2742
+ // ../../common/src/telemetry/pseudonymize.ts
2743
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
2744
+ var PSEUDONYM_HEX_LENGTH = 32;
2716
2745
  function resolveSha256Hex() {
2717
2746
  try {
2718
2747
  const nodeCrypto = __require("node:crypto");
@@ -3108,13 +3137,25 @@ function settlePromiseLike(thenable) {
3108
3137
  return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [toError(error), undefined]);
3109
3138
  }
3110
3139
 
3140
+ // ../../common/src/result-types.ts
3141
+ var RESULTS = {
3142
+ Success: "Success",
3143
+ Failure: "Failure",
3144
+ ConfigError: "ConfigError",
3145
+ AuthenticationError: "AuthenticationError",
3146
+ ValidationError: "ValidationError",
3147
+ TimeoutError: "TimeoutError"
3148
+ };
3149
+
3111
3150
  // ../../common/src/error-codes.ts
3112
3151
  var CLI_ERROR_CODES = [
3113
3152
  "invalid_argument",
3153
+ "confirmation_required",
3114
3154
  "authentication_required",
3115
3155
  "permission_denied",
3116
3156
  "local_permission_denied",
3117
3157
  "not_found",
3158
+ "not_enabled",
3118
3159
  "rate_limited",
3119
3160
  "network_error",
3120
3161
  "timeout",
@@ -3153,6 +3194,12 @@ function carriedRetry(error) {
3153
3194
  const retry = error.retry;
3154
3195
  return isRetryHint(retry) ? retry : undefined;
3155
3196
  }
3197
+ function carriedResult(error) {
3198
+ if (!error || typeof error !== "object")
3199
+ return;
3200
+ const result = error.result;
3201
+ return typeof result === "string" && result !== RESULTS.Success && Object.values(RESULTS).includes(result) ? result : undefined;
3202
+ }
3156
3203
  function defaultRetryForErrorCode(errorCode) {
3157
3204
  switch (errorCode) {
3158
3205
  case "network_error":
@@ -3210,6 +3257,15 @@ function findHttpStatusInGraph(error) {
3210
3257
  }
3211
3258
 
3212
3259
  // ../../common/src/http-status.ts
3260
+ function httpStatusOf(error) {
3261
+ if (!error || typeof error !== "object") {
3262
+ return;
3263
+ }
3264
+ if ("response" in error && error.response && typeof error.response === "object" && "status" in error.response && typeof error.response.status === "number") {
3265
+ return error.response.status;
3266
+ }
3267
+ return "status" in error && typeof error.status === "number" ? error.status : undefined;
3268
+ }
3213
3269
  function classifyHttpStatus(status) {
3214
3270
  if (status === undefined)
3215
3271
  return;
@@ -3542,6 +3598,8 @@ async function extractErrorDetails(error, options) {
3542
3598
  }
3543
3599
  if (parsedBody?.errorCode && typeof parsedBody.errorCode === "string") {
3544
3600
  context.errorCode = parsedBody.errorCode;
3601
+ } else if (typeof parsedBody?.errorCode === "number") {
3602
+ context.errorCode = String(parsedBody.errorCode);
3545
3603
  } else if (parsedBody?.code && typeof parsedBody.code === "string") {
3546
3604
  context.errorCode = parsedBody.code;
3547
3605
  }
@@ -3602,15 +3660,17 @@ async function extractErrorMessage(error, options) {
3602
3660
  const { message } = await extractErrorDetails(error, options);
3603
3661
  return message;
3604
3662
  }
3605
- // ../../common/src/result-types.ts
3606
- var RESULTS = {
3607
- Success: "Success",
3608
- Failure: "Failure",
3609
- ConfigError: "ConfigError",
3610
- AuthenticationError: "AuthenticationError",
3611
- ValidationError: "ValidationError",
3612
- TimeoutError: "TimeoutError"
3613
- };
3663
+ // ../../common/src/classified-failure.ts
3664
+ function notSupportedFailure(operation, instructions, context) {
3665
+ return {
3666
+ Result: RESULTS.Failure,
3667
+ ErrorCode: "not_supported",
3668
+ Message: `${operation} isn't supported on the connected environment.`,
3669
+ Instructions: instructions,
3670
+ Retry: "RetryWillNotFix",
3671
+ ...context ? { Context: context } : {}
3672
+ };
3673
+ }
3614
3674
  // ../../../node_modules/commander/index.js
3615
3675
  var exports_commander = {};
3616
3676
  __exportCjs(exports_commander, {
@@ -4043,7 +4103,10 @@ var AUTH_ERROR_CODES = new Set([
4043
4103
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
4044
4104
  "local_permission_denied"
4045
4105
  ]);
4046
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
4106
+ var VALIDATION_ERROR_CODES = new Set([
4107
+ "invalid_argument",
4108
+ "confirmation_required"
4109
+ ]);
4047
4110
  var NETWORK_HTTP_ERROR_CODES = new Set([
4048
4111
  "network_error",
4049
4112
  "rate_limited",
@@ -4269,6 +4332,109 @@ var CommonTelemetryEvents = {
4269
4332
  ShipSucceeded: "Cli.ShipSucceeded"
4270
4333
  };
4271
4334
 
4335
+ // ../../common/src/telemetry/global-telemetry-properties.ts
4336
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4337
+ function getGlobalTelemetryProperties() {
4338
+ return telemetryPropsSlot.get();
4339
+ }
4340
+
4341
+ // ../../common/src/telemetry/trace-context.ts
4342
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
4343
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
4344
+ function getProcessEnv() {
4345
+ return globalThis.process?.env;
4346
+ }
4347
+ function parseInboundTraceparent(value) {
4348
+ if (!value) {
4349
+ return;
4350
+ }
4351
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
4352
+ if (!match) {
4353
+ return;
4354
+ }
4355
+ const [, traceId, parentSpanId] = match;
4356
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
4357
+ return;
4358
+ }
4359
+ return { traceId, parentSpanId };
4360
+ }
4361
+ function getInboundTraceContext() {
4362
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
4363
+ }
4364
+
4365
+ // ../../common/src/telemetry/session-id.ts
4366
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
4367
+ var SESSION_ID_MAX_LENGTH = 64;
4368
+ var RANDOM_SESSION_ID_LENGTH = 32;
4369
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
4370
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
4371
+ var INHERITED_SESSION_SOURCES = [
4372
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
4373
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
4374
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
4375
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
4376
+ { envVar: "WT_SESSION", source: "terminal" }
4377
+ ];
4378
+ var telemetrySessionSlot = singleton("TelemetrySession");
4379
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
4380
+ function getProcessEnv2() {
4381
+ return globalThis.process?.env;
4382
+ }
4383
+ function normalizeSessionId(value) {
4384
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
4385
+ return;
4386
+ }
4387
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4388
+ return cleaned || undefined;
4389
+ }
4390
+ function getConfiguredTelemetrySessionId() {
4391
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4392
+ }
4393
+ function getInheritedSession(env) {
4394
+ for (const candidate of INHERITED_SESSION_SOURCES) {
4395
+ const handle = normalizeSessionId(env[candidate.envVar]);
4396
+ if (handle) {
4397
+ return { id: handle, source: candidate.source };
4398
+ }
4399
+ }
4400
+ return;
4401
+ }
4402
+ function generateRandomSession() {
4403
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4404
+ crypto.getRandomValues(bytes);
4405
+ let hex = "";
4406
+ for (const byte of bytes) {
4407
+ hex += byte.toString(16).padStart(2, "0");
4408
+ }
4409
+ return { id: hex, source: "random" };
4410
+ }
4411
+ function resolveTelemetrySession() {
4412
+ const existing = telemetrySessionSlot.get();
4413
+ if (existing) {
4414
+ return existing;
4415
+ }
4416
+ const declaredHandle = getConfiguredTelemetrySessionId();
4417
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4418
+ telemetrySessionSlot.set(resolved);
4419
+ return resolved;
4420
+ }
4421
+ function getTelemetrySessionId() {
4422
+ return resolveTelemetrySession().id;
4423
+ }
4424
+ function getTelemetrySessionSource() {
4425
+ return resolveTelemetrySession().source;
4426
+ }
4427
+ function getTelemetryOperationId() {
4428
+ const existing = telemetryOperationIdSlot.get();
4429
+ if (existing) {
4430
+ return existing;
4431
+ }
4432
+ const inboundTraceId = getInboundTraceContext()?.traceId;
4433
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4434
+ telemetryOperationIdSlot.set(generated);
4435
+ return generated;
4436
+ }
4437
+
4272
4438
  // ../../common/src/registry.ts
4273
4439
  import { execFileSync } from "node:child_process";
4274
4440
  function readRegistryValue(keyPath, valueName) {
@@ -4490,108 +4656,6 @@ class NodeContextStorage {
4490
4656
  return this.storage.getStore();
4491
4657
  }
4492
4658
  }
4493
- // ../../common/src/telemetry/trace-context.ts
4494
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
4495
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
4496
- function getProcessEnv() {
4497
- return globalThis.process?.env;
4498
- }
4499
- function parseInboundTraceparent(value) {
4500
- if (!value) {
4501
- return;
4502
- }
4503
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
4504
- if (!match) {
4505
- return;
4506
- }
4507
- const [, traceId, parentSpanId] = match;
4508
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
4509
- return;
4510
- }
4511
- return { traceId, parentSpanId };
4512
- }
4513
- function getInboundTraceContext() {
4514
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
4515
- }
4516
-
4517
- // ../../common/src/telemetry/session-id.ts
4518
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
4519
- var SESSION_ID_MAX_LENGTH = 64;
4520
- var RANDOM_SESSION_ID_LENGTH = 32;
4521
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
4522
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
4523
- var INHERITED_SESSION_SOURCES = [
4524
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
4525
- { envVar: "CODEX_THREAD_ID", source: "codex" },
4526
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
4527
- { envVar: "TERM_SESSION_ID", source: "terminal" },
4528
- { envVar: "WT_SESSION", source: "terminal" }
4529
- ];
4530
- var telemetrySessionSlot = singleton("TelemetrySession");
4531
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
4532
- function getProcessEnv2() {
4533
- return globalThis.process?.env;
4534
- }
4535
- function normalizeSessionId(value) {
4536
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
4537
- return;
4538
- }
4539
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
4540
- return cleaned || undefined;
4541
- }
4542
- function getConfiguredTelemetrySessionId() {
4543
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
4544
- }
4545
- function getInheritedSession(env) {
4546
- for (const candidate of INHERITED_SESSION_SOURCES) {
4547
- const handle = normalizeSessionId(env[candidate.envVar]);
4548
- if (handle) {
4549
- return { id: handle, source: candidate.source };
4550
- }
4551
- }
4552
- return;
4553
- }
4554
- function generateRandomSession() {
4555
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
4556
- crypto.getRandomValues(bytes);
4557
- let hex = "";
4558
- for (const byte of bytes) {
4559
- hex += byte.toString(16).padStart(2, "0");
4560
- }
4561
- return { id: hex, source: "random" };
4562
- }
4563
- function resolveTelemetrySession() {
4564
- const existing = telemetrySessionSlot.get();
4565
- if (existing) {
4566
- return existing;
4567
- }
4568
- const declaredHandle = getConfiguredTelemetrySessionId();
4569
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
4570
- telemetrySessionSlot.set(resolved);
4571
- return resolved;
4572
- }
4573
- function getTelemetrySessionId() {
4574
- return resolveTelemetrySession().id;
4575
- }
4576
- function getTelemetrySessionSource() {
4577
- return resolveTelemetrySession().source;
4578
- }
4579
- function getTelemetryOperationId() {
4580
- const existing = telemetryOperationIdSlot.get();
4581
- if (existing) {
4582
- return existing;
4583
- }
4584
- const inboundTraceId = getInboundTraceContext()?.traceId;
4585
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
4586
- telemetryOperationIdSlot.set(generated);
4587
- return generated;
4588
- }
4589
- // ../../common/src/telemetry/global-telemetry-properties.ts
4590
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
4591
- function getGlobalTelemetryProperties() {
4592
- return telemetryPropsSlot.get();
4593
- }
4594
-
4595
4659
  // ../../common/src/telemetry/span-clock.ts
4596
4660
  function startSpanClock() {
4597
4661
  const started = performance.now();
@@ -4805,6 +4869,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
4805
4869
  // ../../common/src/telemetry/telemetry-init.ts
4806
4870
  var telemetryInstanceSlot = singleton("TelemetryService");
4807
4871
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
4872
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
4808
4873
  function getGlobalTelemetryInstance() {
4809
4874
  const existing = telemetryInstanceSlot.get();
4810
4875
  if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
@@ -4988,7 +5053,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
4988
5053
  const pagedRows = extractPagedRows(data.Data);
4989
5054
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
4990
5055
  items.forEach((item) => {
4991
- const values = Object.values(item).map((v) => v ?? "").join("\t");
5056
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
4992
5057
  logFn(values);
4993
5058
  });
4994
5059
  } else {
@@ -5003,7 +5068,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
5003
5068
  default: {
5004
5069
  const hasData = "Data" in data && data.Data != null;
5005
5070
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
5006
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
5071
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
5072
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
5007
5073
  if (hasData && !(rows !== null && rows.length === 0)) {
5008
5074
  const logValue = data.Log;
5009
5075
  if (rows !== null) {
@@ -5060,6 +5126,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
5060
5126
  function isPlainObjectArray(value) {
5061
5127
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
5062
5128
  }
5129
+ function isPrimitiveArray(value) {
5130
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
5131
+ }
5063
5132
  function isNonEmptyPlainObject(value) {
5064
5133
  return isPlainRecord(value) && Object.keys(value).length > 0;
5065
5134
  }
@@ -5406,12 +5475,12 @@ class FilterEvaluationError extends Error {
5406
5475
  instructions;
5407
5476
  retry = "RetryWillNotFix";
5408
5477
  result = RESULTS.ValidationError;
5409
- constructor(filter, cause) {
5478
+ constructor(filter, cause, hint) {
5410
5479
  const underlying = cause instanceof Error ? cause.message : String(cause);
5411
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
5480
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
5412
5481
  this.name = "FilterEvaluationError";
5413
5482
  this.filter = filter;
5414
- this.instructions = `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
5483
+ this.instructions = (hint ? `${hint.instructions} ` : "") + `The --output-filter expression '${filter}' failed at evaluation time. ` + "Note that --output-filter operates on the 'Data' field of the envelope, not the full object. " + "For example, on a list result use 'length(@)' instead of 'Data | length(@)'.";
5415
5484
  }
5416
5485
  }
5417
5486
 
@@ -5533,6 +5602,93 @@ function nameList(names, cap = 12) {
5533
5602
  const rest = names.length - shown.length;
5534
5603
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
5535
5604
  }
5605
+ function notFieldsOn(names, scope) {
5606
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5607
+ }
5608
+ function failingFieldRead(ast, isList, fn, argIndex) {
5609
+ const [left, right, condition] = ast.children ?? [];
5610
+ let scopes = [];
5611
+ if (!isList) {
5612
+ scopes = [ast];
5613
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
5614
+ scopes = [condition, right];
5615
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
5616
+ scopes = [right];
5617
+ }
5618
+ const reads = new Set;
5619
+ let tracked = 0;
5620
+ const visit = (node) => {
5621
+ if (!node)
5622
+ return;
5623
+ switch (node.type) {
5624
+ case "Function": {
5625
+ const arg = node.children?.[argIndex - 1];
5626
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
5627
+ reads.add(arg.name);
5628
+ tracked++;
5629
+ }
5630
+ node.children?.forEach(visit);
5631
+ return;
5632
+ }
5633
+ case "AndExpression":
5634
+ case "OrExpression":
5635
+ case "NotExpression":
5636
+ case "Comparator":
5637
+ case "MultiSelectList":
5638
+ case "MultiSelectHash":
5639
+ node.children?.forEach(visit);
5640
+ return;
5641
+ case "KeyValuePair":
5642
+ visit(node.value);
5643
+ return;
5644
+ }
5645
+ };
5646
+ scopes.forEach(visit);
5647
+ const calls = (node) => {
5648
+ if (node === null || typeof node !== "object")
5649
+ return 0;
5650
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
5651
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
5652
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
5653
+ };
5654
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
5655
+ }
5656
+ function fieldExpression(name) {
5657
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
5658
+ }
5659
+ function evaluationHint(codec, filter, data, cause) {
5660
+ const underlying = cause instanceof Error ? cause.message : String(cause);
5661
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
5662
+ if (!failure)
5663
+ return;
5664
+ const [, fn, position, expected] = failure;
5665
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
5666
+ if (name === undefined)
5667
+ return;
5668
+ const present = availableFields(data);
5669
+ if (present.length === 0)
5670
+ return;
5671
+ const scope = `${countRecords(data)} record(s)`;
5672
+ if (!present.includes(name)) {
5673
+ return {
5674
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
5675
+ instructions: "Use a field the records have; names are case-sensitive."
5676
+ };
5677
+ }
5678
+ const records = Array.isArray(data) ? data : [data];
5679
+ const unset = records.filter((r) => r?.[name] == null).length;
5680
+ const field = fieldExpression(name);
5681
+ let fallback;
5682
+ if (expected.split(",").includes("string")) {
5683
+ fallback = "''";
5684
+ } else if (expected.split(",").includes("array")) {
5685
+ fallback = "`[]`";
5686
+ }
5687
+ return {
5688
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
5689
+ instructions: fallback ? `Give it a default where ${fn}() reads it, e.g. \`${field} || ${fallback}\`.` : `Filter out the records where \`${name}\` is null before ${fn}() reads it.`
5690
+ };
5691
+ }
5536
5692
  function buildFilterWarning(filter, data, outcome) {
5537
5693
  const present = availableFields(data);
5538
5694
  const refs = referencedFields(filter);
@@ -5540,7 +5696,7 @@ function buildFilterWarning(filter, data, outcome) {
5540
5696
  const unchecked = refs.nested.filter((name) => !present.includes(name));
5541
5697
  const count = countRecords(data);
5542
5698
  const scope = `${count} record(s)`;
5543
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
5699
+ const isNotAField = (names) => notFieldsOn(names, scope);
5544
5700
  const soundness = unchecked.length > 0 ? `${nameList(unchecked)} ${unchecked.length === 1 ? "reads" : "read"} below the top level, so ${unchecked.length === 1 ? "it was" : "they were"} not checked against the record keys` : refs.top.length > 0 ? "every field it names exists" : "";
5545
5701
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
5546
5702
  let detail;
@@ -5591,7 +5747,8 @@ function applyFilter(data, filter, onWarning) {
5591
5747
  try {
5592
5748
  result = codec.search(data, filter);
5593
5749
  } catch (err) {
5594
- throw new FilterEvaluationError(filter, err);
5750
+ const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
5751
+ throw new FilterEvaluationError(filter, err, hint);
5595
5752
  }
5596
5753
  const inputCount = countRecords(data);
5597
5754
  const warn = (outcome) => {
@@ -6482,7 +6639,7 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
6482
6639
  logger.debug(`[trackedAction] ${telemetryName} failed: ${errorMessage}`);
6483
6640
  const typed = error;
6484
6641
  const customInstructions = typeof typed.instructions === "string" ? typed.instructions : undefined;
6485
- const customResult = typeof typed.result === "string" && typed.result !== RESULTS.Success && Object.values(RESULTS).includes(typed.result) ? typed.result : undefined;
6642
+ const customResult = carriedResult(error);
6486
6643
  const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
6487
6644
  const classified = cancellationExitCode === undefined ? await extractErrorDetails(error) : undefined;
6488
6645
  const finalResult = customResult ?? classified?.result ?? RESULTS.Failure;
@@ -6844,6 +7001,8 @@ var FAILURE_STATUSES = new Set([
6844
7001
  "canceled",
6845
7002
  "stopped"
6846
7003
  ]);
7004
+ // ../../common/src/relayed-output.ts
7005
+ var RELAYED_OUTPUT_SYMBOL = Symbol.for("@uipath/common/relayed-output");
6847
7006
  // ../../common/src/screen-logger.ts
6848
7007
  var ScreenLogger;
6849
7008
  ((ScreenLogger) => {
@@ -7651,7 +7810,7 @@ var package_default = {
7651
7810
  name: "@uipath/oms-sdk",
7652
7811
  author: "UiPath",
7653
7812
  license: "SEE LICENSE IN LICENSE.txt",
7654
- version: "1.206.0",
7813
+ version: "1.207.0",
7655
7814
  description: "SDK for the UiPath Organization Management Service API.",
7656
7815
  repository: {
7657
7816
  type: "git",
@@ -9433,6 +9592,8 @@ function settlePromiseLike2(thenable) {
9433
9592
  // ../../auth/src/constants.ts
9434
9593
  var UIPATH_HOME_DIR = ".uipath";
9435
9594
  var AUTH_FILENAME = ".auth";
9595
+ var AUTH_FILE_MODE = 384;
9596
+ var AUTH_DIR_MODE = 448;
9436
9597
  var DEFAULT_BASE_URL = "https://cloud.uipath.com";
9437
9598
  var DEFAULT_AUTH_TIMEOUT_MS2 = 5 * 60 * 1000;
9438
9599
 
@@ -10256,6 +10417,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
10256
10417
  }
10257
10418
  return parseEnvContent(content);
10258
10419
  };
10420
+ var findAuthHomeDir = (fs, dir) => {
10421
+ let current = dir;
10422
+ for (;; ) {
10423
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
10424
+ return current;
10425
+ const parent = fs.path.dirname(current);
10426
+ if (parent === current)
10427
+ return;
10428
+ current = parent;
10429
+ }
10430
+ };
10431
+ var TEMP_FILE_ATTEMPTS = 5;
10432
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
10433
+ var writeTempFile = async (fs, targetPath, content) => {
10434
+ for (let attempt = 1;; attempt++) {
10435
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
10436
+ try {
10437
+ await fs.writeFile(tempPath, content, {
10438
+ mode: AUTH_FILE_MODE,
10439
+ exclusive: true
10440
+ });
10441
+ return tempPath;
10442
+ } catch (error) {
10443
+ if (!isFileExists(error)) {
10444
+ await fs.rm(tempPath).catch(() => {});
10445
+ throw error;
10446
+ }
10447
+ if (attempt === TEMP_FILE_ATTEMPTS)
10448
+ throw error;
10449
+ }
10450
+ }
10451
+ };
10259
10452
  var saveEnvFileAsync = async ({
10260
10453
  envPath,
10261
10454
  data,
@@ -10283,10 +10476,18 @@ var saveEnvFileAsync = async ({
10283
10476
  `)}
10284
10477
  `;
10285
10478
  const dir = fs.path.dirname(absolutePath);
10286
- await fs.mkdir(dir);
10287
- const tempPath = `${absolutePath}.tmp`;
10288
- await fs.writeFile(tempPath, content);
10289
- await fs.rename(tempPath, absolutePath);
10479
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
10480
+ const authHomeDir = findAuthHomeDir(fs, dir);
10481
+ if (authHomeDir !== undefined) {
10482
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
10483
+ }
10484
+ const tempPath = await writeTempFile(fs, absolutePath, content);
10485
+ try {
10486
+ await fs.rename(tempPath, absolutePath);
10487
+ } catch (error) {
10488
+ await fs.rm(tempPath).catch(() => {});
10489
+ throw error;
10490
+ }
10290
10491
  };
10291
10492
 
10292
10493
  // ../../auth/src/loginStatus.ts
@@ -11175,6 +11376,7 @@ var registerOrgServicesCommands = (organizations) => {
11175
11376
  });
11176
11377
  });
11177
11378
  };
11379
+ var REGIONS_NOT_SUPPORTED_INSTRUCTIONS = "The connected environment does not serve the list of regions an organization can be provisioned in. Read it from an environment that offers multi-region provisioning.";
11178
11380
  var registerRegionsCommands = (organizations) => {
11179
11381
  const regions = organizations.command("regions").description("Inspect the regions in which Portal can be provisioned. Use the `list` subcommand.");
11180
11382
  withLoginValidity(regions.command("list").description("List the regions in which Portal can be provisioned for the caller's company.").examples(REGIONS_EXAMPLES)).trackedAction(processContext, async (options) => {
@@ -11182,6 +11384,14 @@ var registerRegionsCommands = (organizations) => {
11182
11384
  if (!client)
11183
11385
  return;
11184
11386
  const [error, result] = await catchError(client.api.organizationGetAllSupportedRegions());
11387
+ if (httpStatusOf(error) === 404) {
11388
+ OutputFormatter.error({
11389
+ Code: "OmsRegionsList",
11390
+ ...notSupportedFailure("Listing provisionable regions", REGIONS_NOT_SUPPORTED_INSTRUCTIONS, { httpStatus: 404 })
11391
+ });
11392
+ processContext.exit(1);
11393
+ return;
11394
+ }
11185
11395
  if (error) {
11186
11396
  await emitFailure(error, LOGIN_INSTRUCTIONS);
11187
11397
  return;
@@ -12116,4 +12326,4 @@ export {
12116
12326
  registerCommands
12117
12327
  };
12118
12328
 
12119
- //# debugId=FA85D6A00C94D69E64756E2164756E21
12329
+ //# debugId=22D7A5F5868EB85564756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/oms-commands",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.301",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "Admin CLI commands for the UiPath Organization Management Service. Library composed by admin-tool, not a standalone CLI tool.",
7
7
  "private": false,
8
8
  "repository": {
@@ -26,5 +26,5 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "gitHead": "078afc3ef7ebf4c38353ee0059e321acf16a350d"
29
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
30
30
  }