typia 9.6.1 → 9.7.1
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/programmers/json/JsonStringifyProgrammer.js +2 -2
- package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
- package/lib/programmers/json/JsonStringifyProgrammer.mjs +2 -2
- package/lib/tags/Constant.d.mts +32 -0
- package/lib/tags/Constant.d.ts +32 -0
- package/lib/tags/ContentMediaType.d.mts +17 -0
- package/lib/tags/ContentMediaType.d.ts +17 -0
- package/lib/tags/Default.d.mts +30 -0
- package/lib/tags/Default.d.ts +30 -0
- package/lib/tags/Example.d.mts +32 -0
- package/lib/tags/Example.d.ts +32 -0
- package/lib/tags/Examples.d.mts +40 -0
- package/lib/tags/Examples.d.ts +40 -0
- package/lib/tags/ExclusiveMaximum.d.mts +18 -0
- package/lib/tags/ExclusiveMaximum.d.ts +18 -0
- package/lib/tags/ExclusiveMinimum.d.mts +18 -0
- package/lib/tags/ExclusiveMinimum.d.ts +18 -0
- package/lib/tags/Format.d.mts +24 -0
- package/lib/tags/Format.d.ts +24 -0
- package/lib/tags/JsonSchemaPlugin.d.mts +26 -0
- package/lib/tags/JsonSchemaPlugin.d.ts +26 -0
- package/lib/tags/MaxItems.d.mts +19 -0
- package/lib/tags/MaxItems.d.ts +19 -0
- package/lib/tags/MaxLength.d.mts +12 -0
- package/lib/tags/MaxLength.d.ts +12 -0
- package/lib/tags/Maximum.d.mts +18 -0
- package/lib/tags/Maximum.d.ts +18 -0
- package/lib/tags/MinItems.d.mts +19 -0
- package/lib/tags/MinItems.d.ts +19 -0
- package/lib/tags/MinLength.d.mts +12 -0
- package/lib/tags/MinLength.d.ts +12 -0
- package/lib/tags/Minimum.d.mts +18 -0
- package/lib/tags/Minimum.d.ts +18 -0
- package/lib/tags/MultipleOf.d.mts +18 -0
- package/lib/tags/MultipleOf.d.ts +18 -0
- package/lib/tags/Pattern.d.mts +15 -0
- package/lib/tags/Pattern.d.ts +15 -0
- package/lib/tags/Sequence.d.mts +25 -0
- package/lib/tags/Sequence.d.ts +25 -0
- package/lib/tags/TagBase.d.mts +27 -0
- package/lib/tags/TagBase.d.ts +27 -0
- package/lib/tags/Type.d.mts +26 -0
- package/lib/tags/Type.d.ts +26 -0
- package/lib/tags/UniqueItems.d.mts +19 -0
- package/lib/tags/UniqueItems.d.ts +19 -0
- package/lib/transformers/ImportTransformer.js +119 -1
- package/lib/transformers/ImportTransformer.js.map +1 -1
- package/lib/transformers/ImportTransformer.mjs +119 -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 +292 -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/programmers/json/JsonStringifyProgrammer.ts +2 -2
- package/src/tags/Constant.ts +32 -0
- package/src/tags/ContentMediaType.ts +17 -0
- package/src/tags/Default.ts +30 -0
- package/src/tags/Example.ts +32 -0
- package/src/tags/Examples.ts +40 -0
- package/src/tags/ExclusiveMaximum.ts +18 -0
- package/src/tags/ExclusiveMinimum.ts +18 -0
- package/src/tags/Format.ts +24 -0
- package/src/tags/JsonSchemaPlugin.ts +26 -0
- package/src/tags/MaxItems.ts +19 -0
- package/src/tags/MaxLength.ts +12 -0
- package/src/tags/Maximum.ts +18 -0
- package/src/tags/MinItems.ts +19 -0
- package/src/tags/MinLength.ts +12 -0
- package/src/tags/Minimum.ts +18 -0
- package/src/tags/MultipleOf.ts +18 -0
- package/src/tags/Pattern.ts +15 -0
- package/src/tags/Sequence.ts +25 -0
- package/src/tags/TagBase.ts +27 -0
- package/src/tags/Type.ts +26 -0
- package/src/tags/UniqueItems.ts +19 -0
- package/src/transformers/ImportTransformer.ts +178 -1
- package/src/transformers/features/llm/LlmApplicationTransformer.ts +18 -22
package/lib/CamelCase.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
7
7
|
*
|
|
8
8
|
* `CamelCase` type is a type that all keys of an object are camelized.
|
|
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 camelized
|
|
13
13
|
* @author Jeongho Nam - https://github.com/samchon
|
package/lib/CamelCase.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
7
7
|
*
|
|
8
8
|
* `CamelCase` type is a type that all keys of an object are camelized.
|
|
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 camelized
|
|
13
13
|
* @author Jeongho Nam - https://github.com/samchon
|
|
@@ -1,40 +1,280 @@
|
|
|
1
1
|
import { OpenApi } from "@samchon/openapi";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for generating random values for various data types.
|
|
4
|
+
*
|
|
5
|
+
* `IRandomGenerator` defines the contract for generating random values
|
|
6
|
+
* that can be used by typia for creating mock data, testing scenarios,
|
|
7
|
+
* and random value generation based on JSON schema constraints.
|
|
8
|
+
*
|
|
9
|
+
* This interface supports generating random values for:
|
|
10
|
+
* - Basic types (boolean, number, integer, bigint, string, array)
|
|
11
|
+
* - String format patterns (email, URL, UUID, etc.)
|
|
12
|
+
* - Date and time formats
|
|
13
|
+
* - Various address and identifier formats
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const generator: IRandomGenerator = {
|
|
18
|
+
* boolean: () => Math.random() > 0.5,
|
|
19
|
+
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
20
|
+
* string: (schema) => "example-string",
|
|
21
|
+
* email: () => "test@example.com",
|
|
22
|
+
* // ... implement other methods
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
27
|
+
*/
|
|
2
28
|
export interface IRandomGenerator {
|
|
29
|
+
/**
|
|
30
|
+
* Generates a random boolean value.
|
|
31
|
+
*
|
|
32
|
+
* @returns Random boolean value or undefined
|
|
33
|
+
*/
|
|
3
34
|
boolean(): boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Generates a random number based on JSON schema constraints.
|
|
37
|
+
*
|
|
38
|
+
* @param schema JSON schema with number constraints (min, max, etc.)
|
|
39
|
+
* @returns Random number within the specified constraints
|
|
40
|
+
*/
|
|
4
41
|
number(schema: OpenApi.IJsonSchema.INumber): number;
|
|
42
|
+
/**
|
|
43
|
+
* Generates a random integer based on JSON schema constraints.
|
|
44
|
+
*
|
|
45
|
+
* @param schema JSON schema with integer constraints (min, max, etc.)
|
|
46
|
+
* @returns Random integer within the specified constraints
|
|
47
|
+
*/
|
|
5
48
|
integer(schema: OpenApi.IJsonSchema.IInteger): number;
|
|
49
|
+
/**
|
|
50
|
+
* Generates a random bigint based on JSON schema constraints.
|
|
51
|
+
*
|
|
52
|
+
* @param schema JSON schema with integer constraints (min, max, etc.)
|
|
53
|
+
* @returns Random bigint within the specified constraints
|
|
54
|
+
*/
|
|
6
55
|
bigint(schema: OpenApi.IJsonSchema.IInteger): bigint;
|
|
56
|
+
/**
|
|
57
|
+
* Generates a random string based on JSON schema constraints.
|
|
58
|
+
*
|
|
59
|
+
* @param schema JSON schema with string constraints (minLength, maxLength, pattern, etc.)
|
|
60
|
+
* @returns Random string matching the specified constraints
|
|
61
|
+
*/
|
|
7
62
|
string(schema: OpenApi.IJsonSchema.IString): string;
|
|
63
|
+
/**
|
|
64
|
+
* Generates a random array with elements created by the provided generator function.
|
|
65
|
+
*
|
|
66
|
+
* @param schema Array schema with element generator function
|
|
67
|
+
* @returns Random array with generated elements
|
|
68
|
+
*/
|
|
8
69
|
array<T>(schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
9
70
|
element: (index: number, count: number) => T;
|
|
10
71
|
}): T[];
|
|
72
|
+
/**
|
|
73
|
+
* Generates a random string matching the given regular expression pattern.
|
|
74
|
+
*
|
|
75
|
+
* @param regex Regular expression pattern to match
|
|
76
|
+
* @returns Random string matching the pattern
|
|
77
|
+
*/
|
|
11
78
|
pattern(regex: RegExp): string;
|
|
79
|
+
/**
|
|
80
|
+
* Generates a random base64-encoded byte string.
|
|
81
|
+
*
|
|
82
|
+
* @returns Random base64 string
|
|
83
|
+
*/
|
|
12
84
|
byte(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Generates a random password string.
|
|
87
|
+
*
|
|
88
|
+
* @returns Random password
|
|
89
|
+
*/
|
|
13
90
|
password(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Generates a random regular expression pattern string.
|
|
93
|
+
*
|
|
94
|
+
* @returns Random regex pattern
|
|
95
|
+
*/
|
|
14
96
|
regex(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Generates a random UUID (Universally Unique Identifier).
|
|
99
|
+
*
|
|
100
|
+
* @returns Random UUID string in standard format
|
|
101
|
+
*/
|
|
15
102
|
uuid(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Generates a random email address.
|
|
105
|
+
*
|
|
106
|
+
* @returns Random email address
|
|
107
|
+
*/
|
|
16
108
|
email(): string;
|
|
109
|
+
/**
|
|
110
|
+
* Generates a random hostname.
|
|
111
|
+
*
|
|
112
|
+
* @returns Random hostname
|
|
113
|
+
*/
|
|
17
114
|
hostname(): string;
|
|
115
|
+
/**
|
|
116
|
+
* Generates a random internationalized email address.
|
|
117
|
+
*
|
|
118
|
+
* @returns Random IDN email address
|
|
119
|
+
*/
|
|
18
120
|
idnEmail(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Generates a random internationalized hostname.
|
|
123
|
+
*
|
|
124
|
+
* @returns Random IDN hostname
|
|
125
|
+
*/
|
|
19
126
|
idnHostname(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Generates a random IRI (Internationalized Resource Identifier).
|
|
129
|
+
*
|
|
130
|
+
* @returns Random IRI
|
|
131
|
+
*/
|
|
20
132
|
iri(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Generates a random IRI reference.
|
|
135
|
+
*
|
|
136
|
+
* @returns Random IRI reference
|
|
137
|
+
*/
|
|
21
138
|
iriReference(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Generates a random IPv4 address.
|
|
141
|
+
*
|
|
142
|
+
* @returns Random IPv4 address
|
|
143
|
+
*/
|
|
22
144
|
ipv4(): string;
|
|
145
|
+
/**
|
|
146
|
+
* Generates a random IPv6 address.
|
|
147
|
+
*
|
|
148
|
+
* @returns Random IPv6 address
|
|
149
|
+
*/
|
|
23
150
|
ipv6(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Generates a random URI (Uniform Resource Identifier).
|
|
153
|
+
*
|
|
154
|
+
* @returns Random URI
|
|
155
|
+
*/
|
|
24
156
|
uri(): string;
|
|
157
|
+
/**
|
|
158
|
+
* Generates a random URI reference.
|
|
159
|
+
*
|
|
160
|
+
* @returns Random URI reference
|
|
161
|
+
*/
|
|
25
162
|
uriReference(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Generates a random URI template.
|
|
165
|
+
*
|
|
166
|
+
* @returns Random URI template
|
|
167
|
+
*/
|
|
26
168
|
uriTemplate(): string;
|
|
169
|
+
/**
|
|
170
|
+
* Generates a random URL (Uniform Resource Locator).
|
|
171
|
+
*
|
|
172
|
+
* @returns Random URL
|
|
173
|
+
*/
|
|
27
174
|
url(): string;
|
|
175
|
+
/**
|
|
176
|
+
* Generates a random datetime string in ISO 8601 format.
|
|
177
|
+
*
|
|
178
|
+
* @param props Optional constraints for minimum and maximum timestamp values
|
|
179
|
+
* @returns Random datetime string
|
|
180
|
+
*/
|
|
28
181
|
datetime(props?: {
|
|
29
182
|
minimum?: number;
|
|
30
183
|
maximum?: number;
|
|
31
184
|
}): string;
|
|
185
|
+
/**
|
|
186
|
+
* Generates a random date string in ISO 8601 format (YYYY-MM-DD).
|
|
187
|
+
*
|
|
188
|
+
* @param props Optional constraints for minimum and maximum timestamp values
|
|
189
|
+
* @returns Random date string
|
|
190
|
+
*/
|
|
32
191
|
date(props?: {
|
|
33
192
|
minimum?: number;
|
|
34
193
|
maximum?: number;
|
|
35
194
|
}): string;
|
|
195
|
+
/**
|
|
196
|
+
* Generates a random time string in ISO 8601 format (HH:MM:SS).
|
|
197
|
+
*
|
|
198
|
+
* @returns Random time string
|
|
199
|
+
*/
|
|
36
200
|
time(): string;
|
|
201
|
+
/**
|
|
202
|
+
* Generates a random duration string in ISO 8601 format.
|
|
203
|
+
*
|
|
204
|
+
* @returns Random duration string
|
|
205
|
+
*/
|
|
37
206
|
duration(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Generates a random JSON pointer string.
|
|
209
|
+
*
|
|
210
|
+
* @returns Random JSON pointer
|
|
211
|
+
*/
|
|
38
212
|
jsonPointer(): string;
|
|
213
|
+
/**
|
|
214
|
+
* Generates a random relative JSON pointer string.
|
|
215
|
+
*
|
|
216
|
+
* @returns Random relative JSON pointer
|
|
217
|
+
*/
|
|
39
218
|
relativeJsonPointer(): string;
|
|
40
219
|
}
|
|
220
|
+
export declare namespace IRandomGenerator {
|
|
221
|
+
/**
|
|
222
|
+
* Map of custom generators for different data types.
|
|
223
|
+
*
|
|
224
|
+
* This interface allows customization of random generation for specific
|
|
225
|
+
* types when they have certain schema properties or constraints.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const generator: Partial<IRandomGenerator> = {
|
|
230
|
+
* string: (schema) => {
|
|
231
|
+
* if ((schema as any)["x-typia-monetary"] === "dollar") {
|
|
232
|
+
* return "$" + Math.floor(Math.random() * 1000);
|
|
233
|
+
* }
|
|
234
|
+
* return "default-string";
|
|
235
|
+
* },
|
|
236
|
+
* number: (schema) => {
|
|
237
|
+
* if ((schema as any)["x-typia-powerOf"] !== undefined) {
|
|
238
|
+
* const powerOf = (schema as any)["x-typia-powerOf"];
|
|
239
|
+
* return Math.pow(powerOf, Math.random() * 10 + 1);
|
|
240
|
+
* }
|
|
241
|
+
* return Math.random() * 100;
|
|
242
|
+
* }
|
|
243
|
+
* };
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
interface CustomMap {
|
|
247
|
+
/**
|
|
248
|
+
* Custom string generator that can handle special string formats
|
|
249
|
+
* based on schema properties.
|
|
250
|
+
*/
|
|
251
|
+
string?: (schema: OpenApi.IJsonSchema.IString & Record<string, any>) => string;
|
|
252
|
+
/**
|
|
253
|
+
* Custom number generator that can handle special number constraints
|
|
254
|
+
* based on schema properties.
|
|
255
|
+
*/
|
|
256
|
+
number?: (schema: OpenApi.IJsonSchema.INumber & Record<string, any>) => number;
|
|
257
|
+
/**
|
|
258
|
+
* Custom integer generator that can handle special integer constraints
|
|
259
|
+
* based on schema properties.
|
|
260
|
+
*/
|
|
261
|
+
integer?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => number;
|
|
262
|
+
/**
|
|
263
|
+
* Custom bigint generator that can handle special bigint constraints
|
|
264
|
+
* based on schema properties.
|
|
265
|
+
*/
|
|
266
|
+
bigint?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => bigint;
|
|
267
|
+
/**
|
|
268
|
+
* Custom boolean generator that can handle special boolean constraints
|
|
269
|
+
* based on schema properties.
|
|
270
|
+
*/
|
|
271
|
+
boolean?: (schema: Record<string, any>) => boolean | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Custom array generator that can handle special array constraints
|
|
274
|
+
* based on schema properties.
|
|
275
|
+
*/
|
|
276
|
+
array?: <T>(schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
277
|
+
element: (index: number, count: number) => T;
|
|
278
|
+
} & Record<string, any>) => T[];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
@@ -1,40 +1,280 @@
|
|
|
1
1
|
import { OpenApi } from "@samchon/openapi";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for generating random values for various data types.
|
|
4
|
+
*
|
|
5
|
+
* `IRandomGenerator` defines the contract for generating random values
|
|
6
|
+
* that can be used by typia for creating mock data, testing scenarios,
|
|
7
|
+
* and random value generation based on JSON schema constraints.
|
|
8
|
+
*
|
|
9
|
+
* This interface supports generating random values for:
|
|
10
|
+
* - Basic types (boolean, number, integer, bigint, string, array)
|
|
11
|
+
* - String format patterns (email, URL, UUID, etc.)
|
|
12
|
+
* - Date and time formats
|
|
13
|
+
* - Various address and identifier formats
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const generator: IRandomGenerator = {
|
|
18
|
+
* boolean: () => Math.random() > 0.5,
|
|
19
|
+
* number: (schema) => Math.random() * (schema.maximum ?? 100),
|
|
20
|
+
* string: (schema) => "example-string",
|
|
21
|
+
* email: () => "test@example.com",
|
|
22
|
+
* // ... implement other methods
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
27
|
+
*/
|
|
2
28
|
export interface IRandomGenerator {
|
|
29
|
+
/**
|
|
30
|
+
* Generates a random boolean value.
|
|
31
|
+
*
|
|
32
|
+
* @returns Random boolean value or undefined
|
|
33
|
+
*/
|
|
3
34
|
boolean(): boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Generates a random number based on JSON schema constraints.
|
|
37
|
+
*
|
|
38
|
+
* @param schema JSON schema with number constraints (min, max, etc.)
|
|
39
|
+
* @returns Random number within the specified constraints
|
|
40
|
+
*/
|
|
4
41
|
number(schema: OpenApi.IJsonSchema.INumber): number;
|
|
42
|
+
/**
|
|
43
|
+
* Generates a random integer based on JSON schema constraints.
|
|
44
|
+
*
|
|
45
|
+
* @param schema JSON schema with integer constraints (min, max, etc.)
|
|
46
|
+
* @returns Random integer within the specified constraints
|
|
47
|
+
*/
|
|
5
48
|
integer(schema: OpenApi.IJsonSchema.IInteger): number;
|
|
49
|
+
/**
|
|
50
|
+
* Generates a random bigint based on JSON schema constraints.
|
|
51
|
+
*
|
|
52
|
+
* @param schema JSON schema with integer constraints (min, max, etc.)
|
|
53
|
+
* @returns Random bigint within the specified constraints
|
|
54
|
+
*/
|
|
6
55
|
bigint(schema: OpenApi.IJsonSchema.IInteger): bigint;
|
|
56
|
+
/**
|
|
57
|
+
* Generates a random string based on JSON schema constraints.
|
|
58
|
+
*
|
|
59
|
+
* @param schema JSON schema with string constraints (minLength, maxLength, pattern, etc.)
|
|
60
|
+
* @returns Random string matching the specified constraints
|
|
61
|
+
*/
|
|
7
62
|
string(schema: OpenApi.IJsonSchema.IString): string;
|
|
63
|
+
/**
|
|
64
|
+
* Generates a random array with elements created by the provided generator function.
|
|
65
|
+
*
|
|
66
|
+
* @param schema Array schema with element generator function
|
|
67
|
+
* @returns Random array with generated elements
|
|
68
|
+
*/
|
|
8
69
|
array<T>(schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
9
70
|
element: (index: number, count: number) => T;
|
|
10
71
|
}): T[];
|
|
72
|
+
/**
|
|
73
|
+
* Generates a random string matching the given regular expression pattern.
|
|
74
|
+
*
|
|
75
|
+
* @param regex Regular expression pattern to match
|
|
76
|
+
* @returns Random string matching the pattern
|
|
77
|
+
*/
|
|
11
78
|
pattern(regex: RegExp): string;
|
|
79
|
+
/**
|
|
80
|
+
* Generates a random base64-encoded byte string.
|
|
81
|
+
*
|
|
82
|
+
* @returns Random base64 string
|
|
83
|
+
*/
|
|
12
84
|
byte(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Generates a random password string.
|
|
87
|
+
*
|
|
88
|
+
* @returns Random password
|
|
89
|
+
*/
|
|
13
90
|
password(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Generates a random regular expression pattern string.
|
|
93
|
+
*
|
|
94
|
+
* @returns Random regex pattern
|
|
95
|
+
*/
|
|
14
96
|
regex(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Generates a random UUID (Universally Unique Identifier).
|
|
99
|
+
*
|
|
100
|
+
* @returns Random UUID string in standard format
|
|
101
|
+
*/
|
|
15
102
|
uuid(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Generates a random email address.
|
|
105
|
+
*
|
|
106
|
+
* @returns Random email address
|
|
107
|
+
*/
|
|
16
108
|
email(): string;
|
|
109
|
+
/**
|
|
110
|
+
* Generates a random hostname.
|
|
111
|
+
*
|
|
112
|
+
* @returns Random hostname
|
|
113
|
+
*/
|
|
17
114
|
hostname(): string;
|
|
115
|
+
/**
|
|
116
|
+
* Generates a random internationalized email address.
|
|
117
|
+
*
|
|
118
|
+
* @returns Random IDN email address
|
|
119
|
+
*/
|
|
18
120
|
idnEmail(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Generates a random internationalized hostname.
|
|
123
|
+
*
|
|
124
|
+
* @returns Random IDN hostname
|
|
125
|
+
*/
|
|
19
126
|
idnHostname(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Generates a random IRI (Internationalized Resource Identifier).
|
|
129
|
+
*
|
|
130
|
+
* @returns Random IRI
|
|
131
|
+
*/
|
|
20
132
|
iri(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Generates a random IRI reference.
|
|
135
|
+
*
|
|
136
|
+
* @returns Random IRI reference
|
|
137
|
+
*/
|
|
21
138
|
iriReference(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Generates a random IPv4 address.
|
|
141
|
+
*
|
|
142
|
+
* @returns Random IPv4 address
|
|
143
|
+
*/
|
|
22
144
|
ipv4(): string;
|
|
145
|
+
/**
|
|
146
|
+
* Generates a random IPv6 address.
|
|
147
|
+
*
|
|
148
|
+
* @returns Random IPv6 address
|
|
149
|
+
*/
|
|
23
150
|
ipv6(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Generates a random URI (Uniform Resource Identifier).
|
|
153
|
+
*
|
|
154
|
+
* @returns Random URI
|
|
155
|
+
*/
|
|
24
156
|
uri(): string;
|
|
157
|
+
/**
|
|
158
|
+
* Generates a random URI reference.
|
|
159
|
+
*
|
|
160
|
+
* @returns Random URI reference
|
|
161
|
+
*/
|
|
25
162
|
uriReference(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Generates a random URI template.
|
|
165
|
+
*
|
|
166
|
+
* @returns Random URI template
|
|
167
|
+
*/
|
|
26
168
|
uriTemplate(): string;
|
|
169
|
+
/**
|
|
170
|
+
* Generates a random URL (Uniform Resource Locator).
|
|
171
|
+
*
|
|
172
|
+
* @returns Random URL
|
|
173
|
+
*/
|
|
27
174
|
url(): string;
|
|
175
|
+
/**
|
|
176
|
+
* Generates a random datetime string in ISO 8601 format.
|
|
177
|
+
*
|
|
178
|
+
* @param props Optional constraints for minimum and maximum timestamp values
|
|
179
|
+
* @returns Random datetime string
|
|
180
|
+
*/
|
|
28
181
|
datetime(props?: {
|
|
29
182
|
minimum?: number;
|
|
30
183
|
maximum?: number;
|
|
31
184
|
}): string;
|
|
185
|
+
/**
|
|
186
|
+
* Generates a random date string in ISO 8601 format (YYYY-MM-DD).
|
|
187
|
+
*
|
|
188
|
+
* @param props Optional constraints for minimum and maximum timestamp values
|
|
189
|
+
* @returns Random date string
|
|
190
|
+
*/
|
|
32
191
|
date(props?: {
|
|
33
192
|
minimum?: number;
|
|
34
193
|
maximum?: number;
|
|
35
194
|
}): string;
|
|
195
|
+
/**
|
|
196
|
+
* Generates a random time string in ISO 8601 format (HH:MM:SS).
|
|
197
|
+
*
|
|
198
|
+
* @returns Random time string
|
|
199
|
+
*/
|
|
36
200
|
time(): string;
|
|
201
|
+
/**
|
|
202
|
+
* Generates a random duration string in ISO 8601 format.
|
|
203
|
+
*
|
|
204
|
+
* @returns Random duration string
|
|
205
|
+
*/
|
|
37
206
|
duration(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Generates a random JSON pointer string.
|
|
209
|
+
*
|
|
210
|
+
* @returns Random JSON pointer
|
|
211
|
+
*/
|
|
38
212
|
jsonPointer(): string;
|
|
213
|
+
/**
|
|
214
|
+
* Generates a random relative JSON pointer string.
|
|
215
|
+
*
|
|
216
|
+
* @returns Random relative JSON pointer
|
|
217
|
+
*/
|
|
39
218
|
relativeJsonPointer(): string;
|
|
40
219
|
}
|
|
220
|
+
export declare namespace IRandomGenerator {
|
|
221
|
+
/**
|
|
222
|
+
* Map of custom generators for different data types.
|
|
223
|
+
*
|
|
224
|
+
* This interface allows customization of random generation for specific
|
|
225
|
+
* types when they have certain schema properties or constraints.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const generator: Partial<IRandomGenerator> = {
|
|
230
|
+
* string: (schema) => {
|
|
231
|
+
* if ((schema as any)["x-typia-monetary"] === "dollar") {
|
|
232
|
+
* return "$" + Math.floor(Math.random() * 1000);
|
|
233
|
+
* }
|
|
234
|
+
* return "default-string";
|
|
235
|
+
* },
|
|
236
|
+
* number: (schema) => {
|
|
237
|
+
* if ((schema as any)["x-typia-powerOf"] !== undefined) {
|
|
238
|
+
* const powerOf = (schema as any)["x-typia-powerOf"];
|
|
239
|
+
* return Math.pow(powerOf, Math.random() * 10 + 1);
|
|
240
|
+
* }
|
|
241
|
+
* return Math.random() * 100;
|
|
242
|
+
* }
|
|
243
|
+
* };
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
interface CustomMap {
|
|
247
|
+
/**
|
|
248
|
+
* Custom string generator that can handle special string formats
|
|
249
|
+
* based on schema properties.
|
|
250
|
+
*/
|
|
251
|
+
string?: (schema: OpenApi.IJsonSchema.IString & Record<string, any>) => string;
|
|
252
|
+
/**
|
|
253
|
+
* Custom number generator that can handle special number constraints
|
|
254
|
+
* based on schema properties.
|
|
255
|
+
*/
|
|
256
|
+
number?: (schema: OpenApi.IJsonSchema.INumber & Record<string, any>) => number;
|
|
257
|
+
/**
|
|
258
|
+
* Custom integer generator that can handle special integer constraints
|
|
259
|
+
* based on schema properties.
|
|
260
|
+
*/
|
|
261
|
+
integer?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => number;
|
|
262
|
+
/**
|
|
263
|
+
* Custom bigint generator that can handle special bigint constraints
|
|
264
|
+
* based on schema properties.
|
|
265
|
+
*/
|
|
266
|
+
bigint?: (schema: OpenApi.IJsonSchema.IInteger & Record<string, any>) => bigint;
|
|
267
|
+
/**
|
|
268
|
+
* Custom boolean generator that can handle special boolean constraints
|
|
269
|
+
* based on schema properties.
|
|
270
|
+
*/
|
|
271
|
+
boolean?: (schema: Record<string, any>) => boolean | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Custom array generator that can handle special array constraints
|
|
274
|
+
* based on schema properties.
|
|
275
|
+
*/
|
|
276
|
+
array?: <T>(schema: Omit<OpenApi.IJsonSchema.IArray, "items"> & {
|
|
277
|
+
element: (index: number, count: number) => T;
|
|
278
|
+
} & Record<string, any>) => T[];
|
|
279
|
+
}
|
|
280
|
+
}
|
package/lib/PascalCase.d.mts
CHANGED
|
@@ -7,7 +7,7 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
7
7
|
*
|
|
8
8
|
* `PascalCase` type is a type that all keys of an object are pascalized.
|
|
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 pascalized
|
|
13
13
|
* @author Jeongho Nam - https://github.com/samchon
|
package/lib/PascalCase.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ValueOf } from "./typings/ValueOf";
|
|
|
7
7
|
*
|
|
8
8
|
* `PascalCase` type is a type that all keys of an object are pascalized.
|
|
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 pascalized
|
|
13
13
|
* @author Jeongho Nam - https://github.com/samchon
|
package/lib/Primitive.d.mts
CHANGED
|
@@ -7,19 +7,19 @@ import { Format } from "./tags";
|
|
|
7
7
|
* Primitive type of JSON.
|
|
8
8
|
*
|
|
9
9
|
* `Primitive<T>` is a TMP (Type Meta Programming) type which converts
|
|
10
|
-
* its argument as a primitive type within framework JSON.
|
|
10
|
+
* its argument as a primitive type within the framework JSON.
|
|
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 an empty object (`{}`).
|
|
16
16
|
*
|
|
17
|
-
* Otherwise, the target argument is a type of custom class, all of its custom
|
|
18
|
-
*
|
|
19
|
-
* Therefore, return type of the TMP type finally be the primitive 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 primitive object.
|
|
20
20
|
*
|
|
21
21
|
* In addition, if the target argument is a type of custom class and it has a special
|
|
22
|
-
* method `toJSON()`, return type of this `Primitive`
|
|
22
|
+
* method `toJSON()`, the return type of this `Primitive` will be not `Primitive<Instance>`
|
|
23
23
|
* but `Primitive<ReturnType<Instance.toJSON>>`.
|
|
24
24
|
*
|
|
25
25
|
* Before | After
|
package/lib/Primitive.d.ts
CHANGED
|
@@ -7,19 +7,19 @@ import { Format } from "./tags";
|
|
|
7
7
|
* Primitive type of JSON.
|
|
8
8
|
*
|
|
9
9
|
* `Primitive<T>` is a TMP (Type Meta Programming) type which converts
|
|
10
|
-
* its argument as a primitive type within framework JSON.
|
|
10
|
+
* its argument as a primitive type within the framework JSON.
|
|
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 an empty object (`{}`).
|
|
16
16
|
*
|
|
17
|
-
* Otherwise, the target argument is a type of custom class, all of its custom
|
|
18
|
-
*
|
|
19
|
-
* Therefore, return type of the TMP type finally be the primitive 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 primitive object.
|
|
20
20
|
*
|
|
21
21
|
* In addition, if the target argument is a type of custom class and it has a special
|
|
22
|
-
* method `toJSON()`, return type of this `Primitive`
|
|
22
|
+
* method `toJSON()`, the return type of this `Primitive` will be not `Primitive<Instance>`
|
|
23
23
|
* but `Primitive<ReturnType<Instance.toJSON>>`.
|
|
24
24
|
*
|
|
25
25
|
* Before | After
|
package/lib/Resolved.d.mts
CHANGED
|
@@ -3,19 +3,19 @@ import { IsTuple } from "./typings/IsTuple";
|
|
|
3
3
|
import { NativeClass } from "./typings/NativeClass";
|
|
4
4
|
import { ValueOf } from "./typings/ValueOf";
|
|
5
5
|
/**
|
|
6
|
-
* Resolved type
|
|
6
|
+
* Resolved type that erases every method.
|
|
7
7
|
*
|
|
8
|
-
* `Resolved` is a
|
|
9
|
-
* its argument as a resolved type that
|
|
8
|
+
* `Resolved` is a TMP (Type Meta Programming) type which converts
|
|
9
|
+
* its argument as a resolved type that erases every method property.
|
|
10
10
|
*
|
|
11
11
|
* If the target argument is a built-in class which returns its origin primitive type
|
|
12
|
-
* through the `valueOf()` method like the `String` or `Number`, its return type
|
|
13
|
-
* be the `string` or `number`. Otherwise, the built-in class does not have the
|
|
14
|
-
* `valueOf()` method, the return type
|
|
12
|
+
* through the `valueOf()` method like the `String` or `Number`, its return type will
|
|
13
|
+
* be the `string` or `number`. Otherwise, if the built-in class does not have the
|
|
14
|
+
* `valueOf()` method, the return type will be the same as the target argument.
|
|
15
15
|
*
|
|
16
|
-
* Otherwise, the target argument is a type of custom class, all of its custom methods
|
|
17
|
-
*
|
|
18
|
-
* Therefore, return type of the TMP type finally be the resolved object.
|
|
16
|
+
* Otherwise, if the target argument is a type of custom class, all of its custom methods
|
|
17
|
+
* will be erased and its prototype will be changed to the primitive `object`.
|
|
18
|
+
* Therefore, the return type of the TMP type will finally be the resolved object.
|
|
19
19
|
*
|
|
20
20
|
* Before | After
|
|
21
21
|
* ------------------------|----------------------------------------
|