@duplojs/server 0.1.0-beta.2 → 0.1.0-beta.4
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/dist/_virtual/_rolldown/runtime.mjs +5 -1
- package/dist/command/argument.d.ts +2 -2
- package/dist/command/create.cjs +18 -10
- package/dist/command/create.d.ts +3 -3
- package/dist/command/create.mjs +18 -10
- package/dist/command/error.cjs +26 -2
- package/dist/command/error.d.ts +9 -1
- package/dist/command/error.mjs +25 -1
- package/dist/command/exec.d.ts +4 -3
- package/dist/command/help.cjs +11 -9
- package/dist/command/help.d.ts +1 -1
- package/dist/command/help.mjs +10 -8
- package/dist/command/index.cjs +4 -0
- package/dist/command/index.mjs +4 -2
- package/dist/command/options/base.cjs +21 -13
- package/dist/command/options/base.d.ts +6 -0
- package/dist/command/options/base.mjs +20 -14
- package/dist/command/options/defaults/array.d.ts +6 -4
- package/dist/command/options/defaults/boolean.cjs +21 -7
- package/dist/command/options/defaults/boolean.d.ts +6 -3
- package/dist/command/options/defaults/boolean.mjs +20 -8
- package/dist/command/options/defaults/simple.d.ts +6 -4
- package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
- package/dist/command/types/index.d.ts +1 -0
- package/dist/common/environmentVariable/index.d.ts +1 -1
- package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +1 -1
- package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +2 -1
- package/dist/common/index.cjs +3 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.mjs +3 -1
- 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/dataStructure/common/codec/defaults/json.cjs +12 -1
- package/dist/dataStructure/common/codec/defaults/json.d.ts +2 -2
- package/dist/dataStructure/common/codec/defaults/json.mjs +12 -1
- package/dist/dataStructure/common/codec/defaults/string.cjs +12 -1
- package/dist/dataStructure/common/codec/defaults/string.d.ts +2 -2
- package/dist/dataStructure/common/codec/defaults/string.mjs +12 -1
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +3 -1
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +7 -2
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +3 -1
- package/dist/dataStructure/constraint/{exist.cjs → fileExist.cjs} +5 -5
- package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
- package/dist/dataStructure/constraint/{exist.mjs → fileExist.mjs} +4 -4
- 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 +2 -1
- package/dist/dataStructure/constraint/mimeType.cjs +1 -1
- package/dist/dataStructure/constraint/mimeType.mjs +1 -1
- package/dist/dataStructure/constraint/types/constraints.d.ts +4 -2
- 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 +1 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +2 -0
- package/dist/dataStructure/helper/file.d.ts +1 -1
- 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 +3 -1
- package/dist/dataStructure/index.cjs +29 -8
- package/dist/dataStructure/index.mjs +19 -6
- 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 +1 -0
- package/dist/dataStructure/type/types/types.d.ts +2 -0
- package/dist/file/appendFile.cjs +46 -22
- package/dist/file/appendFile.d.ts +37 -5
- package/dist/file/appendFile.mjs +36 -23
- package/dist/file/appendTextFile.cjs +44 -20
- package/dist/file/appendTextFile.d.ts +37 -5
- package/dist/file/appendTextFile.mjs +34 -21
- package/dist/file/copy.cjs +36 -14
- package/dist/file/copy.d.ts +37 -5
- package/dist/file/copy.mjs +26 -15
- package/dist/file/createEntryInterface.cjs +6 -3
- package/dist/file/createEntryInterface.d.ts +1 -1
- package/dist/file/createEntryInterface.mjs +4 -2
- package/dist/file/ensureDirectory.cjs +37 -17
- package/dist/file/ensureDirectory.d.ts +30 -4
- package/dist/file/ensureDirectory.mjs +29 -18
- package/dist/file/ensureFile.cjs +41 -19
- package/dist/file/ensureFile.d.ts +33 -4
- package/dist/file/ensureFile.mjs +32 -20
- package/dist/file/exists.cjs +28 -14
- package/dist/file/exists.d.ts +21 -4
- package/dist/file/exists.mjs +23 -15
- package/dist/file/fileInterface.cjs +3 -1
- package/dist/file/fileInterface.d.ts +10 -9
- package/dist/file/fileInterface.mjs +3 -2
- package/dist/file/folderInterface.cjs +3 -1
- package/dist/file/folderInterface.d.ts +9 -8
- package/dist/file/folderInterface.mjs +3 -2
- package/dist/file/index.cjs +512 -0
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.mjs +291 -35
- package/dist/file/link.cjs +48 -22
- package/dist/file/link.d.ts +40 -5
- package/dist/file/link.mjs +37 -23
- package/dist/file/linkStat.cjs +29 -15
- package/dist/file/linkStat.d.ts +24 -4
- package/dist/file/linkStat.mjs +24 -16
- package/dist/file/makeDirectory.cjs +45 -21
- package/dist/file/makeDirectory.d.ts +35 -4
- package/dist/file/makeDirectory.mjs +35 -22
- package/dist/file/makeTemporaryDirectory.cjs +33 -15
- package/dist/file/makeTemporaryDirectory.d.ts +25 -2
- package/dist/file/makeTemporaryDirectory.mjs +26 -16
- package/dist/file/makeTemporaryFile.cjs +37 -20
- package/dist/file/makeTemporaryFile.d.ts +28 -2
- package/dist/file/makeTemporaryFile.mjs +30 -21
- package/dist/file/move.cjs +49 -23
- package/dist/file/move.d.ts +40 -5
- package/dist/file/move.mjs +38 -24
- package/dist/file/readDirectory.cjs +33 -9
- package/dist/file/readDirectory.d.ts +26 -5
- package/dist/file/readDirectory.mjs +25 -10
- package/dist/file/readFile.cjs +35 -17
- package/dist/file/readFile.d.ts +27 -4
- package/dist/file/readFile.mjs +28 -18
- package/dist/file/readJsonFile.cjs +35 -17
- package/dist/file/readJsonFile.d.ts +27 -5
- package/dist/file/readJsonFile.mjs +28 -18
- package/dist/file/readLink.cjs +31 -15
- package/dist/file/readLink.d.ts +24 -4
- package/dist/file/readLink.mjs +25 -16
- package/dist/file/readTextFile.cjs +35 -17
- package/dist/file/readTextFile.d.ts +27 -4
- package/dist/file/readTextFile.mjs +28 -18
- package/dist/file/realPath.cjs +27 -13
- package/dist/file/realPath.d.ts +21 -4
- package/dist/file/realPath.mjs +22 -14
- package/dist/file/relocate.cjs +52 -25
- package/dist/file/relocate.d.ts +40 -5
- package/dist/file/relocate.mjs +41 -26
- package/dist/file/remove.cjs +45 -23
- package/dist/file/remove.d.ts +32 -4
- package/dist/file/remove.mjs +36 -24
- package/dist/file/rename.cjs +52 -25
- package/dist/file/rename.d.ts +40 -5
- package/dist/file/rename.mjs +41 -26
- package/dist/file/setMode.cjs +29 -15
- package/dist/file/setMode.d.ts +24 -5
- package/dist/file/setMode.mjs +24 -16
- package/dist/file/setOwner.cjs +31 -15
- package/dist/file/setOwner.d.ts +25 -5
- package/dist/file/setOwner.mjs +25 -16
- package/dist/file/setTime.cjs +31 -15
- package/dist/file/setTime.d.ts +24 -5
- package/dist/file/setTime.mjs +25 -16
- package/dist/file/stat.cjs +29 -15
- package/dist/file/stat.d.ts +24 -4
- package/dist/file/stat.mjs +24 -16
- package/dist/file/symlink.cjs +42 -20
- package/dist/file/symlink.d.ts +34 -5
- package/dist/file/symlink.mjs +33 -21
- package/dist/file/truncate.cjs +43 -21
- package/dist/file/truncate.d.ts +36 -4
- package/dist/file/truncate.mjs +34 -22
- package/dist/file/unknownEntryInterface.cjs +5 -1
- package/dist/file/unknownEntryInterface.d.ts +8 -6
- package/dist/file/unknownEntryInterface.mjs +4 -2
- package/dist/file/walkDirectory.cjs +38 -15
- package/dist/file/walkDirectory.d.ts +25 -4
- package/dist/file/walkDirectory.mjs +32 -15
- package/dist/file/writeFile.cjs +45 -21
- package/dist/file/writeFile.d.ts +37 -5
- package/dist/file/writeFile.mjs +35 -22
- package/dist/file/writeJsonFile.cjs +48 -27
- package/dist/file/writeJsonFile.d.ts +37 -6
- package/dist/file/writeJsonFile.mjs +39 -28
- package/dist/file/writeTextFile.cjs +45 -21
- package/dist/file/writeTextFile.d.ts +37 -5
- package/dist/file/writeTextFile.mjs +35 -22
- package/dist/implementor.cjs +8 -5
- package/dist/implementor.d.ts +4 -4
- package/dist/implementor.mjs +8 -5
- package/dist/index.cjs +2 -0
- package/dist/index.mjs +2 -1
- package/dist/override.d.ts +8 -0
- package/package.json +4 -4
- package/dist/dataStructure/constraint/exist.d.ts +0 -10
- package/dist/dataStructure/helper/exist.cjs +0 -7
- package/dist/dataStructure/helper/exist.d.ts +0 -2
- package/dist/dataStructure/helper/exist.mjs +0 -7
- package/dist/file/types/fileSystemEither.d.ts +0 -2
- package/dist/file/types/index.d.ts +0 -1
- /package/{README → README.md} +0 -0
|
@@ -5,24 +5,30 @@ import * as DArray from "@duplojs/lang/array";
|
|
|
5
5
|
import * as DString from "@duplojs/lang/string";
|
|
6
6
|
//#region scripts/command/options/base.ts
|
|
7
7
|
const optionKind = createKind("command-option");
|
|
8
|
-
const regexOption = /^(?<dashes>-{1,2})(?<key>[A-Za-z0-9][A-Za-z0-9_-]*)(?:=(?<value>.*))?$/;
|
|
8
|
+
const regexOption = /^(?<dashes>-{1,2})(?<key>(?![0-9]+(?:=|$))[A-Za-z0-9][A-Za-z0-9_-]*)(?:=(?<value>.*))?$/;
|
|
9
|
+
function isOptionToken(input) {
|
|
10
|
+
return DString.test(input, regexOption);
|
|
11
|
+
}
|
|
12
|
+
function findOptionToken(args, option) {
|
|
13
|
+
return DArray.reduce(args, DArray.reduceFrom(null), ({ element, next, exit, index }) => {
|
|
14
|
+
const extractResult = DString.extract(element, regexOption);
|
|
15
|
+
if (!extractResult) return next(null);
|
|
16
|
+
const key = extractResult.namedGroups.key;
|
|
17
|
+
if (option.name !== key && (!DArray.includes(option.aliases, key) || extractResult.namedGroups?.dashes !== "-")) return next(null);
|
|
18
|
+
return exit({
|
|
19
|
+
key,
|
|
20
|
+
value: extractResult.namedGroups?.value,
|
|
21
|
+
index
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
9
25
|
function constructOption(kindHandler, createConstructor) {
|
|
10
26
|
return createConstructor({ init: (name, execute, params, ...rest) => {
|
|
11
27
|
const self = {
|
|
12
28
|
...Object.fromEntries(Object.entries(rest[0] ?? {}).map(([key, prop]) => typeof prop === "function" ? [key, (...args) => prop(self, ...args)] : [key, prop])),
|
|
13
29
|
name,
|
|
14
30
|
execute: async (args, error) => {
|
|
15
|
-
const result =
|
|
16
|
-
const extractResult = DString.extract(element, regexOption);
|
|
17
|
-
if (!extractResult) return next(null);
|
|
18
|
-
const result = {
|
|
19
|
-
key: extractResult.namedGroups.key,
|
|
20
|
-
value: extractResult.namedGroups?.value,
|
|
21
|
-
index
|
|
22
|
-
};
|
|
23
|
-
if (self.name !== result.key && (!DArray.includes(self.aliases, result.key) || extractResult.namedGroups?.dashes !== "-")) return next(null);
|
|
24
|
-
return exit(result);
|
|
25
|
-
});
|
|
31
|
+
const result = findOptionToken(args, self);
|
|
26
32
|
const { value, argumentRest } = DCommon.justExec(() => {
|
|
27
33
|
if (!result) return {
|
|
28
34
|
value: null,
|
|
@@ -30,7 +36,7 @@ function constructOption(kindHandler, createConstructor) {
|
|
|
30
36
|
};
|
|
31
37
|
if (result.value === void 0) {
|
|
32
38
|
const nextArg = args[result.index + 1];
|
|
33
|
-
if (nextArg === void 0 ||
|
|
39
|
+
if (nextArg === void 0 || isOptionToken(nextArg)) return {
|
|
34
40
|
value: void 0,
|
|
35
41
|
argumentRest: DArray.spliceDelete(args, result.index, 1)
|
|
36
42
|
};
|
|
@@ -60,4 +66,4 @@ function constructOption(kindHandler, createConstructor) {
|
|
|
60
66
|
} });
|
|
61
67
|
}
|
|
62
68
|
//#endregion
|
|
63
|
-
export { constructOption, optionKind };
|
|
69
|
+
export { constructOption, findOptionToken, isOptionToken, optionKind };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from '../base';
|
|
2
|
-
import { EligibleType } from '../../types';
|
|
2
|
+
import { EligibleType, ForbiddenInvalidIdentifier } from '../../types';
|
|
3
3
|
import * as DCommon from "@duplojs/lang/common";
|
|
4
4
|
import type * as DKind from "@duplojs/lang/kind";
|
|
5
5
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
@@ -13,12 +13,14 @@ export interface ArrayOption<GenericName extends string = string, GenericValue e
|
|
|
13
13
|
readonly min?: number;
|
|
14
14
|
readonly max?: number;
|
|
15
15
|
}
|
|
16
|
-
export interface CreateArrayOptionParams {
|
|
16
|
+
export interface CreateArrayOptionParams<GenericAliases extends readonly string[] = readonly string[]> {
|
|
17
17
|
description?: string;
|
|
18
|
-
aliases?:
|
|
18
|
+
aliases?: (GenericAliases & {
|
|
19
|
+
readonly [Index in keyof GenericAliases]: ForbiddenInvalidIdentifier<GenericAliases[Index]>;
|
|
20
|
+
});
|
|
19
21
|
min?: number;
|
|
20
22
|
max?: number;
|
|
21
23
|
required?: boolean;
|
|
22
24
|
separator?: string;
|
|
23
25
|
}
|
|
24
|
-
export declare const createArrayOption: <GenericName extends string, GenericStructure extends DDataStructure.Structure<EligibleType>, GenericValue extends DDataStructure.StructureValue<GenericStructure>, const GenericParams extends CreateArrayOptionParams = {}>(name: GenericName
|
|
26
|
+
export declare const createArrayOption: <GenericName extends string, GenericStructure extends DDataStructure.Structure<EligibleType>, GenericValue extends DDataStructure.StructureValue<GenericStructure>, const GenericAliases extends readonly string[] = readonly string[], const GenericParams extends CreateArrayOptionParams<GenericAliases> = {}>(name: GenericName & ForbiddenInvalidIdentifier<GenericName>, dataStructure: GenericStructure, params?: GenericParams & CreateArrayOptionParams<GenericAliases>) => ArrayOption<GenericName, ((readonly GenericValue[] & (DNumber.IsLiteral<Extract<GenericParams["min"], number>> extends true ? DArray.MinElements<Extract<GenericParams["min"], number>> : unknown) & (DNumber.IsLiteral<Extract<GenericParams["max"], number>> extends true ? DArray.MaxElements<Extract<GenericParams["max"], number>> : unknown)) | (DCommon.IsEqual<GenericParams["required"], true> extends true ? never : undefined))>;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
1
2
|
const require_kind = require("../../kind.cjs");
|
|
2
3
|
const require_base = require("../base.cjs");
|
|
4
|
+
let _duplojs_lang_array = require("@duplojs/lang/array");
|
|
5
|
+
_duplojs_lang_array = require_runtime.__toESM(_duplojs_lang_array, 1);
|
|
3
6
|
//#region scripts/command/options/defaults/boolean.ts
|
|
4
7
|
const booleanOptionKind = require_kind.createKind("command-boolean-option");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function createBooleanOption(name, params) {
|
|
9
|
+
const self = {
|
|
10
|
+
name,
|
|
11
|
+
description: params?.description ?? null,
|
|
12
|
+
aliases: params?.aliases ?? [],
|
|
13
|
+
execute: (args, error) => {
|
|
14
|
+
const token = require_base.findOptionToken(args, self);
|
|
15
|
+
if (token?.value !== void 0) return Promise.resolve(error.addUnexpectedOptionValueIssue(self.name, token.value));
|
|
16
|
+
return Promise.resolve({
|
|
17
|
+
result: token !== null,
|
|
18
|
+
argumentRest: token ? _duplojs_lang_array.spliceDelete(args, token.index, 1) : args
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
[require_base.optionKind.runTimeKey]: null,
|
|
22
|
+
[booleanOptionKind.runTimeKey]: null
|
|
23
|
+
};
|
|
24
|
+
return self;
|
|
25
|
+
}
|
|
12
26
|
//#endregion
|
|
13
27
|
exports.booleanOptionKind = booleanOptionKind;
|
|
14
28
|
exports.createBooleanOption = createBooleanOption;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Option } from '../base';
|
|
2
|
+
import { ForbiddenInvalidIdentifier } from '../../types';
|
|
2
3
|
import type * as DCommon from "@duplojs/lang/common";
|
|
3
4
|
import type * as DKind from "@duplojs/lang/kind";
|
|
4
5
|
export declare const booleanOptionKind: DKind.Handler<DKind.Definition<"@DuplojsServerCommand/command-boolean-option", unknown>>;
|
|
5
6
|
export interface BooleanOption<GenericName extends string = string> extends DCommon.Forward<Option<GenericName, boolean> & DKind.Kind<typeof booleanOptionKind>> {
|
|
6
7
|
}
|
|
7
|
-
export interface CreateBooleanOptionParams {
|
|
8
|
+
export interface CreateBooleanOptionParams<GenericAliases extends readonly string[] = readonly string[]> {
|
|
8
9
|
description?: string;
|
|
9
|
-
aliases?:
|
|
10
|
+
aliases?: (GenericAliases & {
|
|
11
|
+
readonly [Index in keyof GenericAliases]: ForbiddenInvalidIdentifier<GenericAliases[Index]>;
|
|
12
|
+
});
|
|
10
13
|
}
|
|
11
|
-
export declare
|
|
14
|
+
export declare function createBooleanOption<GenericName extends string, const GenericAliases extends readonly string[] = readonly string[]>(name: GenericName & ForbiddenInvalidIdentifier<GenericName>, params?: CreateBooleanOptionParams<GenericAliases>): BooleanOption<GenericName>;
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { createKind } from "../../kind.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { findOptionToken, optionKind } from "../base.mjs";
|
|
3
|
+
import * as DArray from "@duplojs/lang/array";
|
|
3
4
|
//#region scripts/command/options/defaults/boolean.ts
|
|
4
5
|
const booleanOptionKind = createKind("command-boolean-option");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
function createBooleanOption(name, params) {
|
|
7
|
+
const self = {
|
|
8
|
+
name,
|
|
9
|
+
description: params?.description ?? null,
|
|
10
|
+
aliases: params?.aliases ?? [],
|
|
11
|
+
execute: (args, error) => {
|
|
12
|
+
const token = findOptionToken(args, self);
|
|
13
|
+
if (token?.value !== void 0) return Promise.resolve(error.addUnexpectedOptionValueIssue(self.name, token.value));
|
|
14
|
+
return Promise.resolve({
|
|
15
|
+
result: token !== null,
|
|
16
|
+
argumentRest: token ? DArray.spliceDelete(args, token.index, 1) : args
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
[optionKind.runTimeKey]: null,
|
|
20
|
+
[booleanOptionKind.runTimeKey]: null
|
|
21
|
+
};
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
12
24
|
//#endregion
|
|
13
25
|
export { booleanOptionKind, createBooleanOption };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from '../base';
|
|
2
|
-
import { EligibleType } from '../../types';
|
|
2
|
+
import { EligibleType, ForbiddenInvalidIdentifier } from '../../types';
|
|
3
3
|
import type * as DCommon from "@duplojs/lang/common";
|
|
4
4
|
import type * as DKind from "@duplojs/lang/kind";
|
|
5
5
|
import type * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
@@ -8,9 +8,11 @@ export interface SimpleOption<GenericName extends string = string, GenericValue
|
|
|
8
8
|
readonly dataStructure: DDataStructure.Structure<GenericValue>;
|
|
9
9
|
readonly required: boolean;
|
|
10
10
|
}
|
|
11
|
-
export interface CreateSimpleOptionParams {
|
|
11
|
+
export interface CreateSimpleOptionParams<GenericAliases extends readonly string[] = readonly string[]> {
|
|
12
12
|
description?: string;
|
|
13
|
-
aliases?:
|
|
13
|
+
aliases?: (GenericAliases & {
|
|
14
|
+
readonly [Index in keyof GenericAliases]: ForbiddenInvalidIdentifier<GenericAliases[Index]>;
|
|
15
|
+
});
|
|
14
16
|
required?: boolean;
|
|
15
17
|
}
|
|
16
|
-
export declare const createOption: <GenericName extends string, GenericStructure extends DDataStructure.Structure<EligibleType>, GenericValue extends DDataStructure.StructureValue<GenericStructure>, const GenericParams extends CreateSimpleOptionParams = {}>(name: GenericName
|
|
18
|
+
export declare const createOption: <GenericName extends string, GenericStructure extends DDataStructure.Structure<EligibleType>, GenericValue extends DDataStructure.StructureValue<GenericStructure>, const GenericAliases extends readonly string[] = readonly string[], const GenericParams extends CreateSimpleOptionParams<GenericAliases> = {}>(name: GenericName & ForbiddenInvalidIdentifier<GenericName>, dataStructure: GenericStructure, params?: GenericParams & CreateSimpleOptionParams<GenericAliases>) => SimpleOption<GenericName, (GenericValue | (DCommon.IsEqual<GenericParams["required"], true> extends true ? never : undefined))>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import type * as DString from "@duplojs/lang/string";
|
|
3
|
+
type AlphanumericCharacter = (DString.CharactersRangeStore["a-z" | "A-Z"] | DString.Digit);
|
|
4
|
+
type AllowedIdentifierCharacter = (AlphanumericCharacter | "_" | "-");
|
|
5
|
+
export type ForbiddenInvalidIdentifier<GenericName extends string> = DCommon.ContainExtends<GenericName, DCommon.BaseConstraint> extends true ? DCommon.ComputedTypeError<"Identifier cannot be a constrained string."> : DString.IsLiteral<GenericName> extends true ? DCommon.IsUnion<GenericName> extends true ? DCommon.ComputedTypeError<"Identifier must be a single string literal."> : DCommon.IsEqual<GenericName, ""> extends true ? DCommon.ComputedTypeError<"Identifier cannot be empty."> : DString.StartsWith<GenericName, AlphanumericCharacter> extends true ? DString.IsAllowedString<GenericName, AllowedIdentifierCharacter> extends true ? DString.IsAllowedString<GenericName, DString.Digit> extends false ? unknown : DCommon.ComputedTypeError<`Identifier "${GenericName}" cannot contain only digits.`> : DCommon.ComputedTypeError<`Identifier "${GenericName}" contains invalid characters (allowed: A-Z, a-z, 0-9, "_" and "-").`> : DCommon.ComputedTypeError<`Identifier "${GenericName}" must start with a letter or digit.`> : DCommon.ComputedTypeError<"Identifier must be a known string literal.">;
|
|
6
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import * as DEither from "@duplojs/lang/either";
|
|
|
3
3
|
import type * as DPath from "@duplojs/lang/path";
|
|
4
4
|
import type * as DSFile from '../../file';
|
|
5
5
|
export interface EnvironmentVariableFileParams {
|
|
6
|
-
includedEnvironmentFiles?:
|
|
6
|
+
includedEnvironmentFiles?: DPath.AnyPath[];
|
|
7
7
|
override?: boolean;
|
|
8
8
|
justRead?: boolean;
|
|
9
9
|
codecs?: DDataStructure.Codecs;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as DPath from "@duplojs/lang/path";
|
|
2
2
|
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import * as DSFile from '../../file';
|
|
3
4
|
export declare function parseEnvironmentLine(line: string): Record<string, string>;
|
|
4
|
-
export declare function parseEnvironmentFiles(baseEnv: Record<string, string>, paths:
|
|
5
|
+
export declare function parseEnvironmentFiles(baseEnv: Record<string, string>, paths: DPath.AnyPath[]): Promise<DEither.Left<"file-system-read-text-file-error", DSFile.ReadTextFileErrors> | readonly Record<string, string>[]>;
|
package/dist/common/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ const require_index = require("./environmentVariable/index.cjs");
|
|
|
7
7
|
const require_environmentVariableOrThrow = require("./environmentVariableOrThrow.cjs");
|
|
8
8
|
const require_exitProcess = require("./exitProcess.cjs");
|
|
9
9
|
const require_getProcessArguments = require("./getProcessArguments.cjs");
|
|
10
|
+
const require_getCurrentDirectoryName = require("./meta/getCurrentDirectoryName.cjs");
|
|
10
11
|
//#region scripts/common/index.ts
|
|
11
12
|
var common_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
12
13
|
EnvironmentVariableError: () => require_environmentVariableOrThrow.EnvironmentVariableError,
|
|
@@ -15,6 +16,7 @@ var common_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
15
16
|
environmentVariable: () => require_index.environmentVariable,
|
|
16
17
|
environmentVariableOrThrow: () => require_environmentVariableOrThrow.environmentVariableOrThrow,
|
|
17
18
|
exitProcess: () => require_exitProcess.exitProcess,
|
|
19
|
+
getCurrentDirectoryName: () => require_getCurrentDirectoryName.getCurrentDirectoryName,
|
|
18
20
|
getCurrentWorkDirectory: () => require_getCurrentWorkDirectory.getCurrentWorkDirectory,
|
|
19
21
|
getCurrentWorkDirectoryOrThrow: () => require_getCurrentWorkDirectoryOrThrow.getCurrentWorkDirectoryOrThrow,
|
|
20
22
|
getProcessArguments: () => require_getProcessArguments.getProcessArguments,
|
|
@@ -34,6 +36,7 @@ Object.defineProperty(exports, "common_exports", {
|
|
|
34
36
|
exports.environmentVariable = require_index.environmentVariable;
|
|
35
37
|
exports.environmentVariableOrThrow = require_environmentVariableOrThrow.environmentVariableOrThrow;
|
|
36
38
|
exports.exitProcess = require_exitProcess.exitProcess;
|
|
39
|
+
exports.getCurrentDirectoryName = require_getCurrentDirectoryName.getCurrentDirectoryName;
|
|
37
40
|
exports.getCurrentWorkDirectory = require_getCurrentWorkDirectory.getCurrentWorkDirectory;
|
|
38
41
|
exports.getCurrentWorkDirectoryOrThrow = require_getCurrentWorkDirectoryOrThrow.getCurrentWorkDirectoryOrThrow;
|
|
39
42
|
exports.getProcessArguments = require_getProcessArguments.getProcessArguments;
|
package/dist/common/index.d.ts
CHANGED
package/dist/common/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { environmentVariable } from "./environmentVariable/index.mjs";
|
|
|
7
7
|
import { EnvironmentVariableError, environmentVariableOrThrow } from "./environmentVariableOrThrow.mjs";
|
|
8
8
|
import { exitProcess } from "./exitProcess.mjs";
|
|
9
9
|
import { getProcessArguments } from "./getProcessArguments.mjs";
|
|
10
|
+
import { getCurrentDirectoryName } from "./meta/getCurrentDirectoryName.mjs";
|
|
10
11
|
//#region scripts/common/index.ts
|
|
11
12
|
var common_exports = /* @__PURE__ */ __exportAll({
|
|
12
13
|
EnvironmentVariableError: () => EnvironmentVariableError,
|
|
@@ -15,6 +16,7 @@ var common_exports = /* @__PURE__ */ __exportAll({
|
|
|
15
16
|
environmentVariable: () => environmentVariable,
|
|
16
17
|
environmentVariableOrThrow: () => environmentVariableOrThrow,
|
|
17
18
|
exitProcess: () => exitProcess,
|
|
19
|
+
getCurrentDirectoryName: () => getCurrentDirectoryName,
|
|
18
20
|
getCurrentWorkDirectory: () => getCurrentWorkDirectory,
|
|
19
21
|
getCurrentWorkDirectoryOrThrow: () => getCurrentWorkDirectoryOrThrow,
|
|
20
22
|
getProcessArguments: () => getProcessArguments,
|
|
@@ -22,4 +24,4 @@ var common_exports = /* @__PURE__ */ __exportAll({
|
|
|
22
24
|
setCurrentWorkingDirectoryOrThrow: () => setCurrentWorkingDirectoryOrThrow
|
|
23
25
|
});
|
|
24
26
|
//#endregion
|
|
25
|
-
export { EnvironmentVariableError, GetCurrentWorkDirectoryError, SetCurrentWorkingDirectoryError, common_exports, environmentVariable, environmentVariableOrThrow, exitProcess, getCurrentWorkDirectory, getCurrentWorkDirectoryOrThrow, getProcessArguments, setCurrentWorkingDirectory, setCurrentWorkingDirectoryOrThrow };
|
|
27
|
+
export { EnvironmentVariableError, GetCurrentWorkDirectoryError, SetCurrentWorkingDirectoryError, common_exports, environmentVariable, environmentVariableOrThrow, exitProcess, getCurrentDirectoryName, getCurrentWorkDirectory, getCurrentWorkDirectoryOrThrow, getProcessArguments, setCurrentWorkingDirectory, setCurrentWorkingDirectoryOrThrow };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
5
|
+
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
6
|
+
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
7
|
+
//#region scripts/common/meta/getCurrentDirectoryName.ts
|
|
8
|
+
const getCurrentDirectoryName = require_implementor.implementFunction("getCurrentDirectoryName", { NODE: (importMeta) => _duplojs_lang_common.pipe(importMeta.dirname, _duplojs_lang_path.createAbsoluteOrThrow) });
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.getCurrentDirectoryName = getCurrentDirectoryName;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as DPath from "@duplojs/lang/path";
|
|
2
|
+
declare module '../../implementor' {
|
|
3
|
+
interface ServerFunction {
|
|
4
|
+
getCurrentDirectoryName(importMeta: ImportMeta): string & DPath.Absolute;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare const getCurrentDirectoryName: (importMeta: ImportMeta) => string & DPath.Absolute;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { implementFunction } from "../../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DPath from "@duplojs/lang/path";
|
|
4
|
+
//#region scripts/common/meta/getCurrentDirectoryName.ts
|
|
5
|
+
const getCurrentDirectoryName = implementFunction("getCurrentDirectoryName", { NODE: (importMeta) => DCommon.pipe(importMeta.dirname, DPath.createAbsoluteOrThrow) });
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getCurrentDirectoryName };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as DKind from "@duplojs/lang/kind";
|
|
2
|
+
declare const importMetaKind: DKind.Handler<DKind.Definition<"@DuplojsServer/import-meta", unknown>>;
|
|
3
|
+
declare global {
|
|
4
|
+
interface ImportMeta extends DKind.Kind<typeof importMetaKind> {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export * from './getCurrentDirectoryName';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const require_runtime = require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_fileInterface = require("../../../../file/fileInterface.cjs");
|
|
3
|
+
const require_folderInterface = require("../../../../file/folderInterface.cjs");
|
|
3
4
|
const require_file = require("../../../fundamentalType/file.cjs");
|
|
5
|
+
const require_folder = require("../../../fundamentalType/folder.cjs");
|
|
4
6
|
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
5
7
|
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
6
8
|
let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
|
|
@@ -8,7 +10,16 @@ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructur
|
|
|
8
10
|
//#region scripts/dataStructure/common/codec/defaults/json.ts
|
|
9
11
|
const codecsJson = _duplojs_lang_dataStructure.createCodecs({
|
|
10
12
|
..._duplojs_lang_dataStructure.codecsJson.definition,
|
|
11
|
-
file: _duplojs_lang_dataStructure.createCodec(require_file.TheFile, (data) => typeof data === "string"
|
|
13
|
+
file: _duplojs_lang_dataStructure.createCodec(require_file.TheFile, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
14
|
+
const result = _duplojs_lang_path.normalize(data);
|
|
15
|
+
if (!result) return _duplojs_lang_dataStructure.ErrorSymbol;
|
|
16
|
+
return require_fileInterface.createFileInterface(result);
|
|
17
|
+
}),
|
|
18
|
+
folder: _duplojs_lang_dataStructure.createCodec(require_folder.TheFolder, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
19
|
+
const result = _duplojs_lang_path.normalize(data);
|
|
20
|
+
if (!result) return _duplojs_lang_dataStructure.ErrorSymbol;
|
|
21
|
+
return require_folderInterface.createFolderInterface(result);
|
|
22
|
+
})
|
|
12
23
|
});
|
|
13
24
|
//#endregion
|
|
14
25
|
exports.codecsJson = codecsJson;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as DPath from "@duplojs/lang/path";
|
|
2
1
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
3
2
|
import * as FundamentalType from "../../../fundamentalType";
|
|
4
3
|
export declare const codecsJson: DDataStructure.Codecs<{
|
|
5
|
-
file: DDataStructure.Codec<FundamentalType.TheFile, string
|
|
4
|
+
file: DDataStructure.Codec<FundamentalType.TheFile, string>;
|
|
5
|
+
folder: DDataStructure.Codec<FundamentalType.TheFolder, string>;
|
|
6
6
|
bigint: import('@duplojs/lang/dataStructure').Codec<DDataStructure.TheBigint, string>;
|
|
7
7
|
date: import('@duplojs/lang/dataStructure').Codec<DDataStructure.TheDate, string>;
|
|
8
8
|
time: import('@duplojs/lang/dataStructure').Codec<DDataStructure.TheTime, string>;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { createFileInterface } from "../../../../file/fileInterface.mjs";
|
|
2
|
+
import { createFolderInterface } from "../../../../file/folderInterface.mjs";
|
|
2
3
|
import { TheFile } from "../../../fundamentalType/file.mjs";
|
|
4
|
+
import { TheFolder } from "../../../fundamentalType/folder.mjs";
|
|
3
5
|
import * as DPath from "@duplojs/lang/path";
|
|
4
6
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
5
7
|
//#region scripts/dataStructure/common/codec/defaults/json.ts
|
|
6
8
|
const codecsJson = DDataStructure.createCodecs({
|
|
7
9
|
...DDataStructure.codecsJson.definition,
|
|
8
|
-
file: DDataStructure.createCodec(TheFile, (data) => typeof data === "string"
|
|
10
|
+
file: DDataStructure.createCodec(TheFile, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
11
|
+
const result = DPath.normalize(data);
|
|
12
|
+
if (!result) return DDataStructure.ErrorSymbol;
|
|
13
|
+
return createFileInterface(result);
|
|
14
|
+
}),
|
|
15
|
+
folder: DDataStructure.createCodec(TheFolder, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
16
|
+
const result = DPath.normalize(data);
|
|
17
|
+
if (!result) return DDataStructure.ErrorSymbol;
|
|
18
|
+
return createFolderInterface(result);
|
|
19
|
+
})
|
|
9
20
|
});
|
|
10
21
|
//#endregion
|
|
11
22
|
export { codecsJson };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const require_runtime = require("../../../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_fileInterface = require("../../../../file/fileInterface.cjs");
|
|
3
|
+
const require_folderInterface = require("../../../../file/folderInterface.cjs");
|
|
3
4
|
const require_file = require("../../../fundamentalType/file.cjs");
|
|
5
|
+
const require_folder = require("../../../fundamentalType/folder.cjs");
|
|
4
6
|
let _duplojs_lang_path = require("@duplojs/lang/path");
|
|
5
7
|
_duplojs_lang_path = require_runtime.__toESM(_duplojs_lang_path, 1);
|
|
6
8
|
let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
|
|
@@ -8,7 +10,16 @@ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructur
|
|
|
8
10
|
//#region scripts/dataStructure/common/codec/defaults/string.ts
|
|
9
11
|
const codecsString = _duplojs_lang_dataStructure.createCodecs({
|
|
10
12
|
..._duplojs_lang_dataStructure.codecsString.definition,
|
|
11
|
-
file: _duplojs_lang_dataStructure.createCodec(require_file.TheFile, (data) => typeof data === "string"
|
|
13
|
+
file: _duplojs_lang_dataStructure.createCodec(require_file.TheFile, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
14
|
+
const result = _duplojs_lang_path.normalize(data);
|
|
15
|
+
if (!result) return _duplojs_lang_dataStructure.ErrorSymbol;
|
|
16
|
+
return require_fileInterface.createFileInterface(result);
|
|
17
|
+
}),
|
|
18
|
+
folder: _duplojs_lang_dataStructure.createCodec(require_folder.TheFolder, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
19
|
+
const result = _duplojs_lang_path.normalize(data);
|
|
20
|
+
if (!result) return _duplojs_lang_dataStructure.ErrorSymbol;
|
|
21
|
+
return require_folderInterface.createFolderInterface(result);
|
|
22
|
+
})
|
|
12
23
|
});
|
|
13
24
|
//#endregion
|
|
14
25
|
exports.codecsString = codecsString;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as DPath from "@duplojs/lang/path";
|
|
2
1
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
3
2
|
import * as FundamentalType from "../../../fundamentalType";
|
|
4
3
|
export declare const codecsString: DDataStructure.Codecs<{
|
|
5
|
-
file: DDataStructure.Codec<FundamentalType.TheFile, string
|
|
4
|
+
file: DDataStructure.Codec<FundamentalType.TheFile, string>;
|
|
5
|
+
folder: DDataStructure.Codec<FundamentalType.TheFolder, string>;
|
|
6
6
|
bigint: import('@duplojs/lang/dataStructure').Codec<DDataStructure.TheBigint, string>;
|
|
7
7
|
boolean: import('@duplojs/lang/dataStructure').Codec<DDataStructure.TheBoolean, "true" | "false">;
|
|
8
8
|
date: import('@duplojs/lang/dataStructure').Codec<DDataStructure.TheDate, string>;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { createFileInterface } from "../../../../file/fileInterface.mjs";
|
|
2
|
+
import { createFolderInterface } from "../../../../file/folderInterface.mjs";
|
|
2
3
|
import { TheFile } from "../../../fundamentalType/file.mjs";
|
|
4
|
+
import { TheFolder } from "../../../fundamentalType/folder.mjs";
|
|
3
5
|
import * as DPath from "@duplojs/lang/path";
|
|
4
6
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
5
7
|
//#region scripts/dataStructure/common/codec/defaults/string.ts
|
|
6
8
|
const codecsString = DDataStructure.createCodecs({
|
|
7
9
|
...DDataStructure.codecsString.definition,
|
|
8
|
-
file: DDataStructure.createCodec(TheFile, (data) => typeof data === "string"
|
|
10
|
+
file: DDataStructure.createCodec(TheFile, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
11
|
+
const result = DPath.normalize(data);
|
|
12
|
+
if (!result) return DDataStructure.ErrorSymbol;
|
|
13
|
+
return createFileInterface(result);
|
|
14
|
+
}),
|
|
15
|
+
folder: DDataStructure.createCodec(TheFolder, (data) => typeof data === "string", (data) => data.path, (data) => {
|
|
16
|
+
const result = DPath.normalize(data);
|
|
17
|
+
if (!result) return DDataStructure.ErrorSymbol;
|
|
18
|
+
return createFolderInterface(result);
|
|
19
|
+
})
|
|
9
20
|
});
|
|
10
21
|
//#endregion
|
|
11
22
|
export { codecsString };
|
|
@@ -6,6 +6,7 @@ _duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructur
|
|
|
6
6
|
const defaultErrorInterpreterDataStructureDictionary = {
|
|
7
7
|
..._duplojs_lang_dataStructure.defaultErrorInterpreterDataStructureDictionary,
|
|
8
8
|
"@DuplojsServerDataStructure/file-type": () => "Expected a valid file.",
|
|
9
|
+
"@DuplojsServerDataStructure/folder-type": () => "Expected a valid folder.",
|
|
9
10
|
"@DuplojsServerDataStructure/size-constraint": (source) => {
|
|
10
11
|
const { min, max } = source.definition;
|
|
11
12
|
if (min !== void 0 && max !== void 0) return `Expected a file size between ${min} and ${max} bytes.`;
|
|
@@ -14,7 +15,8 @@ const defaultErrorInterpreterDataStructureDictionary = {
|
|
|
14
15
|
return "Expected a valid file size.";
|
|
15
16
|
},
|
|
16
17
|
"@DuplojsServerDataStructure/mime-type-constraint": (source) => `Expected a file with a MIME type matching ${source.definition.regex.toString()}.`,
|
|
17
|
-
"@DuplojsServerDataStructure/exist-constraint": () => "Expected the file to exist."
|
|
18
|
+
"@DuplojsServerDataStructure/file-exist-constraint": () => "Expected the file to exist.",
|
|
19
|
+
"@DuplojsServerDataStructure/folder-exist-constraint": () => "Expected the folder to exist."
|
|
18
20
|
};
|
|
19
21
|
const defaultErrorInterpreterCodecDictionary = [..._duplojs_lang_dataStructure.defaultErrorInterpreterCodecDictionary, [require_json.codecsJson.definition.file, (_codec, issue) => {
|
|
20
22
|
if (issue.from === "predicate") return _duplojs_lang_dataStructure.encodeIssueKind.has(issue) ? "The JSON file codec must produce a valid file path string." : "Expected a valid file path string for the JSON file codec.";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
2
2
|
export declare const defaultErrorInterpreterDataStructureDictionary: {
|
|
3
3
|
readonly "@DuplojsServerDataStructure/file-type": () => string;
|
|
4
|
+
readonly "@DuplojsServerDataStructure/folder-type": () => string;
|
|
4
5
|
readonly "@DuplojsServerDataStructure/size-constraint": (source: import('../..').SizeConstraint) => string;
|
|
5
6
|
readonly "@DuplojsServerDataStructure/mime-type-constraint": (source: import('../..').MimeTypeConstraint) => string;
|
|
6
|
-
readonly "@DuplojsServerDataStructure/exist-constraint": () => string;
|
|
7
|
+
readonly "@DuplojsServerDataStructure/file-exist-constraint": () => string;
|
|
8
|
+
readonly "@DuplojsServerDataStructure/folder-exist-constraint": () => string;
|
|
7
9
|
readonly "@DuplojsLangDataStructure/array-structure": () => string;
|
|
8
10
|
readonly "@DuplojsLangDataStructure/lazy-structure": () => string;
|
|
9
11
|
readonly "@DuplojsLangDataStructure/non-encodable-string-structure": (source: import('@duplojs/lang/dataStructure').NonEncodableStringStructure) => string;
|
|
@@ -29,9 +31,11 @@ export declare const defaultErrorInterpreterDataStructureDictionary: {
|
|
|
29
31
|
readonly "@DuplojsLangDataStructure/between-than-constraint": (source: import('@duplojs/lang/dataStructure').BetweenThanConstraint<number, number>) => string;
|
|
30
32
|
readonly "@DuplojsLangDataStructure/between-than-or-equal-constraint": (source: import('@duplojs/lang/dataStructure').BetweenThanOrEqualConstraint<number, number>) => string;
|
|
31
33
|
readonly "@DuplojsLangDataStructure/email-constraint": () => string;
|
|
34
|
+
readonly "@DuplojsLangDataStructure/ends-with-constraint": (source: import('@duplojs/lang/dataStructure').EndsWithConstraint<string>) => string;
|
|
32
35
|
readonly "@DuplojsLangDataStructure/even-constraint": () => string;
|
|
33
36
|
readonly "@DuplojsLangDataStructure/greater-than-constraint": (source: import('@duplojs/lang/dataStructure').GreaterThanConstraint<number>) => string;
|
|
34
37
|
readonly "@DuplojsLangDataStructure/greater-than-or-equal-constraint": (source: import('@duplojs/lang/dataStructure').GreaterThanOrEqualConstraint<number>) => string;
|
|
38
|
+
readonly "@DuplojsLangDataStructure/include-constraint": (source: import('@duplojs/lang/dataStructure').IncludeConstraint<string>) => string;
|
|
35
39
|
readonly "@DuplojsLangDataStructure/integer-constraint": () => string;
|
|
36
40
|
readonly "@DuplojsLangDataStructure/less-than-constraint": (source: import('@duplojs/lang/dataStructure').LessThanConstraint<number>) => string;
|
|
37
41
|
readonly "@DuplojsLangDataStructure/less-than-or-equal-constraint": (source: import('@duplojs/lang/dataStructure').LessThanOrEqualConstraint<number>) => string;
|
|
@@ -51,6 +55,7 @@ export declare const defaultErrorInterpreterDataStructureDictionary: {
|
|
|
51
55
|
readonly "@DuplojsLangDataStructure/regex-constraint": (source: import('@duplojs/lang/dataStructure').RegexConstraint) => string;
|
|
52
56
|
readonly "@DuplojsLangDataStructure/safe-constraint": () => string;
|
|
53
57
|
readonly "@DuplojsLangDataStructure/segment-path-constraint": () => string;
|
|
58
|
+
readonly "@DuplojsLangDataStructure/starts-with-constraint": (source: import('@duplojs/lang/dataStructure').StartsWithConstraint<string>) => string;
|
|
54
59
|
readonly "@DuplojsLangDataStructure/strict-negative-constraint": () => string;
|
|
55
60
|
readonly "@DuplojsLangDataStructure/strict-positive-constraint": () => string;
|
|
56
61
|
readonly "@DuplojsLangDataStructure/string-length-equal-constraint": (source: import('@duplojs/lang/dataStructure').StringLengthEqualConstraint<number>) => string;
|
|
@@ -61,4 +66,4 @@ export declare const defaultErrorInterpreterDataStructureDictionary: {
|
|
|
61
66
|
readonly "@DuplojsLangModeling/new-type-structure": () => string;
|
|
62
67
|
readonly "@DuplojsLangModeling/tagged-object-structure": (source: import('@duplojs/lang/modeling').TaggedObjectStructure<import('@duplojs/lang/modeling').ObjectTag<string>>) => string;
|
|
63
68
|
};
|
|
64
|
-
export declare const defaultErrorInterpreterCodecDictionary: [[DDataStructure.Codec<DDataStructure.TheBigint, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheDate, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheTime, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheBigint, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheBoolean, "true" | "false">, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheDate, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheNull, "null">, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheNumber, string & import('@duplojs/lang/string').Number>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheTime, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheUndefined, "undefined" | undefined>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<import('../..').TheFile, string
|
|
69
|
+
export declare const defaultErrorInterpreterCodecDictionary: [[DDataStructure.Codec<DDataStructure.TheBigint, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheDate, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheTime, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheBigint, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheBoolean, "true" | "false">, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheDate, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheNull, "null">, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheNumber, string & import('@duplojs/lang/string').Number>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheTime, string>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<DDataStructure.TheUndefined, "undefined" | undefined>, (codec: import('@duplojs/lang/dataStructure').Codec, issue: import('@duplojs/lang/dataStructure').EncodeIssue | import('@duplojs/lang/dataStructure').DecodeIssue) => string], [DDataStructure.Codec<import('../..').TheFile, string>, (_codec: DDataStructure.Codec<DDataStructure.FundamentalType<unknown>, unknown>, issue: DDataStructure.EncodeIssue | DDataStructure.DecodeIssue) => string]];
|
|
@@ -4,6 +4,7 @@ import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
|
4
4
|
const defaultErrorInterpreterDataStructureDictionary = {
|
|
5
5
|
...DDataStructure.defaultErrorInterpreterDataStructureDictionary,
|
|
6
6
|
"@DuplojsServerDataStructure/file-type": () => "Expected a valid file.",
|
|
7
|
+
"@DuplojsServerDataStructure/folder-type": () => "Expected a valid folder.",
|
|
7
8
|
"@DuplojsServerDataStructure/size-constraint": (source) => {
|
|
8
9
|
const { min, max } = source.definition;
|
|
9
10
|
if (min !== void 0 && max !== void 0) return `Expected a file size between ${min} and ${max} bytes.`;
|
|
@@ -12,7 +13,8 @@ const defaultErrorInterpreterDataStructureDictionary = {
|
|
|
12
13
|
return "Expected a valid file size.";
|
|
13
14
|
},
|
|
14
15
|
"@DuplojsServerDataStructure/mime-type-constraint": (source) => `Expected a file with a MIME type matching ${source.definition.regex.toString()}.`,
|
|
15
|
-
"@DuplojsServerDataStructure/exist-constraint": () => "Expected the file to exist."
|
|
16
|
+
"@DuplojsServerDataStructure/file-exist-constraint": () => "Expected the file to exist.",
|
|
17
|
+
"@DuplojsServerDataStructure/folder-exist-constraint": () => "Expected the folder to exist."
|
|
16
18
|
};
|
|
17
19
|
const defaultErrorInterpreterCodecDictionary = [...DDataStructure.defaultErrorInterpreterCodecDictionary, [codecsJson.definition.file, (_codec, issue) => {
|
|
18
20
|
if (issue.from === "predicate") return DDataStructure.encodeIssueKind.has(issue) ? "The JSON file codec must produce a valid file path string." : "Expected a valid file path string for the JSON file codec.";
|
|
@@ -4,9 +4,9 @@ let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
|
4
4
|
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
5
5
|
let _duplojs_lang_dataStructure = require("@duplojs/lang/dataStructure");
|
|
6
6
|
_duplojs_lang_dataStructure = require_runtime.__toESM(_duplojs_lang_dataStructure, 1);
|
|
7
|
-
//#region scripts/dataStructure/constraint/
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
//#region scripts/dataStructure/constraint/fileExist.ts
|
|
8
|
+
const fileExistConstraintKind = require_kind.createKind("file-exist-constraint");
|
|
9
|
+
const FileExistConstraint = _duplojs_lang_dataStructure.createConstraint(fileExistConstraintKind, ({ init }) => () => init({}, {
|
|
10
10
|
executeCheck: async (_self, data) => {
|
|
11
11
|
const result = _duplojs_lang_either.rightPipe(await data.stat(), (stat) => stat.isFile ? stat : _duplojs_lang_either.fail());
|
|
12
12
|
if (_duplojs_lang_either.isLeft(result)) return _duplojs_lang_dataStructure.ErrorSymbol;
|
|
@@ -15,5 +15,5 @@ const ExistConstraint = _duplojs_lang_dataStructure.createConstraint(existConstr
|
|
|
15
15
|
isAsynchronous: () => true
|
|
16
16
|
}));
|
|
17
17
|
//#endregion
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
18
|
+
exports.FileExistConstraint = FileExistConstraint;
|
|
19
|
+
exports.fileExistConstraintKind = fileExistConstraintKind;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export declare const fileExistConstraintKind: DKind.Handler<DKind.Definition<"@DuplojsServerDataStructure/file-exist-constraint", unknown>>;
|
|
6
|
+
export interface FileExistConstraintDefinition extends DDataStructure.ConstraintDefinition {
|
|
7
|
+
}
|
|
8
|
+
export interface FileExistConstraint extends DCommon.UnionToIntersection<DDataStructure.Constraint<DSFile.FileInterface, DSFile.FileInterface, FileExistConstraintDefinition> & DKind.Kind<typeof fileExistConstraintKind>> {
|
|
9
|
+
}
|
|
10
|
+
export declare const FileExistConstraint: () => FileExistConstraint;
|