typia 5.0.0-dev.20230820-2 → 5.0.0-dev.20230822
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/README.md +1 -1
- package/lib/factories/MetadataFactory.js +9 -0
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/ProtobufFactory.js +8 -0
- package/lib/factories/ProtobufFactory.js.map +1 -1
- package/lib/functional/$ProtobufReader.d.ts +2 -0
- package/lib/functional/$ProtobufReader.js +14 -3
- package/lib/functional/$ProtobufReader.js.map +1 -1
- package/lib/functional/$ProtobufSizer.js +1 -1
- package/lib/functional/$ProtobufSizer.js.map +1 -1
- package/lib/functional/$ProtobufWriter.js +0 -1
- package/lib/functional/$ProtobufWriter.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +15 -12
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/helpers/ProtobufUtil.d.ts +3 -1
- package/lib/programmers/helpers/ProtobufUtil.js +5 -1
- package/lib/programmers/helpers/ProtobufUtil.js.map +1 -1
- package/lib/programmers/helpers/RandomRanger.js +2 -2
- package/lib/programmers/helpers/RandomRanger.js.map +1 -1
- package/lib/programmers/internal/application_number.js +6 -1
- package/lib/programmers/internal/application_number.js.map +1 -1
- package/lib/programmers/internal/check_bigint.js +8 -11
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_number.js +12 -2
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/json/JsonValidateParseProgrammer.js +2 -3
- package/lib/programmers/json/JsonValidateParseProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js +2 -3
- package/lib/programmers/protobuf/ProtobufAssertDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +357 -6
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +15 -60
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js +1 -1
- package/lib/programmers/protobuf/ProtobufIsDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js +1 -1
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufValidateDecodeProgrammer.js +3 -4
- package/lib/programmers/protobuf/ProtobufValidateDecodeProgrammer.js.map +1 -1
- package/lib/protobuf.d.ts +8 -9
- package/lib/protobuf.js +7 -0
- package/lib/protobuf.js.map +1 -1
- package/package.json +1 -1
- package/src/factories/MetadataFactory.ts +12 -0
- package/src/factories/MetadataTagFactory.ts +1 -1
- package/src/factories/ProtobufFactory.ts +15 -0
- package/src/functional/$ProtobufReader.ts +21 -8
- package/src/functional/$ProtobufSizer.ts +4 -1
- package/src/functional/$ProtobufWriter.ts +1 -1
- package/src/programmers/RandomProgrammer.ts +14 -20
- package/src/programmers/helpers/ProtobufUtil.ts +6 -1
- package/src/programmers/helpers/RandomRanger.ts +2 -10
- package/src/programmers/internal/application_number.ts +5 -1
- package/src/programmers/internal/check_bigint.ts +30 -12
- package/src/programmers/internal/check_number.ts +30 -2
- package/src/programmers/json/JsonValidateParseProgrammer.ts +6 -13
- package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +10 -13
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +625 -10
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +39 -147
- package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +9 -9
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +1 -1
- package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +12 -20
- package/src/protobuf.ts +25 -15
|
@@ -7,13 +7,11 @@ import { ProtobufFactory } from "../../factories/ProtobufFactory";
|
|
|
7
7
|
import { StatementFactory } from "../../factories/StatementFactory";
|
|
8
8
|
import { TypeFactory } from "../../factories/TypeFactory";
|
|
9
9
|
|
|
10
|
-
import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
|
|
11
10
|
import { IMetadataTag } from "../../schemas/metadata/IMetadataTag";
|
|
12
11
|
import { Metadata } from "../../schemas/metadata/Metadata";
|
|
13
12
|
import { MetadataArray } from "../../schemas/metadata/MetadataArray";
|
|
14
13
|
import { MetadataObject } from "../../schemas/metadata/MetadataObject";
|
|
15
14
|
import { MetadataProperty } from "../../schemas/metadata/MetadataProperty";
|
|
16
|
-
import { MetadataTuple } from "../../schemas/metadata/MetadataTuple";
|
|
17
15
|
|
|
18
16
|
import { IProject } from "../../transformers/IProject";
|
|
19
17
|
|
|
@@ -24,7 +22,6 @@ import { IsProgrammer } from "../IsProgrammer";
|
|
|
24
22
|
import { FunctionImporter } from "../helpers/FunctionImporeter";
|
|
25
23
|
import { ProtobufUtil } from "../helpers/ProtobufUtil";
|
|
26
24
|
import { ProtobufWire } from "../helpers/ProtobufWire";
|
|
27
|
-
import { UnionExplorer } from "../helpers/UnionExplorer";
|
|
28
25
|
import { UnionPredicator } from "../helpers/UnionPredicator";
|
|
29
26
|
import { decode_union_object } from "../internal/decode_union_object";
|
|
30
27
|
|
|
@@ -107,7 +104,7 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
107
104
|
(meta: Metadata): ts.ArrowFunction => {
|
|
108
105
|
const functors = collection
|
|
109
106
|
.objects()
|
|
110
|
-
.filter((obj) =>
|
|
107
|
+
.filter((obj) => ProtobufUtil.isStaticObject(obj))
|
|
111
108
|
.map((obj) =>
|
|
112
109
|
StatementFactory.constant(
|
|
113
110
|
`${PREFIX}o${obj.index}`,
|
|
@@ -267,16 +264,18 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
267
264
|
);
|
|
268
265
|
|
|
269
266
|
// STARTS FROM ATOMIC TYPES
|
|
270
|
-
const unions: IUnion[] = ProtobufUtil.
|
|
271
|
-
type
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
ts.factory.
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
267
|
+
const unions: IUnion[] = ProtobufUtil.getAtomics(meta).map(
|
|
268
|
+
(type) => ({
|
|
269
|
+
type,
|
|
270
|
+
wire: () => null!,
|
|
271
|
+
is: () =>
|
|
272
|
+
ts.factory.createStrictEquality(
|
|
273
|
+
ts.factory.createStringLiteral(type),
|
|
274
|
+
ts.factory.createTypeOfExpression(input),
|
|
275
|
+
),
|
|
276
|
+
value: (index) => decode_atomic(index!)(input, type, tags),
|
|
277
|
+
}),
|
|
278
|
+
);
|
|
280
279
|
|
|
281
280
|
// CONSIDER BYTES
|
|
282
281
|
if (meta.natives.length)
|
|
@@ -287,15 +286,15 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
287
286
|
value: (index) => decode_bytes("bytes")(index!)(input),
|
|
288
287
|
});
|
|
289
288
|
|
|
290
|
-
// CONSIDER
|
|
291
|
-
if (meta.
|
|
289
|
+
// CONSIDER ARRAYS
|
|
290
|
+
if (meta.arrays.length)
|
|
292
291
|
unions.push({
|
|
293
|
-
type: "
|
|
294
|
-
is: () => ExpressionFactory.
|
|
292
|
+
type: "array",
|
|
293
|
+
is: () => ExpressionFactory.isArray(input),
|
|
295
294
|
value: (index) =>
|
|
296
|
-
|
|
295
|
+
decode_array(project)(importer)(index!)(
|
|
297
296
|
input,
|
|
298
|
-
meta.
|
|
297
|
+
meta.arrays[0]!,
|
|
299
298
|
{
|
|
300
299
|
...explore,
|
|
301
300
|
from: "array",
|
|
@@ -304,15 +303,15 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
304
303
|
),
|
|
305
304
|
});
|
|
306
305
|
|
|
307
|
-
// CONSIDER
|
|
308
|
-
if (meta.
|
|
306
|
+
// CONSIDER MAPS
|
|
307
|
+
if (meta.maps.length)
|
|
309
308
|
unions.push({
|
|
310
|
-
type: "
|
|
311
|
-
is: () => ExpressionFactory.
|
|
309
|
+
type: "map",
|
|
310
|
+
is: () => ExpressionFactory.isInstanceOf("Map")(input),
|
|
312
311
|
value: (index) =>
|
|
313
|
-
|
|
312
|
+
decode_map(project)(importer)(index!)(
|
|
314
313
|
input,
|
|
315
|
-
meta.
|
|
314
|
+
meta.maps[0]!,
|
|
316
315
|
{
|
|
317
316
|
...explore,
|
|
318
317
|
from: "array",
|
|
@@ -472,7 +471,7 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
472
471
|
: []),
|
|
473
472
|
ts.factory.createCallExpression(
|
|
474
473
|
ts.factory.createIdentifier(
|
|
475
|
-
`${PREFIX}o${object.index}
|
|
474
|
+
importer.useLocal(`${PREFIX}o${object.index}`),
|
|
476
475
|
),
|
|
477
476
|
[],
|
|
478
477
|
[input],
|
|
@@ -648,7 +647,7 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
648
647
|
)
|
|
649
648
|
return ProtobufWire.LEN;
|
|
650
649
|
|
|
651
|
-
const v = ProtobufUtil.
|
|
650
|
+
const v = ProtobufUtil.getAtomics(meta)[0]!;
|
|
652
651
|
if (v === "string") return ProtobufWire.LEN;
|
|
653
652
|
else if (v === "boolean" || v === "bigint") return ProtobufWire.VARIANT;
|
|
654
653
|
|
|
@@ -685,6 +684,9 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
685
684
|
const expected: string = `(${targets
|
|
686
685
|
.map((t) => t.name)
|
|
687
686
|
.join(" | ")})`;
|
|
687
|
+
const indexes: Map<MetadataObject, number> = new Map(
|
|
688
|
+
targets.map((t, i) => [t, index! + i]),
|
|
689
|
+
);
|
|
688
690
|
|
|
689
691
|
// POSSIBLE TO SPECIALIZE?
|
|
690
692
|
const specList = UnionPredicator.object(targets);
|
|
@@ -693,7 +695,12 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
693
695
|
IsProgrammer.decode_object(importer),
|
|
694
696
|
)((i, o, e) =>
|
|
695
697
|
ExpressionFactory.selfCall(
|
|
696
|
-
decode_object(project)(importer)(
|
|
698
|
+
decode_object(project)(importer)(indexes.get(o)!)(
|
|
699
|
+
i,
|
|
700
|
+
o,
|
|
701
|
+
e,
|
|
702
|
+
tags,
|
|
703
|
+
),
|
|
697
704
|
),
|
|
698
705
|
)((expr) => expr)((value, expected) =>
|
|
699
706
|
create_throw_error(importer)(expected)(value),
|
|
@@ -728,12 +735,9 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
728
735
|
pred,
|
|
729
736
|
ts.factory.createReturnStatement(
|
|
730
737
|
ExpressionFactory.selfCall(
|
|
731
|
-
decode_object(project)(importer)(
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
explore,
|
|
735
|
-
tags,
|
|
736
|
-
),
|
|
738
|
+
decode_object(project)(importer)(
|
|
739
|
+
indexes.get(spec.object)!,
|
|
740
|
+
)(input, spec.object, explore, tags),
|
|
737
741
|
),
|
|
738
742
|
),
|
|
739
743
|
i === array.length - 1
|
|
@@ -767,122 +771,10 @@ export namespace ProtobufEncodeProgrammer {
|
|
|
767
771
|
return ts.factory.createBlock([condition], true);
|
|
768
772
|
};
|
|
769
773
|
|
|
770
|
-
const explore_arrays =
|
|
771
|
-
(project: IProject) =>
|
|
772
|
-
(importer: FunctionImporter) =>
|
|
773
|
-
(index: number) =>
|
|
774
|
-
(
|
|
775
|
-
input: ts.Expression,
|
|
776
|
-
elements: MetadataArray[],
|
|
777
|
-
explore: FeatureProgrammer.IExplore,
|
|
778
|
-
tags: IMetadataTag[],
|
|
779
|
-
): ts.Block =>
|
|
780
|
-
elements.length === 1
|
|
781
|
-
? decode_array(project)(importer)(index)(
|
|
782
|
-
input,
|
|
783
|
-
elements[0]!,
|
|
784
|
-
explore,
|
|
785
|
-
tags,
|
|
786
|
-
)
|
|
787
|
-
: explore_array_like_union_types(importer)(
|
|
788
|
-
UnionExplorer.array({
|
|
789
|
-
checker: IsProgrammer.decode(project)(importer),
|
|
790
|
-
decoder: (input, target, explore, tags) =>
|
|
791
|
-
ts.factory.createCallExpression(
|
|
792
|
-
ts.factory.createArrowFunction(
|
|
793
|
-
undefined,
|
|
794
|
-
undefined,
|
|
795
|
-
[],
|
|
796
|
-
undefined,
|
|
797
|
-
undefined,
|
|
798
|
-
decode_array(project)(importer)(index)(
|
|
799
|
-
input,
|
|
800
|
-
target,
|
|
801
|
-
explore,
|
|
802
|
-
tags,
|
|
803
|
-
),
|
|
804
|
-
),
|
|
805
|
-
undefined,
|
|
806
|
-
undefined,
|
|
807
|
-
),
|
|
808
|
-
empty: ts.factory.createStringLiteral("[]"),
|
|
809
|
-
success: ts.factory.createTrue(),
|
|
810
|
-
failure: (input, expected) =>
|
|
811
|
-
create_throw_error(importer)(expected)(input),
|
|
812
|
-
}),
|
|
813
|
-
)(input, elements, explore, tags);
|
|
814
|
-
|
|
815
|
-
const explore_array_like_union_types =
|
|
816
|
-
(importer: FunctionImporter) =>
|
|
817
|
-
<T extends MetadataArray | MetadataTuple>(
|
|
818
|
-
factory: (
|
|
819
|
-
parameters: ts.ParameterDeclaration[],
|
|
820
|
-
) => (
|
|
821
|
-
input: ts.Expression,
|
|
822
|
-
elements: T[],
|
|
823
|
-
explore: FeatureProgrammer.IExplore,
|
|
824
|
-
tags: IMetadataTag[],
|
|
825
|
-
jsDocTags: IJsDocTagInfo[],
|
|
826
|
-
) => ts.ArrowFunction,
|
|
827
|
-
) =>
|
|
828
|
-
(
|
|
829
|
-
input: ts.Expression,
|
|
830
|
-
elements: T[],
|
|
831
|
-
explore: FeatureProgrammer.IExplore,
|
|
832
|
-
tags: IMetadataTag[],
|
|
833
|
-
): ts.Block => {
|
|
834
|
-
const arrow =
|
|
835
|
-
(parameters: ts.ParameterDeclaration[]) =>
|
|
836
|
-
(explore: FeatureProgrammer.IExplore) =>
|
|
837
|
-
(input: ts.Expression): ts.ArrowFunction =>
|
|
838
|
-
factory(parameters)(input, elements, explore, tags, []);
|
|
839
|
-
if (elements.every((e) => e.recursive === false))
|
|
840
|
-
return StatementFactory.block(
|
|
841
|
-
ts.factory.createCallExpression(
|
|
842
|
-
arrow([])(explore)(input),
|
|
843
|
-
undefined,
|
|
844
|
-
[],
|
|
845
|
-
),
|
|
846
|
-
);
|
|
847
|
-
|
|
848
|
-
explore = {
|
|
849
|
-
...explore,
|
|
850
|
-
source: "function",
|
|
851
|
-
from: "array",
|
|
852
|
-
};
|
|
853
|
-
return StatementFactory.block(
|
|
854
|
-
ts.factory.createCallExpression(
|
|
855
|
-
ts.factory.createIdentifier(
|
|
856
|
-
importer.emplaceUnion(
|
|
857
|
-
PREFIX,
|
|
858
|
-
elements.map((e) => e.name).join(" | "),
|
|
859
|
-
() =>
|
|
860
|
-
arrow(
|
|
861
|
-
FeatureProgrammer.parameterDeclarations(
|
|
862
|
-
CONFIG,
|
|
863
|
-
)(TypeFactory.keyword("any"))(
|
|
864
|
-
ts.factory.createIdentifier("input"),
|
|
865
|
-
),
|
|
866
|
-
)({
|
|
867
|
-
...explore,
|
|
868
|
-
postfix: "",
|
|
869
|
-
})(ts.factory.createIdentifier("input")),
|
|
870
|
-
),
|
|
871
|
-
),
|
|
872
|
-
undefined,
|
|
873
|
-
FeatureProgrammer.argumentsArray(CONFIG)(explore)(input),
|
|
874
|
-
),
|
|
875
|
-
);
|
|
876
|
-
};
|
|
877
|
-
|
|
878
774
|
/* -----------------------------------------------------------
|
|
879
775
|
CONFIGURATIONS
|
|
880
776
|
----------------------------------------------------------- */
|
|
881
777
|
const PREFIX = "$pe";
|
|
882
|
-
const CONFIG = {
|
|
883
|
-
path: false,
|
|
884
|
-
trace: false,
|
|
885
|
-
};
|
|
886
778
|
|
|
887
779
|
const create_throw_error =
|
|
888
780
|
(importer: FunctionImporter) =>
|
|
@@ -46,27 +46,27 @@ export namespace ProtobufIsDecodeProgrammer {
|
|
|
46
46
|
},
|
|
47
47
|
})(modulo)(type, name),
|
|
48
48
|
),
|
|
49
|
+
StatementFactory.constant(
|
|
50
|
+
"output",
|
|
51
|
+
ts.factory.createCallExpression(
|
|
52
|
+
ts.factory.createIdentifier("decode"),
|
|
53
|
+
undefined,
|
|
54
|
+
[ts.factory.createIdentifier("input")],
|
|
55
|
+
),
|
|
56
|
+
),
|
|
49
57
|
ts.factory.createIfStatement(
|
|
50
58
|
ts.factory.createPrefixUnaryExpression(
|
|
51
59
|
ts.SyntaxKind.ExclamationToken,
|
|
52
60
|
ts.factory.createCallExpression(
|
|
53
61
|
ts.factory.createIdentifier("is"),
|
|
54
62
|
undefined,
|
|
55
|
-
[ts.factory.createIdentifier("
|
|
63
|
+
[ts.factory.createIdentifier("output")],
|
|
56
64
|
),
|
|
57
65
|
),
|
|
58
66
|
ts.factory.createReturnStatement(
|
|
59
67
|
ts.factory.createNull(),
|
|
60
68
|
),
|
|
61
69
|
),
|
|
62
|
-
StatementFactory.constant(
|
|
63
|
-
"output",
|
|
64
|
-
ts.factory.createCallExpression(
|
|
65
|
-
ts.factory.createIdentifier("decode"),
|
|
66
|
-
undefined,
|
|
67
|
-
[ts.factory.createIdentifier("input")],
|
|
68
|
-
),
|
|
69
|
-
),
|
|
70
70
|
ts.factory.createReturnStatement(
|
|
71
71
|
ts.factory.createIdentifier("output"),
|
|
72
72
|
),
|
|
@@ -108,7 +108,7 @@ export namespace ProtobufMessageProgrammer {
|
|
|
108
108
|
(meta: Metadata): string => {
|
|
109
109
|
const elements: Set<string> = new Set();
|
|
110
110
|
if (meta.natives.length) elements.add("bytes");
|
|
111
|
-
for (const atomic of ProtobufUtil.
|
|
111
|
+
for (const atomic of ProtobufUtil.getAtomics(meta))
|
|
112
112
|
elements.add(decode_atomic(tags)(atomic));
|
|
113
113
|
for (const array of meta.arrays)
|
|
114
114
|
elements.add(`repeated ${decode(ptr)(tags)(array.value)}`);
|
|
@@ -24,7 +24,9 @@ export namespace ProtobufValidateDecodeProgrammer {
|
|
|
24
24
|
),
|
|
25
25
|
],
|
|
26
26
|
ts.factory.createTypeReferenceNode(
|
|
27
|
-
|
|
27
|
+
`typia.IValidation<${
|
|
28
|
+
name ?? TypeFactory.getFullName(project.checker)(type)
|
|
29
|
+
}>`,
|
|
28
30
|
),
|
|
29
31
|
undefined,
|
|
30
32
|
ts.factory.createBlock([
|
|
@@ -52,32 +54,22 @@ export namespace ProtobufValidateDecodeProgrammer {
|
|
|
52
54
|
),
|
|
53
55
|
StatementFactory.constant(
|
|
54
56
|
"output",
|
|
57
|
+
ts.factory.createCallExpression(
|
|
58
|
+
ts.factory.createIdentifier("decode"),
|
|
59
|
+
undefined,
|
|
60
|
+
[ts.factory.createIdentifier("input")],
|
|
61
|
+
),
|
|
62
|
+
),
|
|
63
|
+
ts.factory.createReturnStatement(
|
|
55
64
|
ts.factory.createAsExpression(
|
|
56
65
|
ts.factory.createCallExpression(
|
|
57
66
|
ts.factory.createIdentifier("validate"),
|
|
58
67
|
undefined,
|
|
59
|
-
[ts.factory.createIdentifier("
|
|
60
|
-
),
|
|
61
|
-
TypeFactory.keyword("any"),
|
|
62
|
-
),
|
|
63
|
-
),
|
|
64
|
-
ts.factory.createIfStatement(
|
|
65
|
-
ts.factory.createIdentifier("output.success"),
|
|
66
|
-
ts.factory.createExpressionStatement(
|
|
67
|
-
ts.factory.createBinaryExpression(
|
|
68
|
-
ts.factory.createIdentifier("output.data"),
|
|
69
|
-
ts.SyntaxKind.EqualsToken,
|
|
70
|
-
ts.factory.createCallExpression(
|
|
71
|
-
ts.factory.createIdentifier("decode"),
|
|
72
|
-
undefined,
|
|
73
|
-
[ts.factory.createIdentifier("input")],
|
|
74
|
-
),
|
|
68
|
+
[ts.factory.createIdentifier("output")],
|
|
75
69
|
),
|
|
70
|
+
ts.factory.createTypeReferenceNode("any"),
|
|
76
71
|
),
|
|
77
72
|
),
|
|
78
|
-
ts.factory.createReturnStatement(
|
|
79
|
-
ts.factory.createIdentifier("output"),
|
|
80
|
-
),
|
|
81
73
|
]),
|
|
82
74
|
);
|
|
83
75
|
}
|
package/src/protobuf.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Namespace } from "./functional/Namespace";
|
|
2
2
|
|
|
3
3
|
import { IValidation } from "./IValidation";
|
|
4
|
-
import { Primitive } from "./Primitive";
|
|
5
4
|
|
|
6
5
|
/* ===========================================================
|
|
7
6
|
PROTOCOL BUFFER
|
|
@@ -28,7 +27,7 @@ export function message(): never {
|
|
|
28
27
|
----------------------------------------------------------- */
|
|
29
28
|
export function decode(input: Uint8Array): never;
|
|
30
29
|
|
|
31
|
-
export function decode<T>(input: Uint8Array):
|
|
30
|
+
export function decode<T>(input: Uint8Array): T;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* @internal
|
|
@@ -40,7 +39,7 @@ Object.assign(decode, Namespace.protobuf.decode("decode"));
|
|
|
40
39
|
|
|
41
40
|
export function isDecode(input: Uint8Array): never;
|
|
42
41
|
|
|
43
|
-
export function isDecode<T>(input: Uint8Array):
|
|
42
|
+
export function isDecode<T>(input: Uint8Array): T | null;
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* @internal
|
|
@@ -53,7 +52,7 @@ Object.assign(isDecode, Namespace.protobuf.decode("isDecode"));
|
|
|
53
52
|
|
|
54
53
|
export function assertDecode(input: Uint8Array): never;
|
|
55
54
|
|
|
56
|
-
export function assertDecode<T>(input: Uint8Array):
|
|
55
|
+
export function assertDecode<T>(input: Uint8Array): T;
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
58
|
* @internal
|
|
@@ -66,7 +65,7 @@ Object.assign(assertDecode, Namespace.protobuf.decode("assertDecode"));
|
|
|
66
65
|
|
|
67
66
|
export function validateDecode(input: Uint8Array): never;
|
|
68
67
|
|
|
69
|
-
export function validateDecode<T>(input: Uint8Array): IValidation<
|
|
68
|
+
export function validateDecode<T>(input: Uint8Array): IValidation<T>;
|
|
70
69
|
|
|
71
70
|
/**
|
|
72
71
|
* @internal
|
|
@@ -127,50 +126,61 @@ Object.assign(validateEncode, Namespace.protobuf.encode("validateEncode"));
|
|
|
127
126
|
FACTORY FUNCTIONS
|
|
128
127
|
----------------------------------------------------------- */
|
|
129
128
|
export function createDecode(): never;
|
|
130
|
-
export function createDecode<T>(): (input: Uint8Array) =>
|
|
129
|
+
export function createDecode<T>(): (input: Uint8Array) => T;
|
|
131
130
|
|
|
132
131
|
/**
|
|
133
132
|
* @internal
|
|
134
133
|
*/
|
|
135
|
-
export function createDecode<T>(): (input: Uint8Array) =>
|
|
134
|
+
export function createDecode<T>(): (input: Uint8Array) => T {
|
|
136
135
|
halt("createDecode");
|
|
137
136
|
}
|
|
137
|
+
Object.assign(createDecode, Namespace.protobuf.decode("createDecode"));
|
|
138
138
|
|
|
139
139
|
export function createIsDecode(): never;
|
|
140
|
-
export function createIsDecode<T>(): (input: Uint8Array) =>
|
|
140
|
+
export function createIsDecode<T>(): (input: Uint8Array) => T | null;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* @internal
|
|
144
144
|
*/
|
|
145
|
-
export function createIsDecode<T>(): (
|
|
146
|
-
input: Uint8Array,
|
|
147
|
-
) => Primitive<T> | null {
|
|
145
|
+
export function createIsDecode<T>(): (input: Uint8Array) => T | null {
|
|
148
146
|
halt("createIsDecode");
|
|
149
147
|
}
|
|
148
|
+
Object.assign(createIsDecode, Namespace.is());
|
|
149
|
+
Object.assign(createIsDecode, Namespace.protobuf.decode("createIsDecode"));
|
|
150
150
|
|
|
151
151
|
export function createAssertDecode(): never;
|
|
152
|
-
export function createAssertDecode<T>(): (input: Uint8Array) =>
|
|
152
|
+
export function createAssertDecode<T>(): (input: Uint8Array) => T;
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* @internal
|
|
156
156
|
*/
|
|
157
|
-
export function createAssertDecode<T>(): (input: Uint8Array) =>
|
|
157
|
+
export function createAssertDecode<T>(): (input: Uint8Array) => T {
|
|
158
158
|
halt("createAssertDecode");
|
|
159
159
|
}
|
|
160
|
+
Object.assign(createAssertDecode, Namespace.assert("createAssertDecode"));
|
|
161
|
+
Object.assign(
|
|
162
|
+
createAssertDecode,
|
|
163
|
+
Namespace.protobuf.decode("createAssertDecode"),
|
|
164
|
+
);
|
|
160
165
|
|
|
161
166
|
export function createValidateDecode(): never;
|
|
162
167
|
export function createValidateDecode<T>(): (
|
|
163
168
|
input: Uint8Array,
|
|
164
|
-
) => IValidation<
|
|
169
|
+
) => IValidation<T>;
|
|
165
170
|
|
|
166
171
|
/**
|
|
167
172
|
* @internal
|
|
168
173
|
*/
|
|
169
174
|
export function createValidateDecode<T>(): (
|
|
170
175
|
input: Uint8Array,
|
|
171
|
-
) => IValidation<
|
|
176
|
+
) => IValidation<T> {
|
|
172
177
|
halt("createValidateDecode");
|
|
173
178
|
}
|
|
179
|
+
Object.assign(createValidateDecode, Namespace.validate());
|
|
180
|
+
Object.assign(
|
|
181
|
+
createValidateDecode,
|
|
182
|
+
Namespace.protobuf.decode("createValidateDecode"),
|
|
183
|
+
);
|
|
174
184
|
|
|
175
185
|
export function createEncode(): never;
|
|
176
186
|
export function createEncode<T>(): (input: T) => Uint8Array;
|