typia 3.5.0-dev.20221222 → 3.5.0-dev.20230124
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 +5 -2
- package/lib/executable/internal/TypiaSetupWizard.d.ts +6 -2
- package/lib/executable/internal/TypiaSetupWizard.js +23 -22
- package/lib/executable/internal/TypiaSetupWizard.js.map +1 -1
- package/lib/executable/typia.js +11 -10
- package/lib/executable/typia.js.map +1 -1
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +1 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +20 -0
- package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +2 -1
- package/lib/factories/internal/protocols/iterate_protocol_map.js +7 -4
- package/lib/factories/internal/protocols/iterate_protocol_map.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js +3 -3
- package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +1 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +2 -1
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js +5 -4
- package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +1 -1
- 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/IProtocolProperty.d.ts +2 -1
- package/lib/metadata/Metadata.d.ts +1 -0
- package/lib/metadata/Metadata.js +145 -51
- package/lib/metadata/Metadata.js.map +1 -1
- package/lib/programmers/AssertProgrammer.js +1 -1
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +1 -0
- package/lib/programmers/CheckerProgrammer.js +147 -138
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/MessageProgrammer.js +7 -2
- package/lib/programmers/MessageProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +1 -1
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/UnionExplorer.d.ts +23 -29
- package/lib/programmers/helpers/UnionExplorer.js +29 -41
- package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
- package/lib/programmers/internal/application_array.js +29 -27
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_object.js +96 -31
- package/lib/programmers/internal/application_object.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +28 -136
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_tuple.js +3 -2
- package/lib/programmers/internal/application_tuple.js.map +1 -1
- package/lib/programmers/internal/check_array.js +4 -32
- package/lib/programmers/internal/check_array.js.map +1 -1
- package/lib/programmers/internal/check_array_length.d.ts +1 -0
- package/lib/programmers/internal/check_array_length.js +47 -0
- package/lib/programmers/internal/check_array_length.js.map +1 -0
- package/lib/programmers/internal/check_union_array_like.d.ts +21 -0
- package/lib/programmers/internal/check_union_array_like.js +83 -0
- package/lib/programmers/internal/check_union_array_like.js.map +1 -0
- package/lib/programmers/internal/check_union_tuple.d.ts +1 -0
- package/lib/programmers/internal/check_union_tuple.js +11 -0
- package/lib/programmers/internal/check_union_tuple.js.map +1 -0
- package/lib/schemas/IJsonComponents.d.ts +4 -2
- package/lib/schemas/IJsonSchema.d.ts +2 -0
- package/package.json +4 -4
- package/src/IValidation.ts +21 -21
- package/src/Primitive.ts +82 -82
- package/src/TypeGuardError.ts +36 -36
- package/src/executable/internal/CommandParser.ts +15 -15
- package/src/executable/internal/TypiaSetupWizard.ts +30 -21
- package/src/executable/typia.ts +48 -46
- package/src/factories/CommentFactory.ts +10 -10
- package/src/factories/ExpressionFactory.ts +66 -66
- package/src/factories/IdentifierFactory.ts +72 -72
- package/src/factories/LiteralFactory.ts +44 -44
- package/src/factories/StatementFactory.ts +60 -60
- package/src/factories/TemplateFactory.ts +56 -56
- package/src/factories/TypeFactory.ts +101 -101
- package/src/factories/ValueFactory.ts +12 -12
- package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +20 -0
- package/src/factories/internal/protocols/iterate_protocol_map.ts +9 -3
- package/src/factories/internal/protocols/iterate_protocol_metadata.ts +17 -4
- package/src/factories/internal/protocols/iterate_protocol_repeated.ts +14 -5
- package/src/functional/$every.ts +11 -11
- package/src/functional/$guard.ts +35 -35
- package/src/functional/$is_email.ts +5 -5
- package/src/functional/$is_ipv4.ts +5 -5
- package/src/functional/$is_ipv6.ts +5 -5
- package/src/functional/$is_url.ts +5 -5
- package/src/functional/$is_uuid.ts +5 -5
- package/src/functional/$join.ts +50 -50
- package/src/functional/$report.ts +15 -15
- package/src/functional/$rest.ts +3 -3
- package/src/functional/$string.ts +37 -37
- package/src/functional/$tail.ts +6 -6
- package/src/index.ts +4 -4
- package/src/messages/IProtocolMap.ts +5 -0
- package/src/messages/IProtocolProperty.ts +3 -1
- package/src/metadata/IJsDocTagInfo.ts +10 -10
- package/src/metadata/IMetadata.ts +25 -25
- package/src/metadata/IMetadataApplication.ts +7 -7
- package/src/metadata/IMetadataConstant.ts +16 -16
- package/src/metadata/IMetadataEntry.ts +6 -6
- package/src/metadata/IMetadataObject.ts +29 -29
- package/src/metadata/IMetadataProperty.ts +11 -11
- package/src/metadata/Metadata.ts +64 -7
- package/src/metadata/MetadataConstant.ts +3 -3
- package/src/metadata/MetadataObject.ts +131 -131
- package/src/metadata/MetadataProperty.ts +64 -64
- package/src/programmers/ApplicationProgrammer.ts +55 -55
- package/src/programmers/AssertProgrammer.ts +1 -1
- package/src/programmers/CheckerProgrammer.ts +252 -200
- package/src/programmers/FeatureProgrammer.ts +327 -327
- package/src/programmers/MessageProgrammer.ts +9 -2
- package/src/programmers/ValidateProgrammer.ts +1 -1
- package/src/programmers/helpers/AtomicPredicator.ts +15 -15
- package/src/programmers/helpers/FunctionImporeter.ts +31 -31
- package/src/programmers/helpers/IExpressionEntry.ts +10 -10
- package/src/programmers/helpers/StringifyJoinder.ts +111 -111
- package/src/programmers/helpers/StringifyPredicator.ts +18 -18
- package/src/programmers/helpers/UnionExplorer.ts +274 -437
- package/src/programmers/helpers/UnionPredicator.ts +81 -81
- package/src/programmers/internal/application_array.ts +47 -45
- package/src/programmers/internal/application_boolean.ts +17 -17
- package/src/programmers/internal/application_constant.ts +29 -29
- package/src/programmers/internal/application_default_string.ts +32 -32
- package/src/programmers/internal/application_native.ts +29 -29
- package/src/programmers/internal/application_number.ts +76 -76
- package/src/programmers/internal/application_object.ts +153 -103
- package/src/programmers/internal/application_schema.ts +15 -68
- package/src/programmers/internal/application_string.ts +49 -49
- package/src/programmers/internal/application_templates.ts +27 -27
- package/src/programmers/internal/application_tuple.ts +29 -25
- package/src/programmers/internal/check_array.ts +22 -44
- package/src/programmers/internal/check_array_length.ts +45 -0
- package/src/programmers/internal/check_dynamic_properties.ts +146 -146
- package/src/programmers/internal/check_everything.ts +25 -25
- package/src/programmers/internal/check_length.ts +46 -46
- package/src/programmers/internal/check_native.ts +9 -9
- package/src/programmers/internal/check_object.ts +42 -42
- package/src/programmers/internal/check_string.ts +24 -24
- package/src/programmers/internal/check_string_tags.ts +63 -63
- package/src/programmers/internal/check_template.ts +50 -50
- package/src/programmers/internal/check_union_array_like.ts +242 -0
- package/src/programmers/internal/check_union_tuple.ts +33 -0
- package/src/programmers/internal/decode_union_object.ts +73 -73
- package/src/programmers/internal/feature_object_entries.ts +49 -49
- package/src/programmers/internal/metadata_to_pattern.ts +31 -31
- package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
- package/src/programmers/internal/stringify_native.ts +8 -8
- package/src/programmers/internal/stringify_regular_properties.ts +81 -81
- package/src/programmers/internal/template_to_pattern.ts +15 -15
- package/src/schemas/IJsonApplication.ts +9 -9
- package/src/schemas/IJsonComponents.ts +26 -24
- package/src/schemas/IJsonSchema.ts +2 -0
- package/src/transform.ts +20 -20
- package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
- package/src/transformers/FileTransformer.ts +49 -49
- package/src/transformers/IProject.ts +11 -11
- package/src/transformers/NodeTransformer.ts +19 -19
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +1 -0
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
- package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
- package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
- package/src/transformers/features/validators/AssertTransformer.ts +43 -43
- package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
- package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
- package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
- package/src/transformers/features/validators/IsTransformer.ts +43 -43
- package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
- package/src/typings/Atomic.ts +17 -17
- package/src/typings/ClassProperties.ts +5 -5
- package/src/typings/OmitNever.ts +3 -3
- package/src/typings/SpecialFields.ts +3 -3
- package/src/typings/Writable.ts +11 -11
- package/src/utils/ArrayUtil.ts +49 -49
- package/src/utils/Escaper.ts +50 -50
- package/src/utils/MapUtil.ts +14 -14
- package/src/utils/PatternUtil.ts +30 -30
- package/src/utils/Singleton.ts +17 -17
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IValidation } from "../IValidation";
|
|
2
|
-
|
|
3
|
-
export const $report = (array: IValidation.IError[]) => {
|
|
4
|
-
const reportable = (path: string): boolean => {
|
|
5
|
-
if (array.length === 0) return true;
|
|
6
|
-
const last: string = array[array.length - 1]!.path;
|
|
7
|
-
return (
|
|
8
|
-
path.length > last.length || last.substring(0, path.length) !== path
|
|
9
|
-
);
|
|
10
|
-
};
|
|
11
|
-
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
12
|
-
if (exceptable && reportable(error.path)) array.push(error);
|
|
13
|
-
return false;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
1
|
+
import { IValidation } from "../IValidation";
|
|
2
|
+
|
|
3
|
+
export const $report = (array: IValidation.IError[]) => {
|
|
4
|
+
const reportable = (path: string): boolean => {
|
|
5
|
+
if (array.length === 0) return true;
|
|
6
|
+
const last: string = array[array.length - 1]!.path;
|
|
7
|
+
return (
|
|
8
|
+
path.length > last.length || last.substring(0, path.length) !== path
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
return (exceptable: boolean, error: IValidation.IError): false => {
|
|
12
|
+
if (exceptable && reportable(error.path)) array.push(error);
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
};
|
package/src/functional/$rest.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function $rest(str: string): string {
|
|
2
|
-
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
-
}
|
|
1
|
+
export function $rest(str: string): string {
|
|
2
|
+
return str.length === 2 ? "" : "," + str.substring(1, str.length - 1);
|
|
3
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export function $string(str: string): string {
|
|
5
|
-
if (str.length > 41) return JSON.stringify(str);
|
|
6
|
-
|
|
7
|
-
const length = str.length;
|
|
8
|
-
let result = "";
|
|
9
|
-
let last = 0;
|
|
10
|
-
let found = false;
|
|
11
|
-
let surrogateFound = false;
|
|
12
|
-
let point = 255;
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line
|
|
15
|
-
for (let i = 0; i < length && point >= 32; i++) {
|
|
16
|
-
point = str.charCodeAt(i);
|
|
17
|
-
if (0xd800 <= point && point <= 0xdfff) {
|
|
18
|
-
// The current character is a surrogate.
|
|
19
|
-
surrogateFound = true;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
if (point === 34 || point === 92) {
|
|
23
|
-
result += str.slice(last, i) + "\\";
|
|
24
|
-
last = i;
|
|
25
|
-
found = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!found) {
|
|
30
|
-
result = str;
|
|
31
|
-
} else {
|
|
32
|
-
result += str.slice(last);
|
|
33
|
-
}
|
|
34
|
-
return point < 32 || surrogateFound === true
|
|
35
|
-
? JSON.stringify(str)
|
|
36
|
-
: `"${result}"`;
|
|
37
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export function $string(str: string): string {
|
|
5
|
+
if (str.length > 41) return JSON.stringify(str);
|
|
6
|
+
|
|
7
|
+
const length = str.length;
|
|
8
|
+
let result = "";
|
|
9
|
+
let last = 0;
|
|
10
|
+
let found = false;
|
|
11
|
+
let surrogateFound = false;
|
|
12
|
+
let point = 255;
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line
|
|
15
|
+
for (let i = 0; i < length && point >= 32; i++) {
|
|
16
|
+
point = str.charCodeAt(i);
|
|
17
|
+
if (0xd800 <= point && point <= 0xdfff) {
|
|
18
|
+
// The current character is a surrogate.
|
|
19
|
+
surrogateFound = true;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if (point === 34 || point === 92) {
|
|
23
|
+
result += str.slice(last, i) + "\\";
|
|
24
|
+
last = i;
|
|
25
|
+
found = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!found) {
|
|
30
|
+
result = str;
|
|
31
|
+
} else {
|
|
32
|
+
result += str.slice(last);
|
|
33
|
+
}
|
|
34
|
+
return point < 32 || surrogateFound === true
|
|
35
|
+
? JSON.stringify(str)
|
|
36
|
+
: `"${result}"`;
|
|
37
|
+
}
|
package/src/functional/$tail.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
export function $tail(str: string): string {
|
|
5
|
-
return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
|
|
6
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
4
|
+
export function $tail(str: string): string {
|
|
5
|
+
return str[str.length - 1] === "," ? str.substring(0, str.length - 1) : str;
|
|
6
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as typia from "./module";
|
|
2
|
-
|
|
3
|
-
export default typia;
|
|
4
|
-
export * from "./module";
|
|
1
|
+
import * as typia from "./module";
|
|
2
|
+
|
|
3
|
+
export default typia;
|
|
4
|
+
export * from "./module";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { IProtocolMap } from "./IProtocolMap";
|
|
2
|
+
|
|
1
3
|
export interface IProtocolProperty {
|
|
2
4
|
key: string;
|
|
3
5
|
oneOf: IProtocolProperty.IOneOf[];
|
|
@@ -6,6 +8,6 @@ export interface IProtocolProperty {
|
|
|
6
8
|
}
|
|
7
9
|
export namespace IProtocolProperty {
|
|
8
10
|
export interface IOneOf {
|
|
9
|
-
type: string;
|
|
11
|
+
type: string | IProtocolMap;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export interface IJsDocTagInfo {
|
|
2
|
-
name: string;
|
|
3
|
-
text?: IJsDocTagInfo.IText[];
|
|
4
|
-
}
|
|
5
|
-
export namespace IJsDocTagInfo {
|
|
6
|
-
export interface IText {
|
|
7
|
-
text: string;
|
|
8
|
-
kind: string;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
export interface IJsDocTagInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
text?: IJsDocTagInfo.IText[];
|
|
4
|
+
}
|
|
5
|
+
export namespace IJsDocTagInfo {
|
|
6
|
+
export interface IText {
|
|
7
|
+
text: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Atomic } from "../typings/Atomic";
|
|
2
|
-
|
|
3
|
-
import { IMetadataConstant } from "./IMetadataConstant";
|
|
4
|
-
import { IMetadataEntry } from "./IMetadataEntry";
|
|
5
|
-
|
|
6
|
-
export interface IMetadata {
|
|
7
|
-
any: boolean;
|
|
8
|
-
required: boolean;
|
|
9
|
-
nullable: boolean;
|
|
10
|
-
functional: boolean;
|
|
11
|
-
|
|
12
|
-
atomics: Atomic.Literal[];
|
|
13
|
-
constants: IMetadataConstant[];
|
|
14
|
-
templates: IMetadata[][];
|
|
15
|
-
resolved: IMetadata | null;
|
|
16
|
-
|
|
17
|
-
rest: IMetadata | null;
|
|
18
|
-
arrays: IMetadata[];
|
|
19
|
-
tuples: IMetadata[][];
|
|
20
|
-
objects: string[];
|
|
21
|
-
|
|
22
|
-
natives: string[];
|
|
23
|
-
sets: IMetadata[];
|
|
24
|
-
maps: IMetadataEntry[];
|
|
25
|
-
}
|
|
1
|
+
import { Atomic } from "../typings/Atomic";
|
|
2
|
+
|
|
3
|
+
import { IMetadataConstant } from "./IMetadataConstant";
|
|
4
|
+
import { IMetadataEntry } from "./IMetadataEntry";
|
|
5
|
+
|
|
6
|
+
export interface IMetadata {
|
|
7
|
+
any: boolean;
|
|
8
|
+
required: boolean;
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
functional: boolean;
|
|
11
|
+
|
|
12
|
+
atomics: Atomic.Literal[];
|
|
13
|
+
constants: IMetadataConstant[];
|
|
14
|
+
templates: IMetadata[][];
|
|
15
|
+
resolved: IMetadata | null;
|
|
16
|
+
|
|
17
|
+
rest: IMetadata | null;
|
|
18
|
+
arrays: IMetadata[];
|
|
19
|
+
tuples: IMetadata[][];
|
|
20
|
+
objects: string[];
|
|
21
|
+
|
|
22
|
+
natives: string[];
|
|
23
|
+
sets: IMetadata[];
|
|
24
|
+
maps: IMetadataEntry[];
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IMetadata } from "./IMetadata";
|
|
2
|
-
import { IMetadataObject } from "./IMetadataObject";
|
|
3
|
-
|
|
4
|
-
export interface IMetadataApplication {
|
|
5
|
-
metadatas: IMetadata[];
|
|
6
|
-
collection: IMetadataObject[];
|
|
7
|
-
}
|
|
1
|
+
import { IMetadata } from "./IMetadata";
|
|
2
|
+
import { IMetadataObject } from "./IMetadataObject";
|
|
3
|
+
|
|
4
|
+
export interface IMetadataApplication {
|
|
5
|
+
metadatas: IMetadata[];
|
|
6
|
+
collection: IMetadataObject[];
|
|
7
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Atomic } from "../typings/Atomic";
|
|
2
|
-
|
|
3
|
-
export type IMetadataConstant =
|
|
4
|
-
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
|
-
| IMetadataConstant.IBase<"number", number>
|
|
6
|
-
| IMetadataConstant.IBase<"string", string>
|
|
7
|
-
| IMetadataConstant.IBase<"bigint", bigint>;
|
|
8
|
-
export namespace IMetadataConstant {
|
|
9
|
-
export interface IBase<
|
|
10
|
-
Type extends Atomic.Literal,
|
|
11
|
-
Value extends Atomic.Type,
|
|
12
|
-
> {
|
|
13
|
-
type: Type;
|
|
14
|
-
values: Value[];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { Atomic } from "../typings/Atomic";
|
|
2
|
+
|
|
3
|
+
export type IMetadataConstant =
|
|
4
|
+
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
|
+
| IMetadataConstant.IBase<"number", number>
|
|
6
|
+
| IMetadataConstant.IBase<"string", string>
|
|
7
|
+
| IMetadataConstant.IBase<"bigint", bigint>;
|
|
8
|
+
export namespace IMetadataConstant {
|
|
9
|
+
export interface IBase<
|
|
10
|
+
Type extends Atomic.Literal,
|
|
11
|
+
Value extends Atomic.Type,
|
|
12
|
+
> {
|
|
13
|
+
type: Type;
|
|
14
|
+
values: Value[];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IMetadata } from "./IMetadata";
|
|
2
|
-
|
|
3
|
-
export interface IMetadataEntry {
|
|
4
|
-
key: IMetadata;
|
|
5
|
-
value: IMetadata;
|
|
6
|
-
}
|
|
1
|
+
import { IMetadata } from "./IMetadata";
|
|
2
|
+
|
|
3
|
+
export interface IMetadataEntry {
|
|
4
|
+
key: IMetadata;
|
|
5
|
+
value: IMetadata;
|
|
6
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
-
import { IMetadataProperty } from "./IMetadataProperty";
|
|
3
|
-
|
|
4
|
-
export interface IMetadataObject {
|
|
5
|
-
name: string;
|
|
6
|
-
properties: IMetadataProperty[];
|
|
7
|
-
description?: string;
|
|
8
|
-
jsDocTags: IJsDocTagInfo[];
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
index: number;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
validated: boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
recursive: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
nullables: boolean[];
|
|
29
|
-
}
|
|
1
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
+
import { IMetadataProperty } from "./IMetadataProperty";
|
|
3
|
+
|
|
4
|
+
export interface IMetadataObject {
|
|
5
|
+
name: string;
|
|
6
|
+
properties: IMetadataProperty[];
|
|
7
|
+
description?: string;
|
|
8
|
+
jsDocTags: IJsDocTagInfo[];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
index: number;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
validated: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
recursive: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
nullables: boolean[];
|
|
29
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
-
import { IMetadata } from "./IMetadata";
|
|
3
|
-
import { IMetadataTag } from "./IMetadataTag";
|
|
4
|
-
|
|
5
|
-
export interface IMetadataProperty {
|
|
6
|
-
key: IMetadata;
|
|
7
|
-
value: IMetadata;
|
|
8
|
-
description?: string;
|
|
9
|
-
tags: IMetadataTag[];
|
|
10
|
-
jsDocTags: IJsDocTagInfo[];
|
|
11
|
-
}
|
|
1
|
+
import { IJsDocTagInfo } from "./IJsDocTagInfo";
|
|
2
|
+
import { IMetadata } from "./IMetadata";
|
|
3
|
+
import { IMetadataTag } from "./IMetadataTag";
|
|
4
|
+
|
|
5
|
+
export interface IMetadataProperty {
|
|
6
|
+
key: IMetadata;
|
|
7
|
+
value: IMetadata;
|
|
8
|
+
description?: string;
|
|
9
|
+
tags: IMetadataTag[];
|
|
10
|
+
jsDocTags: IJsDocTagInfo[];
|
|
11
|
+
}
|
package/src/metadata/Metadata.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Atomic } from "../typings/Atomic";
|
|
2
2
|
import { ClassProperties } from "../typings/ClassProperties";
|
|
3
3
|
|
|
4
|
+
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
5
|
+
|
|
4
6
|
import { IMetadata } from "./IMetadata";
|
|
5
7
|
import { IMetadataObject } from "./IMetadataObject";
|
|
6
8
|
import { MetadataConstant } from "./MetadataConstant";
|
|
@@ -315,7 +317,9 @@ export namespace Metadata {
|
|
|
315
317
|
// TUPLES
|
|
316
318
|
for (const xt of x.tuples)
|
|
317
319
|
for (const yt of y.tuples)
|
|
318
|
-
if (
|
|
320
|
+
if (xt.length === 0 || yt.length === 0)
|
|
321
|
+
return xt.length === 0 && yt.length === 0;
|
|
322
|
+
else if (
|
|
319
323
|
xt
|
|
320
324
|
.slice(0, Math.min(xt.length, yt.length))
|
|
321
325
|
.some((xv, i) => intersects(xv, yt[i]!, deep))
|
|
@@ -371,6 +375,7 @@ export namespace Metadata {
|
|
|
371
375
|
// TUPLES
|
|
372
376
|
for (const yt of y.tuples)
|
|
373
377
|
if (
|
|
378
|
+
yt.length !== 0 &&
|
|
374
379
|
x.tuples.some(
|
|
375
380
|
(xt) =>
|
|
376
381
|
xt.length >= yt.length &&
|
|
@@ -414,6 +419,58 @@ export namespace Metadata {
|
|
|
414
419
|
// SUCCESS
|
|
415
420
|
return true;
|
|
416
421
|
}
|
|
422
|
+
|
|
423
|
+
export function merge(x: Metadata, y: Metadata): Metadata {
|
|
424
|
+
const output: Metadata = Metadata.create({
|
|
425
|
+
any: x.any || y.any,
|
|
426
|
+
nullable: x.nullable || y.nullable,
|
|
427
|
+
required: x.required && y.required,
|
|
428
|
+
functional: x.functional || y.functional,
|
|
429
|
+
|
|
430
|
+
resolved:
|
|
431
|
+
x.resolved !== null && y.resolved !== null
|
|
432
|
+
? merge(x.resolved, y.resolved)
|
|
433
|
+
: x.resolved || y.resolved,
|
|
434
|
+
atomics: [...new Set([...x.atomics, ...y.atomics])],
|
|
435
|
+
constants: [...x.constants],
|
|
436
|
+
templates: x.templates.slice(),
|
|
437
|
+
|
|
438
|
+
rest:
|
|
439
|
+
x.rest !== null && y.rest !== null
|
|
440
|
+
? merge(x.rest, y.rest)
|
|
441
|
+
: x.rest ?? y.rest,
|
|
442
|
+
arrays: x.arrays.slice(),
|
|
443
|
+
tuples: x.tuples.slice(),
|
|
444
|
+
objects: x.objects.slice(),
|
|
445
|
+
|
|
446
|
+
natives: [...new Set([...x.natives, ...y.natives])],
|
|
447
|
+
sets: x.sets.slice(),
|
|
448
|
+
maps: x.maps.slice(),
|
|
449
|
+
});
|
|
450
|
+
for (const constant of y.constants) {
|
|
451
|
+
const target: MetadataConstant = ArrayUtil.take(
|
|
452
|
+
output.constants,
|
|
453
|
+
(elem) => elem.type === constant.type,
|
|
454
|
+
() => ({
|
|
455
|
+
type: constant.type,
|
|
456
|
+
values: [],
|
|
457
|
+
}),
|
|
458
|
+
);
|
|
459
|
+
for (const value of constant.values)
|
|
460
|
+
ArrayUtil.add(target.values, value);
|
|
461
|
+
}
|
|
462
|
+
for (const array of y.arrays)
|
|
463
|
+
ArrayUtil.set(output.arrays, array, (elem) => elem.getName());
|
|
464
|
+
for (const obj of y.objects)
|
|
465
|
+
ArrayUtil.set(output.objects, obj, (elem) => elem.name);
|
|
466
|
+
|
|
467
|
+
if (x.rest !== null)
|
|
468
|
+
ArrayUtil.set(output.arrays, x.rest, (elem) => elem.getName());
|
|
469
|
+
if (y.rest !== null)
|
|
470
|
+
ArrayUtil.set(output.arrays, y.rest, (elem) => elem.getName());
|
|
471
|
+
|
|
472
|
+
return output;
|
|
473
|
+
}
|
|
417
474
|
}
|
|
418
475
|
|
|
419
476
|
function getName(metadata: Metadata): string {
|
|
@@ -447,6 +504,12 @@ function getName(metadata: Metadata): string {
|
|
|
447
504
|
"`",
|
|
448
505
|
);
|
|
449
506
|
|
|
507
|
+
// NATIVES
|
|
508
|
+
for (const native of metadata.natives) elements.push(native);
|
|
509
|
+
for (const set of metadata.sets) elements.push(`Set<${set.getName()}>`);
|
|
510
|
+
for (const map of metadata.maps)
|
|
511
|
+
elements.push(`Map<${map.key.getName()}, ${map.value.getName()}>`);
|
|
512
|
+
|
|
450
513
|
// ARRAY
|
|
451
514
|
if (metadata.rest !== null) elements.push(`...${metadata.rest.getName()}`);
|
|
452
515
|
for (const tuple of metadata.tuples)
|
|
@@ -458,12 +521,6 @@ function getName(metadata: Metadata): string {
|
|
|
458
521
|
for (const object of metadata.objects) elements.push(object.name);
|
|
459
522
|
if (metadata.resolved !== null) elements.push(metadata.resolved.getName());
|
|
460
523
|
|
|
461
|
-
// NATIVES
|
|
462
|
-
for (const native of metadata.natives) elements.push(native);
|
|
463
|
-
for (const set of metadata.sets) elements.push(`Set<${set.getName()}>`);
|
|
464
|
-
for (const map of metadata.maps)
|
|
465
|
-
elements.push(`Map<${map.key.getName()}, ${map.value.getName()}>`);
|
|
466
|
-
|
|
467
524
|
// RETURNS
|
|
468
525
|
if (elements.length === 0) return "unknown";
|
|
469
526
|
else if (elements.length === 1) return elements[0]!;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IMetadataConstant } from "./IMetadataConstant";
|
|
2
|
-
|
|
3
|
-
export import MetadataConstant = IMetadataConstant;
|
|
1
|
+
import { IMetadataConstant } from "./IMetadataConstant";
|
|
2
|
+
|
|
3
|
+
export import MetadataConstant = IMetadataConstant;
|