typia 3.6.7 → 3.7.0-dev.20230310
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 +44 -15
- 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 +112 -0
- package/lib/factories/ProtocolFactory.js.map +1 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +16 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +156 -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 +4 -0
- package/lib/factories/internal/protocols/iterate_protocol_map.js +75 -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 +190 -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_never.d.ts +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_never.js +6 -0
- package/lib/factories/internal/protocols/iterate_protocol_never.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_object.d.ts +4 -0
- package/lib/factories/internal/protocols/iterate_protocol_object.js +157 -0
- package/lib/factories/internal/protocols/iterate_protocol_object.js.map +1 -0
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +5 -0
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +25 -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/IProtocolMap.d.ts +5 -0
- package/lib/messages/IProtocolMap.js +3 -0
- package/lib/messages/IProtocolMap.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 +12 -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 +2 -2
- 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 +141 -0
- package/lib/programmers/MessageProgrammer.js.map +1 -0
- 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 +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 -1
- package/src/factories/MetadataCollection.ts +2 -41
- package/src/factories/ProtocolFactory.ts +79 -0
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +163 -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 +58 -0
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +96 -0
- package/src/factories/internal/protocols/iterate_protocol_native.ts +34 -0
- package/src/factories/internal/protocols/iterate_protocol_never.ts +1 -0
- package/src/factories/internal/protocols/iterate_protocol_object.ts +110 -0
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +34 -0
- package/src/factories/internal/protocols/iterate_protocol_tuple.ts +29 -0
- 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/IProtocolMap.ts +5 -0
- package/src/messages/IProtocolMessage.ts +6 -0
- package/src/messages/IProtocolProperty.ts +13 -0
- package/src/metadata/IMetadataTag.ts +20 -4
- package/src/metadata/Metadata.ts +6 -3
- package/src/module.ts +11 -0
- package/src/programmers/MessageProgrammer.ts +126 -0
- package/src/programmers/internal/application_object.ts +5 -5
- package/src/programmers/internal/application_schema.ts +7 -3
- package/src/transformers/CallExpressionTransformer.ts +16 -9
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +1 -3
- package/src/transformers/features/protocols/MessageTransformer.ts +32 -0
- package/src/utils/NameEncoder.ts +32 -0
package/README.md
CHANGED
|
@@ -11,11 +11,6 @@ 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
|
|
@@ -23,6 +18,13 @@ export function assertStringify<T>(input: T): string; // safe and faster
|
|
|
23
18
|
// +) isParse, validateParse
|
|
24
19
|
// +) stringify, isStringify, validateStringify
|
|
25
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
|
|
27
|
+
|
|
26
28
|
// MISC
|
|
27
29
|
export function random<T>(): Primitive<T>; // generate random data
|
|
28
30
|
export function clone<T>(input: T): Primitive<T>; // deep clone
|
|
@@ -35,7 +37,8 @@ export function prune<T extends object>(input: T): void; // erase extra props
|
|
|
35
37
|
|
|
36
38
|
- Super-fast Runtime Validators
|
|
37
39
|
- Safe JSON parse and fast stringify functions
|
|
38
|
-
-
|
|
40
|
+
- Protocol Buffer encoder and decoder
|
|
41
|
+
- Protobuf/JSON schema generator
|
|
39
42
|
- Random data generator
|
|
40
43
|
|
|
41
44
|
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)`.
|
|
@@ -49,7 +52,7 @@ Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance
|
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
|
|
52
|
-
## Sponsors
|
|
55
|
+
## Sponsors
|
|
53
56
|
Thanks for your support.
|
|
54
57
|
|
|
55
58
|
Your donation would encourage `typia` development.
|
|
@@ -174,6 +177,12 @@ For more details, refer to the [Guide Documents (wiki)](https://github.com/samch
|
|
|
174
177
|
> - [`parse()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#parse-functions)
|
|
175
178
|
> - [`stringify()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#stringify-functions)
|
|
176
179
|
> - [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
|
|
180
|
+
> - **Protocol Buffer**
|
|
181
|
+
> - [`message()` function](https://github.com/samchon/typia/wiki/Protocol-Buffer#message-function)
|
|
182
|
+
> - [`decode()` function](https://github.com/samchon/typia/wiki/Protocol-Buffer#decode-function)
|
|
183
|
+
> - [`encode()` functions](https://github.com/samchon/typia/wiki/Protocol-Buffer#encode-functions)
|
|
184
|
+
> - [comment tags](https://github.com/samchon/typia/wiki/Protocol-Buffer#comment-tags)
|
|
185
|
+
> - [weaknesses](https://github.com/samchon/typia/wiki/Protocol-Buffer#weaknesses)
|
|
177
186
|
> - **Miscellaneous**
|
|
178
187
|
> - [`random()` function](https://github.com/samchon/typia/wiki/Miscellaneous#random-function)
|
|
179
188
|
> - [`clone()` functions](https://github.com/samchon/typia/wiki/Miscellaneous#clone-functions)
|
|
@@ -252,19 +261,39 @@ export function createAssertStringify<T>(): (input: T) => string;
|
|
|
252
261
|
|
|
253
262
|
> Measured on [AMD R7 6800HS](https://github.com/samchon/typia/tree/master/benchmark/results/AMD%20Ryzen%207%206800HS%20with%20Radeon%20Graphics)
|
|
254
263
|
|
|
255
|
-
###
|
|
264
|
+
### Protocol Buffer
|
|
256
265
|
```typescript
|
|
257
|
-
|
|
258
|
-
export function
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
266
|
+
// PROTOCOL BUFFER MESSAGE
|
|
267
|
+
export function message<T>(): string;
|
|
268
|
+
|
|
269
|
+
// ENCODE FUNCTIONS
|
|
270
|
+
export function encode<T>(input: T): Uint8Array;
|
|
271
|
+
export function isEncode<T>(input: T): Uint8Array | null;
|
|
272
|
+
export function assertEncode<T>(input: T): Uint8Array;
|
|
273
|
+
export function validateEncode<T>(input: T): IValidation<Uint8Array>;
|
|
274
|
+
|
|
275
|
+
// DECODE FUNCTIONS
|
|
276
|
+
export function decode<T>(buffer: Uint8Array): T;
|
|
277
|
+
export function isDecode<T>(buffer: Uint8Array): T | null;
|
|
278
|
+
export function assertDecode<T>(buffer: Uint8Array): T;
|
|
279
|
+
export function validateDecode<T>(buffer: Uint8Array): IValidation<T>;
|
|
280
|
+
|
|
281
|
+
// FACTORY FUNCTIONS
|
|
282
|
+
export function createDecode<T>(): (input: Uint8Array) => T;
|
|
283
|
+
export function createEncode<T>(): (input: T) => Uint8Array;
|
|
284
|
+
// +) createIsDecode, createAssertDecode, createValidateDecode
|
|
285
|
+
// +) createIsEncode, createAssertEncode, createValidateEncode
|
|
262
286
|
```
|
|
263
287
|
|
|
264
|
-
|
|
288
|
+
`typia` supports Protocol Buffer.
|
|
289
|
+
|
|
290
|
+
- `message()`: generate Protocol Buffer schema
|
|
291
|
+
- `encode()`: encode JavaScript object to Protocol Buffer
|
|
292
|
+
- `decode()`: decode Protocol Buffer to JavaScript object
|
|
265
293
|
|
|
266
|
-
|
|
294
|
+
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`.
|
|
267
295
|
|
|
296
|
+
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)).
|
|
268
297
|
|
|
269
298
|
|
|
270
299
|
|
|
@@ -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,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IAEM,oCAAO,GAAd;QACI,gCAAW,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,UAAE;IACpC,CAAC;IACM,mCAAM,GAAb;QACI,gCAAW,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,UAAE;IACtC,CAAC;IAEM,oCAAO,GAAd,UACI,OAAuB,EACvB,IAAa;;QAEb,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAEjD,IAAM,GAAG,GAAW,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjD,IAAM,GAAG,GAAmB,+BAAc,CAAC,MA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AC;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,112 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,UA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CAAC,IAAK,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,EA5DgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA4D/B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
|
@@ -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;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,C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AAC;YACnB,GAAG,EAAE,KAAK;YACV,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,EAAE;YACb,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC,IAAI,CAAC;SACf,CAAC,CAAC;IACP,CAAC;IAlBe,wBAAG,MAkBlB,CAAA;AACL,CAAC,EA3JgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QA2JpC"}
|
|
@@ -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 (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,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"}
|
|
@@ -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";
|