typia 9.6.1 → 9.7.0
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/CamelCase.d.mts +1 -1
- package/lib/CamelCase.d.ts +1 -1
- package/lib/IRandomGenerator.d.mts +240 -0
- package/lib/IRandomGenerator.d.ts +240 -0
- package/lib/PascalCase.d.mts +1 -1
- package/lib/PascalCase.d.ts +1 -1
- package/lib/Primitive.d.mts +8 -8
- package/lib/Primitive.d.ts +8 -8
- package/lib/Resolved.d.mts +9 -9
- package/lib/Resolved.d.ts +9 -9
- package/lib/SnakeCase.d.mts +1 -1
- package/lib/SnakeCase.d.ts +1 -1
- package/lib/factories/TypeFactory.d.mts +1 -0
- package/lib/factories/TypeFactory.d.ts +1 -0
- package/lib/factories/TypeFactory.js +1 -1
- package/lib/factories/TypeFactory.js.map +1 -1
- package/lib/factories/TypeFactory.mjs +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_map.js +2 -3
- package/lib/factories/internal/metadata/iterate_metadata_map.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_map.mjs +2 -3
- package/lib/factories/internal/metadata/iterate_metadata_set.js +2 -3
- package/lib/factories/internal/metadata/iterate_metadata_set.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_set.mjs +2 -3
- package/lib/functional.js +1 -1
- package/lib/functional.js.map +1 -1
- package/lib/functional.mjs +1 -1
- package/lib/http.d.mts +23 -23
- package/lib/http.d.ts +23 -23
- package/lib/internal/_llmApplicationFinalize.d.mts +1 -1
- package/lib/internal/_llmApplicationFinalize.d.ts +1 -1
- package/lib/internal/_llmApplicationFinalize.js +14 -11
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +13 -9
- package/lib/json.d.mts +16 -16
- package/lib/json.d.ts +16 -16
- package/lib/llm.d.mts +18 -18
- package/lib/llm.d.ts +18 -18
- package/lib/llm.js.map +1 -1
- package/lib/misc.d.mts +23 -23
- package/lib/misc.d.ts +23 -23
- package/lib/module.d.mts +75 -75
- package/lib/module.d.ts +75 -75
- package/lib/module.js.map +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.js +8 -9
- package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
- package/lib/transformers/features/llm/LlmApplicationTransformer.mjs +8 -9
- package/package.json +2 -2
- package/src/CamelCase.ts +1 -1
- package/src/IRandomGenerator.ts +284 -6
- package/src/PascalCase.ts +1 -1
- package/src/Primitive.ts +8 -8
- package/src/Resolved.ts +9 -9
- package/src/SnakeCase.ts +1 -1
- package/src/factories/TypeFactory.ts +5 -3
- package/src/factories/internal/metadata/iterate_metadata_map.ts +3 -3
- package/src/factories/internal/metadata/iterate_metadata_set.ts +2 -3
- package/src/functional.ts +1 -1
- package/src/http.ts +23 -23
- package/src/internal/_llmApplicationFinalize.ts +25 -11
- package/src/json.ts +16 -16
- package/src/llm.ts +26 -18
- package/src/misc.ts +23 -23
- package/src/module.ts +76 -75
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +18 -22
package/src/IRandomGenerator.ts
CHANGED
|
@@ -1,49 +1,327 @@
|
|
|
1
1
|
import { OpenApi } from "@samchon/openapi";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Interface for generating random values for various data types.
|
|
5
|
+
*
|
|
6
|
+
* `IRandomGenerator` defines the contract for generating random values
|
|
7
|
+
* that can be used by typia for creating mock data, testing scenarios,
|
|
8
|
+
* and random value generation based on JSON schema constraints.
|
|
9
|
+
*
|
|
10
|
+
* This interface supports generating random values for:
|
|
11
|
+
* - Basic types (boolean, number, integer, bigint, string, array)
|
|
12
|
+
* - String format patterns (email, URL, UUID, etc.)
|
|
13
|
+
* - Date and time formats
|
|
14
|
+
* - Various address and identifier formats
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const generator: IRandomGenerator = {
|
|
19
|
+
* boolean: () => Math.random() > 0.5,
|
|
20
|
+
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
21
|
+
* string: (schema) => "example-string",
|
|
22
|
+
* email: () => "test@example.com",
|
|
23
|
+
* // ... implement other methods
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
28
|
+
*/
|
|
3
29
|
export interface IRandomGenerator {
|
|
4
|
-
// REGULAR
|
|
30
|
+
// REGULAR DATA TYPES
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generates a random boolean value.
|
|
34
|
+
*
|
|
35
|
+
* @returns Random boolean value or undefined
|
|
36
|
+
*/
|
|
5
37
|
boolean(): boolean | undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Generates a random number based on JSON schema constraints.
|
|
41
|
+
*
|
|
42
|
+
* @param schema JSON schema with number constraints (min, max, etc.)
|
|
43
|
+
* @returns Random number within the specified constraints
|
|
44
|
+
*/
|
|
6
45
|
number(schema: OpenApi.IJsonSchema.INumber): number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generates a random integer based on JSON schema constraints.
|
|
49
|
+
*
|
|
50
|
+
* @param schema JSON schema with integer constraints (min, max, etc.)
|
|
51
|
+
* @returns Random integer within the specified constraints
|
|
52
|
+
*/
|
|
7
53
|
integer(schema: OpenApi.IJsonSchema.IInteger): number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Generates a random bigint based on JSON schema constraints.
|
|
57
|
+
*
|
|
58
|
+
* @param schema JSON schema with integer constraints (min, max, etc.)
|
|
59
|
+
* @returns Random bigint within the specified constraints
|
|
60
|
+
*/
|
|
8
61
|
bigint(schema: OpenApi.IJsonSchema.IInteger): bigint;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Generates a random string based on JSON schema constraints.
|
|
65
|
+
*
|
|
66
|
+
* @param schema JSON schema with string constraints (minLength, maxLength, pattern, etc.)
|
|
67
|
+
* @returns Random string matching the specified constraints
|
|
68
|
+
*/
|
|
9
69
|
string(schema: OpenApi.IJsonSchema.IString): string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Generates a random array with elements created by the provided generator function.
|
|
73
|
+
*
|
|
74
|
+
* @param schema Array schema with element generator function
|
|
75
|
+
* @returns Random array with generated elements
|
|
76
|
+
*/
|
|
10
77
|
array<T>(
|
|
11
78
|
schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
12
79
|
element: (index: number, count: number) => T;
|
|
13
80
|
},
|
|
14
81
|
): T[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generates a random string matching the given regular expression pattern.
|
|
85
|
+
*
|
|
86
|
+
* @param regex Regular expression pattern to match
|
|
87
|
+
* @returns Random string matching the pattern
|
|
88
|
+
*/
|
|
15
89
|
pattern(regex: RegExp): string;
|
|
16
90
|
|
|
17
91
|
//----
|
|
18
|
-
//
|
|
92
|
+
// STRING FORMATS
|
|
19
93
|
//----
|
|
20
|
-
|
|
94
|
+
|
|
95
|
+
// SPECIAL CHARACTER FORMATS
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generates a random base64-encoded byte string.
|
|
99
|
+
*
|
|
100
|
+
* @returns Random base64 string
|
|
101
|
+
*/
|
|
21
102
|
byte(): string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Generates a random password string.
|
|
106
|
+
*
|
|
107
|
+
* @returns Random password
|
|
108
|
+
*/
|
|
22
109
|
password(): string;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Generates a random regular expression pattern string.
|
|
113
|
+
*
|
|
114
|
+
* @returns Random regex pattern
|
|
115
|
+
*/
|
|
23
116
|
regex(): string;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Generates a random UUID (Universally Unique Identifier).
|
|
120
|
+
*
|
|
121
|
+
* @returns Random UUID string in standard format
|
|
122
|
+
*/
|
|
24
123
|
uuid(): string;
|
|
25
124
|
|
|
26
|
-
//
|
|
125
|
+
// ADDRESS AND IDENTIFIER FORMATS
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Generates a random email address.
|
|
129
|
+
*
|
|
130
|
+
* @returns Random email address
|
|
131
|
+
*/
|
|
27
132
|
email(): string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Generates a random hostname.
|
|
136
|
+
*
|
|
137
|
+
* @returns Random hostname
|
|
138
|
+
*/
|
|
28
139
|
hostname(): string;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Generates a random internationalized email address.
|
|
143
|
+
*
|
|
144
|
+
* @returns Random IDN email address
|
|
145
|
+
*/
|
|
29
146
|
idnEmail(): string;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Generates a random internationalized hostname.
|
|
150
|
+
*
|
|
151
|
+
* @returns Random IDN hostname
|
|
152
|
+
*/
|
|
30
153
|
idnHostname(): string;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Generates a random IRI (Internationalized Resource Identifier).
|
|
157
|
+
*
|
|
158
|
+
* @returns Random IRI
|
|
159
|
+
*/
|
|
31
160
|
iri(): string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Generates a random IRI reference.
|
|
164
|
+
*
|
|
165
|
+
* @returns Random IRI reference
|
|
166
|
+
*/
|
|
32
167
|
iriReference(): string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Generates a random IPv4 address.
|
|
171
|
+
*
|
|
172
|
+
* @returns Random IPv4 address
|
|
173
|
+
*/
|
|
33
174
|
ipv4(): string;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Generates a random IPv6 address.
|
|
178
|
+
*
|
|
179
|
+
* @returns Random IPv6 address
|
|
180
|
+
*/
|
|
34
181
|
ipv6(): string;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Generates a random URI (Uniform Resource Identifier).
|
|
185
|
+
*
|
|
186
|
+
* @returns Random URI
|
|
187
|
+
*/
|
|
35
188
|
uri(): string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Generates a random URI reference.
|
|
192
|
+
*
|
|
193
|
+
* @returns Random URI reference
|
|
194
|
+
*/
|
|
36
195
|
uriReference(): string;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Generates a random URI template.
|
|
199
|
+
*
|
|
200
|
+
* @returns Random URI template
|
|
201
|
+
*/
|
|
37
202
|
uriTemplate(): string;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Generates a random URL (Uniform Resource Locator).
|
|
206
|
+
*
|
|
207
|
+
* @returns Random URL
|
|
208
|
+
*/
|
|
38
209
|
url(): string;
|
|
39
210
|
|
|
40
|
-
//
|
|
211
|
+
// DATE AND TIME FORMATS
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Generates a random datetime string in ISO 8601 format.
|
|
215
|
+
*
|
|
216
|
+
* @param props Optional constraints for minimum and maximum timestamp values
|
|
217
|
+
* @returns Random datetime string
|
|
218
|
+
*/
|
|
41
219
|
datetime(props?: { minimum?: number; maximum?: number }): string;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Generates a random date string in ISO 8601 format (YYYY-MM-DD).
|
|
223
|
+
*
|
|
224
|
+
* @param props Optional constraints for minimum and maximum timestamp values
|
|
225
|
+
* @returns Random date string
|
|
226
|
+
*/
|
|
42
227
|
date(props?: { minimum?: number; maximum?: number }): string;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Generates a random time string in ISO 8601 format (HH:MM:SS).
|
|
231
|
+
*
|
|
232
|
+
* @returns Random time string
|
|
233
|
+
*/
|
|
43
234
|
time(): string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Generates a random duration string in ISO 8601 format.
|
|
238
|
+
*
|
|
239
|
+
* @returns Random duration string
|
|
240
|
+
*/
|
|
44
241
|
duration(): string;
|
|
45
242
|
|
|
46
|
-
//
|
|
243
|
+
// JSON POINTER FORMATS
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Generates a random JSON pointer string.
|
|
247
|
+
*
|
|
248
|
+
* @returns Random JSON pointer
|
|
249
|
+
*/
|
|
47
250
|
jsonPointer(): string;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Generates a random relative JSON pointer string.
|
|
254
|
+
*
|
|
255
|
+
* @returns Random relative JSON pointer
|
|
256
|
+
*/
|
|
48
257
|
relativeJsonPointer(): string;
|
|
49
258
|
}
|
|
259
|
+
|
|
260
|
+
export namespace IRandomGenerator {
|
|
261
|
+
/**
|
|
262
|
+
* Map of custom generators for different data types.
|
|
263
|
+
*
|
|
264
|
+
* This interface allows customization of random generation for specific
|
|
265
|
+
* types when they have certain schema properties or constraints.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```typescript
|
|
269
|
+
* const generator: Partial<IRandomGenerator> = {
|
|
270
|
+
* string: (schema) => {
|
|
271
|
+
* if ((schema as any)["x-typia-monetary"] === "dollar") {
|
|
272
|
+
* return "$" + Math.floor(Math.random() * 1000);
|
|
273
|
+
* }
|
|
274
|
+
* return "default-string";
|
|
275
|
+
* },
|
|
276
|
+
* number: (schema) => {
|
|
277
|
+
* if ((schema as any)["x-typia-powerOf"] !== undefined) {
|
|
278
|
+
* const powerOf = (schema as any)["x-typia-powerOf"];
|
|
279
|
+
* return Math.pow(powerOf, Math.random() * 10 + 1);
|
|
280
|
+
* }
|
|
281
|
+
* return Math.random() * 100;
|
|
282
|
+
* }
|
|
283
|
+
* };
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export interface CustomMap {
|
|
287
|
+
/**
|
|
288
|
+
* Custom string generator that can handle special string formats
|
|
289
|
+
* based on schema properties.
|
|
290
|
+
*/
|
|
291
|
+
string?: (schema: OpenApi.IJsonSchema.IString & Record<string, any>) => string;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Custom number generator that can handle special number constraints
|
|
295
|
+
* based on schema properties.
|
|
296
|
+
*/
|
|
297
|
+
number?: (schema: OpenApi.IJsonSchema.INumber & Record<string, any>) => number;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Custom integer generator that can handle special integer constraints
|
|
301
|
+
* based on schema properties.
|
|
302
|
+
*/
|
|
303
|
+
integer?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => number;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Custom bigint generator that can handle special bigint constraints
|
|
307
|
+
* based on schema properties.
|
|
308
|
+
*/
|
|
309
|
+
bigint?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => bigint;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Custom boolean generator that can handle special boolean constraints
|
|
313
|
+
* based on schema properties.
|
|
314
|
+
*/
|
|
315
|
+
boolean?: (schema: Record<string, any>) => boolean | undefined;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Custom array generator that can handle special array constraints
|
|
319
|
+
* based on schema properties.
|
|
320
|
+
*/
|
|
321
|
+
array?: <T>(
|
|
322
|
+
schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
323
|
+
element: (index: number, count: number) => T;
|
|
324
|
+
} & Record<string, any>
|
|
325
|
+
) => T[];
|
|
326
|
+
}
|
|
327
|
+
}
|
package/src/PascalCase.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
8
8
|
*
|
|
9
9
|
* `PascalCase` type is a type that all keys of an object are pascalized.
|
|
10
10
|
*
|
|
11
|
-
* It also
|
|
11
|
+
* It also erases every method property like {@link Resolved} type.
|
|
12
12
|
*
|
|
13
13
|
* @template T Target type to be pascalized
|
|
14
14
|
* @author Jeongho Nam - https://github.com/samchon
|
package/src/Primitive.ts
CHANGED
|
@@ -9,19 +9,19 @@ import { Format } from "./tags";
|
|
|
9
9
|
* Primitive type of JSON.
|
|
10
10
|
*
|
|
11
11
|
* `Primitive<T>` is a TMP (Type Meta Programming) type which converts
|
|
12
|
-
* its argument as a primitive type within framework JSON.
|
|
12
|
+
* its argument as a primitive type within the framework JSON.
|
|
13
13
|
*
|
|
14
14
|
* If the target argument is a built-in class which returns its origin primitive type
|
|
15
|
-
* through the `valueOf()` method like the `String` or `Number`, its return type
|
|
16
|
-
* be the `string` or `number`. Otherwise, the built-in class does not have the
|
|
17
|
-
* `valueOf()` method, the return type
|
|
15
|
+
* through the `valueOf()` method like the `String` or `Number`, its return type will
|
|
16
|
+
* be the `string` or `number`. Otherwise, if the built-in class does not have the
|
|
17
|
+
* `valueOf()` method, the return type will be an empty object (`{}`).
|
|
18
18
|
*
|
|
19
|
-
* Otherwise, the target argument is a type of custom class, all of its custom
|
|
20
|
-
*
|
|
21
|
-
* Therefore, return type of the TMP type finally be the primitive object.
|
|
19
|
+
* Otherwise, if the target argument is a type of custom class, all of its custom methods
|
|
20
|
+
* will be erased and its prototype will be changed to the primitive `object`.
|
|
21
|
+
* Therefore, the return type of the TMP type will finally be the primitive object.
|
|
22
22
|
*
|
|
23
23
|
* In addition, if the target argument is a type of custom class and it has a special
|
|
24
|
-
* method `toJSON()`, return type of this `Primitive`
|
|
24
|
+
* method `toJSON()`, the return type of this `Primitive` will be not `Primitive<Instance>`
|
|
25
25
|
* but `Primitive<ReturnType<Instance.toJSON>>`.
|
|
26
26
|
*
|
|
27
27
|
* Before | After
|
package/src/Resolved.ts
CHANGED
|
@@ -4,19 +4,19 @@ import { NativeClass } from "./typings/NativeClass";
|
|
|
4
4
|
import { ValueOf } from "./typings/ValueOf";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Resolved type
|
|
7
|
+
* Resolved type that erases every method.
|
|
8
8
|
*
|
|
9
|
-
* `Resolved` is a
|
|
10
|
-
* its argument as a resolved type that
|
|
9
|
+
* `Resolved` is a TMP (Type Meta Programming) type which converts
|
|
10
|
+
* its argument as a resolved type that erases every method property.
|
|
11
11
|
*
|
|
12
12
|
* If the target argument is a built-in class which returns its origin primitive type
|
|
13
|
-
* through the `valueOf()` method like the `String` or `Number`, its return type
|
|
14
|
-
* be the `string` or `number`. Otherwise, the built-in class does not have the
|
|
15
|
-
* `valueOf()` method, the return type
|
|
13
|
+
* through the `valueOf()` method like the `String` or `Number`, its return type will
|
|
14
|
+
* be the `string` or `number`. Otherwise, if the built-in class does not have the
|
|
15
|
+
* `valueOf()` method, the return type will be the same as the target argument.
|
|
16
16
|
*
|
|
17
|
-
* Otherwise, the target argument is a type of custom class, all of its custom methods
|
|
18
|
-
*
|
|
19
|
-
* Therefore, return type of the TMP type finally be the resolved object.
|
|
17
|
+
* Otherwise, if the target argument is a type of custom class, all of its custom methods
|
|
18
|
+
* will be erased and its prototype will be changed to the primitive `object`.
|
|
19
|
+
* Therefore, the return type of the TMP type will finally be the resolved object.
|
|
20
20
|
*
|
|
21
21
|
* Before | After
|
|
22
22
|
* ------------------------|----------------------------------------
|
package/src/SnakeCase.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
7
7
|
*
|
|
8
8
|
* `SnakeCase` type is a type that all keys of an object are converted to snake case.
|
|
9
9
|
*
|
|
10
|
-
* It also
|
|
10
|
+
* It also erases every method property like {@link Resolved} type.
|
|
11
11
|
*
|
|
12
12
|
* @template T Target type to be snake cased
|
|
13
13
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -45,6 +45,7 @@ export namespace TypeFactory {
|
|
|
45
45
|
checker: ts.TypeChecker;
|
|
46
46
|
type: ts.Type;
|
|
47
47
|
symbol?: ts.Symbol;
|
|
48
|
+
aliasTypeArguments?: boolean; // default: true
|
|
48
49
|
}): string => {
|
|
49
50
|
// PRIMITIVE
|
|
50
51
|
const symbol =
|
|
@@ -73,9 +74,10 @@ export namespace TypeFactory {
|
|
|
73
74
|
const name: string = get_name(symbol);
|
|
74
75
|
|
|
75
76
|
// CHECK GENERIC
|
|
76
|
-
const generic: readonly ts.Type[] =
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const generic: readonly ts.Type[] =
|
|
78
|
+
props.type.aliasSymbol && props.aliasTypeArguments !== false
|
|
79
|
+
? (props.type.aliasTypeArguments ?? [])
|
|
80
|
+
: props.checker.getTypeArguments(props.type as ts.TypeReference);
|
|
79
81
|
return generic.length
|
|
80
82
|
? name === "Promise"
|
|
81
83
|
? getFullName({
|
|
@@ -17,10 +17,10 @@ export const iterate_metadata_map = (
|
|
|
17
17
|
checker: props.checker,
|
|
18
18
|
type,
|
|
19
19
|
symbol: type.getSymbol(),
|
|
20
|
+
aliasTypeArguments: false,
|
|
20
21
|
});
|
|
21
|
-
const generic: readonly ts.Type[] | undefined =
|
|
22
|
-
|
|
23
|
-
: props.checker.getTypeArguments(type as ts.TypeReference);
|
|
22
|
+
const generic: readonly ts.Type[] | undefined =
|
|
23
|
+
props.checker.getTypeArguments(type as ts.TypeReference);
|
|
24
24
|
if (name.substring(0, 4) !== "Map<" || generic?.length !== 2) return false;
|
|
25
25
|
|
|
26
26
|
const key: ts.Type = generic[0]!;
|
|
@@ -18,10 +18,9 @@ export const iterate_metadata_set = (
|
|
|
18
18
|
checker: props.checker,
|
|
19
19
|
type: type,
|
|
20
20
|
symbol: type.getSymbol(),
|
|
21
|
+
aliasTypeArguments: false,
|
|
21
22
|
});
|
|
22
|
-
const generic = type.
|
|
23
|
-
? type.aliasTypeArguments
|
|
24
|
-
: props.checker.getTypeArguments(type as ts.TypeReference);
|
|
23
|
+
const generic = props.checker.getTypeArguments(type as ts.TypeReference);
|
|
25
24
|
if (name.substring(0, 4) !== "Set<" || generic?.length !== 1) return false;
|
|
26
25
|
|
|
27
26
|
const key: ts.Type = generic[0]!;
|
package/src/functional.ts
CHANGED
|
@@ -567,7 +567,7 @@ export function validateParameters<T extends (...args: any[]) => any>(
|
|
|
567
567
|
* @internal
|
|
568
568
|
*/
|
|
569
569
|
export function validateParameters(): never {
|
|
570
|
-
NoTransformConfigurationError("functional.
|
|
570
|
+
NoTransformConfigurationError("functional.validateParameters");
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
/**
|
package/src/http.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
21
21
|
* Form data decoder.
|
|
22
22
|
*
|
|
23
23
|
* `typia.http.formData()` is a function decoding `FormData` instance, with
|
|
24
|
-
* automatic type casting to the expected type. When
|
|
24
|
+
* automatic type casting to the expected type. When property type is defined
|
|
25
25
|
* as `boolean` or `Blob` type, `typia.http.formData()` will cast the value to
|
|
26
26
|
* the expected type when decoding.
|
|
27
27
|
*
|
|
@@ -32,7 +32,7 @@ import { TypeGuardError } from "./TypeGuardError";
|
|
|
32
32
|
* 1. Type `T` must be an object type
|
|
33
33
|
* 2. Do not allow dynamic property
|
|
34
34
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
35
|
-
* 4.
|
|
35
|
+
* 4. Union types are never allowed
|
|
36
36
|
*
|
|
37
37
|
* Also, `typia.http.formData()` function does not perform validation about the
|
|
38
38
|
* decoded value. Therefore, if you can't sure that input data is following the
|
|
@@ -57,7 +57,7 @@ export function formData(): never {
|
|
|
57
57
|
* Form data decoder with type assertion.
|
|
58
58
|
*
|
|
59
59
|
* `typia.http.assertFormData()` is a function decoding `FormData` instance, with
|
|
60
|
-
* automatic type casting to the expected type. When
|
|
60
|
+
* automatic type casting to the expected type. When property type is defined
|
|
61
61
|
* as `boolean` or `Blob` type, `typia.http.assertFormData()` will cast the value
|
|
62
62
|
* to the expected type when decoding.
|
|
63
63
|
*
|
|
@@ -73,7 +73,7 @@ export function formData(): never {
|
|
|
73
73
|
* 1. Type `T` must be an object type
|
|
74
74
|
* 2. Do not allow dynamic property
|
|
75
75
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
76
|
-
* 4.
|
|
76
|
+
* 4. Union types are never allowed
|
|
77
77
|
*
|
|
78
78
|
* @template T Expected type of decoded value
|
|
79
79
|
* @param input FormData instance
|
|
@@ -98,7 +98,7 @@ export function assertFormData(): never {
|
|
|
98
98
|
* Form data decoder with type checking.
|
|
99
99
|
*
|
|
100
100
|
* `typia.http.isFormData()` is a function decoding `FormData` instance, with
|
|
101
|
-
* automatic type casting to the expected type. When
|
|
101
|
+
* automatic type casting to the expected type. When property type is defined
|
|
102
102
|
* as `boolean` or `Blob` type, `typia.http.isFormData()` will cast the value
|
|
103
103
|
* to the expected type when decoding.
|
|
104
104
|
*
|
|
@@ -113,7 +113,7 @@ export function assertFormData(): never {
|
|
|
113
113
|
* 1. Type `T` must be an object type
|
|
114
114
|
* 2. Do not allow dynamic property
|
|
115
115
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
116
|
-
* 4.
|
|
116
|
+
* 4. Union types are never allowed
|
|
117
117
|
*
|
|
118
118
|
* @template T Expected type of decoded value
|
|
119
119
|
* @param input FormData instance
|
|
@@ -136,7 +136,7 @@ export function isFormData(): never {
|
|
|
136
136
|
* Form data decoder with type validation.
|
|
137
137
|
*
|
|
138
138
|
* `typia.http.validateFormData()` is a function decoding `FormData` instance,
|
|
139
|
-
* with automatic type casting to the expected type. When
|
|
139
|
+
* with automatic type casting to the expected type. When property type is defined
|
|
140
140
|
* as `boolean` or `Blob` type, `typia.http.validateFormData()` will cast the
|
|
141
141
|
* value to the expected type when decoding.
|
|
142
142
|
*
|
|
@@ -153,7 +153,7 @@ export function isFormData(): never {
|
|
|
153
153
|
* 1. Type `T` must be an object type
|
|
154
154
|
* 2. Do not allow dynamic property
|
|
155
155
|
* 3. Only `boolean`, `bigint`, `number`, `string`, `Blob`, `File` or their array types are allowed
|
|
156
|
-
* 4.
|
|
156
|
+
* 4. Union types are never allowed
|
|
157
157
|
*
|
|
158
158
|
* @template T Expected type of decoded value
|
|
159
159
|
* @param input FormData instance
|
|
@@ -190,7 +190,7 @@ export function validateFormData(): never {
|
|
|
190
190
|
* 1. Type `T` must be an object type
|
|
191
191
|
* 2. Do not allow dynamic property
|
|
192
192
|
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
193
|
-
* 4.
|
|
193
|
+
* 4. Union types are never allowed
|
|
194
194
|
*
|
|
195
195
|
* Also, `typia.http.query()` function does not perform validation about the decoded
|
|
196
196
|
* value. Therefore, if you can't sure that input data is following the `T` type,
|
|
@@ -222,7 +222,7 @@ export function query(): never {
|
|
|
222
222
|
*
|
|
223
223
|
* `typia.http.assertQuery()` is a function decoding a query string or an
|
|
224
224
|
* `URLSearchParams` instance, with automatic type casting to the expected type.
|
|
225
|
-
* When property type
|
|
225
|
+
* When property type is defined as `boolean` or `number` type,
|
|
226
226
|
* `typia.http.assertQuery()` will cast the value to the expected type when decoding.
|
|
227
227
|
*
|
|
228
228
|
* Also, after decoding, `typia.http.assertQuery()` performs type assertion to the
|
|
@@ -237,7 +237,7 @@ export function query(): never {
|
|
|
237
237
|
* 1. Type `T` must be an object type
|
|
238
238
|
* 2. Do not allow dynamic property
|
|
239
239
|
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
240
|
-
* 4.
|
|
240
|
+
* 4. Union types are never allowed
|
|
241
241
|
*
|
|
242
242
|
* @template T Expected type of decoded value
|
|
243
243
|
* @param input Query string or URLSearchParams instance
|
|
@@ -263,7 +263,7 @@ export function assertQuery(): never {
|
|
|
263
263
|
*
|
|
264
264
|
* `typia.http.isQuery()` is a function decoding a query string or an
|
|
265
265
|
* `URLSearchParams` instance, with automatic type casting to the expected type.
|
|
266
|
-
* When property type
|
|
266
|
+
* When property type is defined as `boolean` or `number` type,
|
|
267
267
|
* `typia.http.isQuery()` will cast the value to the expected type when decoding.
|
|
268
268
|
*
|
|
269
269
|
* Also, after decoding, `typia.http.isQuery()` performs type checking to the
|
|
@@ -277,7 +277,7 @@ export function assertQuery(): never {
|
|
|
277
277
|
* 1. Type `T` must be an object type
|
|
278
278
|
* 2. Do not allow dynamic property
|
|
279
279
|
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
280
|
-
* 4.
|
|
280
|
+
* 4. Union types are never allowed
|
|
281
281
|
*
|
|
282
282
|
* @template T Expected type of decoded value
|
|
283
283
|
* @param input Query string or URLSearchParams instance
|
|
@@ -301,7 +301,7 @@ export function isQuery(): never {
|
|
|
301
301
|
*
|
|
302
302
|
* `typia.http.validateQuery()` is a function decoding a query string or an
|
|
303
303
|
* `URLSearchParams` instance, with automatic type casting to the expected type.
|
|
304
|
-
* When property type
|
|
304
|
+
* When property type is defined as `boolean` or `number` type,
|
|
305
305
|
* `typia.http.validateQuery()` will cast the value to the expected type when decoding.
|
|
306
306
|
*
|
|
307
307
|
* Also, after decoding, `typia.http.validateQuery()` performs type validation to the
|
|
@@ -316,7 +316,7 @@ export function isQuery(): never {
|
|
|
316
316
|
* 1. Type `T` must be an object type
|
|
317
317
|
* 2. Do not allow dynamic property
|
|
318
318
|
* 3. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
319
|
-
* 4.
|
|
319
|
+
* 4. Union types are never allowed
|
|
320
320
|
*
|
|
321
321
|
* @template T Expected type of decoded value
|
|
322
322
|
* @param input Query string or URLSearchParams instance
|
|
@@ -342,7 +342,7 @@ export function validateQuery(): never {
|
|
|
342
342
|
* Headers decoder (for express and fastify).
|
|
343
343
|
*
|
|
344
344
|
* `typia.http.headers()` is a function decoding an header instance, with automatic
|
|
345
|
-
* type casting to the expected type. When property type
|
|
345
|
+
* type casting to the expected type. When property type is defined as `boolean` or
|
|
346
346
|
* `number` type, `typia.http.headers()` will cast the value to the expected type.
|
|
347
347
|
*
|
|
348
348
|
* By the way, as HTTP headers are not enough to express complex data structures,
|
|
@@ -354,7 +354,7 @@ export function validateQuery(): never {
|
|
|
354
354
|
* 3. Property key must be lower case
|
|
355
355
|
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
356
356
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
357
|
-
* 6.
|
|
357
|
+
* 6. Union types are never allowed
|
|
358
358
|
* 7. Property `set-cookie` must be array type
|
|
359
359
|
* 8. Those properties cannot be array type
|
|
360
360
|
* - age
|
|
@@ -405,7 +405,7 @@ export function headers(): never {
|
|
|
405
405
|
* Headers decoder with type assertion (for express and fastify).
|
|
406
406
|
*
|
|
407
407
|
* `typia.http.assertHeaders()` is a function decoding an header instance, with
|
|
408
|
-
* automatic type casting to the expected type. When property type
|
|
408
|
+
* automatic type casting to the expected type. When property type is defined as
|
|
409
409
|
* `boolean` or `number` type, `typia.http.headers()` will cast the value to the
|
|
410
410
|
* expected type.
|
|
411
411
|
*
|
|
@@ -423,7 +423,7 @@ export function headers(): never {
|
|
|
423
423
|
* 3. Property key must be lower case
|
|
424
424
|
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
425
425
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
426
|
-
* 6.
|
|
426
|
+
* 6. Union types are never allowed
|
|
427
427
|
* 7. Property `set-cookie` must be array type
|
|
428
428
|
* 8. Those properties cannot be array type
|
|
429
429
|
* - age
|
|
@@ -470,7 +470,7 @@ export function assertHeaders(): never {
|
|
|
470
470
|
* Headers decoder with type checking (for express and fastify).
|
|
471
471
|
*
|
|
472
472
|
* `typia.http.isHeaders()` is a function decoding an header instance, with
|
|
473
|
-
* automatic type casting to the expected type. When property type
|
|
473
|
+
* automatic type casting to the expected type. When property type is defined as
|
|
474
474
|
* `boolean` or `number` type, `typia.http.headers()` will cast the value to the
|
|
475
475
|
* expected type.
|
|
476
476
|
*
|
|
@@ -487,7 +487,7 @@ export function assertHeaders(): never {
|
|
|
487
487
|
* 3. Property key must be lower case
|
|
488
488
|
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
489
489
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
490
|
-
* 6.
|
|
490
|
+
* 6. Union types are never allowed
|
|
491
491
|
* 7. Property `set-cookie` must be array type
|
|
492
492
|
* 8. Those properties cannot be array type
|
|
493
493
|
* - age
|
|
@@ -530,7 +530,7 @@ export function isHeaders(): never {
|
|
|
530
530
|
* Headers decoder with type validation (for express and fastify).
|
|
531
531
|
*
|
|
532
532
|
* `typia.http.validateHeaders()` is a function decoding an header instance, with
|
|
533
|
-
* automatic type casting to the expected type. When property type
|
|
533
|
+
* automatic type casting to the expected type. When property type is defined as
|
|
534
534
|
* `boolean` or `number` type, `typia.http.headers()` will cast the value to the
|
|
535
535
|
* expected type.
|
|
536
536
|
*
|
|
@@ -548,7 +548,7 @@ export function isHeaders(): never {
|
|
|
548
548
|
* 3. Property key must be lower case
|
|
549
549
|
* 4. Property value cannot be `null`, but `undefined` is possible
|
|
550
550
|
* 5. Only `boolean`, `bigint`, `number`, `string` or their array types are allowed
|
|
551
|
-
* 6.
|
|
551
|
+
* 6. Union types are never allowed
|
|
552
552
|
* 7. Property `set-cookie` must be array type
|
|
553
553
|
* 8. Those properties cannot be array type
|
|
554
554
|
* - age
|