@duplojs/server 0.0.0-stage → 0.1.0-beta.2

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 (262) hide show
  1. package/README +9 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +33 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +13 -0
  4. package/dist/command/argument.cjs +27 -0
  5. package/dist/command/argument.d.ts +18 -0
  6. package/dist/command/argument.mjs +24 -0
  7. package/dist/command/create.cjs +94 -0
  8. package/dist/command/create.d.ts +47 -0
  9. package/dist/command/create.mjs +88 -0
  10. package/dist/command/error.cjs +153 -0
  11. package/dist/command/error.d.ts +53 -0
  12. package/dist/command/error.mjs +140 -0
  13. package/dist/command/exec.cjs +19 -0
  14. package/dist/command/exec.d.ts +13 -0
  15. package/dist/command/exec.mjs +17 -0
  16. package/dist/command/execOptions.cjs +41 -0
  17. package/dist/command/execOptions.d.ts +14 -0
  18. package/dist/command/execOptions.mjs +37 -0
  19. package/dist/command/help.cjs +257 -0
  20. package/dist/command/help.d.ts +10 -0
  21. package/dist/command/help.mjs +244 -0
  22. package/dist/command/index.cjs +78 -0
  23. package/dist/command/index.d.ts +8 -0
  24. package/dist/command/index.mjs +45 -0
  25. package/dist/command/kind.cjs +7 -0
  26. package/dist/command/kind.d.ts +2 -0
  27. package/dist/command/kind.mjs +5 -0
  28. package/dist/command/options/base.cjs +68 -0
  29. package/dist/command/options/base.d.ts +24 -0
  30. package/dist/command/options/base.mjs +63 -0
  31. package/dist/command/options/defaults/array.cjs +35 -0
  32. package/dist/command/options/defaults/array.d.ts +24 -0
  33. package/dist/command/options/defaults/array.mjs +29 -0
  34. package/dist/command/options/defaults/boolean.cjs +14 -0
  35. package/dist/command/options/defaults/boolean.d.ts +11 -0
  36. package/dist/command/options/defaults/boolean.mjs +13 -0
  37. package/dist/command/options/defaults/index.d.ts +3 -0
  38. package/dist/command/options/defaults/simple.cjs +25 -0
  39. package/dist/command/options/defaults/simple.d.ts +16 -0
  40. package/dist/command/options/defaults/simple.mjs +22 -0
  41. package/dist/command/options/identifier.cjs +7 -0
  42. package/dist/command/options/identifier.d.ts +4 -0
  43. package/dist/command/options/identifier.mjs +5 -0
  44. package/dist/command/options/index.d.ts +4 -0
  45. package/dist/command/options/types/index.d.ts +1 -0
  46. package/dist/command/options/types/options.d.ts +9 -0
  47. package/dist/command/types/eligibleType.d.ts +4 -0
  48. package/dist/command/types/forbiddenDuplicateName.d.ts +11 -0
  49. package/dist/command/types/index.d.ts +2 -0
  50. package/dist/common/environmentVariable/expandEnvironmentVariables.cjs +27 -0
  51. package/dist/common/environmentVariable/expandEnvironmentVariables.d.ts +2 -0
  52. package/dist/common/environmentVariable/expandEnvironmentVariables.mjs +22 -0
  53. package/dist/common/environmentVariable/index.cjs +47 -0
  54. package/dist/common/environmentVariable/index.d.ts +16 -0
  55. package/dist/common/environmentVariable/index.mjs +41 -0
  56. package/dist/common/environmentVariable/overrideEnvironmentVariables.cjs +13 -0
  57. package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +3 -0
  58. package/dist/common/environmentVariable/overrideEnvironmentVariables.mjs +9 -0
  59. package/dist/common/environmentVariable/parseEnvironmentFiles.cjs +32 -0
  60. package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +4 -0
  61. package/dist/common/environmentVariable/parseEnvironmentFiles.mjs +26 -0
  62. package/dist/common/environmentVariableOrThrow.cjs +23 -0
  63. package/dist/common/environmentVariableOrThrow.d.ts +12 -0
  64. package/dist/common/environmentVariableOrThrow.mjs +19 -0
  65. package/dist/common/exitProcess.cjs +7 -0
  66. package/dist/common/exitProcess.d.ts +6 -0
  67. package/dist/common/exitProcess.mjs +8 -0
  68. package/dist/common/getCurrentWorkDirectory.cjs +15 -0
  69. package/dist/common/getCurrentWorkDirectory.d.ts +8 -0
  70. package/dist/common/getCurrentWorkDirectory.mjs +11 -0
  71. package/dist/common/getCurrentWorkDirectoryOrThrow.cjs +25 -0
  72. package/dist/common/getCurrentWorkDirectoryOrThrow.d.ts +8 -0
  73. package/dist/common/getCurrentWorkDirectoryOrThrow.mjs +20 -0
  74. package/dist/common/getProcessArguments.cjs +18 -0
  75. package/dist/common/getProcessArguments.d.ts +6 -0
  76. package/dist/common/getProcessArguments.mjs +18 -0
  77. package/dist/common/index.cjs +41 -0
  78. package/dist/common/index.d.ts +8 -0
  79. package/dist/common/index.mjs +25 -0
  80. package/dist/common/setCurrentWorkingDirectory.cjs +11 -0
  81. package/dist/common/setCurrentWorkingDirectory.d.ts +8 -0
  82. package/dist/common/setCurrentWorkingDirectory.mjs +9 -0
  83. package/dist/common/setCurrentWorkingDirectoryOrThrow.cjs +23 -0
  84. package/dist/common/setCurrentWorkingDirectoryOrThrow.d.ts +8 -0
  85. package/dist/common/setCurrentWorkingDirectoryOrThrow.mjs +18 -0
  86. package/dist/dataStructure/common/codec/defaults/index.d.ts +2 -0
  87. package/dist/dataStructure/common/codec/defaults/json.cjs +14 -0
  88. package/dist/dataStructure/common/codec/defaults/json.d.ts +9 -0
  89. package/dist/dataStructure/common/codec/defaults/json.mjs +11 -0
  90. package/dist/dataStructure/common/codec/defaults/string.cjs +14 -0
  91. package/dist/dataStructure/common/codec/defaults/string.d.ts +13 -0
  92. package/dist/dataStructure/common/codec/defaults/string.mjs +11 -0
  93. package/dist/dataStructure/common/codec/index.d.ts +1 -0
  94. package/dist/dataStructure/common/error/defaultInterpreter.cjs +27 -0
  95. package/dist/dataStructure/common/error/defaultInterpreter.d.ts +64 -0
  96. package/dist/dataStructure/common/error/defaultInterpreter.mjs +24 -0
  97. package/dist/dataStructure/common/error/index.d.ts +1 -0
  98. package/dist/dataStructure/common/index.d.ts +2 -0
  99. package/dist/dataStructure/constraint/exist.cjs +19 -0
  100. package/dist/dataStructure/constraint/exist.d.ts +10 -0
  101. package/dist/dataStructure/constraint/exist.mjs +15 -0
  102. package/dist/dataStructure/constraint/index.d.ts +4 -0
  103. package/dist/dataStructure/constraint/mimeType.cjs +18 -0
  104. package/dist/dataStructure/constraint/mimeType.d.ts +11 -0
  105. package/dist/dataStructure/constraint/mimeType.mjs +14 -0
  106. package/dist/dataStructure/constraint/size.cjs +29 -0
  107. package/dist/dataStructure/constraint/size.d.ts +16 -0
  108. package/dist/dataStructure/constraint/size.mjs +24 -0
  109. package/dist/dataStructure/constraint/types/constraints.d.ts +10 -0
  110. package/dist/dataStructure/constraint/types/index.d.ts +1 -0
  111. package/dist/dataStructure/fundamentalType/file.cjs +11 -0
  112. package/dist/dataStructure/fundamentalType/file.d.ts +8 -0
  113. package/dist/dataStructure/fundamentalType/file.mjs +8 -0
  114. package/dist/dataStructure/fundamentalType/index.d.ts +2 -0
  115. package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +6 -0
  116. package/dist/dataStructure/fundamentalType/types/index.d.ts +1 -0
  117. package/dist/dataStructure/helper/exist.cjs +7 -0
  118. package/dist/dataStructure/helper/exist.d.ts +2 -0
  119. package/dist/dataStructure/helper/exist.mjs +7 -0
  120. package/dist/dataStructure/helper/file.cjs +10 -0
  121. package/dist/dataStructure/helper/file.d.ts +3 -0
  122. package/dist/dataStructure/helper/file.mjs +8 -0
  123. package/dist/dataStructure/helper/index.d.ts +4 -0
  124. package/dist/dataStructure/helper/mimeType.cjs +7 -0
  125. package/dist/dataStructure/helper/mimeType.d.ts +2 -0
  126. package/dist/dataStructure/helper/mimeType.mjs +7 -0
  127. package/dist/dataStructure/helper/size.cjs +7 -0
  128. package/dist/dataStructure/helper/size.d.ts +2 -0
  129. package/dist/dataStructure/helper/size.mjs +7 -0
  130. package/dist/dataStructure/index.cjs +62 -0
  131. package/dist/dataStructure/index.d.ts +6 -0
  132. package/dist/dataStructure/index.mjs +38 -0
  133. package/dist/dataStructure/kind.cjs +7 -0
  134. package/dist/dataStructure/kind.d.ts +2 -0
  135. package/dist/dataStructure/kind.mjs +5 -0
  136. package/dist/dataStructure/type/file.cjs +14 -0
  137. package/dist/dataStructure/type/file.d.ts +11 -0
  138. package/dist/dataStructure/type/file.mjs +11 -0
  139. package/dist/dataStructure/type/index.d.ts +2 -0
  140. package/dist/dataStructure/type/types/index.d.ts +1 -0
  141. package/dist/dataStructure/type/types/types.d.ts +6 -0
  142. package/dist/file/appendFile.cjs +43 -0
  143. package/dist/file/appendFile.d.ts +11 -0
  144. package/dist/file/appendFile.mjs +41 -0
  145. package/dist/file/appendTextFile.cjs +43 -0
  146. package/dist/file/appendTextFile.d.ts +11 -0
  147. package/dist/file/appendTextFile.mjs +41 -0
  148. package/dist/file/copy.cjs +31 -0
  149. package/dist/file/copy.d.ts +11 -0
  150. package/dist/file/copy.mjs +29 -0
  151. package/dist/file/createEntryInterface.cjs +16 -0
  152. package/dist/file/createEntryInterface.d.ts +3 -0
  153. package/dist/file/createEntryInterface.mjs +13 -0
  154. package/dist/file/ensureDirectory.cjs +32 -0
  155. package/dist/file/ensureDirectory.d.ts +10 -0
  156. package/dist/file/ensureDirectory.mjs +30 -0
  157. package/dist/file/ensureFile.cjs +38 -0
  158. package/dist/file/ensureFile.d.ts +10 -0
  159. package/dist/file/ensureFile.mjs +36 -0
  160. package/dist/file/exists.cjs +29 -0
  161. package/dist/file/exists.d.ts +10 -0
  162. package/dist/file/exists.mjs +27 -0
  163. package/dist/file/fileInterface.cjs +74 -0
  164. package/dist/file/fileInterface.d.ts +30 -0
  165. package/dist/file/fileInterface.mjs +69 -0
  166. package/dist/file/folderInterface.cjs +74 -0
  167. package/dist/file/folderInterface.d.ts +32 -0
  168. package/dist/file/folderInterface.mjs +69 -0
  169. package/dist/file/index.cjs +122 -0
  170. package/dist/file/index.d.ts +36 -0
  171. package/dist/file/index.mjs +79 -0
  172. package/dist/file/link.cjs +44 -0
  173. package/dist/file/link.d.ts +11 -0
  174. package/dist/file/link.mjs +42 -0
  175. package/dist/file/linkStat.cjs +84 -0
  176. package/dist/file/linkStat.d.ts +11 -0
  177. package/dist/file/linkStat.mjs +80 -0
  178. package/dist/file/makeDirectory.cjs +36 -0
  179. package/dist/file/makeDirectory.d.ts +14 -0
  180. package/dist/file/makeDirectory.mjs +34 -0
  181. package/dist/file/makeTemporaryDirectory.cjs +30 -0
  182. package/dist/file/makeTemporaryDirectory.d.ts +9 -0
  183. package/dist/file/makeTemporaryDirectory.mjs +28 -0
  184. package/dist/file/makeTemporaryFile.cjs +45 -0
  185. package/dist/file/makeTemporaryFile.d.ts +10 -0
  186. package/dist/file/makeTemporaryFile.mjs +41 -0
  187. package/dist/file/move.cjs +45 -0
  188. package/dist/file/move.d.ts +11 -0
  189. package/dist/file/move.mjs +43 -0
  190. package/dist/file/readDirectory.cjs +20 -0
  191. package/dist/file/readDirectory.d.ts +14 -0
  192. package/dist/file/readDirectory.mjs +18 -0
  193. package/dist/file/readFile.cjs +33 -0
  194. package/dist/file/readFile.d.ts +10 -0
  195. package/dist/file/readFile.mjs +31 -0
  196. package/dist/file/readJsonFile.cjs +33 -0
  197. package/dist/file/readJsonFile.d.ts +11 -0
  198. package/dist/file/readJsonFile.mjs +31 -0
  199. package/dist/file/readLink.cjs +30 -0
  200. package/dist/file/readLink.d.ts +10 -0
  201. package/dist/file/readLink.mjs +28 -0
  202. package/dist/file/readTextFile.cjs +33 -0
  203. package/dist/file/readTextFile.d.ts +10 -0
  204. package/dist/file/readTextFile.mjs +31 -0
  205. package/dist/file/realPath.cjs +28 -0
  206. package/dist/file/realPath.d.ts +10 -0
  207. package/dist/file/realPath.mjs +26 -0
  208. package/dist/file/relocate.cjs +56 -0
  209. package/dist/file/relocate.d.ts +11 -0
  210. package/dist/file/relocate.mjs +53 -0
  211. package/dist/file/remove.cjs +38 -0
  212. package/dist/file/remove.d.ts +14 -0
  213. package/dist/file/remove.mjs +36 -0
  214. package/dist/file/rename.cjs +56 -0
  215. package/dist/file/rename.d.ts +11 -0
  216. package/dist/file/rename.mjs +53 -0
  217. package/dist/file/setMode.cjs +51 -0
  218. package/dist/file/setMode.d.ts +26 -0
  219. package/dist/file/setMode.mjs +48 -0
  220. package/dist/file/setOwner.cjs +37 -0
  221. package/dist/file/setOwner.d.ts +15 -0
  222. package/dist/file/setOwner.mjs +35 -0
  223. package/dist/file/setTime.cjs +39 -0
  224. package/dist/file/setTime.d.ts +17 -0
  225. package/dist/file/setTime.mjs +36 -0
  226. package/dist/file/stat.cjs +85 -0
  227. package/dist/file/stat.d.ts +42 -0
  228. package/dist/file/stat.mjs +81 -0
  229. package/dist/file/symlink.cjs +42 -0
  230. package/dist/file/symlink.d.ts +19 -0
  231. package/dist/file/symlink.mjs +40 -0
  232. package/dist/file/truncate.cjs +38 -0
  233. package/dist/file/truncate.d.ts +10 -0
  234. package/dist/file/truncate.mjs +35 -0
  235. package/dist/file/types/fileSystemEither.d.ts +2 -0
  236. package/dist/file/types/index.d.ts +1 -0
  237. package/dist/file/unknownEntryInterface.cjs +36 -0
  238. package/dist/file/unknownEntryInterface.d.ts +15 -0
  239. package/dist/file/unknownEntryInterface.mjs +33 -0
  240. package/dist/file/walkDirectory.cjs +34 -0
  241. package/dist/file/walkDirectory.d.ts +16 -0
  242. package/dist/file/walkDirectory.mjs +28 -0
  243. package/dist/file/writeFile.cjs +44 -0
  244. package/dist/file/writeFile.d.ts +11 -0
  245. package/dist/file/writeFile.mjs +42 -0
  246. package/dist/file/writeJsonFile.cjs +56 -0
  247. package/dist/file/writeJsonFile.d.ts +15 -0
  248. package/dist/file/writeJsonFile.mjs +53 -0
  249. package/dist/file/writeTextFile.cjs +44 -0
  250. package/dist/file/writeTextFile.d.ts +11 -0
  251. package/dist/file/writeTextFile.mjs +42 -0
  252. package/dist/implementor.cjs +64 -0
  253. package/dist/implementor.d.ts +35 -0
  254. package/dist/implementor.mjs +52 -0
  255. package/dist/index.cjs +74 -0
  256. package/dist/index.d.ts +9 -0
  257. package/dist/index.mjs +14 -0
  258. package/dist/kind.cjs +7 -0
  259. package/dist/kind.d.ts +2 -0
  260. package/dist/kind.mjs +5 -0
  261. package/package.json +81 -3
  262. package/README.md +0 -3
@@ -0,0 +1,29 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_kind = require("../kind.cjs");
3
+ let _duplojs_lang_common = require("@duplojs/lang/common");
4
+ _duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
5
+ let _duplojs_lang_either = require("@duplojs/lang/either");
6
+ _duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
7
+ let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
8
+ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructure, 1);
9
+ //#region scripts/dataStructure/constraint/size.ts
10
+ const sizeConstraintKind = require_kind.createKind("size-constraint");
11
+ const SizeConstraint = _duplojs_lang_dataStructure.createConstraint(sizeConstraintKind, ({ init }) => (params) => init({
12
+ max: params.max === void 0 ? void 0 : _duplojs_lang_common.stringToBytes(params.max),
13
+ min: params.min === void 0 ? void 0 : _duplojs_lang_common.stringToBytes(params.min)
14
+ }, {
15
+ executeCheck: async (self, data) => {
16
+ const result = _duplojs_lang_either.rightPipe(await data.stat(), (stat) => {
17
+ if (!stat.isFile) return _duplojs_lang_either.fail();
18
+ if (self.definition.max !== void 0 && stat.sizeBytes > self.definition.max) return _duplojs_lang_either.fail();
19
+ if (self.definition.min !== void 0 && stat.sizeBytes < self.definition.min) return _duplojs_lang_either.fail();
20
+ return stat;
21
+ });
22
+ if (_duplojs_lang_either.isLeft(result)) return _duplojs_lang_dataStructure.ErrorSymbol;
23
+ return _duplojs_lang_dataStructure.SuccessSymbol;
24
+ },
25
+ isAsynchronous: () => true
26
+ }));
27
+ //#endregion
28
+ exports.SizeConstraint = SizeConstraint;
29
+ exports.sizeConstraintKind = sizeConstraintKind;
@@ -0,0 +1,16 @@
1
+ import * as DCommon from "@duplojs/lang/common";
2
+ import type * as DKind from "@duplojs/lang/kind";
3
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
4
+ import type * as DSFile from '../../file';
5
+ export declare const sizeConstraintKind: DKind.Handler<DKind.Definition<"@DuplojsServerDataStructure/size-constraint", unknown>>;
6
+ export interface SizeConstraintDefinition extends DDataStructure.ConstraintDefinition {
7
+ min?: number;
8
+ max?: number;
9
+ }
10
+ export interface SizeConstraintParams {
11
+ min?: number | DCommon.BytesInString;
12
+ max?: number | DCommon.BytesInString;
13
+ }
14
+ export interface SizeConstraint extends DCommon.UnionToIntersection<DDataStructure.Constraint<DSFile.FileInterface, DSFile.FileInterface, SizeConstraintDefinition> & DKind.Kind<typeof sizeConstraintKind>> {
15
+ }
16
+ export declare const SizeConstraint: (params: SizeConstraintParams) => SizeConstraint;
@@ -0,0 +1,24 @@
1
+ import { createKind } from "../kind.mjs";
2
+ import * as DCommon from "@duplojs/lang/common";
3
+ import * as DEither from "@duplojs/lang/either";
4
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
5
+ //#region scripts/dataStructure/constraint/size.ts
6
+ const sizeConstraintKind = createKind("size-constraint");
7
+ const SizeConstraint = DDataStructure.createConstraint(sizeConstraintKind, ({ init }) => (params) => init({
8
+ max: params.max === void 0 ? void 0 : DCommon.stringToBytes(params.max),
9
+ min: params.min === void 0 ? void 0 : DCommon.stringToBytes(params.min)
10
+ }, {
11
+ executeCheck: async (self, data) => {
12
+ const result = DEither.rightPipe(await data.stat(), (stat) => {
13
+ if (!stat.isFile) return DEither.fail();
14
+ if (self.definition.max !== void 0 && stat.sizeBytes > self.definition.max) return DEither.fail();
15
+ if (self.definition.min !== void 0 && stat.sizeBytes < self.definition.min) return DEither.fail();
16
+ return stat;
17
+ });
18
+ if (DEither.isLeft(result)) return DDataStructure.ErrorSymbol;
19
+ return DDataStructure.SuccessSymbol;
20
+ },
21
+ isAsynchronous: () => true
22
+ }));
23
+ //#endregion
24
+ export { SizeConstraint, sizeConstraintKind };
@@ -0,0 +1,10 @@
1
+ import { ExistConstraint } from '../exist';
2
+ import { MimeTypeConstraint } from '../mimeType';
3
+ import { SizeConstraint } from '../size';
4
+ declare module "@duplojs/lang/dataStructure" {
5
+ interface ConstraintsStore {
6
+ exist: ExistConstraint;
7
+ size: SizeConstraint;
8
+ mimeType: MimeTypeConstraint;
9
+ }
10
+ }
@@ -0,0 +1 @@
1
+ export type * from './constraints';
@@ -0,0 +1,11 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_fileInterface = require("../../file/fileInterface.cjs");
3
+ const require_kind = require("../kind.cjs");
4
+ let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
5
+ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructure, 1);
6
+ //#region scripts/dataStructure/fundamentalType/file.ts
7
+ const fileFundamentalTypeKind = require_kind.createKind("file-fundamental-type");
8
+ const TheFile = _duplojs_lang_dataStructure.createFundamentalType(fileFundamentalTypeKind, (self, data) => require_fileInterface.isFileInterface(data) ? _duplojs_lang_dataStructure.SuccessSymbol : _duplojs_lang_dataStructure.ErrorSymbol);
9
+ //#endregion
10
+ exports.TheFile = TheFile;
11
+ exports.fileFundamentalTypeKind = fileFundamentalTypeKind;
@@ -0,0 +1,8 @@
1
+ import type * as DCommon from "@duplojs/lang/common";
2
+ import type * as DKind from "@duplojs/lang/kind";
3
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
4
+ import * as DSFile from '../../file';
5
+ export declare const fileFundamentalTypeKind: DKind.Handler<DKind.Definition<"@DuplojsServerDataStructure/file-fundamental-type", unknown>>;
6
+ export interface TheFile extends DCommon.UnionToIntersection<DDataStructure.FundamentalType<DSFile.FileInterface> & DKind.Kind<typeof fileFundamentalTypeKind>> {
7
+ }
8
+ export declare const TheFile: TheFile;
@@ -0,0 +1,8 @@
1
+ import { isFileInterface } from "../../file/fileInterface.mjs";
2
+ import { createKind } from "../kind.mjs";
3
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
4
+ //#region scripts/dataStructure/fundamentalType/file.ts
5
+ const fileFundamentalTypeKind = createKind("file-fundamental-type");
6
+ const TheFile = DDataStructure.createFundamentalType(fileFundamentalTypeKind, (self, data) => isFileInterface(data) ? DDataStructure.SuccessSymbol : DDataStructure.ErrorSymbol);
7
+ //#endregion
8
+ export { TheFile, fileFundamentalTypeKind };
@@ -0,0 +1,2 @@
1
+ export * from './file';
2
+ export type * from './types';
@@ -0,0 +1,6 @@
1
+ import { TheFile } from '../file';
2
+ declare module "@duplojs/lang/dataStructure" {
3
+ interface FundamentalTypesStore {
4
+ serverFile: TheFile;
5
+ }
6
+ }
@@ -0,0 +1 @@
1
+ export type * from './fundamentalTypes';
@@ -0,0 +1,7 @@
1
+ const require_exist = require("../constraint/exist.cjs");
2
+ //#region scripts/dataStructure/helper/exist.ts
3
+ function exist() {
4
+ return require_exist.ExistConstraint();
5
+ }
6
+ //#endregion
7
+ exports.exist = exist;
@@ -0,0 +1,2 @@
1
+ import { ExistConstraint } from '../constraint';
2
+ export declare function exist(): ExistConstraint;
@@ -0,0 +1,7 @@
1
+ import { ExistConstraint } from "../constraint/exist.mjs";
2
+ //#region scripts/dataStructure/helper/exist.ts
3
+ function exist() {
4
+ return ExistConstraint();
5
+ }
6
+ //#endregion
7
+ export { exist };
@@ -0,0 +1,10 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_file = require("../type/file.cjs");
3
+ let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
4
+ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructure, 1);
5
+ //#region scripts/dataStructure/helper/file.ts
6
+ function file(constraints = []) {
7
+ return _duplojs_lang_dataStructure.TypeStructure(require_file.FileType(), constraints);
8
+ }
9
+ //#endregion
10
+ exports.file = file;
@@ -0,0 +1,3 @@
1
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
2
+ import type * as DSFile from '../../file';
3
+ export declare function file<const GenericConstraints extends readonly DDataStructure.Constraint<DSFile.FileInterface>[] = readonly []>(constraints?: GenericConstraints): NoInfer<DDataStructure.TypeStructure<DSFile.FileInterface, readonly [...GenericConstraints]>>;
@@ -0,0 +1,8 @@
1
+ import { FileType } from "../type/file.mjs";
2
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
3
+ //#region scripts/dataStructure/helper/file.ts
4
+ function file(constraints = []) {
5
+ return DDataStructure.TypeStructure(FileType(), constraints);
6
+ }
7
+ //#endregion
8
+ export { file };
@@ -0,0 +1,4 @@
1
+ export * from './exist';
2
+ export * from './file';
3
+ export * from './mimeType';
4
+ export * from './size';
@@ -0,0 +1,7 @@
1
+ const require_mimeType = require("../constraint/mimeType.cjs");
2
+ //#region scripts/dataStructure/helper/mimeType.ts
3
+ function mimeType(mimeType) {
4
+ return require_mimeType.MimeTypeConstraint(mimeType);
5
+ }
6
+ //#endregion
7
+ exports.mimeType = mimeType;
@@ -0,0 +1,2 @@
1
+ import { MimeTypeConstraint } from '../constraint';
2
+ export declare function mimeType(mimeType: Parameters<typeof MimeTypeConstraint>[0]): MimeTypeConstraint;
@@ -0,0 +1,7 @@
1
+ import { MimeTypeConstraint } from "../constraint/mimeType.mjs";
2
+ //#region scripts/dataStructure/helper/mimeType.ts
3
+ function mimeType(mimeType) {
4
+ return MimeTypeConstraint(mimeType);
5
+ }
6
+ //#endregion
7
+ export { mimeType };
@@ -0,0 +1,7 @@
1
+ const require_size = require("../constraint/size.cjs");
2
+ //#region scripts/dataStructure/helper/size.ts
3
+ function size(params) {
4
+ return require_size.SizeConstraint(params);
5
+ }
6
+ //#endregion
7
+ exports.size = size;
@@ -0,0 +1,2 @@
1
+ import { SizeConstraint, SizeConstraintParams } from '../constraint';
2
+ export declare function size(params: SizeConstraintParams): SizeConstraint;
@@ -0,0 +1,7 @@
1
+ import { SizeConstraint } from "../constraint/size.mjs";
2
+ //#region scripts/dataStructure/helper/size.ts
3
+ function size(params) {
4
+ return SizeConstraint(params);
5
+ }
6
+ //#endregion
7
+ export { size };
@@ -0,0 +1,62 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_kind = require("./kind.cjs");
3
+ const require_file = require("./fundamentalType/file.cjs");
4
+ const require_json = require("./common/codec/defaults/json.cjs");
5
+ const require_string = require("./common/codec/defaults/string.cjs");
6
+ const require_defaultInterpreter = require("./common/error/defaultInterpreter.cjs");
7
+ const require_exist = require("./constraint/exist.cjs");
8
+ const require_mimeType = require("./constraint/mimeType.cjs");
9
+ const require_size = require("./constraint/size.cjs");
10
+ const require_exist$1 = require("./helper/exist.cjs");
11
+ const require_file$1 = require("./type/file.cjs");
12
+ const require_file$2 = require("./helper/file.cjs");
13
+ const require_mimeType$1 = require("./helper/mimeType.cjs");
14
+ const require_size$1 = require("./helper/size.cjs");
15
+ //#region scripts/dataStructure/index.ts
16
+ var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
17
+ ExistConstraint: () => require_exist.ExistConstraint,
18
+ FileType: () => require_file$1.FileType,
19
+ MimeTypeConstraint: () => require_mimeType.MimeTypeConstraint,
20
+ SizeConstraint: () => require_size.SizeConstraint,
21
+ TheFile: () => require_file.TheFile,
22
+ codecsJson: () => require_json.codecsJson,
23
+ codecsString: () => require_string.codecsString,
24
+ createKind: () => require_kind.createKind,
25
+ defaultErrorInterpreterCodecDictionary: () => require_defaultInterpreter.defaultErrorInterpreterCodecDictionary,
26
+ defaultErrorInterpreterDataStructureDictionary: () => require_defaultInterpreter.defaultErrorInterpreterDataStructureDictionary,
27
+ exist: () => require_exist$1.exist,
28
+ existConstraintKind: () => require_exist.existConstraintKind,
29
+ file: () => require_file$2.file,
30
+ fileFundamentalTypeKind: () => require_file.fileFundamentalTypeKind,
31
+ fileTypeKind: () => require_file$1.fileTypeKind,
32
+ mimeType: () => require_mimeType$1.mimeType,
33
+ mimeTypeConstraintKind: () => require_mimeType.mimeTypeConstraintKind,
34
+ size: () => require_size$1.size,
35
+ sizeConstraintKind: () => require_size.sizeConstraintKind
36
+ });
37
+ //#endregion
38
+ exports.ExistConstraint = require_exist.ExistConstraint;
39
+ exports.FileType = require_file$1.FileType;
40
+ exports.MimeTypeConstraint = require_mimeType.MimeTypeConstraint;
41
+ exports.SizeConstraint = require_size.SizeConstraint;
42
+ exports.TheFile = require_file.TheFile;
43
+ exports.codecsJson = require_json.codecsJson;
44
+ exports.codecsString = require_string.codecsString;
45
+ exports.createKind = require_kind.createKind;
46
+ Object.defineProperty(exports, "dataStructure_exports", {
47
+ enumerable: true,
48
+ get: function() {
49
+ return dataStructure_exports;
50
+ }
51
+ });
52
+ exports.defaultErrorInterpreterCodecDictionary = require_defaultInterpreter.defaultErrorInterpreterCodecDictionary;
53
+ exports.defaultErrorInterpreterDataStructureDictionary = require_defaultInterpreter.defaultErrorInterpreterDataStructureDictionary;
54
+ exports.exist = require_exist$1.exist;
55
+ exports.existConstraintKind = require_exist.existConstraintKind;
56
+ exports.file = require_file$2.file;
57
+ exports.fileFundamentalTypeKind = require_file.fileFundamentalTypeKind;
58
+ exports.fileTypeKind = require_file$1.fileTypeKind;
59
+ exports.mimeType = require_mimeType$1.mimeType;
60
+ exports.mimeTypeConstraintKind = require_mimeType.mimeTypeConstraintKind;
61
+ exports.size = require_size$1.size;
62
+ exports.sizeConstraintKind = require_size.sizeConstraintKind;
@@ -0,0 +1,6 @@
1
+ export * from './common';
2
+ export * from './constraint';
3
+ export * from './fundamentalType';
4
+ export * from './helper';
5
+ export * from './kind';
6
+ export * from './type';
@@ -0,0 +1,38 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { createKind } from "./kind.mjs";
3
+ import { TheFile, fileFundamentalTypeKind } from "./fundamentalType/file.mjs";
4
+ import { codecsJson } from "./common/codec/defaults/json.mjs";
5
+ import { codecsString } from "./common/codec/defaults/string.mjs";
6
+ import { defaultErrorInterpreterCodecDictionary, defaultErrorInterpreterDataStructureDictionary } from "./common/error/defaultInterpreter.mjs";
7
+ import { ExistConstraint, existConstraintKind } from "./constraint/exist.mjs";
8
+ import { MimeTypeConstraint, mimeTypeConstraintKind } from "./constraint/mimeType.mjs";
9
+ import { SizeConstraint, sizeConstraintKind } from "./constraint/size.mjs";
10
+ import { exist } from "./helper/exist.mjs";
11
+ import { FileType, fileTypeKind } from "./type/file.mjs";
12
+ import { file } from "./helper/file.mjs";
13
+ import { mimeType } from "./helper/mimeType.mjs";
14
+ import { size } from "./helper/size.mjs";
15
+ //#region scripts/dataStructure/index.ts
16
+ var dataStructure_exports = /* @__PURE__ */ __exportAll({
17
+ ExistConstraint: () => ExistConstraint,
18
+ FileType: () => FileType,
19
+ MimeTypeConstraint: () => MimeTypeConstraint,
20
+ SizeConstraint: () => SizeConstraint,
21
+ TheFile: () => TheFile,
22
+ codecsJson: () => codecsJson,
23
+ codecsString: () => codecsString,
24
+ createKind: () => createKind,
25
+ defaultErrorInterpreterCodecDictionary: () => defaultErrorInterpreterCodecDictionary,
26
+ defaultErrorInterpreterDataStructureDictionary: () => defaultErrorInterpreterDataStructureDictionary,
27
+ exist: () => exist,
28
+ existConstraintKind: () => existConstraintKind,
29
+ file: () => file,
30
+ fileFundamentalTypeKind: () => fileFundamentalTypeKind,
31
+ fileTypeKind: () => fileTypeKind,
32
+ mimeType: () => mimeType,
33
+ mimeTypeConstraintKind: () => mimeTypeConstraintKind,
34
+ size: () => size,
35
+ sizeConstraintKind: () => sizeConstraintKind
36
+ });
37
+ //#endregion
38
+ export { ExistConstraint, FileType, MimeTypeConstraint, SizeConstraint, TheFile, codecsJson, codecsString, createKind, dataStructure_exports, defaultErrorInterpreterCodecDictionary, defaultErrorInterpreterDataStructureDictionary, exist, existConstraintKind, file, fileFundamentalTypeKind, fileTypeKind, mimeType, mimeTypeConstraintKind, size, sizeConstraintKind };
@@ -0,0 +1,7 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ let _duplojs_lang_kind = require("@duplojs/lang/kind");
3
+ _duplojs_lang_kind = require_runtime.__toESM(_duplojs_lang_kind, 1);
4
+ //#region scripts/dataStructure/kind.ts
5
+ const createKind = _duplojs_lang_kind.createNamespace("DuplojsServerDataStructure");
6
+ //#endregion
7
+ exports.createKind = createKind;
@@ -0,0 +1,2 @@
1
+ import * as DKind from "@duplojs/lang/kind";
2
+ export declare const createKind: <GenericName extends string, GenericKindValue extends unknown = unknown>(name: GenericName & import('@duplojs/lang/string').ForbiddenContain<GenericName, DKind.ForbiddenKindNameCharacter>) => DKind.Handler<DKind.Definition<`@DuplojsServerDataStructure/${GenericName}`, GenericKindValue>>;
@@ -0,0 +1,5 @@
1
+ import * as DKind from "@duplojs/lang/kind";
2
+ //#region scripts/dataStructure/kind.ts
3
+ const createKind = DKind.createNamespace("DuplojsServerDataStructure");
4
+ //#endregion
5
+ export { createKind };
@@ -0,0 +1,14 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_kind = require("../kind.cjs");
3
+ const require_file = require("../fundamentalType/file.cjs");
4
+ let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
5
+ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructure, 1);
6
+ //#region scripts/dataStructure/type/file.ts
7
+ const fileTypeKind = require_kind.createKind("file-type");
8
+ const FileType = _duplojs_lang_dataStructure.createType(require_file.TheFile, fileTypeKind, ({ init }) => () => init({}, {
9
+ executeCheck: () => _duplojs_lang_dataStructure.SuccessSymbol,
10
+ isAsynchronous: () => false
11
+ }));
12
+ //#endregion
13
+ exports.FileType = FileType;
14
+ exports.fileTypeKind = fileTypeKind;
@@ -0,0 +1,11 @@
1
+ import type * as DCommon from "@duplojs/lang/common";
2
+ import type * as DKind from "@duplojs/lang/kind";
3
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
4
+ import type * as DSFile from '../../file';
5
+ import * as FundamentalType from "../fundamentalType";
6
+ export declare const fileTypeKind: DKind.Handler<DKind.Definition<"@DuplojsServerDataStructure/file-type", unknown>>;
7
+ export interface TimeTypeDefinition extends DDataStructure.TypeDefinition {
8
+ }
9
+ export interface FileType extends DCommon.UnionToIntersection<DDataStructure.Type<FundamentalType.TheFile, DSFile.FileInterface, TimeTypeDefinition> & DKind.Kind<typeof fileTypeKind>> {
10
+ }
11
+ export declare const FileType: () => FileType;
@@ -0,0 +1,11 @@
1
+ import { createKind } from "../kind.mjs";
2
+ import { TheFile } from "../fundamentalType/file.mjs";
3
+ import * as DDataStructure from "@duplojs/lang/dataStructure";
4
+ //#region scripts/dataStructure/type/file.ts
5
+ const fileTypeKind = createKind("file-type");
6
+ const FileType = DDataStructure.createType(TheFile, fileTypeKind, ({ init }) => () => init({}, {
7
+ executeCheck: () => DDataStructure.SuccessSymbol,
8
+ isAsynchronous: () => false
9
+ }));
10
+ //#endregion
11
+ export { FileType, fileTypeKind };
@@ -0,0 +1,2 @@
1
+ export * from './file';
2
+ export type * from './types';
@@ -0,0 +1 @@
1
+ export type * from './types';
@@ -0,0 +1,6 @@
1
+ import { FileType } from '../file';
2
+ declare module "@duplojs/lang/dataStructure" {
3
+ interface TypesStore {
4
+ serverFile: FileType;
5
+ }
6
+ }
@@ -0,0 +1,43 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_implementor = require("../implementor.cjs");
3
+ let _duplojs_lang_either = require("@duplojs/lang/either");
4
+ _duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
5
+ //#region scripts/file/appendFile.ts
6
+ function handleNodeAppendFileError(error) {
7
+ if (typeof error === "object" && error !== null && "code" in error) {
8
+ if (error.code === "ENOENT") return _duplojs_lang_either.left("file-system-append-file-not-found", error);
9
+ else if (error.code === "EACCES" || error.code === "EPERM") return _duplojs_lang_either.left("file-system-append-file-permission-denied", error);
10
+ else if (error.code === "EISDIR") return _duplojs_lang_either.left("file-system-append-file-is-directory", error);
11
+ else if (error.code === "ENOTDIR") return _duplojs_lang_either.left("file-system-append-file-not-directory", error);
12
+ else if (error.code === "ENOSPC") return _duplojs_lang_either.left("file-system-append-file-no-space", error);
13
+ else if (error.code === "EROFS") return _duplojs_lang_either.left("file-system-append-file-read-only", error);
14
+ else if (error.code === "EINVAL") return _duplojs_lang_either.left("file-system-append-file-invalid-argument", error);
15
+ else if (error.code === "EMFILE" || error.code === "ENFILE") return _duplojs_lang_either.left("file-system-append-file-too-many-open-files", error);
16
+ else if (error.code === "EBUSY") return _duplojs_lang_either.left("file-system-append-file-busy", error);
17
+ }
18
+ return _duplojs_lang_either.left("file-system-append-file-error", error);
19
+ }
20
+ function handleDenoAppendFileError(error) {
21
+ if (error instanceof Deno.errors.NotFound) return _duplojs_lang_either.left("file-system-append-file-not-found", error);
22
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return _duplojs_lang_either.left("file-system-append-file-permission-denied", error);
23
+ if (error instanceof Deno.errors.IsADirectory) return _duplojs_lang_either.left("file-system-append-file-is-directory", error);
24
+ if (error instanceof Deno.errors.NotADirectory) return _duplojs_lang_either.left("file-system-append-file-not-directory", error);
25
+ if (error instanceof Deno.errors.InvalidData) return _duplojs_lang_either.left("file-system-append-file-invalid-argument", error);
26
+ if (error instanceof Deno.errors.Busy) return _duplojs_lang_either.left("file-system-append-file-busy", error);
27
+ return _duplojs_lang_either.left("file-system-append-file-error", error);
28
+ }
29
+ const appendFileImplementation = require_implementor.implementFunction("appendFile", {
30
+ NODE: async (path, data) => {
31
+ return (await require_implementor.nodeFileSystem.value).appendFile(path, data).then(() => _duplojs_lang_either.right("file-system-append-file")).catch(handleNodeAppendFileError);
32
+ },
33
+ DENO: (path, data) => Deno.writeFile(path, data, { append: true }).then(() => _duplojs_lang_either.right("file-system-append-file")).catch(handleDenoAppendFileError)
34
+ });
35
+ function appendFile(...args) {
36
+ if (args.length === 1) {
37
+ const [data] = args;
38
+ return (path) => appendFileImplementation(path, data);
39
+ }
40
+ return appendFileImplementation(...args);
41
+ }
42
+ //#endregion
43
+ exports.appendFile = appendFile;
@@ -0,0 +1,11 @@
1
+ import { FileSystemEither } from './types';
2
+ import * as DEither from "@duplojs/lang/either";
3
+ import type * as DPath from "@duplojs/lang/path";
4
+ export type AppendFileResult = FileSystemEither<DEither.Right<"append-file", void> | DEither.Left<"append-file-not-found", unknown> | DEither.Left<"append-file-permission-denied", unknown> | DEither.Left<"append-file-is-directory", unknown> | DEither.Left<"append-file-not-directory", unknown> | DEither.Left<"append-file-no-space", unknown> | DEither.Left<"append-file-read-only", unknown> | DEither.Left<"append-file-invalid-argument", unknown> | DEither.Left<"append-file-too-many-open-files", unknown> | DEither.Left<"append-file-busy", unknown> | DEither.Left<"append-file-error", unknown>>;
5
+ declare module '../implementor' {
6
+ interface ServerFunction {
7
+ appendFile(path: string & DPath.Path, data: Uint8Array): Promise<AppendFileResult>;
8
+ }
9
+ }
10
+ export declare function appendFile(data: Uint8Array): (path: string & DPath.Path) => Promise<AppendFileResult>;
11
+ export declare function appendFile(path: string & DPath.Path, data: Uint8Array): Promise<AppendFileResult>;
@@ -0,0 +1,41 @@
1
+ import { implementFunction, nodeFileSystem } from "../implementor.mjs";
2
+ import * as DEither from "@duplojs/lang/either";
3
+ //#region scripts/file/appendFile.ts
4
+ function handleNodeAppendFileError(error) {
5
+ if (typeof error === "object" && error !== null && "code" in error) {
6
+ if (error.code === "ENOENT") return DEither.left("file-system-append-file-not-found", error);
7
+ else if (error.code === "EACCES" || error.code === "EPERM") return DEither.left("file-system-append-file-permission-denied", error);
8
+ else if (error.code === "EISDIR") return DEither.left("file-system-append-file-is-directory", error);
9
+ else if (error.code === "ENOTDIR") return DEither.left("file-system-append-file-not-directory", error);
10
+ else if (error.code === "ENOSPC") return DEither.left("file-system-append-file-no-space", error);
11
+ else if (error.code === "EROFS") return DEither.left("file-system-append-file-read-only", error);
12
+ else if (error.code === "EINVAL") return DEither.left("file-system-append-file-invalid-argument", error);
13
+ else if (error.code === "EMFILE" || error.code === "ENFILE") return DEither.left("file-system-append-file-too-many-open-files", error);
14
+ else if (error.code === "EBUSY") return DEither.left("file-system-append-file-busy", error);
15
+ }
16
+ return DEither.left("file-system-append-file-error", error);
17
+ }
18
+ function handleDenoAppendFileError(error) {
19
+ if (error instanceof Deno.errors.NotFound) return DEither.left("file-system-append-file-not-found", error);
20
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return DEither.left("file-system-append-file-permission-denied", error);
21
+ if (error instanceof Deno.errors.IsADirectory) return DEither.left("file-system-append-file-is-directory", error);
22
+ if (error instanceof Deno.errors.NotADirectory) return DEither.left("file-system-append-file-not-directory", error);
23
+ if (error instanceof Deno.errors.InvalidData) return DEither.left("file-system-append-file-invalid-argument", error);
24
+ if (error instanceof Deno.errors.Busy) return DEither.left("file-system-append-file-busy", error);
25
+ return DEither.left("file-system-append-file-error", error);
26
+ }
27
+ const appendFileImplementation = implementFunction("appendFile", {
28
+ NODE: async (path, data) => {
29
+ return (await nodeFileSystem.value).appendFile(path, data).then(() => DEither.right("file-system-append-file")).catch(handleNodeAppendFileError);
30
+ },
31
+ DENO: (path, data) => Deno.writeFile(path, data, { append: true }).then(() => DEither.right("file-system-append-file")).catch(handleDenoAppendFileError)
32
+ });
33
+ function appendFile(...args) {
34
+ if (args.length === 1) {
35
+ const [data] = args;
36
+ return (path) => appendFileImplementation(path, data);
37
+ }
38
+ return appendFileImplementation(...args);
39
+ }
40
+ //#endregion
41
+ export { appendFile };
@@ -0,0 +1,43 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_implementor = require("../implementor.cjs");
3
+ let _duplojs_lang_either = require("@duplojs/lang/either");
4
+ _duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
5
+ //#region scripts/file/appendTextFile.ts
6
+ function handleNodeAppendTextFileError(error) {
7
+ if (typeof error === "object" && error !== null && "code" in error) {
8
+ if (error.code === "ENOENT") return _duplojs_lang_either.left("file-system-append-text-file-not-found", error);
9
+ else if (error.code === "EACCES" || error.code === "EPERM") return _duplojs_lang_either.left("file-system-append-text-file-permission-denied", error);
10
+ else if (error.code === "EISDIR") return _duplojs_lang_either.left("file-system-append-text-file-is-directory", error);
11
+ else if (error.code === "ENOTDIR") return _duplojs_lang_either.left("file-system-append-text-file-not-directory", error);
12
+ else if (error.code === "ENOSPC") return _duplojs_lang_either.left("file-system-append-text-file-no-space", error);
13
+ else if (error.code === "EROFS") return _duplojs_lang_either.left("file-system-append-text-file-read-only", error);
14
+ else if (error.code === "EINVAL") return _duplojs_lang_either.left("file-system-append-text-file-invalid-argument", error);
15
+ else if (error.code === "EMFILE" || error.code === "ENFILE") return _duplojs_lang_either.left("file-system-append-text-file-too-many-open-files", error);
16
+ else if (error.code === "EBUSY") return _duplojs_lang_either.left("file-system-append-text-file-busy", error);
17
+ }
18
+ return _duplojs_lang_either.left("file-system-append-text-file-error", error);
19
+ }
20
+ function handleDenoAppendTextFileError(error) {
21
+ if (error instanceof Deno.errors.NotFound) return _duplojs_lang_either.left("file-system-append-text-file-not-found", error);
22
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return _duplojs_lang_either.left("file-system-append-text-file-permission-denied", error);
23
+ if (error instanceof Deno.errors.IsADirectory) return _duplojs_lang_either.left("file-system-append-text-file-is-directory", error);
24
+ if (error instanceof Deno.errors.NotADirectory) return _duplojs_lang_either.left("file-system-append-text-file-not-directory", error);
25
+ if (error instanceof Deno.errors.InvalidData) return _duplojs_lang_either.left("file-system-append-text-file-invalid-argument", error);
26
+ if (error instanceof Deno.errors.Busy) return _duplojs_lang_either.left("file-system-append-text-file-busy", error);
27
+ return _duplojs_lang_either.left("file-system-append-text-file-error", error);
28
+ }
29
+ const appendTextFileImplementation = require_implementor.implementFunction("appendTextFile", {
30
+ NODE: async (path, data) => {
31
+ return (await require_implementor.nodeFileSystem.value).appendFile(path, data).then(() => _duplojs_lang_either.right("file-system-append-text-file")).catch(handleNodeAppendTextFileError);
32
+ },
33
+ DENO: (path, data) => Deno.writeTextFile(path, data, { append: true }).then(() => _duplojs_lang_either.right("file-system-append-text-file")).catch(handleDenoAppendTextFileError)
34
+ });
35
+ function appendTextFile(...args) {
36
+ if (args.length === 1) {
37
+ const [data] = args;
38
+ return (path) => appendTextFileImplementation(path, data);
39
+ }
40
+ return appendTextFileImplementation(...args);
41
+ }
42
+ //#endregion
43
+ exports.appendTextFile = appendTextFile;
@@ -0,0 +1,11 @@
1
+ import { FileSystemEither } from './types';
2
+ import * as DEither from "@duplojs/lang/either";
3
+ import type * as DPath from "@duplojs/lang/path";
4
+ export type AppendTextFileResult = FileSystemEither<DEither.Right<"append-text-file", void> | DEither.Left<"append-text-file-not-found", unknown> | DEither.Left<"append-text-file-permission-denied", unknown> | DEither.Left<"append-text-file-is-directory", unknown> | DEither.Left<"append-text-file-not-directory", unknown> | DEither.Left<"append-text-file-no-space", unknown> | DEither.Left<"append-text-file-read-only", unknown> | DEither.Left<"append-text-file-invalid-argument", unknown> | DEither.Left<"append-text-file-too-many-open-files", unknown> | DEither.Left<"append-text-file-busy", unknown> | DEither.Left<"append-text-file-error", unknown>>;
5
+ declare module '../implementor' {
6
+ interface ServerFunction {
7
+ appendTextFile(path: string & DPath.Path, data: string): Promise<AppendTextFileResult>;
8
+ }
9
+ }
10
+ export declare function appendTextFile(data: string): (path: string & DPath.Path) => Promise<AppendTextFileResult>;
11
+ export declare function appendTextFile(path: string & DPath.Path, data: string): Promise<AppendTextFileResult>;