@uipath/aops-policy-sdk 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 +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",
@@ -1528,7 +1552,7 @@ var package_default = {
1528
1552
  name: "@uipath/aops-policy-sdk",
1529
1553
  author: "UiPath",
1530
1554
  license: "SEE LICENSE IN LICENSE.txt",
1531
- version: "1.206.0-preview.301",
1555
+ version: "1.207.0-preview.305",
1532
1556
  description: "SDK for the UiPath AOps Governance API — policy management and deployment.",
1533
1557
  repository: {
1534
1558
  type: "git",
@@ -7810,6 +7834,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
7810
7834
  }
7811
7835
  return parseEnvContent(content);
7812
7836
  };
7837
+ var findAuthHomeDir = (fs, dir) => {
7838
+ let current = dir;
7839
+ for (;; ) {
7840
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
7841
+ return current;
7842
+ const parent = fs.path.dirname(current);
7843
+ if (parent === current)
7844
+ return;
7845
+ current = parent;
7846
+ }
7847
+ };
7848
+ var TEMP_FILE_ATTEMPTS = 5;
7849
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
7850
+ var writeTempFile = async (fs, targetPath, content) => {
7851
+ for (let attempt = 1;; attempt++) {
7852
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
7853
+ try {
7854
+ await fs.writeFile(tempPath, content, {
7855
+ mode: AUTH_FILE_MODE,
7856
+ exclusive: true
7857
+ });
7858
+ return tempPath;
7859
+ } catch (error) {
7860
+ if (!isFileExists(error)) {
7861
+ await fs.rm(tempPath).catch(() => {});
7862
+ throw error;
7863
+ }
7864
+ if (attempt === TEMP_FILE_ATTEMPTS)
7865
+ throw error;
7866
+ }
7867
+ }
7868
+ };
7813
7869
  var saveEnvFileAsync = async ({
7814
7870
  envPath,
7815
7871
  data,
@@ -7837,10 +7893,18 @@ var saveEnvFileAsync = async ({
7837
7893
  `)}
7838
7894
  `;
7839
7895
  const dir = fs.path.dirname(absolutePath);
7840
- await fs.mkdir(dir);
7841
- const tempPath = `${absolutePath}.tmp`;
7842
- await fs.writeFile(tempPath, content);
7843
- await fs.rename(tempPath, absolutePath);
7896
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
7897
+ const authHomeDir = findAuthHomeDir(fs, dir);
7898
+ if (authHomeDir !== undefined) {
7899
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
7900
+ }
7901
+ const tempPath = await writeTempFile(fs, absolutePath, content);
7902
+ try {
7903
+ await fs.rename(tempPath, absolutePath);
7904
+ } catch (error) {
7905
+ await fs.rm(tempPath).catch(() => {});
7906
+ throw error;
7907
+ }
7844
7908
  };
7845
7909
 
7846
7910
  // ../../auth/src/loginStatus.ts
@@ -8446,6 +8510,8 @@ var TENANT_SELECTION_CODES = new Set([
8446
8510
  ]);
8447
8511
  // ../../auth/src/logout.ts
8448
8512
  init_src();
8513
+ // ../../auth/src/utils/lockedEnvFile.ts
8514
+ init_src();
8449
8515
  // src/client-factory.ts
8450
8516
  async function createGovernanceConfig(options) {
8451
8517
  const auth = await getAuthContext({
@@ -8876,4 +8942,4 @@ export {
8876
8942
  querystring
8877
8943
  };
8878
8944
 
8879
- //# debugId=2FB827D258014CE764756E2164756E21
8945
+ //# debugId=9B338A042D9AD79F64756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/aops-policy-sdk",
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": "SDK for the UiPath AOps Governance API — policy management and deployment.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -35,5 +35,5 @@
35
35
  "dist"
36
36
  ],
37
37
  "private": false,
38
- "gitHead": "078afc3ef7ebf4c38353ee0059e321acf16a350d"
38
+ "gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
39
39
  }