typia 5.2.5 → 5.2.6
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.d.ts +1 -0
- package/lib/factories/ExpressionFactory.js +5 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.js +4 -4
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.js +16 -18
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.js +2 -1
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/helpers/RandomJoiner.js +4 -6
- package/lib/programmers/helpers/RandomJoiner.js.map +1 -1
- package/lib/programmers/helpers/RandomRanger.js +3 -2
- package/lib/programmers/helpers/RandomRanger.js.map +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js +1 -1
- package/lib/programmers/http/HttpHeadersProgrammer.js.map +1 -1
- package/lib/programmers/internal/check_dynamic_properties.js +4 -3
- package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
- package/lib/programmers/internal/check_union_array_like.js +3 -2
- package/lib/programmers/internal/check_union_array_like.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.js +1 -3
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/misc/MiscCloneProgrammer.js +1 -3
- 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 +1 -3
- package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
- package/lib/programmers/notations/NotationGeneralProgrammer.js +1 -3
- package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js +6 -6
- package/lib/programmers/protobuf/ProtobufDecodeProgrammer.js.map +1 -1
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js +2 -2
- package/lib/programmers/protobuf/ProtobufEncodeProgrammer.js.map +1 -1
- package/package.json +1 -1
- 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 +8 -0
- package/src/factories/JsonMetadataFactory.ts +50 -50
- package/src/factories/MetadataCollection.ts +282 -282
- package/src/factories/internal/metadata/emplace_metadata_object.ts +178 -178
- package/src/functional/$stoll.ts +8 -8
- package/src/functional/Namespace.ts +168 -168
- package/src/programmers/AssertProgrammer.ts +322 -322
- package/src/programmers/CheckerProgrammer.ts +4 -4
- package/src/programmers/IsProgrammer.ts +258 -258
- package/src/programmers/RandomProgrammer.ts +16 -17
- package/src/programmers/ValidateProgrammer.ts +350 -349
- package/src/programmers/helpers/AtomicPredicator.ts +31 -31
- package/src/programmers/helpers/RandomJoiner.ts +4 -6
- package/src/programmers/helpers/RandomRanger.ts +4 -2
- package/src/programmers/http/HttpHeadersProgrammer.ts +1 -1
- package/src/programmers/internal/check_dynamic_key.ts +178 -178
- package/src/programmers/internal/check_dynamic_properties.ts +202 -201
- package/src/programmers/internal/check_object.ts +62 -62
- package/src/programmers/internal/check_union_array_like.ts +4 -3
- package/src/programmers/json/JsonStringifyProgrammer.ts +960 -964
- package/src/programmers/misc/MiscCloneProgrammer.ts +786 -790
- package/src/programmers/misc/MiscLiteralsProgrammer.ts +1 -1
- package/src/programmers/misc/MiscPruneProgrammer.ts +548 -552
- package/src/programmers/notations/NotationGeneralProgrammer.ts +716 -720
- package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +7 -9
- package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +882 -882
- package/src/transform.ts +35 -35
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
import { NamingConvention } from "../utils/NamingConvention";
|
|
2
|
-
import { RandomGenerator } from "../utils/RandomGenerator";
|
|
3
|
-
|
|
4
|
-
import { IValidation } from "../IValidation";
|
|
5
|
-
import { TypeGuardError } from "../TypeGuardError";
|
|
6
|
-
import { $HeadersReader } from "./$HeadersReader";
|
|
7
|
-
import { $ParameterReader } from "./$ParameterReader";
|
|
8
|
-
import { $ProtobufReader } from "./$ProtobufReader";
|
|
9
|
-
import { $ProtobufSizer } from "./$ProtobufSizer";
|
|
10
|
-
import { $ProtobufWriter } from "./$ProtobufWriter";
|
|
11
|
-
import { $QueryReader } from "./$QueryReader";
|
|
12
|
-
import { $any } from "./$any";
|
|
13
|
-
import { $convention } from "./$convention";
|
|
14
|
-
import { $every } from "./$every";
|
|
15
|
-
import { $guard } from "./$guard";
|
|
16
|
-
import { $is_between } from "./$is_between";
|
|
17
|
-
import { $join } from "./$join";
|
|
18
|
-
import { $number } from "./$number";
|
|
19
|
-
import { $report } from "./$report";
|
|
20
|
-
import { $rest } from "./$rest";
|
|
21
|
-
import { $is_bigint_string } from "./$stoll";
|
|
22
|
-
import { $string } from "./$string";
|
|
23
|
-
import { $strlen } from "./$strlen";
|
|
24
|
-
import { $tail } from "./$tail";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export namespace Namespace {
|
|
30
|
-
export const is = () => ({
|
|
31
|
-
is_between: $is_between,
|
|
32
|
-
is_bigint_string: $is_bigint_string,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
export const assert = (method: string) => ({
|
|
36
|
-
...is(),
|
|
37
|
-
join: $join,
|
|
38
|
-
every: $every,
|
|
39
|
-
guard: $guard(`typia.${method}`),
|
|
40
|
-
predicate: (
|
|
41
|
-
matched: boolean,
|
|
42
|
-
exceptionable: boolean,
|
|
43
|
-
closure: () => Omit<TypeGuardError.IProps, "method">,
|
|
44
|
-
): boolean => {
|
|
45
|
-
if (matched === false && exceptionable === true)
|
|
46
|
-
throw new TypeGuardError({
|
|
47
|
-
...closure(),
|
|
48
|
-
method: `typia.${method}`,
|
|
49
|
-
});
|
|
50
|
-
return matched;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export const validate = () => ({
|
|
55
|
-
...is(),
|
|
56
|
-
join: $join,
|
|
57
|
-
report: $report,
|
|
58
|
-
predicate:
|
|
59
|
-
(res: IValidation) =>
|
|
60
|
-
(
|
|
61
|
-
matched: boolean,
|
|
62
|
-
exceptionable: boolean,
|
|
63
|
-
closure: () => IValidation.IError,
|
|
64
|
-
) => {
|
|
65
|
-
// CHECK FAILURE
|
|
66
|
-
if (matched === false && exceptionable === true)
|
|
67
|
-
(() => {
|
|
68
|
-
res.success &&= false;
|
|
69
|
-
const errorList = (res as IValidation.IFailure).errors;
|
|
70
|
-
|
|
71
|
-
// TRACE ERROR
|
|
72
|
-
const error = closure();
|
|
73
|
-
if (errorList.length) {
|
|
74
|
-
const last = errorList[errorList.length - 1]!.path;
|
|
75
|
-
if (
|
|
76
|
-
last.length >= error.path.length &&
|
|
77
|
-
last.substring(0, error.path.length) ===
|
|
78
|
-
error.path
|
|
79
|
-
)
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
errorList.push(error);
|
|
83
|
-
return;
|
|
84
|
-
})();
|
|
85
|
-
return matched;
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export namespace json {
|
|
90
|
-
export const stringify = (method: string) => ({
|
|
91
|
-
...is(),
|
|
92
|
-
number: $number,
|
|
93
|
-
string: $string,
|
|
94
|
-
tail: $tail,
|
|
95
|
-
rest: $rest,
|
|
96
|
-
throws: $throws(`json.${method}`),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export namespace protobuf {
|
|
101
|
-
export const decode = (method: string) => ({
|
|
102
|
-
...is(),
|
|
103
|
-
Reader: $ProtobufReader,
|
|
104
|
-
throws: $throws(`protobuf.${method}`),
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
export const encode = (method: string) => ({
|
|
108
|
-
...is(),
|
|
109
|
-
Sizer: $ProtobufSizer,
|
|
110
|
-
Writer: $ProtobufWriter,
|
|
111
|
-
strlen: $strlen,
|
|
112
|
-
throws: $throws(method),
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export namespace http {
|
|
117
|
-
export const query = () => $QueryReader;
|
|
118
|
-
export const headers = () => $HeadersReader;
|
|
119
|
-
export const parameter = () => $ParameterReader;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export namespace misc {
|
|
123
|
-
export const clone = (method: string) => ({
|
|
124
|
-
...is(),
|
|
125
|
-
throws: $throws(`misc.${method}`),
|
|
126
|
-
any: $any,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
export const prune = (method: string) => ({
|
|
130
|
-
...is(),
|
|
131
|
-
throws: $throws(`misc.${method}`),
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export namespace notations {
|
|
136
|
-
export const camel = (method: string) => ({
|
|
137
|
-
...base(method),
|
|
138
|
-
any: $convention(NamingConvention.camel),
|
|
139
|
-
});
|
|
140
|
-
export const pascal = (method: string) => ({
|
|
141
|
-
...base(method),
|
|
142
|
-
any: $convention(NamingConvention.pascal),
|
|
143
|
-
});
|
|
144
|
-
export const snake = (method: string) => ({
|
|
145
|
-
...base(method),
|
|
146
|
-
any: $convention(NamingConvention.snake),
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const base = (method: string) => ({
|
|
150
|
-
...is(),
|
|
151
|
-
throws: $throws(`notations.${method}`),
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export const random = () => ({
|
|
156
|
-
generator: RandomGenerator,
|
|
157
|
-
pick: RandomGenerator.pick,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const $throws =
|
|
161
|
-
(method: string) =>
|
|
162
|
-
(props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
|
|
163
|
-
throw new TypeGuardError({
|
|
164
|
-
...props,
|
|
165
|
-
method: `typia.${method}`,
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
}
|
|
1
|
+
import { NamingConvention } from "../utils/NamingConvention";
|
|
2
|
+
import { RandomGenerator } from "../utils/RandomGenerator";
|
|
3
|
+
|
|
4
|
+
import { IValidation } from "../IValidation";
|
|
5
|
+
import { TypeGuardError } from "../TypeGuardError";
|
|
6
|
+
import { $HeadersReader } from "./$HeadersReader";
|
|
7
|
+
import { $ParameterReader } from "./$ParameterReader";
|
|
8
|
+
import { $ProtobufReader } from "./$ProtobufReader";
|
|
9
|
+
import { $ProtobufSizer } from "./$ProtobufSizer";
|
|
10
|
+
import { $ProtobufWriter } from "./$ProtobufWriter";
|
|
11
|
+
import { $QueryReader } from "./$QueryReader";
|
|
12
|
+
import { $any } from "./$any";
|
|
13
|
+
import { $convention } from "./$convention";
|
|
14
|
+
import { $every } from "./$every";
|
|
15
|
+
import { $guard } from "./$guard";
|
|
16
|
+
import { $is_between } from "./$is_between";
|
|
17
|
+
import { $join } from "./$join";
|
|
18
|
+
import { $number } from "./$number";
|
|
19
|
+
import { $report } from "./$report";
|
|
20
|
+
import { $rest } from "./$rest";
|
|
21
|
+
import { $is_bigint_string } from "./$stoll";
|
|
22
|
+
import { $string } from "./$string";
|
|
23
|
+
import { $strlen } from "./$strlen";
|
|
24
|
+
import { $tail } from "./$tail";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export namespace Namespace {
|
|
30
|
+
export const is = () => ({
|
|
31
|
+
is_between: $is_between,
|
|
32
|
+
is_bigint_string: $is_bigint_string,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const assert = (method: string) => ({
|
|
36
|
+
...is(),
|
|
37
|
+
join: $join,
|
|
38
|
+
every: $every,
|
|
39
|
+
guard: $guard(`typia.${method}`),
|
|
40
|
+
predicate: (
|
|
41
|
+
matched: boolean,
|
|
42
|
+
exceptionable: boolean,
|
|
43
|
+
closure: () => Omit<TypeGuardError.IProps, "method">,
|
|
44
|
+
): boolean => {
|
|
45
|
+
if (matched === false && exceptionable === true)
|
|
46
|
+
throw new TypeGuardError({
|
|
47
|
+
...closure(),
|
|
48
|
+
method: `typia.${method}`,
|
|
49
|
+
});
|
|
50
|
+
return matched;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const validate = () => ({
|
|
55
|
+
...is(),
|
|
56
|
+
join: $join,
|
|
57
|
+
report: $report,
|
|
58
|
+
predicate:
|
|
59
|
+
(res: IValidation) =>
|
|
60
|
+
(
|
|
61
|
+
matched: boolean,
|
|
62
|
+
exceptionable: boolean,
|
|
63
|
+
closure: () => IValidation.IError,
|
|
64
|
+
) => {
|
|
65
|
+
// CHECK FAILURE
|
|
66
|
+
if (matched === false && exceptionable === true)
|
|
67
|
+
(() => {
|
|
68
|
+
res.success &&= false;
|
|
69
|
+
const errorList = (res as IValidation.IFailure).errors;
|
|
70
|
+
|
|
71
|
+
// TRACE ERROR
|
|
72
|
+
const error = closure();
|
|
73
|
+
if (errorList.length) {
|
|
74
|
+
const last = errorList[errorList.length - 1]!.path;
|
|
75
|
+
if (
|
|
76
|
+
last.length >= error.path.length &&
|
|
77
|
+
last.substring(0, error.path.length) ===
|
|
78
|
+
error.path
|
|
79
|
+
)
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
errorList.push(error);
|
|
83
|
+
return;
|
|
84
|
+
})();
|
|
85
|
+
return matched;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export namespace json {
|
|
90
|
+
export const stringify = (method: string) => ({
|
|
91
|
+
...is(),
|
|
92
|
+
number: $number,
|
|
93
|
+
string: $string,
|
|
94
|
+
tail: $tail,
|
|
95
|
+
rest: $rest,
|
|
96
|
+
throws: $throws(`json.${method}`),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export namespace protobuf {
|
|
101
|
+
export const decode = (method: string) => ({
|
|
102
|
+
...is(),
|
|
103
|
+
Reader: $ProtobufReader,
|
|
104
|
+
throws: $throws(`protobuf.${method}`),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export const encode = (method: string) => ({
|
|
108
|
+
...is(),
|
|
109
|
+
Sizer: $ProtobufSizer,
|
|
110
|
+
Writer: $ProtobufWriter,
|
|
111
|
+
strlen: $strlen,
|
|
112
|
+
throws: $throws(method),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export namespace http {
|
|
117
|
+
export const query = () => $QueryReader;
|
|
118
|
+
export const headers = () => $HeadersReader;
|
|
119
|
+
export const parameter = () => $ParameterReader;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export namespace misc {
|
|
123
|
+
export const clone = (method: string) => ({
|
|
124
|
+
...is(),
|
|
125
|
+
throws: $throws(`misc.${method}`),
|
|
126
|
+
any: $any,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export const prune = (method: string) => ({
|
|
130
|
+
...is(),
|
|
131
|
+
throws: $throws(`misc.${method}`),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export namespace notations {
|
|
136
|
+
export const camel = (method: string) => ({
|
|
137
|
+
...base(method),
|
|
138
|
+
any: $convention(NamingConvention.camel),
|
|
139
|
+
});
|
|
140
|
+
export const pascal = (method: string) => ({
|
|
141
|
+
...base(method),
|
|
142
|
+
any: $convention(NamingConvention.pascal),
|
|
143
|
+
});
|
|
144
|
+
export const snake = (method: string) => ({
|
|
145
|
+
...base(method),
|
|
146
|
+
any: $convention(NamingConvention.snake),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
const base = (method: string) => ({
|
|
150
|
+
...is(),
|
|
151
|
+
throws: $throws(`notations.${method}`),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const random = () => ({
|
|
156
|
+
generator: RandomGenerator,
|
|
157
|
+
pick: RandomGenerator.pick,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const $throws =
|
|
161
|
+
(method: string) =>
|
|
162
|
+
(props: Pick<TypeGuardError.IProps, "expected" | "value">) => {
|
|
163
|
+
throw new TypeGuardError({
|
|
164
|
+
...props,
|
|
165
|
+
method: `typia.${method}`,
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
}
|