typia 3.6.0 → 3.6.2
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 +14 -9
- package/lib/programmers/AssertCloneProgrammer.d.ts +1 -1
- package/lib/programmers/AssertCloneProgrammer.js +4 -4
- package/lib/programmers/AssertCloneProgrammer.js.map +1 -1
- package/lib/programmers/AssertParseProgrammer.d.ts +1 -1
- package/lib/programmers/AssertParseProgrammer.js +3 -3
- package/lib/programmers/AssertParseProgrammer.js.map +1 -1
- package/lib/programmers/AssertProgrammer.d.ts +1 -1
- package/lib/programmers/AssertProgrammer.js +3 -3
- package/lib/programmers/AssertProgrammer.js.map +1 -1
- package/lib/programmers/AssertPruneProgrammer.d.ts +1 -1
- package/lib/programmers/AssertPruneProgrammer.js +4 -4
- package/lib/programmers/AssertPruneProgrammer.js.map +1 -1
- package/lib/programmers/AssertStringifyProgrammer.d.ts +1 -1
- package/lib/programmers/AssertStringifyProgrammer.js +3 -3
- package/lib/programmers/AssertStringifyProgrammer.js.map +1 -1
- package/lib/programmers/CheckerProgrammer.d.ts +1 -1
- package/lib/programmers/CheckerProgrammer.js +2 -2
- package/lib/programmers/CheckerProgrammer.js.map +1 -1
- package/lib/programmers/CloneProgrammer.d.ts +1 -1
- package/lib/programmers/CloneProgrammer.js +4 -4
- package/lib/programmers/CloneProgrammer.js.map +1 -1
- package/lib/programmers/FeatureProgrammer.d.ts +3 -3
- package/lib/programmers/FeatureProgrammer.js +2 -2
- package/lib/programmers/FeatureProgrammer.js.map +1 -1
- package/lib/programmers/IsCloneProgrammer.d.ts +1 -1
- package/lib/programmers/IsCloneProgrammer.js +4 -4
- package/lib/programmers/IsCloneProgrammer.js.map +1 -1
- package/lib/programmers/IsParseProgrammer.d.ts +1 -1
- package/lib/programmers/IsParseProgrammer.js +3 -3
- package/lib/programmers/IsParseProgrammer.js.map +1 -1
- package/lib/programmers/IsProgrammer.d.ts +1 -1
- package/lib/programmers/IsPruneProgrammer.d.ts +1 -1
- package/lib/programmers/IsPruneProgrammer.js +4 -4
- package/lib/programmers/IsPruneProgrammer.js.map +1 -1
- package/lib/programmers/IsStringifyProgrammer.d.ts +1 -1
- package/lib/programmers/IsStringifyProgrammer.js +4 -4
- package/lib/programmers/IsStringifyProgrammer.js.map +1 -1
- package/lib/programmers/PruneProgrammer.d.ts +1 -1
- package/lib/programmers/PruneProgrammer.js +2 -2
- package/lib/programmers/PruneProgrammer.js.map +1 -1
- package/lib/programmers/RandomProgrammer.d.ts +1 -1
- package/lib/programmers/RandomProgrammer.js +2 -2
- package/lib/programmers/RandomProgrammer.js.map +1 -1
- package/lib/programmers/StringifyProgrammer.d.ts +1 -1
- package/lib/programmers/StringifyProgrammer.js +2 -2
- package/lib/programmers/StringifyProgrammer.js.map +1 -1
- package/lib/programmers/ValidateCloneProgrammer.d.ts +1 -1
- package/lib/programmers/ValidateCloneProgrammer.js +4 -4
- package/lib/programmers/ValidateCloneProgrammer.js.map +1 -1
- package/lib/programmers/ValidateParseProgrammer.d.ts +1 -1
- package/lib/programmers/ValidateParseProgrammer.js +3 -3
- package/lib/programmers/ValidateParseProgrammer.js.map +1 -1
- package/lib/programmers/ValidateProgrammer.d.ts +1 -1
- package/lib/programmers/ValidateProgrammer.js +3 -3
- package/lib/programmers/ValidateProgrammer.js.map +1 -1
- package/lib/programmers/ValidatePruneProgrammer.d.ts +1 -1
- package/lib/programmers/ValidatePruneProgrammer.js +4 -4
- package/lib/programmers/ValidatePruneProgrammer.js.map +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.d.ts +1 -1
- package/lib/programmers/ValidateStringifyProgrammer.js +4 -4
- package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js +2 -15
- package/lib/transformers/features/miscellaneous/AssertCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/AssertPruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/AssertPruneTransformer.js +2 -15
- package/lib/transformers/features/miscellaneous/AssertPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CloneTransformer.js +2 -26
- package/lib/transformers/features/miscellaneous/CloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateAssertCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateAssertPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateIsCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateIsPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +3 -2
- package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateValidateCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js +2 -10
- package/lib/transformers/features/miscellaneous/CreateValidatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.js +2 -15
- package/lib/transformers/features/miscellaneous/IsCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/IsPruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/IsPruneTransformer.js +2 -15
- package/lib/transformers/features/miscellaneous/IsPruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/PruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/PruneTransformer.js +2 -26
- package/lib/transformers/features/miscellaneous/PruneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/RandomTransformer.js +3 -2
- package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js +2 -15
- package/lib/transformers/features/miscellaneous/ValidateCloneTransformer.js.map +1 -1
- package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.d.ts +1 -3
- package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.js +2 -15
- package/lib/transformers/features/miscellaneous/ValidatePruneTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/AssertParseTransformer.d.ts +1 -3
- package/lib/transformers/features/parsers/AssertParseTransformer.js +2 -14
- package/lib/transformers/features/parsers/AssertParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.d.ts +1 -3
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js +2 -10
- package/lib/transformers/features/parsers/CreateAssertParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateIsParseTransformer.d.ts +1 -3
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js +2 -10
- package/lib/transformers/features/parsers/CreateIsParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.d.ts +1 -3
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js +2 -10
- package/lib/transformers/features/parsers/CreateValidateParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/IsParseTransformer.d.ts +1 -3
- package/lib/transformers/features/parsers/IsParseTransformer.js +2 -14
- package/lib/transformers/features/parsers/IsParseTransformer.js.map +1 -1
- package/lib/transformers/features/parsers/ValidateParseTransformer.d.ts +1 -3
- package/lib/transformers/features/parsers/ValidateParseTransformer.js +2 -14
- package/lib/transformers/features/parsers/ValidateParseTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/AssertStringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/AssertStringifyTransformer.js +4 -15
- package/lib/transformers/features/stringifiers/AssertStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js +2 -10
- package/lib/transformers/features/stringifiers/CreateAssertStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js +2 -10
- package/lib/transformers/features/stringifiers/CreateIsStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js +2 -10
- package/lib/transformers/features/stringifiers/CreateStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js +4 -10
- package/lib/transformers/features/stringifiers/CreateValidateStringifyProgrammer.js.map +1 -1
- package/lib/transformers/features/stringifiers/IsStringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/IsStringifyTransformer.js +2 -15
- package/lib/transformers/features/stringifiers/IsStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/StringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/StringifyTransformer.js +2 -26
- package/lib/transformers/features/stringifiers/StringifyTransformer.js.map +1 -1
- package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.d.ts +1 -3
- package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.js +4 -15
- package/lib/transformers/features/stringifiers/ValidateStringifyTransformer.js.map +1 -1
- package/lib/transformers/features/validators/AssertTransformer.d.ts +1 -3
- package/lib/transformers/features/validators/AssertTransformer.js +6 -22
- package/lib/transformers/features/validators/AssertTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateAssertTransformer.d.ts +1 -3
- package/lib/transformers/features/validators/CreateAssertTransformer.js +6 -17
- package/lib/transformers/features/validators/CreateAssertTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateIsTransformer.d.ts +1 -3
- package/lib/transformers/features/validators/CreateIsTransformer.js +4 -17
- package/lib/transformers/features/validators/CreateIsTransformer.js.map +1 -1
- package/lib/transformers/features/validators/CreateValidateTransformer.d.ts +1 -3
- package/lib/transformers/features/validators/CreateValidateTransformer.js +6 -17
- package/lib/transformers/features/validators/CreateValidateTransformer.js.map +1 -1
- package/lib/transformers/features/validators/IsTransformer.d.ts +1 -3
- package/lib/transformers/features/validators/IsTransformer.js +6 -22
- package/lib/transformers/features/validators/IsTransformer.js.map +1 -1
- package/lib/transformers/features/validators/ValidateTransformer.d.ts +1 -3
- package/lib/transformers/features/validators/ValidateTransformer.js +6 -22
- package/lib/transformers/features/validators/ValidateTransformer.js.map +1 -1
- package/lib/transformers/internal/GenericTransformer.d.ts +6 -0
- package/lib/transformers/internal/GenericTransformer.js +72 -0
- package/lib/transformers/internal/GenericTransformer.js.map +1 -0
- package/package.json +2 -1
- package/src/programmers/AssertCloneProgrammer.ts +6 -7
- package/src/programmers/AssertParseProgrammer.ts +5 -6
- package/src/programmers/AssertProgrammer.ts +3 -3
- package/src/programmers/AssertPruneProgrammer.ts +4 -4
- package/src/programmers/AssertStringifyProgrammer.ts +3 -3
- package/src/programmers/CheckerProgrammer.ts +3 -2
- package/src/programmers/CloneProgrammer.ts +6 -7
- package/src/programmers/FeatureProgrammer.ts +5 -5
- package/src/programmers/IsCloneProgrammer.ts +7 -7
- package/src/programmers/IsParseProgrammer.ts +5 -6
- package/src/programmers/IsPruneProgrammer.ts +4 -4
- package/src/programmers/IsStringifyProgrammer.ts +5 -4
- package/src/programmers/PruneProgrammer.ts +2 -2
- package/src/programmers/RandomProgrammer.ts +4 -5
- package/src/programmers/StringifyProgrammer.ts +2 -2
- package/src/programmers/ValidateCloneProgrammer.ts +6 -7
- package/src/programmers/ValidateParseProgrammer.ts +5 -6
- package/src/programmers/ValidateProgrammer.ts +5 -6
- package/src/programmers/ValidatePruneProgrammer.ts +6 -7
- package/src/programmers/ValidateStringifyProgrammer.ts +5 -4
- package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +4 -33
- package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +4 -33
- package/src/transformers/features/miscellaneous/CloneTransformer.ts +4 -41
- package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +4 -27
- package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +4 -27
- package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +4 -26
- package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +4 -27
- package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +4 -27
- package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +4 -26
- package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +7 -4
- package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +4 -27
- package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +4 -27
- package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +4 -33
- package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +4 -33
- package/src/transformers/features/miscellaneous/PruneTransformer.ts +4 -41
- package/src/transformers/features/miscellaneous/RandomTransformer.ts +7 -4
- package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +4 -33
- package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +4 -33
- package/src/transformers/features/parsers/AssertParseTransformer.ts +4 -31
- package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +4 -27
- package/src/transformers/features/parsers/CreateIsParseTransformer.ts +4 -27
- package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +4 -27
- package/src/transformers/features/parsers/IsParseTransformer.ts +4 -31
- package/src/transformers/features/parsers/ValidateParseTransformer.ts +4 -31
- package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +5 -33
- package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +4 -27
- package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +4 -27
- package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +4 -26
- package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +6 -27
- package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +4 -33
- package/src/transformers/features/stringifiers/StringifyTransformer.ts +4 -41
- package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +5 -33
- package/src/transformers/features/validators/AssertTransformer.ts +6 -38
- package/src/transformers/features/validators/CreateAssertTransformer.ts +7 -30
- package/src/transformers/features/validators/CreateIsTransformer.ts +5 -30
- package/src/transformers/features/validators/CreateValidateTransformer.ts +7 -30
- package/src/transformers/features/validators/IsTransformer.ts +5 -38
- package/src/transformers/features/validators/ValidateTransformer.ts +6 -38
- package/src/transformers/internal/GenericTransformer.ts +99 -0
|
@@ -1,46 +1,9 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { StringifyProgrammer } from "../../../programmers/StringifyProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace StringifyTransformer {
|
|
8
|
-
export
|
|
9
|
-
project
|
|
10
|
-
|
|
11
|
-
expression: ts.CallExpression,
|
|
12
|
-
): ts.Expression {
|
|
13
|
-
if (expression.arguments.length !== 1)
|
|
14
|
-
throw new Error(ErrorMessages.NO_INPUT_VALUE);
|
|
15
|
-
|
|
16
|
-
const type: ts.Type =
|
|
17
|
-
expression.typeArguments && expression.typeArguments[0]
|
|
18
|
-
? project.checker.getTypeFromTypeNode(
|
|
19
|
-
expression.typeArguments[0],
|
|
20
|
-
)
|
|
21
|
-
: project.checker.getTypeAtLocation(expression.arguments[0]!);
|
|
22
|
-
if (type.isTypeParameter())
|
|
23
|
-
throw new Error(ErrorMessages.GENERIC_ARGUMENT);
|
|
24
|
-
|
|
25
|
-
return ts.factory.createCallExpression(
|
|
26
|
-
StringifyProgrammer.generate(
|
|
27
|
-
{
|
|
28
|
-
...project,
|
|
29
|
-
options: {
|
|
30
|
-
...project.options,
|
|
31
|
-
functional: false,
|
|
32
|
-
numeric: true,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
modulo,
|
|
36
|
-
)(type),
|
|
37
|
-
undefined,
|
|
38
|
-
[expression.arguments[0]!],
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const enum ErrorMessages {
|
|
44
|
-
NO_INPUT_VALUE = "Error on typia.stringify(): no input value.",
|
|
45
|
-
GENERIC_ARGUMENT = "Error on typia.stringify(): non-specified generic argument.",
|
|
6
|
+
export const transform = GenericTransformer.scalar("stringify")(
|
|
7
|
+
(project, modulo) => StringifyProgrammer.generate(project, modulo),
|
|
8
|
+
);
|
|
46
9
|
}
|
|
@@ -1,38 +1,10 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { ValidateStringifyProgrammer } from "../../../programmers/ValidateStringifyProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace ValidateStringifyTransformer {
|
|
8
|
-
export
|
|
9
|
-
project
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
ValidateStringifyProgrammer.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.validateStringify(): no input value.",
|
|
37
|
-
GENERIC_ARGUMENT = "Error on typia.validateStringify(): non-specified generic argument.",
|
|
6
|
+
export const transform = GenericTransformer.scalar("validatStringify")(
|
|
7
|
+
(project, modulo) =>
|
|
8
|
+
ValidateStringifyProgrammer.generate(project, modulo),
|
|
9
|
+
);
|
|
38
10
|
}
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { AssertProgrammer } from "../../../programmers/AssertProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace AssertTransformer {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return function (
|
|
16
|
-
project: IProject,
|
|
17
|
-
modulo: ts.LeftHandSideExpression,
|
|
18
|
-
expression: ts.CallExpression,
|
|
19
|
-
): ts.Expression {
|
|
20
|
-
if (expression.arguments.length !== 1)
|
|
21
|
-
throw new Error(MESSAGES.NO_INPUT_VALUE);
|
|
22
|
-
|
|
23
|
-
// GET TYPE INFO
|
|
24
|
-
const type: ts.Type =
|
|
25
|
-
expression.typeArguments && expression.typeArguments[0]
|
|
26
|
-
? project.checker.getTypeFromTypeNode(
|
|
27
|
-
expression.typeArguments[0],
|
|
28
|
-
)
|
|
29
|
-
: project.checker.getTypeAtLocation(
|
|
30
|
-
expression.arguments[0]!,
|
|
31
|
-
);
|
|
32
|
-
if (type.isTypeParameter())
|
|
33
|
-
throw new Error(MESSAGES.GENERIC_ARGUMENT);
|
|
34
|
-
|
|
35
|
-
// DO TRANSFORM
|
|
36
|
-
return ts.factory.createCallExpression(
|
|
37
|
-
AssertProgrammer.generate(project, modulo, equals)(type),
|
|
38
|
-
undefined,
|
|
39
|
-
[expression.arguments[0]!],
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
6
|
+
export const transform = (equals: boolean) =>
|
|
7
|
+
GenericTransformer.scalar(equals ? "assertEquals" : "assert")(
|
|
8
|
+
(project, modulo) =>
|
|
9
|
+
AssertProgrammer.generate(project, modulo, equals),
|
|
10
|
+
);
|
|
43
11
|
}
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { AssertProgrammer } from "../../../programmers/AssertProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace CreateAssertTransformer {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return function (
|
|
16
|
-
project: IProject,
|
|
17
|
-
modulo: ts.LeftHandSideExpression,
|
|
18
|
-
expression: ts.CallExpression,
|
|
19
|
-
): ts.Expression {
|
|
20
|
-
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
21
|
-
if (!expression.typeArguments?.[0])
|
|
22
|
-
throw new Error(MESSAGES.NOT_SPECIFIED);
|
|
23
|
-
|
|
24
|
-
// GET TYPE INFO
|
|
25
|
-
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
26
|
-
expression.typeArguments[0],
|
|
27
|
-
);
|
|
28
|
-
if (type.isTypeParameter())
|
|
29
|
-
throw new Error(MESSAGES.GENERIC_ARGUMENT);
|
|
30
|
-
|
|
31
|
-
// DO TRANSFORM
|
|
32
|
-
return AssertProgrammer.generate(project, modulo, equals)(type);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
6
|
+
export const transform = (equals: boolean) =>
|
|
7
|
+
GenericTransformer.factory(
|
|
8
|
+
equals ? "createAssertEquals" : "createAssert",
|
|
9
|
+
)((project, modulo) =>
|
|
10
|
+
AssertProgrammer.generate(project, modulo, equals),
|
|
11
|
+
);
|
|
35
12
|
}
|
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { IsProgrammer } from "../../../programmers/IsProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace CreateIsTransformer {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
GENERIC_ARGUMENT: `Error on typia.${SYMBOL}(): non-specified generic argument.`,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return function (
|
|
16
|
-
project: IProject,
|
|
17
|
-
modulo: ts.LeftHandSideExpression,
|
|
18
|
-
expression: ts.CallExpression,
|
|
19
|
-
): ts.Expression {
|
|
20
|
-
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
21
|
-
if (!expression.typeArguments?.[0])
|
|
22
|
-
throw new Error(MESSAGES.NOT_SPECIFIED);
|
|
23
|
-
|
|
24
|
-
// GET TYPE INFO
|
|
25
|
-
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
26
|
-
expression.typeArguments[0],
|
|
27
|
-
);
|
|
28
|
-
if (type.isTypeParameter())
|
|
29
|
-
throw new Error(MESSAGES.GENERIC_ARGUMENT);
|
|
30
|
-
|
|
31
|
-
// DO TRANSFORM
|
|
32
|
-
return IsProgrammer.generate(project, modulo, equals)(type);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
6
|
+
export const transform = (equals: boolean) =>
|
|
7
|
+
GenericTransformer.factory(equals ? "createEquals" : "createIs")(
|
|
8
|
+
(project, modulo) => IsProgrammer.generate(project, modulo, equals),
|
|
9
|
+
);
|
|
35
10
|
}
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { ValidateProgrammer } from "../../../programmers/ValidateProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace CreateValidateTransformer {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return function (
|
|
16
|
-
project: IProject,
|
|
17
|
-
modulo: ts.LeftHandSideExpression,
|
|
18
|
-
expression: ts.CallExpression,
|
|
19
|
-
): ts.Expression {
|
|
20
|
-
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
21
|
-
if (!expression.typeArguments?.[0])
|
|
22
|
-
throw new Error(MESSAGES.NOT_SPECIFIED);
|
|
23
|
-
|
|
24
|
-
// GET TYPE INFO
|
|
25
|
-
const type: ts.Type = project.checker.getTypeFromTypeNode(
|
|
26
|
-
expression.typeArguments[0],
|
|
27
|
-
);
|
|
28
|
-
if (type.isTypeParameter())
|
|
29
|
-
throw new Error(MESSAGES.GENERIC_ARGUMENT);
|
|
30
|
-
|
|
31
|
-
// DO TRANSFORM
|
|
32
|
-
return ValidateProgrammer.generate(project, modulo, equals)(type);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
6
|
+
export const transform = (equals: boolean) =>
|
|
7
|
+
GenericTransformer.factory(
|
|
8
|
+
equals ? "createValidateEquals" : "createValidate",
|
|
9
|
+
)((project, modulo) =>
|
|
10
|
+
ValidateProgrammer.generate(project, modulo, equals),
|
|
11
|
+
);
|
|
35
12
|
}
|
|
@@ -1,43 +1,10 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { IsProgrammer } from "../../../programmers/IsProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace IsTransformer {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
GENERIC_ARGUMENT: `Error on typia.${SYMBOL}(): non-specified generic argument.`,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return function (
|
|
16
|
-
project: IProject,
|
|
17
|
-
modulo: ts.LeftHandSideExpression,
|
|
18
|
-
expression: ts.CallExpression,
|
|
19
|
-
): ts.Expression {
|
|
20
|
-
if (expression.arguments.length !== 1)
|
|
21
|
-
throw new Error(MESSAGES.NO_INPUT_VALUE);
|
|
22
|
-
|
|
23
|
-
// GET TYPE INFO
|
|
24
|
-
const type: ts.Type =
|
|
25
|
-
expression.typeArguments && expression.typeArguments[0]
|
|
26
|
-
? project.checker.getTypeFromTypeNode(
|
|
27
|
-
expression.typeArguments[0],
|
|
28
|
-
)
|
|
29
|
-
: project.checker.getTypeAtLocation(
|
|
30
|
-
expression.arguments[0]!,
|
|
31
|
-
);
|
|
32
|
-
if (type.isTypeParameter())
|
|
33
|
-
throw new Error(MESSAGES.GENERIC_ARGUMENT);
|
|
34
|
-
|
|
35
|
-
// DO TRANSFORM
|
|
36
|
-
return ts.factory.createCallExpression(
|
|
37
|
-
IsProgrammer.generate(project, modulo, equals)(type),
|
|
38
|
-
undefined,
|
|
39
|
-
[expression.arguments[0]!],
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
6
|
+
export const transform = (equals: boolean) =>
|
|
7
|
+
GenericTransformer.scalar(equals ? "equals" : "is")((project, modulo) =>
|
|
8
|
+
IsProgrammer.generate(project, modulo, equals),
|
|
9
|
+
);
|
|
43
10
|
}
|
|
@@ -1,43 +1,11 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
1
|
import { ValidateProgrammer } from "../../../programmers/ValidateProgrammer";
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import { GenericTransformer } from "../../internal/GenericTransformer";
|
|
6
4
|
|
|
7
5
|
export namespace ValidateTransformer {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return function (
|
|
16
|
-
project: IProject,
|
|
17
|
-
modulo: ts.LeftHandSideExpression,
|
|
18
|
-
expression: ts.CallExpression,
|
|
19
|
-
): ts.Expression {
|
|
20
|
-
if (expression.arguments.length !== 1)
|
|
21
|
-
throw new Error(MESSAGES.NO_INPUT_VALUE);
|
|
22
|
-
|
|
23
|
-
// GET TYPE INFO
|
|
24
|
-
const type: ts.Type =
|
|
25
|
-
expression.typeArguments && expression.typeArguments[0]
|
|
26
|
-
? project.checker.getTypeFromTypeNode(
|
|
27
|
-
expression.typeArguments[0],
|
|
28
|
-
)
|
|
29
|
-
: project.checker.getTypeAtLocation(
|
|
30
|
-
expression.arguments[0]!,
|
|
31
|
-
);
|
|
32
|
-
if (type.isTypeParameter())
|
|
33
|
-
throw new Error(MESSAGES.GENERIC_ARGUMENT);
|
|
34
|
-
|
|
35
|
-
// DO TRANSFORM
|
|
36
|
-
return ts.factory.createCallExpression(
|
|
37
|
-
ValidateProgrammer.generate(project, modulo, equals)(type),
|
|
38
|
-
undefined,
|
|
39
|
-
[expression.arguments[0]!],
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
6
|
+
export const transform = (equals: boolean) =>
|
|
7
|
+
GenericTransformer.scalar(equals ? "validateEquals" : "validate")(
|
|
8
|
+
(project, modulo) =>
|
|
9
|
+
ValidateProgrammer.generate(project, modulo, equals),
|
|
10
|
+
);
|
|
43
11
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { IProject } from "../IProject";
|
|
4
|
+
|
|
5
|
+
export namespace GenericTransformer {
|
|
6
|
+
export const scalar =
|
|
7
|
+
(method: string) =>
|
|
8
|
+
(
|
|
9
|
+
programmer: (
|
|
10
|
+
project: IProject,
|
|
11
|
+
modulo: ts.LeftHandSideExpression,
|
|
12
|
+
) => (type: ts.Type, name: string) => ts.ArrowFunction,
|
|
13
|
+
) =>
|
|
14
|
+
(
|
|
15
|
+
project: IProject,
|
|
16
|
+
modulo: ts.LeftHandSideExpression,
|
|
17
|
+
expression: ts.CallExpression,
|
|
18
|
+
) => {
|
|
19
|
+
// CHECK PARAMETER
|
|
20
|
+
if (expression.arguments.length !== 1)
|
|
21
|
+
throw new Error(`Error on typia.${method}(): no input value.`);
|
|
22
|
+
|
|
23
|
+
// GET TYPE INFO
|
|
24
|
+
const [type, node, generic]: [ts.Type, ts.Node, boolean] =
|
|
25
|
+
expression.typeArguments && expression.typeArguments[0]
|
|
26
|
+
? [
|
|
27
|
+
project.checker.getTypeFromTypeNode(
|
|
28
|
+
expression.typeArguments[0],
|
|
29
|
+
),
|
|
30
|
+
expression.typeArguments[0],
|
|
31
|
+
true,
|
|
32
|
+
]
|
|
33
|
+
: [
|
|
34
|
+
project.checker.getTypeAtLocation(
|
|
35
|
+
expression.arguments[0]!,
|
|
36
|
+
),
|
|
37
|
+
expression.arguments[0]!,
|
|
38
|
+
false,
|
|
39
|
+
];
|
|
40
|
+
if (type.isTypeParameter())
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Error on typia.${method}(): non-specified generic argument.`,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// DO TRANSFORM
|
|
46
|
+
return ts.factory.createCallExpression(
|
|
47
|
+
programmer(project, modulo)(
|
|
48
|
+
type,
|
|
49
|
+
generic
|
|
50
|
+
? node.getText()
|
|
51
|
+
: name(project.checker)(type)(node),
|
|
52
|
+
),
|
|
53
|
+
undefined,
|
|
54
|
+
[expression.arguments[0]!],
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const factory =
|
|
59
|
+
(method: string) =>
|
|
60
|
+
(
|
|
61
|
+
programmer: (
|
|
62
|
+
project: IProject,
|
|
63
|
+
modulo: ts.LeftHandSideExpression,
|
|
64
|
+
) => (type: ts.Type, name: string) => ts.ArrowFunction,
|
|
65
|
+
) =>
|
|
66
|
+
(
|
|
67
|
+
project: IProject,
|
|
68
|
+
modulo: ts.LeftHandSideExpression,
|
|
69
|
+
expression: ts.CallExpression,
|
|
70
|
+
) => {
|
|
71
|
+
// CHECK GENERIC ARGUMENT EXISTENCE
|
|
72
|
+
if (!expression.typeArguments?.[0])
|
|
73
|
+
throw new Error(
|
|
74
|
+
`Error on typia.${method}(): generic argument is not specified.`,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// GET TYPE INFO
|
|
78
|
+
const node: ts.TypeNode = expression.typeArguments[0];
|
|
79
|
+
const type: ts.Type = project.checker.getTypeFromTypeNode(node);
|
|
80
|
+
|
|
81
|
+
if (type.isTypeParameter())
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Error on typia.${method}(): non-specified generic argument.`,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// DO TRANSFORM
|
|
87
|
+
return programmer(project, modulo)(type, node.getText());
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const name =
|
|
91
|
+
(checker: ts.TypeChecker) =>
|
|
92
|
+
(type: ts.Type) =>
|
|
93
|
+
(node: ts.Node): string =>
|
|
94
|
+
checker.typeToString(
|
|
95
|
+
type,
|
|
96
|
+
node,
|
|
97
|
+
ts.TypeFormatFlags.NodeBuilderFlagsMask,
|
|
98
|
+
);
|
|
99
|
+
}
|