typia 3.5.0-dev.20230213 → 3.5.0-dev.20230214
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 +15 -1
- package/lib/IRandomGenerator.d.ts +15 -0
- package/lib/IRandomGenerator.js +3 -0
- package/lib/IRandomGenerator.js.map +1 -0
- package/lib/factories/ExpressionFactory.d.ts +1 -0
- package/lib/factories/ExpressionFactory.js +4 -0
- package/lib/factories/ExpressionFactory.js.map +1 -1
- package/lib/factories/MetadataFactory.js +15 -5
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/MetadataTagFactory.js +11 -101
- package/lib/factories/MetadataTagFactory.js.map +1 -1
- package/lib/functional/$any.d.ts +1 -0
- package/lib/functional/$any.js +8 -0
- package/lib/functional/$any.js.map +1 -0
- package/lib/{programmers/internal/check_length.d.ts → functional/Namespace.d.ts} +0 -0
- package/lib/functional/Namespace.js +80 -0
- package/lib/functional/Namespace.js.map +1 -0
- package/lib/metadata/IMetadataTag.d.ts +3 -10
- package/lib/module.d.ts +254 -18
- package/lib/module.js +68 -246
- package/lib/module.js.map +1 -1
- package/lib/programmers/AssertCloneProgrammer.d.ts +5 -0
- package/lib/programmers/AssertCloneProgrammer.js +37 -0
- package/lib/programmers/AssertCloneProgrammer.js.map +1 -0
- package/lib/programmers/CloneProgrammer.js +2 -4
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/IsCloneProgrammer.d.ts +5 -0
- package/lib/programmers/IsCloneProgrammer.js +37 -0
- package/lib/programmers/IsCloneProgrammer.js.map +1 -0
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsProgrammer.js +5 -2
- package/lib/programmers/IsProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.d.ts +5 -0
- package/lib/programmers/RandomProgrammer.js +338 -0
- package/lib/programmers/RandomProgrammer.js.map +1 -0
- package/lib/programmers/StringifyProgrammer.js +1 -1
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateCloneProgrammer.d.ts +5 -0
- package/lib/programmers/ValidateCloneProgrammer.js +37 -0
- package/lib/programmers/ValidateCloneProgrammer.js.map +1 -0
- package/lib/programmers/ValidateStringifyProgrammer.js +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -1
- package/lib/programmers/helpers/CloneJoiner.js +2 -2
- package/lib/programmers/helpers/CloneJoiner.js.map +1 -1
- package/lib/programmers/helpers/RandomJoiner.d.ts +10 -0
- package/lib/programmers/helpers/RandomJoiner.js +93 -0
- package/lib/programmers/helpers/RandomJoiner.js.map +1 -0
- package/lib/programmers/helpers/RandomRanger.d.ts +25 -0
- package/lib/programmers/helpers/RandomRanger.js +138 -0
- package/lib/programmers/helpers/RandomRanger.js.map +1 -0
- package/lib/programmers/helpers/StringifyJoinder.js +2 -2
- package/lib/programmers/helpers/StringifyJoinder.js.map +1 -1
- package/lib/programmers/internal/application_array.js +0 -10
- package/lib/programmers/internal/application_array.js.map +1 -1
- package/lib/programmers/internal/application_number.js +4 -12
- package/lib/programmers/internal/application_number.js.map +1 -1
- package/lib/programmers/internal/application_string.js +0 -8
- package/lib/programmers/internal/application_string.js.map +1 -1
- package/lib/programmers/internal/check_array_length.js +3 -4
- package/lib/programmers/internal/check_array_length.js.map +1 -1
- package/lib/programmers/internal/check_bigint.js +0 -12
- package/lib/programmers/internal/check_bigint.js.map +1 -1
- package/lib/programmers/internal/check_number.js +7 -25
- package/lib/programmers/internal/check_number.js.map +1 -1
- package/lib/programmers/internal/check_string_tags.js +2 -3
- package/lib/programmers/internal/check_string_tags.js.map +1 -1
- package/lib/schemas/IJsonSchema.d.ts +36 -2
- package/lib/transformers/CallExpressionTransformer.js +16 -0
- package/lib/transformers/CallExpressionTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +29 -0
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js +18 -0
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js +2 -1
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/RandomTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +35 -0
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -0
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.d.ts +5 -0
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js +23 -0
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js.map +1 -0
- package/lib/transformers/features/parsers/AssertParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/AssertParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/IsParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/IsParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/ValidateParseTransformer.js +2 -1
- package/lib/transformers/features/parsers/ValidateParseTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js +2 -1
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js.map +1 -1
- package/lib/transformers/features/validators/CreateAssertTransformer.js +2 -1
- package/lib/transformers/features/validators/CreateAssertTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateIsTransformer.js +2 -1
- package/lib/transformers/features/validators/CreateIsTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateValidateTransformer.js +2 -1
- package/lib/transformers/features/validators/CreateValidateTransformer.js.map +1 -1
- package/lib/utils/RandomGenerator.d.ts +1 -0
- package/lib/utils/RandomGenerator.js +85 -0
- package/lib/utils/RandomGenerator.js.map +1 -0
- package/package.json +8 -3
- package/src/IRandomGenerator.ts +16 -0
- package/src/factories/ExpressionFactory.ts +11 -0
- package/src/factories/MetadataFactory.ts +18 -14
- package/src/factories/MetadataTagFactory.ts +11 -97
- package/src/functional/$any.ts +3 -0
- package/src/functional/Namespace.ts +121 -0
- package/src/metadata/IMetadataTag.ts +2 -11
- package/src/module.ts +375 -368
- package/src/programmers/AssertCloneProgrammer.ts +60 -0
- package/src/programmers/CloneProgrammer.ts +3 -9
- package/src/programmers/IsCloneProgrammer.ts +66 -0
- package/src/programmers/IsProgrammer.ts +8 -5
- package/src/programmers/RandomProgrammer.ts +367 -0
- package/src/programmers/StringifyProgrammer.ts +2 -4
- package/src/programmers/ValidateCloneProgrammer.ts +77 -0
- package/src/programmers/ValidateStringifyProgrammer.ts +1 -4
- package/src/programmers/helpers/CloneJoiner.ts +2 -4
- package/src/programmers/helpers/RandomJoiner.ts +140 -0
- package/src/programmers/helpers/RandomRanger.ts +215 -0
- package/src/programmers/helpers/StringifyJoinder.ts +4 -4
- package/src/programmers/internal/application_array.ts +0 -10
- package/src/programmers/internal/application_number.ts +7 -13
- package/src/programmers/internal/application_string.ts +0 -8
- package/src/programmers/internal/check_array_length.ts +8 -9
- package/src/programmers/internal/check_bigint.ts +0 -21
- package/src/programmers/internal/check_number.ts +0 -30
- package/src/programmers/internal/check_string_tags.ts +7 -7
- package/src/schemas/IJsonSchema.ts +36 -1
- package/src/transformers/CallExpressionTransformer.ts +19 -0
- package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +38 -0
- package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +39 -0
- package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +32 -0
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +1 -1
- package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +38 -0
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +45 -0
- package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +38 -0
- package/src/transformers/features/parsers/AssertParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/IsParseTransformer.ts +1 -1
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +1 -1
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +1 -1
- package/src/transformers/features/validators/CreateAssertTransformer.ts +1 -1
- package/src/transformers/features/validators/CreateIsTransformer.ts +1 -1
- package/src/transformers/features/validators/CreateValidateTransformer.ts +1 -1
- package/src/utils/RandomGenerator.ts +90 -0
- package/lib/programmers/internal/check_length.js +0 -28
- package/lib/programmers/internal/check_length.js.map +0 -1
- package/src/programmers/internal/check_length.ts +0 -46
|
@@ -3,16 +3,24 @@ import ts from "typescript";
|
|
|
3
3
|
|
|
4
4
|
import { IProject } from "./IProject";
|
|
5
5
|
import { ApplicationTransformer } from "./features/miscellaneous/ApplicationTransformer";
|
|
6
|
+
import { AssertCloneTransformer } from "./features/miscellaneous/AssertCloneTransformer";
|
|
6
7
|
import { AssertPruneTransformer } from "./features/miscellaneous/AssertPruneTransformer";
|
|
7
8
|
import { CloneTransformer } from "./features/miscellaneous/CloneTransformer";
|
|
9
|
+
import { CreateAssertCloneTransformer } from "./features/miscellaneous/CreateAssertCloneTransformer";
|
|
8
10
|
import { CreateAssertPruneTransformer } from "./features/miscellaneous/CreateAssertPruneTransformer";
|
|
9
11
|
import { CreateCloneTransformer } from "./features/miscellaneous/CreateCloneTransformer";
|
|
12
|
+
import { CreateIsCloneTransformer } from "./features/miscellaneous/CreateIsCloneTransformer";
|
|
10
13
|
import { CreateIsPruneTransformer } from "./features/miscellaneous/CreateIsPruneTransformer";
|
|
11
14
|
import { CreatePruneTransformer } from "./features/miscellaneous/CreatePruneTransformer";
|
|
15
|
+
import { CreateRandomTransformer } from "./features/miscellaneous/CreateRandomGenerator";
|
|
16
|
+
import { CreateValidateCloneTransformer } from "./features/miscellaneous/CreateValidateCloneTransformer";
|
|
12
17
|
import { CreateValidatePruneTransformer } from "./features/miscellaneous/CreateValidatePruneTransformer";
|
|
18
|
+
import { IsCloneTransformer } from "./features/miscellaneous/IsCloneTransformer";
|
|
13
19
|
import { IsPruneTransformer } from "./features/miscellaneous/IsPruneTransformer";
|
|
14
20
|
import { MetadataTransformer } from "./features/miscellaneous/MetadataTransformer";
|
|
15
21
|
import { PruneTransformer } from "./features/miscellaneous/PruneTransformer";
|
|
22
|
+
import { RandomTransformer } from "./features/miscellaneous/RandomTransformer";
|
|
23
|
+
import { ValidateCloneTransformer } from "./features/miscellaneous/ValidateCloneTransformer";
|
|
16
24
|
import { ValidatePruneTransformer } from "./features/miscellaneous/ValidatePruneTransformer";
|
|
17
25
|
import { AssertParseTransformer } from "./features/parsers/AssertParseTransformer";
|
|
18
26
|
import { CreateAssertParseTransformer } from "./features/parsers/CreateAssertParseTransformer";
|
|
@@ -106,7 +114,13 @@ const FUNCTORS: Record<string, () => Task> = {
|
|
|
106
114
|
|
|
107
115
|
// MISC
|
|
108
116
|
metadata: () => MetadataTransformer.transform,
|
|
117
|
+
random: () => RandomTransformer.transform,
|
|
118
|
+
|
|
109
119
|
clone: () => CloneTransformer.transform,
|
|
120
|
+
assertClone: () => AssertCloneTransformer.transform,
|
|
121
|
+
isClone: () => IsCloneTransformer.transform,
|
|
122
|
+
validateClone: () => ValidateCloneTransformer.transform,
|
|
123
|
+
|
|
110
124
|
prune: () => PruneTransformer.transform,
|
|
111
125
|
assertPrune: () => AssertPruneTransformer.transform,
|
|
112
126
|
isPrune: () => IsPruneTransformer.transform,
|
|
@@ -138,7 +152,12 @@ const FUNCTORS: Record<string, () => Task> = {
|
|
|
138
152
|
createValidateStringify: () => CreateValidateStringifyTransformer.transform,
|
|
139
153
|
|
|
140
154
|
// MISC
|
|
155
|
+
createRandom: () => CreateRandomTransformer.transform,
|
|
141
156
|
createClone: () => CreateCloneTransformer.transform,
|
|
157
|
+
createAssertClone: () => CreateAssertCloneTransformer.transform,
|
|
158
|
+
createIsClone: () => CreateIsCloneTransformer.transform,
|
|
159
|
+
createValidateClone: () => CreateValidateCloneTransformer.transform,
|
|
160
|
+
|
|
142
161
|
createPrune: () => CreatePruneTransformer.transform,
|
|
143
162
|
createAssertPrune: () => CreateAssertPruneTransformer.transform,
|
|
144
163
|
createIsPrune: () => CreateIsPruneTransformer.transform,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { AssertCloneProgrammer } from "../../../programmers/AssertCloneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace AssertCloneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const type: ts.Type =
|
|
18
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
19
|
+
? project.checker.getTypeFromTypeNode(
|
|
20
|
+
expression.typeArguments[0],
|
|
21
|
+
)
|
|
22
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
23
|
+
if (type.isTypeParameter())
|
|
24
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return ts.factory.createCallExpression(
|
|
28
|
+
AssertCloneProgrammer.generate(project, modulo)(type),
|
|
29
|
+
undefined,
|
|
30
|
+
[expression.arguments[0]!],
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const enum ErrorMessages {
|
|
36
|
+
NO_INPUT_VALUE = "Error on typia.assertClone(): no input value.",
|
|
37
|
+
GENERIC_ARGUMENT = "Error on typia.assertClone(): non-specified generic argument.",
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { AssertCloneProgrammer } from "../../../programmers/AssertCloneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateAssertCloneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
);
|
|
21
|
+
if (type.isTypeParameter())
|
|
22
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
|
+
|
|
24
|
+
// DO TRANSFORM
|
|
25
|
+
return AssertCloneProgrammer.generate(project, modulo)(type);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enum ErrorMessages {
|
|
30
|
+
NOT_SPECIFIED = "Error on typia.assertClone(): generic argument is not specified.",
|
|
31
|
+
GENERIC_ARGUMENT = "Error on typia.assertClone(): non-specified generic argument.",
|
|
32
|
+
}
|
|
@@ -11,7 +11,7 @@ export namespace CreateAssertPruneTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateCloneTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IsCloneProgrammer } from "../../../programmers/IsCloneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateIsCloneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
);
|
|
21
|
+
if (type.isTypeParameter())
|
|
22
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
|
+
|
|
24
|
+
// DO TRANSFORM
|
|
25
|
+
return IsCloneProgrammer.generate(project, modulo)(type);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enum ErrorMessages {
|
|
30
|
+
NOT_SPECIFIED = "Error on typia.isClone(): generic argument is not specified.",
|
|
31
|
+
GENERIC_ARGUMENT = "Error on typia.isClone(): non-specified generic argument.",
|
|
32
|
+
}
|
|
@@ -11,7 +11,7 @@ export namespace CreateIsPruneTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreatePruneTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { RandomProgrammer } from "../../../programmers/RandomProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateRandomTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (!expression.typeArguments?.[0])
|
|
14
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
15
|
+
|
|
16
|
+
const type: ts.Type | undefined = project.checker.getTypeFromTypeNode(
|
|
17
|
+
expression.typeArguments[0],
|
|
18
|
+
);
|
|
19
|
+
if (type.isTypeParameter())
|
|
20
|
+
throw new Error(ErrorMessages.NO_GENERIC_ARGUMENT);
|
|
21
|
+
|
|
22
|
+
return RandomProgrammer.generate(
|
|
23
|
+
{
|
|
24
|
+
...project,
|
|
25
|
+
options: {
|
|
26
|
+
...project.options,
|
|
27
|
+
functional: false,
|
|
28
|
+
numeric: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
modulo,
|
|
32
|
+
)(type);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const enum ErrorMessages {
|
|
37
|
+
NOT_SPECIFIED = "Error on typia.createRandom(): generic argument is not specified.",
|
|
38
|
+
NO_GENERIC_ARGUMENT = "Error on typia.createRandom(): non-specified generic argument.",
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ValidateCloneProgrammer } from "../../../programmers/ValidateCloneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace CreateValidateCloneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
19
|
+
expression.typeArguments[0],
|
|
20
|
+
);
|
|
21
|
+
if (type.isTypeParameter())
|
|
22
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
23
|
+
|
|
24
|
+
// DO TRANSFORM
|
|
25
|
+
return ValidateCloneProgrammer.generate(project, modulo)(type);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enum ErrorMessages {
|
|
30
|
+
NOT_SPECIFIED = "Error on typia.validateClone(): generic argument is not specified.",
|
|
31
|
+
GENERIC_ARGUMENT = "Error on typia.validateClone(): non-specified generic argument.",
|
|
32
|
+
}
|
|
@@ -11,7 +11,7 @@ export namespace CreateValidatePruneTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IsCloneProgrammer } from "../../../programmers/IsCloneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace IsCloneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const type: ts.Type =
|
|
18
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
19
|
+
? project.checker.getTypeFromTypeNode(
|
|
20
|
+
expression.typeArguments[0],
|
|
21
|
+
)
|
|
22
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
23
|
+
if (type.isTypeParameter())
|
|
24
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return ts.factory.createCallExpression(
|
|
28
|
+
IsCloneProgrammer.generate(project, modulo)(type),
|
|
29
|
+
undefined,
|
|
30
|
+
[expression.arguments[0]!],
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const enum ErrorMessages {
|
|
36
|
+
NO_INPUT_VALUE = "Error on typia.isClone(): no input value.",
|
|
37
|
+
GENERIC_ARGUMENT = "Error on typia.isClone(): non-specified generic argument.",
|
|
38
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { RandomProgrammer } from "../../../programmers/RandomProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace RandomTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (!expression.typeArguments?.[0])
|
|
14
|
+
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
15
|
+
|
|
16
|
+
const type: ts.Type | undefined = project.checker.getTypeFromTypeNode(
|
|
17
|
+
expression.typeArguments[0],
|
|
18
|
+
);
|
|
19
|
+
if (type.isTypeParameter())
|
|
20
|
+
throw new Error(ErrorMessages.NO_GENERIC_ARGUMENT);
|
|
21
|
+
|
|
22
|
+
return ts.factory.createCallExpression(
|
|
23
|
+
RandomProgrammer.generate(
|
|
24
|
+
{
|
|
25
|
+
...project,
|
|
26
|
+
options: {
|
|
27
|
+
...project.options,
|
|
28
|
+
functional: false,
|
|
29
|
+
numeric: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
modulo,
|
|
33
|
+
)(type),
|
|
34
|
+
undefined,
|
|
35
|
+
expression.arguments.length
|
|
36
|
+
? [expression.arguments[0]!]
|
|
37
|
+
: undefined,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const enum ErrorMessages {
|
|
43
|
+
NOT_SPECIFIED = "Error on typia.random(): generic argument is not specified.",
|
|
44
|
+
NO_GENERIC_ARGUMENT = "Error on typia.random(): non-specified generic argument.",
|
|
45
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { ValidateCloneProgrammer } from "../../../programmers/ValidateCloneProgrammer";
|
|
4
|
+
|
|
5
|
+
import { IProject } from "../../IProject";
|
|
6
|
+
|
|
7
|
+
export namespace ValidateCloneTransformer {
|
|
8
|
+
export function transform(
|
|
9
|
+
project: IProject,
|
|
10
|
+
modulo: ts.LeftHandSideExpression,
|
|
11
|
+
expression: ts.CallExpression,
|
|
12
|
+
): ts.Expression {
|
|
13
|
+
if (expression.arguments.length !== 1)
|
|
14
|
+
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
+
|
|
16
|
+
// GET TYPE INFO
|
|
17
|
+
const type: ts.Type =
|
|
18
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
19
|
+
? project.checker.getTypeFromTypeNode(
|
|
20
|
+
expression.typeArguments[0],
|
|
21
|
+
)
|
|
22
|
+
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
23
|
+
if (type.isTypeParameter())
|
|
24
|
+
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
25
|
+
|
|
26
|
+
// DO TRANSFORM
|
|
27
|
+
return ts.factory.createCallExpression(
|
|
28
|
+
ValidateCloneProgrammer.generate(project, modulo)(type),
|
|
29
|
+
undefined,
|
|
30
|
+
[expression.arguments[0]!],
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const enum ErrorMessages {
|
|
36
|
+
NO_INPUT_VALUE = "Error on typia.validateClone(): no input value.",
|
|
37
|
+
GENERIC_ARGUMENT = "Error on typia.validateClone(): non-specified generic argument.",
|
|
38
|
+
}
|
|
@@ -11,7 +11,7 @@ export namespace AssertParseTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXVALIDATETENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateAssertParseTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXASSERTTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateIsParseTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateValidateParseTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXVALIDATETENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace IsParseTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXVALIDATETENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace ValidateParseTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXVALIDATETENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateAssertStringifyTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateIsStringifyTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateStringifyTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -11,7 +11,7 @@ export namespace CreateValidateStringifyTransformer {
|
|
|
11
11
|
expression: ts.CallExpression,
|
|
12
12
|
): ts.Expression {
|
|
13
13
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
14
|
-
if (!expression.typeArguments
|
|
14
|
+
if (!expression.typeArguments?.[0])
|
|
15
15
|
throw new Error(ErrorMessages.NOT_SPECIFIED);
|
|
16
16
|
|
|
17
17
|
// GET TYPE INFO
|
|
@@ -18,7 +18,7 @@ export namespace CreateAssertTransformer {
|
|
|
18
18
|
expression: ts.CallExpression,
|
|
19
19
|
): ts.Expression {
|
|
20
20
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
21
|
-
if (!expression.typeArguments
|
|
21
|
+
if (!expression.typeArguments?.[0])
|
|
22
22
|
throw new Error(MESSAGES.NOT_SPECIFIED);
|
|
23
23
|
|
|
24
24
|
// GET TYPE INFO
|
|
@@ -18,7 +18,7 @@ export namespace CreateIsTransformer {
|
|
|
18
18
|
expression: ts.CallExpression,
|
|
19
19
|
): ts.Expression {
|
|
20
20
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
21
|
-
if (!expression.typeArguments
|
|
21
|
+
if (!expression.typeArguments?.[0])
|
|
22
22
|
throw new Error(MESSAGES.NOT_SPECIFIED);
|
|
23
23
|
|
|
24
24
|
// GET TYPE INFO
|
|
@@ -18,7 +18,7 @@ export namespace CreateValidateTransformer {
|
|
|
18
18
|
expression: ts.CallExpression,
|
|
19
19
|
): ts.Expression {
|
|
20
20
|
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
21
|
-
if (!expression.typeArguments
|
|
21
|
+
if (!expression.typeArguments?.[0])
|
|
22
22
|
throw new Error(MESSAGES.NOT_SPECIFIED);
|
|
23
23
|
|
|
24
24
|
// GET TYPE INFO
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import RandExp from "randexp";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export namespace RandomGenerator {
|
|
7
|
+
const ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
|
|
8
|
+
|
|
9
|
+
/* -----------------------------------------------------------
|
|
10
|
+
REGULAR
|
|
11
|
+
----------------------------------------------------------- */
|
|
12
|
+
export function boolean(): boolean {
|
|
13
|
+
return Math.random() < 0.5;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function integer(min?: number, max?: number): number {
|
|
17
|
+
min ??= 0;
|
|
18
|
+
max ??= 100;
|
|
19
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function bigint(min?: bigint, max?: bigint): bigint {
|
|
23
|
+
min ??= BigInt(0);
|
|
24
|
+
max ??= BigInt(100);
|
|
25
|
+
return BigInt(integer(Number(min), Number(max)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function number(min?: number, max?: number): number {
|
|
29
|
+
min ??= 0;
|
|
30
|
+
max ??= 100;
|
|
31
|
+
return Math.random() * (max - min) + min;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function string(length?: number): string {
|
|
35
|
+
return new Array(length ?? integer(5, 10))
|
|
36
|
+
.fill(0)
|
|
37
|
+
.map(() => ALPHABETS[integer(0, ALPHABETS.length - 1)])
|
|
38
|
+
.join("");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function array<T>(
|
|
42
|
+
closure: (index: number) => T,
|
|
43
|
+
count?: number,
|
|
44
|
+
): T[] {
|
|
45
|
+
return new Array(count ?? integer(0, 3))
|
|
46
|
+
.fill(0)
|
|
47
|
+
.map((_e, index) => closure(index));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function pick<T>(array: T[]): T {
|
|
51
|
+
return array[integer(0, array.length - 1)]!;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* -----------------------------------------------------------
|
|
55
|
+
SECIAL FORMATS
|
|
56
|
+
----------------------------------------------------------- */
|
|
57
|
+
export function uuid(): string {
|
|
58
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
59
|
+
const r = (Math.random() * 16) | 0;
|
|
60
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
61
|
+
return v.toString(16);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function email(): string {
|
|
66
|
+
return `${string(10)}@${string(10)}.${string(3)}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function url(): string {
|
|
70
|
+
return `https://${string(10)}.${string(3)}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ipv4(): string {
|
|
74
|
+
return array(() => integer(0, 255), 4).join(".");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function ipv6(): string {
|
|
78
|
+
return array(() => integer(0, 65535).toString(16), 8).join(":");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function pattern(regex: RegExp): string {
|
|
82
|
+
return new RandExp(regex).gen();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function date(min?: number, max?: number): string {
|
|
86
|
+
min ??= 0;
|
|
87
|
+
max ??= Date.now();
|
|
88
|
+
return new Date(number(min, max)).toString();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.check_length = void 0;
|
|
7
|
-
var typescript_1 = __importDefault(require("typescript"));
|
|
8
|
-
function check_length(conditions, length, tag) {
|
|
9
|
-
if (tag.minimum !== undefined &&
|
|
10
|
-
tag.maximum !== undefined &&
|
|
11
|
-
tag.minimum.value === tag.maximum.value &&
|
|
12
|
-
tag.minimum.include === true &&
|
|
13
|
-
tag.maximum.include === true) {
|
|
14
|
-
conditions.push(typescript_1.default.factory.createStrictEquality(typescript_1.default.factory.createNumericLiteral(tag.minimum.value), length));
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
if (tag.minimum !== undefined)
|
|
18
|
-
conditions.push((tag.minimum.include
|
|
19
|
-
? typescript_1.default.factory.createLessThanEquals
|
|
20
|
-
: typescript_1.default.factory.createLessThan)(typescript_1.default.factory.createNumericLiteral(tag.minimum.value), length));
|
|
21
|
-
if (tag.maximum !== undefined)
|
|
22
|
-
conditions.push((tag.maximum.include
|
|
23
|
-
? typescript_1.default.factory.createGreaterThanEquals
|
|
24
|
-
: typescript_1.default.factory.createGreaterThan)(typescript_1.default.factory.createNumericLiteral(tag.maximum.value), length));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.check_length = check_length;
|
|
28
|
-
//# sourceMappingURL=check_length.js.map
|