@uipath/ixp-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.
Files changed (2) hide show
  1. package/dist/index.js +72 -12
  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);
@@ -1798,6 +1818,38 @@ var loadEnvFileAsync = async ({ envPath }) => {
1798
1818
  }
1799
1819
  return parseEnvContent(content);
1800
1820
  };
1821
+ var findAuthHomeDir = (fs, dir) => {
1822
+ let current = dir;
1823
+ for (;; ) {
1824
+ if (fs.path.basename(current) === UIPATH_HOME_DIR)
1825
+ return current;
1826
+ const parent = fs.path.dirname(current);
1827
+ if (parent === current)
1828
+ return;
1829
+ current = parent;
1830
+ }
1831
+ };
1832
+ var TEMP_FILE_ATTEMPTS = 5;
1833
+ var isFileExists = (error) => error instanceof Error && error.code === "EEXIST";
1834
+ var writeTempFile = async (fs, targetPath, content) => {
1835
+ for (let attempt = 1;; attempt++) {
1836
+ const tempPath = `${targetPath}.${crypto.randomUUID()}.tmp`;
1837
+ try {
1838
+ await fs.writeFile(tempPath, content, {
1839
+ mode: AUTH_FILE_MODE,
1840
+ exclusive: true
1841
+ });
1842
+ return tempPath;
1843
+ } catch (error) {
1844
+ if (!isFileExists(error)) {
1845
+ await fs.rm(tempPath).catch(() => {});
1846
+ throw error;
1847
+ }
1848
+ if (attempt === TEMP_FILE_ATTEMPTS)
1849
+ throw error;
1850
+ }
1851
+ }
1852
+ };
1801
1853
  var saveEnvFileAsync = async ({
1802
1854
  envPath,
1803
1855
  data,
@@ -1825,10 +1877,18 @@ var saveEnvFileAsync = async ({
1825
1877
  `)}
1826
1878
  `;
1827
1879
  const dir = fs.path.dirname(absolutePath);
1828
- await fs.mkdir(dir);
1829
- const tempPath = `${absolutePath}.tmp`;
1830
- await fs.writeFile(tempPath, content);
1831
- await fs.rename(tempPath, absolutePath);
1880
+ await fs.mkdir(dir, { mode: AUTH_DIR_MODE });
1881
+ const authHomeDir = findAuthHomeDir(fs, dir);
1882
+ if (authHomeDir !== undefined) {
1883
+ await fs.chmod?.(authHomeDir, AUTH_DIR_MODE);
1884
+ }
1885
+ const tempPath = await writeTempFile(fs, absolutePath, content);
1886
+ try {
1887
+ await fs.rename(tempPath, absolutePath);
1888
+ } catch (error) {
1889
+ await fs.rm(tempPath).catch(() => {});
1890
+ throw error;
1891
+ }
1832
1892
  };
1833
1893
 
1834
1894
  // ../auth/src/loginStatus.ts
@@ -2675,7 +2735,7 @@ var package_default = {
2675
2735
  name: "@uipath/ixp-sdk",
2676
2736
  author: "UiPath",
2677
2737
  license: "SEE LICENSE IN LICENSE.txt",
2678
- version: "1.206.0-preview.311",
2738
+ version: "1.206.0-preview.323",
2679
2739
  description: "SDK for the UiPath IXP (Intelligent eXtraction Platform) API — projects, taxonomies, prompts, predictions, and model publishing.",
2680
2740
  repository: {
2681
2741
  type: "git",
@@ -3102,4 +3162,4 @@ export {
3102
3162
  uploadDocument
3103
3163
  };
3104
3164
 
3105
- //# debugId=6744F3589E504D8B64756E2164756E21
3165
+ //# debugId=565E7D39049EB8B664756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/ixp-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 IXP (Intelligent eXtraction Platform) API — projects, taxonomies, prompts, predictions, and model publishing.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -25,5 +25,5 @@
25
25
  "files": [
26
26
  "dist"
27
27
  ],
28
- "gitHead": "562a7f94aae12bb340f2b18932e8809c3d76a3e0"
28
+ "gitHead": "a752d8a8d78de138e3be0a19642620fec7893d99"
29
29
  }