typia 3.4.15 → 3.5.0-dev.20221222
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 +48 -7
- package/lib/factories/MetadataCollection.d.ts +1 -9
- package/lib/factories/MetadataCollection.js +2 -75
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/ProtocolFactory.d.ts +8 -0
- package/lib/factories/ProtocolFactory.js +119 -0
- package/lib/factories/ProtocolFactory.js.map +1 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +11 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +76 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +1 -0
- package/lib/factories/internal/protocols/emplace_protocol_object.d.ts +3 -0
- package/lib/factories/internal/protocols/emplace_protocol_object.js +47 -0
- package/lib/factories/internal/protocols/emplace_protocol_object.js.map +1 -0
- package/lib/factories/internal/protocols/emplace_protocol_property.d.ts +4 -0
- package/lib/factories/internal/protocols/emplace_protocol_property.js +20 -0
- package/lib/factories/internal/protocols/emplace_protocol_property.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_atomic.d.ts +3 -0
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js +69 -0
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_constant.d.ts +2 -0
- package/lib/factories/internal/protocols/iterate_protocol_constant.js +30 -0
- package/lib/factories/internal/protocols/iterate_protocol_constant.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_main.d.ts +3 -0
- package/lib/factories/internal/protocols/iterate_protocol_main.js +17 -0
- package/lib/factories/internal/protocols/iterate_protocol_main.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +3 -0
- package/lib/factories/internal/protocols/iterate_protocol_map.js +71 -0
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_metadata.d.ts +5 -0
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +192 -0
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_native.d.ts +2 -0
- package/lib/factories/internal/protocols/iterate_protocol_native.js +33 -0
- package/lib/factories/internal/protocols/iterate_protocol_native.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +4 -0
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +24 -0
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_tuple.d.ts +3 -0
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js +46 -0
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +1 -0
- package/lib/functional/$proto_bytes.d.ts +2 -0
- package/lib/functional/$proto_bytes.js +37 -0
- package/lib/functional/$proto_bytes.js.map +1 -0
- package/lib/functional/$proto_field.d.ts +10 -0
- package/lib/functional/$proto_field.js +42 -0
- package/lib/functional/$proto_field.js.map +1 -0
- package/lib/functional/$proto_float.d.ts +4 -0
- package/lib/functional/$proto_float.js +28 -0
- package/lib/functional/$proto_float.js.map +1 -0
- package/lib/functional/$proto_i32.d.ts +2 -0
- package/lib/functional/$proto_i32.js +23 -0
- package/lib/functional/$proto_i32.js.map +1 -0
- package/lib/functional/$proto_i64.d.ts +2 -0
- package/lib/functional/$proto_i64.js +31 -0
- package/lib/functional/$proto_i64.js.map +1 -0
- package/lib/functional/$proto_size.d.ts +6 -0
- package/lib/functional/$proto_size.js +76 -0
- package/lib/functional/$proto_size.js.map +1 -0
- package/lib/functional/$proto_string.d.ts +2 -0
- package/lib/functional/$proto_string.js +34 -0
- package/lib/functional/$proto_string.js.map +1 -0
- package/lib/functional/$varint.d.ts +6 -0
- package/lib/functional/$varint.js +99 -0
- package/lib/functional/$varint.js.map +1 -0
- package/lib/functional/$zigzag.d.ts +4 -0
- package/lib/functional/$zigzag.js +34 -0
- package/lib/functional/$zigzag.js.map +1 -0
- package/lib/messages/IProtocolMessage.d.ts +5 -0
- package/lib/messages/IProtocolMessage.js +3 -0
- package/lib/messages/IProtocolMessage.js.map +1 -0
- package/lib/messages/IProtocolProperty.d.ts +11 -0
- package/lib/messages/IProtocolProperty.js +3 -0
- package/lib/messages/IProtocolProperty.js.map +1 -0
- package/lib/metadata/IMetadataTag.d.ts +7 -3
- package/lib/metadata/Metadata.js +1 -1
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/module.d.ts +2 -0
- package/lib/module.js +5 -1
- package/lib/module.js.map +1 -1
- package/lib/programmers/MessageProgrammer.d.ts +5 -0
- package/lib/programmers/MessageProgrammer.js +134 -0
- package/lib/programmers/MessageProgrammer.js.map +1 -0
- package/lib/programmers/internal/application_object.js +9 -9
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +5 -3
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +3 -1
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +1 -3
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/protocols/MessageTransformer.d.ts +5 -0
- package/lib/transformers/features/protocols/MessageTransformer.js +17 -0
- package/lib/transformers/features/protocols/MessageTransformer.js.map +1 -0
- package/lib/utils/NameEncoder.d.ts +4 -0
- package/lib/utils/NameEncoder.js +89 -0
- package/lib/utils/NameEncoder.js.map +1 -0
- package/package.json +2 -3
- package/src/executable/internal/TypiaSetupWizard.ts +173 -173
- package/src/factories/MetadataCollection.ts +83 -122
- package/src/factories/MetadataFactory.ts +47 -47
- package/src/factories/MetadataTagFactory.ts +351 -351
- package/src/factories/ProtocolFactory.ts +92 -0
- package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
- package/src/factories/internal/metadata/emplace_metadata_object.ts +140 -140
- package/src/factories/internal/metadata/explore_metadata.ts +92 -92
- package/src/factories/internal/metadata/iterate_metadata.ts +80 -80
- package/src/factories/internal/metadata/iterate_metadata_array.ts +29 -29
- package/src/factories/internal/metadata/iterate_metadata_atomic.ts +59 -59
- package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
- package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
- package/src/factories/internal/metadata/iterate_metadata_native.ts +227 -227
- package/src/factories/internal/metadata/iterate_metadata_object.ts +48 -48
- package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
- package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
- package/src/factories/internal/metadata/iterate_metadata_template.ts +38 -38
- package/src/factories/internal/metadata/iterate_metadata_tuple.ts +45 -45
- package/src/factories/internal/metadata/iterate_metadata_union.ts +59 -59
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +81 -0
- package/src/factories/internal/protocols/emplace_protocol_object.ts +25 -0
- package/src/factories/internal/protocols/emplace_protocol_property.ts +12 -0
- package/src/factories/internal/protocols/iterate_protocol_atomic.ts +34 -0
- package/src/factories/internal/protocols/iterate_protocol_constant.ts +27 -0
- package/src/factories/internal/protocols/iterate_protocol_main.ts +19 -0
- package/src/factories/internal/protocols/iterate_protocol_map.ts +38 -0
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +76 -0
- package/src/factories/internal/protocols/iterate_protocol_native.ts +34 -0
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +25 -0
- package/src/factories/internal/protocols/iterate_protocol_tuple.ts +25 -0
- package/src/functional/$number.ts +12 -12
- package/src/functional/$proto_bytes.ts +25 -0
- package/src/functional/$proto_field.ts +30 -0
- package/src/functional/$proto_float.ts +37 -0
- package/src/functional/$proto_i32.ts +29 -0
- package/src/functional/$proto_i64.ts +37 -0
- package/src/functional/$proto_size.ts +82 -0
- package/src/functional/$proto_string.ts +24 -0
- package/src/functional/$varint.ts +130 -0
- package/src/functional/$zigzag.ts +39 -0
- package/src/messages/IProtocolMessage.ts +6 -0
- package/src/messages/IProtocolProperty.ts +11 -0
- package/src/metadata/IMetadataTag.ts +137 -122
- package/src/metadata/Metadata.ts +479 -477
- package/src/module.ts +1547 -1535
- package/src/programmers/AssertParseProgrammer.ts +55 -55
- package/src/programmers/AssertProgrammer.ts +445 -445
- package/src/programmers/AssertStringifyProgrammer.ts +65 -65
- package/src/programmers/CheckerProgrammer.ts +810 -810
- package/src/programmers/IsParseProgrammer.ts +61 -61
- package/src/programmers/IsProgrammer.ts +175 -175
- package/src/programmers/IsStringifyProgrammer.ts +69 -69
- package/src/programmers/MessageProgrammer.ts +116 -0
- package/src/programmers/StringifyProgrammer.ts +762 -762
- package/src/programmers/ValidateParseProgrammer.ts +59 -59
- package/src/programmers/ValidateProgrammer.ts +237 -237
- package/src/programmers/ValidateStringifyProgrammer.ts +80 -80
- package/src/programmers/helpers/OptionPredicator.ts +15 -15
- package/src/programmers/internal/application_default.ts +17 -17
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +231 -228
- package/src/programmers/internal/check_bigint.ts +85 -85
- package/src/programmers/internal/check_number.ts +175 -175
- package/src/schemas/IJsonSchema.ts +90 -90
- package/src/transformers/CallExpressionTransformer.ts +131 -124
- package/src/transformers/ITransformOptions.ts +47 -47
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +117 -119
- package/src/transformers/features/protocols/MessageTransformer.ts +32 -0
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +46 -46
- package/src/utils/NameEncoder.ts +32 -0
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
-
|
|
7
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
-
import { iterate_metadata_array } from "./iterate_metadata_array";
|
|
10
|
-
import { iterate_metadata_atomic } from "./iterate_metadata_atomic";
|
|
11
|
-
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
12
|
-
import { iterate_metadata_constant } from "./iterate_metadata_constant";
|
|
13
|
-
import { iterate_metadata_map } from "./iterate_metadata_map";
|
|
14
|
-
import { iterate_metadata_native } from "./iterate_metadata_native";
|
|
15
|
-
import { iterate_metadata_object } from "./iterate_metadata_object";
|
|
16
|
-
import { iterate_metadata_resolve } from "./iterate_metadata_resolve";
|
|
17
|
-
import { iterate_metadata_set } from "./iterate_metadata_set";
|
|
18
|
-
import { iterate_metadata_template } from "./iterate_metadata_template";
|
|
19
|
-
import { iterate_metadata_tuple } from "./iterate_metadata_tuple";
|
|
20
|
-
import { iterate_metadata_union } from "./iterate_metadata_union";
|
|
21
|
-
|
|
22
|
-
export const iterate_metadata =
|
|
23
|
-
(checker: ts.TypeChecker) =>
|
|
24
|
-
(options: MetadataFactory.IOptions) =>
|
|
25
|
-
(collection: MetadataCollection) =>
|
|
26
|
-
(meta: Metadata, type: ts.Type, parentResolved: boolean): void => {
|
|
27
|
-
if (type.isTypeParameter() === true)
|
|
28
|
-
throw new Error(
|
|
29
|
-
`Error on typia.MetadataFactory.generate(): non-specified generic argument on ${meta.getName()}.`,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// CHECK UNION & toJSON()
|
|
33
|
-
if (
|
|
34
|
-
iterate_metadata_union(checker)(options)(collection)(
|
|
35
|
-
meta,
|
|
36
|
-
type,
|
|
37
|
-
parentResolved,
|
|
38
|
-
) ||
|
|
39
|
-
iterate_metadata_resolve(checker)(options)(collection)(
|
|
40
|
-
meta,
|
|
41
|
-
type,
|
|
42
|
-
parentResolved,
|
|
43
|
-
)
|
|
44
|
-
)
|
|
45
|
-
return;
|
|
46
|
-
|
|
47
|
-
// VALIDATE NODE
|
|
48
|
-
const node: ts.TypeNode | undefined = checker.typeToTypeNode(
|
|
49
|
-
type,
|
|
50
|
-
undefined,
|
|
51
|
-
undefined,
|
|
52
|
-
);
|
|
53
|
-
if (node === undefined) {
|
|
54
|
-
// EMPTY TUPLE CASE CAN BE
|
|
55
|
-
ArrayUtil.set(meta.tuples, [], () => "[]");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ITERATE CASES
|
|
60
|
-
iterate_metadata_coalesce(meta, type) ||
|
|
61
|
-
iterate_metadata_constant(checker)(options)(meta, type) ||
|
|
62
|
-
iterate_metadata_template(checker)(options)(collection)(
|
|
63
|
-
meta,
|
|
64
|
-
type,
|
|
65
|
-
) ||
|
|
66
|
-
iterate_metadata_atomic(meta, type) ||
|
|
67
|
-
iterate_metadata_tuple(checker)(options)(collection)(
|
|
68
|
-
meta,
|
|
69
|
-
type as ts.TupleType,
|
|
70
|
-
) ||
|
|
71
|
-
iterate_metadata_array(checker)(options)(collection)(meta, type) ||
|
|
72
|
-
iterate_metadata_native(checker)(meta, type) ||
|
|
73
|
-
iterate_metadata_map(checker)(options)(collection)(meta, type) ||
|
|
74
|
-
iterate_metadata_set(checker)(options)(collection)(meta, type) ||
|
|
75
|
-
iterate_metadata_object(checker)(options)(collection)(
|
|
76
|
-
meta,
|
|
77
|
-
type,
|
|
78
|
-
parentResolved,
|
|
79
|
-
);
|
|
80
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
+
|
|
7
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
+
import { iterate_metadata_array } from "./iterate_metadata_array";
|
|
10
|
+
import { iterate_metadata_atomic } from "./iterate_metadata_atomic";
|
|
11
|
+
import { iterate_metadata_coalesce } from "./iterate_metadata_coalesce";
|
|
12
|
+
import { iterate_metadata_constant } from "./iterate_metadata_constant";
|
|
13
|
+
import { iterate_metadata_map } from "./iterate_metadata_map";
|
|
14
|
+
import { iterate_metadata_native } from "./iterate_metadata_native";
|
|
15
|
+
import { iterate_metadata_object } from "./iterate_metadata_object";
|
|
16
|
+
import { iterate_metadata_resolve } from "./iterate_metadata_resolve";
|
|
17
|
+
import { iterate_metadata_set } from "./iterate_metadata_set";
|
|
18
|
+
import { iterate_metadata_template } from "./iterate_metadata_template";
|
|
19
|
+
import { iterate_metadata_tuple } from "./iterate_metadata_tuple";
|
|
20
|
+
import { iterate_metadata_union } from "./iterate_metadata_union";
|
|
21
|
+
|
|
22
|
+
export const iterate_metadata =
|
|
23
|
+
(checker: ts.TypeChecker) =>
|
|
24
|
+
(options: MetadataFactory.IOptions) =>
|
|
25
|
+
(collection: MetadataCollection) =>
|
|
26
|
+
(meta: Metadata, type: ts.Type, parentResolved: boolean): void => {
|
|
27
|
+
if (type.isTypeParameter() === true)
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Error on typia.MetadataFactory.generate(): non-specified generic argument on ${meta.getName()}.`,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// CHECK UNION & toJSON()
|
|
33
|
+
if (
|
|
34
|
+
iterate_metadata_union(checker)(options)(collection)(
|
|
35
|
+
meta,
|
|
36
|
+
type,
|
|
37
|
+
parentResolved,
|
|
38
|
+
) ||
|
|
39
|
+
iterate_metadata_resolve(checker)(options)(collection)(
|
|
40
|
+
meta,
|
|
41
|
+
type,
|
|
42
|
+
parentResolved,
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
return;
|
|
46
|
+
|
|
47
|
+
// VALIDATE NODE
|
|
48
|
+
const node: ts.TypeNode | undefined = checker.typeToTypeNode(
|
|
49
|
+
type,
|
|
50
|
+
undefined,
|
|
51
|
+
undefined,
|
|
52
|
+
);
|
|
53
|
+
if (node === undefined) {
|
|
54
|
+
// EMPTY TUPLE CASE CAN BE
|
|
55
|
+
ArrayUtil.set(meta.tuples, [], () => "[]");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ITERATE CASES
|
|
60
|
+
iterate_metadata_coalesce(meta, type) ||
|
|
61
|
+
iterate_metadata_constant(checker)(options)(meta, type) ||
|
|
62
|
+
iterate_metadata_template(checker)(options)(collection)(
|
|
63
|
+
meta,
|
|
64
|
+
type,
|
|
65
|
+
) ||
|
|
66
|
+
iterate_metadata_atomic(meta, type) ||
|
|
67
|
+
iterate_metadata_tuple(checker)(options)(collection)(
|
|
68
|
+
meta,
|
|
69
|
+
type as ts.TupleType,
|
|
70
|
+
) ||
|
|
71
|
+
iterate_metadata_array(checker)(options)(collection)(meta, type) ||
|
|
72
|
+
iterate_metadata_native(checker)(meta, type) ||
|
|
73
|
+
iterate_metadata_map(checker)(options)(collection)(meta, type) ||
|
|
74
|
+
iterate_metadata_set(checker)(options)(collection)(meta, type) ||
|
|
75
|
+
iterate_metadata_object(checker)(options)(collection)(
|
|
76
|
+
meta,
|
|
77
|
+
type,
|
|
78
|
+
parentResolved,
|
|
79
|
+
);
|
|
80
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
-
|
|
7
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
-
import { explore_metadata } from "./explore_metadata";
|
|
10
|
-
|
|
11
|
-
export const iterate_metadata_array =
|
|
12
|
-
(checker: ts.TypeChecker) =>
|
|
13
|
-
(options: MetadataFactory.IOptions) =>
|
|
14
|
-
(collection: MetadataCollection) =>
|
|
15
|
-
(meta: Metadata, type: ts.Type): boolean => {
|
|
16
|
-
if (
|
|
17
|
-
!(checker as any).isArrayType(type) &&
|
|
18
|
-
!(checker as any).isArrayLikeType(type)
|
|
19
|
-
)
|
|
20
|
-
return false;
|
|
21
|
-
|
|
22
|
-
const value: ts.Type | null = type.getNumberIndexType() || null;
|
|
23
|
-
ArrayUtil.set(
|
|
24
|
-
meta.arrays,
|
|
25
|
-
explore_metadata(checker)(options)(collection)(value, false),
|
|
26
|
-
(elem) => elem.getName(),
|
|
27
|
-
);
|
|
28
|
-
return true;
|
|
29
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
+
|
|
7
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
+
import { explore_metadata } from "./explore_metadata";
|
|
10
|
+
|
|
11
|
+
export const iterate_metadata_array =
|
|
12
|
+
(checker: ts.TypeChecker) =>
|
|
13
|
+
(options: MetadataFactory.IOptions) =>
|
|
14
|
+
(collection: MetadataCollection) =>
|
|
15
|
+
(meta: Metadata, type: ts.Type): boolean => {
|
|
16
|
+
if (
|
|
17
|
+
!(checker as any).isArrayType(type) &&
|
|
18
|
+
!(checker as any).isArrayLikeType(type)
|
|
19
|
+
)
|
|
20
|
+
return false;
|
|
21
|
+
|
|
22
|
+
const value: ts.Type | null = type.getNumberIndexType() || null;
|
|
23
|
+
ArrayUtil.set(
|
|
24
|
+
meta.arrays,
|
|
25
|
+
explore_metadata(checker)(options)(collection)(value, false),
|
|
26
|
+
(elem) => elem.getName(),
|
|
27
|
+
);
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { Atomic } from "../../../typings/Atomic";
|
|
6
|
-
|
|
7
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
8
|
-
|
|
9
|
-
const same = (type: ts.Type | null) => {
|
|
10
|
-
if (type === null) return () => false;
|
|
11
|
-
return (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const iterate_metadata_atomic = (
|
|
15
|
-
meta: Metadata,
|
|
16
|
-
type: ts.Type,
|
|
17
|
-
): boolean => {
|
|
18
|
-
// PREPARE INTERNAL FUNCTIONS
|
|
19
|
-
const filter = same(type);
|
|
20
|
-
const check = (info: IAtomicInfo) => {
|
|
21
|
-
if (filter(info.atomic) || filter(info.literal)) {
|
|
22
|
-
ArrayUtil.add(meta.atomics, info.name);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// CHECK EACH TYPES
|
|
29
|
-
return ATOMICS.some((info) => check(info));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const ATOMICS: IAtomicInfo[] = [
|
|
33
|
-
{
|
|
34
|
-
name: "boolean",
|
|
35
|
-
atomic: ts.TypeFlags.BooleanLike,
|
|
36
|
-
literal: ts.TypeFlags.BooleanLiteral,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "number",
|
|
40
|
-
atomic: ts.TypeFlags.NumberLike,
|
|
41
|
-
literal: ts.TypeFlags.NumberLiteral,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "bigint",
|
|
45
|
-
atomic: ts.TypeFlags.BigInt,
|
|
46
|
-
literal: ts.TypeFlags.BigIntLiteral,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: "string",
|
|
50
|
-
atomic: ts.TypeFlags.StringLike,
|
|
51
|
-
literal: ts.TypeFlags.StringLiteral,
|
|
52
|
-
},
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
interface IAtomicInfo {
|
|
56
|
-
name: Atomic.Literal;
|
|
57
|
-
atomic: ts.TypeFlags;
|
|
58
|
-
literal: ts.TypeFlags;
|
|
59
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { Atomic } from "../../../typings/Atomic";
|
|
6
|
+
|
|
7
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
8
|
+
|
|
9
|
+
const same = (type: ts.Type | null) => {
|
|
10
|
+
if (type === null) return () => false;
|
|
11
|
+
return (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const iterate_metadata_atomic = (
|
|
15
|
+
meta: Metadata,
|
|
16
|
+
type: ts.Type,
|
|
17
|
+
): boolean => {
|
|
18
|
+
// PREPARE INTERNAL FUNCTIONS
|
|
19
|
+
const filter = same(type);
|
|
20
|
+
const check = (info: IAtomicInfo) => {
|
|
21
|
+
if (filter(info.atomic) || filter(info.literal)) {
|
|
22
|
+
ArrayUtil.add(meta.atomics, info.name);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// CHECK EACH TYPES
|
|
29
|
+
return ATOMICS.some((info) => check(info));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const ATOMICS: IAtomicInfo[] = [
|
|
33
|
+
{
|
|
34
|
+
name: "boolean",
|
|
35
|
+
atomic: ts.TypeFlags.BooleanLike,
|
|
36
|
+
literal: ts.TypeFlags.BooleanLiteral,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "number",
|
|
40
|
+
atomic: ts.TypeFlags.NumberLike,
|
|
41
|
+
literal: ts.TypeFlags.NumberLiteral,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "bigint",
|
|
45
|
+
atomic: ts.TypeFlags.BigInt,
|
|
46
|
+
literal: ts.TypeFlags.BigIntLiteral,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "string",
|
|
50
|
+
atomic: ts.TypeFlags.StringLike,
|
|
51
|
+
literal: ts.TypeFlags.StringLiteral,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
interface IAtomicInfo {
|
|
56
|
+
name: Atomic.Literal;
|
|
57
|
+
atomic: ts.TypeFlags;
|
|
58
|
+
literal: ts.TypeFlags;
|
|
59
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { Writable } from "../../../typings/Writable";
|
|
6
|
-
|
|
7
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
-
|
|
9
|
-
export const iterate_metadata_coalesce = (
|
|
10
|
-
meta: Metadata,
|
|
11
|
-
type: ts.Type,
|
|
12
|
-
): boolean => {
|
|
13
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
14
|
-
if (filter(ts.TypeFlags.Unknown) || filter(ts.TypeFlags.Any)) {
|
|
15
|
-
Writable(meta).any = true;
|
|
16
|
-
return true;
|
|
17
|
-
} else if (filter(ts.TypeFlags.Null)) {
|
|
18
|
-
Writable(meta).nullable = true;
|
|
19
|
-
return true;
|
|
20
|
-
} else if (
|
|
21
|
-
filter(ts.TypeFlags.Undefined) ||
|
|
22
|
-
filter(ts.TypeFlags.Never) ||
|
|
23
|
-
filter(ts.TypeFlags.Void) ||
|
|
24
|
-
filter(ts.TypeFlags.VoidLike)
|
|
25
|
-
) {
|
|
26
|
-
Writable(meta).required = false;
|
|
27
|
-
return true;
|
|
28
|
-
} else if (TypeFactory.isFunction(type) === true) {
|
|
29
|
-
Writable(meta).functional = true;
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { Writable } from "../../../typings/Writable";
|
|
6
|
+
|
|
7
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
8
|
+
|
|
9
|
+
export const iterate_metadata_coalesce = (
|
|
10
|
+
meta: Metadata,
|
|
11
|
+
type: ts.Type,
|
|
12
|
+
): boolean => {
|
|
13
|
+
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
14
|
+
if (filter(ts.TypeFlags.Unknown) || filter(ts.TypeFlags.Any)) {
|
|
15
|
+
Writable(meta).any = true;
|
|
16
|
+
return true;
|
|
17
|
+
} else if (filter(ts.TypeFlags.Null)) {
|
|
18
|
+
Writable(meta).nullable = true;
|
|
19
|
+
return true;
|
|
20
|
+
} else if (
|
|
21
|
+
filter(ts.TypeFlags.Undefined) ||
|
|
22
|
+
filter(ts.TypeFlags.Never) ||
|
|
23
|
+
filter(ts.TypeFlags.Void) ||
|
|
24
|
+
filter(ts.TypeFlags.VoidLike)
|
|
25
|
+
) {
|
|
26
|
+
Writable(meta).required = false;
|
|
27
|
+
return true;
|
|
28
|
+
} else if (TypeFactory.isFunction(type) === true) {
|
|
29
|
+
Writable(meta).functional = true;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
import { MetadataConstant } from "../../../metadata/MetadataConstant";
|
|
5
|
-
|
|
6
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
-
|
|
8
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
-
|
|
10
|
-
export const iterate_metadata_constant =
|
|
11
|
-
(checker: ts.TypeChecker) =>
|
|
12
|
-
(options: MetadataFactory.IOptions) =>
|
|
13
|
-
(meta: Metadata, type: ts.Type): boolean => {
|
|
14
|
-
if (!options.constant) return false;
|
|
15
|
-
|
|
16
|
-
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
17
|
-
if (type.isLiteral()) {
|
|
18
|
-
const value: string | number | bigint =
|
|
19
|
-
typeof type.value === "object"
|
|
20
|
-
? BigInt(
|
|
21
|
-
`${type.value.negative ? "-" : ""}${
|
|
22
|
-
type.value.base10Value
|
|
23
|
-
}`,
|
|
24
|
-
)
|
|
25
|
-
: type.value;
|
|
26
|
-
const constant: MetadataConstant = ArrayUtil.take(
|
|
27
|
-
meta.constants,
|
|
28
|
-
(elem) => elem.type === typeof value,
|
|
29
|
-
() => ({
|
|
30
|
-
type: typeof value as "number",
|
|
31
|
-
values: [],
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
ArrayUtil.add(
|
|
35
|
-
constant.values as Array<any>,
|
|
36
|
-
value,
|
|
37
|
-
(a, b) => a === b,
|
|
38
|
-
);
|
|
39
|
-
return true;
|
|
40
|
-
} else if (filter(ts.TypeFlags.BooleanLiteral)) {
|
|
41
|
-
const value: boolean = checker.typeToString(type) === "true";
|
|
42
|
-
const constant: MetadataConstant = ArrayUtil.take(
|
|
43
|
-
meta.constants,
|
|
44
|
-
(elem) => elem.type === "boolean",
|
|
45
|
-
() => ({
|
|
46
|
-
type: "boolean",
|
|
47
|
-
values: [],
|
|
48
|
-
}),
|
|
49
|
-
);
|
|
50
|
-
ArrayUtil.add(
|
|
51
|
-
constant.values as boolean[],
|
|
52
|
-
value,
|
|
53
|
-
(a, b) => a === b,
|
|
54
|
-
);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
import { MetadataConstant } from "../../../metadata/MetadataConstant";
|
|
5
|
+
|
|
6
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
7
|
+
|
|
8
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
+
|
|
10
|
+
export const iterate_metadata_constant =
|
|
11
|
+
(checker: ts.TypeChecker) =>
|
|
12
|
+
(options: MetadataFactory.IOptions) =>
|
|
13
|
+
(meta: Metadata, type: ts.Type): boolean => {
|
|
14
|
+
if (!options.constant) return false;
|
|
15
|
+
|
|
16
|
+
const filter = (flag: ts.TypeFlags) => (type.getFlags() & flag) !== 0;
|
|
17
|
+
if (type.isLiteral()) {
|
|
18
|
+
const value: string | number | bigint =
|
|
19
|
+
typeof type.value === "object"
|
|
20
|
+
? BigInt(
|
|
21
|
+
`${type.value.negative ? "-" : ""}${
|
|
22
|
+
type.value.base10Value
|
|
23
|
+
}`,
|
|
24
|
+
)
|
|
25
|
+
: type.value;
|
|
26
|
+
const constant: MetadataConstant = ArrayUtil.take(
|
|
27
|
+
meta.constants,
|
|
28
|
+
(elem) => elem.type === typeof value,
|
|
29
|
+
() => ({
|
|
30
|
+
type: typeof value as "number",
|
|
31
|
+
values: [],
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
ArrayUtil.add(
|
|
35
|
+
constant.values as Array<any>,
|
|
36
|
+
value,
|
|
37
|
+
(a, b) => a === b,
|
|
38
|
+
);
|
|
39
|
+
return true;
|
|
40
|
+
} else if (filter(ts.TypeFlags.BooleanLiteral)) {
|
|
41
|
+
const value: boolean = checker.typeToString(type) === "true";
|
|
42
|
+
const constant: MetadataConstant = ArrayUtil.take(
|
|
43
|
+
meta.constants,
|
|
44
|
+
(elem) => elem.type === "boolean",
|
|
45
|
+
() => ({
|
|
46
|
+
type: "boolean",
|
|
47
|
+
values: [],
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
ArrayUtil.add(
|
|
51
|
+
constant.values as boolean[],
|
|
52
|
+
value,
|
|
53
|
+
(a, b) => a === b,
|
|
54
|
+
);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
-
|
|
7
|
-
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
-
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
-
import { TypeFactory } from "../../TypeFactory";
|
|
10
|
-
import { explore_metadata } from "./explore_metadata";
|
|
11
|
-
|
|
12
|
-
export const iterate_metadata_map =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(options: MetadataFactory.IOptions) =>
|
|
15
|
-
(collection: MetadataCollection) =>
|
|
16
|
-
(meta: Metadata, type: ts.Type): boolean => {
|
|
17
|
-
type = checker.getApparentType(type);
|
|
18
|
-
|
|
19
|
-
const name = TypeFactory.getFullName(checker, type, type.getSymbol());
|
|
20
|
-
const generic = type.aliasSymbol
|
|
21
|
-
? type.aliasTypeArguments
|
|
22
|
-
: checker.getTypeArguments(type as ts.TypeReference);
|
|
23
|
-
if (name.substring(0, 4) !== "Map<" || generic?.length !== 2)
|
|
24
|
-
return false;
|
|
25
|
-
|
|
26
|
-
const key: ts.Type = generic[0]!;
|
|
27
|
-
const value: ts.Type = generic[1]!;
|
|
28
|
-
|
|
29
|
-
ArrayUtil.set(
|
|
30
|
-
meta.maps,
|
|
31
|
-
{
|
|
32
|
-
key: explore_metadata(checker)(options)(collection)(key, false),
|
|
33
|
-
value: explore_metadata(checker)(options)(collection)(
|
|
34
|
-
value,
|
|
35
|
-
false,
|
|
36
|
-
),
|
|
37
|
-
},
|
|
38
|
-
(elem) => `Map<${elem.key.getName()}, ${elem.value.getName()}>`,
|
|
39
|
-
);
|
|
40
|
-
return true;
|
|
41
|
-
};
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { Metadata } from "../../../metadata/Metadata";
|
|
4
|
+
|
|
5
|
+
import { ArrayUtil } from "../../../utils/ArrayUtil";
|
|
6
|
+
|
|
7
|
+
import { MetadataCollection } from "../../MetadataCollection";
|
|
8
|
+
import { MetadataFactory } from "../../MetadataFactory";
|
|
9
|
+
import { TypeFactory } from "../../TypeFactory";
|
|
10
|
+
import { explore_metadata } from "./explore_metadata";
|
|
11
|
+
|
|
12
|
+
export const iterate_metadata_map =
|
|
13
|
+
(checker: ts.TypeChecker) =>
|
|
14
|
+
(options: MetadataFactory.IOptions) =>
|
|
15
|
+
(collection: MetadataCollection) =>
|
|
16
|
+
(meta: Metadata, type: ts.Type): boolean => {
|
|
17
|
+
type = checker.getApparentType(type);
|
|
18
|
+
|
|
19
|
+
const name = TypeFactory.getFullName(checker, type, type.getSymbol());
|
|
20
|
+
const generic = type.aliasSymbol
|
|
21
|
+
? type.aliasTypeArguments
|
|
22
|
+
: checker.getTypeArguments(type as ts.TypeReference);
|
|
23
|
+
if (name.substring(0, 4) !== "Map<" || generic?.length !== 2)
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
const key: ts.Type = generic[0]!;
|
|
27
|
+
const value: ts.Type = generic[1]!;
|
|
28
|
+
|
|
29
|
+
ArrayUtil.set(
|
|
30
|
+
meta.maps,
|
|
31
|
+
{
|
|
32
|
+
key: explore_metadata(checker)(options)(collection)(key, false),
|
|
33
|
+
value: explore_metadata(checker)(options)(collection)(
|
|
34
|
+
value,
|
|
35
|
+
false,
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
(elem) => `Map<${elem.key.getName()}, ${elem.value.getName()}>`,
|
|
39
|
+
);
|
|
40
|
+
return true;
|
|
41
|
+
};
|