typia 5.0.0-dev.20230730 → 5.0.0-dev.20230805

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 (227) hide show
  1. package/lib/factories/CommentFactory.d.ts +1 -1
  2. package/lib/factories/CommentFactory.js +31 -28
  3. package/lib/factories/CommentFactory.js.map +1 -1
  4. package/lib/functional/$string.js +16 -20
  5. package/lib/functional/$string.js.map +1 -1
  6. package/lib/programmers/internal/application_object.js +2 -0
  7. package/lib/programmers/internal/application_object.js.map +1 -1
  8. package/lib/schemas/metadata/Metadata.d.ts +1 -0
  9. package/lib/schemas/metadata/Metadata.js +3 -0
  10. package/lib/schemas/metadata/Metadata.js.map +1 -1
  11. package/package.json +2 -2
  12. package/src/factories/CommentFactory.ts +84 -76
  13. package/src/factories/MetadataCollection.ts +264 -264
  14. package/src/factories/MetadataFactory.ts +30 -30
  15. package/src/factories/MetadataTagFactory.ts +362 -362
  16. package/src/factories/ProtocolFactory.ts +80 -80
  17. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  18. package/src/factories/internal/metadata/emend_metadata_atomics.ts +33 -33
  19. package/src/factories/internal/metadata/emplace_metadata_alias.ts +40 -40
  20. package/src/factories/internal/metadata/emplace_metadata_array.ts +34 -34
  21. package/src/factories/internal/metadata/emplace_metadata_object.ts +136 -136
  22. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +50 -50
  23. package/src/factories/internal/metadata/explore_metadata.ts +40 -40
  24. package/src/factories/internal/metadata/iterate_metadata.ts +81 -81
  25. package/src/factories/internal/metadata/iterate_metadata_alias.ts +30 -30
  26. package/src/factories/internal/metadata/iterate_metadata_array.ts +24 -24
  27. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
  28. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  29. package/src/factories/internal/metadata/iterate_metadata_collection.ts +133 -133
  30. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  31. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +83 -83
  32. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  33. package/src/factories/internal/metadata/iterate_metadata_native.ts +219 -219
  34. package/src/factories/internal/metadata/iterate_metadata_object.ts +43 -43
  35. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +49 -49
  36. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  37. package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
  38. package/src/factories/internal/metadata/iterate_metadata_tag.ts +31 -31
  39. package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
  40. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +24 -24
  41. package/src/factories/internal/metadata/iterate_metadata_union.ts +24 -24
  42. package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +180 -180
  43. package/src/factories/internal/protocols/emplace_protocol_object.ts +25 -25
  44. package/src/factories/internal/protocols/emplace_protocol_property.ts +12 -12
  45. package/src/factories/internal/protocols/iterate_protocol_atomic.ts +34 -34
  46. package/src/factories/internal/protocols/iterate_protocol_constant.ts +27 -27
  47. package/src/factories/internal/protocols/iterate_protocol_main.ts +19 -19
  48. package/src/factories/internal/protocols/iterate_protocol_map.ts +58 -58
  49. package/src/factories/internal/protocols/iterate_protocol_metadata.ts +96 -96
  50. package/src/factories/internal/protocols/iterate_protocol_native.ts +34 -34
  51. package/src/factories/internal/protocols/iterate_protocol_never.ts +1 -1
  52. package/src/factories/internal/protocols/iterate_protocol_object.ts +110 -110
  53. package/src/factories/internal/protocols/iterate_protocol_repeated.ts +34 -34
  54. package/src/factories/internal/protocols/iterate_protocol_tuple.ts +29 -29
  55. package/src/functional/$number.ts +13 -13
  56. package/src/functional/$proto_bytes.ts +25 -25
  57. package/src/functional/$proto_field.ts +30 -30
  58. package/src/functional/$proto_float.ts +37 -37
  59. package/src/functional/$proto_i32.ts +29 -29
  60. package/src/functional/$proto_i64.ts +37 -37
  61. package/src/functional/$proto_size.ts +82 -82
  62. package/src/functional/$proto_string.ts +24 -24
  63. package/src/functional/$string.ts +32 -19
  64. package/src/functional/$varint.ts +130 -130
  65. package/src/functional/$zigzag.ts +39 -39
  66. package/src/json.ts +648 -648
  67. package/src/misc.ts +651 -651
  68. package/src/module.ts +781 -781
  69. package/src/programmers/CheckerProgrammer.ts +1182 -1182
  70. package/src/programmers/FeatureProgrammer.ts +495 -495
  71. package/src/programmers/IsProgrammer.ts +239 -239
  72. package/src/programmers/IsPruneProgrammer.ts +73 -73
  73. package/src/programmers/RandomProgrammer.ts +581 -581
  74. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  75. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  76. package/src/programmers/helpers/PruneJoiner.ts +143 -143
  77. package/src/programmers/helpers/RandomJoiner.ts +173 -173
  78. package/src/programmers/helpers/RandomRanger.ts +216 -216
  79. package/src/programmers/helpers/StringifyPredicator.ts +13 -13
  80. package/src/programmers/helpers/UnionExplorer.ts +301 -301
  81. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  82. package/src/programmers/internal/application_alias.ts +66 -66
  83. package/src/programmers/internal/application_array.ts +30 -30
  84. package/src/programmers/internal/application_constant.ts +26 -26
  85. package/src/programmers/internal/application_default.ts +17 -17
  86. package/src/programmers/internal/application_default_string.ts +33 -33
  87. package/src/programmers/internal/application_native.ts +39 -39
  88. package/src/programmers/internal/application_number.ts +77 -77
  89. package/src/programmers/internal/application_object.ts +165 -162
  90. package/src/programmers/internal/application_resolved.ts +55 -55
  91. package/src/programmers/internal/application_schema.ts +157 -157
  92. package/src/programmers/internal/application_string.ts +44 -44
  93. package/src/programmers/internal/application_templates.ts +25 -25
  94. package/src/programmers/internal/application_tuple.ts +57 -57
  95. package/src/programmers/internal/check_array.ts +30 -30
  96. package/src/programmers/internal/check_array_length.ts +35 -35
  97. package/src/programmers/internal/check_bigint.ts +82 -82
  98. package/src/programmers/internal/check_custom.ts +31 -31
  99. package/src/programmers/internal/check_number.ts +177 -177
  100. package/src/programmers/internal/check_string.ts +25 -25
  101. package/src/programmers/internal/check_string_tags.ts +67 -67
  102. package/src/programmers/internal/check_template.ts +56 -56
  103. package/src/programmers/internal/check_union_array_like.ts +329 -329
  104. package/src/programmers/internal/decode_union_object.ts +73 -73
  105. package/src/programmers/internal/feature_object_entries.ts +63 -63
  106. package/src/programmers/internal/get_comment_tags.ts +23 -23
  107. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  108. package/src/programmers/internal/prune_object_properties.ts +60 -60
  109. package/src/programmers/internal/random_custom.ts +29 -29
  110. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  111. package/src/programmers/internal/template_to_pattern.ts +15 -15
  112. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +16 -16
  113. package/src/programmers/json/JsonApplicationProgrammer.ts +47 -47
  114. package/src/programmers/json/JsonAssertParseProgrammer.ts +66 -66
  115. package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
  116. package/src/programmers/json/JsonIsParseProgrammer.ts +72 -72
  117. package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
  118. package/src/programmers/json/JsonStringifyProgrammer.ts +979 -979
  119. package/src/programmers/json/JsonValidateParseProgrammer.ts +70 -70
  120. package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
  121. package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
  122. package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
  123. package/src/programmers/misc/MiscCloneProgrammer.ts +587 -587
  124. package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
  125. package/src/programmers/misc/MiscLiteralsProgrammer.ts +63 -63
  126. package/src/programmers/misc/MiscPruneProgrammer.ts +542 -542
  127. package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
  128. package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
  129. package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +69 -69
  130. package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
  131. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +38 -38
  132. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +36 -36
  133. package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +75 -75
  134. package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
  135. package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +125 -125
  136. package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +83 -83
  137. package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
  138. package/src/protobuf.ts +210 -210
  139. package/src/schemas/json/IJsonApplication.ts +8 -8
  140. package/src/schemas/json/IJsonComponents.ts +33 -33
  141. package/src/schemas/json/IJsonSchema.ts +133 -133
  142. package/src/schemas/metadata/ICommentTag.ts +4 -4
  143. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  144. package/src/schemas/metadata/IMetadata.ts +28 -28
  145. package/src/schemas/metadata/IMetadataAlias.ts +14 -14
  146. package/src/schemas/metadata/IMetadataApplication.ts +7 -7
  147. package/src/schemas/metadata/IMetadataArray.ts +10 -10
  148. package/src/schemas/metadata/IMetadataCollection.ts +11 -11
  149. package/src/schemas/metadata/IMetadataConstant.ts +16 -16
  150. package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
  151. package/src/schemas/metadata/IMetadataEntry.ts +6 -6
  152. package/src/schemas/metadata/IMetadataObject.ts +18 -18
  153. package/src/schemas/metadata/IMetadataProperty.ts +11 -11
  154. package/src/schemas/metadata/IMetadataResolved.ts +6 -6
  155. package/src/schemas/metadata/IMetadataTag.ts +113 -113
  156. package/src/schemas/metadata/IMetadataTuple.ts +10 -10
  157. package/src/schemas/metadata/Metadata.ts +610 -608
  158. package/src/schemas/metadata/MetadataAlias.ts +66 -66
  159. package/src/schemas/metadata/MetadataArray.ts +55 -55
  160. package/src/schemas/metadata/MetadataConstant.ts +3 -3
  161. package/src/schemas/metadata/MetadataObject.ts +129 -129
  162. package/src/schemas/metadata/MetadataProperty.ts +64 -64
  163. package/src/schemas/metadata/MetadataResolved.ts +51 -51
  164. package/src/schemas/metadata/MetadataTuple.ts +53 -53
  165. package/src/schemas/protobuf/IProtocolMap.ts +5 -5
  166. package/src/schemas/protobuf/IProtocolMessage.ts +6 -6
  167. package/src/schemas/protobuf/IProtocolProperty.ts +13 -13
  168. package/src/transformers/CallExpressionTransformer.ts +240 -240
  169. package/src/transformers/features/AssertTransformer.ts +11 -11
  170. package/src/transformers/features/CreateAssertTransformer.ts +13 -13
  171. package/src/transformers/features/CreateIsTransformer.ts +11 -11
  172. package/src/transformers/features/CreateRandomTransformer.ts +39 -39
  173. package/src/transformers/features/CreateValidateTransformer.ts +13 -13
  174. package/src/transformers/features/IsTransformer.ts +11 -11
  175. package/src/transformers/features/RandomTransformer.ts +42 -42
  176. package/src/transformers/features/ValidateTransformer.ts +11 -11
  177. package/src/transformers/features/json/JsonApplicationTransformer.ts +102 -102
  178. package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
  179. package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
  180. package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
  181. package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
  182. package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
  183. package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
  184. package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
  185. package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
  186. package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
  187. package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
  188. package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
  189. package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
  190. package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
  191. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
  192. package/src/transformers/features/misc/MetadataTransformer.ts +53 -53
  193. package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
  194. package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
  195. package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
  196. package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
  197. package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
  198. package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
  199. package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
  200. package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
  201. package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
  202. package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
  203. package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
  204. package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
  205. package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
  206. package/src/transformers/features/misc/MiscLiteralsTransformer.ts +28 -28
  207. package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
  208. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
  209. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
  210. package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +10 -10
  211. package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +10 -10
  212. package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +10 -10
  213. package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +10 -10
  214. package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +10 -10
  215. package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +10 -10
  216. package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +10 -10
  217. package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +10 -10
  218. package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
  219. package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
  220. package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
  221. package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
  222. package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
  223. package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
  224. package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +31 -31
  225. package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +10 -10
  226. package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +10 -10
  227. package/src/utils/NameEncoder.ts +32 -32
@@ -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 "../schemas/metadata/IJsDocTagInfo";
10
- import { IMetadataTag } from "../schemas/metadata/IMetadataTag";
11
- import { Metadata } from "../schemas/metadata/Metadata";
12
- import { MetadataArray } from "../schemas/metadata/MetadataArray";
13
- import { MetadataObject } from "../schemas/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 "../schemas/metadata/IJsDocTagInfo";
10
+ import { IMetadataTag } from "../schemas/metadata/IMetadataTag";
11
+ import { Metadata } from "../schemas/metadata/Metadata";
12
+ import { MetadataArray } from "../schemas/metadata/MetadataArray";
13
+ import { MetadataObject } from "../schemas/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
+ }