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

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,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 WriteTextFileResult = FileSystemEither<DEither.Right<"write-text-file", void> | DEither.Left<"write-text-file-not-found", unknown> | DEither.Left<"write-text-file-permission-denied", unknown> | DEither.Left<"write-text-file-is-directory", unknown> | DEither.Left<"write-text-file-not-directory", unknown> | DEither.Left<"write-text-file-no-space", unknown> | DEither.Left<"write-text-file-read-only", unknown> | DEither.Left<"write-text-file-invalid-argument", unknown> | DEither.Left<"write-text-file-too-many-open-files", unknown> | DEither.Left<"write-text-file-busy", unknown> | DEither.Left<"write-text-file-error", unknown>>;
5
+ declare module '../implementor' {
6
+ interface ServerFunction {
7
+ writeTextFile(path: string & DPath.Path, data: string): Promise<WriteTextFileResult>;
8
+ }
9
+ }
10
+ export declare function writeTextFile(data: string): (path: string & DPath.Path) => Promise<WriteTextFileResult>;
11
+ export declare function writeTextFile(path: string & DPath.Path, data: string): Promise<WriteTextFileResult>;
@@ -0,0 +1,42 @@
1
+ import { implementFunction, nodeFileSystem } from "../implementor.mjs";
2
+ import * as DEither from "@duplojs/lang/either";
3
+ //#region scripts/file/writeTextFile.ts
4
+ function handleNodeWriteTextFileError(error) {
5
+ if (typeof error === "object" && error !== null && "code" in error) {
6
+ if (error.code === "ENOENT") return DEither.left("file-system-write-text-file-not-found", error);
7
+ else if (error.code === "EACCES" || error.code === "EPERM") return DEither.left("file-system-write-text-file-permission-denied", error);
8
+ else if (error.code === "EISDIR") return DEither.left("file-system-write-text-file-is-directory", error);
9
+ else if (error.code === "ENOTDIR") return DEither.left("file-system-write-text-file-not-directory", error);
10
+ else if (error.code === "ENOSPC") return DEither.left("file-system-write-text-file-no-space", error);
11
+ else if (error.code === "EROFS") return DEither.left("file-system-write-text-file-read-only", error);
12
+ else if (error.code === "EINVAL") return DEither.left("file-system-write-text-file-invalid-argument", error);
13
+ else if (error.code === "EMFILE" || error.code === "ENFILE") return DEither.left("file-system-write-text-file-too-many-open-files", error);
14
+ else if (error.code === "EBUSY") return DEither.left("file-system-write-text-file-busy", error);
15
+ }
16
+ return DEither.left("file-system-write-text-file-error", error);
17
+ }
18
+ function handleDenoWriteTextFileError(error) {
19
+ if (error instanceof Deno.errors.NotFound) return DEither.left("file-system-write-text-file-not-found", error);
20
+ if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) return DEither.left("file-system-write-text-file-permission-denied", error);
21
+ if (error instanceof Deno.errors.IsADirectory) return DEither.left("file-system-write-text-file-is-directory", error);
22
+ if (error instanceof Deno.errors.NotADirectory) return DEither.left("file-system-write-text-file-not-directory", error);
23
+ if (error instanceof Deno.errors.InvalidData) return DEither.left("file-system-write-text-file-invalid-argument", error);
24
+ if (error instanceof Deno.errors.Busy) return DEither.left("file-system-write-text-file-busy", error);
25
+ return DEither.left("file-system-write-text-file-error", error);
26
+ }
27
+ const writeTextFileImplementation = implementFunction("writeTextFile", {
28
+ NODE: async (path, data) => {
29
+ return (await nodeFileSystem.value).writeFile(path, data, { encoding: "utf-8" }).then(() => DEither.right("file-system-write-text-file")).catch(handleNodeWriteTextFileError);
30
+ },
31
+ DENO: (path, data) => Deno.writeTextFile(path, data).then(() => DEither.right("file-system-write-text-file")).catch(handleDenoWriteTextFileError),
32
+ BUN: (path, data) => Bun.file(path).write(data).then(() => DEither.right("file-system-write-text-file")).catch(handleNodeWriteTextFileError)
33
+ });
34
+ function writeTextFile(...args) {
35
+ if (args.length === 1) {
36
+ const [data] = args;
37
+ return (path) => writeTextFileImplementation(path, data);
38
+ }
39
+ return writeTextFileImplementation(...args);
40
+ }
41
+ //#endregion
42
+ export { writeTextFile };
@@ -0,0 +1,64 @@
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ let _duplojs_lang_common = require("@duplojs/lang/common");
3
+ _duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
4
+ _duplojs_lang_common.createEnum([
5
+ "BUN",
6
+ "DENO",
7
+ "NODE",
8
+ "TEST"
9
+ ]);
10
+ const SymbolEnvironmentStore = Symbol("environmentStore");
11
+ const environmentStoreHandler = _duplojs_lang_common.createGlobalStore(SymbolEnvironmentStore, (() => {
12
+ if (typeof Deno !== "undefined") return "DENO";
13
+ if (typeof Bun !== "undefined") return "BUN";
14
+ if (typeof process !== "undefined" && process.versions?.node) return "NODE";
15
+ return "NODE";
16
+ })());
17
+ function setEnvironment(environment) {
18
+ environmentStoreHandler.set(environment);
19
+ }
20
+ let TESTImplementation;
21
+ (function(_TESTImplementation) {
22
+ const store = /* @__PURE__ */ new Map();
23
+ function clear() {
24
+ store.clear();
25
+ }
26
+ _TESTImplementation.clear = clear;
27
+ function set(functionName, theFunction) {
28
+ store.set(functionName, theFunction);
29
+ return theFunction;
30
+ }
31
+ _TESTImplementation.set = set;
32
+ function get(functionName) {
33
+ return store.get(functionName);
34
+ }
35
+ _TESTImplementation.get = get;
36
+ })(TESTImplementation || (TESTImplementation = {}));
37
+ function implementFunction(functionName, theFunctions) {
38
+ const environmentFunctions = {
39
+ NODE: theFunctions.NODE,
40
+ BUN: theFunctions.BUN ||= theFunctions.NODE,
41
+ DENO: theFunctions.DENO ||= theFunctions.NODE,
42
+ get TEST() {
43
+ const theFunction = TESTImplementation.get(functionName);
44
+ if (!theFunction) throw new Error(`Missing function implementation "${functionName}" in TEST environment.`);
45
+ return theFunction;
46
+ }
47
+ };
48
+ return (...args) => environmentFunctions[environmentStoreHandler.value](...args);
49
+ }
50
+ const nodeFileSystem = _duplojs_lang_common.memoPromise(() => import("node:fs/promises"));
51
+ const nodeCrypto = _duplojs_lang_common.memoPromise(() => import("node:crypto"));
52
+ const nodeOs = _duplojs_lang_common.memoPromise(() => import("node:os"));
53
+ //#endregion
54
+ Object.defineProperty(exports, "TESTImplementation", {
55
+ enumerable: true,
56
+ get: function() {
57
+ return TESTImplementation;
58
+ }
59
+ });
60
+ exports.implementFunction = implementFunction;
61
+ exports.nodeCrypto = nodeCrypto;
62
+ exports.nodeFileSystem = nodeFileSystem;
63
+ exports.nodeOs = nodeOs;
64
+ exports.setEnvironment = setEnvironment;
@@ -0,0 +1,35 @@
1
+ import * as DCommon from "@duplojs/lang/common";
2
+ export interface ServerFunction {
3
+ }
4
+ export declare const SupportedEnvironment: {
5
+ BUN: "BUN";
6
+ DENO: "DENO";
7
+ NODE: "NODE";
8
+ TEST: "TEST";
9
+ toTuple: () => readonly ["BUN", "DENO", "NODE", "TEST"];
10
+ has: (value: string) => value is "BUN" | "DENO" | "NODE" | "TEST";
11
+ contract: <GenericContractValue extends string = "BUN" | "DENO" | "NODE" | "TEST">(...args: (Exclude<"BUN", GenericContractValue> | Exclude<"DENO", GenericContractValue> | Exclude<"NODE", GenericContractValue> | Exclude<"TEST", GenericContractValue> extends infer InferredMissingValue extends string ? DCommon.IsNever<InferredMissingValue> extends true ? unknown : DCommon.ComputedTypeError<`Enum contract is missing value "${InferredMissingValue}".`> : never) & (Exclude<GenericContractValue, "BUN" | "DENO" | "NODE" | "TEST"> extends infer InferredUnknownValue extends string ? DCommon.IsNever<InferredUnknownValue> extends true ? unknown : DCommon.ComputedTypeError<`Enum contract contains unknown value "${InferredUnknownValue}".`> : never) extends infer InferredRequirement ? DCommon.IsEqual<InferredRequirement, unknown> extends true ? [] : [] & InferredRequirement : never) => /*elided*/ any;
12
+ };
13
+ export type SupportedEnvironment = DCommon.GetEnumValue<typeof SupportedEnvironment>;
14
+ declare const SymbolEnvironmentStore: unique symbol;
15
+ type SymbolEnvironmentStore = typeof SymbolEnvironmentStore;
16
+ declare module "@duplojs/lang" {
17
+ interface GlobalStore {
18
+ [SymbolEnvironmentStore]: SupportedEnvironment;
19
+ }
20
+ }
21
+ export declare function setEnvironment(environment: SupportedEnvironment): void;
22
+ export declare namespace TESTImplementation {
23
+ function clear(): void;
24
+ function set<GenericFunctionName extends keyof ServerFunction>(functionName: GenericFunctionName, theFunction: ServerFunction[GenericFunctionName]): ServerFunction[GenericFunctionName];
25
+ function get<GenericFunctionName extends keyof ServerFunction>(functionName: GenericFunctionName): ServerFunction[GenericFunctionName] | undefined;
26
+ }
27
+ export declare function implementFunction<GenericFunctionName extends keyof ServerFunction>(functionName: GenericFunctionName, theFunctions: {
28
+ NODE: ServerFunction[GenericFunctionName];
29
+ BUN?: ServerFunction[GenericFunctionName];
30
+ DENO?: ServerFunction[GenericFunctionName];
31
+ }): ServerFunction[GenericFunctionName];
32
+ export declare const nodeFileSystem: DCommon.MemoizedPromise<typeof import("node:fs/promises")>;
33
+ export declare const nodeCrypto: DCommon.MemoizedPromise<typeof import("node:crypto")>;
34
+ export declare const nodeOs: DCommon.MemoizedPromise<typeof import("node:os")>;
35
+ export {};
@@ -0,0 +1,52 @@
1
+ import * as DCommon from "@duplojs/lang/common";
2
+ DCommon.createEnum([
3
+ "BUN",
4
+ "DENO",
5
+ "NODE",
6
+ "TEST"
7
+ ]);
8
+ const SymbolEnvironmentStore = Symbol("environmentStore");
9
+ const environmentStoreHandler = DCommon.createGlobalStore(SymbolEnvironmentStore, (() => {
10
+ if (typeof Deno !== "undefined") return "DENO";
11
+ if (typeof Bun !== "undefined") return "BUN";
12
+ if (typeof process !== "undefined" && process.versions?.node) return "NODE";
13
+ return "NODE";
14
+ })());
15
+ function setEnvironment(environment) {
16
+ environmentStoreHandler.set(environment);
17
+ }
18
+ let TESTImplementation;
19
+ (function(_TESTImplementation) {
20
+ const store = /* @__PURE__ */ new Map();
21
+ function clear() {
22
+ store.clear();
23
+ }
24
+ _TESTImplementation.clear = clear;
25
+ function set(functionName, theFunction) {
26
+ store.set(functionName, theFunction);
27
+ return theFunction;
28
+ }
29
+ _TESTImplementation.set = set;
30
+ function get(functionName) {
31
+ return store.get(functionName);
32
+ }
33
+ _TESTImplementation.get = get;
34
+ })(TESTImplementation || (TESTImplementation = {}));
35
+ function implementFunction(functionName, theFunctions) {
36
+ const environmentFunctions = {
37
+ NODE: theFunctions.NODE,
38
+ BUN: theFunctions.BUN ||= theFunctions.NODE,
39
+ DENO: theFunctions.DENO ||= theFunctions.NODE,
40
+ get TEST() {
41
+ const theFunction = TESTImplementation.get(functionName);
42
+ if (!theFunction) throw new Error(`Missing function implementation "${functionName}" in TEST environment.`);
43
+ return theFunction;
44
+ }
45
+ };
46
+ return (...args) => environmentFunctions[environmentStoreHandler.value](...args);
47
+ }
48
+ const nodeFileSystem = DCommon.memoPromise(() => import("node:fs/promises"));
49
+ const nodeCrypto = DCommon.memoPromise(() => import("node:crypto"));
50
+ const nodeOs = DCommon.memoPromise(() => import("node:os"));
51
+ //#endregion
52
+ export { TESTImplementation, implementFunction, nodeCrypto, nodeFileSystem, nodeOs, setEnvironment };
package/dist/index.cjs ADDED
@@ -0,0 +1,74 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_implementor = require("./implementor.cjs");
3
+ const require_getCurrentWorkDirectory = require("./common/getCurrentWorkDirectory.cjs");
4
+ const require_getCurrentWorkDirectoryOrThrow = require("./common/getCurrentWorkDirectoryOrThrow.cjs");
5
+ const require_setCurrentWorkingDirectory = require("./common/setCurrentWorkingDirectory.cjs");
6
+ const require_setCurrentWorkingDirectoryOrThrow = require("./common/setCurrentWorkingDirectoryOrThrow.cjs");
7
+ const require_index = require("./file/index.cjs");
8
+ const require_index$1 = require("./dataStructure/index.cjs");
9
+ const require_index$2 = require("./common/environmentVariable/index.cjs");
10
+ const require_environmentVariableOrThrow = require("./common/environmentVariableOrThrow.cjs");
11
+ const require_exitProcess = require("./common/exitProcess.cjs");
12
+ const require_getProcessArguments = require("./common/getProcessArguments.cjs");
13
+ const require_index$3 = require("./common/index.cjs");
14
+ const require_index$4 = require("./command/index.cjs");
15
+ Object.defineProperty(exports, "DSCommand", {
16
+ enumerable: true,
17
+ get: function() {
18
+ return require_index$4.command_exports;
19
+ }
20
+ });
21
+ Object.defineProperty(exports, "DSCommon", {
22
+ enumerable: true,
23
+ get: function() {
24
+ return require_index$3.common_exports;
25
+ }
26
+ });
27
+ Object.defineProperty(exports, "DSDataStructure", {
28
+ enumerable: true,
29
+ get: function() {
30
+ return require_index$1.dataStructure_exports;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "DSFile", {
34
+ enumerable: true,
35
+ get: function() {
36
+ return require_index.file_exports;
37
+ }
38
+ });
39
+ exports.EnvironmentVariableError = require_environmentVariableOrThrow.EnvironmentVariableError;
40
+ exports.GetCurrentWorkDirectoryError = require_getCurrentWorkDirectoryOrThrow.GetCurrentWorkDirectoryError;
41
+ Object.defineProperty(exports, "SC", {
42
+ enumerable: true,
43
+ get: function() {
44
+ return require_index$4.command_exports;
45
+ }
46
+ });
47
+ Object.defineProperty(exports, "SDS", {
48
+ enumerable: true,
49
+ get: function() {
50
+ return require_index$1.dataStructure_exports;
51
+ }
52
+ });
53
+ Object.defineProperty(exports, "SF", {
54
+ enumerable: true,
55
+ get: function() {
56
+ return require_index.file_exports;
57
+ }
58
+ });
59
+ exports.SetCurrentWorkingDirectoryError = require_setCurrentWorkingDirectoryOrThrow.SetCurrentWorkingDirectoryError;
60
+ Object.defineProperty(exports, "TESTImplementation", {
61
+ enumerable: true,
62
+ get: function() {
63
+ return require_implementor.TESTImplementation;
64
+ }
65
+ });
66
+ exports.environmentVariable = require_index$2.environmentVariable;
67
+ exports.environmentVariableOrThrow = require_environmentVariableOrThrow.environmentVariableOrThrow;
68
+ exports.exitProcess = require_exitProcess.exitProcess;
69
+ exports.getCurrentWorkDirectory = require_getCurrentWorkDirectory.getCurrentWorkDirectory;
70
+ exports.getCurrentWorkDirectoryOrThrow = require_getCurrentWorkDirectoryOrThrow.getCurrentWorkDirectoryOrThrow;
71
+ exports.getProcessArguments = require_getProcessArguments.getProcessArguments;
72
+ exports.setCurrentWorkingDirectory = require_setCurrentWorkingDirectory.setCurrentWorkingDirectory;
73
+ exports.setCurrentWorkingDirectoryOrThrow = require_setCurrentWorkingDirectoryOrThrow.setCurrentWorkingDirectoryOrThrow;
74
+ exports.setEnvironment = require_implementor.setEnvironment;
@@ -0,0 +1,9 @@
1
+ export { setEnvironment, TESTImplementation } from './implementor';
2
+ export * from './common';
3
+ export * as DSCommon from './common';
4
+ export * as SF from './file';
5
+ export * as DSFile from './file';
6
+ export * as SDS from './dataStructure';
7
+ export * as DSDataStructure from './dataStructure';
8
+ export * as SC from './command';
9
+ export * as DSCommand from './command';
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { TESTImplementation, setEnvironment } from "./implementor.mjs";
2
+ import { getCurrentWorkDirectory } from "./common/getCurrentWorkDirectory.mjs";
3
+ import { GetCurrentWorkDirectoryError, getCurrentWorkDirectoryOrThrow } from "./common/getCurrentWorkDirectoryOrThrow.mjs";
4
+ import { setCurrentWorkingDirectory } from "./common/setCurrentWorkingDirectory.mjs";
5
+ import { SetCurrentWorkingDirectoryError, setCurrentWorkingDirectoryOrThrow } from "./common/setCurrentWorkingDirectoryOrThrow.mjs";
6
+ import { file_exports } from "./file/index.mjs";
7
+ import { dataStructure_exports } from "./dataStructure/index.mjs";
8
+ import { environmentVariable } from "./common/environmentVariable/index.mjs";
9
+ import { EnvironmentVariableError, environmentVariableOrThrow } from "./common/environmentVariableOrThrow.mjs";
10
+ import { exitProcess } from "./common/exitProcess.mjs";
11
+ import { getProcessArguments } from "./common/getProcessArguments.mjs";
12
+ import { common_exports } from "./common/index.mjs";
13
+ import { command_exports } from "./command/index.mjs";
14
+ export { command_exports as DSCommand, common_exports as DSCommon, dataStructure_exports as DSDataStructure, file_exports as DSFile, EnvironmentVariableError, GetCurrentWorkDirectoryError, command_exports as SC, dataStructure_exports as SDS, file_exports as SF, SetCurrentWorkingDirectoryError, TESTImplementation, environmentVariable, environmentVariableOrThrow, exitProcess, getCurrentWorkDirectory, getCurrentWorkDirectoryOrThrow, getProcessArguments, setCurrentWorkingDirectory, setCurrentWorkingDirectoryOrThrow, setEnvironment };
package/dist/kind.cjs ADDED
@@ -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/kind.ts
5
+ const createKind = _duplojs_lang_kind.createNamespace("DuplojsServer");
6
+ //#endregion
7
+ exports.createKind = createKind;
package/dist/kind.d.ts ADDED
@@ -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<`@DuplojsServer/${GenericName}`, GenericKindValue>>;
package/dist/kind.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import * as DKind from "@duplojs/lang/kind";
2
+ //#region scripts/kind.ts
3
+ const createKind = DKind.createNamespace("DuplojsServer");
4
+ //#endregion
5
+ export { createKind };
package/package.json CHANGED
@@ -1,6 +1,84 @@
1
1
  {
2
2
  "name": "@duplojs/server",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-beta.1",
4
+ "license": "MIT",
5
+ "author": {
6
+ "name": "DuploJS",
7
+ "url": "https://github.com/duplojs"
8
+ },
9
+ "description": "Typed helpers to handle files, system operations, and CLI commands.",
10
+ "homepage": "https://server.duplojs.dev/",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/duplojs/ecosystem.git",
14
+ "directory": "packages/server"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/duplojs/ecosystem/issues"
18
+ },
19
+ "type": "module",
20
+ "types": "./dist/index.d.ts",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.mjs",
25
+ "require": "./dist/index.cjs",
26
+ "types": "./dist/index.d.ts"
27
+ },
28
+ "./file": {
29
+ "import": "./dist/file/index.mjs",
30
+ "require": "./dist/file/index.cjs",
31
+ "types": "./dist/file/index.d.ts"
32
+ },
33
+ "./common": {
34
+ "import": "./dist/common/index.mjs",
35
+ "require": "./dist/common/index.cjs",
36
+ "types": "./dist/common/index.d.ts"
37
+ },
38
+ "./dataStructure": {
39
+ "import": "./dist/dataStructure/index.mjs",
40
+ "require": "./dist/dataStructure/index.cjs",
41
+ "types": "./dist/dataStructure/index.d.ts"
42
+ },
43
+ "./command": {
44
+ "import": "./dist/command/index.mjs",
45
+ "require": "./dist/command/index.cjs",
46
+ "types": "./dist/command/index.d.ts"
47
+ }
48
+ },
49
+ "peerDependencies": {
50
+ "@duplojs/lang": "0.1.0-beta.1"
51
+ },
52
+ "devDependencies": {
53
+ "@duplojs/code-config": "0.1.0-beta.1",
54
+ "@types/bun": "1.4.1",
55
+ "@types/deno": "2.7.0",
56
+ "@types/node": "24.13.3",
57
+ "bun": "1.4.2",
58
+ "deno": "2.9.6"
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "README"
63
+ ],
64
+ "keywords": [
65
+ "duplojs",
66
+ "file",
67
+ "fileSystem",
68
+ "cli",
69
+ "command",
70
+ "dotenv",
71
+ "env",
72
+ "server-utils"
73
+ ],
74
+ "engines": {
75
+ "node": ">=24.18.0"
76
+ },
77
+ "scripts": {
78
+ "build": "./.commands/build.sh",
79
+ "test:types": "./.commands/test-types.sh",
80
+ "test:types:target": "./.commands/test-types-target.sh",
81
+ "test:lint": "./.commands/test-lint.sh",
82
+ "test:lint:fix": "./.commands/test-lint.sh --fix"
83
+ }
6
84
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.