typia 3.8.0-dev.20230415 → 3.8.0-dev.20230417
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -228
- package/lib/factories/TypiaFileFactory.js +9 -4
- package/lib/factories/TypiaFileFactory.js.map +1 -1
- package/lib/typings/Customizable.d.ts +2 -2
- package/lib/utils/RandomGenerator.d.ts +17 -1
- package/lib/utils/RandomGenerator.js.map +1 -1
- package/package.json +1 -1
- package/src/IRandomGenerator.ts +33 -33
- package/src/executable/TypiaGenerateWizard.ts +85 -85
- package/src/executable/TypiaSetupWizard.ts +118 -118
- package/src/executable/setup/ArgumentParser.ts +45 -45
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +22 -22
- package/src/executable/setup/PackageManager.ts +71 -71
- package/src/executable/setup/PluginConfigurator.ts +59 -59
- package/src/executable/typia.ts +52 -52
- package/src/factories/IdentifierFactory.ts +59 -59
- package/src/factories/MetadataTagFactory.ts +302 -302
- package/src/factories/TypiaFileFactory.ts +12 -3
- package/src/metadata/ICommentTag.ts +4 -4
- package/src/metadata/Metadata.ts +533 -533
- package/src/module.ts +2043 -2043
- package/src/programmers/AssertProgrammer.ts +284 -284
- package/src/programmers/CheckerProgrammer.ts +920 -920
- package/src/programmers/LiteralsProgrammer.ts +65 -65
- package/src/programmers/RandomProgrammer.ts +413 -413
- package/src/programmers/ValidateProgrammer.ts +317 -317
- package/src/programmers/helpers/RandomJoiner.ts +161 -161
- package/src/programmers/helpers/RandomRanger.ts +216 -216
- package/src/programmers/internal/application_native.ts +32 -32
- package/src/programmers/internal/check_array.ts +30 -30
- package/src/programmers/internal/check_array_length.ts +35 -35
- package/src/programmers/internal/check_custom.ts +33 -33
- package/src/programmers/internal/check_number.ts +177 -177
- package/src/programmers/internal/check_object.ts +55 -55
- package/src/programmers/internal/check_string_tags.ts +67 -67
- package/src/programmers/internal/check_template.ts +56 -56
- package/src/programmers/internal/check_union_array_like.ts +272 -272
- package/src/programmers/internal/feature_object_entries.ts +63 -63
- package/src/programmers/internal/get_comment_tags.ts +23 -23
- package/src/programmers/internal/metadata_to_pattern.ts +34 -34
- package/src/programmers/internal/random_custom.ts +30 -30
- package/src/programmers/internal/stringify_dynamic_properties.ts +168 -168
- package/src/programmers/internal/stringify_regular_properties.ts +84 -84
- package/src/transformers/CallExpressionTransformer.ts +174 -174
- package/src/transformers/ImportTransformer.ts +66 -66
- package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +119 -119
- package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +41 -41
- package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +30 -30
- package/src/transformers/features/miscellaneous/MetadataTransformer.ts +54 -54
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +46 -46
- package/src/typings/Customizable.ts +5 -5
- package/src/utils/RandomGenerator.ts +93 -96
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Typia
|
|
2
|
+

|
|
3
|
+
|
|
2
4
|
[](https://github.com/samchon/typia/blob/master/LICENSE)
|
|
3
5
|
[](https://www.npmjs.com/package/typia)
|
|
4
6
|
[](https://www.npmjs.com/package/typia)
|
|
5
7
|
[](https://github.com/samchon/typia/actions?query=workflow%3Abuild)
|
|
6
|
-
[](https://
|
|
8
|
+
[](https://typia.io/docs/)
|
|
7
9
|
|
|
8
10
|
```typescript
|
|
9
11
|
// RUNTIME VALIDATORS
|
|
@@ -21,247 +23,52 @@ export function assertStringify<T>(input: T): string; // safe and faster
|
|
|
21
23
|
|
|
22
24
|
// MISC
|
|
23
25
|
export function random<T>(g?: Partial<IRandomGenerator>): Primitive<T>;
|
|
24
|
-
export function literals<T extends Atomic.Type>(): T[];
|
|
25
|
-
export function clone<T>(input: T): Primitive<T>; // deep clone
|
|
26
|
-
export function prune<T extends object>(input: T): void; // erase extra props
|
|
27
|
-
// +) isClone, assertClone, validateClone
|
|
28
|
-
// +) isPrune, assertPrune, validatePrune
|
|
29
26
|
```
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
Typia is a transformer library supporting below features:
|
|
32
29
|
|
|
33
30
|
- Super-fast Runtime Validators
|
|
34
31
|
- Safe JSON parse and fast stringify functions
|
|
35
32
|
- JSON schema generator
|
|
36
33
|
- Random data generator
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
> Measured on [Intel i5-1135g7, Surface Pro 8](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz#is)
|
|
45
|
-
|
|
35
|
+
> **Note**
|
|
36
|
+
>
|
|
37
|
+
> - **Only one line** required, with pure TypeScript type
|
|
38
|
+
> - Runtime validator is **20,000x faster** than `class-validator`
|
|
39
|
+
> - JSON serialization is **200x faster** than `class-transformer`
|
|
46
40
|
|
|
47
41
|
|
|
48
42
|
|
|
49
|
-
## Sponsors
|
|
43
|
+
## Sponsors
|
|
50
44
|
Thanks for your support.
|
|
51
45
|
|
|
52
46
|
Your donation would encourage `typia` development.
|
|
53
47
|
|
|
54
48
|
[](https://opencollective.com/typia)
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
# INSTALL TYPIA
|
|
82
|
-
npm install --save typia
|
|
83
|
-
npm install --save-dev typescript
|
|
84
|
-
|
|
85
|
-
# GENERATE TRANSFORMED TYPESCRIPT CODES
|
|
86
|
-
npx typia generate \
|
|
87
|
-
--input src/templates \
|
|
88
|
-
--output src/generated \
|
|
89
|
-
--project tsconfig.json
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
For frontend projects.
|
|
93
|
-
|
|
94
|
-
If you're using non-standard TypeScript compiler, you can't use [transform mode](#transformation).
|
|
95
|
-
|
|
96
|
-
- Non-standard TypeScript compilers:
|
|
97
|
-
- [swc](https://swc.rs/) in Next.JS
|
|
98
|
-
- [esbuild](https://esbuild.github.io/) in Vite
|
|
99
|
-
- [babel](https://babeljs.io/) in Create-React-App
|
|
100
|
-
|
|
101
|
-
Instead, you should utilize the generation mode.
|
|
102
|
-
|
|
103
|
-
Install `typia` through `npm install` command and run `typia generate` command. Then, generator of `typia` reads your TypeScript code of `--input`, and writes transformed TypeScript code into the `--output` directory, like below.
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
//--------
|
|
107
|
-
// src/templates/check.ts
|
|
108
|
-
//--------
|
|
109
|
-
import typia from "typia";
|
|
110
|
-
export const check = typia.createIs<string | null>();
|
|
111
|
-
|
|
112
|
-
//--------
|
|
113
|
-
// src/generated/check.ts
|
|
114
|
-
//--------
|
|
115
|
-
import typia from "typia";
|
|
116
|
-
export const check =
|
|
117
|
-
(input: unknown): input is string | null
|
|
118
|
-
=> "string" === typeof input || null === input;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
## Features
|
|
125
|
-
[](https://github.com/samchon/typia/wiki)
|
|
126
|
-
|
|
127
|
-
In here README documents, only summarized informations are provided.
|
|
128
|
-
|
|
129
|
-
For more details, refer to the [Guide Documents (wiki)](https://github.com/samchon/typia/wiki).
|
|
130
|
-
|
|
131
|
-
> - **Runtime Validators**
|
|
132
|
-
> - [powerful validator](https://github.com/samchon/typia/wiki/Runtime-Validators#powerful-validator)
|
|
133
|
-
> - [`is()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#is-function)
|
|
134
|
-
> - [`assert()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#assert-function)
|
|
135
|
-
> - [`validate()` function](https://github.com/samchon/typia/wiki/Runtime-Validators#validate-function)
|
|
136
|
-
> - [strict validators](https://github.com/samchon/typia/wiki/Runtime-Validators#strict-validators)
|
|
137
|
-
> - [factory functions](https://github.com/samchon/typia/wiki/Runtime-Validators#factory-functions)
|
|
138
|
-
> - [comment tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags)
|
|
139
|
-
> - [custom validators](https://github.com/samchon/typia/wiki/Runtime-Validators#custom-validators)
|
|
140
|
-
> - **Enhanced JSON**
|
|
141
|
-
> - [`stringify()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#stringify-functions)
|
|
142
|
-
> - [`parse()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#parse-functions)
|
|
143
|
-
> - [JSON schema](https://github.com/samchon/typia/wiki/Enhanced-JSON#json-schema)
|
|
144
|
-
> - [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
|
|
145
|
-
> - **Random Generator**
|
|
146
|
-
> - [`random()` function](https://github.com/samchon/typia/wiki/Random-Generator#random-function)
|
|
147
|
-
> - [comment tags](https://github.com/samchon/typia/wiki/Random-Geneerator#comment-tags)
|
|
148
|
-
> - [customization](https://github.com/samchon/typia/wiki/Random-Generator#customization)
|
|
149
|
-
|
|
150
|
-
### Runtime Validators
|
|
151
|
-
```typescript
|
|
152
|
-
// ALLOW SUPERFLUOUS PROPERTIES
|
|
153
|
-
export function is<T>(input: unknown): input is T; // returns boolean
|
|
154
|
-
export function assert<T>(input: unknown): T; // throws `TypeGuardError`
|
|
155
|
-
export function validate<T>(input: unknown): IValidation<T>; // detailed
|
|
156
|
-
|
|
157
|
-
// DO NOT ALLOW SUPERFLUOUS PROPERTIES
|
|
158
|
-
export function equals<T>(input: unknown): input is T;
|
|
159
|
-
export function assertEquals<T>(input: unknown): T;
|
|
160
|
-
export function validateEquals<T>(input: unknown): IValidation<T>;
|
|
161
|
-
|
|
162
|
-
// REUSABLE FACTORY FUNCTIONS
|
|
163
|
-
export function createIs<T>(): (input: unknown) => input is T;
|
|
164
|
-
export function createAssert<T>(): (input: unknown) => T;
|
|
165
|
-
export function createValidate<T>(): (input: unknown) => IValidation<T>;
|
|
166
|
-
export function createEquals<T>(): (input: unknown) => input is T;
|
|
167
|
-
export function createAssertEquals<T>(): (input: unknown) => T;
|
|
168
|
-
export function createValidateEquals<T>(): (input: unknown) => IValidation<T>;
|
|
169
|
-
|
|
170
|
-
// YOU CAN ADD CUSTOM VALIDATORS
|
|
171
|
-
export const customValidators: CustomValidatorMap;
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
`typia` supports three type of validator functions:
|
|
175
|
-
|
|
176
|
-
- `is()`: returns `false` if not matched with the type `T`
|
|
177
|
-
- `assert()`: throws a [`TypeGuardError`](https://github.com/samchon/typia/blob/master/src/TypeGuardError.ts) when not matched
|
|
178
|
-
- `validate()`
|
|
179
|
-
- when matched, returns [`IValidation.ISuccess<T>`](https://github.com/samchon/typia/blob/master/src/IValidation.ts) with `value` property
|
|
180
|
-
- otherwise not matched, returns [`IValidation.IFailure`](https://github.com/samchon/typia/blob/master/src/IValidation.ts) with `errors` property
|
|
181
|
-
|
|
182
|
-
Also, if you want more strict validator functions that even do not allowing superfluous properties not written in the type `T`, you can use those functions instead; `equals()`, `assertEquals()`, `validateEquals()`. Otherwise you want to create resuable validator functions, you can utilize factory functions like `createIs()` instead.
|
|
183
|
-
|
|
184
|
-
When you want to add special validation logics, like limiting range of numeric values, you can do it through comment tags. Furthermore, you can add your custom validator logics. If you want to know about them, visit the Guide Documents:
|
|
185
|
-
|
|
186
|
-
- [Features > Runtime Validators > Comment Tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags)
|
|
187
|
-
- [Features > Runtime Validators > Custom Validators](https://github.com/samchon/typia/wiki/Runtime-Validators#custom-validators).
|
|
188
|
-
|
|
189
|
-
### Enhanced JSON
|
|
190
|
-
```typescript
|
|
191
|
-
// JSON SCHEMA GENERATOR
|
|
192
|
-
export function application<
|
|
193
|
-
Types extends unknown[],
|
|
194
|
-
Purpose extends "swagger" | "ajv" = "swagger",
|
|
195
|
-
Prefix extends string = Purpose extends "swagger"
|
|
196
|
-
? "#/components/schemas"
|
|
197
|
-
: "components#/schemas",
|
|
198
|
-
>(): IJsonApplication;
|
|
199
|
-
|
|
200
|
-
// SAFE PARSER FUNCTIONS
|
|
201
|
-
export function isParse<T>(input: string): T | null;
|
|
202
|
-
export function assertParse<T>(input: string): T;
|
|
203
|
-
export function validateParse<T>(input: string): IValidation<T>;
|
|
204
|
-
|
|
205
|
-
// FASTER STRINGIFY FUNCTIONS
|
|
206
|
-
export function stringify<T>(input: T): string; // unsafe
|
|
207
|
-
export function isStringify<T>(input: T): string | null; // safe
|
|
208
|
-
export function assertStringify<T>(input: T): string;
|
|
209
|
-
export function validateStringify<T>(input: T): IValidation<string>;
|
|
210
|
-
|
|
211
|
-
// FACTORY FUNCTIONS
|
|
212
|
-
export function createAssertParse<T>(): (input: string) => T;
|
|
213
|
-
export function createAssertStringify<T>(): (input: T) => string;
|
|
214
|
-
// +) createIsParse, createValidateParse
|
|
215
|
-
// +) createStringify, createIsStringify, createValidateStringify
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
`typia` supports enhanced JSON functions.
|
|
219
|
-
|
|
220
|
-
- `application()`: generate JSON schema with only one line
|
|
221
|
-
- you can complement JSON schema contents through [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
|
|
222
|
-
- `assertParse()`: parse JSON string safely with type validation
|
|
223
|
-
- `isStringify()`: maximum 160x faster JSON stringify fuction even type safe
|
|
224
|
-
|
|
225
|
-

|
|
226
|
-
|
|
227
|
-
> Measured on [AMD R7 6800HS](https://github.com/samchon/typia/tree/master/benchmark/results/AMD%20Ryzen%207%206800HS%20with%20Radeon%20Graphics)
|
|
228
|
-
|
|
229
|
-
### Miscellaneous
|
|
230
|
-
```typescript
|
|
231
|
-
export function random<T>(g?: Partial<IRandomGenerator>): Primitive<T>;
|
|
232
|
-
export function literals<T extends Atomic.Type>(): T[];
|
|
233
|
-
export function clone<T>(input: T): Primitive<T>; // deep copy
|
|
234
|
-
export function prune<T>(input: T): void; // remove superfluous properties
|
|
235
|
-
// +) isClone, assertClone, validateClone
|
|
236
|
-
// +) isPrune, assertPrune, validatePrune
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
When you need random data, just call only `typia.random<T>()` function.
|
|
240
|
-
|
|
241
|
-
If you need specific random data generation, utilize comment tags or do customize.
|
|
242
|
-
|
|
243
|
-
- [Features > Random Generator > comment tags](https://github.com/samchon/typia/wiki/Random-Generator#random-function)
|
|
244
|
-
- [Features > Random Generator > customization](https://github.com/samchon/typia/wiki/Random-Generator#customization)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
## Appendix
|
|
249
|
-
### Nestia
|
|
250
|
-
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
251
|
-
[](https://www.npmjs.com/package/@nestia/core)
|
|
252
|
-
[](https://www.npmjs.com/package/@nestia/core)
|
|
253
|
-
[](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
|
|
254
|
-
[](https://github.com/samchon/nestia/wiki)
|
|
255
|
-
|
|
256
|
-
[Nestia](https://github.com/samchon/nestia) is a set of helper libraries for `NestJS`, supporting below features:
|
|
257
|
-
|
|
258
|
-
- `@nestia/core`: superfast decorators using `typia`
|
|
259
|
-
- **20,000x faster** validation
|
|
260
|
-
- **200x faster** JSON serialization
|
|
261
|
-
- `@nestia/sdk`: evolved **SDK** and **Swagger** generators
|
|
262
|
-
- SDK (Software Development Kit)
|
|
263
|
-
- interaction library for client developers
|
|
264
|
-
- almost same with [tRPC](https://github.com/trpc/trpc)
|
|
265
|
-
- `nestia`: just CLI (command line interface) tool
|
|
266
|
-
|
|
267
|
-

|
|
50
|
+
## Guide Documents
|
|
51
|
+
Check out the document in the [website](https://typia.io/docs/):
|
|
52
|
+
|
|
53
|
+
### 🙋🏻♂️ Home
|
|
54
|
+
- [Introduction](https://typia.io/docs/)
|
|
55
|
+
- [Setup](https://typia.io/docs/setup/)
|
|
56
|
+
|
|
57
|
+
### 📖 Features
|
|
58
|
+
- Runtime Validators
|
|
59
|
+
- [`is()` function](https://typia.io/docs/validators/is/)
|
|
60
|
+
- [`assert()` function](https://typia.io/docs/validators/assert/)
|
|
61
|
+
- [`validate()` function](https://typia.io/docs/validators/validate/)
|
|
62
|
+
- [Comment Tags](https://typia.io/docs/validators/comment-tags/)
|
|
63
|
+
- Enhanced JSON
|
|
64
|
+
- [`stringify()` functions](https://typia.io/docs/json/stringify/)
|
|
65
|
+
- [`parse()` functions](https://typia.io/docs/json/parse/)
|
|
66
|
+
- [JSON Schema](https://typia.io/docs/json/schema)
|
|
67
|
+
- [Random Generator](https://typia.io/docs/random/)
|
|
68
|
+
|
|
69
|
+
### 🔗 Appendix
|
|
70
|
+
- Utillization Cases
|
|
71
|
+
- [NestJS](https://typia.io/docs/utilization/nestjs/)
|
|
72
|
+
- [tRPC](https://typia.io/docs/utilization/trpc/)
|
|
73
|
+
- [⇲ Benchmark Result](https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz)
|
|
74
|
+
- [⇲ `dev.to` Articles](https://dev.to/samchon/series/22474)
|
|
@@ -62,7 +62,7 @@ var TypiaFileFactory;
|
|
|
62
62
|
function generate(props) {
|
|
63
63
|
var _a, _b;
|
|
64
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
-
var parent_1,
|
|
65
|
+
var parent_1, compilerOptions, program, _c, _d, result, printer, _e, _f, file, to, content, e_1_1;
|
|
66
66
|
var e_1, _g;
|
|
67
67
|
var _this = this;
|
|
68
68
|
return __generator(this, function (_h) {
|
|
@@ -93,7 +93,12 @@ var TypiaFileFactory;
|
|
|
93
93
|
_h.sent();
|
|
94
94
|
_h.label = 8;
|
|
95
95
|
case 8:
|
|
96
|
-
|
|
96
|
+
compilerOptions = typescript_1.default.parseJsonConfigFileContent(typescript_1.default.readConfigFile(props.project, typescript_1.default.sys.readFile).config, {
|
|
97
|
+
fileExists: typescript_1.default.sys.fileExists,
|
|
98
|
+
readFile: typescript_1.default.sys.readFile,
|
|
99
|
+
readDirectory: typescript_1.default.sys.readDirectory,
|
|
100
|
+
useCaseSensitiveFileNames: typescript_1.default.sys.useCaseSensitiveFileNames,
|
|
101
|
+
}, path_1.default.dirname(props.project)).options;
|
|
97
102
|
_d = (_c = typescript_1.default).createProgram;
|
|
98
103
|
return [4, (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
99
104
|
var container;
|
|
@@ -109,7 +114,7 @@ var TypiaFileFactory;
|
|
|
109
114
|
});
|
|
110
115
|
}); })()];
|
|
111
116
|
case 9:
|
|
112
|
-
program = _d.apply(_c, [_h.sent(),
|
|
117
|
+
program = _d.apply(_c, [_h.sent(), compilerOptions]);
|
|
113
118
|
result = typescript_1.default.transform(program
|
|
114
119
|
.getSourceFiles()
|
|
115
120
|
.filter(function (file) {
|
|
@@ -117,7 +122,7 @@ var TypiaFileFactory;
|
|
|
117
122
|
path_1.default.resolve(file.fileName).indexOf(props.input) !== -1;
|
|
118
123
|
}), [
|
|
119
124
|
ImportTransformer_1.ImportTransformer.transform(props.input)(props.output),
|
|
120
|
-
(0, transform_1.default)(program, (_b = ((_a =
|
|
125
|
+
(0, transform_1.default)(program, (_b = ((_a = compilerOptions.plugins) !== null && _a !== void 0 ? _a : []).find(function (p) {
|
|
121
126
|
return p.transform === "typia/lib/transform" ||
|
|
122
127
|
p.transform === "../src/transform.ts";
|
|
123
128
|
})) !== null && _b !== void 0 ? _b : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypiaFileFactory.js","sourceRoot":"","sources":["../../src/factories/TypiaFileFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK;oCAChD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;;;;;;;;;;;;;;;;;;qBAEhC;YAdD,CAcC;QAfD,CAeC;IAhBD,CAgBC,CAAC;AACV,CAAC,EAxHgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAwHhC"}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare namespace RandomGenerator {
|
|
2
|
+
function boolean(): boolean;
|
|
3
|
+
function integer(min?: number, max?: number): number;
|
|
4
|
+
function bigint(min?: bigint, max?: bigint): bigint;
|
|
5
|
+
function number(min?: number, max?: number): number;
|
|
6
|
+
function string(length?: number): string;
|
|
7
|
+
function array<T>(closure: (index: number) => T, count?: number): T[];
|
|
8
|
+
function pick<T>(array: T[]): T;
|
|
9
|
+
function uuid(): string;
|
|
10
|
+
function email(): string;
|
|
11
|
+
function url(): string;
|
|
12
|
+
function ipv4(): string;
|
|
13
|
+
function ipv6(): string;
|
|
14
|
+
function pattern(regex: RegExp): string;
|
|
15
|
+
function date(min?: number, max?: number): string;
|
|
16
|
+
function datetime(min?: number, max?: number): string;
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RandomGenerator.js","sourceRoot":"","sources":["../../src/utils/RandomGenerator.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA8B;
|
|
1
|
+
{"version":3,"file":"RandomGenerator.js","sourceRoot":"","sources":["../../src/utils/RandomGenerator.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA8B;AAE9B,IAAiB,eAAe,CA0F/B;AA1FD,WAAiB,eAAe;IAC5B,IAAM,SAAS,GAAG,4BAA4B,CAAC;IAK/C,SAAgB,OAAO;QACnB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;IAC/B,CAAC;IAFe,uBAAO,UAEtB,CAAA;IAED,SAAgB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AI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAC;QACvB,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,CAAC;IAJe,wBAAQ,WAIvB,CAAA;AACL,CAAC,EA1FgB,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA0F/B"}
|
package/package.json
CHANGED
package/src/IRandomGenerator.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Customizable } from "./typings/Customizable";
|
|
2
|
-
|
|
3
|
-
export interface IRandomGenerator {
|
|
4
|
-
boolean(): boolean;
|
|
5
|
-
integer(minimum?: number, maximum?: number): number;
|
|
6
|
-
number(minimum?: number, maximum?: number): number;
|
|
7
|
-
bigint(minimum?: bigint, maximum?: bigint): bigint;
|
|
8
|
-
string(length?: number): string;
|
|
9
|
-
array<T>(closure: (index: number) => T, count?: number): T[];
|
|
10
|
-
|
|
11
|
-
uuid(): string;
|
|
12
|
-
email(): string;
|
|
13
|
-
url(): string;
|
|
14
|
-
ipv4(): string;
|
|
15
|
-
ipv6(): string;
|
|
16
|
-
pattern(regex: RegExp): string;
|
|
17
|
-
date(minimum?: number, maximum?: number): string;
|
|
18
|
-
datetime(minimum?: number, maximum?: number): string;
|
|
19
|
-
|
|
20
|
-
customs?: IRandomGenerator.CustomMap;
|
|
21
|
-
}
|
|
22
|
-
export namespace IRandomGenerator {
|
|
23
|
-
export type CustomMap = {
|
|
24
|
-
[Type in keyof Customizable]?: (
|
|
25
|
-
tags: ICommentTag[],
|
|
26
|
-
) => Customizable[Type] | undefined;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export interface ICommentTag {
|
|
30
|
-
name: string;
|
|
31
|
-
value?: string;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import { Customizable } from "./typings/Customizable";
|
|
2
|
+
|
|
3
|
+
export interface IRandomGenerator {
|
|
4
|
+
boolean(): boolean;
|
|
5
|
+
integer(minimum?: number, maximum?: number): number;
|
|
6
|
+
number(minimum?: number, maximum?: number): number;
|
|
7
|
+
bigint(minimum?: bigint, maximum?: bigint): bigint;
|
|
8
|
+
string(length?: number): string;
|
|
9
|
+
array<T>(closure: (index: number) => T, count?: number): T[];
|
|
10
|
+
|
|
11
|
+
uuid(): string;
|
|
12
|
+
email(): string;
|
|
13
|
+
url(): string;
|
|
14
|
+
ipv4(): string;
|
|
15
|
+
ipv6(): string;
|
|
16
|
+
pattern(regex: RegExp): string;
|
|
17
|
+
date(minimum?: number, maximum?: number): string;
|
|
18
|
+
datetime(minimum?: number, maximum?: number): string;
|
|
19
|
+
|
|
20
|
+
customs?: IRandomGenerator.CustomMap;
|
|
21
|
+
}
|
|
22
|
+
export namespace IRandomGenerator {
|
|
23
|
+
export type CustomMap = {
|
|
24
|
+
[Type in keyof Customizable]?: (
|
|
25
|
+
tags: ICommentTag[],
|
|
26
|
+
) => Customizable[Type] | undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface ICommentTag {
|
|
30
|
+
name: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
}
|
|
33
|
+
}
|