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.
Files changed (113) hide show
  1. package/lib/TypeGuardError.mjs +26 -0
  2. package/lib/TypeGuardError.mjs.map +1 -0
  3. package/lib/executable/setup/PluginConfigurator.js +3 -3
  4. package/lib/executable/typia.js +15 -15
  5. package/lib/functional.mjs +120 -0
  6. package/lib/functional.mjs.map +1 -0
  7. package/lib/http.d.ts +15 -15
  8. package/lib/http.mjs +165 -0
  9. package/lib/http.mjs.map +1 -0
  10. package/lib/index.mjs +27 -1142
  11. package/lib/index.mjs.map +1 -1
  12. package/lib/json.mjs +105 -0
  13. package/lib/json.mjs.map +1 -0
  14. package/lib/llm.mjs +33 -0
  15. package/lib/llm.mjs.map +1 -0
  16. package/lib/misc.mjs +111 -0
  17. package/lib/misc.mjs.map +1 -0
  18. package/lib/module.d.ts +4 -4
  19. package/lib/module.mjs +139 -0
  20. package/lib/module.mjs.map +1 -0
  21. package/lib/notations.mjs +153 -0
  22. package/lib/notations.mjs.map +1 -0
  23. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +12 -0
  24. package/lib/programmers/json/JsonApplicationProgrammer.js +22 -22
  25. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  26. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js +15 -7
  27. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js.map +1 -1
  28. package/lib/programmers/llm/LlmApplicationProgrammer.js +39 -15
  29. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  30. package/lib/protobuf.d.ts +9 -9
  31. package/lib/protobuf.mjs +111 -0
  32. package/lib/protobuf.mjs.map +1 -0
  33. package/lib/reflect.mjs +18 -0
  34. package/lib/reflect.mjs.map +1 -0
  35. package/lib/schemas/llm/ILlmApplicationOfValidate.mjs +6 -0
  36. package/lib/schemas/llm/ILlmApplicationOfValidate.mjs.map +1 -0
  37. package/lib/schemas/llm/ILlmFunctionOfValidate.mjs +6 -0
  38. package/lib/schemas/llm/ILlmFunctionOfValidate.mjs.map +1 -0
  39. package/lib/tags/TagBase.d.ts +1 -1
  40. package/lib/tags/Type.d.ts +0 -1
  41. package/lib/tags/index.mjs +2 -0
  42. package/lib/tags/index.mjs.map +1 -0
  43. package/package.json +10 -8
  44. package/src/AssertionGuard.ts +1 -1
  45. package/src/CamelCase.ts +75 -75
  46. package/src/PascalCase.ts +71 -71
  47. package/src/Primitive.ts +92 -92
  48. package/src/Resolved.ts +74 -74
  49. package/src/SnakeCase.ts +126 -126
  50. package/src/TypeGuardError.ts +37 -37
  51. package/src/executable/setup/CommandExecutor.ts +8 -8
  52. package/src/executable/setup/PluginConfigurator.ts +69 -69
  53. package/src/executable/typia.ts +55 -55
  54. package/src/factories/CommentFactory.ts +79 -79
  55. package/src/factories/ValueFactory.ts +12 -12
  56. package/src/factories/internal/metadata/emend_metadata_atomics.ts +45 -45
  57. package/src/http.ts +15 -15
  58. package/src/index.ts +4 -4
  59. package/src/module.ts +4 -4
  60. package/src/programmers/helpers/ICheckEntry.ts +13 -13
  61. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  62. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  63. package/src/programmers/internal/stringify_native.ts +7 -7
  64. package/src/programmers/json/JsonApplicationProgrammer.ts +27 -27
  65. package/src/programmers/llm/LlmApplicationOfValidateProgrammer.ts +16 -2
  66. package/src/programmers/llm/LlmApplicationProgrammer.ts +50 -12
  67. package/src/protobuf.ts +9 -9
  68. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  69. package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
  70. package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
  71. package/src/schemas/metadata/IMetadataConstant.ts +18 -18
  72. package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
  73. package/src/schemas/metadata/IMetadataFunction.ts +8 -8
  74. package/src/schemas/metadata/IMetadataParameter.ts +9 -9
  75. package/src/schemas/metadata/IMetadataProperty.ts +9 -9
  76. package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
  77. package/src/schemas/metadata/MetadataArrayType.ts +57 -57
  78. package/src/schemas/metadata/MetadataConstant.ts +34 -34
  79. package/src/schemas/metadata/MetadataEscaped.ts +51 -51
  80. package/src/schemas/metadata/MetadataFunction.ts +49 -49
  81. package/src/schemas/metadata/MetadataTupleType.ts +67 -67
  82. package/src/tags/Constant.ts +15 -15
  83. package/src/tags/ContentMediaType.ts +10 -10
  84. package/src/tags/Default.ts +22 -22
  85. package/src/tags/ExclusiveMaximum.ts +25 -25
  86. package/src/tags/ExclusiveMinimum.ts +25 -25
  87. package/src/tags/MaxItems.ts +12 -12
  88. package/src/tags/MaxLength.ts +12 -12
  89. package/src/tags/Maximum.ts +19 -19
  90. package/src/tags/MinItems.ts +12 -12
  91. package/src/tags/MinLength.ts +12 -12
  92. package/src/tags/Minimum.ts +19 -19
  93. package/src/tags/MultipleOf.ts +21 -21
  94. package/src/tags/Pattern.ts +31 -31
  95. package/src/tags/TagBase.ts +1 -1
  96. package/src/tags/Type.ts +0 -1
  97. package/src/tags/internal/FormatCheatSheet.ts +73 -73
  98. package/src/typings/Atomic.ts +13 -13
  99. package/src/typings/ClassProperties.ts +5 -5
  100. package/src/typings/Customizable.ts +5 -5
  101. package/src/typings/Equal.ts +18 -18
  102. package/src/typings/IsTuple.ts +9 -9
  103. package/src/typings/NativeClass.ts +23 -23
  104. package/src/typings/OmitNever.ts +3 -3
  105. package/src/typings/ProtobufAtomic.ts +19 -19
  106. package/src/typings/SpecialFields.ts +3 -3
  107. package/src/typings/ValidationPipe.ts +9 -9
  108. package/src/typings/ValueOf.ts +20 -20
  109. package/src/typings/Writable.ts +11 -11
  110. package/src/utils/ArrayUtil.ts +41 -41
  111. package/src/utils/Escaper.ts +50 -50
  112. package/src/utils/PatternUtil.ts +29 -29
  113. package/src/utils/Singleton.ts +16 -16
@@ -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
+ }>;
@@ -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;
@@ -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;
@@ -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
+ };
@@ -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
- * occured. So, define it with confidence. Compiler will block all your
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
@@ -28,6 +28,5 @@ export type Type<
28
28
  type: Value extends "int32" | "uint32" | "int64" | "uint64"
29
29
  ? "integer"
30
30
  : "number";
31
- format: Value;
32
31
  };
33
32
  }>;
@@ -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
- `/^(?:(?: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]\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,7})|((:[0-9a-f]{1,4}){0,5}:((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}))|:)))$/i`,
42
- ),
43
- uri: `${RegexCall(`/\\/|:/`)} && ${RegexCall(
44
- `/^(?:[a-z][a-z0-9+\\-.]*:)(?:\\/?\\/(?:(?:[a-z0-9\\-._~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:@]|%[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})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a-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,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
+ };
@@ -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;
@@ -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;
@@ -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
+ };
@@ -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
+ }
@@ -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
+ }