@uipath/insights-sdk 1.206.0-preview.311 → 1.206.0-preview.323

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.
@@ -521,7 +521,7 @@ var package_default = {
521
521
  name: "@uipath/insights-sdk",
522
522
  author: "UiPath",
523
523
  license: "SEE LICENSE IN LICENSE.txt",
524
- version: "1.206.0-preview.311",
524
+ version: "1.206.0-preview.323",
525
525
  description: "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
526
526
  repository: {
527
527
  type: "git",
@@ -1969,4 +1969,4 @@ export {
1969
1969
  verifyExportDestination
1970
1970
  };
1971
1971
 
1972
- //# debugId=9F7766CB1C3C934D64756E2164756E21
1972
+ //# debugId=8EC6F770A5273F7D64756E2164756E21
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ function settlePromiseLike2(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);
@@ -1495,7 +1515,7 @@ var package_default = {
1495
1515
  name: "@uipath/insights-sdk",
1496
1516
  author: "UiPath",
1497
1517
  license: "SEE LICENSE IN LICENSE.txt",
1498
- version: "1.206.0-preview.311",
1518
+ version: "1.206.0-preview.323",
1499
1519
  description: "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
1500
1520
  repository: {
1501
1521
  type: "git",
@@ -2887,6 +2907,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
2887
2907
  }
2888
2908
  return parseEnvContent(content);
2889
2909
  };
2910
+ var findAuthHomeDir = (fs, dir) => {
2911
+ let current = dir;
2912
+ for (;; ) {
2913
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
2914
+ return current;
2915
+ const parent = fs.path.dirname(current);
2916
+ if (parent === current)
2917
+ return;
2918
+ current = parent;
2919
+ }
2920
+ };
2921
+ var TEMP_FILE_ATTEMPTS = 5;
2922
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
2923
+ var writeTempFile = async (fs, targetPath, content) => {
2924
+ for (let attempt = 1;; attempt++) {
2925
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
2926
+ try {
2927
+ await fs.writeFile(tempPath, content, {
2928
+ mode: AUTH_FILE_MODE,
2929
+ exclusive: true
2930
+ });
2931
+ return tempPath;
2932
+ } catch (error) {
2933
+ if (!isFileExists(error)) {
2934
+ await fs.rm(tempPath).catch(() => {});
2935
+ throw error;
2936
+ }
2937
+ if (attempt === TEMP_FILE_ATTEMPTS)
2938
+ throw error;
2939
+ }
2940
+ }
2941
+ };
2890
2942
  var saveEnvFileAsync = async ({
2891
2943
  envPath,
2892
2944
  data,
@@ -2914,10 +2966,18 @@ var saveEnvFileAsync = async ({
2914
2966
  `)}
2915
2967
  `;
2916
2968
  const dir = fs.path.dirname(absolutePath);
2917
- await fs.mkdir(dir);
2918
- const tempPath = `${absolutePath}.tmp`;
2919
- await fs.writeFile(tempPath, content);
2920
- await fs.rename(tempPath, absolutePath);
2969
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
2970
+ const authHomeDir = findAuthHomeDir(fs, dir);
2971
+ if (authHomeDir !== undefined) {
2972
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
2973
+ }
2974
+ const tempPath = await writeTempFile(fs, absolutePath, content);
2975
+ try {
2976
+ await fs.rename(tempPath, absolutePath);
2977
+ } catch (error) {
2978
+ await fs.rm(tempPath).catch(() => {});
2979
+ throw error;
2980
+ }
2921
2981
  };
2922
2982
 
2923
2983
  // ../auth/src/loginStatus.ts
@@ -4404,4 +4464,4 @@ export {
4404
4464
  verifyExportDestination
4405
4465
  };
4406
4466
 
4407
- //# debugId=9B5A67200648F5DD64756E2164756E21
4467
+ //# debugId=9CF5BF384417FDED64756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/insights-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.311",
5
+ "version": "1.206.0-preview.323",
6
6
  "description": "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -35,5 +35,5 @@
35
35
  "files": [
36
36
  "dist"
37
37
  ],
38
- "gitHead": "562a7f94aae12bb340f2b18932e8809c3d76a3e0"
38
+ "gitHead": "a752d8a8d78de138e3be0a19642620fec7893d99"
39
39
  }