@uipath/common 1.206.0-preview.306 → 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.
package/dist/testing.js CHANGED
@@ -694,12 +694,26 @@ class NodeFileSystem {
694
694
  throw error;
695
695
  }
696
696
  }
697
- async writeFile(filePath, data) {
697
+ async writeFile(filePath, data, options) {
698
698
  const dir = path2.dirname(filePath);
699
699
  if (dir) {
700
700
  await fs6.mkdir(dir, { recursive: true });
701
701
  }
702
- await fs6.writeFile(filePath, data);
702
+ if (options?.mode === undefined || process.platform === "win32") {
703
+ if (options?.exclusive) {
704
+ await fs6.writeFile(filePath, data, { flag: "wx" });
705
+ } else {
706
+ await fs6.writeFile(filePath, data);
707
+ }
708
+ return;
709
+ }
710
+ const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
711
+ try {
712
+ await handle.chmod(options.mode);
713
+ await handle.writeFile(data);
714
+ } finally {
715
+ await handle.close();
716
+ }
703
717
  }
704
718
  async appendFile(filePath, data) {
705
719
  const dir = path2.dirname(filePath);
@@ -734,7 +748,8 @@ class NodeFileSystem {
734
748
  isDirectory: () => stats.isDirectory(),
735
749
  size: stats.size,
736
750
  mtimeMs: stats.mtimeMs,
737
- ctimeMs: stats.ctimeMs
751
+ ctimeMs: stats.ctimeMs,
752
+ mode: stats.mode
738
753
  };
739
754
  } catch (error) {
740
755
  if (this.isEnoent(error))
@@ -745,8 +760,13 @@ class NodeFileSystem {
745
760
  async exists(filePath) {
746
761
  return existsSync(filePath);
747
762
  }
748
- async mkdir(dirPath) {
749
- await fs6.mkdir(dirPath, { recursive: true });
763
+ async mkdir(dirPath, options) {
764
+ await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
765
+ }
766
+ async chmod(targetPath, mode) {
767
+ if (process.platform === "win32")
768
+ return;
769
+ await fs6.chmod(targetPath, mode);
750
770
  }
751
771
  async acquireLock(lockPath) {
752
772
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -896,7 +916,7 @@ class NodeFileSystem {
896
916
  async getTempDir() {
897
917
  return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
898
918
  }
899
- async copyDirectory(sourcePath, destPath) {
919
+ async copyDirectory(sourcePath, destPath, options) {
900
920
  const sourceStats = await this.stat(sourcePath);
901
921
  if (!sourceStats) {
902
922
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -913,7 +933,9 @@ class NodeFileSystem {
913
933
  if (!entryStats)
914
934
  continue;
915
935
  if (entryStats.isDirectory()) {
916
- await this.copyDirectory(srcEntry, destEntry);
936
+ if (options?.skipDirectoryNames?.includes(entry))
937
+ continue;
938
+ await this.copyDirectory(srcEntry, destEntry, options);
917
939
  } else if (entryStats.isFile()) {
918
940
  const content = await this.readFile(srcEntry);
919
941
  if (content !== null) {
@@ -976,13 +998,15 @@ var ProjectDimensions = {
976
998
  SolutionKey: "SolutionKey",
977
999
  SolutionProjectKey: "SolutionProjectKey",
978
1000
  SolutionIdentityStatus: "SolutionIdentityStatus",
979
- PreviousSolutionKey: "PreviousSolutionKey"
1001
+ PreviousSolutionKey: "PreviousSolutionKey",
1002
+ PreviousProjectKey: "PreviousProjectKey"
980
1003
  };
981
1004
  var GUID_KEY_DIMENSIONS = new Set([
982
1005
  ProjectDimensions.ProjectKey,
983
1006
  ProjectDimensions.SolutionKey,
984
1007
  ProjectDimensions.SolutionProjectKey,
985
- ProjectDimensions.PreviousSolutionKey
1008
+ ProjectDimensions.PreviousSolutionKey,
1009
+ ProjectDimensions.PreviousProjectKey
986
1010
  ]);
987
1011
  var ShipDimensions = {
988
1012
  ShipKind: "ShipKind",
@@ -1108,9 +1132,7 @@ function projectKey(id) {
1108
1132
  return /^[0-9a-f]{32}$/.test(key) ? key : undefined;
1109
1133
  }
1110
1134
 
1111
- // src/telemetry/pseudonymize.ts
1112
- var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
1113
- var PSEUDONYM_HEX_LENGTH = 32;
1135
+ // src/sha256.ts
1114
1136
  var SHA256_K = new Uint32Array([
1115
1137
  1116352408,
1116
1138
  1899447441,
@@ -1190,7 +1212,7 @@ var SHA256_INITIAL_STATE = new Uint32Array([
1190
1212
  function rotr(value, bits) {
1191
1213
  return (value >>> bits | value << 32 - bits) >>> 0;
1192
1214
  }
1193
- function sha256Hex(input) {
1215
+ function sha256Words(input) {
1194
1216
  const bytes = new TextEncoder().encode(input);
1195
1217
  const paddedLength = bytes.length + 9 + 63 >> 6 << 6;
1196
1218
  const buffer = new Uint8Array(paddedLength);
@@ -1246,12 +1268,19 @@ function sha256Hex(input) {
1246
1268
  state[6] = state[6] + g >>> 0;
1247
1269
  state[7] = state[7] + h >>> 0;
1248
1270
  }
1271
+ return state;
1272
+ }
1273
+ function sha256Hex(input) {
1249
1274
  let hex = "";
1250
- for (const word of state) {
1275
+ for (const word of sha256Words(input)) {
1251
1276
  hex += word.toString(16).padStart(8, "0");
1252
1277
  }
1253
1278
  return hex;
1254
1279
  }
1280
+
1281
+ // src/telemetry/pseudonymize.ts
1282
+ var PSEUDONYM_DOMAIN = "uipath-cli/telemetry/pseudonym/v1:";
1283
+ var PSEUDONYM_HEX_LENGTH = 32;
1255
1284
  function resolveSha256Hex() {
1256
1285
  try {
1257
1286
  const nodeCrypto = __require("node:crypto");
@@ -1906,13 +1935,25 @@ function setExitCode(code) {
1906
1935
  recordExitCode(code);
1907
1936
  }
1908
1937
 
1938
+ // src/result-types.ts
1939
+ var RESULTS = {
1940
+ Success: "Success",
1941
+ Failure: "Failure",
1942
+ ConfigError: "ConfigError",
1943
+ AuthenticationError: "AuthenticationError",
1944
+ ValidationError: "ValidationError",
1945
+ TimeoutError: "TimeoutError"
1946
+ };
1947
+
1909
1948
  // src/error-codes.ts
1910
1949
  var CLI_ERROR_CODES = [
1911
1950
  "invalid_argument",
1951
+ "confirmation_required",
1912
1952
  "authentication_required",
1913
1953
  "permission_denied",
1914
1954
  "local_permission_denied",
1915
1955
  "not_found",
1956
+ "not_enabled",
1916
1957
  "rate_limited",
1917
1958
  "network_error",
1918
1959
  "timeout",
@@ -2017,16 +2058,6 @@ function getOutputFilter() {
2017
2058
  return filterSlot.get();
2018
2059
  }
2019
2060
 
2020
- // src/result-types.ts
2021
- var RESULTS = {
2022
- Success: "Success",
2023
- Failure: "Failure",
2024
- ConfigError: "ConfigError",
2025
- AuthenticationError: "AuthenticationError",
2026
- ValidationError: "ValidationError",
2027
- TimeoutError: "TimeoutError"
2028
- };
2029
-
2030
2061
  // src/telemetry/command-terminal.ts
2031
2062
  var recordedFailureSlot = singleton("CommandTelemetryFailure");
2032
2063
  var AUTH_ERROR_CODES = new Set([
@@ -2036,7 +2067,10 @@ var AUTH_ERROR_CODES = new Set([
2036
2067
  var LOCAL_PERMISSION_CLI_ERROR_CODES = new Set([
2037
2068
  "local_permission_denied"
2038
2069
  ]);
2039
- var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
2070
+ var VALIDATION_ERROR_CODES = new Set([
2071
+ "invalid_argument",
2072
+ "confirmation_required"
2073
+ ]);
2040
2074
  var NETWORK_HTTP_ERROR_CODES = new Set([
2041
2075
  "network_error",
2042
2076
  "rate_limited",
@@ -2088,6 +2122,109 @@ var CommonTelemetryEvents = {
2088
2122
  ShipSucceeded: "Cli.ShipSucceeded"
2089
2123
  };
2090
2124
 
2125
+ // src/telemetry/global-telemetry-properties.ts
2126
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
2127
+ function getGlobalTelemetryProperties() {
2128
+ return telemetryPropsSlot.get();
2129
+ }
2130
+
2131
+ // src/telemetry/trace-context.ts
2132
+ var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
2133
+ var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
2134
+ function getProcessEnv() {
2135
+ return globalThis.process?.env;
2136
+ }
2137
+ function parseInboundTraceparent(value) {
2138
+ if (!value) {
2139
+ return;
2140
+ }
2141
+ const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
2142
+ if (!match) {
2143
+ return;
2144
+ }
2145
+ const [, traceId, parentSpanId] = match;
2146
+ if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
2147
+ return;
2148
+ }
2149
+ return { traceId, parentSpanId };
2150
+ }
2151
+ function getInboundTraceContext() {
2152
+ return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
2153
+ }
2154
+
2155
+ // src/telemetry/session-id.ts
2156
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
2157
+ var SESSION_ID_MAX_LENGTH = 64;
2158
+ var RANDOM_SESSION_ID_LENGTH = 32;
2159
+ var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
2160
+ var CONTROL_CHARACTERS = /\p{Cc}/gu;
2161
+ var INHERITED_SESSION_SOURCES = [
2162
+ { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
2163
+ { envVar: "CODEX_THREAD_ID", source: "codex" },
2164
+ { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
2165
+ { envVar: "TERM_SESSION_ID", source: "terminal" },
2166
+ { envVar: "WT_SESSION", source: "terminal" }
2167
+ ];
2168
+ var telemetrySessionSlot = singleton("TelemetrySession");
2169
+ var telemetryOperationIdSlot = singleton("TelemetryOperationId");
2170
+ function getProcessEnv2() {
2171
+ return globalThis.process?.env;
2172
+ }
2173
+ function normalizeSessionId(value) {
2174
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
2175
+ return;
2176
+ }
2177
+ const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
2178
+ return cleaned || undefined;
2179
+ }
2180
+ function getConfiguredTelemetrySessionId() {
2181
+ return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
2182
+ }
2183
+ function getInheritedSession(env) {
2184
+ for (const candidate of INHERITED_SESSION_SOURCES) {
2185
+ const handle = normalizeSessionId(env[candidate.envVar]);
2186
+ if (handle) {
2187
+ return { id: handle, source: candidate.source };
2188
+ }
2189
+ }
2190
+ return;
2191
+ }
2192
+ function generateRandomSession() {
2193
+ const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
2194
+ crypto.getRandomValues(bytes);
2195
+ let hex = "";
2196
+ for (const byte of bytes) {
2197
+ hex += byte.toString(16).padStart(2, "0");
2198
+ }
2199
+ return { id: hex, source: "random" };
2200
+ }
2201
+ function resolveTelemetrySession() {
2202
+ const existing = telemetrySessionSlot.get();
2203
+ if (existing) {
2204
+ return existing;
2205
+ }
2206
+ const declaredHandle = getConfiguredTelemetrySessionId();
2207
+ const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
2208
+ telemetrySessionSlot.set(resolved);
2209
+ return resolved;
2210
+ }
2211
+ function getTelemetrySessionId() {
2212
+ return resolveTelemetrySession().id;
2213
+ }
2214
+ function getTelemetrySessionSource() {
2215
+ return resolveTelemetrySession().source;
2216
+ }
2217
+ function getTelemetryOperationId() {
2218
+ const existing = telemetryOperationIdSlot.get();
2219
+ if (existing) {
2220
+ return existing;
2221
+ }
2222
+ const inboundTraceId = getInboundTraceContext()?.traceId;
2223
+ const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
2224
+ telemetryOperationIdSlot.set(generated);
2225
+ return generated;
2226
+ }
2227
+
2091
2228
  // src/registry.ts
2092
2229
  import { execFileSync as execFileSync2 } from "node:child_process";
2093
2230
  function readRegistryValue(keyPath, valueName) {
@@ -2309,108 +2446,6 @@ class NodeContextStorage {
2309
2446
  return this.storage.getStore();
2310
2447
  }
2311
2448
  }
2312
- // src/telemetry/trace-context.ts
2313
- var TELEMETRY_TRACEPARENT_ENV = "TRACEPARENT";
2314
- var TRACEPARENT_PATTERN = /^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/;
2315
- function getProcessEnv() {
2316
- return globalThis.process?.env;
2317
- }
2318
- function parseInboundTraceparent(value) {
2319
- if (!value) {
2320
- return;
2321
- }
2322
- const match = TRACEPARENT_PATTERN.exec(value.trim().toLowerCase());
2323
- if (!match) {
2324
- return;
2325
- }
2326
- const [, traceId, parentSpanId] = match;
2327
- if (/^0+$/.test(traceId) || /^0+$/.test(parentSpanId)) {
2328
- return;
2329
- }
2330
- return { traceId, parentSpanId };
2331
- }
2332
- function getInboundTraceContext() {
2333
- return parseInboundTraceparent(getProcessEnv()?.[TELEMETRY_TRACEPARENT_ENV]);
2334
- }
2335
-
2336
- // src/telemetry/session-id.ts
2337
- var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
2338
- var SESSION_ID_MAX_LENGTH = 64;
2339
- var RANDOM_SESSION_ID_LENGTH = 32;
2340
- var TELEMETRY_SESSION_SOURCE_PROPERTY = "SessionIdSource";
2341
- var CONTROL_CHARACTERS = /\p{Cc}/gu;
2342
- var INHERITED_SESSION_SOURCES = [
2343
- { envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
2344
- { envVar: "CODEX_THREAD_ID", source: "codex" },
2345
- { envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
2346
- { envVar: "TERM_SESSION_ID", source: "terminal" },
2347
- { envVar: "WT_SESSION", source: "terminal" }
2348
- ];
2349
- var telemetrySessionSlot = singleton("TelemetrySession");
2350
- var telemetryOperationIdSlot = singleton("TelemetryOperationId");
2351
- function getProcessEnv2() {
2352
- return globalThis.process?.env;
2353
- }
2354
- function normalizeSessionId(value) {
2355
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
2356
- return;
2357
- }
2358
- const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
2359
- return cleaned || undefined;
2360
- }
2361
- function getConfiguredTelemetrySessionId() {
2362
- return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
2363
- }
2364
- function getInheritedSession(env) {
2365
- for (const candidate of INHERITED_SESSION_SOURCES) {
2366
- const handle = normalizeSessionId(env[candidate.envVar]);
2367
- if (handle) {
2368
- return { id: handle, source: candidate.source };
2369
- }
2370
- }
2371
- return;
2372
- }
2373
- function generateRandomSession() {
2374
- const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
2375
- crypto.getRandomValues(bytes);
2376
- let hex = "";
2377
- for (const byte of bytes) {
2378
- hex += byte.toString(16).padStart(2, "0");
2379
- }
2380
- return { id: hex, source: "random" };
2381
- }
2382
- function resolveTelemetrySession() {
2383
- const existing = telemetrySessionSlot.get();
2384
- if (existing) {
2385
- return existing;
2386
- }
2387
- const declaredHandle = getConfiguredTelemetrySessionId();
2388
- const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
2389
- telemetrySessionSlot.set(resolved);
2390
- return resolved;
2391
- }
2392
- function getTelemetrySessionId() {
2393
- return resolveTelemetrySession().id;
2394
- }
2395
- function getTelemetrySessionSource() {
2396
- return resolveTelemetrySession().source;
2397
- }
2398
- function getTelemetryOperationId() {
2399
- const existing = telemetryOperationIdSlot.get();
2400
- if (existing) {
2401
- return existing;
2402
- }
2403
- const inboundTraceId = getInboundTraceContext()?.traceId;
2404
- const generated = inboundTraceId ?? crypto.randomUUID().replaceAll("-", "");
2405
- telemetryOperationIdSlot.set(generated);
2406
- return generated;
2407
- }
2408
- // src/telemetry/global-telemetry-properties.ts
2409
- var telemetryPropsSlot = singleton("TelemetryDefaultProps");
2410
- function getGlobalTelemetryProperties() {
2411
- return telemetryPropsSlot.get();
2412
- }
2413
-
2414
2449
  // src/telemetry/span-clock.ts
2415
2450
  function startSpanClock() {
2416
2451
  const started = performance.now();
@@ -2615,6 +2650,7 @@ var MAX_SPOOL_AGE_MS = 72 * 60 * 60 * 1000;
2615
2650
  // src/telemetry/telemetry-init.ts
2616
2651
  var telemetryInstanceSlot = singleton("TelemetryService");
2617
2652
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
2653
+ var browserProviderSlot = singleton("BrowserAppInsightsTelemetryProvider");
2618
2654
  function getGlobalTelemetryInstance() {
2619
2655
  const existing = telemetryInstanceSlot.get();
2620
2656
  if (existing && typeof existing === "object" && "trackEvent" in existing && typeof existing.trackEvent === "function") {
@@ -2798,7 +2834,7 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
2798
2834
  const pagedRows = extractPagedRows(data.Data);
2799
2835
  const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
2800
2836
  items.forEach((item) => {
2801
- const values = Object.values(item).map((v) => v ?? "").join("\t");
2837
+ const values = item === null || typeof item !== "object" ? String(item ?? "") : Object.values(item).map((v) => v ?? "").join("\t");
2802
2838
  logFn(values);
2803
2839
  });
2804
2840
  } else {
@@ -2813,7 +2849,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false, tableRowSt
2813
2849
  default: {
2814
2850
  const hasData = "Data" in data && data.Data != null;
2815
2851
  const pagedRows = hasData ? extractPagedRows(data.Data) : null;
2816
- const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
2852
+ const resolvedRows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
2853
+ const rows = resolvedRows && isPrimitiveArray(resolvedRows) ? resolvedRows.map((entry) => ({ Value: entry })) : resolvedRows;
2817
2854
  if (hasData && !(rows !== null && rows.length === 0)) {
2818
2855
  const logValue = data.Log;
2819
2856
  if (rows !== null) {
@@ -2870,6 +2907,9 @@ function printTable(data, logFn, externalLogValue, tableRowStyle) {
2870
2907
  function isPlainObjectArray(value) {
2871
2908
  return Array.isArray(value) && value.length > 0 && value.every(isPlainRecord);
2872
2909
  }
2910
+ function isPrimitiveArray(value) {
2911
+ return Array.isArray(value) && value.length > 0 && value.every((entry) => entry === null || typeof entry !== "object");
2912
+ }
2873
2913
  function isNonEmptyPlainObject(value) {
2874
2914
  return isPlainRecord(value) && Object.keys(value).length > 0;
2875
2915
  }
@@ -3216,12 +3256,12 @@ class FilterEvaluationError extends Error {
3216
3256
  instructions;
3217
3257
  retry = "RetryWillNotFix";
3218
3258
  result = RESULTS.ValidationError;
3219
- constructor(filter, cause) {
3259
+ constructor(filter, cause, hint) {
3220
3260
  const underlying = cause instanceof Error ? cause.message : String(cause);
3221
- super(`Filter '${filter}' failed to evaluate: ${underlying}`);
3261
+ super(`Filter '${filter}' failed to evaluate: ${underlying}` + (hint ? ` ${hint.detail}` : ""));
3222
3262
  this.name = "FilterEvaluationError";
3223
3263
  this.filter = filter;
3224
- 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(@)'.";
3264
+ 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(@)'.";
3225
3265
  }
3226
3266
  }
3227
3267
  function countRecords(data) {
@@ -3330,6 +3370,93 @@ function nameList(names, cap = 12) {
3330
3370
  const rest = names.length - shown.length;
3331
3371
  return shown.join(", ") + (rest > 0 ? `, and ${rest} more` : "");
3332
3372
  }
3373
+ function notFieldsOn(names, scope) {
3374
+ return `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
3375
+ }
3376
+ function failingFieldRead(ast, isList, fn, argIndex) {
3377
+ const [left, right, condition] = ast.children ?? [];
3378
+ let scopes = [];
3379
+ if (!isList) {
3380
+ scopes = [ast];
3381
+ } else if (ast.type === "FilterProjection" && left?.type === "Identity") {
3382
+ scopes = [condition, right];
3383
+ } else if (ast.type === "Projection" && (left?.type === "Identity" || left?.type === "Flatten" && left.children?.[0]?.type === "Identity")) {
3384
+ scopes = [right];
3385
+ }
3386
+ const reads = new Set;
3387
+ let tracked = 0;
3388
+ const visit = (node) => {
3389
+ if (!node)
3390
+ return;
3391
+ switch (node.type) {
3392
+ case "Function": {
3393
+ const arg = node.children?.[argIndex - 1];
3394
+ if (node.name === fn && arg?.type === "Field" && arg.name) {
3395
+ reads.add(arg.name);
3396
+ tracked++;
3397
+ }
3398
+ node.children?.forEach(visit);
3399
+ return;
3400
+ }
3401
+ case "AndExpression":
3402
+ case "OrExpression":
3403
+ case "NotExpression":
3404
+ case "Comparator":
3405
+ case "MultiSelectList":
3406
+ case "MultiSelectHash":
3407
+ node.children?.forEach(visit);
3408
+ return;
3409
+ case "KeyValuePair":
3410
+ visit(node.value);
3411
+ return;
3412
+ }
3413
+ };
3414
+ scopes.forEach(visit);
3415
+ const calls = (node) => {
3416
+ if (node === null || typeof node !== "object")
3417
+ return 0;
3418
+ const own = node.type === "Function" && node.name === fn ? 1 : 0;
3419
+ const next = node.type === "KeyValuePair" ? [node.value] : node.children ?? [];
3420
+ return own + next.reduce((sum, child) => sum + calls(child), 0);
3421
+ };
3422
+ return reads.size === 1 && tracked === calls(ast) ? [...reads][0] : undefined;
3423
+ }
3424
+ function fieldExpression(name) {
3425
+ return /^[A-Za-z_]\w*$/.test(name) ? name : JSON.stringify(name);
3426
+ }
3427
+ function evaluationHint(codec, filter, data, cause) {
3428
+ const underlying = cause instanceof Error ? cause.message : String(cause);
3429
+ const failure = /\b(\w+)\(\) expected argument (\d+) to be type (\S+) but received type null\b/.exec(underlying);
3430
+ if (!failure)
3431
+ return;
3432
+ const [, fn, position, expected] = failure;
3433
+ const name = failingFieldRead(codec.compile(filter), Array.isArray(data), fn, Number(position));
3434
+ if (name === undefined)
3435
+ return;
3436
+ const present = availableFields(data);
3437
+ if (present.length === 0)
3438
+ return;
3439
+ const scope = `${countRecords(data)} record(s)`;
3440
+ if (!present.includes(name)) {
3441
+ return {
3442
+ detail: `${notFieldsOn([name], scope)}. Available fields: ${nameList(present)}.`,
3443
+ instructions: "Use a field the records have; names are case-sensitive."
3444
+ };
3445
+ }
3446
+ const records = Array.isArray(data) ? data : [data];
3447
+ const unset = records.filter((r) => r?.[name] == null).length;
3448
+ const field = fieldExpression(name);
3449
+ let fallback;
3450
+ if (expected.split(",").includes("string")) {
3451
+ fallback = "''";
3452
+ } else if (expected.split(",").includes("array")) {
3453
+ fallback = "`[]`";
3454
+ }
3455
+ return {
3456
+ detail: `\`${name}\` is null or missing on ${unset} of the ${scope} it read.`,
3457
+ 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.`
3458
+ };
3459
+ }
3333
3460
  function buildFilterWarning(filter, data, outcome) {
3334
3461
  const present = availableFields(data);
3335
3462
  const refs = referencedFields(filter);
@@ -3337,7 +3464,7 @@ function buildFilterWarning(filter, data, outcome) {
3337
3464
  const unchecked = refs.nested.filter((name) => !present.includes(name));
3338
3465
  const count = countRecords(data);
3339
3466
  const scope = `${count} record(s)`;
3340
- const isNotAField = (names) => `${nameList(names)} ${names.length === 1 ? "is not a field" : "are not fields"} on the ${scope} it read`;
3467
+ const isNotAField = (names) => notFieldsOn(names, scope);
3341
3468
  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" : "";
3342
3469
  const withSoundness = (base) => soundness ? `${base}, and ${soundness}` : base;
3343
3470
  let detail;
@@ -3388,7 +3515,8 @@ function applyFilter(data, filter, onWarning) {
3388
3515
  try {
3389
3516
  result = codec.search(data, filter);
3390
3517
  } catch (err) {
3391
- throw new FilterEvaluationError(filter, err);
3518
+ const [, hint] = catchError(() => evaluationHint(codec, filter, data, err));
3519
+ throw new FilterEvaluationError(filter, err, hint);
3392
3520
  }
3393
3521
  const inputCount = countRecords(data);
3394
3522
  const warn = (outcome) => {
@@ -3620,4 +3748,4 @@ export {
3620
3748
  recordFailureExit
3621
3749
  };
3622
3750
 
3623
- //# debugId=5DC6B46BF9D47B6F64756E2164756E21
3751
+ //# debugId=A871AFFD339AC16E64756E2164756E21
package/dist/zip.js CHANGED
@@ -692,12 +692,26 @@ class NodeFileSystem {
692
692
  throw error;
693
693
  }
694
694
  }
695
- async writeFile(filePath, data) {
695
+ async writeFile(filePath, data, options) {
696
696
  const dir = path2.dirname(filePath);
697
697
  if (dir) {
698
698
  await fs6.mkdir(dir, { recursive: true });
699
699
  }
700
- await fs6.writeFile(filePath, data);
700
+ if (options?.mode === undefined || process.platform === "win32") {
701
+ if (options?.exclusive) {
702
+ await fs6.writeFile(filePath, data, { flag: "wx" });
703
+ } else {
704
+ await fs6.writeFile(filePath, data);
705
+ }
706
+ return;
707
+ }
708
+ const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
709
+ try {
710
+ await handle.chmod(options.mode);
711
+ await handle.writeFile(data);
712
+ } finally {
713
+ await handle.close();
714
+ }
701
715
  }
702
716
  async appendFile(filePath, data) {
703
717
  const dir = path2.dirname(filePath);
@@ -732,7 +746,8 @@ class NodeFileSystem {
732
746
  isDirectory: () => stats.isDirectory(),
733
747
  size: stats.size,
734
748
  mtimeMs: stats.mtimeMs,
735
- ctimeMs: stats.ctimeMs
749
+ ctimeMs: stats.ctimeMs,
750
+ mode: stats.mode
736
751
  };
737
752
  } catch (error) {
738
753
  if (this.isEnoent(error))
@@ -743,8 +758,13 @@ class NodeFileSystem {
743
758
  async exists(filePath) {
744
759
  return existsSync(filePath);
745
760
  }
746
- async mkdir(dirPath) {
747
- await fs6.mkdir(dirPath, { recursive: true });
761
+ async mkdir(dirPath, options) {
762
+ await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
763
+ }
764
+ async chmod(targetPath, mode) {
765
+ if (process.platform === "win32")
766
+ return;
767
+ await fs6.chmod(targetPath, mode);
748
768
  }
749
769
  async acquireLock(lockPath) {
750
770
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -894,7 +914,7 @@ class NodeFileSystem {
894
914
  async getTempDir() {
895
915
  return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
896
916
  }
897
- async copyDirectory(sourcePath, destPath) {
917
+ async copyDirectory(sourcePath, destPath, options) {
898
918
  const sourceStats = await this.stat(sourcePath);
899
919
  if (!sourceStats) {
900
920
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -911,7 +931,9 @@ class NodeFileSystem {
911
931
  if (!entryStats)
912
932
  continue;
913
933
  if (entryStats.isDirectory()) {
914
- await this.copyDirectory(srcEntry, destEntry);
934
+ if (options?.skipDirectoryNames?.includes(entry))
935
+ continue;
936
+ await this.copyDirectory(srcEntry, destEntry, options);
915
937
  } else if (entryStats.isFile()) {
916
938
  const content = await this.readFile(srcEntry);
917
939
  if (content !== null) {
@@ -1418,4 +1440,4 @@ export {
1418
1440
  readZipEntry
1419
1441
  };
1420
1442
 
1421
- //# debugId=1C51CF33EEEABF7464756E2164756E21
1443
+ //# debugId=75D3B761F8F9943164756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/common",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.306",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "Common infrastructure needed by uip tools.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -102,5 +102,5 @@
102
102
  "mihaigirleanu",
103
103
  "vlad-uipath"
104
104
  ],
105
- "gitHead": "0b8843ae9b6d2f69a0203f96ab91e5d55e416383"
105
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
106
106
  }