typia 4.2.2 → 4.2.3

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 (250) hide show
  1. package/lib/factories/MetadataCollection.js +1 -0
  2. package/lib/factories/MetadataCollection.js.map +1 -1
  3. package/lib/factories/MetadataFactory.js +27 -0
  4. package/lib/factories/MetadataFactory.js.map +1 -1
  5. package/lib/factories/internal/metadata/explore_metadata.js +3 -7
  6. package/lib/factories/internal/metadata/explore_metadata.js.map +1 -1
  7. package/lib/factories/internal/metadata/iterate_metadata_intersection.js +1 -0
  8. package/lib/factories/internal/metadata/iterate_metadata_intersection.js.map +1 -1
  9. package/lib/programmers/CheckerProgrammer.js +0 -5
  10. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  11. package/lib/programmers/StringifyProgrammer.js +3 -0
  12. package/lib/programmers/StringifyProgrammer.js.map +1 -1
  13. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -0
  14. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/CustomValidatorMap.ts +126 -126
  17. package/src/IRandomGenerator.ts +34 -34
  18. package/src/IValidation.ts +21 -21
  19. package/src/Primitive.ts +131 -131
  20. package/src/TypeGuardError.ts +36 -36
  21. package/src/executable/TypiaGenerateWizard.ts +85 -85
  22. package/src/executable/TypiaSetupWizard.ts +153 -153
  23. package/src/executable/setup/ArgumentParser.ts +45 -45
  24. package/src/executable/setup/CommandExecutor.ts +8 -8
  25. package/src/executable/setup/FileRetriever.ts +22 -22
  26. package/src/executable/setup/PackageManager.ts +71 -71
  27. package/src/executable/setup/PluginConfigurator.ts +70 -70
  28. package/src/executable/typia.ts +52 -52
  29. package/src/factories/CommentFactory.ts +84 -84
  30. package/src/factories/ExpressionFactory.ts +70 -70
  31. package/src/factories/IdentifierFactory.ts +59 -59
  32. package/src/factories/LiteralFactory.ts +39 -39
  33. package/src/factories/MetadataCollection.ts +269 -264
  34. package/src/factories/MetadataFactory.ts +34 -30
  35. package/src/factories/MetadataTagFactory.ts +355 -355
  36. package/src/factories/StatementFactory.ts +24 -24
  37. package/src/factories/TemplateFactory.ts +58 -58
  38. package/src/factories/TypeFactory.ts +124 -124
  39. package/src/factories/ValueFactory.ts +12 -12
  40. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  41. package/src/factories/internal/metadata/emend_metadata_atomics.ts +33 -33
  42. package/src/factories/internal/metadata/emplace_metadata_alias.ts +40 -40
  43. package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
  44. package/src/factories/internal/metadata/emplace_metadata_object.ts +136 -136
  45. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
  46. package/src/factories/internal/metadata/explore_metadata.ts +38 -40
  47. package/src/factories/internal/metadata/iterate_metadata.ts +81 -81
  48. package/src/factories/internal/metadata/iterate_metadata_alias.ts +30 -30
  49. package/src/factories/internal/metadata/iterate_metadata_array.ts +24 -24
  50. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  51. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  52. package/src/factories/internal/metadata/iterate_metadata_collection.ts +133 -133
  53. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  54. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +84 -83
  55. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  56. package/src/factories/internal/metadata/iterate_metadata_native.ts +219 -219
  57. package/src/factories/internal/metadata/iterate_metadata_object.ts +43 -43
  58. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +49 -49
  59. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  60. package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
  61. package/src/factories/internal/metadata/iterate_metadata_tag.ts +31 -31
  62. package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
  63. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
  64. package/src/factories/internal/metadata/iterate_metadata_union.ts +24 -24
  65. package/src/functional/$any.ts +2 -2
  66. package/src/functional/$dictionary.ts +25 -25
  67. package/src/functional/$every.ts +11 -11
  68. package/src/functional/$guard.ts +35 -35
  69. package/src/functional/$is_between.ts +2 -2
  70. package/src/functional/$is_custom.ts +14 -14
  71. package/src/functional/$is_date.ts +3 -3
  72. package/src/functional/$is_datetime.ts +2 -2
  73. package/src/functional/$is_email.ts +4 -4
  74. package/src/functional/$is_ipv4.ts +4 -4
  75. package/src/functional/$is_ipv6.ts +4 -4
  76. package/src/functional/$is_url.ts +4 -4
  77. package/src/functional/$is_uuid.ts +4 -4
  78. package/src/functional/$join.ts +46 -46
  79. package/src/functional/$number.ts +12 -12
  80. package/src/functional/$report.ts +15 -15
  81. package/src/functional/$rest.ts +3 -3
  82. package/src/functional/$string.ts +50 -50
  83. package/src/functional/$tail.ts +5 -5
  84. package/src/functional/Namespace.ts +127 -127
  85. package/src/index.ts +4 -4
  86. package/src/metadata/ICommentTag.ts +4 -4
  87. package/src/metadata/IJsDocTagInfo.ts +10 -10
  88. package/src/metadata/IMetadata.ts +28 -28
  89. package/src/metadata/IMetadataAlias.ts +14 -14
  90. package/src/metadata/IMetadataApplication.ts +7 -7
  91. package/src/metadata/IMetadataArray.ts +10 -10
  92. package/src/metadata/IMetadataCollection.ts +11 -11
  93. package/src/metadata/IMetadataConstant.ts +16 -16
  94. package/src/metadata/IMetadataDictionary.ts +14 -14
  95. package/src/metadata/IMetadataEntry.ts +6 -6
  96. package/src/metadata/IMetadataObject.ts +18 -18
  97. package/src/metadata/IMetadataProperty.ts +11 -11
  98. package/src/metadata/IMetadataResolved.ts +6 -6
  99. package/src/metadata/IMetadataTag.ts +105 -105
  100. package/src/metadata/IMetadataTuple.ts +10 -10
  101. package/src/metadata/Metadata.ts +607 -607
  102. package/src/metadata/MetadataAlias.ts +66 -66
  103. package/src/metadata/MetadataArray.ts +55 -55
  104. package/src/metadata/MetadataConstant.ts +3 -3
  105. package/src/metadata/MetadataObject.ts +129 -129
  106. package/src/metadata/MetadataProperty.ts +64 -64
  107. package/src/metadata/MetadataResolved.ts +51 -51
  108. package/src/metadata/MetadataTuple.ts +53 -53
  109. package/src/module.ts +2038 -2038
  110. package/src/programmers/ApplicationProgrammer.ts +47 -47
  111. package/src/programmers/AssertCloneProgrammer.ts +71 -71
  112. package/src/programmers/AssertParseProgrammer.ts +66 -66
  113. package/src/programmers/AssertProgrammer.ts +279 -279
  114. package/src/programmers/AssertPruneProgrammer.ts +68 -68
  115. package/src/programmers/AssertStringifyProgrammer.ts +66 -66
  116. package/src/programmers/CheckerProgrammer.ts +1173 -1182
  117. package/src/programmers/CloneProgrammer.ts +587 -587
  118. package/src/programmers/FeatureProgrammer.ts +495 -495
  119. package/src/programmers/IsCloneProgrammer.ts +78 -78
  120. package/src/programmers/IsParseProgrammer.ts +72 -72
  121. package/src/programmers/IsProgrammer.ts +239 -239
  122. package/src/programmers/IsPruneProgrammer.ts +73 -73
  123. package/src/programmers/IsStringifyProgrammer.ts +76 -76
  124. package/src/programmers/LiteralsProgrammer.ts +63 -63
  125. package/src/programmers/PruneProgrammer.ts +542 -542
  126. package/src/programmers/RandomProgrammer.ts +579 -579
  127. package/src/programmers/StringifyProgrammer.ts +986 -978
  128. package/src/programmers/TypiaProgrammer.ts +129 -129
  129. package/src/programmers/ValidateCloneProgrammer.ts +85 -85
  130. package/src/programmers/ValidateParseProgrammer.ts +70 -70
  131. package/src/programmers/ValidateProgrammer.ts +305 -305
  132. package/src/programmers/ValidatePruneProgrammer.ts +78 -78
  133. package/src/programmers/ValidateStringifyProgrammer.ts +84 -84
  134. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  135. package/src/programmers/helpers/CloneJoiner.ts +131 -131
  136. package/src/programmers/helpers/FunctionImporeter.ts +78 -78
  137. package/src/programmers/helpers/ICheckEntry.ts +12 -12
  138. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  139. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  140. package/src/programmers/helpers/PruneJoiner.ts +143 -143
  141. package/src/programmers/helpers/RandomJoiner.ts +173 -173
  142. package/src/programmers/helpers/RandomRanger.ts +216 -216
  143. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  144. package/src/programmers/helpers/StringifyPredicator.ts +13 -13
  145. package/src/programmers/helpers/UnionExplorer.ts +301 -301
  146. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  147. package/src/programmers/helpers/disable_function_importer_declare.ts +26 -26
  148. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  149. package/src/programmers/internal/application_alias.ts +66 -66
  150. package/src/programmers/internal/application_array.ts +30 -30
  151. package/src/programmers/internal/application_boolean.ts +15 -15
  152. package/src/programmers/internal/application_constant.ts +26 -26
  153. package/src/programmers/internal/application_default.ts +17 -17
  154. package/src/programmers/internal/application_default_string.ts +33 -33
  155. package/src/programmers/internal/application_native.ts +39 -39
  156. package/src/programmers/internal/application_number.ts +74 -74
  157. package/src/programmers/internal/application_object.ts +165 -165
  158. package/src/programmers/internal/application_resolved.ts +55 -55
  159. package/src/programmers/internal/application_schema.ts +157 -157
  160. package/src/programmers/internal/application_string.ts +44 -44
  161. package/src/programmers/internal/application_templates.ts +25 -25
  162. package/src/programmers/internal/application_tuple.ts +57 -57
  163. package/src/programmers/internal/check_array.ts +30 -30
  164. package/src/programmers/internal/check_array_length.ts +35 -35
  165. package/src/programmers/internal/check_bigint.ts +82 -82
  166. package/src/programmers/internal/check_custom.ts +31 -31
  167. package/src/programmers/internal/check_dynamic_properties.ts +195 -195
  168. package/src/programmers/internal/check_everything.ts +28 -28
  169. package/src/programmers/internal/check_native.ts +21 -21
  170. package/src/programmers/internal/check_number.ts +177 -177
  171. package/src/programmers/internal/check_object.ts +55 -55
  172. package/src/programmers/internal/check_string.ts +25 -25
  173. package/src/programmers/internal/check_string_tags.ts +67 -67
  174. package/src/programmers/internal/check_template.ts +56 -56
  175. package/src/programmers/internal/check_union_array_like.ts +329 -329
  176. package/src/programmers/internal/decode_union_object.ts +73 -73
  177. package/src/programmers/internal/feature_object_entries.ts +63 -63
  178. package/src/programmers/internal/get_comment_tags.ts +23 -23
  179. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  180. package/src/programmers/internal/prune_object_properties.ts +60 -60
  181. package/src/programmers/internal/random_custom.ts +29 -29
  182. package/src/programmers/internal/stringify_dynamic_properties.ts +171 -171
  183. package/src/programmers/internal/stringify_native.ts +7 -7
  184. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  185. package/src/programmers/internal/template_to_pattern.ts +15 -15
  186. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
  187. package/src/schemas/IJsonApplication.ts +8 -8
  188. package/src/schemas/IJsonComponents.ts +33 -33
  189. package/src/schemas/IJsonSchema.ts +133 -133
  190. package/src/transform.ts +27 -27
  191. package/src/transformers/CallExpressionTransformer.ts +179 -179
  192. package/src/transformers/FileTransformer.ts +47 -47
  193. package/src/transformers/IProject.ts +11 -11
  194. package/src/transformers/ITransformOptions.ts +62 -62
  195. package/src/transformers/ImportTransformer.ts +66 -66
  196. package/src/transformers/NodeTransformer.ts +13 -13
  197. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +112 -104
  198. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  199. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  200. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  201. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  202. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  203. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  204. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  205. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  206. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  207. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +39 -39
  208. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  209. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  210. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  211. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  212. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +28 -28
  213. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +53 -53
  214. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  215. package/src/transformers/features/miscellaneous/RandomTransformer.ts +42 -42
  216. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  217. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  218. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  219. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  220. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  221. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  222. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  223. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  224. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  225. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +12 -12
  226. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  227. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  228. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +12 -12
  229. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  230. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  231. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  232. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  233. package/src/transformers/features/validators/CreateAssertTransformer.ts +13 -13
  234. package/src/transformers/features/validators/CreateIsTransformer.ts +11 -11
  235. package/src/transformers/features/validators/CreateValidateTransformer.ts +13 -13
  236. package/src/transformers/features/validators/IsTransformer.ts +11 -11
  237. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  238. package/src/transformers/internal/GenericTransformer.ts +97 -97
  239. package/src/typings/Atomic.ts +17 -17
  240. package/src/typings/ClassProperties.ts +5 -5
  241. package/src/typings/Customizable.ts +5 -5
  242. package/src/typings/OmitNever.ts +3 -3
  243. package/src/typings/SpecialFields.ts +3 -3
  244. package/src/typings/Writable.ts +11 -11
  245. package/src/utils/ArrayUtil.ts +45 -45
  246. package/src/utils/Escaper.ts +46 -46
  247. package/src/utils/MapUtil.ts +12 -12
  248. package/src/utils/PatternUtil.ts +33 -33
  249. package/src/utils/RandomGenerator.ts +81 -81
  250. package/src/utils/Singleton.ts +17 -17
@@ -1,495 +1,495 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../factories/IdentifierFactory";
4
- import { MetadataCollection } from "../factories/MetadataCollection";
5
- import { StatementFactory } from "../factories/StatementFactory";
6
- import { TypeFactory } from "../factories/TypeFactory";
7
- import { ValueFactory } from "../factories/ValueFactory";
8
-
9
- import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
10
- import { IMetadataTag } from "../metadata/IMetadataTag";
11
- import { Metadata } from "../metadata/Metadata";
12
- import { MetadataArray } from "../metadata/MetadataArray";
13
- import { MetadataObject } from "../metadata/MetadataObject";
14
-
15
- import { IProject } from "../transformers/IProject";
16
-
17
- import { CheckerProgrammer } from "./CheckerProgrammer";
18
- import { FunctionImporter } from "./helpers/FunctionImporeter";
19
- import { IExpressionEntry } from "./helpers/IExpressionEntry";
20
- import { UnionExplorer } from "./helpers/UnionExplorer";
21
- import { feature_object_entries } from "./internal/feature_object_entries";
22
-
23
- export namespace FeatureProgrammer {
24
- /* -----------------------------------------------------------
25
- PARAMETERS
26
- ----------------------------------------------------------- */
27
- export interface IConfig<Output extends ts.ConciseBody = ts.ConciseBody> {
28
- types: IConfig.ITypes;
29
-
30
- /**
31
- * Prefix name of internal functions for specific types.
32
- */
33
- prefix: string;
34
-
35
- /**
36
- * Whether to archive access path or not.
37
- */
38
- path: boolean;
39
-
40
- /**
41
- * Whether to trace exception or not.
42
- */
43
- trace: boolean;
44
-
45
- addition?(collection: MetadataCollection): ts.Statement[];
46
-
47
- /**
48
- * Initializer of metadata.
49
- */
50
- initializer: (
51
- project: IProject,
52
- ) => (type: ts.Type) => [MetadataCollection, Metadata];
53
-
54
- /**
55
- * Decoder, station of every types.
56
- */
57
- decoder: () => Decoder<Metadata, Output>;
58
-
59
- /**
60
- * Object configurator.
61
- */
62
- objector: IConfig.IObjector;
63
-
64
- /**
65
- * Generator of functions for object types.
66
- */
67
- generator: IConfig.IGenerator;
68
- }
69
- export namespace IConfig {
70
- export interface ITypes {
71
- input: (type: ts.Type, name?: string) => ts.TypeNode;
72
- output: (type: ts.Type, name?: string) => ts.TypeNode;
73
- }
74
-
75
- export interface IObjector {
76
- /**
77
- * Type checker when union object type comes.
78
- */
79
- checker: () => Decoder<Metadata, ts.Expression>;
80
-
81
- /**
82
- * Decoder, function call expression generator of specific typed objects.
83
- */
84
- decoder: () => Decoder<MetadataObject, ts.Expression>;
85
-
86
- /**
87
- * Joiner of expressions from properties.
88
- */
89
- joiner(
90
- input: ts.Expression,
91
- entries: IExpressionEntry[],
92
- parent: MetadataObject,
93
- ): ts.ConciseBody;
94
-
95
- /**
96
- * Union type specificator.
97
- *
98
- * Expression of an algorithm specifying object type and calling
99
- * the `decoder` function of the specified object type.
100
- */
101
- unionizer: Decoder<MetadataObject[], ts.Expression>;
102
-
103
- /**
104
- * Handler of union type specification failure.
105
- *
106
- * @param value Expression of input parameter
107
- * @param expected Expected type name
108
- * @param explore Exploration info
109
- * @returns Statement of failure
110
- */
111
- failure(
112
- value: ts.Expression,
113
- expected: string,
114
- explore?: IExplore,
115
- ): ts.Statement;
116
-
117
- /**
118
- * Transformer of type checking expression by discrimination.
119
- *
120
- * When an object type has been specified by a discrimination without full
121
- * iteration, the `unionizer` will decode the object instance after
122
- * the last type checking.
123
- *
124
- * In such circumtance, you can transform the last type checking function.
125
- *
126
- * @param exp Current expression about type checking
127
- * @returns Transformed expression
128
- * @deprecated
129
- */
130
- is?(exp: ts.Expression): ts.Expression;
131
-
132
- /**
133
- * Transformer of non-undefined type checking by discrimination.
134
- *
135
- * When specifying an union type of objects, `typia` tries to find
136
- * descrimination way just by checking only one property type.
137
- * If succeeded to find the discrimination way, `typia` will check the target
138
- * property type and in the checking, non-undefined type checking would be
139
- * done.
140
- *
141
- * In such process, you can transform the non-undefined type checking.
142
- *
143
- * @param exp
144
- * @returns Transformed expression
145
- * @deprecated
146
- */
147
- required?(exp: ts.Expression): ts.Expression;
148
-
149
- /**
150
- * Conditon wrapper when unable to specify any object type.
151
- *
152
- * When failed to specify an object type through discrimination, full
153
- * iteration type checking would be happend. In such circumstance, you
154
- * can wrap the condition with additional function.
155
- *
156
- * @param condition Current condition
157
- * @returns A function wrapped current condition
158
- */
159
- full?: (
160
- condition: ts.Expression,
161
- ) => (
162
- input: ts.Expression,
163
- expected: string,
164
- explore: IExplore,
165
- ) => ts.Expression;
166
-
167
- /**
168
- * Return type.
169
- */
170
- type?: ts.TypeNode;
171
- }
172
- export interface IGenerator {
173
- objects?(): (col: MetadataCollection) => ts.VariableStatement[];
174
- unions?(): (col: MetadataCollection) => ts.VariableStatement[];
175
- arrays(): (col: MetadataCollection) => ts.VariableStatement[];
176
- tuples(): (col: MetadataCollection) => ts.VariableStatement[];
177
- }
178
- }
179
-
180
- export interface IExplore {
181
- tracable: boolean;
182
- source: "top" | "function";
183
- from: "top" | "array" | "object";
184
- postfix: string;
185
- start?: number;
186
- }
187
-
188
- export interface Decoder<
189
- T,
190
- Output extends ts.ConciseBody = ts.ConciseBody,
191
- > {
192
- (
193
- input: ts.Expression,
194
- target: T,
195
- explore: IExplore,
196
- metaTags: IMetadataTag[],
197
- jsDocTags: ts.JSDocTagInfo[],
198
- ): Output;
199
- }
200
-
201
- /* -----------------------------------------------------------
202
- GENERATORS
203
- ----------------------------------------------------------- */
204
- export const write =
205
- (project: IProject) =>
206
- (config: IConfig) =>
207
- (importer: FunctionImporter) =>
208
- (type: ts.Type, name?: string) => {
209
- const [collection, meta] = config.initializer(project)(type);
210
-
211
- // ITERATE OVER ALL METADATA
212
- const output: ts.ConciseBody = config.decoder()(
213
- ValueFactory.INPUT(),
214
- meta,
215
- {
216
- tracable: config.path || config.trace,
217
- source: "top",
218
- from: "top",
219
- postfix: '""',
220
- },
221
- [],
222
- [],
223
- );
224
-
225
- // RETURNS THE OPTIMAL ARROW FUNCTION
226
- const functions = {
227
- objects: (
228
- config.generator.objects?.() ??
229
- write_object_functions(config)(importer)
230
- )(collection),
231
- unions: (
232
- config.generator.unions?.() ?? write_union_functions(config)
233
- )(collection),
234
- arrays: config.generator.arrays()(collection),
235
- tuples: config.generator.tuples()(collection),
236
- };
237
- const added: ts.Statement[] = (config.addition ?? (() => []))(
238
- collection,
239
- );
240
-
241
- return ts.factory.createArrowFunction(
242
- undefined,
243
- undefined,
244
- parameterDeclarations(config)(config.types.input(type, name))(
245
- ValueFactory.INPUT(),
246
- ),
247
- config.types.output(type, name),
248
- undefined,
249
- ts.factory.createBlock(
250
- [
251
- ...added,
252
- ...functions.objects.filter((_, i) =>
253
- importer.hasLocal(`${config.prefix}o${i}`),
254
- ),
255
- ...functions.unions.filter((_, i) =>
256
- importer.hasLocal(`${config.prefix}u${i}`),
257
- ),
258
- ...functions.arrays.filter((_, i) =>
259
- importer.hasLocal(`${config.prefix}a${i}`),
260
- ),
261
- ...functions.tuples.filter((_, i) =>
262
- importer.hasLocal(`${config.prefix}t${i}`),
263
- ),
264
- ...(ts.isBlock(output)
265
- ? output.statements
266
- : [ts.factory.createReturnStatement(output)]),
267
- ],
268
- true,
269
- ),
270
- );
271
- };
272
-
273
- export const write_object_functions =
274
- (config: IConfig) =>
275
- (importer: FunctionImporter) =>
276
- (collection: MetadataCollection) =>
277
- collection
278
- .objects()
279
- .map((obj, i) =>
280
- StatementFactory.constant(
281
- `${config.prefix}o${i}`,
282
- ts.factory.createArrowFunction(
283
- undefined,
284
- undefined,
285
- parameterDeclarations(config)(
286
- TypeFactory.keyword("any"),
287
- )(ValueFactory.INPUT()),
288
- config.objector.type ?? TypeFactory.keyword("any"),
289
- undefined,
290
- config.objector.joiner(
291
- ts.factory.createIdentifier("input"),
292
- feature_object_entries(config)(importer)(obj)(
293
- ts.factory.createIdentifier("input"),
294
- ),
295
- obj,
296
- ),
297
- ),
298
- ),
299
- );
300
-
301
- export const write_union_functions =
302
- (config: IConfig) => (collection: MetadataCollection) =>
303
- collection
304
- .unions()
305
- .map((union, i) =>
306
- StatementFactory.constant(
307
- `${config.prefix}u${i}`,
308
- write_union(config)(union),
309
- ),
310
- );
311
-
312
- const write_union = (config: IConfig) => {
313
- const explorer = UnionExplorer.object(config);
314
- const input = ValueFactory.INPUT();
315
-
316
- return (meta: MetadataObject[]) =>
317
- ts.factory.createArrowFunction(
318
- undefined,
319
- undefined,
320
- parameterDeclarations(config)(TypeFactory.keyword("any"))(
321
- ValueFactory.INPUT(),
322
- ),
323
- TypeFactory.keyword("any"),
324
- undefined,
325
- explorer(
326
- input,
327
- meta,
328
- {
329
- tracable: config.path || config.trace,
330
- source: "function",
331
- from: "object",
332
- postfix: "",
333
- },
334
- [],
335
- [],
336
- ),
337
- );
338
- };
339
-
340
- /* -----------------------------------------------------------
341
- DECODERS
342
- ----------------------------------------------------------- */
343
- export const decode_array =
344
- (config: Pick<IConfig, "trace" | "path" | "decoder" | "prefix">) =>
345
- (importer: FunctionImporter) =>
346
- (
347
- combiner: (
348
- input: ts.Expression,
349
- arrow: ts.ArrowFunction,
350
- metaTags: IMetadataTag[],
351
- jsDocTags: ts.JSDocTagInfo[],
352
- ) => ts.Expression,
353
- ) => {
354
- const rand: string = importer.increment().toString();
355
- const tail =
356
- config.path || config.trace
357
- ? [
358
- IdentifierFactory.parameter(
359
- "_index" + rand,
360
- TypeFactory.keyword("number"),
361
- ),
362
- ]
363
- : [];
364
-
365
- return (
366
- input: ts.Expression,
367
- array: MetadataArray,
368
- explore: IExplore,
369
- metaTags: IMetadataTag[],
370
- jsDocTags: IJsDocTagInfo[],
371
- ) => {
372
- const arrow: ts.ArrowFunction = ts.factory.createArrowFunction(
373
- undefined,
374
- undefined,
375
- [
376
- IdentifierFactory.parameter(
377
- "elem",
378
- TypeFactory.keyword("any"),
379
- ),
380
- ...tail,
381
- ],
382
- undefined,
383
- undefined,
384
- config.decoder()(
385
- ValueFactory.INPUT("elem"),
386
- array.value,
387
- {
388
- tracable: explore.tracable,
389
- source: explore.source,
390
- from: "array",
391
- postfix: index(explore.start ?? null)(
392
- explore.postfix,
393
- )(rand),
394
- },
395
- metaTags,
396
- jsDocTags,
397
- ),
398
- );
399
- return combiner(input, arrow, metaTags, jsDocTags);
400
- };
401
- };
402
-
403
- export const decode_object =
404
- (config: Pick<IConfig, "trace" | "path" | "prefix">) =>
405
- (importer: FunctionImporter) =>
406
- (input: ts.Expression, obj: MetadataObject, explore: IExplore) =>
407
- ts.factory.createCallExpression(
408
- ts.factory.createIdentifier(
409
- importer.useLocal(`${config.prefix}o${obj.index}`),
410
- ),
411
- undefined,
412
- argumentsArray(config)(explore)(input),
413
- );
414
-
415
- /* -----------------------------------------------------------
416
- UTILITIES FOR INTERNAL FUNCTIONS
417
- ----------------------------------------------------------- */
418
- export const index =
419
- (start: number | null) => (prev: string) => (rand: string) => {
420
- const tail: string =
421
- start !== null
422
- ? `"[" + (${start} + _index${rand}) + "]"`
423
- : `"[" + _index${rand} + "]"`;
424
- if (prev === "") return tail;
425
- else if (prev[prev.length - 1] === `"`)
426
- return prev.substring(0, prev.length - 1) + tail.substring(1);
427
- return prev + ` + ${tail}`;
428
- };
429
-
430
- export const argumentsArray =
431
- (config: Pick<IConfig, "path" | "trace">) =>
432
- (explore: FeatureProgrammer.IExplore) => {
433
- const tail: ts.Expression[] =
434
- config.path === false && config.trace === false
435
- ? []
436
- : config.path === true && config.trace === true
437
- ? [
438
- ts.factory.createIdentifier(
439
- explore.postfix
440
- ? `_path + ${explore.postfix}`
441
- : "_path",
442
- ),
443
- explore.source === "function"
444
- ? ts.factory.createIdentifier(
445
- `${explore.tracable} && _exceptionable`,
446
- )
447
- : explore.tracable
448
- ? ts.factory.createTrue()
449
- : ts.factory.createFalse(),
450
- ]
451
- : config.path === true
452
- ? [
453
- ts.factory.createIdentifier(
454
- explore.postfix
455
- ? `_path + ${explore.postfix}`
456
- : "_path",
457
- ),
458
- ]
459
- : [
460
- explore.source === "function"
461
- ? ts.factory.createIdentifier(
462
- `${explore.tracable} && _exceptionable`,
463
- )
464
- : explore.tracable
465
- ? ts.factory.createTrue()
466
- : ts.factory.createFalse(),
467
- ];
468
- return (input: ts.Expression) => [input, ...tail];
469
- };
470
-
471
- export const parameterDeclarations =
472
- (props: Pick<CheckerProgrammer.IConfig, "path" | "trace">) =>
473
- (type: ts.TypeNode) => {
474
- const tail: ts.ParameterDeclaration[] = [];
475
- if (props.path)
476
- tail.push(
477
- IdentifierFactory.parameter(
478
- "_path",
479
- TypeFactory.keyword("string"),
480
- ),
481
- );
482
- if (props.trace)
483
- tail.push(
484
- IdentifierFactory.parameter(
485
- "_exceptionable",
486
- TypeFactory.keyword("boolean"),
487
- ts.factory.createTrue(),
488
- ),
489
- );
490
- return (input: ts.Identifier): ts.ParameterDeclaration[] => [
491
- IdentifierFactory.parameter(input, type),
492
- ...tail,
493
- ];
494
- };
495
- }
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../factories/IdentifierFactory";
4
+ import { MetadataCollection } from "../factories/MetadataCollection";
5
+ import { StatementFactory } from "../factories/StatementFactory";
6
+ import { TypeFactory } from "../factories/TypeFactory";
7
+ import { ValueFactory } from "../factories/ValueFactory";
8
+
9
+ import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
10
+ import { IMetadataTag } from "../metadata/IMetadataTag";
11
+ import { Metadata } from "../metadata/Metadata";
12
+ import { MetadataArray } from "../metadata/MetadataArray";
13
+ import { MetadataObject } from "../metadata/MetadataObject";
14
+
15
+ import { IProject } from "../transformers/IProject";
16
+
17
+ import { CheckerProgrammer } from "./CheckerProgrammer";
18
+ import { FunctionImporter } from "./helpers/FunctionImporeter";
19
+ import { IExpressionEntry } from "./helpers/IExpressionEntry";
20
+ import { UnionExplorer } from "./helpers/UnionExplorer";
21
+ import { feature_object_entries } from "./internal/feature_object_entries";
22
+
23
+ export namespace FeatureProgrammer {
24
+ /* -----------------------------------------------------------
25
+ PARAMETERS
26
+ ----------------------------------------------------------- */
27
+ export interface IConfig<Output extends ts.ConciseBody = ts.ConciseBody> {
28
+ types: IConfig.ITypes;
29
+
30
+ /**
31
+ * Prefix name of internal functions for specific types.
32
+ */
33
+ prefix: string;
34
+
35
+ /**
36
+ * Whether to archive access path or not.
37
+ */
38
+ path: boolean;
39
+
40
+ /**
41
+ * Whether to trace exception or not.
42
+ */
43
+ trace: boolean;
44
+
45
+ addition?(collection: MetadataCollection): ts.Statement[];
46
+
47
+ /**
48
+ * Initializer of metadata.
49
+ */
50
+ initializer: (
51
+ project: IProject,
52
+ ) => (type: ts.Type) => [MetadataCollection, Metadata];
53
+
54
+ /**
55
+ * Decoder, station of every types.
56
+ */
57
+ decoder: () => Decoder<Metadata, Output>;
58
+
59
+ /**
60
+ * Object configurator.
61
+ */
62
+ objector: IConfig.IObjector;
63
+
64
+ /**
65
+ * Generator of functions for object types.
66
+ */
67
+ generator: IConfig.IGenerator;
68
+ }
69
+ export namespace IConfig {
70
+ export interface ITypes {
71
+ input: (type: ts.Type, name?: string) => ts.TypeNode;
72
+ output: (type: ts.Type, name?: string) => ts.TypeNode;
73
+ }
74
+
75
+ export interface IObjector {
76
+ /**
77
+ * Type checker when union object type comes.
78
+ */
79
+ checker: () => Decoder<Metadata, ts.Expression>;
80
+
81
+ /**
82
+ * Decoder, function call expression generator of specific typed objects.
83
+ */
84
+ decoder: () => Decoder<MetadataObject, ts.Expression>;
85
+
86
+ /**
87
+ * Joiner of expressions from properties.
88
+ */
89
+ joiner(
90
+ input: ts.Expression,
91
+ entries: IExpressionEntry[],
92
+ parent: MetadataObject,
93
+ ): ts.ConciseBody;
94
+
95
+ /**
96
+ * Union type specificator.
97
+ *
98
+ * Expression of an algorithm specifying object type and calling
99
+ * the `decoder` function of the specified object type.
100
+ */
101
+ unionizer: Decoder<MetadataObject[], ts.Expression>;
102
+
103
+ /**
104
+ * Handler of union type specification failure.
105
+ *
106
+ * @param value Expression of input parameter
107
+ * @param expected Expected type name
108
+ * @param explore Exploration info
109
+ * @returns Statement of failure
110
+ */
111
+ failure(
112
+ value: ts.Expression,
113
+ expected: string,
114
+ explore?: IExplore,
115
+ ): ts.Statement;
116
+
117
+ /**
118
+ * Transformer of type checking expression by discrimination.
119
+ *
120
+ * When an object type has been specified by a discrimination without full
121
+ * iteration, the `unionizer` will decode the object instance after
122
+ * the last type checking.
123
+ *
124
+ * In such circumtance, you can transform the last type checking function.
125
+ *
126
+ * @param exp Current expression about type checking
127
+ * @returns Transformed expression
128
+ * @deprecated
129
+ */
130
+ is?(exp: ts.Expression): ts.Expression;
131
+
132
+ /**
133
+ * Transformer of non-undefined type checking by discrimination.
134
+ *
135
+ * When specifying an union type of objects, `typia` tries to find
136
+ * descrimination way just by checking only one property type.
137
+ * If succeeded to find the discrimination way, `typia` will check the target
138
+ * property type and in the checking, non-undefined type checking would be
139
+ * done.
140
+ *
141
+ * In such process, you can transform the non-undefined type checking.
142
+ *
143
+ * @param exp
144
+ * @returns Transformed expression
145
+ * @deprecated
146
+ */
147
+ required?(exp: ts.Expression): ts.Expression;
148
+
149
+ /**
150
+ * Conditon wrapper when unable to specify any object type.
151
+ *
152
+ * When failed to specify an object type through discrimination, full
153
+ * iteration type checking would be happend. In such circumstance, you
154
+ * can wrap the condition with additional function.
155
+ *
156
+ * @param condition Current condition
157
+ * @returns A function wrapped current condition
158
+ */
159
+ full?: (
160
+ condition: ts.Expression,
161
+ ) => (
162
+ input: ts.Expression,
163
+ expected: string,
164
+ explore: IExplore,
165
+ ) => ts.Expression;
166
+
167
+ /**
168
+ * Return type.
169
+ */
170
+ type?: ts.TypeNode;
171
+ }
172
+ export interface IGenerator {
173
+ objects?(): (col: MetadataCollection) => ts.VariableStatement[];
174
+ unions?(): (col: MetadataCollection) => ts.VariableStatement[];
175
+ arrays(): (col: MetadataCollection) => ts.VariableStatement[];
176
+ tuples(): (col: MetadataCollection) => ts.VariableStatement[];
177
+ }
178
+ }
179
+
180
+ export interface IExplore {
181
+ tracable: boolean;
182
+ source: "top" | "function";
183
+ from: "top" | "array" | "object";
184
+ postfix: string;
185
+ start?: number;
186
+ }
187
+
188
+ export interface Decoder<
189
+ T,
190
+ Output extends ts.ConciseBody = ts.ConciseBody,
191
+ > {
192
+ (
193
+ input: ts.Expression,
194
+ target: T,
195
+ explore: IExplore,
196
+ metaTags: IMetadataTag[],
197
+ jsDocTags: ts.JSDocTagInfo[],
198
+ ): Output;
199
+ }
200
+
201
+ /* -----------------------------------------------------------
202
+ GENERATORS
203
+ ----------------------------------------------------------- */
204
+ export const write =
205
+ (project: IProject) =>
206
+ (config: IConfig) =>
207
+ (importer: FunctionImporter) =>
208
+ (type: ts.Type, name?: string) => {
209
+ const [collection, meta] = config.initializer(project)(type);
210
+
211
+ // ITERATE OVER ALL METADATA
212
+ const output: ts.ConciseBody = config.decoder()(
213
+ ValueFactory.INPUT(),
214
+ meta,
215
+ {
216
+ tracable: config.path || config.trace,
217
+ source: "top",
218
+ from: "top",
219
+ postfix: '""',
220
+ },
221
+ [],
222
+ [],
223
+ );
224
+
225
+ // RETURNS THE OPTIMAL ARROW FUNCTION
226
+ const functions = {
227
+ objects: (
228
+ config.generator.objects?.() ??
229
+ write_object_functions(config)(importer)
230
+ )(collection),
231
+ unions: (
232
+ config.generator.unions?.() ?? write_union_functions(config)
233
+ )(collection),
234
+ arrays: config.generator.arrays()(collection),
235
+ tuples: config.generator.tuples()(collection),
236
+ };
237
+ const added: ts.Statement[] = (config.addition ?? (() => []))(
238
+ collection,
239
+ );
240
+
241
+ return ts.factory.createArrowFunction(
242
+ undefined,
243
+ undefined,
244
+ parameterDeclarations(config)(config.types.input(type, name))(
245
+ ValueFactory.INPUT(),
246
+ ),
247
+ config.types.output(type, name),
248
+ undefined,
249
+ ts.factory.createBlock(
250
+ [
251
+ ...added,
252
+ ...functions.objects.filter((_, i) =>
253
+ importer.hasLocal(`${config.prefix}o${i}`),
254
+ ),
255
+ ...functions.unions.filter((_, i) =>
256
+ importer.hasLocal(`${config.prefix}u${i}`),
257
+ ),
258
+ ...functions.arrays.filter((_, i) =>
259
+ importer.hasLocal(`${config.prefix}a${i}`),
260
+ ),
261
+ ...functions.tuples.filter((_, i) =>
262
+ importer.hasLocal(`${config.prefix}t${i}`),
263
+ ),
264
+ ...(ts.isBlock(output)
265
+ ? output.statements
266
+ : [ts.factory.createReturnStatement(output)]),
267
+ ],
268
+ true,
269
+ ),
270
+ );
271
+ };
272
+
273
+ export const write_object_functions =
274
+ (config: IConfig) =>
275
+ (importer: FunctionImporter) =>
276
+ (collection: MetadataCollection) =>
277
+ collection
278
+ .objects()
279
+ .map((obj, i) =>
280
+ StatementFactory.constant(
281
+ `${config.prefix}o${i}`,
282
+ ts.factory.createArrowFunction(
283
+ undefined,
284
+ undefined,
285
+ parameterDeclarations(config)(
286
+ TypeFactory.keyword("any"),
287
+ )(ValueFactory.INPUT()),
288
+ config.objector.type ?? TypeFactory.keyword("any"),
289
+ undefined,
290
+ config.objector.joiner(
291
+ ts.factory.createIdentifier("input"),
292
+ feature_object_entries(config)(importer)(obj)(
293
+ ts.factory.createIdentifier("input"),
294
+ ),
295
+ obj,
296
+ ),
297
+ ),
298
+ ),
299
+ );
300
+
301
+ export const write_union_functions =
302
+ (config: IConfig) => (collection: MetadataCollection) =>
303
+ collection
304
+ .unions()
305
+ .map((union, i) =>
306
+ StatementFactory.constant(
307
+ `${config.prefix}u${i}`,
308
+ write_union(config)(union),
309
+ ),
310
+ );
311
+
312
+ const write_union = (config: IConfig) => {
313
+ const explorer = UnionExplorer.object(config);
314
+ const input = ValueFactory.INPUT();
315
+
316
+ return (meta: MetadataObject[]) =>
317
+ ts.factory.createArrowFunction(
318
+ undefined,
319
+ undefined,
320
+ parameterDeclarations(config)(TypeFactory.keyword("any"))(
321
+ ValueFactory.INPUT(),
322
+ ),
323
+ TypeFactory.keyword("any"),
324
+ undefined,
325
+ explorer(
326
+ input,
327
+ meta,
328
+ {
329
+ tracable: config.path || config.trace,
330
+ source: "function",
331
+ from: "object",
332
+ postfix: "",
333
+ },
334
+ [],
335
+ [],
336
+ ),
337
+ );
338
+ };
339
+
340
+ /* -----------------------------------------------------------
341
+ DECODERS
342
+ ----------------------------------------------------------- */
343
+ export const decode_array =
344
+ (config: Pick<IConfig, "trace" | "path" | "decoder" | "prefix">) =>
345
+ (importer: FunctionImporter) =>
346
+ (
347
+ combiner: (
348
+ input: ts.Expression,
349
+ arrow: ts.ArrowFunction,
350
+ metaTags: IMetadataTag[],
351
+ jsDocTags: ts.JSDocTagInfo[],
352
+ ) => ts.Expression,
353
+ ) => {
354
+ const rand: string = importer.increment().toString();
355
+ const tail =
356
+ config.path || config.trace
357
+ ? [
358
+ IdentifierFactory.parameter(
359
+ "_index" + rand,
360
+ TypeFactory.keyword("number"),
361
+ ),
362
+ ]
363
+ : [];
364
+
365
+ return (
366
+ input: ts.Expression,
367
+ array: MetadataArray,
368
+ explore: IExplore,
369
+ metaTags: IMetadataTag[],
370
+ jsDocTags: IJsDocTagInfo[],
371
+ ) => {
372
+ const arrow: ts.ArrowFunction = ts.factory.createArrowFunction(
373
+ undefined,
374
+ undefined,
375
+ [
376
+ IdentifierFactory.parameter(
377
+ "elem",
378
+ TypeFactory.keyword("any"),
379
+ ),
380
+ ...tail,
381
+ ],
382
+ undefined,
383
+ undefined,
384
+ config.decoder()(
385
+ ValueFactory.INPUT("elem"),
386
+ array.value,
387
+ {
388
+ tracable: explore.tracable,
389
+ source: explore.source,
390
+ from: "array",
391
+ postfix: index(explore.start ?? null)(
392
+ explore.postfix,
393
+ )(rand),
394
+ },
395
+ metaTags,
396
+ jsDocTags,
397
+ ),
398
+ );
399
+ return combiner(input, arrow, metaTags, jsDocTags);
400
+ };
401
+ };
402
+
403
+ export const decode_object =
404
+ (config: Pick<IConfig, "trace" | "path" | "prefix">) =>
405
+ (importer: FunctionImporter) =>
406
+ (input: ts.Expression, obj: MetadataObject, explore: IExplore) =>
407
+ ts.factory.createCallExpression(
408
+ ts.factory.createIdentifier(
409
+ importer.useLocal(`${config.prefix}o${obj.index}`),
410
+ ),
411
+ undefined,
412
+ argumentsArray(config)(explore)(input),
413
+ );
414
+
415
+ /* -----------------------------------------------------------
416
+ UTILITIES FOR INTERNAL FUNCTIONS
417
+ ----------------------------------------------------------- */
418
+ export const index =
419
+ (start: number | null) => (prev: string) => (rand: string) => {
420
+ const tail: string =
421
+ start !== null
422
+ ? `"[" + (${start} + _index${rand}) + "]"`
423
+ : `"[" + _index${rand} + "]"`;
424
+ if (prev === "") return tail;
425
+ else if (prev[prev.length - 1] === `"`)
426
+ return prev.substring(0, prev.length - 1) + tail.substring(1);
427
+ return prev + ` + ${tail}`;
428
+ };
429
+
430
+ export const argumentsArray =
431
+ (config: Pick<IConfig, "path" | "trace">) =>
432
+ (explore: FeatureProgrammer.IExplore) => {
433
+ const tail: ts.Expression[] =
434
+ config.path === false && config.trace === false
435
+ ? []
436
+ : config.path === true && config.trace === true
437
+ ? [
438
+ ts.factory.createIdentifier(
439
+ explore.postfix
440
+ ? `_path + ${explore.postfix}`
441
+ : "_path",
442
+ ),
443
+ explore.source === "function"
444
+ ? ts.factory.createIdentifier(
445
+ `${explore.tracable} && _exceptionable`,
446
+ )
447
+ : explore.tracable
448
+ ? ts.factory.createTrue()
449
+ : ts.factory.createFalse(),
450
+ ]
451
+ : config.path === true
452
+ ? [
453
+ ts.factory.createIdentifier(
454
+ explore.postfix
455
+ ? `_path + ${explore.postfix}`
456
+ : "_path",
457
+ ),
458
+ ]
459
+ : [
460
+ explore.source === "function"
461
+ ? ts.factory.createIdentifier(
462
+ `${explore.tracable} && _exceptionable`,
463
+ )
464
+ : explore.tracable
465
+ ? ts.factory.createTrue()
466
+ : ts.factory.createFalse(),
467
+ ];
468
+ return (input: ts.Expression) => [input, ...tail];
469
+ };
470
+
471
+ export const parameterDeclarations =
472
+ (props: Pick<CheckerProgrammer.IConfig, "path" | "trace">) =>
473
+ (type: ts.TypeNode) => {
474
+ const tail: ts.ParameterDeclaration[] = [];
475
+ if (props.path)
476
+ tail.push(
477
+ IdentifierFactory.parameter(
478
+ "_path",
479
+ TypeFactory.keyword("string"),
480
+ ),
481
+ );
482
+ if (props.trace)
483
+ tail.push(
484
+ IdentifierFactory.parameter(
485
+ "_exceptionable",
486
+ TypeFactory.keyword("boolean"),
487
+ ts.factory.createTrue(),
488
+ ),
489
+ );
490
+ return (input: ts.Identifier): ts.ParameterDeclaration[] => [
491
+ IdentifierFactory.parameter(input, type),
492
+ ...tail,
493
+ ];
494
+ };
495
+ }