typia 7.6.0-dev.20241229 → 7.6.1-dev.20250203

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 (170) hide show
  1. package/README.md +2 -1
  2. package/lib/IReadableURLSearchParams.d.ts +1 -1
  3. package/lib/TypeGuardError.mjs +26 -0
  4. package/lib/TypeGuardError.mjs.map +1 -0
  5. package/lib/executable/setup/PluginConfigurator.js +3 -3
  6. package/lib/executable/typia.js +15 -15
  7. package/lib/factories/MetadataTypeTagFactory.js +1 -1
  8. package/lib/factories/MetadataTypeTagFactory.js.map +1 -1
  9. package/lib/factories/ProtobufFactory.js +4 -4
  10. package/lib/factories/ProtobufFactory.js.map +1 -1
  11. package/lib/factories/internal/metadata/iterate_metadata_intersection.js +1 -1
  12. package/lib/factories/internal/metadata/iterate_metadata_intersection.js.map +1 -1
  13. package/lib/functional.mjs +120 -0
  14. package/lib/functional.mjs.map +1 -0
  15. package/lib/http.d.ts +16 -16
  16. package/lib/http.mjs +165 -0
  17. package/lib/http.mjs.map +1 -0
  18. package/lib/index.mjs +27 -1142
  19. package/lib/index.mjs.map +1 -1
  20. package/lib/internal/_isUniqueItems.js +1 -1
  21. package/lib/json.d.ts +5 -5
  22. package/lib/json.mjs +105 -0
  23. package/lib/json.mjs.map +1 -0
  24. package/lib/llm.d.ts +8 -8
  25. package/lib/llm.mjs +33 -0
  26. package/lib/llm.mjs.map +1 -0
  27. package/lib/misc.d.ts +10 -10
  28. package/lib/misc.mjs +111 -0
  29. package/lib/misc.mjs.map +1 -0
  30. package/lib/module.d.ts +5 -5
  31. package/lib/module.mjs +139 -0
  32. package/lib/module.mjs.map +1 -0
  33. package/lib/notations.mjs +153 -0
  34. package/lib/notations.mjs.map +1 -0
  35. package/lib/programmers/FeatureProgrammer.d.ts +3 -3
  36. package/lib/programmers/TypiaProgrammer.js +1 -1
  37. package/lib/programmers/TypiaProgrammer.js.map +1 -1
  38. package/lib/programmers/helpers/UnionExplorer.js +1 -1
  39. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  40. package/lib/programmers/helpers/UnionPredicator.d.ts +1 -1
  41. package/lib/programmers/helpers/UnionPredicator.js +1 -1
  42. package/lib/programmers/helpers/UnionPredicator.js.map +1 -1
  43. package/lib/programmers/json/JsonApplicationProgrammer.d.ts +12 -0
  44. package/lib/programmers/json/JsonApplicationProgrammer.js +23 -23
  45. package/lib/programmers/json/JsonApplicationProgrammer.js.map +1 -1
  46. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js +15 -7
  47. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js.map +1 -1
  48. package/lib/programmers/llm/LlmApplicationProgrammer.js +40 -16
  49. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  50. package/lib/programmers/llm/LlmParametersProgrammer.js +1 -1
  51. package/lib/programmers/llm/LlmParametersProgrammer.js.map +1 -1
  52. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +1 -1
  53. package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
  54. package/lib/protobuf.d.ts +9 -9
  55. package/lib/protobuf.mjs +111 -0
  56. package/lib/protobuf.mjs.map +1 -0
  57. package/lib/reflect.mjs +18 -0
  58. package/lib/reflect.mjs.map +1 -0
  59. package/lib/schemas/llm/ILlmApplicationOfValidate.d.ts +2 -2
  60. package/lib/schemas/llm/ILlmApplicationOfValidate.mjs +6 -0
  61. package/lib/schemas/llm/ILlmApplicationOfValidate.mjs.map +1 -0
  62. package/lib/schemas/llm/ILlmFunctionOfValidate.mjs +6 -0
  63. package/lib/schemas/llm/ILlmFunctionOfValidate.mjs.map +1 -0
  64. package/lib/tags/TagBase.d.ts +1 -1
  65. package/lib/tags/Type.d.ts +0 -1
  66. package/lib/tags/index.mjs +2 -0
  67. package/lib/tags/index.mjs.map +1 -0
  68. package/lib/transformers/ImportTransformer.js +3 -3
  69. package/lib/transformers/ImportTransformer.js.map +1 -1
  70. package/lib/transformers/features/json/JsonValidateParseTransformer.js +1 -1
  71. package/lib/transformers/features/json/JsonValidateParseTransformer.js.map +1 -1
  72. package/lib/transformers/features/json/JsonValidateStringifyTransformer.js +1 -1
  73. package/lib/transformers/features/json/JsonValidateStringifyTransformer.js.map +1 -1
  74. package/lib/transformers/features/misc/MiscValidateCloneTransformer.js +1 -1
  75. package/lib/transformers/features/misc/MiscValidateCloneTransformer.js.map +1 -1
  76. package/lib/transformers/features/misc/MiscValidatePruneTransformer.js +1 -1
  77. package/lib/transformers/features/misc/MiscValidatePruneTransformer.js.map +1 -1
  78. package/lib/transformers/features/reflect/ReflectNameTransformer.js +1 -1
  79. package/package.json +11 -8
  80. package/src/AssertionGuard.ts +1 -1
  81. package/src/CamelCase.ts +75 -75
  82. package/src/IReadableURLSearchParams.ts +1 -1
  83. package/src/PascalCase.ts +71 -71
  84. package/src/Primitive.ts +92 -92
  85. package/src/Resolved.ts +74 -74
  86. package/src/SnakeCase.ts +126 -126
  87. package/src/TypeGuardError.ts +37 -37
  88. package/src/executable/setup/CommandExecutor.ts +8 -8
  89. package/src/executable/setup/PluginConfigurator.ts +69 -69
  90. package/src/executable/typia.ts +55 -55
  91. package/src/factories/CommentFactory.ts +79 -79
  92. package/src/factories/MetadataTypeTagFactory.ts +1 -1
  93. package/src/factories/ProtobufFactory.ts +4 -4
  94. package/src/factories/ValueFactory.ts +12 -12
  95. package/src/factories/internal/metadata/emend_metadata_atomics.ts +45 -45
  96. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +1 -1
  97. package/src/http.ts +16 -16
  98. package/src/index.ts +4 -4
  99. package/src/internal/_isUniqueItems.ts +1 -1
  100. package/src/json.ts +6 -6
  101. package/src/llm.ts +8 -8
  102. package/src/misc.ts +11 -11
  103. package/src/module.ts +5 -5
  104. package/src/programmers/FeatureProgrammer.ts +3 -3
  105. package/src/programmers/TypiaProgrammer.ts +1 -1
  106. package/src/programmers/helpers/ICheckEntry.ts +13 -13
  107. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  108. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  109. package/src/programmers/helpers/UnionExplorer.ts +1 -1
  110. package/src/programmers/helpers/UnionPredicator.ts +3 -3
  111. package/src/programmers/internal/stringify_native.ts +7 -7
  112. package/src/programmers/json/JsonApplicationProgrammer.ts +28 -28
  113. package/src/programmers/llm/LlmApplicationOfValidateProgrammer.ts +16 -2
  114. package/src/programmers/llm/LlmApplicationProgrammer.ts +51 -13
  115. package/src/programmers/llm/LlmParametersProgrammer.ts +1 -1
  116. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +1 -1
  117. package/src/protobuf.ts +9 -9
  118. package/src/schemas/llm/ILlmApplicationOfValidate.ts +2 -2
  119. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  120. package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
  121. package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
  122. package/src/schemas/metadata/IMetadataConstant.ts +18 -18
  123. package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
  124. package/src/schemas/metadata/IMetadataFunction.ts +8 -8
  125. package/src/schemas/metadata/IMetadataParameter.ts +9 -9
  126. package/src/schemas/metadata/IMetadataProperty.ts +9 -9
  127. package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
  128. package/src/schemas/metadata/MetadataArrayType.ts +57 -57
  129. package/src/schemas/metadata/MetadataConstant.ts +34 -34
  130. package/src/schemas/metadata/MetadataEscaped.ts +51 -51
  131. package/src/schemas/metadata/MetadataFunction.ts +49 -49
  132. package/src/schemas/metadata/MetadataTupleType.ts +67 -67
  133. package/src/tags/Constant.ts +15 -15
  134. package/src/tags/ContentMediaType.ts +10 -10
  135. package/src/tags/Default.ts +22 -22
  136. package/src/tags/ExclusiveMaximum.ts +25 -25
  137. package/src/tags/ExclusiveMinimum.ts +25 -25
  138. package/src/tags/MaxItems.ts +12 -12
  139. package/src/tags/MaxLength.ts +12 -12
  140. package/src/tags/Maximum.ts +19 -19
  141. package/src/tags/MinItems.ts +12 -12
  142. package/src/tags/MinLength.ts +12 -12
  143. package/src/tags/Minimum.ts +19 -19
  144. package/src/tags/MultipleOf.ts +21 -21
  145. package/src/tags/Pattern.ts +31 -31
  146. package/src/tags/TagBase.ts +1 -1
  147. package/src/tags/Type.ts +0 -1
  148. package/src/tags/internal/FormatCheatSheet.ts +73 -73
  149. package/src/transformers/ImportTransformer.ts +3 -3
  150. package/src/transformers/features/json/JsonValidateParseTransformer.ts +1 -1
  151. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +1 -1
  152. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +1 -1
  153. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +1 -1
  154. package/src/transformers/features/reflect/ReflectNameTransformer.ts +1 -1
  155. package/src/typings/Atomic.ts +13 -13
  156. package/src/typings/ClassProperties.ts +5 -5
  157. package/src/typings/Customizable.ts +5 -5
  158. package/src/typings/Equal.ts +18 -18
  159. package/src/typings/IsTuple.ts +9 -9
  160. package/src/typings/NativeClass.ts +23 -23
  161. package/src/typings/OmitNever.ts +3 -3
  162. package/src/typings/ProtobufAtomic.ts +19 -19
  163. package/src/typings/SpecialFields.ts +3 -3
  164. package/src/typings/ValidationPipe.ts +9 -9
  165. package/src/typings/ValueOf.ts +20 -20
  166. package/src/typings/Writable.ts +11 -11
  167. package/src/utils/ArrayUtil.ts +41 -41
  168. package/src/utils/Escaper.ts +50 -50
  169. package/src/utils/PatternUtil.ts +29 -29
  170. package/src/utils/Singleton.ts +16 -16
package/src/Resolved.ts CHANGED
@@ -1,74 +1,74 @@
1
- import { Equal } from "./typings/Equal";
2
- import { IsTuple } from "./typings/IsTuple";
3
- import { NativeClass } from "./typings/NativeClass";
4
- import { ValueOf } from "./typings/ValueOf";
5
-
6
- /**
7
- * Resolved type erased every methods.
8
- *
9
- * `Resolved` is a type of TMP (Type Meta Programming) type which converts
10
- * its argument as a resolved type that erased every method properties.
11
- *
12
- * If the target argument is a built-in class which returns its origin primitive type
13
- * through the `valueOf()` method like the `String` or `Number`, its return type would
14
- * be the `string` or `number`. Otherwise, the built-in class does not have the
15
- * `valueOf()` method, the return type would be same with the target argument.
16
- *
17
- * Otherwise, the target argument is a type of custom class, all of its custom methods
18
- * would be erased and its prototype would be changed to the primitive `object`.
19
- * Therefore, return type of the TMP type finally be the resolved object.
20
- *
21
- * Before | After
22
- * ------------------------|----------------------------------------
23
- * `Boolean` | `boolean`
24
- * `Number` | `number`
25
- * `BigInt` | `bigint`
26
- * `String` | `string`
27
- * `Class` | `interface`
28
- * Native Class or Others | No change
29
- *
30
- * @template T Target argument type.
31
- * @author Jeongho Nam - https://github.com/samchon
32
- * @author Kyungsu Kang - https://github.com/kakasoo
33
- */
34
- export type Resolved<T> =
35
- Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
36
-
37
- type ResolvedMain<T> = T extends [never]
38
- ? never // (special trick for jsonable | null) type
39
- : ValueOf<T> extends boolean | number | bigint | string
40
- ? ValueOf<T>
41
- : T extends Function
42
- ? never
43
- : T extends object
44
- ? ResolvedObject<T>
45
- : ValueOf<T>;
46
-
47
- type ResolvedObject<T extends object> =
48
- T extends Array<infer U>
49
- ? IsTuple<T> extends true
50
- ? ResolvedTuple<T>
51
- : ResolvedMain<U>[]
52
- : T extends Set<infer U>
53
- ? Set<ResolvedMain<U>>
54
- : T extends Map<infer K, infer V>
55
- ? Map<ResolvedMain<K>, ResolvedMain<V>>
56
- : T extends WeakSet<any> | WeakMap<any, any>
57
- ? never
58
- : T extends NativeClass
59
- ? T
60
- : {
61
- [P in keyof T]: ResolvedMain<T[P]>;
62
- };
63
-
64
- type ResolvedTuple<T extends readonly any[]> = T extends []
65
- ? []
66
- : T extends [infer F]
67
- ? [ResolvedMain<F>]
68
- : T extends [infer F, ...infer Rest extends readonly any[]]
69
- ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
70
- : T extends [(infer F)?]
71
- ? [ResolvedMain<F>?]
72
- : T extends [(infer F)?, ...infer Rest extends readonly any[]]
73
- ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
74
- : [];
1
+ import { Equal } from "./typings/Equal";
2
+ import { IsTuple } from "./typings/IsTuple";
3
+ import { NativeClass } from "./typings/NativeClass";
4
+ import { ValueOf } from "./typings/ValueOf";
5
+
6
+ /**
7
+ * Resolved type erased every methods.
8
+ *
9
+ * `Resolved` is a type of TMP (Type Meta Programming) type which converts
10
+ * its argument as a resolved type that erased every method properties.
11
+ *
12
+ * If the target argument is a built-in class which returns its origin primitive type
13
+ * through the `valueOf()` method like the `String` or `Number`, its return type would
14
+ * be the `string` or `number`. Otherwise, the built-in class does not have the
15
+ * `valueOf()` method, the return type would be same with the target argument.
16
+ *
17
+ * Otherwise, the target argument is a type of custom class, all of its custom methods
18
+ * would be erased and its prototype would be changed to the primitive `object`.
19
+ * Therefore, return type of the TMP type finally be the resolved object.
20
+ *
21
+ * Before | After
22
+ * ------------------------|----------------------------------------
23
+ * `Boolean` | `boolean`
24
+ * `Number` | `number`
25
+ * `BigInt` | `bigint`
26
+ * `String` | `string`
27
+ * `Class` | `interface`
28
+ * Native Class or Others | No change
29
+ *
30
+ * @template T Target argument type.
31
+ * @author Jeongho Nam - https://github.com/samchon
32
+ * @author Kyungsu Kang - https://github.com/kakasoo
33
+ */
34
+ export type Resolved<T> =
35
+ Equal<T, ResolvedMain<T>> extends true ? T : ResolvedMain<T>;
36
+
37
+ type ResolvedMain<T> = T extends [never]
38
+ ? never // (special trick for jsonable | null) type
39
+ : ValueOf<T> extends boolean | number | bigint | string
40
+ ? ValueOf<T>
41
+ : T extends Function
42
+ ? never
43
+ : T extends object
44
+ ? ResolvedObject<T>
45
+ : ValueOf<T>;
46
+
47
+ type ResolvedObject<T extends object> =
48
+ T extends Array<infer U>
49
+ ? IsTuple<T> extends true
50
+ ? ResolvedTuple<T>
51
+ : ResolvedMain<U>[]
52
+ : T extends Set<infer U>
53
+ ? Set<ResolvedMain<U>>
54
+ : T extends Map<infer K, infer V>
55
+ ? Map<ResolvedMain<K>, ResolvedMain<V>>
56
+ : T extends WeakSet<any> | WeakMap<any, any>
57
+ ? never
58
+ : T extends NativeClass
59
+ ? T
60
+ : {
61
+ [P in keyof T]: ResolvedMain<T[P]>;
62
+ };
63
+
64
+ type ResolvedTuple<T extends readonly any[]> = T extends []
65
+ ? []
66
+ : T extends [infer F]
67
+ ? [ResolvedMain<F>]
68
+ : T extends [infer F, ...infer Rest extends readonly any[]]
69
+ ? [ResolvedMain<F>, ...ResolvedTuple<Rest>]
70
+ : T extends [(infer F)?]
71
+ ? [ResolvedMain<F>?]
72
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
73
+ ? [ResolvedMain<F>?, ...ResolvedTuple<Rest>]
74
+ : [];
package/src/SnakeCase.ts CHANGED
@@ -1,126 +1,126 @@
1
- import { Equal } from "./typings/Equal";
2
- import { NativeClass } from "./typings/NativeClass";
3
- import { ValueOf } from "./typings/ValueOf";
4
-
5
- /**
6
- * Snake case type.
7
- *
8
- * `SnakeCase` type is a type that all keys of an object are converted to snake case.
9
- *
10
- * It also erase every method properties like {@link Resolved} type.
11
- *
12
- * @template T Target type to be snake cased
13
- * @author Jeongho Nam - https://github.com/samchon
14
- */
15
- export type SnakeCase<T> =
16
- Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
17
-
18
- /* -----------------------------------------------------------
19
- OBJECT CONVERSION
20
- ----------------------------------------------------------- */
21
-
22
- type SnakageMain<T> = T extends [never]
23
- ? never // special trick for (jsonable | null) type
24
- : T extends { valueOf(): boolean | bigint | number | string }
25
- ? ValueOf<T>
26
- : T extends Function
27
- ? never
28
- : T extends object
29
- ? SnakageObject<T>
30
- : T;
31
-
32
- type SnakageObject<T extends object> =
33
- T extends Array<infer U>
34
- ? IsTuple<T> extends true
35
- ? SnakageTuple<T>
36
- : SnakageMain<U>[]
37
- : T extends Set<infer U>
38
- ? Set<SnakageMain<U>>
39
- : T extends Map<infer K, infer V>
40
- ? Map<SnakageMain<K>, SnakageMain<V>>
41
- : T extends WeakSet<any> | WeakMap<any, any>
42
- ? never
43
- : T extends NativeClass
44
- ? T
45
- : {
46
- [Key in keyof T as SnakageString<Key & string>]: SnakageMain<
47
- T[Key]
48
- >;
49
- };
50
-
51
- /* -----------------------------------------------------------
52
- SPECIAL CASES
53
- ----------------------------------------------------------- */
54
- type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
55
- never,
56
- ]
57
- ? false
58
- : T extends readonly any[]
59
- ? number extends T["length"]
60
- ? false
61
- : true
62
- : false;
63
- type SnakageTuple<T extends readonly any[]> = T extends []
64
- ? []
65
- : T extends [infer F]
66
- ? [SnakageMain<F>]
67
- : T extends [infer F, ...infer Rest extends readonly any[]]
68
- ? [SnakageMain<F>, ...SnakageTuple<Rest>]
69
- : T extends [(infer F)?]
70
- ? [SnakageMain<F>?]
71
- : T extends [(infer F)?, ...infer Rest extends readonly any[]]
72
- ? [SnakageMain<F>?, ...SnakageTuple<Rest>]
73
- : [];
74
-
75
- /* -----------------------------------------------------------
76
- STRING CONVERTER
77
- ----------------------------------------------------------- */
78
- type SnakageString<Key extends string> = Key extends `${infer _}`
79
- ? SnakageStringRepeatedly<Key, "">
80
- : Key;
81
- type SnakageStringRepeatedly<
82
- S extends string,
83
- Previous extends string,
84
- > = S extends `${infer First}${infer Second}${infer Rest}`
85
- ? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
86
- First,
87
- Second
88
- >}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
89
- : S extends `${infer First}`
90
- ? `${Underscore<Previous, First>}${Lowercase<First>}`
91
- : "";
92
- type Underscore<First extends string, Second extends string> = First extends
93
- | UpperAlphabetic
94
- | ""
95
- | "_"
96
- ? ""
97
- : Second extends UpperAlphabetic
98
- ? "_"
99
- : "";
100
- type UpperAlphabetic =
101
- | "A"
102
- | "B"
103
- | "C"
104
- | "D"
105
- | "E"
106
- | "F"
107
- | "G"
108
- | "H"
109
- | "I"
110
- | "J"
111
- | "K"
112
- | "L"
113
- | "M"
114
- | "N"
115
- | "O"
116
- | "P"
117
- | "Q"
118
- | "R"
119
- | "S"
120
- | "T"
121
- | "U"
122
- | "V"
123
- | "W"
124
- | "X"
125
- | "Y"
126
- | "Z";
1
+ import { Equal } from "./typings/Equal";
2
+ import { NativeClass } from "./typings/NativeClass";
3
+ import { ValueOf } from "./typings/ValueOf";
4
+
5
+ /**
6
+ * Snake case type.
7
+ *
8
+ * `SnakeCase` type is a type that all keys of an object are converted to snake case.
9
+ *
10
+ * It also erase every method properties like {@link Resolved} type.
11
+ *
12
+ * @template T Target type to be snake cased
13
+ * @author Jeongho Nam - https://github.com/samchon
14
+ */
15
+ export type SnakeCase<T> =
16
+ Equal<T, SnakageMain<T>> extends true ? T : SnakageMain<T>;
17
+
18
+ /* -----------------------------------------------------------
19
+ OBJECT CONVERSION
20
+ ----------------------------------------------------------- */
21
+
22
+ type SnakageMain<T> = T extends [never]
23
+ ? never // special trick for (jsonable | null) type
24
+ : T extends { valueOf(): boolean | bigint | number | string }
25
+ ? ValueOf<T>
26
+ : T extends Function
27
+ ? never
28
+ : T extends object
29
+ ? SnakageObject<T>
30
+ : T;
31
+
32
+ type SnakageObject<T extends object> =
33
+ T extends Array<infer U>
34
+ ? IsTuple<T> extends true
35
+ ? SnakageTuple<T>
36
+ : SnakageMain<U>[]
37
+ : T extends Set<infer U>
38
+ ? Set<SnakageMain<U>>
39
+ : T extends Map<infer K, infer V>
40
+ ? Map<SnakageMain<K>, SnakageMain<V>>
41
+ : T extends WeakSet<any> | WeakMap<any, any>
42
+ ? never
43
+ : T extends NativeClass
44
+ ? T
45
+ : {
46
+ [Key in keyof T as SnakageString<Key & string>]: SnakageMain<
47
+ T[Key]
48
+ >;
49
+ };
50
+
51
+ /* -----------------------------------------------------------
52
+ SPECIAL CASES
53
+ ----------------------------------------------------------- */
54
+ type IsTuple<T extends readonly any[] | { length: number }> = [T] extends [
55
+ never,
56
+ ]
57
+ ? false
58
+ : T extends readonly any[]
59
+ ? number extends T["length"]
60
+ ? false
61
+ : true
62
+ : false;
63
+ type SnakageTuple<T extends readonly any[]> = T extends []
64
+ ? []
65
+ : T extends [infer F]
66
+ ? [SnakageMain<F>]
67
+ : T extends [infer F, ...infer Rest extends readonly any[]]
68
+ ? [SnakageMain<F>, ...SnakageTuple<Rest>]
69
+ : T extends [(infer F)?]
70
+ ? [SnakageMain<F>?]
71
+ : T extends [(infer F)?, ...infer Rest extends readonly any[]]
72
+ ? [SnakageMain<F>?, ...SnakageTuple<Rest>]
73
+ : [];
74
+
75
+ /* -----------------------------------------------------------
76
+ STRING CONVERTER
77
+ ----------------------------------------------------------- */
78
+ type SnakageString<Key extends string> = Key extends `${infer _}`
79
+ ? SnakageStringRepeatedly<Key, "">
80
+ : Key;
81
+ type SnakageStringRepeatedly<
82
+ S extends string,
83
+ Previous extends string,
84
+ > = S extends `${infer First}${infer Second}${infer Rest}`
85
+ ? `${Underscore<Previous, First>}${Lowercase<First>}${Underscore<
86
+ First,
87
+ Second
88
+ >}${Lowercase<Second>}${SnakageStringRepeatedly<Rest, Second>}`
89
+ : S extends `${infer First}`
90
+ ? `${Underscore<Previous, First>}${Lowercase<First>}`
91
+ : "";
92
+ type Underscore<First extends string, Second extends string> = First extends
93
+ | UpperAlphabetic
94
+ | ""
95
+ | "_"
96
+ ? ""
97
+ : Second extends UpperAlphabetic
98
+ ? "_"
99
+ : "";
100
+ type UpperAlphabetic =
101
+ | "A"
102
+ | "B"
103
+ | "C"
104
+ | "D"
105
+ | "E"
106
+ | "F"
107
+ | "G"
108
+ | "H"
109
+ | "I"
110
+ | "J"
111
+ | "K"
112
+ | "L"
113
+ | "M"
114
+ | "N"
115
+ | "O"
116
+ | "P"
117
+ | "Q"
118
+ | "R"
119
+ | "S"
120
+ | "T"
121
+ | "U"
122
+ | "V"
123
+ | "W"
124
+ | "X"
125
+ | "Y"
126
+ | "Z";
@@ -1,37 +1,37 @@
1
- export class TypeGuardError<T = any> extends Error {
2
- public readonly method: string;
3
- public readonly path: string | undefined;
4
- public readonly expected: string;
5
- public readonly value: any;
6
- protected readonly fake_expected_typed_value_?: T | undefined;
7
-
8
- public constructor(props: TypeGuardError.IProps) {
9
- // MESSAGE CONSTRUCTION
10
- super(
11
- props.message ||
12
- `Error on ${props.method}(): invalid type${
13
- props.path ? ` on ${props.path}` : ""
14
- }, expect to be ${props.expected}`,
15
- );
16
-
17
- // INHERITANCE POLYFILL
18
- const proto = new.target.prototype;
19
- if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
20
- else (this as any).__proto__ = proto;
21
-
22
- // ASSIGN MEMBERS
23
- this.method = props.method;
24
- this.path = props.path;
25
- this.expected = props.expected;
26
- this.value = props.value;
27
- }
28
- }
29
- export namespace TypeGuardError {
30
- export interface IProps {
31
- method: string;
32
- path?: undefined | string;
33
- expected: string;
34
- value: any;
35
- message?: undefined | string;
36
- }
37
- }
1
+ export class TypeGuardError<T = any> extends Error {
2
+ public readonly method: string;
3
+ public readonly path: string | undefined;
4
+ public readonly expected: string;
5
+ public readonly value: any;
6
+ protected readonly fake_expected_typed_value_?: T | undefined;
7
+
8
+ public constructor(props: TypeGuardError.IProps) {
9
+ // MESSAGE CONSTRUCTION
10
+ super(
11
+ props.message ||
12
+ `Error on ${props.method}(): invalid type${
13
+ props.path ? ` on ${props.path}` : ""
14
+ }, expect to be ${props.expected}`,
15
+ );
16
+
17
+ // INHERITANCE POLYFILL
18
+ const proto = new.target.prototype;
19
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, proto);
20
+ else (this as any).__proto__ = proto;
21
+
22
+ // ASSIGN MEMBERS
23
+ this.method = props.method;
24
+ this.path = props.path;
25
+ this.expected = props.expected;
26
+ this.value = props.value;
27
+ }
28
+ }
29
+ export namespace TypeGuardError {
30
+ export interface IProps {
31
+ method: string;
32
+ path?: undefined | string;
33
+ expected: string;
34
+ value: any;
35
+ message?: undefined | string;
36
+ }
37
+ }
@@ -1,8 +1,8 @@
1
- import cp from "child_process";
2
-
3
- export namespace CommandExecutor {
4
- export const run = (str: string): void => {
5
- console.log(`\n$ ${str}`);
6
- cp.execSync(str, { stdio: "inherit" });
7
- };
8
- }
1
+ import cp from "child_process";
2
+
3
+ export namespace CommandExecutor {
4
+ export const run = (str: string): void => {
5
+ console.log(`\n$ ${str}`);
6
+ cp.execSync(str, { stdio: "inherit" });
7
+ };
8
+ }
@@ -1,69 +1,69 @@
1
- import comments from "comment-json";
2
- import fs from "fs";
3
-
4
- import { TypiaSetupWizard } from "../TypiaSetupWizard";
5
-
6
- export namespace PluginConfigurator {
7
- export async function configure(
8
- args: TypiaSetupWizard.IArguments,
9
- ): Promise<void> {
10
- // GET COMPILER-OPTIONS
11
- const config: comments.CommentObject = comments.parse(
12
- await fs.promises.readFile(args.project!, "utf8"),
13
- ) as comments.CommentObject;
14
- const compilerOptions = config.compilerOptions as
15
- | comments.CommentObject
16
- | undefined;
17
- if (compilerOptions === undefined)
18
- throw new ReferenceError(
19
- `${args.project} file does not have "compilerOptions" property.`,
20
- );
21
-
22
- // PREPARE PLUGINS
23
- const plugins: comments.CommentArray<comments.CommentObject> = (() => {
24
- const plugins = compilerOptions.plugins as
25
- | comments.CommentArray<comments.CommentObject>
26
- | undefined;
27
- if (plugins === undefined) return (compilerOptions.plugins = [] as any);
28
- else if (!Array.isArray(plugins))
29
- throw new TypeError(
30
- `"plugins" property of ${args.project} must be array type.`,
31
- );
32
- return plugins;
33
- })();
34
-
35
- const strict: boolean | undefined = compilerOptions.strict as
36
- | boolean
37
- | undefined;
38
- const strictNullChecks: boolean | undefined =
39
- compilerOptions.strictNullChecks as boolean | undefined;
40
- const oldbie: comments.CommentObject | undefined = plugins.find(
41
- (p) =>
42
- typeof p === "object" &&
43
- p !== null &&
44
- p.transform === "typia/lib/transform",
45
- );
46
- if (
47
- strictNullChecks !== false &&
48
- (strict === true || strictNullChecks === true) &&
49
- oldbie !== undefined
50
- )
51
- return;
52
-
53
- // DO CONFIGURE
54
- compilerOptions.strictNullChecks = true;
55
- if (strict === undefined && strictNullChecks === undefined)
56
- compilerOptions.strict = true;
57
- if (oldbie === undefined)
58
- plugins.push(
59
- comments.parse(`
60
- {
61
- "transform": "typia/lib/transform"
62
- }`) as comments.CommentObject,
63
- );
64
- await fs.promises.writeFile(
65
- args.project!,
66
- comments.stringify(config, null, 2),
67
- );
68
- }
69
- }
1
+ import comments from "comment-json";
2
+ import fs from "fs";
3
+
4
+ import { TypiaSetupWizard } from "../TypiaSetupWizard";
5
+
6
+ export namespace PluginConfigurator {
7
+ export async function configure(
8
+ args: TypiaSetupWizard.IArguments,
9
+ ): Promise<void> {
10
+ // GET COMPILER-OPTIONS
11
+ const config: comments.CommentObject = comments.parse(
12
+ await fs.promises.readFile(args.project!, "utf8"),
13
+ ) as comments.CommentObject;
14
+ const compilerOptions = config.compilerOptions as
15
+ | comments.CommentObject
16
+ | undefined;
17
+ if (compilerOptions === undefined)
18
+ throw new ReferenceError(
19
+ `${args.project} file does not have "compilerOptions" property.`,
20
+ );
21
+
22
+ // PREPARE PLUGINS
23
+ const plugins: comments.CommentArray<comments.CommentObject> = (() => {
24
+ const plugins = compilerOptions.plugins as
25
+ | comments.CommentArray<comments.CommentObject>
26
+ | undefined;
27
+ if (plugins === undefined) return (compilerOptions.plugins = [] as any);
28
+ else if (!Array.isArray(plugins))
29
+ throw new TypeError(
30
+ `"plugins" property of ${args.project} must be array type.`,
31
+ );
32
+ return plugins;
33
+ })();
34
+
35
+ const strict: boolean | undefined = compilerOptions.strict as
36
+ | boolean
37
+ | undefined;
38
+ const strictNullChecks: boolean | undefined =
39
+ compilerOptions.strictNullChecks as boolean | undefined;
40
+ const oldbie: comments.CommentObject | undefined = plugins.find(
41
+ (p) =>
42
+ typeof p === "object" &&
43
+ p !== null &&
44
+ p.transform === "typia/lib/transform",
45
+ );
46
+ if (
47
+ strictNullChecks !== false &&
48
+ (strict === true || strictNullChecks === true) &&
49
+ oldbie !== undefined
50
+ )
51
+ return;
52
+
53
+ // DO CONFIGURE
54
+ compilerOptions.strictNullChecks = true;
55
+ if (strict === undefined && strictNullChecks === undefined)
56
+ compilerOptions.strict = true;
57
+ if (oldbie === undefined)
58
+ plugins.push(
59
+ comments.parse(`
60
+ {
61
+ "transform": "typia/lib/transform"
62
+ }`) as comments.CommentObject,
63
+ );
64
+ await fs.promises.writeFile(
65
+ args.project!,
66
+ comments.stringify(config, null, 2),
67
+ );
68
+ }
69
+ }