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
package/README.md
CHANGED
|
@@ -11,24 +11,27 @@ export function is<T>(input: unknown | T): input is T; // returns boolean
|
|
|
11
11
|
export function assert<T>(input: unknown | T): T; // throws TypeGuardError
|
|
12
12
|
export function validate<T>(input: unknown | T): IValidation<T>; // detailed
|
|
13
13
|
|
|
14
|
-
// STRICT VALIDATORS
|
|
15
|
-
export function equals<T>(input: unknown | T): input is T;
|
|
16
|
-
export function assertEquals<T>(input: unknown | T): T;
|
|
17
|
-
export function validateEquals<T>(input: unknown | T): IValidation<T>;
|
|
18
|
-
|
|
19
14
|
// JSON
|
|
20
15
|
export function application<T>(): IJsonApplication; // JSON schema
|
|
21
16
|
export function assertParse<T>(input: string): T; // type safe parser
|
|
22
17
|
export function assertStringify<T>(input: T): string; // safe and faster
|
|
23
18
|
// +) isParse, validateParse
|
|
24
19
|
// +) stringify, isStringify, validateStringify
|
|
20
|
+
|
|
21
|
+
// PROTOCOL BUFFER
|
|
22
|
+
export function message<T>(): string; // Protocol Buffer message
|
|
23
|
+
export function assertDecode<T>(buffer: Buffer): T; // safe decoder
|
|
24
|
+
export function assertEncode<T>(input: T): Uint8Array; // safe encoder
|
|
25
|
+
// +) decode, isDecode, validateDecode
|
|
26
|
+
// +) encode, isEncode, validateEncode
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
`typia` is a transformer library of TypeScript, supporting below features:
|
|
28
30
|
|
|
29
31
|
- Super-fast Runtime Validators
|
|
30
32
|
- Safe JSON parse and fast stringify functions
|
|
31
|
-
-
|
|
33
|
+
- Protocol Buffer encoder and decoder
|
|
34
|
+
- Protobuf/JSON schema generator
|
|
32
35
|
|
|
33
36
|
All functions in `typia` require **only one line**. You don't need any extra dedication like JSON schema definitions or decorator function calls. Just call `typia` function with only one line like `typia.assert<T>(input)`.
|
|
34
37
|
|
|
@@ -41,7 +44,7 @@ Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance
|
|
|
41
44
|
|
|
42
45
|
|
|
43
46
|
|
|
44
|
-
## Sponsors
|
|
47
|
+
## Sponsors
|
|
45
48
|
Thanks for your support.
|
|
46
49
|
|
|
47
50
|
Your donation would encourage `typia` development.
|
|
@@ -133,6 +136,12 @@ For more details, refer to the [Guide Documents (wiki)](https://github.com/samch
|
|
|
133
136
|
> - [`parse()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#parse-functions)
|
|
134
137
|
> - [`stringify()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#stringify-functions)
|
|
135
138
|
> - [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
|
|
139
|
+
> - **Protocol Buffer**
|
|
140
|
+
> - [`message()` function](https://github.com/samchon/typia/wiki/Protocol-Buffer#message-function)
|
|
141
|
+
> - [`decode()` function](https://github.com/samchon/typia/wiki/Protocol-Buffer#decode-function)
|
|
142
|
+
> - [`encode()` functions](https://github.com/samchon/typia/wiki/Protocol-Buffer#encode-functions)
|
|
143
|
+
> - [comment tags](https://github.com/samchon/typia/wiki/Protocol-Buffer#comment-tags)
|
|
144
|
+
> - [weaknesses](https://github.com/samchon/typia/wiki/Protocol-Buffer#weaknesses)
|
|
136
145
|
|
|
137
146
|
### Runtime Validators
|
|
138
147
|
```typescript
|
|
@@ -207,7 +216,39 @@ export function createAssertStringify<T>(): (input: T) => string;
|
|
|
207
216
|
|
|
208
217
|
> Measured on [AMD R7 5800H](https://github.com/samchon/typia/tree/master/benchmark/results/AMD%20Ryzen%207%205800H%20with%20Radeon%20Graphics#stringify)
|
|
209
218
|
|
|
219
|
+
### Protocol Buffer
|
|
220
|
+
```typescript
|
|
221
|
+
// PROTOCOL BUFFER MESSAGE
|
|
222
|
+
export function message<T>(): string;
|
|
223
|
+
|
|
224
|
+
// ENCODE FUNCTIONS
|
|
225
|
+
export function encode<T>(input: T): Uint8Array;
|
|
226
|
+
export function isEncode<T>(input: T): Uint8Array | null;
|
|
227
|
+
export function assertEncode<T>(input: T): Uint8Array;
|
|
228
|
+
export function validateEncode<T>(input: T): IValidation<Uint8Array>;
|
|
229
|
+
|
|
230
|
+
// DECODE FUNCTIONS
|
|
231
|
+
export function decode<T>(buffer: Uint8Array): T;
|
|
232
|
+
export function isDecode<T>(buffer: Uint8Array): T | null;
|
|
233
|
+
export function assertDecode<T>(buffer: Uint8Array): T;
|
|
234
|
+
export function validateDecode<T>(buffer: Uint8Array): IValidation<T>;
|
|
235
|
+
|
|
236
|
+
// FACTORY FUNCTIONS
|
|
237
|
+
export function createDecode<T>(): (input: Uint8Array) => T;
|
|
238
|
+
export function createEncode<T>(): (input: T) => Uint8Array;
|
|
239
|
+
// +) createIsDecode, createAssertDecode, createValidateDecode
|
|
240
|
+
// +) createIsEncode, createAssertEncode, createValidateEncode
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
`typia` supports Protocol Buffer.
|
|
244
|
+
|
|
245
|
+
- `message()`: generate Protocol Buffer schema
|
|
246
|
+
- `encode()`: encode JavaScript object to Protocol Buffer
|
|
247
|
+
- `decode()`: decode Protocol Buffer to JavaScript object
|
|
248
|
+
|
|
249
|
+
Do not need to define any `*.proto` schema file. Just call above functions with generic argument `T`, then `typia` will generate the Protocol Buffer schema automatically, by analyzing your type `T`.
|
|
210
250
|
|
|
251
|
+
If you want to add special type like `float32`, you can do it through **comment tags**. If you want to know more about those comment tags, visit Guide Documents ([Features > Protocol Buffer > Comment Tags](https://github.com/samchon/typia/wiki/Protocol-Buffer#comment-tags)).
|
|
211
252
|
|
|
212
253
|
|
|
213
254
|
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { MetadataObject } from "../metadata/MetadataObject";
|
|
3
3
|
export declare class MetadataCollection {
|
|
4
|
-
private readonly options?;
|
|
5
4
|
private readonly dict_;
|
|
6
5
|
private readonly names_;
|
|
7
6
|
private readonly unions_;
|
|
8
7
|
private index_;
|
|
9
|
-
constructor(
|
|
8
|
+
constructor();
|
|
10
9
|
objects(): MetadataObject[];
|
|
11
10
|
unions(): MetadataObject[][];
|
|
12
11
|
emplace(checker: ts.TypeChecker, type: ts.Type): [MetadataObject, boolean];
|
|
13
12
|
private get_name;
|
|
14
13
|
}
|
|
15
|
-
export declare namespace MetadataCollection {
|
|
16
|
-
interface IOptions {
|
|
17
|
-
replace?(str: string): string;
|
|
18
|
-
}
|
|
19
|
-
function replace(str: string): string;
|
|
20
|
-
function escape(str: string): string;
|
|
21
|
-
}
|
|
@@ -24,17 +24,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
24
24
|
}
|
|
25
25
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
26
|
};
|
|
27
|
-
var __values = (this && this.__values) || function(o) {
|
|
28
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
-
if (m) return m.call(o);
|
|
30
|
-
if (o && typeof o.length === "number") return {
|
|
31
|
-
next: function () {
|
|
32
|
-
if (o && i >= o.length) o = void 0;
|
|
33
|
-
return { value: o && o[i++], done: !o };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
-
};
|
|
38
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
28
|
exports.MetadataCollection = void 0;
|
|
40
29
|
var MetadataObject_1 = require("../metadata/MetadataObject");
|
|
@@ -42,8 +31,7 @@ var MapUtil_1 = require("../utils/MapUtil");
|
|
|
42
31
|
var CommentFactory_1 = require("./CommentFactory");
|
|
43
32
|
var TypeFactory_1 = require("./TypeFactory");
|
|
44
33
|
var MetadataCollection = (function () {
|
|
45
|
-
function MetadataCollection(
|
|
46
|
-
this.options = options;
|
|
34
|
+
function MetadataCollection() {
|
|
47
35
|
this.dict_ = new Map();
|
|
48
36
|
this.names_ = new Map();
|
|
49
37
|
this.unions_ = new Map();
|
|
@@ -82,12 +70,7 @@ var MetadataCollection = (function () {
|
|
|
82
70
|
return __spreadArray([], __read(this.unions_.keys()), false).indexOf(key);
|
|
83
71
|
};
|
|
84
72
|
MetadataCollection.prototype.get_name = function (checker, type) {
|
|
85
|
-
var
|
|
86
|
-
var name = (function () {
|
|
87
|
-
var _a;
|
|
88
|
-
var str = TypeFactory_1.TypeFactory.getFullName(checker, type);
|
|
89
|
-
return ((_a = _this.options) === null || _a === void 0 ? void 0 : _a.replace) ? _this.options.replace(str) : str;
|
|
90
|
-
})();
|
|
73
|
+
var name = TypeFactory_1.TypeFactory.getFullName(checker, type);
|
|
91
74
|
var duplicates = MapUtil_1.MapUtil.take(this.names_, name, function () { return new Map(); });
|
|
92
75
|
var oldbie = duplicates.get(type);
|
|
93
76
|
if (oldbie !== undefined)
|
|
@@ -101,60 +84,4 @@ var MetadataCollection = (function () {
|
|
|
101
84
|
return MetadataCollection;
|
|
102
85
|
}());
|
|
103
86
|
exports.MetadataCollection = MetadataCollection;
|
|
104
|
-
(function (MetadataCollection) {
|
|
105
|
-
function replace(str) {
|
|
106
|
-
var e_1, _a;
|
|
107
|
-
try {
|
|
108
|
-
for (var REPLACERS_1 = __values(REPLACERS), REPLACERS_1_1 = REPLACERS_1.next(); !REPLACERS_1_1.done; REPLACERS_1_1 = REPLACERS_1.next()) {
|
|
109
|
-
var _b = __read(REPLACERS_1_1.value, 2), before = _b[0], after = _b[1];
|
|
110
|
-
str = str.split(before).join(after);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
114
|
-
finally {
|
|
115
|
-
try {
|
|
116
|
-
if (REPLACERS_1_1 && !REPLACERS_1_1.done && (_a = REPLACERS_1.return)) _a.call(REPLACERS_1);
|
|
117
|
-
}
|
|
118
|
-
finally { if (e_1) throw e_1.error; }
|
|
119
|
-
}
|
|
120
|
-
return str;
|
|
121
|
-
}
|
|
122
|
-
MetadataCollection.replace = replace;
|
|
123
|
-
function escape(str) {
|
|
124
|
-
var e_2, _a;
|
|
125
|
-
try {
|
|
126
|
-
for (var REPLACERS_2 = __values(REPLACERS), REPLACERS_2_1 = REPLACERS_2.next(); !REPLACERS_2_1.done; REPLACERS_2_1 = REPLACERS_2.next()) {
|
|
127
|
-
var _b = __read(REPLACERS_2_1.value, 2), before = _b[0], after = _b[1];
|
|
128
|
-
if (after !== "")
|
|
129
|
-
str = str.split(after).join(before);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
133
|
-
finally {
|
|
134
|
-
try {
|
|
135
|
-
if (REPLACERS_2_1 && !REPLACERS_2_1.done && (_a = REPLACERS_2.return)) _a.call(REPLACERS_2);
|
|
136
|
-
}
|
|
137
|
-
finally { if (e_2) throw e_2.error; }
|
|
138
|
-
}
|
|
139
|
-
return str;
|
|
140
|
-
}
|
|
141
|
-
MetadataCollection.escape = escape;
|
|
142
|
-
})(MetadataCollection = exports.MetadataCollection || (exports.MetadataCollection = {}));
|
|
143
|
-
exports.MetadataCollection = MetadataCollection;
|
|
144
|
-
var REPLACERS = [
|
|
145
|
-
["$", "_dollar_"],
|
|
146
|
-
["&", "_and_"],
|
|
147
|
-
["|", "_or_"],
|
|
148
|
-
["{", "_blt_"],
|
|
149
|
-
["}", "_bgt_"],
|
|
150
|
-
["<", "_lt_"],
|
|
151
|
-
[">", "_gt_"],
|
|
152
|
-
["[", "_alt_"],
|
|
153
|
-
["]", "_agt_"],
|
|
154
|
-
[",", "_comma_"],
|
|
155
|
-
["`", "_backquote_"],
|
|
156
|
-
["'", "_singlequote_"],
|
|
157
|
-
['"', "_doublequote_"],
|
|
158
|
-
[" ", "_space_"],
|
|
159
|
-
];
|
|
160
87
|
//# sourceMappingURL=MetadataCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetadataCollection.js","sourceRoot":"","sources":["../../src/factories/MetadataCollection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetadataCollection.js","sourceRoot":"","sources":["../../src/factories/MetadataCollection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,6DAA4D;AAE5D,4CAA2C;AAE3C,mDAAkD;AAClD,6CAA4C;AAE5C;IAMI;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC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,GAAG,IAAK,OAAA,GAAG,CAAC,IAAI,EAAR,CAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,cAAM,OAAA,IAAI,CAAC,OAAO,EAAZ,CAAY,CAAC,CAAC;QACpD,OAAO,yBAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC;IAEO,qCAAQ,GAAhB,UAAiB,OAAuB,EAAE,IAAa;QACnD,IAAM,IAAI,GAAW,yBAAW,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC5D,IAAM,UAAU,GAAyB,iBAAO,CAAC,IAAI,CACjD,IAAI,CAAC,MAAM,EACX,IAAI,EACJ,cAAM,OAAA,IAAI,GAAG,EAAE,EAAT,CAAS,CAClB,CAAC;QACF,IAAM,MAAM,GAAuB,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QAExC,IAAM,QAAQ,GAAW,UAAU,CAAC,IAAI;YACpC,CAAC,CAAC,UAAG,IAAI,eAAK,UAAU,CAAC,IAAI,CAAE;YAC/B,CAAC,CAAC,IAAI,CAAC;QACX,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,QAAQ,CAAC;IACpB,CAAC;IACL,yBAAC;AAAD,CAAC,AAxED,IAwEC;AAxEY,gDAAkB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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.filter(function (p) {
|
|
37
|
+
return p.key.isSoleLiteral();
|
|
38
|
+
}).length &&
|
|
39
|
+
o.properties.filter(function (p) { return !p.key.isSoleLiteral(); }).length;
|
|
40
|
+
}))
|
|
41
|
+
throw new Error("Error on typia.message(): object can't have both regular and dynamic properties in protocol buffer.");
|
|
42
|
+
else if (meta.objects.some(function (o) {
|
|
43
|
+
return o.properties.some(function (p) { return !is_atomic_key(p.key); });
|
|
44
|
+
}) ||
|
|
45
|
+
meta.maps.some(function (m) { return !is_atomic_key(m.key); }))
|
|
46
|
+
throw new Error("Error on typia.message(): only atomic key type is supported in protocol buffer.");
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
ProtocolFactory.generate = function (collection) {
|
|
53
|
+
return function (dict) {
|
|
54
|
+
return function (meta) {
|
|
55
|
+
var e_1, _a;
|
|
56
|
+
try {
|
|
57
|
+
for (var _b = __values(collection.objects()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
58
|
+
var obj = _c.value;
|
|
59
|
+
(0, emplace_protocol_object_1.emplace_protocol_object)(dict)(obj);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
63
|
+
finally {
|
|
64
|
+
try {
|
|
65
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
66
|
+
}
|
|
67
|
+
finally { if (e_1) throw e_1.error; }
|
|
68
|
+
}
|
|
69
|
+
(0, iterate_protocol_main_1.iterate_protocol_main)(dict)(meta);
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
var is_atomic_key = function (key) {
|
|
74
|
+
var e_2, _a, e_3, _b;
|
|
75
|
+
if (key.required &&
|
|
76
|
+
key.nullable === false &&
|
|
77
|
+
key.functional === false &&
|
|
78
|
+
key.resolved === null &&
|
|
79
|
+
key.size() ===
|
|
80
|
+
key.atomics.length +
|
|
81
|
+
key.constants
|
|
82
|
+
.map(function (c) { return c.values.length; })
|
|
83
|
+
.reduce(function (a, b) { return a + b; }, 0) +
|
|
84
|
+
key.templates.length) {
|
|
85
|
+
var set = new Set();
|
|
86
|
+
try {
|
|
87
|
+
for (var _c = __values(key.atomics), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
88
|
+
var atomic = _d.value;
|
|
89
|
+
set.add(atomic);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e_2) throw e_2.error; }
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
for (var _e = __values(key.constants), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
101
|
+
var constant = _f.value;
|
|
102
|
+
set.add(constant.type);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
106
|
+
finally {
|
|
107
|
+
try {
|
|
108
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
109
|
+
}
|
|
110
|
+
finally { if (e_3) throw e_3.error; }
|
|
111
|
+
}
|
|
112
|
+
if (key.templates.length)
|
|
113
|
+
set.add("string");
|
|
114
|
+
return set.size === 1;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
};
|
|
118
|
+
})(ProtocolFactory = exports.ProtocolFactory || (exports.ProtocolFactory = {}));
|
|
119
|
+
//# sourceMappingURL=ProtocolFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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K,OAAA,CAAC,CAAC,MAAM,CAAC,MAAM,EAAf,CAAe,CAAC;yBAC3B,MAAM,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK,EAAE,CAAC,CAAC;oBAC/B,GAAG,CAAC,SAAS,CAAC,MAAM,EAC9B;YACE,IAAM,GAAG,GAAgB,IAAI,GAAG,EAAE,CAAC;;gBACnC,KAAqB,IAAA,KAAA,SAAA,GAAG,CAAC,OAAO,CAAA,gBAAA;oBAA3B,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,EAxEgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAwE/B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
export declare namespace ProtocolMetadataUtil {
|
|
6
|
+
function size(meta: Metadata): number;
|
|
7
|
+
function standalone(meta: Metadata): boolean;
|
|
8
|
+
function regular(obj: MetadataObject): boolean;
|
|
9
|
+
function object(name: string, index: number): MetadataObject;
|
|
10
|
+
function property(key: string, value: Metadata, tags: IMetadataTag[]): MetadataProperty;
|
|
11
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
})(ProtocolMetadataUtil = exports.ProtocolMetadataUtil || (exports.ProtocolMetadataUtil = {}));
|
|
76
|
+
//# sourceMappingURL=ProtocolMetadataUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolMetadataUtil.js","sourceRoot":"","sources":["../../../../src/factories/internal/protocols/ProtocolMetadataUtil.ts"],"names":[],"mappings":";;;AACA,uDAAsD;AACtD,mEAAkE;AAClE,uEAAsE;AAEtE,IAAiB,oBAAoB,CA2EpC;AA3ED,WAAiB,oBAAoB;IACjC,SAAgB,IAAI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,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE,CAAC,GAAG,CAAC;iBAChB,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;YAChB,CAAC,CAAC,EAAE;YACJ,KAAK,EAAE,KAAK;YACZ,WAAW,EAAE,SAAS;YACtB,IAAI,MAAA;YACJ,SAAS,EAAE,EAAE;SAChB,CAAC,CAAC;IACP,CAAC;IAnBe,6BAAQ,WAmBvB,CAAA;AACL,CAAC,EA3EgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA2EpC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
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;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 (!regular.length || 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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO;IAE9C,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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.emplace_protocol_property = void 0;
|
|
15
|
+
var iterate_protocol_metadata_1 = require("./iterate_protocol_metadata");
|
|
16
|
+
var emplace_protocol_property = function (dict) {
|
|
17
|
+
return function (property) { return (__assign({ key: property.key.getSoleLiteral() }, (0, iterate_protocol_metadata_1.iterate_protocol_metadata)(dict)(property.value)(property.tags))); };
|
|
18
|
+
};
|
|
19
|
+
exports.emplace_protocol_property = emplace_protocol_property;
|
|
20
|
+
//# sourceMappingURL=emplace_protocol_property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emplace_protocol_property.js","sourceRoot":"","sources":["../../../../src/factories/internal/protocols/emplace_protocol_property.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,yEAAwE;AAEjE,IAAM,yBAAyB,GAClC,UAAC,IAAmC;IACpC,OAAA,UAAC,QAA0B,IAAwB,OAAA,YAC/C,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAG,IAChC,IAAA,qDAAyB,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EACnE,EAHiD,CAGjD;AAHF,CAGE,CAAC;AALM,QAAA,yBAAyB,6BAK/B"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IMetadataTag } from "../../../metadata/IMetadataTag";
|
|
2
|
+
import { Atomic } from "../../../typings/Atomic";
|
|
3
|
+
export declare const iterate_protocol_atomic: (tags: IMetadataTag[]) => (type: Atomic.Literal) => "string" | "int32" | "uint32" | "int64" | "uint64" | "double" | "bool";
|
|
@@ -0,0 +1,69 @@
|
|
|
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.iterate_protocol_atomic = void 0;
|
|
15
|
+
var iterate_protocol_atomic = function (tags) { return function (type) {
|
|
16
|
+
if (type === "boolean")
|
|
17
|
+
return "bool";
|
|
18
|
+
else if (type === "number")
|
|
19
|
+
return number(tags);
|
|
20
|
+
else if (type === "bigint")
|
|
21
|
+
return bigint(tags);
|
|
22
|
+
else
|
|
23
|
+
return "string";
|
|
24
|
+
}; };
|
|
25
|
+
exports.iterate_protocol_atomic = iterate_protocol_atomic;
|
|
26
|
+
var number = function (tagList) {
|
|
27
|
+
var e_1, _a;
|
|
28
|
+
var filtered = tagList.filter(function (tag) { return tag.kind === "type"; });
|
|
29
|
+
try {
|
|
30
|
+
for (var filtered_1 = __values(filtered), filtered_1_1 = filtered_1.next(); !filtered_1_1.done; filtered_1_1 = filtered_1.next()) {
|
|
31
|
+
var value = filtered_1_1.value.value;
|
|
32
|
+
if (value === "int")
|
|
33
|
+
return "int32";
|
|
34
|
+
else if (value === "uint")
|
|
35
|
+
return "uint32";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
39
|
+
finally {
|
|
40
|
+
try {
|
|
41
|
+
if (filtered_1_1 && !filtered_1_1.done && (_a = filtered_1.return)) _a.call(filtered_1);
|
|
42
|
+
}
|
|
43
|
+
finally { if (e_1) throw e_1.error; }
|
|
44
|
+
}
|
|
45
|
+
return "double";
|
|
46
|
+
};
|
|
47
|
+
var bigint = function (tagList) {
|
|
48
|
+
var e_2, _a;
|
|
49
|
+
var filtered = tagList.filter(function (tag) {
|
|
50
|
+
return tag.kind === "type" &&
|
|
51
|
+
(tag.value === "int64" || tag.value === "uint64");
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
for (var filtered_2 = __values(filtered), filtered_2_1 = filtered_2.next(); !filtered_2_1.done; filtered_2_1 = filtered_2.next()) {
|
|
55
|
+
var value = filtered_2_1.value.value;
|
|
56
|
+
if (value === "int64" || value === "uint64")
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
if (filtered_2_1 && !filtered_2_1.done && (_a = filtered_2.return)) _a.call(filtered_2);
|
|
64
|
+
}
|
|
65
|
+
finally { if (e_2) throw e_2.error; }
|
|
66
|
+
}
|
|
67
|
+
return "int64";
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=iterate_protocol_atomic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterate_protocol_atomic.js","sourceRoot":"","sources":["../../../../src/factories/internal/protocols/iterate_protocol_atomic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIO,IAAM,uBAAuB,GAChC,UAAC,IAAoB,IAAK,OAAA,UAAC,IAAoB;IAC3C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;SACjC,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;;QAC3C,OAAO,QAAQ,CAAC;AACzB,CAAC,EALyB,CAKzB,CAAC;AANO,QAAA,uBAAuB,2BAM9B;AAEN,IAAM,MAAM,GAAG,UAAC,OAAuB;;IACnC,IAAM,QAAQ,GAA+B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