typia 5.0.4 → 5.0.5-dev.20230921

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 (291) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/IRandomGenerator.ts +35 -35
  4. package/src/IValidation.ts +21 -21
  5. package/src/Primitive.ts +135 -135
  6. package/src/Resolved.ts +116 -116
  7. package/src/TypeGuardError.ts +36 -36
  8. package/src/executable/TypiaGenerateWizard.ts +85 -85
  9. package/src/executable/TypiaSetupWizard.ts +153 -153
  10. package/src/executable/setup/ArgumentParser.ts +45 -45
  11. package/src/executable/setup/CommandExecutor.ts +8 -8
  12. package/src/executable/setup/FileRetriever.ts +22 -22
  13. package/src/executable/setup/PackageManager.ts +71 -71
  14. package/src/executable/setup/PluginConfigurator.ts +70 -70
  15. package/src/executable/typia.ts +52 -52
  16. package/src/factories/CommentFactory.ts +84 -84
  17. package/src/factories/ExpressionFactory.ts +159 -159
  18. package/src/factories/IdentifierFactory.ts +74 -74
  19. package/src/factories/JsonMetadataFactory.ts +43 -43
  20. package/src/factories/LiteralFactory.ts +47 -47
  21. package/src/factories/MetadataCollection.ts +269 -269
  22. package/src/factories/MetadataCommentTagFactory.ts +629 -629
  23. package/src/factories/MetadataFactory.ts +214 -214
  24. package/src/factories/MetadataTypeTagFactory.ts +313 -313
  25. package/src/factories/NumericRangeFactory.ts +33 -33
  26. package/src/factories/ProtobufFactory.ts +272 -272
  27. package/src/factories/StatementFactory.ts +72 -72
  28. package/src/factories/TemplateFactory.ts +58 -58
  29. package/src/factories/TypeFactory.ts +119 -119
  30. package/src/factories/ValueFactory.ts +12 -12
  31. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  32. package/src/factories/internal/metadata/emend_metadata_atomics.ts +40 -40
  33. package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
  34. package/src/factories/internal/metadata/emplace_metadata_array_type.ts +41 -41
  35. package/src/factories/internal/metadata/emplace_metadata_object.ts +150 -150
  36. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +60 -60
  37. package/src/factories/internal/metadata/explore_metadata.ts +32 -32
  38. package/src/factories/internal/metadata/iterate_metadata.ts +101 -101
  39. package/src/factories/internal/metadata/iterate_metadata_alias.ts +35 -35
  40. package/src/factories/internal/metadata/iterate_metadata_array.ts +37 -37
  41. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
  42. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  43. package/src/factories/internal/metadata/iterate_metadata_collection.ts +141 -141
  44. package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
  45. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  46. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +197 -197
  47. package/src/factories/internal/metadata/iterate_metadata_map.ts +57 -57
  48. package/src/factories/internal/metadata/iterate_metadata_native.ts +210 -210
  49. package/src/factories/internal/metadata/iterate_metadata_object.ts +44 -44
  50. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
  51. package/src/factories/internal/metadata/iterate_metadata_set.ts +42 -42
  52. package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
  53. package/src/factories/internal/metadata/iterate_metadata_template.ts +47 -47
  54. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +37 -37
  55. package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
  56. package/src/functional/$ProtobufReader.ts +201 -201
  57. package/src/functional/$ProtobufSizer.ts +147 -147
  58. package/src/functional/$ProtobufWriter.ts +151 -151
  59. package/src/functional/$any.ts +4 -4
  60. package/src/functional/$clone.ts +4 -4
  61. package/src/functional/$dictionary.ts +25 -25
  62. package/src/functional/$every.ts +11 -11
  63. package/src/functional/$guard.ts +35 -35
  64. package/src/functional/$is_between.ts +2 -2
  65. package/src/functional/$join.ts +46 -46
  66. package/src/functional/$number.ts +13 -13
  67. package/src/functional/$report.ts +15 -15
  68. package/src/functional/$rest.ts +3 -3
  69. package/src/functional/$string.ts +50 -50
  70. package/src/functional/$strlen.ts +7 -7
  71. package/src/functional/$tail.ts +5 -5
  72. package/src/functional/$varint.ts +130 -130
  73. package/src/functional/$zigzag.ts +39 -39
  74. package/src/functional/IProtobufWriter.ts +18 -18
  75. package/src/functional/Namespace.ts +133 -133
  76. package/src/index.ts +4 -4
  77. package/src/json.ts +648 -648
  78. package/src/misc.ts +651 -651
  79. package/src/module.ts +656 -656
  80. package/src/programmers/AssertProgrammer.ts +317 -317
  81. package/src/programmers/CheckerProgrammer.ts +1137 -1137
  82. package/src/programmers/FeatureProgrammer.ts +478 -478
  83. package/src/programmers/IsProgrammer.ts +252 -252
  84. package/src/programmers/RandomProgrammer.ts +878 -878
  85. package/src/programmers/TypiaProgrammer.ts +163 -163
  86. package/src/programmers/ValidateProgrammer.ts +346 -346
  87. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  88. package/src/programmers/helpers/CloneJoiner.ts +144 -144
  89. package/src/programmers/helpers/FunctionImporeter.ts +91 -91
  90. package/src/programmers/helpers/ICheckEntry.ts +13 -13
  91. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  92. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  93. package/src/programmers/helpers/ProtobufUtil.ts +125 -125
  94. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  95. package/src/programmers/helpers/PruneJoiner.ts +143 -143
  96. package/src/programmers/helpers/RandomJoiner.ts +151 -151
  97. package/src/programmers/helpers/RandomRanger.ts +173 -173
  98. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  99. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  100. package/src/programmers/helpers/UnionExplorer.ts +305 -305
  101. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  102. package/src/programmers/helpers/disable_function_importer_declare.ts +32 -32
  103. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  104. package/src/programmers/internal/application_alias.ts +65 -65
  105. package/src/programmers/internal/application_array.ts +53 -53
  106. package/src/programmers/internal/application_boolean.ts +15 -15
  107. package/src/programmers/internal/application_constant.ts +26 -26
  108. package/src/programmers/internal/application_default.ts +17 -17
  109. package/src/programmers/internal/application_default_string.ts +37 -37
  110. package/src/programmers/internal/application_escaped.ts +55 -55
  111. package/src/programmers/internal/application_native.ts +39 -39
  112. package/src/programmers/internal/application_number.ts +88 -88
  113. package/src/programmers/internal/application_object.ts +162 -162
  114. package/src/programmers/internal/application_schema.ts +175 -175
  115. package/src/programmers/internal/application_string.ts +51 -51
  116. package/src/programmers/internal/application_templates.ts +25 -25
  117. package/src/programmers/internal/application_tuple.ts +58 -58
  118. package/src/programmers/internal/check_array_length.ts +41 -41
  119. package/src/programmers/internal/check_bigint.ts +45 -45
  120. package/src/programmers/internal/check_dynamic_properties.ts +194 -194
  121. package/src/programmers/internal/check_everything.ts +28 -28
  122. package/src/programmers/internal/check_native.ts +21 -21
  123. package/src/programmers/internal/check_number.ts +105 -105
  124. package/src/programmers/internal/check_object.ts +55 -55
  125. package/src/programmers/internal/check_string.ts +45 -45
  126. package/src/programmers/internal/check_template.ts +61 -61
  127. package/src/programmers/internal/check_union_array_like.ts +323 -323
  128. package/src/programmers/internal/decode_union_object.ts +84 -84
  129. package/src/programmers/internal/feature_object_entries.ts +58 -58
  130. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  131. package/src/programmers/internal/prune_object_properties.ts +60 -60
  132. package/src/programmers/internal/random_custom.ts +37 -37
  133. package/src/programmers/internal/stringify_dynamic_properties.ts +171 -171
  134. package/src/programmers/internal/stringify_native.ts +7 -7
  135. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  136. package/src/programmers/internal/template_to_pattern.ts +15 -15
  137. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +20 -20
  138. package/src/programmers/json/JsonApplicationProgrammer.ts +50 -50
  139. package/src/programmers/json/JsonAssertParseProgrammer.ts +71 -71
  140. package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
  141. package/src/programmers/json/JsonIsParseProgrammer.ts +77 -77
  142. package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
  143. package/src/programmers/json/JsonStringifyProgrammer.ts +964 -964
  144. package/src/programmers/json/JsonValidateParseProgrammer.ts +68 -68
  145. package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
  146. package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
  147. package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
  148. package/src/programmers/misc/MiscCloneProgrammer.ts +774 -774
  149. package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
  150. package/src/programmers/misc/MiscIsPruneProgrammer.ts +73 -73
  151. package/src/programmers/misc/MiscLiteralsProgrammer.ts +69 -69
  152. package/src/programmers/misc/MiscPruneProgrammer.ts +550 -550
  153. package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
  154. package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
  155. package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
  156. package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
  157. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +655 -655
  158. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +883 -883
  159. package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +85 -85
  160. package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
  161. package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +165 -165
  162. package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
  163. package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
  164. package/src/protobuf.ts +881 -881
  165. package/src/schemas/json/IJsonApplication.ts +8 -8
  166. package/src/schemas/json/IJsonComponents.ts +33 -33
  167. package/src/schemas/json/IJsonSchema.ts +110 -110
  168. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  169. package/src/schemas/metadata/IMetadata.ts +34 -34
  170. package/src/schemas/metadata/IMetadataAlias.ts +12 -12
  171. package/src/schemas/metadata/IMetadataApplication.ts +7 -7
  172. package/src/schemas/metadata/IMetadataArray.ts +7 -7
  173. package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
  174. package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
  175. package/src/schemas/metadata/IMetadataCollection.ts +11 -11
  176. package/src/schemas/metadata/IMetadataConstant.ts +16 -16
  177. package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
  178. package/src/schemas/metadata/IMetadataEntry.ts +6 -6
  179. package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
  180. package/src/schemas/metadata/IMetadataObject.ts +18 -18
  181. package/src/schemas/metadata/IMetadataProperty.ts +9 -9
  182. package/src/schemas/metadata/IMetadataTuple.ts +7 -7
  183. package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
  184. package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
  185. package/src/schemas/metadata/Metadata.ts +685 -685
  186. package/src/schemas/metadata/MetadataAlias.ts +61 -61
  187. package/src/schemas/metadata/MetadataArray.ts +49 -49
  188. package/src/schemas/metadata/MetadataArrayType.ts +57 -57
  189. package/src/schemas/metadata/MetadataAtomic.ts +42 -42
  190. package/src/schemas/metadata/MetadataConstant.ts +3 -3
  191. package/src/schemas/metadata/MetadataEscaped.ts +51 -51
  192. package/src/schemas/metadata/MetadataObject.ts +139 -139
  193. package/src/schemas/metadata/MetadataProperty.ts +59 -59
  194. package/src/schemas/metadata/MetadataTuple.ts +32 -32
  195. package/src/schemas/metadata/MetadataTupleType.ts +67 -67
  196. package/src/tags/ExclusiveMaximum.ts +13 -13
  197. package/src/tags/ExclusiveMinimum.ts +13 -13
  198. package/src/tags/Format.ts +30 -30
  199. package/src/tags/MaxItems.ts +9 -9
  200. package/src/tags/MaxLength.ts +9 -9
  201. package/src/tags/Maximum.ts +13 -13
  202. package/src/tags/MinItems.ts +9 -9
  203. package/src/tags/MinLength.ts +9 -9
  204. package/src/tags/Minimum.ts +13 -13
  205. package/src/tags/MultipleOf.ts +15 -15
  206. package/src/tags/Pattern.ts +8 -8
  207. package/src/tags/TagBase.ts +68 -68
  208. package/src/tags/Type.ts +27 -27
  209. package/src/tags/index.ts +13 -13
  210. package/src/transform.ts +35 -35
  211. package/src/transformers/CallExpressionTransformer.ts +243 -243
  212. package/src/transformers/FileTransformer.ts +57 -57
  213. package/src/transformers/IProject.ts +15 -15
  214. package/src/transformers/ITransformOptions.ts +62 -62
  215. package/src/transformers/ImportTransformer.ts +66 -66
  216. package/src/transformers/NodeTransformer.ts +13 -13
  217. package/src/transformers/TransformerError.ts +55 -55
  218. package/src/transformers/features/AssertTransformer.ts +11 -11
  219. package/src/transformers/features/CreateAssertTransformer.ts +13 -13
  220. package/src/transformers/features/CreateIsTransformer.ts +11 -11
  221. package/src/transformers/features/CreateRandomTransformer.ts +43 -43
  222. package/src/transformers/features/CreateValidateTransformer.ts +13 -13
  223. package/src/transformers/features/IsTransformer.ts +11 -11
  224. package/src/transformers/features/RandomTransformer.ts +46 -46
  225. package/src/transformers/features/ValidateTransformer.ts +11 -11
  226. package/src/transformers/features/json/JsonApplicationTransformer.ts +118 -118
  227. package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
  228. package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
  229. package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
  230. package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
  231. package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
  232. package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
  233. package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
  234. package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
  235. package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
  236. package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
  237. package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
  238. package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
  239. package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
  240. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
  241. package/src/transformers/features/misc/MetadataTransformer.ts +61 -61
  242. package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
  243. package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
  244. package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
  245. package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
  246. package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
  247. package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
  248. package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
  249. package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
  250. package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
  251. package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
  252. package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
  253. package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
  254. package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
  255. package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
  256. package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
  257. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
  258. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
  259. package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +12 -12
  260. package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +12 -12
  261. package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +9 -9
  262. package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +9 -9
  263. package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +12 -12
  264. package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +12 -12
  265. package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +12 -12
  266. package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +12 -12
  267. package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
  268. package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
  269. package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
  270. package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
  271. package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
  272. package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
  273. package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
  274. package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +12 -12
  275. package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +12 -12
  276. package/src/transformers/internal/GenericTransformer.ts +104 -104
  277. package/src/typings/Atomic.ts +18 -18
  278. package/src/typings/ClassProperties.ts +5 -5
  279. package/src/typings/Customizable.ts +5 -5
  280. package/src/typings/OmitNever.ts +3 -3
  281. package/src/typings/ProtobufAtomic.ts +19 -19
  282. package/src/typings/SpecialFields.ts +3 -3
  283. package/src/typings/ValidationPipe.ts +9 -9
  284. package/src/typings/Writable.ts +11 -11
  285. package/src/utils/ArrayUtil.ts +45 -45
  286. package/src/utils/Escaper.ts +46 -46
  287. package/src/utils/MapUtil.ts +12 -12
  288. package/src/utils/NameEncoder.ts +32 -32
  289. package/src/utils/PatternUtil.ts +33 -33
  290. package/src/utils/RandomGenerator.ts +83 -83
  291. package/src/utils/Singleton.ts +17 -17
package/src/protobuf.ts CHANGED
@@ -1,881 +1,881 @@
1
- import { Namespace } from "./functional/Namespace";
2
-
3
- import { IValidation } from "./IValidation";
4
- import { Resolved } from "./Resolved";
5
-
6
- /* ===========================================================
7
- PROTOCOL BUFFER
8
- - MESSAGE
9
- - DECODE
10
- - ENCODE
11
- - FACTORY FUNCTIONS
12
- ==============================================================
13
- SCHEMA
14
- ----------------------------------------------------------- */
15
- /**
16
- * > You must configure the generic argument `T`.
17
- *
18
- * Protocol Buffer Message Schema.
19
- *
20
- * Creates a Protocol Buffer Message Schema from a TypeScript type. The message
21
- * schema would be returned as a string value, and it can be used to share with
22
- * other developers/languages/frameworks.
23
- *
24
- * For reference, Protocol Buffer has lots of restrictions, so that expression power
25
- * of Protocol Buffer is not enough strong to fully meet the TypeScript type specs.
26
- * In such reason, if you put a TypeScript type that is not compatible with Protocol
27
- * Buffer, this function would throw a compilation error.
28
- *
29
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
30
- *
31
- * @template T Target type
32
- * @returns Protocol Buffer Message Schema.
33
- *
34
- * @author Jeongho Nam - https://github.com/samchon
35
- */
36
- export function message(): never;
37
-
38
- /**
39
- * Protocol Buffer Message Schema.
40
- *
41
- * Creates a Protocol Buffer Message Schema from a TypeScript type. The message
42
- * schema would be returned as a string value, and it can be used to share with
43
- * other developers/languages/frameworks.
44
- *
45
- * For reference, Protocol Buffer has lots of restrictions, so that expression power
46
- * of Protocol Buffer is not enough strong to fully meet the TypeScript type specs.
47
- * In such reason, if you put a TypeScript type that is not compatible with Protocol
48
- * Buffer, this function would throw a compilation error.
49
- *
50
- * @template T Target type
51
- * @returns Protocol Buffer Message Schema.
52
- *
53
- * @author Jeongho Nam - https://github.com/samchon
54
- */
55
- export function message<T>(): string;
56
-
57
- /**
58
- * @internal
59
- */
60
- export function message(): never {
61
- halt("message");
62
- }
63
-
64
- /* -----------------------------------------------------------
65
- DECODE
66
- ----------------------------------------------------------- */
67
- /**
68
- * > You must configure the generic argument `T`.
69
- *
70
- * Protocol Buffer Decoder.
71
- *
72
- * `typia.protobuf.decode()` is a function decoding a binary data of Protocol Buffer
73
- * format to a TypeScript instance.
74
- *
75
- * For reference, as Protocol Buffer handles binary data directly, there's no way
76
- * when `input` binary data was not encoded from the `T` typed value. In that case,
77
- * unexpected behavior or internal error would be occured. Therefore, I recommend you
78
- * to encode binary data of Protocol Buffer from type safe encode functions like below.
79
- * Use {@link encode} function only when you can ensure it.
80
- *
81
- * - {@link assertEncode}
82
- * - {@link isEncode}
83
- * - {@link validateEncode}
84
- *
85
- * Also, `typia` is providing type safe decoders like {@link assertDecode}, but it
86
- * is just for additional type validation like `number & Minimum<7>` or
87
- * `string & Format<"uuid">` cases, that are represented by
88
- * [custom tags](https://typia.io/docs/validators/tags). Thus, I repeat that,
89
- * you've to ensure the type safety when using decoder functions.
90
- *
91
- * @tempate Expected type of decoded value
92
- * @param input Protobuf Buffer binary data
93
- * @returns Decoded value
94
- *
95
- * @author Jeongho Nam - https://github.com/samchon
96
- */
97
- export function decode(input: Uint8Array): never;
98
-
99
- /**
100
- * Protocol Buffer Decoder.
101
- *
102
- * `typia.protobuf.decode()` is a function decoding a binary data of Protocol Buffer
103
- * format to a TypeScript instance.
104
- *
105
- * For reference, as Protocol Buffer handles binary data directly, there's no way
106
- * when `input` binary data was not encoded from the `T` typed value. In that case,
107
- * unexpected behavior or internal error would be occured. Therefore, I recommend you
108
- * to encode binary data of Protocol Buffer from type safe encode functions like below.
109
- * Use {@link encode} function only when you can ensure it.
110
- *
111
- * - {@link assertEncode}
112
- * - {@link isEncode}
113
- * - {@link validateEncode}
114
- *
115
- * Also, `typia` is providing type safe decoders like {@link assertDecode}, but it
116
- * is just for additional type validation like `number & Minimum<7>` or
117
- * `string & Format<"uuid">` cases, that are represented by
118
- * [custom tags](https://typia.io/docs/validators/tags). Thus, I repeat that,
119
- * you've to ensure the type safety when using decoder functions.
120
- *
121
- * @tempate Expected type of decoded value
122
- * @param input Protobuf Buffer binary data
123
- * @returns Decoded value
124
- *
125
- * @author Jeongho Nam - https://github.com/samchon
126
- */
127
- export function decode<T>(input: Uint8Array): Resolved<T>;
128
-
129
- /**
130
- * @internal
131
- */
132
- export function decode(): never {
133
- halt("decode");
134
- }
135
- Object.assign(decode, Namespace.protobuf.decode("decode"));
136
-
137
- /**
138
- * > You must configure the generic argument `T`.
139
- *
140
- * Protocol Buffer Decoder wity type assertion, but not safe.
141
- *
142
- * `typia.protobuf.assertDecode()` is a combination function of {@link decode} and
143
- * {@link assert} function. Therefore, it decodes a binary data of Protocol Buffer to
144
- * a TypeScript instance, and performs type assertion process. If decoded value is
145
- * following the type `T`, it returns the decoded value. Otherwise, it throws
146
- * {@link TypeGuardError} instead.
147
- *
148
- * However, note that, this validation is not always safe. It just performs additional
149
- * type assertion like `number & Minimum<7>` or `string & Format<"uuid">` cases,
150
- * that are represented by [custom tags](https://typia.io/docs/validators/tags).
151
- * Therefore, when using `typia.protobuf.assertDecode<T>()` function, you have to
152
- * ensure the type safety by yourself.
153
- *
154
- * In such type safety reason, I recommend you to use type safe encode functions.
155
- *
156
- * - {@link assertEncode}
157
- * - {@link isEncode}
158
- * - {@link validateEncode}
159
- *
160
- * @tempate Expected type of decoded value
161
- * @param input Protobuf Buffer binary data
162
- * @returns Decoded value
163
- *
164
- * @author Jeongho Nam - https://github.com/samchon
165
- */
166
- export function assertDecode(input: Uint8Array): never;
167
-
168
- /**
169
- * Protocol Buffer Decoder wity type assertion, but not safe.
170
- *
171
- * `typia.protobuf.assertDecode()` is a combination function of {@link decode} and
172
- * {@link assert} function. Therefore, it decodes a binary data of Protocol Buffer to
173
- * a TypeScript instance, and performs type assertion process. If decoded value is
174
- * following the type `T`, it returns the decoded value. Otherwise, it throws
175
- * {@link TypeGuardError} instead.
176
- *
177
- * However, note that, this validation is not always safe. It just performs additional
178
- * type assertion like `number & Minimum<7>` or `string & Format<"uuid">` cases,
179
- * that are represented by [custom tags](https://typia.io/docs/validators/tags).
180
- * Therefore, when using `typia.protobuf.assertDecode<T>()` function, you have to
181
- * ensure the type safety by yourself.
182
- *
183
- * In such type safety reason, I recommend you to use type safe encode functions.
184
- *
185
- * - {@link assertEncode}
186
- * - {@link isEncode}
187
- * - {@link validateEncode}
188
- *
189
- * @tempate Expected type of decoded value
190
- * @param input Protobuf Buffer binary data
191
- * @returns Decoded value
192
- *
193
- * @author Jeongho Nam - https://github.com/samchon
194
- */
195
- export function assertDecode<T>(input: Uint8Array): Resolved<T>;
196
-
197
- /**
198
- * @internal
199
- */
200
- export function assertDecode(): never {
201
- halt("assertDecode");
202
- }
203
- Object.assign(assertDecode, Namespace.assert("assertDecode"));
204
- Object.assign(assertDecode, Namespace.protobuf.decode("assertDecode"));
205
-
206
- /**
207
- * > You must configure the generic argument `T`.
208
- *
209
- * Protocol Buffer Decoder wity type checking, but not safe.
210
- *
211
- * `typia.protobuf.isDecode()` is a combination function of {@link decode} and
212
- * {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
213
- * a TypeScript instance, and performs type checking process. If decoded value is
214
- * following the type `T`, it returns the decoded value. Otherwise, it returns
215
- * `null` value instead.
216
- *
217
- * However, note that, this validation is not always safe. It just performs additional
218
- * type checking like `number & Minimum<7>` or `string & Format<"uuid">` cases,
219
- * that are represented by [custom tags](https://typia.io/docs/validators/tags).
220
- * Therefore, when using `typia.protobuf.isDecode<T>()` function, you have to
221
- * ensure the type safety by yourself.
222
- *
223
- * In such type safety reason, I recommend you to use type safe encode functions.
224
- *
225
- * - {@link assertEncode}
226
- * - {@link isEncode}
227
- * - {@link validateEncode}
228
- *
229
- * @tempate Expected type of decoded value
230
- * @param input Protobuf Buffer binary data
231
- * @returns Decoded value
232
- *
233
- * @author Jeongho Nam - https://github.com/samchon
234
- */
235
- export function isDecode(input: Uint8Array): never;
236
-
237
- /**
238
- * Protocol Buffer Decoder wity type checking, but not safe.
239
- *
240
- * `typia.protobuf.isDecode()` is a combination function of {@link decode} and
241
- * {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
242
- * a TypeScript instance, and performs type checking process. If decoded value is
243
- * following the type `T`, it returns the decoded value. Otherwise, it returns
244
- * `null` value instead.
245
- *
246
- * However, note that, this validation is not always safe. It just performs additional
247
- * type checking like `number & Minimum<7>` or `string & Format<"uuid">` cases,
248
- * that are represented by [custom tags](https://typia.io/docs/validators/tags).
249
- * Therefore, when using `typia.protobuf.isDecode<T>()` function, you have to
250
- * ensure the type safety by yourself.
251
- *
252
- * In such type safety reason, I recommend you to use type safe encode functions.
253
- *
254
- * - {@link assertEncode}
255
- * - {@link isEncode}
256
- * - {@link validateEncode}
257
- *
258
- * @tempate Expected type of decoded value
259
- * @param input Protobuf Buffer binary data
260
- * @returns Decoded value
261
- *
262
- * @author Jeongho Nam - https://github.com/samchon
263
- */
264
- export function isDecode<T>(input: Uint8Array): Resolved<T> | null;
265
-
266
- /**
267
- * @internal
268
- */
269
- export function isDecode(): never {
270
- halt("isDecode");
271
- }
272
- Object.assign(isDecode, Namespace.is());
273
- Object.assign(isDecode, Namespace.protobuf.decode("isDecode"));
274
-
275
- /**
276
- * > You must configure the generic argument `T`.
277
- *
278
- * Protocol Buffer Decoder wity type validation, but not safe.
279
- *
280
- * `typia.protobuf.validateDecode()` is a combination function of {@link decode} and
281
- * {@link validate} function. Therefore, it decodes a binary data of Protocol Buffer to
282
- * a TypeScript instance, and performs type validation process. If decoded value is
283
- * following the type `T`, it returns the decoded value with
284
- * {@link IValidation.ISuccess} typed instance. Otherwise, it returns
285
- * {@link IValidation.IFailure} value instead with detailed error reasons.
286
- *
287
- * However, note that, this validation is not always safe. It just performs additional
288
- * type validation like `number & Minimum<7>` or `string & Format<"uuid">` cases,
289
- * that are represented by [custom tags](https://typia.io/docs/validators/tags).
290
- * Therefore, when using `typia.protobuf.validateDecode<T>()` function, you have to
291
- * ensure the type safety by yourself.
292
- *
293
- * In such type safety reason, I recommend you to use type safe encode functions.
294
- *
295
- * - {@link assertEncode}
296
- * - {@link isEncode}
297
- * - {@link validateEncode}
298
- *
299
- * @tempate Expected type of decoded value
300
- * @param input Protobuf Buffer binary data
301
- * @returns Decoded value
302
- *
303
- * @author Jeongho Nam - https://github.com/samchon
304
- */
305
- export function validateDecode(input: Uint8Array): never;
306
-
307
- /**
308
- * Protocol Buffer Decoder wity type validation, but not safe.
309
- *
310
- * `typia.protobuf.validateDecode()` is a combination function of {@link decode} and
311
- * {@link validate} function. Therefore, it decodes a binary data of Protocol Buffer to
312
- * a TypeScript instance, and performs type validation process. If decoded value is
313
- * following the type `T`, it returns the decoded value with
314
- * {@link IValidation.ISuccess} typed instance. Otherwise, it returns
315
- * {@link IValidation.IFailure} value instead with detailed error reasons.
316
- *
317
- * However, note that, this validation is not always safe. It just performs additional
318
- * type validation like `number & Minimum<7>` or `string & Format<"uuid">` cases,
319
- * that are represented by [custom tags](https://typia.io/docs/validators/tags).
320
- * Therefore, when using `typia.protobuf.validateDecode<T>()` function, you have to
321
- * ensure the type safety by yourself.
322
- *
323
- * In such type safety reason, I recommend you to use type safe encode functions.
324
- *
325
- * - {@link assertEncode}
326
- * - {@link isEncode}
327
- * - {@link validateEncode}
328
- *
329
- * @tempate Expected type of decoded value
330
- * @param input Protobuf Buffer binary data
331
- * @returns Decoded value
332
- *
333
- * @author Jeongho Nam - https://github.com/samchon
334
- */
335
- export function validateDecode<T>(input: Uint8Array): IValidation<Resolved<T>>;
336
-
337
- /**
338
- * @internal
339
- */
340
- export function validateDecode(): never {
341
- halt("validateDecode");
342
- }
343
- Object.assign(validateDecode, Namespace.validate());
344
- Object.assign(validateDecode, Namespace.protobuf.decode("validateDecode"));
345
-
346
- /* -----------------------------------------------------------
347
- ENCODE
348
- ----------------------------------------------------------- */
349
- /**
350
- * Protocol Buffer Encoder.
351
- *
352
- * Converts an input value to a binary data of Protocol Buffer format.
353
- *
354
- * For reference, this `typia.protobuf.encode()` does not validate the `input` value.
355
- * It just believes that the `input` value is valid and converts it to a binary data
356
- * directly. Therefore, if you can't ensure the `input` value type, it would better to
357
- * call one of below functions intead.
358
- *
359
- * - {@link assertEncode}
360
- * - {@link isEncode}
361
- * - {@link validateEncode}
362
- *
363
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
364
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
365
- * type that is not compatible with Protocol Buffer, this function would throw a
366
- * compilation error.
367
- *
368
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
369
- *
370
- * @template T Type of the value input
371
- * @param input A value to encode
372
- * @returns Encoded binary data
373
- *
374
- * @author Jeongho Nam - https://github.com/samchon
375
- */
376
- export function encode<T>(input: T): Uint8Array;
377
-
378
- /**
379
- * @internal
380
- */
381
- export function encode(): never {
382
- halt("encode");
383
- }
384
- Object.assign(encode, Namespace.protobuf.encode("encode"));
385
-
386
- /**
387
- * Protocol Buffer Encoder with type assertion.
388
- *
389
- * `typia.protobuf.assertEncode()` is a combination function of {@link assert} and
390
- * {@link encode}.
391
- *
392
- * Therefore, it converts an `input` value to a binary data of
393
- * Protocol Buffer, with type assertion. If `input` value is not valid, it throws
394
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value,
395
- * Protocol Buffer binary data would be returned.
396
- *
397
- * If you can trust `input` value, or want to perform other type of validation, use
398
- * below functions intead.
399
- *
400
- * - {@link encode}
401
- * - {@link isEncode}
402
- * - {@link validateEncode}
403
- *
404
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
405
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
406
- * type that is not compatible with Protocol Buffer, this function would throw a
407
- * compilation error.
408
- *
409
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
410
- *
411
- * @template T Type of the value input
412
- * @param input A value to encode
413
- * @returns Encoded binary data
414
- *
415
- * @author Jeongho Nam - https://github.com/samchon
416
- */
417
- export function assertEncode<T>(input: T): Uint8Array;
418
-
419
- /**
420
- * Protocol Buffer Encoder with type assertion.
421
- *
422
- * `typia.protobuf.assertEncode()` is a combination function of {@link assert} and
423
- * {@link encode}.
424
- *
425
- * Therefore, it converts an `input` value to a binary data of
426
- * Protocol Buffer, with type assertion. If `input` value is not valid, it throws
427
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value,
428
- * Protocol Buffer binary data would be returned.
429
- *
430
- * If you can trust `input` value, or want to perform other type of validation, use
431
- * below functions intead.
432
- *
433
- * - {@link encode}
434
- * - {@link isEncode}
435
- * - {@link validateEncode}
436
- *
437
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
438
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
439
- * type that is not compatible with Protocol Buffer, this function would throw a
440
- * compilation error.
441
- *
442
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
443
- *
444
- * @template T Type of the value input
445
- * @param input A value to encode
446
- * @returns Encoded binary data
447
- *
448
- * @author Jeongho Nam - https://github.com/samchon
449
- */
450
- export function assertEncode<T>(input: unknown): Uint8Array;
451
-
452
- /**
453
- * @internal
454
- */
455
- export function assertEncode(): never {
456
- halt("assertEncode");
457
- }
458
- Object.assign(assertEncode, Namespace.assert("assertEncode"));
459
- Object.assign(assertEncode, Namespace.protobuf.encode("assertEncode"));
460
-
461
- /**
462
- * Protocol Buffer Encoder with type checking.
463
- *
464
- * `typia.protobuf.isEncode()` is a combination function of {@link is} and
465
- * {@link encode}.
466
- *
467
- * Therefore, it converts an `input` value to a binary data of
468
- * Protocol Buffer, with type checking. If `input` value is not valid, it returns
469
- * `null` value. Otherwise, there's no problem on the `input` value, Protocol
470
- * Buffer binary data would be returned.
471
- *
472
- * If you can trust `input` value, or want to perform other type of validation, use
473
- * below functions intead.
474
- *
475
- * - {@link encode}
476
- * - {@link assertEncode}
477
- * - {@link validateEncode}
478
- *
479
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
480
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
481
- * type that is not compatible with Protocol Buffer, this function would throw a
482
- * compilation error.
483
- *
484
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
485
- *
486
- * @template T Type of the value input
487
- * @param input A value to encode
488
- * @returns Encoded binary data
489
- *
490
- * @author Jeongho Nam - https://github.com/samchon
491
- */
492
- export function isEncode<T>(input: T): Uint8Array | null;
493
-
494
- /**
495
- * Protocol Buffer Encoder with type checking.
496
- *
497
- * `typia.protobuf.isEncode()` is a combination function of {@link is} and
498
- * {@link encode}.
499
- *
500
- * Therefore, it converts an `input` value to a binary data of
501
- * Protocol Buffer, with type checking. If `input` value is not valid, it returns
502
- * `null` value. Otherwise, there's no problem on the `input` value, Protocol
503
- * Buffer binary data would be returned.
504
- *
505
- * If you can trust `input` value, or want to perform other type of validation, use
506
- * below functions intead.
507
- *
508
- * - {@link encode}
509
- * - {@link assertEncode}
510
- * - {@link validateEncode}
511
- *
512
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
513
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
514
- * type that is not compatible with Protocol Buffer, this function would throw a
515
- * compilation error.
516
- *
517
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
518
- *
519
- * @template T Type of the value input
520
- * @param input A value to encode
521
- * @returns Encoded binary data
522
- *
523
- * @author Jeongho Nam - https://github.com/samchon
524
- */
525
- export function isEncode<T>(input: unknown): Uint8Array | null;
526
-
527
- /**
528
- * @internal
529
- */
530
- export function isEncode(): never {
531
- halt("isEncode");
532
- }
533
- Object.assign(isEncode, Namespace.is());
534
- Object.assign(isEncode, Namespace.protobuf.encode("isEncode"));
535
-
536
- /**
537
- * Protocol Buffer Encoder with type validation.
538
- *
539
- * `typia.protobuf.validateEncode()` is a combination function of
540
- * {@link validation} and {@link encode}.
541
- *
542
- * Therefore, it converts an `input` value to a binary data of
543
- * Protocol Buffer, with type validation. If `input` value is not valid, it returns
544
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
545
- * no problem on the `input` value, Protocol Buffer binary data would be stored in
546
- * `data` property of the output {@link IValidation.ISuccess} instance.
547
- *
548
- * If you can trust `input` value, or want to perform other type of validation, use
549
- * below functions intead.
550
- *
551
- * - {@link encode}
552
- * - {@link assertEncode}
553
- * - {@link isEncode}
554
- *
555
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
556
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
557
- * type that is not compatible with Protocol Buffer, this function would throw a
558
- * compilation error.
559
- *
560
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
561
- *
562
- * @template T Type of the value input
563
- * @param input A value to encode
564
- * @returns Encoded binary data
565
- *
566
- * @author Jeongho Nam - https://github.com/samchon
567
- */
568
- export function validateEncode<T>(input: T): IValidation<Uint8Array>;
569
-
570
- /**
571
- * Protocol Buffer Encoder with type validation.
572
- *
573
- * `typia.protobuf.validateEncode()` is a combination function of
574
- * {@link validation} and {@link encode}.
575
- *
576
- * Therefore, it converts an `input` value to a binary data of
577
- * Protocol Buffer, with type validation. If `input` value is not valid, it returns
578
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
579
- * no problem on the `input` value, Protocol Buffer binary data would be stored in
580
- * `data` property of the output {@link IValidation.ISuccess} instance.
581
- *
582
- * If you can trust `input` value, or want to perform other type of validation, use
583
- * below functions intead.
584
- *
585
- * - {@link encode}
586
- * - {@link assertEncode}
587
- * - {@link isEncode}
588
- *
589
- * By the way, you know what? Expression power of Protocol Buffer is not enough strong
590
- * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
591
- * type that is not compatible with Protocol Buffer, this function would throw a
592
- * compilation error.
593
- *
594
- * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
595
- *
596
- * @template T Type of the value input
597
- * @param input A value to encode
598
- * @returns Encoded binary data
599
- *
600
- * @author Jeongho Nam - https://github.com/samchon
601
- */
602
- export function validateEncode<T>(input: unknown): IValidation<Uint8Array>;
603
-
604
- /**
605
- * @internal
606
- */
607
- export function validateEncode(): never {
608
- halt("validateEncode");
609
- }
610
- Object.assign(validateEncode, Namespace.validate());
611
- Object.assign(validateEncode, Namespace.protobuf.encode("validateEncode"));
612
-
613
- /* -----------------------------------------------------------
614
- FACTORY FUNCTIONS
615
- ----------------------------------------------------------- */
616
- /**
617
- * Creates a reusable {@link decode} function.
618
- *
619
- * @danger You must configure the generic argument `T`
620
- * @returns Nothing until you configure the generic argument `T`
621
- * @throws compile error
622
- *
623
- * @author Jeongho Nam - https://github.com/samchon
624
- */
625
- export function createDecode(): never;
626
-
627
- /**
628
- * Creates a reusable {@link decode} function.
629
- *
630
- * @template T Target type
631
- * @returns A reusable `decode` function
632
- *
633
- * @author Jeongho Nam - https://github.com/samchon
634
- */
635
- export function createDecode<T>(): (input: Uint8Array) => Resolved<T>;
636
-
637
- /**
638
- * @internal
639
- */
640
- export function createDecode<T>(): (input: Uint8Array) => Resolved<T> {
641
- halt("createDecode");
642
- }
643
- Object.assign(createDecode, Namespace.protobuf.decode("createDecode"));
644
-
645
- /**
646
- * Creates a reusable {@link isDecode} function.
647
- *
648
- * @danger You must configure the generic argument `T`
649
- * @returns Nothing until you configure the generic argument `T`
650
- * @throws compile error
651
- *
652
- * @author Jeongho Nam - https://github.com/samchon
653
- */
654
- export function createIsDecode(): never;
655
-
656
- /**
657
- * Creates a reusable {@link isDecode} function.
658
- *
659
- * @template T Target type
660
- * @returns A reusable `isDecode` function
661
- *
662
- * @author Jeongho Nam - https://github.com/samchon
663
- */
664
- export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null;
665
-
666
- /**
667
- * @internal
668
- */
669
- export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null {
670
- halt("createIsDecode");
671
- }
672
- Object.assign(createIsDecode, Namespace.is());
673
- Object.assign(createIsDecode, Namespace.protobuf.decode("createIsDecode"));
674
-
675
- /**
676
- * Creates a reusable {@link assertDecode} function.
677
- *
678
- * @danger You must configure the generic argument `T`
679
- * @returns Nothing until you configure the generic argument `T`
680
- * @throws compile error
681
- *
682
- * @author Jeongho Nam - https://github.com/samchon
683
- */
684
- export function createAssertDecode(): never;
685
-
686
- /**
687
- * Creates a reusable {@link assertDecode} function.
688
- *
689
- * @template T Target type
690
- * @returns A reusable `assertDecode` function
691
- *
692
- * @author Jeongho Nam - https://github.com/samchon
693
- */
694
- export function createAssertDecode<T>(): (input: Uint8Array) => Resolved<T>;
695
-
696
- /**
697
- * @internal
698
- */
699
- export function createAssertDecode<T>(): (input: Uint8Array) => Resolved<T> {
700
- halt("createAssertDecode");
701
- }
702
- Object.assign(createAssertDecode, Namespace.assert("createAssertDecode"));
703
- Object.assign(
704
- createAssertDecode,
705
- Namespace.protobuf.decode("createAssertDecode"),
706
- );
707
-
708
- /**
709
- * Creates a reusable {@link validateDecode} function.
710
- *
711
- * @danger You must configure the generic argument `T`
712
- * @returns Nothing until you configure the generic argument `T`
713
- * @throws compile error
714
- *
715
- * @author Jeongho Nam - https://github.com/samchon
716
- */
717
- export function createValidateDecode(): never;
718
-
719
- /**
720
- * Creates a reusable {@link validateDecode} function.
721
- *
722
- * @template T Target type
723
- * @returns A reusable `validateDecode` function
724
- *
725
- * @author Jeongho Nam - https://github.com/samchon
726
- */
727
- export function createValidateDecode<T>(): (
728
- input: Uint8Array,
729
- ) => IValidation<Resolved<T>>;
730
-
731
- /**
732
- * @internal
733
- */
734
- export function createValidateDecode<T>(): (
735
- input: Uint8Array,
736
- ) => IValidation<Resolved<T>> {
737
- halt("createValidateDecode");
738
- }
739
- Object.assign(createValidateDecode, Namespace.validate());
740
- Object.assign(
741
- createValidateDecode,
742
- Namespace.protobuf.decode("createValidateDecode"),
743
- );
744
-
745
- /**
746
- * Creates a reusable {@link encode} function.
747
- *
748
- * @danger You must configure the generic argument `T`
749
- * @returns Nothing until you configure the generic argument `T`
750
- * @throws compile error
751
- *
752
- * @author Jeongho Nam - https://github.com/samchon
753
- */
754
- export function createEncode(): never;
755
-
756
- /**
757
- * Creates a reusable {@link encode} function.
758
- *
759
- * @template T Target type
760
- * @returns A reusable `encode` function
761
- *
762
- * @author Jeongho Nam - https://github.com/samchon
763
- */
764
- export function createEncode<T>(): (input: T) => Uint8Array;
765
-
766
- /**
767
- * @internal
768
- */
769
- export function createEncode<T>(): (input: T) => Uint8Array {
770
- halt("createEncode");
771
- }
772
- Object.assign(createEncode, Namespace.protobuf.encode("createEncode"));
773
-
774
- /**
775
- * Creates a reusable {@link isEncode} function.
776
- *
777
- * @danger You must configure the generic argument `T`
778
- * @returns Nothing until you configure the generic argument `T`
779
- * @throws compile error
780
- *
781
- * @author Jeongho Nam - https://github.com/samchon
782
- */
783
- export function createIsEncode(): never;
784
-
785
- /**
786
- * Creates a reusable {@link isEncode} function.
787
- *
788
- * @template T Target type
789
- * @returns A reusable `isEncode` function
790
- *
791
- * @author Jeongho Nam - https://github.com/samchon
792
- */
793
- export function createIsEncode<T>(): (input: T) => Uint8Array | null;
794
-
795
- /**
796
- * @internal
797
- */
798
- export function createIsEncode<T>(): (input: T) => Uint8Array | null {
799
- halt("createIsEncode");
800
- }
801
- Object.assign(createIsEncode, Namespace.is());
802
- Object.assign(createIsEncode, Namespace.protobuf.encode("createIsEncode"));
803
-
804
- /**
805
- * Creates a reusable {@link assertEncode} function.
806
- *
807
- * @danger You must configure the generic argument `T`
808
- * @returns Nothing until you configure the generic argument `T`
809
- * @throws compile error
810
- *
811
- * @author Jeongho Nam - https://github.com/samchon
812
- */
813
- export function createAssertEncode(): never;
814
-
815
- /**
816
- * Creates a reusable {@link assertEncode} function.
817
- *
818
- * @template T Target type
819
- * @returns A reusable `assertEncode` function
820
- *
821
- * @author Jeongho Nam - https://github.com/samchon
822
- */
823
- export function createAssertEncode<T>(): (input: T) => Uint8Array;
824
-
825
- /**
826
- * @internal
827
- */
828
- export function createAssertEncode<T>(): (input: T) => Uint8Array {
829
- halt("createAssertEncode");
830
- }
831
- Object.assign(createAssertEncode, Namespace.assert("createAssertEncode"));
832
- Object.assign(
833
- createAssertEncode,
834
- Namespace.protobuf.encode("createAssertEncode"),
835
- );
836
-
837
- /**
838
- * Creates a reusable {@link validateEncode} function.
839
- *
840
- * @danger You must configure the generic argument `T`
841
- * @returns Nothing until you configure the generic argument `T`
842
- * @throws compile error
843
- *
844
- * @author Jeongho Nam - https://github.com/samchon
845
- */
846
- export function createValidateEncode(): never;
847
-
848
- /**
849
- * Creates a reusable {@link validateEncode} function.
850
- *
851
- * @template T Target type
852
- * @returns A reusable `validateEncode` function
853
- *
854
- * @author Jeongho Nam - https://github.com/samchon
855
- */
856
- export function createValidateEncode<T>(): (
857
- input: T,
858
- ) => IValidation<Uint8Array>;
859
-
860
- /**
861
- * @internal
862
- */
863
- export function createValidateEncode<T>(): (
864
- input: T,
865
- ) => IValidation<Uint8Array> {
866
- halt("createValidateEncode");
867
- }
868
- Object.assign(createValidateEncode, Namespace.validate());
869
- Object.assign(
870
- createValidateEncode,
871
- Namespace.protobuf.encode("createValidateEncode"),
872
- );
873
-
874
- /**
875
- * @internal
876
- */
877
- function halt(name: string): never {
878
- throw new Error(
879
- `Error on typia.protobuf.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
880
- );
881
- }
1
+ import { Namespace } from "./functional/Namespace";
2
+
3
+ import { IValidation } from "./IValidation";
4
+ import { Resolved } from "./Resolved";
5
+
6
+ /* ===========================================================
7
+ PROTOCOL BUFFER
8
+ - MESSAGE
9
+ - DECODE
10
+ - ENCODE
11
+ - FACTORY FUNCTIONS
12
+ ==============================================================
13
+ SCHEMA
14
+ ----------------------------------------------------------- */
15
+ /**
16
+ * > You must configure the generic argument `T`.
17
+ *
18
+ * Protocol Buffer Message Schema.
19
+ *
20
+ * Creates a Protocol Buffer Message Schema from a TypeScript type. The message
21
+ * schema would be returned as a string value, and it can be used to share with
22
+ * other developers/languages/frameworks.
23
+ *
24
+ * For reference, Protocol Buffer has lots of restrictions, so that expression power
25
+ * of Protocol Buffer is not enough strong to fully meet the TypeScript type specs.
26
+ * In such reason, if you put a TypeScript type that is not compatible with Protocol
27
+ * Buffer, this function would throw a compilation error.
28
+ *
29
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
30
+ *
31
+ * @template T Target type
32
+ * @returns Protocol Buffer Message Schema.
33
+ *
34
+ * @author Jeongho Nam - https://github.com/samchon
35
+ */
36
+ export function message(): never;
37
+
38
+ /**
39
+ * Protocol Buffer Message Schema.
40
+ *
41
+ * Creates a Protocol Buffer Message Schema from a TypeScript type. The message
42
+ * schema would be returned as a string value, and it can be used to share with
43
+ * other developers/languages/frameworks.
44
+ *
45
+ * For reference, Protocol Buffer has lots of restrictions, so that expression power
46
+ * of Protocol Buffer is not enough strong to fully meet the TypeScript type specs.
47
+ * In such reason, if you put a TypeScript type that is not compatible with Protocol
48
+ * Buffer, this function would throw a compilation error.
49
+ *
50
+ * @template T Target type
51
+ * @returns Protocol Buffer Message Schema.
52
+ *
53
+ * @author Jeongho Nam - https://github.com/samchon
54
+ */
55
+ export function message<T>(): string;
56
+
57
+ /**
58
+ * @internal
59
+ */
60
+ export function message(): never {
61
+ halt("message");
62
+ }
63
+
64
+ /* -----------------------------------------------------------
65
+ DECODE
66
+ ----------------------------------------------------------- */
67
+ /**
68
+ * > You must configure the generic argument `T`.
69
+ *
70
+ * Protocol Buffer Decoder.
71
+ *
72
+ * `typia.protobuf.decode()` is a function decoding a binary data of Protocol Buffer
73
+ * format to a TypeScript instance.
74
+ *
75
+ * For reference, as Protocol Buffer handles binary data directly, there's no way
76
+ * when `input` binary data was not encoded from the `T` typed value. In that case,
77
+ * unexpected behavior or internal error would be occured. Therefore, I recommend you
78
+ * to encode binary data of Protocol Buffer from type safe encode functions like below.
79
+ * Use {@link encode} function only when you can ensure it.
80
+ *
81
+ * - {@link assertEncode}
82
+ * - {@link isEncode}
83
+ * - {@link validateEncode}
84
+ *
85
+ * Also, `typia` is providing type safe decoders like {@link assertDecode}, but it
86
+ * is just for additional type validation like `number & Minimum<7>` or
87
+ * `string & Format<"uuid">` cases, that are represented by
88
+ * [custom tags](https://typia.io/docs/validators/tags). Thus, I repeat that,
89
+ * you've to ensure the type safety when using decoder functions.
90
+ *
91
+ * @tempate Expected type of decoded value
92
+ * @param input Protobuf Buffer binary data
93
+ * @returns Decoded value
94
+ *
95
+ * @author Jeongho Nam - https://github.com/samchon
96
+ */
97
+ export function decode(input: Uint8Array): never;
98
+
99
+ /**
100
+ * Protocol Buffer Decoder.
101
+ *
102
+ * `typia.protobuf.decode()` is a function decoding a binary data of Protocol Buffer
103
+ * format to a TypeScript instance.
104
+ *
105
+ * For reference, as Protocol Buffer handles binary data directly, there's no way
106
+ * when `input` binary data was not encoded from the `T` typed value. In that case,
107
+ * unexpected behavior or internal error would be occured. Therefore, I recommend you
108
+ * to encode binary data of Protocol Buffer from type safe encode functions like below.
109
+ * Use {@link encode} function only when you can ensure it.
110
+ *
111
+ * - {@link assertEncode}
112
+ * - {@link isEncode}
113
+ * - {@link validateEncode}
114
+ *
115
+ * Also, `typia` is providing type safe decoders like {@link assertDecode}, but it
116
+ * is just for additional type validation like `number & Minimum<7>` or
117
+ * `string & Format<"uuid">` cases, that are represented by
118
+ * [custom tags](https://typia.io/docs/validators/tags). Thus, I repeat that,
119
+ * you've to ensure the type safety when using decoder functions.
120
+ *
121
+ * @tempate Expected type of decoded value
122
+ * @param input Protobuf Buffer binary data
123
+ * @returns Decoded value
124
+ *
125
+ * @author Jeongho Nam - https://github.com/samchon
126
+ */
127
+ export function decode<T>(input: Uint8Array): Resolved<T>;
128
+
129
+ /**
130
+ * @internal
131
+ */
132
+ export function decode(): never {
133
+ halt("decode");
134
+ }
135
+ Object.assign(decode, Namespace.protobuf.decode("decode"));
136
+
137
+ /**
138
+ * > You must configure the generic argument `T`.
139
+ *
140
+ * Protocol Buffer Decoder wity type assertion, but not safe.
141
+ *
142
+ * `typia.protobuf.assertDecode()` is a combination function of {@link decode} and
143
+ * {@link assert} function. Therefore, it decodes a binary data of Protocol Buffer to
144
+ * a TypeScript instance, and performs type assertion process. If decoded value is
145
+ * following the type `T`, it returns the decoded value. Otherwise, it throws
146
+ * {@link TypeGuardError} instead.
147
+ *
148
+ * However, note that, this validation is not always safe. It just performs additional
149
+ * type assertion like `number & Minimum<7>` or `string & Format<"uuid">` cases,
150
+ * that are represented by [custom tags](https://typia.io/docs/validators/tags).
151
+ * Therefore, when using `typia.protobuf.assertDecode<T>()` function, you have to
152
+ * ensure the type safety by yourself.
153
+ *
154
+ * In such type safety reason, I recommend you to use type safe encode functions.
155
+ *
156
+ * - {@link assertEncode}
157
+ * - {@link isEncode}
158
+ * - {@link validateEncode}
159
+ *
160
+ * @tempate Expected type of decoded value
161
+ * @param input Protobuf Buffer binary data
162
+ * @returns Decoded value
163
+ *
164
+ * @author Jeongho Nam - https://github.com/samchon
165
+ */
166
+ export function assertDecode(input: Uint8Array): never;
167
+
168
+ /**
169
+ * Protocol Buffer Decoder wity type assertion, but not safe.
170
+ *
171
+ * `typia.protobuf.assertDecode()` is a combination function of {@link decode} and
172
+ * {@link assert} function. Therefore, it decodes a binary data of Protocol Buffer to
173
+ * a TypeScript instance, and performs type assertion process. If decoded value is
174
+ * following the type `T`, it returns the decoded value. Otherwise, it throws
175
+ * {@link TypeGuardError} instead.
176
+ *
177
+ * However, note that, this validation is not always safe. It just performs additional
178
+ * type assertion like `number & Minimum<7>` or `string & Format<"uuid">` cases,
179
+ * that are represented by [custom tags](https://typia.io/docs/validators/tags).
180
+ * Therefore, when using `typia.protobuf.assertDecode<T>()` function, you have to
181
+ * ensure the type safety by yourself.
182
+ *
183
+ * In such type safety reason, I recommend you to use type safe encode functions.
184
+ *
185
+ * - {@link assertEncode}
186
+ * - {@link isEncode}
187
+ * - {@link validateEncode}
188
+ *
189
+ * @tempate Expected type of decoded value
190
+ * @param input Protobuf Buffer binary data
191
+ * @returns Decoded value
192
+ *
193
+ * @author Jeongho Nam - https://github.com/samchon
194
+ */
195
+ export function assertDecode<T>(input: Uint8Array): Resolved<T>;
196
+
197
+ /**
198
+ * @internal
199
+ */
200
+ export function assertDecode(): never {
201
+ halt("assertDecode");
202
+ }
203
+ Object.assign(assertDecode, Namespace.assert("assertDecode"));
204
+ Object.assign(assertDecode, Namespace.protobuf.decode("assertDecode"));
205
+
206
+ /**
207
+ * > You must configure the generic argument `T`.
208
+ *
209
+ * Protocol Buffer Decoder wity type checking, but not safe.
210
+ *
211
+ * `typia.protobuf.isDecode()` is a combination function of {@link decode} and
212
+ * {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
213
+ * a TypeScript instance, and performs type checking process. If decoded value is
214
+ * following the type `T`, it returns the decoded value. Otherwise, it returns
215
+ * `null` value instead.
216
+ *
217
+ * However, note that, this validation is not always safe. It just performs additional
218
+ * type checking like `number & Minimum<7>` or `string & Format<"uuid">` cases,
219
+ * that are represented by [custom tags](https://typia.io/docs/validators/tags).
220
+ * Therefore, when using `typia.protobuf.isDecode<T>()` function, you have to
221
+ * ensure the type safety by yourself.
222
+ *
223
+ * In such type safety reason, I recommend you to use type safe encode functions.
224
+ *
225
+ * - {@link assertEncode}
226
+ * - {@link isEncode}
227
+ * - {@link validateEncode}
228
+ *
229
+ * @tempate Expected type of decoded value
230
+ * @param input Protobuf Buffer binary data
231
+ * @returns Decoded value
232
+ *
233
+ * @author Jeongho Nam - https://github.com/samchon
234
+ */
235
+ export function isDecode(input: Uint8Array): never;
236
+
237
+ /**
238
+ * Protocol Buffer Decoder wity type checking, but not safe.
239
+ *
240
+ * `typia.protobuf.isDecode()` is a combination function of {@link decode} and
241
+ * {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
242
+ * a TypeScript instance, and performs type checking process. If decoded value is
243
+ * following the type `T`, it returns the decoded value. Otherwise, it returns
244
+ * `null` value instead.
245
+ *
246
+ * However, note that, this validation is not always safe. It just performs additional
247
+ * type checking like `number & Minimum<7>` or `string & Format<"uuid">` cases,
248
+ * that are represented by [custom tags](https://typia.io/docs/validators/tags).
249
+ * Therefore, when using `typia.protobuf.isDecode<T>()` function, you have to
250
+ * ensure the type safety by yourself.
251
+ *
252
+ * In such type safety reason, I recommend you to use type safe encode functions.
253
+ *
254
+ * - {@link assertEncode}
255
+ * - {@link isEncode}
256
+ * - {@link validateEncode}
257
+ *
258
+ * @tempate Expected type of decoded value
259
+ * @param input Protobuf Buffer binary data
260
+ * @returns Decoded value
261
+ *
262
+ * @author Jeongho Nam - https://github.com/samchon
263
+ */
264
+ export function isDecode<T>(input: Uint8Array): Resolved<T> | null;
265
+
266
+ /**
267
+ * @internal
268
+ */
269
+ export function isDecode(): never {
270
+ halt("isDecode");
271
+ }
272
+ Object.assign(isDecode, Namespace.is());
273
+ Object.assign(isDecode, Namespace.protobuf.decode("isDecode"));
274
+
275
+ /**
276
+ * > You must configure the generic argument `T`.
277
+ *
278
+ * Protocol Buffer Decoder wity type validation, but not safe.
279
+ *
280
+ * `typia.protobuf.validateDecode()` is a combination function of {@link decode} and
281
+ * {@link validate} function. Therefore, it decodes a binary data of Protocol Buffer to
282
+ * a TypeScript instance, and performs type validation process. If decoded value is
283
+ * following the type `T`, it returns the decoded value with
284
+ * {@link IValidation.ISuccess} typed instance. Otherwise, it returns
285
+ * {@link IValidation.IFailure} value instead with detailed error reasons.
286
+ *
287
+ * However, note that, this validation is not always safe. It just performs additional
288
+ * type validation like `number & Minimum<7>` or `string & Format<"uuid">` cases,
289
+ * that are represented by [custom tags](https://typia.io/docs/validators/tags).
290
+ * Therefore, when using `typia.protobuf.validateDecode<T>()` function, you have to
291
+ * ensure the type safety by yourself.
292
+ *
293
+ * In such type safety reason, I recommend you to use type safe encode functions.
294
+ *
295
+ * - {@link assertEncode}
296
+ * - {@link isEncode}
297
+ * - {@link validateEncode}
298
+ *
299
+ * @tempate Expected type of decoded value
300
+ * @param input Protobuf Buffer binary data
301
+ * @returns Decoded value
302
+ *
303
+ * @author Jeongho Nam - https://github.com/samchon
304
+ */
305
+ export function validateDecode(input: Uint8Array): never;
306
+
307
+ /**
308
+ * Protocol Buffer Decoder wity type validation, but not safe.
309
+ *
310
+ * `typia.protobuf.validateDecode()` is a combination function of {@link decode} and
311
+ * {@link validate} function. Therefore, it decodes a binary data of Protocol Buffer to
312
+ * a TypeScript instance, and performs type validation process. If decoded value is
313
+ * following the type `T`, it returns the decoded value with
314
+ * {@link IValidation.ISuccess} typed instance. Otherwise, it returns
315
+ * {@link IValidation.IFailure} value instead with detailed error reasons.
316
+ *
317
+ * However, note that, this validation is not always safe. It just performs additional
318
+ * type validation like `number & Minimum<7>` or `string & Format<"uuid">` cases,
319
+ * that are represented by [custom tags](https://typia.io/docs/validators/tags).
320
+ * Therefore, when using `typia.protobuf.validateDecode<T>()` function, you have to
321
+ * ensure the type safety by yourself.
322
+ *
323
+ * In such type safety reason, I recommend you to use type safe encode functions.
324
+ *
325
+ * - {@link assertEncode}
326
+ * - {@link isEncode}
327
+ * - {@link validateEncode}
328
+ *
329
+ * @tempate Expected type of decoded value
330
+ * @param input Protobuf Buffer binary data
331
+ * @returns Decoded value
332
+ *
333
+ * @author Jeongho Nam - https://github.com/samchon
334
+ */
335
+ export function validateDecode<T>(input: Uint8Array): IValidation<Resolved<T>>;
336
+
337
+ /**
338
+ * @internal
339
+ */
340
+ export function validateDecode(): never {
341
+ halt("validateDecode");
342
+ }
343
+ Object.assign(validateDecode, Namespace.validate());
344
+ Object.assign(validateDecode, Namespace.protobuf.decode("validateDecode"));
345
+
346
+ /* -----------------------------------------------------------
347
+ ENCODE
348
+ ----------------------------------------------------------- */
349
+ /**
350
+ * Protocol Buffer Encoder.
351
+ *
352
+ * Converts an input value to a binary data of Protocol Buffer format.
353
+ *
354
+ * For reference, this `typia.protobuf.encode()` does not validate the `input` value.
355
+ * It just believes that the `input` value is valid and converts it to a binary data
356
+ * directly. Therefore, if you can't ensure the `input` value type, it would better to
357
+ * call one of below functions intead.
358
+ *
359
+ * - {@link assertEncode}
360
+ * - {@link isEncode}
361
+ * - {@link validateEncode}
362
+ *
363
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
364
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
365
+ * type that is not compatible with Protocol Buffer, this function would throw a
366
+ * compilation error.
367
+ *
368
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
369
+ *
370
+ * @template T Type of the value input
371
+ * @param input A value to encode
372
+ * @returns Encoded binary data
373
+ *
374
+ * @author Jeongho Nam - https://github.com/samchon
375
+ */
376
+ export function encode<T>(input: T): Uint8Array;
377
+
378
+ /**
379
+ * @internal
380
+ */
381
+ export function encode(): never {
382
+ halt("encode");
383
+ }
384
+ Object.assign(encode, Namespace.protobuf.encode("encode"));
385
+
386
+ /**
387
+ * Protocol Buffer Encoder with type assertion.
388
+ *
389
+ * `typia.protobuf.assertEncode()` is a combination function of {@link assert} and
390
+ * {@link encode}.
391
+ *
392
+ * Therefore, it converts an `input` value to a binary data of
393
+ * Protocol Buffer, with type assertion. If `input` value is not valid, it throws
394
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value,
395
+ * Protocol Buffer binary data would be returned.
396
+ *
397
+ * If you can trust `input` value, or want to perform other type of validation, use
398
+ * below functions intead.
399
+ *
400
+ * - {@link encode}
401
+ * - {@link isEncode}
402
+ * - {@link validateEncode}
403
+ *
404
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
405
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
406
+ * type that is not compatible with Protocol Buffer, this function would throw a
407
+ * compilation error.
408
+ *
409
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
410
+ *
411
+ * @template T Type of the value input
412
+ * @param input A value to encode
413
+ * @returns Encoded binary data
414
+ *
415
+ * @author Jeongho Nam - https://github.com/samchon
416
+ */
417
+ export function assertEncode<T>(input: T): Uint8Array;
418
+
419
+ /**
420
+ * Protocol Buffer Encoder with type assertion.
421
+ *
422
+ * `typia.protobuf.assertEncode()` is a combination function of {@link assert} and
423
+ * {@link encode}.
424
+ *
425
+ * Therefore, it converts an `input` value to a binary data of
426
+ * Protocol Buffer, with type assertion. If `input` value is not valid, it throws
427
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value,
428
+ * Protocol Buffer binary data would be returned.
429
+ *
430
+ * If you can trust `input` value, or want to perform other type of validation, use
431
+ * below functions intead.
432
+ *
433
+ * - {@link encode}
434
+ * - {@link isEncode}
435
+ * - {@link validateEncode}
436
+ *
437
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
438
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
439
+ * type that is not compatible with Protocol Buffer, this function would throw a
440
+ * compilation error.
441
+ *
442
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
443
+ *
444
+ * @template T Type of the value input
445
+ * @param input A value to encode
446
+ * @returns Encoded binary data
447
+ *
448
+ * @author Jeongho Nam - https://github.com/samchon
449
+ */
450
+ export function assertEncode<T>(input: unknown): Uint8Array;
451
+
452
+ /**
453
+ * @internal
454
+ */
455
+ export function assertEncode(): never {
456
+ halt("assertEncode");
457
+ }
458
+ Object.assign(assertEncode, Namespace.assert("assertEncode"));
459
+ Object.assign(assertEncode, Namespace.protobuf.encode("assertEncode"));
460
+
461
+ /**
462
+ * Protocol Buffer Encoder with type checking.
463
+ *
464
+ * `typia.protobuf.isEncode()` is a combination function of {@link is} and
465
+ * {@link encode}.
466
+ *
467
+ * Therefore, it converts an `input` value to a binary data of
468
+ * Protocol Buffer, with type checking. If `input` value is not valid, it returns
469
+ * `null` value. Otherwise, there's no problem on the `input` value, Protocol
470
+ * Buffer binary data would be returned.
471
+ *
472
+ * If you can trust `input` value, or want to perform other type of validation, use
473
+ * below functions intead.
474
+ *
475
+ * - {@link encode}
476
+ * - {@link assertEncode}
477
+ * - {@link validateEncode}
478
+ *
479
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
480
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
481
+ * type that is not compatible with Protocol Buffer, this function would throw a
482
+ * compilation error.
483
+ *
484
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
485
+ *
486
+ * @template T Type of the value input
487
+ * @param input A value to encode
488
+ * @returns Encoded binary data
489
+ *
490
+ * @author Jeongho Nam - https://github.com/samchon
491
+ */
492
+ export function isEncode<T>(input: T): Uint8Array | null;
493
+
494
+ /**
495
+ * Protocol Buffer Encoder with type checking.
496
+ *
497
+ * `typia.protobuf.isEncode()` is a combination function of {@link is} and
498
+ * {@link encode}.
499
+ *
500
+ * Therefore, it converts an `input` value to a binary data of
501
+ * Protocol Buffer, with type checking. If `input` value is not valid, it returns
502
+ * `null` value. Otherwise, there's no problem on the `input` value, Protocol
503
+ * Buffer binary data would be returned.
504
+ *
505
+ * If you can trust `input` value, or want to perform other type of validation, use
506
+ * below functions intead.
507
+ *
508
+ * - {@link encode}
509
+ * - {@link assertEncode}
510
+ * - {@link validateEncode}
511
+ *
512
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
513
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
514
+ * type that is not compatible with Protocol Buffer, this function would throw a
515
+ * compilation error.
516
+ *
517
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
518
+ *
519
+ * @template T Type of the value input
520
+ * @param input A value to encode
521
+ * @returns Encoded binary data
522
+ *
523
+ * @author Jeongho Nam - https://github.com/samchon
524
+ */
525
+ export function isEncode<T>(input: unknown): Uint8Array | null;
526
+
527
+ /**
528
+ * @internal
529
+ */
530
+ export function isEncode(): never {
531
+ halt("isEncode");
532
+ }
533
+ Object.assign(isEncode, Namespace.is());
534
+ Object.assign(isEncode, Namespace.protobuf.encode("isEncode"));
535
+
536
+ /**
537
+ * Protocol Buffer Encoder with type validation.
538
+ *
539
+ * `typia.protobuf.validateEncode()` is a combination function of
540
+ * {@link validation} and {@link encode}.
541
+ *
542
+ * Therefore, it converts an `input` value to a binary data of
543
+ * Protocol Buffer, with type validation. If `input` value is not valid, it returns
544
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
545
+ * no problem on the `input` value, Protocol Buffer binary data would be stored in
546
+ * `data` property of the output {@link IValidation.ISuccess} instance.
547
+ *
548
+ * If you can trust `input` value, or want to perform other type of validation, use
549
+ * below functions intead.
550
+ *
551
+ * - {@link encode}
552
+ * - {@link assertEncode}
553
+ * - {@link isEncode}
554
+ *
555
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
556
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
557
+ * type that is not compatible with Protocol Buffer, this function would throw a
558
+ * compilation error.
559
+ *
560
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
561
+ *
562
+ * @template T Type of the value input
563
+ * @param input A value to encode
564
+ * @returns Encoded binary data
565
+ *
566
+ * @author Jeongho Nam - https://github.com/samchon
567
+ */
568
+ export function validateEncode<T>(input: T): IValidation<Uint8Array>;
569
+
570
+ /**
571
+ * Protocol Buffer Encoder with type validation.
572
+ *
573
+ * `typia.protobuf.validateEncode()` is a combination function of
574
+ * {@link validation} and {@link encode}.
575
+ *
576
+ * Therefore, it converts an `input` value to a binary data of
577
+ * Protocol Buffer, with type validation. If `input` value is not valid, it returns
578
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise, there's
579
+ * no problem on the `input` value, Protocol Buffer binary data would be stored in
580
+ * `data` property of the output {@link IValidation.ISuccess} instance.
581
+ *
582
+ * If you can trust `input` value, or want to perform other type of validation, use
583
+ * below functions intead.
584
+ *
585
+ * - {@link encode}
586
+ * - {@link assertEncode}
587
+ * - {@link isEncode}
588
+ *
589
+ * By the way, you know what? Expression power of Protocol Buffer is not enough strong
590
+ * to fully meet the TypeScript type specs. In such reason, if you put a TypeScript
591
+ * type that is not compatible with Protocol Buffer, this function would throw a
592
+ * compilation error.
593
+ *
594
+ * - [Restrictions of Protocol Buffer](https://typia.io/docs/protobuf/message/#restrictions)
595
+ *
596
+ * @template T Type of the value input
597
+ * @param input A value to encode
598
+ * @returns Encoded binary data
599
+ *
600
+ * @author Jeongho Nam - https://github.com/samchon
601
+ */
602
+ export function validateEncode<T>(input: unknown): IValidation<Uint8Array>;
603
+
604
+ /**
605
+ * @internal
606
+ */
607
+ export function validateEncode(): never {
608
+ halt("validateEncode");
609
+ }
610
+ Object.assign(validateEncode, Namespace.validate());
611
+ Object.assign(validateEncode, Namespace.protobuf.encode("validateEncode"));
612
+
613
+ /* -----------------------------------------------------------
614
+ FACTORY FUNCTIONS
615
+ ----------------------------------------------------------- */
616
+ /**
617
+ * Creates a reusable {@link decode} function.
618
+ *
619
+ * @danger You must configure the generic argument `T`
620
+ * @returns Nothing until you configure the generic argument `T`
621
+ * @throws compile error
622
+ *
623
+ * @author Jeongho Nam - https://github.com/samchon
624
+ */
625
+ export function createDecode(): never;
626
+
627
+ /**
628
+ * Creates a reusable {@link decode} function.
629
+ *
630
+ * @template T Target type
631
+ * @returns A reusable `decode` function
632
+ *
633
+ * @author Jeongho Nam - https://github.com/samchon
634
+ */
635
+ export function createDecode<T>(): (input: Uint8Array) => Resolved<T>;
636
+
637
+ /**
638
+ * @internal
639
+ */
640
+ export function createDecode<T>(): (input: Uint8Array) => Resolved<T> {
641
+ halt("createDecode");
642
+ }
643
+ Object.assign(createDecode, Namespace.protobuf.decode("createDecode"));
644
+
645
+ /**
646
+ * Creates a reusable {@link isDecode} function.
647
+ *
648
+ * @danger You must configure the generic argument `T`
649
+ * @returns Nothing until you configure the generic argument `T`
650
+ * @throws compile error
651
+ *
652
+ * @author Jeongho Nam - https://github.com/samchon
653
+ */
654
+ export function createIsDecode(): never;
655
+
656
+ /**
657
+ * Creates a reusable {@link isDecode} function.
658
+ *
659
+ * @template T Target type
660
+ * @returns A reusable `isDecode` function
661
+ *
662
+ * @author Jeongho Nam - https://github.com/samchon
663
+ */
664
+ export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null;
665
+
666
+ /**
667
+ * @internal
668
+ */
669
+ export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null {
670
+ halt("createIsDecode");
671
+ }
672
+ Object.assign(createIsDecode, Namespace.is());
673
+ Object.assign(createIsDecode, Namespace.protobuf.decode("createIsDecode"));
674
+
675
+ /**
676
+ * Creates a reusable {@link assertDecode} function.
677
+ *
678
+ * @danger You must configure the generic argument `T`
679
+ * @returns Nothing until you configure the generic argument `T`
680
+ * @throws compile error
681
+ *
682
+ * @author Jeongho Nam - https://github.com/samchon
683
+ */
684
+ export function createAssertDecode(): never;
685
+
686
+ /**
687
+ * Creates a reusable {@link assertDecode} function.
688
+ *
689
+ * @template T Target type
690
+ * @returns A reusable `assertDecode` function
691
+ *
692
+ * @author Jeongho Nam - https://github.com/samchon
693
+ */
694
+ export function createAssertDecode<T>(): (input: Uint8Array) => Resolved<T>;
695
+
696
+ /**
697
+ * @internal
698
+ */
699
+ export function createAssertDecode<T>(): (input: Uint8Array) => Resolved<T> {
700
+ halt("createAssertDecode");
701
+ }
702
+ Object.assign(createAssertDecode, Namespace.assert("createAssertDecode"));
703
+ Object.assign(
704
+ createAssertDecode,
705
+ Namespace.protobuf.decode("createAssertDecode"),
706
+ );
707
+
708
+ /**
709
+ * Creates a reusable {@link validateDecode} function.
710
+ *
711
+ * @danger You must configure the generic argument `T`
712
+ * @returns Nothing until you configure the generic argument `T`
713
+ * @throws compile error
714
+ *
715
+ * @author Jeongho Nam - https://github.com/samchon
716
+ */
717
+ export function createValidateDecode(): never;
718
+
719
+ /**
720
+ * Creates a reusable {@link validateDecode} function.
721
+ *
722
+ * @template T Target type
723
+ * @returns A reusable `validateDecode` function
724
+ *
725
+ * @author Jeongho Nam - https://github.com/samchon
726
+ */
727
+ export function createValidateDecode<T>(): (
728
+ input: Uint8Array,
729
+ ) => IValidation<Resolved<T>>;
730
+
731
+ /**
732
+ * @internal
733
+ */
734
+ export function createValidateDecode<T>(): (
735
+ input: Uint8Array,
736
+ ) => IValidation<Resolved<T>> {
737
+ halt("createValidateDecode");
738
+ }
739
+ Object.assign(createValidateDecode, Namespace.validate());
740
+ Object.assign(
741
+ createValidateDecode,
742
+ Namespace.protobuf.decode("createValidateDecode"),
743
+ );
744
+
745
+ /**
746
+ * Creates a reusable {@link encode} function.
747
+ *
748
+ * @danger You must configure the generic argument `T`
749
+ * @returns Nothing until you configure the generic argument `T`
750
+ * @throws compile error
751
+ *
752
+ * @author Jeongho Nam - https://github.com/samchon
753
+ */
754
+ export function createEncode(): never;
755
+
756
+ /**
757
+ * Creates a reusable {@link encode} function.
758
+ *
759
+ * @template T Target type
760
+ * @returns A reusable `encode` function
761
+ *
762
+ * @author Jeongho Nam - https://github.com/samchon
763
+ */
764
+ export function createEncode<T>(): (input: T) => Uint8Array;
765
+
766
+ /**
767
+ * @internal
768
+ */
769
+ export function createEncode<T>(): (input: T) => Uint8Array {
770
+ halt("createEncode");
771
+ }
772
+ Object.assign(createEncode, Namespace.protobuf.encode("createEncode"));
773
+
774
+ /**
775
+ * Creates a reusable {@link isEncode} function.
776
+ *
777
+ * @danger You must configure the generic argument `T`
778
+ * @returns Nothing until you configure the generic argument `T`
779
+ * @throws compile error
780
+ *
781
+ * @author Jeongho Nam - https://github.com/samchon
782
+ */
783
+ export function createIsEncode(): never;
784
+
785
+ /**
786
+ * Creates a reusable {@link isEncode} function.
787
+ *
788
+ * @template T Target type
789
+ * @returns A reusable `isEncode` function
790
+ *
791
+ * @author Jeongho Nam - https://github.com/samchon
792
+ */
793
+ export function createIsEncode<T>(): (input: T) => Uint8Array | null;
794
+
795
+ /**
796
+ * @internal
797
+ */
798
+ export function createIsEncode<T>(): (input: T) => Uint8Array | null {
799
+ halt("createIsEncode");
800
+ }
801
+ Object.assign(createIsEncode, Namespace.is());
802
+ Object.assign(createIsEncode, Namespace.protobuf.encode("createIsEncode"));
803
+
804
+ /**
805
+ * Creates a reusable {@link assertEncode} function.
806
+ *
807
+ * @danger You must configure the generic argument `T`
808
+ * @returns Nothing until you configure the generic argument `T`
809
+ * @throws compile error
810
+ *
811
+ * @author Jeongho Nam - https://github.com/samchon
812
+ */
813
+ export function createAssertEncode(): never;
814
+
815
+ /**
816
+ * Creates a reusable {@link assertEncode} function.
817
+ *
818
+ * @template T Target type
819
+ * @returns A reusable `assertEncode` function
820
+ *
821
+ * @author Jeongho Nam - https://github.com/samchon
822
+ */
823
+ export function createAssertEncode<T>(): (input: T) => Uint8Array;
824
+
825
+ /**
826
+ * @internal
827
+ */
828
+ export function createAssertEncode<T>(): (input: T) => Uint8Array {
829
+ halt("createAssertEncode");
830
+ }
831
+ Object.assign(createAssertEncode, Namespace.assert("createAssertEncode"));
832
+ Object.assign(
833
+ createAssertEncode,
834
+ Namespace.protobuf.encode("createAssertEncode"),
835
+ );
836
+
837
+ /**
838
+ * Creates a reusable {@link validateEncode} function.
839
+ *
840
+ * @danger You must configure the generic argument `T`
841
+ * @returns Nothing until you configure the generic argument `T`
842
+ * @throws compile error
843
+ *
844
+ * @author Jeongho Nam - https://github.com/samchon
845
+ */
846
+ export function createValidateEncode(): never;
847
+
848
+ /**
849
+ * Creates a reusable {@link validateEncode} function.
850
+ *
851
+ * @template T Target type
852
+ * @returns A reusable `validateEncode` function
853
+ *
854
+ * @author Jeongho Nam - https://github.com/samchon
855
+ */
856
+ export function createValidateEncode<T>(): (
857
+ input: T,
858
+ ) => IValidation<Uint8Array>;
859
+
860
+ /**
861
+ * @internal
862
+ */
863
+ export function createValidateEncode<T>(): (
864
+ input: T,
865
+ ) => IValidation<Uint8Array> {
866
+ halt("createValidateEncode");
867
+ }
868
+ Object.assign(createValidateEncode, Namespace.validate());
869
+ Object.assign(
870
+ createValidateEncode,
871
+ Namespace.protobuf.encode("createValidateEncode"),
872
+ );
873
+
874
+ /**
875
+ * @internal
876
+ */
877
+ function halt(name: string): never {
878
+ throw new Error(
879
+ `Error on typia.protobuf.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
880
+ );
881
+ }