@duplojs/server 0.1.0-beta.1 → 0.1.0-beta.10

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 (198) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +5 -1
  2. package/dist/command/argument.d.ts +2 -2
  3. package/dist/command/create.cjs +18 -10
  4. package/dist/command/create.d.ts +3 -3
  5. package/dist/command/create.mjs +18 -10
  6. package/dist/command/error.cjs +96 -43
  7. package/dist/command/error.d.ts +9 -1
  8. package/dist/command/error.mjs +95 -42
  9. package/dist/command/exec.d.ts +4 -3
  10. package/dist/command/help.cjs +28 -35
  11. package/dist/command/help.d.ts +1 -1
  12. package/dist/command/help.mjs +27 -34
  13. package/dist/command/index.cjs +4 -0
  14. package/dist/command/index.mjs +4 -2
  15. package/dist/command/options/base.cjs +21 -13
  16. package/dist/command/options/base.d.ts +6 -0
  17. package/dist/command/options/base.mjs +20 -14
  18. package/dist/command/options/defaults/array.d.ts +6 -4
  19. package/dist/command/options/defaults/boolean.cjs +21 -7
  20. package/dist/command/options/defaults/boolean.d.ts +6 -3
  21. package/dist/command/options/defaults/boolean.mjs +20 -8
  22. package/dist/command/options/defaults/simple.d.ts +6 -4
  23. package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
  24. package/dist/command/types/index.d.ts +1 -0
  25. package/dist/common/environmentVariable/index.d.ts +1 -1
  26. package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +1 -1
  27. package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +2 -1
  28. package/dist/common/index.cjs +3 -0
  29. package/dist/common/index.d.ts +1 -0
  30. package/dist/common/index.mjs +3 -1
  31. package/dist/common/meta/getCurrentDirectoryName.cjs +10 -0
  32. package/dist/common/meta/getCurrentDirectoryName.d.ts +7 -0
  33. package/dist/common/meta/getCurrentDirectoryName.mjs +7 -0
  34. package/dist/common/meta/index.d.ts +7 -0
  35. package/dist/dataStructure/common/codec/defaults/json.cjs +12 -1
  36. package/dist/dataStructure/common/codec/defaults/json.d.ts +2 -2
  37. package/dist/dataStructure/common/codec/defaults/json.mjs +12 -1
  38. package/dist/dataStructure/common/codec/defaults/string.cjs +12 -1
  39. package/dist/dataStructure/common/codec/defaults/string.d.ts +2 -2
  40. package/dist/dataStructure/common/codec/defaults/string.mjs +12 -1
  41. package/dist/dataStructure/common/error/defaultInterpreter.cjs +3 -1
  42. package/dist/dataStructure/common/error/defaultInterpreter.d.ts +7 -2
  43. package/dist/dataStructure/common/error/defaultInterpreter.mjs +3 -1
  44. package/dist/dataStructure/constraint/{exist.cjs → fileExist.cjs} +5 -5
  45. package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
  46. package/dist/dataStructure/constraint/{exist.mjs → fileExist.mjs} +4 -4
  47. package/dist/dataStructure/constraint/folderExist.cjs +19 -0
  48. package/dist/dataStructure/constraint/folderExist.d.ts +10 -0
  49. package/dist/dataStructure/constraint/folderExist.mjs +15 -0
  50. package/dist/dataStructure/constraint/index.d.ts +2 -1
  51. package/dist/dataStructure/constraint/mimeType.cjs +1 -1
  52. package/dist/dataStructure/constraint/mimeType.mjs +1 -1
  53. package/dist/dataStructure/constraint/types/constraints.d.ts +4 -2
  54. package/dist/dataStructure/fundamentalType/folder.cjs +11 -0
  55. package/dist/dataStructure/fundamentalType/folder.d.ts +8 -0
  56. package/dist/dataStructure/fundamentalType/folder.mjs +8 -0
  57. package/dist/dataStructure/fundamentalType/index.d.ts +1 -0
  58. package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +2 -0
  59. package/dist/dataStructure/helper/file.d.ts +1 -1
  60. package/dist/dataStructure/helper/fileExist.cjs +7 -0
  61. package/dist/dataStructure/helper/fileExist.d.ts +2 -0
  62. package/dist/dataStructure/helper/fileExist.mjs +7 -0
  63. package/dist/dataStructure/helper/folder.cjs +10 -0
  64. package/dist/dataStructure/helper/folder.d.ts +3 -0
  65. package/dist/dataStructure/helper/folder.mjs +8 -0
  66. package/dist/dataStructure/helper/folderExist.cjs +7 -0
  67. package/dist/dataStructure/helper/folderExist.d.ts +2 -0
  68. package/dist/dataStructure/helper/folderExist.mjs +7 -0
  69. package/dist/dataStructure/helper/index.d.ts +3 -1
  70. package/dist/dataStructure/index.cjs +29 -8
  71. package/dist/dataStructure/index.mjs +19 -6
  72. package/dist/dataStructure/type/folder.cjs +14 -0
  73. package/dist/dataStructure/type/folder.d.ts +11 -0
  74. package/dist/dataStructure/type/folder.mjs +11 -0
  75. package/dist/dataStructure/type/index.d.ts +1 -0
  76. package/dist/dataStructure/type/types/types.d.ts +2 -0
  77. package/dist/file/appendFile.cjs +46 -22
  78. package/dist/file/appendFile.d.ts +37 -5
  79. package/dist/file/appendFile.mjs +36 -23
  80. package/dist/file/appendTextFile.cjs +44 -20
  81. package/dist/file/appendTextFile.d.ts +37 -5
  82. package/dist/file/appendTextFile.mjs +34 -21
  83. package/dist/file/copy.cjs +36 -14
  84. package/dist/file/copy.d.ts +37 -5
  85. package/dist/file/copy.mjs +26 -15
  86. package/dist/file/createEntryInterface.cjs +6 -3
  87. package/dist/file/createEntryInterface.d.ts +1 -1
  88. package/dist/file/createEntryInterface.mjs +4 -2
  89. package/dist/file/ensureDirectory.cjs +37 -17
  90. package/dist/file/ensureDirectory.d.ts +30 -4
  91. package/dist/file/ensureDirectory.mjs +29 -18
  92. package/dist/file/ensureFile.cjs +41 -19
  93. package/dist/file/ensureFile.d.ts +33 -4
  94. package/dist/file/ensureFile.mjs +32 -20
  95. package/dist/file/exists.cjs +28 -14
  96. package/dist/file/exists.d.ts +21 -4
  97. package/dist/file/exists.mjs +23 -15
  98. package/dist/file/fileInterface.cjs +3 -1
  99. package/dist/file/fileInterface.d.ts +10 -9
  100. package/dist/file/fileInterface.mjs +3 -2
  101. package/dist/file/folderInterface.cjs +3 -1
  102. package/dist/file/folderInterface.d.ts +9 -8
  103. package/dist/file/folderInterface.mjs +3 -2
  104. package/dist/file/index.cjs +512 -0
  105. package/dist/file/index.d.ts +0 -1
  106. package/dist/file/index.mjs +291 -35
  107. package/dist/file/link.cjs +48 -22
  108. package/dist/file/link.d.ts +40 -5
  109. package/dist/file/link.mjs +37 -23
  110. package/dist/file/linkStat.cjs +29 -15
  111. package/dist/file/linkStat.d.ts +24 -4
  112. package/dist/file/linkStat.mjs +24 -16
  113. package/dist/file/makeDirectory.cjs +45 -21
  114. package/dist/file/makeDirectory.d.ts +35 -4
  115. package/dist/file/makeDirectory.mjs +35 -22
  116. package/dist/file/makeTemporaryDirectory.cjs +33 -15
  117. package/dist/file/makeTemporaryDirectory.d.ts +25 -2
  118. package/dist/file/makeTemporaryDirectory.mjs +26 -16
  119. package/dist/file/makeTemporaryFile.cjs +37 -20
  120. package/dist/file/makeTemporaryFile.d.ts +28 -2
  121. package/dist/file/makeTemporaryFile.mjs +30 -21
  122. package/dist/file/move.cjs +49 -23
  123. package/dist/file/move.d.ts +40 -5
  124. package/dist/file/move.mjs +38 -24
  125. package/dist/file/readDirectory.cjs +33 -9
  126. package/dist/file/readDirectory.d.ts +26 -5
  127. package/dist/file/readDirectory.mjs +25 -10
  128. package/dist/file/readFile.cjs +35 -17
  129. package/dist/file/readFile.d.ts +27 -4
  130. package/dist/file/readFile.mjs +28 -18
  131. package/dist/file/readJsonFile.cjs +35 -17
  132. package/dist/file/readJsonFile.d.ts +27 -5
  133. package/dist/file/readJsonFile.mjs +28 -18
  134. package/dist/file/readLink.cjs +31 -15
  135. package/dist/file/readLink.d.ts +24 -4
  136. package/dist/file/readLink.mjs +25 -16
  137. package/dist/file/readTextFile.cjs +35 -17
  138. package/dist/file/readTextFile.d.ts +27 -4
  139. package/dist/file/readTextFile.mjs +28 -18
  140. package/dist/file/realPath.cjs +27 -13
  141. package/dist/file/realPath.d.ts +21 -4
  142. package/dist/file/realPath.mjs +22 -14
  143. package/dist/file/relocate.cjs +52 -25
  144. package/dist/file/relocate.d.ts +40 -5
  145. package/dist/file/relocate.mjs +41 -26
  146. package/dist/file/remove.cjs +45 -23
  147. package/dist/file/remove.d.ts +32 -4
  148. package/dist/file/remove.mjs +36 -24
  149. package/dist/file/rename.cjs +52 -25
  150. package/dist/file/rename.d.ts +40 -5
  151. package/dist/file/rename.mjs +41 -26
  152. package/dist/file/setMode.cjs +29 -15
  153. package/dist/file/setMode.d.ts +24 -5
  154. package/dist/file/setMode.mjs +24 -16
  155. package/dist/file/setOwner.cjs +31 -15
  156. package/dist/file/setOwner.d.ts +25 -5
  157. package/dist/file/setOwner.mjs +25 -16
  158. package/dist/file/setTime.cjs +31 -15
  159. package/dist/file/setTime.d.ts +24 -5
  160. package/dist/file/setTime.mjs +25 -16
  161. package/dist/file/stat.cjs +29 -15
  162. package/dist/file/stat.d.ts +24 -4
  163. package/dist/file/stat.mjs +24 -16
  164. package/dist/file/symlink.cjs +42 -20
  165. package/dist/file/symlink.d.ts +34 -5
  166. package/dist/file/symlink.mjs +33 -21
  167. package/dist/file/truncate.cjs +43 -21
  168. package/dist/file/truncate.d.ts +36 -4
  169. package/dist/file/truncate.mjs +34 -22
  170. package/dist/file/unknownEntryInterface.cjs +5 -1
  171. package/dist/file/unknownEntryInterface.d.ts +8 -6
  172. package/dist/file/unknownEntryInterface.mjs +4 -2
  173. package/dist/file/walkDirectory.cjs +38 -15
  174. package/dist/file/walkDirectory.d.ts +25 -4
  175. package/dist/file/walkDirectory.mjs +32 -15
  176. package/dist/file/writeFile.cjs +45 -21
  177. package/dist/file/writeFile.d.ts +37 -5
  178. package/dist/file/writeFile.mjs +35 -22
  179. package/dist/file/writeJsonFile.cjs +48 -27
  180. package/dist/file/writeJsonFile.d.ts +37 -6
  181. package/dist/file/writeJsonFile.mjs +39 -28
  182. package/dist/file/writeTextFile.cjs +45 -21
  183. package/dist/file/writeTextFile.d.ts +37 -5
  184. package/dist/file/writeTextFile.mjs +35 -22
  185. package/dist/implementor.cjs +8 -5
  186. package/dist/implementor.d.ts +4 -4
  187. package/dist/implementor.mjs +8 -5
  188. package/dist/index.cjs +2 -0
  189. package/dist/index.mjs +2 -1
  190. package/dist/override.d.ts +8 -0
  191. package/package.json +4 -4
  192. package/dist/dataStructure/constraint/exist.d.ts +0 -10
  193. package/dist/dataStructure/helper/exist.cjs +0 -7
  194. package/dist/dataStructure/helper/exist.d.ts +0 -2
  195. package/dist/dataStructure/helper/exist.mjs +0 -7
  196. package/dist/file/types/fileSystemEither.d.ts +0 -2
  197. package/dist/file/types/index.d.ts +0 -1
  198. /package/{README → README.md} +0 -0
@@ -1,30 +1,41 @@
1
1
  import { implementFunction, nodeFileSystem } from "../implementor.mjs";
2
+ import * as DCommon from "@duplojs/lang/common";
2
3
  import * as DEither from "@duplojs/lang/either";
3
4
  //#region scripts/file/ensureDirectory.ts
5
+ var EnsureDirectoryErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-permission-denied", Error) {};
6
+ var EnsureDirectoryErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-not-directory", Error) {};
7
+ var EnsureDirectoryErrorNoSpace = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-no-space", Error) {};
8
+ var EnsureDirectoryErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-read-only", Error) {};
9
+ var EnsureDirectoryErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-invalid-argument", Error) {};
10
+ var EnsureDirectoryErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-too-many-open-files", Error) {};
11
+ var EnsureDirectoryErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-busy", Error) {};
12
+ var EnsureDirectoryError = class extends DCommon.DuploJSError.parentClass("file-system-ensure-directory-error", Error) {};
4
13
  function handleNodeEnsureDirectoryError(error) {
5
- if (typeof error === "object" && error !== null && "code" in error) {
6
- if (error.code === "EACCES" || error.code === "EPERM") return DEither.left("file-system-ensure-directory-permission-denied", error);
7
- else if (error.code === "ENOTDIR") return DEither.left("file-system-ensure-directory-not-directory", error);
8
- else if (error.code === "ENOSPC") return DEither.left("file-system-ensure-directory-no-space", error);
9
- else if (error.code === "EROFS") return DEither.left("file-system-ensure-directory-read-only", error);
10
- else if (error.code === "EINVAL") return DEither.left("file-system-ensure-directory-invalid-argument", error);
11
- else if (error.code === "EMFILE" || error.code === "ENFILE") return DEither.left("file-system-ensure-directory-too-many-open-files", error);
12
- else if (error.code === "EBUSY") return DEither.left("file-system-ensure-directory-busy", error);
14
+ let ensureDirectoryError = void 0;
15
+ if ("code" in error) {
16
+ if (error.code === "EACCES" || error.code === "EPERM") ensureDirectoryError = new EnsureDirectoryErrorPermissionDenied(error);
17
+ else if (error.code === "ENOTDIR") ensureDirectoryError = new EnsureDirectoryErrorNotDirectory(error);
18
+ else if (error.code === "ENOSPC") ensureDirectoryError = new EnsureDirectoryErrorNoSpace(error);
19
+ else if (error.code === "EROFS") ensureDirectoryError = new EnsureDirectoryErrorReadOnly(error);
20
+ else if (error.code === "EINVAL") ensureDirectoryError = new EnsureDirectoryErrorInvalidArgument(error);
21
+ else if (error.code === "EMFILE" || error.code === "ENFILE") ensureDirectoryError = new EnsureDirectoryErrorTooManyOpenFiles(error);
22
+ else if (error.code === "EBUSY") ensureDirectoryError = new EnsureDirectoryErrorBusy(error);
13
23
  }
14
- return DEither.left("file-system-ensure-directory-error", error);
24
+ if (ensureDirectoryError === void 0) ensureDirectoryError = new EnsureDirectoryError(error);
25
+ return DEither.left("file-system-ensure-directory-error", ensureDirectoryError);
15
26
  }
16
27
  function handleDenoEnsureDirectoryError(error) {
17
- if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return DEither.left("file-system-ensure-directory-permission-denied", error);
18
- if (error instanceof Deno.errors.NotADirectory) return DEither.left("file-system-ensure-directory-not-directory", error);
19
- if (error instanceof Deno.errors.InvalidData) return DEither.left("file-system-ensure-directory-invalid-argument", error);
20
- if (error instanceof Deno.errors.Busy) return DEither.left("file-system-ensure-directory-busy", error);
21
- return DEither.left("file-system-ensure-directory-error", error);
28
+ let ensureDirectoryError = void 0;
29
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) ensureDirectoryError = new EnsureDirectoryErrorPermissionDenied(error);
30
+ else if (error instanceof Deno.errors.NotADirectory) ensureDirectoryError = new EnsureDirectoryErrorNotDirectory(error);
31
+ else if (error instanceof Deno.errors.InvalidData) ensureDirectoryError = new EnsureDirectoryErrorInvalidArgument(error);
32
+ else if (error instanceof Deno.errors.Busy) ensureDirectoryError = new EnsureDirectoryErrorBusy(error);
33
+ if (ensureDirectoryError === void 0) ensureDirectoryError = new EnsureDirectoryError(error);
34
+ return DEither.left("file-system-ensure-directory-error", ensureDirectoryError);
22
35
  }
23
36
  const ensureDirectory = implementFunction("ensureDirectory", {
24
- NODE: async (path) => {
25
- return (await nodeFileSystem.value).mkdir(path, { recursive: true }).then(() => DEither.right("file-system-ensure-directory")).catch(handleNodeEnsureDirectoryError);
26
- },
37
+ NODE: async (path) => nodeFileSystem.value.mkdir(path, { recursive: true }).then(() => DEither.right("file-system-ensure-directory")).catch(handleNodeEnsureDirectoryError),
27
38
  DENO: (path) => Deno.mkdir(path, { recursive: true }).then(() => DEither.right("file-system-ensure-directory")).catch(handleDenoEnsureDirectoryError)
28
39
  });
29
40
  //#endregion
30
- export { ensureDirectory };
41
+ export { EnsureDirectoryError, EnsureDirectoryErrorBusy, EnsureDirectoryErrorInvalidArgument, EnsureDirectoryErrorNoSpace, EnsureDirectoryErrorNotDirectory, EnsureDirectoryErrorPermissionDenied, EnsureDirectoryErrorReadOnly, EnsureDirectoryErrorTooManyOpenFiles, ensureDirectory };
@@ -1,33 +1,46 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_implementor = require("../implementor.cjs");
3
+ let _duplojs_lang_common = require("@duplojs/lang/common");
4
+ _duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
3
5
  let _duplojs_lang_either = require("@duplojs/lang/either");
4
6
  _duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
5
7
  //#region scripts/file/ensureFile.ts
8
+ var EnsureFileErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-permission-denied", Error) {};
9
+ var EnsureFileErrorIsDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-is-directory", Error) {};
10
+ var EnsureFileErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-not-directory", Error) {};
11
+ var EnsureFileErrorNoSpace = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-no-space", Error) {};
12
+ var EnsureFileErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-read-only", Error) {};
13
+ var EnsureFileErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-invalid-argument", Error) {};
14
+ var EnsureFileErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-too-many-open-files", Error) {};
15
+ var EnsureFileErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-busy", Error) {};
16
+ var EnsureFileError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-ensure-file-error", Error) {};
6
17
  function handleNodeEnsureFileError(error) {
7
- if (typeof error === "object" && error !== null && "code" in error) {
8
- if (error.code === "EACCES" || error.code === "EPERM") return _duplojs_lang_either.left("file-system-ensure-file-permission-denied", error);
9
- else if (error.code === "EISDIR") return _duplojs_lang_either.left("file-system-ensure-file-is-directory", error);
10
- else if (error.code === "ENOTDIR") return _duplojs_lang_either.left("file-system-ensure-file-not-directory", error);
11
- else if (error.code === "ENOSPC") return _duplojs_lang_either.left("file-system-ensure-file-no-space", error);
12
- else if (error.code === "EROFS") return _duplojs_lang_either.left("file-system-ensure-file-read-only", error);
13
- else if (error.code === "EINVAL") return _duplojs_lang_either.left("file-system-ensure-file-invalid-argument", error);
14
- else if (error.code === "EMFILE" || error.code === "ENFILE") return _duplojs_lang_either.left("file-system-ensure-file-too-many-open-files", error);
15
- else if (error.code === "EBUSY") return _duplojs_lang_either.left("file-system-ensure-file-busy", error);
18
+ let ensureFileError = void 0;
19
+ if ("code" in error) {
20
+ if (error.code === "EACCES" || error.code === "EPERM") ensureFileError = new EnsureFileErrorPermissionDenied(error);
21
+ else if (error.code === "EISDIR") ensureFileError = new EnsureFileErrorIsDirectory(error);
22
+ else if (error.code === "ENOTDIR") ensureFileError = new EnsureFileErrorNotDirectory(error);
23
+ else if (error.code === "ENOSPC") ensureFileError = new EnsureFileErrorNoSpace(error);
24
+ else if (error.code === "EROFS") ensureFileError = new EnsureFileErrorReadOnly(error);
25
+ else if (error.code === "EINVAL") ensureFileError = new EnsureFileErrorInvalidArgument(error);
26
+ else if (error.code === "EMFILE" || error.code === "ENFILE") ensureFileError = new EnsureFileErrorTooManyOpenFiles(error);
27
+ else if (error.code === "EBUSY") ensureFileError = new EnsureFileErrorBusy(error);
16
28
  }
17
- return _duplojs_lang_either.left("file-system-ensure-file-error", error);
29
+ if (ensureFileError === void 0) ensureFileError = new EnsureFileError(error);
30
+ return _duplojs_lang_either.left("file-system-ensure-file-error", ensureFileError);
18
31
  }
19
32
  function handleDenoEnsureFileError(error) {
20
- if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return _duplojs_lang_either.left("file-system-ensure-file-permission-denied", error);
21
- if (error instanceof Deno.errors.IsADirectory) return _duplojs_lang_either.left("file-system-ensure-file-is-directory", error);
22
- if (error instanceof Deno.errors.NotADirectory) return _duplojs_lang_either.left("file-system-ensure-file-not-directory", error);
23
- if (error instanceof Deno.errors.InvalidData) return _duplojs_lang_either.left("file-system-ensure-file-invalid-argument", error);
24
- if (error instanceof Deno.errors.Busy) return _duplojs_lang_either.left("file-system-ensure-file-busy", error);
25
- return _duplojs_lang_either.left("file-system-ensure-file-error", error);
33
+ let ensureFileError = void 0;
34
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) ensureFileError = new EnsureFileErrorPermissionDenied(error);
35
+ else if (error instanceof Deno.errors.IsADirectory) ensureFileError = new EnsureFileErrorIsDirectory(error);
36
+ else if (error instanceof Deno.errors.NotADirectory) ensureFileError = new EnsureFileErrorNotDirectory(error);
37
+ else if (error instanceof Deno.errors.InvalidData) ensureFileError = new EnsureFileErrorInvalidArgument(error);
38
+ else if (error instanceof Deno.errors.Busy) ensureFileError = new EnsureFileErrorBusy(error);
39
+ if (ensureFileError === void 0) ensureFileError = new EnsureFileError(error);
40
+ return _duplojs_lang_either.left("file-system-ensure-file-error", ensureFileError);
26
41
  }
27
42
  const ensureFile = require_implementor.implementFunction("ensureFile", {
28
- NODE: async (path) => {
29
- return (await require_implementor.nodeFileSystem.value).open(path, "a").then((fh) => fh.close()).then(() => _duplojs_lang_either.right("file-system-ensure-file")).catch(handleNodeEnsureFileError);
30
- },
43
+ NODE: async (path) => require_implementor.nodeFileSystem.value.open(path, "a").then((fh) => fh.close()).then(() => _duplojs_lang_either.right("file-system-ensure-file")).catch(handleNodeEnsureFileError),
31
44
  DENO: (path) => Deno.open(path, {
32
45
  write: true,
33
46
  create: true,
@@ -35,4 +48,13 @@ const ensureFile = require_implementor.implementFunction("ensureFile", {
35
48
  }).then((fh) => void fh.close()).then(() => _duplojs_lang_either.right("file-system-ensure-file")).catch(handleDenoEnsureFileError)
36
49
  });
37
50
  //#endregion
51
+ exports.EnsureFileError = EnsureFileError;
52
+ exports.EnsureFileErrorBusy = EnsureFileErrorBusy;
53
+ exports.EnsureFileErrorInvalidArgument = EnsureFileErrorInvalidArgument;
54
+ exports.EnsureFileErrorIsDirectory = EnsureFileErrorIsDirectory;
55
+ exports.EnsureFileErrorNoSpace = EnsureFileErrorNoSpace;
56
+ exports.EnsureFileErrorNotDirectory = EnsureFileErrorNotDirectory;
57
+ exports.EnsureFileErrorPermissionDenied = EnsureFileErrorPermissionDenied;
58
+ exports.EnsureFileErrorReadOnly = EnsureFileErrorReadOnly;
59
+ exports.EnsureFileErrorTooManyOpenFiles = EnsureFileErrorTooManyOpenFiles;
38
60
  exports.ensureFile = ensureFile;
@@ -1,10 +1,39 @@
1
- import { FileSystemEither } from './types';
2
1
  import * as DEither from "@duplojs/lang/either";
3
2
  import type * as DPath from "@duplojs/lang/path";
4
- export type EnsureFileResult = FileSystemEither<DEither.Right<"ensure-file", void> | DEither.Left<"ensure-file-permission-denied", unknown> | DEither.Left<"ensure-file-is-directory", unknown> | DEither.Left<"ensure-file-not-directory", unknown> | DEither.Left<"ensure-file-no-space", unknown> | DEither.Left<"ensure-file-read-only", unknown> | DEither.Left<"ensure-file-invalid-argument", unknown> | DEither.Left<"ensure-file-too-many-open-files", unknown> | DEither.Left<"ensure-file-busy", unknown> | DEither.Left<"ensure-file-error", unknown>>;
3
+ import * as DCommon from "@duplojs/lang/common";
4
+ declare const EnsureFileErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-permission-denied", unknown>>, unknown>;
5
+ export declare class EnsureFileErrorPermissionDenied extends EnsureFileErrorPermissionDenied_base {
6
+ }
7
+ declare const EnsureFileErrorIsDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-is-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-is-directory", unknown>>, unknown>;
8
+ export declare class EnsureFileErrorIsDirectory extends EnsureFileErrorIsDirectory_base {
9
+ }
10
+ declare const EnsureFileErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-not-directory", unknown>>, unknown>;
11
+ export declare class EnsureFileErrorNotDirectory extends EnsureFileErrorNotDirectory_base {
12
+ }
13
+ declare const EnsureFileErrorNoSpace_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-no-space", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-no-space", unknown>>, unknown>;
14
+ export declare class EnsureFileErrorNoSpace extends EnsureFileErrorNoSpace_base {
15
+ }
16
+ declare const EnsureFileErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-read-only", unknown>>, unknown>;
17
+ export declare class EnsureFileErrorReadOnly extends EnsureFileErrorReadOnly_base {
18
+ }
19
+ declare const EnsureFileErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-invalid-argument", unknown>>, unknown>;
20
+ export declare class EnsureFileErrorInvalidArgument extends EnsureFileErrorInvalidArgument_base {
21
+ }
22
+ declare const EnsureFileErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-too-many-open-files", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-too-many-open-files", unknown>>, unknown>;
23
+ export declare class EnsureFileErrorTooManyOpenFiles extends EnsureFileErrorTooManyOpenFiles_base {
24
+ }
25
+ declare const EnsureFileErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-busy", unknown>>, unknown>;
26
+ export declare class EnsureFileErrorBusy extends EnsureFileErrorBusy_base {
27
+ }
28
+ declare const EnsureFileError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-ensure-file-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-ensure-file-error", unknown>>, unknown>;
29
+ export declare class EnsureFileError extends EnsureFileError_base {
30
+ }
31
+ export type EnsureFileErrors = (EnsureFileErrorPermissionDenied | EnsureFileErrorIsDirectory | EnsureFileErrorNotDirectory | EnsureFileErrorNoSpace | EnsureFileErrorReadOnly | EnsureFileErrorInvalidArgument | EnsureFileErrorTooManyOpenFiles | EnsureFileErrorBusy | EnsureFileError);
32
+ export type EnsureFileResult = (DEither.Right<"file-system-ensure-file", void> | DEither.Left<"file-system-ensure-file-error", EnsureFileErrors>);
5
33
  declare module '../implementor' {
6
34
  interface ServerFunction {
7
- ensureFile(path: string & DPath.Path): Promise<EnsureFileResult>;
35
+ ensureFile(path: DPath.AnyPath): Promise<EnsureFileResult>;
8
36
  }
9
37
  }
10
- export declare const ensureFile: (path: string & DPath.Path) => Promise<EnsureFileResult>;
38
+ export declare const ensureFile: (path: DPath.AnyPath) => Promise<EnsureFileResult>;
39
+ export {};
@@ -1,31 +1,43 @@
1
1
  import { implementFunction, nodeFileSystem } from "../implementor.mjs";
2
+ import * as DCommon from "@duplojs/lang/common";
2
3
  import * as DEither from "@duplojs/lang/either";
3
4
  //#region scripts/file/ensureFile.ts
5
+ var EnsureFileErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-permission-denied", Error) {};
6
+ var EnsureFileErrorIsDirectory = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-is-directory", Error) {};
7
+ var EnsureFileErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-not-directory", Error) {};
8
+ var EnsureFileErrorNoSpace = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-no-space", Error) {};
9
+ var EnsureFileErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-read-only", Error) {};
10
+ var EnsureFileErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-invalid-argument", Error) {};
11
+ var EnsureFileErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-too-many-open-files", Error) {};
12
+ var EnsureFileErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-busy", Error) {};
13
+ var EnsureFileError = class extends DCommon.DuploJSError.parentClass("file-system-ensure-file-error", Error) {};
4
14
  function handleNodeEnsureFileError(error) {
5
- if (typeof error === "object" && error !== null && "code" in error) {
6
- if (error.code === "EACCES" || error.code === "EPERM") return DEither.left("file-system-ensure-file-permission-denied", error);
7
- else if (error.code === "EISDIR") return DEither.left("file-system-ensure-file-is-directory", error);
8
- else if (error.code === "ENOTDIR") return DEither.left("file-system-ensure-file-not-directory", error);
9
- else if (error.code === "ENOSPC") return DEither.left("file-system-ensure-file-no-space", error);
10
- else if (error.code === "EROFS") return DEither.left("file-system-ensure-file-read-only", error);
11
- else if (error.code === "EINVAL") return DEither.left("file-system-ensure-file-invalid-argument", error);
12
- else if (error.code === "EMFILE" || error.code === "ENFILE") return DEither.left("file-system-ensure-file-too-many-open-files", error);
13
- else if (error.code === "EBUSY") return DEither.left("file-system-ensure-file-busy", error);
15
+ let ensureFileError = void 0;
16
+ if ("code" in error) {
17
+ if (error.code === "EACCES" || error.code === "EPERM") ensureFileError = new EnsureFileErrorPermissionDenied(error);
18
+ else if (error.code === "EISDIR") ensureFileError = new EnsureFileErrorIsDirectory(error);
19
+ else if (error.code === "ENOTDIR") ensureFileError = new EnsureFileErrorNotDirectory(error);
20
+ else if (error.code === "ENOSPC") ensureFileError = new EnsureFileErrorNoSpace(error);
21
+ else if (error.code === "EROFS") ensureFileError = new EnsureFileErrorReadOnly(error);
22
+ else if (error.code === "EINVAL") ensureFileError = new EnsureFileErrorInvalidArgument(error);
23
+ else if (error.code === "EMFILE" || error.code === "ENFILE") ensureFileError = new EnsureFileErrorTooManyOpenFiles(error);
24
+ else if (error.code === "EBUSY") ensureFileError = new EnsureFileErrorBusy(error);
14
25
  }
15
- return DEither.left("file-system-ensure-file-error", error);
26
+ if (ensureFileError === void 0) ensureFileError = new EnsureFileError(error);
27
+ return DEither.left("file-system-ensure-file-error", ensureFileError);
16
28
  }
17
29
  function handleDenoEnsureFileError(error) {
18
- if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return DEither.left("file-system-ensure-file-permission-denied", error);
19
- if (error instanceof Deno.errors.IsADirectory) return DEither.left("file-system-ensure-file-is-directory", error);
20
- if (error instanceof Deno.errors.NotADirectory) return DEither.left("file-system-ensure-file-not-directory", error);
21
- if (error instanceof Deno.errors.InvalidData) return DEither.left("file-system-ensure-file-invalid-argument", error);
22
- if (error instanceof Deno.errors.Busy) return DEither.left("file-system-ensure-file-busy", error);
23
- return DEither.left("file-system-ensure-file-error", error);
30
+ let ensureFileError = void 0;
31
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) ensureFileError = new EnsureFileErrorPermissionDenied(error);
32
+ else if (error instanceof Deno.errors.IsADirectory) ensureFileError = new EnsureFileErrorIsDirectory(error);
33
+ else if (error instanceof Deno.errors.NotADirectory) ensureFileError = new EnsureFileErrorNotDirectory(error);
34
+ else if (error instanceof Deno.errors.InvalidData) ensureFileError = new EnsureFileErrorInvalidArgument(error);
35
+ else if (error instanceof Deno.errors.Busy) ensureFileError = new EnsureFileErrorBusy(error);
36
+ if (ensureFileError === void 0) ensureFileError = new EnsureFileError(error);
37
+ return DEither.left("file-system-ensure-file-error", ensureFileError);
24
38
  }
25
39
  const ensureFile = implementFunction("ensureFile", {
26
- NODE: async (path) => {
27
- return (await nodeFileSystem.value).open(path, "a").then((fh) => fh.close()).then(() => DEither.right("file-system-ensure-file")).catch(handleNodeEnsureFileError);
28
- },
40
+ NODE: async (path) => nodeFileSystem.value.open(path, "a").then((fh) => fh.close()).then(() => DEither.right("file-system-ensure-file")).catch(handleNodeEnsureFileError),
29
41
  DENO: (path) => Deno.open(path, {
30
42
  write: true,
31
43
  create: true,
@@ -33,4 +45,4 @@ const ensureFile = implementFunction("ensureFile", {
33
45
  }).then((fh) => void fh.close()).then(() => DEither.right("file-system-ensure-file")).catch(handleDenoEnsureFileError)
34
46
  });
35
47
  //#endregion
36
- export { ensureFile };
48
+ export { EnsureFileError, EnsureFileErrorBusy, EnsureFileErrorInvalidArgument, EnsureFileErrorIsDirectory, EnsureFileErrorNoSpace, EnsureFileErrorNotDirectory, EnsureFileErrorPermissionDenied, EnsureFileErrorReadOnly, EnsureFileErrorTooManyOpenFiles, ensureFile };
@@ -1,29 +1,43 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_implementor = require("../implementor.cjs");
3
+ let _duplojs_lang_common = require("@duplojs/lang/common");
4
+ _duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
3
5
  let _duplojs_lang_either = require("@duplojs/lang/either");
4
6
  _duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
5
7
  //#region scripts/file/exists.ts
8
+ var ExistsErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-exists-not-found", Error) {};
9
+ var ExistsErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-exists-permission-denied", Error) {};
10
+ var ExistsErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-exists-not-directory", Error) {};
11
+ var ExistsErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-exists-too-many-open-files", Error) {};
12
+ var ExistsError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-exists-error", Error) {};
6
13
  function handleNodeExistsError(error) {
7
- if (typeof error === "object" && error !== null && "code" in error) {
8
- if (error.code === "ENOENT") return _duplojs_lang_either.left("file-system-exists-not-found", error);
9
- else if (error.code === "EACCES" || error.code === "EPERM") return _duplojs_lang_either.left("file-system-exists-permission-denied", error);
10
- else if (error.code === "ENOTDIR") return _duplojs_lang_either.left("file-system-exists-not-directory", error);
11
- else if (error.code === "EMFILE" || error.code === "ENFILE") return _duplojs_lang_either.left("file-system-exists-too-many-open-files", error);
14
+ let existsError = void 0;
15
+ if ("code" in error) {
16
+ if (error.code === "ENOENT") existsError = new ExistsErrorNotFound(error);
17
+ else if (error.code === "EACCES" || error.code === "EPERM") existsError = new ExistsErrorPermissionDenied(error);
18
+ else if (error.code === "ENOTDIR") existsError = new ExistsErrorNotDirectory(error);
19
+ else if (error.code === "EMFILE" || error.code === "ENFILE") existsError = new ExistsErrorTooManyOpenFiles(error);
12
20
  }
13
- return _duplojs_lang_either.left("file-system-exists-error", error);
21
+ if (existsError === void 0) existsError = new ExistsError(error);
22
+ return _duplojs_lang_either.left("file-system-exists-error", existsError);
14
23
  }
15
24
  function handleDenoExistsError(error) {
16
- if (error instanceof Deno.errors.NotFound) return _duplojs_lang_either.left("file-system-exists-not-found", error);
17
- if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return _duplojs_lang_either.left("file-system-exists-permission-denied", error);
18
- if (error instanceof Deno.errors.NotADirectory) return _duplojs_lang_either.left("file-system-exists-not-directory", error);
19
- return _duplojs_lang_either.left("file-system-exists-error", error);
25
+ let existsError = void 0;
26
+ if (error instanceof Deno.errors.NotFound) existsError = new ExistsErrorNotFound(error);
27
+ else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) existsError = new ExistsErrorPermissionDenied(error);
28
+ else if (error instanceof Deno.errors.NotADirectory) existsError = new ExistsErrorNotDirectory(error);
29
+ if (existsError === void 0) existsError = new ExistsError(error);
30
+ return _duplojs_lang_either.left("file-system-exists-error", existsError);
20
31
  }
21
32
  const exists = require_implementor.implementFunction("exists", {
22
- NODE: async (path) => {
23
- return (await require_implementor.nodeFileSystem.value).access(path).then(() => _duplojs_lang_either.right("file-system-exists")).catch(handleNodeExistsError);
24
- },
33
+ NODE: async (path) => require_implementor.nodeFileSystem.value.access(path).then(() => _duplojs_lang_either.right("file-system-exists")).catch(handleNodeExistsError),
25
34
  DENO: (path) => Deno.stat(path).then(() => _duplojs_lang_either.right("file-system-exists")).catch(handleDenoExistsError),
26
- BUN: (path) => Bun.file(path).exists().then((value) => value ? _duplojs_lang_either.right("file-system-exists") : _duplojs_lang_either.left("file-system-exists-not-found", /* @__PURE__ */ new Error("Path does not exist"))).catch(handleNodeExistsError)
35
+ BUN: (path) => Bun.file(path).exists().then((value) => value ? _duplojs_lang_either.right("file-system-exists") : _duplojs_lang_either.left("file-system-exists-error", new ExistsErrorNotFound(/* @__PURE__ */ new Error("Path does not exist")))).catch(handleNodeExistsError)
27
36
  });
28
37
  //#endregion
38
+ exports.ExistsError = ExistsError;
39
+ exports.ExistsErrorNotDirectory = ExistsErrorNotDirectory;
40
+ exports.ExistsErrorNotFound = ExistsErrorNotFound;
41
+ exports.ExistsErrorPermissionDenied = ExistsErrorPermissionDenied;
42
+ exports.ExistsErrorTooManyOpenFiles = ExistsErrorTooManyOpenFiles;
29
43
  exports.exists = exists;
@@ -1,10 +1,27 @@
1
- import { FileSystemEither } from './types';
2
1
  import * as DEither from "@duplojs/lang/either";
3
2
  import type * as DPath from "@duplojs/lang/path";
4
- export type ExistsResult = FileSystemEither<DEither.Right<"exists", void> | DEither.Left<"exists-not-found", unknown> | DEither.Left<"exists-permission-denied", unknown> | DEither.Left<"exists-not-directory", unknown> | DEither.Left<"exists-too-many-open-files", unknown> | DEither.Left<"exists-error", unknown>>;
3
+ import * as DCommon from "@duplojs/lang/common";
4
+ declare const ExistsErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-exists-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-exists-not-found", unknown>>, unknown>;
5
+ export declare class ExistsErrorNotFound extends ExistsErrorNotFound_base {
6
+ }
7
+ declare const ExistsErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-exists-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-exists-permission-denied", unknown>>, unknown>;
8
+ export declare class ExistsErrorPermissionDenied extends ExistsErrorPermissionDenied_base {
9
+ }
10
+ declare const ExistsErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-exists-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-exists-not-directory", unknown>>, unknown>;
11
+ export declare class ExistsErrorNotDirectory extends ExistsErrorNotDirectory_base {
12
+ }
13
+ declare const ExistsErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-exists-too-many-open-files", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-exists-too-many-open-files", unknown>>, unknown>;
14
+ export declare class ExistsErrorTooManyOpenFiles extends ExistsErrorTooManyOpenFiles_base {
15
+ }
16
+ declare const ExistsError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-exists-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-exists-error", unknown>>, unknown>;
17
+ export declare class ExistsError extends ExistsError_base {
18
+ }
19
+ export type ExistsErrors = (ExistsErrorNotFound | ExistsErrorPermissionDenied | ExistsErrorNotDirectory | ExistsErrorTooManyOpenFiles | ExistsError);
20
+ export type ExistsResult = (DEither.Right<"file-system-exists", void> | DEither.Left<"file-system-exists-error", ExistsErrors>);
5
21
  declare module '../implementor' {
6
22
  interface ServerFunction {
7
- exists(path: string & DPath.Path): Promise<ExistsResult>;
23
+ exists(path: DPath.AnyPath): Promise<ExistsResult>;
8
24
  }
9
25
  }
10
- export declare const exists: (path: string & DPath.Path) => Promise<ExistsResult>;
26
+ export declare const exists: (path: DPath.AnyPath) => Promise<ExistsResult>;
27
+ export {};
@@ -1,27 +1,35 @@
1
1
  import { implementFunction, nodeFileSystem } from "../implementor.mjs";
2
+ import * as DCommon from "@duplojs/lang/common";
2
3
  import * as DEither from "@duplojs/lang/either";
3
4
  //#region scripts/file/exists.ts
5
+ var ExistsErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-exists-not-found", Error) {};
6
+ var ExistsErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-exists-permission-denied", Error) {};
7
+ var ExistsErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-exists-not-directory", Error) {};
8
+ var ExistsErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-exists-too-many-open-files", Error) {};
9
+ var ExistsError = class extends DCommon.DuploJSError.parentClass("file-system-exists-error", Error) {};
4
10
  function handleNodeExistsError(error) {
5
- if (typeof error === "object" && error !== null && "code" in error) {
6
- if (error.code === "ENOENT") return DEither.left("file-system-exists-not-found", error);
7
- else if (error.code === "EACCES" || error.code === "EPERM") return DEither.left("file-system-exists-permission-denied", error);
8
- else if (error.code === "ENOTDIR") return DEither.left("file-system-exists-not-directory", error);
9
- else if (error.code === "EMFILE" || error.code === "ENFILE") return DEither.left("file-system-exists-too-many-open-files", error);
11
+ let existsError = void 0;
12
+ if ("code" in error) {
13
+ if (error.code === "ENOENT") existsError = new ExistsErrorNotFound(error);
14
+ else if (error.code === "EACCES" || error.code === "EPERM") existsError = new ExistsErrorPermissionDenied(error);
15
+ else if (error.code === "ENOTDIR") existsError = new ExistsErrorNotDirectory(error);
16
+ else if (error.code === "EMFILE" || error.code === "ENFILE") existsError = new ExistsErrorTooManyOpenFiles(error);
10
17
  }
11
- return DEither.left("file-system-exists-error", error);
18
+ if (existsError === void 0) existsError = new ExistsError(error);
19
+ return DEither.left("file-system-exists-error", existsError);
12
20
  }
13
21
  function handleDenoExistsError(error) {
14
- if (error instanceof Deno.errors.NotFound) return DEither.left("file-system-exists-not-found", error);
15
- if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return DEither.left("file-system-exists-permission-denied", error);
16
- if (error instanceof Deno.errors.NotADirectory) return DEither.left("file-system-exists-not-directory", error);
17
- return DEither.left("file-system-exists-error", error);
22
+ let existsError = void 0;
23
+ if (error instanceof Deno.errors.NotFound) existsError = new ExistsErrorNotFound(error);
24
+ else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) existsError = new ExistsErrorPermissionDenied(error);
25
+ else if (error instanceof Deno.errors.NotADirectory) existsError = new ExistsErrorNotDirectory(error);
26
+ if (existsError === void 0) existsError = new ExistsError(error);
27
+ return DEither.left("file-system-exists-error", existsError);
18
28
  }
19
29
  const exists = implementFunction("exists", {
20
- NODE: async (path) => {
21
- return (await nodeFileSystem.value).access(path).then(() => DEither.right("file-system-exists")).catch(handleNodeExistsError);
22
- },
30
+ NODE: async (path) => nodeFileSystem.value.access(path).then(() => DEither.right("file-system-exists")).catch(handleNodeExistsError),
23
31
  DENO: (path) => Deno.stat(path).then(() => DEither.right("file-system-exists")).catch(handleDenoExistsError),
24
- BUN: (path) => Bun.file(path).exists().then((value) => value ? DEither.right("file-system-exists") : DEither.left("file-system-exists-not-found", /* @__PURE__ */ new Error("Path does not exist"))).catch(handleNodeExistsError)
32
+ BUN: (path) => Bun.file(path).exists().then((value) => value ? DEither.right("file-system-exists") : DEither.left("file-system-exists-error", new ExistsErrorNotFound(/* @__PURE__ */ new Error("Path does not exist")))).catch(handleNodeExistsError)
25
33
  });
26
34
  //#endregion
27
- export { exists };
35
+ export { ExistsError, ExistsErrorNotDirectory, ExistsErrorNotFound, ExistsErrorPermissionDenied, ExistsErrorTooManyOpenFiles, exists };
@@ -51,7 +51,7 @@ function createFileInterface(path) {
51
51
  return _duplojs_lang_common.asyncPipe(localStat(), _duplojs_lang_either.whenHasInformationOtherwise("file-system-stat", ({ isFile }) => isFile, _duplojs_lang_common.justReturn(false)));
52
52
  }
53
53
  return {
54
- path,
54
+ path: _duplojs_lang_common.cast(path),
55
55
  getName,
56
56
  getExtension,
57
57
  getMimeType,
@@ -69,6 +69,8 @@ function createFileInterface(path) {
69
69
  function isFileInterface(input) {
70
70
  return fileInterfaceKind.has(input);
71
71
  }
72
+ const isFileInterfaceFromUnknown = isFileInterface;
72
73
  //#endregion
73
74
  exports.createFileInterface = createFileInterface;
74
75
  exports.isFileInterface = isFileInterface;
76
+ exports.isFileInterfaceFromUnknown = isFileInterfaceFromUnknown;
@@ -11,20 +11,21 @@ declare const fileInterfaceKind: DKind.Handler<DKind.Definition<"@DuplojsServer/
11
11
  type FileInterfaceRenameResult = Exclude<RenameResult, DEither.Right> | DEither.Right<"file-system-rename", FileInterface>;
12
12
  type FileInterfaceRelocateResult = Exclude<RelocateResult, DEither.Right> | DEither.Right<"file-system-relocate", FileInterface>;
13
13
  type FileInterfaceMoveResult = Exclude<MoveResult, DEither.Right> | DEither.Right<"file-system-move", FileInterface>;
14
- export interface FileInterface extends DKind.Kind<typeof fileInterfaceKind> {
15
- path: string & DPath.Path;
16
- getName(): (string & DPath.Segment) | null;
14
+ export interface FileInterface<GenericPath extends DPath.AnyPath = DPath.AnyPath> extends DKind.Kind<typeof fileInterfaceKind> {
15
+ path: GenericPath & DPath.Path;
16
+ getName(): (string & DPath.Segment & DPath.Path) | null;
17
17
  getMimeType(): string | null;
18
- getExtension(params?: DPath.GetExtensionNameParams): (string & DPath.Segment) | null;
19
- getParentPath(): (string & DPath.Path) | null;
18
+ getExtension(params?: DPath.GetExtensionNameParams): (string & DPath.Segment & DPath.Path) | null;
19
+ getParentPath(): ReturnType<typeof DPath.getParentFolderPath<GenericPath>>;
20
20
  rename(newName: string & DPath.Segment): Promise<FileInterfaceRenameResult>;
21
- relocate(parentPath: string & DPath.Path): Promise<FileInterfaceRelocateResult>;
22
- move(newPath: string & DPath.Path): Promise<FileInterfaceMoveResult>;
21
+ relocate(parentPath: DPath.AnyPath): Promise<FileInterfaceRelocateResult>;
22
+ move(newPath: DPath.AnyPath): Promise<FileInterfaceMoveResult>;
23
23
  exists(): Promise<ExistsResult>;
24
24
  remove(): Promise<RemoveResult>;
25
25
  stat(): Promise<StatResult>;
26
26
  isFile(): Promise<boolean>;
27
27
  }
28
- export declare function createFileInterface(path: string & DPath.Path): FileInterface;
29
- export declare function isFileInterface(input: unknown): input is FileInterface;
28
+ export declare function createFileInterface<GenericPath extends DPath.AnyPath = DPath.AnyPath>(path: GenericPath): FileInterface<GenericPath>;
29
+ export declare function isFileInterface<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, FileInterface>;
30
+ export declare const isFileInterfaceFromUnknown: (input: unknown) => input is FileInterface;
30
31
  export {};
@@ -47,7 +47,7 @@ function createFileInterface(path) {
47
47
  return DCommon.asyncPipe(localStat(), DEither.whenHasInformationOtherwise("file-system-stat", ({ isFile }) => isFile, DCommon.justReturn(false)));
48
48
  }
49
49
  return {
50
- path,
50
+ path: DCommon.cast(path),
51
51
  getName,
52
52
  getExtension,
53
53
  getMimeType,
@@ -65,5 +65,6 @@ function createFileInterface(path) {
65
65
  function isFileInterface(input) {
66
66
  return fileInterfaceKind.has(input);
67
67
  }
68
+ const isFileInterfaceFromUnknown = isFileInterface;
68
69
  //#endregion
69
- export { createFileInterface, isFileInterface };
70
+ export { createFileInterface, isFileInterface, isFileInterfaceFromUnknown };
@@ -51,7 +51,7 @@ function createFolderInterface(path) {
51
51
  return _duplojs_lang_common.asyncPipe(localStat(), _duplojs_lang_either.whenHasInformationOtherwise("file-system-stat", ({ isDirectory }) => isDirectory, _duplojs_lang_common.justReturn(false)));
52
52
  }
53
53
  return {
54
- path,
54
+ path: _duplojs_lang_common.cast(path),
55
55
  getName,
56
56
  getParentPath,
57
57
  move: localMove,
@@ -69,6 +69,8 @@ function createFolderInterface(path) {
69
69
  function isFolderInterface(input) {
70
70
  return folderInterfaceKind.has(input);
71
71
  }
72
+ const isFolderInterfaceFromUnknown = isFolderInterface;
72
73
  //#endregion
73
74
  exports.createFolderInterface = createFolderInterface;
74
75
  exports.isFolderInterface = isFolderInterface;
76
+ exports.isFolderInterfaceFromUnknown = isFolderInterfaceFromUnknown;
@@ -13,20 +13,21 @@ declare const folderInterfaceKind: DKind.Handler<DKind.Definition<"@DuplojsServe
13
13
  type FolderInterfaceRenameResult = Exclude<RenameResult, DEither.Right> | DEither.Right<"file-system-rename", FolderInterface>;
14
14
  type FolderInterfaceRelocateResult = Exclude<RelocateResult, DEither.Right> | DEither.Right<"file-system-relocate", FolderInterface>;
15
15
  type FolderInterfaceMoveResult = Exclude<MoveResult, DEither.Right> | DEither.Right<"file-system-move", FolderInterface>;
16
- export interface FolderInterface extends DKind.Kind<typeof folderInterfaceKind> {
17
- path: string & DPath.Path;
18
- getName(): (string & DPath.Segment) | null;
19
- getParentPath(): (string & DPath.Path) | null;
16
+ export interface FolderInterface<GenericPath extends DPath.AnyPath = DPath.AnyPath> extends DKind.Kind<typeof folderInterfaceKind> {
17
+ path: GenericPath & DPath.Path;
18
+ getName(): (string & DPath.Segment & DPath.Path) | null;
19
+ getParentPath(): ReturnType<typeof DPath.getParentFolderPath<GenericPath>>;
20
20
  rename(newName: (string & DPath.Segment)): Promise<FolderInterfaceRenameResult>;
21
21
  exists(): Promise<ExistsResult>;
22
- relocate(parentPath: string & DPath.Path): Promise<FolderInterfaceRelocateResult>;
23
- move(newPath: string & DPath.Path): Promise<FolderInterfaceMoveResult>;
22
+ relocate(parentPath: DPath.AnyPath): Promise<FolderInterfaceRelocateResult>;
23
+ move(newPath: DPath.AnyPath): Promise<FolderInterfaceMoveResult>;
24
24
  remove(): Promise<RemoveResult>;
25
25
  getChildren(): Promise<ReadDirectoryResult>;
26
26
  stat(): Promise<StatResult>;
27
27
  walk(params?: WalkDirectoryParams): Promise<WalkDirectoryResult>;
28
28
  isFolder(): Promise<boolean>;
29
29
  }
30
- export declare function createFolderInterface(path: string & DPath.Path): FolderInterface;
31
- export declare function isFolderInterface(input: unknown): input is FolderInterface;
30
+ export declare function createFolderInterface<GenericPath extends DPath.AnyPath = DPath.AnyPath>(path: GenericPath): FolderInterface<GenericPath>;
31
+ export declare function isFolderInterface<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, FolderInterface>;
32
+ export declare const isFolderInterfaceFromUnknown: (input: unknown) => input is FolderInterface;
32
33
  export {};
@@ -47,7 +47,7 @@ function createFolderInterface(path) {
47
47
  return DCommon.asyncPipe(localStat(), DEither.whenHasInformationOtherwise("file-system-stat", ({ isDirectory }) => isDirectory, DCommon.justReturn(false)));
48
48
  }
49
49
  return {
50
- path,
50
+ path: DCommon.cast(path),
51
51
  getName,
52
52
  getParentPath,
53
53
  move: localMove,
@@ -65,5 +65,6 @@ function createFolderInterface(path) {
65
65
  function isFolderInterface(input) {
66
66
  return folderInterfaceKind.has(input);
67
67
  }
68
+ const isFolderInterfaceFromUnknown = isFolderInterface;
68
69
  //#endregion
69
- export { createFolderInterface, isFolderInterface };
70
+ export { createFolderInterface, isFolderInterface, isFolderInterfaceFromUnknown };