typia 3.5.0-dev.20230126 → 3.5.0-dev.20230211
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 +64 -71
- package/lib/factories/MetadataCollection.d.ts +9 -1
- package/lib/factories/MetadataCollection.js +75 -2
- package/lib/factories/MetadataCollection.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_native.js +0 -3
- package/lib/factories/internal/metadata/iterate_metadata_native.js.map +1 -1
- package/lib/functional/$is_between.d.ts +1 -0
- package/lib/functional/$is_between.js +8 -0
- package/lib/functional/$is_between.js.map +1 -0
- package/lib/metadata/IMetadataTag.d.ts +3 -7
- package/lib/metadata/Metadata.js +2 -2
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/module.d.ts +33 -3
- package/lib/module.js +36 -8
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +3 -2
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +2 -2
- package/lib/programmers/CheckerProgrammer.js +21 -16
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +114 -18
- package/lib/programmers/FeatureProgrammer.js +4 -4
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +4 -3
- package/lib/programmers/IsProgrammer.js +72 -61
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.d.ts +5 -0
- package/lib/programmers/PruneProgrammer.js +279 -0
- package/lib/programmers/PruneProgrammer.js.map +1 -0
- package/lib/programmers/StringifyProgrammer.js +26 -21
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +3 -2
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/AtomicPredicator.d.ts +2 -0
- package/lib/programmers/helpers/AtomicPredicator.js +9 -1
- package/lib/programmers/helpers/AtomicPredicator.js.map +1 -1
- package/lib/programmers/helpers/IExpressionEntry.d.ts +2 -2
- package/lib/programmers/helpers/OptionPredicator.d.ts +1 -0
- package/lib/programmers/helpers/OptionPredicator.js +4 -0
- package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
- package/lib/programmers/helpers/PruneJoiner.d.ts +8 -0
- package/lib/programmers/helpers/PruneJoiner.js +60 -0
- package/lib/programmers/helpers/PruneJoiner.js.map +1 -0
- package/lib/programmers/helpers/StringifyJoinder.d.ts +1 -1
- package/lib/programmers/helpers/StringifyJoinder.js +2 -4
- package/lib/programmers/helpers/StringifyJoinder.js.map +1 -1
- package/lib/programmers/internal/application_object.js +11 -11
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +21 -12
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.js +34 -11
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_native.js +9 -1
- package/lib/programmers/internal/check_native.js.map +1 -1
- package/lib/programmers/internal/check_object.d.ts +1 -0
- package/lib/programmers/internal/check_object.js +13 -9
- package/lib/programmers/internal/check_object.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.d.ts +1 -1
- package/lib/programmers/internal/check_union_array_like.js +3 -1
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.d.ts +2 -2
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/lib/programmers/internal/prune_object_properties.d.ts +1 -0
- package/lib/programmers/internal/prune_object_properties.js +28 -0
- package/lib/programmers/internal/prune_object_properties.js.map +1 -0
- package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/stringify_regular_properties.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +5 -3
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/ITransformOptions.d.ts +14 -0
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js +17 -0
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/PruneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/PruneTransformer.js +34 -0
- package/lib/transformers/features/miscellaneous/PruneTransformer.js.map +1 -0
- package/package.json +5 -4
- package/src/factories/MetadataCollection.ts +41 -2
- package/src/factories/internal/metadata/iterate_metadata_native.ts +0 -5
- package/src/functional/$is_between.ts +7 -0
- package/src/metadata/IMetadataTag.ts +4 -19
- package/src/metadata/Metadata.ts +3 -6
- package/src/module.ts +91 -17
- package/src/programmers/AssertProgrammer.ts +3 -2
- package/src/programmers/CheckerProgrammer.ts +21 -13
- package/src/programmers/FeatureProgrammer.ts +146 -21
- package/src/programmers/IsProgrammer.ts +107 -87
- package/src/programmers/PruneProgrammer.ts +320 -0
- package/src/programmers/StringifyProgrammer.ts +51 -34
- package/src/programmers/ValidateProgrammer.ts +3 -2
- package/src/programmers/helpers/AtomicPredicator.ts +17 -1
- package/src/programmers/helpers/IExpressionEntry.ts +4 -2
- package/src/programmers/helpers/OptionPredicator.ts +4 -0
- package/src/programmers/helpers/PruneJoiner.ts +52 -0
- package/src/programmers/helpers/StringifyJoinder.ts +7 -4
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +33 -27
- package/src/programmers/internal/check_dynamic_properties.ts +67 -16
- package/src/programmers/internal/check_native.ts +14 -2
- package/src/programmers/internal/check_object.ts +8 -2
- package/src/programmers/internal/check_union_array_like.ts +4 -2
- package/src/programmers/internal/feature_object_entries.ts +6 -1
- package/src/programmers/internal/prune_object_properties.ts +60 -0
- package/src/programmers/internal/stringify_dynamic_properties.ts +2 -2
- package/src/programmers/internal/stringify_regular_properties.ts +2 -2
- package/src/transformers/CallExpressionTransformer.ts +15 -16
- package/src/transformers/ITransformOptions.ts +15 -0
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +3 -1
- package/src/transformers/features/{protocols/MessageTransformer.ts → miscellaneous/CreatePruneTransformer.ts} +6 -7
- package/src/transformers/features/miscellaneous/PruneTransformer.ts +46 -0
- package/lib/factories/ProtocolFactory.d.ts +0 -8
- package/lib/factories/ProtocolFactory.js +0 -112
- package/lib/factories/ProtocolFactory.js.map +0 -1
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +0 -16
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +0 -156
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +0 -1
- package/lib/factories/internal/protocols/emplace_protocol_object.d.ts +0 -3
- package/lib/factories/internal/protocols/emplace_protocol_object.js +0 -47
- package/lib/factories/internal/protocols/emplace_protocol_object.js.map +0 -1
- package/lib/factories/internal/protocols/emplace_protocol_property.d.ts +0 -4
- package/lib/factories/internal/protocols/emplace_protocol_property.js +0 -20
- package/lib/factories/internal/protocols/emplace_protocol_property.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_atomic.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js +0 -69
- package/lib/factories/internal/protocols/iterate_protocol_atomic.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_constant.d.ts +0 -2
- package/lib/factories/internal/protocols/iterate_protocol_constant.js +0 -30
- package/lib/factories/internal/protocols/iterate_protocol_constant.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_main.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_main.js +0 -17
- package/lib/factories/internal/protocols/iterate_protocol_main.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +0 -4
- package/lib/factories/internal/protocols/iterate_protocol_map.js +0 -75
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_metadata.d.ts +0 -5
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +0 -190
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_native.d.ts +0 -2
- package/lib/factories/internal/protocols/iterate_protocol_native.js +0 -33
- package/lib/factories/internal/protocols/iterate_protocol_native.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_never.d.ts +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_never.js +0 -6
- package/lib/factories/internal/protocols/iterate_protocol_never.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_object.d.ts +0 -4
- package/lib/factories/internal/protocols/iterate_protocol_object.js +0 -157
- package/lib/factories/internal/protocols/iterate_protocol_object.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +0 -5
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +0 -25
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +0 -1
- package/lib/factories/internal/protocols/iterate_protocol_tuple.d.ts +0 -3
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js +0 -46
- package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +0 -1
- package/lib/functional/$proto_bytes.d.ts +0 -2
- package/lib/functional/$proto_bytes.js +0 -37
- package/lib/functional/$proto_bytes.js.map +0 -1
- package/lib/functional/$proto_field.d.ts +0 -10
- package/lib/functional/$proto_field.js +0 -42
- package/lib/functional/$proto_field.js.map +0 -1
- package/lib/functional/$proto_float.d.ts +0 -4
- package/lib/functional/$proto_float.js +0 -28
- package/lib/functional/$proto_float.js.map +0 -1
- package/lib/functional/$proto_i32.d.ts +0 -2
- package/lib/functional/$proto_i32.js +0 -23
- package/lib/functional/$proto_i32.js.map +0 -1
- package/lib/functional/$proto_i64.d.ts +0 -2
- package/lib/functional/$proto_i64.js +0 -31
- package/lib/functional/$proto_i64.js.map +0 -1
- package/lib/functional/$proto_size.d.ts +0 -6
- package/lib/functional/$proto_size.js +0 -76
- package/lib/functional/$proto_size.js.map +0 -1
- package/lib/functional/$proto_string.d.ts +0 -2
- package/lib/functional/$proto_string.js +0 -34
- package/lib/functional/$proto_string.js.map +0 -1
- package/lib/functional/$varint.d.ts +0 -6
- package/lib/functional/$varint.js +0 -99
- package/lib/functional/$varint.js.map +0 -1
- package/lib/functional/$zigzag.d.ts +0 -4
- package/lib/functional/$zigzag.js +0 -34
- package/lib/functional/$zigzag.js.map +0 -1
- package/lib/messages/IProtocolMap.d.ts +0 -5
- package/lib/messages/IProtocolMap.js +0 -3
- package/lib/messages/IProtocolMap.js.map +0 -1
- package/lib/messages/IProtocolMessage.d.ts +0 -5
- package/lib/messages/IProtocolMessage.js +0 -3
- package/lib/messages/IProtocolMessage.js.map +0 -1
- package/lib/messages/IProtocolProperty.d.ts +0 -12
- package/lib/messages/IProtocolProperty.js +0 -3
- package/lib/messages/IProtocolProperty.js.map +0 -1
- package/lib/programmers/MessageProgrammer.d.ts +0 -5
- package/lib/programmers/MessageProgrammer.js +0 -141
- package/lib/programmers/MessageProgrammer.js.map +0 -1
- package/lib/transformers/features/protocols/MessageTransformer.d.ts +0 -5
- package/lib/transformers/features/protocols/MessageTransformer.js +0 -17
- package/lib/transformers/features/protocols/MessageTransformer.js.map +0 -1
- package/lib/utils/NameEncoder.d.ts +0 -4
- package/lib/utils/NameEncoder.js +0 -89
- package/lib/utils/NameEncoder.js.map +0 -1
- package/src/factories/ProtocolFactory.ts +0 -79
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +0 -163
- package/src/factories/internal/protocols/emplace_protocol_object.ts +0 -25
- package/src/factories/internal/protocols/emplace_protocol_property.ts +0 -12
- package/src/factories/internal/protocols/iterate_protocol_atomic.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_constant.ts +0 -27
- package/src/factories/internal/protocols/iterate_protocol_main.ts +0 -19
- package/src/factories/internal/protocols/iterate_protocol_map.ts +0 -58
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +0 -96
- package/src/factories/internal/protocols/iterate_protocol_native.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_never.ts +0 -1
- package/src/factories/internal/protocols/iterate_protocol_object.ts +0 -110
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +0 -34
- package/src/factories/internal/protocols/iterate_protocol_tuple.ts +0 -29
- package/src/functional/$proto_bytes.ts +0 -25
- package/src/functional/$proto_field.ts +0 -30
- package/src/functional/$proto_float.ts +0 -37
- package/src/functional/$proto_i32.ts +0 -29
- package/src/functional/$proto_i64.ts +0 -37
- package/src/functional/$proto_size.ts +0 -82
- package/src/functional/$proto_string.ts +0 -24
- package/src/functional/$varint.ts +0 -130
- package/src/functional/$zigzag.ts +0 -39
- package/src/messages/IProtocolMap.ts +0 -5
- package/src/messages/IProtocolMessage.ts +0 -6
- package/src/messages/IProtocolProperty.ts +0 -13
- package/src/programmers/MessageProgrammer.ts +0 -126
- package/src/utils/NameEncoder.ts +0 -32
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { StatementFactory } from "../../factories/StatementFactory";
|
|
4
|
+
|
|
5
|
+
import { MetadataObject } from "../../metadata/MetadataObject";
|
|
6
|
+
|
|
7
|
+
import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export const prune_object_properties = (obj: MetadataObject) => {
|
|
13
|
+
const input: ts.Expression = ts.factory.createIdentifier("input");
|
|
14
|
+
const key: ts.Expression = ts.factory.createIdentifier("key");
|
|
15
|
+
|
|
16
|
+
const condition: ts.Expression[] = obj.properties.map((prop) => {
|
|
17
|
+
const name: string | null = prop.key.getSoleLiteral();
|
|
18
|
+
if (name !== null)
|
|
19
|
+
return ts.factory.createStrictEquality(
|
|
20
|
+
ts.factory.createStringLiteral(name),
|
|
21
|
+
ts.factory.createIdentifier("key"),
|
|
22
|
+
);
|
|
23
|
+
return ts.factory.createCallExpression(
|
|
24
|
+
ts.factory.createIdentifier(
|
|
25
|
+
`RegExp(/${metadata_to_pattern(true)(prop.key)}/).test`,
|
|
26
|
+
),
|
|
27
|
+
undefined,
|
|
28
|
+
[key],
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const statements: ts.Statement[] = [];
|
|
33
|
+
if (condition.length)
|
|
34
|
+
statements.push(
|
|
35
|
+
ts.factory.createIfStatement(
|
|
36
|
+
condition.reduce((a, b) => ts.factory.createLogicalOr(a, b)),
|
|
37
|
+
ts.factory.createContinueStatement(),
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
statements.push(
|
|
41
|
+
ts.factory.createExpressionStatement(
|
|
42
|
+
ts.factory.createDeleteExpression(
|
|
43
|
+
ts.factory.createElementAccessExpression(input, key),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return ts.factory.createForOfStatement(
|
|
49
|
+
undefined,
|
|
50
|
+
StatementFactory.constant("key").declarationList,
|
|
51
|
+
ts.factory.createCallExpression(
|
|
52
|
+
ts.factory.createIdentifier("Object.keys"),
|
|
53
|
+
undefined,
|
|
54
|
+
[input],
|
|
55
|
+
),
|
|
56
|
+
statements.length === 1
|
|
57
|
+
? statements[0]!
|
|
58
|
+
: ts.factory.createBlock(statements, true),
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -10,7 +10,7 @@ import { metadata_to_pattern } from "./metadata_to_pattern";
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export function stringify_dynamic_properties(
|
|
13
|
-
dynamic: IExpressionEntry[],
|
|
13
|
+
dynamic: IExpressionEntry<ts.Expression>[],
|
|
14
14
|
regular: string[],
|
|
15
15
|
): ts.Expression {
|
|
16
16
|
// BASIC STATMEMENT, CHECK UNDEFINED
|
|
@@ -149,7 +149,7 @@ export function stringify_dynamic_properties(
|
|
|
149
149
|
return output();
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
function stringify(entry: IExpressionEntry): ts.ReturnStatement {
|
|
152
|
+
function stringify(entry: IExpressionEntry<ts.Expression>): ts.ReturnStatement {
|
|
153
153
|
return ts.factory.createReturnStatement(
|
|
154
154
|
TemplateFactory.generate([
|
|
155
155
|
ts.factory.createCallExpression(
|
|
@@ -11,8 +11,8 @@ import { IExpressionEntry } from "../helpers/IExpressionEntry";
|
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
13
|
export function stringify_regular_properties(
|
|
14
|
-
regular: IExpressionEntry[],
|
|
15
|
-
dynamic: IExpressionEntry[],
|
|
14
|
+
regular: IExpressionEntry<ts.Expression>[],
|
|
15
|
+
dynamic: IExpressionEntry<ts.Expression>[],
|
|
16
16
|
): ts.Expression[] {
|
|
17
17
|
const output: ts.Expression[] = [];
|
|
18
18
|
|
|
@@ -3,14 +3,15 @@ import ts from "typescript";
|
|
|
3
3
|
|
|
4
4
|
import { IProject } from "./IProject";
|
|
5
5
|
import { ApplicationTransformer } from "./features/miscellaneous/ApplicationTransformer";
|
|
6
|
+
import { CreatePruneTransformer } from "./features/miscellaneous/CreatePruneTransformer";
|
|
6
7
|
import { MetadataTransformer } from "./features/miscellaneous/MetadataTransformer";
|
|
8
|
+
import { PruneTransformer } from "./features/miscellaneous/PruneTransformer";
|
|
7
9
|
import { AssertParseTransformer } from "./features/parsers/AssertParseTransformer";
|
|
8
10
|
import { CreateAssertParseTransformer } from "./features/parsers/CreateAssertParseTransformer";
|
|
9
11
|
import { CreateIsParseTransformer } from "./features/parsers/CreateIsParseTransformer";
|
|
10
12
|
import { CreateValidateParseTransformer } from "./features/parsers/CreateValidateParseTransformer";
|
|
11
13
|
import { IsParseTransformer } from "./features/parsers/IsParseTransformer";
|
|
12
14
|
import { ValidateParseTransformer } from "./features/parsers/ValidateParseTransformer";
|
|
13
|
-
import { MessageTransformer } from "./features/protocols/MessageTransformer";
|
|
14
15
|
import { AssertStringifyTransformer } from "./features/stringifiers/AssertStringifyTransformer";
|
|
15
16
|
import { CreateAssertStringifyTransformer } from "./features/stringifiers/CreateAssertStringifyTransformer";
|
|
16
17
|
import { CreateIsStringifyTransformer } from "./features/stringifiers/CreateIsStringifyTransformer";
|
|
@@ -70,7 +71,7 @@ const SRC_PATH = path.resolve(path.join(__dirname, "..", "module.ts"));
|
|
|
70
71
|
|
|
71
72
|
const FUNCTORS: Record<string, () => Task> = {
|
|
72
73
|
//----
|
|
73
|
-
//
|
|
74
|
+
// SINGLE FUNCTIONS
|
|
74
75
|
//----
|
|
75
76
|
// BASIC VALIDATORS
|
|
76
77
|
assert: () => AssertTransformer.transform(false),
|
|
@@ -83,18 +84,7 @@ const FUNCTORS: Record<string, () => Task> = {
|
|
|
83
84
|
equals: () => IsTransformer.transform(true),
|
|
84
85
|
validateEquals: () => ValidateTransformer.transform(true),
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
// PROTOCOL BUFFER
|
|
88
|
-
//----
|
|
89
|
-
message: () => MessageTransformer.transform,
|
|
90
|
-
|
|
91
|
-
//----
|
|
92
|
-
// JSON FUNCTIONS
|
|
93
|
-
//----
|
|
94
|
-
// SCHEMA DEFINITION
|
|
95
|
-
application: () => ApplicationTransformer.transform,
|
|
96
|
-
|
|
97
|
-
// PARSER FUNCTIONS
|
|
87
|
+
// PARSE FUNCTIONS
|
|
98
88
|
isParse: () => IsParseTransformer.transform,
|
|
99
89
|
assertParse: () => AssertParseTransformer.transform,
|
|
100
90
|
validateParse: () => ValidateParseTransformer.transform,
|
|
@@ -106,26 +96,35 @@ const FUNCTORS: Record<string, () => Task> = {
|
|
|
106
96
|
validateStringify: () => ValidateStringifyTransformer.transform,
|
|
107
97
|
|
|
108
98
|
// MISC
|
|
99
|
+
application: () => ApplicationTransformer.transform,
|
|
109
100
|
metadata: () => MetadataTransformer.transform,
|
|
101
|
+
prune: () => PruneTransformer.transform,
|
|
110
102
|
|
|
111
103
|
//----
|
|
112
104
|
// FACTORY FUNCTIONS
|
|
113
105
|
//----
|
|
114
|
-
// VALIDATORS
|
|
106
|
+
// BASIC VALIDATORS
|
|
115
107
|
createAssert: () => CreateAssertTransformer.transform(false),
|
|
116
108
|
createAssertType: () => CreateAssertTransformer.transform(false),
|
|
117
109
|
createIs: () => CreateIsTransformer.transform(false),
|
|
118
110
|
createValidate: () => CreateValidateTransformer.transform(false),
|
|
111
|
+
|
|
112
|
+
// STRICT VALIDATORS
|
|
119
113
|
createAssertEquals: () => CreateAssertTransformer.transform(true),
|
|
120
114
|
createEquals: () => CreateIsTransformer.transform(true),
|
|
121
115
|
createValidateEquals: () => CreateValidateTransformer.transform(true),
|
|
122
116
|
|
|
123
|
-
//
|
|
117
|
+
// PARSE FUNCTIONS
|
|
124
118
|
createIsParse: () => CreateIsParseTransformer.transform,
|
|
125
119
|
createAssertParse: () => CreateAssertParseTransformer.transform,
|
|
126
120
|
createValidateParse: () => CreateValidateParseTransformer.transform,
|
|
121
|
+
|
|
122
|
+
// STRINGIFY FUNCTIONS
|
|
127
123
|
createStringify: () => CreateStringifyTransformer.transform,
|
|
128
124
|
createAssertStringify: () => CreateAssertStringifyTransformer.transform,
|
|
129
125
|
createIsStringify: () => CreateIsStringifyTransformer.transform,
|
|
130
126
|
createValidateStringify: () => CreateValidateStringifyTransformer.transform,
|
|
127
|
+
|
|
128
|
+
// MISC
|
|
129
|
+
createPrune: () => CreatePruneTransformer.transform,
|
|
131
130
|
};
|
|
@@ -44,4 +44,19 @@ export interface ITransformOptions {
|
|
|
44
44
|
* @default false
|
|
45
45
|
*/
|
|
46
46
|
functional?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether to check undefined value or not.
|
|
50
|
+
*
|
|
51
|
+
* JavaScript can assign `undefined` value to a specific property and it is an
|
|
52
|
+
* issue when validating without allowing superfluous properties. Should undefined
|
|
53
|
+
* value assigned superfluous property be allowed or not?
|
|
54
|
+
*
|
|
55
|
+
* Note that, this option only works on {@link equals} function. Other function
|
|
56
|
+
* like {@link assertEquals} or {@link validateEquals} would ignore this option
|
|
57
|
+
* value and always allow the `undefined` value.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
undefined?: boolean;
|
|
47
62
|
}
|
|
@@ -59,7 +59,9 @@ export namespace ApplicationTransformer {
|
|
|
59
59
|
// GENERATORS
|
|
60
60
|
//----
|
|
61
61
|
// METADATA
|
|
62
|
-
const collection: MetadataCollection = new MetadataCollection(
|
|
62
|
+
const collection: MetadataCollection = new MetadataCollection({
|
|
63
|
+
replace: MetadataCollection.replace,
|
|
64
|
+
});
|
|
63
65
|
const metadatas: Array<Metadata> = types.map((type) =>
|
|
64
66
|
MetadataFactory.generate(checker, collection, type, {
|
|
65
67
|
resolve: true,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { PruneProgrammer } from "../../../programmers/PruneProgrammer";
|
|
4
4
|
|
|
5
5
|
import { IProject } from "../../IProject";
|
|
6
6
|
|
|
7
|
-
export namespace
|
|
7
|
+
export namespace CreatePruneTransformer {
|
|
8
8
|
export function transform(
|
|
9
9
|
project: IProject,
|
|
10
|
-
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
@@ -21,12 +21,11 @@ export namespace MessageTransformer {
|
|
|
21
21
|
if (type.isTypeParameter())
|
|
22
22
|
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
return MessageProgrammer.generate(project)(type);
|
|
24
|
+
return PruneProgrammer.generate(project, modulo)(type);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
const enum ErrorMessages {
|
|
30
|
-
NOT_SPECIFIED = "Error on typia.
|
|
31
|
-
GENERIC_ARGUMENT = "Error on typia.
|
|
29
|
+
NOT_SPECIFIED = "Error on typia.prune(): generic argument is not specified.",
|
|
30
|
+
GENERIC_ARGUMENT = "Error on typia.prune(): non-specified generic argument.",
|
|
32
31
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { PruneProgrammer } from "../../../programmers/PruneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace PruneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
const type: ts.Type =
|
|
17
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
18
|
+
? project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
)
|
|
21
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
22
|
+
if (type.isTypeParameter())
|
|
23
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
24
|
+
|
|
25
|
+
return ts.factory.createCallExpression(
|
|
26
|
+
PruneProgrammer.generate(
|
|
27
|
+
{
|
|
28
|
+
...project,
|
|
29
|
+
options: {
|
|
30
|
+
...project.options,
|
|
31
|
+
functional: false,
|
|
32
|
+
numeric: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
modulo,
|
|
36
|
+
)(type),
|
|
37
|
+
undefined,
|
|
38
|
+
[expression.arguments[0]!],
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const enum ErrorMessages {
|
|
44
|
+
NO_INPUT_VALUE = "Error on typia.prune(): no input value.",
|
|
45
|
+
GENERIC_ARGUMENT = "Error on typia.prune(): non-specified generic argument.",
|
|
46
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { Metadata } from "../metadata/Metadata";
|
|
3
|
-
import { IProtocolMessage } from "../messages/IProtocolMessage";
|
|
4
|
-
import { MetadataCollection } from "./MetadataCollection";
|
|
5
|
-
export declare namespace ProtocolFactory {
|
|
6
|
-
const metadata: (checker: ts.TypeChecker) => (collection: MetadataCollection) => (type: ts.Type) => Metadata;
|
|
7
|
-
const generate: (collection: MetadataCollection) => (dict: Map<string, IProtocolMessage>) => (meta: Metadata) => void;
|
|
8
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.ProtocolFactory = void 0;
|
|
15
|
-
var MetadataFactory_1 = require("./MetadataFactory");
|
|
16
|
-
var emplace_protocol_object_1 = require("./internal/protocols/emplace_protocol_object");
|
|
17
|
-
var iterate_protocol_main_1 = require("./internal/protocols/iterate_protocol_main");
|
|
18
|
-
var ProtocolFactory;
|
|
19
|
-
(function (ProtocolFactory) {
|
|
20
|
-
ProtocolFactory.metadata = function (checker) {
|
|
21
|
-
return function (collection) {
|
|
22
|
-
return function (type) {
|
|
23
|
-
return MetadataFactory_1.MetadataFactory.generate(checker, collection, type, {
|
|
24
|
-
resolve: false,
|
|
25
|
-
constant: true,
|
|
26
|
-
validate: function (meta) {
|
|
27
|
-
if (meta.any)
|
|
28
|
-
throw new Error("Error on typia.message(): any type is not supported in protocol buffer.");
|
|
29
|
-
else if (meta.functional && meta.size() !== 1)
|
|
30
|
-
throw new Error("Error on typia.message(): functional type is not supported in protocol buffer.");
|
|
31
|
-
else if (meta.objects.find(function (o) { return o.name === "__Main"; }))
|
|
32
|
-
throw new Error("Error on typia.message(): reserved type \"__Main\" has been detected.");
|
|
33
|
-
else if (meta.objects.find(function (o) { return o.name === "__Timestamp"; }))
|
|
34
|
-
throw new Error("Error on typia.message(): reserved type \"__Timestamp\" has been detected.");
|
|
35
|
-
else if (meta.objects.some(function (o) {
|
|
36
|
-
return o.properties.some(function (p) { return !is_atomic_key(p.key); });
|
|
37
|
-
}) ||
|
|
38
|
-
meta.maps.some(function (m) { return !is_atomic_key(m.key); }))
|
|
39
|
-
throw new Error("Error on typia.message(): only atomic key type is supported in protocol buffer.");
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
ProtocolFactory.generate = function (collection) {
|
|
46
|
-
return function (dict) {
|
|
47
|
-
return function (meta) {
|
|
48
|
-
var e_1, _a;
|
|
49
|
-
try {
|
|
50
|
-
for (var _b = __values(collection.objects()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
51
|
-
var obj = _c.value;
|
|
52
|
-
(0, emplace_protocol_object_1.emplace_protocol_object)(dict)(obj);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
56
|
-
finally {
|
|
57
|
-
try {
|
|
58
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
59
|
-
}
|
|
60
|
-
finally { if (e_1) throw e_1.error; }
|
|
61
|
-
}
|
|
62
|
-
(0, iterate_protocol_main_1.iterate_protocol_main)(dict)(meta);
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
var is_atomic_key = function (key) {
|
|
67
|
-
var e_2, _a, e_3, _b;
|
|
68
|
-
if (key.required &&
|
|
69
|
-
key.nullable === false &&
|
|
70
|
-
key.functional === false &&
|
|
71
|
-
key.resolved === null &&
|
|
72
|
-
key.size() ===
|
|
73
|
-
key.atomics.length +
|
|
74
|
-
key.constants
|
|
75
|
-
.map(function (c) { return c.values.length; })
|
|
76
|
-
.reduce(function (a, b) { return a + b; }, 0) +
|
|
77
|
-
key.templates.length) {
|
|
78
|
-
var set = new Set();
|
|
79
|
-
try {
|
|
80
|
-
for (var _c = __values(key.atomics), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
81
|
-
var atomic = _d.value;
|
|
82
|
-
set.add(atomic);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
86
|
-
finally {
|
|
87
|
-
try {
|
|
88
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
89
|
-
}
|
|
90
|
-
finally { if (e_2) throw e_2.error; }
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
for (var _e = __values(key.constants), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
94
|
-
var constant = _f.value;
|
|
95
|
-
set.add(constant.type);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
99
|
-
finally {
|
|
100
|
-
try {
|
|
101
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
102
|
-
}
|
|
103
|
-
finally { if (e_3) throw e_3.error; }
|
|
104
|
-
}
|
|
105
|
-
if (key.templates.length)
|
|
106
|
-
set.add("string");
|
|
107
|
-
return set.size === 1;
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
};
|
|
111
|
-
})(ProtocolFactory = exports.ProtocolFactory || (exports.ProtocolFactory = {}));
|
|
112
|
-
//# sourceMappingURL=ProtocolFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolFactory.js","sourceRoot":"","sources":["../../src/factories/ProtocolFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,qDAAoD;AACpD,wFAAuF;AACvF,oFAAmF;AAEnF,IAAiB,eAAe,CA4D/B;AA5DD,WAAiB,eAAe;IACf,wBAAQ,GACjB,UAAC,OAAuB;QACxB,OAAA,UAAC,UAA8B;YAC/B,OAAA,UAAC,IAAa;gBACV,OAAA,iCAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE;oBAChD,OAAO,EAAE,KAAK;oBACd,QAAQ,EAAE,IAAI;oBACd,QAAQ,EAAE,UAAC,IAAI;wBACX,IAAI,IAAI,CAAC,GAAG;4BAAE,MAAM,IAAI,KAAK,2EAAsB,CAAC;6BAC/C,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;4BACzC,MAAM,IAAI,KAAK,kFAA6B,CAAC;6BAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAnB,CAAmB,CAAC;4BAClD,MAAM,IAAI,KAAK,yEAAuB,CAAC;6BACtC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,aAAa,EAAxB,CAAwB,CAAC;4BACvD,MAAM,IAAI,KAAK,8EAA4B,CAAC;6BAC3C,IACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,CAAC;4BAChB,OAAA,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAArB,CAAqB,CAAC;wBAA/C,CAA+C,CAClD;4BAC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A3B,IAAM,MAAM,WAAA;oBAAiB,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBAAA;;;;;;;;;;gBAClD,KAAuB,IAAA,KAAA,SAAA,GAAG,CAAC,SAAS,CAAA,gBAAA;oBAA/B,IAAM,QAAQ,WAAA;oBAAmB,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;iBAAA;;;;;;;;;YAC7D,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM;gBAAE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAE5C,OAAO,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC;SACzB;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACN,CAAC,EA5DgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA4D/B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IMetadataTag } from "../../../metadata/IMetadataTag";
|
|
2
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
3
|
-
import { MetadataObject } from "../../../metadata/MetadataObject";
|
|
4
|
-
import { MetadataProperty } from "../../../metadata/MetadataProperty";
|
|
5
|
-
import { Atomic } from "../../../typings/Atomic";
|
|
6
|
-
export declare namespace ProtocolMetadataUtil {
|
|
7
|
-
function size(meta: Metadata): number;
|
|
8
|
-
function standalone(meta: Metadata): boolean;
|
|
9
|
-
function regular(obj: MetadataObject): boolean;
|
|
10
|
-
function object(name: string, index: number): MetadataObject;
|
|
11
|
-
function property(key: string, value: Metadata, tags: IMetadataTag[]): MetadataProperty;
|
|
12
|
-
function array(meta: Metadata): Metadata;
|
|
13
|
-
function atomic(type: Atomic.Literal): Metadata;
|
|
14
|
-
function reference(obj: MetadataObject): Metadata;
|
|
15
|
-
function map(elem: Metadata.Entry): Metadata;
|
|
16
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProtocolMetadataUtil = void 0;
|
|
4
|
-
var Metadata_1 = require("../../../metadata/Metadata");
|
|
5
|
-
var MetadataObject_1 = require("../../../metadata/MetadataObject");
|
|
6
|
-
var MetadataProperty_1 = require("../../../metadata/MetadataProperty");
|
|
7
|
-
var ProtocolMetadataUtil;
|
|
8
|
-
(function (ProtocolMetadataUtil) {
|
|
9
|
-
function size(meta) {
|
|
10
|
-
return (meta.atomics.length +
|
|
11
|
-
meta.constants.filter(function (c) {
|
|
12
|
-
return meta.atomics.find(function (type) { return c.type === type; }) === undefined;
|
|
13
|
-
}).length +
|
|
14
|
-
(meta.templates.length !== 0 &&
|
|
15
|
-
meta.atomics.find(function (type) { return type === "string"; }) === undefined &&
|
|
16
|
-
meta.constants.find(function (c) { return c.type === "string"; }) === undefined
|
|
17
|
-
? 1
|
|
18
|
-
: 0) +
|
|
19
|
-
meta.tuples.length +
|
|
20
|
-
meta.arrays.length +
|
|
21
|
-
meta.sets.length +
|
|
22
|
-
meta.maps.length +
|
|
23
|
-
meta.objects.length +
|
|
24
|
-
meta.natives.filter(function (n) { return n === "Date"; }).length +
|
|
25
|
-
(meta.natives.filter(function (n) { return n !== "Date"; }).length ? 1 : 0));
|
|
26
|
-
}
|
|
27
|
-
ProtocolMetadataUtil.size = size;
|
|
28
|
-
function standalone(meta) {
|
|
29
|
-
return (size(meta) === 1 &&
|
|
30
|
-
meta.required === true &&
|
|
31
|
-
meta.nullable === false &&
|
|
32
|
-
meta.tuples.length === 0 &&
|
|
33
|
-
meta.arrays.length === 0 &&
|
|
34
|
-
meta.sets.length === 0 &&
|
|
35
|
-
meta.maps.length === 0 &&
|
|
36
|
-
meta.objects.every(function (obj) {
|
|
37
|
-
return obj.properties.every(function (p) { return p.key.isSoleLiteral(); });
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
ProtocolMetadataUtil.standalone = standalone;
|
|
41
|
-
function regular(obj) {
|
|
42
|
-
return obj.properties.every(function (p) { return p.key.isSoleLiteral(); });
|
|
43
|
-
}
|
|
44
|
-
ProtocolMetadataUtil.regular = regular;
|
|
45
|
-
function object(name, index) {
|
|
46
|
-
return MetadataObject_1.MetadataObject.create({
|
|
47
|
-
name: name,
|
|
48
|
-
index: index,
|
|
49
|
-
properties: [],
|
|
50
|
-
description: undefined,
|
|
51
|
-
jsDocTags: [],
|
|
52
|
-
validated: false,
|
|
53
|
-
recursive: false,
|
|
54
|
-
nullables: [false],
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
ProtocolMetadataUtil.object = object;
|
|
58
|
-
function property(key, value, tags) {
|
|
59
|
-
return MetadataProperty_1.MetadataProperty.create({
|
|
60
|
-
key: (function () {
|
|
61
|
-
var meta = Metadata_1.Metadata.initialize();
|
|
62
|
-
meta.constants.push({
|
|
63
|
-
type: "string",
|
|
64
|
-
values: [key],
|
|
65
|
-
});
|
|
66
|
-
return meta;
|
|
67
|
-
})(),
|
|
68
|
-
value: value,
|
|
69
|
-
description: undefined,
|
|
70
|
-
tags: tags,
|
|
71
|
-
jsDocTags: [],
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
ProtocolMetadataUtil.property = property;
|
|
75
|
-
function array(meta) {
|
|
76
|
-
return Metadata_1.Metadata.create({
|
|
77
|
-
any: false,
|
|
78
|
-
required: true,
|
|
79
|
-
nullable: false,
|
|
80
|
-
functional: false,
|
|
81
|
-
resolved: null,
|
|
82
|
-
atomics: [],
|
|
83
|
-
constants: [],
|
|
84
|
-
templates: [],
|
|
85
|
-
rest: null,
|
|
86
|
-
arrays: [meta],
|
|
87
|
-
tuples: [],
|
|
88
|
-
objects: [],
|
|
89
|
-
natives: [],
|
|
90
|
-
sets: [],
|
|
91
|
-
maps: [],
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
ProtocolMetadataUtil.array = array;
|
|
95
|
-
function atomic(type) {
|
|
96
|
-
return Metadata_1.Metadata.create({
|
|
97
|
-
any: false,
|
|
98
|
-
required: true,
|
|
99
|
-
nullable: false,
|
|
100
|
-
functional: false,
|
|
101
|
-
resolved: null,
|
|
102
|
-
atomics: [type],
|
|
103
|
-
constants: [],
|
|
104
|
-
templates: [],
|
|
105
|
-
rest: null,
|
|
106
|
-
arrays: [],
|
|
107
|
-
tuples: [],
|
|
108
|
-
objects: [],
|
|
109
|
-
natives: [],
|
|
110
|
-
sets: [],
|
|
111
|
-
maps: [],
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
ProtocolMetadataUtil.atomic = atomic;
|
|
115
|
-
function reference(obj) {
|
|
116
|
-
return Metadata_1.Metadata.create({
|
|
117
|
-
any: false,
|
|
118
|
-
required: true,
|
|
119
|
-
nullable: false,
|
|
120
|
-
functional: false,
|
|
121
|
-
resolved: null,
|
|
122
|
-
atomics: [],
|
|
123
|
-
constants: [],
|
|
124
|
-
templates: [],
|
|
125
|
-
rest: null,
|
|
126
|
-
arrays: [],
|
|
127
|
-
tuples: [],
|
|
128
|
-
objects: [obj],
|
|
129
|
-
natives: [],
|
|
130
|
-
sets: [],
|
|
131
|
-
maps: [],
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
ProtocolMetadataUtil.reference = reference;
|
|
135
|
-
function map(elem) {
|
|
136
|
-
return Metadata_1.Metadata.create({
|
|
137
|
-
any: false,
|
|
138
|
-
required: true,
|
|
139
|
-
nullable: false,
|
|
140
|
-
functional: false,
|
|
141
|
-
resolved: null,
|
|
142
|
-
atomics: [],
|
|
143
|
-
constants: [],
|
|
144
|
-
templates: [],
|
|
145
|
-
rest: null,
|
|
146
|
-
arrays: [],
|
|
147
|
-
tuples: [],
|
|
148
|
-
objects: [],
|
|
149
|
-
natives: [],
|
|
150
|
-
sets: [],
|
|
151
|
-
maps: [elem],
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
ProtocolMetadataUtil.map = map;
|
|
155
|
-
})(ProtocolMetadataUtil = exports.ProtocolMetadataUtil || (exports.ProtocolMetadataUtil = {}));
|
|
156
|
-
//# sourceMappingURL=ProtocolMetadataUtil.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolMetadataUtil.js","sourceRoot":"","sources":["../../../../src/factories/internal/protocols/ProtocolMetadataUtil.ts"],"names":[],"mappings":";;;AACA,uDAAsD;AACtD,mEAAkE;AAClE,uEAAsE;AAItE,IAAiB,oBAAoB,CA2JpC;AA3JD,WAAiB,oBAAoB;IACjC,SAAgB,IAAI,CAAC,IAAc;QAC/B,OAAO,CACH,IAAI,CAAC,OAAO,CAAC,MAAM;YACnB,IAAI,CAAC,SAAS,CAAC,MAAM,CACjB,UAAC,CAAC;gBACE,OAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,IAAI,EAAf,CAAe,CAAC,KAAK,SAAS;YAA1D,CAA0D,CACjE,CAAC,MAAM;YACR,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;gBAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,KAAK,QAAQ,EAAjB,CAAiB,CAAC,KAAK,SAAS;gBAC5D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAnB,CAAmB,CAAC,KAAK,SAAS;gBACzD,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,CAAC,CAAC;YACR,IAAI,CAAC,MAAM,CAAC,MAAM;YAClB,IAAI,CAAC,MAAM,CAAC,MAAM;YAClB,IAAI,CAAC,IAAI,CAAC,MAAM;YAChB,IAAI,CAAC,IAAI,CAAC,MAAM;YAChB,IAAI,CAAC,OAAO,CAAC,MAAM;YACnB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,KAAK,MAAM,EAAZ,CAAY,CAAC,CAAC,MAAM;YAC/C,CAAC,IAAI,CA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R,IAAI,EAAE,CAAC,IAAI,CAAC;SACf,CAAC,CAAC;IACP,CAAC;IAlBe,wBAAG,MAkBlB,CAAA;AACL,CAAC,EA3JgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA2JpC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { MetadataObject } from "../../../metadata/MetadataObject";
|
|
2
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
3
|
-
export declare const emplace_protocol_object: (dict: Map<string, IProtocolMessage>) => (object: MetadataObject) => IProtocolMessage | undefined;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.emplace_protocol_object = void 0;
|
|
29
|
-
var emplace_protocol_property_1 = require("./emplace_protocol_property");
|
|
30
|
-
var emplace_protocol_object = function (dict) { return function (object) {
|
|
31
|
-
var _a;
|
|
32
|
-
if (dict.has(object.name))
|
|
33
|
-
return;
|
|
34
|
-
var regular = object.properties.filter(function (p) { return p.key.isSoleLiteral(); });
|
|
35
|
-
var dynamic = object.properties.filter(function (p) { return !p.key.isSoleLiteral(); });
|
|
36
|
-
if (dynamic.length)
|
|
37
|
-
return;
|
|
38
|
-
var output = {
|
|
39
|
-
name: object.name,
|
|
40
|
-
properties: [],
|
|
41
|
-
};
|
|
42
|
-
dict.set(object.name, output);
|
|
43
|
-
(_a = output.properties).push.apply(_a, __spreadArray([], __read(regular.map(function (prop) { return (0, emplace_protocol_property_1.emplace_protocol_property)(dict)(prop); })), false));
|
|
44
|
-
return output;
|
|
45
|
-
}; };
|
|
46
|
-
exports.emplace_protocol_object = emplace_protocol_object;
|
|
47
|
-
//# sourceMappingURL=emplace_protocol_object.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emplace_protocol_object.js","sourceRoot":"","sources":["../../../../src/factories/internal/protocols/emplace_protocol_object.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,yEAAwE;AAEjE,IAAM,uBAAuB,GAChC,UAAC,IAAmC,IAAK,OAAA,UAAC,MAAsB;;IAC5D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO;IAElC,IAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,EAArB,CAAqB,CAAC,CAAC;IACvE,IAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,EAAE,EAAtB,CAAsB,CAAC,CAAC;IAExE,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO;IAE3B,IAAM,MAAM,GAAqB;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,UAAU,EAAE,EAAE;KACjB,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE9B,CAAA,KAAA,MAAM,CAAC,UAAU,CAAA,CAAC,IAAI,oCACf,OAAO,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,IAAA,qDAAyB,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAArC,CAAqC,CAAC,WACjE;IACF,OAAO,MAAM,CAAC;AAClB,CAAC,EAlBwC,CAkBxC,CAAC;AAnBO,QAAA,uBAAuB,2BAmB9B"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { MetadataProperty } from "../../../metadata/MetadataProperty";
|
|
2
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
3
|
-
import { IProtocolProperty } from "../../../messages/IProtocolProperty";
|
|
4
|
-
export declare const emplace_protocol_property: (dict: Map<string, IProtocolMessage>) => (property: MetadataProperty) => IProtocolProperty;
|