@uipath/agent-sdk 1.206.0-preview.303 → 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 +82 -16
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ function settlePromiseLike(thenable) {
41
41
  }
42
42
 
43
43
  // ../auth/src/constants.ts
44
- var UIPATH_HOME_DIR = ".uipath", AUTH_FILENAME = ".auth", DEFAULT_BASE_URL = "https://cloud.uipath.com", DEFAULT_AUTH_TIMEOUT_MS;
44
+ var UIPATH_HOME_DIR = ".uipath", AUTH_FILENAME = ".auth", AUTH_FILE_MODE = 384, AUTH_DIR_MODE = 448, DEFAULT_BASE_URL = "https://cloud.uipath.com", DEFAULT_AUTH_TIMEOUT_MS;
45
45
  var init_constants = __esm(() => {
46
46
  DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
47
47
  });
@@ -724,12 +724,26 @@ class NodeFileSystem {
724
724
  throw error;
725
725
  }
726
726
  }
727
- async writeFile(filePath, data) {
727
+ async writeFile(filePath, data, options) {
728
728
  const dir = path2.dirname(filePath);
729
729
  if (dir) {
730
730
  await fs6.mkdir(dir, { recursive: true });
731
731
  }
732
- await fs6.writeFile(filePath, data);
732
+ if (options?.mode === undefined || process.platform === "win32") {
733
+ if (options?.exclusive) {
734
+ await fs6.writeFile(filePath, data, { flag: "wx" });
735
+ } else {
736
+ await fs6.writeFile(filePath, data);
737
+ }
738
+ return;
739
+ }
740
+ const handle = await fs6.open(filePath, options.exclusive ? "wx" : "w", options.mode);
741
+ try {
742
+ await handle.chmod(options.mode);
743
+ await handle.writeFile(data);
744
+ } finally {
745
+ await handle.close();
746
+ }
733
747
  }
734
748
  async appendFile(filePath, data) {
735
749
  const dir = path2.dirname(filePath);
@@ -764,7 +778,8 @@ class NodeFileSystem {
764
778
  isDirectory: () => stats.isDirectory(),
765
779
  size: stats.size,
766
780
  mtimeMs: stats.mtimeMs,
767
- ctimeMs: stats.ctimeMs
781
+ ctimeMs: stats.ctimeMs,
782
+ mode: stats.mode
768
783
  };
769
784
  } catch (error) {
770
785
  if (this.isEnoent(error))
@@ -775,8 +790,13 @@ class NodeFileSystem {
775
790
  async exists(filePath) {
776
791
  return existsSync(filePath);
777
792
  }
778
- async mkdir(dirPath) {
779
- await fs6.mkdir(dirPath, { recursive: true });
793
+ async mkdir(dirPath, options) {
794
+ await fs6.mkdir(dirPath, { recursive: true, mode: options?.mode });
795
+ }
796
+ async chmod(targetPath, mode) {
797
+ if (process.platform === "win32")
798
+ return;
799
+ await fs6.chmod(targetPath, mode);
780
800
  }
781
801
  async acquireLock(lockPath) {
782
802
  const canonicalPath = await this.canonicalizeLockTarget(lockPath);
@@ -926,7 +946,7 @@ class NodeFileSystem {
926
946
  async getTempDir() {
927
947
  return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-"));
928
948
  }
929
- async copyDirectory(sourcePath, destPath) {
949
+ async copyDirectory(sourcePath, destPath, options) {
930
950
  const sourceStats = await this.stat(sourcePath);
931
951
  if (!sourceStats) {
932
952
  throw new Error(`Source directory does not exist: ${sourcePath}`);
@@ -943,7 +963,9 @@ class NodeFileSystem {
943
963
  if (!entryStats)
944
964
  continue;
945
965
  if (entryStats.isDirectory()) {
946
- await this.copyDirectory(srcEntry, destEntry);
966
+ if (options?.skipDirectoryNames?.includes(entry))
967
+ continue;
968
+ await this.copyDirectory(srcEntry, destEntry, options);
947
969
  } else if (entryStats.isFile()) {
948
970
  const content = await this.readFile(srcEntry);
949
971
  if (content !== null) {
@@ -1047,13 +1069,15 @@ var ProjectDimensions = {
1047
1069
  SolutionKey: "SolutionKey",
1048
1070
  SolutionProjectKey: "SolutionProjectKey",
1049
1071
  SolutionIdentityStatus: "SolutionIdentityStatus",
1050
- PreviousSolutionKey: "PreviousSolutionKey"
1072
+ PreviousSolutionKey: "PreviousSolutionKey",
1073
+ PreviousProjectKey: "PreviousProjectKey"
1051
1074
  };
1052
1075
  var GUID_KEY_DIMENSIONS = new Set([
1053
1076
  ProjectDimensions.ProjectKey,
1054
1077
  ProjectDimensions.SolutionKey,
1055
1078
  ProjectDimensions.SolutionProjectKey,
1056
- ProjectDimensions.PreviousSolutionKey
1079
+ ProjectDimensions.PreviousSolutionKey,
1080
+ ProjectDimensions.PreviousProjectKey
1057
1081
  ]);
1058
1082
  var ShipDimensions = {
1059
1083
  ShipKind: "ShipKind",
@@ -1540,7 +1564,7 @@ var package_default = {
1540
1564
  name: "@uipath/agent-sdk",
1541
1565
  author: "UiPath",
1542
1566
  license: "SEE LICENSE IN LICENSE.txt",
1543
- version: "1.206.0-preview.303",
1567
+ version: "1.207.0-preview.305",
1544
1568
  description: "SDK for the UiPath Agent Runtime API — evaluation execution and debug sessions.",
1545
1569
  repository: {
1546
1570
  type: "git",
@@ -5354,6 +5378,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
5354
5378
  }
5355
5379
  return parseEnvContent(content);
5356
5380
  };
5381
+ var findAuthHomeDir = (fs, dir) => {
5382
+ let current = dir;
5383
+ for (;; ) {
5384
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
5385
+ return current;
5386
+ const parent = fs.path.dirname(current);
5387
+ if (parent === current)
5388
+ return;
5389
+ current = parent;
5390
+ }
5391
+ };
5392
+ var TEMP_FILE_ATTEMPTS = 5;
5393
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
5394
+ var writeTempFile = async (fs, targetPath, content) => {
5395
+ for (let attempt = 1;; attempt++) {
5396
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
5397
+ try {
5398
+ await fs.writeFile(tempPath, content, {
5399
+ mode: AUTH_FILE_MODE,
5400
+ exclusive: true
5401
+ });
5402
+ return tempPath;
5403
+ } catch (error) {
5404
+ if (!isFileExists(error)) {
5405
+ await fs.rm(tempPath).catch(() => {});
5406
+ throw error;
5407
+ }
5408
+ if (attempt === TEMP_FILE_ATTEMPTS)
5409
+ throw error;
5410
+ }
5411
+ }
5412
+ };
5357
5413
  var saveEnvFileAsync = async ({
5358
5414
  envPath,
5359
5415
  data,
@@ -5381,10 +5437,18 @@ var saveEnvFileAsync = async ({
5381
5437
  `)}
5382
5438
  `;
5383
5439
  const dir = fs.path.dirname(absolutePath);
5384
- await fs.mkdir(dir);
5385
- const tempPath = `${absolutePath}.tmp`;
5386
- await fs.writeFile(tempPath, content);
5387
- await fs.rename(tempPath, absolutePath);
5440
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
5441
+ const authHomeDir = findAuthHomeDir(fs, dir);
5442
+ if (authHomeDir !== undefined) {
5443
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
5444
+ }
5445
+ const tempPath = await writeTempFile(fs, absolutePath, content);
5446
+ try {
5447
+ await fs.rename(tempPath, absolutePath);
5448
+ } catch (error) {
5449
+ await fs.rm(tempPath).catch(() => {});
5450
+ throw error;
5451
+ }
5388
5452
  };
5389
5453
 
5390
5454
  // ../auth/src/loginStatus.ts
@@ -5990,6 +6054,8 @@ var TENANT_SELECTION_CODES = new Set([
5990
6054
  ]);
5991
6055
  // ../auth/src/logout.ts
5992
6056
  init_src();
6057
+ // ../auth/src/utils/lockedEnvFile.ts
6058
+ init_src();
5993
6059
  // src/client-factory.ts
5994
6060
  async function createAgentRuntimeConfig(options) {
5995
6061
  const ctx = await getAuthContext({
@@ -6520,4 +6586,4 @@ export {
6520
6586
  querystring
6521
6587
  };
6522
6588
 
6523
- //# debugId=BD442D06EEB281F864756E2164756E21
6589
+ //# debugId=E4EB2DD37E3B5DD864756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/agent-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.303",
5
+ "version": "1.207.0-preview.305",
6
6
  "description": "SDK for the UiPath Agent Runtime API — evaluation execution and debug sessions.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -30,5 +30,5 @@
30
30
  "files": [
31
31
  "dist"
32
32
  ],
33
- "gitHead": "7d17b8a3c1a50892d42c9302087abc8307b04409"
33
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
34
34
  }