typia 5.1.2-dev.20230927 → 5.1.3-dev.20230927
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/MetadataTypeTagFactory.d.ts +2 -2
- package/lib/factories/MetadataTypeTagFactory.js +19 -11
- package/lib/factories/MetadataTypeTagFactory.js.map +1 -1
- package/lib/factories/internal/metadata/emend_metadata_atomics.js +4 -2
- package/lib/factories/internal/metadata/emend_metadata_atomics.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_intersection.js +70 -22
- package/lib/factories/internal/metadata/iterate_metadata_intersection.js.map +1 -1
- package/lib/programmers/internal/application_boolean.js +12 -1
- package/lib/programmers/internal/application_boolean.js.map +1 -1
- package/lib/programmers/internal/application_number.js +5 -2
- package/lib/programmers/internal/application_number.js.map +1 -1
- package/lib/programmers/internal/application_schema.js +7 -6
- package/lib/programmers/internal/application_schema.js.map +1 -1
- package/lib/programmers/internal/application_string.js +4 -1
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array_length.js +4 -1
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_bigint.js +4 -1
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_number.js +4 -1
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string.js +4 -1
- package/lib/programmers/internal/check_string.js.map +1 -1
- package/lib/schemas/json/IJsonSchema.d.ts +1 -0
- package/lib/schemas/metadata/IMetadataTypeTag.d.ts +2 -2
- package/lib/schemas/metadata/Metadata.js.map +1 -1
- package/lib/tags/Default.d.ts +7 -0
- package/lib/tags/Default.js +3 -0
- package/lib/tags/Default.js.map +1 -0
- package/lib/tags/Format.d.ts +1 -1
- package/lib/tags/Pattern.d.ts +1 -0
- package/lib/tags/TagBase.d.ts +2 -2
- package/lib/tags/index.d.ts +1 -0
- package/lib/tags/index.js +1 -0
- package/lib/tags/index.js.map +1 -1
- package/package.json +1 -1
- package/src/factories/MetadataTypeTagFactory.ts +24 -12
- package/src/factories/internal/metadata/emend_metadata_atomics.ts +3 -2
- package/src/factories/internal/metadata/iterate_metadata_intersection.ts +79 -17
- package/src/programmers/internal/application_boolean.ts +24 -9
- package/src/programmers/internal/application_number.ts +3 -1
- package/src/programmers/internal/application_schema.ts +11 -6
- package/src/programmers/internal/application_string.ts +4 -1
- package/src/programmers/internal/check_array_length.ts +11 -8
- package/src/programmers/internal/check_bigint.ts +11 -8
- package/src/programmers/internal/check_number.ts +43 -40
- package/src/programmers/internal/check_string.ts +11 -8
- package/src/schemas/json/IJsonSchema.ts +3 -1
- package/src/schemas/metadata/IMetadataConstant.ts +9 -0
- package/src/schemas/metadata/IMetadataTypeTag.ts +2 -2
- package/src/schemas/metadata/Metadata.ts +1 -0
- package/src/tags/Default.ts +15 -0
- package/src/tags/Format.ts +1 -1
- package/src/tags/Pattern.ts +1 -0
- package/src/tags/TagBase.ts +2 -2
- package/src/tags/index.ts +1 -0
|
@@ -80,13 +80,11 @@ export const application_schema =
|
|
|
80
80
|
for (const a of meta.atomics)
|
|
81
81
|
if (a.type === "bigint") throw new TypeError(NO_BIGINT);
|
|
82
82
|
else if (a.type === "boolean")
|
|
83
|
-
|
|
83
|
+
application_boolean(a)(attribute).forEach(insert);
|
|
84
84
|
else if (a.type === "number")
|
|
85
|
-
application_number(a)(attribute).forEach(
|
|
85
|
+
application_number(a)(attribute).forEach(insert);
|
|
86
86
|
else if (a.type === "string")
|
|
87
|
-
application_string(meta)(a)(attribute).forEach(
|
|
88
|
-
insert(s),
|
|
89
|
-
);
|
|
87
|
+
application_string(meta)(a)(attribute).forEach(insert);
|
|
90
88
|
|
|
91
89
|
// ARRAY
|
|
92
90
|
for (const array of meta.arrays)
|
|
@@ -105,7 +103,14 @@ export const application_schema =
|
|
|
105
103
|
if (meta.atomics.some((a) => a.type === type)) continue;
|
|
106
104
|
else if (type === "bigint") throw new TypeError(NO_BIGINT);
|
|
107
105
|
else if (type === "boolean")
|
|
108
|
-
insert(
|
|
106
|
+
insert(
|
|
107
|
+
application_boolean(
|
|
108
|
+
MetadataAtomic.create({
|
|
109
|
+
type: "boolean",
|
|
110
|
+
tags: [],
|
|
111
|
+
}),
|
|
112
|
+
)(attribute)[0]!,
|
|
113
|
+
);
|
|
109
114
|
else if (type === "number")
|
|
110
115
|
insert(
|
|
111
116
|
application_number(
|
|
@@ -18,7 +18,8 @@ export const application_string =
|
|
|
18
18
|
type: "string",
|
|
19
19
|
};
|
|
20
20
|
const out = (schema: IJsonSchema.IString) => {
|
|
21
|
-
schema.default
|
|
21
|
+
schema.default ??=
|
|
22
|
+
application_default_string(meta)(attribute)(base);
|
|
22
23
|
return schema;
|
|
23
24
|
};
|
|
24
25
|
if (atomic.tags.length === 0) return [out(base)];
|
|
@@ -46,6 +47,8 @@ const application_string_tags =
|
|
|
46
47
|
else if (tag.kind === "format" && typeof tag.value === "string")
|
|
47
48
|
base.format = tag.value;
|
|
48
49
|
else if (tag.kind === "pattern") base.pattern = tag.value;
|
|
50
|
+
else if (tag.kind === "default" && typeof tag.value === "string")
|
|
51
|
+
base.default = tag.value;
|
|
49
52
|
base["x-typia-typeTags"] = row;
|
|
50
53
|
return base;
|
|
51
54
|
};
|
|
@@ -31,11 +31,14 @@ const check_string_type_tags =
|
|
|
31
31
|
(project: IProject) =>
|
|
32
32
|
(matrix: IMetadataTypeTag[][]) =>
|
|
33
33
|
(input: ts.Expression): ICheckEntry.ICondition[][] =>
|
|
34
|
-
matrix
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
matrix
|
|
35
|
+
.map((row) => row.filter((tag) => !!tag.validate))
|
|
36
|
+
.filter((row) => !!row.length)
|
|
37
|
+
.map((row) =>
|
|
38
|
+
row.map((tag) => ({
|
|
39
|
+
expected: `Array<> & ${tag.name}`,
|
|
40
|
+
expression: ExpressionFactory.transpile(project.context)(
|
|
41
|
+
tag.validate!,
|
|
42
|
+
)(input),
|
|
43
|
+
})),
|
|
44
|
+
);
|
|
@@ -35,11 +35,14 @@ const check_bigint_type_tags =
|
|
|
35
35
|
(project: IProject) =>
|
|
36
36
|
(atomic: MetadataAtomic) =>
|
|
37
37
|
(input: ts.Expression): ICheckEntry.ICondition[][] =>
|
|
38
|
-
atomic.tags
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
atomic.tags
|
|
39
|
+
.map((row) => row.filter((tag) => !!tag.validate))
|
|
40
|
+
.filter((row) => !!row.length)
|
|
41
|
+
.map((row) =>
|
|
42
|
+
row.map((tag) => ({
|
|
43
|
+
expected: `bigint & ${tag.name}`,
|
|
44
|
+
expression: ExpressionFactory.transpile(project.context)(
|
|
45
|
+
tag.validate!,
|
|
46
|
+
)(input),
|
|
47
|
+
})),
|
|
48
|
+
);
|
|
@@ -60,46 +60,49 @@ const check_numeric_type_tags =
|
|
|
60
60
|
(atomic: MetadataAtomic) =>
|
|
61
61
|
(addition: ts.Expression | null) =>
|
|
62
62
|
(input: ts.Expression): ICheckEntry.ICondition[][] =>
|
|
63
|
-
atomic.tags
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
tag.
|
|
72
|
-
tag.value === "
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
typeof tag.value === "number",
|
|
79
|
-
) ||
|
|
80
|
-
(row.some(
|
|
81
|
-
(tag) =>
|
|
82
|
-
(tag.kind === "minimum" ||
|
|
83
|
-
tag.kind === "exclusiveMinimum") &&
|
|
84
|
-
typeof tag.value === "number",
|
|
85
|
-
) &&
|
|
63
|
+
atomic.tags
|
|
64
|
+
.map((row) => row.filter((tag) => !!tag.validate))
|
|
65
|
+
.filter((row) => !!row.length)
|
|
66
|
+
.map((row) => [
|
|
67
|
+
...(addition === null
|
|
68
|
+
? []
|
|
69
|
+
: row.some(
|
|
70
|
+
(tag) =>
|
|
71
|
+
tag.kind === "type" &&
|
|
72
|
+
(tag.value === "int32" ||
|
|
73
|
+
tag.value === "uint32" ||
|
|
74
|
+
tag.value === "int64" ||
|
|
75
|
+
tag.value === "uint64" ||
|
|
76
|
+
tag.value === "float"),
|
|
77
|
+
) ||
|
|
86
78
|
row.some(
|
|
87
79
|
(tag) =>
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
tag.kind === "multipleOf" &&
|
|
81
|
+
typeof tag.value === "number",
|
|
82
|
+
) ||
|
|
83
|
+
(row.some(
|
|
84
|
+
(tag) =>
|
|
85
|
+
(tag.kind === "minimum" ||
|
|
86
|
+
tag.kind === "exclusiveMinimum") &&
|
|
90
87
|
typeof tag.value === "number",
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
) &&
|
|
89
|
+
row.some(
|
|
90
|
+
(tag) =>
|
|
91
|
+
(tag.kind === "maximum" ||
|
|
92
|
+
tag.kind === "exclusiveMaximum") &&
|
|
93
|
+
typeof tag.value === "number",
|
|
94
|
+
))
|
|
95
|
+
? []
|
|
96
|
+
: [
|
|
97
|
+
{
|
|
98
|
+
expected: "number",
|
|
99
|
+
expression: addition!,
|
|
100
|
+
},
|
|
101
|
+
]),
|
|
102
|
+
...row.map((tag) => ({
|
|
103
|
+
expected: `number & ${tag.name}`,
|
|
104
|
+
expression: ExpressionFactory.transpile(project.context)(
|
|
105
|
+
tag.validate!,
|
|
106
|
+
)(input),
|
|
107
|
+
})),
|
|
108
|
+
]);
|
|
@@ -35,11 +35,14 @@ const check_string_type_tags =
|
|
|
35
35
|
(project: IProject) =>
|
|
36
36
|
(atomic: MetadataAtomic) =>
|
|
37
37
|
(input: ts.Expression): ICheckEntry.ICondition[][] =>
|
|
38
|
-
atomic.tags
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
atomic.tags
|
|
39
|
+
.map((row) => row.filter((tag) => !!tag.validate))
|
|
40
|
+
.filter((row) => !!row.length)
|
|
41
|
+
.map((row) =>
|
|
42
|
+
row.map((tag) => ({
|
|
43
|
+
expected: `string & ${tag.name}`,
|
|
44
|
+
expression: ExpressionFactory.transpile(project.context)(
|
|
45
|
+
tag.validate!,
|
|
46
|
+
)(input),
|
|
47
|
+
})),
|
|
48
|
+
);
|
|
@@ -60,7 +60,9 @@ export namespace IJsonSchema {
|
|
|
60
60
|
multipleOf?: number & Type<"int32">;
|
|
61
61
|
"x-typia-typeTags"?: IMetadataTypeTag[];
|
|
62
62
|
}
|
|
63
|
-
export interface IBoolean extends IAtomic<"boolean"> {
|
|
63
|
+
export interface IBoolean extends IAtomic<"boolean"> {
|
|
64
|
+
"x-typia-typeTags"?: IMetadataTypeTag[];
|
|
65
|
+
}
|
|
64
66
|
|
|
65
67
|
/* -----------------------------------------------------------
|
|
66
68
|
OBJECTS
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Atomic } from "../../typings/Atomic";
|
|
2
2
|
|
|
3
|
+
import { IMetadataTypeTag } from "./IMetadataTypeTag";
|
|
4
|
+
|
|
3
5
|
export type IMetadataConstant =
|
|
4
6
|
| IMetadataConstant.IBase<"boolean", boolean>
|
|
5
7
|
| IMetadataConstant.IBase<"number", number>
|
|
@@ -12,5 +14,12 @@ export namespace IMetadataConstant {
|
|
|
12
14
|
> {
|
|
13
15
|
type: Type;
|
|
14
16
|
values: Value[];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
tags?: Type extends "boolean"
|
|
22
|
+
? IMetadataTypeTag[][] | undefined
|
|
23
|
+
: never;
|
|
15
24
|
}
|
|
16
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface IMetadataTypeTag {
|
|
2
|
-
target: "bigint" | "number" | "string" | "array";
|
|
2
|
+
target: "boolean" | "bigint" | "number" | "string" | "array";
|
|
3
3
|
name: string;
|
|
4
4
|
kind: string;
|
|
5
5
|
value: any;
|
|
6
|
-
validate: string;
|
|
6
|
+
validate: string | undefined;
|
|
7
7
|
exclusive: boolean | string[];
|
|
8
8
|
}
|
|
@@ -44,6 +44,7 @@ export class Metadata {
|
|
|
44
44
|
/** @internal */ private parent_resolved_: boolean = false;
|
|
45
45
|
/** @internal */ public union_index?: number;
|
|
46
46
|
/** @internal */ public fixed_?: number | null;
|
|
47
|
+
/** @internal */ public boolean_literal_intersected_?: boolean;
|
|
47
48
|
|
|
48
49
|
/* -----------------------------------------------------------
|
|
49
50
|
CONSTRUCTORS
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TagBase } from "./TagBase";
|
|
2
|
+
|
|
3
|
+
export type Default<Value extends boolean | bigint | number | string> =
|
|
4
|
+
TagBase<{
|
|
5
|
+
target: Value extends boolean
|
|
6
|
+
? "boolean"
|
|
7
|
+
: Value extends bigint
|
|
8
|
+
? "bigint"
|
|
9
|
+
: Value extends number
|
|
10
|
+
? "number"
|
|
11
|
+
: "string";
|
|
12
|
+
kind: "default";
|
|
13
|
+
value: Value;
|
|
14
|
+
exclusive: true;
|
|
15
|
+
}>;
|
package/src/tags/Format.ts
CHANGED
package/src/tags/Pattern.ts
CHANGED
package/src/tags/TagBase.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type TagBase<Props extends TagBase.IProps<any, any, any, any, any>> = {
|
|
|
8
8
|
};
|
|
9
9
|
export namespace TagBase {
|
|
10
10
|
export interface IProps<
|
|
11
|
-
Target extends "bigint" | "number" | "string" | "array",
|
|
11
|
+
Target extends "boolean" | "bigint" | "number" | "string" | "array",
|
|
12
12
|
Kind extends string,
|
|
13
13
|
Value extends boolean | bigint | number | string | undefined,
|
|
14
14
|
Validate extends
|
|
@@ -51,7 +51,7 @@ export namespace TagBase {
|
|
|
51
51
|
* occured. So, define it with confidence. Compiler will block all your
|
|
52
52
|
* mistakes.
|
|
53
53
|
*/
|
|
54
|
-
validate
|
|
54
|
+
validate?: Validate;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Exclusive option.
|
package/src/tags/index.ts
CHANGED