typia 9.7.2 → 10.0.0-dev.20251107
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.
- package/LICENSE +21 -21
- package/README.md +153 -153
- package/lib/factories/ProtobufFactory.js +1 -1
- package/lib/factories/ProtobufFactory.mjs +1 -1
- package/lib/programmers/internal/json_schema_station.d.mts +2 -2
- package/lib/programmers/internal/json_schema_station.d.ts +2 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
- package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
- package/package.json +121 -121
- package/src/AssertionGuard.ts +41 -41
- package/src/CamelCase.ts +75 -75
- package/src/IRandomGenerator.ts +337 -337
- package/src/IReadableURLSearchParams.ts +9 -9
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +90 -90
- package/src/Resolved.ts +72 -72
- package/src/SnakeCase.ts +127 -127
- package/src/TypeGuardError.ts +216 -216
- package/src/factories/MetadataCollection.ts +270 -270
- package/src/factories/MetadataCommentTagFactory.ts +632 -632
- package/src/factories/MetadataFactory.ts +402 -402
- package/src/factories/ProtobufFactory.ts +873 -873
- package/src/functional.ts +705 -705
- package/src/http.ts +972 -972
- package/src/internal/_ProtobufReader.ts +188 -188
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/json.ts +643 -643
- package/src/llm.ts +615 -615
- package/src/misc.ts +594 -594
- package/src/module.ts +889 -889
- package/src/notations.ts +751 -751
- package/src/programmers/FeatureProgrammer.ts +605 -605
- package/src/programmers/ImportProgrammer.ts +179 -179
- package/src/programmers/RandomProgrammer.ts +1195 -1195
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/check_array_length.ts +43 -43
- package/src/programmers/internal/check_bigint.ts +46 -46
- package/src/programmers/internal/check_dynamic_key.ts +197 -197
- package/src/programmers/internal/check_dynamic_properties.ts +231 -231
- package/src/programmers/internal/check_everything.ts +21 -21
- package/src/programmers/internal/check_native.ts +23 -23
- package/src/programmers/internal/check_number.ts +108 -108
- package/src/programmers/internal/check_object.ts +72 -72
- package/src/programmers/internal/check_string.ts +46 -46
- package/src/programmers/internal/check_template.ts +46 -46
- package/src/programmers/internal/check_union_array_like.ts +331 -331
- package/src/programmers/internal/decode_union_object.ts +110 -110
- package/src/programmers/internal/feature_object_entries.ts +59 -59
- package/src/programmers/internal/json_schema_escaped.ts +78 -78
- package/src/programmers/internal/json_schema_object.ts +150 -150
- package/src/programmers/internal/json_schema_station.ts +2 -2
- package/src/programmers/internal/metadata_to_pattern.ts +40 -40
- package/src/programmers/internal/postfix_of_tuple.ts +3 -3
- package/src/programmers/internal/prune_object_properties.ts +69 -69
- package/src/programmers/internal/stringify_dynamic_properties.ts +158 -158
- package/src/programmers/internal/stringify_native.ts +5 -5
- package/src/programmers/internal/stringify_regular_properties.ts +77 -77
- package/src/programmers/internal/template_to_pattern.ts +21 -21
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -21
- package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
- package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
- package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
- package/src/protobuf.ts +820 -820
- package/src/reflect.ts +46 -46
- package/src/schemas/json/IJsonApplication.ts +77 -77
- package/src/schemas/json/IJsonSchemaCollection.ts +212 -212
- package/src/schemas/json/IJsonSchemaUnit.ts +263 -263
- package/src/schemas/metadata/IMetadataTypeTag.ts +14 -14
- package/src/schemas/metadata/Metadata.ts +669 -669
- package/src/schemas/metadata/MetadataAliasType.ts +57 -57
- package/src/schemas/metadata/MetadataApplication.ts +40 -40
- package/src/schemas/metadata/MetadataArray.ts +47 -47
- package/src/schemas/metadata/MetadataArrayType.ts +51 -51
- package/src/schemas/metadata/MetadataAtomic.ts +85 -85
- package/src/schemas/metadata/MetadataEscaped.ts +45 -45
- package/src/schemas/metadata/MetadataFunction.ts +45 -45
- package/src/schemas/metadata/MetadataObject.ts +46 -46
- package/src/schemas/metadata/MetadataObjectType.ts +137 -137
- package/src/schemas/metadata/MetadataParameter.ts +52 -52
- package/src/schemas/metadata/MetadataProperty.ts +53 -53
- package/src/schemas/metadata/MetadataTemplate.ts +78 -78
- package/src/schemas/metadata/MetadataTuple.ts +28 -28
- package/src/schemas/metadata/MetadataTupleType.ts +61 -61
- package/src/tags/Constant.ts +47 -47
- package/src/tags/ContentMediaType.ts +27 -27
- package/src/tags/Default.ts +52 -52
- package/src/tags/Example.ts +56 -56
- package/src/tags/Examples.ts +56 -56
- package/src/tags/ExclusiveMaximum.ts +44 -44
- package/src/tags/ExclusiveMinimum.ts +44 -44
- package/src/tags/Format.ts +78 -78
- package/src/tags/JsonSchemaPlugin.ts +36 -36
- package/src/tags/MaxItems.ts +31 -31
- package/src/tags/MaxLength.ts +25 -25
- package/src/tags/Maximum.ts +39 -39
- package/src/tags/MinItems.ts +31 -31
- package/src/tags/MinLength.ts +25 -25
- package/src/tags/Minimum.ts +39 -39
- package/src/tags/MultipleOf.ts +42 -42
- package/src/tags/Pattern.ts +49 -49
- package/src/tags/Sequence.ts +37 -37
- package/src/tags/TagBase.ts +102 -102
- package/src/tags/Type.ts +64 -64
- package/src/tags/UniqueItems.ts +34 -34
- package/src/tags/internal/FormatCheatSheet.ts +71 -71
- package/src/transformers/ITransformOptions.ts +70 -70
- package/src/transformers/ImportTransformer.ts +253 -253
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -224
- package/src/typings/Equal.ts +18 -18
package/src/protobuf.ts
CHANGED
|
@@ -1,820 +1,820 @@
|
|
|
1
|
-
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
2
|
-
|
|
3
|
-
import { IValidation } from "./IValidation";
|
|
4
|
-
import { Resolved } from "./Resolved";
|
|
5
|
-
import { TypeGuardError } from "./TypeGuardError";
|
|
6
|
-
|
|
7
|
-
/* ===========================================================
|
|
8
|
-
PROTOCOL BUFFER
|
|
9
|
-
- MESSAGE
|
|
10
|
-
- DECODE
|
|
11
|
-
- ENCODE
|
|
12
|
-
- FACTORY FUNCTIONS
|
|
13
|
-
==============================================================
|
|
14
|
-
SCHEMA
|
|
15
|
-
----------------------------------------------------------- */
|
|
16
|
-
/**
|
|
17
|
-
* > You must configure the generic argument `T`.
|
|
18
|
-
*
|
|
19
|
-
* Protocol Buffer Message Schema.
|
|
20
|
-
*
|
|
21
|
-
* Creates a Protocol Buffer Message Schema from a TypeScript type. The message
|
|
22
|
-
* schema would be returned as a string value, and it can be used to share with
|
|
23
|
-
* other developers/languages/frameworks.
|
|
24
|
-
*
|
|
25
|
-
* For reference, Protocol Buffer has lots of restrictions, so that expression
|
|
26
|
-
* power of Protocol Buffer is not enough strong to fully meet the TypeScript
|
|
27
|
-
* type specs. In such reason, if you put a TypeScript type that is not
|
|
28
|
-
* compatible with Protocol Buffer, this function would throw compilation
|
|
29
|
-
* errors.
|
|
30
|
-
*
|
|
31
|
-
* - [Restrictions of Protocol
|
|
32
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
33
|
-
*
|
|
34
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
35
|
-
* @template T Target type
|
|
36
|
-
* @returns Protocol Buffer Message Schema.
|
|
37
|
-
*/
|
|
38
|
-
export function message(): never;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Protocol Buffer Message Schema.
|
|
42
|
-
*
|
|
43
|
-
* Creates a Protocol Buffer Message Schema from a TypeScript type. The message
|
|
44
|
-
* schema would be returned as a string value, and it can be used to share with
|
|
45
|
-
* other developers/languages/frameworks.
|
|
46
|
-
*
|
|
47
|
-
* For reference, Protocol Buffer has lots of restrictions, so that expression
|
|
48
|
-
* power of Protocol Buffer is not enough strong to fully meet the TypeScript
|
|
49
|
-
* type specs. In such reason, if you put a TypeScript type that is not
|
|
50
|
-
* compatible with Protocol Buffer, this function would throw compilation
|
|
51
|
-
* errors.
|
|
52
|
-
*
|
|
53
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
54
|
-
* @template T Target type
|
|
55
|
-
* @returns Protocol Buffer Message Schema.
|
|
56
|
-
*/
|
|
57
|
-
export function message<T>(): string;
|
|
58
|
-
|
|
59
|
-
/** @internal */
|
|
60
|
-
export function message(): never {
|
|
61
|
-
NoTransformConfigurationError("protobuf.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
|
|
73
|
-
* Buffer format to a TypeScript instance.
|
|
74
|
-
*
|
|
75
|
-
* For reference, as Protocol Buffer handles binary data directly, there's no
|
|
76
|
-
* way when `input` binary data was not encoded from the `T` typed value. In
|
|
77
|
-
* that case, unexpected behavior or internal error would be occurred.
|
|
78
|
-
* Therefore, I recommend you to encode binary data of Protocol Buffer from type
|
|
79
|
-
* safe encode functions like below. Use {@link encode} function only when you
|
|
80
|
-
* can ensure it.
|
|
81
|
-
*
|
|
82
|
-
* - {@link assertEncode}
|
|
83
|
-
* - {@link isEncode}
|
|
84
|
-
* - {@link validateEncode}
|
|
85
|
-
*
|
|
86
|
-
* Also, `typia` is providing type safe decoders like {@link assertDecode}, but
|
|
87
|
-
* it is just for additional type validation like `number & Minimum<7>` or
|
|
88
|
-
* `string & Format<"uuid">` cases, that are represented by [custom
|
|
89
|
-
* tags](https://typia.io/docs/validators/tags). Thus, I repeat that, you've to
|
|
90
|
-
* ensure the type safety when using decoder functions.
|
|
91
|
-
*
|
|
92
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
93
|
-
* @template T Expected type of decoded value
|
|
94
|
-
* @param input Protobuf Buffer binary data
|
|
95
|
-
* @returns Decoded value
|
|
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
|
|
103
|
-
* Buffer format to a TypeScript instance.
|
|
104
|
-
*
|
|
105
|
-
* For reference, as Protocol Buffer handles binary data directly, there's no
|
|
106
|
-
* way when `input` binary data was not encoded from the `T` typed value. In
|
|
107
|
-
* that case, unexpected behavior or internal error would be occurred.
|
|
108
|
-
* Therefore, I recommend you to encode binary data of Protocol Buffer from type
|
|
109
|
-
* safe encode functions like below. Use {@link encode} function only when you
|
|
110
|
-
* can ensure it.
|
|
111
|
-
*
|
|
112
|
-
* - {@link assertEncode}
|
|
113
|
-
* - {@link isEncode}
|
|
114
|
-
* - {@link validateEncode}
|
|
115
|
-
*
|
|
116
|
-
* Also, `typia` is providing type safe decoders like {@link assertDecode}, but
|
|
117
|
-
* it is just for additional type validation like `number & Minimum<7>` or
|
|
118
|
-
* `string & Format<"uuid">` cases, that are represented by [custom
|
|
119
|
-
* tags](https://typia.io/docs/validators/tags). Thus, I repeat that, you've to
|
|
120
|
-
* ensure the type safety when using decoder functions.
|
|
121
|
-
*
|
|
122
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
123
|
-
* @template T Expected type of decoded value
|
|
124
|
-
* @param input Protobuf Buffer binary data
|
|
125
|
-
* @returns Decoded value
|
|
126
|
-
*/
|
|
127
|
-
export function decode<T>(input: Uint8Array): Resolved<T>;
|
|
128
|
-
|
|
129
|
-
/** @internal */
|
|
130
|
-
export function decode(): never {
|
|
131
|
-
NoTransformConfigurationError("protobuf.decode");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* > You must configure the generic argument `T`.
|
|
136
|
-
*
|
|
137
|
-
* Protocol Buffer Decoder wity type assertion, but not safe.
|
|
138
|
-
*
|
|
139
|
-
* `typia.protobuf.assertDecode()` is a combination function of {@link decode}
|
|
140
|
-
* and {@link assert} function. Therefore, it decodes a binary data of Protocol
|
|
141
|
-
* Buffer to a TypeScript instance, and performs type assertion process. If
|
|
142
|
-
* decoded value is following the type `T`, it returns the decoded value.
|
|
143
|
-
* Otherwise, it throws {@link TypeGuardError} instead.
|
|
144
|
-
*
|
|
145
|
-
* However, note that, this validation is not always safe. It just performs
|
|
146
|
-
* additional type assertion like `number & Minimum<7>` or `string &
|
|
147
|
-
* Format<"uuid">` cases, that are represented by [custom
|
|
148
|
-
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
149
|
-
* `typia.protobuf.assertDecode<T>()` function, you have to ensure the type
|
|
150
|
-
* safety by yourself.
|
|
151
|
-
*
|
|
152
|
-
* In such type safety reason, I recommend you to use type safe encode
|
|
153
|
-
* functions.
|
|
154
|
-
*
|
|
155
|
-
* - {@link assertEncode}
|
|
156
|
-
* - {@link isEncode}
|
|
157
|
-
* - {@link validateEncode}
|
|
158
|
-
*
|
|
159
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
160
|
-
* @template T Expected type of decoded value
|
|
161
|
-
* @param input Protobuf Buffer binary data
|
|
162
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
163
|
-
* @returns Decoded value
|
|
164
|
-
*/
|
|
165
|
-
export function assertDecode(
|
|
166
|
-
input: Uint8Array,
|
|
167
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
168
|
-
): never;
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Protocol Buffer Decoder wity type assertion, but not safe.
|
|
172
|
-
*
|
|
173
|
-
* `typia.protobuf.assertDecode()` is a combination function of {@link decode}
|
|
174
|
-
* and {@link assert} function. Therefore, it decodes a binary data of Protocol
|
|
175
|
-
* Buffer to a TypeScript instance, and performs type assertion process. If
|
|
176
|
-
* decoded value is following the type `T`, it returns the decoded value.
|
|
177
|
-
* Otherwise, it throws {@link TypeGuardError} instead.
|
|
178
|
-
*
|
|
179
|
-
* However, note that, this validation is not always safe. It just performs
|
|
180
|
-
* additional type assertion like `number & Minimum<7>` or `string &
|
|
181
|
-
* Format<"uuid">` cases, that are represented by [custom
|
|
182
|
-
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
183
|
-
* `typia.protobuf.assertDecode<T>()` function, you have to ensure the type
|
|
184
|
-
* safety by yourself.
|
|
185
|
-
*
|
|
186
|
-
* In such type safety reason, I recommend you to use type safe encode
|
|
187
|
-
* functions.
|
|
188
|
-
*
|
|
189
|
-
* - {@link assertEncode}
|
|
190
|
-
* - {@link isEncode}
|
|
191
|
-
* - {@link validateEncode}
|
|
192
|
-
*
|
|
193
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
194
|
-
* @template T Expected type of decoded value
|
|
195
|
-
* @param input Protobuf Buffer binary data
|
|
196
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
197
|
-
* @returns Decoded value
|
|
198
|
-
*/
|
|
199
|
-
export function assertDecode<T>(
|
|
200
|
-
input: Uint8Array,
|
|
201
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
202
|
-
): Resolved<T>;
|
|
203
|
-
|
|
204
|
-
/** @internal */
|
|
205
|
-
export function assertDecode(): never {
|
|
206
|
-
NoTransformConfigurationError("protobuf.assertDecode");
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* > You must configure the generic argument `T`.
|
|
211
|
-
*
|
|
212
|
-
* Protocol Buffer Decoder wity type checking, but not safe.
|
|
213
|
-
*
|
|
214
|
-
* `typia.protobuf.isDecode()` is a combination function of {@link decode} and
|
|
215
|
-
* {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
|
|
216
|
-
* a TypeScript instance, and performs type checking process. If decoded value
|
|
217
|
-
* is following the type `T`, it returns the decoded value. Otherwise, it
|
|
218
|
-
* returns `null` value instead.
|
|
219
|
-
*
|
|
220
|
-
* However, note that, this validation is not always safe. It just performs
|
|
221
|
-
* additional type checking like `number & Minimum<7>` or `string &
|
|
222
|
-
* Format<"uuid">` cases, that are represented by [custom
|
|
223
|
-
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
224
|
-
* `typia.protobuf.isDecode<T>()` function, you have to ensure the type safety
|
|
225
|
-
* by yourself.
|
|
226
|
-
*
|
|
227
|
-
* In such type safety reason, I recommend you to use type safe encode
|
|
228
|
-
* functions.
|
|
229
|
-
*
|
|
230
|
-
* - {@link assertEncode}
|
|
231
|
-
* - {@link isEncode}
|
|
232
|
-
* - {@link validateEncode}
|
|
233
|
-
*
|
|
234
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
235
|
-
* @template T Expected type of decoded value
|
|
236
|
-
* @param input Protobuf Buffer binary data
|
|
237
|
-
* @returns Decoded value
|
|
238
|
-
*/
|
|
239
|
-
export function isDecode(input: Uint8Array): never;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Protocol Buffer Decoder wity type checking, but not safe.
|
|
243
|
-
*
|
|
244
|
-
* `typia.protobuf.isDecode()` is a combination function of {@link decode} and
|
|
245
|
-
* {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
|
|
246
|
-
* a TypeScript instance, and performs type checking process. If decoded value
|
|
247
|
-
* is following the type `T`, it returns the decoded value. Otherwise, it
|
|
248
|
-
* returns `null` value instead.
|
|
249
|
-
*
|
|
250
|
-
* However, note that, this validation is not always safe. It just performs
|
|
251
|
-
* additional type checking like `number & Minimum<7>` or `string &
|
|
252
|
-
* Format<"uuid">` cases, that are represented by [custom
|
|
253
|
-
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
254
|
-
* `typia.protobuf.isDecode<T>()` function, you have to ensure the type safety
|
|
255
|
-
* by yourself.
|
|
256
|
-
*
|
|
257
|
-
* In such type safety reason, I recommend you to use type safe encode
|
|
258
|
-
* functions.
|
|
259
|
-
*
|
|
260
|
-
* - {@link assertEncode}
|
|
261
|
-
* - {@link isEncode}
|
|
262
|
-
* - {@link validateEncode}
|
|
263
|
-
*
|
|
264
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
265
|
-
* @template T Expected type of decoded value
|
|
266
|
-
* @param input Protobuf Buffer binary data
|
|
267
|
-
* @returns Decoded value
|
|
268
|
-
*/
|
|
269
|
-
export function isDecode<T>(input: Uint8Array): Resolved<T> | null;
|
|
270
|
-
|
|
271
|
-
/** @internal */
|
|
272
|
-
export function isDecode(): never {
|
|
273
|
-
NoTransformConfigurationError("protobuf.isDecode");
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* > You must configure the generic argument `T`.
|
|
278
|
-
*
|
|
279
|
-
* Protocol Buffer Decoder wity type validation, but not safe.
|
|
280
|
-
*
|
|
281
|
-
* `typia.protobuf.validateDecode()` is a combination function of {@link decode}
|
|
282
|
-
* and {@link validate} function. Therefore, it decodes a binary data of Protocol
|
|
283
|
-
* Buffer to a TypeScript instance, and performs type validation process. If
|
|
284
|
-
* decoded value is following the type `T`, it returns the decoded value with
|
|
285
|
-
* {@link IValidation.ISuccess} typed instance. Otherwise, it returns
|
|
286
|
-
* {@link IValidation.IFailure} value instead with detailed error reasons.
|
|
287
|
-
*
|
|
288
|
-
* However, note that, this validation is not always safe. It just performs
|
|
289
|
-
* additional type validation like `number & Minimum<7>` or `string &
|
|
290
|
-
* Format<"uuid">` cases, that are represented by [custom
|
|
291
|
-
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
292
|
-
* `typia.protobuf.validateDecode<T>()` function, you have to ensure the type
|
|
293
|
-
* safety by yourself.
|
|
294
|
-
*
|
|
295
|
-
* In such type safety reason, I recommend you to use type safe encode
|
|
296
|
-
* functions.
|
|
297
|
-
*
|
|
298
|
-
* - {@link assertEncode}
|
|
299
|
-
* - {@link isEncode}
|
|
300
|
-
* - {@link validateEncode}
|
|
301
|
-
*
|
|
302
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
303
|
-
* @template T Expected type of decoded value
|
|
304
|
-
* @param input Protobuf Buffer binary data
|
|
305
|
-
* @returns Decoded value
|
|
306
|
-
*/
|
|
307
|
-
export function validateDecode(input: Uint8Array): never;
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Protocol Buffer Decoder wity type validation, but not safe.
|
|
311
|
-
*
|
|
312
|
-
* `typia.protobuf.validateDecode()` is a combination function of {@link decode}
|
|
313
|
-
* and {@link validate} function. Therefore, it decodes a binary data of Protocol
|
|
314
|
-
* Buffer to a TypeScript instance, and performs type validation process. If
|
|
315
|
-
* decoded value is following the type `T`, it returns the decoded value with
|
|
316
|
-
* {@link IValidation.ISuccess} typed instance. Otherwise, it returns
|
|
317
|
-
* {@link IValidation.IFailure} value instead with detailed error reasons.
|
|
318
|
-
*
|
|
319
|
-
* However, note that, this validation is not always safe. It just performs
|
|
320
|
-
* additional type validation like `number & Minimum<7>` or `string &
|
|
321
|
-
* Format<"uuid">` cases, that are represented by [custom
|
|
322
|
-
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
323
|
-
* `typia.protobuf.validateDecode<T>()` function, you have to ensure the type
|
|
324
|
-
* safety by yourself.
|
|
325
|
-
*
|
|
326
|
-
* In such type safety reason, I recommend you to use type safe encode
|
|
327
|
-
* functions.
|
|
328
|
-
*
|
|
329
|
-
* - {@link assertEncode}
|
|
330
|
-
* - {@link isEncode}
|
|
331
|
-
* - {@link validateEncode}
|
|
332
|
-
*
|
|
333
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
334
|
-
* @template T Expected type of decoded value
|
|
335
|
-
* @param input Protobuf Buffer binary data
|
|
336
|
-
* @returns Decoded value
|
|
337
|
-
*/
|
|
338
|
-
export function validateDecode<T>(input: Uint8Array): IValidation<Resolved<T>>;
|
|
339
|
-
|
|
340
|
-
/** @internal */
|
|
341
|
-
export function validateDecode(): never {
|
|
342
|
-
NoTransformConfigurationError("protobuf.validateDecode");
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/* -----------------------------------------------------------
|
|
346
|
-
ENCODE
|
|
347
|
-
----------------------------------------------------------- */
|
|
348
|
-
/**
|
|
349
|
-
* Protocol Buffer Encoder.
|
|
350
|
-
*
|
|
351
|
-
* Converts an input value to a binary data of Protocol Buffer format.
|
|
352
|
-
*
|
|
353
|
-
* For reference, this `typia.protobuf.encode()` does not validate the `input`
|
|
354
|
-
* value. It just believes that the `input` value is valid and converts it to a
|
|
355
|
-
* binary data directly. Therefore, if you can't ensure the `input` value type,
|
|
356
|
-
* it would better to call one of below functions instead.
|
|
357
|
-
*
|
|
358
|
-
* - {@link assertEncode}
|
|
359
|
-
* - {@link isEncode}
|
|
360
|
-
* - {@link validateEncode}
|
|
361
|
-
*
|
|
362
|
-
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
363
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
364
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
365
|
-
* would throw compilation errors.
|
|
366
|
-
*
|
|
367
|
-
* - [Restrictions of Protocol
|
|
368
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
369
|
-
*
|
|
370
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
371
|
-
* @template T Type of the value input
|
|
372
|
-
* @param input A value to encode
|
|
373
|
-
* @returns Encoded binary data
|
|
374
|
-
*/
|
|
375
|
-
export function encode<T>(input: T): Uint8Array;
|
|
376
|
-
|
|
377
|
-
/** @internal */
|
|
378
|
-
export function encode(): never {
|
|
379
|
-
NoTransformConfigurationError("protobuf.encode");
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Protocol Buffer Encoder with type assertion.
|
|
384
|
-
*
|
|
385
|
-
* `typia.protobuf.assertEncode()` is a combination function of {@link assert}
|
|
386
|
-
* and {@link encode}.
|
|
387
|
-
*
|
|
388
|
-
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
389
|
-
* with type assertion. If `input` value is not valid, it throws
|
|
390
|
-
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value,
|
|
391
|
-
* Protocol Buffer binary data would be returned.
|
|
392
|
-
*
|
|
393
|
-
* If you can trust `input` value, or want to perform other type of validation,
|
|
394
|
-
* use below functions instead.
|
|
395
|
-
*
|
|
396
|
-
* - {@link encode}
|
|
397
|
-
* - {@link isEncode}
|
|
398
|
-
* - {@link validateEncode}
|
|
399
|
-
*
|
|
400
|
-
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
401
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
402
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
403
|
-
* would throw compilation errors.
|
|
404
|
-
*
|
|
405
|
-
* - [Restrictions of Protocol
|
|
406
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
407
|
-
*
|
|
408
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
409
|
-
* @template T Type of the value input
|
|
410
|
-
* @param input A value to encode
|
|
411
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
412
|
-
* @returns Encoded binary data
|
|
413
|
-
*/
|
|
414
|
-
export function assertEncode<T>(
|
|
415
|
-
input: T,
|
|
416
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
417
|
-
): Uint8Array;
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Protocol Buffer Encoder with type assertion.
|
|
421
|
-
*
|
|
422
|
-
* `typia.protobuf.assertEncode()` is a combination function of {@link assert}
|
|
423
|
-
* and {@link encode}.
|
|
424
|
-
*
|
|
425
|
-
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
426
|
-
* 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,
|
|
431
|
-
* use below functions instead.
|
|
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
|
|
438
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
439
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
440
|
-
* would throw compilation errors.
|
|
441
|
-
*
|
|
442
|
-
* - [Restrictions of Protocol
|
|
443
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
444
|
-
*
|
|
445
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
446
|
-
* @template T Type of the value input
|
|
447
|
-
* @param input A value to encode
|
|
448
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
449
|
-
* @returns Encoded binary data
|
|
450
|
-
*/
|
|
451
|
-
export function assertEncode<T>(
|
|
452
|
-
input: unknown,
|
|
453
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
454
|
-
): Uint8Array;
|
|
455
|
-
|
|
456
|
-
/** @internal */
|
|
457
|
-
export function assertEncode(): never {
|
|
458
|
-
NoTransformConfigurationError("protobuf.assertEncode");
|
|
459
|
-
}
|
|
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 Protocol Buffer,
|
|
468
|
-
* with type checking. If `input` value is not valid, it returns `null` value.
|
|
469
|
-
* Otherwise, there's no problem on the `input` value, Protocol Buffer binary
|
|
470
|
-
* data would be returned.
|
|
471
|
-
*
|
|
472
|
-
* If you can trust `input` value, or want to perform other type of validation,
|
|
473
|
-
* use below functions instead.
|
|
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
|
|
480
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
481
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
482
|
-
* would throw compilation errors.
|
|
483
|
-
*
|
|
484
|
-
* - [Restrictions of Protocol
|
|
485
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
486
|
-
*
|
|
487
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
488
|
-
* @template T Type of the value input
|
|
489
|
-
* @param input A value to encode
|
|
490
|
-
* @returns Encoded binary data
|
|
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 Protocol Buffer,
|
|
501
|
-
* with type checking. If `input` value is not valid, it returns `null` value.
|
|
502
|
-
* Otherwise, there's no problem on the `input` value, Protocol Buffer binary
|
|
503
|
-
* data would be returned.
|
|
504
|
-
*
|
|
505
|
-
* If you can trust `input` value, or want to perform other type of validation,
|
|
506
|
-
* use below functions instead.
|
|
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
|
|
513
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
514
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
515
|
-
* would throw compilation errors.
|
|
516
|
-
*
|
|
517
|
-
* - [Restrictions of Protocol
|
|
518
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
519
|
-
*
|
|
520
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
521
|
-
* @template T Type of the value input
|
|
522
|
-
* @param input A value to encode
|
|
523
|
-
* @returns Encoded binary data
|
|
524
|
-
*/
|
|
525
|
-
export function isEncode<T>(input: unknown): Uint8Array | null;
|
|
526
|
-
|
|
527
|
-
/** @internal */
|
|
528
|
-
export function isEncode(): never {
|
|
529
|
-
NoTransformConfigurationError("protobuf.isEncode");
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Protocol Buffer Encoder with type validation.
|
|
534
|
-
*
|
|
535
|
-
* `typia.protobuf.validateEncode()` is a combination function of
|
|
536
|
-
* {@link validation} and {@link encode}.
|
|
537
|
-
*
|
|
538
|
-
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
539
|
-
* with type validation. If `input` value is not valid, it returns
|
|
540
|
-
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
|
|
541
|
-
* there's no problem on the `input` value, Protocol Buffer binary data would be
|
|
542
|
-
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
543
|
-
* instance.
|
|
544
|
-
*
|
|
545
|
-
* If you can trust `input` value, or want to perform other type of validation,
|
|
546
|
-
* use below functions instead.
|
|
547
|
-
*
|
|
548
|
-
* - {@link encode}
|
|
549
|
-
* - {@link assertEncode}
|
|
550
|
-
* - {@link isEncode}
|
|
551
|
-
*
|
|
552
|
-
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
553
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
554
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
555
|
-
* would throw compilation errors.
|
|
556
|
-
*
|
|
557
|
-
* - [Restrictions of Protocol
|
|
558
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
559
|
-
*
|
|
560
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
561
|
-
* @template T Type of the value input
|
|
562
|
-
* @param input A value to encode
|
|
563
|
-
* @returns Encoded binary data
|
|
564
|
-
*/
|
|
565
|
-
export function validateEncode<T>(input: T): IValidation<Uint8Array>;
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Protocol Buffer Encoder with type validation.
|
|
569
|
-
*
|
|
570
|
-
* `typia.protobuf.validateEncode()` is a combination function of
|
|
571
|
-
* {@link validation} and {@link encode}.
|
|
572
|
-
*
|
|
573
|
-
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
574
|
-
* with type validation. If `input` value is not valid, it returns
|
|
575
|
-
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
|
|
576
|
-
* there's no problem on the `input` value, Protocol Buffer binary data would be
|
|
577
|
-
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
578
|
-
* instance.
|
|
579
|
-
*
|
|
580
|
-
* If you can trust `input` value, or want to perform other type of validation,
|
|
581
|
-
* use below functions instead.
|
|
582
|
-
*
|
|
583
|
-
* - {@link encode}
|
|
584
|
-
* - {@link assertEncode}
|
|
585
|
-
* - {@link isEncode}
|
|
586
|
-
*
|
|
587
|
-
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
588
|
-
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
589
|
-
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
590
|
-
* would throw compilation errors.
|
|
591
|
-
*
|
|
592
|
-
* - [Restrictions of Protocol
|
|
593
|
-
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
594
|
-
*
|
|
595
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
596
|
-
* @template T Type of the value input
|
|
597
|
-
* @param input A value to encode
|
|
598
|
-
* @returns Encoded binary data
|
|
599
|
-
*/
|
|
600
|
-
export function validateEncode<T>(input: unknown): IValidation<Uint8Array>;
|
|
601
|
-
|
|
602
|
-
/** @internal */
|
|
603
|
-
export function validateEncode(): never {
|
|
604
|
-
NoTransformConfigurationError("protobuf.validateEncode");
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/* -----------------------------------------------------------
|
|
608
|
-
FACTORY FUNCTIONS
|
|
609
|
-
----------------------------------------------------------- */
|
|
610
|
-
/**
|
|
611
|
-
* Creates a reusable {@link decode} function.
|
|
612
|
-
*
|
|
613
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
614
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
615
|
-
* @throws Compile error
|
|
616
|
-
* @danger You must configure the generic argument `T`
|
|
617
|
-
*/
|
|
618
|
-
export function createDecode(): never;
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Creates a reusable {@link decode} function.
|
|
622
|
-
*
|
|
623
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
624
|
-
* @template T Target type
|
|
625
|
-
* @returns A reusable `decode` function
|
|
626
|
-
*/
|
|
627
|
-
export function createDecode<T>(): (input: Uint8Array) => Resolved<T>;
|
|
628
|
-
|
|
629
|
-
/** @internal */
|
|
630
|
-
export function createDecode<T>(): (input: Uint8Array) => Resolved<T> {
|
|
631
|
-
NoTransformConfigurationError("protobuf.createDecode");
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Creates a reusable {@link isDecode} function.
|
|
636
|
-
*
|
|
637
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
638
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
639
|
-
* @throws Compile error
|
|
640
|
-
* @danger You must configure the generic argument `T`
|
|
641
|
-
*/
|
|
642
|
-
export function createIsDecode(): never;
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* Creates a reusable {@link isDecode} function.
|
|
646
|
-
*
|
|
647
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
648
|
-
* @template T Target type
|
|
649
|
-
* @returns A reusable `isDecode` function
|
|
650
|
-
*/
|
|
651
|
-
export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null;
|
|
652
|
-
|
|
653
|
-
/** @internal */
|
|
654
|
-
export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null {
|
|
655
|
-
NoTransformConfigurationError("protobuf.createIsDecode");
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
/**
|
|
659
|
-
* Creates a reusable {@link assertDecode} function.
|
|
660
|
-
*
|
|
661
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
662
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
663
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
664
|
-
* @throws Compile error
|
|
665
|
-
* @danger You must configure the generic argument `T`
|
|
666
|
-
*/
|
|
667
|
-
export function createAssertDecode(
|
|
668
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
669
|
-
): never;
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Creates a reusable {@link assertDecode} function.
|
|
673
|
-
*
|
|
674
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
675
|
-
* @template T Target type
|
|
676
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
677
|
-
* @returns A reusable `assertDecode` function
|
|
678
|
-
*/
|
|
679
|
-
export function createAssertDecode<T>(
|
|
680
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
681
|
-
): (input: Uint8Array) => Resolved<T>;
|
|
682
|
-
|
|
683
|
-
/** @internal */
|
|
684
|
-
export function createAssertDecode<T>(): (input: Uint8Array) => Resolved<T> {
|
|
685
|
-
NoTransformConfigurationError("protobuf.createAssertDecode");
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Creates a reusable {@link validateDecode} function.
|
|
690
|
-
*
|
|
691
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
692
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
693
|
-
* @throws Compile error
|
|
694
|
-
* @danger You must configure the generic argument `T`
|
|
695
|
-
*/
|
|
696
|
-
export function createValidateDecode(): never;
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* Creates a reusable {@link validateDecode} function.
|
|
700
|
-
*
|
|
701
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
702
|
-
* @template T Target type
|
|
703
|
-
* @returns A reusable `validateDecode` function
|
|
704
|
-
*/
|
|
705
|
-
export function createValidateDecode<T>(): (
|
|
706
|
-
input: Uint8Array,
|
|
707
|
-
) => IValidation<Resolved<T>>;
|
|
708
|
-
|
|
709
|
-
/** @internal */
|
|
710
|
-
export function createValidateDecode<T>(): (
|
|
711
|
-
input: Uint8Array,
|
|
712
|
-
) => IValidation<Resolved<T>> {
|
|
713
|
-
NoTransformConfigurationError("protobuf.createValidateDecode");
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Creates a reusable {@link encode} function.
|
|
718
|
-
*
|
|
719
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
720
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
721
|
-
* @throws Compile error
|
|
722
|
-
* @danger You must configure the generic argument `T`
|
|
723
|
-
*/
|
|
724
|
-
export function createEncode(): never;
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Creates a reusable {@link encode} function.
|
|
728
|
-
*
|
|
729
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
730
|
-
* @template T Target type
|
|
731
|
-
* @returns A reusable `encode` function
|
|
732
|
-
*/
|
|
733
|
-
export function createEncode<T>(): (input: T) => Uint8Array;
|
|
734
|
-
|
|
735
|
-
/** @internal */
|
|
736
|
-
export function createEncode<T>(): (input: T) => Uint8Array {
|
|
737
|
-
NoTransformConfigurationError("protobuf.createEncode");
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
/**
|
|
741
|
-
* Creates a reusable {@link isEncode} function.
|
|
742
|
-
*
|
|
743
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
744
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
745
|
-
* @throws Compile error
|
|
746
|
-
* @danger You must configure the generic argument `T`
|
|
747
|
-
*/
|
|
748
|
-
export function createIsEncode(): never;
|
|
749
|
-
|
|
750
|
-
/**
|
|
751
|
-
* Creates a reusable {@link isEncode} function.
|
|
752
|
-
*
|
|
753
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
754
|
-
* @template T Target type
|
|
755
|
-
* @returns A reusable `isEncode` function
|
|
756
|
-
*/
|
|
757
|
-
export function createIsEncode<T>(): (input: T) => Uint8Array | null;
|
|
758
|
-
|
|
759
|
-
/** @internal */
|
|
760
|
-
export function createIsEncode<T>(): (input: T) => Uint8Array | null {
|
|
761
|
-
NoTransformConfigurationError("protobuf.createIsEncode");
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Creates a reusable {@link assertEncode} function.
|
|
766
|
-
*
|
|
767
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
768
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
769
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
770
|
-
* @throws Compile error
|
|
771
|
-
* @danger You must configure the generic argument `T`
|
|
772
|
-
*/
|
|
773
|
-
export function createAssertEncode(
|
|
774
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
775
|
-
): never;
|
|
776
|
-
|
|
777
|
-
/**
|
|
778
|
-
* Creates a reusable {@link assertEncode} function.
|
|
779
|
-
*
|
|
780
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
781
|
-
* @template T Target type
|
|
782
|
-
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
783
|
-
* @returns A reusable `assertEncode` function
|
|
784
|
-
*/
|
|
785
|
-
export function createAssertEncode<T>(
|
|
786
|
-
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
787
|
-
): (input: T) => Uint8Array;
|
|
788
|
-
|
|
789
|
-
/** @internal */
|
|
790
|
-
export function createAssertEncode<T>(): (input: T) => Uint8Array {
|
|
791
|
-
NoTransformConfigurationError("protobuf.createAssertEncode");
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
/**
|
|
795
|
-
* Creates a reusable {@link validateEncode} function.
|
|
796
|
-
*
|
|
797
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
798
|
-
* @returns Nothing until you configure the generic argument `T`
|
|
799
|
-
* @throws Compile error
|
|
800
|
-
* @danger You must configure the generic argument `T`
|
|
801
|
-
*/
|
|
802
|
-
export function createValidateEncode(): never;
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Creates a reusable {@link validateEncode} function.
|
|
806
|
-
*
|
|
807
|
-
* @author Jeongho Nam - https://github.com/samchon
|
|
808
|
-
* @template T Target type
|
|
809
|
-
* @returns A reusable `validateEncode` function
|
|
810
|
-
*/
|
|
811
|
-
export function createValidateEncode<T>(): (
|
|
812
|
-
input: T,
|
|
813
|
-
) => IValidation<Uint8Array>;
|
|
814
|
-
|
|
815
|
-
/** @internal */
|
|
816
|
-
export function createValidateEncode<T>(): (
|
|
817
|
-
input: T,
|
|
818
|
-
) => IValidation<Uint8Array> {
|
|
819
|
-
NoTransformConfigurationError("protobuf.createValidateEncode");
|
|
820
|
-
}
|
|
1
|
+
import { NoTransformConfigurationError } from "./transformers/NoTransformConfigurationError";
|
|
2
|
+
|
|
3
|
+
import { IValidation } from "./IValidation";
|
|
4
|
+
import { Resolved } from "./Resolved";
|
|
5
|
+
import { TypeGuardError } from "./TypeGuardError";
|
|
6
|
+
|
|
7
|
+
/* ===========================================================
|
|
8
|
+
PROTOCOL BUFFER
|
|
9
|
+
- MESSAGE
|
|
10
|
+
- DECODE
|
|
11
|
+
- ENCODE
|
|
12
|
+
- FACTORY FUNCTIONS
|
|
13
|
+
==============================================================
|
|
14
|
+
SCHEMA
|
|
15
|
+
----------------------------------------------------------- */
|
|
16
|
+
/**
|
|
17
|
+
* > You must configure the generic argument `T`.
|
|
18
|
+
*
|
|
19
|
+
* Protocol Buffer Message Schema.
|
|
20
|
+
*
|
|
21
|
+
* Creates a Protocol Buffer Message Schema from a TypeScript type. The message
|
|
22
|
+
* schema would be returned as a string value, and it can be used to share with
|
|
23
|
+
* other developers/languages/frameworks.
|
|
24
|
+
*
|
|
25
|
+
* For reference, Protocol Buffer has lots of restrictions, so that expression
|
|
26
|
+
* power of Protocol Buffer is not enough strong to fully meet the TypeScript
|
|
27
|
+
* type specs. In such reason, if you put a TypeScript type that is not
|
|
28
|
+
* compatible with Protocol Buffer, this function would throw compilation
|
|
29
|
+
* errors.
|
|
30
|
+
*
|
|
31
|
+
* - [Restrictions of Protocol
|
|
32
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
33
|
+
*
|
|
34
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
35
|
+
* @template T Target type
|
|
36
|
+
* @returns Protocol Buffer Message Schema.
|
|
37
|
+
*/
|
|
38
|
+
export function message(): never;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Protocol Buffer Message Schema.
|
|
42
|
+
*
|
|
43
|
+
* Creates a Protocol Buffer Message Schema from a TypeScript type. The message
|
|
44
|
+
* schema would be returned as a string value, and it can be used to share with
|
|
45
|
+
* other developers/languages/frameworks.
|
|
46
|
+
*
|
|
47
|
+
* For reference, Protocol Buffer has lots of restrictions, so that expression
|
|
48
|
+
* power of Protocol Buffer is not enough strong to fully meet the TypeScript
|
|
49
|
+
* type specs. In such reason, if you put a TypeScript type that is not
|
|
50
|
+
* compatible with Protocol Buffer, this function would throw compilation
|
|
51
|
+
* errors.
|
|
52
|
+
*
|
|
53
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
54
|
+
* @template T Target type
|
|
55
|
+
* @returns Protocol Buffer Message Schema.
|
|
56
|
+
*/
|
|
57
|
+
export function message<T>(): string;
|
|
58
|
+
|
|
59
|
+
/** @internal */
|
|
60
|
+
export function message(): never {
|
|
61
|
+
NoTransformConfigurationError("protobuf.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
|
|
73
|
+
* Buffer format to a TypeScript instance.
|
|
74
|
+
*
|
|
75
|
+
* For reference, as Protocol Buffer handles binary data directly, there's no
|
|
76
|
+
* way when `input` binary data was not encoded from the `T` typed value. In
|
|
77
|
+
* that case, unexpected behavior or internal error would be occurred.
|
|
78
|
+
* Therefore, I recommend you to encode binary data of Protocol Buffer from type
|
|
79
|
+
* safe encode functions like below. Use {@link encode} function only when you
|
|
80
|
+
* can ensure it.
|
|
81
|
+
*
|
|
82
|
+
* - {@link assertEncode}
|
|
83
|
+
* - {@link isEncode}
|
|
84
|
+
* - {@link validateEncode}
|
|
85
|
+
*
|
|
86
|
+
* Also, `typia` is providing type safe decoders like {@link assertDecode}, but
|
|
87
|
+
* it is just for additional type validation like `number & Minimum<7>` or
|
|
88
|
+
* `string & Format<"uuid">` cases, that are represented by [custom
|
|
89
|
+
* tags](https://typia.io/docs/validators/tags). Thus, I repeat that, you've to
|
|
90
|
+
* ensure the type safety when using decoder functions.
|
|
91
|
+
*
|
|
92
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
93
|
+
* @template T Expected type of decoded value
|
|
94
|
+
* @param input Protobuf Buffer binary data
|
|
95
|
+
* @returns Decoded value
|
|
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
|
|
103
|
+
* Buffer format to a TypeScript instance.
|
|
104
|
+
*
|
|
105
|
+
* For reference, as Protocol Buffer handles binary data directly, there's no
|
|
106
|
+
* way when `input` binary data was not encoded from the `T` typed value. In
|
|
107
|
+
* that case, unexpected behavior or internal error would be occurred.
|
|
108
|
+
* Therefore, I recommend you to encode binary data of Protocol Buffer from type
|
|
109
|
+
* safe encode functions like below. Use {@link encode} function only when you
|
|
110
|
+
* can ensure it.
|
|
111
|
+
*
|
|
112
|
+
* - {@link assertEncode}
|
|
113
|
+
* - {@link isEncode}
|
|
114
|
+
* - {@link validateEncode}
|
|
115
|
+
*
|
|
116
|
+
* Also, `typia` is providing type safe decoders like {@link assertDecode}, but
|
|
117
|
+
* it is just for additional type validation like `number & Minimum<7>` or
|
|
118
|
+
* `string & Format<"uuid">` cases, that are represented by [custom
|
|
119
|
+
* tags](https://typia.io/docs/validators/tags). Thus, I repeat that, you've to
|
|
120
|
+
* ensure the type safety when using decoder functions.
|
|
121
|
+
*
|
|
122
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
123
|
+
* @template T Expected type of decoded value
|
|
124
|
+
* @param input Protobuf Buffer binary data
|
|
125
|
+
* @returns Decoded value
|
|
126
|
+
*/
|
|
127
|
+
export function decode<T>(input: Uint8Array): Resolved<T>;
|
|
128
|
+
|
|
129
|
+
/** @internal */
|
|
130
|
+
export function decode(): never {
|
|
131
|
+
NoTransformConfigurationError("protobuf.decode");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* > You must configure the generic argument `T`.
|
|
136
|
+
*
|
|
137
|
+
* Protocol Buffer Decoder wity type assertion, but not safe.
|
|
138
|
+
*
|
|
139
|
+
* `typia.protobuf.assertDecode()` is a combination function of {@link decode}
|
|
140
|
+
* and {@link assert} function. Therefore, it decodes a binary data of Protocol
|
|
141
|
+
* Buffer to a TypeScript instance, and performs type assertion process. If
|
|
142
|
+
* decoded value is following the type `T`, it returns the decoded value.
|
|
143
|
+
* Otherwise, it throws {@link TypeGuardError} instead.
|
|
144
|
+
*
|
|
145
|
+
* However, note that, this validation is not always safe. It just performs
|
|
146
|
+
* additional type assertion like `number & Minimum<7>` or `string &
|
|
147
|
+
* Format<"uuid">` cases, that are represented by [custom
|
|
148
|
+
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
149
|
+
* `typia.protobuf.assertDecode<T>()` function, you have to ensure the type
|
|
150
|
+
* safety by yourself.
|
|
151
|
+
*
|
|
152
|
+
* In such type safety reason, I recommend you to use type safe encode
|
|
153
|
+
* functions.
|
|
154
|
+
*
|
|
155
|
+
* - {@link assertEncode}
|
|
156
|
+
* - {@link isEncode}
|
|
157
|
+
* - {@link validateEncode}
|
|
158
|
+
*
|
|
159
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
160
|
+
* @template T Expected type of decoded value
|
|
161
|
+
* @param input Protobuf Buffer binary data
|
|
162
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
163
|
+
* @returns Decoded value
|
|
164
|
+
*/
|
|
165
|
+
export function assertDecode(
|
|
166
|
+
input: Uint8Array,
|
|
167
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
168
|
+
): never;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Protocol Buffer Decoder wity type assertion, but not safe.
|
|
172
|
+
*
|
|
173
|
+
* `typia.protobuf.assertDecode()` is a combination function of {@link decode}
|
|
174
|
+
* and {@link assert} function. Therefore, it decodes a binary data of Protocol
|
|
175
|
+
* Buffer to a TypeScript instance, and performs type assertion process. If
|
|
176
|
+
* decoded value is following the type `T`, it returns the decoded value.
|
|
177
|
+
* Otherwise, it throws {@link TypeGuardError} instead.
|
|
178
|
+
*
|
|
179
|
+
* However, note that, this validation is not always safe. It just performs
|
|
180
|
+
* additional type assertion like `number & Minimum<7>` or `string &
|
|
181
|
+
* Format<"uuid">` cases, that are represented by [custom
|
|
182
|
+
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
183
|
+
* `typia.protobuf.assertDecode<T>()` function, you have to ensure the type
|
|
184
|
+
* safety by yourself.
|
|
185
|
+
*
|
|
186
|
+
* In such type safety reason, I recommend you to use type safe encode
|
|
187
|
+
* functions.
|
|
188
|
+
*
|
|
189
|
+
* - {@link assertEncode}
|
|
190
|
+
* - {@link isEncode}
|
|
191
|
+
* - {@link validateEncode}
|
|
192
|
+
*
|
|
193
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
194
|
+
* @template T Expected type of decoded value
|
|
195
|
+
* @param input Protobuf Buffer binary data
|
|
196
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
197
|
+
* @returns Decoded value
|
|
198
|
+
*/
|
|
199
|
+
export function assertDecode<T>(
|
|
200
|
+
input: Uint8Array,
|
|
201
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
202
|
+
): Resolved<T>;
|
|
203
|
+
|
|
204
|
+
/** @internal */
|
|
205
|
+
export function assertDecode(): never {
|
|
206
|
+
NoTransformConfigurationError("protobuf.assertDecode");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* > You must configure the generic argument `T`.
|
|
211
|
+
*
|
|
212
|
+
* Protocol Buffer Decoder wity type checking, but not safe.
|
|
213
|
+
*
|
|
214
|
+
* `typia.protobuf.isDecode()` is a combination function of {@link decode} and
|
|
215
|
+
* {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
|
|
216
|
+
* a TypeScript instance, and performs type checking process. If decoded value
|
|
217
|
+
* is following the type `T`, it returns the decoded value. Otherwise, it
|
|
218
|
+
* returns `null` value instead.
|
|
219
|
+
*
|
|
220
|
+
* However, note that, this validation is not always safe. It just performs
|
|
221
|
+
* additional type checking like `number & Minimum<7>` or `string &
|
|
222
|
+
* Format<"uuid">` cases, that are represented by [custom
|
|
223
|
+
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
224
|
+
* `typia.protobuf.isDecode<T>()` function, you have to ensure the type safety
|
|
225
|
+
* by yourself.
|
|
226
|
+
*
|
|
227
|
+
* In such type safety reason, I recommend you to use type safe encode
|
|
228
|
+
* functions.
|
|
229
|
+
*
|
|
230
|
+
* - {@link assertEncode}
|
|
231
|
+
* - {@link isEncode}
|
|
232
|
+
* - {@link validateEncode}
|
|
233
|
+
*
|
|
234
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
235
|
+
* @template T Expected type of decoded value
|
|
236
|
+
* @param input Protobuf Buffer binary data
|
|
237
|
+
* @returns Decoded value
|
|
238
|
+
*/
|
|
239
|
+
export function isDecode(input: Uint8Array): never;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Protocol Buffer Decoder wity type checking, but not safe.
|
|
243
|
+
*
|
|
244
|
+
* `typia.protobuf.isDecode()` is a combination function of {@link decode} and
|
|
245
|
+
* {@link is} function. Therefore, it decodes a binary data of Protocol Buffer to
|
|
246
|
+
* a TypeScript instance, and performs type checking process. If decoded value
|
|
247
|
+
* is following the type `T`, it returns the decoded value. Otherwise, it
|
|
248
|
+
* returns `null` value instead.
|
|
249
|
+
*
|
|
250
|
+
* However, note that, this validation is not always safe. It just performs
|
|
251
|
+
* additional type checking like `number & Minimum<7>` or `string &
|
|
252
|
+
* Format<"uuid">` cases, that are represented by [custom
|
|
253
|
+
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
254
|
+
* `typia.protobuf.isDecode<T>()` function, you have to ensure the type safety
|
|
255
|
+
* by yourself.
|
|
256
|
+
*
|
|
257
|
+
* In such type safety reason, I recommend you to use type safe encode
|
|
258
|
+
* functions.
|
|
259
|
+
*
|
|
260
|
+
* - {@link assertEncode}
|
|
261
|
+
* - {@link isEncode}
|
|
262
|
+
* - {@link validateEncode}
|
|
263
|
+
*
|
|
264
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
265
|
+
* @template T Expected type of decoded value
|
|
266
|
+
* @param input Protobuf Buffer binary data
|
|
267
|
+
* @returns Decoded value
|
|
268
|
+
*/
|
|
269
|
+
export function isDecode<T>(input: Uint8Array): Resolved<T> | null;
|
|
270
|
+
|
|
271
|
+
/** @internal */
|
|
272
|
+
export function isDecode(): never {
|
|
273
|
+
NoTransformConfigurationError("protobuf.isDecode");
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* > You must configure the generic argument `T`.
|
|
278
|
+
*
|
|
279
|
+
* Protocol Buffer Decoder wity type validation, but not safe.
|
|
280
|
+
*
|
|
281
|
+
* `typia.protobuf.validateDecode()` is a combination function of {@link decode}
|
|
282
|
+
* and {@link validate} function. Therefore, it decodes a binary data of Protocol
|
|
283
|
+
* Buffer to a TypeScript instance, and performs type validation process. If
|
|
284
|
+
* decoded value is following the type `T`, it returns the decoded value with
|
|
285
|
+
* {@link IValidation.ISuccess} typed instance. Otherwise, it returns
|
|
286
|
+
* {@link IValidation.IFailure} value instead with detailed error reasons.
|
|
287
|
+
*
|
|
288
|
+
* However, note that, this validation is not always safe. It just performs
|
|
289
|
+
* additional type validation like `number & Minimum<7>` or `string &
|
|
290
|
+
* Format<"uuid">` cases, that are represented by [custom
|
|
291
|
+
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
292
|
+
* `typia.protobuf.validateDecode<T>()` function, you have to ensure the type
|
|
293
|
+
* safety by yourself.
|
|
294
|
+
*
|
|
295
|
+
* In such type safety reason, I recommend you to use type safe encode
|
|
296
|
+
* functions.
|
|
297
|
+
*
|
|
298
|
+
* - {@link assertEncode}
|
|
299
|
+
* - {@link isEncode}
|
|
300
|
+
* - {@link validateEncode}
|
|
301
|
+
*
|
|
302
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
303
|
+
* @template T Expected type of decoded value
|
|
304
|
+
* @param input Protobuf Buffer binary data
|
|
305
|
+
* @returns Decoded value
|
|
306
|
+
*/
|
|
307
|
+
export function validateDecode(input: Uint8Array): never;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Protocol Buffer Decoder wity type validation, but not safe.
|
|
311
|
+
*
|
|
312
|
+
* `typia.protobuf.validateDecode()` is a combination function of {@link decode}
|
|
313
|
+
* and {@link validate} function. Therefore, it decodes a binary data of Protocol
|
|
314
|
+
* Buffer to a TypeScript instance, and performs type validation process. If
|
|
315
|
+
* decoded value is following the type `T`, it returns the decoded value with
|
|
316
|
+
* {@link IValidation.ISuccess} typed instance. Otherwise, it returns
|
|
317
|
+
* {@link IValidation.IFailure} value instead with detailed error reasons.
|
|
318
|
+
*
|
|
319
|
+
* However, note that, this validation is not always safe. It just performs
|
|
320
|
+
* additional type validation like `number & Minimum<7>` or `string &
|
|
321
|
+
* Format<"uuid">` cases, that are represented by [custom
|
|
322
|
+
* tags](https://typia.io/docs/validators/tags). Therefore, when using
|
|
323
|
+
* `typia.protobuf.validateDecode<T>()` function, you have to ensure the type
|
|
324
|
+
* safety by yourself.
|
|
325
|
+
*
|
|
326
|
+
* In such type safety reason, I recommend you to use type safe encode
|
|
327
|
+
* functions.
|
|
328
|
+
*
|
|
329
|
+
* - {@link assertEncode}
|
|
330
|
+
* - {@link isEncode}
|
|
331
|
+
* - {@link validateEncode}
|
|
332
|
+
*
|
|
333
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
334
|
+
* @template T Expected type of decoded value
|
|
335
|
+
* @param input Protobuf Buffer binary data
|
|
336
|
+
* @returns Decoded value
|
|
337
|
+
*/
|
|
338
|
+
export function validateDecode<T>(input: Uint8Array): IValidation<Resolved<T>>;
|
|
339
|
+
|
|
340
|
+
/** @internal */
|
|
341
|
+
export function validateDecode(): never {
|
|
342
|
+
NoTransformConfigurationError("protobuf.validateDecode");
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/* -----------------------------------------------------------
|
|
346
|
+
ENCODE
|
|
347
|
+
----------------------------------------------------------- */
|
|
348
|
+
/**
|
|
349
|
+
* Protocol Buffer Encoder.
|
|
350
|
+
*
|
|
351
|
+
* Converts an input value to a binary data of Protocol Buffer format.
|
|
352
|
+
*
|
|
353
|
+
* For reference, this `typia.protobuf.encode()` does not validate the `input`
|
|
354
|
+
* value. It just believes that the `input` value is valid and converts it to a
|
|
355
|
+
* binary data directly. Therefore, if you can't ensure the `input` value type,
|
|
356
|
+
* it would better to call one of below functions instead.
|
|
357
|
+
*
|
|
358
|
+
* - {@link assertEncode}
|
|
359
|
+
* - {@link isEncode}
|
|
360
|
+
* - {@link validateEncode}
|
|
361
|
+
*
|
|
362
|
+
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
363
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
364
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
365
|
+
* would throw compilation errors.
|
|
366
|
+
*
|
|
367
|
+
* - [Restrictions of Protocol
|
|
368
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
369
|
+
*
|
|
370
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
371
|
+
* @template T Type of the value input
|
|
372
|
+
* @param input A value to encode
|
|
373
|
+
* @returns Encoded binary data
|
|
374
|
+
*/
|
|
375
|
+
export function encode<T>(input: T): Uint8Array;
|
|
376
|
+
|
|
377
|
+
/** @internal */
|
|
378
|
+
export function encode(): never {
|
|
379
|
+
NoTransformConfigurationError("protobuf.encode");
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Protocol Buffer Encoder with type assertion.
|
|
384
|
+
*
|
|
385
|
+
* `typia.protobuf.assertEncode()` is a combination function of {@link assert}
|
|
386
|
+
* and {@link encode}.
|
|
387
|
+
*
|
|
388
|
+
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
389
|
+
* with type assertion. If `input` value is not valid, it throws
|
|
390
|
+
* {@link TypeGuardError}. Otherwise, there's no problem on the `input` value,
|
|
391
|
+
* Protocol Buffer binary data would be returned.
|
|
392
|
+
*
|
|
393
|
+
* If you can trust `input` value, or want to perform other type of validation,
|
|
394
|
+
* use below functions instead.
|
|
395
|
+
*
|
|
396
|
+
* - {@link encode}
|
|
397
|
+
* - {@link isEncode}
|
|
398
|
+
* - {@link validateEncode}
|
|
399
|
+
*
|
|
400
|
+
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
401
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
402
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
403
|
+
* would throw compilation errors.
|
|
404
|
+
*
|
|
405
|
+
* - [Restrictions of Protocol
|
|
406
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
407
|
+
*
|
|
408
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
409
|
+
* @template T Type of the value input
|
|
410
|
+
* @param input A value to encode
|
|
411
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
412
|
+
* @returns Encoded binary data
|
|
413
|
+
*/
|
|
414
|
+
export function assertEncode<T>(
|
|
415
|
+
input: T,
|
|
416
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
417
|
+
): Uint8Array;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Protocol Buffer Encoder with type assertion.
|
|
421
|
+
*
|
|
422
|
+
* `typia.protobuf.assertEncode()` is a combination function of {@link assert}
|
|
423
|
+
* and {@link encode}.
|
|
424
|
+
*
|
|
425
|
+
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
426
|
+
* 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,
|
|
431
|
+
* use below functions instead.
|
|
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
|
|
438
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
439
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
440
|
+
* would throw compilation errors.
|
|
441
|
+
*
|
|
442
|
+
* - [Restrictions of Protocol
|
|
443
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
444
|
+
*
|
|
445
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
446
|
+
* @template T Type of the value input
|
|
447
|
+
* @param input A value to encode
|
|
448
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
449
|
+
* @returns Encoded binary data
|
|
450
|
+
*/
|
|
451
|
+
export function assertEncode<T>(
|
|
452
|
+
input: unknown,
|
|
453
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
454
|
+
): Uint8Array;
|
|
455
|
+
|
|
456
|
+
/** @internal */
|
|
457
|
+
export function assertEncode(): never {
|
|
458
|
+
NoTransformConfigurationError("protobuf.assertEncode");
|
|
459
|
+
}
|
|
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 Protocol Buffer,
|
|
468
|
+
* with type checking. If `input` value is not valid, it returns `null` value.
|
|
469
|
+
* Otherwise, there's no problem on the `input` value, Protocol Buffer binary
|
|
470
|
+
* data would be returned.
|
|
471
|
+
*
|
|
472
|
+
* If you can trust `input` value, or want to perform other type of validation,
|
|
473
|
+
* use below functions instead.
|
|
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
|
|
480
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
481
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
482
|
+
* would throw compilation errors.
|
|
483
|
+
*
|
|
484
|
+
* - [Restrictions of Protocol
|
|
485
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
486
|
+
*
|
|
487
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
488
|
+
* @template T Type of the value input
|
|
489
|
+
* @param input A value to encode
|
|
490
|
+
* @returns Encoded binary data
|
|
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 Protocol Buffer,
|
|
501
|
+
* with type checking. If `input` value is not valid, it returns `null` value.
|
|
502
|
+
* Otherwise, there's no problem on the `input` value, Protocol Buffer binary
|
|
503
|
+
* data would be returned.
|
|
504
|
+
*
|
|
505
|
+
* If you can trust `input` value, or want to perform other type of validation,
|
|
506
|
+
* use below functions instead.
|
|
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
|
|
513
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
514
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
515
|
+
* would throw compilation errors.
|
|
516
|
+
*
|
|
517
|
+
* - [Restrictions of Protocol
|
|
518
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
519
|
+
*
|
|
520
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
521
|
+
* @template T Type of the value input
|
|
522
|
+
* @param input A value to encode
|
|
523
|
+
* @returns Encoded binary data
|
|
524
|
+
*/
|
|
525
|
+
export function isEncode<T>(input: unknown): Uint8Array | null;
|
|
526
|
+
|
|
527
|
+
/** @internal */
|
|
528
|
+
export function isEncode(): never {
|
|
529
|
+
NoTransformConfigurationError("protobuf.isEncode");
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Protocol Buffer Encoder with type validation.
|
|
534
|
+
*
|
|
535
|
+
* `typia.protobuf.validateEncode()` is a combination function of
|
|
536
|
+
* {@link validation} and {@link encode}.
|
|
537
|
+
*
|
|
538
|
+
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
539
|
+
* with type validation. If `input` value is not valid, it returns
|
|
540
|
+
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
|
|
541
|
+
* there's no problem on the `input` value, Protocol Buffer binary data would be
|
|
542
|
+
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
543
|
+
* instance.
|
|
544
|
+
*
|
|
545
|
+
* If you can trust `input` value, or want to perform other type of validation,
|
|
546
|
+
* use below functions instead.
|
|
547
|
+
*
|
|
548
|
+
* - {@link encode}
|
|
549
|
+
* - {@link assertEncode}
|
|
550
|
+
* - {@link isEncode}
|
|
551
|
+
*
|
|
552
|
+
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
553
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
554
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
555
|
+
* would throw compilation errors.
|
|
556
|
+
*
|
|
557
|
+
* - [Restrictions of Protocol
|
|
558
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
559
|
+
*
|
|
560
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
561
|
+
* @template T Type of the value input
|
|
562
|
+
* @param input A value to encode
|
|
563
|
+
* @returns Encoded binary data
|
|
564
|
+
*/
|
|
565
|
+
export function validateEncode<T>(input: T): IValidation<Uint8Array>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Protocol Buffer Encoder with type validation.
|
|
569
|
+
*
|
|
570
|
+
* `typia.protobuf.validateEncode()` is a combination function of
|
|
571
|
+
* {@link validation} and {@link encode}.
|
|
572
|
+
*
|
|
573
|
+
* Therefore, it converts an `input` value to a binary data of Protocol Buffer,
|
|
574
|
+
* with type validation. If `input` value is not valid, it returns
|
|
575
|
+
* {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
|
|
576
|
+
* there's no problem on the `input` value, Protocol Buffer binary data would be
|
|
577
|
+
* stored in `data` property of the output {@link IValidation.ISuccess}
|
|
578
|
+
* instance.
|
|
579
|
+
*
|
|
580
|
+
* If you can trust `input` value, or want to perform other type of validation,
|
|
581
|
+
* use below functions instead.
|
|
582
|
+
*
|
|
583
|
+
* - {@link encode}
|
|
584
|
+
* - {@link assertEncode}
|
|
585
|
+
* - {@link isEncode}
|
|
586
|
+
*
|
|
587
|
+
* By the way, you know what? Expression power of Protocol Buffer is not enough
|
|
588
|
+
* strong to fully meet the TypeScript type specs. In such reason, if you put a
|
|
589
|
+
* TypeScript type that is not compatible with Protocol Buffer, this function
|
|
590
|
+
* would throw compilation errors.
|
|
591
|
+
*
|
|
592
|
+
* - [Restrictions of Protocol
|
|
593
|
+
* Buffer](https://typia.io/docs/protobuf/message/#restrictions)
|
|
594
|
+
*
|
|
595
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
596
|
+
* @template T Type of the value input
|
|
597
|
+
* @param input A value to encode
|
|
598
|
+
* @returns Encoded binary data
|
|
599
|
+
*/
|
|
600
|
+
export function validateEncode<T>(input: unknown): IValidation<Uint8Array>;
|
|
601
|
+
|
|
602
|
+
/** @internal */
|
|
603
|
+
export function validateEncode(): never {
|
|
604
|
+
NoTransformConfigurationError("protobuf.validateEncode");
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/* -----------------------------------------------------------
|
|
608
|
+
FACTORY FUNCTIONS
|
|
609
|
+
----------------------------------------------------------- */
|
|
610
|
+
/**
|
|
611
|
+
* Creates a reusable {@link decode} function.
|
|
612
|
+
*
|
|
613
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
614
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
615
|
+
* @throws Compile error
|
|
616
|
+
* @danger You must configure the generic argument `T`
|
|
617
|
+
*/
|
|
618
|
+
export function createDecode(): never;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Creates a reusable {@link decode} function.
|
|
622
|
+
*
|
|
623
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
624
|
+
* @template T Target type
|
|
625
|
+
* @returns A reusable `decode` function
|
|
626
|
+
*/
|
|
627
|
+
export function createDecode<T>(): (input: Uint8Array) => Resolved<T>;
|
|
628
|
+
|
|
629
|
+
/** @internal */
|
|
630
|
+
export function createDecode<T>(): (input: Uint8Array) => Resolved<T> {
|
|
631
|
+
NoTransformConfigurationError("protobuf.createDecode");
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Creates a reusable {@link isDecode} function.
|
|
636
|
+
*
|
|
637
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
638
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
639
|
+
* @throws Compile error
|
|
640
|
+
* @danger You must configure the generic argument `T`
|
|
641
|
+
*/
|
|
642
|
+
export function createIsDecode(): never;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Creates a reusable {@link isDecode} function.
|
|
646
|
+
*
|
|
647
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
648
|
+
* @template T Target type
|
|
649
|
+
* @returns A reusable `isDecode` function
|
|
650
|
+
*/
|
|
651
|
+
export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null;
|
|
652
|
+
|
|
653
|
+
/** @internal */
|
|
654
|
+
export function createIsDecode<T>(): (input: Uint8Array) => Resolved<T> | null {
|
|
655
|
+
NoTransformConfigurationError("protobuf.createIsDecode");
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Creates a reusable {@link assertDecode} function.
|
|
660
|
+
*
|
|
661
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
662
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
663
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
664
|
+
* @throws Compile error
|
|
665
|
+
* @danger You must configure the generic argument `T`
|
|
666
|
+
*/
|
|
667
|
+
export function createAssertDecode(
|
|
668
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
669
|
+
): never;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Creates a reusable {@link assertDecode} function.
|
|
673
|
+
*
|
|
674
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
675
|
+
* @template T Target type
|
|
676
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
677
|
+
* @returns A reusable `assertDecode` function
|
|
678
|
+
*/
|
|
679
|
+
export function createAssertDecode<T>(
|
|
680
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
681
|
+
): (input: Uint8Array) => Resolved<T>;
|
|
682
|
+
|
|
683
|
+
/** @internal */
|
|
684
|
+
export function createAssertDecode<T>(): (input: Uint8Array) => Resolved<T> {
|
|
685
|
+
NoTransformConfigurationError("protobuf.createAssertDecode");
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Creates a reusable {@link validateDecode} function.
|
|
690
|
+
*
|
|
691
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
692
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
693
|
+
* @throws Compile error
|
|
694
|
+
* @danger You must configure the generic argument `T`
|
|
695
|
+
*/
|
|
696
|
+
export function createValidateDecode(): never;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Creates a reusable {@link validateDecode} function.
|
|
700
|
+
*
|
|
701
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
702
|
+
* @template T Target type
|
|
703
|
+
* @returns A reusable `validateDecode` function
|
|
704
|
+
*/
|
|
705
|
+
export function createValidateDecode<T>(): (
|
|
706
|
+
input: Uint8Array,
|
|
707
|
+
) => IValidation<Resolved<T>>;
|
|
708
|
+
|
|
709
|
+
/** @internal */
|
|
710
|
+
export function createValidateDecode<T>(): (
|
|
711
|
+
input: Uint8Array,
|
|
712
|
+
) => IValidation<Resolved<T>> {
|
|
713
|
+
NoTransformConfigurationError("protobuf.createValidateDecode");
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Creates a reusable {@link encode} function.
|
|
718
|
+
*
|
|
719
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
720
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
721
|
+
* @throws Compile error
|
|
722
|
+
* @danger You must configure the generic argument `T`
|
|
723
|
+
*/
|
|
724
|
+
export function createEncode(): never;
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Creates a reusable {@link encode} function.
|
|
728
|
+
*
|
|
729
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
730
|
+
* @template T Target type
|
|
731
|
+
* @returns A reusable `encode` function
|
|
732
|
+
*/
|
|
733
|
+
export function createEncode<T>(): (input: T) => Uint8Array;
|
|
734
|
+
|
|
735
|
+
/** @internal */
|
|
736
|
+
export function createEncode<T>(): (input: T) => Uint8Array {
|
|
737
|
+
NoTransformConfigurationError("protobuf.createEncode");
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Creates a reusable {@link isEncode} function.
|
|
742
|
+
*
|
|
743
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
744
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
745
|
+
* @throws Compile error
|
|
746
|
+
* @danger You must configure the generic argument `T`
|
|
747
|
+
*/
|
|
748
|
+
export function createIsEncode(): never;
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Creates a reusable {@link isEncode} function.
|
|
752
|
+
*
|
|
753
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
754
|
+
* @template T Target type
|
|
755
|
+
* @returns A reusable `isEncode` function
|
|
756
|
+
*/
|
|
757
|
+
export function createIsEncode<T>(): (input: T) => Uint8Array | null;
|
|
758
|
+
|
|
759
|
+
/** @internal */
|
|
760
|
+
export function createIsEncode<T>(): (input: T) => Uint8Array | null {
|
|
761
|
+
NoTransformConfigurationError("protobuf.createIsEncode");
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Creates a reusable {@link assertEncode} function.
|
|
766
|
+
*
|
|
767
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
768
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
769
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
770
|
+
* @throws Compile error
|
|
771
|
+
* @danger You must configure the generic argument `T`
|
|
772
|
+
*/
|
|
773
|
+
export function createAssertEncode(
|
|
774
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
775
|
+
): never;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Creates a reusable {@link assertEncode} function.
|
|
779
|
+
*
|
|
780
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
781
|
+
* @template T Target type
|
|
782
|
+
* @param errorFactory Custom error factory. Default is `TypeGuardError`
|
|
783
|
+
* @returns A reusable `assertEncode` function
|
|
784
|
+
*/
|
|
785
|
+
export function createAssertEncode<T>(
|
|
786
|
+
errorFactory?: undefined | ((props: TypeGuardError.IProps) => Error),
|
|
787
|
+
): (input: T) => Uint8Array;
|
|
788
|
+
|
|
789
|
+
/** @internal */
|
|
790
|
+
export function createAssertEncode<T>(): (input: T) => Uint8Array {
|
|
791
|
+
NoTransformConfigurationError("protobuf.createAssertEncode");
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Creates a reusable {@link validateEncode} function.
|
|
796
|
+
*
|
|
797
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
798
|
+
* @returns Nothing until you configure the generic argument `T`
|
|
799
|
+
* @throws Compile error
|
|
800
|
+
* @danger You must configure the generic argument `T`
|
|
801
|
+
*/
|
|
802
|
+
export function createValidateEncode(): never;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Creates a reusable {@link validateEncode} function.
|
|
806
|
+
*
|
|
807
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
808
|
+
* @template T Target type
|
|
809
|
+
* @returns A reusable `validateEncode` function
|
|
810
|
+
*/
|
|
811
|
+
export function createValidateEncode<T>(): (
|
|
812
|
+
input: T,
|
|
813
|
+
) => IValidation<Uint8Array>;
|
|
814
|
+
|
|
815
|
+
/** @internal */
|
|
816
|
+
export function createValidateEncode<T>(): (
|
|
817
|
+
input: T,
|
|
818
|
+
) => IValidation<Uint8Array> {
|
|
819
|
+
NoTransformConfigurationError("protobuf.createValidateEncode");
|
|
820
|
+
}
|