typia 9.7.2 → 10.0.0-dev.20251107
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/LICENSE +21 -21
- package/README.md +153 -153
- package/lib/factories/ProtobufFactory.js +1 -1
- package/lib/factories/ProtobufFactory.mjs +1 -1
- package/lib/programmers/internal/json_schema_station.d.mts +2 -2
- package/lib/programmers/internal/json_schema_station.d.ts +2 -2
- package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
- package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
- package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
- package/package.json +121 -121
- package/src/AssertionGuard.ts +41 -41
- package/src/CamelCase.ts +75 -75
- package/src/IRandomGenerator.ts +337 -337
- package/src/IReadableURLSearchParams.ts +9 -9
- package/src/PascalCase.ts +71 -71
- package/src/Primitive.ts +90 -90
- package/src/Resolved.ts +72 -72
- package/src/SnakeCase.ts +127 -127
- package/src/TypeGuardError.ts +216 -216
- package/src/factories/MetadataCollection.ts +270 -270
- package/src/factories/MetadataCommentTagFactory.ts +632 -632
- package/src/factories/MetadataFactory.ts +402 -402
- package/src/factories/ProtobufFactory.ts +873 -873
- package/src/functional.ts +705 -705
- package/src/http.ts +972 -972
- package/src/internal/_ProtobufReader.ts +188 -188
- package/src/internal/_ProtobufSizer.ts +137 -137
- package/src/internal/_ProtobufWriter.ts +135 -135
- package/src/internal/_jsonStringifyString.ts +42 -42
- package/src/json.ts +643 -643
- package/src/llm.ts +615 -615
- package/src/misc.ts +594 -594
- package/src/module.ts +889 -889
- package/src/notations.ts +751 -751
- package/src/programmers/FeatureProgrammer.ts +605 -605
- package/src/programmers/ImportProgrammer.ts +179 -179
- package/src/programmers/RandomProgrammer.ts +1195 -1195
- package/src/programmers/helpers/ProtobufWire.ts +34 -34
- package/src/programmers/internal/check_array_length.ts +43 -43
- package/src/programmers/internal/check_bigint.ts +46 -46
- package/src/programmers/internal/check_dynamic_key.ts +197 -197
- package/src/programmers/internal/check_dynamic_properties.ts +231 -231
- package/src/programmers/internal/check_everything.ts +21 -21
- package/src/programmers/internal/check_native.ts +23 -23
- package/src/programmers/internal/check_number.ts +108 -108
- package/src/programmers/internal/check_object.ts +72 -72
- package/src/programmers/internal/check_string.ts +46 -46
- package/src/programmers/internal/check_template.ts +46 -46
- package/src/programmers/internal/check_union_array_like.ts +331 -331
- package/src/programmers/internal/decode_union_object.ts +110 -110
- package/src/programmers/internal/feature_object_entries.ts +59 -59
- package/src/programmers/internal/json_schema_escaped.ts +78 -78
- package/src/programmers/internal/json_schema_object.ts +150 -150
- package/src/programmers/internal/json_schema_station.ts +2 -2
- package/src/programmers/internal/metadata_to_pattern.ts +40 -40
- package/src/programmers/internal/postfix_of_tuple.ts +3 -3
- package/src/programmers/internal/prune_object_properties.ts +69 -69
- package/src/programmers/internal/stringify_dynamic_properties.ts +158 -158
- package/src/programmers/internal/stringify_native.ts +5 -5
- package/src/programmers/internal/stringify_regular_properties.ts +77 -77
- package/src/programmers/internal/template_to_pattern.ts +21 -21
- package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -21
- package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
- package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
- package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
- package/src/protobuf.ts +820 -820
- package/src/reflect.ts +46 -46
- package/src/schemas/json/IJsonApplication.ts +77 -77
- package/src/schemas/json/IJsonSchemaCollection.ts +212 -212
- package/src/schemas/json/IJsonSchemaUnit.ts +263 -263
- package/src/schemas/metadata/IMetadataTypeTag.ts +14 -14
- package/src/schemas/metadata/Metadata.ts +669 -669
- package/src/schemas/metadata/MetadataAliasType.ts +57 -57
- package/src/schemas/metadata/MetadataApplication.ts +40 -40
- package/src/schemas/metadata/MetadataArray.ts +47 -47
- package/src/schemas/metadata/MetadataArrayType.ts +51 -51
- package/src/schemas/metadata/MetadataAtomic.ts +85 -85
- package/src/schemas/metadata/MetadataEscaped.ts +45 -45
- package/src/schemas/metadata/MetadataFunction.ts +45 -45
- package/src/schemas/metadata/MetadataObject.ts +46 -46
- package/src/schemas/metadata/MetadataObjectType.ts +137 -137
- package/src/schemas/metadata/MetadataParameter.ts +52 -52
- package/src/schemas/metadata/MetadataProperty.ts +53 -53
- package/src/schemas/metadata/MetadataTemplate.ts +78 -78
- package/src/schemas/metadata/MetadataTuple.ts +28 -28
- package/src/schemas/metadata/MetadataTupleType.ts +61 -61
- package/src/tags/Constant.ts +47 -47
- package/src/tags/ContentMediaType.ts +27 -27
- package/src/tags/Default.ts +52 -52
- package/src/tags/Example.ts +56 -56
- package/src/tags/Examples.ts +56 -56
- package/src/tags/ExclusiveMaximum.ts +44 -44
- package/src/tags/ExclusiveMinimum.ts +44 -44
- package/src/tags/Format.ts +78 -78
- package/src/tags/JsonSchemaPlugin.ts +36 -36
- package/src/tags/MaxItems.ts +31 -31
- package/src/tags/MaxLength.ts +25 -25
- package/src/tags/Maximum.ts +39 -39
- package/src/tags/MinItems.ts +31 -31
- package/src/tags/MinLength.ts +25 -25
- package/src/tags/Minimum.ts +39 -39
- package/src/tags/MultipleOf.ts +42 -42
- package/src/tags/Pattern.ts +49 -49
- package/src/tags/Sequence.ts +37 -37
- package/src/tags/TagBase.ts +102 -102
- package/src/tags/Type.ts +64 -64
- package/src/tags/UniqueItems.ts +34 -34
- package/src/tags/internal/FormatCheatSheet.ts +71 -71
- package/src/transformers/ITransformOptions.ts +70 -70
- package/src/transformers/ImportTransformer.ts +253 -253
- package/src/transformers/NoTransformConfigurationError.ts +16 -16
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -224
- package/src/typings/Equal.ts +18 -18
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
-
|
|
3
|
-
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
4
|
-
import { IMetadataFunction } from "./IMetadataFunction";
|
|
5
|
-
import { Metadata } from "./Metadata";
|
|
6
|
-
import { MetadataParameter } from "./MetadataParameter";
|
|
7
|
-
|
|
8
|
-
export class MetadataFunction {
|
|
9
|
-
public parameters: MetadataParameter[];
|
|
10
|
-
public output: Metadata;
|
|
11
|
-
public async: boolean;
|
|
12
|
-
|
|
13
|
-
/** @ignore */
|
|
14
|
-
private constructor(props: ClassProperties<MetadataFunction>) {
|
|
15
|
-
this.parameters = props.parameters;
|
|
16
|
-
this.output = props.output;
|
|
17
|
-
this.async = props.async;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** @internal */
|
|
21
|
-
public static create(
|
|
22
|
-
props: ClassProperties<MetadataFunction>,
|
|
23
|
-
): MetadataFunction {
|
|
24
|
-
return new MetadataFunction(props);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public static from(
|
|
28
|
-
json: IMetadataFunction,
|
|
29
|
-
dict: IMetadataDictionary,
|
|
30
|
-
): MetadataFunction {
|
|
31
|
-
return MetadataFunction.create({
|
|
32
|
-
parameters: json.parameters.map((p) => MetadataParameter.from(p, dict)),
|
|
33
|
-
output: Metadata.from(json.output, dict),
|
|
34
|
-
async: json.async,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public toJSON(): IMetadataFunction {
|
|
39
|
-
return {
|
|
40
|
-
parameters: this.parameters.map((p) => p.toJSON()),
|
|
41
|
-
output: this.output.toJSON(),
|
|
42
|
-
async: this.async,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
4
|
+
import { IMetadataFunction } from "./IMetadataFunction";
|
|
5
|
+
import { Metadata } from "./Metadata";
|
|
6
|
+
import { MetadataParameter } from "./MetadataParameter";
|
|
7
|
+
|
|
8
|
+
export class MetadataFunction {
|
|
9
|
+
public parameters: MetadataParameter[];
|
|
10
|
+
public output: Metadata;
|
|
11
|
+
public async: boolean;
|
|
12
|
+
|
|
13
|
+
/** @ignore */
|
|
14
|
+
private constructor(props: ClassProperties<MetadataFunction>) {
|
|
15
|
+
this.parameters = props.parameters;
|
|
16
|
+
this.output = props.output;
|
|
17
|
+
this.async = props.async;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @internal */
|
|
21
|
+
public static create(
|
|
22
|
+
props: ClassProperties<MetadataFunction>,
|
|
23
|
+
): MetadataFunction {
|
|
24
|
+
return new MetadataFunction(props);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public static from(
|
|
28
|
+
json: IMetadataFunction,
|
|
29
|
+
dict: IMetadataDictionary,
|
|
30
|
+
): MetadataFunction {
|
|
31
|
+
return MetadataFunction.create({
|
|
32
|
+
parameters: json.parameters.map((p) => MetadataParameter.from(p, dict)),
|
|
33
|
+
output: Metadata.from(json.output, dict),
|
|
34
|
+
async: json.async,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public toJSON(): IMetadataFunction {
|
|
39
|
+
return {
|
|
40
|
+
parameters: this.parameters.map((p) => p.toJSON()),
|
|
41
|
+
output: this.output.toJSON(),
|
|
42
|
+
async: this.async,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
-
|
|
3
|
-
import { IMetadataObject } from "./IMetadataObject";
|
|
4
|
-
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
5
|
-
import { MetadataObjectType } from "./MetadataObjectType";
|
|
6
|
-
|
|
7
|
-
export class MetadataObject {
|
|
8
|
-
public readonly type: MetadataObjectType;
|
|
9
|
-
public readonly tags: IMetadataTypeTag[][];
|
|
10
|
-
private name_?: string;
|
|
11
|
-
|
|
12
|
-
/** @ignore */
|
|
13
|
-
private constructor(props: ClassProperties<MetadataObject>) {
|
|
14
|
-
this.type = props.type;
|
|
15
|
-
this.tags = props.tags;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public static create(props: ClassProperties<MetadataObject>): MetadataObject {
|
|
19
|
-
return new MetadataObject(props);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public getName(): string {
|
|
23
|
-
return (this.name_ ??= (() => {
|
|
24
|
-
if (this.tags.length === 0) return this.type.name;
|
|
25
|
-
else if (this.tags.length === 1) {
|
|
26
|
-
const str: string = [
|
|
27
|
-
this.type.name,
|
|
28
|
-
...this.tags[0]!.map((t) => t.name),
|
|
29
|
-
].join(" & ");
|
|
30
|
-
return `(${str})`;
|
|
31
|
-
}
|
|
32
|
-
const rows: string[] = this.tags.map((row) => {
|
|
33
|
-
const str: string = row.map((t) => t.name).join(" & ");
|
|
34
|
-
return row.length === 1 ? str : `(${str})`;
|
|
35
|
-
});
|
|
36
|
-
return `(${this.type.name} & (${rows.join(" | ")}))`;
|
|
37
|
-
})());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public toJSON(): IMetadataObject {
|
|
41
|
-
return {
|
|
42
|
-
name: this.type.name,
|
|
43
|
-
tags: this.tags.map((row) => row.slice()),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IMetadataObject } from "./IMetadataObject";
|
|
4
|
+
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
5
|
+
import { MetadataObjectType } from "./MetadataObjectType";
|
|
6
|
+
|
|
7
|
+
export class MetadataObject {
|
|
8
|
+
public readonly type: MetadataObjectType;
|
|
9
|
+
public readonly tags: IMetadataTypeTag[][];
|
|
10
|
+
private name_?: string;
|
|
11
|
+
|
|
12
|
+
/** @ignore */
|
|
13
|
+
private constructor(props: ClassProperties<MetadataObject>) {
|
|
14
|
+
this.type = props.type;
|
|
15
|
+
this.tags = props.tags;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public static create(props: ClassProperties<MetadataObject>): MetadataObject {
|
|
19
|
+
return new MetadataObject(props);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getName(): string {
|
|
23
|
+
return (this.name_ ??= (() => {
|
|
24
|
+
if (this.tags.length === 0) return this.type.name;
|
|
25
|
+
else if (this.tags.length === 1) {
|
|
26
|
+
const str: string = [
|
|
27
|
+
this.type.name,
|
|
28
|
+
...this.tags[0]!.map((t) => t.name),
|
|
29
|
+
].join(" & ");
|
|
30
|
+
return `(${str})`;
|
|
31
|
+
}
|
|
32
|
+
const rows: string[] = this.tags.map((row) => {
|
|
33
|
+
const str: string = row.map((t) => t.name).join(" & ");
|
|
34
|
+
return row.length === 1 ? str : `(${str})`;
|
|
35
|
+
});
|
|
36
|
+
return `(${this.type.name} & (${rows.join(" | ")}))`;
|
|
37
|
+
})());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public toJSON(): IMetadataObject {
|
|
41
|
+
return {
|
|
42
|
+
name: this.type.name,
|
|
43
|
+
tags: this.tags.map((row) => row.slice()),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
-
|
|
3
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
-
import { IMetadataObjectType } from "./IMetadataObjectType";
|
|
5
|
-
import { MetadataProperty } from "./MetadataProperty";
|
|
6
|
-
|
|
7
|
-
export class MetadataObjectType {
|
|
8
|
-
public readonly name: string;
|
|
9
|
-
public readonly properties: Array<MetadataProperty>;
|
|
10
|
-
public readonly description: string | undefined;
|
|
11
|
-
public readonly jsDocTags: IJsDocTagInfo[];
|
|
12
|
-
|
|
13
|
-
public readonly index: number;
|
|
14
|
-
public validated: boolean;
|
|
15
|
-
public recursive: boolean;
|
|
16
|
-
public nullables: boolean[] = [];
|
|
17
|
-
|
|
18
|
-
/** @internal */
|
|
19
|
-
public tagged_: boolean = false;
|
|
20
|
-
|
|
21
|
-
/** @internal */
|
|
22
|
-
private literal_?: boolean;
|
|
23
|
-
|
|
24
|
-
/* -----------------------------------------------------------
|
|
25
|
-
CONSTRUCTORS
|
|
26
|
-
----------------------------------------------------------- */
|
|
27
|
-
/** @ignore */
|
|
28
|
-
private constructor(
|
|
29
|
-
props: Omit<ClassProperties<MetadataObjectType>, "tagged_">,
|
|
30
|
-
) {
|
|
31
|
-
this.name = props.name;
|
|
32
|
-
this.properties = props.properties;
|
|
33
|
-
this.description = props.description;
|
|
34
|
-
this.jsDocTags = props.jsDocTags;
|
|
35
|
-
|
|
36
|
-
this.index = props.index;
|
|
37
|
-
this.validated = props.validated;
|
|
38
|
-
this.recursive = props.recursive;
|
|
39
|
-
this.nullables = props.nullables.slice();
|
|
40
|
-
|
|
41
|
-
this.tagged_ = false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** @internal */
|
|
45
|
-
public static create(
|
|
46
|
-
props: Omit<ClassProperties<MetadataObjectType>, "tagged_">,
|
|
47
|
-
) {
|
|
48
|
-
return new MetadataObjectType(props);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** @internal */
|
|
52
|
-
public static _From_without_properties(
|
|
53
|
-
obj: IMetadataObjectType,
|
|
54
|
-
): MetadataObjectType {
|
|
55
|
-
return MetadataObjectType.create({
|
|
56
|
-
name: obj.name,
|
|
57
|
-
properties: [],
|
|
58
|
-
description: obj.description,
|
|
59
|
-
jsDocTags: obj.jsDocTags,
|
|
60
|
-
|
|
61
|
-
index: obj.index,
|
|
62
|
-
validated: false,
|
|
63
|
-
recursive: obj.recursive,
|
|
64
|
-
nullables: obj.nullables.slice(),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public isPlain(level: number = 0): boolean {
|
|
69
|
-
return (
|
|
70
|
-
this.recursive === false &&
|
|
71
|
-
this.properties.length < 10 &&
|
|
72
|
-
this.properties.every(
|
|
73
|
-
(property) =>
|
|
74
|
-
property.key.isSoleLiteral() &&
|
|
75
|
-
property.value.size() === 1 &&
|
|
76
|
-
property.value.isRequired() === true &&
|
|
77
|
-
property.value.nullable === false &&
|
|
78
|
-
(property.value.atomics.length === 1 ||
|
|
79
|
-
(level < 1 &&
|
|
80
|
-
property.value.objects.length === 1 &&
|
|
81
|
-
property.value.objects[0]!.type.isPlain(level + 1))),
|
|
82
|
-
)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public isLiteral(): boolean {
|
|
87
|
-
return (this.literal_ ??= (() => {
|
|
88
|
-
if (this.recursive === true) return false;
|
|
89
|
-
return (
|
|
90
|
-
this.name === "__type" ||
|
|
91
|
-
this.name === "__object" ||
|
|
92
|
-
this.name.startsWith("__type.") ||
|
|
93
|
-
this.name.startsWith("__object.") ||
|
|
94
|
-
this.name.includes("readonly [")
|
|
95
|
-
);
|
|
96
|
-
})());
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
public toJSON(): IMetadataObjectType {
|
|
100
|
-
return {
|
|
101
|
-
name: this.name,
|
|
102
|
-
properties: this.properties.map((property) => property.toJSON()),
|
|
103
|
-
description: this.description,
|
|
104
|
-
jsDocTags: this.jsDocTags,
|
|
105
|
-
|
|
106
|
-
index: this.index,
|
|
107
|
-
recursive: this.recursive,
|
|
108
|
-
nullables: this.nullables.slice(),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** @internal */
|
|
114
|
-
export namespace MetadataObjectType {
|
|
115
|
-
export const intersects = (
|
|
116
|
-
x: MetadataObjectType,
|
|
117
|
-
y: MetadataObjectType,
|
|
118
|
-
): boolean =>
|
|
119
|
-
x.properties.some(
|
|
120
|
-
(prop) =>
|
|
121
|
-
y.properties.find(
|
|
122
|
-
(oppo) => prop.key.getName() === oppo.key.getName(),
|
|
123
|
-
) !== undefined,
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
export const covers = (
|
|
127
|
-
x: MetadataObjectType,
|
|
128
|
-
y: MetadataObjectType,
|
|
129
|
-
): boolean =>
|
|
130
|
-
x.properties.length >= y.properties.length &&
|
|
131
|
-
x.properties.every(
|
|
132
|
-
(prop) =>
|
|
133
|
-
y.properties.find(
|
|
134
|
-
(oppo) => prop.key.getName() === oppo.key.getName(),
|
|
135
|
-
) !== undefined,
|
|
136
|
-
);
|
|
137
|
-
}
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
4
|
+
import { IMetadataObjectType } from "./IMetadataObjectType";
|
|
5
|
+
import { MetadataProperty } from "./MetadataProperty";
|
|
6
|
+
|
|
7
|
+
export class MetadataObjectType {
|
|
8
|
+
public readonly name: string;
|
|
9
|
+
public readonly properties: Array<MetadataProperty>;
|
|
10
|
+
public readonly description: string | undefined;
|
|
11
|
+
public readonly jsDocTags: IJsDocTagInfo[];
|
|
12
|
+
|
|
13
|
+
public readonly index: number;
|
|
14
|
+
public validated: boolean;
|
|
15
|
+
public recursive: boolean;
|
|
16
|
+
public nullables: boolean[] = [];
|
|
17
|
+
|
|
18
|
+
/** @internal */
|
|
19
|
+
public tagged_: boolean = false;
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
private literal_?: boolean;
|
|
23
|
+
|
|
24
|
+
/* -----------------------------------------------------------
|
|
25
|
+
CONSTRUCTORS
|
|
26
|
+
----------------------------------------------------------- */
|
|
27
|
+
/** @ignore */
|
|
28
|
+
private constructor(
|
|
29
|
+
props: Omit<ClassProperties<MetadataObjectType>, "tagged_">,
|
|
30
|
+
) {
|
|
31
|
+
this.name = props.name;
|
|
32
|
+
this.properties = props.properties;
|
|
33
|
+
this.description = props.description;
|
|
34
|
+
this.jsDocTags = props.jsDocTags;
|
|
35
|
+
|
|
36
|
+
this.index = props.index;
|
|
37
|
+
this.validated = props.validated;
|
|
38
|
+
this.recursive = props.recursive;
|
|
39
|
+
this.nullables = props.nullables.slice();
|
|
40
|
+
|
|
41
|
+
this.tagged_ = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @internal */
|
|
45
|
+
public static create(
|
|
46
|
+
props: Omit<ClassProperties<MetadataObjectType>, "tagged_">,
|
|
47
|
+
) {
|
|
48
|
+
return new MetadataObjectType(props);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @internal */
|
|
52
|
+
public static _From_without_properties(
|
|
53
|
+
obj: IMetadataObjectType,
|
|
54
|
+
): MetadataObjectType {
|
|
55
|
+
return MetadataObjectType.create({
|
|
56
|
+
name: obj.name,
|
|
57
|
+
properties: [],
|
|
58
|
+
description: obj.description,
|
|
59
|
+
jsDocTags: obj.jsDocTags,
|
|
60
|
+
|
|
61
|
+
index: obj.index,
|
|
62
|
+
validated: false,
|
|
63
|
+
recursive: obj.recursive,
|
|
64
|
+
nullables: obj.nullables.slice(),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public isPlain(level: number = 0): boolean {
|
|
69
|
+
return (
|
|
70
|
+
this.recursive === false &&
|
|
71
|
+
this.properties.length < 10 &&
|
|
72
|
+
this.properties.every(
|
|
73
|
+
(property) =>
|
|
74
|
+
property.key.isSoleLiteral() &&
|
|
75
|
+
property.value.size() === 1 &&
|
|
76
|
+
property.value.isRequired() === true &&
|
|
77
|
+
property.value.nullable === false &&
|
|
78
|
+
(property.value.atomics.length === 1 ||
|
|
79
|
+
(level < 1 &&
|
|
80
|
+
property.value.objects.length === 1 &&
|
|
81
|
+
property.value.objects[0]!.type.isPlain(level + 1))),
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public isLiteral(): boolean {
|
|
87
|
+
return (this.literal_ ??= (() => {
|
|
88
|
+
if (this.recursive === true) return false;
|
|
89
|
+
return (
|
|
90
|
+
this.name === "__type" ||
|
|
91
|
+
this.name === "__object" ||
|
|
92
|
+
this.name.startsWith("__type.") ||
|
|
93
|
+
this.name.startsWith("__object.") ||
|
|
94
|
+
this.name.includes("readonly [")
|
|
95
|
+
);
|
|
96
|
+
})());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public toJSON(): IMetadataObjectType {
|
|
100
|
+
return {
|
|
101
|
+
name: this.name,
|
|
102
|
+
properties: this.properties.map((property) => property.toJSON()),
|
|
103
|
+
description: this.description,
|
|
104
|
+
jsDocTags: this.jsDocTags,
|
|
105
|
+
|
|
106
|
+
index: this.index,
|
|
107
|
+
recursive: this.recursive,
|
|
108
|
+
nullables: this.nullables.slice(),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** @internal */
|
|
114
|
+
export namespace MetadataObjectType {
|
|
115
|
+
export const intersects = (
|
|
116
|
+
x: MetadataObjectType,
|
|
117
|
+
y: MetadataObjectType,
|
|
118
|
+
): boolean =>
|
|
119
|
+
x.properties.some(
|
|
120
|
+
(prop) =>
|
|
121
|
+
y.properties.find(
|
|
122
|
+
(oppo) => prop.key.getName() === oppo.key.getName(),
|
|
123
|
+
) !== undefined,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
export const covers = (
|
|
127
|
+
x: MetadataObjectType,
|
|
128
|
+
y: MetadataObjectType,
|
|
129
|
+
): boolean =>
|
|
130
|
+
x.properties.length >= y.properties.length &&
|
|
131
|
+
x.properties.every(
|
|
132
|
+
(prop) =>
|
|
133
|
+
y.properties.find(
|
|
134
|
+
(oppo) => prop.key.getName() === oppo.key.getName(),
|
|
135
|
+
) !== undefined,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { ClassProperties } from "../../typings/ClassProperties";
|
|
4
|
-
|
|
5
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
6
|
-
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
7
|
-
import { IMetadataParameter } from "./IMetadataParameter";
|
|
8
|
-
import { Metadata } from "./Metadata";
|
|
9
|
-
|
|
10
|
-
export class MetadataParameter {
|
|
11
|
-
public name: string;
|
|
12
|
-
public type: Metadata;
|
|
13
|
-
public description: string | null;
|
|
14
|
-
public jsDocTags: IJsDocTagInfo[];
|
|
15
|
-
public tsType?: ts.Type;
|
|
16
|
-
|
|
17
|
-
private constructor(props: ClassProperties<MetadataParameter>) {
|
|
18
|
-
this.name = props.name;
|
|
19
|
-
this.type = props.type;
|
|
20
|
-
this.description = props.description;
|
|
21
|
-
this.jsDocTags = props.jsDocTags;
|
|
22
|
-
this.tsType = props.tsType;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** @internal */
|
|
26
|
-
public static create(
|
|
27
|
-
props: ClassProperties<MetadataParameter>,
|
|
28
|
-
): MetadataParameter {
|
|
29
|
-
return new MetadataParameter(props);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static from(
|
|
33
|
-
json: IMetadataParameter,
|
|
34
|
-
dict: IMetadataDictionary,
|
|
35
|
-
): MetadataParameter {
|
|
36
|
-
return MetadataParameter.create({
|
|
37
|
-
name: json.name,
|
|
38
|
-
type: Metadata.from(json.type, dict),
|
|
39
|
-
description: json.description,
|
|
40
|
-
jsDocTags: json.jsDocTags,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public toJSON(): IMetadataParameter {
|
|
45
|
-
return {
|
|
46
|
-
name: this.name,
|
|
47
|
-
type: this.type.toJSON(),
|
|
48
|
-
description: this.description,
|
|
49
|
-
jsDocTags: this.jsDocTags,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
4
|
+
|
|
5
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
6
|
+
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
7
|
+
import { IMetadataParameter } from "./IMetadataParameter";
|
|
8
|
+
import { Metadata } from "./Metadata";
|
|
9
|
+
|
|
10
|
+
export class MetadataParameter {
|
|
11
|
+
public name: string;
|
|
12
|
+
public type: Metadata;
|
|
13
|
+
public description: string | null;
|
|
14
|
+
public jsDocTags: IJsDocTagInfo[];
|
|
15
|
+
public tsType?: ts.Type;
|
|
16
|
+
|
|
17
|
+
private constructor(props: ClassProperties<MetadataParameter>) {
|
|
18
|
+
this.name = props.name;
|
|
19
|
+
this.type = props.type;
|
|
20
|
+
this.description = props.description;
|
|
21
|
+
this.jsDocTags = props.jsDocTags;
|
|
22
|
+
this.tsType = props.tsType;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @internal */
|
|
26
|
+
public static create(
|
|
27
|
+
props: ClassProperties<MetadataParameter>,
|
|
28
|
+
): MetadataParameter {
|
|
29
|
+
return new MetadataParameter(props);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static from(
|
|
33
|
+
json: IMetadataParameter,
|
|
34
|
+
dict: IMetadataDictionary,
|
|
35
|
+
): MetadataParameter {
|
|
36
|
+
return MetadataParameter.create({
|
|
37
|
+
name: json.name,
|
|
38
|
+
type: Metadata.from(json.type, dict),
|
|
39
|
+
description: json.description,
|
|
40
|
+
jsDocTags: json.jsDocTags,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public toJSON(): IMetadataParameter {
|
|
45
|
+
return {
|
|
46
|
+
name: this.name,
|
|
47
|
+
type: this.type.toJSON(),
|
|
48
|
+
description: this.description,
|
|
49
|
+
jsDocTags: this.jsDocTags,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
-
|
|
3
|
-
import { IProtobufProperty } from "../protobuf/IProtobufProperty";
|
|
4
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
5
|
-
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
6
|
-
import { IMetadataProperty } from "./IMetadataProperty";
|
|
7
|
-
import { Metadata } from "./Metadata";
|
|
8
|
-
|
|
9
|
-
export class MetadataProperty {
|
|
10
|
-
public readonly key: Metadata;
|
|
11
|
-
public readonly value: Metadata;
|
|
12
|
-
public readonly description: string | null;
|
|
13
|
-
public readonly jsDocTags: IJsDocTagInfo[];
|
|
14
|
-
|
|
15
|
-
public of_protobuf_?: IProtobufProperty;
|
|
16
|
-
|
|
17
|
-
/* -----------------------------------------------------------
|
|
18
|
-
CONSTRUCTORS
|
|
19
|
-
----------------------------------------------------------- */
|
|
20
|
-
/** @ignore */
|
|
21
|
-
private constructor(props: ClassProperties<MetadataProperty>) {
|
|
22
|
-
this.key = props.key;
|
|
23
|
-
this.value = props.value;
|
|
24
|
-
this.description = props.description;
|
|
25
|
-
this.jsDocTags = props.jsDocTags;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @internal */
|
|
29
|
-
public static create(
|
|
30
|
-
props: ClassProperties<MetadataProperty>,
|
|
31
|
-
): MetadataProperty {
|
|
32
|
-
return new MetadataProperty(props);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** @internal */
|
|
36
|
-
public static from(property: IMetadataProperty, dict: IMetadataDictionary) {
|
|
37
|
-
return MetadataProperty.create({
|
|
38
|
-
key: Metadata.from(property.key, dict),
|
|
39
|
-
value: Metadata.from(property.value, dict),
|
|
40
|
-
description: property.description,
|
|
41
|
-
jsDocTags: property.jsDocTags.slice(),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public toJSON(): IMetadataProperty {
|
|
46
|
-
return {
|
|
47
|
-
key: this.key.toJSON(),
|
|
48
|
-
value: this.value.toJSON(),
|
|
49
|
-
description: this.description,
|
|
50
|
-
jsDocTags: this.jsDocTags,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
import { ClassProperties } from "../../typings/ClassProperties";
|
|
2
|
+
|
|
3
|
+
import { IProtobufProperty } from "../protobuf/IProtobufProperty";
|
|
4
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
5
|
+
import { IMetadataDictionary } from "./IMetadataDictionary";
|
|
6
|
+
import { IMetadataProperty } from "./IMetadataProperty";
|
|
7
|
+
import { Metadata } from "./Metadata";
|
|
8
|
+
|
|
9
|
+
export class MetadataProperty {
|
|
10
|
+
public readonly key: Metadata;
|
|
11
|
+
public readonly value: Metadata;
|
|
12
|
+
public readonly description: string | null;
|
|
13
|
+
public readonly jsDocTags: IJsDocTagInfo[];
|
|
14
|
+
|
|
15
|
+
public of_protobuf_?: IProtobufProperty;
|
|
16
|
+
|
|
17
|
+
/* -----------------------------------------------------------
|
|
18
|
+
CONSTRUCTORS
|
|
19
|
+
----------------------------------------------------------- */
|
|
20
|
+
/** @ignore */
|
|
21
|
+
private constructor(props: ClassProperties<MetadataProperty>) {
|
|
22
|
+
this.key = props.key;
|
|
23
|
+
this.value = props.value;
|
|
24
|
+
this.description = props.description;
|
|
25
|
+
this.jsDocTags = props.jsDocTags;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
public static create(
|
|
30
|
+
props: ClassProperties<MetadataProperty>,
|
|
31
|
+
): MetadataProperty {
|
|
32
|
+
return new MetadataProperty(props);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** @internal */
|
|
36
|
+
public static from(property: IMetadataProperty, dict: IMetadataDictionary) {
|
|
37
|
+
return MetadataProperty.create({
|
|
38
|
+
key: Metadata.from(property.key, dict),
|
|
39
|
+
value: Metadata.from(property.value, dict),
|
|
40
|
+
description: property.description,
|
|
41
|
+
jsDocTags: property.jsDocTags.slice(),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public toJSON(): IMetadataProperty {
|
|
46
|
+
return {
|
|
47
|
+
key: this.key.toJSON(),
|
|
48
|
+
value: this.value.toJSON(),
|
|
49
|
+
description: this.description,
|
|
50
|
+
jsDocTags: this.jsDocTags,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|