typia 7.6.0-dev.20241229 → 7.7.0-dev.20250130
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/lib/TypeGuardError.mjs +26 -0
- package/lib/TypeGuardError.mjs.map +1 -0
- package/lib/executable/setup/PluginConfigurator.js +3 -3
- package/lib/executable/typia.js +15 -15
- package/lib/functional.mjs +120 -0
- package/lib/functional.mjs.map +1 -0
- package/lib/http.d.ts +15 -15
- package/lib/http.mjs +165 -0
- package/lib/http.mjs.map +1 -0
- package/lib/index.mjs +27 -1142
- package/lib/index.mjs.map +1 -1
- package/lib/json.mjs +105 -0
- package/lib/json.mjs.map +1 -0
- package/lib/llm.mjs +33 -0
- package/lib/llm.mjs.map +1 -0
- package/lib/misc.mjs +111 -0
- package/lib/misc.mjs.map +1 -0
- package/lib/module.d.ts +4 -4
- package/lib/module.mjs +139 -0
- package/lib/module.mjs.map +1 -0
- package/lib/notations.mjs +153 -0
- package/lib/notations.mjs.map +1 -0
- package/lib/programmers/json/JsonApplicationProgrammer.d.ts +12 -0
- package/lib/programmers/json/JsonApplicationProgrammer.js +22 -22
- package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js +15 -7
- package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js +39 -15
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/protobuf.d.ts +9 -9
- package/lib/protobuf.mjs +111 -0
- package/lib/protobuf.mjs.map +1 -0
- package/lib/reflect.mjs +18 -0
- package/lib/reflect.mjs.map +1 -0
- package/lib/schemas/llm/ILlmApplicationOfValidate.mjs +6 -0
- package/lib/schemas/llm/ILlmApplicationOfValidate.mjs.map +1 -0
- package/lib/schemas/llm/ILlmFunctionOfValidate.mjs +6 -0
- package/lib/schemas/llm/ILlmFunctionOfValidate.mjs.map +1 -0
- package/lib/tags/TagBase.d.ts +1 -1
- package/lib/tags/Type.d.ts +0 -1
- package/lib/tags/index.mjs +2 -0
- package/lib/tags/index.mjs.map +1 -0
- package/package.json +10 -8
- package/src/AssertionGuard.ts +1 -1
- package/src/CamelCase.ts +75 -75
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +92 -92
- package/src/Resolved.ts +74 -74
- package/src/SnakeCase.ts +126 -126
- package/src/TypeGuardError.ts +37 -37
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/PluginConfigurator.ts +69 -69
- package/src/executable/typia.ts +55 -55
- package/src/factories/CommentFactory.ts +79 -79
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/metadata/emend_metadata_atomics.ts +45 -45
- package/src/http.ts +15 -15
- package/src/index.ts +4 -4
- package/src/module.ts +4 -4
- package/src/programmers/helpers/ICheckEntry.ts +13 -13
- package/src/programmers/helpers/IExpressionEntry.ts +12 -12
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/stringify_native.ts +7 -7
- package/src/programmers/json/JsonApplicationProgrammer.ts +27 -27
- package/src/programmers/llm/LlmApplicationOfValidateProgrammer.ts +16 -2
- package/src/programmers/llm/LlmApplicationProgrammer.ts +50 -12
- package/src/protobuf.ts +9 -9
- package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
- package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
- package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
- package/src/schemas/metadata/IMetadataConstant.ts +18 -18
- package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
- package/src/schemas/metadata/IMetadataFunction.ts +8 -8
- package/src/schemas/metadata/IMetadataParameter.ts +9 -9
- package/src/schemas/metadata/IMetadataProperty.ts +9 -9
- package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
- package/src/schemas/metadata/MetadataArrayType.ts +57 -57
- package/src/schemas/metadata/MetadataConstant.ts +34 -34
- package/src/schemas/metadata/MetadataEscaped.ts +51 -51
- package/src/schemas/metadata/MetadataFunction.ts +49 -49
- package/src/schemas/metadata/MetadataTupleType.ts +67 -67
- package/src/tags/Constant.ts +15 -15
- package/src/tags/ContentMediaType.ts +10 -10
- package/src/tags/Default.ts +22 -22
- package/src/tags/ExclusiveMaximum.ts +25 -25
- package/src/tags/ExclusiveMinimum.ts +25 -25
- package/src/tags/MaxItems.ts +12 -12
- package/src/tags/MaxLength.ts +12 -12
- package/src/tags/Maximum.ts +19 -19
- package/src/tags/MinItems.ts +12 -12
- package/src/tags/MinLength.ts +12 -12
- package/src/tags/Minimum.ts +19 -19
- package/src/tags/MultipleOf.ts +21 -21
- package/src/tags/Pattern.ts +31 -31
- package/src/tags/TagBase.ts +1 -1
- package/src/tags/Type.ts +0 -1
- package/src/tags/internal/FormatCheatSheet.ts +73 -73
- package/src/typings/Atomic.ts +13 -13
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/Customizable.ts +5 -5
- package/src/typings/Equal.ts +18 -18
- package/src/typings/IsTuple.ts +9 -9
- package/src/typings/NativeClass.ts +23 -23
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/ProtobufAtomic.ts +19 -19
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/ValidationPipe.ts +9 -9
- package/src/typings/ValueOf.ts +20 -20
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +41 -41
- package/src/utils/Escaper.ts +50 -50
- package/src/utils/PatternUtil.ts +29 -29
- package/src/utils/Singleton.ts +16 -16
package/src/tags/MinLength.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TagBase } from "./TagBase";
|
|
2
|
-
|
|
3
|
-
export type MinLength<Value extends number> = TagBase<{
|
|
4
|
-
target: "string";
|
|
5
|
-
kind: "minLength";
|
|
6
|
-
value: Value;
|
|
7
|
-
validate: `${Value} <= $input.length`;
|
|
8
|
-
exclusive: true;
|
|
9
|
-
schema: {
|
|
10
|
-
minLength: Value;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
export type MinLength<Value extends number> = TagBase<{
|
|
4
|
+
target: "string";
|
|
5
|
+
kind: "minLength";
|
|
6
|
+
value: Value;
|
|
7
|
+
validate: `${Value} <= $input.length`;
|
|
8
|
+
exclusive: true;
|
|
9
|
+
schema: {
|
|
10
|
+
minLength: Value;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
package/src/tags/Minimum.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { TagBase } from "./TagBase";
|
|
2
|
-
|
|
3
|
-
export type Minimum<Value extends number | bigint> = TagBase<{
|
|
4
|
-
target: Value extends bigint ? "bigint" : "number";
|
|
5
|
-
kind: "minimum";
|
|
6
|
-
value: Value;
|
|
7
|
-
validate: `${Cast<Value>} <= $input`;
|
|
8
|
-
exclusive: ["minimum", "exclusiveMinimum"];
|
|
9
|
-
schema: Value extends bigint
|
|
10
|
-
? { minimum: Numeric<Value> }
|
|
11
|
-
: { minimum: Value };
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
type Cast<Value extends number | bigint> = Value extends number
|
|
15
|
-
? Value
|
|
16
|
-
: `BigInt(${Value})`;
|
|
17
|
-
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
18
|
-
? N
|
|
19
|
-
: never;
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
export type Minimum<Value extends number | bigint> = TagBase<{
|
|
4
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
5
|
+
kind: "minimum";
|
|
6
|
+
value: Value;
|
|
7
|
+
validate: `${Cast<Value>} <= $input`;
|
|
8
|
+
exclusive: ["minimum", "exclusiveMinimum"];
|
|
9
|
+
schema: Value extends bigint
|
|
10
|
+
? { minimum: Numeric<Value> }
|
|
11
|
+
: { minimum: Value };
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
type Cast<Value extends number | bigint> = Value extends number
|
|
15
|
+
? Value
|
|
16
|
+
: `BigInt(${Value})`;
|
|
17
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
18
|
+
? N
|
|
19
|
+
: never;
|
package/src/tags/MultipleOf.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { TagBase } from "./TagBase";
|
|
2
|
-
|
|
3
|
-
export type MultipleOf<Value extends number | bigint> = TagBase<{
|
|
4
|
-
target: Value extends bigint ? "bigint" : "number";
|
|
5
|
-
kind: "multipleOf";
|
|
6
|
-
value: Value;
|
|
7
|
-
validate: `$input % ${Cast<Value>} === ${Value extends bigint
|
|
8
|
-
? Cast<0n>
|
|
9
|
-
: 0}`;
|
|
10
|
-
exclusive: true;
|
|
11
|
-
schema: Value extends bigint
|
|
12
|
-
? { multipleOf: Numeric<Value> }
|
|
13
|
-
: { multipleOf: Value };
|
|
14
|
-
}>;
|
|
15
|
-
|
|
16
|
-
type Cast<Value extends number | bigint> = Value extends number
|
|
17
|
-
? Value
|
|
18
|
-
: `BigInt(${Value})`;
|
|
19
|
-
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
20
|
-
? N
|
|
21
|
-
: never;
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
export type MultipleOf<Value extends number | bigint> = TagBase<{
|
|
4
|
+
target: Value extends bigint ? "bigint" : "number";
|
|
5
|
+
kind: "multipleOf";
|
|
6
|
+
value: Value;
|
|
7
|
+
validate: `$input % ${Cast<Value>} === ${Value extends bigint
|
|
8
|
+
? Cast<0n>
|
|
9
|
+
: 0}`;
|
|
10
|
+
exclusive: true;
|
|
11
|
+
schema: Value extends bigint
|
|
12
|
+
? { multipleOf: Numeric<Value> }
|
|
13
|
+
: { multipleOf: Value };
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
type Cast<Value extends number | bigint> = Value extends number
|
|
17
|
+
? Value
|
|
18
|
+
: `BigInt(${Value})`;
|
|
19
|
+
type Numeric<T extends bigint> = `${T}` extends `${infer N extends number}`
|
|
20
|
+
? N
|
|
21
|
+
: never;
|
package/src/tags/Pattern.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { TagBase } from "./TagBase";
|
|
2
|
-
|
|
3
|
-
export type Pattern<Value extends string> = TagBase<{
|
|
4
|
-
target: "string";
|
|
5
|
-
kind: "pattern";
|
|
6
|
-
value: Value;
|
|
7
|
-
validate: `RegExp("${Serialize<Value>}").test($input)`;
|
|
8
|
-
exclusive: ["format", "pattern"];
|
|
9
|
-
schema: {
|
|
10
|
-
pattern: Value;
|
|
11
|
-
};
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
/// reference: https://github.com/type-challenges/type-challenges/issues/22394#issuecomment-1397158205
|
|
15
|
-
type Serialize<T extends string, Output extends string = ""> = string extends T
|
|
16
|
-
? never
|
|
17
|
-
: T extends ""
|
|
18
|
-
? Output
|
|
19
|
-
: T extends `${infer P}${infer R}`
|
|
20
|
-
? Serialize<R, `${Output}${P extends keyof Escaper ? Escaper[P] : P}`>
|
|
21
|
-
: never;
|
|
22
|
-
|
|
23
|
-
type Escaper = {
|
|
24
|
-
'"': '\\"';
|
|
25
|
-
"\\": "\\\\";
|
|
26
|
-
"\b": "\\b";
|
|
27
|
-
"\f": "\\f";
|
|
28
|
-
"\n": "\\n";
|
|
29
|
-
"\r": "\\r";
|
|
30
|
-
"\t": "\\t";
|
|
31
|
-
};
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
export type Pattern<Value extends string> = TagBase<{
|
|
4
|
+
target: "string";
|
|
5
|
+
kind: "pattern";
|
|
6
|
+
value: Value;
|
|
7
|
+
validate: `RegExp("${Serialize<Value>}").test($input)`;
|
|
8
|
+
exclusive: ["format", "pattern"];
|
|
9
|
+
schema: {
|
|
10
|
+
pattern: Value;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
/// reference: https://github.com/type-challenges/type-challenges/issues/22394#issuecomment-1397158205
|
|
15
|
+
type Serialize<T extends string, Output extends string = ""> = string extends T
|
|
16
|
+
? never
|
|
17
|
+
: T extends ""
|
|
18
|
+
? Output
|
|
19
|
+
: T extends `${infer P}${infer R}`
|
|
20
|
+
? Serialize<R, `${Output}${P extends keyof Escaper ? Escaper[P] : P}`>
|
|
21
|
+
: never;
|
|
22
|
+
|
|
23
|
+
type Escaper = {
|
|
24
|
+
'"': '\\"';
|
|
25
|
+
"\\": "\\\\";
|
|
26
|
+
"\b": "\\b";
|
|
27
|
+
"\f": "\\f";
|
|
28
|
+
"\n": "\\n";
|
|
29
|
+
"\r": "\\r";
|
|
30
|
+
"\t": "\\t";
|
|
31
|
+
};
|
package/src/tags/TagBase.ts
CHANGED
|
@@ -57,7 +57,7 @@ export namespace TagBase {
|
|
|
57
57
|
* `$input` would be transformed to the suitable when compilation.
|
|
58
58
|
*
|
|
59
59
|
* Also, If you've take a mistake on this script, compile error would be
|
|
60
|
-
*
|
|
60
|
+
* occurred. So, define it with confidence. Compiler will block all your
|
|
61
61
|
* mistakes.
|
|
62
62
|
*/
|
|
63
63
|
validate?: Validate;
|
package/src/tags/Type.ts
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
const RegexCall = <Text extends string>(text: Text) =>
|
|
2
|
-
`${text}.test($input)` as const;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @reference https://github.dev/ajv-validator/ajv-formats/blob/master/src/formats.ts
|
|
6
|
-
*/
|
|
7
|
-
export const FormatCheatSheet = {
|
|
8
|
-
// SPECIAL CHARACTERS
|
|
9
|
-
byte: RegexCall(
|
|
10
|
-
`/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm`,
|
|
11
|
-
),
|
|
12
|
-
password: `true`,
|
|
13
|
-
regex: `(() => { try { new RegExp($input); return true; } catch { return false; } })()`,
|
|
14
|
-
uuid: RegexCall(
|
|
15
|
-
`/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i`,
|
|
16
|
-
),
|
|
17
|
-
|
|
18
|
-
// ADDRESSES
|
|
19
|
-
email: RegexCall(
|
|
20
|
-
`/^[a-z0-9!#$%&'*+/=?^_\`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i`,
|
|
21
|
-
),
|
|
22
|
-
hostname: RegexCall(
|
|
23
|
-
`/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i`,
|
|
24
|
-
),
|
|
25
|
-
"idn-email": RegexCall(
|
|
26
|
-
`/^(([^<>()[\\]\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@(([^<>()[\\]\\.,;:\\s@\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\"]{2,})$/i`,
|
|
27
|
-
),
|
|
28
|
-
"idn-hostname": RegexCall(
|
|
29
|
-
`/^([a-z0-9\\u00a1-\\uffff0-9]+(-[a-z0-9\\u00a1-\\uffff0-9]+)*\\.)+[a-z\\u00a1-\\uffff]{2,}$/i`,
|
|
30
|
-
),
|
|
31
|
-
iri: RegexCall(
|
|
32
|
-
`/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
|
|
33
|
-
),
|
|
34
|
-
"iri-reference": RegexCall(
|
|
35
|
-
`/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
|
|
36
|
-
),
|
|
37
|
-
ipv4: RegexCall(
|
|
38
|
-
`/^(?:(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[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\\?(?:[a-z0-9\\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i`,
|
|
48
|
-
),
|
|
49
|
-
"uri-template": RegexCall(
|
|
50
|
-
`/^(?:(?:[^\\x00-\\x20"'<>%\\\\^\`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i`,
|
|
51
|
-
),
|
|
52
|
-
url: RegexCall(
|
|
53
|
-
`/^(?:https?|ftp):\\/\\/(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)(?:\\.(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu`,
|
|
54
|
-
),
|
|
55
|
-
|
|
56
|
-
// TIMESTAMPS
|
|
57
|
-
"date-time": RegexCall(
|
|
58
|
-
`/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
|
|
59
|
-
),
|
|
60
|
-
date: RegexCall(`/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/`),
|
|
61
|
-
time: RegexCall(
|
|
62
|
-
`/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
|
|
63
|
-
),
|
|
64
|
-
duration: RegexCall(
|
|
65
|
-
`/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/`,
|
|
66
|
-
),
|
|
67
|
-
|
|
68
|
-
// POINTERS
|
|
69
|
-
"json-pointer": RegexCall(`/^(?:\\/(?:[^~/]|~0|~1)*)*$/`),
|
|
70
|
-
"relative-json-pointer": RegexCall(
|
|
71
|
-
`/^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/`,
|
|
72
|
-
),
|
|
73
|
-
} as const;
|
|
1
|
+
const RegexCall = <Text extends string>(text: Text) =>
|
|
2
|
+
`${text}.test($input)` as const;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @reference https://github.dev/ajv-validator/ajv-formats/blob/master/src/formats.ts
|
|
6
|
+
*/
|
|
7
|
+
export const FormatCheatSheet = {
|
|
8
|
+
// SPECIAL CHARACTERS
|
|
9
|
+
byte: RegexCall(
|
|
10
|
+
`/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm`,
|
|
11
|
+
),
|
|
12
|
+
password: `true`,
|
|
13
|
+
regex: `(() => { try { new RegExp($input); return true; } catch { return false; } })()`,
|
|
14
|
+
uuid: RegexCall(
|
|
15
|
+
`/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i`,
|
|
16
|
+
),
|
|
17
|
+
|
|
18
|
+
// ADDRESSES
|
|
19
|
+
email: RegexCall(
|
|
20
|
+
`/^[a-z0-9!#$%&'*+/=?^_\`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i`,
|
|
21
|
+
),
|
|
22
|
+
hostname: RegexCall(
|
|
23
|
+
`/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i`,
|
|
24
|
+
),
|
|
25
|
+
"idn-email": RegexCall(
|
|
26
|
+
`/^(([^<>()[\\]\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@(([^<>()[\\]\\.,;:\\s@\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\"]{2,})$/i`,
|
|
27
|
+
),
|
|
28
|
+
"idn-hostname": RegexCall(
|
|
29
|
+
`/^([a-z0-9\\u00a1-\\uffff0-9]+(-[a-z0-9\\u00a1-\\uffff0-9]+)*\\.)+[a-z\\u00a1-\\uffff]{2,}$/i`,
|
|
30
|
+
),
|
|
31
|
+
iri: RegexCall(
|
|
32
|
+
`/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
|
|
33
|
+
),
|
|
34
|
+
"iri-reference": RegexCall(
|
|
35
|
+
`/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020"<>\\\\^\`{|}]*$/u`,
|
|
36
|
+
),
|
|
37
|
+
ipv4: RegexCall(
|
|
38
|
+
`/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/`,
|
|
39
|
+
),
|
|
40
|
+
ipv6: RegexCall(
|
|
41
|
+
`/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\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~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\\?(?:[a-z0-9\\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i`,
|
|
48
|
+
),
|
|
49
|
+
"uri-template": RegexCall(
|
|
50
|
+
`/^(?:(?:[^\\x00-\\x20"'<>%\\\\^\`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i`,
|
|
51
|
+
),
|
|
52
|
+
url: RegexCall(
|
|
53
|
+
`/^(?:https?|ftp):\\/\\/(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)(?:\\.(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu`,
|
|
54
|
+
),
|
|
55
|
+
|
|
56
|
+
// TIMESTAMPS
|
|
57
|
+
"date-time": RegexCall(
|
|
58
|
+
`/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
|
|
59
|
+
),
|
|
60
|
+
date: RegexCall(`/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/`),
|
|
61
|
+
time: RegexCall(
|
|
62
|
+
`/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i`,
|
|
63
|
+
),
|
|
64
|
+
duration: RegexCall(
|
|
65
|
+
`/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/`,
|
|
66
|
+
),
|
|
67
|
+
|
|
68
|
+
// POINTERS
|
|
69
|
+
"json-pointer": RegexCall(`/^(?:\\/(?:[^~/]|~0|~1)*)*$/`),
|
|
70
|
+
"relative-json-pointer": RegexCall(
|
|
71
|
+
`/^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/`,
|
|
72
|
+
),
|
|
73
|
+
} as const;
|
package/src/typings/Atomic.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export namespace Atomic {
|
|
2
|
-
export type Type = boolean | number | string | bigint;
|
|
3
|
-
|
|
4
|
-
export type Literal = "boolean" | "integer" | "number" | "string" | "bigint";
|
|
5
|
-
|
|
6
|
-
export type Mapper = {
|
|
7
|
-
boolean: boolean;
|
|
8
|
-
integer: number;
|
|
9
|
-
number: number;
|
|
10
|
-
string: string;
|
|
11
|
-
bigint: bigint;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
1
|
+
export namespace Atomic {
|
|
2
|
+
export type Type = boolean | number | string | bigint;
|
|
3
|
+
|
|
4
|
+
export type Literal = "boolean" | "integer" | "number" | "string" | "bigint";
|
|
5
|
+
|
|
6
|
+
export type Mapper = {
|
|
7
|
+
boolean: boolean;
|
|
8
|
+
integer: number;
|
|
9
|
+
number: number;
|
|
10
|
+
string: string;
|
|
11
|
+
bigint: bigint;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OmitNever } from "./OmitNever";
|
|
2
|
-
|
|
3
|
-
export type ClassProperties<T extends object> = OmitNever<{
|
|
4
|
-
[K in keyof T]: T[K] extends Function ? never : T[K];
|
|
5
|
-
}>;
|
|
1
|
+
import { OmitNever } from "./OmitNever";
|
|
2
|
+
|
|
3
|
+
export type ClassProperties<T extends object> = OmitNever<{
|
|
4
|
+
[K in keyof T]: T[K] extends Function ? never : T[K];
|
|
5
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type Customizable = {
|
|
2
|
-
number: number;
|
|
3
|
-
string: string;
|
|
4
|
-
bigint: bigint;
|
|
5
|
-
};
|
|
1
|
+
export type Customizable = {
|
|
2
|
+
number: number;
|
|
3
|
+
string: string;
|
|
4
|
+
bigint: bigint;
|
|
5
|
+
};
|
package/src/typings/Equal.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compare the equivalence of the two types X and Y.
|
|
3
|
-
*
|
|
4
|
-
* The two types X and Y refer to any type that can be expressed in the type script, such as the union type and the object type.
|
|
5
|
-
*
|
|
6
|
-
* @template X One of the types to compare
|
|
7
|
-
* @template Y One of the types to compare
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* type Answer = Equal<1 | 2, 1 | 2>; // true
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
14
|
-
*/
|
|
15
|
-
export type Equal<X, Y> =
|
|
16
|
-
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
|
17
|
-
? true
|
|
18
|
-
: false;
|
|
1
|
+
/**
|
|
2
|
+
* Compare the equivalence of the two types X and Y.
|
|
3
|
+
*
|
|
4
|
+
* The two types X and Y refer to any type that can be expressed in the type script, such as the union type and the object type.
|
|
5
|
+
*
|
|
6
|
+
* @template X One of the types to compare
|
|
7
|
+
* @template Y One of the types to compare
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* type Answer = Equal<1 | 2, 1 | 2>; // true
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @author Kyungsu Kang - https://github.com/kakasoo
|
|
14
|
+
*/
|
|
15
|
+
export type Equal<X, Y> =
|
|
16
|
+
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
|
|
17
|
+
? true
|
|
18
|
+
: false;
|
package/src/typings/IsTuple.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type IsTuple<T extends readonly any[] | { length: number }> = [
|
|
2
|
-
T,
|
|
3
|
-
] extends [never]
|
|
4
|
-
? false
|
|
5
|
-
: T extends readonly any[]
|
|
6
|
-
? number extends T["length"]
|
|
7
|
-
? false
|
|
8
|
-
: true
|
|
9
|
-
: false;
|
|
1
|
+
export type IsTuple<T extends readonly any[] | { length: number }> = [
|
|
2
|
+
T,
|
|
3
|
+
] extends [never]
|
|
4
|
+
? false
|
|
5
|
+
: T extends readonly any[]
|
|
6
|
+
? number extends T["length"]
|
|
7
|
+
? false
|
|
8
|
+
: true
|
|
9
|
+
: false;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export type NativeClass =
|
|
2
|
-
| Date
|
|
3
|
-
| Set<any>
|
|
4
|
-
| Map<any, any>
|
|
5
|
-
| WeakSet<any>
|
|
6
|
-
| WeakMap<any, any>
|
|
7
|
-
| Uint8Array
|
|
8
|
-
| Uint8ClampedArray
|
|
9
|
-
| Uint16Array
|
|
10
|
-
| Uint32Array
|
|
11
|
-
| BigUint64Array
|
|
12
|
-
| Int8Array
|
|
13
|
-
| Int16Array
|
|
14
|
-
| Int32Array
|
|
15
|
-
| BigInt64Array
|
|
16
|
-
| Float32Array
|
|
17
|
-
| Float64Array
|
|
18
|
-
| ArrayBuffer
|
|
19
|
-
| SharedArrayBuffer
|
|
20
|
-
| DataView
|
|
21
|
-
| Blob
|
|
22
|
-
| File
|
|
23
|
-
| RegExp;
|
|
1
|
+
export type NativeClass =
|
|
2
|
+
| Date
|
|
3
|
+
| Set<any>
|
|
4
|
+
| Map<any, any>
|
|
5
|
+
| WeakSet<any>
|
|
6
|
+
| WeakMap<any, any>
|
|
7
|
+
| Uint8Array
|
|
8
|
+
| Uint8ClampedArray
|
|
9
|
+
| Uint16Array
|
|
10
|
+
| Uint32Array
|
|
11
|
+
| BigUint64Array
|
|
12
|
+
| Int8Array
|
|
13
|
+
| Int16Array
|
|
14
|
+
| Int32Array
|
|
15
|
+
| BigInt64Array
|
|
16
|
+
| Float32Array
|
|
17
|
+
| Float64Array
|
|
18
|
+
| ArrayBuffer
|
|
19
|
+
| SharedArrayBuffer
|
|
20
|
+
| DataView
|
|
21
|
+
| Blob
|
|
22
|
+
| File
|
|
23
|
+
| RegExp;
|
package/src/typings/OmitNever.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SpecialFields } from "./SpecialFields";
|
|
2
|
-
|
|
3
|
-
export type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;
|
|
1
|
+
import { SpecialFields } from "./SpecialFields";
|
|
2
|
+
|
|
3
|
+
export type OmitNever<T extends object> = Omit<T, SpecialFields<T, never>>;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export type ProtobufAtomic =
|
|
2
|
-
| "bool"
|
|
3
|
-
| "int32"
|
|
4
|
-
| "uint32"
|
|
5
|
-
| "int64"
|
|
6
|
-
| "uint64"
|
|
7
|
-
| "float"
|
|
8
|
-
| "double"
|
|
9
|
-
| "string";
|
|
10
|
-
export namespace ProtobufAtomic {
|
|
11
|
-
export type Numeric =
|
|
12
|
-
| "int32"
|
|
13
|
-
| "uint32"
|
|
14
|
-
| "int64"
|
|
15
|
-
| "uint64"
|
|
16
|
-
| "float"
|
|
17
|
-
| "double";
|
|
18
|
-
export type BigNumeric = "int64" | "uint64";
|
|
19
|
-
}
|
|
1
|
+
export type ProtobufAtomic =
|
|
2
|
+
| "bool"
|
|
3
|
+
| "int32"
|
|
4
|
+
| "uint32"
|
|
5
|
+
| "int64"
|
|
6
|
+
| "uint64"
|
|
7
|
+
| "float"
|
|
8
|
+
| "double"
|
|
9
|
+
| "string";
|
|
10
|
+
export namespace ProtobufAtomic {
|
|
11
|
+
export type Numeric =
|
|
12
|
+
| "int32"
|
|
13
|
+
| "uint32"
|
|
14
|
+
| "int64"
|
|
15
|
+
| "uint64"
|
|
16
|
+
| "float"
|
|
17
|
+
| "double";
|
|
18
|
+
export type BigNumeric = "int64" | "uint64";
|
|
19
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type SpecialFields<Instance extends object, Target> = {
|
|
2
|
-
[P in keyof Instance]: Instance[P] extends Target ? P : never;
|
|
3
|
-
}[keyof Instance & string];
|
|
1
|
+
export type SpecialFields<Instance extends object, Target> = {
|
|
2
|
+
[P in keyof Instance]: Instance[P] extends Target ? P : never;
|
|
3
|
+
}[keyof Instance & string];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type ValidationPipe<T, E> =
|
|
2
|
-
| {
|
|
3
|
-
success: true;
|
|
4
|
-
data: T;
|
|
5
|
-
}
|
|
6
|
-
| {
|
|
7
|
-
success: false;
|
|
8
|
-
errors: E[];
|
|
9
|
-
};
|
|
1
|
+
export type ValidationPipe<T, E> =
|
|
2
|
+
| {
|
|
3
|
+
success: true;
|
|
4
|
+
data: T;
|
|
5
|
+
}
|
|
6
|
+
| {
|
|
7
|
+
success: false;
|
|
8
|
+
errors: E[];
|
|
9
|
+
};
|
package/src/typings/ValueOf.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export type ValueOf<Instance> =
|
|
2
|
-
IsValueOf<Instance, Boolean> extends true
|
|
3
|
-
? boolean
|
|
4
|
-
: IsValueOf<Instance, Number> extends true
|
|
5
|
-
? number
|
|
6
|
-
: IsValueOf<Instance, String> extends true
|
|
7
|
-
? string
|
|
8
|
-
: Instance;
|
|
9
|
-
|
|
10
|
-
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
11
|
-
? Object extends IValueOf<infer Primitive>
|
|
12
|
-
? Instance extends Primitive
|
|
13
|
-
? false
|
|
14
|
-
: true // not Primitive, but Object
|
|
15
|
-
: false // cannot be
|
|
16
|
-
: false;
|
|
17
|
-
|
|
18
|
-
interface IValueOf<T> {
|
|
19
|
-
valueOf(): T;
|
|
20
|
-
}
|
|
1
|
+
export type ValueOf<Instance> =
|
|
2
|
+
IsValueOf<Instance, Boolean> extends true
|
|
3
|
+
? boolean
|
|
4
|
+
: IsValueOf<Instance, Number> extends true
|
|
5
|
+
? number
|
|
6
|
+
: IsValueOf<Instance, String> extends true
|
|
7
|
+
? string
|
|
8
|
+
: Instance;
|
|
9
|
+
|
|
10
|
+
type IsValueOf<Instance, Object extends IValueOf<any>> = Instance extends Object
|
|
11
|
+
? Object extends IValueOf<infer Primitive>
|
|
12
|
+
? Instance extends Primitive
|
|
13
|
+
? false
|
|
14
|
+
: true // not Primitive, but Object
|
|
15
|
+
: false // cannot be
|
|
16
|
+
: false;
|
|
17
|
+
|
|
18
|
+
interface IValueOf<T> {
|
|
19
|
+
valueOf(): T;
|
|
20
|
+
}
|
package/src/typings/Writable.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ClassProperties } from "./ClassProperties";
|
|
2
|
-
|
|
3
|
-
export type Writable<T extends object> = {
|
|
4
|
-
-readonly [P in keyof T]: T[P];
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export function Writable<T extends object>(
|
|
8
|
-
elem: T,
|
|
9
|
-
): Writable<ClassProperties<T>> {
|
|
10
|
-
return elem as any;
|
|
11
|
-
}
|
|
1
|
+
import { ClassProperties } from "./ClassProperties";
|
|
2
|
+
|
|
3
|
+
export type Writable<T extends object> = {
|
|
4
|
+
-readonly [P in keyof T]: T[P];
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export function Writable<T extends object>(
|
|
8
|
+
elem: T,
|
|
9
|
+
): Writable<ClassProperties<T>> {
|
|
10
|
+
return elem as any;
|
|
11
|
+
}
|