typia 5.2.6 → 5.3.0-dev.20231112
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/lib/factories/ExpressionFactory.js +14 -16
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/JsonMetadataFactory.d.ts +1 -1
- package/lib/factories/JsonMetadataFactory.js +2 -2
- package/lib/factories/JsonMetadataFactory.js.map +1 -1
- package/lib/factories/LiteralFactory.js +2 -0
- package/lib/factories/LiteralFactory.js.map +1 -1
- package/lib/factories/MetadataCollection.d.ts +2 -2
- package/lib/factories/MetadataFactory.d.ts +1 -1
- package/lib/factories/MetadataFactory.js +236 -170
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/NumericRangeFactory.d.ts +2 -2
- package/lib/factories/NumericRangeFactory.js +41 -21
- package/lib/factories/NumericRangeFactory.js.map +1 -1
- package/lib/factories/ProtobufFactory.d.ts +1 -1
- package/lib/factories/ProtobufFactory.js +2 -2
- package/lib/factories/ProtobufFactory.js.map +1 -1
- package/lib/factories/internal/metadata/MetadataHelper.js +3 -2
- package/lib/factories/internal/metadata/MetadataHelper.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_constant.js +13 -8
- package/lib/factories/internal/metadata/iterate_metadata_constant.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_intersection.js +8 -5
- package/lib/factories/internal/metadata/iterate_metadata_intersection.js.map +1 -1
- package/lib/functional/$from.d.ts +3 -0
- package/lib/functional/$from.js +9 -0
- package/lib/functional/$from.js.map +1 -0
- package/lib/functional/Namespace.js +7 -0
- package/lib/functional/Namespace.js.map +1 -1
- package/lib/module.d.ts +1 -0
- package/lib/module.js +2 -5
- package/lib/module.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.js +11 -16
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +1 -1
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/helpers/ProtobufUtil.js.map +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpParameterProgrammer.js +1 -1
- package/lib/programmers/http/HttpParameterProgrammer.js.map +1 -1
- package/lib/programmers/http/HttpQueryProgrammer.js +1 -1
- package/lib/programmers/http/HttpQueryProgrammer.js.map +1 -1
- package/lib/programmers/internal/application_array.js +8 -0
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_number.js +8 -1
- package/lib/programmers/internal/application_number.js.map +1 -1
- package/lib/programmers/internal/application_string.js +8 -1
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array_length.js +7 -4
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_bigint.js +7 -4
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_number.js +7 -4
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string.js +7 -4
- package/lib/programmers/internal/check_string.js.map +1 -1
- package/lib/programmers/internal/metadata_to_pattern.js +3 -1
- package/lib/programmers/internal/metadata_to_pattern.js.map +1 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.js +1 -1
- package/lib/programmers/json/JsonAssertParseProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonIsParseProgrammer.js +1 -1
- package/lib/programmers/json/JsonIsParseProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +3 -8
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonValidateParseProgrammer.js +1 -1
- package/lib/programmers/json/JsonValidateParseProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +19 -24
- package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js +1 -1
- package/lib/programmers/misc/MiscLiteralsProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscPruneProgrammer.js +11 -16
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +11 -16
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +38 -42
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.d.ts +1 -1
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js +22 -25
- package/lib/programmers/protobuf/ProtobufMessageProgrammer.js.map +1 -1
- package/lib/reflect.d.ts +3 -0
- package/lib/reflect.js +13 -0
- package/lib/reflect.js.map +1 -0
- package/lib/schemas/json/IJsonSchema.d.ts +1 -0
- package/lib/schemas/metadata/IMetadataApplication.d.ts +2 -2
- package/lib/schemas/metadata/{IMetadataCollection.d.ts → IMetadataComponents.d.ts} +1 -1
- package/lib/schemas/metadata/{IMetadataCollection.js → IMetadataComponents.js} +1 -1
- package/lib/schemas/metadata/IMetadataComponents.js.map +1 -0
- package/lib/schemas/metadata/IMetadataConstant.d.ts +1 -1
- package/lib/schemas/metadata/IMetadataTypeTag.d.ts +2 -2
- package/lib/schemas/metadata/Metadata.d.ts +2 -2
- package/lib/schemas/metadata/Metadata.js +82 -173
- package/lib/schemas/metadata/Metadata.js.map +1 -1
- package/lib/schemas/metadata/MetadataAlias.js +1 -1
- package/lib/schemas/metadata/MetadataAlias.js.map +1 -1
- package/lib/schemas/metadata/MetadataApplication.d.ts +13 -0
- package/lib/schemas/metadata/MetadataApplication.js +30 -0
- package/lib/schemas/metadata/MetadataApplication.js.map +1 -0
- package/lib/schemas/metadata/MetadataArrayType.js +1 -1
- package/lib/schemas/metadata/MetadataArrayType.js.map +1 -1
- package/lib/schemas/metadata/MetadataAtomic.d.ts +3 -0
- package/lib/schemas/metadata/MetadataAtomic.js +42 -0
- package/lib/schemas/metadata/MetadataAtomic.js.map +1 -1
- package/lib/schemas/metadata/MetadataComponents.d.ts +16 -0
- package/lib/schemas/metadata/MetadataComponents.js +151 -0
- package/lib/schemas/metadata/MetadataComponents.js.map +1 -0
- package/lib/schemas/metadata/MetadataConstant.d.ts +9 -1
- package/lib/schemas/metadata/MetadataConstant.js +29 -0
- package/lib/schemas/metadata/MetadataConstant.js.map +1 -1
- package/lib/schemas/metadata/MetadataEscaped.js +4 -4
- package/lib/schemas/metadata/MetadataEscaped.js.map +1 -1
- package/lib/schemas/metadata/MetadataObject.js +2 -2
- package/lib/schemas/metadata/MetadataObject.js.map +1 -1
- package/lib/schemas/metadata/MetadataProperty.js +4 -4
- package/lib/schemas/metadata/MetadataProperty.js.map +1 -1
- package/lib/schemas/metadata/MetadataTupleType.js +1 -1
- package/lib/schemas/metadata/MetadataTupleType.js.map +1 -1
- package/lib/transformers/CallExpressionTransformer.js +5 -2
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.d.ts +1 -1
- package/lib/transformers/features/json/JsonApplicationTransformer.js +4 -5
- package/lib/transformers/features/json/JsonApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/reflect/ReflectMetadataTransformer.d.ts +5 -0
- package/lib/transformers/features/reflect/ReflectMetadataTransformer.js +58 -0
- package/lib/transformers/features/reflect/ReflectMetadataTransformer.js.map +1 -0
- package/package.json +2 -2
- package/src/Primitive.ts +135 -135
- package/src/executable/TypiaSetupWizard.ts +142 -142
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/factories/ExpressionFactory.ts +12 -13
- package/src/factories/JsonMetadataFactory.ts +53 -50
- package/src/factories/LiteralFactory.ts +2 -0
- package/src/factories/MetadataCollection.ts +282 -282
- package/src/factories/MetadataFactory.ts +55 -22
- package/src/factories/NumericRangeFactory.ts +56 -17
- package/src/factories/ProtobufFactory.ts +5 -2
- package/src/factories/internal/metadata/MetadataHelper.ts +7 -4
- package/src/factories/internal/metadata/emplace_metadata_object.ts +178 -178
- package/src/factories/internal/metadata/iterate_metadata_constant.ts +10 -8
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +9 -8
- package/src/functional/$from.ts +5 -0
- package/src/functional/$stoll.ts +8 -8
- package/src/functional/Namespace.ts +175 -168
- package/src/module.ts +1 -19
- package/src/programmers/AssertProgrammer.ts +322 -322
- package/src/programmers/CheckerProgrammer.ts +16 -17
- package/src/programmers/IsProgrammer.ts +258 -258
- package/src/programmers/RandomProgrammer.ts +4 -1
- package/src/programmers/ValidateProgrammer.ts +350 -350
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/ProtobufUtil.ts +3 -2
- package/src/programmers/http/HttpHeadersProgrammer.ts +4 -1
- package/src/programmers/http/HttpParameterProgrammer.ts +4 -1
- package/src/programmers/http/HttpQueryProgrammer.ts +4 -1
- package/src/programmers/internal/application_array.ts +8 -0
- package/src/programmers/internal/application_number.ts +8 -1
- package/src/programmers/internal/application_string.ts +8 -1
- package/src/programmers/internal/check_array_length.ts +5 -2
- package/src/programmers/internal/check_bigint.ts +5 -2
- package/src/programmers/internal/check_dynamic_key.ts +178 -178
- package/src/programmers/internal/check_dynamic_properties.ts +202 -202
- package/src/programmers/internal/check_number.ts +5 -2
- package/src/programmers/internal/check_object.ts +62 -62
- package/src/programmers/internal/check_string.ts +5 -3
- package/src/programmers/internal/metadata_to_pattern.ts +3 -1
- package/src/programmers/json/JsonAssertParseProgrammer.ts +1 -0
- package/src/programmers/json/JsonIsParseProgrammer.ts +1 -0
- package/src/programmers/json/JsonStringifyProgrammer.ts +959 -960
- package/src/programmers/json/JsonValidateParseProgrammer.ts +1 -0
- package/src/programmers/misc/MiscCloneProgrammer.ts +787 -786
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +4 -1
- package/src/programmers/misc/MiscPruneProgrammer.ts +549 -548
- package/src/programmers/notations/NotationGeneralProgrammer.ts +717 -716
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +1 -0
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +872 -882
- package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +21 -21
- package/src/reflect.ts +24 -0
- package/src/schemas/json/IJsonSchema.ts +1 -0
- package/src/schemas/metadata/IMetadataApplication.ts +2 -2
- package/src/schemas/metadata/{IMetadataCollection.ts → IMetadataComponents.ts} +1 -1
- package/src/schemas/metadata/IMetadataConstant.ts +1 -1
- package/src/schemas/metadata/IMetadataTypeTag.ts +9 -2
- package/src/schemas/metadata/Metadata.ts +18 -91
- package/src/schemas/metadata/MetadataAlias.ts +1 -1
- package/src/schemas/metadata/MetadataApplication.ts +44 -0
- package/src/schemas/metadata/MetadataArrayType.ts +1 -1
- package/src/schemas/metadata/MetadataAtomic.ts +44 -0
- package/src/schemas/metadata/MetadataComponents.ts +98 -0
- package/src/schemas/metadata/MetadataConstant.ts +44 -1
- package/src/schemas/metadata/MetadataEscaped.ts +4 -4
- package/src/schemas/metadata/MetadataObject.ts +2 -2
- package/src/schemas/metadata/MetadataProperty.ts +4 -7
- package/src/schemas/metadata/MetadataTupleType.ts +1 -1
- package/src/transform.ts +35 -35
- package/src/transformers/CallExpressionTransformer.ts +5 -2
- package/src/transformers/features/json/JsonApplicationTransformer.ts +7 -4
- package/src/transformers/features/{misc/MetadataTransformer.ts → reflect/ReflectMetadataTransformer.ts} +25 -8
- package/lib/schemas/metadata/IMetadataCollection.js.map +0 -1
- package/lib/transformers/features/misc/MetadataTransformer.d.ts +0 -5
- package/lib/transformers/features/misc/MetadataTransformer.js +0 -55
- package/lib/transformers/features/misc/MetadataTransformer.js.map +0 -1
|
@@ -16,27 +16,27 @@ import { NameEncoder } from "../../utils/NameEncoder";
|
|
|
16
16
|
import { ProtobufUtil } from "../helpers/ProtobufUtil";
|
|
17
17
|
|
|
18
18
|
export namespace ProtobufMessageProgrammer {
|
|
19
|
-
export const write =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
export const write = (project: IProject) => (type: ts.Type) => {
|
|
20
|
+
// PARSE TARGET TYPE
|
|
21
|
+
const collection: MetadataCollection = new MetadataCollection();
|
|
22
|
+
ProtobufFactory.metadata("message")(project.checker, project.context)(
|
|
23
|
+
collection,
|
|
24
|
+
)(type);
|
|
25
|
+
|
|
26
|
+
// STRINGIFY
|
|
27
|
+
const hierarchies: Map<string, Hierarchy> = new Map();
|
|
28
|
+
for (const obj of collection.objects())
|
|
29
|
+
if (is_dynamic_object(obj) === false) emplace(hierarchies)(obj);
|
|
30
|
+
|
|
31
|
+
const content: string =
|
|
32
|
+
`syntax = "proto3";\n\n` +
|
|
33
|
+
[...hierarchies.values()]
|
|
34
|
+
.map((hier) => write_hierarchy(hier))
|
|
35
|
+
.join("\n\n");
|
|
36
|
+
|
|
37
|
+
// RETURNS
|
|
38
|
+
return ts.factory.createStringLiteral(content);
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
const emplace = (dict: Map<string, Hierarchy>) => (obj: MetadataObject) => {
|
|
42
42
|
const accessors: string[] = obj.name.split(".");
|
package/src/reflect.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Namespace } from "./functional/Namespace";
|
|
2
|
+
|
|
3
|
+
import { MetadataApplication } from "./schemas/metadata/MetadataApplication";
|
|
4
|
+
|
|
5
|
+
export function metadata(): never;
|
|
6
|
+
|
|
7
|
+
export function metadata<Types extends unknown[]>(): MetadataApplication;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export function metadata(): never {
|
|
13
|
+
halt("metadata");
|
|
14
|
+
}
|
|
15
|
+
Object.assign(metadata, Namespace.reflect.metadata());
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function halt(name: string): never {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`Error on typia.reflect.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -72,6 +72,7 @@ export namespace IJsonSchema {
|
|
|
72
72
|
minItems?: undefined | (number & Type<"uint32">);
|
|
73
73
|
maxItems?: undefined | (number & Type<"uint32">);
|
|
74
74
|
"x-typia-tuple"?: undefined | ITuple;
|
|
75
|
+
"x-typia-typeTags"?: undefined | IMetadataTypeTag[];
|
|
75
76
|
}
|
|
76
77
|
export interface ITuple extends ISignificant<"array"> {
|
|
77
78
|
items: IJsonSchema[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IMetadata } from "./IMetadata";
|
|
2
|
-
import {
|
|
2
|
+
import { IMetadataComponents } from "./IMetadataComponents";
|
|
3
3
|
|
|
4
4
|
export interface IMetadataApplication {
|
|
5
5
|
metadatas: IMetadata[];
|
|
6
|
-
|
|
6
|
+
components: IMetadataComponents;
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ import { IMetadataArrayType } from "./IMetadataArrayType";
|
|
|
3
3
|
import { IMetadataObject } from "./IMetadataObject";
|
|
4
4
|
import { IMetadataTupleType } from "./IMetadataTupleType";
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface IMetadataComponents {
|
|
7
7
|
objects: IMetadataObject[];
|
|
8
8
|
aliases: IMetadataAlias[];
|
|
9
9
|
arrays: IMetadataArrayType[];
|
|
@@ -6,7 +6,7 @@ export type IMetadataConstant =
|
|
|
6
6
|
| IMetadataConstant.IBase<"boolean", boolean>
|
|
7
7
|
| IMetadataConstant.IBase<"number", number>
|
|
8
8
|
| IMetadataConstant.IBase<"string", string>
|
|
9
|
-
| IMetadataConstant.IBase<"bigint",
|
|
9
|
+
| IMetadataConstant.IBase<"bigint", string>;
|
|
10
10
|
export namespace IMetadataConstant {
|
|
11
11
|
export interface IBase<
|
|
12
12
|
Type extends Atomic.Literal,
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import type ts from "typescript";
|
|
2
|
+
|
|
1
3
|
export interface IMetadataTypeTag {
|
|
2
4
|
target: "boolean" | "bigint" | "number" | "string" | "array";
|
|
3
5
|
name: string;
|
|
4
6
|
kind: string;
|
|
5
|
-
value: any;
|
|
6
|
-
validate: string | undefined;
|
|
7
7
|
exclusive: boolean | string[];
|
|
8
|
+
value?: any;
|
|
9
|
+
validate?: string | undefined;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
predicate?: (input: ts.Expression) => ts.Expression;
|
|
8
15
|
}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
-
import { Writable } from "../../typings/Writable";
|
|
3
2
|
|
|
4
3
|
import { ArrayUtil } from "../../utils/ArrayUtil";
|
|
5
4
|
|
|
6
5
|
import { IMetadata } from "./IMetadata";
|
|
7
|
-
import { IMetadataCollection } from "./IMetadataCollection";
|
|
8
6
|
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
9
7
|
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
10
8
|
import { MetadataAlias } from "./MetadataAlias";
|
|
11
9
|
import { MetadataArray } from "./MetadataArray";
|
|
12
|
-
import { MetadataArrayType } from "./MetadataArrayType";
|
|
13
10
|
import { MetadataAtomic } from "./MetadataAtomic";
|
|
14
11
|
import { MetadataConstant } from "./MetadataConstant";
|
|
15
12
|
import { MetadataEscaped } from "./MetadataEscaped";
|
|
16
13
|
import { MetadataObject } from "./MetadataObject";
|
|
17
|
-
import { MetadataProperty } from "./MetadataProperty";
|
|
18
14
|
import { MetadataTuple } from "./MetadataTuple";
|
|
19
|
-
import { MetadataTupleType } from "./MetadataTupleType";
|
|
20
15
|
|
|
21
16
|
export class Metadata {
|
|
22
17
|
public any: boolean;
|
|
@@ -86,7 +81,7 @@ export class Metadata {
|
|
|
86
81
|
* @internal
|
|
87
82
|
*/
|
|
88
83
|
public static initialize(parentResolved: boolean = false): Metadata {
|
|
89
|
-
const meta: Metadata =
|
|
84
|
+
const meta: Metadata = Metadata.create({
|
|
90
85
|
any: false,
|
|
91
86
|
nullable: false,
|
|
92
87
|
required: true,
|
|
@@ -119,16 +114,8 @@ export class Metadata {
|
|
|
119
114
|
nullable: this.nullable,
|
|
120
115
|
functional: this.functional,
|
|
121
116
|
|
|
122
|
-
atomics: this.atomics.map((a) =>
|
|
123
|
-
|
|
124
|
-
type: a.type,
|
|
125
|
-
tags: a.tags.map((r) => r.slice()),
|
|
126
|
-
}),
|
|
127
|
-
),
|
|
128
|
-
constants: this.constants.map((c) => ({
|
|
129
|
-
type: c.type,
|
|
130
|
-
values: c.values.slice() as any,
|
|
131
|
-
})),
|
|
117
|
+
atomics: this.atomics.map((a) => a.toJSON()),
|
|
118
|
+
constants: this.constants.map((c) => c.toJSON()),
|
|
132
119
|
templates: this.templates.map((tpl) =>
|
|
133
120
|
tpl.map((meta) => meta.toJSON()),
|
|
134
121
|
),
|
|
@@ -155,85 +142,24 @@ export class Metadata {
|
|
|
155
142
|
};
|
|
156
143
|
}
|
|
157
144
|
|
|
158
|
-
public static from(
|
|
159
|
-
|
|
160
|
-
collection: IMetadataCollection,
|
|
161
|
-
): Metadata {
|
|
162
|
-
const dict: IMetadataDictionary = {
|
|
163
|
-
objects: new Map(
|
|
164
|
-
collection.objects.map((obj) => [
|
|
165
|
-
obj.name,
|
|
166
|
-
MetadataObject._From_without_properties(obj),
|
|
167
|
-
]),
|
|
168
|
-
),
|
|
169
|
-
aliases: new Map(
|
|
170
|
-
collection.aliases.map((alias) => [
|
|
171
|
-
alias.name,
|
|
172
|
-
MetadataAlias._From_without_value(alias),
|
|
173
|
-
]),
|
|
174
|
-
),
|
|
175
|
-
arrays: new Map(
|
|
176
|
-
collection.arrays.map((arr) => [
|
|
177
|
-
arr.name,
|
|
178
|
-
MetadataArrayType._From_without_value(arr),
|
|
179
|
-
]),
|
|
180
|
-
),
|
|
181
|
-
tuples: new Map(
|
|
182
|
-
collection.tuples.map((tpl) => [
|
|
183
|
-
tpl.name,
|
|
184
|
-
MetadataTupleType._From_without_elements(tpl),
|
|
185
|
-
]),
|
|
186
|
-
),
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
for (const obj of collection.objects) {
|
|
190
|
-
const initialized = dict.objects.get(obj.name)!;
|
|
191
|
-
initialized.properties.push(
|
|
192
|
-
...obj.properties.map((prop) =>
|
|
193
|
-
MetadataProperty._From(prop, dict),
|
|
194
|
-
),
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
for (const alias of collection.aliases)
|
|
198
|
-
Writable(dict.aliases.get(alias.name)!).value = this._From(
|
|
199
|
-
alias.value,
|
|
200
|
-
dict,
|
|
201
|
-
);
|
|
202
|
-
for (const array of collection.arrays)
|
|
203
|
-
Writable(dict.arrays.get(array.name)!).value = this._From(
|
|
204
|
-
array.value,
|
|
205
|
-
dict,
|
|
206
|
-
);
|
|
207
|
-
for (const tuple of collection.tuples)
|
|
208
|
-
Writable(dict.tuples.get(tuple.name)!).elements =
|
|
209
|
-
tuple.elements.map((elem) => this._From(elem, dict));
|
|
210
|
-
|
|
211
|
-
return this._From(meta, dict);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* @internal
|
|
216
|
-
*/
|
|
217
|
-
public static _From(meta: IMetadata, dict: IMetadataDictionary): Metadata {
|
|
218
|
-
return this.create({
|
|
145
|
+
public static from(meta: IMetadata, dict: IMetadataDictionary): Metadata {
|
|
146
|
+
return Metadata.create({
|
|
219
147
|
any: meta.any,
|
|
220
148
|
required: meta.required,
|
|
221
149
|
optional: meta.optional,
|
|
222
150
|
nullable: meta.nullable,
|
|
223
151
|
functional: meta.functional,
|
|
224
152
|
|
|
225
|
-
constants: meta.constants.
|
|
226
|
-
atomics: meta.atomics.map(
|
|
227
|
-
MetadataAtomic.create({ type: a.type, tags: a.tags }),
|
|
228
|
-
),
|
|
153
|
+
constants: meta.constants.map(MetadataConstant.from),
|
|
154
|
+
atomics: meta.atomics.map(MetadataAtomic.from),
|
|
229
155
|
templates: meta.templates.map((tpl) =>
|
|
230
|
-
tpl.map((meta) => this.
|
|
156
|
+
tpl.map((meta) => this.from(meta, dict)),
|
|
231
157
|
),
|
|
232
158
|
escaped: meta.escaped
|
|
233
|
-
? MetadataEscaped.
|
|
159
|
+
? MetadataEscaped.from(meta.escaped, dict)
|
|
234
160
|
: null,
|
|
235
161
|
|
|
236
|
-
rest: meta.rest ? this.
|
|
162
|
+
rest: meta.rest ? this.from(meta.rest, dict) : null,
|
|
237
163
|
arrays: meta.arrays.map((ref) => {
|
|
238
164
|
const type = dict.arrays.get(ref.name);
|
|
239
165
|
if (type === undefined)
|
|
@@ -274,10 +200,10 @@ export class Metadata {
|
|
|
274
200
|
}),
|
|
275
201
|
|
|
276
202
|
natives: meta.natives.slice(),
|
|
277
|
-
sets: meta.sets.map((meta) => this.
|
|
203
|
+
sets: meta.sets.map((meta) => this.from(meta, dict)),
|
|
278
204
|
maps: meta.maps.map((entry) => ({
|
|
279
|
-
key: this.
|
|
280
|
-
value: this.
|
|
205
|
+
key: this.from(entry.key, dict),
|
|
206
|
+
value: this.from(entry.value, dict),
|
|
281
207
|
})),
|
|
282
208
|
});
|
|
283
209
|
}
|
|
@@ -570,10 +496,11 @@ export namespace Metadata {
|
|
|
570
496
|
const target: MetadataConstant = ArrayUtil.take(
|
|
571
497
|
output.constants,
|
|
572
498
|
(elem) => elem.type === constant.type,
|
|
573
|
-
() =>
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
499
|
+
() =>
|
|
500
|
+
MetadataConstant.create({
|
|
501
|
+
type: constant.type,
|
|
502
|
+
values: [],
|
|
503
|
+
}),
|
|
577
504
|
);
|
|
578
505
|
for (const value of constant.values)
|
|
579
506
|
ArrayUtil.add(target.values, value);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IMetadataApplication } from "./IMetadataApplication";
|
|
4
|
+
import { Metadata } from "./Metadata";
|
|
5
|
+
import { MetadataComponents } from "./MetadataComponents";
|
|
6
|
+
|
|
7
|
+
export class MetadataApplication {
|
|
8
|
+
public readonly metadatas: Metadata[];
|
|
9
|
+
public readonly components: MetadataComponents;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
private constructor(props: ClassProperties<MetadataApplication>) {
|
|
15
|
+
this.metadatas = props.metadatas;
|
|
16
|
+
this.components = props.components;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
public static create(
|
|
23
|
+
props: ClassProperties<MetadataApplication>,
|
|
24
|
+
): MetadataApplication {
|
|
25
|
+
return new MetadataApplication(props);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static from(app: IMetadataApplication): MetadataApplication {
|
|
29
|
+
const components: MetadataComponents = MetadataComponents.from(
|
|
30
|
+
app.components,
|
|
31
|
+
);
|
|
32
|
+
const metadatas: Metadata[] = app.metadatas.map((metadata) =>
|
|
33
|
+
Metadata.from(metadata, components.dictionary),
|
|
34
|
+
);
|
|
35
|
+
return MetadataApplication.create({ metadatas, components });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public toJSON(): IMetadataApplication {
|
|
39
|
+
return {
|
|
40
|
+
metadatas: this.metadatas.map((metadata) => metadata.toJSON()),
|
|
41
|
+
components: this.components.toJSON(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -27,7 +27,7 @@ export class MetadataArrayType {
|
|
|
27
27
|
public static _From_without_value(
|
|
28
28
|
props: Omit<IMetadataArrayType, "value">,
|
|
29
29
|
): MetadataArrayType {
|
|
30
|
-
return
|
|
30
|
+
return MetadataArrayType.create({
|
|
31
31
|
name: props.name,
|
|
32
32
|
value: null!,
|
|
33
33
|
index: props.index,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
2
|
|
|
3
|
+
import { IMetadataAtomic } from "./IMetadataAtomic";
|
|
3
4
|
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
4
5
|
|
|
5
6
|
export class MetadataAtomic {
|
|
@@ -22,6 +23,27 @@ export class MetadataAtomic {
|
|
|
22
23
|
return new MetadataAtomic(props);
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
public static from(json: IMetadataAtomic): MetadataAtomic {
|
|
27
|
+
return MetadataAtomic.create({
|
|
28
|
+
type: json.type,
|
|
29
|
+
tags: json.tags.map((row) =>
|
|
30
|
+
row.map((tag) => ({
|
|
31
|
+
target: tag.target,
|
|
32
|
+
name: tag.name,
|
|
33
|
+
kind: tag.kind,
|
|
34
|
+
value:
|
|
35
|
+
typeof tag.value === "object" &&
|
|
36
|
+
tag.value?.type === "bigint" &&
|
|
37
|
+
typeof tag.value.value === "string"
|
|
38
|
+
? BigInt(tag.value.value)
|
|
39
|
+
: tag.value,
|
|
40
|
+
validate: tag.validate,
|
|
41
|
+
exclusive: tag.exclusive,
|
|
42
|
+
})),
|
|
43
|
+
),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
25
47
|
public getName(): string {
|
|
26
48
|
return (this.name_ ??= (() => {
|
|
27
49
|
if (this.tags.length === 0) return this.type;
|
|
@@ -39,4 +61,26 @@ export class MetadataAtomic {
|
|
|
39
61
|
return `(${this.type} & (${rows.join(" | ")}))`;
|
|
40
62
|
})());
|
|
41
63
|
}
|
|
64
|
+
|
|
65
|
+
public toJSON(): IMetadataAtomic {
|
|
66
|
+
return {
|
|
67
|
+
type: this.type,
|
|
68
|
+
tags: this.tags.map((row) =>
|
|
69
|
+
row.map((tag) => ({
|
|
70
|
+
target: tag.target,
|
|
71
|
+
name: tag.name,
|
|
72
|
+
kind: tag.kind,
|
|
73
|
+
value:
|
|
74
|
+
typeof tag.value === "bigint"
|
|
75
|
+
? {
|
|
76
|
+
type: "bigint",
|
|
77
|
+
value: tag.value.toString(),
|
|
78
|
+
}
|
|
79
|
+
: tag.value,
|
|
80
|
+
validate: tag.validate,
|
|
81
|
+
exclusive: tag.exclusive,
|
|
82
|
+
})),
|
|
83
|
+
),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
42
86
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
import { Writable } from "../../typings/Writable";
|
|
3
|
+
|
|
4
|
+
import { IMetadataComponents } from "./IMetadataComponents";
|
|
5
|
+
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
6
|
+
import { Metadata } from "./Metadata";
|
|
7
|
+
import { MetadataAlias } from "./MetadataAlias";
|
|
8
|
+
import { MetadataArrayType } from "./MetadataArrayType";
|
|
9
|
+
import { MetadataObject } from "./MetadataObject";
|
|
10
|
+
import { MetadataProperty } from "./MetadataProperty";
|
|
11
|
+
import { MetadataTupleType } from "./MetadataTupleType";
|
|
12
|
+
|
|
13
|
+
export class MetadataComponents {
|
|
14
|
+
public readonly aliases: MetadataAlias[];
|
|
15
|
+
public readonly objects: MetadataObject[];
|
|
16
|
+
public readonly arrays: MetadataArrayType[];
|
|
17
|
+
public readonly tuples: MetadataTupleType[];
|
|
18
|
+
public readonly dictionary: IMetadataDictionary;
|
|
19
|
+
|
|
20
|
+
private constructor(props: ClassProperties<MetadataComponents>) {
|
|
21
|
+
this.aliases = props.aliases;
|
|
22
|
+
this.objects = props.objects;
|
|
23
|
+
this.arrays = props.arrays;
|
|
24
|
+
this.tuples = props.tuples;
|
|
25
|
+
this.dictionary = props.dictionary;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static from(json: IMetadataComponents): MetadataComponents {
|
|
29
|
+
// INITIALIZE COMPONENTS
|
|
30
|
+
const dictionary: IMetadataDictionary = {
|
|
31
|
+
objects: new Map(
|
|
32
|
+
json.objects.map((obj) => [
|
|
33
|
+
obj.name,
|
|
34
|
+
MetadataObject._From_without_properties(obj),
|
|
35
|
+
]),
|
|
36
|
+
),
|
|
37
|
+
aliases: new Map(
|
|
38
|
+
json.aliases.map((alias) => [
|
|
39
|
+
alias.name,
|
|
40
|
+
MetadataAlias._From_without_value(alias),
|
|
41
|
+
]),
|
|
42
|
+
),
|
|
43
|
+
arrays: new Map(
|
|
44
|
+
json.arrays.map((arr) => [
|
|
45
|
+
arr.name,
|
|
46
|
+
MetadataArrayType._From_without_value(arr),
|
|
47
|
+
]),
|
|
48
|
+
),
|
|
49
|
+
tuples: new Map(
|
|
50
|
+
json.tuples.map((tpl) => [
|
|
51
|
+
tpl.name,
|
|
52
|
+
MetadataTupleType._From_without_elements(tpl),
|
|
53
|
+
]),
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// CONSTRUCT METADATA OF THEM
|
|
58
|
+
for (const obj of json.objects)
|
|
59
|
+
dictionary.objects
|
|
60
|
+
.get(obj.name)!
|
|
61
|
+
.properties.push(
|
|
62
|
+
...obj.properties.map((prop) =>
|
|
63
|
+
MetadataProperty.from(prop, dictionary),
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
for (const alias of json.aliases)
|
|
67
|
+
Writable(dictionary.aliases.get(alias.name)!).value = Metadata.from(
|
|
68
|
+
alias.value,
|
|
69
|
+
dictionary,
|
|
70
|
+
);
|
|
71
|
+
for (const array of json.arrays)
|
|
72
|
+
Writable(dictionary.arrays.get(array.name)!).value = Metadata.from(
|
|
73
|
+
array.value,
|
|
74
|
+
dictionary,
|
|
75
|
+
);
|
|
76
|
+
for (const tuple of json.tuples)
|
|
77
|
+
Writable(dictionary.tuples.get(tuple.name)!).elements =
|
|
78
|
+
tuple.elements.map((elem) => Metadata.from(elem, dictionary));
|
|
79
|
+
|
|
80
|
+
// FINALIZE
|
|
81
|
+
return new MetadataComponents({
|
|
82
|
+
aliases: [...dictionary.aliases.values()],
|
|
83
|
+
objects: [...dictionary.objects.values()],
|
|
84
|
+
arrays: [...dictionary.arrays.values()],
|
|
85
|
+
tuples: [...dictionary.tuples.values()],
|
|
86
|
+
dictionary,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public toJSON(): IMetadataComponents {
|
|
91
|
+
return {
|
|
92
|
+
aliases: this.aliases.map((alias) => alias.toJSON()),
|
|
93
|
+
objects: this.objects.map((object) => object.toJSON()),
|
|
94
|
+
arrays: this.arrays.map((array) => array.toJSON()),
|
|
95
|
+
tuples: this.tuples.map((tuple) => tuple.toJSON()),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,3 +1,46 @@
|
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
|
|
1
3
|
import { IMetadataConstant } from "./IMetadataConstant";
|
|
4
|
+
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
5
|
+
|
|
6
|
+
export class MetadataConstant {
|
|
7
|
+
public readonly type: "boolean" | "bigint" | "number" | "string";
|
|
8
|
+
public readonly values: boolean[] | bigint[] | number[] | string[];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
public tags?: IMetadataTypeTag[][] | undefined;
|
|
14
|
+
|
|
15
|
+
private constructor(props: ClassProperties<MetadataConstant>) {
|
|
16
|
+
this.type = props.type;
|
|
17
|
+
this.values = props.values;
|
|
18
|
+
this.tags = props.tags;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static create(
|
|
22
|
+
props: ClassProperties<MetadataConstant>,
|
|
23
|
+
): MetadataConstant {
|
|
24
|
+
return new MetadataConstant(props);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public static from(json: IMetadataConstant): MetadataConstant {
|
|
28
|
+
return MetadataConstant.create({
|
|
29
|
+
type: json.type,
|
|
30
|
+
values:
|
|
31
|
+
json.type === "bigint"
|
|
32
|
+
? json.values.map((v) => BigInt(v))
|
|
33
|
+
: (json.values as any[]),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
2
36
|
|
|
3
|
-
|
|
37
|
+
public toJSON(): IMetadataConstant {
|
|
38
|
+
return {
|
|
39
|
+
type: this.type,
|
|
40
|
+
values:
|
|
41
|
+
this.type === "bigint"
|
|
42
|
+
? this.values.map((v) => v.toString())
|
|
43
|
+
: (this.values as any[]),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -19,13 +19,13 @@ export class MetadataEscaped {
|
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
public static
|
|
22
|
+
public static from(
|
|
23
23
|
props: IMetadataEscaped,
|
|
24
24
|
dict: IMetadataDictionary,
|
|
25
25
|
): MetadataEscaped {
|
|
26
|
-
return
|
|
27
|
-
original: Metadata.
|
|
28
|
-
returns: Metadata.
|
|
26
|
+
return MetadataEscaped.create({
|
|
27
|
+
original: Metadata.from(props.original, dict),
|
|
28
|
+
returns: Metadata.from(props.returns, dict),
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -37,7 +37,7 @@ export class MetadataObject {
|
|
|
37
37
|
this.index = props.index;
|
|
38
38
|
this.validated = props.validated;
|
|
39
39
|
this.recursive = props.recursive;
|
|
40
|
-
this.nullables =
|
|
40
|
+
this.nullables = props.nullables.slice();
|
|
41
41
|
|
|
42
42
|
this.tagged_ = false;
|
|
43
43
|
}
|
|
@@ -57,7 +57,7 @@ export class MetadataObject {
|
|
|
57
57
|
public static _From_without_properties(
|
|
58
58
|
obj: IMetadataObject,
|
|
59
59
|
): MetadataObject {
|
|
60
|
-
return
|
|
60
|
+
return MetadataObject.create({
|
|
61
61
|
name: obj.name,
|
|
62
62
|
properties: [],
|
|
63
63
|
description: obj.description,
|
|
@@ -36,13 +36,10 @@ export class MetadataProperty {
|
|
|
36
36
|
/**
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
|
-
public static
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return this.create({
|
|
44
|
-
key: Metadata._From(property.key, dict),
|
|
45
|
-
value: Metadata._From(property.value, dict),
|
|
39
|
+
public static from(property: IMetadataProperty, dict: IMetadataDictionary) {
|
|
40
|
+
return MetadataProperty.create({
|
|
41
|
+
key: Metadata.from(property.key, dict),
|
|
42
|
+
value: Metadata.from(property.value, dict),
|
|
46
43
|
description: property.description,
|
|
47
44
|
jsDocTags: property.jsDocTags.slice(),
|
|
48
45
|
});
|
|
@@ -33,7 +33,7 @@ export class MetadataTupleType {
|
|
|
33
33
|
public static _From_without_elements(
|
|
34
34
|
props: Omit<IMetadataTupleType, "elements">,
|
|
35
35
|
): MetadataTupleType {
|
|
36
|
-
return
|
|
36
|
+
return MetadataTupleType.create({
|
|
37
37
|
name: props.name,
|
|
38
38
|
index: props.index,
|
|
39
39
|
elements: null!,
|