@duplojs/server 0.0.0-stage → 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.
- package/README.md +8 -2
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.mjs +17 -0
- package/dist/command/argument.cjs +27 -0
- package/dist/command/argument.d.ts +18 -0
- package/dist/command/argument.mjs +24 -0
- package/dist/command/create.cjs +102 -0
- package/dist/command/create.d.ts +47 -0
- package/dist/command/create.mjs +96 -0
- package/dist/command/error.cjs +206 -0
- package/dist/command/error.d.ts +61 -0
- package/dist/command/error.mjs +193 -0
- package/dist/command/exec.cjs +19 -0
- package/dist/command/exec.d.ts +14 -0
- package/dist/command/exec.mjs +17 -0
- package/dist/command/execOptions.cjs +41 -0
- package/dist/command/execOptions.d.ts +14 -0
- package/dist/command/execOptions.mjs +37 -0
- package/dist/command/help.cjs +250 -0
- package/dist/command/help.d.ts +10 -0
- package/dist/command/help.mjs +237 -0
- package/dist/command/index.cjs +82 -0
- package/dist/command/index.d.ts +8 -0
- package/dist/command/index.mjs +47 -0
- package/dist/command/kind.cjs +7 -0
- package/dist/command/kind.d.ts +2 -0
- package/dist/command/kind.mjs +5 -0
- package/dist/command/options/base.cjs +76 -0
- package/dist/command/options/base.d.ts +30 -0
- package/dist/command/options/base.mjs +69 -0
- package/dist/command/options/defaults/array.cjs +35 -0
- package/dist/command/options/defaults/array.d.ts +26 -0
- package/dist/command/options/defaults/array.mjs +29 -0
- package/dist/command/options/defaults/boolean.cjs +28 -0
- package/dist/command/options/defaults/boolean.d.ts +14 -0
- package/dist/command/options/defaults/boolean.mjs +25 -0
- package/dist/command/options/defaults/index.d.ts +3 -0
- package/dist/command/options/defaults/simple.cjs +25 -0
- package/dist/command/options/defaults/simple.d.ts +18 -0
- package/dist/command/options/defaults/simple.mjs +22 -0
- package/dist/command/options/identifier.cjs +7 -0
- package/dist/command/options/identifier.d.ts +4 -0
- package/dist/command/options/identifier.mjs +5 -0
- package/dist/command/options/index.d.ts +4 -0
- package/dist/command/options/types/index.d.ts +1 -0
- package/dist/command/options/types/options.d.ts +9 -0
- package/dist/command/types/eligibleType.d.ts +4 -0
- package/dist/command/types/forbiddenDuplicateName.d.ts +11 -0
- package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
- package/dist/command/types/index.d.ts +3 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.cjs +27 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.d.ts +2 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.mjs +22 -0
- package/dist/common/environmentVariable/index.cjs +47 -0
- package/dist/common/environmentVariable/index.d.ts +16 -0
- package/dist/common/environmentVariable/index.mjs +41 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.cjs +13 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +3 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.mjs +9 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.cjs +32 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +5 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.mjs +26 -0
- package/dist/common/environmentVariableOrThrow.cjs +23 -0
- package/dist/common/environmentVariableOrThrow.d.ts +12 -0
- package/dist/common/environmentVariableOrThrow.mjs +19 -0
- package/dist/common/exitProcess.cjs +7 -0
- package/dist/common/exitProcess.d.ts +6 -0
- package/dist/common/exitProcess.mjs +8 -0
- package/dist/common/getCurrentWorkDirectory.cjs +15 -0
- package/dist/common/getCurrentWorkDirectory.d.ts +8 -0
- package/dist/common/getCurrentWorkDirectory.mjs +11 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.cjs +25 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.d.ts +8 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.mjs +20 -0
- package/dist/common/getProcessArguments.cjs +18 -0
- package/dist/common/getProcessArguments.d.ts +6 -0
- package/dist/common/getProcessArguments.mjs +18 -0
- package/dist/common/index.cjs +44 -0
- package/dist/common/index.d.ts +9 -0
- package/dist/common/index.mjs +27 -0
- package/dist/common/meta/getCurrentDirectoryName.cjs +10 -0
- package/dist/common/meta/getCurrentDirectoryName.d.ts +7 -0
- package/dist/common/meta/getCurrentDirectoryName.mjs +7 -0
- package/dist/common/meta/index.d.ts +7 -0
- package/dist/common/setCurrentWorkingDirectory.cjs +11 -0
- package/dist/common/setCurrentWorkingDirectory.d.ts +8 -0
- package/dist/common/setCurrentWorkingDirectory.mjs +9 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.cjs +23 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.d.ts +8 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.mjs +18 -0
- package/dist/dataStructure/common/codec/defaults/index.d.ts +2 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +25 -0
- package/dist/dataStructure/common/codec/defaults/json.d.ts +9 -0
- package/dist/dataStructure/common/codec/defaults/json.mjs +22 -0
- package/dist/dataStructure/common/codec/defaults/string.cjs +25 -0
- package/dist/dataStructure/common/codec/defaults/string.d.ts +13 -0
- package/dist/dataStructure/common/codec/defaults/string.mjs +22 -0
- package/dist/dataStructure/common/codec/index.d.ts +1 -0
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +29 -0
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +69 -0
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +26 -0
- package/dist/dataStructure/common/error/index.d.ts +1 -0
- package/dist/dataStructure/common/index.d.ts +2 -0
- package/dist/dataStructure/constraint/fileExist.cjs +19 -0
- package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
- package/dist/dataStructure/constraint/fileExist.mjs +15 -0
- package/dist/dataStructure/constraint/folderExist.cjs +19 -0
- package/dist/dataStructure/constraint/folderExist.d.ts +10 -0
- package/dist/dataStructure/constraint/folderExist.mjs +15 -0
- package/dist/dataStructure/constraint/index.d.ts +5 -0
- package/dist/dataStructure/constraint/mimeType.cjs +18 -0
- package/dist/dataStructure/constraint/mimeType.d.ts +11 -0
- package/dist/dataStructure/constraint/mimeType.mjs +14 -0
- package/dist/dataStructure/constraint/size.cjs +29 -0
- package/dist/dataStructure/constraint/size.d.ts +16 -0
- package/dist/dataStructure/constraint/size.mjs +24 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +12 -0
- package/dist/dataStructure/constraint/types/index.d.ts +1 -0
- package/dist/dataStructure/fundamentalType/file.cjs +11 -0
- package/dist/dataStructure/fundamentalType/file.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/file.mjs +8 -0
- package/dist/dataStructure/fundamentalType/folder.cjs +11 -0
- package/dist/dataStructure/fundamentalType/folder.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/folder.mjs +8 -0
- package/dist/dataStructure/fundamentalType/index.d.ts +3 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/types/index.d.ts +1 -0
- package/dist/dataStructure/helper/file.cjs +10 -0
- package/dist/dataStructure/helper/file.d.ts +3 -0
- package/dist/dataStructure/helper/file.mjs +8 -0
- package/dist/dataStructure/helper/fileExist.cjs +7 -0
- package/dist/dataStructure/helper/fileExist.d.ts +2 -0
- package/dist/dataStructure/helper/fileExist.mjs +7 -0
- package/dist/dataStructure/helper/folder.cjs +10 -0
- package/dist/dataStructure/helper/folder.d.ts +3 -0
- package/dist/dataStructure/helper/folder.mjs +8 -0
- package/dist/dataStructure/helper/folderExist.cjs +7 -0
- package/dist/dataStructure/helper/folderExist.d.ts +2 -0
- package/dist/dataStructure/helper/folderExist.mjs +7 -0
- package/dist/dataStructure/helper/index.d.ts +6 -0
- package/dist/dataStructure/helper/mimeType.cjs +7 -0
- package/dist/dataStructure/helper/mimeType.d.ts +2 -0
- package/dist/dataStructure/helper/mimeType.mjs +7 -0
- package/dist/dataStructure/helper/size.cjs +7 -0
- package/dist/dataStructure/helper/size.d.ts +2 -0
- package/dist/dataStructure/helper/size.mjs +7 -0
- package/dist/dataStructure/index.cjs +83 -0
- package/dist/dataStructure/index.d.ts +6 -0
- package/dist/dataStructure/index.mjs +51 -0
- package/dist/dataStructure/kind.cjs +7 -0
- package/dist/dataStructure/kind.d.ts +2 -0
- package/dist/dataStructure/kind.mjs +5 -0
- package/dist/dataStructure/type/file.cjs +14 -0
- package/dist/dataStructure/type/file.d.ts +11 -0
- package/dist/dataStructure/type/file.mjs +11 -0
- package/dist/dataStructure/type/folder.cjs +14 -0
- package/dist/dataStructure/type/folder.d.ts +11 -0
- package/dist/dataStructure/type/folder.mjs +11 -0
- package/dist/dataStructure/type/index.d.ts +3 -0
- package/dist/dataStructure/type/types/index.d.ts +1 -0
- package/dist/dataStructure/type/types/types.d.ts +8 -0
- package/dist/file/appendFile.cjs +67 -0
- package/dist/file/appendFile.d.ts +43 -0
- package/dist/file/appendFile.mjs +54 -0
- package/dist/file/appendTextFile.cjs +67 -0
- package/dist/file/appendTextFile.d.ts +43 -0
- package/dist/file/appendTextFile.mjs +54 -0
- package/dist/file/copy.cjs +53 -0
- package/dist/file/copy.d.ts +43 -0
- package/dist/file/copy.mjs +40 -0
- package/dist/file/createEntryInterface.cjs +19 -0
- package/dist/file/createEntryInterface.d.ts +3 -0
- package/dist/file/createEntryInterface.mjs +15 -0
- package/dist/file/ensureDirectory.cjs +52 -0
- package/dist/file/ensureDirectory.d.ts +36 -0
- package/dist/file/ensureDirectory.mjs +41 -0
- package/dist/file/ensureFile.cjs +60 -0
- package/dist/file/ensureFile.d.ts +39 -0
- package/dist/file/ensureFile.mjs +48 -0
- package/dist/file/exists.cjs +43 -0
- package/dist/file/exists.d.ts +27 -0
- package/dist/file/exists.mjs +35 -0
- package/dist/file/fileInterface.cjs +76 -0
- package/dist/file/fileInterface.d.ts +31 -0
- package/dist/file/fileInterface.mjs +70 -0
- package/dist/file/folderInterface.cjs +76 -0
- package/dist/file/folderInterface.d.ts +33 -0
- package/dist/file/folderInterface.mjs +70 -0
- package/dist/file/index.cjs +634 -0
- package/dist/file/index.d.ts +35 -0
- package/dist/file/index.mjs +335 -0
- package/dist/file/link.cjs +70 -0
- package/dist/file/link.d.ts +46 -0
- package/dist/file/link.mjs +56 -0
- package/dist/file/linkStat.cjs +98 -0
- package/dist/file/linkStat.d.ts +31 -0
- package/dist/file/linkStat.mjs +88 -0
- package/dist/file/makeDirectory.cjs +60 -0
- package/dist/file/makeDirectory.d.ts +45 -0
- package/dist/file/makeDirectory.mjs +47 -0
- package/dist/file/makeTemporaryDirectory.cjs +48 -0
- package/dist/file/makeTemporaryDirectory.d.ts +32 -0
- package/dist/file/makeTemporaryDirectory.mjs +38 -0
- package/dist/file/makeTemporaryFile.cjs +62 -0
- package/dist/file/makeTemporaryFile.d.ts +36 -0
- package/dist/file/makeTemporaryFile.mjs +50 -0
- package/dist/file/move.cjs +71 -0
- package/dist/file/move.d.ts +46 -0
- package/dist/file/move.mjs +57 -0
- package/dist/file/readDirectory.cjs +44 -0
- package/dist/file/readDirectory.d.ts +35 -0
- package/dist/file/readDirectory.mjs +33 -0
- package/dist/file/readFile.cjs +51 -0
- package/dist/file/readFile.d.ts +33 -0
- package/dist/file/readFile.mjs +41 -0
- package/dist/file/readJsonFile.cjs +51 -0
- package/dist/file/readJsonFile.d.ts +33 -0
- package/dist/file/readJsonFile.mjs +41 -0
- package/dist/file/readLink.cjs +46 -0
- package/dist/file/readLink.d.ts +30 -0
- package/dist/file/readLink.mjs +37 -0
- package/dist/file/readTextFile.cjs +51 -0
- package/dist/file/readTextFile.d.ts +33 -0
- package/dist/file/readTextFile.mjs +41 -0
- package/dist/file/realPath.cjs +42 -0
- package/dist/file/realPath.d.ts +27 -0
- package/dist/file/realPath.mjs +34 -0
- package/dist/file/relocate.cjs +83 -0
- package/dist/file/relocate.d.ts +46 -0
- package/dist/file/relocate.mjs +68 -0
- package/dist/file/remove.cjs +60 -0
- package/dist/file/remove.d.ts +42 -0
- package/dist/file/remove.mjs +48 -0
- package/dist/file/rename.cjs +83 -0
- package/dist/file/rename.d.ts +46 -0
- package/dist/file/rename.mjs +68 -0
- package/dist/file/setMode.cjs +65 -0
- package/dist/file/setMode.d.ts +45 -0
- package/dist/file/setMode.mjs +56 -0
- package/dist/file/setOwner.cjs +53 -0
- package/dist/file/setOwner.d.ts +35 -0
- package/dist/file/setOwner.mjs +44 -0
- package/dist/file/setTime.cjs +55 -0
- package/dist/file/setTime.d.ts +36 -0
- package/dist/file/setTime.mjs +45 -0
- package/dist/file/stat.cjs +99 -0
- package/dist/file/stat.d.ts +62 -0
- package/dist/file/stat.mjs +89 -0
- package/dist/file/symlink.cjs +64 -0
- package/dist/file/symlink.d.ts +48 -0
- package/dist/file/symlink.mjs +52 -0
- package/dist/file/truncate.cjs +60 -0
- package/dist/file/truncate.d.ts +42 -0
- package/dist/file/truncate.mjs +47 -0
- package/dist/file/unknownEntryInterface.cjs +40 -0
- package/dist/file/unknownEntryInterface.d.ts +17 -0
- package/dist/file/unknownEntryInterface.mjs +35 -0
- package/dist/file/walkDirectory.cjs +57 -0
- package/dist/file/walkDirectory.d.ts +37 -0
- package/dist/file/walkDirectory.mjs +45 -0
- package/dist/file/writeFile.cjs +68 -0
- package/dist/file/writeFile.d.ts +43 -0
- package/dist/file/writeFile.mjs +55 -0
- package/dist/file/writeJsonFile.cjs +77 -0
- package/dist/file/writeJsonFile.d.ts +46 -0
- package/dist/file/writeJsonFile.mjs +64 -0
- package/dist/file/writeTextFile.cjs +68 -0
- package/dist/file/writeTextFile.d.ts +43 -0
- package/dist/file/writeTextFile.mjs +55 -0
- package/dist/implementor.cjs +67 -0
- package/dist/implementor.d.ts +35 -0
- package/dist/implementor.mjs +55 -0
- package/dist/index.cjs +76 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +15 -0
- package/dist/kind.cjs +7 -0
- package/dist/kind.d.ts +2 -0
- package/dist/kind.mjs +5 -0
- package/dist/override.d.ts +8 -0
- package/package.json +81 -3
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_kind = require("../kind.cjs");
|
|
3
|
+
const require_stat = require("./stat.cjs");
|
|
4
|
+
const require_rename = require("./rename.cjs");
|
|
5
|
+
const require_exists = require("./exists.cjs");
|
|
6
|
+
const require_move = require("./move.cjs");
|
|
7
|
+
const require_remove = require("./remove.cjs");
|
|
8
|
+
const require_relocate = require("./relocate.cjs");
|
|
9
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
10
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
11
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
12
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
13
|
+
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
14
|
+
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
15
|
+
//#region scripts/file/fileInterface.ts
|
|
16
|
+
const fileInterfaceKind = require_kind.createKind("fileInterface");
|
|
17
|
+
function createFileInterface(path) {
|
|
18
|
+
function getName() {
|
|
19
|
+
return _duplojs_lang_path.getBaseName(path);
|
|
20
|
+
}
|
|
21
|
+
function getExtension(params) {
|
|
22
|
+
return _duplojs_lang_path.getExtensionName(path, params);
|
|
23
|
+
}
|
|
24
|
+
function getMimeType() {
|
|
25
|
+
const extension = getExtension();
|
|
26
|
+
if (!extension) return null;
|
|
27
|
+
return _duplojs_lang_common.mimeType.get(extension) ?? null;
|
|
28
|
+
}
|
|
29
|
+
function getParentPath() {
|
|
30
|
+
return _duplojs_lang_path.getParentFolderPath(path);
|
|
31
|
+
}
|
|
32
|
+
function localExists() {
|
|
33
|
+
return require_exists.exists(path);
|
|
34
|
+
}
|
|
35
|
+
function localRename(newName) {
|
|
36
|
+
return _duplojs_lang_common.asyncPipe(require_rename.rename(path, newName), _duplojs_lang_either.whenIsRight(_duplojs_lang_common.innerPipe(createFileInterface, (value) => _duplojs_lang_either.right("file-system-rename", value))));
|
|
37
|
+
}
|
|
38
|
+
function localRelocate(newParentPath) {
|
|
39
|
+
return _duplojs_lang_common.asyncPipe(require_relocate.relocate(path, newParentPath), _duplojs_lang_either.whenIsRight(_duplojs_lang_common.innerPipe(createFileInterface, (value) => _duplojs_lang_either.right("file-system-relocate", value))));
|
|
40
|
+
}
|
|
41
|
+
function localMove(newPath) {
|
|
42
|
+
return _duplojs_lang_common.asyncPipe(require_move.move(path, newPath), _duplojs_lang_either.whenIsRight(() => _duplojs_lang_either.right("file-system-move", createFileInterface(newPath))));
|
|
43
|
+
}
|
|
44
|
+
function localRemove() {
|
|
45
|
+
return require_remove.remove(path);
|
|
46
|
+
}
|
|
47
|
+
function localStat() {
|
|
48
|
+
return require_stat.stat(path);
|
|
49
|
+
}
|
|
50
|
+
function isFile() {
|
|
51
|
+
return _duplojs_lang_common.asyncPipe(localStat(), _duplojs_lang_either.whenHasInformationOtherwise("file-system-stat", ({ isFile }) => isFile, _duplojs_lang_common.justReturn(false)));
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
path: _duplojs_lang_common.cast(path),
|
|
55
|
+
getName,
|
|
56
|
+
getExtension,
|
|
57
|
+
getMimeType,
|
|
58
|
+
getParentPath,
|
|
59
|
+
rename: localRename,
|
|
60
|
+
exists: localExists,
|
|
61
|
+
relocate: localRelocate,
|
|
62
|
+
remove: localRemove,
|
|
63
|
+
move: localMove,
|
|
64
|
+
stat: localStat,
|
|
65
|
+
isFile,
|
|
66
|
+
[fileInterfaceKind.runTimeKey]: null
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function isFileInterface(input) {
|
|
70
|
+
return fileInterfaceKind.has(input);
|
|
71
|
+
}
|
|
72
|
+
const isFileInterfaceFromUnknown = isFileInterface;
|
|
73
|
+
//#endregion
|
|
74
|
+
exports.createFileInterface = createFileInterface;
|
|
75
|
+
exports.isFileInterface = isFileInterface;
|
|
76
|
+
exports.isFileInterfaceFromUnknown = isFileInterfaceFromUnknown;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RenameResult } from './rename';
|
|
2
|
+
import { ExistsResult } from './exists';
|
|
3
|
+
import { MoveResult } from './move';
|
|
4
|
+
import { RemoveResult } from './remove';
|
|
5
|
+
import { StatResult } from './stat';
|
|
6
|
+
import { RelocateResult } from './relocate';
|
|
7
|
+
import type * as DKind from "@duplojs/lang/kind";
|
|
8
|
+
import * as DPath from "@duplojs/lang/path";
|
|
9
|
+
import * as DEither from "@duplojs/lang/either";
|
|
10
|
+
declare const fileInterfaceKind: DKind.Handler<DKind.Definition<"@DuplojsServer/fileInterface", unknown>>;
|
|
11
|
+
type FileInterfaceRenameResult = Exclude<RenameResult, DEither.Right> | DEither.Right<"file-system-rename", FileInterface>;
|
|
12
|
+
type FileInterfaceRelocateResult = Exclude<RelocateResult, DEither.Right> | DEither.Right<"file-system-relocate", FileInterface>;
|
|
13
|
+
type FileInterfaceMoveResult = Exclude<MoveResult, DEither.Right> | DEither.Right<"file-system-move", FileInterface>;
|
|
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
|
+
getMimeType(): string | null;
|
|
18
|
+
getExtension(params?: DPath.GetExtensionNameParams): (string & DPath.Segment & DPath.Path) | null;
|
|
19
|
+
getParentPath(): ReturnType<typeof DPath.getParentFolderPath<GenericPath>>;
|
|
20
|
+
rename(newName: string & DPath.Segment): Promise<FileInterfaceRenameResult>;
|
|
21
|
+
relocate(parentPath: DPath.AnyPath): Promise<FileInterfaceRelocateResult>;
|
|
22
|
+
move(newPath: DPath.AnyPath): Promise<FileInterfaceMoveResult>;
|
|
23
|
+
exists(): Promise<ExistsResult>;
|
|
24
|
+
remove(): Promise<RemoveResult>;
|
|
25
|
+
stat(): Promise<StatResult>;
|
|
26
|
+
isFile(): Promise<boolean>;
|
|
27
|
+
}
|
|
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;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createKind } from "../kind.mjs";
|
|
2
|
+
import { stat } from "./stat.mjs";
|
|
3
|
+
import { rename } from "./rename.mjs";
|
|
4
|
+
import { exists } from "./exists.mjs";
|
|
5
|
+
import { move } from "./move.mjs";
|
|
6
|
+
import { remove } from "./remove.mjs";
|
|
7
|
+
import { relocate } from "./relocate.mjs";
|
|
8
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
9
|
+
import * as DEither from "@duplojs/lang/either";
|
|
10
|
+
import * as DPath from "@duplojs/lang/path";
|
|
11
|
+
//#region scripts/file/fileInterface.ts
|
|
12
|
+
const fileInterfaceKind = createKind("fileInterface");
|
|
13
|
+
function createFileInterface(path) {
|
|
14
|
+
function getName() {
|
|
15
|
+
return DPath.getBaseName(path);
|
|
16
|
+
}
|
|
17
|
+
function getExtension(params) {
|
|
18
|
+
return DPath.getExtensionName(path, params);
|
|
19
|
+
}
|
|
20
|
+
function getMimeType() {
|
|
21
|
+
const extension = getExtension();
|
|
22
|
+
if (!extension) return null;
|
|
23
|
+
return DCommon.mimeType.get(extension) ?? null;
|
|
24
|
+
}
|
|
25
|
+
function getParentPath() {
|
|
26
|
+
return DPath.getParentFolderPath(path);
|
|
27
|
+
}
|
|
28
|
+
function localExists() {
|
|
29
|
+
return exists(path);
|
|
30
|
+
}
|
|
31
|
+
function localRename(newName) {
|
|
32
|
+
return DCommon.asyncPipe(rename(path, newName), DEither.whenIsRight(DCommon.innerPipe(createFileInterface, (value) => DEither.right("file-system-rename", value))));
|
|
33
|
+
}
|
|
34
|
+
function localRelocate(newParentPath) {
|
|
35
|
+
return DCommon.asyncPipe(relocate(path, newParentPath), DEither.whenIsRight(DCommon.innerPipe(createFileInterface, (value) => DEither.right("file-system-relocate", value))));
|
|
36
|
+
}
|
|
37
|
+
function localMove(newPath) {
|
|
38
|
+
return DCommon.asyncPipe(move(path, newPath), DEither.whenIsRight(() => DEither.right("file-system-move", createFileInterface(newPath))));
|
|
39
|
+
}
|
|
40
|
+
function localRemove() {
|
|
41
|
+
return remove(path);
|
|
42
|
+
}
|
|
43
|
+
function localStat() {
|
|
44
|
+
return stat(path);
|
|
45
|
+
}
|
|
46
|
+
function isFile() {
|
|
47
|
+
return DCommon.asyncPipe(localStat(), DEither.whenHasInformationOtherwise("file-system-stat", ({ isFile }) => isFile, DCommon.justReturn(false)));
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
path: DCommon.cast(path),
|
|
51
|
+
getName,
|
|
52
|
+
getExtension,
|
|
53
|
+
getMimeType,
|
|
54
|
+
getParentPath,
|
|
55
|
+
rename: localRename,
|
|
56
|
+
exists: localExists,
|
|
57
|
+
relocate: localRelocate,
|
|
58
|
+
remove: localRemove,
|
|
59
|
+
move: localMove,
|
|
60
|
+
stat: localStat,
|
|
61
|
+
isFile,
|
|
62
|
+
[fileInterfaceKind.runTimeKey]: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function isFileInterface(input) {
|
|
66
|
+
return fileInterfaceKind.has(input);
|
|
67
|
+
}
|
|
68
|
+
const isFileInterfaceFromUnknown = isFileInterface;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { createFileInterface, isFileInterface, isFileInterfaceFromUnknown };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_kind = require("../kind.cjs");
|
|
3
|
+
const require_stat = require("./stat.cjs");
|
|
4
|
+
const require_rename = require("./rename.cjs");
|
|
5
|
+
const require_exists = require("./exists.cjs");
|
|
6
|
+
const require_move = require("./move.cjs");
|
|
7
|
+
const require_remove = require("./remove.cjs");
|
|
8
|
+
const require_relocate = require("./relocate.cjs");
|
|
9
|
+
const require_readDirectory = require("./readDirectory.cjs");
|
|
10
|
+
const require_walkDirectory = require("./walkDirectory.cjs");
|
|
11
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
12
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
13
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
14
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
15
|
+
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
16
|
+
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
17
|
+
//#region scripts/file/folderInterface.ts
|
|
18
|
+
const folderInterfaceKind = require_kind.createKind("folderInterface");
|
|
19
|
+
function createFolderInterface(path) {
|
|
20
|
+
function getName() {
|
|
21
|
+
return _duplojs_lang_path.getBaseName(path);
|
|
22
|
+
}
|
|
23
|
+
function getParentPath() {
|
|
24
|
+
return _duplojs_lang_path.getParentFolderPath(path);
|
|
25
|
+
}
|
|
26
|
+
function localRename(newName) {
|
|
27
|
+
return _duplojs_lang_common.asyncPipe(require_rename.rename(path, newName), _duplojs_lang_either.whenIsRight(_duplojs_lang_common.innerPipe(createFolderInterface, (value) => _duplojs_lang_either.right("file-system-rename", value))));
|
|
28
|
+
}
|
|
29
|
+
function localRelocate(newParentPath) {
|
|
30
|
+
return _duplojs_lang_common.asyncPipe(require_relocate.relocate(path, newParentPath), _duplojs_lang_either.whenIsRight(_duplojs_lang_common.innerPipe(createFolderInterface, (value) => _duplojs_lang_either.right("file-system-relocate", value))));
|
|
31
|
+
}
|
|
32
|
+
function localMove(newPath) {
|
|
33
|
+
return _duplojs_lang_common.asyncPipe(require_move.move(path, newPath), _duplojs_lang_either.whenIsRight(() => _duplojs_lang_either.right("file-system-move", createFolderInterface(newPath))));
|
|
34
|
+
}
|
|
35
|
+
function localExists() {
|
|
36
|
+
return require_exists.exists(path);
|
|
37
|
+
}
|
|
38
|
+
function localRemove() {
|
|
39
|
+
return require_remove.remove(path);
|
|
40
|
+
}
|
|
41
|
+
function localStat() {
|
|
42
|
+
return require_stat.stat(path);
|
|
43
|
+
}
|
|
44
|
+
function getChildren() {
|
|
45
|
+
return require_readDirectory.readDirectory(path);
|
|
46
|
+
}
|
|
47
|
+
function walk(params) {
|
|
48
|
+
return require_walkDirectory.walkDirectory(path, params);
|
|
49
|
+
}
|
|
50
|
+
function isFolder() {
|
|
51
|
+
return _duplojs_lang_common.asyncPipe(localStat(), _duplojs_lang_either.whenHasInformationOtherwise("file-system-stat", ({ isDirectory }) => isDirectory, _duplojs_lang_common.justReturn(false)));
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
path: _duplojs_lang_common.cast(path),
|
|
55
|
+
getName,
|
|
56
|
+
getParentPath,
|
|
57
|
+
move: localMove,
|
|
58
|
+
rename: localRename,
|
|
59
|
+
exists: localExists,
|
|
60
|
+
relocate: localRelocate,
|
|
61
|
+
remove: localRemove,
|
|
62
|
+
getChildren,
|
|
63
|
+
stat: localStat,
|
|
64
|
+
walk,
|
|
65
|
+
isFolder,
|
|
66
|
+
[folderInterfaceKind.runTimeKey]: null
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function isFolderInterface(input) {
|
|
70
|
+
return folderInterfaceKind.has(input);
|
|
71
|
+
}
|
|
72
|
+
const isFolderInterfaceFromUnknown = isFolderInterface;
|
|
73
|
+
//#endregion
|
|
74
|
+
exports.createFolderInterface = createFolderInterface;
|
|
75
|
+
exports.isFolderInterface = isFolderInterface;
|
|
76
|
+
exports.isFolderInterfaceFromUnknown = isFolderInterfaceFromUnknown;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MoveResult } from './move';
|
|
2
|
+
import { ExistsResult } from './exists';
|
|
3
|
+
import { RenameResult } from './rename';
|
|
4
|
+
import { RemoveResult } from './remove';
|
|
5
|
+
import { ReadDirectoryResult } from './readDirectory';
|
|
6
|
+
import { StatResult } from './stat';
|
|
7
|
+
import { WalkDirectoryParams, WalkDirectoryResult } from './walkDirectory';
|
|
8
|
+
import { RelocateResult } from './relocate';
|
|
9
|
+
import type * as DKind from "@duplojs/lang/kind";
|
|
10
|
+
import * as DPath from "@duplojs/lang/path";
|
|
11
|
+
import * as DEither from "@duplojs/lang/either";
|
|
12
|
+
declare const folderInterfaceKind: DKind.Handler<DKind.Definition<"@DuplojsServer/folderInterface", unknown>>;
|
|
13
|
+
type FolderInterfaceRenameResult = Exclude<RenameResult, DEither.Right> | DEither.Right<"file-system-rename", FolderInterface>;
|
|
14
|
+
type FolderInterfaceRelocateResult = Exclude<RelocateResult, DEither.Right> | DEither.Right<"file-system-relocate", FolderInterface>;
|
|
15
|
+
type FolderInterfaceMoveResult = Exclude<MoveResult, DEither.Right> | DEither.Right<"file-system-move", FolderInterface>;
|
|
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
|
+
rename(newName: (string & DPath.Segment)): Promise<FolderInterfaceRenameResult>;
|
|
21
|
+
exists(): Promise<ExistsResult>;
|
|
22
|
+
relocate(parentPath: DPath.AnyPath): Promise<FolderInterfaceRelocateResult>;
|
|
23
|
+
move(newPath: DPath.AnyPath): Promise<FolderInterfaceMoveResult>;
|
|
24
|
+
remove(): Promise<RemoveResult>;
|
|
25
|
+
getChildren(): Promise<ReadDirectoryResult>;
|
|
26
|
+
stat(): Promise<StatResult>;
|
|
27
|
+
walk(params?: WalkDirectoryParams): Promise<WalkDirectoryResult>;
|
|
28
|
+
isFolder(): Promise<boolean>;
|
|
29
|
+
}
|
|
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;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createKind } from "../kind.mjs";
|
|
2
|
+
import { stat } from "./stat.mjs";
|
|
3
|
+
import { rename } from "./rename.mjs";
|
|
4
|
+
import { exists } from "./exists.mjs";
|
|
5
|
+
import { move } from "./move.mjs";
|
|
6
|
+
import { remove } from "./remove.mjs";
|
|
7
|
+
import { relocate } from "./relocate.mjs";
|
|
8
|
+
import { readDirectory } from "./readDirectory.mjs";
|
|
9
|
+
import { walkDirectory } from "./walkDirectory.mjs";
|
|
10
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
11
|
+
import * as DEither from "@duplojs/lang/either";
|
|
12
|
+
import * as DPath from "@duplojs/lang/path";
|
|
13
|
+
//#region scripts/file/folderInterface.ts
|
|
14
|
+
const folderInterfaceKind = createKind("folderInterface");
|
|
15
|
+
function createFolderInterface(path) {
|
|
16
|
+
function getName() {
|
|
17
|
+
return DPath.getBaseName(path);
|
|
18
|
+
}
|
|
19
|
+
function getParentPath() {
|
|
20
|
+
return DPath.getParentFolderPath(path);
|
|
21
|
+
}
|
|
22
|
+
function localRename(newName) {
|
|
23
|
+
return DCommon.asyncPipe(rename(path, newName), DEither.whenIsRight(DCommon.innerPipe(createFolderInterface, (value) => DEither.right("file-system-rename", value))));
|
|
24
|
+
}
|
|
25
|
+
function localRelocate(newParentPath) {
|
|
26
|
+
return DCommon.asyncPipe(relocate(path, newParentPath), DEither.whenIsRight(DCommon.innerPipe(createFolderInterface, (value) => DEither.right("file-system-relocate", value))));
|
|
27
|
+
}
|
|
28
|
+
function localMove(newPath) {
|
|
29
|
+
return DCommon.asyncPipe(move(path, newPath), DEither.whenIsRight(() => DEither.right("file-system-move", createFolderInterface(newPath))));
|
|
30
|
+
}
|
|
31
|
+
function localExists() {
|
|
32
|
+
return exists(path);
|
|
33
|
+
}
|
|
34
|
+
function localRemove() {
|
|
35
|
+
return remove(path);
|
|
36
|
+
}
|
|
37
|
+
function localStat() {
|
|
38
|
+
return stat(path);
|
|
39
|
+
}
|
|
40
|
+
function getChildren() {
|
|
41
|
+
return readDirectory(path);
|
|
42
|
+
}
|
|
43
|
+
function walk(params) {
|
|
44
|
+
return walkDirectory(path, params);
|
|
45
|
+
}
|
|
46
|
+
function isFolder() {
|
|
47
|
+
return DCommon.asyncPipe(localStat(), DEither.whenHasInformationOtherwise("file-system-stat", ({ isDirectory }) => isDirectory, DCommon.justReturn(false)));
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
path: DCommon.cast(path),
|
|
51
|
+
getName,
|
|
52
|
+
getParentPath,
|
|
53
|
+
move: localMove,
|
|
54
|
+
rename: localRename,
|
|
55
|
+
exists: localExists,
|
|
56
|
+
relocate: localRelocate,
|
|
57
|
+
remove: localRemove,
|
|
58
|
+
getChildren,
|
|
59
|
+
stat: localStat,
|
|
60
|
+
walk,
|
|
61
|
+
isFolder,
|
|
62
|
+
[folderInterfaceKind.runTimeKey]: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function isFolderInterface(input) {
|
|
66
|
+
return folderInterfaceKind.has(input);
|
|
67
|
+
}
|
|
68
|
+
const isFolderInterfaceFromUnknown = isFolderInterface;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { createFolderInterface, isFolderInterface, isFolderInterfaceFromUnknown };
|