typia 3.7.0-dev.20230310 → 3.7.0-dev.20230401
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 +16 -45
- package/lib/IRandomGenerator.d.ts +2 -1
- package/lib/executable/TypiaSetupWizard.js +12 -2
- package/lib/executable/TypiaSetupWizard.js.map +1 -1
- 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/MetadataTagFactory.js +151 -132
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/factories/TypeFactory.js +1 -1
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/TypiaFileFactory.js +61 -54
- package/lib/factories/TypiaFileFactory.js.map +1 -1
- package/lib/functional/$dictionary.d.ts +1 -0
- package/lib/functional/$dictionary.js +14 -0
- package/lib/functional/$dictionary.js.map +1 -0
- package/lib/functional/$is_custom.d.ts +2 -0
- package/lib/functional/$is_custom.js +12 -0
- package/lib/functional/$is_custom.js.map +1 -0
- package/lib/functional/$is_date.d.ts +1 -0
- package/lib/functional/$is_date.js +9 -0
- package/lib/functional/$is_date.js.map +1 -0
- package/lib/functional/$is_datetime.d.ts +1 -0
- package/lib/functional/$is_datetime.js +8 -0
- package/lib/functional/$is_datetime.js.map +1 -0
- package/lib/functional/Namespace.js +6 -0
- package/lib/functional/Namespace.js.map +1 -1
- package/lib/metadata/IMetadataTag.d.ts +30 -38
- package/lib/metadata/Metadata.js +2 -2
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/module.d.ts +25 -2
- package/lib/module.js +12 -5
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +11 -0
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +4 -2
- package/lib/programmers/CheckerProgrammer.js +26 -27
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/CloneProgrammer.js +2 -2
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +3 -2
- package/lib/programmers/FeatureProgrammer.js +5 -5
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.js +32 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.js +2 -2
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +1 -2
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.js +6 -6
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +11 -0
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/ICheckEntry.d.ts +11 -0
- package/lib/{messages/IProtocolMap.js → programmers/helpers/ICheckEntry.js} +1 -1
- package/lib/programmers/helpers/ICheckEntry.js.map +1 -0
- package/lib/programmers/helpers/UnionExplorer.d.ts +7 -7
- package/lib/programmers/helpers/UnionExplorer.js +6 -6
- package/lib/programmers/helpers/UnionExplorer.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 +3 -5
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_string.js +8 -5
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array.js +35 -10
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_array_length.js +23 -36
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_bigint.d.ts +1 -3
- package/lib/programmers/internal/check_bigint.js +92 -57
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_custom.d.ts +5 -0
- package/lib/programmers/internal/check_custom.js +40 -0
- package/lib/programmers/internal/check_custom.js.map +1 -0
- package/lib/programmers/internal/check_number.js +126 -73
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string.js +10 -9
- package/lib/programmers/internal/check_string.js.map +1 -1
- package/lib/programmers/internal/check_string_tags.js +63 -24
- package/lib/programmers/internal/check_string_tags.js.map +1 -1
- package/lib/programmers/internal/check_template.js +23 -11
- package/lib/programmers/internal/check_template.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.d.ts +2 -2
- package/lib/programmers/internal/check_union_array_like.js +4 -4
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/internal/check_union_tuple.js +2 -2
- package/lib/programmers/internal/check_union_tuple.js.map +1 -1
- package/lib/programmers/internal/feature_object_entries.js +1 -1
- package/lib/programmers/internal/feature_object_entries.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +1 -3
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -1
- package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -1
- package/lib/transformers/internal/GenericTransformer.js +2 -2
- package/lib/transformers/internal/GenericTransformer.js.map +1 -1
- package/lib/typings/Customizable.d.ts +6 -0
- package/lib/{messages/IProtocolMessage.js → typings/Customizable.js} +1 -1
- package/lib/typings/Customizable.js.map +1 -0
- package/lib/utils/RandomGenerator.js +8 -2
- package/lib/utils/RandomGenerator.js.map +1 -1
- package/package.json +10 -9
- package/src/IRandomGenerator.ts +2 -1
- package/src/executable/TypiaSetupWizard.ts +16 -6
- package/src/factories/MetadataCollection.ts +41 -2
- package/src/factories/MetadataTagFactory.ts +186 -149
- package/src/factories/TypeFactory.ts +1 -1
- package/src/factories/TypiaFileFactory.ts +10 -7
- package/src/functional/$dictionary.ts +17 -0
- package/src/functional/$is_custom.ts +14 -0
- package/src/functional/$is_date.ts +4 -0
- package/src/functional/$is_datetime.ts +3 -0
- package/src/functional/Namespace.ts +6 -0
- package/src/metadata/IMetadataTag.ts +46 -70
- package/src/metadata/Metadata.ts +3 -6
- package/src/module.ts +39 -10
- package/src/programmers/AssertProgrammer.ts +24 -0
- package/src/programmers/CheckerProgrammer.ts +66 -37
- package/src/programmers/CloneProgrammer.ts +2 -0
- package/src/programmers/FeatureProgrammer.ts +12 -5
- package/src/programmers/IsProgrammer.ts +7 -1
- package/src/programmers/PruneProgrammer.ts +2 -0
- package/src/programmers/RandomProgrammer.ts +1 -4
- package/src/programmers/StringifyProgrammer.ts +6 -0
- package/src/programmers/ValidateProgrammer.ts +24 -0
- package/src/programmers/helpers/ICheckEntry.ts +12 -0
- package/src/programmers/helpers/UnionExplorer.ts +7 -0
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +3 -7
- package/src/programmers/internal/application_string.ts +6 -2
- package/src/programmers/internal/check_array.ts +15 -11
- package/src/programmers/internal/check_array_length.ts +31 -35
- package/src/programmers/internal/check_bigint.ts +76 -58
- package/src/programmers/internal/check_custom.ts +41 -0
- package/src/programmers/internal/check_number.ts +106 -77
- package/src/programmers/internal/check_string.ts +15 -14
- package/src/programmers/internal/check_string_tags.ts +23 -13
- package/src/programmers/internal/check_template.ts +16 -7
- package/src/programmers/internal/check_union_array_like.ts +5 -0
- package/src/programmers/internal/check_union_tuple.ts +2 -0
- package/src/programmers/internal/feature_object_entries.ts +1 -0
- package/src/transformers/CallExpressionTransformer.ts +9 -16
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +3 -1
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +1 -1
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +1 -1
- package/src/transformers/internal/GenericTransformer.ts +2 -2
- package/src/typings/Customizable.ts +6 -0
- package/src/utils/RandomGenerator.ts +8 -2
- 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.map +0 -1
- package/lib/messages/IProtocolMessage.d.ts +0 -5
- 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/transformers/features/protocols/MessageTransformer.ts +0 -32
- package/src/utils/NameEncoder.ts +0 -32
package/lib/utils/NameEncoder.js
DELETED
|
@@ -1,89 +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
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.NameEncoder = void 0;
|
|
31
|
-
var NameEncoder;
|
|
32
|
-
(function (NameEncoder) {
|
|
33
|
-
function encode(str) {
|
|
34
|
-
var e_1, _a;
|
|
35
|
-
try {
|
|
36
|
-
for (var REPLACERS_1 = __values(REPLACERS), REPLACERS_1_1 = REPLACERS_1.next(); !REPLACERS_1_1.done; REPLACERS_1_1 = REPLACERS_1.next()) {
|
|
37
|
-
var _b = __read(REPLACERS_1_1.value, 2), before = _b[0], after = _b[1];
|
|
38
|
-
str = str.split(before).join(after);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
42
|
-
finally {
|
|
43
|
-
try {
|
|
44
|
-
if (REPLACERS_1_1 && !REPLACERS_1_1.done && (_a = REPLACERS_1.return)) _a.call(REPLACERS_1);
|
|
45
|
-
}
|
|
46
|
-
finally { if (e_1) throw e_1.error; }
|
|
47
|
-
}
|
|
48
|
-
return str;
|
|
49
|
-
}
|
|
50
|
-
NameEncoder.encode = encode;
|
|
51
|
-
function decode(str) {
|
|
52
|
-
var e_2, _a;
|
|
53
|
-
try {
|
|
54
|
-
for (var REPLACERS_2 = __values(REPLACERS), REPLACERS_2_1 = REPLACERS_2.next(); !REPLACERS_2_1.done; REPLACERS_2_1 = REPLACERS_2.next()) {
|
|
55
|
-
var _b = __read(REPLACERS_2_1.value, 2), before = _b[0], after = _b[1];
|
|
56
|
-
if (after !== "")
|
|
57
|
-
str = str.split(after).join(before);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
61
|
-
finally {
|
|
62
|
-
try {
|
|
63
|
-
if (REPLACERS_2_1 && !REPLACERS_2_1.done && (_a = REPLACERS_2.return)) _a.call(REPLACERS_2);
|
|
64
|
-
}
|
|
65
|
-
finally { if (e_2) throw e_2.error; }
|
|
66
|
-
}
|
|
67
|
-
return str;
|
|
68
|
-
}
|
|
69
|
-
NameEncoder.decode = decode;
|
|
70
|
-
})(NameEncoder = exports.NameEncoder || (exports.NameEncoder = {}));
|
|
71
|
-
var REPLACERS = [
|
|
72
|
-
["$", "_dollar_"],
|
|
73
|
-
["&", "_and_"],
|
|
74
|
-
["|", "_or_"],
|
|
75
|
-
["{", "_blt_"],
|
|
76
|
-
["}", "_bgt_"],
|
|
77
|
-
["<", "_lt_"],
|
|
78
|
-
[">", "_gt_"],
|
|
79
|
-
["(", "_lp_"],
|
|
80
|
-
[")", "_rp_"],
|
|
81
|
-
["[", "_alt_"],
|
|
82
|
-
["]", "_agt_"],
|
|
83
|
-
[",", "_comma_"],
|
|
84
|
-
["`", "_backquote_"],
|
|
85
|
-
["'", "_singlequote_"],
|
|
86
|
-
['"', "_doublequote_"],
|
|
87
|
-
[" ", "_space_"],
|
|
88
|
-
];
|
|
89
|
-
//# sourceMappingURL=NameEncoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NameEncoder.js","sourceRoot":"","sources":["../../src/utils/NameEncoder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAiB,WAAW,CAY3B;AAZD,WAAiB,WAAW;IACxB,SAAgB,MAAM,CAAC,GAAW;;;YAC9B,KAA8B,IAAA,cAAA,SAAA,SAAS,CAAA,oCAAA;gBAA5B,IAAA,KAAA,8BAAe,EAAd,MAAM,QAAA,EAAE,KAAK,QAAA;gBACrB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAAA;;;;;;;;;QACxC,OAAO,GAAG,CAAC;IACf,CAAC;IAJe,kBAAM,SAIrB,CAAA;IAED,SAAgB,MAAM,CAAC,GAAW;;;YAC9B,KAA8B,IAAA,cAAA,SAAA,SAAS,CAAA,oCAAA;gBAA5B,IAAA,KAAA,8BAAe,EAAd,MAAM,QAAA,EAAE,KAAK,QAAA;gBACrB,IAAI,KAAK,KAAK,EAAE;oBAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAAA;;;;;;;;;QAC1D,OAAO,GAAG,CAAC;IACf,CAAC;IAJe,kBAAM,SAIrB,CAAA;AACL,CAAC,EAZgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAY3B;AAED,IAAM,SAAS,GAAuB;IAClC,CAAC,GAAG,EAAE,UAAU,CAAC;IACjB,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,OAAO,CAAC;IACd,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { Metadata } from "../metadata/Metadata";
|
|
4
|
-
|
|
5
|
-
import { IProtocolMessage } from "../messages/IProtocolMessage";
|
|
6
|
-
import { MetadataCollection } from "./MetadataCollection";
|
|
7
|
-
import { MetadataFactory } from "./MetadataFactory";
|
|
8
|
-
import { emplace_protocol_object } from "./internal/protocols/emplace_protocol_object";
|
|
9
|
-
import { iterate_protocol_main } from "./internal/protocols/iterate_protocol_main";
|
|
10
|
-
|
|
11
|
-
export namespace ProtocolFactory {
|
|
12
|
-
export const metadata =
|
|
13
|
-
(checker: ts.TypeChecker) =>
|
|
14
|
-
(collection: MetadataCollection) =>
|
|
15
|
-
(type: ts.Type) =>
|
|
16
|
-
MetadataFactory.generate(checker, collection, type, {
|
|
17
|
-
resolve: false,
|
|
18
|
-
constant: true,
|
|
19
|
-
validate: (meta) => {
|
|
20
|
-
if (meta.any) throw new Error(ErrorMessages.NO_ANY);
|
|
21
|
-
else if (meta.functional && meta.size() !== 1)
|
|
22
|
-
throw new Error(ErrorMessages.NO_FUNCTIONAL);
|
|
23
|
-
else if (meta.objects.find((o) => o.name === "__Main"))
|
|
24
|
-
throw new Error(ErrorMessages.NO_MAIN);
|
|
25
|
-
else if (meta.objects.find((o) => o.name === "__Timestamp"))
|
|
26
|
-
throw new Error(ErrorMessages.NO_TIMESTAMP);
|
|
27
|
-
else if (
|
|
28
|
-
meta.objects.some((o) =>
|
|
29
|
-
o.properties.some((p) => !is_atomic_key(p.key)),
|
|
30
|
-
) ||
|
|
31
|
-
meta.maps.some((m) => !is_atomic_key(m.key))
|
|
32
|
-
)
|
|
33
|
-
throw new Error(ErrorMessages.NOT_ALLOWED_KEY);
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export const generate =
|
|
38
|
-
(collection: MetadataCollection) =>
|
|
39
|
-
(dict: Map<string, IProtocolMessage>) =>
|
|
40
|
-
(meta: Metadata) => {
|
|
41
|
-
// EMPLACE OBJECTS
|
|
42
|
-
for (const obj of collection.objects())
|
|
43
|
-
emplace_protocol_object(dict)(obj);
|
|
44
|
-
|
|
45
|
-
// WHEN NOT OBJECT, WRAP IT INTO A FAKE MAIN OBJECT
|
|
46
|
-
iterate_protocol_main(dict)(meta);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const is_atomic_key = (key: Metadata) => {
|
|
50
|
-
if (
|
|
51
|
-
key.required &&
|
|
52
|
-
key.nullable === false &&
|
|
53
|
-
key.functional === false &&
|
|
54
|
-
key.resolved === null &&
|
|
55
|
-
key.size() ===
|
|
56
|
-
key.atomics.length +
|
|
57
|
-
key.constants
|
|
58
|
-
.map((c) => c.values.length)
|
|
59
|
-
.reduce((a, b) => a + b, 0) +
|
|
60
|
-
key.templates.length
|
|
61
|
-
) {
|
|
62
|
-
const set: Set<string> = new Set();
|
|
63
|
-
for (const atomic of key.atomics) set.add(atomic);
|
|
64
|
-
for (const constant of key.constants) set.add(constant.type);
|
|
65
|
-
if (key.templates.length) set.add("string");
|
|
66
|
-
|
|
67
|
-
return set.size === 1;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const enum ErrorMessages {
|
|
74
|
-
NO_ANY = `Error on typia.message(): any type is not supported in protocol buffer.`,
|
|
75
|
-
NO_FUNCTIONAL = `Error on typia.message(): functional type is not supported in protocol buffer.`,
|
|
76
|
-
NO_MAIN = `Error on typia.message(): reserved type "__Main" has been detected.`,
|
|
77
|
-
NO_TIMESTAMP = `Error on typia.message(): reserved type "__Timestamp" has been detected.`,
|
|
78
|
-
NOT_ALLOWED_KEY = `Error on typia.message(): only atomic key type is supported in protocol buffer.`,
|
|
79
|
-
}
|
|
@@ -1,163 +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
|
-
|
|
6
|
-
import { Atomic } from "../../../typings/Atomic";
|
|
7
|
-
|
|
8
|
-
export namespace ProtocolMetadataUtil {
|
|
9
|
-
export function size(meta: Metadata): number {
|
|
10
|
-
return (
|
|
11
|
-
meta.atomics.length +
|
|
12
|
-
meta.constants.filter(
|
|
13
|
-
(c) =>
|
|
14
|
-
meta.atomics.find((type) => c.type === type) === undefined,
|
|
15
|
-
).length +
|
|
16
|
-
(meta.templates.length !== 0 &&
|
|
17
|
-
meta.atomics.find((type) => type === "string") === undefined &&
|
|
18
|
-
meta.constants.find((c) => c.type === "string") === undefined
|
|
19
|
-
? 1
|
|
20
|
-
: 0) +
|
|
21
|
-
meta.tuples.length +
|
|
22
|
-
meta.arrays.length +
|
|
23
|
-
meta.sets.length +
|
|
24
|
-
meta.maps.length +
|
|
25
|
-
meta.objects.length +
|
|
26
|
-
meta.natives.filter((n) => n === "Date").length +
|
|
27
|
-
(meta.natives.filter((n) => n !== "Date").length ? 1 : 0)
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function standalone(meta: Metadata): boolean {
|
|
32
|
-
return (
|
|
33
|
-
size(meta) === 1 &&
|
|
34
|
-
meta.required === true &&
|
|
35
|
-
meta.nullable === false &&
|
|
36
|
-
meta.tuples.length === 0 &&
|
|
37
|
-
meta.arrays.length === 0 &&
|
|
38
|
-
meta.sets.length === 0 &&
|
|
39
|
-
meta.maps.length === 0 &&
|
|
40
|
-
meta.objects.every((obj) =>
|
|
41
|
-
obj.properties.every((p) => p.key.isSoleLiteral()),
|
|
42
|
-
)
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function regular(obj: MetadataObject): boolean {
|
|
47
|
-
return obj.properties.every((p) => p.key.isSoleLiteral());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function object(name: string, index: number): MetadataObject {
|
|
51
|
-
return MetadataObject.create({
|
|
52
|
-
name,
|
|
53
|
-
index,
|
|
54
|
-
properties: [],
|
|
55
|
-
description: undefined,
|
|
56
|
-
jsDocTags: [],
|
|
57
|
-
validated: false,
|
|
58
|
-
recursive: false,
|
|
59
|
-
nullables: [false],
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function property(
|
|
64
|
-
key: string,
|
|
65
|
-
value: Metadata,
|
|
66
|
-
tags: IMetadataTag[],
|
|
67
|
-
): MetadataProperty {
|
|
68
|
-
return MetadataProperty.create({
|
|
69
|
-
key: (() => {
|
|
70
|
-
const meta: Metadata = Metadata.initialize();
|
|
71
|
-
meta.constants.push({
|
|
72
|
-
type: "string",
|
|
73
|
-
values: [key],
|
|
74
|
-
});
|
|
75
|
-
return meta;
|
|
76
|
-
})(),
|
|
77
|
-
value: value,
|
|
78
|
-
description: undefined,
|
|
79
|
-
tags,
|
|
80
|
-
jsDocTags: [],
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function array(meta: Metadata): Metadata {
|
|
85
|
-
return Metadata.create({
|
|
86
|
-
any: false,
|
|
87
|
-
required: true,
|
|
88
|
-
nullable: false,
|
|
89
|
-
functional: false,
|
|
90
|
-
resolved: null,
|
|
91
|
-
atomics: [],
|
|
92
|
-
constants: [],
|
|
93
|
-
templates: [],
|
|
94
|
-
rest: null,
|
|
95
|
-
arrays: [meta],
|
|
96
|
-
tuples: [],
|
|
97
|
-
objects: [],
|
|
98
|
-
natives: [],
|
|
99
|
-
sets: [],
|
|
100
|
-
maps: [],
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function atomic(type: Atomic.Literal): Metadata {
|
|
105
|
-
return Metadata.create({
|
|
106
|
-
any: false,
|
|
107
|
-
required: true,
|
|
108
|
-
nullable: false,
|
|
109
|
-
functional: false,
|
|
110
|
-
resolved: null,
|
|
111
|
-
atomics: [type],
|
|
112
|
-
constants: [],
|
|
113
|
-
templates: [],
|
|
114
|
-
rest: null,
|
|
115
|
-
arrays: [],
|
|
116
|
-
tuples: [],
|
|
117
|
-
objects: [],
|
|
118
|
-
natives: [],
|
|
119
|
-
sets: [],
|
|
120
|
-
maps: [],
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function reference(obj: MetadataObject): Metadata {
|
|
125
|
-
return Metadata.create({
|
|
126
|
-
any: false,
|
|
127
|
-
required: true,
|
|
128
|
-
nullable: false,
|
|
129
|
-
functional: false,
|
|
130
|
-
resolved: null,
|
|
131
|
-
atomics: [],
|
|
132
|
-
constants: [],
|
|
133
|
-
templates: [],
|
|
134
|
-
rest: null,
|
|
135
|
-
arrays: [],
|
|
136
|
-
tuples: [],
|
|
137
|
-
objects: [obj],
|
|
138
|
-
natives: [],
|
|
139
|
-
sets: [],
|
|
140
|
-
maps: [],
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function map(elem: Metadata.Entry): Metadata {
|
|
145
|
-
return Metadata.create({
|
|
146
|
-
any: false,
|
|
147
|
-
required: true,
|
|
148
|
-
nullable: false,
|
|
149
|
-
functional: false,
|
|
150
|
-
resolved: null,
|
|
151
|
-
atomics: [],
|
|
152
|
-
constants: [],
|
|
153
|
-
templates: [],
|
|
154
|
-
rest: null,
|
|
155
|
-
arrays: [],
|
|
156
|
-
tuples: [],
|
|
157
|
-
objects: [],
|
|
158
|
-
natives: [],
|
|
159
|
-
sets: [],
|
|
160
|
-
maps: [elem],
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { MetadataObject } from "../../../metadata/MetadataObject";
|
|
2
|
-
|
|
3
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
4
|
-
import { emplace_protocol_property } from "./emplace_protocol_property";
|
|
5
|
-
|
|
6
|
-
export const emplace_protocol_object =
|
|
7
|
-
(dict: Map<string, IProtocolMessage>) => (object: MetadataObject) => {
|
|
8
|
-
if (dict.has(object.name)) return;
|
|
9
|
-
|
|
10
|
-
const regular = object.properties.filter((p) => p.key.isSoleLiteral());
|
|
11
|
-
const dynamic = object.properties.filter((p) => !p.key.isSoleLiteral());
|
|
12
|
-
|
|
13
|
-
if (dynamic.length) return;
|
|
14
|
-
|
|
15
|
-
const output: IProtocolMessage = {
|
|
16
|
-
name: object.name,
|
|
17
|
-
properties: [],
|
|
18
|
-
};
|
|
19
|
-
dict.set(object.name, output);
|
|
20
|
-
|
|
21
|
-
output.properties.push(
|
|
22
|
-
...regular.map((prop) => emplace_protocol_property(dict)(prop)),
|
|
23
|
-
);
|
|
24
|
-
return output;
|
|
25
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MetadataProperty } from "../../../metadata/MetadataProperty";
|
|
2
|
-
|
|
3
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
4
|
-
import { IProtocolProperty } from "../../../messages/IProtocolProperty";
|
|
5
|
-
import { iterate_protocol_metadata } from "./iterate_protocol_metadata";
|
|
6
|
-
|
|
7
|
-
export const emplace_protocol_property =
|
|
8
|
-
(dict: Map<string, IProtocolMessage>) =>
|
|
9
|
-
(property: MetadataProperty): IProtocolProperty => ({
|
|
10
|
-
key: property.key.getSoleLiteral()!,
|
|
11
|
-
...iterate_protocol_metadata(dict)(property.value)(property.tags),
|
|
12
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IMetadataTag } from "../../../metadata/IMetadataTag";
|
|
2
|
-
|
|
3
|
-
import { Atomic } from "../../../typings/Atomic";
|
|
4
|
-
|
|
5
|
-
export const iterate_protocol_atomic =
|
|
6
|
-
(tags: IMetadataTag[]) => (type: Atomic.Literal) => {
|
|
7
|
-
if (type === "boolean") return "bool";
|
|
8
|
-
else if (type === "number") return number(tags);
|
|
9
|
-
else if (type === "bigint") return bigint(tags);
|
|
10
|
-
else return "string";
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const number = (tagList: IMetadataTag[]) => {
|
|
14
|
-
const filtered: IMetadataTag.INumberType[] = tagList.filter(
|
|
15
|
-
(tag) => tag.kind === "type",
|
|
16
|
-
) as IMetadataTag.INumberType[];
|
|
17
|
-
|
|
18
|
-
for (const { value } of filtered)
|
|
19
|
-
if (value === "int") return "int32";
|
|
20
|
-
else if (value === "uint") return "uint32";
|
|
21
|
-
return "double";
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const bigint = (tagList: IMetadataTag[]) => {
|
|
25
|
-
const filtered: IMetadataTag.IBigintType[] = tagList.filter(
|
|
26
|
-
(tag) =>
|
|
27
|
-
tag.kind === "type" &&
|
|
28
|
-
(tag.value === "int64" || tag.value === "uint64"),
|
|
29
|
-
) as IMetadataTag.IBigintType[];
|
|
30
|
-
|
|
31
|
-
for (const { value } of filtered)
|
|
32
|
-
if (value === "int64" || value === "uint64") return value;
|
|
33
|
-
return "int64";
|
|
34
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MetadataConstant } from "../../../metadata/MetadataConstant";
|
|
2
|
-
|
|
3
|
-
export const iterate_protocol_constant = ({
|
|
4
|
-
type,
|
|
5
|
-
values,
|
|
6
|
-
}: MetadataConstant) => {
|
|
7
|
-
if (type === "boolean") return "bool";
|
|
8
|
-
else if (type === "number") return number(values);
|
|
9
|
-
else if (type === "bigint") return bigint(values);
|
|
10
|
-
else return "string";
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const bigint = (values: bigint[]): string => {
|
|
14
|
-
return values.every((v) => v >= BigInt(0)) ? "uint64" : "int64";
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const number = (values: number[]): string => {
|
|
18
|
-
return values.some((v) => Math.floor(v) !== v)
|
|
19
|
-
? "double"
|
|
20
|
-
: values.every((v) => v >= 0)
|
|
21
|
-
? values.every((v) => v <= 2 ** 64 - 1)
|
|
22
|
-
? "uint32"
|
|
23
|
-
: "uint64"
|
|
24
|
-
: values.every((v) => -(2 ** 31) <= v && v <= 2 ** 31 - 1)
|
|
25
|
-
? "int32"
|
|
26
|
-
: "int64";
|
|
27
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
2
|
-
|
|
3
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
4
|
-
import { ProtocolMetadataUtil } from "./ProtocolMetadataUtil";
|
|
5
|
-
import { emplace_protocol_object } from "./emplace_protocol_object";
|
|
6
|
-
|
|
7
|
-
export const iterate_protocol_main =
|
|
8
|
-
(dict: Map<string, IProtocolMessage>) =>
|
|
9
|
-
(meta: Metadata): string => {
|
|
10
|
-
// ONLY ONE OBJECT TYPE
|
|
11
|
-
if (ProtocolMetadataUtil.standalone(meta) && meta.objects.length === 1)
|
|
12
|
-
return meta.getName();
|
|
13
|
-
|
|
14
|
-
const obj = ProtocolMetadataUtil.object("__Main", dict.size);
|
|
15
|
-
obj.properties.push(ProtocolMetadataUtil.property("value", meta, []));
|
|
16
|
-
emplace_protocol_object(dict)(obj);
|
|
17
|
-
|
|
18
|
-
return obj.name;
|
|
19
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
2
|
-
import { MetadataObject } from "../../../metadata/MetadataObject";
|
|
3
|
-
|
|
4
|
-
import { IProtocolMap } from "../../../messages/IProtocolMap";
|
|
5
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
6
|
-
import { ProtocolMetadataUtil } from "./ProtocolMetadataUtil";
|
|
7
|
-
import { emplace_protocol_object } from "./emplace_protocol_object";
|
|
8
|
-
import { iterate_protocol_atomic } from "./iterate_protocol_atomic";
|
|
9
|
-
import { iterate_protocol_constant } from "./iterate_protocol_constant";
|
|
10
|
-
import { iterate_protocol_metadata } from "./iterate_protocol_metadata";
|
|
11
|
-
|
|
12
|
-
export const iterate_protocol_map =
|
|
13
|
-
(sole: boolean) =>
|
|
14
|
-
(dict: Map<string, IProtocolMessage>) =>
|
|
15
|
-
(prop: Metadata.Entry): string | IProtocolMap => {
|
|
16
|
-
if (sole === true)
|
|
17
|
-
return {
|
|
18
|
-
type: "map",
|
|
19
|
-
key: getKeyName(prop.key),
|
|
20
|
-
value: getValueName(dict)(prop.value),
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const obj: MetadataObject = ProtocolMetadataUtil.object(
|
|
24
|
-
`Map.Wrapper<${prop.key.getName()}, ${prop.value.getName()}>`,
|
|
25
|
-
dict.size,
|
|
26
|
-
);
|
|
27
|
-
obj.properties.push(
|
|
28
|
-
ProtocolMetadataUtil.property(
|
|
29
|
-
"value",
|
|
30
|
-
ProtocolMetadataUtil.map(prop),
|
|
31
|
-
[],
|
|
32
|
-
),
|
|
33
|
-
);
|
|
34
|
-
emplace_protocol_object(dict)(obj);
|
|
35
|
-
return obj.name;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const getKeyName = (meta: Metadata) => {
|
|
39
|
-
for (const atomic of meta.atomics)
|
|
40
|
-
return iterate_protocol_atomic([])(atomic);
|
|
41
|
-
for (const constant of meta.constants)
|
|
42
|
-
return iterate_protocol_constant(constant);
|
|
43
|
-
return "string";
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const getValueName =
|
|
47
|
-
(dict: Map<string, IProtocolMessage>) => (meta: Metadata) => {
|
|
48
|
-
if (ProtocolMetadataUtil.standalone(meta))
|
|
49
|
-
return iterate_protocol_metadata(dict)(meta)([]).oneOf[0]!.type;
|
|
50
|
-
|
|
51
|
-
const obj: MetadataObject = ProtocolMetadataUtil.object(
|
|
52
|
-
`Map.Value<${meta.getName()}>`,
|
|
53
|
-
dict.size,
|
|
54
|
-
);
|
|
55
|
-
obj.properties.push(ProtocolMetadataUtil.property("value", meta, []));
|
|
56
|
-
emplace_protocol_object(dict)(obj);
|
|
57
|
-
return obj.name;
|
|
58
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { IMetadataTag } from "../../../metadata/IMetadataTag";
|
|
2
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
3
|
-
|
|
4
|
-
import { IProtocolMap } from "../../../messages/IProtocolMap";
|
|
5
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
6
|
-
import { IProtocolProperty } from "../../../messages/IProtocolProperty";
|
|
7
|
-
import { iterate_protocol_atomic } from "./iterate_protocol_atomic";
|
|
8
|
-
import { iterate_protocol_constant } from "./iterate_protocol_constant";
|
|
9
|
-
import { iterate_protocol_map } from "./iterate_protocol_map";
|
|
10
|
-
import { iterate_protocol_native } from "./iterate_protocol_native";
|
|
11
|
-
import { iterate_protocol_never } from "./iterate_protocol_never";
|
|
12
|
-
import { iterate_protocol_object } from "./iterate_protocol_object";
|
|
13
|
-
import { iterate_protocol_repeated } from "./iterate_protocol_repeated";
|
|
14
|
-
import { iterate_protocol_tuple } from "./iterate_protocol_tuple";
|
|
15
|
-
|
|
16
|
-
export const iterate_protocol_metadata =
|
|
17
|
-
(dict: Map<string, IProtocolMessage>) =>
|
|
18
|
-
(meta: Metadata) =>
|
|
19
|
-
(tags: IMetadataTag[]): Omit<IProtocolProperty, "key"> => {
|
|
20
|
-
// PREPARE ASSETS
|
|
21
|
-
const sole: boolean = meta.size() === 1;
|
|
22
|
-
const bucket: boolean = sole && meta.bucket() === 1;
|
|
23
|
-
const required: boolean =
|
|
24
|
-
(meta.required && !meta.nullable) ||
|
|
25
|
-
(sole &&
|
|
26
|
-
(meta.arrays.length === 1 ||
|
|
27
|
-
meta.sets.length === 1 ||
|
|
28
|
-
meta.maps.length === 1 ||
|
|
29
|
-
(meta.objects.length === 1 &&
|
|
30
|
-
meta.objects[0]!.properties.length === 1 &&
|
|
31
|
-
!meta.objects[0]!.properties[0]?.key.isSoleLiteral())));
|
|
32
|
-
|
|
33
|
-
const oneOf: IProtocolProperty.IOneOf[] = [];
|
|
34
|
-
const add = (type: string | IProtocolMap) => {
|
|
35
|
-
if (oneOf.some((one) => one.type === type)) return;
|
|
36
|
-
oneOf.push({
|
|
37
|
-
type,
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// WHEN SINGULAR ARRAY TYPE
|
|
42
|
-
if (sole && meta.arrays.length + meta.sets.length === 1) {
|
|
43
|
-
const [container, child] =
|
|
44
|
-
meta.arrays.length === 1
|
|
45
|
-
? (["Array", meta.arrays[0]!] as const)
|
|
46
|
-
: (["Set", meta.sets[0]!] as const);
|
|
47
|
-
add(
|
|
48
|
-
iterate_protocol_repeated(container)(true, true)(dict)(child)(
|
|
49
|
-
tags,
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
return {
|
|
53
|
-
required,
|
|
54
|
-
oneOf,
|
|
55
|
-
repeated: true,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ATOMIC TYPES
|
|
60
|
-
for (const type of meta.atomics)
|
|
61
|
-
add(iterate_protocol_atomic(tags)(type));
|
|
62
|
-
for (const constant of meta.constants)
|
|
63
|
-
add(iterate_protocol_constant(constant));
|
|
64
|
-
if (meta.templates.length) add("string");
|
|
65
|
-
if (meta.size() === 0) add(iterate_protocol_never());
|
|
66
|
-
|
|
67
|
-
// OBJECT TYPES
|
|
68
|
-
for (const obj of meta.objects)
|
|
69
|
-
add(iterate_protocol_object(sole)(dict)(obj));
|
|
70
|
-
for (const map of meta.maps) add(iterate_protocol_map(sole)(dict)(map));
|
|
71
|
-
for (const native of meta.natives)
|
|
72
|
-
add(iterate_protocol_native(dict)(native));
|
|
73
|
-
|
|
74
|
-
// ARRAY TYPES
|
|
75
|
-
for (const tuple of meta.tuples)
|
|
76
|
-
add(iterate_protocol_tuple(dict)(tuple));
|
|
77
|
-
for (const array of meta.arrays)
|
|
78
|
-
add(
|
|
79
|
-
iterate_protocol_repeated("Array")(false, bucket)(dict)(array)(
|
|
80
|
-
tags,
|
|
81
|
-
),
|
|
82
|
-
);
|
|
83
|
-
for (const set of meta.sets)
|
|
84
|
-
add(
|
|
85
|
-
iterate_protocol_repeated("Set")(false, bucket)(dict)(set)(
|
|
86
|
-
tags,
|
|
87
|
-
),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// RETURNS
|
|
91
|
-
return {
|
|
92
|
-
required,
|
|
93
|
-
oneOf,
|
|
94
|
-
repeated: false,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Metadata } from "../../../metadata/Metadata";
|
|
2
|
-
|
|
3
|
-
import { IProtocolMessage } from "../../../messages/IProtocolMessage";
|
|
4
|
-
import { ProtocolMetadataUtil } from "./ProtocolMetadataUtil";
|
|
5
|
-
import { emplace_protocol_object } from "./emplace_protocol_object";
|
|
6
|
-
|
|
7
|
-
export const iterate_protocol_native =
|
|
8
|
-
(dict: Map<string, IProtocolMessage>) => (native: string) => {
|
|
9
|
-
if (native === "Date") {
|
|
10
|
-
const obj = ProtocolMetadataUtil.object("__Timestamp", dict.size);
|
|
11
|
-
obj.properties.push(
|
|
12
|
-
ProtocolMetadataUtil.property("seconds", integer("bigint"), [
|
|
13
|
-
{
|
|
14
|
-
kind: "type",
|
|
15
|
-
value: "int64",
|
|
16
|
-
},
|
|
17
|
-
]),
|
|
18
|
-
ProtocolMetadataUtil.property("nanos", integer("number"), [
|
|
19
|
-
{
|
|
20
|
-
kind: "type",
|
|
21
|
-
value: "int",
|
|
22
|
-
},
|
|
23
|
-
]),
|
|
24
|
-
);
|
|
25
|
-
emplace_protocol_object(dict)(obj);
|
|
26
|
-
return "__Timestamp";
|
|
27
|
-
} else return "bytes";
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const integer = (type: "number" | "bigint") => {
|
|
31
|
-
const meta = Metadata.initialize();
|
|
32
|
-
meta.atomics.push(type);
|
|
33
|
-
return meta;
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const iterate_protocol_never = () => "uint32";
|